OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // Helper base class for all help pages and overlays, which controls | 5 // Helper base class for all help pages and overlays, which controls |
6 // overlays, focus and scroll. This class is partially based on | 6 // overlays, focus and scroll. This class is partially based on |
7 // OptionsPage, but simpler and contains only overlay- and focus- | 7 // OptionsPage, but simpler and contains only overlay- and focus- |
8 // handling logic. As in OptionsPage each page can be an overlay itself, | 8 // handling logic. As in OptionsPage each page can be an overlay itself, |
9 // but each page contains its own list of registered overlays which can be | 9 // but each page contains its own list of registered overlays which can be |
10 // displayed over it. | 10 // displayed over it. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 108 } |
109 return null; | 109 return null; |
110 }, | 110 }, |
111 | 111 |
112 /** | 112 /** |
113 * Freezes current page, makes it impossible to scroll it. | 113 * Freezes current page, makes it impossible to scroll it. |
114 * @param {boolean} freeze True if the page should be frozen. | 114 * @param {boolean} freeze True if the page should be frozen. |
115 * @private | 115 * @private |
116 */ | 116 */ |
117 freeze_: function(freeze) { | 117 freeze_: function(freeze) { |
| 118 var scrollLeft = scrollLeftForDocument(document); |
118 if (freeze) { | 119 if (freeze) { |
119 this.lastScrollTop = document.documentElement.scrollTop; | 120 this.lastScrollTop = scrollTopForDocument(document); |
120 document.body.style.overflow = 'hidden'; | 121 document.body.style.overflow = 'hidden'; |
121 window.scroll(document.documentElement.scrollLeft, 0); | 122 window.scroll(scrollLeft, 0); |
122 } else { | 123 } else { |
123 document.body.style.overflow = 'auto'; | 124 document.body.style.overflow = 'auto'; |
124 window.scroll(document.documentElement.scrollLeft, this.lastScrollTop); | 125 window.scroll(scrollLeft, this.lastScrollTop); |
125 } | 126 } |
126 }, | 127 }, |
127 | 128 |
128 /** | 129 /** |
129 * Initializes current page. | 130 * Initializes current page. |
130 * @param {string} name Name of the current page. | 131 * @param {string} name Name of the current page. |
131 */ | 132 */ |
132 initialize: function(name) { | 133 initialize: function(name) { |
133 this.name = name; | 134 this.name = name; |
134 this.pageDiv = $(name); | 135 this.pageDiv = $(name); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 return; | 237 return; |
237 } | 238 } |
238 }, | 239 }, |
239 }; | 240 }; |
240 | 241 |
241 // Export | 242 // Export |
242 return { | 243 return { |
243 HelpBasePage: HelpBasePage | 244 HelpBasePage: HelpBasePage |
244 }; | 245 }; |
245 }); | 246 }); |
OLD | NEW |