mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-05 07:01:00 +00:00
removed the custom menu portions of the selectmenu, which will be moved to select.custom.js, which is non-functional in this commit
This commit is contained in:
parent
b7a19b604c
commit
db22dfa111
2 changed files with 41 additions and 164 deletions
34
js/jquery.mobile.forms.select.custom.js
Normal file
34
js/jquery.mobile.forms.select.custom.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* jQuery Mobile Framework : "selectmenu" plugin
|
||||
* Copyright (c) jQuery Project
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
(function( $, undefined ) {
|
||||
|
||||
/* add options to selectmenu pertaining to custom menus*/
|
||||
$.mobile.selectmenu.prototype.options.menuPageTheme = "b";
|
||||
$.mobile.selectmenu.prototype.options.overlayTheme = "a";
|
||||
$.mobile.selectmenu.prototype.options.hidePlaceholderMenuItems = true;
|
||||
$.mobile.selectmenu.prototype.options.closeText = "Close";
|
||||
$.mobile.selectmenu.prototype.options.nativeMenu = true;
|
||||
|
||||
|
||||
|
||||
$( "select" ).live( "selectmenucreate", function() {
|
||||
|
||||
var select = $( this ),
|
||||
selectmenu = select.data( "selectmenu" );
|
||||
|
||||
if ( !selectmenu.options.nativeMenu ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
})( jQuery );
|
||||
|
||||
|
|
@ -42,13 +42,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
// select first in this case
|
||||
selectedIndex = select[ 0 ].selectedIndex == -1 ? 0 : select[ 0 ].selectedIndex,
|
||||
|
||||
button = ( self.options.nativeMenu ? $( "<div/>" ) : $( "<a>", {
|
||||
"href": "#",
|
||||
"role": "button",
|
||||
"id": buttonId,
|
||||
"aria-haspopup": "true",
|
||||
"aria-owns": menuId
|
||||
}) )
|
||||
button = $( "<div/>" )
|
||||
.text( $( select[ 0 ].options.item( selectedIndex ) ).text() )
|
||||
.insertBefore( select )
|
||||
.buttonMarkup({
|
||||
|
|
@ -72,70 +66,6 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
select.addClass( "ui-select-nativeonly" );
|
||||
}
|
||||
|
||||
//vars for non-native menus
|
||||
if ( !o.nativeMenu ) {
|
||||
var options = select.find("option"),
|
||||
|
||||
buttonId = selectID + "-button",
|
||||
|
||||
menuId = selectID + "-menu",
|
||||
|
||||
thisPage = select.closest( ".ui-page" ),
|
||||
|
||||
//button theme
|
||||
theme = /ui-btn-up-([a-z])/.exec( button.attr( "class" ) )[1],
|
||||
|
||||
menuPage = $( "<div data-" + $.mobile.ns + "role='dialog' data-" +$.mobile.ns + "theme='"+ o.menuPageTheme +"'>" +
|
||||
"<div data-" + $.mobile.ns + "role='header'>" +
|
||||
"<div class='ui-title'>" + label.text() + "</div>"+
|
||||
"</div>"+
|
||||
"<div data-" + $.mobile.ns + "role='content'></div>"+
|
||||
"</div>" )
|
||||
.appendTo( $.mobile.pageContainer )
|
||||
.page(),
|
||||
|
||||
menuPageContent = menuPage.find( ".ui-content" ),
|
||||
|
||||
menuPageClose = menuPage.find( ".ui-header a" ),
|
||||
|
||||
screen = $( "<div>", {"class": "ui-selectmenu-screen ui-screen-hidden"})
|
||||
.appendTo( thisPage ),
|
||||
|
||||
listbox = $("<div>", { "class": "ui-selectmenu ui-selectmenu-hidden ui-overlay-shadow ui-corner-all ui-body-" + o.overlayTheme + " " + $.mobile.defaultDialogTransition })
|
||||
.insertAfter(screen),
|
||||
|
||||
list = $( "<ul>", {
|
||||
"class": "ui-selectmenu-list",
|
||||
"id": menuId,
|
||||
"role": "listbox",
|
||||
"aria-labelledby": buttonId
|
||||
})
|
||||
.attr( "data-" + $.mobile.ns + "theme", theme )
|
||||
.appendTo( listbox ),
|
||||
|
||||
header = $( "<div>", {
|
||||
"class": "ui-header ui-bar-" + theme
|
||||
})
|
||||
.prependTo( listbox ),
|
||||
|
||||
headerTitle = $( "<h1>", {
|
||||
"class": "ui-title"
|
||||
})
|
||||
.appendTo( header ),
|
||||
|
||||
headerClose = $( "<a>", {
|
||||
"text": o.closeText,
|
||||
"href": "#",
|
||||
"class": "ui-btn-left"
|
||||
})
|
||||
.attr( "data-" + $.mobile.ns + "iconpos", "notext" )
|
||||
.attr( "data-" + $.mobile.ns + "icon", "delete" )
|
||||
.appendTo( header )
|
||||
.buttonMarkup(),
|
||||
|
||||
menuType;
|
||||
} // End non native vars
|
||||
|
||||
// Add counter for multi selects
|
||||
if ( isMultiple ) {
|
||||
self.buttonCount = $( "<span>" )
|
||||
|
|
@ -157,23 +87,9 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
// Expose to other methods
|
||||
$.extend( self, {
|
||||
select: select,
|
||||
optionElems: options,
|
||||
selectID: selectID,
|
||||
label: label,
|
||||
buttonId: buttonId,
|
||||
menuId: menuId,
|
||||
thisPage: thisPage,
|
||||
button: button,
|
||||
menuPage: menuPage,
|
||||
menuPageContent: menuPageContent,
|
||||
screen: screen,
|
||||
listbox: listbox,
|
||||
list: list,
|
||||
menuType: menuType,
|
||||
header: header,
|
||||
headerClose: headerClose,
|
||||
headerTitle: headerTitle,
|
||||
placeholder: ""
|
||||
button: button
|
||||
});
|
||||
|
||||
// Support for using the native select menu with a custom button
|
||||
|
|
@ -257,76 +173,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
}
|
||||
|
||||
event.preventDefault();
|
||||
})
|
||||
//keyboard events for menu items
|
||||
.keydown(function( event ) {
|
||||
var target = $( event.target ),
|
||||
li = target.closest( "li" ),
|
||||
prev, next;
|
||||
|
||||
// switch logic based on which key was pressed
|
||||
switch ( event.keyCode ) {
|
||||
// up or left arrow keys
|
||||
case 38:
|
||||
prev = li.prev();
|
||||
|
||||
// if there's a previous option, focus it
|
||||
if ( prev.length ) {
|
||||
target
|
||||
.blur()
|
||||
.attr( "tabindex", "-1" );
|
||||
|
||||
prev.find( "a" ).first().focus();
|
||||
}
|
||||
|
||||
return false;
|
||||
break;
|
||||
|
||||
// down or right arrow keys
|
||||
case 40:
|
||||
next = li.next();
|
||||
|
||||
// if there's a next option, focus it
|
||||
if ( next.length ) {
|
||||
target
|
||||
.blur()
|
||||
.attr( "tabindex", "-1" );
|
||||
|
||||
next.find( "a" ).first().focus();
|
||||
}
|
||||
|
||||
return false;
|
||||
break;
|
||||
|
||||
// If enter or space is pressed, trigger click
|
||||
case 13:
|
||||
case 32:
|
||||
target.trigger( "vclick" );
|
||||
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// button refocus ensures proper height calculation
|
||||
// by removing the inline style and ensuring page inclusion
|
||||
self.menuPage.bind( "pagehide", function(){
|
||||
self.list.appendTo( self.listbox );
|
||||
self._focusButton();
|
||||
});
|
||||
|
||||
// Events on "screen" overlay
|
||||
screen.bind( "vclick", function( event ) {
|
||||
self.close();
|
||||
});
|
||||
|
||||
// Close button on small overlays
|
||||
self.headerClose.click(function() {
|
||||
if ( self.menuType == "overlay" ) {
|
||||
self.close();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -398,6 +245,8 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
|
||||
// Now populated, create listview
|
||||
self.list.listview();
|
||||
=======
|
||||
>>>>>>> removed the custom menu portions of the selectmenu, which will be moved to select.custom.js, which is non-functional in this commit
|
||||
},
|
||||
|
||||
refresh: function( forceRebuild ) {
|
||||
|
|
@ -412,12 +261,6 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
return options.index( this );
|
||||
}).get();
|
||||
|
||||
if ( !self.options.nativeMenu &&
|
||||
( forceRebuild || select[0].options.length != self.list.find( "li" ).length ) ) {
|
||||
|
||||
self._buildList();
|
||||
}
|
||||
|
||||
self.button.find( ".ui-btn-text" )
|
||||
.text(function() {
|
||||
|
||||
|
|
@ -425,9 +268,9 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
|
|||
return selected.text();
|
||||
}
|
||||
|
||||
return selected.length ? selected.map(function() {
|
||||
return selected.map(function() {
|
||||
return $( this ).text();
|
||||
}).get().join( ", " ) : self.placeholder;
|
||||
}).get().join( ", " );
|
||||
});
|
||||
|
||||
// multiple count inside button
|
||||
|
|
|
|||
Loading…
Reference in a new issue