diff --git a/core/js/js.js b/core/js/js.js
index 61588f7a0f..df1b5c6ce7 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -125,7 +125,8 @@ OC={
OC.search.showResults(results);
});
}
- }
+ },
+ dialogs:OCdialogs
};
OC.search.customResults={};
OC.search.currentResult=-1;
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
new file mode 100644
index 0000000000..de67c342a7
--- /dev/null
+++ b/core/js/oc-dialogs.js
@@ -0,0 +1,145 @@
+/**
+ * ownCloud
+ *
+ * @author Bartek Przybylski
+ * @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see .
+ *
+ * todo(bartek): add select option in form
+ */
+
+/**
+ * this class ease usage of jquery dialogs
+ */
+OCdialogs = {
+ /**
+ * displays alert dialog
+ * @param text content of dialog
+ * @param title dialog title
+ * @param callback which will be triggered when user press OK
+ */
+ alert:function(text, title, callback) {
+ var content = '
'+text+'
';
+ OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback);
+ },
+ /**
+ * displays info dialog
+ * @param text content of dialog
+ * @param title dialog title
+ * @param callback which will be triggered when user press OK
+ */
+ info:function(text, title, callback) {
+ var content = '
'+text+'
';
+ OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback);
+ },
+ /**
+ * displays confirmation dialog
+ * @param text content of dialog
+ * @param title dialog title
+ * @param callback which will be triggered when user press YES or NO (true or false would be passed to callback respectively)
+ */
+ confirm:function(text, title, callback) {
+ var content = '
'+text+'
';
+ OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTON, callback);
+ },
+ /**
+ * prompt for user input
+ * @param text content of dialog
+ * @param title dialog title
+ * @param callback which will be triggered when user press OK (input text will be passed to callback)
+ */
+ prompt:function(text, title, callback) {
+ var content = '
'+text+':
';
+ OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback);
+ },
+ /**
+ * prompt user for input with custom form
+ * fields should be passed in following format: [{text:'prompt text', name:'return name', type:'input type'},...]
+ * @param fields to display
+ * @param title dialog title
+ * @param callback which will be triggered when user press OK (user answers will be passed to callback in following format: [{name:'return name', value: 'user value'},...])
+ */
+ form:function(fields, title, callback) {
+ var content = '
';
+ for (var a in fields) {
+ content += '
'+fields[a].text+'
';
+ var type=fields[a].type;
+ if (type == 'text' || type == 'checkbox' || type == 'password')
+ content += '';
+ content += "
"
+ }
+ content += "
";
+ OCdialogs.message(content, title, OCdialogs.FORM_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback);
+ },
+ message:function(content, title, dialog_type, buttons, callback) {
+ var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content';
+ var c_id = '#'+c_name;
+ var d = '