Index: ui/file_manager/audio_player/elements/repeat_button.js |
diff --git a/ui/file_manager/audio_player/elements/repeat_button.js b/ui/file_manager/audio_player/elements/repeat_button.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..51f5b9ca01654da70f5dbccf6d921958a94644f4 |
--- /dev/null |
+++ b/ui/file_manager/audio_player/elements/repeat_button.js |
@@ -0,0 +1,65 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * Repeat Button. |
+ * |
+ * This is for repeat button in Control Panel for Audio Player. |
+ */ |
+Polymer({ |
+ is: 'repeat-button', |
+ |
+ properties: { |
+ 'repeatMode': { |
+ type: String, |
+ notify: true, |
+ reflectToAttribute: true |
+ } |
+ }, |
+ |
+ listeners: { |
+ tap: '_tapHandler' |
+ }, |
+ |
+ /** |
+ * Initialize member variables. |
+ */ |
+ created: function() { |
+ /** |
+ * @private {Array<string>} |
+ */ |
+ this.modeName_ = [ |
+ "no-repeat", |
+ "repeat-all", |
+ "repeat-one" |
+ ]; |
+ }, |
+ |
+ _tapHandler: function() { |
+ this.next_(); |
+ }, |
+ |
+ /** |
+ * Change the mode into next one. |
+ * @private |
+ */ |
+ next_: function() { |
+ this.index_ = this.index_ || this.modeName_.indexOf(this.repeatMode); |
+ if(this.index_ === -1) |
+ return; |
+ |
+ var nextIndex = (this.index_ + 1) % this.modeName_.length; |
+ this.repeatMode = this.modeName_[nextIndex]; |
+ this.index_ = nextIndex; |
+ }, |
+ |
+ /** |
+ * Whether or not the button is active, which means it should be toggled. |
+ * @param {string} mode Current mode name |
+ * @return {boolean} True if the mode is repeat. |
+ */ |
+ isActive: function(mode) { |
+ return mode === "repeat-all" || mode === "repeat-one"; |
+ }, |
+}); |