OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * Repeat Button. |
| 7 * |
| 8 * This is for repeat button in Control Panel for Audio Player. |
| 9 */ |
| 10 Polymer({ |
| 11 is: 'repeat-button', |
| 12 |
| 13 properties: { |
| 14 'repeatMode': { |
| 15 type: String, |
| 16 notify: true, |
| 17 reflectToAttribute: true |
| 18 } |
| 19 }, |
| 20 |
| 21 listeners: { |
| 22 tap: '_tapHandler' |
| 23 }, |
| 24 |
| 25 /** |
| 26 * Initialize member variables. |
| 27 */ |
| 28 created: function() { |
| 29 /** |
| 30 * @private {Array<string>} |
| 31 */ |
| 32 this.modeName_ = [ |
| 33 "no-repeat", |
| 34 "repeat-all", |
| 35 "repeat-one" |
| 36 ]; |
| 37 }, |
| 38 |
| 39 _tapHandler: function() { |
| 40 this.next_(); |
| 41 }, |
| 42 |
| 43 /** |
| 44 * Change the mode into next one. |
| 45 * @private |
| 46 */ |
| 47 next_: function() { |
| 48 this.index_ = this.index_ || this.modeName_.indexOf(this.repeatMode); |
| 49 if(this.index_ === -1) |
| 50 return; |
| 51 |
| 52 var nextIndex = (this.index_ + 1) % this.modeName_.length; |
| 53 this.repeatMode = this.modeName_[nextIndex]; |
| 54 this.index_ = nextIndex; |
| 55 }, |
| 56 |
| 57 /** |
| 58 * Whether or not the button is active, which means it should be toggled. |
| 59 * @param {string} mode Current mode name |
| 60 * @return {boolean} True if the mode is repeat. |
| 61 */ |
| 62 isActive: function(mode) { |
| 63 return mode === "repeat-all" || mode === "repeat-one"; |
| 64 }, |
| 65 }); |
OLD | NEW |