Skip to content

Commit bc3ea22

Browse files
committed
Dialog: Extract button pane creation into _createButtonPane
1 parent c51b891 commit bc3ea22

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

tests/visual/dialog/complex-dialogs.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@
2525
var dialog = $( "#dialog" ).dialog({
2626
modal: true,
2727
height: 300,
28-
width: 500
28+
width: 500,
29+
buttons: [
30+
{
31+
text: "Ok"
32+
},
33+
{
34+
text: "Cancel"
35+
}
36+
]
2937
}),
3038

3139
datepickerDialog = $( "#dialog-datepicker" ).dialog({

ui/jquery.ui.dialog.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,8 @@ $.widget("ui.dialog", {
123123
.addClass( "ui-dialog-content ui-widget-content" )
124124
.appendTo( this.uiDialog );
125125

126-
this._createTitlebar();
127-
128-
// TODO extract this one and the next into a _createButtonPane method
129-
uiDialogButtonPane = ( this.uiDialogButtonPane = $( "<div>" ) )
130-
.addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
131-
132-
( this.uiButtonSet = $( "<div>" ) )
133-
.addClass( "ui-dialog-buttonset" )
134-
.appendTo( uiDialogButtonPane );
135-
126+
this._createTitlebar();
127+
this._createButtonPane();
136128

137129
// TODO move into _createWrapper
138130
// We assume that any existing aria-describedby attribute means
@@ -151,9 +143,6 @@ $.widget("ui.dialog", {
151143
this._makeResizable();
152144
}
153145

154-
// TODO merge with _createButtonPane?
155-
this._createButtons();
156-
157146
this._isOpen = false;
158147

159148
// prevent tabbing out of dialogs
@@ -365,6 +354,17 @@ $.widget("ui.dialog", {
365354
});
366355
},
367356

357+
_createButtonPane: function() {
358+
var uiDialogButtonPane = ( this.uiDialogButtonPane = $( "<div>" ) )
359+
.addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
360+
361+
this.uiButtonSet = $( "<div>" )
362+
.addClass( "ui-dialog-buttonset" )
363+
.appendTo( uiDialogButtonPane );
364+
365+
this._createButtons();
366+
},
367+
368368
_createButtons: function() {
369369
var that = this,
370370
buttons = this.options.buttons;

0 commit comments

Comments
 (0)