|
2
|
1 |
IriSP.Widgets.MusitagAndYou = function(player, config) { |
|
|
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
3 |
}; |
|
|
4 |
|
|
|
5 |
IriSP.Widgets.MusitagAndYou.prototype = new IriSP.Widgets.Widget(); |
|
|
6 |
|
|
|
7 |
IriSP.Widgets.MusitagAndYou.prototype.defaults = { |
|
|
8 |
min_left: -90, |
|
|
9 |
max_right: 900, |
|
|
10 |
width: 870 |
|
|
11 |
}; |
|
|
12 |
|
|
|
13 |
IriSP.Widgets.MusitagAndYou.prototype.template = |
|
|
14 |
'<div class="Musitag-AndYou-PositionBar"></div><div class="Musitag-AndYou-Main">' |
|
|
15 |
+ '<div class="Musitag-AndYou-Tag Musitag-container-50">' |
|
|
16 |
+ '<div class="Musitag-shadow"></div>' |
|
|
17 |
+ '<div class="Musitag-color Musitag-green Musitag-AndYou-crossfade Musitag-AndYou-anim-6s Musitag-AndYou-cf-3"></div>' |
|
|
18 |
+ '<div class="Musitag-color Musitag-yellow Musitag-AndYou-crossfade Musitag-AndYou-anim-6s Musitag-AndYou-cf-2"></div>' |
|
|
19 |
+ '<div class="Musitag-color Musitag-red Musitag-AndYou-crossfade Musitag-AndYou-anim-6s Musitag-AndYou-cf-1"></div>' |
|
|
20 |
+ '<div class="Musitag-color Musitag-blue Musitag-AndYou-crossfade Musitag-AndYou-anim-6s"></div>' |
|
|
21 |
+ '<div class="Musitag-emoticon Musitag-laughing Musitag-AndYou-crossfade Musitag-AndYou-anim-8s"></div>' |
|
|
22 |
+ '<div class="Musitag-emoticon Musitag-happy Musitag-AndYou-crossfade Musitag-AndYou-anim-8s Musitag-AndYou-cf-1"></div>' |
|
|
23 |
+ '<div class="Musitag-emoticon Musitag-unhappy Musitag-AndYou-crossfade Musitag-AndYou-anim-8s Musitag-AndYou-cf-2"></div>' |
|
|
24 |
+ '<div class="Musitag-emoticon Musitag-surprised Musitag-AndYou-crossfade Musitag-AndYou-anim-8s Musitag-AndYou-cf-3"></div></div></div>'; |
|
|
25 |
|
|
|
26 |
IriSP.Widgets.MusitagAndYou.prototype.draw = function() { |
|
|
27 |
this.renderTemplate(); |
|
|
28 |
this.position_bar = this.$.find(".Musitag-AndYou-PositionBar"); |
|
|
29 |
this.position_bar.hide(); |
|
|
30 |
this.position_width = this.position_bar.outerWidth(); |
|
|
31 |
this.main_div = this.$.find(".Musitag-AndYou-Main"); |
|
|
32 |
this.main_width = this.main_div.outerWidth(); |
|
|
33 |
this.bindPopcorn("timeupdate","onTimeupdate"); |
|
|
34 |
this.bindPopcorn("IriSP.MusitagAndYou.hide","hide"); |
|
|
35 |
this.bindPopcorn("IriSP.MusitagAndYou.show","show"); |
|
|
36 |
this.show(); |
|
|
37 |
var _this = this; |
|
|
38 |
this.main_div.click(function() { |
|
|
39 |
_this.hide(); |
|
|
40 |
_this.player.popcorn.trigger("IriSP.MusitagAnnotator.show"); |
|
|
41 |
}) |
|
|
42 |
} |
|
|
43 |
|
|
|
44 |
IriSP.Widgets.MusitagAndYou.prototype.onTimeupdate = function() { |
|
|
45 |
var _x = Math.floor(this.width * this.player.popcorn.currentTime() / this.source.getDuration().getSeconds()); |
|
|
46 |
this.position_bar.css("margin-left", (_x - this.position_width / 2)+"px"); |
|
|
47 |
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"); |
|
|
48 |
} |
|
|
49 |
|
|
|
50 |
IriSP.Widgets.MusitagAndYou.prototype.show = function() { |
|
|
51 |
this.$.show(); |
|
|
52 |
this.position_bar.slideDown(500); |
|
|
53 |
} |
|
|
54 |
|
|
|
55 |
IriSP.Widgets.MusitagAndYou.prototype.hide = function() { |
|
|
56 |
var _this = this; |
|
|
57 |
this.position_bar.slideUp(500, function() { |
|
|
58 |
_this.$.hide(); |
|
|
59 |
}); |
|
|
60 |
} |