| 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 /** @const */ var FocusOutlineManager = cr.ui.FocusOutlineManager; | 6 /** @const */ var FocusOutlineManager = cr.ui.FocusOutlineManager; |
| 7 | 7 |
| 8 ///////////////////////////////////////////////////////////////////////////// | 8 ///////////////////////////////////////////////////////////////////////////// |
| 9 // OptionsPage class: | 9 // OptionsPage class: |
| 10 | 10 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 /** | 198 /** |
| 199 * Scrolls the page to the correct position (the top when opening an overlay, | 199 * Scrolls the page to the correct position (the top when opening an overlay, |
| 200 * or the old scroll position a previously hidden overlay becomes visible). | 200 * or the old scroll position a previously hidden overlay becomes visible). |
| 201 * @private | 201 * @private |
| 202 */ | 202 */ |
| 203 OptionsPage.updateScrollPosition_ = function() { | 203 OptionsPage.updateScrollPosition_ = function() { |
| 204 var container = $('page-container'); | 204 var container = $('page-container'); |
| 205 var scrollTop = container.oldScrollTop || 0; | 205 var scrollTop = container.oldScrollTop || 0; |
| 206 container.oldScrollTop = undefined; | 206 container.oldScrollTop = undefined; |
| 207 window.scroll(document.documentElement.scrollLeft, scrollTop); | 207 var scrollLeft = scrollLeftForDocument(document); |
| 208 window.scroll(scrollLeft, scrollTop); |
| 208 }; | 209 }; |
| 209 | 210 |
| 210 /** | 211 /** |
| 211 * Pushes the current page onto the history stack, overriding the last page | 212 * Pushes the current page onto the history stack, overriding the last page |
| 212 * if it is the generic chrome://settings/. | 213 * if it is the generic chrome://settings/. |
| 213 * @param {boolean} replace If true, allow no history events to be created. | 214 * @param {boolean} replace If true, allow no history events to be created. |
| 214 * @param {object=} opt_params A bag of optional params, including: | 215 * @param {object=} opt_params A bag of optional params, including: |
| 215 * {boolean} ignoreHash Whether to include the hash or not. | 216 * {boolean} ignoreHash Whether to include the hash or not. |
| 216 * @private | 217 * @private |
| 217 */ | 218 */ |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 * @private | 605 * @private |
| 605 */ | 606 */ |
| 606 OptionsPage.setRootPageFrozen_ = function(freeze) { | 607 OptionsPage.setRootPageFrozen_ = function(freeze) { |
| 607 var container = $('page-container'); | 608 var container = $('page-container'); |
| 608 if (container.classList.contains('frozen') == freeze) | 609 if (container.classList.contains('frozen') == freeze) |
| 609 return; | 610 return; |
| 610 | 611 |
| 611 if (freeze) { | 612 if (freeze) { |
| 612 // Lock the width, since auto width computation may change. | 613 // Lock the width, since auto width computation may change. |
| 613 container.style.width = window.getComputedStyle(container).width; | 614 container.style.width = window.getComputedStyle(container).width; |
| 614 container.oldScrollTop = document.documentElement.scrollTop; | 615 container.oldScrollTop = scrollTopForDocument(document); |
| 615 container.classList.add('frozen'); | 616 container.classList.add('frozen'); |
| 616 var verticalPosition = | 617 var verticalPosition = |
| 617 container.getBoundingClientRect().top - container.oldScrollTop; | 618 container.getBoundingClientRect().top - container.oldScrollTop; |
| 618 container.style.top = verticalPosition + 'px'; | 619 container.style.top = verticalPosition + 'px'; |
| 619 this.updateFrozenElementHorizontalPosition_(container); | 620 this.updateFrozenElementHorizontalPosition_(container); |
| 620 } else { | 621 } else { |
| 621 container.classList.remove('frozen'); | 622 container.classList.remove('frozen'); |
| 622 container.style.top = ''; | 623 container.style.top = ''; |
| 623 container.style.left = ''; | 624 container.style.left = ''; |
| 624 container.style.right = ''; | 625 container.style.right = ''; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 | 697 |
| 697 /** | 698 /** |
| 698 * Updates the given frozen element to match the horizontal scroll position. | 699 * Updates the given frozen element to match the horizontal scroll position. |
| 699 * @param {HTMLElement} e The frozen element to update. | 700 * @param {HTMLElement} e The frozen element to update. |
| 700 * @private | 701 * @private |
| 701 */ | 702 */ |
| 702 OptionsPage.updateFrozenElementHorizontalPosition_ = function(e) { | 703 OptionsPage.updateFrozenElementHorizontalPosition_ = function(e) { |
| 703 if (isRTL()) { | 704 if (isRTL()) { |
| 704 e.style.right = OptionsPage.horizontalOffset + 'px'; | 705 e.style.right = OptionsPage.horizontalOffset + 'px'; |
| 705 } else { | 706 } else { |
| 706 e.style.left = OptionsPage.horizontalOffset - | 707 var scrollLeft = scrollLeftForDocument(document); |
| 707 document.documentElement.scrollLeft + 'px'; | 708 e.style.left = OptionsPage.horizontalOffset - scrollLeft + 'px'; |
| 708 } | 709 } |
| 709 }; | 710 }; |
| 710 | 711 |
| 711 /** | 712 /** |
| 712 * Change the horizontal offset used to reposition elements while showing an | 713 * Change the horizontal offset used to reposition elements while showing an |
| 713 * overlay from the default. | 714 * overlay from the default. |
| 714 */ | 715 */ |
| 715 OptionsPage.setHorizontalOffset = function(value) { | 716 OptionsPage.setHorizontalOffset = function(value) { |
| 716 OptionsPage.horizontalOffset = value; | 717 OptionsPage.horizontalOffset = value; |
| 717 }; | 718 }; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 canShowPage: function() { | 998 canShowPage: function() { |
| 998 return true; | 999 return true; |
| 999 }, | 1000 }, |
| 1000 }; | 1001 }; |
| 1001 | 1002 |
| 1002 // Export | 1003 // Export |
| 1003 return { | 1004 return { |
| 1004 OptionsPage: OptionsPage | 1005 OptionsPage: OptionsPage |
| 1005 }; | 1006 }; |
| 1006 }); | 1007 }); |
| OLD | NEW |