2017-02-03 23:05:59 +01:00
|
|
|
/* Pop up Dialog Box */
|
2017-08-30 19:44:29 +02:00
|
|
|
let dialogBoxes = [];
|
2017-05-24 15:49:52 +02:00
|
|
|
|
|
|
|
//Close dialog box when clicking outside
|
2017-06-07 02:28:20 +02:00
|
|
|
$(document).click(function(event) {
|
|
|
|
if (dialogBoxOpened && dialogBoxes.length >= 1) {
|
|
|
|
if (!$(event.target).closest(dialogBoxes[0]).length){
|
|
|
|
dialogBoxes[0].remove();
|
|
|
|
dialogBoxes.splice(0, 1);
|
|
|
|
if (dialogBoxes.length == 0) {
|
|
|
|
dialogBoxOpened = false;
|
|
|
|
} else {
|
|
|
|
dialogBoxes[0].style.visibility = "visible";
|
2017-06-01 06:17:50 +02:00
|
|
|
}
|
2017-05-24 15:49:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-06-07 02:28:20 +02:00
|
|
|
|
2017-06-01 06:17:50 +02:00
|
|
|
//Dialog box close buttons
|
2017-06-07 02:28:20 +02:00
|
|
|
$(document).on('click', '.dialog-box-close-button', function( event ) {
|
|
|
|
if (dialogBoxOpened && dialogBoxes.length >= 1) {
|
|
|
|
dialogBoxes[0].remove();
|
|
|
|
dialogBoxes.splice(0, 1);
|
|
|
|
if (dialogBoxes.length == 0) {
|
|
|
|
dialogBoxOpened = false;
|
|
|
|
} else {
|
|
|
|
dialogBoxes[0].style.visibility = "visible";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2017-02-03 23:05:59 +01:00
|
|
|
|
2017-06-01 06:17:50 +02:00
|
|
|
var dialogBoxOpened = false;
|
2017-02-03 23:05:59 +01:00
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function dialogBoxCreate(txt) {
|
2017-06-01 06:17:50 +02:00
|
|
|
var container = document.createElement("div");
|
|
|
|
container.setAttribute("class", "dialog-box-container");
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-06-01 06:17:50 +02:00
|
|
|
var content = document.createElement("div");
|
|
|
|
content.setAttribute("class", "dialog-box-content");
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-06-01 06:17:50 +02:00
|
|
|
var closeButton = document.createElement("span");
|
|
|
|
closeButton.setAttribute("class", "dialog-box-close-button");
|
|
|
|
closeButton.innerHTML = "×"
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-06-01 06:17:50 +02:00
|
|
|
var textE = document.createElement("p");
|
2017-10-12 22:10:34 +02:00
|
|
|
textE.innerHTML = txt.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-06-01 06:17:50 +02:00
|
|
|
content.appendChild(closeButton);
|
|
|
|
content.appendChild(textE);
|
|
|
|
container.appendChild(content);
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-06-01 06:17:50 +02:00
|
|
|
document.body.appendChild(container);
|
2017-06-07 02:28:20 +02:00
|
|
|
if (dialogBoxes.length >= 1) {
|
|
|
|
container.style.visibility = "hidden";
|
|
|
|
}
|
|
|
|
dialogBoxes.push(container);
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-05-24 15:49:52 +02:00
|
|
|
setTimeout(function() {
|
|
|
|
dialogBoxOpened = true;
|
2017-06-07 02:28:20 +02:00
|
|
|
}, 400);
|
2017-08-30 19:44:29 +02:00
|
|
|
}
|
|
|
|
|
2017-09-19 20:38:03 +02:00
|
|
|
export {dialogBoxCreate, dialogBoxOpened};
|