diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index 4240b75c6f..0fa41696a1 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -20,226 +20,245 @@
*/
/**
- * this class ease usage of jquery dialogs
+ * this class to ease the 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, modal) {
- var content = '
'+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 press OK
- */
- info:function(text, title, callback, modal) {
- var content = '
'+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 press YES or NO (true or false would be passed to callback respectively)
- */
- confirm:function(text, title, callback, modal) {
- var content = '
'+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 press OK (input text will be passed to callback)
- */
- prompt:function(text, title, default_value, callback, modal) {
- var content = '
'+text+':
';
- OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, 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: 'dafault value'},...]
- * @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, modal) {
- var content = '
';
- for (var a in fields) {
- content += '
'+fields[a].text+'
';
- var type=fields[a].type;
- if (type == 'text' || type == 'checkbox' || type == 'password') {
- content += '';
- } else content += '>';
- } else if (type == 'text' || type == 'password' && fields[a].value)
- content += ' value="'+fields[a].value+'">';
- } else if (type == 'select') {
- content += '';
- }
- content += '
';
- }
- content += '
';
- OCdialogs.message(content, title, OCdialogs.FORM_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback, modal);
- },
- filepicker:function(title, callback, multiselect, mimetype_filter, modal) {
- var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content';
- var c_id = '#'+c_name;
- var d = '
';
- if (!modal) modal = false;
- if (!multiselect) multiselect = false;
- $('body').append(d);
- $(c_id + ' #dirtree').focus(function() { var t = $(this); t.data('oldval', t.val())})
- .change({dcid: c_id}, OC.dialogs.handleTreeListSelect);
- $(c_id).ready(function(){
- $.getJSON(OC.filePath('files', 'ajax', 'rawlist.php'), {mimetype: mimetype_filter} ,function(r){OC.dialogs.fillFilePicker(r, c_id, callback)});
- }).data('multiselect', multiselect).data('mimetype',mimetype_filter);
- // build buttons
- var b = [
- {text: t('dialogs', 'Choose'), click: function(){
- if (callback != undefined) {
- var p;
- if ($(c_id).data('multiselect') == true) {
- p = [];
- $(c_id+' .filepicker_element_selected #filename').each(function(i, elem) {
- p.push(($(c_id).data('path')?$(c_id).data('path'):'')+'/'+$(elem).text());
- });
- } else {
- var p = $(c_id).data('path');
- if (p == undefined) p = '';
- p = p+'/'+$(c_id+' .filepicker_element_selected #filename').text()
- }
- callback(p);
- $(c_id).dialog('close');
- }
- }
- },
- {text: t('dialogs', 'Cancel'), click: function(){$(c_id).dialog('close'); }}
- ];
- $(c_id).dialog({width: ((4*$('body').width())/9), height: 400, modal: modal, buttons: b});
- OCdialogs.dialogs_counter++;
- },
- // guts, dont use, dont touch
- message:function(content, title, dialog_type, buttons, callback, modal) {
- var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content';
- var c_id = '#'+c_name;
- var d = '
';
- var names = '';
- for (var a in r.data) {
- names += entry_template.replace('*LASTMODDATE*', OC.mtime2date(r.data[a].mtime)).replace('*NAME*', r.data[a].name).replace('*MIMETYPEICON*', r.data[a].mimetype_icon).replace('*ENTRYNAME*', r.data[a].name).replace('*ENTRYTYPE*', r.data[a].type);
- }
- $(dialog_content_id + ' #filelist').html(names);
- $(dialog_content_id + ' .filepicker_loader').css('visibility', 'hidden');
- },
- handleTreeListSelect:function(event) {
- var newval = parseInt($(this).val());
- var oldval = parseInt($(this).data('oldval'));
- while (newval != oldval && oldval > 0) {
- $('option:last', this).remove();
- $('option:last', this).attr('selected','selected');
- oldval--;
- }
- var skip_first = true;
- var path = '';
- $(this).children().each(function(i, element) { if (skip_first) {skip_first = false; return; }path += '/'+$(element).text(); });
- $(event.data.dcid).data('path', path);
- $(event.data.dcid + ' .filepicker_loader').css('visibility', 'visible');
- $.getJSON(OC.filePath('files', 'ajax', 'rawlist.php'), {dir: path, mimetype: $(event.data.dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, event.data.dcid)});
- },
- // this function is in early development state, please dont use it unlsess you know what you are doing
- handlePickerClick:function(element, name, dcid) {
- var p = $(dcid).data('path');
- if (p == undefined) p = '';
- p = p+'/'+name;
- if ($(element).attr('data') == 'file'){
- if ($(dcid).data('multiselect') != true)
- $(dcid+' .filepicker_element_selected').removeClass('filepicker_element_selected');
- $(element).toggleClass('filepicker_element_selected');
- return;
- }
- $(dcid).data('path', p);
- $(dcid + ' #dirtree option:last').removeAttr('selected');
- var newval = parseInt($(dcid + ' #dirtree option:last').val())+1;
- $(dcid + ' #dirtree').append('');
- $(dcid + ' .filepicker_loader').css('visibility', 'visible');
- $.getJSON(OC.filePath('files', 'ajax', 'rawlist.php'), {dir: p, mimetype: $(dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, dcid)});
- }
+ /**
+ * 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, modal) {
+ var content = '
'+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 press OK
+ */
+ info:function(text, title, callback, modal) {
+ var content = '
'+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 press YES or NO (true or false would be passed to callback respectively)
+ */
+ confirm:function(text, title, callback, modal) {
+ var content = '
'+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 press OK (input text will be passed to callback)
+ */
+ prompt:function(text, title, default_value, callback, modal) {
+ var content = '
'+text+':
';
+ OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, 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: 'dafault value'},...]
+ * @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, modal) {
+ var content = '