Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 7a55b27

Browse files
author
Gabriel Schulhof
committed
Checkboxradio: Get rid of buttonMarkup.
1 parent e28733d commit 7a55b27

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

css/structure/jquery.mobile.forms.checkboxradio.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
.ui-checkbox .ui-mini.ui-btn-icon-right .ui-btn-inner, .ui-radio .ui-mini.ui-btn-icon-right .ui-btn-inner { padding-right: 36px; }
1010
.ui-checkbox .ui-btn-icon-top .ui-btn-inner, .ui-radio .ui-btn-icon-top .ui-btn-inner { padding-right: 0; padding-left: 0; text-align: center; }
1111
.ui-checkbox .ui-btn-icon-bottom .ui-btn-inner, .ui-radio .ui-btn-icon-bottom .ui-btn-inner { padding-right: 0; padding-left: 0; text-align: center; }
12-
.ui-checkbox .ui-icon, .ui-radio .ui-icon { top: 1.1em; }
1312
.ui-checkbox .ui-btn-icon-left .ui-icon, .ui-radio .ui-btn-icon-left .ui-icon { left: 15px; }
1413
.ui-checkbox .ui-mini.ui-btn-icon-left .ui-icon, .ui-radio .ui-mini.ui-btn-icon-left .ui-icon { left: 9px; }
1514
.ui-checkbox .ui-btn-icon-right .ui-icon, .ui-radio .ui-btn-icon-right .ui-icon { right: 15px; }

css/themes/default/jquery.mobile.theme.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,7 @@ button,
849849
-webkit-border-radius: 3px;
850850
border-radius: 3px;
851851
}
852-
.ui-icon-checkbox-off,
853-
.ui-icon-radio-off {
854-
background-color: transparent;
855-
}
852+
856853
.ui-checkbox-on .ui-icon,
857854
.ui-radio-on .ui-icon {
858855
background-color: #4596ce /*{global-active-background-color}*/; /* NOTE: this hex should match the active state color. It's repeated here for cascade */

js/widgets/forms/checkboxradio.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
define( [ "jquery",
1313
"../../jquery.mobile.core",
1414
"../../jquery.mobile.widget",
15-
"../../jquery.mobile.buttonMarkup",
1615
"../optionDemultiplexer",
1716
"./reset" ], function( jQuery ) {
1817
//>>excludeEnd("jqmBuildExclude");
@@ -37,7 +36,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, $.extend( {
3736
mini = inheritAttr( input, "mini" ) || o.mini,
3837
checkedState = inputtype + "-on",
3938
uncheckedState = inputtype + "-off",
40-
iconpos = inheritAttr( input, "iconpos" ),
39+
iconpos = inheritAttr( input, "iconpos" ) || "left",
4140
checkedClass = "ui-" + checkedState,
4241
uncheckedClass = "ui-" + uncheckedState,
4342
wrapper;
@@ -46,20 +45,16 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, $.extend( {
4645
return;
4746
}
4847

48+
// Establish options
4949
// If there's no selected theme check the data attr
5050
if ( !o.theme ) {
5151
o.theme = $.mobile.getInheritedTheme( this.element, "a" );
5252
}
53+
o.mini = inheritAttr( input, "mini" ) || o.mini;
5354

5455
// Expose for other methods
5556
$.extend( this, {
56-
//save buttonMarkup options to use them in refresh
57-
buttonMarkupOptions: {
58-
theme: o.theme,
59-
shadow: false,
60-
mini: mini,
61-
iconpos: iconpos
62-
},
57+
iconpos: iconpos,
6358
label: label,
6459
inputtype: inputtype,
6560
checkedClass: checkedClass,
@@ -71,8 +66,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, $.extend( {
7166
// Wrap the input + label in a div
7267
wrapper = document.createElement( "div" );
7368
wrapper.className = "ui-" + inputtype;
74-
7569
input.add( label ).wrapAll( wrapper );
70+
label.addClass( "ui-btn ui-btn-corner-all ui-btn-icon-" + iconpos );
7671

7772
this._on( label, {
7873
vmouseover: "_handleLabelVMouseOver",
@@ -87,6 +82,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, $.extend( {
8782
});
8883

8984
this._handleFormReset();
85+
this._setOptions( o );
9086
this.refresh();
9187
},
9288

@@ -183,20 +179,21 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, $.extend( {
183179
refresh: function() {
184180
var input = this.element[ 0 ],
185181
active = " " + $.mobile.activeBtnClass,
186-
checkedClass = this.checkedClass + ( this.element.parents( ".ui-controlgroup-horizontal" ).length ? active : "" ),
187-
label = this.label,
188-
options = this.buttonMarkupOptions;
189-
182+
hasIcon = ( this.element.parents( ".ui-controlgroup-horizontal" ).length === 0 ),
183+
checkedClass = this.checkedClass + ( hasIcon ? "" : active ),
184+
label = this.label;
185+
186+
label
187+
.toggleClass( "ui-btn-icon-" + this.iconpos, hasIcon )
188+
.toggleClass( "ui-icon", hasIcon )
189+
.toggleClass( "ui-icon-" + this.checkedicon, input.checked )
190+
.toggleClass( "ui-icon-" + this.uncheckedicon, !input.checked );
190191
if ( input.checked ) {
191-
options.icon = this.checkedicon;
192-
label.removeClass( this.uncheckedClass + active ).addClass( checkedClass ).buttonMarkup( options );
192+
label.removeClass( this.uncheckedClass + active ).addClass( checkedClass );
193193
} else {
194-
options.icon = this.uncheckedicon;
195-
label.removeClass( checkedClass ).addClass( this.uncheckedClass ).buttonMarkup( options );
194+
label.removeClass( checkedClass ).addClass( this.uncheckedClass );
196195
}
197196

198-
this.buttonMarkupOptions = {};
199-
200197
if ( input.disabled ) {
201198
this.disable();
202199
} else {
@@ -205,11 +202,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, $.extend( {
205202
},
206203

207204
_setTheme: function( value ) {
208-
this.label.buttonMarkup( { theme: value } );
205+
this.label.removeClass( "ui-btn-" + this.options.theme ).addClass( "ui-btn-" + value );
209206
},
210207

211208
_setMini: function( value ) {
212-
this.label.buttonMarkup( { mini: !!value } );
209+
this.label.toggleClass( "ui-mini", !!value );
213210
},
214211

215212
_setDisabled: function( value ) {

0 commit comments

Comments
 (0)