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 <include src="../uber/uber_utils.js"> | 5 <include src="../uber/uber_utils.js"> |
6 | 6 |
7 cr.define('help', function() { | 7 cr.define('help', function() { |
| 8 var localStrings = new LocalStrings(); |
| 9 |
8 /** | 10 /** |
9 * Encapsulated handling of the help page. | 11 * Encapsulated handling of the help page. |
10 */ | 12 */ |
11 function HelpPage() {} | 13 function HelpPage() {} |
12 | 14 |
13 cr.addSingletonGetter(HelpPage); | 15 cr.addSingletonGetter(HelpPage); |
14 | 16 |
15 HelpPage.prototype = { | 17 HelpPage.prototype = { |
16 __proto__: HTMLDivElement.prototype, | 18 __proto__: HTMLDivElement.prototype, |
17 | 19 |
18 /** | 20 /** |
19 * Perform initial setup. | 21 * Perform initial setup. |
20 */ | 22 */ |
21 initialize: function() { | 23 initialize: function() { |
22 uber.onContentFrameLoaded(); | 24 uber.onContentFrameLoaded(); |
23 | 25 |
24 // Set the title. | 26 // Set the title. |
25 var title = loadTimeData.getString('helpTitle'); | 27 var title = localStrings.getString('helpTitle'); |
26 uber.invokeMethodOnParent('setTitle', {title: title}); | 28 uber.invokeMethodOnParent('setTitle', {title: title}); |
27 | 29 |
28 $('product-license').innerHTML = loadTimeData.getString('productLicense'); | 30 $('product-license').innerHTML = localStrings.getString('productLicense'); |
29 if (cr.isChromeOS) { | 31 if (cr.isChromeOS) |
30 $('product-os-license').innerHTML = | 32 $('product-os-license').innerHTML = |
31 loadTimeData.getString('productOsLicense'); | 33 localStrings.getString('productOsLicense'); |
32 } | |
33 | 34 |
34 var productTOS = $('product-tos'); | 35 var productTOS = $('product-tos'); |
35 if (productTOS) | 36 if (productTOS) |
36 productTOS.innerHTML = loadTimeData.getString('productTOS'); | 37 productTOS.innerHTML = localStrings.getString('productTOS'); |
37 | 38 |
38 $('get-help').onclick = chrome.send.bind(chrome, 'openHelpPage'); | 39 $('get-help').onclick = chrome.send.bind(chrome, 'openHelpPage'); |
39 $('report-issue').onclick = | 40 $('report-issue').onclick = |
40 chrome.send.bind(chrome, 'openFeedbackDialog'); | 41 chrome.send.bind(chrome, 'openFeedbackDialog'); |
41 | 42 |
42 this.maybeSetOnClick_($('more-info-expander'), | 43 this.maybeSetOnClick_($('more-info-expander'), |
43 this.toggleMoreInfo_.bind(this)); | 44 this.toggleMoreInfo_.bind(this)); |
44 | 45 |
45 this.maybeSetOnClick_($('promote'), | 46 this.maybeSetOnClick_($('promote'), |
46 chrome.send.bind(chrome, 'promoteUpdater')); | 47 chrome.send.bind(chrome, 'promoteUpdater')); |
(...skipping 16 matching lines...) Expand all Loading... |
63 * Toggles the visible state of the 'More Info' section. | 64 * Toggles the visible state of the 'More Info' section. |
64 * @private | 65 * @private |
65 */ | 66 */ |
66 toggleMoreInfo_: function() { | 67 toggleMoreInfo_: function() { |
67 var moreInfo = $('more-info-container'); | 68 var moreInfo = $('more-info-container'); |
68 var visible = moreInfo.className == 'visible'; | 69 var visible = moreInfo.className == 'visible'; |
69 moreInfo.className = visible ? '' : 'visible'; | 70 moreInfo.className = visible ? '' : 'visible'; |
70 moreInfo.style.height = visible ? '' : moreInfo.scrollHeight + 'px'; | 71 moreInfo.style.height = visible ? '' : moreInfo.scrollHeight + 'px'; |
71 moreInfo.addEventListener('webkitTransitionEnd', function(event) { | 72 moreInfo.addEventListener('webkitTransitionEnd', function(event) { |
72 $('more-info-expander').textContent = visible ? | 73 $('more-info-expander').textContent = visible ? |
73 loadTimeData.getString('showMoreInfo') : | 74 localStrings.getString('showMoreInfo') : |
74 loadTimeData.getString('hideMoreInfo'); | 75 localStrings.getString('hideMoreInfo'); |
75 }); | 76 }); |
76 }, | 77 }, |
77 | 78 |
78 /** | 79 /** |
79 * Assigns |method| to the onclick property of |el| if |el| exists. | 80 * Assigns |method| to the onclick property of |el| if |el| exists. |
80 * @private | 81 * @private |
81 */ | 82 */ |
82 maybeSetOnClick_: function(el, method) { | 83 maybeSetOnClick_: function(el, method) { |
83 if (el) | 84 if (el) |
84 el.onclick = method; | 85 el.onclick = method; |
85 }, | 86 }, |
86 | 87 |
87 /** | 88 /** |
88 * @private | 89 * @private |
89 */ | 90 */ |
90 setUpdateImage_: function(state) { | 91 setUpdateImage_: function(state) { |
91 $('update-status-icon').className = 'update-icon ' + state; | 92 $('update-status-icon').className = 'update-icon ' + state; |
92 }, | 93 }, |
93 | 94 |
94 /** | 95 /** |
95 * @private | 96 * @private |
96 */ | 97 */ |
97 setUpdateStatus_: function(status, message) { | 98 setUpdateStatus_: function(status, message) { |
98 if (status == 'checking') { | 99 if (status == 'checking') { |
99 this.setUpdateImage_('working'); | 100 this.setUpdateImage_('working'); |
100 $('update-status').innerHTML = | 101 $('update-status').innerHTML = |
101 loadTimeData.getString('updateCheckStarted'); | 102 localStrings.getString('updateCheckStarted'); |
102 } else if (status == 'updating') { | 103 } else if (status == 'updating') { |
103 this.setUpdateImage_('working'); | 104 this.setUpdateImage_('working'); |
104 $('update-status').innerHTML = loadTimeData.getString('updating'); | 105 $('update-status').innerHTML = localStrings.getString('updating'); |
105 } else if (status == 'nearly_updated') { | 106 } else if (status == 'nearly_updated') { |
106 this.setUpdateImage_('up-to-date'); | 107 this.setUpdateImage_('up-to-date'); |
107 $('update-status').innerHTML = | 108 $('update-status').innerHTML = |
108 loadTimeData.getString('updateAlmostDone'); | 109 localStrings.getString('updateAlmostDone'); |
109 } else if (status == 'updated') { | 110 } else if (status == 'updated') { |
110 this.setUpdateImage_('up-to-date'); | 111 this.setUpdateImage_('up-to-date'); |
111 $('update-status').innerHTML = loadTimeData.getString('upToDate'); | 112 $('update-status').innerHTML = localStrings.getString('upToDate'); |
112 } else if (status == 'failed') { | 113 } else if (status == 'failed') { |
113 this.setUpdateImage_('failed'); | 114 this.setUpdateImage_('failed'); |
114 $('update-status').innerHTML = message; | 115 $('update-status').innerHTML = message; |
115 } else if (status == 'disabled') { | 116 } else if (status == 'disabled') { |
116 var container = $('update-status-container'); | 117 var container = $('update-status-container'); |
117 if (container) | 118 if (container) |
118 container.hidden = true; | 119 container.hidden = true; |
119 return; | 120 return; |
120 } | 121 } |
121 | 122 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 HelpPage: HelpPage | 270 HelpPage: HelpPage |
270 }; | 271 }; |
271 }); | 272 }); |
272 | 273 |
273 /** | 274 /** |
274 * onload listener to initialize the HelpPage. | 275 * onload listener to initialize the HelpPage. |
275 */ | 276 */ |
276 window.onload = function() { | 277 window.onload = function() { |
277 help.HelpPage.getInstance().initialize(); | 278 help.HelpPage.getInstance().initialize(); |
278 }; | 279 }; |
OLD | NEW |