From 45c9f1978ec6221b7f302f0722b0e6795fa91804 Mon Sep 17 00:00:00 2001 From: Simon Birnbach Date: Fri, 16 Mar 2012 00:03:23 +0100 Subject: Initial version of drag&drop file upload support --- files/js/files.js | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'files/js/files.js') diff --git a/files/js/files.js b/files/js/files.js index a678e12cc2d..a129b853b67 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -150,6 +150,7 @@ $(document).ready(function() { return false; }); + /* $('.file_upload_start').live('change',function(){ var form=$(this).closest('form'); var that=this; @@ -228,6 +229,88 @@ $(document).ready(function() { form.hide(); } }); +*/ + + // drag&drop support using jquery.fileupload + $(function() { + $('.file_upload_start').fileupload({ + //dropZone: $('#content'), // restrict dropZone to content div + add: function(e, data) { + var files = data.files; + var totalSize=0; + if(files){ + for(var i=0;i$('#max_upload').val()){ + $( "#uploadsize-message" ).dialog({ + modal: true, + buttons: { + Close: function() { + $( this ).dialog( "close" ); + } + } + }); + }else{ + data.submit(); + var date=new Date(); + if(files){ + for(var i=0;i0){ + var size=files[i].size; + }else{ + var size=t('files','Pending'); + } + if(files){ + FileList.addFile(files[i].name,size,date,true); + } + } + }else{ + var filename=this.value.split('\\').pop(); //ie prepends C:\fakepath\ in front of the filename + FileList.addFile(filename,'Pending',date,true); + } + } + }, + done: function(e, data) { + var response=jQuery.parseJSON(data.result); + if(response[0] != undefined && response[0].status == 'success') { + for(var i=0;i0){ + var size=file.size; + }else{ + var size=t('files','Pending'); + } + $('tr').filterAttr('data-file',file.name).data('mime',file.mime); + if(size=='Pending'){ + $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); + } + FileList.loadingDone(file.name); + } + } else { + $('#notification').text(t('files', response.data.message)); + $('#notification').fadeIn(); + $('#fileList > tr').not('[data-mime]').fadeOut(); + $('#fileList > tr').not('[data-mime]').remove(); + } + }, + fail: function(e, data) { + console.debug("Fail", data); + // TODO: cancel upload & display error notification + }, + progress: function(e, data) { + } + }) + }); + + //add multiply file upload attribute to all browsers except konqueror (which crashes when it's used) if(navigator.userAgent.search(/konqueror/i)==-1){ -- cgit v1.2.3 From b949619d0409d6caca169707bae42037b1145a47 Mon Sep 17 00:00:00 2001 From: Simon Birnbach Date: Fri, 16 Mar 2012 00:11:50 +0100 Subject: coding guidelines --- files/js/files.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'files/js/files.js') diff --git a/files/js/files.js b/files/js/files.js index a129b853b67..e5e97c01b95 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -250,11 +250,11 @@ $(document).ready(function() { } } if(totalSize>$('#max_upload').val()){ - $( "#uploadsize-message" ).dialog({ + $( '#uploadsize-message' ).dialog({ modal: true, buttons: { Close: function() { - $( this ).dialog( "close" ); + $( this ).dialog( 'close' ); } } }); @@ -302,7 +302,7 @@ $(document).ready(function() { } }, fail: function(e, data) { - console.debug("Fail", data); + console.debug('Fail', data); // TODO: cancel upload & display error notification }, progress: function(e, data) { -- cgit v1.2.3 From 9377b753507f6d47640d2815f1d61bd5fefd3b3e Mon Sep 17 00:00:00 2001 From: Simon Birnbach Date: Fri, 16 Mar 2012 19:58:28 +0100 Subject: Support for legacy browsers --- files/index.php | 1 + files/js/files.js | 112 ++++-------------------- files/js/jquery.iframe-transport.js | 165 ++++++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+), 95 deletions(-) create mode 100644 files/js/jquery.iframe-transport.js (limited to 'files/js/files.js') diff --git a/files/index.php b/files/index.php index a625d3cdf9f..9604f118c4b 100644 --- a/files/index.php +++ b/files/index.php @@ -30,6 +30,7 @@ OC_Util::checkLoggedIn(); // Load the files we need OC_Util::addStyle( "files", "files" ); +OC_Util::addScript( "files", "jquery.iframe-transport" ); OC_Util::addScript( "files", "jquery.fileupload" ); OC_Util::addScript( "files", "files" ); OC_Util::addScript( 'files', 'filelist' ); diff --git a/files/js/files.js b/files/js/files.js index e5e97c01b95..a09bb9abe98 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -150,87 +150,6 @@ $(document).ready(function() { return false; }); - /* - $('.file_upload_start').live('change',function(){ - var form=$(this).closest('form'); - var that=this; - var uploadId=form.attr('data-upload-id'); - var files=this.files; - var target=form.children('iframe'); - var totalSize=0; - if(files){ - for(var i=0;i$('#max_upload').val()){ - $( "#uploadsize-message" ).dialog({ - modal: true, - buttons: { - Close: function() { - $( this ).dialog( "close" ); - } - } - }); - }else{ - target.load(function(){ - var response=jQuery.parseJSON(target.contents().find('body').text()); - //set mimetype and if needed filesize - if(response){ - if(response[0] != undefined && response[0].status == 'success'){ - for(var i=0;i tr').not('[data-mime]').fadeOut(); - $('#fileList > tr').not('[data-mime]').remove(); - } - } - }); - form.submit(); - var date=new Date(); - if(files){ - for(var i=0;i0){ - var size=files[i].size; - }else{ - var size=t('files','Pending'); - } - if(files){ - FileList.addFile(files[i].name,size,date,true); - } - } - }else{ - var filename=this.value.split('\\').pop(); //ie prepends C:\fakepath\ in front of the filename - FileList.addFile(filename,'Pending',date,true); - } - - //clone the upload form and hide the new one to allow users to start a new upload while the old one is still uploading - var clone=form.clone(); - uploadId++; - clone.attr('data-upload-id',uploadId); - clone.attr('target','file_upload_target_'+uploadId); - clone.children('iframe').attr('name','file_upload_target_'+uploadId) - clone.insertBefore(form); - form.hide(); - } - }); -*/ - // drag&drop support using jquery.fileupload $(function() { $('.file_upload_start').fileupload({ @@ -279,21 +198,24 @@ $(document).ready(function() { } }, done: function(e, data) { - var response=jQuery.parseJSON(data.result); + var response; + if(data.dataType == 'iframe ') { + response = jQuery.parseJSON(data.result[0].body.innerText); + } else { + response=jQuery.parseJSON(data.result); + } if(response[0] != undefined && response[0].status == 'success') { - for(var i=0;i0){ - var size=file.size; - }else{ - var size=t('files','Pending'); - } - $('tr').filterAttr('data-file',file.name).data('mime',file.mime); - if(size=='Pending'){ - $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); - } - FileList.loadingDone(file.name); + var file=response[0]; + if(file.size>0){ + var size=file.size; + }else{ + var size=t('files','Pending'); + } + $('tr').filterAttr('data-file',file.name).data('mime',file.type); + if(size=='Pending'){ + $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); } + FileList.loadingDone(file.name); } else { $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); @@ -302,10 +224,10 @@ $(document).ready(function() { } }, fail: function(e, data) { - console.debug('Fail', data); // TODO: cancel upload & display error notification }, progress: function(e, data) { + // TODO: show nice progress bar } }) }); diff --git a/files/js/jquery.iframe-transport.js b/files/js/jquery.iframe-transport.js new file mode 100644 index 00000000000..d85c0c11297 --- /dev/null +++ b/files/js/jquery.iframe-transport.js @@ -0,0 +1,165 @@ +/* + * jQuery Iframe Transport Plugin 1.3 + * https://github.com/blueimp/jQuery-File-Upload + * + * Copyright 2011, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/MIT + */ + +/*jslint unparam: true, nomen: true */ +/*global define, window, document */ + +(function (factory) { + 'use strict'; + if (typeof define === 'function' && define.amd) { + // Register as an anonymous AMD module: + define(['jquery'], factory); + } else { + // Browser globals: + factory(window.jQuery); + } +}(function ($) { + 'use strict'; + + // Helper variable to create unique names for the transport iframes: + var counter = 0; + + // The iframe transport accepts three additional options: + // options.fileInput: a jQuery collection of file input fields + // options.paramName: the parameter name for the file form data, + // overrides the name property of the file input field(s) + // options.formData: an array of objects with name and value properties, + // equivalent to the return data of .serializeArray(), e.g.: + // [{name: 'a', value: 1}, {name: 'b', value: 2}] + $.ajaxTransport('iframe', function (options) { + if (options.async && (options.type === 'POST' || options.type === 'GET')) { + var form, + iframe; + return { + send: function (_, completeCallback) { + form = $('
'); + // javascript:false as initial iframe src + // prevents warning popups on HTTPS in IE6. + // IE versions below IE8 cannot set the name property of + // elements that have already been added to the DOM, + // so we set the name along with the iframe HTML markup: + iframe = $( + '' + ).bind('load', function () { + var fileInputClones; + iframe + .unbind('load') + .bind('load', function () { + var response; + // Wrap in a try/catch block to catch exceptions thrown + // when trying to access cross-domain iframe contents: + try { + response = iframe.contents(); + // Google Chrome and Firefox do not throw an + // exception when calling iframe.contents() on + // cross-domain requests, so we unify the response: + if (!response.length || !response[0].firstChild) { + throw new Error(); + } + } catch (e) { + response = undefined; + } + // The complete callback returns the + // iframe content document as response object: + completeCallback( + 200, + 'success', + {'iframe': response} + ); + // Fix for IE endless progress bar activity bug + // (happens on form submits to iframe targets): + $('') + .appendTo(form); + form.remove(); + }); + form + .prop('target', iframe.prop('name')) + .prop('action', options.url) + .prop('method', options.type); + if (options.formData) { + $.each(options.formData, function (index, field) { + $('') + .prop('name', field.name) + .val(field.value) + .appendTo(form); + }); + } + if (options.fileInput && options.fileInput.length && + options.type === 'POST') { + fileInputClones = options.fileInput.clone(); + // Insert a clone for each file input field: + options.fileInput.after(function (index) { + return fileInputClones[index]; + }); + if (options.paramName) { + options.fileInput.each(function () { + $(this).prop('name', options.paramName); + }); + } + // Appending the file input fields to the hidden form + // removes them from their original location: + form + .append(options.fileInput) + .prop('enctype', 'multipart/form-data') + // enctype must be set as encoding for IE: + .prop('encoding', 'multipart/form-data'); + } + form.submit(); + // Insert the file input fields at their original location + // by replacing the clones with the originals: + if (fileInputClones && fileInputClones.length) { + options.fileInput.each(function (index, input) { + var clone = $(fileInputClones[index]); + $(input).prop('name', clone.prop('name')); + clone.replaceWith(input); + }); + } + }); + form.append(iframe).appendTo(document.body); + }, + abort: function () { + if (iframe) { + // javascript:false as iframe src aborts the request + // and prevents warning popups on HTTPS in IE6. + // concat is used to avoid the "Script URL" JSLint error: + iframe + .unbind('load') + .prop('src', 'javascript'.concat(':false;')); + } + if (form) { + form.remove(); + } + } + }; + } + }); + + // The iframe transport returns the iframe content document as response. + // The following adds converters from iframe to text, json, html, and script: + $.ajaxSetup({ + converters: { + 'iframe text': function (iframe) { + return $(iframe[0].body).text(); + }, + 'iframe json': function (iframe) { + return $.parseJSON($(iframe[0].body).text()); + }, + 'iframe html': function (iframe) { + return $(iframe[0].body).html(); + }, + 'iframe script': function (iframe) { + return $.globalEval($(iframe[0].body).text()); + } + } + }); + +})); -- cgit v1.2.3 From 38072e1900b2f3b5d0d9d0d7bd78658026a8ab23 Mon Sep 17 00:00:00 2001 From: Simon Birnbach Date: Sat, 17 Mar 2012 13:56:33 +0100 Subject: Fixed upload of undeleted file and size information --- files/js/files.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'files/js/files.js') diff --git a/files/js/files.js b/files/js/files.js index a09bb9abe98..666e0c7602f 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -162,7 +162,7 @@ $(document).ready(function() { totalSize+=files[i].size; if(FileList.deleteFiles && FileList.deleteFiles.indexOf(files[i].name)!=-1){//finish delete if we are uploading a deleted file FileList.finishDelete(function(){ - $(that).change(); + $('.file_upload_start').change(); }); return; } @@ -206,13 +206,9 @@ $(document).ready(function() { } if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; - if(file.size>0){ - var size=file.size; - }else{ - var size=t('files','Pending'); - } $('tr').filterAttr('data-file',file.name).data('mime',file.type); - if(size=='Pending'){ + var size = $('tr').filterAttr('data-file',file.name).find('td.filesize').text(); + if(size==t('files','Pending')){ $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); } FileList.loadingDone(file.name); -- cgit v1.2.3 From b1a33110fc44d2cf20ab6de6aa68031054ec0761 Mon Sep 17 00:00:00 2001 From: Simon Birnbach Date: Sat, 17 Mar 2012 22:20:39 +0100 Subject: Added global progressbar for all uploads --- files/css/files.css | 1 + files/js/files.js | 14 +++++++++++++- files/templates/index.php | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'files/js/files.js') diff --git a/files/css/files.css b/files/css/files.css index 512e462cb6f..60851b6f57e 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -30,6 +30,7 @@ .file_upload_filename { position: relative; z-index:100; padding-left: 0.8em; padding-right: 0.8em; cursor:pointer; border-top-left-radius:0; border-bottom-left-radius:0; } .file_upload_filename img { position: absolute; top: 0.4em; left: 0.4em; } +#uploadprogressbar { position:absolute; right:14.5em; display:inline-block; width:10em; height:1.5em; top:.4em; } .file_upload_form, .file_upload_wrapper, .file_upload_start, .file_upload_filename, #file_upload_submit { cursor:pointer; } diff --git a/files/js/files.js b/files/js/files.js index 666e0c7602f..5f61bdd2ac3 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -223,7 +223,19 @@ $(document).ready(function() { // TODO: cancel upload & display error notification }, progress: function(e, data) { - // TODO: show nice progress bar + // TODO: show nice progress bar in file row + }, + progressall: function(e, data) { + var progress = (data.loaded/data.total)*100; + $('#uploadprogressbar').progressbar('value',progress); + }, + start: function(e, data) { + $('#uploadprogressbar').progressbar({value:0}); + $('#uploadprogressbar').fadeIn(); + }, + stop: function(e, data) { + $('#uploadprogressbar').progressbar('value',100); + $('#uploadprogressbar').fadeOut(); } }) }); diff --git a/files/templates/index.php b/files/templates/index.php index 7fc51c288e1..abcbd269211 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -21,6 +21,7 @@ +
-- cgit v1.2.3 From 4e89a0faf652f2f100cca47cca54a3b35e720aad Mon Sep 17 00:00:00 2001 From: Simon Birnbach Date: Tue, 27 Mar 2012 21:38:55 +0200 Subject: Added uploading to folder and cancellable downloads --- files/css/files.css | 10 ++- files/js/fileactions.js | 15 +++- files/js/filelist.js | 1 + files/js/files.js | 173 ++++++++++++++++++++++++++++++++++-------- files/templates/index.php | 6 +- files/templates/part.list.php | 4 + 6 files changed, 173 insertions(+), 36 deletions(-) (limited to 'files/js/files.js') diff --git a/files/css/files.css b/files/css/files.css index 60851b6f57e..8e3a767721e 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -30,7 +30,8 @@ .file_upload_filename { position: relative; z-index:100; padding-left: 0.8em; padding-right: 0.8em; cursor:pointer; border-top-left-radius:0; border-bottom-left-radius:0; } .file_upload_filename img { position: absolute; top: 0.4em; left: 0.4em; } -#uploadprogressbar { position:absolute; right:14.5em; display:inline-block; width:10em; height:1.5em; top:.4em; } +#upload { position:absolute; right:13.5em; top:0em; } +#upload #uploadprogressbar { position:relative; display:inline-block; width:10em; height:1.5em; top:.4em; } .file_upload_form, .file_upload_wrapper, .file_upload_start, .file_upload_filename, #file_upload_submit { cursor:pointer; } @@ -41,7 +42,7 @@ tbody tr:hover, tbody tr:active, tbody tr.selected { background-color:#f8f8f8; h tbody tr { background-color:#fff; } tbody tr.selected { background-color:#eee; } tbody a { color:#000; } -span.extention, td.date { color:#999; } +span.extention, span.uploading, td.date { color:#999; } span.extention { opacity:0; -webkit-transition:opacity 500ms; -moz-transition:opacity 500ms; -o-transition:opacity 500ms; transition:opacity 500ms; } tr:hover span.extention { opacity:1; } div.crumb { float:left; display:block; background:no-repeat right 0; padding:.75em 1.5em 0 1em; height:2.9em; } @@ -60,8 +61,9 @@ table td.filename a.name { display:block; height:1.5em; vertical-align:middle; m table tr[data-type="dir"] td.filename a.name {font-weight:bold; } table td.filename a.name input, table td.filename a.name form { width:100%; cursor:text; } table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:.2em .5em .5em 0; } -table td.filename .nametext, .modified { float:left; padding:.3em 0; } -table td.filename .nametext { width:60%; } +table td.filename .nametext, .uploadtext, .modified { float:left; padding:.3em 0; } +//table td.filename .nametext { width:60%; } +table td.filename .uploadtext { font-weight:normal; margin-left:.5em; } table td.filename form { float:left; font-size:.85em; } table thead.fixed tr{ position:fixed; top:6.5em; z-index:49; -moz-box-shadow:0 -3px 7px #ddd; -webkit-box-shadow:0 -3px 7px #ddd; box-shadow:0 -3px 7px #ddd; } table thead.fixed { height:2em; } diff --git a/files/js/fileactions.js b/files/js/fileactions.js index b5dd3982803..384ffc92cf2 100644 --- a/files/js/fileactions.js +++ b/files/js/fileactions.js @@ -133,7 +133,20 @@ FileActions.register('all','Download',function(){return OC.imagePath('core','act }); FileActions.register('all','Delete',function(){return OC.imagePath('core','actions/delete')},function(filename){ - FileList.do_delete(filename); + if(Files.cancelUpload(filename)) { + if(filename.substr){ + filename=[filename]; + } + $.each(filename,function(index,file){ + var filename = $('tr').filterAttr('data-file',file); + filename.hide(); + filename.find('input[type="checkbox"]').removeAttr('checked'); + filename.removeClass('selected'); + }); + procesSelection(); + }else{ + FileList.do_delete(filename); + } }); FileActions.register('all','Rename',function(){return OC.imagePath('core','actions/rename')},function(filename){ diff --git a/files/js/filelist.js b/files/js/filelist.js index 35847e06dfe..0faff08a73f 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -42,6 +42,7 @@ FileList={ td.append(''); var link_elem = $('').attr({ "class": "name", "href": "index.php?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); link_elem.append($('').addClass('nametext').text(name)); + link_elem.append($('').attr({'class': 'uploadtext', 'currentUploads': 0})); td.append(link_elem); html.append(td); if(size!='Pending'){ diff --git a/files/js/files.js b/files/js/files.js index 5f61bdd2ac3..6eed25dfe99 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -1,3 +1,25 @@ +var uploadingFiles = {}; +Files={ + cancelUpload:function(filename) { + if(uploadingFiles[filename]) { + uploadingFiles[filename].abort(); + delete uploadingFiles[filename]; + return true; + } + return false; + }, + cancelUploads:function() { + $.each(uploadingFiles,function(index,file){ + file.abort(); + delete uploadingFiles[index]; + var filename = $('tr').filterAttr('data-file',index); + filename.hide(); + filename.find('input[type="checkbox"]').removeAttr('checked'); + filename.removeClass('selected'); + }); + procesSelection(); + } +} $(document).ready(function() { $('#fileList tr').each(function(){ //little hack to set unescape filenames in attribute @@ -151,9 +173,13 @@ $(document).ready(function() { }); // drag&drop support using jquery.fileupload + $(document).bind('drop dragover', function (e) { + e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone + }); + $(function() { $('.file_upload_start').fileupload({ - //dropZone: $('#content'), // restrict dropZone to content div + dropZone: $('#content'), // restrict dropZone to content div add: function(e, data) { var files = data.files; var totalSize=0; @@ -178,7 +204,97 @@ $(document).ready(function() { } }); }else{ - data.submit(); + if($.support.xhrFileUpload) { + for(var i=0;i tr').not('[data-mime]').fadeOut(); + $('#fileList > tr').not('[data-mime]').remove(); + } + }) + .error(function(jqXHR, textStatus, errorThrown) { + if(errorThrown === 'abort') { + $('#notification').hide(); + $('#notification').text(t('files', 'Upload cancelled.')); + $('#notification').fadeIn(); + } + }); + } + uploadingFiles[files[i].name] = jqXHR; + } + }else{ + data.submit().success(function(data, status) { + response = jQuery.parseJSON(data[0].body.innerText); + if(response[0] != undefined && response[0].status == 'success') { + var file=response[0]; + delete uploadingFiles[file.name]; + $('tr').filterAttr('data-file',file.name).data('mime',file.mime); + var size = $('tr').filterAttr('data-file',file.name).find('td.filesize').text(); + if(size==t('files','Pending')){ + $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); + } + FileList.loadingDone(file.name); + } else { + $('#notification').text(t('files', response.data.message)); + $('#notification').fadeIn(); + $('#fileList > tr').not('[data-mime]').fadeOut(); + $('#fileList > tr').not('[data-mime]').remove(); + } + }); + } + var date=new Date(); if(files){ for(var i=0;i tr').not('[data-mime]').fadeOut(); - $('#fileList > tr').not('[data-mime]').remove(); - } - }, fail: function(e, data) { // TODO: cancel upload & display error notification }, @@ -230,17 +338,22 @@ $(document).ready(function() { $('#uploadprogressbar').progressbar('value',progress); }, start: function(e, data) { - $('#uploadprogressbar').progressbar({value:0}); - $('#uploadprogressbar').fadeIn(); + $('#uploadprogressbar').progressbar({value:0}); + $('#uploadprogressbar').fadeIn(); + if(data.dataType != 'iframe ') { + $('#upload input.stop').show(); + } }, stop: function(e, data) { - $('#uploadprogressbar').progressbar('value',100); - $('#uploadprogressbar').fadeOut(); + if(data.dataType != 'iframe ') { + $('#upload input.stop').hide(); + } + $('#uploadprogressbar').progressbar('value',100); + $('#uploadprogressbar').fadeOut(); } }) }); - //add multiply file upload attribute to all browsers except konqueror (which crashes when it's used) if(navigator.userAgent.search(/konqueror/i)==-1){ diff --git a/files/templates/index.php b/files/templates/index.php index abcbd269211..319c8c64a07 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -21,7 +21,11 @@ -
+
+
+ +
+
diff --git a/files/templates/part.list.php b/files/templates/part.list.php index b117d81a1a5..a86632bafc8 100644 --- a/files/templates/part.list.php +++ b/files/templates/part.list.php @@ -21,6 +21,10 @@ + + + + -- cgit v1.2.3 From 8e27b725ba2aa26cb9037b44b18ff800649017b1 Mon Sep 17 00:00:00 2001 From: Simon Birnbach Date: Sun, 15 Apr 2012 16:47:53 +0200 Subject: Fixed cancelling upload of same file to folder and subfolder --- files/css/files.css | 1 + files/js/files.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'files/js/files.js') diff --git a/files/css/files.css b/files/css/files.css index 4d2b749bf8c..544b323bb29 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -62,6 +62,7 @@ table tr[data-type="dir"] td.filename a.name {font-weight:bold; } table td.filename a.name input, table td.filename a.name form { width:100%; cursor:text; } table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:.2em .5em .5em 0; } table td.filename .nametext, .uploadtext, .modified { float:left; padding:.3em 0; } +// TODO fix usability bug (accidental file/folder selection) //table td.filename .nametext { width:60%; } table td.filename .uploadtext { font-weight:normal; margin-left:.5em; } table td.filename form { float:left; font-size:.85em; } diff --git a/files/js/files.js b/files/js/files.js index 89101ce4b8f..a7a4d3077c1 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -172,6 +172,7 @@ $(document).ready(function() { }); // drag&drop support using jquery.fileupload + // TODO use OC.dialogs $(document).bind('drop dragover', function (e) { e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone }); @@ -242,6 +243,7 @@ $(document).ready(function() { $('#notification').fadeIn(); } }); + uploadingFiles[dirName+"/"+files[i].name] = jqXHR; } else { var jqXHR = $('.file_upload_start').fileupload('send', {files: files[i]}) .success(function(result, textStatus, jqXHR) { @@ -270,8 +272,8 @@ $(document).ready(function() { $('#notification').fadeIn(); } }); + uploadingFiles[files[i].name] = jqXHR; } - uploadingFiles[files[i].name] = jqXHR; } }else{ data.submit().success(function(data, status) { -- cgit v1.2.3 From 965a8ba2c60eb04e2f65a4ace215113ac61f7c98 Mon Sep 17 00:00:00 2001 From: Simon Birnbach Date: Sun, 15 Apr 2012 23:52:36 +0200 Subject: Fixed cancelling of uploads and wrong merge conflict resolution --- files/css/files.css | 6 +++--- files/js/files.js | 42 +++++++++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 12 deletions(-) (limited to 'files/js/files.js') diff --git a/files/css/files.css b/files/css/files.css index 544b323bb29..5dc7983bec4 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -42,9 +42,9 @@ tbody tr { background-color:#fff; height:2.5em; } tbody tr:hover, tbody tr:active, tbody tr.selected { background-color:#f8f8f8; } tbody tr.selected { background-color:#eee; } tbody a { color:#000; } -span.extention, span.uploading, td.date { color:#999; } -span.extention { opacity:0; -webkit-transition:opacity 500ms; -moz-transition:opacity 500ms; -o-transition:opacity 500ms; transition:opacity 500ms; } -tr:hover span.extention { opacity:1; } +span.extension, span.uploading, td.date { color:#999; } +span.extension { text-transform:lowercase; opacity:0; -webkit-transition:opacity 500ms; -moz-transition:opacity 500ms; -o-transition:opacity 500ms; transition:opacity 500ms; } +tr:hover span.extension { opacity:1; } div.crumb { float:left; display:block; background:no-repeat right 0; padding:.75em 1.5em 0 1em; height:2.9em; } div.crumb:first-child { padding-left:1em; } div.crumb.last { font-weight:bold; } diff --git a/files/js/files.js b/files/js/files.js index a7a4d3077c1..56fff753737 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -9,13 +9,20 @@ Files={ return false; }, cancelUploads:function() { - $.each(uploadingFiles,function(index,file){ - file.abort(); + $.each(uploadingFiles,function(index,file) { + if(typeof file['abort'] === 'function') { + file.abort(); + var filename = $('tr').filterAttr('data-file',index); + filename.hide(); + filename.find('input[type="checkbox"]').removeAttr('checked'); + filename.removeClass('selected'); + } else { + $.each(file,function(i,f) { + f.abort(); + delete file[i]; + }); + } delete uploadingFiles[index]; - var filename = $('tr').filterAttr('data-file',index); - filename.hide(); - filename.find('input[type="checkbox"]').removeAttr('checked'); - filename.removeClass('selected'); }); procesSelection(); } @@ -206,8 +213,9 @@ $(document).ready(function() { }else{ if($.support.xhrFileUpload) { for(var i=0;i