From c29727dd39fa3fac888057c2ffe7059af96d523a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 23 Oct 2015 16:45:27 +0000 Subject: Replaces the link with a checkbox to select/unselect all items in the list. git-svn-id: http://svn.redmine.org/redmine/trunk@14729 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- public/javascripts/context_menu.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'public/javascripts') diff --git a/public/javascripts/context_menu.js b/public/javascripts/context_menu.js index de848a1ed..2b48e351b 100644 --- a/public/javascripts/context_menu.js +++ b/public/javascripts/context_menu.js @@ -67,6 +67,8 @@ function contextMenuClick(event) { // click is outside the rows if (target.is('a') && (target.hasClass('disabled') || target.hasClass('submenu'))) { event.preventDefault(); + } else if (target.is('.toggle-selection')) { + // nop } else { contextMenuUnselectAll(); } @@ -149,6 +151,7 @@ function contextMenuLastSelected() { } function contextMenuUnselectAll() { + $('input[type=checkbox].toggle-selection').prop('checked', false); $('.hascontextmenu').each(function(){ contextMenuRemoveSelection($(this)); }); @@ -208,18 +211,9 @@ function contextMenuInit(url) { } function toggleIssuesSelection(el) { - var boxes = $(el).parents('form').find('input[type=checkbox]'); - var all_checked = true; - boxes.each(function(){ if (!$(this).prop('checked')) { all_checked = false; } }); - boxes.each(function(){ - if (all_checked) { - $(this).removeAttr('checked'); - $(this).parents('tr').removeClass('context-menu-selection'); - } else if (!$(this).prop('checked')) { - $(this).prop('checked', true); - $(this).parents('tr').addClass('context-menu-selection'); - } - }); + var checked = $(this).prop('checked'); + var boxes = $(this).parents('table').find('input[name=ids\\[\\]]'); + boxes.prop('checked', checked).parents('tr').toggleClass('context-menu-selection', checked); } function window_size() { @@ -237,3 +231,7 @@ function window_size() { } return {width: w, height: h}; } + +$(document).ready(function(){ + $('input[type=checkbox].toggle-selection').on('change', toggleIssuesSelection); +}); -- cgit v1.2.3