From c29727dd39fa3fac888057c2ffe7059af96d523a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 23 Oct 2015 16:45:27 +0000 Subject: [PATCH] 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 --- app/views/issues/_list.html.erb | 5 ++--- app/views/timelog/_list.html.erb | 4 +--- public/javascripts/context_menu.js | 22 ++++++++++------------ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 57ae6b2bc..7d3654169 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -5,9 +5,8 @@ - <%= link_to image_tag('toggle_check.png'), {}, - :onclick => 'toggleIssuesSelection(this); return false;', - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> + <%= check_box_tag 'check_all', '', false, :class => 'toggle-selection', + :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> <% query.inline_columns.each do |column| %> <%= column_header(column) %> diff --git a/app/views/timelog/_list.html.erb b/app/views/timelog/_list.html.erb index d257375d5..7ec60cdbd 100644 --- a/app/views/timelog/_list.html.erb +++ b/app/views/timelog/_list.html.erb @@ -5,9 +5,7 @@ - <%= link_to image_tag('toggle_check.png'), - {}, - :onclick => 'toggleIssuesSelection(this); return false;', + <%= check_box_tag 'check_all', '', false, :class => 'toggle-selection', :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> <% @query.inline_columns.each do |column| %> 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); +}); -- 2.39.5