Permalink
Browse files

exposed automatic initialization selectors on most widgets that expos…

…e options through the widget factory. Option name is "initSelector"
  • Loading branch information...
scottjehl
scottjehl committed Jul 26, 2011
1 parent 79d3aa6 commit e07c40e3d0bbc2826133dc8dd3552e030687cd9a
@@ -7,8 +7,10 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = ":jqmData(role='collapsible')";
$( document ).bind( "pagecreate create", function( e ){
$( ":jqmData(role='collapsible')", e.target ).collapsible();
$( initSelector, e.target ).collapsible();
});
$.widget( "mobile.collapsible", $.mobile.widget, {
@@ -18,7 +20,8 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
collapsed: false,
heading: ">:header,>legend",
theme: null,
iconTheme: "d"
iconTheme: "d",
initSelector: initSelector
},
_create: function() {
@@ -7,8 +7,10 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = ":jqmData(role='controlgroup')";
$( document ).bind( "pagecreate create", function( e ){
$( ":jqmData(role='controlgroup')", e.target ).controlgroup({ excludeInvisible: false });
$( initSelector, e.target ).controlgroup({ excludeInvisible: false });
});
$.fn.controlgroup = function( options ) {
@@ -7,14 +7,17 @@
(function( $, window, undefined ) {
//auto self-init widgets
$( ":jqmData(role='dialog')" ).live( "pagecreate", function(){
var initSelector = ":jqmData(role='dialog')";
$( initSelector ).live( "pagecreate", function(){
$( this ).dialog();
});
$.widget( "mobile.dialog", $.mobile.widget, {
options: {
closeBtnText : "Close",
theme : "a"
theme : "a",
initSelector : initSelector
},
_create: function() {
var $el = this.element,
@@ -8,8 +8,10 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = ":jqmData(role='fieldcontain')";
$( document ).bind( "pagecreate create", function( e ){
$( ":jqmData(role='fieldcontain')", e.target ).fieldcontain();
$( initSelector, e.target ).fieldcontain();
});
$.fn.fieldcontain = function( options ) {
@@ -8,9 +8,11 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = ":jqmData(position='fixed')";
$( document ).bind( "pagecreate create", function( e ){
if( $( ":jqmData(position='fixed')", e.target ).length ){
if( $( initSelector, e.target ).length ){
$( e.target ).each(function(){
if ( !$.support.scrollTop ) {
@@ -8,8 +8,10 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = "button, [type='button'], [type='submit'], [type='reset'], [type='image']";
$( document ).bind( "pagecreate create", function( e ){
$( "button, [type='button'], [type='submit'], [type='reset'], [type='image']", e.target )
$( initSelector, e.target )
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
.button();
});
@@ -22,7 +24,8 @@ $.widget( "mobile.button", $.mobile.widget, {
inline: null,
corners: true,
shadow: true,
iconshadow: true
iconshadow: true,
initSelector: initSelector
},
_create: function() {
var $el = this.element,
@@ -8,15 +8,18 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = "input[type='checkbox'],input[type='radio']";
$( document ).bind( "pagecreate create", function( e ){
$( "input[type='checkbox'],input[type='radio']", e.target )
$( $.mobile.checkboxradio.prototype.options.initSelector, e.target )

This comment has been minimized.

Show comment
Hide comment
@negue

negue Jul 27, 2011

Contributor

This is the only initSelector which is from .prototype.options.

All other are just using the default var initSelector, maybe all inits should use .prototype.options.initSelector

@negue

negue Jul 27, 2011

Contributor

This is the only initSelector which is from .prototype.options.

All other are just using the default var initSelector, maybe all inits should use .prototype.options.initSelector

This comment has been minimized.

Show comment
Hide comment
@scottjehl

scottjehl Jul 27, 2011

Contributor

Thanks - yep that should be initSelector.

@scottjehl

scottjehl Jul 27, 2011

Contributor

Thanks - yep that should be initSelector.

.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
.checkboxradio();
});
$.widget( "mobile.checkboxradio", $.mobile.widget, {
options: {
theme: null
theme: null,
initSelector: initSelector
},
_create: function() {
var self = this,
@@ -8,8 +8,10 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = "select:not(:jqmData(role='slider'))";
$( document ).bind( "pagecreate create", function( e ){
$( "select:not(:jqmData(role='slider'))", e.target )
$( initSelector, e.target )
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
.selectmenu();
});
@@ -28,7 +30,8 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
overlayTheme: "a",
hidePlaceholderMenuItems: true,
closeText: "Close",
nativeMenu: true
nativeMenu: true,
initSelector: initSelector
},
_create: function() {
@@ -8,10 +8,12 @@
( function( $, undefined ) {
//auto self-init widgets
var initSelector = "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')";
$( document ).bind( "pagecreate create", function( e ){
//now self-init
$( "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')", e.target )
$( initSelector, e.target )
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
.slider();
@@ -21,7 +23,8 @@ $.widget( "mobile.slider", $.mobile.widget, {
options: {
theme: null,
trackTheme: null,
disabled: false
disabled: false,
initSelector: initSelector
},
_create: function() {
@@ -8,15 +8,18 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea";
$( document ).bind( "pagecreate create", function( e ){
$( "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea", e.target )
$( initSelector, e.target )
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
.textinput();
});
$.widget( "mobile.textinput", $.mobile.widget, {
options: {
theme: null
theme: null,
initSelector: initSelector
},
_create: function() {
@@ -8,8 +8,10 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = ":jqmData(role='listview')";
$( document ).bind( "pagecreate create", function( e ){
$( ":jqmData(role='listview')", e.target ).listview();
$( initSelector, e.target ).listview();
});
//Keeps track of the number of lists per page UID
@@ -25,7 +27,8 @@ $.widget( "mobile.listview", $.mobile.widget, {
dividerTheme: "b",
splitIcon: "arrow-r",
splitTheme: "b",
inset: false
inset: false,
initSelector: initSelector
},
_create: function() {
@@ -8,14 +8,17 @@
(function( $, undefined ) {
//auto self-init widgets
var initSelector = ":jqmData(role='navbar')";
$( document ).bind( "pagecreate create", function( e ){
$( ":jqmData(role='navbar')", e.target ).navbar();
$( initSelector, e.target ).navbar();
});
$.widget( "mobile.navbar", $.mobile.widget, {
options: {
iconpos: "top",
grid: null
grid: null,
initSelector: initSelector
},
_create: function(){

0 comments on commit e07c40e

Please sign in to comment.