| author | veltr |
| Fri, 30 Mar 2012 18:00:26 +0200 | |
| branch | popcorn-port |
| changeset 840 | ac66e2240e1e |
| parent 838 | 03b03865eb9b |
| child 841 | 8da49ff273e0 |
| 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 ?", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
16 |
"share_on": "Share on" |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
17 |
}, |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
18 |
"fr": { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
19 |
"submit": "Envoyer", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
20 |
"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
|
21 |
"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
|
22 |
"your_name": "Votre nom", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
23 |
"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
|
24 |
"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
|
25 |
"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
|
26 |
"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
|
27 |
"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
|
28 |
"share_annotation": "Souhaitez-vous la partager sur les réseaux sociaux ?", |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
29 |
"share_on": "Partager sur" |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
30 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
31 |
} |
|
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 |
|
| 543 | 34 |
IriSP.createAnnotationWidget = function(Popcorn, config, Serializer) { |
35 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
36 |
this._hidden = true; |
|
| 718 | 37 |
|
| 830 | 38 |
this.checkOption("keywords"); |
39 |
this.checkOption("polemic_mode", true); |
|
40 |
this.checkOption("polemics"); |
|
41 |
this.checkOption("cinecast_version", false); |
|
42 |
this.checkOption("api_endpoint_template"); |
|
43 |
this.checkOption("show_from_field", true); |
|
44 |
this.checkOption("api_method"); |
|
45 |
|
|
46 |
if (!IriSP.null_or_undefined(IriSP.user)) { |
|
47 |
if (!IriSP.null_or_undefined(IriSP.user.avatar)) { |
|
48 |
this.user_avatar = IriSP.user.avatar; |
|
49 |
} |
|
50 |
if (!IriSP.null_or_undefined(IriSP.user.name)) { |
|
51 |
this.user_name = IriSP.user.name; |
|
52 |
} |
|
53 |
} |
|
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
54 |
|
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
55 |
/* 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
|
56 |
if (this.cinecast_version) { |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
57 |
this.sliceLeft = 0; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
58 |
this.sliceWidth = 0; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
59 |
} |
| 543 | 60 |
}; |
61 |
||
62 |
||
63 |
IriSP.createAnnotationWidget.prototype = new IriSP.Widget(); |
|
64 |
||
65 |
IriSP.createAnnotationWidget.prototype.clear = function() { |
|
66 |
this.selector.find(".Ldt-SaTitle").text(""); |
|
67 |
this.selector.find(".Ldt-SaDescription").text(""); |
|
68 |
this.selector.find(".Ldt-SaKeywordText").text(""); |
|
69 |
}; |
|
70 |
||
71 |
IriSP.createAnnotationWidget.prototype.draw = function() { |
|
72 |
var _this = this; |
|
|
762
5497895a3ddb
if the platform has defined an user avatar, use it when submitting the annotation.
hamidouk
parents:
759
diff
changeset
|
73 |
|
| 718 | 74 |
var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template, |
| 830 | 75 |
this); |
|
553
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
76 |
|
| 543 | 77 |
this.selector.append(annotationMarkup); |
| 548 | 78 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
79 |
if (!this.cinecast_version) |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
80 |
this.selector.hide(); |
|
817
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
81 |
else { |
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
82 |
this.showStartScreen(); |
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
83 |
} |
| 830 | 84 |
|
85 |
// 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
|
86 |
|
| 831 | 87 |
this.selector.find(".Ldt-createAnnotation-btnblock button").click(function() { |
| 830 | 88 |
_this.addKeyword(IriSP.jQuery(this).text()); |
89 |
}); |
|
| 548 | 90 |
|
| 799 | 91 |
// js_mod is a custom event because there's no simple way to test for a js |
92 |
// change in a textfield. |
|
| 549 | 93 |
this.selector.find(".Ldt-createAnnotation-Description") |
| 799 | 94 |
.bind("propertychange keyup input paste js_mod", IriSP.wrap(this, this.handleTextChanges)); |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
95 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
96 |
/* the cinecast version of the player is supposed to pause when the user clicks on the button */ |
| 833 | 97 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
98 |
/* 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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
*/ |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
103 |
if (this.cinecast_version) { |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
104 |
var legal_ids; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
105 |
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
|
106 |
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
|
107 |
else |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
108 |
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
|
109 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
110 |
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
|
111 |
var i; |
|
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 |
for (i in annotations) { |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
114 |
var annotation = annotations[i]; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
115 |
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
|
116 |
&& 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
|
117 |
continue; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
118 |
} |
|
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 |
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
|
121 |
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
|
122 |
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
|
123 |
_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
|
124 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
125 |
_this._currentAnnotation = annotation; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
126 |
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
|
127 |
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
|
128 |
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
|
129 |
_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
|
130 |
} }(annotation) |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
131 |
}; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
132 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
133 |
this._Popcorn.code(code); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
134 |
} |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
135 |
} |
| 543 | 136 |
|
|
553
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
137 |
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
|
138 |
|
| 721 | 139 |
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
|
140 |
this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", |
| 721 | 141 |
IriSP.wrap(this, this.handleAnnotateSignal)); |
142 |
|
|
143 |
// handle clicks on the cancel button too. |
|
144 |
this.selector.find(".Ldt-createAnnotation-Minimize").click(IriSP.wrap(this, |
|
145 |
function() { |
|
146 |
// we've got to simulate the pressing of the button because there's no |
|
147 |
// other way to minimize the widget and show the widgets that were hidden |
|
148 |
// same time |
|
149 |
this._Popcorn.trigger("IriSP.PlayerWidget.AnnotateButton.clicked"); |
|
150 |
} |
|
151 |
)); |
|
152 |
} |
|
| 543 | 153 |
}; |
154 |
||
| 830 | 155 |
/* Handles adding keywords and polemics */ |
156 |
IriSP.createAnnotationWidget.prototype.addKeyword = function(_keyword) { |
|
157 |
var _field = this.selector.find(".Ldt-createAnnotation-Description"), |
|
158 |
_rx = IriSP.regexpFromText(_keyword), |
|
159 |
_contents = _field.val(); |
|
160 |
_contents = ( _rx.test(_contents) |
|
161 |
? _contents.replace(_rx,"").replace(" "," ").trim() |
|
162 |
: _contents.trim() + " " + _keyword |
|
163 |
); |
|
164 |
_field.val(_contents); |
|
165 |
_field.trigger("js_mod"); |
|
166 |
} |
|
167 |
||
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
168 |
/** handles clicks on the annotate button. Works only for the non-cinecast version */ |
| 543 | 169 |
IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() { |
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
170 |
|
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
171 |
if (this._hidden == false && this._state == 'startScreen') { |
| 543 | 172 |
this.selector.hide(); |
173 |
this._hidden = true; |
|
| 570 | 174 |
|
175 |
// free the arrow. |
|
176 |
this._Popcorn.trigger("IriSP.ArrowWidget.releaseArrow"); |
|
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
177 |
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
|
178 |
this._Popcorn.trigger("IriSP.AnnotationsWidget.show"); |
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
179 |
|
| 543 | 180 |
} else { |
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
181 |
this._Popcorn.trigger("IriSP.AnnotationsWidget.hide"); |
|
817
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
182 |
this.showStartScreen(); |
| 543 | 183 |
this.selector.show(); |
184 |
this._hidden = false; |
|
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
185 |
var currentTime = this._Popcorn.currentTime(); |
| 563 | 186 |
|
187 |
// block the arrow. |
|
188 |
this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow"); |
|
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
189 |
|
|
820
7968346b9689
Added compatibility with cinecast format (with get_aliased)
veltr
parents:
817
diff
changeset
|
190 |
var duration = this._serializer.getDuration(); |
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
191 |
|
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
192 |
var currentChapter = this._serializer.currentChapitre(currentTime); |
|
779
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
193 |
|
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
194 |
if (IriSP.null_or_undefined(currentChapter)) { |
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
195 |
var left = this.selector.width() / 2; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
196 |
var width = this.selector.width() / 10; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
197 |
} else { |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
198 |
var left = (currentChapter.begin / duration) * this.selector.width(); |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
199 |
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
|
200 |
} |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
201 |
|
|
779
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
202 |
// slider position and length is kept in percents. |
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
203 |
this.sliceLeft = (left / this.selector.width()) * 100; |
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
204 |
this.sliceWidth = (width / this.selector.width()) * 100; |
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
205 |
|
|
620
fe981f0aab71
automatically position and show the sliceWidget under the current chapter.
hamidouk
parents:
616
diff
changeset
|
206 |
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
|
207 |
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
|
208 |
this._Popcorn.trigger("IriSP.SliceWidget.show"); |
| 722 | 209 |
|
| 776 | 210 |
if (!IriSP.null_or_undefined(currentChapter)) { |
211 |
this.selector.find(".Ldt-createAnnotation-Title").html(currentChapter.content.title); |
|
| 722 | 212 |
|
| 776 | 213 |
this._currentcurrentChapter = currentChapter; |
214 |
var beginTime = IriSP.msToTime(currentChapter.begin); |
|
215 |
var endTime = IriSP.msToTime(currentChapter.end); |
|
216 |
var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime }); |
|
217 |
this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate); |
|
218 |
} |
|
| 543 | 219 |
} |
| 549 | 220 |
}; |
221 |
||
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
222 |
|
| 549 | 223 |
/** watch for changes in the textfield and change the buttons accordingly */ |
224 |
IriSP.createAnnotationWidget.prototype.handleTextChanges = function(event) { |
|
225 |
var contents = this.selector.find(".Ldt-createAnnotation-Description").val(); |
|
| 833 | 226 |
if (this.cinecast_version && !this._Popcorn.media.paused) { |
227 |
this._Popcorn.pause(); |
|
228 |
} |
|
| 831 | 229 |
this.selector.find(".Ldt-createAnnotation-btnblock button").each(function() { |
| 830 | 230 |
var _rx = IriSP.regexpFromText(IriSP.jQuery(this).text()); |
231 |
if (_rx.test(contents)) { |
|
| 831 | 232 |
IriSP.jQuery(this).parent().addClass("Ldt-createAnnotation-active-button"); |
| 830 | 233 |
} else { |
| 831 | 234 |
IriSP.jQuery(this).parent().removeClass("Ldt-createAnnotation-active-button"); |
| 549 | 235 |
} |
| 830 | 236 |
}); |
| 831 | 237 |
|
|
553
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
238 |
}; |
|
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
239 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
240 |
IriSP.createAnnotationWidget.prototype.showStartScreen = function() { |
| 831 | 241 |
this.selector.find(".Ldt-createAnnotation-screen").hide(); |
|
627
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
242 |
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
|
243 |
|
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
244 |
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
|
245 |
|
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
246 |
/* 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
|
247 |
if (!IriSP.null_or_undefined(jqTextfield.get(0).placeholder)) { |
| 837 | 248 |
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
|
249 |
} else { |
| 837 | 250 |
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
|
251 |
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
|
252 |
} |
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
253 |
|
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
254 |
|
|
e9599ee285ab
implements the most asked for feature ever : placeholder text in the
hamidouk
parents:
814
diff
changeset
|
255 |
|
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
256 |
this._state = "startScreen"; |
|
627
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
257 |
}; |
|
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
258 |
|
|
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
259 |
IriSP.createAnnotationWidget.prototype.showWaitScreen = function() { |
| 831 | 260 |
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
|
261 |
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
|
262 |
this._state = "waitScreen"; |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
263 |
}; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
264 |
|
| 769 | 265 |
IriSP.createAnnotationWidget.prototype.showErrorScreen = function() { |
| 831 | 266 |
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
|
267 |
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
|
268 |
this._state = "errorScreen"; |
| 832 | 269 |
var _this = this; |
270 |
window.setTimeout(function() { _this.showStartScreen(); }, 2000); |
|
| 769 | 271 |
}; |
272 |
||
273 |
/** update show the final screen with links to share the created annotation */ |
|
| 651 | 274 |
IriSP.createAnnotationWidget.prototype.showEndScreen = function(annotation) { |
| 831 | 275 |
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
|
276 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
277 |
if (this.cinecast_version) { |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
278 |
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
|
279 |
} |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
280 |
|
| 836 | 281 |
var url = ( (typeof annotation.meta == "object" && typeof annotation.meta.url == "string" && annotation.meta.url.length) |
282 |
? annotation.meta.url |
|
283 |
: ( document.location.href + "#id=" + annotation.id ) ); |
|
| 651 | 284 |
var twStatus = IriSP.mkTweetUrl(url); |
285 |
var gpStatus = IriSP.mkGplusUrl(url); |
|
286 |
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
|
287 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
288 |
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
|
289 |
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
|
290 |
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
|
291 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
292 |
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
|
293 |
this._state = "endScreen"; |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
294 |
}; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
295 |
|
|
553
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
296 |
/** handle clicks on "send annotation" button */ |
|
10d08f43c534
widget works now more or less like in samuel's crea.
hamidouk
parents:
549
diff
changeset
|
297 |
IriSP.createAnnotationWidget.prototype.handleButtonClick = function(event) { |
| 597 | 298 |
var _this = this; |
|
561
a10e7b6fdb08
display an error message when the user forget to enter text.
hamidouk
parents:
553
diff
changeset
|
299 |
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
|
300 |
var contents = textfield.val(); |
| 830 | 301 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
302 |
if (contents === "") { |
| 570 | 303 |
if (this.selector.find(".Ldt-createAnnotation-errorMessage").length === 0) { |
304 |
this.selector.find(".Ldt-createAnnotation-Container") |
|
305 |
.after(IriSP.templToHTML(IriSP.createAnnotation_errorMessage_template)); |
|
| 571 | 306 |
textfield.css("background-color", "#d93c71"); |
| 769 | 307 |
} else { |
| 571 | 308 |
this.selector.find(".Ldt-createAnnotation-errorMessage").show(); |
309 |
} |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
310 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
311 |
textfield.one("js_mod propertychange keyup input paste", IriSP.wrap(this, function() { |
| 570 | 312 |
var contents = textfield.val(); |
| 611 | 313 |
|
| 570 | 314 |
if (contents !== "") { |
315 |
this.selector.find(".Ldt-createAnnotation-errorMessage").hide(); |
|
316 |
textfield.css("background-color", ""); |
|
317 |
} |
|
318 |
})); |
|
|
561
a10e7b6fdb08
display an error message when the user forget to enter text.
hamidouk
parents:
553
diff
changeset
|
319 |
} else { |
|
627
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
320 |
this.showWaitScreen(); |
|
594
96af41097260
WIP - adapting the widget to the new segments conventions.
hamidouk
parents:
575
diff
changeset
|
321 |
|
| 678 | 322 |
this.sendLdtData(contents, function(annotation) { |
| 683 | 323 |
if (_this.cinecast_version) { |
324 |
if (_this._Popcorn.media.paused) |
|
325 |
_this._Popcorn.play(); |
|
326 |
} |
|
|
630
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
327 |
|
|
778
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
328 |
if (_this._state == "waitScreen") { |
|
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
329 |
_this.showEndScreen(annotation); |
|
8329f476d852
clicking on the annotate button when the annotation creation widget is opened
hamidouk
parents:
776
diff
changeset
|
330 |
if (_this.cinecast_version) { |
| 832 | 331 |
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
|
332 |
} |
| 683 | 333 |
} |
334 |
// hide the slicer widget |
|
335 |
if (!_this.cinecast_version) { |
|
336 |
_this._Popcorn.trigger("IriSP.SliceWidget.hide"); |
|
337 |
} |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
338 |
}); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
339 |
} |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
340 |
}; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
341 |
|
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
342 |
IriSP.createAnnotationWidget.prototype.handleSliderChanges = function(params) { |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
343 |
this.sliceLeft = params[0]; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
344 |
this.sliceWidth = params[1]; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
345 |
}; |
|
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
346 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
347 |
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
|
348 |
var _this = this; |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
349 |
var apiJson = {annotations : [{}], meta: {}}; |
| 836 | 350 |
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
|
351 |
|
| 836 | 352 |
annotation.media = this._serializer.currentMedia()["id"]; |
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
353 |
|
| 678 | 354 |
if (this.cinecast_version) { |
| 836 | 355 |
annotation.begin = Math.round(this._Popcorn.currentTime() * 1000); |
356 |
annotation.end = annotation.begin; |
|
|
623
d8f107938feb
WIP - create custom-sized segments in "normal" (non-cinecast) mode.
hamidouk
parents:
620
diff
changeset
|
357 |
} else { |
|
820
7968346b9689
Added compatibility with cinecast format (with get_aliased)
veltr
parents:
817
diff
changeset
|
358 |
var duration = this._serializer.getDuration(); |
| 836 | 359 |
annotation.begin = +((duration * (this.sliceLeft / 100)).toFixed(0)); |
360 |
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
|
361 |
} |
|
779
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
362 |
|
|
52be94ec8e1c
fixed default slicerWidget position bug. check boundaries of created annotations.
hamidouk
parents:
778
diff
changeset
|
363 |
// boundary checks |
| 836 | 364 |
annotation.begin = Math.max(0, annotation.begin); |
365 |
annotation.end = Math.min(this._serializer.getDuration(), annotation.end); |
|
| 645 | 366 |
|
| 836 | 367 |
annotation.type = ( this.cinecast_version ? "cinecast:UserAnnotation" : ( this._serializer.getContributions() || "" )); |
368 |
if (typeof(annotation.type) === "undefined") |
|
369 |
annotation.type = ""; |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
370 |
|
| 836 | 371 |
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
|
372 |
annotation.content = {}; |
| 836 | 373 |
annotation.content.data = contents; |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
374 |
if (this.cinecast_version) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
375 |
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
|
376 |
.filter(function(_a) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
377 |
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
|
378 |
}) |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
379 |
if (_extract.length) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
380 |
annotation.extract = _extract[0].id; |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
381 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
837
diff
changeset
|
382 |
} |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
383 |
|
| 836 | 384 |
var meta = apiJson.meta; |
| 830 | 385 |
|
386 |
|
|
387 |
var _username = this.selector.find(".Ldt-createAnnotation-userName").val(); |
|
388 |
meta.creator = ( |
|
389 |
(_username && _username.length) |
|
390 |
? _username |
|
391 |
: ( |
|
392 |
(!IriSP.null_or_undefined(IriSP.user) && !IriSP.null_or_undefined(IriSP.user.name)) |
|
393 |
? IriSP.user.name |
|
394 |
: "Anonymous user" |
|
395 |
) |
|
396 |
); |
|
|
759
4dc3240f2c56
send the correct username if the user is loggedin on the platform.
hamidouk
parents:
722
diff
changeset
|
397 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
398 |
meta.created = Date().toString(); |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
399 |
|
| 830 | 400 |
// All #hashtags are added to tags |
| 836 | 401 |
annotation.tags = contents.match(/#[^#\s]+\b/gim) || []; |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
402 |
|
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
403 |
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
|
404 |
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
|
405 |
|
|
797
8407313c144f
correct url for annotations + null data on serializer
ymh <ymh.work@gmail.com>
parents:
779
diff
changeset
|
406 |
//TODO: extract magic url |
|
814
9abad8fe5207
get the annotation creation api endpoint from the settings instead of
hamidouk
parents:
807
diff
changeset
|
407 |
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
|
408 |
{id: project_id}); |
|
627
13b9f14bf49a
added a spinner displayed while submitting an annotation.
hamidouk
parents:
626
diff
changeset
|
409 |
|
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
410 |
IriSP.jQuery.ajax({ |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
411 |
url: url, |
| 830 | 412 |
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
|
413 |
contentType: 'application/json', |
|
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
414 |
data: jsonString, |
| 626 | 415 |
//dataType: 'json', |
|
630
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
416 |
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
|
417 |
/* add the annotation to the annotation and tell the world */ |
| 840 | 418 |
var annotation = json.annotations[0]; |
419 |
|
|
420 |
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
|
421 |
/* if the media doesn't have a contributions line, we need to add one */ |
| 836 | 422 |
if (typeof(this._serializer.getContributions()) === "undefined") { |
423 |
/* set up a basic view */ |
|
424 |
var tmp_view = {"dc:contributor": "perso", "dc:creator": "perso", "dc:title": "Contributions", |
|
425 |
"id": json.annotations[0].type} |
|
426 |
|
|
427 |
|
|
428 |
IriSP.get_aliased(this._serializer._data, ["annotation_types", "annotation-types"]).push(tmp_view); |
|
429 |
} |
|
430 |
|
|
431 |
delete annotation.tags; |
|
432 |
annotation.content.description = annotation.content.data; |
|
433 |
annotation.content.title = ""; |
|
434 |
delete annotation.content.data; |
|
435 |
annotation.id = json.annotations[0].id; |
|
436 |
|
|
437 |
annotation.meta = meta; |
|
438 |
annotation.meta["id-ref"] = json.annotations[0]["type"]; |
|
|
630
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
439 |
} |
| 836 | 440 |
|
| 597 | 441 |
// everything is shared so there's no need to propagate the change |
442 |
_this._serializer._data.annotations.push(annotation); |
|
| 651 | 443 |
|
| 643 | 444 |
_this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation", annotation); |
| 651 | 445 |
callback(annotation); |
|
630
7c53857650b1
create a new contribution line in the json if it's not defined already.
hamidouk
parents:
627
diff
changeset
|
446 |
}), |
|
614
116de1c38a7d
lots of refactoring for this widget, as well as changes to support the cinecast
hamidouk
parents:
611
diff
changeset
|
447 |
error: |
| 626 | 448 |
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
|
449 |
console.log("an error occured while contacting " |
| 769 | 450 |
+ url + " and sending " + jsonString + textStatus ); |
451 |
_this.showErrorScreen(); } }); |
|
| 543 | 452 |
}; |