| author | cavaliet |
| Thu, 02 Jan 2014 16:54:22 +0100 | |
| changeset 1021 | 7253d4d06f0d |
| parent 1013 | 392ddcd212d7 |
| child 1024 | 894079bece86 |
| permissions | -rw-r--r-- |
| 982 | 1 |
IriSP.Widgets.MultiSegments = function(player, config) { |
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
3 |
}; |
|
4 |
||
5 |
IriSP.Widgets.MultiSegments.prototype = new IriSP.Widgets.Widget(); |
|
6 |
||
7 |
IriSP.Widgets.MultiSegments.prototype.defaults = { |
|
8 |
annotation_show_arrow: true, |
|
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
9 |
annotation_start_minimized: false, |
| 982 | 10 |
annotation_show_annotation_type: true, |
11 |
show_all: false |
|
| 1013 | 12 |
}; |
| 982 | 13 |
|
14 |
IriSP.Widgets.MultiSegments.prototype.draw = function() { |
|
15 |
var _this = this, |
|
16 |
lines = [], |
|
17 |
currentLine = null, |
|
18 |
segmentsopts = {}, |
|
19 |
annotationopts = {}; |
|
20 |
IriSP._(this).each(function(_v,_k) { |
|
21 |
if (/^segments_/.test(_k)) { |
|
22 |
segmentsopts[_k.replace(/^segments_/,"")] = _v; |
|
23 |
} |
|
24 |
if (/^annotation_/.test(_k)) { |
|
25 |
annotationopts[_k.replace(/^annotation_/,"")] = _v; |
|
26 |
} |
|
| 1013 | 27 |
}); |
| 982 | 28 |
this.source.getAnnotationTypes().forEach(function(_anntype) { |
29 |
var segments = _anntype.getAnnotations().filter(function(_ann) { |
|
30 |
return _ann.getDuration() > 0; |
|
31 |
}); |
|
32 |
if (segments.length) { |
|
33 |
|
|
34 |
var visible = false; |
|
35 |
|
|
36 |
var line = { |
|
37 |
segmentWidget: IriSP.jQuery("<div>"), |
|
38 |
annotationWidget: IriSP.jQuery("<div>"), |
|
39 |
hasSegmentsNow: function() { |
|
40 |
var _time = _this.media.getCurrentTime(); |
|
41 |
return !!segments.filter(function(_annotation) { |
|
42 |
return _annotation.begin <= _time && _annotation.end > _time; |
|
43 |
}).length; |
|
44 |
}, |
|
45 |
hide: function() { |
|
46 |
if (visible) { |
|
47 |
visible = false; |
|
48 |
this.annotationWidget.slideUp(); |
|
49 |
} |
|
50 |
}, |
|
51 |
show: function() { |
|
52 |
if (!visible) { |
|
53 |
visible = true; |
|
54 |
this.annotationWidget.slideDown(); |
|
55 |
} |
|
56 |
} |
|
| 1013 | 57 |
}; |
| 982 | 58 |
|
59 |
|
|
60 |
line.segmentWidget |
|
61 |
.addClass("Ldt-MultiSegments-Segment") |
|
62 |
.appendTo(_this.$); |
|
63 |
|
|
64 |
if (!_this.show_all) { |
|
65 |
line.segmentWidget.mouseenter(function() { |
|
66 |
if (line.hasSegmentsNow()) { |
|
67 |
currentLine = line; |
|
68 |
checkVisibilities(); |
|
69 |
} |
|
70 |
}); |
|
71 |
} |
|
72 |
|
|
73 |
line.annotationWidget |
|
74 |
.addClass("Ldt-MultiSegments-Annotation") |
|
75 |
.appendTo(_this.$) |
|
76 |
.hide(); |
|
77 |
|
|
78 |
_this.insertSubwidget( |
|
79 |
line.segmentWidget, |
|
80 |
IriSP._({ |
|
81 |
type: "Segments", |
|
|
988
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
982
diff
changeset
|
82 |
annotation_type: _anntype, |
|
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
982
diff
changeset
|
83 |
width: _this.width |
| 982 | 84 |
}).extend(segmentsopts) |
85 |
); |
|
86 |
|
|
87 |
_this.insertSubwidget( |
|
88 |
line.annotationWidget, |
|
89 |
IriSP._({ |
|
90 |
type: "Annotation", |
|
|
988
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
982
diff
changeset
|
91 |
annotation_type: _anntype, |
|
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
982
diff
changeset
|
92 |
width: _this.width |
| 982 | 93 |
}).extend(annotationopts) |
94 |
); |
|
95 |
|
|
96 |
lines.push(line); |
|
97 |
} |
|
98 |
}); |
|
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
99 |
|
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
100 |
// open line on segment click |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
101 |
$j(document).on("click",".Ldt-Segments-Segment",function(e){ |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
102 |
if (!_this.show_all && currentLine && !currentLine.hasSegmentsNow()) { |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
103 |
currentLine = undefined; |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
104 |
} |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
105 |
IriSP._(lines).each(function(line) { |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
106 |
if($j(e.target).parent().parent()[0]==line.segmentWidget[0]){ |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
107 |
currentLine = line; |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
108 |
line.show(); |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
109 |
} else { |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
110 |
line.hide(); |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
111 |
} |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
112 |
}); |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
113 |
}); |
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
114 |
|
|
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
115 |
//var _annotationWidgets = _this.$.find(".Ldt-MultiSegments-Annotation"); |
| 982 | 116 |
|
117 |
function checkVisibilities(_time) { |
|
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
118 |
/*if (!_this.show_all && currentLine && !currentLine.hasSegmentsNow()) { |
| 982 | 119 |
currentLine = undefined; |
120 |
} |
|
121 |
IriSP._(lines).each(function(line) { |
|
122 |
if (line.hasSegmentsNow()) { |
|
123 |
if (!_this.show_all && !currentLine) { |
|
124 |
currentLine = line; |
|
125 |
} |
|
126 |
if (_this.show_all || line === currentLine) { |
|
127 |
line.show(); |
|
128 |
} else { |
|
129 |
line.hide(); |
|
130 |
} |
|
131 |
} else { |
|
132 |
line.hide(); |
|
133 |
} |
|
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1013
diff
changeset
|
134 |
});*/ |
| 982 | 135 |
} |
| 1013 | 136 |
}; |