diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2012-07-26 11:17:28 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2012-08-02 10:27:17 +0200 |
commit | c2783b9b54ecae8299da0dc593c3813c2bd26fe2 (patch) | |
tree | 8d43ff1b23545ea58a20bbc911f82f23a455acd2 /install/ui/widget.js | |
parent | 1a94109f4ad5bcb304c4c23af868c3cf07ce92ec (diff) | |
download | freeipa.git-c2783b9b54ecae8299da0dc593c3813c2bd26fe2.tar.gz freeipa.git-c2783b9b54ecae8299da0dc593c3813c2bd26fe2.tar.xz freeipa.git-c2783b9b54ecae8299da0dc593c3813c2bd26fe2.zip |
Replace use of attr with prop for booleans
Recommened way of setting boolean HTML attributes is by $.prop(boolean) method not $.attr(boolean) because it sets DOM object property not an attribute. Latter works because of jquery's backward compatibility. This patch makes things clearer.
Some info about prop and attr: http://stackoverflow.com/a/5876747
https://fedorahosted.org/freeipa/ticket/2817
Diffstat (limited to 'install/ui/widget.js')
-rw-r--r-- | install/ui/widget.js | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/install/ui/widget.js b/install/ui/widget.js index ed7fcf76..9b15f2f1 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -297,11 +297,7 @@ IPA.text_widget = function(spec) { that.set_enabled = function(value) { - if(value) { - that.input.removeAttr('disabled'); - } else { - that.input.attr('disabled', 'disabled'); - } + that.input.prop('disabled', !value); }; that.clear = function() { @@ -669,11 +665,11 @@ IPA.checkbox_widget = function (spec) { value = that.checked; } - that.input.attr('checked', value); + that.input.prop('checked', value); }; that.clear = function() { - that.input.attr('checked', false); + that.input.prop('checked', false); }; that.checkbox_save = that.save; @@ -741,18 +737,18 @@ IPA.checkboxes_widget = function (spec) { that.update = function(values) { var inputs = $('input[name="'+that.name+'"]', that.container); - inputs.attr('checked', false); + inputs.prop('checked', false); for (var j=0; values && j<values.length; j++) { var value = values[j]; var input = $('input[name="'+that.name+'"][value="'+value+'"]', that.container); if (!input.length) continue; - input.attr('checked', true); + input.prop('checked', true); } }; that.clear = function() { - $('input[name="'+that.name+'"]').attr('checked', false); + $('input[name="'+that.name+'"]').prop('checked', false); }; that.add_option = function(option) { @@ -829,21 +825,21 @@ IPA.radio_widget = function(spec) { var value = values && values.length ? values[0] : ''; var input = $(that.selector+'[value="'+value+'"]', that.container); if (input.length) { - input.attr('checked', true); + input.prop('checked', true); } else if (that.default_value) { input = $(that.selector+'[value="'+that.default_value+'"]', that.container); - input.attr('checked', true); + input.prop('checked', true); } that.value_changed.notify([that.save()], that); }; that.clear = function() { - $(that.selector, that.container).attr('checked', false); + $(that.selector, that.container).prop('checked', false); if (that.default_value) { var input = $(that.selector+'[value="'+that.default_value+'"]', that.container); - input.attr('checked', true); + input.prop('checked', true); } }; @@ -915,7 +911,7 @@ IPA.select_widget = function(spec) { var value = values[0]; var option = $('option[value="'+value+'"]', that.select); if (!option.length) return; - option.attr('selected', 'selected'); + option.prop('selected', true); }; that.empty = function() { @@ -923,7 +919,7 @@ IPA.select_widget = function(spec) { }; that.clear = function() { - $('option', that.select).attr('selected', ''); + $('option', that.select).prop('selected', false); }; that.set_options_enabled = function(enabled, options) { @@ -1521,24 +1517,24 @@ IPA.table_widget = function (spec) { }; that.select_all = function() { - $('input[name="'+that.name+'"]', that.thead).attr('checked', true). + $('input[name="'+that.name+'"]', that.thead).prop('checked', true). attr('title', IPA.messages.search.unselect_all); - $('input[name="'+that.name+'"]', that.tbody).attr('checked', true); + $('input[name="'+that.name+'"]', that.tbody).prop('checked', true); that.select_changed(); }; that.unselect_all = function() { - $('input[name="'+that.name+'"]', that.thead).attr('checked', false). + $('input[name="'+that.name+'"]', that.thead).prop('checked', false). attr('title', IPA.messages.search.select_all); - $('input[name="'+that.name+'"]', that.tbody).attr('checked', false); + $('input[name="'+that.name+'"]', that.tbody).prop('checked', false); that.select_changed(); }; that.set_values = function(values) { - $('input[name="'+that.name+'"]', that.tbody).attr('checked', false); + $('input[name="'+that.name+'"]', that.tbody).prop('checked', false); for (var i=0; values && i<values.length; i++) { var value = values[i]; - $('input[name="'+that.name+'"][value="'+value+'"]', that.tbody).attr('checked', true); + $('input[name="'+that.name+'"][value="'+value+'"]', that.tbody).prop('checked', true); } that.select_changed(); }; @@ -1697,11 +1693,7 @@ IPA.table_widget = function (spec) { }; that.set_enabled = function(enabled) { - if (enabled) { - $('input[name="'+that.name+'"]', that.table).attr('disabled', false); - } else { - $('input[name="'+that.name+'"]', that.table).attr('disabled', true); - } + $('input[name="'+that.name+'"]', that.table).prop('disabled', !enabled); }; that.clear = function() { @@ -2316,7 +2308,7 @@ IPA.combobox_widget = function(spec) { // if no option found, skip if (!option.length) return; - option.attr('selected', 'selected'); + option.prop('selected', true); that.set_value(option.val()); that.value_changed.notify([], that); |