-
Notifications
You must be signed in to change notification settings - Fork 8
/
playbar.js
46 lines (44 loc) · 1.27 KB
/
playbar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
window.PlayBarView = Backbone.View.extend({
initialize: function () {
this.render();
this.last_pressed = "";
},
render: function () {
$(this.el).html(template.playbar());
return this;
},
events: {
"change" : "change",
"click #bck" : "back",
"click #pause" : "pause",
"click #play" : "play",
"click #fwd" : "forward",
},
change: function (event) {
// Remove any existing alert message
utils.showAlert('Success!', 'button changed ?', 'alert-success');
},
set_state: function (state) {
var state_name = this.model.get('state_name');
if (! state_name.indexOf(state))
return console.log ("error: invalid state:" + state);
this.model.save({state: state_name.indexOf(state)});
},
btn_toggle: function (source) {
$(source).addClass('disabled');
$(this.last_pressed).removeClass('disabled');
this.last_pressed = source;
},
back: function () {
},
pause: function () {
this.btn_toggle('#pause');
this.set_state ('PAUSED');
},
play: function () {
this.btn_toggle('#play');
this.set_state ('PLAYING');
},
forward: function () {
},
});