diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-01-11 09:53:12 +0100 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-01-11 09:53:12 +0100 |
commit | 23896a72906f1dca08d8413ea9a339b5d74aa658 (patch) | |
tree | 89edfcc629cfe1aac7787448338432875df63bed /apps/files/js/files.js | |
parent | bae175518427de1f43ac23dbc1e06a15f6933370 (diff) | |
parent | 60489764f37a6f344fa20e361a26c7a6006f9c97 (diff) | |
download | nextcloud-server-23896a72906f1dca08d8413ea9a339b5d74aa658.tar.gz nextcloud-server-23896a72906f1dca08d8413ea9a339b5d74aa658.zip |
Merge branch 'master' into fixing-784-master
Conflicts:
apps/files/js/files.js
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r-- | apps/files/js/files.js | 98 |
1 files changed, 57 insertions, 41 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 8d4cd06326e..96b3cc5b627 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -43,19 +43,19 @@ Files={ } }, - isFileNameValid:function (name) { - if (name === '.') { - $('#notification').text(t('files', "'.' is an invalid file name.")); - $('#notification').fadeIn(); - return false; - } - if (name.length == 0) { - $('#notification').text(t('files', "File name cannot be empty.")); - $('#notification').fadeIn(); - return false; - } + isFileNameValid:function (name) { + if (name === '.') { + $('#notification').text(t('files', '\'.\' is an invalid file name.')); + $('#notification').fadeIn(); + return false; + } + if (name.length == 0) { + $('#notification').text(t('files', 'File name cannot be empty.')); + $('#notification').fadeIn(); + return false; + } - // check for invalid characters + // check for invalid characters var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { if (name.indexOf(invalid_characters[i]) != -1) { @@ -263,12 +263,12 @@ $(document).ready(function() { } }); }else{ - var dropTarget = $(e.originalEvent.target).closest('tr'); - if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder - var dirName = dropTarget.attr('data-file') - } + var dropTarget = $(e.originalEvent.target).closest('tr'); + if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder + var dirName = dropTarget.attr('data-file') + } - var date=new Date(); + var date=new Date(); if(files){ for(var i=0;i<files.length;i++){ if(files[i].size>0){ @@ -321,9 +321,9 @@ $(document).ready(function() { var jqXHR = $('#file_upload_start').fileupload('send', {files: files[i], formData: function(form) { var formArray = form.serializeArray(); - // array index 0 contains the max files size - // array index 1 contains the request token - // array index 2 contains the directory + // array index 0 contains the max files size + // array index 1 contains the request token + // array index 2 contains the directory formArray[2]['value'] = dirName; return formArray; }}).success(function(result, textStatus, jqXHR) { @@ -335,13 +335,14 @@ $(document).ready(function() { } Files.updateMaxUploadFilesize(response); var file=response[0]; - // TODO: this doesn't work if the file name has been changed server side + // TODO: this doesn't work if the file name has been changed server side delete uploadingFiles[dirName][file.name]; - if ($.assocArraySize(uploadingFiles[dirName]) == 0) { - delete uploadingFiles[dirName]; - } + if ($.assocArraySize(uploadingFiles[dirName]) == 0) { + delete uploadingFiles[dirName]; + } + //TODO update file upload size limit - var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext') + var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext') var currentUploads = parseInt(uploadtext.attr('currentUploads')); currentUploads -= 1; uploadtext.attr('currentUploads', currentUploads); @@ -369,6 +370,7 @@ $(document).ready(function() { } else { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } + delete uploadingFiles[dirName][fileName]; $('#notification').hide(); $('#notification').text(t('files', 'Upload cancelled.')); $('#notification').fadeIn(); @@ -394,8 +396,10 @@ $(document).ready(function() { if(size==t('files','Pending')){ $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); } + //TODO update file upload size limit FileList.loadingDone(file.name, file.id); } else { + Files.cancelUpload(this.files[0].name); $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); $('#fileList > tr').not('[data-mime]').fadeOut(); @@ -404,6 +408,7 @@ $(document).ready(function() { }) .error(function(jqXHR, textStatus, errorThrown) { if(errorThrown === 'abort') { + Files.cancelUpload(this.files[0].name); $('#notification').hide(); $('#notification').text(t('files', 'Upload cancelled.')); $('#notification').fadeIn(); @@ -425,8 +430,10 @@ $(document).ready(function() { if(size==t('files','Pending')){ $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); } + //TODO update file upload size limit FileList.loadingDone(file.name, file.id); } else { + //TODO Files.cancelUpload(/*where do we get the filename*/); $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); $('#fileList > tr').not('[data-mime]').fadeOut(); @@ -467,7 +474,7 @@ $(document).ready(function() { // http://stackoverflow.com/a/6700/11236 var size = 0, key; for (key in obj) { - if (obj.hasOwnProperty(key)) size++; + if (obj.hasOwnProperty(key)) size++; } return size; }; @@ -510,7 +517,7 @@ $(document).ready(function() { $('#new').removeClass('active'); $('#new li').each(function(i,element){ if($(element).children('p').length==0){ - $(element).children('input').remove(); + $(element).children('form').remove(); $(element).append('<p>'+$(element).data('text')+'</p>'); } }); @@ -529,7 +536,7 @@ $(document).ready(function() { $('#new li').each(function(i,element){ if($(element).children('p').length==0){ - $(element).children('input').remove(); + $(element).children('form').remove(); $(element).append('<p>'+$(element).data('text')+'</p>'); } }); @@ -538,23 +545,32 @@ $(document).ready(function() { var text=$(this).children('p').text(); $(this).data('text',text); $(this).children('p').remove(); + var form=$('<form></form>'); var input=$('<input>'); - $(this).append(input); + form.append(input); + $(this).append(form); input.focus(); - input.change(function(){ - if (type != 'web' && !Files.isFileNameValid($(this).val())) { - return; - } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { - $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); + form.submit(function(event){ + event.stopPropagation(); + event.preventDefault(); + var newname=input.val(); + if(type == 'web' && newname.length == 0) { + $('#notification').text(t('files', 'URL cannot be empty.')); $('#notification').fadeIn(); - return; + return false; + } else if (type != 'web' && !Files.isFileNameValid(newname)) { + return false; + } else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') { + $('#notification').text(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud')); + $('#notification').fadeIn(); + return false; } if (FileList.lastAction) { FileList.lastAction(); } - var name = getUniqueName($(this).val()); - if (name != $(this).val()) { - FileList.checkName(name, $(this).val(), true); + var name = getUniqueName(newname); + if (newname != name) { + FileList.checkName(name, newname, true); var hidden = true; } else { var hidden = false; @@ -598,7 +614,7 @@ $(document).ready(function() { break; case 'web': if(name.substr(0,8)!='https://' && name.substr(0,7)!='http://'){ - name='http://'.name; + name='http://'+name; } var localName=name; if(localName.substr(localName.length-1,1)=='/'){//strip / @@ -637,8 +653,8 @@ $(document).ready(function() { }); break; } - var li=$(this).parent(); - $(this).remove(); + var li=form.parent(); + form.remove(); li.append('<p>'+li.data('text')+'</p>'); $('#new>a').click(); }); |