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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 632 } |
633 | 633 |
634 var pageContainer = $('page-container'); | 634 var pageContainer = $('page-container'); |
635 // pageContainer.offsetTop is relative to the screen. | 635 // pageContainer.offsetTop is relative to the screen. |
636 var pageTop = pageContainer.offsetTop; | 636 var pageTop = pageContainer.offsetTop; |
637 var sectionBottom = section.offsetTop + section.offsetHeight; | 637 var sectionBottom = section.offsetTop + section.offsetHeight; |
638 // section.offsetTop is relative to the 'page-container'. | 638 // section.offsetTop is relative to the 'page-container'. |
639 var sectionTop = section.offsetTop; | 639 var sectionTop = section.offsetTop; |
640 if (pageTop + sectionBottom > document.body.scrollHeight || | 640 if (pageTop + sectionBottom > document.body.scrollHeight || |
641 pageTop + sectionTop < 0) { | 641 pageTop + sectionTop < 0) { |
642 pageContainer.oldScrollTop = -pageTop; | |
643 // Currently not all layout updates are guaranteed to precede the | 642 // Currently not all layout updates are guaranteed to precede the |
644 // initializationComplete event (for example 'set-as-default-browser' | 643 // initializationComplete event (for example 'set-as-default-browser' |
645 // button) leaving some uncertainty in the optimal scroll position. | 644 // button) leaving some uncertainty in the optimal scroll position. |
646 // The section is placed approximately in the middle of the screen. | 645 // The section is placed approximately in the middle of the screen. |
647 pageContainer.style.top = document.body.scrollHeight / 2 - | 646 var top = Math.min(0, document.body.scrollHeight / 2 - sectionBottom); |
648 sectionBottom + 'px'; | 647 pageContainer.style.top = top + 'px'; |
| 648 pageContainer.oldScrollTop = -top; |
649 } | 649 } |
650 }, | 650 }, |
651 | 651 |
652 /** | 652 /** |
653 * Adds a |webkitTransitionEnd| listener to the given section so that | 653 * Adds a |webkitTransitionEnd| listener to the given section so that |
654 * it can be animated. The listener will only be added to a given section | 654 * it can be animated. The listener will only be added to a given section |
655 * once, so this can be called as multiple times. | 655 * once, so this can be called as multiple times. |
656 * @param {HTMLElement} section The section to be animated. | 656 * @param {HTMLElement} section The section to be animated. |
657 * @private | 657 * @private |
658 */ | 658 */ |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 BrowserOptions.getLoggedInUsername = function() { | 1564 BrowserOptions.getLoggedInUsername = function() { |
1565 return BrowserOptions.getInstance().username_; | 1565 return BrowserOptions.getInstance().username_; |
1566 }; | 1566 }; |
1567 } | 1567 } |
1568 | 1568 |
1569 // Export | 1569 // Export |
1570 return { | 1570 return { |
1571 BrowserOptions: BrowserOptions | 1571 BrowserOptions: BrowserOptions |
1572 }; | 1572 }; |
1573 }); | 1573 }); |
OLD | NEW |