aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/resources/lib/pushbar.js/library.js
diff options
context:
space:
mode:
authorGitea <gitea@fake.local>2021-11-10 17:53:50 +0100
committerGitea <gitea@fake.local>2021-11-10 17:53:50 +0100
commit8fabf77b2a7720a357c63817c07035a9908818a0 (patch)
treed689fcac1403e2473010fe80bc337599a78c21a4 /Neutron-trunk/resources/lib/pushbar.js/library.js
parent7b4af63a90a726b98a59b83e53f040a7a566a11d (diff)
downloadelectrode-8fabf77b2a7720a357c63817c07035a9908818a0.tar.gz
electrode-8fabf77b2a7720a357c63817c07035a9908818a0.tar.bz2
electrode-8fabf77b2a7720a357c63817c07035a9908818a0.zip
Update
Diffstat (limited to 'Neutron-trunk/resources/lib/pushbar.js/library.js')
-rw-r--r--Neutron-trunk/resources/lib/pushbar.js/library.js79
1 files changed, 0 insertions, 79 deletions
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