From 94bb5ddff3eae16b2dca85520d2db77aa27fcd71 Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Mon, 28 Jul 2014 19:09:41 +0200 Subject: [PATCH] Selectmenu: Introduce _renderButton method Fixes #10142 --- ui/selectmenu.js | 50 +++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/ui/selectmenu.js b/ui/selectmenu.js index a3d4281a6f3..2191c5e85f7 100644 --- a/ui/selectmenu.js +++ b/ui/selectmenu.js @@ -67,8 +67,7 @@ return $.widget( "ui.selectmenu", { }, _drawButton: function() { - var that = this, - tabindex = this.element.attr( "tabindex" ); + var that = this; // Associate existing label with the new button this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button ); @@ -83,28 +82,7 @@ return $.widget( "ui.selectmenu", { this.element.hide(); // Create button - this.button = $( "", { - "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all", - tabindex: tabindex || this.options.disabled ? -1 : 0, - id: this.ids.button, - role: "combobox", - "aria-expanded": "false", - "aria-autocomplete": "list", - "aria-owns": this.ids.menu, - "aria-haspopup": "true" - }) - .insertAfter( this.element ); - - $( "", { - "class": "ui-icon " + this.options.icons.button - }) - .prependTo( this.button ); - - this.buttonText = $( "", { - "class": "ui-selectmenu-text" - }) - .appendTo( this.button ); - + this._renderButton(); this._setText( this.buttonText, this.element.find( "option:selected" ).text() ); this._resizeButton(); @@ -267,6 +245,30 @@ return $.widget( "ui.selectmenu", { return this.menu; }, + _renderButton: function() { + this.button = $( "", { + "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all", + tabindex: this.element.attr( "tabindex" ) || this.options.disabled ? -1 : 0, + id: this.ids.button, + role: "combobox", + "aria-expanded": "false", + "aria-autocomplete": "list", + "aria-owns": this.ids.menu, + "aria-haspopup": "true" + }) + .insertAfter( this.element ); + + $( "", { + "class": "ui-icon " + this.options.icons.button + }) + .prependTo( this.button ); + + this.buttonText = $( "", { + "class": "ui-selectmenu-text" + }) + .appendTo( this.button ); + }, + _renderMenu: function( ul, items ) { var that = this, currentOptgroup = "";