/
eb
/
js-excel
Обзор
Документация
Войти
/
eb
/
js-excel
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/components/excel/Excel.js
50 строк
1 KB
Evgeniy Budaev
Routing implemented
17 июн 2020, 10:58
17 июн 2020, 10:58
6622668
Код
Авторство
О чём код?
import {$} from "@core/dom"; import {Emitter} from "@core/Emitter"; import {StoreSubscriber} from "@core/StoreSubscriber"; import {updateDate} from "@/redux/actions"; import {preventDefault} from "@core/utils"; export class Excel { constructor(options) { this.components = options.components || [] this.store = options.store this.emitter = new Emitter() this.subscriber = new StoreSubscriber(this.store) } getRoot() { const $root = $.create('div', 'excel') const componentOptions = { emitter: this.emitter, store: this.store } this.components = this.components.map(Component => { const $el = $.create('div', Component.className) const component = new Component($el, componentOptions) // console.log(component.toHtml()) // $el.insertAdjacentHTML('beforeend', component.toHtml()) $el.html(component.toHtml()) $root.append($el) return component }) return $root } init() { if (process.env.NODE_ENV === 'production') { document.addEventListener('contextmenu', preventDefault) } // console.log(process.env.NODE_ENV) this.store.dispatch(updateDate()) this.subscriber.subscribeComponents(this.components) this.components.forEach(component => component.init()) } destroy() { this.subscriber.unsubscribeFromStore() this.components.forEach(component => component.destroy()) document.removeEventListener('contextmenu', preventDefault) } }