diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index 10e543f42b9..e7c04e234eb 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -39,60 +39,60 @@ $.widget( "ui.selectmenu", { }, _create: function() { - var self = this, + var that = this, options = this.options, tabindex = this.element.attr( 'tabindex' ), // set a default id value, generate a new random one if not set by developer - selectmenuId = self.element.attr( 'id' ) || 'ui-selectmenu-' + Math.random().toString( 16 ).slice( 2, 10 ); + selectmenuId = that.element.attr( 'id' ) || 'ui-selectmenu-' + Math.random().toString( 16 ).slice( 2, 10 ); // quick array of button and menu id's - self.ids = [ selectmenuId + '-button', selectmenuId + '-menu' ]; + that.ids = [ selectmenuId + '-button', selectmenuId + '-menu' ]; // save options - self.items = self.element.find( 'option' ); + that.items = that.element.find( 'option' ); // set current value if ( options.value ) { - self.element[0].value = options.value; + that.element[0].value = options.value; } else { - options.value = self.element[0].value; + options.value = that.element[0].value; } // catch click event of the label - self.element.bind( 'click.selectmenu', function() { - self.newelement.focus(); + that.element.bind( 'click.selectmenu', function() { + that.newelement.focus(); return false; }) .hide(); // create button - self.newelement = $( '', { + that.newelement = $( '', { href: '#' + selectmenuId, - tabindex: ( tabindex ? tabindex : self.element.attr( 'disabled' ) ? 1 : 0 ), - id: self.ids[ 0 ], + tabindex: ( tabindex ? tabindex : that.element.attr( 'disabled' ) ? 1 : 0 ), + id: that.ids[ 0 ], css: { - width: self.element.outerWidth() + width: that.element.outerWidth() }, 'aria-disabled': options.disabled, - 'aria-owns': self.ids[ 1 ], + 'aria-owns': that.ids[ 1 ], 'aria-haspopup': true }) - .addClass( self.widgetBaseClass + '-button' ) + .addClass( that.widgetBaseClass + '-button' ) .button({ - label: self.items.eq( this.element[0].selectedIndex ).text(), + label: that.items.eq( this.element[0].selectedIndex ).text(), icons: { primary: ( options.dropdown ? 'ui-icon-triangle-1-s' : 'ui-icon-triangle-2-n-s' ) } }); // wrap and insert new button - self.newelementWrap = $( options.wrapperElement ) - .append( self.newelement ) - .insertAfter( self.element ); + that.newelementWrap = $( options.wrapperElement ) + .append( that.newelement ) + .insertAfter( that.element ); - self.newelement.bind({ + that.newelement.bind({ 'mousedown.selectmenu': function( event ) { - self._toggle( event ); + that._toggle( event ); return false; }, 'click.selectmenu': function() { @@ -101,54 +101,54 @@ $.widget( "ui.selectmenu", { 'keydown.selectmenu': function( event ) { switch (event.keyCode) { case $.ui.keyCode.TAB: - if ( self.opened ) self.close(); + if ( that.opened ) that.close(); break; case $.ui.keyCode.ENTER: - if ( self.opened ) self.list.menu( "select", self._getSelectedItem() ); + if ( that.opened ) that.list.menu( "select", that._getSelectedItem() ); event.preventDefault(); break; case $.ui.keyCode.SPACE: - self._toggle(event); + that._toggle(event); event.preventDefault(); break; case $.ui.keyCode.UP: if ( event.altKey ) { - self._toggle( event ); + that._toggle( event ); } else { - self._move( "previous", event ); + that._move( "previous", event ); } event.preventDefault(); break; case $.ui.keyCode.DOWN: if ( event.altKey ) { - self._toggle( event ); + that._toggle( event ); } else { - self._move( "next", event ); + that._move( "next", event ); } event.preventDefault(); break; case $.ui.keyCode.LEFT: - self._move( "previous", event ); + that._move( "previous", event ); event.preventDefault(); break; case $.ui.keyCode.RIGHT: - self._move( "next", event ); + that._move( "next", event ); event.preventDefault(); break; default: - self.list.trigger( event ); + that.list.trigger( event ); } } }); // built menu - self.refresh(); + that.refresh(); // document click closes menu $( document ).bind( 'mousedown.selectmenu', function( event ) { - if ( self.opened && !self.hover) { + if ( that.opened && !that.hover) { window.setTimeout( function() { - self.close( event ); + that.close( event ); }, 200 ); } }); @@ -156,109 +156,109 @@ $.widget( "ui.selectmenu", { // TODO update the value option refresh: function() { - var self = this, + var that = this, options = this.options; // create menu portion, append to body - self.list = $( '