1
0
mirror of https://github.com/2ec0b4/kaamelott-soundboard.git synced 2025-12-08 23:53:24 +00:00
Files
kaamelott-soundboard/js/app/views/sound.js
Antoine 56ab369699 Amélioration des tâches Gulp (#3)
* Test en cours d'un nouveau package Gulp

* Change de librairie pour la gestion des templates HBS

* Renomme le nom du channel (pour ne pas qu'il soit modifié lors du Gulp build)

* Renomme les régions (pour ne pas qu'elles soient modifiées lors du Gulp build)

* Simplifie le Gulp build (WIP)

* Ne versionne pas les fichiers de type mp3

* Supprime un paramètre inutile
2016-06-16 14:04:48 +02:00

68 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
define("views/sound", function(require) {
"use strict";
var Marionette = require("marionette"),
SoundModel = require("models/sound"),
SoundTemplate = require("hbs!templates/sound"),
SoundView;
SoundView = Marionette.ItemView.extend({
template: SoundTemplate,
model: SoundModel,
tagName: "li",
ui: {
soundItem: "a"
},
events: {
"click @ui.soundItem": "toggleSound",
"mouseenter @ui.soundItem": "toggleSoundDetail",
"mouseleave @ui.soundItem": "toggleSoundDetail"
},
initialize: function() {
this.listenTo(this.model, "change:playing", this.playingAttributeChanged);
},
toggleSound: function(e) {
e.preventDefault();
if( this.model.get("playing") ) {
this.trigger("sound:stop");
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");
}
},
toggleSoundDetail: function(e) {
var offset;
if (e.type === "mouseleave") {
$(".tooltip").remove();
return;
}
offset = $(this.el).offset();
$("<div/>")
.addClass("tooltip")
.append(
$("<p/>").text(this.model.getSoundDetail())
)
.css({left: (offset.left+25)+"px", top: (offset.top+30)+"px"})
.appendTo("body")
.delay(1000)
.show(0);
}
});
return SoundView;
});