UNPKG

storm-modal

Version:
21 lines (17 loc) 608 B
/** * @name storm-modal: Accessible modal dialogue * @version 1.2.0: Thu, 02 Aug 2018 12:23:05 GMT * @author stormid * @license MIT */ import defaults from './lib/defaults'; import componentPrototype from './lib/component-prototype'; const init = (sel, opts) => { let els = [].slice.call(document.querySelectorAll(sel)); if(els.length === 0) throw new Error('Modal cannot be initialised, no trigger elements found'); return els.map(el => Object.assign(Object.create(componentPrototype), { node: el, settings: Object.assign({}, defaults, opts) }).init()); }; export default { init };