Home | History | Annotate | Download | only in chromeos
      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
      3 // found in the LICENSE file.
      4 
      5 cr.define('options', function() {
      6   /** @const */ var SettingsDialog = options.SettingsDialog;
      7 
      8   /**
      9    * PointerOverlay class
     10    * Dialog that allows users to set pointer settings (touchpad/mouse).
     11    * @extends {SettingsDialog}
     12    */
     13   function PointerOverlay() {
     14     // The title is updated dynamically in the setTitle method as pointer
     15     // devices are discovered or removed.
     16     SettingsDialog.call(this, 'pointer-overlay',
     17                         '', 'pointer-overlay',
     18                         $('pointer-overlay-confirm'),
     19                         $('pointer-overlay-cancel'));
     20   }
     21 
     22   cr.addSingletonGetter(PointerOverlay);
     23 
     24   PointerOverlay.prototype = {
     25     __proto__: SettingsDialog.prototype,
     26 
     27     /**
     28      * Initialize the page.
     29      */
     30     initializePage: function() {
     31       // Call base class implementation to start preference initialization.
     32       SettingsDialog.prototype.initializePage.call(this);
     33     },
     34   };
     35 
     36   /**
     37    * Sets the visibility state of the touchpad group.
     38    * @param {boolean} show True to show, false to hide.
     39    */
     40   PointerOverlay.showTouchpadControls = function(show) {
     41     $('pointer-section-touchpad').hidden = !show;
     42   };
     43 
     44   /**
     45    * Sets the visibility state of the mouse group.
     46    * @param {boolean} show True to show, false to hide.
     47    */
     48   PointerOverlay.showMouseControls = function(show) {
     49     $('pointer-section-mouse').hidden = !show;
     50   };
     51 
     52   /**
     53    * Updates the title of the pointer dialog.  The title is set dynamically
     54    * based on whether a touchpad, mouse or both are present.  The label on the
     55    * button that activates the overlay is also updated to stay in sync. A
     56    * message is displayed in the main settings page if no pointer devices are
     57    * available.
     58    * @param {string} label i18n key for the overlay title.
     59    */
     60   PointerOverlay.setTitle = function(label) {
     61     var button = $('pointer-settings-button');
     62     var noPointersLabel = $('no-pointing-devices');
     63     if (label.length > 0) {
     64       var title = loadTimeData.getString(label);
     65       button.textContent = title;
     66       button.hidden = false;
     67       noPointersLabel.hidden = true;
     68     } else {
     69       button.hidden = true;
     70       noPointersLabel.hidden = false;
     71     }
     72   };
     73 
     74   // Export
     75   return {
     76     PointerOverlay: PointerOverlay
     77   };
     78 });
     79