| author | cavaliet |
| Thu, 02 Jan 2014 16:40:25 +0100 | |
| branch | new-model |
| changeset 1019 | 3ab36f402b0c |
| parent 937 | eb3c442cec50 |
| child 1020 | 198c2b79f5e1 |
| 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 |
} |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
18 |
}; |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
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, |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
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 |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
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 |
|
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
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, |
| 882 | 75 |
_list = this.getWidgetAnnotations(), |
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) { |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
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 : [] |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
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( |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
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, |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
129 |
title: _annotation.title, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
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() { |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
138 |
_annotation.trigger("click"); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
139 |
return false; |
| 882 | 140 |
}); |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
141 |
IriSP.attachDndData(_el, { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
142 |
title: _annotation.title, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
143 |
description: _annotation.description, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
144 |
image: _annotation.thumbnail, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
145 |
uri: (typeof _annotation.url !== "undefined" |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
146 |
? _annotation.url |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
147 |
: (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)) |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
148 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
149 |
// test if annotation has several colors. |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
150 |
var colAr = []; |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
151 |
for (var _j = 0; _j < _this.polemics.length; _j++) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
152 |
if( IriSP.Model.regexpFromTextOrArray( _this.polemics[_j].keywords ).test( _annotation.title ) ){ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
153 |
colAr.push(_this.polemics[_j].color); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
154 |
} |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
155 |
} |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
156 |
// display annotation |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
157 |
_annotation.on("select", function() { |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
158 |
if (_this.tooltip) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
159 |
_this.tooltip.show( |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
160 |
+ Math.floor(_elx + (_this.element_width - 1) / 2), |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
161 |
+ _ely, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
162 |
_annotation.title, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
163 |
( (colAr.length>1) ? colAr : _col ) |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
164 |
); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
165 |
} |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
166 |
_this.$tweets.each(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
167 |
var _e = IriSP.jQuery(this); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
168 |
_e.css( |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
169 |
"opacity", |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
170 |
( _e.attr("annotation-id") == _annotation.id ? 1 : .3 ) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
171 |
); |
|
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 |
_annotation.on("unselect", function() { |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
175 |
if (_this.tooltip) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
176 |
_this.tooltip.hide(); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
177 |
} |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
178 |
_this.$tweets.css("opacity",1); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
179 |
}); |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
180 |
_annotation.on("found", function() { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
181 |
_el.css({ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
182 |
"background" : _this.foundcolor, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
183 |
"opacity" : 1 |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
184 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
185 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
186 |
_annotation.on("not-found", function() { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
187 |
_el.css({ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
188 |
"background" : _col, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
189 |
"opacity" : .3 |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
190 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
191 |
}); |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
192 |
_this.$zone.append(_el); |
| 882 | 193 |
} |
194 |
|
|
195 |
IriSP._(_slices).forEach(function(_slice) { |
|
196 |
var _y = _this.height; |
|
197 |
_slice.annotations.forEach(function(_annotation) { |
|
198 |
_y -= _this.element_height; |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
199 |
displayAnnotation(_x, _y, "none", _this.defaultcolor, _annotation); |
| 882 | 200 |
}); |
201 |
IriSP._(_slice.polemicStacks).forEach(function(_annotations, _j) { |
|
| 930 | 202 |
var _color = _this.polemics[_j].color, |
203 |
_polemic = _this.polemics[_j].name; |
|
| 882 | 204 |
_annotations.forEach(function(_annotation) { |
205 |
_y -= _this.element_height; |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
206 |
displayAnnotation(_x, _y, _polemic, _color, _annotation); |
| 882 | 207 |
}); |
208 |
}); |
|
209 |
_x += _this.element_width; |
|
210 |
}); |
|
211 |
|
|
212 |
this.$zone.append(_html); |
|
213 |
|
|
214 |
this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv"); |
|
215 |
|
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
216 |
this.source.getAnnotations().on("search-cleared", function() { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
217 |
_this.$tweets.each(function() { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
218 |
var _el = IriSP.jQuery(this); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
219 |
_el.css({ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
220 |
"background" : _el.attr("polemic-color"), |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
221 |
"opacity" : 1 |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
222 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
223 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
224 |
}); |
| 882 | 225 |
|
226 |
} else { |
|
227 |
this.$zone.hide(); |
|
228 |
} |
|
229 |
} else { |
|
230 |
this.is_stackgraph = true; |
|
231 |
|
|
232 |
this.height = (2 + this.max_elements) * this.element_height; |
|
233 |
this.$zone.css({ |
|
234 |
width: this.width + "px", |
|
235 |
height: this.height + "px", |
|
236 |
position: "relative" |
|
|
874
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
237 |
}); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
238 |
|
| 882 | 239 |
var _x = 0, |
240 |
_html = '', |
|
241 |
_scale = this.max_elements * this.element_height / _max; |
|
242 |
|
|
| 930 | 243 |
function displayStackElement(_x, _y, _h, _color, _nums, _begin, _end, _polemic) { |
| 882 | 244 |
_html += Mustache.to_html( |
| 930 | 245 |
'<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 | 246 |
+ ' style="width: {{width}}px; height: {{height}}px; top: {{top}}px; left: {{left}}px; background: {{color}}"></div>', |
247 |
{ |
|
248 |
nums: _nums, |
|
249 |
posx: Math.floor(_x + (_this.element_width - 1) / 2), |
|
| 930 | 250 |
media_id: _this.source.currentMedia.id, |
251 |
polemic: _polemic, |
|
| 882 | 252 |
left: _x, |
253 |
top: _y, |
|
254 |
color: _color, |
|
255 |
width: (_this.element_width-1), |
|
256 |
height: _h, |
|
257 |
begin: _begin, |
|
258 |
end: _end |
|
259 |
}); |
|
260 |
} |
|
261 |
|
|
262 |
IriSP._(_slices).forEach(function(_slice) { |
|
263 |
var _y = _this.height, |
|
264 |
_nums = _slice.annotations.length + "," + IriSP._(_slice.polemicStacks).map(function(_annotations) { |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
265 |
return _annotations.length; |
| 882 | 266 |
}).join(","); |
267 |
if (_slice.annotations.length) { |
|
268 |
var _h = Math.ceil(_scale * _slice.annotations.length); |
|
269 |
_y -= _h; |
|
| 930 | 270 |
displayStackElement(_x, _y, _h, _this.defaultcolor, _nums, _slice.begin, _slice.end, "none"); |
| 882 | 271 |
} |
272 |
IriSP._(_slice.polemicStacks).forEach(function(_annotations, _j) { |
|
273 |
if (_annotations.length) { |
|
274 |
var _color = _this.polemics[_j].color, |
|
| 930 | 275 |
_polemic = _this.polemics[_j].name, |
| 882 | 276 |
_h = Math.ceil(_scale * _annotations.length); |
277 |
_y -= _h; |
|
| 930 | 278 |
displayStackElement(_x, _y, _h, _color, _nums, _slice.begin, _slice.end, _polemic); |
| 882 | 279 |
} |
280 |
}); |
|
281 |
_x += _this.element_width; |
|
| 876 | 282 |
}); |
| 882 | 283 |
|
284 |
this.$zone.append(_html); |
|
285 |
|
|
286 |
this.$tweets = this.$.find(".Ldt-Polemic-TweetDiv"); |
|
287 |
|
|
288 |
this.$tweets |
|
289 |
.mouseover(function() { |
|
290 |
var _el = IriSP.jQuery(this), |
|
291 |
_nums = _el.attr("annotation-counts").split(","), |
|
292 |
_html = '<p>' + _this.l10n.from_ + _el.attr("begin-time") + _this.l10n._to_ + _el.attr("end-time") + '</p>'; |
|
293 |
for (var _i = 0; _i <= _this.polemics.length; _i++) { |
|
294 |
var _color = _i ? _this.polemics[_i - 1].color : _this.defaultcolor; |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
295 |
_html += '<div class="Ldt-Tooltip-AltColor" style="background: ' + _color + '"></div><p>' + _nums[_i] + _this.l10n._annotations + '</p>'; |
| 882 | 296 |
} |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
297 |
if (_this.tooltip) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
298 |
_this.tooltip.show(+ _el.attr("pos-x"), + _el.attr("pos-y"), _html); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
299 |
} |
| 882 | 300 |
}) |
301 |
.mouseout(function() { |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
302 |
if (_this.tooltip) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
303 |
_this.tooltip.hide(); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
304 |
} |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
305 |
}); |
| 882 | 306 |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
307 |
}; |
|
194
f5d86e5c4a56
some cleaning. Also added a progression indicator.
hamidouk
parents:
192
diff
changeset
|
308 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
309 |
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
|
310 |
|
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
311 |
this.$zone.append(this.$position); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
312 |
|
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
313 |
this.$zone.click(function(_e) { |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
314 |
var _x = _e.pageX - _this.$zone.offset().left; |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
315 |
_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
|
316 |
}); |
| 924 | 317 |
|
318 |
this.$.append('<div class="Ldt-Polemic-Tooltip"></div>'); |
|
319 |
|
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
320 |
this.insertSubwidget( |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
321 |
this.$.find(".Ldt-Polemic-Tooltip"), |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
322 |
{ |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
323 |
type: "Tooltip", |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
324 |
min_x: 0, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
325 |
max_x: this.width |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
326 |
}, |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
327 |
"tooltip" |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
328 |
); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
329 |
}; |
|
194
f5d86e5c4a56
some cleaning. Also added a progression indicator.
hamidouk
parents:
192
diff
changeset
|
330 |
|
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
331 |
IriSP.Widgets.Polemic.prototype.onTimeupdate = function(_time) { |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
332 |
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
|
333 |
this.$elapsed.css({ |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
334 |
width: _x + "px" |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
335 |
}); |
|
38b65761a7d5
TooltipWidget, SliderWidget, corrections in AnnotationList, CSS are now split
veltr
parents:
842
diff
changeset
|
336 |
this.$position.css({ |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
874
diff
changeset
|
337 |
left: _x + "px" |
|
1019
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
338 |
}); |
|
3ab36f402b0c
update widgets after enhance in annotation platform.
cavaliet
parents:
937
diff
changeset
|
339 |
}; |