Skip to content

Commit

Permalink
#101 Improvements to #99
Browse files Browse the repository at this point in the history
Close #101
  • Loading branch information
Rafael committed Nov 2, 2017
1 parent 98e36b1 commit e018a3f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions Extension/esgst.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ class Popout {

class Popup {
constructor(icon, title, temp, settings, popup = null) {
esgst.popups.push(this);
this.isCreated = popup ? false : true;
this.temp = temp;
this.popup = popup || insertHtml(document.body, `beforeEnd`, `
Expand Down Expand Up @@ -307,6 +306,8 @@ class Popup {
}
open(callback) {
this.isOpen = true;
esgst.openPopups += 1;
esgst.popups.push(this);
this.modal = insertHtml(document.body, `beforeEnd`, `
<div class="esgst-popup-modal"></div>
`);
Expand All @@ -321,6 +322,9 @@ class Popup {
this.popup.style.zIndex = n + 1;
this.modal.addEventListener(`click`, () => this.close());
this.reposition();
if (!esgst.isRepositioning) {
setTimeout(repositionPopups, 2000);
}
if (callback) {
callback();
}
Expand All @@ -339,6 +343,8 @@ class Popup {
if (this.onClose) {
this.onClose();
}
esgst.openPopups -= 1;
esgst.popups.pop();
this.isOpen = false;
}
reposition() {
Expand Down Expand Up @@ -438,6 +444,7 @@ function loadEsgst(storage) {
currentDiscussions: [],
profileFeatures: [],
popups: [],
openPopups: 0,
elgbCache: JSON.parse(getValue(`esgst_elgbCache`, `{"descriptions": {}, "timestamp": ${Date.now()}}`)),
menuPath: location.pathname.match(/^\/esgst\//),
settingsPath: location.pathname.match(/^\/esgst\/settings/),
Expand Down Expand Up @@ -7765,16 +7772,17 @@ function loadFeatures() {
notifyNewVersion(version);
}
}
repositionPopups();
setTimeout(repositionPopups, 2000);
}

function repositionPopups() {
esgst.popups.forEach(popup => {
if (popup.isOpen) {
popup.reposition();
}
});
setTimeout(repositionPopups, 1000);
if (esgst.openPopups > 0) {
esgst.popups.forEach(popup => popup.reposition());
esgst.isRepositioning = true;
setTimeout(repositionPopups, 2000);
} else {
esgst.isRepositioning = false;
}
}

function fixFsSidebar() {
Expand Down

0 comments on commit e018a3f

Please sign in to comment.