aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/fileactions.js30
-rw-r--r--apps/files/js/filelist.js136
-rw-r--r--apps/files/js/files.js13
3 files changed, 110 insertions, 69 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index af3fc483910..38f5bab6f73 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -81,7 +81,7 @@ var FileActions = {
event.data.actionFunc(file);
};
- $.each(actions, function (name, action) {
+ var addAction = function (name, action) {
// NOTE: Temporary fix to prevent rename action in root of Shared directory
if (name === 'Rename' && $('#dir').val() === '/Shared') {
return true;
@@ -92,7 +92,7 @@ var FileActions = {
if (img.call) {
img = img(file);
}
- var html = '<a href="#" class="action" data-action="'+name+'">';
+ var html = '<a href="#" class="action" data-action="' + name + '">';
if (img) {
html += '<img class ="svg" src="' + img + '" /> ';
}
@@ -101,21 +101,27 @@ var FileActions = {
var element = $(html);
element.data('action', name);
//alert(element);
- element.on('click',{a:null, elem:parent, actionFunc:actions[name]},actionHandler);
+ element.on('click', {a: null, elem: parent, actionFunc: actions[name]}, actionHandler);
parent.find('a.name>span.fileactions').append(element);
}
+ };
+
+ $.each(actions, function (name, action) {
+ if (name !== 'Share') {
+ addAction(name, action);
+ }
});
+ if(actions.Share){
+ addAction('Share', actions.Share);
+ }
if (actions['Delete']) {
var img = FileActions.icons['Delete'];
if (img.call) {
img = img(file);
}
- // NOTE: Temporary fix to allow unsharing of files in root of Shared folder
- if ($('#dir').val() == '/Shared') {
- var html = '<a href="#" original-title="' + t('files', 'Unshare') + '" class="action delete" />';
- } else if (typeof trashBinApp !== 'undefined' && trashBinApp) {
+ if (typeof trashBinApp !== 'undefined' && trashBinApp) {
var html = '<a href="#" original-title="' + t('files', 'Delete permanently') + '" class="action delete" />';
} else {
var html = '<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete" />';
@@ -125,7 +131,7 @@ var FileActions = {
element.append($('<img class ="svg" src="' + img + '"/>'));
}
element.data('action', actions['Delete']);
- element.on('click',{a:null, elem:parent, actionFunc:actions['Delete']},actionHandler);
+ element.on('click', {a: null, elem: parent, actionFunc: actions['Delete']}, actionHandler);
parent.parent().children().last().append(element);
}
},
@@ -149,7 +155,7 @@ $(document).ready(function () {
} else {
var downloadScope = 'file';
}
-
+
if (typeof disableDownloadActions == 'undefined' || !disableDownloadActions) {
FileActions.register(downloadScope, 'Download', OC.PERMISSION_READ, function () {
return OC.imagePath('core', 'actions/download');
@@ -157,11 +163,11 @@ $(document).ready(function () {
window.location = OC.filePath('files', 'ajax', 'download.php') + '?files=' + encodeURIComponent(filename) + '&dir=' + encodeURIComponent($('#dir').val());
});
}
-
- $('#fileList tr').each(function(){
+
+ $('#fileList tr').each(function () {
FileActions.display($(this).children('td.filename'));
});
-
+
});
FileActions.register('all', 'Delete', OC.PERMISSION_DELETE, function () {
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 72b353b48c2..cc107656da8 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -3,35 +3,92 @@ var FileList={
update:function(fileListHtml) {
$('#fileList').empty().html(fileListHtml);
},
- addFile:function(name,size,lastModified,loading,hidden){
- 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){
+ createRow:function(type, name, iconurl, linktarget, size, lastModified, permissions){
+ var td, simpleSize, basename, extension;
+ //containing tr
+ var tr = $('<tr></tr>').attr({
+ "data-type": type,
+ "data-size": size,
+ "data-file": name,
+ "data-permissions": permissions
+ });
+ // filename td
+ td = $('<td></td>').attr({
+ "class": "filename",
+ "style": 'background-image:url('+iconurl+')'
+ });
+ td.append('<input type="checkbox" />');
+ var link_elem = $('<a></a>').attr({
+ "class": "name",
+ "href": linktarget
+ });
+ //split extension from filename for non dirs
+ if (type != 'dir' && name.indexOf('.')!=-1) {
basename=name.substr(0,name.lastIndexOf('.'));
extension=name.substr(name.lastIndexOf('.'));
- }else{
+ } else {
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;')+'/'+escapeHTML(name)+'"><span class="nametext">'+escapeHTML(basename);
+ var name_span=$('<span></span>').addClass('nametext').text(basename);
+ link_elem.append(name_span);
if(extension){
- html+='<span class="extension">'+escapeHTML(extension)+'</span>';
+ name_span.append($('<span></span>').addClass('extension').text(extension));
+ }
+ //dirs can show the number of uploaded files
+ if (type == 'dir') {
+ link_elem.append($('<span></span>').attr({
+ 'class': 'uploadtext',
+ 'currentUploads': 0
+ }));
}
- html+='</span></a></td>';
- if(size!='Pending'){
+ td.append(link_elem);
+ tr.append(td);
+
+ //size column
+ if(size!=t('files', 'Pending')){
simpleSize=simpleFileSize(size);
}else{
- simpleSize='Pending';
+ simpleSize=t('files', 'Pending');
}
- sizeColor = Math.round(200-size/(1024*1024)*2);
- lastModifiedTime=Math.round(lastModified.getTime() / 1000);
- modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*14);
- html+='<td class="filesize" title="'+humanFileSize(size)+'" style="color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')">'+simpleSize+'</td>';
- html+='<td class="date"><span class="modified" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</span></td>';
- html+='</tr>';
- FileList.insertElement(name,'file',$(html).attr('data-file',name));
+ var sizeColor = Math.round(200-Math.pow((size/(1024*1024)),2));
+ var lastModifiedTime = Math.round(lastModified.getTime() / 1000);
+ td = $('<td></td>').attr({
+ "class": "filesize",
+ "title": humanFileSize(size),
+ "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'
+ }).text(simpleSize);
+ tr.append(td);
+
+ // date column
+ var modifiedColor = Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5);
+ td = $('<td></td>').attr({ "class": "date" });
+ td.append($('<span></span>').attr({
+ "class": "modified",
+ "title": formatDate(lastModified),
+ "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')'
+ }).text( relative_modified_date(lastModified.getTime() / 1000) ));
+ tr.append(td);
+ return tr;
+ },
+ addFile:function(name,size,lastModified,loading,hidden){
+ var imgurl;
+ if (loading) {
+ imgurl = OC.imagePath('core', 'loading.gif');
+ } else {
+ imgurl = OC.imagePath('core', 'filetypes/file.png');
+ }
+ var tr = this.createRow(
+ 'file',
+ name,
+ imgurl,
+ OC.Router.generate('download', { file: $('#dir').val()+'/'+name }),
+ size,
+ lastModified,
+ $('#permissions').val()
+ );
+
+ FileList.insertElement(name, 'file', tr.attr('data-file',name));
var row = $('tr').filterAttr('data-file',name);
if(loading){
row.data('loading',true);
@@ -44,30 +101,18 @@ var FileList={
FileActions.display(row.find('td.filename'));
},
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" />');
- 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);
- html.append(td);
- if(size!='Pending'){
- simpleSize=simpleFileSize(size);
- }else{
- simpleSize='Pending';
- }
- sizeColor = Math.round(200-Math.pow((size/(1024*1024)),2));
- lastModifiedTime=Math.round(lastModified.getTime() / 1000);
- modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5);
- td = $('<td></td>').attr({ "class": "filesize", "title": humanFileSize(size), "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'}).text(simpleSize);
- html.append(td);
-
- td = $('<td></td>').attr({ "class": "date" });
- td.append($('<span></span>').attr({ "class": "modified", "title": formatDate(lastModified), "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')' }).text( relative_modified_date(lastModified.getTime() / 1000) ));
- html.append(td);
- FileList.insertElement(name,'dir',html);
+
+ var tr = this.createRow(
+ 'dir',
+ name,
+ OC.imagePath('core', 'filetypes/folder.png'),
+ OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/'),
+ size,
+ lastModified,
+ $('#permissions').val()
+ );
+
+ FileList.insertElement(name,'dir',tr);
var row = $('tr').filterAttr('data-file',name);
row.find('td.filename').draggable(dragOptions);
row.find('td.filename').droppable(folderDropOptions);
@@ -216,9 +261,6 @@ var FileList={
},
replace:function(oldName, newName, isNewFile) {
// Finish any existing actions
- if (FileList.lastAction || !FileList.useUndo) {
- FileList.lastAction();
- }
$('tr').filterAttr('data-file', oldName).hide();
$('tr').filterAttr('data-file', newName).hide();
var tr = $('tr').filterAttr('data-file', oldName).clone();
@@ -321,7 +363,6 @@ $(document).ready(function(){
// Delete the new uploaded file
FileList.deleteCanceled = false;
FileList.deleteFiles = [FileList.replaceOldName];
- FileList.finishDelete(null, true);
} else {
$('tr').filterAttr('data-file', FileList.replaceOldName).show();
}
@@ -348,7 +389,6 @@ $(document).ready(function(){
if ($('#notification').data('isNewFile')) {
FileList.deleteCanceled = false;
FileList.deleteFiles = [$('#notification').data('oldName')];
- FileList.finishDelete(null, true);
}
});
FileList.useUndo=(window.onbeforeunload)?true:false;
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 7c377afc620..918182162d4 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -262,12 +262,6 @@ $(document).ready(function() {
return;
}
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(){
- $('#file_upload_start').change();
- });
- return;
- }
}
}
if(totalSize>$('#max_upload').val()){
@@ -691,9 +685,10 @@ $(document).ready(function() {
breadcrumbsWidth += $(breadcrumb).get(0).offsetWidth;
});
- if ($('#controls .actions').length > 0) {
- breadcrumbsWidth += $('#controls .actions').get(0).offsetWidth;
- }
+
+ $.each($('#controls .actions>div'), function(index, action) {
+ breadcrumbsWidth += $(action).get(0).offsetWidth;
+ });
function resizeBreadcrumbs(firstRun) {
var width = $(this).width();