Fix repeating directory names.

Also fix some CSS for Firefox.
This commit is contained in:
kondou 2013-04-06 16:44:13 +02:00
parent fba6681f71
commit 3e185911f1
2 changed files with 18 additions and 15 deletions

View file

@ -328,7 +328,7 @@ a.bookmarklet { background-color:#ddd; border:1px solid #ccc; padding:5px;paddin
/* ---- DIALOGS ---- */ /* ---- DIALOGS ---- */
#dirup {width:4%;} #dirup {width:4%;}
#dirtree {width:93%;} #dirtree {width:92%;}
#filelist {height:270px; overflow-y:auto; background-color:white; width:100%;} #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: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;} .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;}

View file

@ -151,6 +151,12 @@ var OCdialogs = {
$(dialog_id + ' #dirtree').focus().change( {dcid: dialog_id}, OCdialogs.handleTreeListSelect ); $(dialog_id + ' #dirtree').focus().change( {dcid: dialog_id}, OCdialogs.handleTreeListSelect );
$(dialog_id + ' #dirup').click( {dcid: dialog_id}, OCdialogs.filepickerDirUp ); $(dialog_id + ' #dirup').click( {dcid: dialog_id}, OCdialogs.filepickerDirUp );
$(dialog_id + ' #filelist').click('[data="file"]', function() {
OCdialogs.handlePickerClick(this, $(this).data('entryname'), $(this).data('dcid'));
});
$(dialog_id + ' #filelist').on('click', '[data="dir"]', function() {
OCdialogs.handlePickerClick(this, $(this).data('entryname'), $(this).data('dcid'));
});
$(dialog_id).ready(function(){ $(dialog_id).ready(function(){
$.getJSON(OC.filePath('files', 'ajax', 'rawlist.php'), { mimetype: mimetype_filter } ,function(request) { $.getJSON(OC.filePath('files', 'ajax', 'rawlist.php'), { mimetype: mimetype_filter } ,function(request) {
@ -310,12 +316,7 @@ var OCdialogs = {
files += template.replace('*LASTMODDATE*', OC.mtime2date(sorted[i].mtime)).replace('*NAME*', escapeHTML(sorted[i].name)).replace('*MIMETYPEICON*', sorted[i].mimetype_icon).replace('*ENTRYNAME*', escapeHTML(sorted[i].name)).replace('*ENTRYTYPE*', escapeHTML(sorted[i].type)); files += template.replace('*LASTMODDATE*', OC.mtime2date(sorted[i].mtime)).replace('*NAME*', escapeHTML(sorted[i].name)).replace('*MIMETYPEICON*', sorted[i].mimetype_icon).replace('*ENTRYNAME*', escapeHTML(sorted[i].name)).replace('*ENTRYTYPE*', escapeHTML(sorted[i].type));
} }
$(dialog_content_id + ' #filelist').html(files).on('click', '[data="file"]', function() { $(dialog_content_id + ' #filelist').html(files);
OCdialogs.handlePickerClick(this, $(this).data('entryname'), $(this).data('dcid'));
});
$(dialog_content_id + ' #filelist').html(files).on('click', '[data="dir"]', function() {
OCdialogs.handlePickerClick(this, $(this).data('entryname'), $(this).data('dcid'));
});
$(dialog_content_id + ' .filepicker_loader').css('visibility', 'hidden'); $(dialog_content_id + ' .filepicker_loader').css('visibility', 'hidden');
}, },
/** /**
@ -334,9 +335,10 @@ var OCdialogs = {
$(dialog_id + ' #dirtree').html(paths); $(dialog_id + ' #dirtree').html(paths);
}, },
/**
* handle selection made in the tree list
*/
handleTreeListSelect:function(event) { 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 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()); $(event.data.dcid).data('path', $("option:selected", this).html());
} else { } else {
@ -360,7 +362,9 @@ var OCdialogs = {
function(request) { OCdialogs.fillTreeList(request, event.data.dcid) } function(request) { OCdialogs.fillTreeList(request, event.data.dcid) }
); );
}, },
// go one directory up /**
* go one directory up
*/
filepickerDirUp:function(event) { filepickerDirUp:function(event) {
var old_path = $(event.data.dcid).data('path'); var old_path = $(event.data.dcid).data('path');
if ( old_path !== "/") { if ( old_path !== "/") {
@ -388,11 +392,10 @@ var OCdialogs = {
); );
} }
}, },
// this function is in early development state, please dont use it unless you know what you are doing /**
* handle clicks made in the filepicker
*/
handlePickerClick:function(element, name, dialog_content_id) { handlePickerClick:function(element, name, dialog_content_id) {
var datapath = $(dialog_content_id).data('path');
if (datapath === undefined) { datapath = '' };
datapath += name;
if ( $(element).attr('data') === 'file' ){ if ( $(element).attr('data') === 'file' ){
if ( $(dialog_content_id).data('multiselect') !== true) { if ( $(dialog_content_id).data('multiselect') !== true) {
$(dialog_content_id + ' .filepicker_element_selected').removeClass('filepicker_element_selected'); $(dialog_content_id + ' .filepicker_element_selected').removeClass('filepicker_element_selected');
@ -400,7 +403,7 @@ var OCdialogs = {
$(element).toggleClass('filepicker_element_selected'); $(element).toggleClass('filepicker_element_selected');
return; return;
} else if ( $(element).attr('data') === 'dir' ) { } else if ( $(element).attr('data') === 'dir' ) {
datapath += '/'; var datapath = escapeHTML( $(dialog_content_id).data('path') + name + '/' );
$(dialog_content_id).data('path', datapath); $(dialog_content_id).data('path', datapath);
$(dialog_content_id + ' .filepicker_loader').css('visibility', 'visible'); $(dialog_content_id + ' .filepicker_loader').css('visibility', 'visible');
$.getJSON( $.getJSON(