OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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('help', function() { | 5 cr.define('help', function() { |
6 var Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
8 | 8 |
9 /** | 9 /** |
10 * Encapsulated handling of the About page. Called 'help' internally to avoid | 10 * Encapsulated handling of the About page. Called 'help' internally to avoid |
11 * confusion with generic AboutUI (about:memory, about:sandbox, etc.). | 11 * confusion with generic AboutUI (about:memory, about:sandbox, etc.). |
12 */ | 12 */ |
13 function HelpPage() { | 13 function HelpPage() { |
14 Page.call(this, 'help', loadTimeData.getString('aboutTitle'), | 14 var id = loadTimeData.valueExists('aboutOverlayTabTitle') ? |
15 'help-page'); | 15 'aboutOverlayTabTitle' : 'aboutTitle'; |
16 Page.call(this, 'help', loadTimeData.getString(id), 'help-page'); | |
16 } | 17 } |
17 | 18 |
18 cr.addSingletonGetter(HelpPage); | 19 cr.addSingletonGetter(HelpPage); |
19 | 20 |
20 HelpPage.prototype = { | 21 HelpPage.prototype = { |
21 __proto__: Page.prototype, | 22 __proto__: Page.prototype, |
22 | 23 |
23 /** | 24 /** |
24 * True if after update powerwash button should be displayed. | 25 * True if after update powerwash button should be displayed. |
25 * @private | 26 * @private |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 | 108 |
108 if (cr.isChromeOS) { | 109 if (cr.isChromeOS) { |
109 // Add event listener for the close button when shown as an overlay. | 110 // Add event listener for the close button when shown as an overlay. |
110 if ($('about-done')) { | 111 if ($('about-done')) { |
111 $('about-done').addEventListener('click', function() { | 112 $('about-done').addEventListener('click', function() { |
112 PageManager.closeOverlay(); | 113 PageManager.closeOverlay(); |
113 }); | 114 }); |
114 } | 115 } |
115 | 116 |
116 $('change-channel').onclick = function() { | 117 $('change-channel').onclick = function() { |
117 PageManager.showPageByName('channel-change-page', false); | 118 PageManager.showPageByName('channel-change-page'); |
118 }; | 119 }; |
119 | 120 |
120 var channelChangeDisallowedError = document.createElement('div'); | 121 var channelChangeDisallowedError = document.createElement('div'); |
121 channelChangeDisallowedError.className = 'channel-change-error-bubble'; | 122 channelChangeDisallowedError.className = 'channel-change-error-bubble'; |
122 | 123 |
123 var channelChangeDisallowedIcon = document.createElement('div'); | 124 var channelChangeDisallowedIcon = document.createElement('div'); |
124 channelChangeDisallowedIcon.classList.add('help-page-icon-large'); | 125 channelChangeDisallowedIcon.classList.add('help-page-icon-large'); |
125 channelChangeDisallowedIcon.classList.add('channel-change-error-icon'); | 126 channelChangeDisallowedIcon.classList.add('channel-change-error-icon'); |
126 channelChangeDisallowedError.appendChild(channelChangeDisallowedIcon); | 127 channelChangeDisallowedError.appendChild(channelChangeDisallowedIcon); |
127 | 128 |
128 var channelChangeDisallowedText = document.createElement('div'); | 129 var channelChangeDisallowedText = document.createElement('div'); |
129 channelChangeDisallowedText.className = 'channel-change-error-text'; | 130 channelChangeDisallowedText.className = 'channel-change-error-text'; |
130 channelChangeDisallowedText.textContent = | 131 channelChangeDisallowedText.textContent = |
131 loadTimeData.getString('channelChangeDisallowedMessage'); | 132 loadTimeData.getString('channelChangeDisallowedMessage'); |
132 channelChangeDisallowedError.appendChild(channelChangeDisallowedText); | 133 channelChangeDisallowedError.appendChild(channelChangeDisallowedText); |
133 | 134 |
134 $('channel-change-disallowed-icon').onclick = function() { | 135 $('channel-change-disallowed-icon').onclick = function() { |
135 PageManager.showBubble(channelChangeDisallowedError, | 136 PageManager.showBubble(channelChangeDisallowedError, |
136 $('channel-change-disallowed-icon'), | 137 $('channel-change-disallowed-icon'), |
137 $('help-container'), | 138 $('help-container'), |
138 cr.ui.ArrowLocation.TOP_END); | 139 cr.ui.ArrowLocation.TOP_END); |
139 }; | 140 }; |
140 } | 141 } |
141 | 142 |
142 // Attempt to update. | 143 // Attempt to update. |
143 chrome.send('onPageLoaded'); | 144 chrome.send('onPageLoaded'); |
144 }, | 145 }, |
145 | 146 |
147 /** @override */ | |
148 didClosePage: function() { | |
149 if ($('more-info-container').classList.contains('visible')) | |
150 this.toggleMoreInfo_(); | |
Dan Beam
2014/08/13 17:03:18
nit: i'd make a setMoreInfoVisible_ and use it her
michaelpg
2014/08/13 20:17:51
Done.
| |
151 }, | |
152 | |
146 /** | 153 /** |
147 * Toggles the visible state of the 'More Info' section. | 154 * Toggles the visible state of the 'More Info' section. |
148 * @private | 155 * @private |
149 */ | 156 */ |
150 toggleMoreInfo_: function() { | 157 toggleMoreInfo_: function() { |
151 var moreInfo = $('more-info-container'); | 158 var moreInfo = $('more-info-container'); |
152 var visible = moreInfo.className == 'visible'; | 159 var visible = moreInfo.className == 'visible'; |
153 moreInfo.className = visible ? '' : 'visible'; | 160 moreInfo.className = visible ? '' : 'visible'; |
154 moreInfo.style.height = visible ? '' : moreInfo.scrollHeight + 'px'; | 161 moreInfo.style.height = visible ? '' : moreInfo.scrollHeight + 'px'; |
155 moreInfo.addEventListener('webkitTransitionEnd', function(event) { | 162 moreInfo.addEventListener('webkitTransitionEnd', function(event) { |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 | 516 |
510 HelpPage.updateChannelChangePageContainerVisibility = function() { | 517 HelpPage.updateChannelChangePageContainerVisibility = function() { |
511 HelpPage.getInstance().updateChannelChangePageContainerVisibility_(); | 518 HelpPage.getInstance().updateChannelChangePageContainerVisibility_(); |
512 }; | 519 }; |
513 | 520 |
514 // Export | 521 // Export |
515 return { | 522 return { |
516 HelpPage: HelpPage | 523 HelpPage: HelpPage |
517 }; | 524 }; |
518 }); | 525 }); |
OLD | NEW |