Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: chrome/browser/resources/options/browser_options.js

Issue 11414204: Delay scroll to section until page initialization is complete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add docs. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/options_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options/browser_options.js
diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js
index 29b678496f9e59e5c60e248928e5e3daa1e81009..55454b9caf1d4d518e9785ca375c42b137cda07f 100644
--- a/chrome/browser/resources/options/browser_options.js
+++ b/chrome/browser/resources/options/browser_options.js
@@ -32,11 +32,22 @@ cr.define('options', function() {
*/
onShowHomeButtonChangedCalled_: false,
+ /**
+ * Track if page initialization is complete. All C++ UI handlers have the
+ * chance to manipulate page content within their InitializePage mathods.
+ * This flag is set to true after all initializers have been called.
+ * @type (boolean}
+ * @private
+ */
+ initializationComplete_: false,
+
/** @override */
initializePage: function() {
OptionsPage.prototype.initializePage.call(this);
var self = this;
+ this.initializationComplete_ = false;
James Hawkins 2012/11/29 23:20:21 Why do we need to set this here? Does reinitializ
kevers 2012/11/30 19:46:25 Flag reset is redundant. Removed.
+
// Ensure that navigation events are unblocked on uber page. A reload of
// the settings page while an overlay is open would otherwise leave uber
// page in a blocked state, where tab switching is not possible.
@@ -418,6 +429,16 @@ cr.define('options', function() {
$('search-field').focus();
},
+ /**
+ * Called after all C++ UI handlers have called InitializePage to notify
+ * that initialization is complete.
+ * @private
+ */
+ notifyInitializationComplete_: function() {
+ this.initializationComplete_ = true;
+ cr.dispatchSimpleEvent(document, 'initializationComplete');
+ },
+
/**
* Event listener for the 'session.restore_on_startup' pref.
* @param {Event} event The preference change event.
@@ -546,6 +567,17 @@ cr.define('options', function() {
/* animate */ false);
this.updateAdvancedSettingsExpander_();
}
+
+ if (!this.initializationComplete_) {
+ var self = this;
+ var callback = function() {
+ document.removeEventListener('initializationComplete', callback);
+ self.scrollToSection_(section);
+ };
+ document.addEventListener('initializationComplete', callback);
+ return;
+ }
+
var pageContainer = $('page-container');
var pageTop = parseFloat(pageContainer.style.top);
var topSection = document.querySelector('#page-container section');
@@ -1286,6 +1318,7 @@ cr.define('options', function() {
'getCurrentProfile',
'getStartStopSyncButton',
'hideBluetoothSettings',
+ 'notifyInitializationComplete',
'removeBluetoothDevice',
'removeCloudPrintConnectorSection',
'scrollToSection',
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/options_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698