Skip to content
Snippets Groups Projects
Commit 4f9d339d authored by Tögl, Christina's avatar Tögl, Christina
Browse files

Add event listener to additional menu

parent b4eaa615
No related branches found
No related tags found
No related merge requests found
Pipeline #61700 failed
...@@ -59,7 +59,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -59,7 +59,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
this.authInfo = ''; this.authInfo = '';
this.selectBtnDisabled = true; this.selectBtnDisabled = true;
this.storeSession = false; this.storeSession = false;
this.boundCloseAdditionalMenuHandler = this.closeAdditionalMenu.bind(this); this.boundCloseAdditionalMenuHandler = this.hideMoreMenu.bind(this);//this.closeAdditionalMenu.bind(this);
this.initateOpenAdditionalMenu = false; this.initateOpenAdditionalMenu = false;
this.showAdditionalMenu = false; this.showAdditionalMenu = false;
this.isInFavorites = false; this.isInFavorites = false;
...@@ -1593,17 +1593,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1593,17 +1593,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
return this.nextcloudFileURL + this.directoryPath; return this.nextcloudFileURL + this.directoryPath;
} }
closeAdditionalMenu() { //TODO integrate this
if (this.initateOpenAdditionalMenu && this.showAdditionalMenu) {
this.initateOpenAdditionalMenu = false;
return;
}
if (this.showAdditionalMenu){
document.removeEventListener('click', this.boundCloseAdditionalMenuHandler);
this.showAdditionalMenu = false;
}
}
toggleMoreMenu() { toggleMoreMenu() {
const menu = this.shadowRoot.querySelector("ul.extended-menu"); const menu = this.shadowRoot.querySelector("ul.extended-menu");
const menuStart = this.shadowRoot.querySelector("a.extended-menu-link"); const menuStart = this.shadowRoot.querySelector("a.extended-menu-link");
...@@ -1612,8 +1601,9 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1612,8 +1601,9 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
return; return;
} }
menu.classList.toggle('hidden'); menu.classList.toggle('hidden'); //sets hidden or removes it
// computations for overflow - begin
if (this.menuHeight === -1) { if (this.menuHeight === -1) {
this.menuHeight = menu.clientHeight; this.menuHeight = menu.clientHeight;
} }
...@@ -1629,15 +1619,24 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1629,15 +1619,24 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
document.body.removeAttribute('style', 'overflow:hidden;'); document.body.removeAttribute('style', 'overflow:hidden;');
menu.removeAttribute('style'); menu.removeAttribute('style');
} }
// computations for overflow - end
if (!this.showAdditionalMenu) { if (!menu.classList.contains('hidden')) { // add event listener for clicking outside of menu
this.initateOpenAdditionalMenu = true;
this.showAdditionalMenu = true;
document.addEventListener('click', this.boundCloseAdditionalMenuHandler); document.addEventListener('click', this.boundCloseAdditionalMenuHandler);
console.log('add event listener');
this.initateOpenAdditionalMenu = true;
}
else {
document.removeEventListener('click', this.boundCloseAdditionalMenuHandler);
console.log('delete event listener');
} }
} }
hideMoreMenu() { hideMoreMenu() {
if (this.initateOpenAdditionalMenu) {
this.initateOpenAdditionalMenu = false;
return;
}
const menu = this.shadowRoot.querySelector("ul.extended-menu"); const menu = this.shadowRoot.querySelector("ul.extended-menu");
if (menu && !menu.classList.contains('hidden')) if (menu && !menu.classList.contains('hidden'))
this.toggleMoreMenu(); this.toggleMoreMenu();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment