Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / help / channel_change_page.js
index 53be8bc..3763f65 100644 (file)
@@ -3,15 +3,20 @@
 // found in the LICENSE file.
 
 cr.define('help', function() {
+  var Page = cr.ui.pageManager.Page;
+  var PageManager = cr.ui.pageManager.PageManager;
+
   /**
    * Encapsulated handling of the channel change overlay.
    */
-  function ChannelChangePage() {}
+  function ChannelChangePage() {
+    Page.call(this, 'channel-change-page', '', 'channel-change-page');
+  }
 
   cr.addSingletonGetter(ChannelChangePage);
 
   ChannelChangePage.prototype = {
-    __proto__: help.HelpBasePage.prototype,
+    __proto__: Page.prototype,
 
     /**
      * Name of the channel the device is currently on.
@@ -46,18 +51,14 @@ cr.define('help', function() {
                     'selected-channel-good',
                     'selected-channel-unstable'],
 
-    /**
-     * Perform initial setup.
-     */
-    initialize: function() {
-      help.HelpBasePage.prototype.initialize.call(this, 'channel-change-page');
+    /** override */
+    initializePage: function() {
+      Page.prototype.initializePage.call(this);
 
-      var self = this;
-
-      $('channel-change-page-cancel-button').onclick = function() {
-        help.HelpPage.cancelOverlay();
-      };
+      $('channel-change-page-cancel-button').onclick =
+        PageManager.closeOverlay.bind(PageManager);
 
+      var self = this;
       var options = this.getAllChannelOptions_();
       for (var i = 0; i < options.length; i++) {
         var option = options[i];
@@ -68,17 +69,17 @@ cr.define('help', function() {
 
       $('channel-change-page-powerwash-button').onclick = function() {
         self.setChannel_(self.getSelectedOption_(), true);
-        help.HelpPage.cancelOverlay();
+        PageManager.closeOverlay();
       };
 
       $('channel-change-page-change-button').onclick = function() {
         self.setChannel_(self.getSelectedOption_(), false);
-        help.HelpPage.cancelOverlay();
+        PageManager.closeOverlay();
       };
     },
 
-    onBeforeShow: function() {
-      help.HelpBasePage.prototype.onBeforeShow.call(this);
+    /** @override */
+    didShowPage: function() {
       if (this.targetChannel_ != null)
         this.selectOption_(this.targetChannel_);
       else if (this.currentChannel_ != null)
@@ -93,16 +94,16 @@ cr.define('help', function() {
 
     /**
      * Returns the list of all radio buttons responsible for channel selection.
-     * @return {Array.<HTMLInputElement>} Array of radio buttons
+     * @return {NodeList} Array of radio buttons
      * @private
      */
     getAllChannelOptions_: function() {
-      return $('channel-change-page').querySelectorAll('input[type="radio"]');
+      return this.pageDiv.querySelectorAll('input[type="radio"]');
     },
 
     /**
      * Returns value of the selected option.
-     * @return {string} Selected channel name or null, if neither
+     * @return {?string} Selected channel name or null, if neither
      *     option is selected.
      * @private
      */
@@ -168,10 +169,10 @@ cr.define('help', function() {
 
       // Switch to the new UI state.
       for (var i = 0; i < this.uiClassTable_.length; i++)
-          $('channel-change-page').classList.remove(this.uiClassTable_[i]);
+        this.pageDiv.classList.remove(this.uiClassTable_[i]);
 
       if (newOverlayClass)
-        $('channel-change-page').classList.add(newOverlayClass);
+        this.pageDiv.classList.add(newOverlayClass);
     },
 
     /**
@@ -194,7 +195,6 @@ cr.define('help', function() {
      */
     updateIsEnterpriseManaged_: function(isEnterpriseManaged) {
       this.isEnterpriseManaged_ = isEnterpriseManaged;
-      help.HelpPage.updateChannelChangePageContainerVisibility();
     },
 
     /**
@@ -208,7 +208,6 @@ cr.define('help', function() {
         return;
       this.currentChannel_ = channel;
       this.selectOption_(channel);
-      help.HelpPage.updateChannelChangePageContainerVisibility();
     },
 
     /**
@@ -222,7 +221,6 @@ cr.define('help', function() {
       if (this.channelList_.indexOf(channel) < 0)
         return;
       this.targetChannel_ = channel;
-      help.HelpPage.updateChannelChangePageContainerVisibility();
     },
 
     /**