/**
* ownCloud
*
* @author Bartek Przybylski
* @copyright 2012 Bartek Przybylski bartek@alefzero.eu
*
* 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 .
*
*/
/**
* this class to ease the usage of jquery dialogs
*/
var OCdialogs = {
/**
* displays alert dialog
* @param text content of dialog
* @param title dialog title
* @param callback which will be triggered when user presses OK
* @param modal make the dialog modal
*/
alert:function(text, title, callback, modal) {
var content = '
' + escapeHTML(text) + '
';
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
},
/**
* displays info dialog
* @param text content of dialog
* @param title dialog title
* @param callback which will be triggered when user presses OK
* @param modal make the dialog modal
*/
info:function(text, title, callback, modal) {
var content = '
' + escapeHTML(text) + '
';
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
},
/**
* displays confirmation 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
*/
confirm:function(text, title, callback, modal) {
var content = '
' + escapeHTML(text) + '
';
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTONS, callback, modal);
},
/**
* prompt for user input
* @param text content of dialog
* @param title dialog title
* @param callback which will be triggered when user presses OK (input text will be passed to callback)
* @param modal make the dialog modal
*/
prompt:function(text, title, default_value, callback, modal) {
var input = '';
var content = '
' + escapeHTML(text) + ': ' + input + '
';
OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
},
/**
* prompt user for input with custom form
* fields should be passed in following format: [{text:'prompt text', name:'return name', type:'input type', value: 'default value'},...]
* example:
* var fields=[{text:'Test', name:'test', type:'select', options:[{text:'hello1',value:1},{text:'hello2',value:2}] }];
* @param fields to display
* @param title dialog title
* @param callback which will be triggered when user presses OK (user answers will be passed to callback in following format: [{name:'return name', value: 'user value'},...])
* @param modal make the dialog modal
*/
form:function(fields, title, callback, modal) {
var content = '