summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2012-10-24 13:24:37 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-01-07 10:53:58 +0100
commit731fce88a103610578a005d143eda55a12d3cd1f (patch)
treef1599faf78b8ab5f009852fdd448c83625778711 /install
parent7d457d521e668b9760f582107a6ac8693c819a6f (diff)
downloadfreeipa-731fce88a103610578a005d143eda55a12d3cd1f.tar.gz
freeipa-731fce88a103610578a005d143eda55a12d3cd1f.tar.xz
freeipa-731fce88a103610578a005d143eda55a12d3cd1f.zip
Focus last dialog when some is closed
When multiple dialogs is opened and one is closed the new top dialog doesn't recieve focus. It prevents from confirming/canceling the dialog using keyboard. This patch is fixing it. https://fedorahosted.org/freeipa/ticket/3200
Diffstat (limited to 'install')
-rw-r--r--install/ui/dialog.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 4a992fc4f..d0d51533e 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -22,6 +22,34 @@
/* REQUIRES: widget.js, details.js */
+IPA.opened_dialogs = {
+
+ dialogs: [],
+
+ top_dialog: function() {
+ var top = null;
+ if (this.dialogs.length) top = this.dialogs[this.dialogs.length - 1];
+ return top;
+ },
+
+ focus_top: function() {
+ var top = this.top_dialog();
+ if (top) {
+ top.container.dialog('moveToTop'); //make sure the last dialog is top dialog
+ top.focus_first_element();
+ }
+ },
+
+ add_dialog: function(dialog) {
+ this.dialogs.push(dialog);
+ },
+
+ remove_dialog: function(dialog) {
+ var index = this.dialogs.indexOf(dialog);
+ if (index > -1) this.dialogs.splice(index, 1);
+ }
+};
+
IPA.dialog_button = function(spec) {
spec = spec || {};
@@ -180,6 +208,21 @@ IPA.dialog = function(spec) {
that.set_buttons();
that.register_listeners();
+ IPA.opened_dialogs.add_dialog(that);
+ that.focus_first_element();
+ };
+
+ that.focus_first_element = function() {
+ // set focus to the first tabbable element in the content area or the first button
+ // if there are no tabbable elements, set focus on the dialog itself
+
+ var element = that.container;
+ var ui_dialog = that.container.parent('.ui-dialog'); // jq dialog div
+
+ // code taken from jquery dialog source code
+ $(element.find(':tabbable').get().concat(
+ ui_dialog.find('.ui-dialog-buttonpane :tabbable').get().concat(
+ ui_dialog.get()))).eq(0).focus();
};
that.option = function(name, value) {
@@ -231,6 +274,8 @@ IPA.dialog = function(spec) {
that.container.dialog('destroy');
that.container.remove();
that.remove_listeners();
+ IPA.opened_dialogs.remove_dialog(that);
+ IPA.opened_dialogs.focus_top();
};
that.reset = function() {