summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-12-09 10:47:40 +0100
committerMorris Jobke <hey@morrisjobke.de>2016-12-09 12:52:46 +0100
commitec52286a0f5296df1582210a92b7b29a763843fb (patch)
treec14f68b42c3ef03bcc067a7bd1838042577eaffc /core
parent88d90066ba51e88b26083901961183a0cbed01e4 (diff)
downloadnextcloud-server-ec52286a0f5296df1582210a92b7b29a763843fb.tar.gz
nextcloud-server-ec52286a0f5296df1582210a92b7b29a763843fb.zip
Fire callback also on pure closing of prompt dialog
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'core')
-rw-r--r--core/js/oc-dialogs.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index 7476c93ba45..7e059b4bbc0 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -124,6 +124,14 @@ var OCdialogs = {
modal = false;
}
$('body').append($dlg);
+
+ // wrap callback in _.once():
+ // only call callback once and not twice (button handler and close
+ // event) but call it for the close event, if ESC or the x is hit
+ if (callback !== undefined) {
+ callback = _.once(callback);
+ }
+
var buttonlist = [{
text : t('core', 'No'),
click: function () {
@@ -147,7 +155,13 @@ var OCdialogs = {
$(dialogId).ocdialog({
closeOnEscape: true,
modal : modal,
- buttons : buttonlist
+ buttons : buttonlist,
+ close : function() {
+ // callback is already fired if Yes/No is clicked directly
+ if (callback !== undefined) {
+ callback(false, input.val());
+ }
+ }
});
input.focus();
OCdialogs.dialogsCounter++;