Added optional doc argument to popup class for cPanel usage.
This commit is contained in:
parent
c04edb6691
commit
c83ca63f9a
2 changed files with 19 additions and 17 deletions
|
|
@ -355,11 +355,12 @@ class canopyUXUtils{
|
|||
}
|
||||
|
||||
static popup = class{
|
||||
constructor(content, ajaxPopup = false, cb){
|
||||
constructor(content, ajaxPopup = false, cb, doc = document){
|
||||
//Define non-popup node values
|
||||
this.content = content;
|
||||
this.ajaxPopup = ajaxPopup;
|
||||
this.cb = cb;
|
||||
this.doc = doc;
|
||||
//define popup nodes
|
||||
this.createPopup();
|
||||
|
||||
|
|
@ -369,7 +370,7 @@ class canopyUXUtils{
|
|||
|
||||
createPopup(){
|
||||
//Check if another popup has already thrown a backer up
|
||||
if(document.querySelector('.popup-backer') == null){
|
||||
if(this.doc.querySelector('.popup-backer') == null){
|
||||
//Create popup backer
|
||||
this.popupBacker = document.createElement('div');
|
||||
this.popupBacker.classList.add('popup-backer');
|
||||
|
|
@ -401,12 +402,12 @@ class canopyUXUtils{
|
|||
//Close the pop-up
|
||||
this.closePopup();
|
||||
//Remove this event listener
|
||||
document.removeEventListener('keydown', this.keyClose);
|
||||
this.doc.removeEventListener('keydown', this.keyClose);
|
||||
}
|
||||
}).bind(this);
|
||||
|
||||
//Add event listener to close popup when enter is hit
|
||||
document.addEventListener('keydown', this.keyClose);
|
||||
this.doc.addEventListener('keydown', this.keyClose);
|
||||
}
|
||||
|
||||
async fillPopupContent(){
|
||||
|
|
@ -428,15 +429,15 @@ class canopyUXUtils{
|
|||
|
||||
displayPopup(){
|
||||
//Blur active element that probably caused the popup
|
||||
document.activeElement.blur();
|
||||
this.doc.activeElement.blur();
|
||||
|
||||
//display the popup
|
||||
document.body.prepend(this.popupDiv);
|
||||
this.doc.body.prepend(this.popupDiv);
|
||||
|
||||
//if we created a popup backer
|
||||
if(this.popupBacker != null){
|
||||
//display the popup backer
|
||||
document.body.prepend(this.popupBacker);
|
||||
this.doc.body.prepend(this.popupBacker);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -447,7 +448,7 @@ class canopyUXUtils{
|
|||
this.popupDiv.remove();
|
||||
|
||||
//Look for the backer instead of using the object property since the bitch mighta been created by someone else
|
||||
const foundBacker = document.querySelector('.popup-backer');
|
||||
const foundBacker = this.doc.querySelector('.popup-backer');
|
||||
|
||||
//if there aren't any more popups
|
||||
if(document.querySelector('.popup-div') == null && foundBacker != null){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue