Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * @fileoverview 'settings-device-page' is the settings page for device and | 6 * @fileoverview 'settings-device-page' is the settings page for device and |
| 7 * peripheral settings. | 7 * peripheral settings. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-device-page', | 10 is: 'settings-device-page', |
| 11 | 11 |
| 12 behaviors: [ | |
| 13 I18nBehavior, | |
| 14 WebUIListenerBehavior, | |
| 15 ], | |
| 16 | |
| 12 properties: { | 17 properties: { |
| 13 /** The current active route. */ | 18 /** The current active route. */ |
| 14 currentRoute: { | 19 currentRoute: { |
| 15 type: Object, | 20 type: Object, |
| 16 notify: true, | 21 notify: true, |
| 17 }, | 22 }, |
| 18 | 23 |
| 19 /** Preferences state. */ | 24 /** Preferences state. */ |
| 20 prefs: { | 25 prefs: { |
| 21 type: Object, | 26 type: Object, |
| 22 notify: true, | 27 notify: true, |
| 23 }, | 28 }, |
| 29 | |
| 30 /** @private */ | |
| 31 hasMouse_: { | |
| 32 type: Boolean, | |
| 33 value: false, | |
| 34 }, | |
| 35 | |
| 36 /** @private */ | |
| 37 hasTouchpad_: { | |
| 38 type: Boolean, | |
| 39 value: false, | |
| 40 }, | |
| 41 }, | |
| 42 | |
| 43 ready: function() { | |
| 44 cr.addWebUIListener( | |
| 45 'has-mouse-changed', this.hasMouseChanged_.bind(this)); | |
| 46 cr.addWebUIListener( | |
| 47 'has-touchpad-changed', this.hasTouchpadChanged_.bind(this)); | |
| 48 settings.DevicePageBrowserProxyImpl.getInstance().initializePointers(); | |
| 24 }, | 49 }, |
| 25 | 50 |
| 26 /** | 51 /** |
| 27 * Handler for tapping the Touchpad settings menu item. | 52 * Callback to set whether a mouse is connected. |
| 53 * @param {boolean} hasMouse | |
| 28 * @private | 54 * @private |
| 29 */ | 55 */ |
| 30 onTouchpadTap_: function() { | 56 hasMouseChanged_: function(hasMouse) { |
| 31 this.$.pages.setSubpageChain(['touchpad']); | 57 this.hasMouse_ = hasMouse; |
| 32 }, | 58 }, |
| 33 | 59 |
| 34 /** | 60 /** |
| 61 * Callback to set whether a touchpad is connected. | |
| 62 * @param {boolean} hasTouchpad | |
| 63 * @private | |
| 64 */ | |
| 65 hasTouchpadChanged_: function(hasTouchpad) { | |
| 66 this.hasTouchpad_ = hasTouchpad; | |
| 67 }, | |
|
stevenjb
2016/06/30 00:07:49
nit: Any reason not to just inline these two fairl
michaelpg
2016/07/09 04:11:30
Done.
| |
| 68 | |
| 69 /** | |
| 70 * @return {string} | |
| 71 * @private | |
| 72 */ | |
| 73 getPointersTitle_: function() { | |
| 74 if (this.hasMouse_ && this.hasTouchpad_) | |
| 75 return this.i18n('mouseAndTouchpadTitle'); | |
| 76 if (this.hasMouse_) | |
| 77 return this.i18n('mouseTitle'); | |
| 78 if (this.hasTouchpad_) | |
| 79 return this.i18n('touchpadTitle'); | |
| 80 return ''; | |
| 81 }, | |
| 82 | |
| 83 /** | |
| 84 * @return {string} | |
| 85 * @private | |
| 86 */ | |
| 87 getPointersIcon_: function() { | |
| 88 if (this.hasMouse_) | |
| 89 return 'settings:mouse'; | |
| 90 if (this.hasTouchpad_) | |
| 91 return 'settings:touch-app'; | |
| 92 return ''; | |
| 93 }, | |
| 94 | |
| 95 /** | |
| 96 * Handler for tapping the mouse and touchpad settings menu item. | |
| 97 * @private | |
| 98 */ | |
| 99 onPointersTap_: function() { | |
| 100 this.$.pages.setSubpageChain(['pointers']); | |
| 101 }, | |
| 102 | |
| 103 /** | |
| 35 * Handler for tapping the Keyboard settings menu item. | 104 * Handler for tapping the Keyboard settings menu item. |
| 36 * @private | 105 * @private |
| 37 */ | 106 */ |
| 38 onKeyboardTap_: function() { | 107 onKeyboardTap_: function() { |
| 39 this.$.pages.setSubpageChain(['keyboard']); | 108 this.$.pages.setSubpageChain(['keyboard']); |
| 40 }, | 109 }, |
| 41 | 110 |
| 42 /** | 111 /** |
| 43 * Handler for tapping the Display settings menu item. | 112 * Handler for tapping the Display settings menu item. |
| 44 * @private | 113 * @private |
| 45 */ | 114 */ |
| 46 onDisplayTap_: function() { | 115 onDisplayTap_: function() { |
| 47 this.$.pages.setSubpageChain(['display']); | 116 this.$.pages.setSubpageChain(['display']); |
| 48 }, | 117 }, |
| 118 | |
| 119 /** | |
| 120 * @return {boolean} | |
| 121 * @private | |
| 122 */ | |
| 123 showPointers_: function(hasMouse, hasTouchpad) { | |
| 124 return hasMouse || hasTouchpad; | |
| 125 }, | |
| 49 }); | 126 }); |
| OLD | NEW |