diff --git a/src/web/App.mjs b/src/web/App.mjs index 56746a41..60491ef4 100755 --- a/src/web/App.mjs +++ b/src/web/App.mjs @@ -670,18 +670,22 @@ class App { * * @param {string} title - The title of the box * @param {string} body - The question (HTML supported) + * @param {string} accept - The text of the accept button + * @param {string} reject - The text of the reject button * @param {function} callback - A function accepting one boolean argument which handles the * response e.g. function(answer) {...} * @param {Object} [scope=this] - The object to bind to the callback function * * @example * // Pops up a box asking if the user would like a cookie. Prints the answer to the console. - * this.confirm("Question", "Would you like a cookie?", function(answer) {console.log(answer);}); + * this.confirm("Question", "Would you like a cookie?", "Yes", "No", function(answer) {console.log(answer);}); */ - confirm(title, body, callback, scope) { + confirm(title, body, accept, reject, callback, scope) { scope = scope || this; document.getElementById("confirm-title").innerHTML = title; document.getElementById("confirm-body").innerHTML = body; + document.getElementById("confirm-yes").innerText = accept; + document.getElementById("confirm-no").innerText = reject; document.getElementById("confirm-modal").style.display = "block"; this.confirmClosed = false; @@ -694,9 +698,14 @@ class App { callback.bind(scope)(true); $("#confirm-modal").modal("hide"); }.bind(this)) + .one("click", "#confirm-no", function() { + this.confirmClosed = true; + callback.bind(scope)(false); + }.bind(this)) .one("hide.bs.modal", function(e) { - if (!this.confirmClosed) - callback.bind(scope)(false); + if (!this.confirmClosed) { + callback.bind(scope)(undefined); + } this.confirmClosed = true; }.bind(this)); }