From e0547a25ab9c5a3d9454611f72e00e3bc667e2d2 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 3 May 2013 00:15:28 +0200 Subject: if rename of file fails, the rename is undone in the view - #fix 2820 Changes: * OC.dialog -> OC.Notification * Added test * Fixed OC.Notification.show() issue for queued items * Highlight failed item and show notification --- apps/files/js/filelist.js | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index e19a35bbc5b..c6663836fd7 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -208,13 +208,44 @@ var FileList={ if (FileList.checkName(name, newname, false)) { newname = name; } 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; + // save background image, because it's replaced by a spinner while async request + var oldBackgroundImage = td.css('background-image'); + // mark as loading + td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); + $.ajax({ + url: OC.filePath('files','ajax','rename.php'), + data: { + dir : $('#dir').val(), + newname: newname, + file: name + }, + success: function(result) { + if (!result || result.status === 'error') { + OC.Notification.show(result.data.message); + newname = name; + // revert changes + 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.find('a.name span.nametext').text(basename); + if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') { + if (td.find('a.name span.extension').length === 0 ) { + td.find('a.name span.nametext').append(''); + } + td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.'))); + } + tr.find('.fileactions').effect('highlight', {}, 5000); + tr.effect('highlight', {}, 5000); + } + // remove loading mark and recover old image + td.css('background-image', oldBackgroundImage); } }); - } } tr.data('renaming',false); -- cgit v1.2.3 From 492c0571a04135539c5b3857a6c1b3fda9abf40a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 1 Jul 2013 15:47:17 +0200 Subject: fix detection of public upload in filelist.js --- apps/files/js/filelist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index f4ca098eed1..7027273664f 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -436,7 +436,7 @@ $(document).ready(function(){ } var date=new Date(); var param = {}; - if ($('#publicUploadRequestToken')) { + if ($('#publicUploadRequestToken').length) { param.download_url = document.location.href + '&download&path=/' + $('#dir').val() + '/' + uniqueName; } // create new file context -- cgit v1.2.3 From cb81ceb31d1a5aba8f1febfafecdcc2106822168 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Fri, 12 Jul 2013 10:40:24 +0200 Subject: add new file above summary if it is the first file in the list --- apps/files/js/filelist.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index cf3ce2e5089..c847e2eff8b 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -171,6 +171,8 @@ var FileList={ } }else if(type=='dir' && $('tr[data-file]').length>0){ $('tr[data-file]').first().before(element); + } else if(type=='file' && $('tr[data-file]').length>0) { + $('tr[data-file]').last().before(element); }else{ $('#fileList').append(element); } -- cgit v1.2.3 From 48948ccf5f6f1d7de2765fb955f956063d9bedc8 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 18 Jul 2013 22:15:26 +0200 Subject: finally remove the file size obfuscation as it had more disadvantages. I was wrong, sorry. --- apps/files/js/filelist.js | 3 +-- apps/files/js/files.js | 4 +--- apps/files/templates/index.php | 2 +- apps/files/templates/part.list.php | 6 ++---- core/js/js.js | 10 ---------- lib/public/template.php | 10 ---------- lib/template.php | 18 ------------------ 7 files changed, 5 insertions(+), 48 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index c847e2eff8b..04a9fb91649 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -47,7 +47,7 @@ var FileList={ //size column if(size!=t('files', 'Pending')){ - simpleSize=simpleFileSize(size); + simpleSize = humanFileSize(size); }else{ simpleSize=t('files', 'Pending'); } @@ -55,7 +55,6 @@ var FileList={ var lastModifiedTime = Math.round(lastModified.getTime() / 1000); td = $('').attr({ "class": "filesize", - "title": humanFileSize(size), "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')' }).text(simpleSize); tr.append(td); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 51b3f31fb96..98fc53b71a9 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -756,9 +756,7 @@ function procesSelection(){ for(var i=0;i0){ if(selectedFolders.length==1){ diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 7d679bc4bf6..fa4cda6f6b2 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -77,7 +77,7 @@ - t('Size (MB)')); ?> + t('Size')); ?> t( 'Modified' )); ?> diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 97a9026860b..0c7d6936697 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -9,7 +9,6 @@ $totalsize = 0; ?> } else { $totalfiles++; } - $simple_file_size = OCP\simple_file_size($file['size']); // the bigger the file, the darker the shade of grey; megabytes*2 $simple_size_color = intval(160-$file['size']/(1024*1024)*2); if($simple_size_color<0) $simple_size_color = 0; @@ -52,9 +51,8 @@ $totalsize = 0; ?> - + } ?> - + diff --git a/core/js/js.js b/core/js/js.js index 5158b66d73a..cf4e72324dc 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -666,8 +666,6 @@ $(document).ready(function(){ $('.selectedActions a').tipsy({gravity:'s', fade:true, live:true}); $('a.delete').tipsy({gravity: 'e', fade:true, live:true}); $('a.action').tipsy({gravity:'s', fade:true, live:true}); - $('#headerSize').tipsy({gravity:'s', fade:true, live:true}); - $('td.filesize').tipsy({gravity:'s', fade:true, live:true}); $('td .modified').tipsy({gravity:'s', fade:true, live:true}); $('input').tipsy({gravity:'w', fade:true}); @@ -697,14 +695,6 @@ function humanFileSize(size) { return relativeSize + ' ' + readableFormat; } -function simpleFileSize(bytes) { - var mbytes = Math.round(bytes/(1024*1024/10))/10; - if(bytes == 0) { return '0'; } - else if(mbytes < 0.1) { return '< 0.1'; } - else if(mbytes > 1000) { return '> 1000'; } - else { return mbytes.toFixed(1); } -} - function formatDate(date){ if(typeof date=='number'){ date=new Date(date); diff --git a/lib/public/template.php b/lib/public/template.php index ccf19cf052c..d81a169579e 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -76,16 +76,6 @@ function relative_modified_date($timestamp) { } -/** - * @brief Return a human readable outout for a file size. - * @param $byte size of a file in byte - * @returns human readable interpretation of a file size - */ -function simple_file_size($bytes) { - return(\simple_file_size($bytes)); -} - - /** * @brief Generate html code for an options block. * @param $options the options diff --git a/lib/template.php b/lib/template.php index ae9ea187445..08df168afc6 100644 --- a/lib/template.php +++ b/lib/template.php @@ -84,24 +84,6 @@ function human_file_size( $bytes ) { return OC_Helper::humanFileSize( $bytes ); } -function simple_file_size($bytes) { - if ($bytes < 0) { - return '?'; - } - $mbytes = round($bytes / (1024 * 1024), 1); - if ($bytes == 0) { - return '0'; - } - if ($mbytes < 0.1) { - return '< 0.1'; - } - if ($mbytes > 1000) { - return '> 1000'; - } else { - return number_format($mbytes, 1); - } -} - function relative_modified_date($timestamp) { $l=OC_L10N::get('lib'); $timediff = time() - $timestamp; -- cgit v1.2.3