commit
223adc3167
|
@ -5,7 +5,6 @@ OCP\User::checkLoggedIn();
|
||||||
|
|
||||||
OCP\App::setActiveNavigationEntry('files_index');
|
OCP\App::setActiveNavigationEntry('files_index');
|
||||||
|
|
||||||
OCP\Util::addScript('files_trashbin', 'trash');
|
|
||||||
OCP\Util::addScript('files_trashbin', 'disableDefaultActions');
|
OCP\Util::addScript('files_trashbin', 'disableDefaultActions');
|
||||||
OCP\Util::addScript('files', 'fileactions');
|
OCP\Util::addScript('files', 'fileactions');
|
||||||
$tmpl = new OCP\Template('files_trashbin', 'index', 'user');
|
$tmpl = new OCP\Template('files_trashbin', 'index', 'user');
|
||||||
|
@ -15,6 +14,7 @@ OCP\Util::addScript('files', 'filelist');
|
||||||
// filelist overrides
|
// filelist overrides
|
||||||
OCP\Util::addScript('files_trashbin', 'filelist');
|
OCP\Util::addScript('files_trashbin', 'filelist');
|
||||||
OCP\Util::addscript('files', 'files');
|
OCP\Util::addscript('files', 'files');
|
||||||
|
OCP\Util::addScript('files_trashbin', 'trash');
|
||||||
|
|
||||||
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
|
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,13 @@ $(document).ready(function() {
|
||||||
|
|
||||||
if (typeof FileActions !== 'undefined') {
|
if (typeof FileActions !== 'undefined') {
|
||||||
FileActions.register('all', 'Restore', OC.PERMISSION_READ, OC.imagePath('core', 'actions/history'), function(filename) {
|
FileActions.register('all', 'Restore', OC.PERMISSION_READ, OC.imagePath('core', 'actions/history'), function(filename) {
|
||||||
var tr=$('tr').filterAttr('data-file', 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 deleteAction = $('tr').filterAttr('data-file', filename).children("td.date").children(".action.delete");
|
||||||
var undeleteAction = $('tr').filterAttr('data-file',filename).children("td.date");
|
deleteAction.removeClass('delete-icon').addClass('progress-icon');
|
||||||
var files = tr.attr('data-file');
|
|
||||||
undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner;
|
|
||||||
disableActions();
|
disableActions();
|
||||||
$.post(OC.filePath('files_trashbin','ajax','undelete.php'),
|
$.post(OC.filePath('files_trashbin', 'ajax', 'undelete.php'),
|
||||||
{files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') },
|
{files: JSON.stringify([filename]), dirlisting: tr.attr('data-dirlisting')},
|
||||||
function(result){
|
function(result) {
|
||||||
for (var i = 0; i < result.data.success.length; i++) {
|
for (var i = 0; i < result.data.success.length; i++) {
|
||||||
var row = document.getElementById(result.data.success[i].filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
|
@ -21,26 +19,23 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
enableActions();
|
enableActions();
|
||||||
FileList.updateFileSummary();
|
FileList.updateFileSummary();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
FileActions.register('all', 'Delete', OC.PERMISSION_READ, function () {
|
FileActions.register('all', 'Delete', OC.PERMISSION_READ, function() {
|
||||||
return OC.imagePath('core', 'actions/delete');
|
return OC.imagePath('core', 'actions/delete');
|
||||||
}, function (filename) {
|
}, function(filename) {
|
||||||
$('.tipsy').remove();
|
$('.tipsy').remove();
|
||||||
|
var tr = $('tr').filterAttr('data-file', filename);
|
||||||
var tr=$('tr').filterAttr('data-file', filename);
|
var deleteAction = $('tr').filterAttr('data-file', filename).children("td.date").children(".action.delete");
|
||||||
var deleteAction = $('tr').filterAttr('data-file',filename).children("td.date").children(".action.delete");
|
deleteAction.removeClass('delete-icon').addClass('progress-icon');
|
||||||
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();
|
disableActions();
|
||||||
$.post(OC.filePath('files_trashbin','ajax','delete.php'),
|
$.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'),
|
||||||
{files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') },
|
{files: JSON.stringify([filename]), dirlisting: tr.attr('data-dirlisting')},
|
||||||
function(result){
|
function(result) {
|
||||||
for (var i = 0; i < result.data.success.length; i++) {
|
for (var i = 0; i < result.data.success.length; i++) {
|
||||||
var row = document.getElementById(result.data.success[i].filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
|
@ -50,26 +45,28 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
enableActions();
|
enableActions();
|
||||||
FileList.updateFileSummary();
|
FileList.updateFileSummary();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sets the select_all checkbox behaviour :
|
// Sets the select_all checkbox behaviour :
|
||||||
$('#select_all').click(function() {
|
$('#select_all').click(function() {
|
||||||
if($(this).attr('checked')){
|
if ($(this).attr('checked')) {
|
||||||
// Check all
|
// Check all
|
||||||
$('td.filename input:checkbox').attr('checked', true);
|
$('td.filename input:checkbox').attr('checked', true);
|
||||||
$('td.filename input:checkbox').parent().parent().addClass('selected');
|
$('td.filename input:checkbox').parent().parent().addClass('selected');
|
||||||
}else{
|
} else {
|
||||||
// Uncheck all
|
// Uncheck all
|
||||||
$('td.filename input:checkbox').attr('checked', false);
|
$('td.filename input:checkbox').attr('checked', false);
|
||||||
$('td.filename input:checkbox').parent().parent().removeClass('selected');
|
$('td.filename input:checkbox').parent().parent().removeClass('selected');
|
||||||
}
|
}
|
||||||
processSelection();
|
procesSelection();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('td.filename input:checkbox').live('change',function(event) {
|
$('#fileList').on('click', 'td.filename a', function(event) {
|
||||||
if (event.shiftKey) {
|
if (event.shiftKey) {
|
||||||
|
event.preventDefault();
|
||||||
var last = $(lastChecked).parent().parent().prevAll().length;
|
var last = $(lastChecked).parent().parent().prevAll().length;
|
||||||
var first = $(this).parent().parent().prevAll().length;
|
var first = $(this).parent().parent().prevAll().length;
|
||||||
var start = Math.min(first, last);
|
var start = Math.min(first, last);
|
||||||
|
@ -77,7 +74,7 @@ $(document).ready(function() {
|
||||||
var rows = $(this).parent().parent().parent().children('tr');
|
var rows = $(this).parent().parent().parent().children('tr');
|
||||||
for (var i = start; i < end; i++) {
|
for (var i = start; i < end; i++) {
|
||||||
$(rows).each(function(index) {
|
$(rows).each(function(index) {
|
||||||
if (index === i) {
|
if (index == i) {
|
||||||
var checkbox = $(this).children().children('input:checkbox');
|
var checkbox = $(this).children().children('input:checkbox');
|
||||||
$(checkbox).attr('checked', 'checked');
|
$(checkbox).attr('checked', 'checked');
|
||||||
$(checkbox).parent().parent().addClass('selected');
|
$(checkbox).parent().parent().addClass('selected');
|
||||||
|
@ -85,33 +82,37 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var selectedCount=$('td.filename input:checkbox:checked').length;
|
var checkbox = $(this).parent().children('input:checkbox');
|
||||||
$(this).parent().parent().toggleClass('selected');
|
lastChecked = checkbox;
|
||||||
if(!$(this).attr('checked')){
|
if ($(checkbox).attr('checked')) {
|
||||||
$('#select_all').attr('checked',false);
|
$(checkbox).removeAttr('checked');
|
||||||
}else{
|
$(checkbox).parent().parent().removeClass('selected');
|
||||||
if(selectedCount==$('td.filename input:checkbox').length){
|
$('#select_all').removeAttr('checked');
|
||||||
$('#select_all').attr('checked',true);
|
} 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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
processSelection();
|
procesSelection();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.undelete').click('click',function(event) {
|
$('.undelete').click('click', function(event) {
|
||||||
event.preventDefault();
|
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 files=getSelectedFiles('file');
|
|
||||||
var fileslist = JSON.stringify(files);
|
var fileslist = JSON.stringify(files);
|
||||||
var dirlisting=getSelectedFiles('dirlisting')[0];
|
var dirlisting = getSelectedFiles('dirlisting')[0];
|
||||||
disableActions();
|
disableActions();
|
||||||
for (var i=0; i<files.length; i++) {
|
for (var i = 0; i < files.length; i++) {
|
||||||
var undeleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date");
|
var deleteAction = $('tr').filterAttr('data-file', files[i]).children("td.date").children(".action.delete");
|
||||||
undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner;
|
deleteAction.removeClass('delete-icon').addClass('progress-icon');
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post(OC.filePath('files_trashbin','ajax','undelete.php'),
|
$.post(OC.filePath('files_trashbin', 'ajax', 'undelete.php'),
|
||||||
{files:fileslist, dirlisting:dirlisting},
|
{files: fileslist, dirlisting: dirlisting},
|
||||||
function(result){
|
function(result) {
|
||||||
for (var i = 0; i < result.data.success.length; i++) {
|
for (var i = 0; i < result.data.success.length; i++) {
|
||||||
var row = document.getElementById(result.data.success[i].filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
|
@ -120,26 +121,26 @@ $(document).ready(function() {
|
||||||
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
||||||
}
|
}
|
||||||
enableActions();
|
enableActions();
|
||||||
});
|
FileList.updateFileSummary();
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.delete').click('click',function(event) {
|
$('.delete').click('click', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
console.log("delete selected");
|
var files = getSelectedFiles('file');
|
||||||
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 fileslist = JSON.stringify(files);
|
||||||
var dirlisting=getSelectedFiles('dirlisting')[0];
|
var dirlisting = getSelectedFiles('dirlisting')[0];
|
||||||
|
|
||||||
disableActions();
|
disableActions();
|
||||||
for (var i=0; i<files.length; i++) {
|
for (var i = 0; i < files.length; i++) {
|
||||||
var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date");
|
var deleteAction = $('tr').filterAttr('data-file', files[i]).children("td.date").children(".action.delete");
|
||||||
deleteAction[0].innerHTML = deleteAction[0].innerHTML+spinner;
|
deleteAction.removeClass('delete-icon').addClass('progress-icon');
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post(OC.filePath('files_trashbin','ajax','delete.php'),
|
$.post(OC.filePath('files_trashbin', 'ajax', 'delete.php'),
|
||||||
{files:fileslist, dirlisting:dirlisting},
|
{files: fileslist, dirlisting: dirlisting},
|
||||||
function(result){
|
function(result) {
|
||||||
for (var i = 0; i < result.data.success.length; i++) {
|
for (var i = 0; i < result.data.success.length; i++) {
|
||||||
var row = document.getElementById(result.data.success[i].filename);
|
var row = document.getElementById(result.data.success[i].filename);
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
|
@ -148,7 +149,10 @@ $(document).ready(function() {
|
||||||
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
||||||
}
|
}
|
||||||
enableActions();
|
enableActions();
|
||||||
});
|
FileList.updateFileSummary();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#fileList').on('click', 'td.filename a', function(event) {
|
$('#fileList').on('click', 'td.filename a', function(event) {
|
||||||
|
@ -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
|
* @brief get a list of selected files
|
||||||
* @param string property (option) the property of the file requested
|
* @param string property (option) the property of the file requested
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th id='headerName'>
|
<th id='headerName'>
|
||||||
|
<div id="headerName-container">
|
||||||
<input type="checkbox" id="select_all" />
|
<input type="checkbox" id="select_all" />
|
||||||
|
<label for="select_all"></label>
|
||||||
<span class='name'><?php p($l->t( 'Name' )); ?></span>
|
<span class='name'><?php p($l->t( 'Name' )); ?></span>
|
||||||
<span class='selectedActions'>
|
<span class='selectedActions'>
|
||||||
<a href="" class="undelete">
|
<a href="" class="undelete">
|
||||||
|
@ -26,6 +28,7 @@
|
||||||
<?php p($l->t('Restore'))?>
|
<?php p($l->t('Restore'))?>
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
</th>
|
</th>
|
||||||
<th id="headerDate">
|
<th id="headerDate">
|
||||||
<span id="modified"><?php p($l->t( 'Deleted' )); ?></span>
|
<span id="modified"><?php p($l->t( 'Deleted' )); ?></span>
|
||||||
|
|
Loading…
Reference in New Issue