Skip to content

Commit

Permalink
Convert every onclick on checkboxes to onchange
Browse files Browse the repository at this point in the history
This is so that checkbox handlers do the correct thing even when the checkbox was checked by keyboard, etc.

https://bugzilla.redhat.com/show_bug.cgi?id=1343659
  • Loading branch information
himdel committed Aug 17, 2016
1 parent 792e03e commit 76bbf4c
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/automate_import_export.js
Expand Up @@ -191,7 +191,7 @@ var Automate = {
showSuccessMessage('Import cancelled');
});

$('#toggle-all').click(function() {
$('#toggle-all').on('change', function() {
$('.domain-tree').dynatree('getRoot').visit(function(node) {
node.select($('#toggle-all').prop('checked'));
});
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/miq_grid.js
Expand Up @@ -18,7 +18,7 @@

// table-checkable
if (table.hasClass('table-checkable')) {
checkboxes.click(function (_e) {
checkboxes.on('change', function (_e) {
var checked = $.map(checkboxes.filter(':checked'), function (cb) {
return cb.value;
});
Expand All @@ -32,7 +32,7 @@
});

// Handle the click on the "Check all" checkbox
checkall.click(function (_e) {
checkall.on('change', function (_e) {
var unchecked = checkboxes.filter(':not(:checked)');
if (unchecked.length > 0) {
unchecked.trigger('click');
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/miq_ujs_bindings.js
Expand Up @@ -127,7 +127,7 @@ $(document).ready(function () {
}
});

$(document).on('click', '[data-miq_observe_checkbox]', function (event) {
$(document).on('change', '[data-miq_observe_checkbox]', function (event) {
var el = $(this);
var parms = $.parseJSON(el.attr('data-miq_observe_checkbox'));
var url = parms.url;
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_ae_tree_select.html.haml
Expand Up @@ -34,7 +34,7 @@
:autoload => true})
.modal-footer
%div{:id => "include_domain_prefix_div"}
%input#include_domain_prefix_chk{:onclick => "miqOnClickIncludeDomainPrefix()",
%input#include_domain_prefix_chk{:onchange => "miqOnClickIncludeDomainPrefix()",
:type => "checkbox",
:disabled => "disabled"}
= _("Include Domain prefix in the path")
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_drift_history.html.haml
Expand Up @@ -17,7 +17,7 @@
- @timestamps.reverse.each_with_index do |ts, idx|
%tr
%td
= check_box_tag("check_#{(@timestamps.length - 1 - idx)}", 1, false, :class => "listcheckbox", :onclick => "miqUpdateButtons(this,'center_tb');")
= check_box_tag("check_#{(@timestamps.length - 1 - idx)}", 1, false, :class => "listcheckbox", :onchange => "miqUpdateButtons(this, 'center_tb');")
%td
= h(format_timezone(ts, Time.zone, "view"))
(#{h(time_ago_in_words(ts.in_time_zone(Time.zone)))} ago)
2 changes: 1 addition & 1 deletion app/views/layouts/_list_grid.html.haml
Expand Up @@ -65,7 +65,7 @@
%td{{:onclick => (cell[:is_checkbox] || cell[:is_button]) ? "event.stopPropagation()" : false}}
- if cell[:is_checkbox]
= check_box_tag("check_#{row[:id]}", row[:id], false,
:onclick => "miqGridOnCheck(this, '#{button_div}')",
:onchange => "miqGridOnCheck(this, '#{button_div}')",
:class => "list-grid-checkbox")
- elsif cell[:is_button]
%button.btn.btn-primary{:onclick => cell[:onclick] + "; return false;",
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/gtl/_grid.html.haml
Expand Up @@ -14,7 +14,7 @@
= check_box_tag("check_#{to_cid(@id)}", 1, false,
:style => "padding-bottom: 0px; margin-bottom: 0px",
:class => "listcheckbox list-grid-checkbox",
:onclick => "miqGridOnCheck(this, '#{button_div}', 'gtl_div');")
:onchange => "miqGridOnCheck(this, '#{button_div}', 'gtl_div');")
%td
= render_quadicon(item, :mode => :icon)
%tr
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/gtl/_list.html.haml
Expand Up @@ -84,7 +84,7 @@
%td.narrow
= check_box_tag("check_#{@id}", 1, false,
:class => "listcheckbox list-grid-checkbox",
:onclick => "miqGridOnCheck(this, '#{button_div}', 'gtl_div');")
:onchange => "miqGridOnCheck(this, '#{button_div}', 'gtl_div');")
- title = ""
- click = ""
- unless (@embedded || @no_checkboxes) && ! @showlinks
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/gtl/_tile.html.haml
Expand Up @@ -19,7 +19,7 @@
- unless @embedded || @no_checkboxes
= check_box_tag("check_#{to_cid(@id)}", 1, false,
:class => "listcheckbox list-grid-checkbox",
:onclick => "miqGridOnCheck(this, '#{button_div}', 'gtl_div');")
:onchange => "miqGridOnCheck(this, '#{button_div}', 'gtl_div');")
%td
= render_quadicon(item, :mode => :icon)
%tr
Expand Down
Expand Up @@ -68,7 +68,7 @@
e.preventDefault();
});

$('#check-all').click(function (e) {
$('#check-all').on('change', function (e) {
$("table#import-grid tbody input[type='checkbox']").prop('checked', $(this).prop('checked'));
});

Expand Down
5 changes: 2 additions & 3 deletions app/views/ops/_settings_cu_collection_tab.html.haml
Expand Up @@ -29,7 +29,7 @@
%br/
%b= _("Enable Collection by %{clusters}") % {:clusters => cluster_title}
%br/
%input#cl_toggle{:name => "cl_toggle", :onclick => "miqCheckCUAll(this,'#{@cluster_tree.name}');", :type => "checkbox"}/
%input#cl_toggle{:name => "cl_toggle", :onchange => "miqCheckCUAll(this,'#{@cluster_tree.name}');", :type => "checkbox"}/
= _("Check All")
:javascript
miqDynatreeResetState('#{j_str @cluster_tree.name}');
Expand All @@ -54,9 +54,8 @@
%br/
%b= _("Enable Collection by Datastore")
%br/
%input#ds_toggle{:name => "ds_toggle", :onclick => "miqCheckCUAll(this,'#{@datastore_tree.name}');", :type => "checkbox"}/
%input#ds_toggle{:name => "ds_toggle", :onchange => "miqCheckCUAll(this,'#{@datastore_tree.name}');", :type => "checkbox"}/
= _("Check All")
:javascript
miqDynatreeResetState('#{j_str @datastore_tree.name}');
= render(:partial => 'shared/tree', :locals => {:tree => @datastore_tree, :name => @datastore_tree.name})

2 changes: 1 addition & 1 deletion app/views/ops/rhn/_server_table.html.haml
Expand Up @@ -62,7 +62,7 @@
= check_box_tag("check_server_#{update.id}", 1,
update.checked,
:class => 'listcheckbox',
:onclick => "miqUpdateButtons(this,'rhn_buttons');")
:onchange => "miqUpdateButtons(this, 'rhn_buttons');")
%td= update.name
%td= update.zone
%td= update.status
Expand Down
2 changes: 1 addition & 1 deletion app/views/report/_export_widgets.html.haml
Expand Up @@ -92,7 +92,7 @@
e.preventDefault();
});

$('#check-all').click(function (e) {
$('#check-all').on('change', function (e) {
$("#import-widgets-form table tbody input[type='checkbox']").prop('checked', $(this).prop('checked'));
});

Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_master_toggle.html.haml
@@ -1,4 +1,4 @@
%input#masterToggle{:name => "masterToggle",
:type => "checkbox",
:onclick => "miqUpdateAllCheckboxes('#{button_div}');"}
:onchange => "miqUpdateAllCheckboxes('#{button_div}');"}
= label
2 changes: 1 addition & 1 deletion app/views/vm_common/_vmtree.html.haml
@@ -1,6 +1,6 @@
#vm_tree_div
= render :partial => "layouts/flash_msg"
%input#masterToggle{:type => "checkbox", :name => "masterToggle", :onclick => "miqCheckAll(this, 'genealogy_tree');"}
%input#masterToggle{:type => "checkbox", :name => "masterToggle", :onchange => "miqCheckAll(this, 'genealogy_tree');"}
= _("(Check All)")
%p

Expand Down

0 comments on commit 76bbf4c

Please sign in to comment.