mirror of
https://github.com/2ec0b4/kaamelott-soundboard.git
synced 2025-12-09 16:05:35 +00:00
Partage de sons (#4)
* Permet la lecture d'un son passé en paramètre d'URL * Remplace du code créé par l'utilisation d'un template * Ajoute un bouton de partage * Ajoute une région pour gérer une modal * Affiche une modal de partage * Améliore le style du flash de sélection de son * Corrige un mauvais appel de fonction * Supprime la destruction de la vue au scroll de la fenêtre : le comportement n'est pas idéal sur iOS quand il y a le focus sur l'input * Ne joue pas automatiquement le son partagé sur iOS (après avoir tenté : https://paulbakaus.com/tutorials/html5/web-audio-on-ios/ ) * Permet d'éviter le zoom au focus sur l'input * Ajoute, dans le style, des préfixes manquants
This commit is contained in:
@@ -5,6 +5,7 @@ define("views/sounds", function(require) {
|
||||
Radio = require("backbone.radio"),
|
||||
SoundsCollection = require("collections/sounds"),
|
||||
SoundView = require("views/sound"),
|
||||
SoundShareView = require("views/share"),
|
||||
SoundsCollectionView;
|
||||
|
||||
SoundsCollectionView = Marionette.CollectionView.extend({
|
||||
@@ -12,11 +13,14 @@ define("views/sounds", function(require) {
|
||||
collection: new SoundsCollection(),
|
||||
tagName: "ul",
|
||||
childEvents: {
|
||||
"sound:play": "stopPlayingSound"
|
||||
"sound:play": "stopPlayingSound",
|
||||
"sound:share": "shareSoundLink"
|
||||
},
|
||||
initialize: function() {
|
||||
initialize: function(options) {
|
||||
var that = this;
|
||||
|
||||
this.slug = typeof options.slug !== 'undefined' ? options.slug : '';
|
||||
|
||||
this.data = {
|
||||
collection: this.collection
|
||||
};
|
||||
@@ -25,6 +29,17 @@ define("views/sounds", function(require) {
|
||||
this.channel.request("getSounds").then(this.initCollection.bind(this));
|
||||
this.channel.on("sounds:filter", this.filterCollection.bind(this));
|
||||
},
|
||||
onBeforeRender: function() {
|
||||
var sound;
|
||||
|
||||
if( this.slug ) {
|
||||
sound = this.collection.findWhere({file: this.slug+".mp3"});
|
||||
|
||||
if( sound ) {
|
||||
sound.set('selected', true);
|
||||
}
|
||||
}
|
||||
},
|
||||
initCollection: function(sounds) {
|
||||
this.data.collection = new SoundsCollection(sounds);
|
||||
this.collection = this.data.collection;
|
||||
@@ -42,6 +57,11 @@ define("views/sounds", function(require) {
|
||||
if( playingSound ) {
|
||||
playingSound.stop();
|
||||
}
|
||||
},
|
||||
shareSoundLink: function(args) {
|
||||
var view = new SoundShareView({model: args.model});
|
||||
|
||||
Radio.channel("App").request("modal:show", { view: view });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user