| 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 /////////////////////////////////////////////////////////////////////////////// | 5 /////////////////////////////////////////////////////////////////////////////// |
| 6 // OptionsPage class: | 6 // OptionsPage class: |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Base class for options page. | 9 * Base class for options page. |
| 10 * @constructor | 10 * @constructor |
| 11 * @param {string} name Options page name, also defines id of the div element | 11 * @param {string} name Options page name, also defines id of the div element |
| 12 * containing the options view and the name of options page navigation bar | 12 * containing the options view and the name of options page navigation bar |
| 13 * item as name+'PageNav'. | 13 * item as name+'PageNav'. |
| 14 * @param {string} title Options page title, used for navigation bar | 14 * @param {string} title Options page title, used for navigation bar |
| 15 * @extends {EventTarget} |
| 15 */ | 16 */ |
| 16 function OptionsPage(name, title, pageDivName) { | 17 function OptionsPage(name, title, pageDivName) { |
| 17 this.name = name; | 18 this.name = name; |
| 18 this.title = title; | 19 this.title = title; |
| 19 this.pageDivName = pageDivName; | 20 this.pageDivName = pageDivName; |
| 20 this.pageDiv = $(this.pageDivName); | 21 this.pageDiv = $(this.pageDivName); |
| 21 this.tab = null; | 22 this.tab = null; |
| 22 } | 23 } |
| 23 | 24 |
| 24 OptionsPage.registeredPages_ = {}; | 25 OptionsPage.registeredPages_ = {}; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 115 |
| 115 /** | 116 /** |
| 116 * Initializes the complete options page. This will cause | 117 * Initializes the complete options page. This will cause |
| 117 * all C++ handlers to be invoked to do final setup. | 118 * all C++ handlers to be invoked to do final setup. |
| 118 */ | 119 */ |
| 119 OptionsPage.initialize = function() { | 120 OptionsPage.initialize = function() { |
| 120 chrome.send('coreOptionsInitialize'); | 121 chrome.send('coreOptionsInitialize'); |
| 121 }; | 122 }; |
| 122 | 123 |
| 123 OptionsPage.prototype = { | 124 OptionsPage.prototype = { |
| 125 __proto__: cr.EventTarget.prototype, |
| 126 |
| 124 /** | 127 /** |
| 125 * Initializes page content. | 128 * Initializes page content. |
| 126 */ | 129 */ |
| 127 initializePage: function() {}, | 130 initializePage: function() {}, |
| 128 | 131 |
| 129 /** | 132 /** |
| 130 * Gets page visibility state. | 133 * Gets page visibility state. |
| 131 */ | 134 */ |
| 132 get visible() { | 135 get visible() { |
| 133 var page = $(this.pageDivName); | 136 var page = $(this.pageDivName); |
| 134 return page.ownerDocument.defaultView.getComputedStyle( | 137 return page.ownerDocument.defaultView.getComputedStyle( |
| 135 page).display == 'block'; | 138 page).display == 'block'; |
| 136 }, | 139 }, |
| 137 | 140 |
| 138 /** | 141 /** |
| 139 * Sets page visibility. | 142 * Sets page visibility. |
| 140 */ | 143 */ |
| 141 set visible(visible) { | 144 set visible(visible) { |
| 142 if ((this.visible && visible) || (!this.visible && !visible)) | 145 if ((this.visible && visible) || (!this.visible && !visible)) |
| 143 return; | 146 return; |
| 144 | 147 |
| 145 if (visible) { | 148 if (visible) { |
| 146 window.history.pushState({pageName: this.name}, | 149 window.history.pushState({pageName: this.name}, |
| 147 this.title, | 150 this.title, |
| 148 '/' + this.name); | 151 '/' + this.name); |
| 149 this.pageDiv.style.display = 'block'; | 152 this.pageDiv.style.display = 'block'; |
| 150 if (this.isOverlay) { | 153 if (this.isOverlay) { |
| 151 var overlay = $('overlay'); | 154 var overlay = $('overlay'); |
| 152 overlay.classList.remove('hidden'); | 155 overlay.classList.remove('hidden'); |
| 153 overlay.classList.add('overlay-visible'); | |
| 154 } | 156 } |
| 155 if (this.tab) { | 157 if (this.tab) { |
| 156 this.tab.classList.add('navbar-item-selected'); | 158 this.tab.classList.add('navbar-item-selected'); |
| 157 if (this.tab.parentNode && this.tab.parentNode.id == 'subpagesnav') | 159 if (this.tab.parentNode && this.tab.parentNode.id == 'subpagesnav') |
| 158 this.tab.classList.remove('hidden'); | 160 this.tab.classList.remove('hidden'); |
| 159 } | 161 } |
| 160 } else { | 162 } else { |
| 161 if (this.isOverlay) { | 163 if (this.isOverlay) { |
| 162 var overlay = $('overlay'); | 164 var overlay = $('overlay'); |
| 163 overlay.classList.add('hidden'); | 165 overlay.classList.add('hidden'); |
| 164 overlay.classList.remove('overlay-visible'); | |
| 165 } | 166 } |
| 166 this.pageDiv.style.display = 'none'; | 167 this.pageDiv.style.display = 'none'; |
| 167 if (this.tab) { | 168 if (this.tab) { |
| 168 this.tab.classList.remove('navbar-item-selected'); | 169 this.tab.classList.remove('navbar-item-selected'); |
| 169 if (this.tab.parentNode && this.tab.parentNode.id == 'subpagesnav') | 170 if (this.tab.parentNode && this.tab.parentNode.id == 'subpagesnav') |
| 170 this.tab.classList.add('hidden'); | 171 this.tab.classList.add('hidden'); |
| 171 } | 172 } |
| 172 } | 173 } |
| 174 |
| 175 cr.dispatchPropertyChange(this, 'visible', visible, !visible); |
| 173 } | 176 } |
| 174 }; | 177 }; |
| OLD | NEW |