From 4c9caa816906d53b989c65bd24c56147517eee82 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Zaefferer?= Date: Thu, 15 Nov 2012 23:23:25 +0100 Subject: [PATCH] Dialog: Extract button pane creation into _createButtonPane --- tests/visual/dialog/complex-dialogs.html | 10 ++++++++- ui/jquery.ui.dialog.js | 26 ++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/tests/visual/dialog/complex-dialogs.html b/tests/visual/dialog/complex-dialogs.html index 2b9a0d3a6..8e5d84d3d 100644 --- a/tests/visual/dialog/complex-dialogs.html +++ b/tests/visual/dialog/complex-dialogs.html @@ -25,7 +25,15 @@ var dialog = $( "#dialog" ).dialog({ modal: true, height: 300, - width: 500 + width: 500, + buttons: [ + { + text: "Ok" + }, + { + text: "Cancel" + } + ] }), datepickerDialog = $( "#dialog-datepicker" ).dialog({ diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index d4f03af60..79aae52ab 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -123,16 +123,8 @@ $.widget("ui.dialog", { .addClass( "ui-dialog-content ui-widget-content" ) .appendTo( this.uiDialog ); - this._createTitlebar(); - - // TODO extract this one and the next into a _createButtonPane method - uiDialogButtonPane = ( this.uiDialogButtonPane = $( "
" ) ) - .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ); - - ( this.uiButtonSet = $( "
" ) ) - .addClass( "ui-dialog-buttonset" ) - .appendTo( uiDialogButtonPane ); - + this._createTitlebar(); + this._createButtonPane(); // TODO move into _createWrapper // We assume that any existing aria-describedby attribute means @@ -151,9 +143,6 @@ $.widget("ui.dialog", { this._makeResizable(); } - // TODO merge with _createButtonPane? - this._createButtons(); - this._isOpen = false; // prevent tabbing out of dialogs @@ -365,6 +354,17 @@ $.widget("ui.dialog", { }); }, + _createButtonPane: function() { + var uiDialogButtonPane = ( this.uiDialogButtonPane = $( "
" ) ) + .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ); + + this.uiButtonSet = $( "
" ) + .addClass( "ui-dialog-buttonset" ) + .appendTo( uiDialogButtonPane ); + + this._createButtons(); + }, + _createButtons: function() { var that = this, buttons = this.options.buttons; -- 2.39.5