|
2
|
1 |
IriSP.Widgets.MusitagAnnotator = function(player, config) { |
|
|
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
3 |
}; |
|
|
4 |
|
|
|
5 |
IriSP.Widgets.MusitagAnnotator.prototype = new IriSP.Widgets.Widget(); |
|
|
6 |
|
|
|
7 |
IriSP.Widgets.MusitagAnnotator.prototype.defaults = { |
|
|
8 |
min_left: -90, |
|
|
9 |
max_right: 900, |
|
|
10 |
width: 870 |
|
|
11 |
}; |
|
|
12 |
|
|
|
13 |
IriSP.Widgets.MusitagAnnotator.prototype.template = |
|
|
14 |
'<div class="Musitag-Annotator-PositionBar"></div><div class="Musitag-Annotator-Main">' |
|
|
15 |
+ '<div class="Musitag-Annotator-section"><h2>1</h2>' |
|
|
16 |
+ ' <h3>Choisis<br />une couleur</h3>' |
|
|
17 |
+ ' <div class="Musitag-Annotator-selector">' |
|
|
18 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
19 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
20 |
+ ' <div class="Musitag-color"></div>' |
|
|
21 |
+ ' <div class="Musitag-color Musitag-red"></div>' |
|
|
22 |
+ ' </div>' |
|
|
23 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
24 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
25 |
+ ' <div class="Musitag-color"></div>' |
|
|
26 |
+ ' <div class="Musitag-color Musitag-yellow"></div>' |
|
|
27 |
+ ' </div>' |
|
|
28 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
29 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
30 |
+ ' <div class="Musitag-color"></div>' |
|
|
31 |
+ ' <div class="Musitag-color Musitag-green"></div>' |
|
|
32 |
+ ' </div>' |
|
|
33 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
34 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
35 |
+ ' <div class="Musitag-color"></div>' |
|
|
36 |
+ ' <div class="Musitag-color Musitag-blue"></div>' |
|
|
37 |
+ ' </div>' |
|
|
38 |
+ ' </div>' |
|
|
39 |
+ '</div>' |
|
|
40 |
+ '<div class="Musitag-Annotator-separator"></div>' |
|
|
41 |
+ '<div class="Musitag-Annotator-section">' |
|
|
42 |
+ ' <h2>2</h2>' |
|
|
43 |
+ ' <h3>Choisis<br />une émotion</h3>' |
|
|
44 |
+ ' <div class="Musitag-Annotator-selector">' |
|
|
45 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
46 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
47 |
+ ' <div class="Musitag-color"></div>' |
|
|
48 |
+ ' <div class="Musitag-emoticon Musitag-happy"></div>' |
|
|
49 |
+ ' </div>' |
|
|
50 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
51 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
52 |
+ ' <div class="Musitag-color"></div>' |
|
|
53 |
+ ' <div class="Musitag-emoticon Musitag-unhappy"></div>' |
|
|
54 |
+ ' </div>' |
|
|
55 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
56 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
57 |
+ ' <div class="Musitag-color"></div>' |
|
|
58 |
+ ' <div class="Musitag-emoticon Musitag-laughing"></div>' |
|
|
59 |
+ ' </div>' |
|
|
60 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSelector">' |
|
|
61 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
62 |
+ ' <div class="Musitag-color"></div>' |
|
|
63 |
+ ' <div class="Musitag-emoticon Musitag-surprised"></div>' |
|
|
64 |
+ ' </div>' |
|
|
65 |
+ ' </div>' |
|
|
66 |
+ '</div>' |
|
|
67 |
+ '<div class="Musitag-Annotator-separator"></div>' |
|
|
68 |
+ '<div class="Musitag-Annotator-section">' |
|
|
69 |
+ ' <h2>3</h2>' |
|
|
70 |
+ ' <h3>Enregistre<br />ta voix</h3>' |
|
|
71 |
+ ' <div class="Musitag-Annotator-record"></div>' |
|
|
72 |
+ '</div>' |
|
|
73 |
+ '<div class="Musitag-Annotator-separator"></div>' |
|
|
74 |
+ '<div class="Musitag-Annotator-section">' |
|
|
75 |
+ ' <h2>4</h2>' |
|
|
76 |
+ ' <h3>Envoie<br />ton Musitag</h3>' |
|
|
77 |
+ ' <div class="Musitag-Annotator-Note">' |
|
|
78 |
+ ' <div class="Musitag-container-80 Musitag-Annotator-tagInSend">' |
|
|
79 |
+ ' <div class="Musitag-shadow"></div>' |
|
|
80 |
+ ' <div class="Musitag-color"></div>' |
|
|
81 |
+ ' <div class="Musitag-emoticon hidden"></div>' |
|
|
82 |
+ ' </div>' |
|
|
83 |
+ ' </div>' |
|
|
84 |
+ '</div>' |
|
|
85 |
+ '<div class="Musitag-Annotator-close"></div>' |
|
|
86 |
+ '</div></div>'; |
|
|
87 |
|
|
|
88 |
IriSP.Widgets.MusitagAnnotator.prototype.draw = function() { |
|
|
89 |
this.renderTemplate(); |
|
|
90 |
this.position_bar = this.$.find(".Musitag-Annotator-PositionBar"); |
|
|
91 |
this.position_bar.hide(); |
|
|
92 |
this.position_width = this.position_bar.outerWidth(); |
|
|
93 |
this.main_div = this.$.find(".Musitag-Annotator-Main"); |
|
|
94 |
this.$.hide(); |
|
|
95 |
this.main_width = this.main_div.outerWidth(); |
|
|
96 |
this.bindPopcorn("timeupdate","onTimeupdate"); |
|
|
97 |
this.bindPopcorn("IriSP.MusitagAnnotator.hide","hide"); |
|
|
98 |
this.bindPopcorn("IriSP.MusitagAnnotator.show","show"); |
|
|
99 |
this.$.find('.Musitag-Annotator-tagInSelector').click(function() { |
|
|
100 |
var _class = IriSP.jQuery(this).children(':last-child').attr('class'), |
|
|
101 |
_classes = _class.split(' '); |
|
|
102 |
IriSP.jQuery('.Musitag-Annotator-tagInSend .' + _classes[0]).attr('class',_class); |
|
|
103 |
IriSP.jQuery(this).siblings().removeClass('down') |
|
|
104 |
.children(':last-child').css('opacity',.35); |
|
|
105 |
IriSP.jQuery(this).addClass('down') |
|
|
106 |
.children(':last-child').css('opacity',1); |
|
|
107 |
}); |
|
|
108 |
var _this = this; |
|
|
109 |
this.$.find('.Musitag-Annotator-close').click(function() { |
|
|
110 |
_this.hide(); |
|
|
111 |
_this.player.popcorn.trigger("IriSP.MusitagAndYou.show"); |
|
|
112 |
}) |
|
|
113 |
} |
|
|
114 |
|
|
|
115 |
IriSP.Widgets.MusitagAnnotator.prototype.onTimeupdate = function() { |
|
|
116 |
var _x = Math.floor(this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds()); |
|
|
117 |
this.position_bar.css("margin-left", (_x - this.position_width / 2)+"px"); |
|
|
118 |
this.main_div.css("margin-left",Math.max(this.min_left, Math.min(this.max_right - this.main_width, _x - this.main_width / 2))+"px"); |
|
|
119 |
} |
|
|
120 |
|
|
|
121 |
IriSP.Widgets.MusitagAnnotator.prototype.show = function() { |
|
|
122 |
this.$.show(); |
|
|
123 |
this.position_bar.slideDown(200); |
|
|
124 |
} |
|
|
125 |
|
|
|
126 |
IriSP.Widgets.MusitagAnnotator.prototype.hide = function() { |
|
|
127 |
var _this = this; |
|
|
128 |
this.position_bar.slideUp(200, function() { |
|
|
129 |
_this.$.hide(); |
|
|
130 |
}); |
|
|
131 |
} |