Merge pull request #2758 from Kondou-ger/refactor_OCdialogs

Refactor OCdialogs.
This commit is contained in:
Bart Visscher 2013-04-09 13:24:04 -07:00
commit 51e07a90b7
2 changed files with 324 additions and 166 deletions

View File

@ -345,11 +345,13 @@ a.bookmarklet { background-color:#ddd; border:1px solid #ccc; padding:5px;paddin
.ui-datepicker-prev,.ui-datepicker-next{ border:1px solid #ddd; background:#ffffff; } .ui-datepicker-prev,.ui-datepicker-next{ border:1px solid #ddd; background:#ffffff; }
/* ---- DIALOGS ---- */ /* ---- DIALOGS ---- */
#dirtree {width:100%;} #dirup {width:4%;}
#filelist {height:270px; overflow:scroll; background-color:white; width:100%;} #dirtree {width:92%;}
#filelist {height:270px; overflow-y:auto; background-color:white; width:100%;}
.filepicker_element_selected { background-color:lightblue;} .filepicker_element_selected { background-color:lightblue;}
.filepicker_loader {height:120px; width:100%; background-color:#333; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"; filter:alpha(opacity=30); opacity:.3; visibility:visible; position:absolute; top:0; left:0; text-align:center; padding-top:150px;} .filepicker_loader {height:170px; width:100%; background-color:#333; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"; filter:alpha(opacity=30); opacity:.3; visibility:visible; position:absolute; top:0; left:0; text-align:center; padding-top:150px;}
.ui-dialog {position:fixed !important;}
span.ui-icon {float: left; margin: 3px 7px 30px 0;}
/* ---- CATEGORIES ---- */ /* ---- CATEGORIES ---- */
#categoryform .scrollarea { position:absolute; left:10px; top:10px; right:10px; bottom:50px; overflow:auto; border:1px solid #ddd; background:#f8f8f8; } #categoryform .scrollarea { position:absolute; left:10px; top:10px; right:10px; bottom:50px; overflow:auto; border:1px solid #ddd; background:#f8f8f8; }

View File

@ -27,75 +27,79 @@ var OCdialogs = {
* displays alert dialog * displays alert dialog
* @param text content of dialog * @param text content of dialog
* @param title dialog title * @param title dialog title
* @param callback which will be triggered when user press OK * @param callback which will be triggered when user presses OK
* @param modal make the dialog modal
*/ */
alert:function(text, title, callback, modal) { alert:function(text, title, callback, modal) {
var content = '<p><span class="ui-icon ui-icon-alert"></span>'+text+'</p>'; var content = '<p><span class="ui-icon ui-icon-alert"></span>' + escapeHTML(text) + '</p>';
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal); OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
}, },
/** /**
* displays info dialog * displays info dialog
* @param text content of dialog * @param text content of dialog
* @param title dialog title * @param title dialog title
* @param callback which will be triggered when user press OK * @param callback which will be triggered when user presses OK
* @param modal make the dialog modal
*/ */
info:function(text, title, callback, modal) { info:function(text, title, callback, modal) {
var content = '<p><span class="ui-icon ui-icon-info"></span>'+text+'</p>'; var content = '<p><span class="ui-icon ui-icon-info"></span>' + escapeHTML(text) + '</p>';
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal); OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
}, },
/** /**
* displays confirmation dialog * displays confirmation dialog
* @param text content of dialog * @param text content of dialog
* @param title dialog title * @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) * @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) { confirm:function(text, title, callback, modal) {
var content = '<p><span class="ui-icon ui-icon-notice"></span>'+text+'</p>'; var content = '<p><span class="ui-icon ui-icon-notice"></span>' + escapeHTML(text) + '</p>';
OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTONS, callback, modal); OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTONS, callback, modal);
}, },
/** /**
* prompt for user input * prompt for user input
* @param text content of dialog * @param text content of dialog
* @param title dialog title * @param title dialog title
* @param callback which will be triggered when user press OK (input text will be passed to callback) * @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) { prompt:function(text, title, default_value, callback, modal) {
var content = '<p><span class="ui-icon ui-icon-pencil"></span>'+text+':<br/><input type="text" id="oc-dialog-prompt-input" value="'+default_value+'" style="width:90%"></p>'; var input = '<input type="text" id="oc-dialog-prompt-input" value="' + escapeHTML(default_value) + '" style="width:90%">';
OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback, modal); var content = '<p><span class="ui-icon ui-icon-pencil"></span>' + escapeHTML(text) + ':<br/>' + input + '</p>';
OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_BUTTON, callback, modal);
}, },
/** /**
* prompt user for input with custom form * 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'},...] * fields should be passed in following format: [{text:'prompt text', name:'return name', type:'input type', value: 'default value'},...]
* select example var fields=[{text:'Test', name:'test', type:'select', options:[{text:'hallo',value:1},{text:'hallo1',value:2}] }]; * example:
* var fields=[{text:'Test', name:'test', type:'select', options:[{text:'hello1',value:1},{text:'hello2',value:2}] }];
* @param fields to display * @param fields to display
* @param title dialog title * @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'},...]) * @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) { form:function(fields, title, callback, modal) {
var content = '<table>'; var content = '<table>';
$.each(fields, function(index, val){ $.each(fields, function(index, field){
content += '<tr><td>'+val.text+'</td><td>'; content += '<tr><td>' + escapeHTML(field.text) + '</td><td>';
var type=val.type; var type = field.type;
if (type == 'text' || type == 'checkbox' || type == 'password') { if (type === 'text' || type === 'checkbox' || type === 'password') {
content += '<input type="'+type+'" name="'+val.name+'"'; content += '<input type="' + type + '" name="' + field.name + '"';
if (type == 'checkbox') { if (type === 'checkbox' && field.value === true) {
if (val.value != undefined && val.value == true) { content += ' checked="checked"';
content += ' checked="checked">'; } else if (type === 'text' || type === 'password' && val.value) {
} else { content += ' value="' + escapeHTML(field.value) + '"';
content += '>';
}
} else if (type == 'text' || type == 'password' && val.value) {
content += ' value="'+val.value+'">';
}
} else if (type == 'select') {
content += '<select name="'+val.name+'"';
if (val.value != undefined) {
content += ' value="'+val.value+'"';
} }
content += '>'; content += '>';
$.each(val.options, function(index, valo){ } else if (type === 'select') {
content += '<option value="'+valo.value+'">'+valo.text+'</option>'; content += '<select name="' + escapeHTML(field.name) + '"';
if (field.value !== undefined) {
content += ' value="' + escapeHTML(field.value) + '"';
}
content += '>';
$.each(field.options, function(index, field_option){
content += '<option value="' + escapeHTML(field_option.value) + '">' + escapeHTML(field_option.text) + '</option>';
}); });
content += '</select>'; content += '</select>';
} }
@ -103,168 +107,320 @@ var OCdialogs = {
}); });
content += '</table>'; content += '</table>';
OCdialogs.message(content, title, OCdialogs.FORM_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback, modal);
}, var dialog_name = 'oc-dialog-' + OCdialogs.dialogs_counter + '-content';
filepicker:function(title, callback, multiselect, mimetype_filter, modal) { var dialog_id = '#' + dialog_name;
var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content'; var dialog_div = '<div id="' + dialog_name + '" title="' + escapeHTML(title) + '">' + content + '</div>';
var c_id = '#'+c_name; if (modal === undefined) { modal = false };
var d = '<div id="'+c_name+'" title="'+title+'"><select id="dirtree"><option value="0">'+OC.currentUser+'</option></select><div id="filelist"></div><div class="filepicker_loader"><img src="'+OC.filePath('gallery','img','loading.gif')+'"></div></div>'; $('body').append(dialog_div);
if (!modal) modal = false; // Huh.. var buttonlist = [{
if (!multiselect) multiselect = false; text: t('core', 'Ok'),
$('body').append(d); click: function(){ OCdialogs.form_ok_handler(callback, dialog_id); }
$(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('core', '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('core', 'Cancel'), text: t('core', 'Cancel'),
click: function(){$(c_id).dialog('close'); }} click: function(){ $(dialog_id).dialog('close'); }
]; }];
$(c_id).dialog({width: ((4*$('body').width())/9), height: 400, modal: modal, buttons: b}); 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++; OCdialogs.dialogs_counter++;
}, },
// guts, dont use, dont touch /**
* 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
*/
filepicker:function(title, callback, multiselect, mimetype_filter, modal) {
var dialog_name = 'oc-dialog-' + OCdialogs.dialogs_counter + '-content';
var dialog_id = '#' + dialog_name;
var dialog_content = '<button id="dirup">↑</button><select id="dirtree"></select><div id="filelist"></div>';
var dialog_loader = '<div class="filepicker_loader"><img src="' + OC.filePath('gallery','img','loading.gif') + '"></div>';
var dialog_div = '<div id="' + dialog_name + '" title="' + escapeHTML(title) + '">' + dialog_content + dialog_loader + '</div>';
if (modal === undefined) { modal = false };
if (multiselect === undefined) { multiselect = false };
if (mimetype_filter === undefined) { mimetype_filter = '' };
$('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) {
OCdialogs.fillFilePicker(request, dialog_id);
});
$.getJSON(OC.filePath('files', 'ajax', 'rawlist.php'), { mimetype: "httpd/unix-directory" }, function(request) {
OCdialogs.fillTreeList(request, dialog_id);
});
}).data('multiselect', multiselect).data('mimetype',mimetype_filter);
// build buttons
var functionToCall = function() {
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') + $(element).text() );
});
} else {
var datapath = $(dialog_id).data('path');
datapath += $(dialog_id+' .filepicker_element_selected .filename').text();
}
callback(datapath);
$(dialog_id).dialog('close');
}
};
var buttonlist = [{
text: t('core', 'Choose'),
click: functionToCall
},
{
text: t('core', 'Cancel'),
click: function(){$(dialog_id).dialog('close'); }
}];
$(dialog_id).dialog({
width: (4/9)*$(document).width(),
height: 420,
modal: modal,
buttons: buttonlist
});
OCdialogs.dialogs_counter++;
},
/**
* Displays raw dialog
* You better use a wrapper instead ...
*/
message:function(content, title, dialog_type, buttons, callback, modal) { message:function(content, title, dialog_type, buttons, callback, modal) {
var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content'; var dialog_name = 'oc-dialog-' + OCdialogs.dialogs_counter + '-content';
var c_id = '#'+c_name; var dialog_id = '#' + dialog_name;
var d = '<div id="'+c_name+'" title="'+title+'">'+content+'</div>'; var dialog_div = '<div id="' + dialog_name + '" title="' + escapeHTML(title) + '">' + content + '</div>';
if (modal == undefined) modal = false; if (modal === undefined) { modal = false };
$('body').append(d); $('body').append(dialog_div);
var b = []; var buttonlist = [];
switch (buttons) { switch (buttons) {
case OCdialogs.YES_NO_BUTTONS: case OCdialogs.YES_NO_BUTTONS:
b[1] = {text: t('core', 'No'), click: function(){ if (callback != undefined) callback(false); $(c_id).dialog('close'); }}; buttonlist = [{
b[0] = {text: t('core', 'Yes'), click: function(){ if (callback != undefined) callback(true); $(c_id).dialog('close');}}; text: t('core', 'Yes'),
click: function(){
if (callback !== undefined) { callback(true) };
$(dialog_id).dialog('close');
}
},
{
text: t('core', 'No'),
click: function(){
if (callback !== undefined) { callback(false) };
$(dialog_id).dialog('close');
}
}];
break; break;
case OCdialogs.OK_CANCEL_BUTTONS: case OCdialogs.OK_BUTTON:
b[1] = {text: t('core', 'Cancel'), click: function(){$(c_id).dialog('close'); }}; var functionToCall;
case OCdialogs.OK_BUTTON: // fallthrough
var f;
switch(dialog_type) { switch(dialog_type) {
case OCdialogs.ALERT_DIALOG: case OCdialogs.ALERT_DIALOG:
f = function(){$(c_id).dialog('close'); if(callback) callback();}; functionToCall = function() {
$(dialog_id).dialog('close');
if(callback !== undefined) { callback() };
};
break; break;
case OCdialogs.PROMPT_DIALOG: case OCdialogs.PROMPT_DIALOG:
f = function(){OCdialogs.prompt_ok_handler(callback, c_id)}; buttonlist[1] = {
break; text: t('core', 'Cancel'),
case OCdialogs.FORM_DIALOG: click: function() { $(dialog_id).dialog('close'); }
f = function(){OCdialogs.form_ok_handler(callback, c_id)}; };
functionToCall = function() { OCdialogs.prompt_ok_handler(callback, dialog_id); };
break; break;
} }
b[0] = {text: t('core', 'Ok'), click: f}; buttonlist[0] = {
text: t('core', 'Ok'),
click: functionToCall
};
break; break;
} };
var possible_height = ($('tr', d).size()+1)*30;
$(c_id).dialog({width: 4*$(document).width()/9, height: possible_height + 120, modal: modal, buttons: b}); $(dialog_id).dialog({
width: (4/9) * $(document).width(),
height: 180,
modal: modal,
buttons: buttonlist
});
OCdialogs.dialogs_counter++; OCdialogs.dialogs_counter++;
}, },
// dialogs buttons types // dialog button types
YES_NO_BUTTONS: 70, YES_NO_BUTTONS: 70,
OK_BUTTONS: 71, OK_BUTTONS: 71,
OK_CANCEL_BUTTONS: 72,
// dialogs types // dialogs types
ALERT_DIALOG: 80, ALERT_DIALOG: 80,
INFO_DIALOG: 81, INFO_DIALOG: 81,
PROMPT_DIALOG: 82, FORM_DIALOG: 82,
FORM_DIALOG: 83, // used to name each dialog
dialogs_counter: 0, dialogs_counter: 0,
determineValue: function(element) { determineValue: function(element) {
switch ($(element).attr('type')) { if ( $(element).attr('type') === 'checkbox' ) {
case 'checkbox': return element.checked; return element.checked;
}
return $(element).val();
},
prompt_ok_handler: function(callback, c_id) { $(c_id).dialog('close'); if (callback != undefined) callback($(c_id + " input#oc-dialog-prompt-input").val()); },
form_ok_handler: function(callback, c_id) {
if (callback != undefined) {
var r = [];
var c = 0;
$(c_id + ' input, '+c_id+' select').each(function(i, elem) {
r[c] = {name: $(elem).attr('name'), value: OCdialogs.determineValue(elem)};
c++;
});
$(c_id).dialog('close');
callback(r);
} else { } else {
$(c_id).dialog('close'); return $(element).val();
} }
}, },
fillFilePicker:function(r, dialog_content_id) {
var entry_template = '<div data-entryname="*ENTRYNAME*" data-dcid="'+dialog_content_id+'" data="*ENTRYTYPE*"><img src="*MIMETYPEICON*" style="margin-right:1em;"><span class="filename">*NAME*</span><div style="float:right;margin-right:1em;">*LASTMODDATE*</div></div>'; prompt_ok_handler: function(callback, dialog_id) {
var names = ''; $(dialog_id).dialog('close');
$.each(r.data, function(index, a) { if (callback !== undefined) { callback($(dialog_id + " input#oc-dialog-prompt-input").val()) };
names += entry_template.replace('*LASTMODDATE*', OC.mtime2date(a.mtime)).replace('*NAME*', a.name).replace('*MIMETYPEICON*', a.mimetype_icon).replace('*ENTRYNAME*', a.name).replace('*ENTRYTYPE*', a.type); },
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: $(element).attr('name'), value: OCdialogs.determineValue(element) };
});
$(dialog_id).dialog('close');
callback(valuelist);
} else {
$(dialog_id).dialog('close');
}
},
/**
* fills the filepicker with files
*/
fillFilePicker:function(request, dialog_content_id) {
var template_content = '<img src="*MIMETYPEICON*" style="margin: 2px 1em 0 4px;"><span class="filename">*NAME*</span><div style="float:right;margin-right:1em;">*LASTMODDATE*</div>';
var template = '<div data-entryname="*ENTRYNAME*" data-dcid="' + escapeHTML(dialog_content_id) + '" data="*ENTRYTYPE*">*CONTENT*</div>';
var files = '';
var dirs = [];
var others = [];
$.each(request.data, function(index, file) {
if (file.type === 'dir') {
dirs.push(file);
} else {
others.push(file);
}
});
var sorted = dirs.concat(others);
for (var i = 0; i < sorted.length; i++) {
files_content = template_content.replace('*LASTMODDATE*', OC.mtime2date(sorted[i].mtime)).replace('*NAME*', escapeHTML(sorted[i].name)).replace('*MIMETYPEICON*', sorted[i].mimetype_icon);
files += template.replace('*ENTRYNAME*', escapeHTML(sorted[i].name)).replace('*ENTRYTYPE*', escapeHTML(sorted[i].type)).replace('*CONTENT*', files_content);
}
$(dialog_content_id + ' #filelist').html(files);
$('#filelist div').click(function() {
OCdialogs.handlePickerClick($(this), $(this).data('entryname'), dialog_content_id);
}); });
$(dialog_content_id + ' #filelist').html(names).on('click', '[data="file"]', function() {
OC.dialogs.handlePickerClick(this, $(this).data('entryname'), $(this).data('dcid'));
});
$(dialog_content_id + ' .filepicker_loader').css('visibility', 'hidden'); $(dialog_content_id + ' .filepicker_loader').css('visibility', 'hidden');
}, },
handleTreeListSelect:function(event) { /**
var newval = parseInt($(this).val()); * fills the tree list with directories
var oldval = parseInt($(this).data('oldval')); */
while (newval != oldval && oldval > 0) { fillTreeList: function(request, dialog_id) {
$('option:last', this).remove(); var template = '<option value="*COUNT*">*NAME*</option>';
$('option:last', this).attr('selected','selected'); var paths = '<option value="0">' + escapeHTML($(dialog_id).data('path')) + '</option>';
oldval--; $.each(request.data, function(index, file) {
} paths += template.replace('*COUNT*', index).replace('*NAME*', escapeHTML(file.name));
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'); $(dialog_id + ' #dirtree').html(paths);
$.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) { * handle selection made in the tree list
var p = $(dcid).data('path'); */
if (p == undefined) p = ''; handleTreeListSelect:function(event) {
p = p+'/'+name; if ($("option:selected", this).html().indexOf('/') !== -1) { // if there's a slash in the selected path, don't append it
if ($(element).attr('data') == 'file'){ $(event.data.dcid).data('path', $("option:selected", this).html());
if ($(dcid).data('multiselect') != true) { } else {
$(dcid+' .filepicker_element_selected').removeClass('filepicker_element_selected'); $(event.data.dcid).data('path', $(event.data.dcid).data('path') + $("option:selected", this).html() + '/');
}
$(event.data.dcid + ' .filepicker_loader').css('visibility', 'visible');
$.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) }
);
}
},
/**
* handle clicks made in the filepicker
*/
handlePickerClick:function(element, name, dialog_content_id) {
if ( $(element).attr('data') === 'file' ){
if ( $(dialog_content_id).data('multiselect') !== true) {
$(dialog_content_id + ' .filepicker_element_selected').removeClass('filepicker_element_selected');
} }
$(element).toggleClass('filepicker_element_selected'); $(element).toggleClass('filepicker_element_selected');
return; return;
} else if ( $(element).attr('data') === 'dir' ) {
var datapath = escapeHTML( $(dialog_content_id).data('path') + name + '/' );
$(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) }
);
} }
$(dcid).data('path', p);
$(dcid + ' #dirtree option:last').removeAttr('selected');
var newval = parseInt($(dcid + ' #dirtree option:last').val())+1;
$(dcid + ' #dirtree').append('<option selected="selected" value="'+newval+'">'+name+'</option>');
$(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)});
} }
}; };