From 3e185911f1d6f397d95f96419e5b65c1c10390ea Mon Sep 17 00:00:00 2001 From: kondou Date: Sat, 6 Apr 2013 16:44:13 +0200 Subject: [PATCH] Fix repeating directory names. Also fix some CSS for Firefox. --- core/css/styles.css | 2 +- core/js/oc-dialogs.js | 31 +++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index 2c570fd78e6..3324cd9be89 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -328,7 +328,7 @@ a.bookmarklet { background-color:#ddd; border:1px solid #ccc; padding:5px;paddin /* ---- DIALOGS ---- */ #dirup {width:4%;} -#dirtree {width:93%;} +#dirtree {width:92%;} #filelist {height:270px; overflow-y:auto; background-color:white; width:100%;} .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;} diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index cd5412fdeda..f929eb87dc5 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -151,6 +151,12 @@ var OCdialogs = { $(dialog_id + ' #dirtree').focus().change( {dcid: dialog_id}, OCdialogs.handleTreeListSelect ); $(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(){ $.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)); } - $(dialog_content_id + ' #filelist').html(files).on('click', '[data="file"]', function() { - 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 + ' #filelist').html(files); $(dialog_content_id + ' .filepicker_loader').css('visibility', 'hidden'); }, /** @@ -334,9 +335,10 @@ var OCdialogs = { $(dialog_id + ' #dirtree').html(paths); }, - + /** + * handle selection made in the tree list + */ 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 { @@ -360,7 +362,9 @@ var OCdialogs = { function(request) { OCdialogs.fillTreeList(request, event.data.dcid) } ); }, - // go one directory up + /** + * go one directory up + */ filepickerDirUp:function(event) { var old_path = $(event.data.dcid).data('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) { - var datapath = $(dialog_content_id).data('path'); - if (datapath === undefined) { datapath = '' }; - datapath += name; if ( $(element).attr('data') === 'file' ){ if ( $(dialog_content_id).data('multiselect') !== true) { $(dialog_content_id + ' .filepicker_element_selected').removeClass('filepicker_element_selected'); @@ -400,7 +403,7 @@ var OCdialogs = { $(element).toggleClass('filepicker_element_selected'); return; } 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 + ' .filepicker_loader').css('visibility', 'visible'); $.getJSON( -- 2.39.5