/** * ownCloud * * @author Bartek Przybylski, Christopher Schäpers, Thomas Tanghus * @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 . * */ /* global alert */ /** * this class to ease the usage of jquery dialogs * @lends OC.dialogs */ var OCdialogs = { // dialog button types YES_NO_BUTTONS: 70, OK_BUTTONS: 71, FILEPICKER_TYPE_CHOOSE: 1, FILEPICKER_TYPE_MOVE: 2, FILEPICKER_TYPE_COPY: 3, FILEPICKER_TYPE_COPY_MOVE: 4, // used to name each dialog dialogsCounter: 0, /** * 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) { this.message( text, title, 'alert', 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) { this.message(text, title, 'info', 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) { return this.message( text, title, 'notice', OCdialogs.YES_NO_BUTTONS, 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 */ confirmHtml:function(text, title, callback, modal) { return this.message( text, title, 'notice', OCdialogs.YES_NO_BUTTONS, callback, modal, true ); }, /** * 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) { return $.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.attr('type', password ? 'password' : 'text').attr('id', dialogName + '-input').attr('placeholder', name); var label = $('