Skip to content
Permalink
Browse files

Selectmenu: removed Button widget dependency

  • Loading branch information...
fnagel committed Feb 23, 2012
1 parent 6957f9f commit 29effb38eb04ae1cf779c96edd36e90c56438127
@@ -8,7 +8,6 @@
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.button.js"></script>
<script src="../../ui/jquery.ui.menu.js"></script>
<script src="../../ui/jquery.ui.selectmenu.js"></script>
<link rel="stylesheet" href="../demos.css">
@@ -8,7 +8,6 @@
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.button.js"></script>
<script src="../../ui/jquery.ui.menu.js"></script>
<script src="../../ui/jquery.ui.selectmenu.js"></script>
<link rel="stylesheet" href="../demos.css">
@@ -5,14 +5,12 @@
<title>jQuery UI Selectmenu Test Suite</title>

<link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css">
<link rel="stylesheet" href="../../../themes/base/jquery.ui.button.css">
<link rel="stylesheet" href="../../../themes/base/jquery.ui.menu.css">
<link rel="stylesheet" href="../../../themes/base/jquery.ui.selectmenu.css">

<script src="../../jquery.js"></script>
<script src="../../../ui/jquery.ui.core.js"></script>
<script src="../../../ui/jquery.ui.widget.js"></script>
<script src="../../../ui/jquery.ui.button.js"></script>
<script src="../../../ui/jquery.ui.menu.js"></script>
<script src="../../../ui/jquery.ui.selectmenu.js"></script>

@@ -11,7 +11,6 @@
<script src="../../../ui/jquery.ui.tabs.js"></script>
<script src="../../../ui/jquery.ui.dialog.js"></script>
<script src="../../../ui/jquery.ui.autocomplete.js"></script>
<script src="../../../ui/jquery.ui.button.js"></script>
<script src="../../../ui/jquery.ui.menu.js"></script>
<script src="../../../ui/jquery.ui.selectmenu.js"></script>
<link rel="stylesheet" href="../../../demos/demos.css">
@@ -8,7 +8,6 @@
<script src="../../../ui/jquery.ui.core.js"></script>
<script src="../../../ui/jquery.ui.widget.js"></script>
<script src="../../../ui/jquery.ui.position.js"></script>
<script src="../../../ui/jquery.ui.button.js"></script>
<script src="../../../ui/jquery.ui.menu.js"></script>
<script src="../../../ui/jquery.ui.selectmenu.js"></script>
<link rel="stylesheet" href="../../../demos/demos.css">
@@ -8,7 +8,6 @@
<script src="../../../ui/jquery.ui.core.js"></script>
<script src="../../../ui/jquery.ui.widget.js"></script>
<script src="../../../ui/jquery.ui.position.js"></script>
<script src="../../../ui/jquery.ui.button.js"></script>
<script src="../../../ui/jquery.ui.menu.js"></script>
<script src="../../../ui/jquery.ui.selectmenu.js"></script>
<link rel="stylesheet" href="../../../demos/demos.css">
@@ -8,7 +8,6 @@
<script src="../../../ui/jquery.ui.core.js"></script>
<script src="../../../ui/jquery.ui.widget.js"></script>
<script src="../../../ui/jquery.ui.position.js"></script>
<script src="../../../ui/jquery.ui.button.js"></script>
<script src="../../../ui/jquery.ui.menu.js"></script>
<script src="../../../ui/jquery.ui.selectmenu.js"></script>
<link rel="stylesheet" href="../../../demos/demos.css">
@@ -13,6 +13,5 @@
.ui-selectmenu-menu .ui-menu li.ui-state-disabled { padding: 0.3em 1em 0.3em 1em; }
.ui-selectmenu-menu .ui-menu li.ui-selectmenu-optgroup { font-weight: bold; line-height: 1.5; padding: 2px 0.4em; margin: 0.5em 0 0 0; }
.ui-selectmenu-open { display: block; }

.ui-selectmenu-button span.ui-icon { right: 0.5em; left: auto; }
.ui-selectmenu-button span.ui-button-text { text-align: left; padding: 0.4em 2.1em 0.4em 1em }
.ui-selectmenu-button span.ui-icon { right: 0.5em; left: auto; margin-top: -8px; position: absolute; top: 50%; }
.ui-selectmenu-button span.ui-selectmenu-text { text-align: left; padding: 0.4em 2.1em 0.4em 1em; display: block; line-height: 1.4; }
@@ -12,7 +12,6 @@
* jquery.ui.widget.js
* jquery.ui.position.js
* jquery.ui.menu.js
* jquery.ui.button.js
*/
(function( $, undefined ) {

@@ -68,23 +67,25 @@ $.widget( "ui.selectmenu", {

// create button
this.button = $( '<a />', {
href: '#' + this.ids.id,
html: this.element.find( "option:selected" ).text() || '&nbsp;',
tabindex: ( tabindex ? tabindex : this.options.disabled ? -1 : 0 ),
id: this.ids.button,
width: this.element.outerWidth(),
'aria-expanded': false,
'aria-autocomplete': 'list',
'aria-owns': this.ids.menu,
'aria-haspopup': true
'class': 'ui-button ui-widget ui-state-default ui-corner-all',
href: '#' + this.ids.id,
tabindex: ( tabindex ? tabindex : this.options.disabled ? -1 : 0 ),
id: this.ids.button,
width: this.element.outerWidth(),
role: 'combobox',
'aria-expanded': false,
'aria-autocomplete': 'list',
'aria-owns': this.ids.menu,
'aria-haspopup': true
});

this.button.prepend( $( '<span class="ui-icon ' + ( this.options.dropdown ? 'ui-icon-triangle-1-s' : 'ui-icon-triangle-2-n-s' ) + '"/>' ) );

this.buttonText = $( '<span />', {
'class': 'ui-selectmenu-text' ,
html: this.element.find( "option:selected" ).text() || '&nbsp;'
})
.button({
icons: {
primary: ( this.options.dropdown ? 'ui-icon-triangle-1-s' : 'ui-icon-triangle-2-n-s' )
}
})
// change ARIA role
.attr( 'role', 'combobox' );
.appendTo( this.button );

// wrap and insert new button
this.buttonWrap = $( '<span />', {
@@ -108,8 +109,7 @@ $.widget( "ui.selectmenu", {
if ( this.options.dropdown ) {
var setWidth = this.button.outerWidth();
} else {
var text = this.button.find( "span.ui-button-text"),
setWidth = text.width() + parseFloat( text.css( "padding-left" ) ) || 0 + parseFloat( text.css( "margin-left" ) || 0 );
var setWidth = this.buttonText.width() + parseFloat( this.buttonText.css( "padding-left" ) ) || 0 + parseFloat( this.buttonText.css( "margin-left" ) || 0 );
}

// wrap menu
@@ -391,7 +391,7 @@ $.widget( "ui.selectmenu", {

_setSelected: function( item ) {
// update button text
this.button.find( "span.ui-button-text" ).html( item.label );
this.buttonText.html( item.label );
// change ARIA attr
this.menuItems.find("a").attr( "aria-selected", false );
this._getSelectedItem().find("a").attr( "aria-selected", true );
@@ -407,7 +407,6 @@ $.widget( "ui.selectmenu", {
this.menu.toggleClass( 'ui-corner-bottom', value ).toggleClass( 'ui-corner-all', !value );
}
if ( key === "disabled" ) {
this.button.button( "option", "disabled", value );
this.menu.menu( "option", "disabled", value );
if ( value ) {
this.element.attr( "disabled", "disabled" );

0 comments on commit 29effb3

Please sign in to comment.
You can’t perform that action at this time.