summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/resources/help/channel_change_page.js6
-rw-r--r--chrome/browser/resources/help/help_base_page.js5
-rw-r--r--ui/webui/resources/js/cr/ui/focus_manager.js43
3 files changed, 43 insertions, 11 deletions
diff --git a/chrome/browser/resources/help/channel_change_page.js b/chrome/browser/resources/help/channel_change_page.js
index 931e6ad..53be8bc 100644
--- a/chrome/browser/resources/help/channel_change_page.js
+++ b/chrome/browser/resources/help/channel_change_page.js
@@ -83,6 +83,12 @@ cr.define('help', function() {
this.selectOption_(this.targetChannel_);
else if (this.currentChannel_ != null)
this.selectOption_(this.currentChannel_);
+ var options = this.getAllChannelOptions_();
+ for (var i = 0; i < options.length; i++) {
+ var option = options[i];
+ if (option.checked)
+ option.focus();
+ }
},
/**
diff --git a/chrome/browser/resources/help/help_base_page.js b/chrome/browser/resources/help/help_base_page.js
index de39a28..578e260 100644
--- a/chrome/browser/resources/help/help_base_page.js
+++ b/chrome/browser/resources/help/help_base_page.js
@@ -76,12 +76,11 @@ cr.define('help', function() {
*/
setOverlayVisible_: function(visible) {
assert(this.isOverlay);
- var pageDiv = this.pageDiv;
this.container.hidden = !visible;
if (visible)
- pageDiv.classList.add('showing');
+ this.pageDiv.classList.add('showing');
else
- pageDiv.classList.remove('showing');
+ this.pageDiv.classList.remove('showing');
},
/**
diff --git a/ui/webui/resources/js/cr/ui/focus_manager.js b/ui/webui/resources/js/cr/ui/focus_manager.js
index caa0454..4291d7c 100644
--- a/ui/webui/resources/js/cr/ui/focus_manager.js
+++ b/ui/webui/resources/js/cr/ui/focus_manager.js
@@ -112,14 +112,7 @@ cr.define('cr.ui', function() {
* @private
*/
setFocus_: function() {
- // If |this.focusDirBackwards_| is true, the user has pressed "Shift+Tab"
- // and has caused the focus to be transferred backward, outside of the
- // current dialog. In this case, loop around and try to focus the last
- // element of the dialog; otherwise, try to focus the first element of the
- // dialog.
- var focusableElements = this.getFocusableElements_();
- var element = this.focusDirBackwards_ ? focusableElements.pop() :
- focusableElements.shift();
+ var element = this.selectFocusableElement_();
if (element) {
element.focus();
this.dispatchFocusEvent_(element);
@@ -134,6 +127,40 @@ cr.define('cr.ui', function() {
},
/**
+ * Selects first appropriate focusable element according to the
+ * current focus direction and element type. If it is a radio button,
+ * checked one is selected from the group.
+ * @private
+ */
+ selectFocusableElement_: function() {
+ // If |this.focusDirBackwards_| is true, the user has pressed "Shift+Tab"
+ // and has caused the focus to be transferred backward, outside of the
+ // current dialog. In this case, loop around and try to focus the last
+ // element of the dialog; otherwise, try to focus the first element of the
+ // dialog.
+ var focusableElements = this.getFocusableElements_();
+ var element = this.focusDirBackwards_ ? focusableElements.pop() :
+ focusableElements.shift();
+ if (!element)
+ return null;
+ if (element.tagName != 'INPUT' || element.type != 'radio' ||
+ element.name == '') {
+ return element;
+ }
+ if (!element.checked) {
+ for (var i = 0; i < focusableElements.length; i++) {
+ var e = focusableElements[i];
+ if (e && e.tagName == 'INPUT' && e.type == 'radio' &&
+ e.name == element.name && e.checked) {
+ element = e;
+ break;
+ }
+ }
+ }
+ return element;
+ },
+
+ /**
* Handler for focus events on the page.
* @param {Event} event The focus event.
* @private