1
0
mirror of https://github.com/2ec0b4/kaamelott-soundboard.git synced 2025-12-08 15:43:24 +00:00
Files
kaamelott-soundboard/docs/js/app/views/sounds.e61b9c22.js

1 line
1.9 KiB
JavaScript

define("views/sounds.e61b9c22",function(require){"use strict";var n,i=require("marionette"),t=require("backbone.radio"),e=require("collections/sounds.8bb5d10e"),o=require("views/sound.ca903070"),l=require("views/share.4adddf27");return n=i.CollectionView.extend({childView:o,collection:new e,tagName:"ul",childEvents:{"sound:play":"manageSounds","sound:share":"shareSoundLink"},initialize:function(n){this.slug="undefined"!=typeof n.slug?n.slug:"",this.data={collection:this.collection},this.channel=t.channel("Sounds"),this.channel.request("getSounds").then(this.initCollection.bind(this)),this.channel.on("sounds:filter",this.filterCollection.bind(this)),this.channel.on("sounds:random",this.randomSound.bind(this)),this.channel.on("sounds:reset",this.resetCollection.bind(this))},onBeforeRender:function(){var n;this.slug&&(n=this.collection.findWhere({file:this.slug+".mp3"}),n&&(n.set("selected",!0),this.slug=""))},initCollection:function(n){this.data.collection=new e(n),this.collection=this.data.collection,this.render()},filterCollection:function(n){this.collection=this.data.collection.filterByTitle(n),this.render()},filterCollectionByCid:function(n){this.collection=this.data.collection.filterByCid(n),this.render()},manageSounds:function(n){this.stopPlayingSound(),t.channel("Sounds").trigger("sound:play",n.model.getSlug())},randomSound:function(){this.stopPlayingSound(),this.filterCollection("");var n=Math.floor(Math.random()*Math.floor(this.collection.length)),i=this.collection.models[n];this.filterCollectionByCid(i.cid),t.channel("Sounds").trigger("sound:play",i.getSlug()),i.play()},resetCollection:function(){this.filterCollection(""),t.channel("Sounds").trigger("sound:stop")},stopPlayingSound:function(){var n=this.collection.findWhere({playing:!0});n&&n.stop()},shareSoundLink:function(n){var i=new l({model:n.model});t.channel("App").request("modal:show",{view:i})}})});