Added optional doc argument to popup class for cPanel usage.
This commit is contained in:
parent
c04edb6691
commit
c83ca63f9a
|
|
@ -156,7 +156,7 @@ class queuePanel extends panelObj{
|
|||
|
||||
clearMedia(event){
|
||||
//Call up the popup
|
||||
new clearPopup(event, this.client, null);
|
||||
new clearPopup(event, this.client, null, this.ownerDoc);
|
||||
}
|
||||
|
||||
/* add queue controls */
|
||||
|
|
@ -171,7 +171,7 @@ class queuePanel extends panelObj{
|
|||
|
||||
queueAt(event){
|
||||
//Call up the popup
|
||||
new schedulePopup(event, this.client, this.addMediaLinkPrompt.value, this.addMediaNamePrompt.value, null);
|
||||
new schedulePopup(event, this.client, this.addMediaLinkPrompt.value, this.addMediaNamePrompt.value, null, this.ownerDoc);
|
||||
|
||||
//Clear out prompts
|
||||
this.addMediaLinkPrompt.value = '';
|
||||
|
|
@ -519,7 +519,7 @@ class queuePanel extends panelObj{
|
|||
//context menu
|
||||
const menuMap = new Map([
|
||||
["Play now", ()=>{this.client.socket.emit('move', {uuid: entry[1].uuid})}],
|
||||
["Move To...", (event)=>{new reschedulePopup(event, this.client, entry[1])}],
|
||||
["Move To...", (event)=>{new reschedulePopup(event, this.client, entry[1], null, this.ownerDoc)}],
|
||||
["Delete", ()=>{this.client.socket.emit('delete', {uuid: entry[1].uuid})}],
|
||||
["Open in New Tab", ()=>{window.open(entry[1].url, '_blank').focus();}],
|
||||
["Copy URL", ()=>{navigator.clipboard.writeText(entry[1].url);}],
|
||||
|
|
@ -875,7 +875,7 @@ class queuePanel extends panelObj{
|
|||
}
|
||||
|
||||
class schedulePopup{
|
||||
constructor(event, client, url, title, cb){
|
||||
constructor(event, client, url, title, cb, doc){
|
||||
//Set Client
|
||||
this.client = client;
|
||||
//Set link
|
||||
|
|
@ -887,7 +887,7 @@ class schedulePopup{
|
|||
|
||||
//Create media popup and call async constructor when done
|
||||
//unfortunately we cant call constructors asyncronously, and we cant call back to this from super, so we can't extend this as it stands :(
|
||||
this.popup = new canopyUXUtils.popup('/scheduleMedia', true, this.asyncConstructor.bind(this));
|
||||
this.popup = new canopyUXUtils.popup('/scheduleMedia', true, this.asyncConstructor.bind(this), doc);
|
||||
}
|
||||
|
||||
asyncConstructor(){
|
||||
|
|
@ -934,9 +934,9 @@ class schedulePopup{
|
|||
}
|
||||
|
||||
class reschedulePopup extends schedulePopup{
|
||||
constructor(event, client, media, cb){
|
||||
constructor(event, client, media, cb, doc){
|
||||
//Call derived constructor
|
||||
super(event, client, null, null, cb);
|
||||
super(event, client, null, null, cb, doc);
|
||||
|
||||
//Set media
|
||||
this.media = media;
|
||||
|
|
@ -958,15 +958,16 @@ class reschedulePopup extends schedulePopup{
|
|||
}
|
||||
|
||||
class clearPopup{
|
||||
constructor(event, client, cb){
|
||||
constructor(event, client, cb, doc){
|
||||
//Set Client
|
||||
this.client = client;
|
||||
//Set callback
|
||||
this.cb = cb;
|
||||
console.log(doc);
|
||||
|
||||
//Create media popup and call async constructor when done
|
||||
//unfortunately we cant call constructors asyncronously, and we cant call back to this from super, so we can't extend this as it stands :(
|
||||
this.popup = new canopyUXUtils.popup('/clearMedia', true, this.asyncConstructor.bind(this));
|
||||
this.popup = new canopyUXUtils.popup('/clearMedia', true, this.asyncConstructor.bind(this), doc);
|
||||
}
|
||||
|
||||
asyncConstructor(){
|
||||
|
|
|
|||
|
|
@ -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…
Reference in a new issue