mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-16 22:10:25 +00:00
Moved autoinit calls to after widgets. Made it so auto init selectors use the initSelector option, so that it can be configurable.
This commit is contained in:
parent
d1e8083f15
commit
263193f490
12 changed files with 114 additions and 132 deletions
|
|
@ -6,13 +6,6 @@
|
|||
*/
|
||||
(function( $, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = ":jqmData(role='collapsible')";
|
||||
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( initSelector, e.target ).collapsible();
|
||||
});
|
||||
|
||||
$.widget( "mobile.collapsible", $.mobile.widget, {
|
||||
options: {
|
||||
expandCueText: " click to expand contents",
|
||||
|
|
@ -21,7 +14,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
|
|||
heading: ">:header,>legend",
|
||||
theme: null,
|
||||
iconTheme: "d",
|
||||
initSelector: initSelector
|
||||
initSelector: ":jqmData(role='collapsible')"
|
||||
},
|
||||
_create: function() {
|
||||
|
||||
|
|
@ -163,4 +156,10 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( $.mobile.collapsible.prototype.options.initSelector, e.target ).collapsible();
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
|
|
|||
|
|
@ -6,13 +6,6 @@
|
|||
*/
|
||||
(function( $, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = ":jqmData(role='controlgroup')";
|
||||
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( initSelector, e.target ).controlgroup({ excludeInvisible: false });
|
||||
});
|
||||
|
||||
$.fn.controlgroup = function( options ) {
|
||||
|
||||
return this.each(function() {
|
||||
|
|
@ -53,4 +46,10 @@ $.fn.controlgroup = function( options ) {
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( ":jqmData(role='controlgroup')", e.target ).controlgroup({ excludeInvisible: false });
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
|
@ -6,18 +6,11 @@
|
|||
|
||||
(function( $, window, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = ":jqmData(role='dialog')";
|
||||
|
||||
$( initSelector ).live( "pagecreate", function(){
|
||||
$( this ).dialog();
|
||||
});
|
||||
|
||||
$.widget( "mobile.dialog", $.mobile.widget, {
|
||||
options: {
|
||||
closeBtnText : "Close",
|
||||
theme : "a",
|
||||
initSelector : initSelector
|
||||
initSelector : ":jqmData(role='dialog')"
|
||||
},
|
||||
_create: function() {
|
||||
var $el = this.element,
|
||||
|
|
@ -68,4 +61,10 @@ $.widget( "mobile.dialog", $.mobile.widget, {
|
|||
window.history.back();
|
||||
}
|
||||
});
|
||||
|
||||
//auto self-init widgets
|
||||
$( $.mobile.dialog.prototype.options.initSelector ).live( "pagecreate", function(){
|
||||
$( this ).dialog();
|
||||
});
|
||||
|
||||
})( jQuery, this );
|
||||
|
|
|
|||
|
|
@ -7,15 +7,13 @@
|
|||
|
||||
(function( $, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = ":jqmData(role='fieldcontain')";
|
||||
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( initSelector, e.target ).fieldcontain();
|
||||
});
|
||||
|
||||
$.fn.fieldcontain = function( options ) {
|
||||
return this.addClass( "ui-field-contain ui-body ui-br" );
|
||||
};
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( ":jqmData(role='fieldcontain')", e.target ).fieldcontain();
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
|
@ -6,37 +6,6 @@
|
|||
*/
|
||||
|
||||
(function( $, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = ":jqmData(position='fixed')";
|
||||
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
|
||||
if( $( initSelector, e.target ).length ){
|
||||
$( e.target ).each(function(){
|
||||
|
||||
if ( !$.support.scrollTop ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
var $this = $( this );
|
||||
|
||||
if ( $this.jqmData( "fullscreen" ) ) {
|
||||
$this.addClass( "ui-page-fullscreen" );
|
||||
}
|
||||
|
||||
// Should be slidedown
|
||||
$this.find( ".ui-header:jqmData(position='fixed')" ).addClass( "ui-header-fixed ui-fixed-inline fade" );
|
||||
|
||||
// Should be slideup
|
||||
$this.find( ".ui-footer:jqmData(position='fixed')" ).addClass( "ui-footer-fixed ui-fixed-inline fade" );
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$.fn.fixHeaderFooter = function( options ) {
|
||||
|
||||
|
|
@ -376,4 +345,31 @@ $.fixedToolbars = (function() {
|
|||
};
|
||||
})();
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
|
||||
if( $( ":jqmData(position='fixed')", e.target ).length ){
|
||||
$( e.target ).each(function(){
|
||||
|
||||
if ( !$.support.scrollTop ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
var $this = $( this );
|
||||
|
||||
if ( $this.jqmData( "fullscreen" ) ) {
|
||||
$this.addClass( "ui-page-fullscreen" );
|
||||
}
|
||||
|
||||
// Should be slidedown
|
||||
$this.find( ".ui-header:jqmData(position='fixed')" ).addClass( "ui-header-fixed ui-fixed-inline fade" );
|
||||
|
||||
// Should be slideup
|
||||
$this.find( ".ui-footer:jqmData(position='fixed')" ).addClass( "ui-footer-fixed ui-fixed-inline fade" );
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
|
|
|||
|
|
@ -7,15 +7,6 @@
|
|||
|
||||
(function( $, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = "button, [type='button'], [type='submit'], [type='reset'], [type='image']";
|
||||
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.button();
|
||||
});
|
||||
|
||||
$.widget( "mobile.button", $.mobile.widget, {
|
||||
options: {
|
||||
theme: null,
|
||||
|
|
@ -25,7 +16,7 @@ $.widget( "mobile.button", $.mobile.widget, {
|
|||
corners: true,
|
||||
shadow: true,
|
||||
iconshadow: true,
|
||||
initSelector: initSelector
|
||||
initSelector: "button, [type='button'], [type='submit'], [type='reset'], [type='image']"
|
||||
},
|
||||
_create: function() {
|
||||
var $el = this.element,
|
||||
|
|
@ -91,4 +82,12 @@ $.widget( "mobile.button", $.mobile.widget, {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( $.mobile.button.prototype.options.initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.button();
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
|
@ -7,19 +7,10 @@
|
|||
|
||||
(function( $, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = "input[type='checkbox'],input[type='radio']";
|
||||
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.checkboxradio();
|
||||
});
|
||||
|
||||
$.widget( "mobile.checkboxradio", $.mobile.widget, {
|
||||
options: {
|
||||
theme: null,
|
||||
initSelector: initSelector
|
||||
initSelector: "input[type='checkbox'],input[type='radio']"
|
||||
},
|
||||
_create: function() {
|
||||
var self = this,
|
||||
|
|
@ -192,4 +183,12 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
|
|||
this.element.prop( "disabled", false ).parent().removeClass( "ui-disabled" );
|
||||
}
|
||||
});
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( $.mobile.checkboxradio.prototype.options.initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.checkboxradio();
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
|
|
|||
|
|
@ -7,15 +7,6 @@
|
|||
|
||||
(function( $, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = "select:not(:jqmData(role='slider'))";
|
||||
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.selectmenu();
|
||||
});
|
||||
|
||||
$.widget( "mobile.selectmenu", $.mobile.widget, {
|
||||
options: {
|
||||
theme: null,
|
||||
|
|
@ -31,7 +22,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
hidePlaceholderMenuItems: true,
|
||||
closeText: "Close",
|
||||
nativeMenu: true,
|
||||
initSelector: initSelector
|
||||
initSelector: "select:not(:jqmData(role='slider'))"
|
||||
},
|
||||
_create: function() {
|
||||
|
||||
|
|
@ -611,5 +602,13 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
return this._setOption( "disabled", false );
|
||||
}
|
||||
});
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( $.mobile.selectmenu.prototype.options.initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.selectmenu();
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
||||
|
|
|
|||
|
|
@ -7,24 +7,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
|
||||
$( initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.slider();
|
||||
|
||||
});
|
||||
|
||||
$.widget( "mobile.slider", $.mobile.widget, {
|
||||
options: {
|
||||
theme: null,
|
||||
trackTheme: null,
|
||||
disabled: false,
|
||||
initSelector: initSelector
|
||||
initSelector: "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')"
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
|
|
@ -325,5 +313,14 @@ $.widget( "mobile.slider", $.mobile.widget, {
|
|||
}
|
||||
|
||||
});
|
||||
})( jQuery );
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
|
||||
$( $.mobile.slider.prototype.options.initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.slider();
|
||||
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
|
@ -7,19 +7,10 @@
|
|||
|
||||
(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 ){
|
||||
$( initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.textinput();
|
||||
});
|
||||
|
||||
$.widget( "mobile.textinput", $.mobile.widget, {
|
||||
options: {
|
||||
theme: null,
|
||||
initSelector: initSelector
|
||||
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"
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
|
|
@ -131,4 +122,14 @@ $.widget( "mobile.textinput", $.mobile.widget, {
|
|||
this.element.parent() : this.element ).removeClass( "ui-disabled" );
|
||||
}
|
||||
});
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
|
||||
$( $.mobile.textinput.prototype.options.initSelector, e.target )
|
||||
.not( ":jqmData(role='none'), :jqmData(role='nojs')" )
|
||||
.textinput();
|
||||
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
|
|
|||
|
|
@ -7,13 +7,6 @@
|
|||
|
||||
(function( $, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = ":jqmData(role='listview')";
|
||||
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( initSelector, e.target ).listview();
|
||||
});
|
||||
|
||||
//Keeps track of the number of lists per page UID
|
||||
//This allows support for multiple nested list in the same page
|
||||
//https://github.com/jquery/jquery-mobile/issues/1617
|
||||
|
|
@ -28,7 +21,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
|
|||
splitIcon: "arrow-r",
|
||||
splitTheme: "b",
|
||||
inset: false,
|
||||
initSelector: initSelector
|
||||
initSelector: ":jqmData(role='listview')"
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
|
|
@ -264,4 +257,9 @@ $.widget( "mobile.listview", $.mobile.widget, {
|
|||
}
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( $.mobile.listview.prototype.options.initSelector, e.target ).listview();
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
|
@ -7,18 +7,11 @@
|
|||
|
||||
(function( $, undefined ) {
|
||||
|
||||
//auto self-init widgets
|
||||
var initSelector = ":jqmData(role='navbar')";
|
||||
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( initSelector, e.target ).navbar();
|
||||
});
|
||||
|
||||
$.widget( "mobile.navbar", $.mobile.widget, {
|
||||
options: {
|
||||
iconpos: "top",
|
||||
grid: null,
|
||||
initSelector: initSelector
|
||||
initSelector: ":jqmData(role='navbar')"
|
||||
},
|
||||
|
||||
_create: function(){
|
||||
|
|
@ -50,4 +43,9 @@ $.widget( "mobile.navbar", $.mobile.widget, {
|
|||
}
|
||||
});
|
||||
|
||||
//auto self-init widgets
|
||||
$( document ).bind( "pagecreate create", function( e ){
|
||||
$( $.mobile.navbar.prototype.options.initSelector, e.target ).navbar();
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
|
|
|||
Loading…
Reference in a new issue