-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Selectmenu: Introduce _renderButton method #1297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = $( "<span>", { | ||
"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 ); | ||
|
||
$( "<span>", { | ||
"class": "ui-icon " + this.options.icons.button | ||
}) | ||
.prependTo( this.button ); | ||
|
||
this.buttonText = $( "<span>", { | ||
"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 = $( "<span>", { | ||
"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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of this can be in here. These are all required functionality. |
||
}) | ||
.insertAfter( this.element ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Insertion in the DOM in not part of rendering. |
||
|
||
$( "<span>", { | ||
"class": "ui-icon " + this.options.icons.button | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not thrilled about the fact that an extension point needs to concern itself with other built-in options, but I don't see any way around this. |
||
.prependTo( this.button ); | ||
|
||
this.buttonText = $( "<span>", { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot rely on this property existing once it goes into an extension point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's needed to change the button text. Any idea how to work around? |
||
"class": "ui-selectmenu-text" | ||
}) | ||
.appendTo( this.button ); | ||
}, | ||
|
||
_renderMenu: function( ul, items ) { | ||
var that = this, | ||
currentOptgroup = ""; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't do any assigning. It should just return an element.