Skip to content

Commit 9c3ebe0

Browse files
gseguinscottjehl
authored andcommitted
Added state class to label of checkbox/radio
1 parent 3ab9665 commit 9c3ebe0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

js/jquery.mobile.forms.checkboxradio.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
1616
//filter works though.
1717
label = input.closest("form,fieldset,:jqmData(role='page')").find("label").filter('[for="' + input[0].id + '"]'),
1818
inputtype = input.attr( "type" ),
19+
checkedClass = "ui-"+ inputtype + "-on",
20+
uncheckedClass = "ui-"+ inputtype + "-off",
1921
checkedicon = "ui-icon-" + inputtype + "-on",
2022
uncheckedicon = "ui-icon-" + inputtype + "-off";
2123

@@ -25,6 +27,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
2527
$.extend( this,{
2628
label : label,
2729
inputtype : inputtype,
30+
checkedClass : checkedClass,
31+
uncheckedClass : uncheckedClass,
2832
checkedicon : checkedicon,
2933
uncheckedicon : uncheckedicon
3034
});
@@ -133,9 +137,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
133137
// input[0].checked expando doesn't always report the proper value
134138
// for checked='checked'
135139
if ( $(input[0]).prop('checked') ) {
140+
label.addClass( this.checkedClass ).removeClass( this.uncheckedClass );
136141
icon.addClass( this.checkedicon ).removeClass( this.uncheckedicon );
137142

138143
} else {
144+
label.removeClass( this.checkedClass ).addClass( this.uncheckedClass );
139145
icon.removeClass( this.checkedicon ).addClass( this.uncheckedicon );
140146
}
141147

themes/default/jquery.mobile.theme.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,8 @@ a.ui-link-inherit {
828828
.ui-icon-radio-off {
829829
background-color: transparent;
830830
}
831-
.ui-icon-checkbox-on,
832-
.ui-icon-radio-on {
831+
.ui-checkbox-on .ui-icon,
832+
.ui-radio-on .ui-icon {
833833
background-color: #4596ce; /* NOTE: this hex should match the active state color. It's repeated here for cascade */
834834
}
835835
.ui-icon-searchfield {

0 commit comments

Comments
 (0)