Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #2853: Added role plugin and use it in widgets and controls.

  • Loading branch information...
commit 3fd33397ad182310f89456ca0e41226fdd176c0c 1 parent d106e68
@gseguin gseguin authored
View
2  js/jquery.mobile.collapsible.js
@@ -155,7 +155,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $( $.mobile.collapsible.prototype.options.initSelector, e.target ).collapsible();
+ e.$jqmRoleElements.filter( $.mobile.collapsible.prototype.options.initSelector ).collapsible();
});
})( jQuery );
View
2  js/jquery.mobile.controlGroup.js
@@ -49,7 +49,7 @@ $.fn.controlgroup = function( options ) {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $( ":jqmData(role='controlgroup')", e.target ).controlgroup({ excludeInvisible: false });
+ e.$jqmRoleElements.filter( ":jqmData(role='controlgroup')" ).controlgroup({ excludeInvisible: false });
});
})(jQuery);
View
2  js/jquery.mobile.degradeInputs.js
@@ -36,7 +36,7 @@ $( document ).bind( "pagecreate create", function( e ){
options = page.options;
// degrade inputs to avoid poorly implemented native functionality
- $( e.target ).find( "input" ).not( page.keepNativeSelector() ).each(function() {
+ e.$controlElements.filter( "input" ).not( page.keepNativeSelector() ).each(function() {
var $this = $( this ),
type = this.getAttribute( "type" ),
optType = options.degradeInputs[ type ] || "text";
View
4 js/jquery.mobile.dialog.js
@@ -72,8 +72,8 @@ $.widget( "mobile.dialog", $.mobile.widget, {
});
//auto self-init widgets
-$( $.mobile.dialog.prototype.options.initSelector ).live( "pagecreate", function(){
- $( this ).dialog();
+$( document ).bind( "pagecreate create", function( e ){
+ e.$jqmRoleElements.filter( $.mobile.dialog.prototype.options.initSelector ).dialog();
});
})( jQuery, this );
View
2  js/jquery.mobile.fieldContain.js
@@ -13,7 +13,7 @@ $.fn.fieldcontain = function( options ) {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $( ":jqmData(role='fieldcontain')", e.target ).fieldcontain();
+ e.$jqmRoleElements.filter( ":jqmData(role='fieldcontain')" ).fieldcontain();
});
})( jQuery );
View
2  js/jquery.mobile.forms.button.js
@@ -89,7 +89,7 @@ $.widget( "mobile.button", $.mobile.widget, {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $.mobile.button.prototype.enhanceWithin( e.target );
+ $.mobile.button.prototype.enhanceWithin( e.target, e.$controlElements );
});
})( jQuery );
View
2  js/jquery.mobile.forms.checkboxradio.js
@@ -193,7 +193,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $.mobile.checkboxradio.prototype.enhanceWithin( e.target );
+ $.mobile.checkboxradio.prototype.enhanceWithin( e.target, e.$controlElements );
});
})( jQuery );
View
2  js/jquery.mobile.forms.select.js
@@ -203,6 +203,6 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $.mobile.selectmenu.prototype.enhanceWithin( e.target );
+ $.mobile.selectmenu.prototype.enhanceWithin( e.target, e.$controlElements );
});
})( jQuery );
View
2  js/jquery.mobile.forms.slider.js
@@ -318,7 +318,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $.mobile.slider.prototype.enhanceWithin( e.target );
+ $.mobile.slider.prototype.enhanceWithin( e.target, e.$controlElements );
});
})( jQuery );
View
2  js/jquery.mobile.forms.textinput.js
@@ -132,7 +132,7 @@ $.widget( "mobile.textinput", $.mobile.widget, {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $.mobile.textinput.prototype.enhanceWithin( e.target );
+ $.mobile.textinput.prototype.enhanceWithin( e.target, e.$controlElements );
});
})( jQuery );
View
2  js/jquery.mobile.listview.js
@@ -309,7 +309,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $( $.mobile.listview.prototype.options.initSelector, e.target ).listview();
+ e.$jqmRoleElements.filter( $.mobile.listview.prototype.options.initSelector ).listview();
});
})( jQuery );
View
2  js/jquery.mobile.navbar.js
@@ -45,7 +45,7 @@ $.widget( "mobile.navbar", $.mobile.widget, {
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
- $( $.mobile.navbar.prototype.options.initSelector, e.target ).navbar();
+ e.$jqmRoleElements.filter( $.mobile.navbar.prototype.options.initSelector ).navbar();
});
})( jQuery );
View
3  js/jquery.mobile.role.js
@@ -6,7 +6,8 @@
*/
(function( $, undefined ) {
- $( document ).bind( "pagecreate create", function( e ){
+ $( document ).bind( "pagecreate", function( e ){
e.$jqmRoleElements = $( ":jqmData(role)", e.target );
+ e.$controlElements = $( "input, textarea, select, button", e.target );
});
}( jQuery ));
View
13 js/jquery.mobile.widget.js
@@ -38,16 +38,21 @@ $.widget( "mobile.widget", {
return options;
},
- enhanceWithin: function( target ) {
+ enhanceWithin: function( target, coll ) {
// TODO remove dependency on the page widget for the keepNative.
// Currently the keepNative value is defined on the page prototype so
// the method is as well
var page = $(target).closest(":jqmData(role='page')").data( "page" ),
- keepNative = (page && page.keepNativeSelector()) || "";
+ keepNative = (page && page.keepNativeSelector()) || "",
+ elements;
-
- $( this.options.initSelector, target ).not( keepNative )[ this.widgetName ]();
+ if ( !coll ) {
+ elements = $( this.options.initSelector, target );
+ } else {
+ elements = coll.filter( this.options.initSelector );
+ }
+ elements.not( keepNative )[ this.widgetName ]();
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.