OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 ///////////////////////////////////////////////////////////////////////////// | 6 ///////////////////////////////////////////////////////////////////////////// |
7 // OptionsPage class: | 7 // OptionsPage class: |
8 | 8 |
9 /** | 9 /** |
10 * Base class for options page. | 10 * Base class for options page. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 /** | 102 /** |
103 * Closes any currently-open subpage. | 103 * Closes any currently-open subpage. |
104 */ | 104 */ |
105 OptionsPage.closeSubPage = function() { | 105 OptionsPage.closeSubPage = function() { |
106 for (var name in OptionsPage.registeredSubPages_) { | 106 for (var name in OptionsPage.registeredSubPages_) { |
107 var pageInfo = OptionsPage.registeredSubPages_[name]; | 107 var pageInfo = OptionsPage.registeredSubPages_[name]; |
108 if (pageInfo.page.visible) { | 108 if (pageInfo.page.visible) { |
109 pageInfo.page.visible = false; | 109 pageInfo.page.visible = false; |
110 // Since the managed pref banner lives outside the overlay, and the | 110 // Since the managed pref banner lives outside the overlay, and the |
111 // parent is not changing visibility, update the banner explicitly. | 111 // parent is not changing visibility, update the banner explicitly. |
112 var banner = $('managed-prefs-banner'); | 112 if (pageInfo.parentPage.managed) { |
113 banner.style.display = pageInfo.parentPage.managed ? 'block' : 'none'; | 113 $('managed-prefs-banner').classList.remove('hidden'); |
114 } else { | |
115 $('managed-prefs-banner').classList.add('hidden'); | |
116 } | |
stuartmorgan
2010/11/16 23:42:55
Since we have this duplicated three times, how abo
csilv
2010/11/17 00:15:24
Done.
| |
114 } | 117 } |
115 } | 118 } |
116 }; | 119 }; |
117 | 120 |
118 /** | 121 /** |
119 * Shows the tab contents for the given navigation tab. | 122 * Shows the tab contents for the given navigation tab. |
120 * @param {!Element} tab The tab that the user clicked. | 123 * @param {!Element} tab The tab that the user clicked. |
121 */ | 124 */ |
122 OptionsPage.showTab = function(tab) { | 125 OptionsPage.showTab = function(tab) { |
123 // Search parents until we find a tab, or the nav bar itself. This allows | 126 // Search parents until we find a tab, or the nav bar itself. This allows |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 * Initializes page content. | 228 * Initializes page content. |
226 */ | 229 */ |
227 initializePage: function() {}, | 230 initializePage: function() {}, |
228 | 231 |
229 /** | 232 /** |
230 * Sets managed banner visibility state. | 233 * Sets managed banner visibility state. |
231 */ | 234 */ |
232 setManagedBannerVisibility: function(visible) { | 235 setManagedBannerVisibility: function(visible) { |
233 this.managed = visible; | 236 this.managed = visible; |
234 if (this.visible) { | 237 if (this.visible) { |
235 $('managed-prefs-banner').style.display = visible ? 'block' : 'none'; | 238 if (this.managed) { |
239 $('managed-prefs-banner').classList.remove('hidden'); | |
240 } else { | |
241 $('managed-prefs-banner').classList.add('hidden'); | |
242 } | |
236 } | 243 } |
237 }, | 244 }, |
238 | 245 |
239 /** | 246 /** |
240 * Gets page visibility state. | 247 * Gets page visibility state. |
241 */ | 248 */ |
242 get visible() { | 249 get visible() { |
243 var page = $(this.pageDivName); | 250 var page = $(this.pageDivName); |
244 return page && page.ownerDocument.defaultView.getComputedStyle( | 251 return page && page.ownerDocument.defaultView.getComputedStyle( |
245 page).display == 'block'; | 252 page).display == 'block'; |
246 }, | 253 }, |
247 | 254 |
248 /** | 255 /** |
249 * Sets page visibility. | 256 * Sets page visibility. |
250 */ | 257 */ |
251 set visible(visible) { | 258 set visible(visible) { |
252 if ((this.visible && visible) || (!this.visible && !visible)) | 259 if ((this.visible && visible) || (!this.visible && !visible)) |
253 return; | 260 return; |
254 | 261 |
255 if (visible) { | 262 if (visible) { |
256 this.pageDiv.style.display = 'block'; | 263 this.pageDiv.classList.remove('hidden'); |
257 if (this.isOverlay) { | 264 if (this.isOverlay) { |
258 var overlay = $('overlay'); | 265 $('overlay').classList.remove('hidden'); |
259 overlay.classList.remove('hidden'); | |
260 document.addEventListener('keydown', | 266 document.addEventListener('keydown', |
261 OptionsPage.clearOverlaysOnEsc_); | 267 OptionsPage.clearOverlaysOnEsc_); |
262 } else { | 268 } else { |
263 if (this.isSubPageSheet) | 269 if (this.isSubPageSheet) |
264 $('subpage-sheet-container').classList.remove('hidden'); | 270 $('subpage-sheet-container').classList.remove('hidden'); |
265 | 271 |
266 var banner = $('managed-prefs-banner'); | 272 if (this.managed) { |
267 banner.style.display = this.managed ? 'block' : 'none'; | 273 $('managed-prefs-banner').classList.remove('hidden'); |
274 } else { | |
275 $('managed-prefs-banner').classList.add('hidden'); | |
276 } | |
268 | 277 |
269 // Recent webkit change no longer allows url change from "chrome://". | 278 // Recent webkit change no longer allows url change from "chrome://". |
270 window.history.pushState({pageName: this.name}, | 279 window.history.pushState({pageName: this.name}, |
271 this.title); | 280 this.title); |
272 } | 281 } |
273 if (this.tab) { | 282 if (this.tab) { |
274 this.tab.classList.add('navbar-item-selected'); | 283 this.tab.classList.add('navbar-item-selected'); |
275 } | 284 } |
276 } else { | 285 } else { |
286 this.pageDiv.classList.add('hidden'); | |
277 if (this.isOverlay) { | 287 if (this.isOverlay) { |
278 var overlay = $('overlay'); | 288 $('overlay').classList.add('hidden'); |
279 overlay.classList.add('hidden'); | |
280 document.removeEventListener('keydown', | 289 document.removeEventListener('keydown', |
281 OptionsPage.clearOverlaysOnEsc_); | 290 OptionsPage.clearOverlaysOnEsc_); |
282 } else if (this.isSubPageSheet) { | 291 } else if (this.isSubPageSheet) { |
283 $('subpage-sheet-container').classList.add('hidden'); | 292 $('subpage-sheet-container').classList.add('hidden'); |
284 } | 293 } |
285 this.pageDiv.style.display = 'none'; | |
286 if (this.tab) { | 294 if (this.tab) { |
287 this.tab.classList.remove('navbar-item-selected'); | 295 this.tab.classList.remove('navbar-item-selected'); |
288 } | 296 } |
289 } | 297 } |
290 | 298 |
291 cr.dispatchPropertyChange(this, 'visible', visible, !visible); | 299 cr.dispatchPropertyChange(this, 'visible', visible, !visible); |
292 }, | 300 }, |
293 | 301 |
294 /** | 302 /** |
295 * Handles a hash value in the URL (such as bar in | 303 * Handles a hash value in the URL (such as bar in |
296 * chrome://options/foo#bar). Called on page load. By default, this shows | 304 * chrome://options/foo#bar). Called on page load. By default, this shows |
297 * an overlay that matches the hash name, but can be overriden by individual | 305 * an overlay that matches the hash name, but can be overriden by individual |
298 * OptionsPage subclasses to get other behavior. | 306 * OptionsPage subclasses to get other behavior. |
299 * @param {string} hash The hash value. | 307 * @param {string} hash The hash value. |
300 */ | 308 */ |
301 handleHash: function(hash) { | 309 handleHash: function(hash) { |
302 OptionsPage.showOverlay(hash); | 310 OptionsPage.showOverlay(hash); |
303 }, | 311 }, |
304 }; | 312 }; |
305 | 313 |
306 // Export | 314 // Export |
307 return { | 315 return { |
308 OptionsPage: OptionsPage | 316 OptionsPage: OptionsPage |
309 }; | 317 }; |
310 | 318 |
311 }); | 319 }); |
OLD | NEW |