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