diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-12-09 13:44:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-09 13:44:53 +0100 |
commit | 49473dee85b0b7f004c7fd34acee1d1c3c7fe09e (patch) | |
tree | 0d28adf827152ce4343b4e5770847d5dfc5b0c90 /core | |
parent | e3b2832ee192a9cc961342420efe6ec077638461 (diff) | |
parent | ec52286a0f5296df1582210a92b7b29a763843fb (diff) | |
download | nextcloud-server-49473dee85b0b7f004c7fd34acee1d1c3c7fe09e.tar.gz nextcloud-server-49473dee85b0b7f004c7fd34acee1d1c3c7fe09e.zip |
Merge pull request #2582 from nextcloud/callback-alos-on-close
Fire callback also on pure closing of prompt dialog
Diffstat (limited to 'core')
-rw-r--r-- | core/js/oc-dialogs.js | 16 |
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++; |