mirror of
https://github.com/2ec0b4/kaamelott-soundboard.git
synced 2025-12-08 23:53:24 +00:00
Permet la lecture des sons
This commit is contained in:
@@ -4,13 +4,21 @@ define(
|
||||
'marionette',
|
||||
'backbone.radio',
|
||||
'underscore',
|
||||
'collections/sounds',
|
||||
'hbs!templates/sounds'
|
||||
],
|
||||
function (Marionette, Radio, _, SoundListTemplate) {
|
||||
function (Marionette, Radio, _, SoundsCollection, SoundListTemplate) {
|
||||
"use strict";
|
||||
|
||||
var SoundListView = Marionette.LayoutView.extend({
|
||||
collection : new SoundsCollection(),
|
||||
template: SoundListTemplate,
|
||||
ui: {
|
||||
soundItem: 'li a'
|
||||
},
|
||||
events: {
|
||||
'click @ui.soundItem': 'playSound'
|
||||
},
|
||||
initialize: function() {
|
||||
var that = this;
|
||||
|
||||
@@ -18,11 +26,23 @@ define(
|
||||
|
||||
this.channel = Radio.channel('Sounds');
|
||||
this.channel.request('getSounds')
|
||||
.then(function (sounds) {
|
||||
that.data.sounds = sounds;
|
||||
.then(function(sounds) {
|
||||
that.collection = new SoundsCollection(sounds);
|
||||
that.data.sounds = that.collection.toJSON();
|
||||
|
||||
that.render();
|
||||
});
|
||||
},
|
||||
playSound: function(e) {
|
||||
var index = $(e.currentTarget).attr('data-sound'),
|
||||
sound = this.collection.at(index);
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if( sound ) {
|
||||
sound.play();
|
||||
}
|
||||
},
|
||||
serializeData: function () {
|
||||
var viewData = {data: this.data};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user