removed options from shared, move theme determination to method

This commit is contained in:
John Bender 2011-08-09 13:47:40 -07:00
parent fd8fb03205
commit 67e76a072b
2 changed files with 24 additions and 31 deletions

View file

@ -29,14 +29,33 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
return $( "<div/>" );
},
_theme: function(){
var themedParent, theme;
// if no theme is defined, try to find closest theme container
// TODO move to core as something like findCurrentTheme
themedParent = this.select.closest( "[class*='ui-bar-'], [class*='ui-body-']" );
theme = themedParent.length ?
/ui-(bar|body)-([a-z])/.exec( themedParent.attr( "class" ) )[2] :
"c";
return theme;
},
_create: function() {
// Allows for extension of the native select for custom selects and other plugins
// see select.custom for example extension
// TODO explore plugin registration
this.select = this.element.wrap( "<div class='ui-select'>" );
this._trigger( "beforeCreate" );
this.button = this._button();
$.extend( this, $.mobile.selectShared.call(this));
this.button = this._button();
this.options.theme = this._theme();
$.extend( this, $.mobile.selectShared.call(this) );
var self = this,
menu = this,
o = this.options,

View file

@ -8,36 +8,10 @@
(function( $, undefined ) {
$.mobile.selectShared = function(){
var widget = this,
select = this.element.wrap( "<div class='ui-select'>" );
var widget = this;
this.options = {
theme: null,
disabled: false,
icon: "arrow-d",
iconpos: "right",
inline: null,
corners: true,
shadow: true,
iconshadow: true,
menuPageTheme: "b",
overlayTheme: "a",
hidePlaceholderMenuItems: true,
closeText: "Close",
nativeMenu: true,
initSelector: "select:not(:jqmData(role='slider'))"
};
// if not, try to find closest theme container
// TODO move to core as findCurrentTheme
if ( !widget.options.theme ) {
var themedParent = select.closest( "[class*='ui-bar-'],[class*='ui-body-']" );
widget.options.theme = themedParent.length ?
/ui-(bar|body)-([a-z])/.exec( themedParent.attr( "class" ) )[2] :
"c";
}
var selectID = select.attr( "id" ),
var select = this.select,
selectID = select.attr( "id" ),
label = $( "label[for='"+ selectID +"']" ).addClass( "ui-select" ),
thisPage = select.closest( ".ui-page" ),
screen = $( "<div>", {"class": "ui-selectmenu-screen ui-screen-hidden"} ).appendTo( thisPage ),