Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: ui/file_manager/audio_player/elements/repeat_button.js

Issue 2305623003: Support to repeat one song in Audio Player. (Closed)
Patch Set: Add a test for 3 repeat mode. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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";
+ },
+});
« no previous file with comments | « ui/file_manager/audio_player/elements/repeat_button.html ('k') | ui/file_manager/audio_player/js/audio_player.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698