| author | ymh <ymh.work@gmail.com> |
| Mon, 28 Dec 2015 15:50:04 +0100 | |
| changeset 1069 | 2409cb4cebaf |
| parent 1068 | 7623f9af9272 |
| child 1072 | ac1eacb3aa33 |
| permissions | -rw-r--r-- |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
1 |
// TODO: Trigger IriSP.SegmentsWidget.click |
| 876 | 2 |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
3 |
IriSP.Widgets.Segments = function(player, config) { |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
4 |
IriSP.Widgets.Widget.call(this, player, config); |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
5 |
}; |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
6 |
|
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
7 |
IriSP.Widgets.Segments.prototype = new IriSP.Widgets.Widget(); |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
8 |
|
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
9 |
IriSP.Widgets.Segments.prototype.defaults = { |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
10 |
annotation_type : "chap", |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
11 |
colors: ["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"], |
| 982 | 12 |
line_height: 8, |
13 |
background: "#e0e0e0", |
|
| 983 | 14 |
overlap: .25, |
15 |
found_color: "#FF00FC", |
|
| 1033 | 16 |
faded_found_color: "#ff80fc", |
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
17 |
selected_color: "#74d600", |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
18 |
faded_selected_color: "#baf9b5", |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
19 |
no_tooltip: false, |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
20 |
use_timerange: false, |
|
1069
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
21 |
scale_to_parent: true |
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
22 |
}; |
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
23 |
|
|
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
24 |
IriSP.Widgets.Segments.prototype.template = |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
25 |
'<div class="Ldt-Segments-List"></div>' |
| 924 | 26 |
+ '<div class="Ldt-Segments-Position"></div>' |
27 |
+ '<div class="Ldt-Segments-Tooltip"></div>'; |
|
|
875
43629caa77bc
Big refactoring of widget files + started migration of segmentwidget
veltr
parents:
diff
changeset
|
28 |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
29 |
IriSP.Widgets.Segments.prototype.annotationTemplate = |
|
996
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
30 |
'<div class="Ldt-Segments-Segment Ldt-TraceMe" trace-info="segment-id:{{id}}, media-id:{{media_id}}, from:{{from}}, to:{{to}}" segment-text="{{text}}"' |
| 1013 | 31 |
+ 'style="top:{{top}}px; height:{{height}}px; left:{{left}}px; width:{{width}}px; background:{{medcolor}}" data-base-color="{{color}}" data-low-color="{{lowcolor}}" data-medium-color="{{medcolor}}"></div>'; |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
32 |
|
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
33 |
|
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
34 |
IriSP.Widgets.Segments.prototype.do_draw = function (isRedraw) { |
|
1069
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
35 |
if (this.width != this.$.parent().width() && this.scale_to_parent) { |
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
36 |
// Reset width |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
37 |
this.width = this.$.parent().width(); |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
38 |
this.$.css({ width : this.width + "px" }); |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
39 |
} |
|
1069
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
40 |
var _this = this, |
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
41 |
_list = this.getWidgetAnnotations().filter(function(_ann) { |
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
42 |
return _ann.getDuration() > 0 && _ann.getMedia().id == _this.media.id; |
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
43 |
}), |
| 983 | 44 |
_scale = this.width / this.source.getDuration(), |
45 |
list_$ = this.$.find('.Ldt-Segments-List'), |
|
| 982 | 46 |
lines = [], |
| 983 | 47 |
zindex = 1, |
48 |
searching = false; |
|
| 982 | 49 |
|
50 |
function saturate(r, g, b, s) { |
|
51 |
function satcomp(c) { |
|
52 |
return Math.floor(240 * (1 - s) + c * s); |
|
53 |
} |
|
54 |
var res = ( 0x10000 * satcomp(r) + 0x100 * satcomp(g) + satcomp(b)).toString(16); |
|
55 |
while (res.length < 6) { |
|
56 |
res = "0" + res; |
|
57 |
} |
|
58 |
return "#" + res; |
|
59 |
} |
|
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
60 |
|
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
61 |
if (isRedraw) { |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
62 |
// Remove all previous elements before recreating them. Not very efficient. |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
63 |
this.$.find('.Ldt-Segments-Segment').remove(); |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
64 |
} |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
65 |
_list.forEach(function(_annotation, _k) { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
66 |
var _left = _annotation.begin * _scale, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
67 |
_width = ( _annotation.getDuration() ) * _scale, |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
68 |
_center = Math.floor( _left + _width / 2 ), |
| 982 | 69 |
_fulltext = _annotation.title + ( _annotation.description ? ( '<br/>' + _annotation.description ) : '' ), |
70 |
line = IriSP._(lines).find(function(line) { |
|
71 |
return !IriSP._(line.annotations).find(function(a) { |
|
| 1013 | 72 |
return a.begin < _annotation.end && a.end > _annotation.begin; |
| 982 | 73 |
}); |
74 |
}); |
|
75 |
if (!line) { |
|
76 |
line = { index: lines.length, annotations: []}; |
|
77 |
lines.push(line); |
|
78 |
} |
|
79 |
line.annotations.push(_annotation); |
|
80 |
var _top = ((1 - _this.overlap) * line.index) * _this.line_height, |
|
81 |
color = ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.colors[_k % _this.colors.length] ), |
|
82 |
r = parseInt(color.substr(1,2),16), |
|
83 |
g = parseInt(color.substr(3,2),16), |
|
84 |
b = parseInt(color.substr(5,2),16), |
|
85 |
medcolor = saturate(r, g, b, .5), |
|
86 |
lowcolor = saturate(r, g, b, .2); |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
87 |
var _data = { |
| 982 | 88 |
color : color, |
89 |
medcolor: medcolor, |
|
90 |
lowcolor: lowcolor, |
|
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
91 |
text: (_annotation.creator ? (_annotation.creator + " : ") : "" ) + _fulltext.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1…'), |
| 982 | 92 |
left : _left, |
93 |
width : _width, |
|
94 |
top: _top, |
|
95 |
height: _this.line_height - 1, |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
96 |
id : _annotation.id, |
| 990 | 97 |
media_id : _annotation.getMedia().id, |
98 |
from: _annotation.begin.toString(), |
|
99 |
to: _annotation.end.toString() |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
100 |
}; |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
101 |
var _html = Mustache.to_html(_this.annotationTemplate, _data), |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
102 |
_el = IriSP.jQuery(_html); |
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
103 |
_el.mouseover(function() { |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
104 |
_annotation.trigger("select"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
105 |
}) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
106 |
.mouseout(function() { |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
107 |
_annotation.trigger("unselect"); |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
108 |
}) |
|
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
109 |
.click(function() { |
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
110 |
if(_this.use_timerange){ |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
111 |
if(!_this.media.getTimeRange()){ |
|
1058
ded3cd1312c1
If TimeRange is set, clicking on a segment will play the video
durandn
parents:
1044
diff
changeset
|
112 |
_this.media.setCurrentTime(_annotation.begin); |
|
ded3cd1312c1
If TimeRange is set, clicking on a segment will play the video
durandn
parents:
1044
diff
changeset
|
113 |
_this.media.setTimeRange(_annotation.begin, _annotation.end); |
|
ded3cd1312c1
If TimeRange is set, clicking on a segment will play the video
durandn
parents:
1044
diff
changeset
|
114 |
_this.media.play(); |
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
115 |
_this.$segments.each(function(){ |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
116 |
var _segment = IriSP.jQuery(this); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
117 |
_segment.css("background", lowcolor).removeClass("selected"); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
118 |
}) |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
119 |
_el.css("background", _this.selected_color).addClass("selected"); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
120 |
} |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
121 |
else if (_this.media.getTimeRange()[0]==_annotation.begin || _this.media.getTimeRange()[1]==_annotation.end){ |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
122 |
_this.media.resetTimeRange(); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
123 |
_this.$segments.each(function(){ |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
124 |
var _segment = IriSP.jQuery(this); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
125 |
_segment.css("background", lowcolor).removeClass("selected"); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
126 |
_annotation.trigger("select"); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
127 |
}) |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
128 |
} |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
129 |
else { |
|
1058
ded3cd1312c1
If TimeRange is set, clicking on a segment will play the video
durandn
parents:
1044
diff
changeset
|
130 |
_this.media.setCurrentTime(_annotation.begin); |
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
131 |
_this.media.setTimeRange(_annotation.begin, _annotation.end); |
|
1058
ded3cd1312c1
If TimeRange is set, clicking on a segment will play the video
durandn
parents:
1044
diff
changeset
|
132 |
_this.media.play(); |
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
133 |
_this.$segments.each(function(){ |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
134 |
var _segment = IriSP.jQuery(this); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
135 |
_segment.css("background", lowcolor).removeClass("selected"); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
136 |
}) |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
137 |
_el.css("background", _this.selected_color).addClass("selected"); |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
138 |
} |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
139 |
} |
| 964 | 140 |
_annotation.trigger("click"); |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
141 |
}) |
|
996
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
142 |
.appendTo(list_$); |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
143 |
IriSP.attachDndData(_el, { |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
144 |
title: _annotation.title, |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
145 |
description: _annotation.description, |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
146 |
uri: (typeof _annotation.url !== "undefined" |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
147 |
? _annotation.url |
|
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
148 |
: (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)), |
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
149 |
image: _annotation.thumbnail, |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
150 |
text: '[' + _annotation.begin.toString() + '] ' + _annotation.title |
|
996
c472984db275
refactored drag-and-drop interface (IE Compatibility)
veltr
parents:
994
diff
changeset
|
151 |
}); |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
152 |
_annotation.on("select", function() { |
| 982 | 153 |
_this.$segments.each(function() { |
154 |
var _segment = IriSP.jQuery(this); |
|
155 |
_segment.css({ |
|
| 983 | 156 |
background: _segment.hasClass("found") ? _this.faded_found_color : _segment.attr("data-low-color") |
| 982 | 157 |
}); |
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
158 |
_segment.css({ |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
159 |
background: _segment.hasClass("selected") ? _this.faded_selected_color : _segment.attr("data-low-color") |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
160 |
}) |
| 982 | 161 |
}); |
| 983 | 162 |
_el.css({ |
163 |
background: _el.hasClass("found") ? _this.found_color: color, |
|
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
164 |
background: _el.hasClass("selected") ? _this.selected_color: color, |
| 983 | 165 |
"z-index": ++zindex |
166 |
}); |
|
| 986 | 167 |
if (_this.tooltip) { |
168 |
_this.tooltip.show( _center, _top, _data.text, _data.color ); |
|
169 |
} |
|
| 983 | 170 |
}); |
171 |
_annotation.on("unselect", function() { |
|
| 986 | 172 |
if (_this.tooltip) { |
173 |
_this.tooltip.hide(); |
|
174 |
} |
|
| 983 | 175 |
_this.$segments.each(function() { |
176 |
var _segment = IriSP.jQuery(this); |
|
177 |
_segment.css("background", _segment.hasClass("found") ? _this.found_color : _segment.attr(searching ? "data-low-color" : "data-medium-color")); |
|
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
178 |
_segment.css("background", _segment.hasClass("selected") ? _this.selected_color : _segment.attr(searching ? "data-low-color" : "data-medium-color")); |
| 982 | 179 |
}); |
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
180 |
}); |
| 983 | 181 |
_annotation.on("found", function() { |
182 |
_el.css("background", _this.found_color).addClass("found"); |
|
183 |
}); |
|
184 |
_annotation.on("not-found", function() { |
|
185 |
_el.css("background", lowcolor).removeClass("found"); |
|
186 |
}); |
|
| 982 | 187 |
}); |
188 |
|
|
|
1069
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
189 |
this.onMediaEvent("resettimerange", function(){ |
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
190 |
|
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
191 |
_this.$segments.each(function(){ |
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
192 |
var _segment = IriSP.jQuery(this); |
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
193 |
_segment.removeClass("selected"); |
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
194 |
}) |
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
195 |
}); |
|
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1068
diff
changeset
|
196 |
|
| 982 | 197 |
this.$.css({ |
198 |
width : this.width + "px", |
|
199 |
height : (((1 - this.overlap) * lines.length + this.overlap) * this.line_height) + "px", |
|
200 |
background : this.background, |
|
201 |
margin: "1px 0" |
|
|
937
eb3c442cec50
Added events on annotation for inter widget communication
veltr
parents:
930
diff
changeset
|
202 |
}); |
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
203 |
this.$segments = this.$.find('.Ldt-Segments-Segment'); |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
204 |
}; |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
205 |
|
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
206 |
IriSP.Widgets.Segments.prototype.draw = function() { |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
207 |
var widget = this; |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
208 |
widget.onMediaEvent("timeupdate", "onTimeupdate"); |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
209 |
widget.renderTemplate(); |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
210 |
widget.do_draw(); |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
211 |
if (!this.no_tooltip) { |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
212 |
widget.insertSubwidget( |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
213 |
widget.$.find(".Ldt-Segments-Tooltip"), |
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
214 |
{ |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
215 |
type: "Tooltip", |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
216 |
min_x: 0, |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
217 |
max_x: this.width |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
218 |
}, |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
219 |
"tooltip" |
|
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
220 |
); |
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
221 |
}; |
|
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
222 |
widget.source.getAnnotations().on("search", function() { |
| 983 | 223 |
searching = true; |
224 |
}); |
|
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
225 |
widget.source.getAnnotations().on("search-cleared", function() { |
| 983 | 226 |
searching = false; |
| 982 | 227 |
_this.$segments.each(function() { |
228 |
var _segment = IriSP.jQuery(this); |
|
| 983 | 229 |
_segment.css("background", _segment.attr("data-medium-color")).removeClass("found"); |
| 982 | 230 |
}); |
| 983 | 231 |
}); |
|
1068
7623f9af9272
merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents:
1058
diff
changeset
|
232 |
this.$.on("resize", function () { widget.do_draw(true); }); |
| 1013 | 233 |
}; |
| 876 | 234 |
|
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
235 |
IriSP.Widgets.Segments.prototype.onTimeupdate = function(_time) { |
| 957 | 236 |
var _x = Math.floor( this.width * _time / this.media.duration); |
| 876 | 237 |
this.$.find('.Ldt-Segments-Position').css({ |
238 |
left: _x + "px" |
|
| 1013 | 239 |
}); |
| 1033 | 240 |
}; |
|
1044
d8339b45edc4
Added support for defining a "time range" for a Playable to set the time boundaries of what can be played by the diffenrent players (Popcorn and HtmlPlayer for now). Added option in Segment widget to define a timerange on click.
durandn
parents:
1033
diff
changeset
|
241 |