2012-02-28 22:02:02 +00:00
|
|
|
/**
|
|
|
|
* ownCloud
|
|
|
|
*
|
|
|
|
* @author Bartek Przybylski
|
2012-03-24 17:35:16 +00:00
|
|
|
* @copyright 2012 Bartek Przybylski bartek@alefzero.eu
|
2012-02-28 22:02:02 +00:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2012-05-05 11:48:12 +00:00
|
|
|
* this class to ease the usage of jquery dialogs
|
2012-02-28 22:02:02 +00:00
|
|
|
*/
|
2012-09-05 20:22:04 +00:00
|
|
|
var OCdialogs = {
|
2012-05-05 11:48:12 +00:00
|
|
|
/**
|
|
|
|
* displays alert dialog
|
|
|
|
* @param text content of dialog
|
|
|
|
* @param title dialog title
|
2013-04-06 08:07:12 +00:00
|
|
|
* @param callback which will be triggered when user presses OK
|
|
|
|
* @param modal make the dialog modal
|
2012-05-05 11:48:12 +00:00
|
|
|
*/
|
|
|
|
alert:function(text, title, callback, modal) {
|
2013-04-06 10:16:55 +00:00
|
|
|
var content = '<p><span class="ui-icon ui-icon-alert"></span>' + escapeHTML(text) + '</p>';
|
2012-05-05 11:48:12 +00:00
|
|
|
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* displays info dialog
|
|
|
|
* @param text content of dialog
|
|
|
|
* @param title dialog title
|
2013-04-06 08:07:12 +00:00
|
|
|
* @param callback which will be triggered when user presses OK
|
|
|
|
* @param modal make the dialog modal
|
2012-05-05 11:48:12 +00:00
|
|
|
*/
|
|
|
|
info:function(text, title, callback, modal) {
|
2013-04-06 10:16:55 +00:00
|
|
|
var content = '<p><span class="ui-icon ui-icon-info"></span>' + escapeHTML(text) + '</p>';
|
2012-05-05 11:48:12 +00:00
|
|
|
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* displays confirmation dialog
|
|
|
|
* @param text content of dialog
|
|
|
|
* @param title dialog title
|
2013-04-06 08:07:12 +00:00
|
|
|
* @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
|
2012-05-05 11:48:12 +00:00
|
|
|
*/
|
|
|
|
confirm:function(text, title, callback, modal) {
|
2013-04-06 10:16:55 +00:00
|
|
|
var content = '<p><span class="ui-icon ui-icon-notice"></span>' + escapeHTML(text) + '</p>';
|
2012-05-05 11:48:12 +00:00
|
|
|
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
|
2013-04-06 08:07:12 +00:00
|
|
|
* @param callback which will be triggered when user presses OK (input text will be passed to callback)
|
|
|
|
* @param modal make the dialog modal
|
2012-05-05 11:48:12 +00:00
|
|
|
*/
|
|
|
|
prompt:function(text, title, default_value, callback, modal) {
|
2013-04-06 10:16:55 +00:00
|
|
|
var content = '<p><span class="ui-icon ui-icon-pencil"></span>' + escapeHTML(text) + ':<br/><input type="text" id="oc-dialog-prompt-input" value="' + escapeHTML(default_value) + '" style="width:90%"></p>';
|
2013-04-06 08:07:12 +00:00
|
|
|
OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
|
2012-05-05 11:48:12 +00:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* prompt user for input with custom form
|
2013-04-06 08:07:12 +00:00
|
|
|
* 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}] }];
|
2012-05-05 11:48:12 +00:00
|
|
|
* @param fields to display
|
|
|
|
* @param title dialog title
|
2013-04-06 08:07:12 +00:00
|
|
|
* @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
|
2012-05-05 11:48:12 +00:00
|
|
|
*/
|
|
|
|
form:function(fields, title, callback, modal) {
|
|
|
|
var content = '<table>';
|
2013-04-06 08:07:12 +00:00
|
|
|
$.each(fields, function(index, field){
|
2013-04-06 10:16:55 +00:00
|
|
|
content += '<tr><td>' + escapeHTML(field.text) + '</td><td>';
|
2013-04-06 08:07:12 +00:00
|
|
|
var type = field.type;
|
2012-10-26 18:34:04 +00:00
|
|
|
|
2013-04-06 08:07:12 +00:00
|
|
|
if (type === 'text' || type === 'checkbox' || type === 'password') {
|
|
|
|
content += '<input type="' + type + '" name="' + field.name + '"';
|
|
|
|
if (type === 'checkbox' && field.value === true) {
|
|
|
|
content += ' checked="checked"';
|
|
|
|
} else if (type === 'text' || type === 'password' && val.value) {
|
2013-04-06 10:16:55 +00:00
|
|
|
content += ' value="' + escapeHTML(field.value) + '"';
|
2012-05-05 11:48:12 +00:00
|
|
|
}
|
2013-04-06 08:07:12 +00:00
|
|
|
content += '>';
|
|
|
|
} else if (type === 'select') {
|
2013-04-06 10:16:55 +00:00
|
|
|
content += '<select name="' + escapeHTML(field.name) + '"';
|
2013-04-06 08:07:12 +00:00
|
|
|
if (field.value !== undefined) {
|
2013-04-06 10:16:55 +00:00
|
|
|
content += ' value="' + escapeHTML(field.value) + '"';
|
2012-05-05 11:48:12 +00:00
|
|
|
}
|
|
|
|
content += '>';
|
2013-04-06 08:07:12 +00:00
|
|
|
$.each(field.options, function(index, field_option){
|
2013-04-06 10:16:55 +00:00
|
|
|
content += '<option value="' + escapeHTML(field_option.value) + '">' + escapeHTML(field_option.text) + '</option>';
|
2012-10-26 18:34:04 +00:00
|
|
|
});
|
2012-05-05 11:48:12 +00:00
|
|
|
content += '</select>';
|
|
|
|
}
|
|
|
|
content += '</td></tr>';
|
2012-10-26 18:34:04 +00:00
|
|
|
|
|
|
|
});
|
2012-05-05 11:48:12 +00:00
|
|
|
content += '</table>';
|
2013-04-06 08:07:12 +00:00
|
|
|
|
|
|
|
var dialog_name = 'oc-dialog-' + OCdialogs.dialogs_counter + '-content';
|
|
|
|
var dialog_id = '#' + dialog_name;
|
2013-04-06 10:16:55 +00:00
|
|
|
var dialog_div = '<div id="' + dialog_name + '" title="' + escapeHTML(title) + '">' + escapeHTML(content) + '</div>';
|
|
|
|
if (modal === undefined) { modal = false };
|
2013-04-06 08:07:12 +00:00
|
|
|
$('body').append(dialog_div);
|
|
|
|
var buttonlist = [{
|
|
|
|
text: t('core', 'Ok'),
|
|
|
|
click: function(){ OCdialogs.form_ok_handler(callback, dialog_id); }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: t('core', 'Cancel'),
|
|
|
|
click: function(){ $(dialog_id).dialog('close'); }
|
|
|
|
}];
|
|
|
|
var dialog_height = ( $('tr', dialog_div).length + 1 ) * 30 + 120;
|
|
|
|
$(dialog_id).dialog({
|
|
|
|
width: (4/9) * $(document).width(),
|
|
|
|
height: dialog_height,
|
|
|
|
modal: modal,
|
|
|
|
buttons: buttonlist
|
|
|
|
});
|
|
|
|
OCdialogs.dialogs_counter++;
|
2012-05-05 11:48:12 +00:00
|
|
|
},
|
2013-04-06 08:07:12 +00:00
|
|
|
/**
|
|
|
|
* show a file picker to pick a file from
|
|
|
|
* @param title dialog title
|
|
|
|
* @param callback which will be triggered when user presses Choose
|
|
|
|
* @param multiselect whether it should be possible to select multiple files
|
|
|
|
* @param mimetype_filter mimetype to filter by
|
|
|
|
* @param modal make the dialog modal
|
|
|
|
*/
|
2012-05-05 11:48:12 +00:00
|
|
|
filepicker:function(title, callback, multiselect, mimetype_filter, modal) {
|
2013-04-06 08:07:12 +00:00
|
|
|
var dialog_name = 'oc-dialog-' + OCdialogs.dialogs_counter + '-content';
|
|
|
|
var dialog_id = '#' + dialog_name;
|
2013-04-06 10:16:55 +00:00
|
|
|
var dialog_div = '<div id="' + dialog_name + '" title="' + escapeHTML(title) + '"><button id="dirup">↑</button><select id="dirtree"></select><div id="filelist"></div><div class="filepicker_loader"><img src="' + OC.filePath('gallery','img','loading.gif') + '"></div></div>';
|
|
|
|
if (modal === undefined) { modal = false };
|
|
|
|
if (multiselect === undefined) { multiselect = false };
|
|
|
|
if (mimetype_filter === undefined) { mimetype_filter = '' };
|
2013-04-06 08:07:12 +00:00
|
|
|
|
|
|
|
$('body').append(dialog_div);
|
|
|
|
|
|
|
|
$(dialog_id).data('path', '/');
|
|
|
|
|
|
|
|
$(dialog_id + ' #dirtree').focus().change( {dcid: dialog_id}, OCdialogs.handleTreeListSelect );
|
|
|
|
$(dialog_id + ' #dirup').click( {dcid: dialog_id}, OCdialogs.filepickerDirUp );
|
|
|
|
|
|
|
|
$(dialog_id).ready(function(){
|
|
|
|
$.getJSON(OC.filePath('files', 'ajax', 'rawlist.php'), { mimetype: mimetype_filter } ,function(request) {
|
2013-04-06 10:16:55 +00:00
|
|
|
OCdialogs.fillFilePicker(request, dialog_id);
|
2013-04-06 08:07:12 +00:00
|
|
|
});
|
|
|
|
$.getJSON(OC.filePath('files', 'ajax', 'rawlist.php'), { mimetype: "httpd/unix-directory" }, function(request) {
|
2013-04-06 10:16:55 +00:00
|
|
|
OCdialogs.fillTreeList(request, dialog_id);
|
2012-05-05 11:48:12 +00:00
|
|
|
});
|
|
|
|
}).data('multiselect', multiselect).data('mimetype',mimetype_filter);
|
2013-04-06 08:07:12 +00:00
|
|
|
|
2012-05-05 11:48:12 +00:00
|
|
|
// build buttons
|
2013-04-06 10:16:55 +00:00
|
|
|
var functionToCall = function() {
|
2013-04-06 08:07:12 +00:00
|
|
|
if (callback !== undefined) {
|
|
|
|
var datapath;
|
|
|
|
if (multiselect === true) {
|
|
|
|
datapath = [];
|
|
|
|
$(dialog_id + ' .filepicker_element_selected .filename').each(function(index, element) {
|
|
|
|
datapath.push( $(dialog_id).data('path') + $(elem).text() );
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
var datapath = $(dialog_id).data('path');
|
2013-04-06 10:16:55 +00:00
|
|
|
datapath += $(dialog_id+' .filepicker_element_selected .filename').text();
|
2012-05-05 11:48:12 +00:00
|
|
|
}
|
2013-04-06 08:07:12 +00:00
|
|
|
callback(datapath);
|
|
|
|
$(dialog_id).dialog('close');
|
2012-05-05 11:48:12 +00:00
|
|
|
}
|
2013-04-06 08:07:12 +00:00
|
|
|
};
|
|
|
|
var buttonlist = [{
|
|
|
|
text: t('core', 'Choose'),
|
2013-04-06 10:16:55 +00:00
|
|
|
click: functionToCall
|
2013-04-06 08:07:12 +00:00
|
|
|
},
|
|
|
|
{
|
2012-09-21 09:48:57 +00:00
|
|
|
text: t('core', 'Cancel'),
|
2013-04-06 08:07:12 +00:00
|
|
|
click: function(){$(dialog_id).dialog('close'); }
|
|
|
|
}];
|
|
|
|
|
|
|
|
$(dialog_id).dialog({
|
|
|
|
width: (4/9)*$(document).width(),
|
|
|
|
height: 420,
|
|
|
|
modal: modal,
|
|
|
|
buttons: buttonlist
|
|
|
|
});
|
2012-05-05 11:48:12 +00:00
|
|
|
OCdialogs.dialogs_counter++;
|
|
|
|
},
|
2013-04-06 08:07:12 +00:00
|
|
|
/**
|
|
|
|
* Displays raw dialog
|
|
|
|
* You better use a wrapper instead ...
|
|
|
|
*/
|
2012-05-05 11:48:12 +00:00
|
|
|
message:function(content, title, dialog_type, buttons, callback, modal) {
|
2013-04-06 08:07:12 +00:00
|
|
|
var dialog_name = 'oc-dialog-' + OCdialogs.dialogs_counter + '-content';
|
|
|
|
var dialog_id = '#' + dialog_name;
|
2013-04-06 10:16:55 +00:00
|
|
|
var dialog_div = '<div id="' + dialog_name + '" title="' + escapeHTML(title) + '">' + escapeHTML(content) + '</div>';
|
|
|
|
if (modal === undefined) { modal = false };
|
2013-04-06 08:07:12 +00:00
|
|
|
$('body').append(dialog_div);
|
|
|
|
var buttonlist = [];
|
2012-05-05 11:48:12 +00:00
|
|
|
switch (buttons) {
|
|
|
|
case OCdialogs.YES_NO_BUTTONS:
|
2013-04-06 08:07:12 +00:00
|
|
|
buttonlist = [{
|
|
|
|
text: t('core', 'Yes'),
|
|
|
|
click: function(){
|
2013-04-06 10:16:55 +00:00
|
|
|
if (callback !== undefined) { callback(true) };
|
2013-04-06 08:07:12 +00:00
|
|
|
$(dialog_id).dialog('close');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: t('core', 'No'),
|
|
|
|
click: function(){
|
2013-04-06 10:16:55 +00:00
|
|
|
if (callback !== undefined) { callback(false) };
|
2013-04-06 08:07:12 +00:00
|
|
|
$(dialog_id).dialog('close');
|
|
|
|
}
|
|
|
|
}];
|
2012-05-05 11:48:12 +00:00
|
|
|
break;
|
2013-04-06 08:07:12 +00:00
|
|
|
case OCdialogs.OK_BUTTON:
|
2013-04-06 10:16:55 +00:00
|
|
|
var functionToCall;
|
2012-05-05 11:48:12 +00:00
|
|
|
switch(dialog_type) {
|
|
|
|
case OCdialogs.ALERT_DIALOG:
|
2013-04-06 10:16:55 +00:00
|
|
|
functionToCall = function() {
|
2013-04-06 08:07:12 +00:00
|
|
|
$(dialog_id).dialog('close');
|
2013-04-06 10:16:55 +00:00
|
|
|
if(callback !== undefined) { callback() };
|
2013-04-06 08:07:12 +00:00
|
|
|
};
|
2012-05-05 11:48:12 +00:00
|
|
|
break;
|
|
|
|
case OCdialogs.PROMPT_DIALOG:
|
2013-04-06 08:07:12 +00:00
|
|
|
buttonlist[1] = {
|
|
|
|
text: t('core', 'Cancel'),
|
|
|
|
click: function() { $(dialog_id).dialog('close'); }
|
|
|
|
};
|
2013-04-06 10:16:55 +00:00
|
|
|
functionToCall = function() { OCdialogs.prompt_ok_handler(callback, dialog_id); };
|
2012-05-05 11:48:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-04-06 08:07:12 +00:00
|
|
|
buttonlist[0] = {
|
|
|
|
text: t('core', 'Ok'),
|
2013-04-06 10:16:55 +00:00
|
|
|
click: functionToCall
|
2013-04-06 08:07:12 +00:00
|
|
|
};
|
2012-05-05 11:48:12 +00:00
|
|
|
break;
|
2013-04-06 08:07:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$(dialog_id).dialog({
|
|
|
|
width: (4/9) * $(document).width(),
|
|
|
|
height: 180,
|
|
|
|
modal: modal,
|
|
|
|
buttons: buttonlist
|
|
|
|
});
|
2012-05-05 11:48:12 +00:00
|
|
|
OCdialogs.dialogs_counter++;
|
|
|
|
},
|
2013-04-06 08:07:12 +00:00
|
|
|
// dialog button types
|
|
|
|
YES_NO_BUTTONS: 70,
|
|
|
|
OK_BUTTONS: 71,
|
2012-05-05 11:48:12 +00:00
|
|
|
// dialogs types
|
2013-04-06 08:07:12 +00:00
|
|
|
ALERT_DIALOG: 80,
|
|
|
|
INFO_DIALOG: 81,
|
|
|
|
FORM_DIALOG: 82,
|
|
|
|
// used to name each dialog
|
2012-05-05 11:48:12 +00:00
|
|
|
dialogs_counter: 0,
|
2013-04-06 08:07:12 +00:00
|
|
|
|
2012-05-05 11:48:12 +00:00
|
|
|
determineValue: function(element) {
|
2013-04-06 08:07:12 +00:00
|
|
|
if ( $(element).attr('type') === 'checkbox' ) {
|
|
|
|
return element.checked;
|
|
|
|
} else {
|
|
|
|
return $(element).val();
|
2012-05-05 11:48:12 +00:00
|
|
|
}
|
|
|
|
},
|
2013-04-06 08:07:12 +00:00
|
|
|
|
|
|
|
prompt_ok_handler: function(callback, dialog_id) {
|
|
|
|
$(dialog_id).dialog('close');
|
2013-04-06 10:16:55 +00:00
|
|
|
if (callback !== undefined) { callback($(dialog_id + " input#oc-dialog-prompt-input").val()) };
|
2013-04-06 08:07:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
form_ok_handler: function(callback, dialog_id) {
|
|
|
|
if (callback !== undefined) {
|
|
|
|
var valuelist = [];
|
|
|
|
$(dialog_id + ' input, ' + dialog_id + ' select').each(function(index, element) {
|
|
|
|
valuelist[index] = { name: $(elem).attr('name'), value: OCdialogs.determineValue(elem) };
|
2012-05-05 11:48:12 +00:00
|
|
|
});
|
2013-04-06 08:07:12 +00:00
|
|
|
$(dialog_id).dialog('close');
|
|
|
|
callback(valuelist);
|
2012-05-05 11:48:12 +00:00
|
|
|
} else {
|
2013-04-06 08:07:12 +00:00
|
|
|
$(dialog_id).dialog('close');
|
2012-05-05 11:48:12 +00:00
|
|
|
}
|
|
|
|
},
|
2013-04-06 08:07:12 +00:00
|
|
|
/**
|
|
|
|
* fills the filepicker with files
|
|
|
|
*/
|
|
|
|
fillFilePicker:function(request, dialog_content_id) {
|
2013-04-06 10:16:55 +00:00
|
|
|
var template = '<div data-entryname="*ENTRYNAME*" data-dcid="' + escapeHTML(dialog_content_id) + '" data="*ENTRYTYPE*"><img src="*MIMETYPEICON*" style="margin: 2px 1em 0 4px;"><span class="filename">*NAME*</span><div style="float:right;margin-right:1em;">*LASTMODDATE*</div></div>';
|
2013-04-06 08:07:12 +00:00
|
|
|
var files = '';
|
|
|
|
$.each(request.data, function(index, file) {
|
2013-04-06 10:16:55 +00:00
|
|
|
files += template.replace('*LASTMODDATE*', OC.mtime2date(file.mtime)).replace('*NAME*', escapeHTML(file.name)).replace('*MIMETYPEICON*', file.mimetype_icon).replace('*ENTRYNAME*', escapeHTML(file.name)).replace('*ENTRYTYPE*', escapeHTML(file.type));
|
2012-10-26 18:34:04 +00:00
|
|
|
});
|
|
|
|
|
2013-04-06 08:07:12 +00:00
|
|
|
$(dialog_content_id + ' #filelist').html(files).on('click', '[data="file"]', function() {
|
|
|
|
OCdialogs.handlePickerClick(this, $(this).data('entryname'), $(this).data('dcid'));
|
2013-03-04 15:36:49 +00:00
|
|
|
});
|
2013-04-06 12:17:47 +00:00
|
|
|
$(dialog_content_id + ' #filelist').html(files).on('click', '[data="dir"]', function() {
|
|
|
|
OCdialogs.handlePickerClick(this, $(this).data('entryname'), $(this).data('dcid'));
|
|
|
|
});
|
2012-05-05 11:48:12 +00:00
|
|
|
$(dialog_content_id + ' .filepicker_loader').css('visibility', 'hidden');
|
|
|
|
},
|
2013-04-06 08:07:12 +00:00
|
|
|
/**
|
|
|
|
* fills the tree list with directories
|
|
|
|
*/
|
|
|
|
fillTreeList: function(request, dialog_id) {
|
|
|
|
var template = '<option value="*COUNT*">*NAME*</option>';
|
2013-04-06 10:16:55 +00:00
|
|
|
var paths = '<option value="0">' + escapeHTML($(dialog_id).data('path')) + '</option>';
|
2013-04-06 08:07:12 +00:00
|
|
|
var count = 1;
|
|
|
|
$.each(request.data, function(index, file) {
|
|
|
|
if (file.mimetype === "httpd/unix-directory") {
|
2013-04-06 10:16:55 +00:00
|
|
|
paths += template.replace('*COUNT*', count).replace('*NAME*', escapeHTML(file.name));
|
2013-04-06 08:07:12 +00:00
|
|
|
count++;
|
2012-05-05 11:48:12 +00:00
|
|
|
}
|
|
|
|
});
|
2013-04-06 08:07:12 +00:00
|
|
|
|
|
|
|
$(dialog_id + ' #dirtree').html(paths);
|
|
|
|
},
|
|
|
|
|
|
|
|
handleTreeListSelect:function(event) {
|
|
|
|
// fails at paths with &
|
|
|
|
if ($("option:selected", this).html().indexOf('/') !== -1) { // if there's a slash in the selected path, don't append it
|
|
|
|
$(event.data.dcid).data('path', $("option:selected", this).html());
|
|
|
|
} else {
|
|
|
|
$(event.data.dcid).data('path', $(event.data.dcid).data('path') + $("option:selected", this).html() + '/');
|
|
|
|
}
|
2012-05-05 11:48:12 +00:00
|
|
|
$(event.data.dcid + ' .filepicker_loader').css('visibility', 'visible');
|
2013-04-06 08:07:12 +00:00
|
|
|
$.getJSON(
|
|
|
|
OC.filePath('files', 'ajax', 'rawlist.php'),
|
|
|
|
{
|
|
|
|
dir: $(event.data.dcid).data('path'),
|
|
|
|
mimetype: $(event.data.dcid).data('mimetype')
|
|
|
|
},
|
|
|
|
function(request) { OCdialogs.fillFilePicker(request, event.data.dcid) }
|
|
|
|
);
|
|
|
|
$.getJSON(
|
|
|
|
OC.filePath('files', 'ajax', 'rawlist.php'),
|
|
|
|
{
|
|
|
|
dir: $(event.data.dcid).data('path'),
|
|
|
|
mimetype: "httpd/unix-directory"
|
|
|
|
},
|
|
|
|
function(request) { OCdialogs.fillTreeList(request, event.data.dcid) }
|
|
|
|
);
|
|
|
|
},
|
|
|
|
// go one directory up
|
|
|
|
filepickerDirUp:function(event) {
|
|
|
|
var old_path = $(event.data.dcid).data('path');
|
|
|
|
if ( old_path !== "/") {
|
|
|
|
var splitted_path = old_path.split("/");
|
|
|
|
var new_path = ""
|
|
|
|
for (var i = 0; i < splitted_path.length - 2; i++) {
|
|
|
|
new_path += splitted_path[i] + "/"
|
|
|
|
}
|
|
|
|
$(event.data.dcid).data('path', new_path);
|
|
|
|
$.getJSON(
|
|
|
|
OC.filePath('files', 'ajax', 'rawlist.php'),
|
|
|
|
{
|
|
|
|
dir: $(event.data.dcid).data('path'),
|
|
|
|
mimetype: $(event.data.dcid).data('mimetype')
|
|
|
|
},
|
|
|
|
function(request) { OCdialogs.fillFilePicker(request, event.data.dcid) }
|
|
|
|
);
|
|
|
|
$.getJSON(
|
|
|
|
OC.filePath('files', 'ajax', 'rawlist.php'),
|
|
|
|
{
|
|
|
|
dir: $(event.data.dcid).data('path'),
|
|
|
|
mimetype: "httpd/unix-directory"
|
|
|
|
},
|
|
|
|
function(request) { OCdialogs.fillTreeList(request, event.data.dcid) }
|
|
|
|
);
|
|
|
|
}
|
2012-05-05 11:48:12 +00:00
|
|
|
},
|
2013-04-06 08:07:12 +00:00
|
|
|
// this function is in early development state, please dont use it unless you know what you are doing
|
|
|
|
handlePickerClick:function(element, name, dialog_content_id) {
|
|
|
|
var datapath = $(dialog_content_id).data('path');
|
2013-04-06 10:16:55 +00:00
|
|
|
if (datapath === undefined) { datapath = '' };
|
2013-04-06 08:07:12 +00:00
|
|
|
datapath += name;
|
|
|
|
if ( $(element).attr('data') === 'file' ){
|
|
|
|
if ( $(dialog_content_id).data('multiselect') !== true) {
|
|
|
|
$(dialog_content_id + ' .filepicker_element_selected').removeClass('filepicker_element_selected');
|
2012-05-05 11:48:12 +00:00
|
|
|
}
|
|
|
|
$(element).toggleClass('filepicker_element_selected');
|
|
|
|
return;
|
2013-04-06 12:17:47 +00:00
|
|
|
} else if ( $(element).attr('data') === 'dir' ) {
|
|
|
|
datapath += '/';
|
|
|
|
$(dialog_content_id).data('path', datapath);
|
|
|
|
$(dialog_content_id + ' .filepicker_loader').css('visibility', 'visible');
|
|
|
|
$.getJSON(
|
|
|
|
OC.filePath('files', 'ajax', 'rawlist.php'),
|
|
|
|
{
|
|
|
|
dir: datapath,
|
|
|
|
mimetype: $(dialog_content_id).data('mimetype')
|
|
|
|
},
|
|
|
|
function(request){ OCdialogs.fillFilePicker(request, dialog_content_id) }
|
|
|
|
);
|
|
|
|
$.getJSON(
|
|
|
|
OC.filePath('files', 'ajax', 'rawlist.php'),
|
|
|
|
{
|
|
|
|
dir: datapath,
|
|
|
|
mimetype: "httpd/unix-directory"
|
|
|
|
},
|
|
|
|
function(request) { OCdialogs.fillTreeList(request, dialog_content_id) }
|
|
|
|
);
|
2012-05-05 11:48:12 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-28 22:02:02 +00:00
|
|
|
};
|