OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('options', function() { | 5 cr.define('options', function() { |
6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 var ArrayDataModel = cr.ui.ArrayDataModel; | 7 var ArrayDataModel = cr.ui.ArrayDataModel; |
8 var RepeatingButton = cr.ui.RepeatingButton; | 8 var RepeatingButton = cr.ui.RepeatingButton; |
9 | 9 |
10 // | 10 // |
(...skipping 14 matching lines...) Expand all Loading... | |
25 syncSetupCompleted: false, | 25 syncSetupCompleted: false, |
26 | 26 |
27 /** | 27 /** |
28 * Keeps track of whether |onShowHomeButtonChanged_| has been called. See | 28 * Keeps track of whether |onShowHomeButtonChanged_| has been called. See |
29 * |onShowHomeButtonChanged_|. | 29 * |onShowHomeButtonChanged_|. |
30 * @type {bool} | 30 * @type {bool} |
31 * @private | 31 * @private |
32 */ | 32 */ |
33 onShowHomeButtonChangedCalled_: false, | 33 onShowHomeButtonChangedCalled_: false, |
34 | 34 |
35 /** | |
36 * Track if page initialization is complete. All C++ UI handlers have the | |
37 * chance to manipulate page content within their InitializePage mathods. | |
38 * This flag is set to true after all initializers have been called. | |
39 * @type (boolean} | |
40 * @private | |
41 */ | |
42 initializationComplete_: false, | |
43 | |
35 /** @override */ | 44 /** @override */ |
36 initializePage: function() { | 45 initializePage: function() { |
37 OptionsPage.prototype.initializePage.call(this); | 46 OptionsPage.prototype.initializePage.call(this); |
38 var self = this; | 47 var self = this; |
39 | 48 |
49 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.
| |
50 | |
40 // Ensure that navigation events are unblocked on uber page. A reload of | 51 // Ensure that navigation events are unblocked on uber page. A reload of |
41 // the settings page while an overlay is open would otherwise leave uber | 52 // the settings page while an overlay is open would otherwise leave uber |
42 // page in a blocked state, where tab switching is not possible. | 53 // page in a blocked state, where tab switching is not possible. |
43 uber.invokeMethodOnParent('stopInterceptingEvents'); | 54 uber.invokeMethodOnParent('stopInterceptingEvents'); |
44 | 55 |
45 window.addEventListener('message', this.handleWindowMessage_.bind(this)); | 56 window.addEventListener('message', this.handleWindowMessage_.bind(this)); |
46 | 57 |
47 $('advanced-settings-expander').onclick = function() { | 58 $('advanced-settings-expander').onclick = function() { |
48 self.toggleSectionWithAnimation_( | 59 self.toggleSectionWithAnimation_( |
49 $('advanced-settings'), | 60 $('advanced-settings'), |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 OptionsPage.navigateToPage('factoryResetData'); | 422 OptionsPage.navigateToPage('factoryResetData'); |
412 }; | 423 }; |
413 } | 424 } |
414 }, | 425 }, |
415 | 426 |
416 /** @override */ | 427 /** @override */ |
417 didShowPage: function() { | 428 didShowPage: function() { |
418 $('search-field').focus(); | 429 $('search-field').focus(); |
419 }, | 430 }, |
420 | 431 |
432 /** | |
433 * Called after all C++ UI handlers have called InitializePage to notify | |
434 * that initialization is complete. | |
435 * @private | |
436 */ | |
437 notifyInitializationComplete_: function() { | |
438 this.initializationComplete_ = true; | |
439 cr.dispatchSimpleEvent(document, 'initializationComplete'); | |
440 }, | |
441 | |
421 /** | 442 /** |
422 * Event listener for the 'session.restore_on_startup' pref. | 443 * Event listener for the 'session.restore_on_startup' pref. |
423 * @param {Event} event The preference change event. | 444 * @param {Event} event The preference change event. |
424 * @private | 445 * @private |
425 */ | 446 */ |
426 onRestoreOnStartupChanged_: function(event) { | 447 onRestoreOnStartupChanged_: function(event) { |
427 /** @const */ var showHomePageValue = 0; | 448 /** @const */ var showHomePageValue = 0; |
428 | 449 |
429 if (event.value.value == showHomePageValue) { | 450 if (event.value.value == showHomePageValue) { |
430 // If the user previously selected "Show the homepage", the | 451 // If the user previously selected "Show the homepage", the |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 */ | 560 */ |
540 scrollToSection_: function(section) { | 561 scrollToSection_: function(section) { |
541 var advancedSettings = $('advanced-settings'); | 562 var advancedSettings = $('advanced-settings'); |
542 var container = $('advanced-settings-container'); | 563 var container = $('advanced-settings-container'); |
543 if (advancedSettings.hidden && section.parentNode == container) { | 564 if (advancedSettings.hidden && section.parentNode == container) { |
544 this.showSection_($('advanced-settings'), | 565 this.showSection_($('advanced-settings'), |
545 $('advanced-settings-container'), | 566 $('advanced-settings-container'), |
546 /* animate */ false); | 567 /* animate */ false); |
547 this.updateAdvancedSettingsExpander_(); | 568 this.updateAdvancedSettingsExpander_(); |
548 } | 569 } |
570 | |
571 if (!this.initializationComplete_) { | |
572 var self = this; | |
573 var callback = function() { | |
574 document.removeEventListener('initializationComplete', callback); | |
575 self.scrollToSection_(section); | |
576 }; | |
577 document.addEventListener('initializationComplete', callback); | |
578 return; | |
579 } | |
580 | |
549 var pageContainer = $('page-container'); | 581 var pageContainer = $('page-container'); |
550 var pageTop = parseFloat(pageContainer.style.top); | 582 var pageTop = parseFloat(pageContainer.style.top); |
551 var topSection = document.querySelector('#page-container section'); | 583 var topSection = document.querySelector('#page-container section'); |
552 var pageHeight = document.body.scrollHeight - topSection.offsetTop; | 584 var pageHeight = document.body.scrollHeight - topSection.offsetTop; |
553 var sectionTop = section.offsetTop; | 585 var sectionTop = section.offsetTop; |
554 var sectionHeight = section.offsetHeight; | 586 var sectionHeight = section.offsetHeight; |
555 var marginBottom = window.getComputedStyle(section).marginBottom; | 587 var marginBottom = window.getComputedStyle(section).marginBottom; |
556 if (marginBottom) | 588 if (marginBottom) |
557 sectionHeight += parseFloat(marginBottom); | 589 sectionHeight += parseFloat(marginBottom); |
558 if (pageHeight - pageTop < sectionTop + sectionHeight) { | 590 if (pageHeight - pageTop < sectionTop + sectionHeight) { |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1279 | 1311 |
1280 }; | 1312 }; |
1281 | 1313 |
1282 //Forward public APIs to private implementations. | 1314 //Forward public APIs to private implementations. |
1283 [ | 1315 [ |
1284 'addBluetoothDevice', | 1316 'addBluetoothDevice', |
1285 'enableFactoryResetSection', | 1317 'enableFactoryResetSection', |
1286 'getCurrentProfile', | 1318 'getCurrentProfile', |
1287 'getStartStopSyncButton', | 1319 'getStartStopSyncButton', |
1288 'hideBluetoothSettings', | 1320 'hideBluetoothSettings', |
1321 'notifyInitializationComplete', | |
1289 'removeBluetoothDevice', | 1322 'removeBluetoothDevice', |
1290 'removeCloudPrintConnectorSection', | 1323 'removeCloudPrintConnectorSection', |
1291 'scrollToSection', | 1324 'scrollToSection', |
1292 'setAutoOpenFileTypesDisplayed', | 1325 'setAutoOpenFileTypesDisplayed', |
1293 'setBluetoothState', | 1326 'setBluetoothState', |
1294 'setFontSize', | 1327 'setFontSize', |
1295 'setGtkThemeButtonEnabled', | 1328 'setGtkThemeButtonEnabled', |
1296 'setHighContrastCheckboxState', | 1329 'setHighContrastCheckboxState', |
1297 'setMetricsReportingCheckboxState', | 1330 'setMetricsReportingCheckboxState', |
1298 'setMetricsReportingSettingVisibility', | 1331 'setMetricsReportingSettingVisibility', |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1331 BrowserOptions.getLoggedInUsername = function() { | 1364 BrowserOptions.getLoggedInUsername = function() { |
1332 return BrowserOptions.getInstance().username_; | 1365 return BrowserOptions.getInstance().username_; |
1333 }; | 1366 }; |
1334 } | 1367 } |
1335 | 1368 |
1336 // Export | 1369 // Export |
1337 return { | 1370 return { |
1338 BrowserOptions: BrowserOptions | 1371 BrowserOptions: BrowserOptions |
1339 }; | 1372 }; |
1340 }); | 1373 }); |
OLD | NEW |