aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-09-30 06:51:40 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-09-30 06:51:40 +0200
commit241862756eaa0fdbdcc278d14c6c1652dc4237d0 (patch)
tree0954204d047f587424384f60fd4c4e1d334ec8da /apps/files/js
parent3273beb887fb8fd4c317a0263caa38a26e34f95e (diff)
parent258782584e490b92ccfcf032921aa7062a28da9f (diff)
downloadnextcloud-server-241862756eaa0fdbdcc278d14c6c1652dc4237d0.tar.gz
nextcloud-server-241862756eaa0fdbdcc278d14c6c1652dc4237d0.zip
Merge branch 'master' of github.com:owncloud/core into vcategories_db
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/fileactions.js3
-rw-r--r--apps/files/js/filelist.js101
-rw-r--r--apps/files/js/files.js14
3 files changed, 64 insertions, 54 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 1403d345e8a..e184cbfa915 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -157,7 +157,7 @@ $(document).ready(function(){
var downloadScope = 'file';
}
FileActions.register(downloadScope,'Download', OC.PERMISSION_READ, function(){return OC.imagePath('core','actions/download');},function(filename){
- window.location=OC.filePath('files', 'ajax', 'download.php') + encodeURIComponent('?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val()));
+ window.location=OC.filePath('files', 'ajax', 'download.php') + '&files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val());
});
});
@@ -179,6 +179,7 @@ FileActions.register('all','Delete', OC.PERMISSION_DELETE, function(){return OC.
$('.tipsy').remove();
});
+// t('files', 'Rename')
FileActions.register('all','Rename', OC.PERMISSION_UPDATE, function(){return OC.imagePath('core','actions/rename');},function(filename){
FileList.rename(filename);
});
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 7ebfd4b68bb..683f7db8678 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -4,14 +4,15 @@ var FileList={
$('#fileList').empty().html(fileListHtml);
},
addFile:function(name,size,lastModified,loading,hidden){
- var img=(loading)?OC.imagePath('core', 'loading.gif'):OC.imagePath('core', 'filetypes/file.png');
- var html='<tr data-type="file" data-size="'+size+'" data-permissions="'+$('#permissions').val()+'">';
+ var basename, extension, simpleSize, sizeColor, lastModifiedTime, modifiedColor,
+ img=(loading)?OC.imagePath('core', 'loading.gif'):OC.imagePath('core', 'filetypes/file.png'),
+ html='<tr data-type="file" data-size="'+size+'" data-permissions="'+$('#permissions').val()+'">';
if(name.indexOf('.')!=-1){
- var basename=name.substr(0,name.lastIndexOf('.'));
- var extension=name.substr(name.lastIndexOf('.'));
+ basename=name.substr(0,name.lastIndexOf('.'));
+ extension=name.substr(name.lastIndexOf('.'));
}else{
- var basename=name;
- var extension=false;
+ basename=name;
+ extension=false;
}
html+='<td class="filename" style="background-image:url('+img+')"><input type="checkbox" />';
html+='<a class="name" href="download.php?file='+$('#dir').val().replace(/</, '&lt;').replace(/>/, '&gt;')+'/'+name+'"><span class="nametext">'+basename;
@@ -41,10 +42,11 @@ var FileList={
}
},
addDir:function(name,size,lastModified,hidden){
+ var html, td, link_elem, sizeColor, lastModifiedTime, modifiedColor;
html = $('<tr></tr>').attr({ "data-type": "dir", "data-size": size, "data-file": name, "data-permissions": $('#permissions').val()});
td = $('<td></td>').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' });
td.append('<input type="checkbox" />');
- var link_elem = $('<a></a>').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"&dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') });
+ link_elem = $('<a></a>').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"&dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') });
link_elem.append($('<span></span>').addClass('nametext').text(name));
link_elem.append($('<span></span>').attr({'class': 'uploadtext', 'currentUploads': 0}));
td.append(link_elem);
@@ -71,7 +73,7 @@ var FileList={
}
},
refresh:function(data) {
- result = jQuery.parseJSON(data.responseText);
+ var result = jQuery.parseJSON(data.responseText);
if(typeof(result.data.breadcrumb) != 'undefined'){
updateBreadcrumb(result.data.breadcrumb);
}
@@ -88,14 +90,13 @@ var FileList={
},
insertElement:function(name,type,element){
//find the correct spot to insert the file or folder
- var fileElements=$('tr[data-file][data-type="'+type+'"]:visible');
- var pos;
+ var pos, fileElements=$('tr[data-file][data-type="'+type+'"]:visible');
if(name.localeCompare($(fileElements[0]).attr('data-file'))<0){
pos=-1;
}else if(name.localeCompare($(fileElements[fileElements.length-1]).attr('data-file'))>0){
pos=fileElements.length-1;
}else{
- for(var pos=0;pos<fileElements.length-1;pos++){
+ for(pos=0;pos<fileElements.length-1;pos++){
if(name.localeCompare($(fileElements[pos]).attr('data-file'))>0 && name.localeCompare($(fileElements[pos+1]).attr('data-file'))<0){
break;
}
@@ -116,9 +117,9 @@ var FileList={
$('.file_upload_filename').removeClass('highlight');
},
loadingDone:function(name){
- var tr=$('tr').filterAttr('data-file',name);
+ var mime, tr=$('tr').filterAttr('data-file',name);
tr.data('loading',false);
- var mime=tr.data('mime');
+ mime=tr.data('mime');
tr.attr('data-mime',mime);
getMimeIcon(mime,function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')');
@@ -129,14 +130,15 @@ var FileList={
return $('tr').filterAttr('data-file',name).data('loading');
},
rename:function(name){
- var tr=$('tr').filterAttr('data-file',name);
+ var tr, td, input, form;
+ tr=$('tr').filterAttr('data-file',name);
tr.data('renaming',true);
- var td=tr.children('td.filename');
- var input=$('<input class="filename"></input>').val(name);
- var form=$('<form></form>')
+ td=tr.children('td.filename');
+ input=$('<input class="filename"></input>').val(name);
+ form=$('<form></form>');
form.append(input);
td.children('a.name').text('');
- td.children('a.name').append(form)
+ td.children('a.name').append(form);
input.focus();
form.submit(function(event){
event.stopPropagation();
@@ -145,31 +147,33 @@ var FileList={
if (newname != name) {
if (FileList.checkName(name, newname, false)) {
newname = name;
- } else {
+ } else {
$.get(OC.filePath('files','ajax','rename.php'), { dir : $('#dir').val(), newname: newname, file: name },function(result) {
if (!result || result.status == 'error') {
OC.dialogs.alert(result.data.message, 'Error moving file');
newname = name;
}
+ tr.data('renaming',false);
});
+
+ }
+
+ tr.attr('data-file', newname);
+ var path = td.children('a.name').attr('href');
+ td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname)));
+ if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') {
+ var basename=newname.substr(0,newname.lastIndexOf('.'));
+ } else {
+ var basename=newname;
+ }
+ td.children('a.name').empty();
+ var span=$('<span class="nametext"></span>');
+ span.text(basename);
+ td.children('a.name').append(span);
+ if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') {
+ span.append($('<span class="extension">'+newname.substr(newname.lastIndexOf('.'))+'</span>'));
}
}
- tr.attr('data-file', newname);
- var path = td.children('a.name').attr('href');
- td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname)));
- if (newname.indexOf('.') > 0) {
- var basename=newname.substr(0,newname.lastIndexOf('.'));
- } else {
- var basename=newname;
- }
- td.children('a.name').empty();
- var span=$('<span class="nametext"></span>');
- span.text(basename);
- td.children('a.name').append(span);
- if (newname.indexOf('.') > 0) {
- span.append($('<span class="extension">'+newname.substr(newname.lastIndexOf('.'))+'</span>'));
- }
- tr.data('renaming',false);
return false;
});
input.click(function(event){
@@ -255,21 +259,23 @@ var FileList={
},
do_delete:function(files){
// Finish any existing actions
- if (FileList.lastAction || !FileList.useUndo) {
- if(!FileList.deleteFiles) {
- FileList.prepareDeletion(files);
- }
+ if (FileList.lastAction) {
FileList.lastAction();
- return;
}
+
FileList.prepareDeletion(files);
- // NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
- if ($('#dir').val() == '/Shared') {
- $('#notification').html(t('files', 'unshared')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
+
+ if (!FileList.useUndo) {
+ FileList.lastAction();
} else {
- $('#notification').html(t('files', 'deleted')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
+ // NOTE: Temporary fix to change the text to unshared for files in root of Shared folder
+ if ($('#dir').val() == '/Shared') {
+ $('#notification').html(t('files', 'unshared')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
+ } else {
+ $('#notification').html(t('files', 'deleted')+' '+files+'<span class="undo">'+t('files', 'undo')+'</span>');
+ }
+ $('#notification').fadeIn();
}
- $('#notification').fadeIn();
},
finishDelete:function(ready,sync){
if(!FileList.deleteCanceled && FileList.deleteFiles){
@@ -277,6 +283,7 @@ var FileList={
$.ajax({
url: OC.filePath('files', 'ajax', 'delete.php'),
async:!sync,
+ type:'post',
data: {dir:$('#dir').val(),files:fileNames},
complete: function(data){
boolOperationFinished(data, function(){
@@ -312,7 +319,7 @@ var FileList={
FileList.finishDelete(null, true);
};
}
-}
+};
$(document).ready(function(){
$('#notification').hide();
@@ -358,7 +365,7 @@ $(document).ready(function(){
FileList.finishDelete(null, true);
}
});
- FileList.useUndo=('onbeforeunload' in window)
+ FileList.useUndo=(window.onbeforeunload)?true:false;
$(window).bind('beforeunload', function (){
if (FileList.lastAction) {
FileList.lastAction();
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index aefd6f20bec..0c00fe8c922 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -336,7 +336,7 @@ $(document).ready(function() {
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);
+ $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
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);
@@ -356,16 +356,17 @@ $(document).ready(function() {
$('#notification').fadeIn();
}
});
- uploadingFiles[files[i].name] = jqXHR;
+ uploadingFiles[uniqueName] = jqXHR;
}
}
}else{
data.submit().success(function(data, status) {
- response = jQuery.parseJSON(data[0].body.innerText);
+ // in safari data is a string
+ response = jQuery.parseJSON(typeof data === 'string' ? data : 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);
+ $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
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);
@@ -511,7 +512,7 @@ $(document).ready(function() {
var date=new Date();
FileList.addFile(name,0,date,false,hidden);
var tr=$('tr').filterAttr('data-file',name);
- tr.data('mime','text/plain');
+ tr.data('mime','text/plain').data('id',result.data.id);
getMimeIcon('text/plain',function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')');
});
@@ -559,11 +560,12 @@ $(document).ready(function() {
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);
+ tr.data('mime',mime).data('id',id);
getMimeIcon(mime,function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')');
});