summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2013-10-09 08:27:54 -0700
committerBjörn Schießle <bjoern@schiessle.org>2013-10-09 08:27:54 -0700
commit223adc3167d82d8bcd88b19aae78b1da2773e729 (patch)
tree760093c736b493247ea6d8302ba618490c1c0e7f
parent45510f2fe0c393ceee905a5a2227015bf212e6dc (diff)
parent7ab4fef7a9bee5ecad7ccf6fbc30cb8087861d4b (diff)
downloadnextcloud-server-223adc3167d82d8bcd88b19aae78b1da2773e729.tar.gz
nextcloud-server-223adc3167d82d8bcd88b19aae78b1da2773e729.zip
Merge pull request #5230 from owncloud/trashbin_fixes
Trashbin fixes
-rw-r--r--apps/files_trashbin/index.php2
-rw-r--r--apps/files_trashbin/js/trash.js272
-rw-r--r--apps/files_trashbin/templates/index.php3
3 files changed, 128 insertions, 149 deletions
diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php
index d8661e170a5..d079af3fb6d 100644
--- a/apps/files_trashbin/index.php
+++ b/apps/files_trashbin/index.php
@@ -5,7 +5,6 @@ OCP\User::checkLoggedIn();
OCP\App::setActiveNavigationEntry('files_index');
-OCP\Util::addScript('files_trashbin', 'trash');
OCP\Util::addScript('files_trashbin', 'disableDefaultActions');
OCP\Util::addScript('files', 'fileactions');
$tmpl = new OCP\Template('files_trashbin', 'index', 'user');
@@ -15,6 +14,7 @@ OCP\Util::addScript('files', 'filelist');
// filelist overrides
OCP\Util::addScript('files_trashbin', 'filelist');
OCP\Util::addscript('files', 'files');
+OCP\Util::addScript('files_trashbin', 'trash');
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js
index d73eadb6011..4e83afcdb06 100644
--- a/apps/files_trashbin/js/trash.js
+++ b/apps/files_trashbin/js/trash.js
@@ -3,15 +3,39 @@ $(document).ready(function() {
if (typeof FileActions !== 'undefined') {
FileActions.register('all', 'Restore', OC.PERMISSION_READ, OC.imagePath('core', 'actions/history'), function(filename) {
- var tr=$('tr').filterAttr('data-file', filename);
- var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
- var undeleteAction = $('tr').filterAttr('data-file',filename).children("td.date");
- var files = tr.attr('data-file');
- undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner;
+ var tr = $('tr').filterAttr('data-file', filename);
+ var deleteAction = $('tr').filterAttr('data-file', filename).children("td.date").children(".action.delete");
+ deleteAction.removeClass('delete-icon').addClass('progress-icon');
disableActions();
- $.post(OC.filePath('files_trashbin','ajax','undelete.php'),
- {files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') },
- function(result){
+ $.post(OC.filePath('files_trashbin', 'ajax', 'undelete.php'),
+ {files: JSON.stringify([filename]), dirlisting: tr.attr('data-dirlisting')},
+ function(result) {
+ for (var i = 0; i < result.data.success.length; i++) {
+ var row = document.getElementById(result.data.success[i].filename);
+ row.parentNode.removeChild(row);
+ }
+ if (result.status !== 'success') {
+ OC.dialogs.alert(result.data.message, t('core', 'Error'));
+ }
+ enableActions();
+ FileList.updateFileSummary();
+ }
+ );
+
+ });
+ };
+
+ FileActions.register('all', 'Delete', OC.PERMISSION_READ, function() {
+ return OC.imagePath('core', 'actions/delete');
+ }, function(filename) {
+ $('.tipsy').remove();
+ var tr = $('tr').filterAttr('data-file', filename);
+ var deleteAction = $('tr').filterAttr('data-file', filename).children("td.date").children(".action.delete");
+ deleteAction.removeClass('delete-icon').addClass('progress-icon');
+ disableActions();
+ $.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'),
+ {files: JSON.stringify([filename]), dirlisting: tr.attr('data-dirlisting')},
+ function(result) {
for (var i = 0; i < result.data.success.length; i++) {
var row = document.getElementById(result.data.success[i].filename);
row.parentNode.removeChild(row);
@@ -21,26 +45,74 @@ $(document).ready(function() {
}
enableActions();
FileList.updateFileSummary();
- });
+ }
+ );
- });
- };
+ });
- FileActions.register('all', 'Delete', OC.PERMISSION_READ, function () {
- return OC.imagePath('core', 'actions/delete');
- }, function (filename) {
- $('.tipsy').remove();
+ // Sets the select_all checkbox behaviour :
+ $('#select_all').click(function() {
+ if ($(this).attr('checked')) {
+ // Check all
+ $('td.filename input:checkbox').attr('checked', true);
+ $('td.filename input:checkbox').parent().parent().addClass('selected');
+ } else {
+ // Uncheck all
+ $('td.filename input:checkbox').attr('checked', false);
+ $('td.filename input:checkbox').parent().parent().removeClass('selected');
+ }
+ procesSelection();
+ });
- var tr=$('tr').filterAttr('data-file', filename);
- var deleteAction = $('tr').filterAttr('data-file',filename).children("td.date").children(".action.delete");
- var oldHTML = deleteAction[0].outerHTML;
- var newHTML = '<img class="move2trash" data-action="Delete" title="'+t('files', 'delete file permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
- var files = tr.attr('data-file');
- deleteAction[0].outerHTML = newHTML;
- disableActions();
- $.post(OC.filePath('files_trashbin','ajax','delete.php'),
- {files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') },
- function(result){
+ $('#fileList').on('click', 'td.filename a', function(event) {
+ if (event.shiftKey) {
+ event.preventDefault();
+ var last = $(lastChecked).parent().parent().prevAll().length;
+ var first = $(this).parent().parent().prevAll().length;
+ var start = Math.min(first, last);
+ var end = Math.max(first, last);
+ var rows = $(this).parent().parent().parent().children('tr');
+ for (var i = start; i < end; i++) {
+ $(rows).each(function(index) {
+ if (index == i) {
+ var checkbox = $(this).children().children('input:checkbox');
+ $(checkbox).attr('checked', 'checked');
+ $(checkbox).parent().parent().addClass('selected');
+ }
+ });
+ }
+ }
+ var checkbox = $(this).parent().children('input:checkbox');
+ lastChecked = checkbox;
+ if ($(checkbox).attr('checked')) {
+ $(checkbox).removeAttr('checked');
+ $(checkbox).parent().parent().removeClass('selected');
+ $('#select_all').removeAttr('checked');
+ } else {
+ $(checkbox).attr('checked', 'checked');
+ $(checkbox).parent().parent().toggleClass('selected');
+ var selectedCount = $('td.filename input:checkbox:checked').length;
+ if (selectedCount == $('td.filename input:checkbox').length) {
+ $('#select_all').attr('checked', 'checked');
+ }
+ }
+ procesSelection();
+ });
+
+ $('.undelete').click('click', function(event) {
+ event.preventDefault();
+ var files = getSelectedFiles('file');
+ var fileslist = JSON.stringify(files);
+ var dirlisting = getSelectedFiles('dirlisting')[0];
+ disableActions();
+ for (var i = 0; i < files.length; i++) {
+ var deleteAction = $('tr').filterAttr('data-file', files[i]).children("td.date").children(".action.delete");
+ deleteAction.removeClass('delete-icon').addClass('progress-icon');
+ }
+
+ $.post(OC.filePath('files_trashbin', 'ajax', 'undelete.php'),
+ {files: fileslist, dirlisting: dirlisting},
+ function(result) {
for (var i = 0; i < result.data.success.length; i++) {
var row = document.getElementById(result.data.success[i].filename);
row.parentNode.removeChild(row);
@@ -50,106 +122,38 @@ $(document).ready(function() {
}
enableActions();
FileList.updateFileSummary();
- });
-
- });
-
- // Sets the select_all checkbox behaviour :
- $('#select_all').click(function() {
- if($(this).attr('checked')){
- // Check all
- $('td.filename input:checkbox').attr('checked', true);
- $('td.filename input:checkbox').parent().parent().addClass('selected');
- }else{
- // Uncheck all
- $('td.filename input:checkbox').attr('checked', false);
- $('td.filename input:checkbox').parent().parent().removeClass('selected');
- }
- processSelection();
- });
-
- $('td.filename input:checkbox').live('change',function(event) {
- if (event.shiftKey) {
- var last = $(lastChecked).parent().parent().prevAll().length;
- var first = $(this).parent().parent().prevAll().length;
- var start = Math.min(first, last);
- var end = Math.max(first, last);
- var rows = $(this).parent().parent().parent().children('tr');
- for (var i = start; i < end; i++) {
- $(rows).each(function(index) {
- if (index === i) {
- var checkbox = $(this).children().children('input:checkbox');
- $(checkbox).attr('checked', 'checked');
- $(checkbox).parent().parent().addClass('selected');
- }
- });
}
- }
- var selectedCount=$('td.filename input:checkbox:checked').length;
- $(this).parent().parent().toggleClass('selected');
- if(!$(this).attr('checked')){
- $('#select_all').attr('checked',false);
- }else{
- if(selectedCount==$('td.filename input:checkbox').length){
- $('#select_all').attr('checked',true);
- }
- }
- processSelection();
- });
+ );
+ });
- $('.undelete').click('click',function(event) {
- event.preventDefault();
- var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
- var files=getSelectedFiles('file');
- var fileslist = JSON.stringify(files);
- var dirlisting=getSelectedFiles('dirlisting')[0];
- disableActions();
- for (var i=0; i<files.length; i++) {
- var undeleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date");
- undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner;
- }
+ $('.delete').click('click', function(event) {
+ event.preventDefault();
+ var files = getSelectedFiles('file');
+ var fileslist = JSON.stringify(files);
+ var dirlisting = getSelectedFiles('dirlisting')[0];
- $.post(OC.filePath('files_trashbin','ajax','undelete.php'),
- {files:fileslist, dirlisting:dirlisting},
- function(result){
- for (var i = 0; i < result.data.success.length; i++) {
- var row = document.getElementById(result.data.success[i].filename);
- row.parentNode.removeChild(row);
- }
- if (result.status !== 'success') {
- OC.dialogs.alert(result.data.message, t('core', 'Error'));
- }
- enableActions();
- });
- });
-
- $('.delete').click('click',function(event) {
- event.preventDefault();
- console.log("delete selected");
- var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'Delete permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
- var files=getSelectedFiles('file');
- var fileslist = JSON.stringify(files);
- var dirlisting=getSelectedFiles('dirlisting')[0];
+ disableActions();
+ for (var i = 0; i < files.length; i++) {
+ var deleteAction = $('tr').filterAttr('data-file', files[i]).children("td.date").children(".action.delete");
+ deleteAction.removeClass('delete-icon').addClass('progress-icon');
+ }
- disableActions();
- for (var i=0; i<files.length; i++) {
- var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date");
- deleteAction[0].innerHTML = deleteAction[0].innerHTML+spinner;
- }
+ $.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'),
+ {files: fileslist, dirlisting: dirlisting},
+ function(result) {
+ for (var i = 0; i < result.data.success.length; i++) {
+ var row = document.getElementById(result.data.success[i].filename);
+ row.parentNode.removeChild(row);
+ }
+ if (result.status !== 'success') {
+ OC.dialogs.alert(result.data.message, t('core', 'Error'));
+ }
+ enableActions();
+ FileList.updateFileSummary();
+ }
+ );
- $.post(OC.filePath('files_trashbin','ajax','delete.php'),
- {files:fileslist, dirlisting:dirlisting},
- function(result){
- for (var i = 0; i < result.data.success.length; i++) {
- var row = document.getElementById(result.data.success[i].filename);
- row.parentNode.removeChild(row);
- }
- if (result.status !== 'success') {
- OC.dialogs.alert(result.data.message, t('core', 'Error'));
- }
- enableActions();
- });
- });
+ });
$('#fileList').on('click', 'td.filename a', function(event) {
var mime = $(this).parent().parent().data('mime');
@@ -182,34 +186,6 @@ $(document).ready(function() {
};
});
-function processSelection(){
- var selected=getSelectedFiles();
- var selectedFiles=selected.filter(function(el){return el.type === 'file'});
- var selectedFolders=selected.filter(function(el){return el.type === 'dir'});
- if(selectedFiles.length === 0 && selectedFolders.length === 0) {
- $('#headerName>span.name').text(t('files','Name'));
- $('#modified').text(t('files','Deleted'));
- $('table').removeClass('multiselect');
- $('.selectedActions').hide();
- }
- else {
- $('.selectedActions').show();
- var selection='';
- if(selectedFolders.length>0){
- selection += n('files', '%n folder', '%n folders', selectedFolders.length);
- if(selectedFiles.length>0){
- selection+=' & ';
- }
- }
- if(selectedFiles.length>0){
- selection += n('files', '%n file', '%n files', selectedFiles.length);
- }
- $('#headerName>span.name').text(selection);
- $('#modified').text('');
- $('table').addClass('multiselect');
- }
-}
-
/**
* @brief get a list of selected files
* @param string property (option) the property of the file requested
diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php
index 82ba0608834..9b01a2589a5 100644
--- a/apps/files_trashbin/templates/index.php
+++ b/apps/files_trashbin/templates/index.php
@@ -17,7 +17,9 @@
<thead>
<tr>
<th id='headerName'>
+ <div id="headerName-container">
<input type="checkbox" id="select_all" />
+ <label for="select_all"></label>
<span class='name'><?php p($l->t( 'Name' )); ?></span>
<span class='selectedActions'>
<a href="" class="undelete">
@@ -26,6 +28,7 @@
<?php p($l->t('Restore'))?>
</a>
</span>
+ </div>
</th>
<th id="headerDate">
<span id="modified"><?php p($l->t( 'Deleted' )); ?></span>