Index: chrome/browser/resources/chromeos/login/display_manager.js |
diff --git a/chrome/browser/resources/chromeos/login/display_manager.js b/chrome/browser/resources/chromeos/login/display_manager.js |
index 07fbab324a5f892494c0627e997d152c466f0c94..73104ef92df295adfa3862377efd0102bd3d1a4a 100644 |
--- a/chrome/browser/resources/chromeos/login/display_manager.js |
+++ b/chrome/browser/resources/chromeos/login/display_manager.js |
@@ -128,6 +128,14 @@ cr.define('cr.ui.login', function() { |
}, |
/** |
+ * Sets focus on a button with the autofocus attribute in the current |
+ * screen. |
+ */ |
+ restoreFocus: function() { |
+ this.updateFocus_($(this.screens_[this.currentStep_])); |
+ }, |
+ |
+ /** |
* Appends buttons to the button strip. |
* @param {Array.<HTMLElement>} buttons Array with the buttons to append. |
* @param {string} screenId Id of the screen that buttons belong to. |
@@ -160,6 +168,19 @@ cr.define('cr.ui.login', function() { |
}, |
/** |
+ * Sets focus on a button with the autofocus attribute. |
+ * @param {HTMLElement} screen Screen which controls should be affected. |
+ */ |
+ updateFocus_: function(screen) { |
+ var buttons = document.querySelectorAll( |
Nikita (slow)
2012/11/28 18:26:26
I think this should be implemented differently.
Y
mtomasz
2012/11/28 21:57:42
Isn't screen.buttons getter producing new buttons
Nikita (slow)
2012/11/29 16:08:11
You're right, screen.buttons always creates new el
|
+ '#' + screen.id + '-controls button'); |
+ for (var i = 0; i < buttons.length; ++i) { |
+ if (buttons[i].autofocus) |
+ buttons[i].focus(); |
Nikita (slow)
2012/11/28 18:26:26
break;
mtomasz
2012/11/28 21:57:42
Done.
|
+ } |
+ }, |
+ |
+ /** |
* Updates a step's css classes to reflect left, current, or right position. |
* @param {number} stepIndex step index. |
* @param {string} state one of 'left', 'current', 'right'. |
@@ -238,10 +259,12 @@ cr.define('cr.ui.login', function() { |
oldStep.classList.contains('right')) { |
innerContainer.classList.remove('animation'); |
oldStep.classList.add('hidden'); |
+ this.updateFocus_(newStep); |
} |
- }); |
+ }.bind(this)); |
Nikita (slow)
2012/11/28 18:26:26
Have you tested how OOBE works with this change?
mtomasz
2012/11/28 21:57:42
Yes, tested locally.
|
} else { |
oldStep.classList.add('hidden'); |
+ this.updateFocus_(newStep); |
} |
} else { |
// First screen on OOBE launch. |
@@ -252,7 +275,10 @@ cr.define('cr.ui.login', function() { |
innerContainer.removeEventListener('webkitTransitionEnd', f); |
$('progress-dots').classList.remove('down'); |
chrome.send('loginVisible', ['oobe']); |
- }); |
+ this.updateFocus_(newStep); |
+ }.bind(this)); |
+ } else { |
+ this.updateFocus_(newStep); |
} |
newHeader.classList.remove('right'); // Old OOBE. |
} |