| author | veltr |
| Fri, 06 Apr 2012 16:49:32 +0200 | |
| branch | popcorn-port |
| changeset 842 | 4ae2247a59f4 |
| parent 841 | 8da49ff273e0 |
| child 852 | eefb64f74a3f |
| permissions | -rw-r--r-- |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
1 |
/* Internationalization for this widget */ |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
2 |
|
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
3 |
IriSP.i18n.addMessages( |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
4 |
{ |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
5 |
"en": { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
6 |
"submit": "Submit", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
7 |
"add_keywords": "Add keywords", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
8 |
"add_polemic_keywords": "Add polemic keywords", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
9 |
"your_name": "Your name", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
10 |
"type_here": "Type your annotation here.", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
11 |
"wait_while_processed": "Please wait while your request is being processed...", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
12 |
"error_while_contacting": "An error happened while contacting the server. Your annotation has not been saved.", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
13 |
"empty_annotation": "Your annotation is empty. Please write something before submitting.", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
14 |
"annotation_saved": "Thank you, your annotation has been saved.", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
15 |
"share_annotation": "Would you like to share it on social networks ?", |
| 841 | 16 |
"share_on": "Share on", |
| 842 | 17 |
"more_tags": "More tags" |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
18 |
}, |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
19 |
"fr": { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
20 |
"submit": "Envoyer", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
21 |
"add_keywords": "Ajouter des mots-clés", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
22 |
"add_polemic_keywords": "Ajouter des mots-clés polémiques", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
23 |
"your_name": "Votre nom", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
24 |
"type_here": "Rédigez votre annotation ici.", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
25 |
"wait_while_processed": "Veuillez patienter pendant le traitement de votre requête...", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
26 |
"error_while_contacting": "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
27 |
"empty_annotation": "Votre annotation est vide. Merci de rédiger un texte avant de l'envoyer.", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
28 |
"annotation_saved": "Merci, votre annotation a été enregistrée.", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
29 |
"share_annotation": "Souhaitez-vous la partager sur les réseaux sociaux ?", |
| 841 | 30 |
"share_on": "Partager sur", |
| 842 | 31 |
"more_tags": "Plus de mots-clés" |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
32 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
33 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
34 |
); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
35 |
|
| 543 | 36 |
IriSP.createAnnotationWidget = function(Popcorn, config, Serializer) { |
37 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
38 |
this._hidden = true; |
|
| 830 | 39 |
|
40 |
if (!IriSP.null_or_undefined(IriSP.user)) { |
|
41 |
if (!IriSP.null_or_undefined(IriSP.user.avatar)) { |
|
42 |
this.user_avatar = IriSP.user.avatar; |
|
43 |
} |
|
44 |
if (!IriSP.null_or_undefined(IriSP.user.name)) { |
|
45 |
this.user_name = IriSP.user.name; |
|
46 |
} |
|
47 |
} |
|
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
48 |
|
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
49 |
/* variables to save the current position of the slicer */ |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
50 |
if (this.cinecast_version) { |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
51 |
this.sliceLeft = 0; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
52 |
this.sliceWidth = 0; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
53 |
} |
| 543 | 54 |
}; |
55 |
||
56 |
||
57 |
IriSP.createAnnotationWidget.prototype = new IriSP.Widget(); |
|
58 |
||
59 |
IriSP.createAnnotationWidget.prototype.clear = function() { |
|
60 |
this.selector.find(".Ldt-SaTitle").text(""); |
|
61 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
62 |
this.selector.find(".Ldt-SaKeywordText").text(""); |
|
63 |
}; |
|
64 |
||
65 |
IriSP.createAnnotationWidget.prototype.draw = function() { |
|
| 841 | 66 |
var _this = this; |
| 842 | 67 |
if (typeof this.remote_tags == "object") { |
68 |
IriSP.jQuery.getJSON((typeof this.remote_tags.alias == "string" ? this.remote_tags.alias : this.remote_tags.url), function(_json) { |
|
69 |
_this.tags = _json.tags; |
|
| 841 | 70 |
_this.drawCallback(); |
71 |
}); |
|
72 |
} else { |
|
73 |
this.drawCallback(); |
|
74 |
} |
|
75 |
} |
|
76 |
||
77 |
IriSP.createAnnotationWidget.prototype.drawCallback = function() { |
|
| 543 | 78 |
var _this = this; |
|
762
5497895a3ddb
if the platform has defined an user avatar, use it when submitting the annotation.
hamidouk
parents:
759
diff
changeset
|
79 |
|
| 718 | 80 |
var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template, |
| 830 | 81 |
this); |
|
553
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
82 |
|
| 543 | 83 |
this.selector.append(annotationMarkup); |
| 548 | 84 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
85 |
if (!this.cinecast_version) |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
86 |
this.selector.hide(); |
|
817
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
87 |
else { |
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
88 |
this.showStartScreen(); |
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
89 |
} |
| 841 | 90 |
|
| 842 | 91 |
if (this.random_tags) { |
| 841 | 92 |
this.selector.find(".Ldt-createAnnotation-keywords li").hide(); |
| 842 | 93 |
this.showMoreTags(); |
| 841 | 94 |
this.selector.find('.Ldt-createAnnotation-moar-keywordz').click(function() { |
| 842 | 95 |
_this.showMoreTags(); |
| 841 | 96 |
}) |
97 |
} |
|
| 830 | 98 |
// Add onclick event to both polemic and keywords buttons |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
99 |
|
| 841 | 100 |
this.selector.find(".Ldt-createAnnotation-keyword-button, .Ldt-createAnnotation-polemic-button").click(function() { |
| 830 | 101 |
_this.addKeyword(IriSP.jQuery(this).text()); |
| 841 | 102 |
return false; |
| 830 | 103 |
}); |
| 548 | 104 |
|
| 799 | 105 |
// js_mod is a custom event because there's no simple way to test for a js |
106 |
// change in a textfield. |
|
| 549 | 107 |
this.selector.find(".Ldt-createAnnotation-Description") |
| 842 | 108 |
.bind("propertychange keyup input paste click js_mod", IriSP.wrap(this, this.handleTextChanges)) |
109 |
.keyup(function(_e) { |
|
110 |
console.log(_e); |
|
111 |
}); |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
112 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
113 |
/* the cinecast version of the player is supposed to pause when the user clicks on the button */ |
| 833 | 114 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
115 |
/* the cinecast version expects the user to comment on a defined segment. |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
116 |
As the widget is always shown, we need a way to update it's content as |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
117 |
time passes. We do this like we did with the annotationsWidget : we schedule |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
118 |
a .code start function which will be called at the right time. |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
119 |
*/ |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
120 |
if (this.cinecast_version) { |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
121 |
var legal_ids; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
122 |
if (typeof(this._serializer.getChapitrage()) !== "undefined") |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
123 |
legal_id = this._serializer.getChapitrage(); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
124 |
else |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
125 |
legal_id = this._serializer.getNonTweetIds()[0]; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
126 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
127 |
var annotations = this._serializer._data.annotations; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
128 |
var i; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
129 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
130 |
for (i in annotations) { |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
131 |
var annotation = annotations[i]; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
132 |
if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
133 |
&& legal_id !== annotation.meta["id-ref"]) { |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
134 |
continue; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
135 |
} |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
136 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
137 |
code = {start: annotation.begin / 1000, end: annotation.end / 1000, |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
138 |
onStart: function(annotation) { return function() { |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
139 |
if (typeof(annotation.content) !== "undefined") |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
140 |
_this.selector.find(".Ldt-createAnnotation-Title").html(annotation.content.title); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
141 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
142 |
_this._currentAnnotation = annotation; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
143 |
var beginTime = IriSP.msToTime(annotation.begin); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
144 |
var endTime = IriSP.msToTime(annotation.end); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
145 |
var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime }); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
146 |
_this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
147 |
} }(annotation) |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
148 |
}; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
149 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
150 |
this._Popcorn.code(code); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
151 |
} |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
152 |
} |
| 543 | 153 |
|
|
553
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
154 |
this.selector.find(".Ldt-createAnnotation-submitButton").click(IriSP.wrap(this, this.handleButtonClick)); |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
155 |
|
| 721 | 156 |
if (!this.cinecast_version) { |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
157 |
this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", |
| 721 | 158 |
IriSP.wrap(this, this.handleAnnotateSignal)); |
159 |
|
|
160 |
// handle clicks on the cancel button too. |
|
161 |
this.selector.find(".Ldt-createAnnotation-Minimize").click(IriSP.wrap(this, |
|
162 |
function() { |
|
163 |
// we've got to simulate the pressing of the button because there's no |
|
164 |
// other way to minimize the widget and show the widgets that were hidden |
|
165 |
// same time |
|
166 |
this._Popcorn.trigger("IriSP.PlayerWidget.AnnotateButton.clicked"); |
|
167 |
} |
|
168 |
)); |
|
169 |
} |
|
| 543 | 170 |
}; |
171 |
||
| 842 | 172 |
IriSP.createAnnotationWidget.prototype.showMoreTags = function() { |
173 |
for (var j=0; j < this.random_tags; j++) { |
|
| 841 | 174 |
var _jq = this.selector.find(".Ldt-createAnnotation-keywords li:hidden"); |
175 |
if (_jq.length > 1) { |
|
176 |
IriSP.jQuery(_jq[Math.floor(_jq.length*Math.random())]).show(); |
|
177 |
} else { |
|
178 |
_jq.show(); |
|
179 |
break; |
|
180 |
} |
|
181 |
} |
|
182 |
if (this.selector.find(".Ldt-createAnnotation-keywords li:hidden").length == 0) { |
|
183 |
this.selector.find('.Ldt-createAnnotation-moar-keywordz').hide(); |
|
184 |
} |
|
185 |
} |
|
186 |
||
| 830 | 187 |
/* Handles adding keywords and polemics */ |
188 |
IriSP.createAnnotationWidget.prototype.addKeyword = function(_keyword) { |
|
189 |
var _field = this.selector.find(".Ldt-createAnnotation-Description"), |
|
190 |
_rx = IriSP.regexpFromText(_keyword), |
|
191 |
_contents = _field.val(); |
|
192 |
_contents = ( _rx.test(_contents) |
|
193 |
? _contents.replace(_rx,"").replace(" "," ").trim() |
|
194 |
: _contents.trim() + " " + _keyword |
|
195 |
); |
|
| 841 | 196 |
_field.val(_contents.trim()); |
| 830 | 197 |
_field.trigger("js_mod"); |
198 |
} |
|
199 |
||
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
200 |
/** handles clicks on the annotate button. Works only for the non-cinecast version */ |
| 543 | 201 |
IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() { |
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
202 |
|
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
203 |
if (this._hidden == false && this._state == 'startScreen') { |
| 543 | 204 |
this.selector.hide(); |
205 |
this._hidden = true; |
|
| 570 | 206 |
|
207 |
// free the arrow. |
|
208 |
this._Popcorn.trigger("IriSP.ArrowWidget.releaseArrow"); |
|
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
209 |
this._Popcorn.trigger("IriSP.SliceWidget.hide"); |
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
210 |
this._Popcorn.trigger("IriSP.AnnotationsWidget.show"); |
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
211 |
|
| 543 | 212 |
} else { |
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
213 |
this._Popcorn.trigger("IriSP.AnnotationsWidget.hide"); |
|
817
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
214 |
this.showStartScreen(); |
| 543 | 215 |
this.selector.show(); |
216 |
this._hidden = false; |
|
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
217 |
var currentTime = this._Popcorn.currentTime(); |
| 563 | 218 |
|
219 |
// block the arrow. |
|
220 |
this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow"); |
|
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
221 |
|
| 842 | 222 |
var duration = this.getDuration(); |
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
223 |
|
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
224 |
var currentChapter = this._serializer.currentChapitre(currentTime); |
|
779
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
225 |
|
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
226 |
if (IriSP.null_or_undefined(currentChapter)) { |
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
227 |
var left = this.selector.width() / 2; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
228 |
var width = this.selector.width() / 10; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
229 |
} else { |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
230 |
var left = (currentChapter.begin / duration) * this.selector.width(); |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
231 |
var width = (currentChapter.end / duration) * this.selector.width() - left; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
232 |
} |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
233 |
|
|
779
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
234 |
// slider position and length is kept in percents. |
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
235 |
this.sliceLeft = (left / this.selector.width()) * 100; |
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
236 |
this.sliceWidth = (width / this.selector.width()) * 100; |
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
237 |
|
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
238 |
this._Popcorn.trigger("IriSP.SliceWidget.position", [left, width]); |
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
239 |
this._Popcorn.listen("IriSP.SliceWidget.zoneChange", IriSP.wrap(this, this.handleSliderChanges)); |
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
240 |
this._Popcorn.trigger("IriSP.SliceWidget.show"); |
| 722 | 241 |
|
| 776 | 242 |
if (!IriSP.null_or_undefined(currentChapter)) { |
243 |
this.selector.find(".Ldt-createAnnotation-Title").html(currentChapter.content.title); |
|
| 722 | 244 |
|
| 776 | 245 |
this._currentcurrentChapter = currentChapter; |
246 |
var beginTime = IriSP.msToTime(currentChapter.begin); |
|
247 |
var endTime = IriSP.msToTime(currentChapter.end); |
|
248 |
var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime }); |
|
249 |
this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate); |
|
250 |
} |
|
| 543 | 251 |
} |
| 549 | 252 |
}; |
253 |
||
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
254 |
|
| 549 | 255 |
/** watch for changes in the textfield and change the buttons accordingly */ |
256 |
IriSP.createAnnotationWidget.prototype.handleTextChanges = function(event) { |
|
257 |
var contents = this.selector.find(".Ldt-createAnnotation-Description").val(); |
|
| 841 | 258 |
if (this.cinecast_version) { |
| 833 | 259 |
this._Popcorn.pause(); |
260 |
} |
|
| 831 | 261 |
this.selector.find(".Ldt-createAnnotation-btnblock button").each(function() { |
| 830 | 262 |
var _rx = IriSP.regexpFromText(IriSP.jQuery(this).text()); |
263 |
if (_rx.test(contents)) { |
|
| 831 | 264 |
IriSP.jQuery(this).parent().addClass("Ldt-createAnnotation-active-button"); |
| 830 | 265 |
} else { |
| 831 | 266 |
IriSP.jQuery(this).parent().removeClass("Ldt-createAnnotation-active-button"); |
| 549 | 267 |
} |
| 830 | 268 |
}); |
| 831 | 269 |
|
|
553
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
270 |
}; |
|
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
271 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
272 |
IriSP.createAnnotationWidget.prototype.showStartScreen = function() { |
| 831 | 273 |
this.selector.find(".Ldt-createAnnotation-screen").hide(); |
|
627
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
274 |
this.selector.find(".Ldt-createAnnotation-startScreen").show(); |
|
817
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
275 |
|
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
276 |
var jqTextfield = this.selector.find(".Ldt-createAnnotation-Description"); // handle on the textfield. used for the closure |
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
277 |
|
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
278 |
/* test if the browser supports the placeholder attribute */ |
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
279 |
if (!IriSP.null_or_undefined(jqTextfield.get(0).placeholder)) { |
| 837 | 280 |
jqTextfield.attr("placeholder", IriSP.i18n.getMessage('type_here')); |
|
817
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
281 |
} else { |
| 837 | 282 |
jqTextfield.val(IriSP.i18n.getMessage('type_here')); |
|
817
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
283 |
jqTextfield.one("click", IriSP.wrap(this, function() { jqTextfield.val(""); })); |
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
284 |
} |
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
285 |
|
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
286 |
|
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
287 |
|
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
288 |
this._state = "startScreen"; |
|
627
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
289 |
}; |
|
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
290 |
|
|
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
291 |
IriSP.createAnnotationWidget.prototype.showWaitScreen = function() { |
| 831 | 292 |
this.selector.find(".Ldt-createAnnotation-screen").hide(); |
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
293 |
this.selector.find(".Ldt-createAnnotation-waitScreen").show(); |
|
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
294 |
this._state = "waitScreen"; |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
295 |
}; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
296 |
|
| 769 | 297 |
IriSP.createAnnotationWidget.prototype.showErrorScreen = function() { |
| 831 | 298 |
this.selector.find(".Ldt-createAnnotation-screen").hide(); |
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
299 |
this.selector.find(".Ldt-createAnnotation-errorScreen").show(); |
|
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
300 |
this._state = "errorScreen"; |
| 832 | 301 |
var _this = this; |
302 |
window.setTimeout(function() { _this.showStartScreen(); }, 2000); |
|
| 769 | 303 |
}; |
304 |
||
305 |
/** update show the final screen with links to share the created annotation */ |
|
| 651 | 306 |
IriSP.createAnnotationWidget.prototype.showEndScreen = function(annotation) { |
| 831 | 307 |
this.selector.find(".Ldt-createAnnotation-screen").hide(); |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
308 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
309 |
if (this.cinecast_version) { |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
310 |
this.selector.find(".Ldt-createAnnotation-Title").parent().show(); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
311 |
} |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
312 |
|
| 836 | 313 |
var url = ( (typeof annotation.meta == "object" && typeof annotation.meta.url == "string" && annotation.meta.url.length) |
314 |
? annotation.meta.url |
|
315 |
: ( document.location.href + "#id=" + annotation.id ) ); |
|
| 651 | 316 |
var twStatus = IriSP.mkTweetUrl(url); |
317 |
var gpStatus = IriSP.mkGplusUrl(url); |
|
318 |
var fbStatus = IriSP.mkFbUrl(url); |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
319 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
320 |
this.selector.find(".Ldt-createAnnotation-endScreen-TweetLink").attr("href", twStatus); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
321 |
this.selector.find(".Ldt-createAnnotation-endScreen-FbLink").attr("href", fbStatus); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
322 |
this.selector.find(".Ldt-createAnnotation-endScreen-GplusLink").attr("href", gpStatus); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
323 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
324 |
this.selector.find(".Ldt-createAnnotation-endScreen").show(); |
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
325 |
this._state = "endScreen"; |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
326 |
}; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
327 |
|
|
553
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
328 |
/** handle clicks on "send annotation" button */ |
|
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
329 |
IriSP.createAnnotationWidget.prototype.handleButtonClick = function(event) { |
| 597 | 330 |
var _this = this; |
|
561
a10e7b6fdb08
display an error message when the user forget to enter text.
hamidouk
parents:
553
diff
changeset
|
331 |
var textfield = this.selector.find(".Ldt-createAnnotation-Description"); |
|
a10e7b6fdb08
display an error message when the user forget to enter text.
hamidouk
parents:
553
diff
changeset
|
332 |
var contents = textfield.val(); |
| 830 | 333 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
334 |
if (contents === "") { |
| 570 | 335 |
if (this.selector.find(".Ldt-createAnnotation-errorMessage").length === 0) { |
336 |
this.selector.find(".Ldt-createAnnotation-Container") |
|
337 |
.after(IriSP.templToHTML(IriSP.createAnnotation_errorMessage_template)); |
|
| 571 | 338 |
textfield.css("background-color", "#d93c71"); |
| 769 | 339 |
} else { |
| 571 | 340 |
this.selector.find(".Ldt-createAnnotation-errorMessage").show(); |
341 |
} |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
342 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
343 |
textfield.one("js_mod propertychange keyup input paste", IriSP.wrap(this, function() { |
| 570 | 344 |
var contents = textfield.val(); |
| 611 | 345 |
|
| 570 | 346 |
if (contents !== "") { |
347 |
this.selector.find(".Ldt-createAnnotation-errorMessage").hide(); |
|
348 |
textfield.css("background-color", ""); |
|
349 |
} |
|
350 |
})); |
|
|
561
a10e7b6fdb08
display an error message when the user forget to enter text.
hamidouk
parents:
553
diff
changeset
|
351 |
} else { |
|
627
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
352 |
this.showWaitScreen(); |
|
594
96af41097260
WIP - adapting the widget to the new segments conventions.
hamidouk
parents:
575
diff
changeset
|
353 |
|
| 678 | 354 |
this.sendLdtData(contents, function(annotation) { |
| 683 | 355 |
if (_this.cinecast_version) { |
356 |
if (_this._Popcorn.media.paused) |
|
357 |
_this._Popcorn.play(); |
|
358 |
} |
|
|
630
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
359 |
|
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
360 |
if (_this._state == "waitScreen") { |
|
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
361 |
_this.showEndScreen(annotation); |
|
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
362 |
if (_this.cinecast_version) { |
| 832 | 363 |
window.setTimeout(function() { _this.showStartScreen(); }, 5000); |
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
364 |
} |
| 683 | 365 |
} |
366 |
// hide the slicer widget |
|
367 |
if (!_this.cinecast_version) { |
|
368 |
_this._Popcorn.trigger("IriSP.SliceWidget.hide"); |
|
369 |
} |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
370 |
}); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
371 |
} |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
372 |
}; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
373 |
|
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
374 |
IriSP.createAnnotationWidget.prototype.handleSliderChanges = function(params) { |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
375 |
this.sliceLeft = params[0]; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
376 |
this.sliceWidth = params[1]; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
377 |
}; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
378 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
379 |
IriSP.createAnnotationWidget.prototype.sendLdtData = function(contents, callback) { |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
380 |
var _this = this; |
| 842 | 381 |
var apiJson = { |
382 |
format : "http://advene.org/ns/cinelab/", |
|
383 |
annotations : [ |
|
384 |
{} |
|
385 |
], |
|
386 |
meta: {}}; |
|
| 836 | 387 |
var annotation = apiJson.annotations[0]; |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
388 |
|
| 842 | 389 |
annotation.media = this.currentMedia()["id"]; |
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
390 |
|
| 678 | 391 |
if (this.cinecast_version) { |
| 836 | 392 |
annotation.begin = Math.round(this._Popcorn.currentTime() * 1000); |
393 |
annotation.end = annotation.begin; |
|
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
394 |
} else { |
| 842 | 395 |
var duration = this.getDuration(); |
| 836 | 396 |
annotation.begin = +((duration * (this.sliceLeft / 100)).toFixed(0)); |
397 |
annotation.end = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0)); |
|
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
398 |
} |
|
779
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
399 |
|
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
400 |
// boundary checks |
| 836 | 401 |
annotation.begin = Math.max(0, annotation.begin); |
| 842 | 402 |
annotation.end = Math.min(this.getDuration(), annotation.end); |
| 645 | 403 |
|
| 836 | 404 |
annotation.type = ( this.cinecast_version ? "cinecast:UserAnnotation" : ( this._serializer.getContributions() || "" )); |
405 |
if (typeof(annotation.type) === "undefined") |
|
406 |
annotation.type = ""; |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
407 |
|
| 836 | 408 |
annotation.type_title = "Contributions"; |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
409 |
annotation.content = {}; |
| 836 | 410 |
annotation.content.data = contents; |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
411 |
if (this.cinecast_version) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
412 |
var _extract = IriSP.underscore(this._serializer._data.annotations) |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
413 |
.filter(function(_a) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
414 |
return (_a.begin <= annotation.begin && _a.end >= annotation.begin && _a.type == "cinecast:MovieExtract"); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
415 |
}) |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
416 |
if (_extract.length) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
417 |
annotation.extract = _extract[0].id; |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
418 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
419 |
} |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
420 |
|
| 836 | 421 |
var meta = apiJson.meta; |
| 830 | 422 |
|
423 |
|
|
424 |
var _username = this.selector.find(".Ldt-createAnnotation-userName").val(); |
|
425 |
meta.creator = ( |
|
426 |
(_username && _username.length) |
|
427 |
? _username |
|
428 |
: ( |
|
429 |
(!IriSP.null_or_undefined(IriSP.user) && !IriSP.null_or_undefined(IriSP.user.name)) |
|
430 |
? IriSP.user.name |
|
431 |
: "Anonymous user" |
|
432 |
) |
|
433 |
); |
|
|
759
4dc3240f2c56
send the correct username if the user is loggedin on the platform.
hamidouk
parents:
722
diff
changeset
|
434 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
435 |
meta.created = Date().toString(); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
436 |
|
| 842 | 437 |
var _tags = []; |
438 |
IriSP._(this.tags).each(function(_v) { |
|
439 |
var _rx = IriSP.regexpFromText(_v.meta.description); |
|
| 841 | 440 |
if (_rx.test(contents)) { |
| 842 | 441 |
_tags.push(_v.id); |
| 841 | 442 |
} |
443 |
}); |
|
| 842 | 444 |
|
445 |
if (typeof this.remote_tags == "object") { |
|
446 |
_tags = IriSP._(_tags).map(function(_t) { |
|
447 |
return _this.remote_tags.id + ':' + _t |
|
448 |
}); |
|
449 |
if (typeof apiJson.imports == "undefined") { |
|
450 |
apiJson.imports = []; |
|
451 |
} |
|
452 |
apiJson.imports.push({ |
|
453 |
"id" : this.remote_tags.id, |
|
454 |
"url" : this.remote_tags.url |
|
455 |
}) |
|
456 |
} |
|
| 841 | 457 |
annotation.tags = IriSP.underscore.uniq(_tags); |
458 |
|
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
459 |
var jsonString = JSON.stringify(apiJson); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
460 |
var project_id = this._serializer._data.meta.id; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
461 |
|
|
797
8407313c144f
correct url for annotations + null data on serializer
ymh <ymh.work@gmail.com>
parents:
779
diff
changeset
|
462 |
//TODO: extract magic url |
|
814
9abad8fe5207
get the annotation creation api endpoint from the settings instead of
hamidouk
parents:
807
diff
changeset
|
463 |
var url = Mustache.to_html(this.api_endpoint_template, |
|
9abad8fe5207
get the annotation creation api endpoint from the settings instead of
hamidouk
parents:
807
diff
changeset
|
464 |
{id: project_id}); |
|
627
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
465 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
466 |
IriSP.jQuery.ajax({ |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
467 |
url: url, |
| 830 | 468 |
type: this.api_method, |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
469 |
contentType: 'application/json', |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
470 |
data: jsonString, |
| 626 | 471 |
//dataType: 'json', |
|
630
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
472 |
success: IriSP.wrap(this, function(json, textStatus, XMLHttpRequest) { |
|
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
473 |
/* add the annotation to the annotation and tell the world */ |
| 840 | 474 |
var annotation = json.annotations[0]; |
475 |
|
|
476 |
if (!this.cinecast_version) { |
|
|
630
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
477 |
/* if the media doesn't have a contributions line, we need to add one */ |
| 836 | 478 |
if (typeof(this._serializer.getContributions()) === "undefined") { |
479 |
/* set up a basic view */ |
|
480 |
var tmp_view = {"dc:contributor": "perso", "dc:creator": "perso", "dc:title": "Contributions", |
|
481 |
"id": json.annotations[0].type} |
|
482 |
|
|
483 |
|
|
484 |
IriSP.get_aliased(this._serializer._data, ["annotation_types", "annotation-types"]).push(tmp_view); |
|
485 |
} |
|
486 |
|
|
487 |
delete annotation.tags; |
|
488 |
annotation.content.description = annotation.content.data; |
|
489 |
annotation.content.title = ""; |
|
490 |
delete annotation.content.data; |
|
491 |
annotation.id = json.annotations[0].id; |
|
492 |
|
|
493 |
annotation.meta = meta; |
|
494 |
annotation.meta["id-ref"] = json.annotations[0]["type"]; |
|
| 841 | 495 |
} else { |
496 |
annotation.type = "cinecast:UserAnnotation"; |
|
|
630
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
497 |
} |
| 841 | 498 |
annotation.is_new = true; |
| 597 | 499 |
// everything is shared so there's no need to propagate the change |
500 |
_this._serializer._data.annotations.push(annotation); |
|
| 651 | 501 |
|
| 643 | 502 |
_this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation", annotation); |
| 842 | 503 |
this.selector.find(".Ldt-createAnnotation-Description").val(""); |
| 651 | 504 |
callback(annotation); |
|
630
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
505 |
}), |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
506 |
error: |
| 626 | 507 |
function(jqXHR, textStatus, errorThrown) { |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
508 |
console.log("an error occured while contacting " |
| 769 | 509 |
+ url + " and sending " + jsonString + textStatus ); |
510 |
_this.showErrorScreen(); } }); |
|
| 543 | 511 |
}; |