add disabled option support. fixes #350

This commit is contained in:
ehynds 2010-12-03 21:19:25 +08:00 committed by Scott Jehl
parent e4f55d3c91
commit e2eb9e9298
4 changed files with 22 additions and 10 deletions

View file

@ -82,7 +82,7 @@ $.fn.buttonMarkup.defaults = {
};
var attachEvents = function() {
$(".ui-btn").live({
$(".ui-btn:not(.ui-disabled)").live({
mousedown: function() {
var theme = $(this).attr( "data-theme" );
$(this).removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme );

View file

@ -128,7 +128,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
});
//events for list items
list.delegate("li",'click', function(){
list.delegate("li:not(.ui-disabled)", "click", function(){
//update select
var newIndex = list.find( "li" ).index( this ),
prevIndex = select[0].selectedIndex;
@ -161,13 +161,22 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
//populate menu with options from select element
self.select.find( "option" ).each(function( i ){
var anchor = $("<a>", {
"role": "option",
"href": "#"
})
.text( $(this).text() );
var anchor = $("<a>", {
"role": "option",
"href": "#",
"text": $(this).text()
}),
item = $( "<li>", {"data-icon": "checkbox-on"});
$( "<li>", {"data-icon": "checkbox-on"})
// support disabled option tags
if( this.disabled ){
item
.addClass("ui-disabled")
.attr("aria-disabled", true);
}
item
.append( anchor )
.appendTo( self.list );
});

View file

@ -139,7 +139,8 @@ a.ui-link-inherit { text-decoration: none !important; }
/* Interaction Cues
----------------------------------*/
.ui-disabled { cursor: default !important; opacity: .3; }
.ui-disabled { opacity: .3; }
.ui-disabled, .ui-disabled a { cursor: default !important; }
/* Icons
----------------------------------*/

View file

@ -701,9 +701,11 @@ a.ui-link-inherit {
/* Interaction Cues
----------------------------------*/
.ui-disabled {
cursor: default !important;
opacity: .3;
}
.ui-disabled, .ui-disabled a {
cursor: default !important;
}
/* Icons
----------------------------------*/