| author | ymh <ymh.work@gmail.com> |
| Fri, 02 Oct 2015 11:27:17 +0200 | |
| changeset 1068 | 7623f9af9272 |
| parent 1021 | 7253d4d06f0d |
| child 1069 | 2409cb4cebaf |
| permissions | -rw-r--r-- |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
1 |
IriSP.Widgets.Polemic = function(player, config) { |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
2 |
IriSP.Widgets.Widget.call(this, player, config); |
| 169 | 3 |
}; |
4 |
||
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
5 |
IriSP.Widgets.Polemic.prototype = new IriSP.Widgets.Widget(); |
| 187 | 6 |
|
| 882 | 7 |
IriSP.Widgets.Polemic.prototype.messages = { |
8 |
fr: { |
|
9 |
from_: "de ", |
|
10 |
_to_: " à ", |
|
11 |
_annotations: " annotation(s)" |
|
12 |
}, |
|
13 |
en: { |
|
14 |
from_: "from ", |
|
15 |
_to_: " to ", |
|
16 |
_annotations: " annotation(s)" |
|
17 |
} |
|
| 1012 | 18 |
}; |
19 |
||
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
20 |
IriSP.Widgets.Polemic.prototype.defaults = { |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
21 |
element_width : 5, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
22 |
element_height : 5, |
| 987 | 23 |
max_elements: 20, |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
24 |
annotation_type : "tweet", |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
25 |
defaultcolor : "#585858", |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
26 |
foundcolor : "#fc00ff", |
| 880 | 27 |
polemics : [ |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
28 |
{ |
| 930 | 29 |
"name" : "OK", |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
30 |
"keywords" : [ "++" ], |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
31 |
"color" : "#1D973D" |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
32 |
}, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
33 |
{ |
| 930 | 34 |
"name" : "KO", |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
35 |
"keywords" : [ "--" ], |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
36 |
"color" : "#CE0A15" |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
37 |
}, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
38 |
{ |
| 930 | 39 |
"name" : "REF", |
| 909 | 40 |
"keywords" : [ "==", "http://" ], |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
41 |
"color" : "#C5A62D" |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
42 |
}, |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
43 |
{ |
| 930 | 44 |
"name" : "Q", |
| 909 | 45 |
"keywords" : [ "?" ], |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
46 |
"color" : "#036AAE" |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
47 |
} |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
48 |
] |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
49 |
}; |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
50 |
|
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
51 |
IriSP.Widgets.Polemic.prototype.draw = function() { |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
52 |
|
| 957 | 53 |
this.onMediaEvent("timeupdate", "onTimeupdate"); |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
54 |
this.$zone = IriSP.jQuery('<div>'); |
| 882 | 55 |
this.$zone.addClass("Ldt-Polemic"); |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
56 |
this.$.append(this.$zone); |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
57 |
|
| 882 | 58 |
this.$elapsed = IriSP.jQuery('<div>') |
59 |
.css({ |
|
60 |
background: '#cccccc', |
|
61 |
position: "absolute", |
|
62 |
top: 0, |
|
63 |
left: 0, |
|
64 |
width: 0, |
|
65 |
height: "100%" |
|
66 |
}); |
|
67 |
|
|
68 |
this.$zone.append(this.$elapsed); |
|
69 |
|
|
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
70 |
// we don't filter with null duration anymore |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
71 |
var _slices = [], |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
72 |
_slice_count = Math.floor( this.width / this.element_width ), |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
73 |
_duration = this.source.getDuration(), |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
74 |
_max = 0, |
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
75 |
_list = this.getWidgetAnnotations(), |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
76 |
_this = this; |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
77 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
78 |
for (var _i = 0; _i < _slice_count; _i++) { |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
79 |
var _begin = new IriSP.Model.Time( _i * _duration / _slice_count ), |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
80 |
_end = new IriSP.Model.Time( ( _i + 1 ) * _duration / _slice_count ), |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
81 |
_count = 0, |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
82 |
_res = { |
| 882 | 83 |
begin : _begin.toString(), |
84 |
end : _end.toString(), |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
85 |
annotations : _list.filter(function(_annotation) { |
| 1004 | 86 |
return _annotation.begin >= _begin && _annotation.begin < _end; |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
87 |
}), |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
88 |
polemicStacks : [] |
| 1012 | 89 |
}; |
|
566
098929cd2d62
made the polemicwidget adjust its size automatically and fixed a couple edgecases.
hamidouk
parents:
565
diff
changeset
|
90 |
|
| 880 | 91 |
for (var _j = 0; _j < this.polemics.length; _j++) { |
92 |
var _polemic = _res.annotations.searchByDescription(this.polemics[_j].keywords); |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
93 |
_count += _polemic.length; |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
94 |
_res.polemicStacks.push(_polemic); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
95 |
} |
| 880 | 96 |
for (var _j = 0; _j < this.polemics.length; _j++) { |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
97 |
_res.annotations.removeElements(_res.polemicStacks[_j]); |
| 207 | 98 |
} |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
99 |
_count += _res.annotations.length; |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
100 |
_max = Math.max(_max, _count); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
101 |
_slices.push(_res); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
102 |
} |
| 882 | 103 |
if (_max < this.max_elements) { |
104 |
this.is_stackgraph = false; |
|
105 |
if (_max) { |
|
106 |
|
|
107 |
this.height = (2 + _max) * this.element_height; |
|
108 |
this.$zone.css({ |
|
109 |
width: this.width + "px", |
|
110 |
height: this.height + "px", |
|
111 |
position: "relative" |
|
112 |
}); |
|
113 |
|
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
114 |
var _x = 0; |
| 882 | 115 |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
116 |
function displayAnnotation(_elx, _ely, _pol, _col, _annotation) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
117 |
var _html = Mustache.to_html( |
|
996
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
118 |
'<div class="Ldt-Polemic-TweetDiv Ldt-TraceMe" trace-info="annotation-id:{{id}}, media-id:{{media_id}}, polemic:{{polemic}}, time:{{time}}" polemic-color="{{color}}"' |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
119 |
+ ' tweet-title="{{title}}" annotation-id="{{id}}" style="width: {{width}}px; height: {{height}}px; top: {{top}}px; left: {{left}}px; background: {{color}}"></div>', |
| 882 | 120 |
{ |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
121 |
id: _annotation.id, |
| 930 | 122 |
media_id: _this.source.currentMedia.id, |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
123 |
polemic: _pol, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
124 |
left: _elx, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
125 |
top: _ely, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
126 |
color: _col, |
| 882 | 127 |
width: (_this.element_width-1), |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
128 |
height: _this.element_height, |
| 990 | 129 |
title: _annotation.title, |
130 |
time: _annotation.begin.toString() |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
131 |
}); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
132 |
var _el = IriSP.jQuery(_html); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
133 |
_el.mouseover(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
134 |
_annotation.trigger("select"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
135 |
}).mouseout(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
136 |
_annotation.trigger("unselect"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
137 |
}).click(function() { |
| 964 | 138 |
_annotation.trigger("click"); |
| 1004 | 139 |
return false; |
|
996
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
140 |
}); |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
141 |
IriSP.attachDndData(_el, { |
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
142 |
title: _annotation.title, |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
143 |
description: _annotation.description, |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
144 |
image: _annotation.thumbnail, |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
145 |
uri: (typeof _annotation.url !== "undefined" |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
146 |
? _annotation.url |
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1021
diff
changeset
|
147 |
: (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)), |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1021
diff
changeset
|
148 |
text: '[' + _annotation.begin.toString() + '] ' + _annotation.title |
|
996
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
149 |
}); |
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
150 |
// test if annotation has several colors. |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
151 |
var colAr = []; |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
152 |
for (var _j = 0; _j < _this.polemics.length; _j++) { |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
153 |
if( IriSP.Model.regexpFromTextOrArray( _this.polemics[_j].keywords ).test( _annotation.title ) ){ |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
154 |
colAr.push(_this.polemics[_j].color); |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
155 |
} |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
156 |
} |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
157 |
// display annotation |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
158 |
_annotation.on("select", function() { |
| 986 | 159 |
if (_this.tooltip) { |
160 |
_this.tooltip.show( |
|
| 987 | 161 |
+ Math.floor(_elx + (_this.element_width - 1) / 2), |
162 |
+ _ely, |
|
| 986 | 163 |
_annotation.title, |
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
164 |
( (colAr.length>1) ? colAr : _col ) |
| 986 | 165 |
); |
166 |
} |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
167 |
_this.$tweets.each(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
168 |
var _e = IriSP.jQuery(this); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
169 |
_e.css( |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
170 |
"opacity", |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
171 |
( _e.attr("annotation-id") == _annotation.id ? 1 : .3 ) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
172 |
); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
173 |
}); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
174 |
}); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
175 |
_annotation.on("unselect", function() { |
| 986 | 176 |
if (_this.tooltip) { |
177 |
_this.tooltip.hide(); |
|
178 |
} |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
179 |
_this.$tweets.css("opacity",1); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
180 |
}); |
| 983 | 181 |
_annotation.on("found", function() { |
182 |
_el.css({ |
|
183 |
"background" : _this.foundcolor, |
|
184 |
"opacity" : 1 |
|
185 |
}); |
|
186 |
}); |
|
187 |
_annotation.on("not-found", function() { |
|
188 |
_el.css({ |
|
189 |
"background" : _col, |
|
190 |
"opacity" : .3 |
|
191 |
}); |
|
192 |
}); |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
193 |
_this.$zone.append(_el); |
| 882 | 194 |
} |
195 |
|
|
196 |
IriSP._(_slices).forEach(function(_slice) { |
|
197 |
var _y = _this.height; |
|
198 |
_slice.annotations.forEach(function(_annotation) { |
|
199 |
_y -= _this.element_height; |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
200 |
displayAnnotation(_x, _y, "none", _this.defaultcolor, _annotation); |
| 882 | 201 |
}); |
202 |
IriSP._(_slice.polemicStacks).forEach(function(_annotations, _j) { |
|
| 930 | 203 |
var _color = _this.polemics[_j].color, |
204 |
_polemic = _this.polemics[_j].name; |
|
| 882 | 205 |
_annotations.forEach(function(_annotation) { |
206 |
_y -= _this.element_height; |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
207 |
displayAnnotation(_x, _y, _polemic, _color, _annotation); |
| 882 | 208 |
}); |
209 |
}); |
|
210 |
_x += _this.element_width; |
|
211 |
}); |
|
212 |
|
|
213 |
this.$zone.append(_html); |
|
214 |
|
|
215 |
this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv"); |
|
216 |
|
|
| 983 | 217 |
this.source.getAnnotations().on("search-cleared", function() { |
218 |
_this.$tweets.each(function() { |
|
219 |
var _el = IriSP.jQuery(this); |
|
220 |
_el.css({ |
|
221 |
"background" : _el.attr("polemic-color"), |
|
222 |
"opacity" : 1 |
|
223 |
}); |
|
224 |
}); |
|
225 |
}); |
|
| 882 | 226 |
|
227 |
} else { |
|
228 |
this.$zone.hide(); |
|
229 |
} |
|
230 |
} else { |
|
231 |
this.is_stackgraph = true; |
|
232 |
|
|
233 |
this.height = (2 + this.max_elements) * this.element_height; |
|
234 |
this.$zone.css({ |
|
235 |
width: this.width + "px", |
|
236 |
height: this.height + "px", |
|
237 |
position: "relative" |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
238 |
}); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
239 |
|
| 882 | 240 |
var _x = 0, |
241 |
_html = '', |
|
242 |
_scale = this.max_elements * this.element_height / _max; |
|
243 |
|
|
| 930 | 244 |
function displayStackElement(_x, _y, _h, _color, _nums, _begin, _end, _polemic) { |
| 882 | 245 |
_html += Mustache.to_html( |
| 930 | 246 |
'<div class="Ldt-Polemic-TweetDiv Ldt-TraceMe" trace-info="annotation-block, media-id={{media_id}}, polemic={{polemic}}, time:{{begin}}" pos-x="{{posx}}" pos-y="{{top}}" annotation-counts="{{nums}}" begin-time="{{begin}}" end-time="{{end}}"' |
| 882 | 247 |
+ ' style="width: {{width}}px; height: {{height}}px; top: {{top}}px; left: {{left}}px; background: {{color}}"></div>', |
248 |
{ |
|
249 |
nums: _nums, |
|
250 |
posx: Math.floor(_x + (_this.element_width - 1) / 2), |
|
| 930 | 251 |
media_id: _this.source.currentMedia.id, |
252 |
polemic: _polemic, |
|
| 882 | 253 |
left: _x, |
254 |
top: _y, |
|
255 |
color: _color, |
|
256 |
width: (_this.element_width-1), |
|
257 |
height: _h, |
|
258 |
begin: _begin, |
|
259 |
end: _end |
|
260 |
}); |
|
261 |
} |
|
262 |
|
|
263 |
IriSP._(_slices).forEach(function(_slice) { |
|
264 |
var _y = _this.height, |
|
265 |
_nums = _slice.annotations.length + "," + IriSP._(_slice.polemicStacks).map(function(_annotations) { |
|
| 1012 | 266 |
return _annotations.length; |
| 882 | 267 |
}).join(","); |
268 |
if (_slice.annotations.length) { |
|
269 |
var _h = Math.ceil(_scale * _slice.annotations.length); |
|
270 |
_y -= _h; |
|
| 930 | 271 |
displayStackElement(_x, _y, _h, _this.defaultcolor, _nums, _slice.begin, _slice.end, "none"); |
| 882 | 272 |
} |
273 |
IriSP._(_slice.polemicStacks).forEach(function(_annotations, _j) { |
|
274 |
if (_annotations.length) { |
|
275 |
var _color = _this.polemics[_j].color, |
|
| 930 | 276 |
_polemic = _this.polemics[_j].name, |
| 882 | 277 |
_h = Math.ceil(_scale * _annotations.length); |
278 |
_y -= _h; |
|
| 930 | 279 |
displayStackElement(_x, _y, _h, _color, _nums, _slice.begin, _slice.end, _polemic); |
| 882 | 280 |
} |
281 |
}); |
|
282 |
_x += _this.element_width; |
|
| 876 | 283 |
}); |
| 882 | 284 |
|
285 |
this.$zone.append(_html); |
|
286 |
|
|
287 |
this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv"); |
|
288 |
|
|
289 |
this.$tweets |
|
290 |
.mouseover(function() { |
|
291 |
var _el = IriSP.jQuery(this), |
|
292 |
_nums = _el.attr("annotation-counts").split(","), |
|
293 |
_html = '<p>' + _this.l10n.from_ + _el.attr("begin-time") + _this.l10n._to_ + _el.attr("end-time") + '</p>'; |
|
294 |
for (var _i = 0; _i <= _this.polemics.length; _i++) { |
|
295 |
var _color = _i ? _this.polemics[_i - 1].color : _this.defaultcolor; |
|
| 1012 | 296 |
_html += '<div class="Ldt-Tooltip-AltColor" style="background: ' + _color + '"></div><p>' + _nums[_i] + _this.l10n._annotations + '</p>'; |
| 882 | 297 |
} |
| 986 | 298 |
if (_this.tooltip) { |
| 987 | 299 |
_this.tooltip.show(+ _el.attr("pos-x"), + _el.attr("pos-y"), _html); |
| 986 | 300 |
} |
| 882 | 301 |
}) |
302 |
.mouseout(function() { |
|
| 986 | 303 |
if (_this.tooltip) { |
304 |
_this.tooltip.hide(); |
|
305 |
} |
|
| 1012 | 306 |
}); |
| 882 | 307 |
|
| 1012 | 308 |
}; |
|
194
f5d86e5c4a56
some cleaning. Also added a progression indicator.
hamidouk
parents:
192
diff
changeset
|
309 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
310 |
this.$position = IriSP.jQuery('<div>').addClass("Ldt-Polemic-Position"); |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
311 |
|
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
312 |
this.$zone.append(this.$position); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
313 |
|
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
314 |
this.$zone.click(function(_e) { |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
315 |
var _x = _e.pageX - _this.$zone.offset().left; |
| 957 | 316 |
_this.media.setCurrentTime(_this.media.duration * _x / _this.width); |
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
317 |
}); |
| 924 | 318 |
|
319 |
this.$.append('<div class="Ldt-Polemic-Tooltip"></div>'); |
|
320 |
|
|
| 986 | 321 |
this.insertSubwidget( |
322 |
this.$.find(".Ldt-Polemic-Tooltip"), |
|
323 |
{ |
|
324 |
type: "Tooltip", |
|
325 |
min_x: 0, |
|
326 |
max_x: this.width |
|
327 |
}, |
|
328 |
"tooltip" |
|
329 |
); |
|
| 1012 | 330 |
}; |
|
194
f5d86e5c4a56
some cleaning. Also added a progression indicator.
hamidouk
parents:
192
diff
changeset
|
331 |
|
| 957 | 332 |
IriSP.Widgets.Polemic.prototype.onTimeupdate = function(_time) { |
333 |
var _x = Math.floor( this.width * _time / this.media.duration); |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
334 |
this.$elapsed.css({ |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
335 |
width: _x + "px" |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
336 |
}); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
337 |
this.$position.css({ |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
338 |
left: _x + "px" |
| 1012 | 339 |
}); |
340 |
}; |