From 46bce8e5400e3acc6e91d40249a81e3d3c7a46db Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 9 Oct 2013 13:15:53 +0200 Subject: [PATCH] fix checkbox --- apps/files_trashbin/js/trash.js | 52 ++++++++++----------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js index 58821cd300b..5fcc60100b0 100644 --- a/apps/files_trashbin/js/trash.js +++ b/apps/files_trashbin/js/trash.js @@ -61,11 +61,12 @@ $(document).ready(function() { $('td.filename input:checkbox').attr('checked', false); $('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) { + event.preventDefault(); var last = $(lastChecked).parent().parent().prevAll().length; var first = $(this).parent().parent().prevAll().length; var start = Math.min(first, last); @@ -73,7 +74,7 @@ $(document).ready(function() { var rows = $(this).parent().parent().parent().children('tr'); for (var i = start; i < end; i++) { $(rows).each(function(index) { - if (index === i) { + if (index == i) { var checkbox = $(this).children().children('input:checkbox'); $(checkbox).attr('checked', 'checked'); $(checkbox).parent().parent().addClass('selected'); @@ -81,16 +82,21 @@ $(document).ready(function() { }); } } - var selectedCount = $('td.filename input:checkbox:checked').length; - $(this).parent().parent().toggleClass('selected'); - if (!$(this).attr('checked')) { - $('#select_all').attr('checked', false); + 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', true); + $('#select_all').attr('checked', 'checked'); } } - processSelection(); + procesSelection(); }); $('.undelete').click('click', function(event) { @@ -178,34 +184,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 -- 2.39.5