/*
* jQuery Mobile Framework : common functionality for the custom and native
* select menus
* Copyright (c) jQuery Project
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
(function( $, undefined ) {
$.mobile.selectShared = function(){
var widget = this,
select = this.element.wrap( "
" );
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" ),
label = $( "label[for='"+ selectID +"']" ).addClass( "ui-select" ),
thisPage = select.closest( ".ui-page" ),
screen = $( "
", {"class": "ui-selectmenu-screen ui-screen-hidden"} ).appendTo( thisPage ),
selectOptions = select.find("option"),
isMultiple = widget.isMultiple = select[ 0 ].multiple,
buttonId = selectID + "-button",
menuId = selectID + "-menu",
menuPage = $( "
" +
"
" +
"
" + label.text() + "
"+
"
"+
"
"+
"
" ).appendTo( $.mobile.pageContainer ).page(),
listbox = $("
", { "class": "ui-selectmenu ui-selectmenu-hidden ui-overlay-shadow ui-corner-all ui-body-" + widget.options.overlayTheme + " " + $.mobile.defaultDialogTransition } ).insertAfter(screen),
list = $( "