[Pkg-owncloud-commits] [owncloud] 23/172: Add prompt dialog to OC.dialogs

David Prévot taffit at moszumanska.debian.org
Sun May 18 20:09:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 163a7a47f9bb5a4ec8c939f9e3ed67d4c0123d0f
Author: Robin Appelman <icewind at owncloud.com>
Date:   Fri May 9 17:09:06 2014 +0200

    Add prompt dialog to OC.dialogs
---
 core/js/oc-dialogs.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index 11833f1..3e45e37 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -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 wether 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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list