Skip to content

Commit 189d2ae

Browse files
author
Gabriel Schulhof
committed
Checkboxradio: Deprecate option "mini"
This marks the occurrences of the option as deprecated, and moves processing of the initial value of wrapperClass from _wrapper() to _setOptions(), so that ui-mini will be applied if it's present in wrapperClass even if the mini option is false. Note that this requires the wrapperClass option to be processed after the mini option in _setOptions(). Closes jquery-archivegh-7466 Fixes jquery-archivegh-7463
1 parent 2dd9cf4 commit 189d2ae

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

demos/checkboxradio-checkbox/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242

4343
<h2>Mini size</h2>
4444

45-
<p>For a more compact version that is useful in toolbars and tight spaces, add the <code>data-mini="true"</code> attribute to the element to create a mini version. </p>
45+
<p>For a more compact version that is useful in toolbars and tight spaces, add the <code>ui-mini</code> class to the element's <code>data-wrapper-class</code> attribute to create a mini version. </p>
4646

4747
<div data-demo-html="true">
4848
<form>
49-
<input type="checkbox" name="checkbox-mini-0" id="checkbox-mini-0" data-mini="true">
49+
<input type="checkbox" name="checkbox-mini-0" id="checkbox-mini-0" data-wrapper-class="ui-mini">
5050
<label for="checkbox-mini-0">I agree</label>
5151
</form>
5252
</div><!--/demo-html -->
@@ -89,7 +89,7 @@
8989

9090
<h2>Icon position</h2>
9191

92-
<p>To swap the position of the check icon from the default position on the left, add the <code>data-iconpos="right"</code> attribute to the fieldset to create a mini version. </p>
92+
<p>To swap the position of the check icon from the default position on the left, add the <code>data-iconpos="right"</code> attribute to the fieldset.</p>
9393

9494
<div data-demo-html="true">
9595
<form>

demos/checkboxradio-radio/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
<h2>Mini size</h2>
8383

84-
<p>For a more compact version that is useful in toolbars and tight spaces, add the <code>data-mini="true"</code> attribute to the element to create a mini version. </p>
84+
<p>For a more compact version that is useful in toolbars and tight spaces, add the <code>ui-mini</code> class to the element to create a mini version. </p>
8585

8686
<div data-demo-html="true">
8787
<form>

demos/grids-buttons/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@
8585
<select id="grid-select-2" name="grid-select-2" data-shadow="false" data-mini="true">
8686
<option>Select</option>
8787
<option value="1">The 1st Option</option>
88-
<option value="2">The 2nt Option</option>
88+
<option value="2">The 2nd Option</option>
8989
<option value="3">The 3rd Option</option>
9090
<option value="4">The 4th Option</option>
9191
</select>
9292
</div>
9393
<div class="ui-block-b">
9494
<label for="grid-checkbox-2">Checkbox</label>
95-
<input type="checkbox" id="grid-checkbox-2" name="grid-checkbox-2" data-mini="true">
95+
<input type="checkbox" id="grid-checkbox-2" name="grid-checkbox-2" data-wrapper-class="mini">
9696
</div>
9797
<div class="ui-block-c">
9898
<label for="grid-radio-2">Radio</label>
99-
<input type="radio" id="grid-radio-2" name="grid-radio-2" data-mini="true">
99+
<input type="radio" id="grid-radio-2" name="grid-radio-2" data-wrapper-class="mini">
100100
</div>
101101
</form>
102102
</div><!--/demo-html -->

js/widgets/forms/checkboxradio.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ $.widget( "mobile.checkboxradio", $.extend( {
2626

2727
options: {
2828
theme: "inherit",
29+
30+
// Deprecated as of 1.5.0
2931
mini: false,
3032
wrapperClass: null,
3133
enhanced: false,
@@ -60,6 +62,7 @@ $.widget( "mobile.checkboxradio", $.extend( {
6062
o.iconpos = inheritAttr( input, "iconpos" ) ||
6163
label.element.attr( "data-" + $.mobile.ns + "iconpos" ) || o.iconpos,
6264

65+
// Deprecated as of 1.5.0
6366
// Establish options
6467
o.mini = inheritAttr( input, "mini" ) || o.mini;
6568

@@ -135,15 +138,16 @@ $.widget( "mobile.checkboxradio", $.extend( {
135138
this._setOptions({
136139
"theme": this.options.theme,
137140
"iconpos": this.options.iconpos,
141+
"wrapperClass": this.options.wrapperClass,
142+
143+
// Deprecated as of 1.5.0
138144
"mini": this.options.mini
139145
});
140146

141147
},
142148

143149
_wrapper: function() {
144-
return $( "<div class='" +
145-
( this.options.wrapperClass ? this.options.wrapperClass : "" ) +
146-
" ui-" + this.inputtype +
150+
return $( "<div class='ui-" + this.inputtype +
147151
( this.options.disabled ? " ui-state-disabled" : "" ) + "' ></div>" );
148152
},
149153

@@ -339,6 +343,8 @@ $.widget( "mobile.checkboxradio", $.extend( {
339343
this.input.prop( "disabled", !!options.disabled );
340344
outer.toggleClass( "ui-state-disabled", !!options.disabled );
341345
}
346+
347+
// Deprecated as of 1.5.0
342348
if ( options.mini !== undefined ) {
343349
outer.toggleClass( "ui-mini", !!options.mini );
344350
}

tests/unit/checkboxradio/checkboxradio_core.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
*/
44
(function($){
55
module( 'jquery.mobile.forms.checkboxradio.js' );
6+
test( "Checkbox is made mini when ui-mini is among wrapper classes", function() {
7+
var widget = $( "#wrapper-class-mini" );
8+
9+
deepEqual( widget.checkboxradio( "option", "mini" ), false,
10+
"Checkboxradio option mini is false" );
11+
deepEqual( widget.parent().hasClass( "ui-mini" ),
12+
true,
13+
"Widget has class ui-mini" );
14+
});
15+
616
test( "Programmatic click on radio input correctly updates group", function() {
717
var first = $( "#programmatic-click-test input" ).eq( 0 ),
818
last = $( "#programmatic-click-test input" ).eq( 2 );

tests/unit/checkboxradio/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
],
1919
[
2020
"widgets/forms/checkboxradio",
21-
"widgets/page" // Needed by the test suite
2221
],
2322
[
2423
"checkboxradio_core.js"
@@ -40,6 +39,8 @@
4039
<div data-nstest-role="page" data-nstest-theme="b">
4140
<div data-nstest-role="content" id="the-content">
4241

42+
<label>Wrapper Class Mini<input type="checkbox" id="wrapper-class-mini" data-nstest-wrapper-class="ui-mini"></label>
43+
4344
<div id="programmatic-click-test">
4445
<label>Radio 1<input type="radio" name="programmatic-click-test" checked></label>
4546
<label>Radio 2<input type="radio" name="programmatic-click-test"></label>

0 commit comments

Comments
 (0)