From 94190220b8abe2131473951443401eb2a18df543 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Sat, 24 Nov 2018 17:12:27 +0100 Subject: [PATCH] UserPopout no longer gets out of bounds in CreationDate/JoinedAtDate --- Plugins/CreationDate/CreationDate.plugin.js | 13 +++++++++---- Plugins/JoinedAtDate/JoinedAtDate.plugin.js | 15 ++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Plugins/CreationDate/CreationDate.plugin.js b/Plugins/CreationDate/CreationDate.plugin.js index 035cf92e9c..3b25425314 100644 --- a/Plugins/CreationDate/CreationDate.plugin.js +++ b/Plugins/CreationDate/CreationDate.plugin.js @@ -45,7 +45,7 @@ class CreationDate { getDescription () {return "Displays the Creation Date of an Account in the UserPopout and UserModal.";} - getVersion () {return "1.1.9";} + getVersion () {return "1.2.0";} getAuthor () {return "DevilBro";} @@ -109,7 +109,7 @@ class CreationDate { if (change.addedNodes) { change.addedNodes.forEach((node) => { if (node.tagName && node.querySelector(BDFDB.dotCN.userpopout)) { - if (BDFDB.getData("addInUserPopout", this, "settings")) this.addCreationDate(node.querySelector(BDFDB.dotCN.userpopoutheadertext)); + if (BDFDB.getData("addInUserPopout", this, "settings")) this.addCreationDate(node.querySelector(BDFDB.dotCN.userpopoutheadertext), node); } }); } @@ -124,7 +124,7 @@ class CreationDate { if (change.addedNodes) { change.addedNodes.forEach((node) => { if (node.tagName && node.querySelector("[class*='topSection']")) { - if (BDFDB.getData("addInUserProfil", this, "settings")) this.addCreationDate(node.querySelector(BDFDB.dotCN.userprofileheaderinfo)); + if (BDFDB.getData("addInUserProfil", this, "settings")) this.addCreationDate(node.querySelector(BDFDB.dotCN.userprofileheaderinfo), null); } }); } @@ -197,7 +197,7 @@ class CreationDate { return $(menuhtml)[0]; } - addCreationDate (container) { + addCreationDate (container, popout) { if (!container) return; var info = BDFDB.getKeyInformation({"node":container,"key":"user"}); if (info) { @@ -207,6 +207,11 @@ class CreationDate { var nametag = container.querySelector(BDFDB.dotCN.nametag); var joinedAtDate = container.querySelector(".joinedAtDate"); container.insertBefore(creationDate[0], joinedAtDate ? joinedAtDate.nextSibling : (nametag ? nametag.nextSibling : null)); + if (popout) { + var arect = document.querySelector(BDFDB.dotCN.appmount).getBoundingClientRect(); + var prect = popout.getBoundingClientRect(); + popout.style.setProperty("top", (prect.y + prect.height > arect.height ? (arect.height - prect.height) : prect.y) + "px"); + } } } diff --git a/Plugins/JoinedAtDate/JoinedAtDate.plugin.js b/Plugins/JoinedAtDate/JoinedAtDate.plugin.js index 4b895e0f70..1bae8fffaa 100644 --- a/Plugins/JoinedAtDate/JoinedAtDate.plugin.js +++ b/Plugins/JoinedAtDate/JoinedAtDate.plugin.js @@ -45,9 +45,9 @@ class JoinedAtDate { getName () {return "JoinedAtDate";} - getDescription () {return "Displays the Joined At Date of a Member in the UserPopout and UserModal.";} + getDescription () {return "Displays the Joined At Date of the current Server for a Member in the UserPopout and UserModal.";} - getVersion () {return "1.0.0";} + getVersion () {return "1.0.1";} getAuthor () {return "DevilBro";} @@ -115,7 +115,7 @@ class JoinedAtDate { if (change.addedNodes) { change.addedNodes.forEach((node) => { if (node.tagName && node.querySelector(BDFDB.dotCN.userpopout)) { - if (BDFDB.getData("addInUserPopout", this, "settings")) this.addJoinedAtDate(node.querySelector(BDFDB.dotCN.userpopoutheadertext)); + if (BDFDB.getData("addInUserPopout", this, "settings")) this.addJoinedAtDate(node.querySelector(BDFDB.dotCN.userpopoutheadertext), node); } }); } @@ -130,7 +130,7 @@ class JoinedAtDate { if (change.addedNodes) { change.addedNodes.forEach((node) => { if (node.tagName && node.querySelector("[class*='topSection']")) { - if (BDFDB.getData("addInUserProfil", this, "settings")) this.addJoinedAtDate(node.querySelector(BDFDB.dotCN.userprofileheaderinfo)); + if (BDFDB.getData("addInUserProfil", this, "settings")) this.addJoinedAtDate(node.querySelector(BDFDB.dotCN.userprofileheaderinfo), null); } }); } @@ -203,7 +203,7 @@ class JoinedAtDate { return $(menuhtml)[0]; } - addJoinedAtDate (container) { + addJoinedAtDate (container, popout) { if (!container) return; var guildid = this.CurrentGuildStore.getGuildId(); if (guildid) { @@ -217,6 +217,11 @@ class JoinedAtDate { var nametag = container.querySelector(BDFDB.dotCN.nametag); var creationDate = container.querySelector(".creationDate"); container.insertBefore(joinedAtDate[0], creationDate ? creationDate : (nametag ? nametag.nextSibling : null)); + if (popout) { + var arect = document.querySelector(BDFDB.dotCN.appmount).getBoundingClientRect(); + var prect = popout.getBoundingClientRect(); + popout.style.setProperty("top", (prect.y + prect.height > arect.height ? (arect.height - prect.height) : prect.y) + "px"); + } }; if (this.loadedusers[guildid][info.id]) addTimestamp(this.loadedusers[guildid][info.id]); else this.APIModule.get(this.DiscordConstants.Endpoints.GUILD_MEMBER(guildid,info.id)).then(result => {