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

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: Remove unnecessary flag reset. 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 100981fcb650e6c27f72ed9c3b581eedc9bed247..7ac6f17a521471c5f2ae3434dac3c0ee82a70698 100644
--- a/chrome/browser/resources/options/browser_options.js
+++ b/chrome/browser/resources/options/browser_options.js
@@ -32,6 +32,15 @@ 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);
@@ -418,6 +427,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 +565,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 +1316,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