Skip to content

Commit

Permalink
Checkbox- Fixes issue where radio checkbox would uncheck itself mista…
Browse files Browse the repository at this point in the history
…kenly when unchecking other radios #2506
  • Loading branch information
jlukic committed Jul 6, 2015
1 parent 7a53664 commit 7d64b86
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
2 changes: 2 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
- **Modal** - `scrolling modal` now correctly inherits rules so that it appears at top of screen on mobile
- **Menu** - Inverted menu no longer includes a 1px transparent border.
- **Menu** - Fixes `compact vertical menu` using `flex` style incorrectly
- **Tab** - Fixed bug where remote loaded tab content would not show `loading tab` on first load.

**Docs**
- **Image** - Added docs for missing `fluid image` variation
- **Modal** - Removed legacy JS animation settings still accidentally in docs
- **Tab** - Added new examples for `evaluateScripts` and HTML5 state tabs

### Version 2.0.0 - June 30, 2015

Expand Down
63 changes: 36 additions & 27 deletions src/definitions/modules/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ $.fn.checkbox = function(parameters) {
;
return $('input[name="' + name + '"]').closest(selector.checkbox);
},
otherRadios: function() {
return module.get.radios().not($module);
},
name: function() {
return $input.attr('name');
}
Expand Down Expand Up @@ -314,25 +317,31 @@ $.fn.checkbox = function(parameters) {

set: {
checked: function() {
module.verbose('Setting class to checked');
$module
.removeClass(className.indeterminate)
.addClass(className.checked)
;
if( module.is.radio() ) {
module.uncheckOthers();
}
if(!module.is.indeterminate() && module.is.checked()) {
module.debug('Input is already checked');
module.debug('Input is already checked, skipping input property change');
return;
}
module.verbose('Setting state to checked', $input[0]);
if( module.is.radio() ) {
module.uncheckOthers();
}
$input
.prop('indeterminate', false)
.prop('checked', true)
;
$module
.removeClass(className.indeterminate)
.addClass(className.checked)
;
module.trigger.change();
},
unchecked: function() {
module.verbose('Removing checked class');
$module
.removeClass(className.indeterminate)
.removeClass(className.checked)
;
if(!module.is.indeterminate() && module.is.unchecked() ) {
module.debug('Input is already unchecked');
return;
Expand All @@ -342,63 +351,63 @@ $.fn.checkbox = function(parameters) {
.prop('indeterminate', false)
.prop('checked', false)
;
$module
.removeClass(className.indeterminate)
.removeClass(className.checked)
;
module.trigger.change();
},
indeterminate: function() {
module.verbose('Setting class to indeterminate');
$module
.addClass(className.indeterminate)
;
if( module.is.indeterminate() ) {
module.debug('Input is already indeterminate');
module.debug('Input is already indeterminate, skipping input property change');
return;
}
module.debug('Setting state to indeterminate');
$input
.prop('indeterminate', true)
;
$module
.addClass(className.indeterminate)
;
module.trigger.change();
},
determinate: function() {
module.verbose('Removing indeterminate class');
$module
.removeClass(className.indeterminate)
;
if( module.is.determinate() ) {
module.debug('Input is already determinate');
module.debug('Input is already determinate, skipping input property change');
return;
}
module.debug('Setting state to determinate');
$input
.prop('indeterminate', false)
;
$module
.removeClass(className.indeterminate)
;
},
disabled: function() {
module.verbose('Setting class to disabled');
$module
.addClass(className.disabled)
;
if( module.is.disabled() ) {
module.debug('Input is already disabled');
module.debug('Input is already disabled, skipping input property change');
return;
}
module.debug('Setting state to disabled');
$input
.prop('disabled', 'disabled')
;
$module
.addClass(className.disabled)
;
module.trigger.change();
},
enabled: function() {
module.verbose('Removing disabled class');
$module.removeClass(className.disabled);
if( module.is.enabled() ) {
module.debug('Input is already enabled');
module.debug('Input is already enabled, skipping input property change');
return;
}
module.debug('Setting state to enabled');
$input
.prop('disabled', false)
;
$module.removeClass(className.disabled);
module.trigger.change();
},
tabbable: function() {
Expand Down Expand Up @@ -459,7 +468,7 @@ $.fn.checkbox = function(parameters) {

uncheckOthers: function() {
var
$radios = module.get.radios()
$radios = module.get.otherRadios()
;
module.debug('Unchecking other radios', $radios);
$radios.removeClass(className.checked);
Expand Down

0 comments on commit 7d64b86

Please sign in to comment.