From 8fabf77b2a7720a357c63817c07035a9908818a0 Mon Sep 17 00:00:00 2001 From: Gitea Date: Wed, 10 Nov 2021 17:53:50 +0100 Subject: Update --- Neutron-trunk/resources/lib/pushbar.js/library.js | 79 ----------------------- 1 file changed, 79 deletions(-) delete mode 100644 Neutron-trunk/resources/lib/pushbar.js/library.js (limited to 'Neutron-trunk/resources/lib/pushbar.js/library.js') diff --git a/Neutron-trunk/resources/lib/pushbar.js/library.js b/Neutron-trunk/resources/lib/pushbar.js/library.js deleted file mode 100644 index 4d50246..0000000 --- a/Neutron-trunk/resources/lib/pushbar.js/library.js +++ /dev/null @@ -1,79 +0,0 @@ -class Pushbar { - constructor(config = { overlay: true, blur: false }) { - this.activeId; - this.activeElement; - this.overlayElement; - if (config.overlay) { - this.overlayElement = document.createElement('div'); - this.overlayElement.classList.add('pushbar_overlay'); - document.querySelector('body').appendChild(this.overlayElement); - } - if (config.blur) { - const mainContent = document.querySelector('.pushbar_main_content'); - if (mainContent) { - mainContent.classList.add('pushbar_blur'); - } - } - this.bindEvents(); - } - - emitOpening() { - const event = new CustomEvent('pushbar_opening', { bubbles: true, detail: { element: this.activeElement, id: this.activeId } }); - this.activeElement.dispatchEvent(event); - } - - emitClosing() { - const event = new CustomEvent('pushbar_closing', { bubbles: true, detail: { element: this.activeElement, id: this.activeId } }); - this.activeElement.dispatchEvent(event); - } - - handleOpenEvent(e) { - e.preventDefault(); - const pushbarId = e.currentTarget.getAttribute('data-pushbar-target'); - this.open(pushbarId); - } - - handleCloseEvent(e) { - e.preventDefault(); - this.close(); - } - - handleKeyEvent(e) { - if (e.keyCode === 27) this.close(); - } - - bindEvents() { - const triggers = document.querySelectorAll('[data-pushbar-target]'); - const closers = document.querySelectorAll('[data-pushbar-close]'); - triggers.forEach(trigger => trigger.addEventListener('click', e => this.handleOpenEvent(e), false)); - closers.forEach(closer => closer.addEventListener('click', e => this.handleCloseEvent(e), false)); - if (this.overlayElement) { - this.overlayElement.addEventListener('click', e => this.handleCloseEvent(e), false); - } - document.addEventListener('keyup', e => this.handleKeyEvent(e)); - } - - open(pushbarId) { - if (this.activeId === String(pushbarId) || !pushbarId) return; - if (this.activeId && this.activeId !== String(pushbarId)) this.close(); - this.activeId = pushbarId - this.activeElement = document.querySelector(`[data-pushbar-id="${this.activeId}"]`) - if (!this.activeElement) return; - this.emitOpening(); - this.activeElement.classList.add('opened'); - const pageRootElement = document.querySelector('html') - pageRootElement.classList.add('pushbar_locked'); - pageRootElement.setAttribute('pushbar', pushbarId) - } - - close() { - if (!this.activeId) return; - this.emitClosing(); - this.activeElement.classList.remove('opened'); - const pageRootElement = document.querySelector('html') - pageRootElement.classList.remove('pushbar_locked'); - pageRootElement.removeAttribute('pushbar') - this.activeId = null; - this.activeElement = null; - } -} \ No newline at end of file -- cgit