Skip to content

Commit 3c32dff

Browse files
committed
switch control group to explicit call site exclusion
1 parent b3c0042 commit 3c32dff

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

js/jquery.mobile.controlGroup.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ define( [ "jquery", "./jquery.mobile.buttonMarkup" ], function( $ ) {
77
(function( $, undefined ) {
88

99
$.fn.controlgroup = function( options ) {
10-
var $workingSet = this;
11-
12-
// trim the working set when ignoring content is switched on
13-
$workingSet = $.mobile.enhanceable( $workingSet );
14-
1510
function flipClasses( els, flCorners ) {
1611
els.removeClass( "ui-btn-corner-all ui-shadow" )
1712
.eq( 0 ).addClass( flCorners[ 0 ] )
1813
.end()
1914
.last().addClass( flCorners[ 1 ] ).addClass( "ui-controlgroup-last" );
2015
}
2116

22-
return $workingSet.each(function() {
17+
return this.each(function() {
2318
var $el = $( this ),
2419
o = $.extend({
2520
direction: $el.jqmData( "type" ) || "vertical",

js/jquery.mobile.core.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ define( [ "jquery", "../external/requirejs/text!../version.txt", "./jquery.mobil
270270
return $( "<div/>" ).text( $(this).text() ).html();
271271
};
272272

273+
// fluent helper function for the mobile namespaced equivalent
274+
$.fn.jqmEnhanceable = function() {
275+
return $.mobile.enhanceable( this );
276+
};
277+
273278
// Monkey-patching Sizzle to filter the :jqmData selector
274279
var oldFind = $.find,
275280
jqmDataRE = /:jqmData\(([^)]*)\)/g;

js/jquery.mobile.init.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
167167
//auto self-init widgets for those widgets that have a soft dependency on others
168168
if ( $.fn.controlgroup ) {
169169
$( document ).bind( "pagecreate create", function( e ){
170-
$( ":jqmData(role='controlgroup')", e.target ).controlgroup({ excludeInvisible: false });
170+
$( ":jqmData(role='controlgroup')", e.target )
171+
.jqmEnhanceable()
172+
.controlgroup({ excludeInvisible: false });
171173
});
172174
}
173175

tests/unit/controlgroup/controlgroup_core.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,14 @@
130130

131131
$.mobile.ignoreContentEnabled = true;
132132

133-
$unenhancedFieldSet.controlgroup();
133+
// attempt to enhance the controlgroup
134+
$unenhancedFieldSet.parent().trigger("create");
134135

135136
same( $unenhancedFieldSet.length, 1, "the fieldset test fixtures exist" );
136137
ok( !$unenhancedFieldSet.is(".ui-controlgroup"), "there is no control group" );
137138

138-
$enhancedFieldSet.controlgroup();
139+
// attempt to enhance the controlgroup
140+
$enhancedFieldSet.parent().trigger("create");
139141

140142
same( $enhancedFieldSet.length, 1, "the fieldset test fixtures exist" );
141143
ok( $enhancedFieldSet.is(".ui-controlgroup"), "there is a control group" );

tests/unit/controlgroup/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ <h2 id="qunit-userAgent"></h2>
7575

7676
</div>
7777
</div>
78+
7879
<div data-nstest-enhance="false" data-nstest-role="fieldcontain" id="unenhanced-fieldcontain">
79-
<fieldset data-nstest-type="horizontal" id="unenhanced-fieldset">
80+
<fieldset data-nstest-type="horizontal" id="unenhanced-fieldset" data-nstest-role="controlgroup">
8081
<input type="checkbox" name="checkbox-10" id="checkbox-10" class="custom" />
8182
<label for="checkbox-10">b</label>
8283

@@ -86,7 +87,7 @@ <h2 id="qunit-userAgent"></h2>
8687
</div>
8788

8889
<div data-nstest-role="fieldcontain" id="enhanced-fieldcontain">
89-
<fieldset data-nstest-type="horizontal" id="enhanced-fieldset">
90+
<fieldset data-nstest-type="horizontal" id="enhanced-fieldset" data-nstest-role="controlgroup">
9091
<input type="checkbox" name="checkbox-12" id="checkbox-12" class="custom" />
9192
<label for="checkbox-12">b</label>
9293

0 commit comments

Comments
 (0)