| author | durandn |
| Fri, 03 Jul 2015 16:59:29 +0200 | |
| changeset 1039 | 4fddc765a716 |
| child 1046 | eb77616c245f |
| permissions | -rw-r--r-- |
|
1039
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
1 |
/* |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
2 |
* Widget that ties AnnotationList and CreateAnnotation together |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
3 |
* using buttons to hide/show AnnotationList and CreateAnnotation widgets. |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
4 |
* |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
5 |
*/ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
6 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
7 |
IriSP.Widgets.AnnotationsController = function(player, config){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
8 |
IriSP.Widgets.Widget.call(this, player, config); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
9 |
}; |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
10 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
11 |
IriSP.Widgets.AnnotationsController.prototype = new IriSP.Widgets.Widget(); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
12 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
13 |
IriSP.Widgets.AnnotationsController.prototype.defaults = { |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
14 |
// If true, displaying AnnotationList will hide CreateAnnotation and vice versa. |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
15 |
display_or_write: false, |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
16 |
starts_hidden: false, |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
17 |
hide_without_segment: false, |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
18 |
segments_annotation_type: "chap" |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
19 |
}; |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
20 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
21 |
IriSP.Widgets.AnnotationsController.prototype.template = |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
22 |
"<div class='Ldt-AnnotationsController'>" |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
23 |
+ "<div class='Ldt-AnnotationsController-ButtonsContainer'>" |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
24 |
+ " <div class='Ldt-AnnotationsController-Button Ldt-AnnotationsController-ShowAnnotationsListButton'>{{l10n.display}}</div>" |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
25 |
+ " <div class='Ldt-AnnotationsController-Button Ldt-AnnotationsController-ShowCreateAnnotationButton'>{{l10n.write}}</div>" |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
26 |
+ "</div>" |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
27 |
+ "</div>" |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
28 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
29 |
IriSP.Widgets.AnnotationsController.prototype.messages = { |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
30 |
en : { |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
31 |
write : "Write", |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
32 |
display : "Display", |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
33 |
}, |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
34 |
fr : { |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
35 |
write : "Ecrire", |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
36 |
display : "Voir" |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
37 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
38 |
}; |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
39 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
40 |
IriSP.Widgets.AnnotationsController.prototype.draw = function() { |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
41 |
this.renderTemplate(); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
42 |
var _this = this; |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
43 |
this.element_$ = this.$.find(".Ldt-AnnotationsController") |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
44 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
45 |
this.displayButton_$ = this.$.find(".Ldt-AnnotationsController-ShowAnnotationsListButton"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
46 |
this.writeButton_$ = this.$.find(".Ldt-AnnotationsController-ShowCreateAnnotationButton"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
47 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
48 |
this.writeButton_$.click(function(){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
49 |
_this.player.trigger("CreateAnnotation.toggle"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
50 |
if (_this.display_or_write){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
51 |
_this.player.trigger("AnnotationsList.hide"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
52 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
53 |
}); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
54 |
this.displayButton_$.click(function(){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
55 |
_this.player.trigger("AnnotationsList.toggle"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
56 |
if (_this.display_or_write){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
57 |
_this.player.trigger("CreateAnnotation.hide"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
58 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
59 |
}) |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
60 |
this.onMediaEvent("timeupdate", "onTimeUpdate") |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
61 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
62 |
if (this.starts_hidden) { |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
63 |
this.visible = true |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
64 |
this.hide(); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
65 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
66 |
else{ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
67 |
this.visible = false |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
68 |
this.show(); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
69 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
70 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
71 |
}; |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
72 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
73 |
IriSP.Widgets.AnnotationsController.prototype.onTimeUpdate = function(){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
74 |
if (this.hide_without_segment){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
75 |
_currentTime = this.media.getCurrentTime() |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
76 |
_segmentsAnnotations = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type) |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
77 |
_currentSegments = _segmentsAnnotations.filter(function(_segment){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
78 |
return (_currentTime >= _segment.begin && _currentTime <= _segment.end) |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
79 |
}); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
80 |
if (_currentSegments.length == 0){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
81 |
if (this.visible){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
82 |
this.hide(); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
83 |
_this.player.trigger("CreateAnnotation.hide"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
84 |
_this.player.trigger("AnnotationsList.hide"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
85 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
86 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
87 |
else { |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
88 |
if (!this.visible){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
89 |
this.show(); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
90 |
_this.player.trigger("CreateAnnotation.hide"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
91 |
_this.player.trigger("AnnotationsList.hide"); |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
92 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
93 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
94 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
95 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
96 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
97 |
IriSP.Widgets.AnnotationsController.prototype.hide = function() { |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
98 |
if (this.visible){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
99 |
this.visible = false; |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
100 |
this.element_$.hide() |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
101 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
102 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
103 |
|
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
104 |
IriSP.Widgets.AnnotationsController.prototype.show = function() { |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
105 |
if(!this.visible){ |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
106 |
this.visible = true; |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
107 |
this.element_$.show() |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
108 |
} |
|
4fddc765a716
New widget AnnotationsController that displays buttons to hide/show AnnotationsList and CreateAnnotations
durandn
parents:
diff
changeset
|
109 |
} |