|
2
|
1 |
IriSP.Widgets.MusitagAnnotations = function(player, config) { |
|
|
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
3 |
}; |
|
|
4 |
|
|
|
5 |
IriSP.Widgets.MusitagAnnotations.prototype = new IriSP.Widgets.Widget(); |
|
|
6 |
|
|
|
7 |
IriSP.Widgets.MusitagAnnotations.prototype.defaults = { |
|
|
8 |
annotation_type: 'musitag', |
|
|
9 |
columns: 15, |
|
|
10 |
max_by_column: 10, |
|
|
11 |
emoticons: ['happy', 'unhappy', 'laughing', 'surprised'], |
|
|
12 |
colors: ['red', 'yellow', 'green', 'blue'] |
|
|
13 |
}; |
|
|
14 |
|
|
|
15 |
IriSP.Widgets.MusitagAnnotations.prototype.draw = function() { |
|
|
16 |
var _html = '', |
|
|
17 |
_annotations = this.getWidgetAnnotations(), |
|
|
18 |
_duration = this.source.getDuration().milliseconds, |
|
|
19 |
_sliceDuration = _duration/this.columns, |
|
|
20 |
_this = this; |
|
|
21 |
_annotations.forEach(function(_annotation) { |
|
|
22 |
var _tags = _annotation.getTagTexts(); |
|
|
23 |
_annotation.color_tag = false; |
|
|
24 |
_annotation.emoticon_tag = false; |
|
|
25 |
_tags.forEach(function(_tag) { |
|
|
26 |
if (_this.emoticons.indexOf(_tag) != -1) { |
|
|
27 |
_annotation.emoticon_tag = _tag; |
|
|
28 |
} |
|
|
29 |
if (_this.colors.indexOf(_tag) != -1) { |
|
|
30 |
_annotation.color_tag = _tag; |
|
|
31 |
} |
|
|
32 |
}); |
|
|
33 |
}); |
|
|
34 |
for (var i = 0; i < this.columns; i++) { |
|
|
35 |
var _sliceStart = i * _sliceDuration, |
|
|
36 |
_sliceEnd = (i+1) * _sliceDuration, |
|
|
37 |
_column = _annotations.filter(function(_annotation) { |
|
|
38 |
return _annotation.begin >= _sliceStart |
|
|
39 |
&& _annotation.begin < _sliceEnd |
|
|
40 |
&& _annotation.emoticon_tag |
|
|
41 |
&& _annotation.color_tag |
|
|
42 |
}).sortBy(function(_annotation) { |
|
|
43 |
return _annotation.created; |
|
|
44 |
}); |
|
|
45 |
if (_column.length > this.max_by_column) { |
|
|
46 |
_column = _column.slice(_column.length - this.max_by_column, _column.length); |
|
|
47 |
} |
|
|
48 |
_html += '<div class="Musitag-Annotations-column">'; |
|
|
49 |
_html += _column.map(function(_annotation) { |
|
4
|
50 |
return '<div class="Musitag-Annotations-tag" begin-time="' + _annotation.begin + '">' |
|
|
51 |
+ '<div class="Musitag-container-50">' |
|
|
52 |
+ '<div class="Musitag-shadow"></div>' |
|
|
53 |
+ '<div class="Musitag-color Musitag-' + _annotation.color_tag + '"></div>' |
|
|
54 |
+ '<div class="Musitag-emoticon Musitag-' + _annotation.emoticon_tag + '"></div>' |
|
|
55 |
+ '</div><div class="Musitag-Annotations-Balloon"></div></div>'; |
|
2
|
56 |
}).join(''); |
|
|
57 |
_html += '</div>'; |
|
|
58 |
} |
|
|
59 |
this.$.html(_html); |
|
4
|
60 |
this.$.find('.Musitag-Annotations-tag .Musitag-container-50').click(function() { |
|
|
61 |
var _el = IriSP.jQuery(this).parent(); |
|
3
|
62 |
_this.player.popcorn.currentTime(_el.attr("begin-time") / 1000); |
|
|
63 |
}); |
|
4
|
64 |
this.$.find('.Musitag-Annotations-tag').mouseover(function() { |
|
|
65 |
var _el = IriSP.jQuery(this); |
|
|
66 |
_this.$.find('.Musitag-Annotations-Balloon').hide(); |
|
|
67 |
_el.find('.Musitag-Annotations-Balloon').show(); |
|
|
68 |
}); |
|
2
|
69 |
} |