| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('cr.ui', function() { | 5 cr.define('cr.ui', function() { |
| 6 /** | 6 /** |
| 7 * Creates a new button element. The repeating button behaves like a | 7 * Creates a new button element. The repeating button behaves like a |
| 8 * keyboard button, which auto-repeats if held. This button is designed | 8 * keyboard button, which auto-repeats if held. This button is designed |
| 9 * for use with controls such as brightness and volume adjustment buttons. | 9 * for use with controls such as brightness and volume adjustment buttons. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 }; | 108 }; |
| 109 this.armRepeaterCallbackId_ = | 109 this.armRepeaterCallbackId_ = |
| 110 setTimeout(armRepeaterCallback, this.holdDelayTime_); | 110 setTimeout(armRepeaterCallback, this.holdDelayTime_); |
| 111 }, | 111 }, |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * Called when the user releases this button. | 114 * Called when the user releases this button. |
| 115 * @param {!Event} e The triggered event. | 115 * @param {!Event} e The triggered event. |
| 116 * @private | 116 * @private |
| 117 */ | 117 */ |
| 118 buttonUp_: function(e) { this.clearTimeout_(); }, | 118 buttonUp_: function(e) { |
| 119 this.clearTimeout_(); |
| 120 }, |
| 119 | 121 |
| 120 /** | 122 /** |
| 121 * Resets the interval callback. | 123 * Resets the interval callback. |
| 122 * @private | 124 * @private |
| 123 */ | 125 */ |
| 124 clearTimeout_: function() { | 126 clearTimeout_: function() { |
| 125 if (typeof this.armRepeaterCallbackId_ != 'undefined') { | 127 if (typeof this.armRepeaterCallbackId_ != 'undefined') { |
| 126 clearTimeout(this.armRepeaterCallbackId_); | 128 clearTimeout(this.armRepeaterCallbackId_); |
| 127 this.armRepeaterCallbackId_ = undefined; | 129 this.armRepeaterCallbackId_ = undefined; |
| 128 } | 130 } |
| 129 if (typeof this.intervalCallbackId_ != 'undefined') { | 131 if (typeof this.intervalCallbackId_ != 'undefined') { |
| 130 clearInterval(this.intervalCallbackId_); | 132 clearInterval(this.intervalCallbackId_); |
| 131 this.intervalCallbackId_ = undefined; | 133 this.intervalCallbackId_ = undefined; |
| 132 } | 134 } |
| 133 }, | 135 }, |
| 134 | 136 |
| 135 /** | 137 /** |
| 136 * Dispatches the action associated with keeping this button pressed. | 138 * Dispatches the action associated with keeping this button pressed. |
| 137 * @private | 139 * @private |
| 138 */ | 140 */ |
| 139 buttonHeld_: function() { | 141 buttonHeld_: function() { |
| 140 cr.dispatchSimpleEvent(this, RepeatingButton.Event.BUTTON_HELD); | 142 cr.dispatchSimpleEvent(this, RepeatingButton.Event.BUTTON_HELD); |
| 141 }, | 143 }, |
| 142 | 144 |
| 143 /** | 145 /** |
| 144 * Getter for the initial delay before repeating. | 146 * Getter for the initial delay before repeating. |
| 145 * @type {number} The delay in milliseconds. | 147 * @type {number} The delay in milliseconds. |
| 146 */ | 148 */ |
| 147 get repeatDelay() { return this.holdDelayTime_; }, | 149 get repeatDelay() { |
| 150 return this.holdDelayTime_; |
| 151 }, |
| 148 | 152 |
| 149 /** | 153 /** |
| 150 * Setter for the initial delay before repeating. | 154 * Setter for the initial delay before repeating. |
| 151 * @type {number} The delay in milliseconds. | 155 * @type {number} The delay in milliseconds. |
| 152 */ | 156 */ |
| 153 set repeatDelay(delay) { this.holdDelayTime_ = delay; }, | 157 set repeatDelay(delay) { |
| 158 this.holdDelayTime_ = delay; |
| 159 }, |
| 154 | 160 |
| 155 /** | 161 /** |
| 156 * Getter for the repeat interval. | 162 * Getter for the repeat interval. |
| 157 * @type {number} The repeat interval in milliseconds. | 163 * @type {number} The repeat interval in milliseconds. |
| 158 */ | 164 */ |
| 159 get repeatInterval() { return this.holdRepeatIntervalTime_; }, | 165 get repeatInterval() { |
| 166 return this.holdRepeatIntervalTime_; |
| 167 }, |
| 160 | 168 |
| 161 /** | 169 /** |
| 162 * Setter for the repeat interval. | 170 * Setter for the repeat interval. |
| 163 * @type {number} The interval in milliseconds. | 171 * @type {number} The interval in milliseconds. |
| 164 */ | 172 */ |
| 165 set repeatInterval(delay) { this.holdRepeatIntervalTime_ = delay; } | 173 set repeatInterval(delay) { |
| 174 this.holdRepeatIntervalTime_ = delay; |
| 175 } |
| 166 }; | 176 }; |
| 167 | 177 |
| 168 return {RepeatingButton: RepeatingButton}; | 178 return {RepeatingButton: RepeatingButton}; |
| 169 }); | 179 }); |
| OLD | NEW |