Chromium Code Reviews| Index: chrome/browser/resources/help/help_page.js |
| diff --git a/chrome/browser/resources/help/help.js b/chrome/browser/resources/help/help_page.js |
| similarity index 80% |
| copy from chrome/browser/resources/help/help.js |
| copy to chrome/browser/resources/help/help_page.js |
| index 2b3de172eb13cebf3af04eb36dbd327b42f39a13..abf51324a6d06abf32a6a63ca30d01f3e7bc0a04 100644 |
| --- a/chrome/browser/resources/help/help.js |
| +++ b/chrome/browser/resources/help/help_page.js |
| @@ -1,19 +1,24 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -<include src="../uber/uber_utils.js"> |
| - |
| cr.define('help', function() { |
| + var Page = cr.ui.pageManager.Page; |
| + var PageManager = cr.ui.pageManager.PageManager; |
| + |
| /** |
| - * Encapsulated handling of the help page. |
| + * Encapsulated handling of the About page. Called 'help' internally to avoid |
| + * confusion with generic AboutUI (about:memory, about:sandbox, etc.). |
| */ |
| - function HelpPage() {} |
| + function HelpPage() { |
| + Page.call(this, 'help', loadTimeData.getString('aboutTitle'), |
| + 'help-page'); |
| + } |
| cr.addSingletonGetter(HelpPage); |
| HelpPage.prototype = { |
| - __proto__: help.HelpBasePage.prototype, |
| + __proto__: Page.prototype, |
| /** |
| * True if after update powerwash button should be displayed. |
| @@ -22,18 +27,12 @@ cr.define('help', function() { |
| powerwashAfterUpdate_: false, |
| /** |
| - * List of the channels names. |
| + * List of the channel names. |
| * @private |
| */ |
| channelList_: ['dev-channel', 'beta-channel', 'stable-channel'], |
| /** |
| - * Bubble for error messages and notifications. |
| - * @private |
| - */ |
| - bubble_: null, |
| - |
| - /** |
| * Name of the channel the device is currently on. |
| * @private |
| */ |
| @@ -45,18 +44,9 @@ cr.define('help', function() { |
| */ |
| targetChannel_: null, |
| - /** |
| - * Perform initial setup. |
| - */ |
| - initialize: function() { |
| - help.HelpBasePage.prototype.initialize.call(this, 'help-page'); |
| - |
| - var self = this; |
| - |
| - uber.onContentFrameLoaded(); |
| - |
| - // Set the title. |
| - uber.setTitle(loadTimeData.getString('aboutTitle')); |
| + /** @override */ |
| + initializePage: function() { |
| + Page.prototype.initializePage.call(this); |
| $('product-license').innerHTML = loadTimeData.getString('productLicense'); |
| if (cr.isChromeOS) { |
| @@ -93,20 +83,21 @@ cr.define('help', function() { |
| this.channelTable_ = { |
| 'stable-channel': { |
| - 'name': loadTimeData.getString('stable'), |
| - 'label': loadTimeData.getString('currentChannelStable'), |
| + 'name': loadTimeData.getString('stable'), |
| + 'label': loadTimeData.getString('currentChannelStable'), |
| }, |
| 'beta-channel': { |
| - 'name': loadTimeData.getString('beta'), |
| - 'label': loadTimeData.getString('currentChannelBeta') |
| + 'name': loadTimeData.getString('beta'), |
| + 'label': loadTimeData.getString('currentChannelBeta') |
| }, |
| 'dev-channel': { |
| - 'name': loadTimeData.getString('dev'), |
| - 'label': loadTimeData.getString('currentChannelDev') |
| + 'name': loadTimeData.getString('dev'), |
| + 'label': loadTimeData.getString('currentChannelDev') |
| } |
| }; |
| } |
| + var self = this; |
| var channelChanger = $('channel-changer'); |
| if (channelChanger) { |
| channelChanger.onchange = function(event) { |
| @@ -115,16 +106,15 @@ cr.define('help', function() { |
| } |
| if (cr.isChromeOS) { |
| - help.ChannelChangePage.getInstance().initialize(); |
| - this.registerOverlay(help.ChannelChangePage.getInstance()); |
| + // Add event listener for the close button when shown as an overlay. |
| + if ($('about-done')) { |
| + $('about-done').addEventListener('click', function() { |
| + PageManager.closeOverlay(); |
| + }); |
| + } |
| - cr.ui.overlay.setupOverlay($('overlay-container')); |
| - cr.ui.overlay.globalInitialization(); |
| - $('overlay-container').addEventListener('cancelOverlay', function() { |
| - self.closeOverlay(); |
| - }); |
| $('change-channel').onclick = function() { |
| - self.showOverlay('channel-change-page'); |
| + PageManager.showPageByName('channel-change-page', false); |
| }; |
| var channelChangeDisallowedError = document.createElement('div'); |
| @@ -142,51 +132,21 @@ cr.define('help', function() { |
| channelChangeDisallowedError.appendChild(channelChangeDisallowedText); |
| $('channel-change-disallowed-icon').onclick = function() { |
| - self.showBubble_(channelChangeDisallowedError, |
| - $('help-container'), |
| - $('channel-change-disallowed-icon'), |
| - cr.ui.ArrowLocation.TOP_END); |
| + PageManager.showBubble(channelChangeDisallowedError, |
| + $('channel-change-disallowed-icon'), |
| + $('help-container'), |
| + cr.ui.ArrowLocation.TOP_END); |
| }; |
| } |
| - cr.ui.FocusManager.disableMouseFocusOnButtons(); |
| - help.HelpFocusManager.getInstance().initialize(); |
| - |
| // Attempt to update. |
| chrome.send('onPageLoaded'); |
| }, |
| - /** |
| - * Shows the bubble. |
| - * @param {HTMLDivElement} content The content of the bubble. |
| - * @param {HTMLElement} target The element at which the bubble points. |
| - * @param {HTMLElement} domSibling The element after which the bubble is |
| - * added to the DOM. |
| - * @param {cr.ui.ArrowLocation} location The arrow location. |
| - * @private |
| - */ |
| - showBubble_: function(content, domSibling, target, location) { |
| - if (!cr.isChromeOS) |
| - return; |
| - this.hideBubble_(); |
| - var bubble = new cr.ui.AutoCloseBubble; |
| - bubble.anchorNode = target; |
| - bubble.domSibling = domSibling; |
| - bubble.arrowLocation = location; |
| - bubble.content = content; |
| - bubble.show(); |
| - this.bubble_ = bubble; |
| - }, |
| - |
| - /** |
| - * Hides the bubble. |
| - * @private |
| - */ |
| - hideBubble_: function() { |
| - if (!cr.isChromeOS) |
| - return; |
| - if (this.bubble_) |
| - this.bubble_.hide(); |
| + /** @override */ |
| + didHidePage: function() { |
| + if ($('more-info-container').className == 'visible') |
|
Dan Beam
2014/08/06 18:30:54
nit: $('more-info-container').classList.contains('
michaelpg
2014/08/06 21:58:18
Done.
|
| + this.toggleMoreInfo_(); |
| }, |
| /** |
| @@ -207,6 +167,8 @@ cr.define('help', function() { |
| /** |
| * Assigns |method| to the onclick property of |el| if |el| exists. |
| + * @param {HTMLElement} el The element on which to set the click handler. |
| + * @param {function} method The click handler. |
| * @private |
| */ |
| maybeSetOnClick_: function(el, method) { |
| @@ -215,7 +177,8 @@ cr.define('help', function() { |
| }, |
| /** |
| - * @private |
| + * @param {string} state The state of the update. |
| + * private |
| */ |
| setUpdateImage_: function(state) { |
| $('update-status-icon').className = 'help-page-icon ' + state; |
| @@ -231,8 +194,8 @@ cr.define('help', function() { |
| }, |
| /** |
| - * @return {boolean} True if target and current channels are not |
| - * null and not equals |
| + * @return {boolean} True if target and current channels are not null and |
| + * not equal. |
| * @private |
| */ |
| channelsDiffer_: function() { |
| @@ -242,6 +205,8 @@ cr.define('help', function() { |
| }, |
| /** |
| + * @param {string} status The status of the update. |
| + * @param {string} message Failure message to display. |
| * @private |
| */ |
| setUpdateStatus_: function(status, message) { |
| @@ -311,6 +276,7 @@ cr.define('help', function() { |
| }, |
| /** |
| + * @param {number} progress The percent completion. |
| * @private |
| */ |
| setProgress_: function(progress) { |
| @@ -318,6 +284,7 @@ cr.define('help', function() { |
| }, |
| /** |
| + * @param {string} message The allowed connection types message. |
| * @private |
| */ |
| setAllowedConnectionTypesMsg_: function(message) { |
| @@ -325,6 +292,7 @@ cr.define('help', function() { |
| }, |
| /** |
| + * @param {boolean} visible Whether to show the message. |
| * @private |
| */ |
| showAllowedConnectionTypesMsg_: function(visible) { |
| @@ -332,6 +300,7 @@ cr.define('help', function() { |
| }, |
| /** |
| + * @param {string} state The promote state to set. |
| * @private |
| */ |
| setPromotionState_: function(state) { |
| @@ -347,6 +316,7 @@ cr.define('help', function() { |
| }, |
| /** |
| + * @param {boolean} obsolete Whether the system is obsolete. |
| * @private |
| */ |
| setObsoleteSystem_: function(obsolete) { |
| @@ -356,6 +326,7 @@ cr.define('help', function() { |
| }, |
| /** |
| + * @param {boolean} endOfTheLine Train has rolled into the station. |
|
Dan Beam
2014/08/06 18:30:54
Whether the train has rolled into the station.
michaelpg
2014/08/06 21:58:18
Done.
|
| * @private |
| */ |
| setObsoleteSystemEndOfTheLine_: function(endOfTheLine) { |
| @@ -371,6 +342,7 @@ cr.define('help', function() { |
| }, |
| /** |
| + * @param {string} version Version of Chrome OS. |
| * @private |
| */ |
| setOSVersion_: function(version) { |
| @@ -382,6 +354,7 @@ cr.define('help', function() { |
| }, |
| /** |
| + * @param {string} firmware Firmware on Chrome OS. |
| * @private |
| */ |
| setOSFirmware_: function(firmware) { |
| @@ -395,7 +368,7 @@ cr.define('help', function() { |
| /** |
| * Updates name of the current channel, i.e. the name of the |
| * channel the device is currently on. |
| - * @param {string} channel The name of the current channel |
| + * @param {string} channel The name of the current channel. |
| * @private |
| */ |
| updateCurrentChannel_: function(channel) { |
| @@ -408,7 +381,7 @@ cr.define('help', function() { |
| }, |
| /** |
| - * |enabled| is true if the release channel can be enabled. |
| + * @param {boolean} enabled True if the release channel can be enabled. |
| * @private |
| */ |
| updateEnableReleaseChannel_: function(enabled) { |
| @@ -419,8 +392,8 @@ cr.define('help', function() { |
| /** |
| * Sets the device target channel. |
| - * @param {string} channel The name of the target channel |
| - * @param {boolean} isPowerwashAllowed True iff powerwash is allowed |
| + * @param {string} channel The name of the target channel. |
| + * @param {boolean} isPowerwashAllowed True iff powerwash is allowed. |
| * @private |
| */ |
| setChannel_: function(channel, isPowerwashAllowed) { |
| @@ -509,18 +482,6 @@ cr.define('help', function() { |
| HelpPage.getInstance().setOSFirmware_(firmware); |
| }; |
| - HelpPage.showOverlay = function(name) { |
| - HelpPage.getInstance().showOverlay(name); |
| - }; |
| - |
| - HelpPage.cancelOverlay = function() { |
| - HelpPage.getInstance().closeOverlay(); |
| - }; |
| - |
| - HelpPage.getTopmostVisiblePage = function() { |
| - return HelpPage.getInstance().getTopmostVisiblePage(); |
| - }; |
| - |
| HelpPage.updateIsEnterpriseManaged = function(isEnterpriseManaged) { |
| if (!cr.isChromeOS) |
| return; |
| @@ -560,10 +521,3 @@ cr.define('help', function() { |
| HelpPage: HelpPage |
| }; |
| }); |
| - |
| -/** |
| - * onload listener to initialize the HelpPage. |
| - */ |
| -window.onload = function() { |
| - help.HelpPage.getInstance().initialize(); |
| -}; |