UNPKG

@ithaka/bonsai

Version:
36 lines (27 loc) 983 B
"use strict"; import $ from "jquery"; /** * All Bonsai components inherit this base class * * @param {jQuery} elements - jQuery object of the elements to create the component from * @param {Object} options - Object containing Foundation plugin options {@link http://foundation.zurb.com/sites/docs/javascript.html#configuring-plugins} */ class BonsaiBase { constructor(elements, options = {}) { if(typeof Bonsai === "undefined") { window.Bonsai = {}; } if (!elements) { throw new Error("Need to pass in an element to bind the given component"); } if (typeof(elements) === "object" && !elements instanceof jQuery) { elements = $(elements); } if (!elements instanceof jQuery) { throw new Error("Unknown element passed in, needs to be DOM or jQuery Object"); } this.elements = elements; this.options = options; } } export { BonsaiBase };