| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 (function() { | 5 (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Moves |target| element above |anchor| element, in order to match the | 9 * Moves |target| element above |anchor| element, in order to match the |
| 10 * bottom lines. | 10 * bottom lines. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 }, | 92 }, |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Whether the volume slider is expanded or not. | 95 * Whether the volume slider is expanded or not. |
| 96 */ | 96 */ |
| 97 volumeSliderShown: { | 97 volumeSliderShown: { |
| 98 type: Boolean, | 98 type: Boolean, |
| 99 value: false, | 99 value: false, |
| 100 observer: 'volumeSliderShownChanged', | 100 observer: 'volumeSliderShownChanged', |
| 101 notify: true | 101 notify: true |
| 102 }, |
| 103 |
| 104 /** |
| 105 * Whether the knob of time slider is being dragged. |
| 106 */ |
| 107 dragging: { |
| 108 type: Boolean, |
| 109 value: false, |
| 110 notify: true |
| 102 } | 111 } |
| 103 }, | 112 }, |
| 104 | 113 |
| 105 /** | 114 /** |
| 106 * Initializes an element. This method is called automatically when the | 115 * Initializes an element. This method is called automatically when the |
| 107 * element is ready. | 116 * element is ready. |
| 108 */ | 117 */ |
| 109 ready: function() { | 118 ready: function() { |
| 110 var onFocusoutBound = this.onVolumeControllerFocusout_.bind(this); | 119 var onFocusoutBound = this.onVolumeControllerFocusout_.bind(this); |
| 111 | 120 |
| 112 this.$.volumeSlider.addEventListener('focusout', onFocusoutBound); | 121 this.$.volumeSlider.addEventListener('focusout', onFocusoutBound); |
| 113 this.$.volumeButton.addEventListener('focusout', onFocusoutBound); | 122 this.$.volumeButton.addEventListener('focusout', onFocusoutBound); |
| 114 | 123 |
| 115 // Prevent the time slider from being moved by arrow keys. | 124 this.$.timeSlider.addEventListener('value-change', function() { |
| 116 this.$.timeInput.addEventListener('keydown', function(event) { | 125 if (this.dragging) |
| 117 switch (event.keyCode) { | 126 this.dragging = false; |
| 118 case 37: // Left arrow | 127 }.bind(this)); |
| 119 case 38: // Up arrow | 128 this.$.timeSlider.addEventListener('immediate-value-change', function() { |
| 120 case 39: // Right arrow | 129 if (!this.dragging) |
| 121 case 40: // Down arrow | 130 this.dragging = true; |
| 122 event.preventDefault(); | 131 }.bind(this)); |
| 123 break; | |
| 124 }; | |
| 125 }); | |
| 126 }, | 132 }, |
| 127 | 133 |
| 128 /** | 134 /** |
| 129 * Invoked when the next button is clicked. | 135 * Invoked when the next button is clicked. |
| 130 */ | 136 */ |
| 131 nextClick: function() { | 137 nextClick: function() { |
| 132 this.fire('next-clicked'); | 138 this.fire('next-clicked'); |
| 133 }, | 139 }, |
| 134 | 140 |
| 135 /** | 141 /** |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 /** | 193 /** |
| 188 * Converts the time into human friendly string. | 194 * Converts the time into human friendly string. |
| 189 * @param {number} time Time to be converted. | 195 * @param {number} time Time to be converted. |
| 190 * @return {string} String representation of the given time | 196 * @return {string} String representation of the given time |
| 191 */ | 197 */ |
| 192 time2string_: function(time) { | 198 time2string_: function(time) { |
| 193 return ~~(time / 60000) + ':' + ('0' + ~~(time / 1000 % 60)).slice(-2); | 199 return ~~(time / 60000) + ':' + ('0' + ~~(time / 1000 % 60)).slice(-2); |
| 194 }, | 200 }, |
| 195 | 201 |
| 196 /** | 202 /** |
| 203 * Converts the time and duration into human friendly string. |
| 204 * @param {number} time Time to be converted. |
| 205 * @param {number} duration Duration to be converted. |
| 206 * @return {string} String representation of the given time |
| 207 */ |
| 208 computeTimeString_: function(time, duration) { |
| 209 return this.time2string_(time) + ' / ' + this.time2string_(duration); |
| 210 }, |
| 211 |
| 212 /** |
| 197 * Computes state for play button based on 'playing' property. | 213 * Computes state for play button based on 'playing' property. |
| 198 * @return {string} | 214 * @return {string} |
| 199 */ | 215 */ |
| 200 computePlayState_: function(playing) { | 216 computePlayState_: function(playing) { |
| 201 return playing ? "playing" : "ended"; | 217 return playing ? "playing" : "ended"; |
| 202 }, | 218 }, |
| 203 | 219 |
| 204 /** | 220 /** |
| 205 * Computes style for '.filled' element of progress bar. | 221 * Computes style for '.filled' element of progress bar. |
| 206 * @return {string} | 222 * @return {string} |
| 207 */ | 223 */ |
| 208 computeProgressBarStyle_: function(time, duration) { | 224 computeProgressBarStyle_: function(time, duration) { |
| 209 return 'width: ' + (time / duration * 100) + '%;'; | 225 return 'width: ' + (time / duration * 100) + '%;'; |
| 210 } | 226 } |
| 211 }); | 227 }); |
| 212 })(); // Anonymous closure | 228 })(); // Anonymous closure |
| OLD | NEW |