<thead>
<tr>
<th class="checkbox hide-when-print">
- <%= 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)}" %>
</th>
<% query.inline_columns.each do |column| %>
<%= column_header(column) %>
<thead>
<tr>
<th class="checkbox hide-when-print">
- <%= 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)}" %>
</th>
<% @query.inline_columns.each do |column| %>
// 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();
}
}
function contextMenuUnselectAll() {
+ $('input[type=checkbox].toggle-selection').prop('checked', false);
$('.hascontextmenu').each(function(){
contextMenuRemoveSelection($(this));
});
}
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() {
}
return {width: w, height: h};
}
+
+$(document).ready(function(){
+ $('input[type=checkbox].toggle-selection').on('change', toggleIssuesSelection);
+});