Update ReadAllNotificationsButton.plugin.js

This commit is contained in:
Mirco Wittrien 2018-11-19 15:08:51 +01:00
parent 164baba7d3
commit e59cf6e45b
1 changed files with 20 additions and 23 deletions

View File

@ -12,8 +12,8 @@ class ReadAllNotificationsButton {
</div>`; </div>`;
this.RAMbuttonMarkup = this.RAMbuttonMarkup =
`<button type="button" id="RAMbutton" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemin + BDFDB.disCN.buttongrow}" style="flex: 0 0 auto; margin-top: -5px; height: 25px;"> `<button type="button" id="RAMbutton" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemin + BDFDB.disCN.buttongrow}" style="flex: 0 0 auto; margin-left: 25px; height: 25px;">
<div class="${BDFDB.disCN.buttoncontents}">Clear all Mentions</div> <div class="${BDFDB.disCN.buttoncontents}">Clear Mentions</div>
</button>`; </button>`;
this.defaults = { this.defaults = {
@ -79,27 +79,24 @@ class ReadAllNotificationsButton {
if (change.addedNodes) { if (change.addedNodes) {
change.addedNodes.forEach((node) => { change.addedNodes.forEach((node) => {
var mentionspopout = null; var mentionspopout = null;
if (node && node.tagName && (mentionspopout = node.querySelector(BDFDB.dotCN.recentmentionspopout)) != null) { if (node.tagName && (mentionspopout = node.querySelector(BDFDB.dotCN.recentmentionspopout)) != null && node.querySelector(BDFDB.dotCN.recentmentionsmentionfilter)) {
let filter = node.querySelector(BDFDB.dotCN.recentmentionsmentionfilter); $(this.RAMbuttonMarkup).appendTo(BDFDB.dotCN.recentmentionstitle, mentionspopout)
if (filter) { .on("click", () => {
$(this.RAMbuttonMarkup).insertBefore(filter, mentionspopout) var loadinterval = setInterval(() => {
.on("click", () => { if (!mentionspopout || !mentionspopout.parentElement) clearInterval(loadinterval);
var loadinterval = setInterval(() => { var loadbutton = mentionspopout.querySelector(BDFDB.dotCNS.messagespopouthasmore + "button");
if (!mentionspopout || !mentionspopout.parentElement) clearInterval(loadinterval); var closebuttons = mentionspopout.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton);
var loadbutton = mentionspopout.querySelector(BDFDB.dotCNS.messagespopouthasmore + "button"); if (!loadbutton) {
var closebuttons = mentionspopout.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton); closebuttons.forEach((btn) => {btn.click();});
if (!loadbutton) { clearInterval(loadinterval);
closebuttons.forEach((btn) => {btn.click();}); }
clearInterval(loadinterval); else {
} closebuttons.forEach((btn,i) => {if (closebuttons.length-1 > i) btn.click();});
else { loadbutton.click();
closebuttons.forEach((btn,i) => {if (closebuttons.length-1 > i) btn.click();}); }
loadbutton.click(); },2000);
} });
},2000); mentionspopout.classList.add("RAM-added");
});
mentionspopout.classList.add("RAM-added");
}
} }
}); });
} }