summaryrefslogtreecommitdiffstats
path: root/apps/files/js/file-upload.js
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2013-09-10 16:54:48 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2013-09-10 16:54:48 +0200
commitcec932f29252da7d47ddcbb33003ba11252d5753 (patch)
tree3c17c41b075f37b537c5851325940ab951ce2a52 /apps/files/js/file-upload.js
parente17c40acb79a6848af0481d434ec7643c5c9bf03 (diff)
parent72689f643b631061777149d96f6f170f7722e894 (diff)
downloadnextcloud-server-cec932f29252da7d47ddcbb33003ba11252d5753.tar.gz
nextcloud-server-cec932f29252da7d47ddcbb33003ba11252d5753.zip
Merge branch 'master' into fix_3728_with_file_exists_dialog
Conflicts: apps/files/js/file-upload.js
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r--apps/files/js/file-upload.js151
1 files changed, 75 insertions, 76 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index d1f9a79f21a..e5b3f807580 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -355,8 +355,6 @@ $(document).ready(function() {
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
fu._trigger('fail', e, data);
}
-
-
},
/**
* called after last upload
@@ -436,40 +434,41 @@ $(document).ready(function() {
return t('files', 'File upload is in progress. Leaving the page now will cancel the upload.');
}
});
+
//add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)
- if(navigator.userAgent.search(/konqueror/i) === -1) {
- $('#file_upload_start').attr('multiple', 'multiple');
+ if(navigator.userAgent.search(/konqueror/i)==-1){
+ $('#file_upload_start').attr('multiple','multiple');
}
//if the breadcrumb is to long, start by replacing foldernames with '...' except for the current folder
- var crumb = $('div.crumb').first();
- while($('div.controls').height() > 40 && crumb.next('div.crumb').length > 0) {
+ var crumb=$('div.crumb').first();
+ while($('div.controls').height()>40 && crumb.next('div.crumb').length>0){
crumb.children('a').text('...');
- crumb = crumb.next('div.crumb');
+ crumb=crumb.next('div.crumb');
}
//if that isn't enough, start removing items from the breacrumb except for the current folder and it's parent
- var crumb = $('div.crumb').first();
- var next = crumb.next('div.crumb');
- while($('div.controls').height() > 40 && next.next('div.crumb').length > 0) {
+ var crumb=$('div.crumb').first();
+ var next=crumb.next('div.crumb');
+ while($('div.controls').height()>40 && next.next('div.crumb').length>0){
crumb.remove();
- crumb = next;
- next = crumb.next('div.crumb');
+ crumb=next;
+ next=crumb.next('div.crumb');
}
//still not enough, start shorting down the current folder name
- var crumb = $('div.crumb>a').last();
- while($('div.controls').height() > 40 && crumb.text().length > 6) {
- var text = crumb.text();
- text = text.substr(0, text.length-6)+'...';
+ var crumb=$('div.crumb>a').last();
+ while($('div.controls').height()>40 && crumb.text().length>6){
+ var text=crumb.text()
+ text=text.substr(0,text.length-6)+'...';
crumb.text(text);
}
- $(document).click(function() {
+ $(document).click(function(){
$('#new>ul').hide();
$('#new').removeClass('active');
- $('#new li').each(function(i, element) {
- if($(element).children('p').length === 0) {
+ $('#new li').each(function(i,element){
+ if($(element).children('p').length==0){
$(element).children('form').remove();
- $(element).append('<p>' + $(element).data('text') + '</p>');
+ $(element).append('<p>'+$(element).data('text')+'</p>');
}
});
});
@@ -485,57 +484,57 @@ $(document).ready(function() {
return;
}
- $('#new li').each(function(i, element) {
- if($(element).children('p').length === 0) {
+ $('#new li').each(function(i,element){
+ if($(element).children('p').length==0){
$(element).children('form').remove();
- $(element).append('<p>' + $(element).data('text') + '</p>');
+ $(element).append('<p>'+$(element).data('text')+'</p>');
}
});
- var type = $(this).data('type');
- var text = $(this).children('p').text();
- $(this).data('text', text);
+ var type=$(this).data('type');
+ var text=$(this).children('p').text();
+ $(this).data('text',text);
$(this).children('p').remove();
- var form = $('<form></form>');
- var input = $('<input>');
+ var form=$('<form></form>');
+ var input=$('<input type="text">');
form.append(input);
$(this).append(form);
input.focus();
- form.submit(function(event) {
+ form.submit(function(event){
event.stopPropagation();
event.preventDefault();
var newname=input.val();
- if(type === 'web' && newname.length === 0) {
+ if(type == 'web' && newname.length == 0) {
OC.Notification.show(t('files', 'URL cannot be empty.'));
return false;
- } else if (type !== 'web' && !Files.isFileNameValid(newname)) {
+ } else if (type != 'web' && !Files.isFileNameValid(newname)) {
return false;
- } else if( type === 'folder' && $('#dir').val() === '/' && newname === 'Shared') {
- OC.Notification.show(t('files', 'Invalid folder name. Usage of \'Shared\' is reserved by ownCloud'));
+ } else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') {
+ OC.Notification.show(t('files','Invalid folder name. Usage of \'Shared\' is reserved by ownCloud'));
return false;
}
if (FileList.lastAction) {
FileList.lastAction();
}
var name = getUniqueName(newname);
- if (newname !== name) {
+ if (newname != name) {
FileList.checkName(name, newname, true);
var hidden = true;
} else {
var hidden = false;
}
- switch(type) {
+ switch(type){
case 'file':
$.post(
- OC.filePath('files', 'ajax', 'newfile.php'),
- {dir:$('#dir').val(), filename:name},
- function(result) {
- if (result.status === 'success') {
- var date = new Date();
- FileList.addFile(name, 0, date, false, hidden);
- var tr = $('tr').filterAttr('data-file', name);
+ OC.filePath('files','ajax','newfile.php'),
+ {dir:$('#dir').val(),filename:name},
+ function(result){
+ if (result.status == 'success') {
+ var date=new Date();
+ FileList.addFile(name,0,date,false,hidden);
+ var tr=$('tr').filterAttr('data-file',name);
tr.attr('data-size',result.data.size);
- tr.attr('data-mime', result.data.mime);
+ tr.attr('data-mime',result.data.mime);
tr.attr('data-id', result.data.id);
tr.find('.filesize').text(humanFileSize(result.data.size));
var path = getPathForPreview(name);
@@ -550,13 +549,13 @@ $(document).ready(function() {
break;
case 'folder':
$.post(
- OC.filePath('files', 'ajax', 'newfolder.php'),
- {dir:$('#dir').val(), foldername:name},
- function(result) {
- if (result.status === 'success') {
- var date = new Date();
- FileList.addDir(name, 0, date, hidden);
- var tr = $('tr').filterAttr('data-file', name);
+ OC.filePath('files','ajax','newfolder.php'),
+ {dir:$('#dir').val(),foldername:name},
+ function(result){
+ if (result.status == 'success') {
+ var date=new Date();
+ FileList.addDir(name,0,date,hidden);
+ var tr=$('tr').filterAttr('data-file',name);
tr.attr('data-id', result.data.id);
} else {
OC.dialogs.alert(result.data.message, t('core', 'Error'));
@@ -565,61 +564,61 @@ $(document).ready(function() {
);
break;
case 'web':
- if (name.substr(0, 8) !== 'https://' && name.substr(0, 7) !== 'http://') {
- name = 'http://' + name;
+ if(name.substr(0,8)!='https://' && name.substr(0,7)!='http://'){
+ name='http://'+name;
}
- var localName = name;
- if(localName.substr(localName.length-1, 1) === '/') { //strip /
- localName = localName.substr(0, localName.length-1);
+ var localName=name;
+ if(localName.substr(localName.length-1,1)=='/'){//strip /
+ localName=localName.substr(0,localName.length-1)
}
- if (localName.indexOf('/')) { //use last part of url
- localName = localName.split('/').pop();
+ if(localName.indexOf('/')){//use last part of url
+ localName=localName.split('/').pop();
} else { //or the domain
- localName = (localName.match(/:\/\/(.[^\/]+)/)[1]).replace('www.', '');
+ localName=(localName.match(/:\/\/(.[^\/]+)/)[1]).replace('www.','');
}
localName = getUniqueName(localName);
-
//IE < 10 does not fire the necessary events for the progress bar.
if($('html.lte9').length === 0) {
$('#uploadprogressbar').progressbar({value:0});
$('#uploadprogressbar').fadeIn();
}
- var eventSource = new OC.EventSource(
- OC.filePath('files', 'ajax', 'newfile.php'),
- {dir:$('#dir').val(), source:name, filename:localName}
- );
+
+ var eventSource=new OC.EventSource(OC.filePath('files','ajax','newfile.php'),{dir:$('#dir').val(),source:name,filename:localName});
eventSource.listen('progress',function(progress){
//IE < 10 does not fire the necessary events for the progress bar.
if($('html.lte9').length === 0) {
- $('#uploadprogressbar').progressbar('value', progress);
+ $('#uploadprogressbar').progressbar('value',progress);
}
});
- eventSource.listen('success', function(data) {
- var mime = data.mime;
- var size = data.size;
- var id = data.id;
+ eventSource.listen('success',function(data){
+ var mime=data.mime;
+ var size=data.size;
+ var id=data.id;
$('#uploadprogressbar').fadeOut();
- var date = new Date();
- FileList.addFile(localName, size, date, false, hidden);
- var tr = $('tr').filterAttr('data-file', localName);
- tr.data('mime', mime).data('id', id);
+ var date=new Date();
+ FileList.addFile(localName,size,date,false,hidden);
+ var tr=$('tr').filterAttr('data-file',localName);
+ tr.data('mime',mime).data('id',id);
tr.attr('data-id', id);
var path = $('#dir').val()+'/'+localName;
lazyLoadPreview(path, mime, function(previewpath){
tr.find('td.filename').attr('style','background-image:url('+previewpath+')');
});
});
- eventSource.listen('error', function(error) {
+ eventSource.listen('error',function(error){
$('#uploadprogressbar').fadeOut();
alert(error);
});
break;
}
- var li = form.parent();
+ var li=form.parent();
form.remove();
- li.append('<p>' + li.data('text') + '</p>');
+ /* workaround for IE 9&10 click event trap, 2 lines: */
+ $('input').first().focus();
+ $('#content').focus();
+ li.append('<p>'+li.data('text')+'</p>');
$('#new>a').click();
});
-
});
+ window.file_upload_param = file_upload_param;
});