summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-05-13 17:32:06 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-05-13 17:32:06 +0200
commit7babd44dd07091abaa871b40df8e8b10073482a3 (patch)
treed148051a26b10688cd09db01173b55b8ce89f2b8 /core
parentb8de1e5d716c416beae328506e368cd0554509e1 (diff)
parent62364269c5952756315121fabbb7f956412dac45 (diff)
downloadnextcloud-server-7babd44dd07091abaa871b40df8e8b10073482a3.tar.gz
nextcloud-server-7babd44dd07091abaa871b40df8e8b10073482a3.zip
Merge pull request #8524 from owncloud/prompt-dialog
Add prompt dialog to OC.dialogs
Diffstat (limited to 'core')
-rw-r--r--core/js/oc-dialogs.js61
1 files changed, 60 insertions, 1 deletions
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index 11833f12e2d..f6c17122d7d 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -19,7 +19,7 @@
*
*/
-/* global OC, t, alert */
+/* global OC, t, alert, $ */
/**
* this class to ease the usage of jquery dialogs
@@ -62,6 +62,65 @@ var OCdialogs = {
this.message(text, title, 'notice', OCdialogs.YES_NO_BUTTONS, callback, modal);
},
/**
+ * displays prompt dialog
+ * @param text content of dialog
+ * @param title dialog title
+ * @param callback which will be triggered when user presses YES or NO
+ * (true or false would be passed to callback respectively)
+ * @param modal make the dialog modal
+ * @param name name of the input field
+ * @param password whether the input should be a password input
+ */
+ prompt: function (text, title, callback, modal, name, password) {
+ $.when(this._getMessageTemplate()).then(function ($tmpl) {
+ var dialogName = 'oc-dialog-' + OCdialogs.dialogsCounter + '-content';
+ var dialogId = '#' + dialogName;
+ var $dlg = $tmpl.octemplate({
+ dialog_name: dialogName,
+ title : title,
+ message : text,
+ type : 'notice'
+ });
+ var input = $('<input/>');
+ input.attr('type', password ? 'password' : 'text').attr('id', dialogName + '-input');
+ var label = $('<label/>').attr('for', dialogName + '-input').text(name + ': ');
+ $dlg.append(label);
+ $dlg.append(input);
+ if (modal === undefined) {
+ modal = false;
+ }
+ $('body').append($dlg);
+ var buttonlist = [
+ {
+ text : t('core', 'Yes'),
+ click : function () {
+ if (callback !== undefined) {
+ callback(true, input.val());
+ }
+ $(dialogId).ocdialog('close');
+ },
+ defaultButton: true
+ },
+ {
+ text : t('core', 'No'),
+ click: function () {
+ if (callback !== undefined) {
+ callback(false, input.val());
+ }
+ $(dialogId).ocdialog('close');
+ }
+ }
+ ];
+
+ $(dialogId).ocdialog({
+ closeOnEscape: true,
+ modal : modal,
+ buttons : buttonlist
+ });
+ OCdialogs.dialogsCounter++;
+ });
+ },
+ /**
* show a file picker to pick a file from
* @param title dialog title
* @param callback which will be triggered when user presses Choose