1
0
mirror of https://github.com/2ec0b4/kaamelott-soundboard.git synced 2025-12-09 16:05:35 +00:00

Joue / stoppe le son

This commit is contained in:
Antoine
2016-04-21 23:30:41 +02:00
parent 3eeae4e9e2
commit b8fba8535e
3 changed files with 27 additions and 4 deletions

View File

@@ -16,14 +16,30 @@ define(
soundItem: 'a'
},
events: {
'click @ui.soundItem': 'playSound'
'click @ui.soundItem': 'toggleSound'
},
playSound: function(e) {
initialize: function() {
this.listenTo(this.model, "change:playing", this.playingAttributeChanged);
},
toggleSound: function(e) {
e.preventDefault();
this.trigger('sound:play');
if( this.model.get('playing') ) {
this.trigger('sound:stop');
this.model.play();
this.model.stop();
} else {
this.trigger('sound:play');
this.model.play();
}
},
playingAttributeChanged: function() {
if( this.model.get('playing') ) {
$(this.ui.soundItem).addClass('playing');
} else {
$(this.ui.soundItem).removeClass('playing');
}
}
});