diff options
author | Scott González <scott.gonzalez@gmail.com> | 2009-01-17 21:00:59 +0000 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2009-01-17 21:00:59 +0000 |
commit | 60856ea46146ad93e173fe1cddff9f882c73d916 (patch) | |
tree | f131ba9e5e38f4876d49e0ca33b91797b26befe7 /ui/ui.dialog.js | |
parent | 0ce1fa23029590637f86ce44248770ae7b1aae47 (diff) | |
download | jquery-ui-60856ea46146ad93e173fe1cddff9f882c73d916.tar.gz jquery-ui-60856ea46146ad93e173fe1cddff9f882c73d916.zip |
Dialog: Giving the content area and button pane priority over the title bar for which element should gain focus on open.
Diffstat (limited to 'ui/ui.dialog.js')
-rw-r--r-- | ui/ui.dialog.js | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/ui/ui.dialog.js b/ui/ui.dialog.js index 38c24c596..bd5d3b850 100644 --- a/ui/ui.dialog.js +++ b/ui/ui.dialog.js @@ -207,15 +207,18 @@ $.widget("ui.dialog", { open: function() { if (this._isOpen) { return; } - this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null; - (this.uiDialog.next().length && this.uiDialog.appendTo('body')); + var options = this.options, + uiDialog = this.uiDialog; + + this.overlay = options.modal ? new $.ui.dialog.overlay(this) : null; + (uiDialog.next().length && uiDialog.appendTo('body')); this._size(); - this._position(this.options.position); - this.uiDialog.show(this.options.show); + this._position(options.position); + uiDialog.show(options.show); this.moveToTop(true); // prevent tabbing out of modal dialogs - (this.options.modal && this.uiDialog.bind('keypress.ui-dialog', function(event) { + (options.modal && uiDialog.bind('keypress.ui-dialog', function(event) { if (event.keyCode != $.ui.keyCode.TAB) { return; } @@ -235,7 +238,17 @@ $.widget("ui.dialog", { } })); - this.uiDialog.find(':tabbable:first').focus(); + // set focus to the first tabbable element in: + // - content area + // - button pane + // - title bar + $([]) + .add(uiDialog.find('.ui-dialog-content :tabbable:first')) + .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first')) + .add(uiDialog.find('.ui-dialog-titlebar :tabbable:first')) + .filter(':first') + .focus(); + this._trigger('open'); this._isOpen = true; }, |