OLD | NEW |
| (Empty) |
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 header = $('pointer-overlay-title'); | |
62 var button = $('pointer-settings-button'); | |
63 var noPointersLabel = $('no-pointing-devices'); | |
64 if (label.length > 0) { | |
65 var title = loadTimeData.getString(label); | |
66 header.textContent = title; | |
67 button.textContent = title; | |
68 button.hidden = false; | |
69 noPointersLabel.hidden = true; | |
70 } else { | |
71 header.textContent = ''; | |
72 button.hidden = true; | |
73 noPointersLabel.hidden = false; | |
74 } | |
75 }; | |
76 | |
77 // Export | |
78 return { | |
79 PointerOverlay: PointerOverlay | |
80 }; | |
81 }); | |
OLD | NEW |