'
+ + '
'
+ '
'
+ '
'
+ ''
+ '
'
+ + '{{#allow_annotations_deletion}}'
+ + '
✖
'
+ + '{{/allow_annotations_deletion}}'
+ '{{#show_timecode}}
{{begin}} - {{end}}
{{/show_timecode}}'
+ '
'
+ '
{{{hdescription}}}
'
+ '{{#created}}'
@@ -130,7 +228,7 @@
+ '{{/tags}}'
+ ''
+ '{{/tags.length}}'
- + '{{#audio}}
{{l10n.voice_annotation}}
{{/audio}}'
+ + '{{#audio}}
{{l10n.voice_annotation}}
{{/audio}}'
+ '';
// obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project
@@ -150,6 +248,11 @@
}, this.metadata));
};
+IriSP.Widgets.AnnotationsList.prototype.showScreen = function(_screenName) {
+ this.$.find('.Ldt-AnnotationsList-Screen' + _screenName).show()
+ .siblings().hide();
+}
+
IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() {
var _currentTime = this.media.getCurrentTime();
var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime);
@@ -189,7 +292,7 @@
return _annotation.found !== false;
});
- if ((this.filter_by_segments)&&(!(this.show_filters && this.ignoresegmentcheckbox_$[0].checked))) {
+ if ((this.filter_by_segments)&&(!(this.show_filters && this.segment_filter && this.ignoresegmentcheckbox_$[0].checked))) {
/*
* A given annotation is considered "in" segment if the middle of it is between the segment beginning and the segment end.
* Note this is meant to be used for "markings" annotations (not segments)
@@ -216,6 +319,10 @@
return (_currentSegments[0].begin <= _annotation_time && _currentSegments[0].end >= _annotation_time)
});
}
+ if(this.annotations_count_header && this.annotations_count != _list.length){
+ this.annotations_count = _list.length;
+ this.refreshHeader();
+ }
}
if (this.show_only_annotation_from_user){
_list = _list.filter(function(_annotation){
@@ -240,25 +347,43 @@
}
if (this.show_filters){
- _username = this.userselect_$[0].options[this.userselect_$[0].selectedIndex].value;
- if (_username != "false")
- {
- _list = _list.filter(function(_annotation){
- return _annotation.creator == _username
- })
+ if (this.user_filter){
+ _username = this.userselect_$[0].options[this.userselect_$[0].selectedIndex].value;
+ if (_username != "false")
+ {
+ _list = _list.filter(function(_annotation){
+ return _annotation.creator == _username
+ })
+ }
}
+ if (this.keyword_filter){
_keyword = this.keywordinput_$[0].value;
- if (_keyword != ""){
- _list = _list.filter(function(_annotation){
- return _annotation.description.toLowerCase().match(_keyword.toLowerCase());
- });
+ if (_keyword != ""){
+ _list = _list.filter(function(_annotation){
+ return _annotation.description.toLowerCase().match(_keyword.toLowerCase());
+ });
+ }
}
-
-
- if(this.datefilterinput_$[0].value != ""){
- _date = this.datefilterinput_$.datepicker("getDate");
- _list = _list.filter(function(_annotation){
- return ((_annotation.created.getDate() == _date.getDate())&&(_annotation.created.getMonth() == _date.getMonth())&&(_annotation.created.getFullYear() == _date.getFullYear()))
+ if (this.date_filter){
+ if(this.datefilterinput_$[0].value != ""){
+ _date = this.datefilterinput_$.datepicker("getDate");
+ _list = _list.filter(function(_annotation){
+ return ((_annotation.created.getDate() == _date.getDate())&&(_annotation.created.getMonth() == _date.getMonth())&&(_annotation.created.getFullYear() == _date.getFullYear()));
+ });
+ }
+ }
+ if (this.latest_contributions_filter && this.latestcontributionscheckbox_$[0].checked){
+ _list = _list.sortBy(function(_annotation) {
+ return -_annotation.created.valueOf();
+ });
+ this.usernames.forEach(function(_user){
+
+ latest_ann = _list.filter(function(_annotation){
+ return _annotation.creator == _user;
+ })[0];
+ _list = _list.filter(function(_annotation){
+ return _annotation.id == (latest_ann ? latest_ann.id : false) || _annotation.creator != _user;
+ });
});
}
@@ -295,7 +420,17 @@
// Update : display creator
if (_annotation.creator) {
- _title = _annotation.creator;
+ var _users = _this.source.users_data.filter(function(_user_data){
+ return _user_data.username == _annotation.creator
+ }),
+ _user = {};
+ if (_users.length == 0){
+ _user.username = _annotation.creator
+ }
+ else{
+ _user = _users[0]
+ }
+ _title = _this.make_name_string_function(_user);
}
if (_annotation.title) {
var tempTitle = _annotation.title;
@@ -334,7 +469,8 @@
url : _url,
tags : _tags,
specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""),
- l10n: _this.l10n
+ l10n: _this.l10n,
+ allow_annotations_deletion: _this.allow_annotations_deletion
};
if (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null") {
_data.audio = true;
@@ -426,6 +562,8 @@
_$.html(IriSP.textFieldHtml(_$.text(), rx));
});
}
+
+ this.$.find(".Ldt-AnnotationsList-DeleteButton").click(_this.functionWrapper("onDeleteClick"))
}
if (this.ajax_url) {
@@ -441,6 +579,75 @@
return _list.length;
};
+IriSP.Widgets.AnnotationsList.prototype.onDeleteClick = function(event){
+
+ ann_id = event.target.id;
+ console.log(ann_id)
+ delete_preview_$ = this.$.find(".Ldt-AnnotationsList-ul-ToDelete");
+ delete_preview_$.html("");
+ _list = this.getWidgetAnnotations()
+ _list = _list.filter(function(_annotation){
+ return _annotation.id == ann_id
+ })
+ var _annotation = _list[0],
+ _title = "",
+ _this = this;
+ console.log(_annotation)
+ if (_annotation.creator) {
+ var _users = _this.source.users_data.filter(function(_user_data){
+ return _user_data.username == _annotation.creator
+ }),
+ _user = {};
+ if (_users.length == 0){
+ _user.username = _annotation.creator
+ }
+ else{
+ _user = _users[0]
+ }
+ _title = _this.make_name_string_function(_user);
+ }
+ if (_annotation.title) {
+ var tempTitle = _annotation.title;
+ if( tempTitle.substr(0, _title.length + 1) == (_title + ":") ){
+ _title = "";
+ }
+ _title = _title + ( (_title=="") ? "" : ": ") + _annotation.title;
+ }
+ var _created = false;
+ if (this.show_creation_date) {
+ _created = _annotation.created.toLocaleDateString()+", "+_annotation.created.toLocaleTimeString();
+ }
+ var _data = {
+ id : _annotation.id,
+ media_id : _annotation.getMedia().id,
+ htitle : IriSP.textFieldHtml(_title),
+ hdescription : IriSP.textFieldHtml(_annotation.description),
+ begin : _annotation.begin.toString(),
+ end : _annotation.end.toString(),
+ created : _created,
+ show_timecode : this.show_timecode,
+ tags : false,
+ l10n: this.l10n,
+ allow_annotations_deletion: false
+ }
+ _html = Mustache.to_html(this.annotationTemplate, _data)
+ delete_preview_$.html(_html)
+
+ this.$.find(".Ldt-AnnotationsList-ConfirmDelete").click(function(){
+ _this.sendDelete(ann_id);
+ });
+
+ this.showScreen("Delete");
+}
+
+IriSP.Widgets.AnnotationsList.prototype.refreshHeader = function() {
+ var annotation_count_string = " (" + this.annotations_count +" annotations)";
+ this.$.find('.Ldt-AnnotationsList-header').html("");
+ this.$.find('.Ldt-AnnotationsList-header').html(
+ this.custom_header && typeof this.custom_header == "string"? this.custom_header + annotation_count_string : this.l10n.header + annotation_count_string
+ );
+}
+
IriSP.Widgets.AnnotationsList.prototype.hide = function() {
var _this = this;
if (this.visible){
@@ -448,6 +655,7 @@
this.widget_$.slideUp(function(){
_this.$.find('.Ldt-AnnotationsList-header').hide();
});
+ this.showScreen("Main")
}
}
@@ -456,6 +664,7 @@
this.visible = true;
this.$.find('.Ldt-AnnotationsList-header').show();
this.widget_$.slideDown();
+ this.showScreen("Main")
}
}
@@ -470,34 +679,89 @@
}
};
+IriSP.Widgets.AnnotationsList.prototype.revertToMainScreen = function(){
+ if (this.$.find(".Ldt-AnnotationsList-ScreenMain").is(":hidden")){
+ this.showScreen("Main");
+ }
+}
+
+IriSP.Widgets.AnnotationsList.prototype.sendDelete = function(id){
+ console.log("deleting "+id)
+ var _this = this,
+ _url = Mustache.to_html(this.api_delete_endpoint, {annotation_id: id})
+
+ IriSP.jQuery.ajax({
+ url: _url,
+ type: this.api_delete_method,
+ contentType: 'application/json',
+ success: function(_data) {
+ _this.showScreen('Success');
+ window.setTimeout(_this.functionWrapper("revertToMainScreen"),(_this.after_send_timeout || 2000));
+ _this.currentSource.getAnnotations().removeId(id);
+ _this.player.trigger("AnnotationsList.refresh");
+ },
+ error: function(_xhr, _error, _thrown) {
+ IriSP.log("Error when sending annotation", _thrown);
+ _this.showScreen('Error');
+ window.setTimeout(_this.functionWrapper("revertToMainScreen"),(_this.after_send_timeout || 2000));
+ }
+ });
+ this.showScreen('Sending');
+}
+
IriSP.Widgets.AnnotationsList.prototype.draw = function() {
-
this.jwplayers = {};
this.mashupMode = (this.media.elementType === "mashup");
this.renderTemplate();
var _this = this;
-
+
this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
this.widget_$ = this.$.find(".Ldt-AnnotationsListWidget");
- this.userselect_$ = this.$.find("#Ldt-AnnotationsList-userFilter");
- this.userselect_$.change(function(){
- _this.player.trigger("AnnotationsList.refresh");
- });
- this.keywordinput_$ = this.$.find("#Ldt-AnnotationsList-keywordsFilter");
- this.keywordinput_$.keyup(function(){
- _this.player.trigger("AnnotationsList.refresh");
- });
- this.ignoresegmentcheckbox_$ = this.$.find("#Ldt-AnnotationsList-ignoreSegmentsFilter");
- this.ignoresegmentcheckbox_$.click(function(){
- _this.player.trigger("AnnotationsList.refresh");
- });
- this.datefilterinput_$ = this.$.find("#Ldt-AnnotationsList-dateFilter");
- this.datefilterinput_$.datepicker({ dateFormat: 'dd/mm/yy' });
- this.datefilterinput_$.change(function(){
- _this.player.trigger("AnnotationsList.refresh")
- })
+
+ if (this.show_filters){
+ if (this.user_filter){
+ this.userselect_$ = this.$.find("#Ldt-AnnotationsList-userFilter");
+ this.userselect_$.change(function(){
+ _this.player.trigger("AnnotationsList.refresh");
+ });
+ this.userselect_$.html("
");
+ this.usernames.forEach(function(_user){
+ _this.userselect_$.append("
");
+ });
+ }
+ if (this.keyword_filter){
+ this.keywordinput_$ = this.$.find("#Ldt-AnnotationsList-keywordsFilter");
+ this.keywordinput_$.keyup(function(){
+ _this.player.trigger("AnnotationsList.refresh");
+ });
+
+ }
+ if (this.segment_filter){
+ this.ignoresegmentcheckbox_$ = this.$.find("#Ldt-AnnotationsList-ignoreSegmentsFilter");
+ this.ignoresegmentcheckbox_$.click(function(){
+ _this.player.trigger("AnnotationsList.refresh");
+ });
+ }
+ if(this.date_filter){
+ this.datefilterinput_$ = this.$.find("#Ldt-AnnotationsList-dateFilter");
+ this.datefilterinput_$.datepicker({ dateFormat: 'dd/mm/yy' });
+ this.datefilterinput_$.change(function(){
+ _this.player.trigger("AnnotationsList.refresh")
+ })
+ if (this.current_day_filter){
+ currentDate = new Date();
+ this.datefilterinput_$.datepicker("setDate",currentDate);
+ }
+ }
+ if(this.latest_contributions_filter){
+ this.latestcontributionscheckbox_$ = this.$.find("#Ldt-AnnotationsList-latestContributionsFilter");
+ this.latestcontributionscheckbox_$.click(function(){
+ _this.player.trigger("AnnotationsList.refresh");
+ });
+ }
+ }
this.source.getAnnotations().on("search", function(_text) {
_this.searchString = _text;
@@ -518,24 +782,15 @@
_this.currentSource.getAnnotations().trigger("clear-search");
}
});
+
+ this.$.find(".Ldt-AnnotationsList-Close").click(function(){
+ _this.showScreen("Main");
+ })
+
this.source.getAnnotations().on("search-cleared", function() {
_this.throttledRefresh();
});
- if (this.show_filters){
- _usernames = Array();
- _list = this.getWidgetAnnotations()
- _list.forEach(function(_annotation){
- if(_usernames.indexOf(_annotation.creator) == -1){
- _usernames.push(_annotation.creator);
- }
- });
- this.userselect_$.html("
");
- _usernames.forEach(function(_user){
- _this.userselect_$.append("
");
- });
- }
-
this.onMdpEvent("AnnotationsList.refresh", function() {
if (_this.ajax_url) {
if (_this.mashupMode) {
@@ -563,6 +818,10 @@
}, this.refresh_interval);
}
+ if (this.annotations_count_header){
+ this.annotations_count = false;
+ }
+
this.onMdpEvent("AnnotationsList.toggle","toggle");
this.onMdpEvent("AnnotationsList.hide", "hide");
this.onMdpEvent("AnnotationsList.show", "show");
@@ -580,9 +839,13 @@
this.throttledRefresh();
+ this.showScreen("Main");
+ this.$.find(".Ldt-AnnotationsList-CancelDelete").click(function(){
+ _this.showScreen("Main")
+ });
+
this.visible = true;
if (!this.start_visible){
this.hide();
}
-
};