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){
|
clearMedia(event){
|
||||||
//Call up the popup
|
//Call up the popup
|
||||||
new clearPopup(event, this.client, null);
|
new clearPopup(event, this.client, null, this.ownerDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add queue controls */
|
/* add queue controls */
|
||||||
|
|
@ -171,7 +171,7 @@ class queuePanel extends panelObj{
|
||||||
|
|
||||||
queueAt(event){
|
queueAt(event){
|
||||||
//Call up the popup
|
//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
|
//Clear out prompts
|
||||||
this.addMediaLinkPrompt.value = '';
|
this.addMediaLinkPrompt.value = '';
|
||||||
|
|
@ -519,7 +519,7 @@ class queuePanel extends panelObj{
|
||||||
//context menu
|
//context menu
|
||||||
const menuMap = new Map([
|
const menuMap = new Map([
|
||||||
["Play now", ()=>{this.client.socket.emit('move', {uuid: entry[1].uuid})}],
|
["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})}],
|
["Delete", ()=>{this.client.socket.emit('delete', {uuid: entry[1].uuid})}],
|
||||||
["Open in New Tab", ()=>{window.open(entry[1].url, '_blank').focus();}],
|
["Open in New Tab", ()=>{window.open(entry[1].url, '_blank').focus();}],
|
||||||
["Copy URL", ()=>{navigator.clipboard.writeText(entry[1].url);}],
|
["Copy URL", ()=>{navigator.clipboard.writeText(entry[1].url);}],
|
||||||
|
|
@ -875,7 +875,7 @@ class queuePanel extends panelObj{
|
||||||
}
|
}
|
||||||
|
|
||||||
class schedulePopup{
|
class schedulePopup{
|
||||||
constructor(event, client, url, title, cb){
|
constructor(event, client, url, title, cb, doc){
|
||||||
//Set Client
|
//Set Client
|
||||||
this.client = client;
|
this.client = client;
|
||||||
//Set link
|
//Set link
|
||||||
|
|
@ -887,7 +887,7 @@ class schedulePopup{
|
||||||
|
|
||||||
//Create media popup and call async constructor when done
|
//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 :(
|
//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(){
|
asyncConstructor(){
|
||||||
|
|
@ -934,9 +934,9 @@ class schedulePopup{
|
||||||
}
|
}
|
||||||
|
|
||||||
class reschedulePopup extends schedulePopup{
|
class reschedulePopup extends schedulePopup{
|
||||||
constructor(event, client, media, cb){
|
constructor(event, client, media, cb, doc){
|
||||||
//Call derived constructor
|
//Call derived constructor
|
||||||
super(event, client, null, null, cb);
|
super(event, client, null, null, cb, doc);
|
||||||
|
|
||||||
//Set media
|
//Set media
|
||||||
this.media = media;
|
this.media = media;
|
||||||
|
|
@ -958,15 +958,16 @@ class reschedulePopup extends schedulePopup{
|
||||||
}
|
}
|
||||||
|
|
||||||
class clearPopup{
|
class clearPopup{
|
||||||
constructor(event, client, cb){
|
constructor(event, client, cb, doc){
|
||||||
//Set Client
|
//Set Client
|
||||||
this.client = client;
|
this.client = client;
|
||||||
//Set callback
|
//Set callback
|
||||||
this.cb = cb;
|
this.cb = cb;
|
||||||
|
console.log(doc);
|
||||||
|
|
||||||
//Create media popup and call async constructor when done
|
//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 :(
|
//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(){
|
asyncConstructor(){
|
||||||
|
|
|
||||||
|
|
@ -355,11 +355,12 @@ class canopyUXUtils{
|
||||||
}
|
}
|
||||||
|
|
||||||
static popup = class{
|
static popup = class{
|
||||||
constructor(content, ajaxPopup = false, cb){
|
constructor(content, ajaxPopup = false, cb, doc = document){
|
||||||
//Define non-popup node values
|
//Define non-popup node values
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.ajaxPopup = ajaxPopup;
|
this.ajaxPopup = ajaxPopup;
|
||||||
this.cb = cb;
|
this.cb = cb;
|
||||||
|
this.doc = doc;
|
||||||
//define popup nodes
|
//define popup nodes
|
||||||
this.createPopup();
|
this.createPopup();
|
||||||
|
|
||||||
|
|
@ -369,7 +370,7 @@ class canopyUXUtils{
|
||||||
|
|
||||||
createPopup(){
|
createPopup(){
|
||||||
//Check if another popup has already thrown a backer up
|
//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
|
//Create popup backer
|
||||||
this.popupBacker = document.createElement('div');
|
this.popupBacker = document.createElement('div');
|
||||||
this.popupBacker.classList.add('popup-backer');
|
this.popupBacker.classList.add('popup-backer');
|
||||||
|
|
@ -401,12 +402,12 @@ class canopyUXUtils{
|
||||||
//Close the pop-up
|
//Close the pop-up
|
||||||
this.closePopup();
|
this.closePopup();
|
||||||
//Remove this event listener
|
//Remove this event listener
|
||||||
document.removeEventListener('keydown', this.keyClose);
|
this.doc.removeEventListener('keydown', this.keyClose);
|
||||||
}
|
}
|
||||||
}).bind(this);
|
}).bind(this);
|
||||||
|
|
||||||
//Add event listener to close popup when enter is hit
|
//Add event listener to close popup when enter is hit
|
||||||
document.addEventListener('keydown', this.keyClose);
|
this.doc.addEventListener('keydown', this.keyClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fillPopupContent(){
|
async fillPopupContent(){
|
||||||
|
|
@ -428,15 +429,15 @@ class canopyUXUtils{
|
||||||
|
|
||||||
displayPopup(){
|
displayPopup(){
|
||||||
//Blur active element that probably caused the popup
|
//Blur active element that probably caused the popup
|
||||||
document.activeElement.blur();
|
this.doc.activeElement.blur();
|
||||||
|
|
||||||
//display the popup
|
//display the popup
|
||||||
document.body.prepend(this.popupDiv);
|
this.doc.body.prepend(this.popupDiv);
|
||||||
|
|
||||||
//if we created a popup backer
|
//if we created a popup backer
|
||||||
if(this.popupBacker != null){
|
if(this.popupBacker != null){
|
||||||
//display the popup backer
|
//display the popup backer
|
||||||
document.body.prepend(this.popupBacker);
|
this.doc.body.prepend(this.popupBacker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -447,7 +448,7 @@ class canopyUXUtils{
|
||||||
this.popupDiv.remove();
|
this.popupDiv.remove();
|
||||||
|
|
||||||
//Look for the backer instead of using the object property since the bitch mighta been created by someone else
|
//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 there aren't any more popups
|
||||||
if(document.querySelector('.popup-div') == null && foundBacker != null){
|
if(document.querySelector('.popup-div') == null && foundBacker != null){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue