| author | ymh <ymh.work@gmail.com> |
| Wed, 04 Sep 2024 17:32:50 +0200 | |
| changeset 1072 | ac1eacb3aa33 |
| parent 1069 | 2409cb4cebaf |
| permissions | -rw-r--r-- |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
1 |
/* Widget that displays the last annotation that was posted, optionally for current segment, optionally for a given username */ |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
2 |
import Mustache from "mustache"; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
3 |
import jQuery from "jquery"; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
4 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
5 |
import latestAnnotationStyles from "./LatestAnnotation.module.css"; |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
6 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
7 |
const LatestAnnotation = function (ns) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
8 |
return class extends ns.Widgets.Widget { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
9 |
constructor(player, config) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
10 |
super(player, config); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
11 |
} |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
12 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
13 |
static defaults = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
14 |
pre_draw_callback: function () { |
|
1054
cfea8c04c8c7
Added support for displaying user name using additional user informations
durandn
parents:
1046
diff
changeset
|
15 |
return this.importUsers(); |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
16 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
17 |
from_user: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
18 |
filter_by_segment: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
19 |
segments_annotation_type: "chap", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
20 |
hide_without_segment: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
21 |
annotation_type: "contribution", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
22 |
/* |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
23 |
* Set to a username if you only want to display annotations from a given user |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
24 |
*/ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
25 |
show_only_annotation_from_user: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
26 |
/* |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
27 |
* Displays a button that copy currently displayed annotation into CreateAnnotation input field |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
28 |
*/ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
29 |
copy_and_edit_button: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
30 |
hide_annotations_list: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
31 |
/* |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
32 |
* Allows clicks on an annotation from Annotations to display the annotation content into this widget |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
33 |
*/ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
34 |
selectable_annotations: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
35 |
empty_message: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
36 |
starts_hidden: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
37 |
show_header: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
38 |
custom_header: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
39 |
make_name_string_function: function (params) { |
|
1054
cfea8c04c8c7
Added support for displaying user name using additional user informations
durandn
parents:
1046
diff
changeset
|
40 |
return params.username ? params.username : "Anonymous"; |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
41 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
42 |
}; |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
43 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
44 |
static messages = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
45 |
fr: { |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
46 |
copy_and_edit: "Copier et Editer", |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
47 |
empty: "Aucune annotation à afficher", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
48 |
header: "Dernière annotation", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
49 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
50 |
en: { |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
51 |
copy_and_edit: "Copy and Edit", |
|
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
52 |
empty: "No annotation to display", |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
53 |
header: "Last annotation", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
54 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
55 |
}; |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
56 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
57 |
static template = |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
58 |
"{{#show_header}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
59 |
"<p class='Ldt-LatestAnnotation-header'>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
60 |
"{{#custom_header}}{{custom_header}}{{/custom_header}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
61 |
"{{^custom_header}}{{l10n.header}}{{/custom_header}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
62 |
"</p>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
63 |
"{{/show_header}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
64 |
"<div class='Ldt-LatestAnnotation'>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
65 |
"</div>"; |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
66 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
67 |
static annotationTemplate = |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
68 |
"<div class='Ldt-LatestAnnotation-Box'>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
69 |
"{{#copy_and_edit_button}}<div class='Ldt-LatestAnnotation-CopyEditButton'>{{button_text}}</div>{{/copy_and_edit_button}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
70 |
"<div class='Ldt-LatestAnnotation-Element Ldt-LatestAnnotation-CreationDate'>{{{annotation_created}}}</div>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
71 |
"<div class='Ldt-LatestAnnotation-Element Ldt-LatestAnnotation-Title'>{{{annotation_creator}}}{{#annotation_title}}: {{{annotation_title}}}{{/annotation_title}}</div>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
72 |
"<div class='Ldt-LatestAnnotation-Element Ldt-LatestAnnotation-Content'>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
73 |
"{{{annotation_content}}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
74 |
"</div>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
75 |
"</div>"; |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
76 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
77 |
importUsers() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
78 |
if (!this.source.users_data) { |
|
1054
cfea8c04c8c7
Added support for displaying user name using additional user informations
durandn
parents:
1046
diff
changeset
|
79 |
this.usernames = Array(); |
|
cfea8c04c8c7
Added support for displaying user name using additional user informations
durandn
parents:
1046
diff
changeset
|
80 |
var _this = this, |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
81 |
_list = this.getWidgetAnnotations(), |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
82 |
usernames_list_string = ""; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
83 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
84 |
_list.forEach(function (_annotation) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
85 |
if (_this.usernames.indexOf(_annotation.creator) == -1) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
86 |
_this.usernames.push(_annotation.creator); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
87 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
88 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
89 |
this.usernames.forEach(function (_username) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
90 |
usernames_list_string += _username + ","; |
|
1054
cfea8c04c8c7
Added support for displaying user name using additional user informations
durandn
parents:
1046
diff
changeset
|
91 |
}); |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
92 |
usernames_list_string = usernames_list_string.substring( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
93 |
0, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
94 |
usernames_list_string.length - 1 |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
95 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
96 |
_url = Mustache.render(this.api_users_endpoint, { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
97 |
usernames_list_string: encodeURIComponent(usernames_list_string), |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
98 |
usernames_list_length: this.usernames.length, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
99 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
100 |
return jQuery.ajax({ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
101 |
async: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
102 |
url: _url, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
103 |
type: "GET", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
104 |
success: function (_data) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
105 |
_this.source.users_data = _data.objects; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
106 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
107 |
error: function (_xhr, _error, _thrown) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
108 |
console.log(_xhr); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
109 |
console.log(_error); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
110 |
console.log(_thrown); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
111 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
112 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
113 |
} |
|
1054
cfea8c04c8c7
Added support for displaying user name using additional user informations
durandn
parents:
1046
diff
changeset
|
114 |
} |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
115 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
116 |
draw() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
117 |
var _this = this; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
118 |
this.renderTemplate(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
119 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
120 |
this.annotationContainer_$ = this.$.find(".Ldt-LatestAnnotation"); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
121 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
122 |
if (this.selectable_annotations) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
123 |
this.onMdpEvent("AnnotationsList.refresh", function () { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
124 |
_this.getWidgetAnnotations().forEach(function (_annotation) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
125 |
_annotation.off("click"); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
126 |
_annotation.on("click", function () { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
127 |
var _user = {}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
128 |
_user_display_string = "", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
129 |
_users = this.source.users_data.filter(function (_user_data) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
130 |
return _user_data.username == _annotation.creator; |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
131 |
}); |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
132 |
if (_users.length == 0) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
133 |
_user.username = _annotation.creator; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
134 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
135 |
_user = _users[0]; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
136 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
137 |
_user_display_string = _this.make_name_string_function(_user); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
138 |
_html = Mustache.render(_this.annotationTemplate, { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
139 |
annotation_created: |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
140 |
_annotation.created.toLocaleDateString() + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
141 |
", " + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
142 |
_annotation.created.toLocaleTimeString(), |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
143 |
annotation_creator: _user_display_string, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
144 |
annotation_title: _annotation.title, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
145 |
annotation_content: _annotation.description, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
146 |
copy_and_edit_button: _this.copy_and_edit_button, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
147 |
button_text: _this.l10n.copy_and_edit, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
148 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
149 |
_this.annotationContainer_$.html(_html); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
150 |
_this.selectedAnnotation = true; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
151 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
152 |
}); |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
153 |
}); |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
154 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
155 |
this.segments = _this.source.getAnnotationsByTypeTitle( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
156 |
this.segments_annotation_type |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
157 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
158 |
this.segments.forEach(function (_segment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
159 |
_segment.on("click", function () { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
160 |
_this.selectedAnnotation = false; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
161 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
162 |
}); |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
163 |
this.currentSegment = false; |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
164 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
165 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
166 |
this.onMediaEvent("timeupdate", function () { |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
167 |
_this.refresh(); |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
168 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
169 |
this.onMediaEvent("settimerange", function (_timeRange) { |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
170 |
_this.refresh(_timeRange); |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
171 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
172 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
173 |
if (this.starts_hidden) { |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
174 |
this.visible = true; |
|
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
175 |
this.hide(); |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
176 |
} else { |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
177 |
this.visible = false; |
|
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
178 |
this.show(); |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
179 |
} |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
180 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
181 |
this.selectedAnnotation = false; // This flag tells the widget if it must display last annotation (false) or clicked annotation (true) |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
182 |
this.player.trigger("AnnotationsList.refresh"); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
183 |
this.refresh(); |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
184 |
} |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
185 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
186 |
refresh(_timeRange) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
187 |
_timeRange = typeof _timeRange !== "undefined" ? _timeRange : false; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
188 |
var _this = this; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
189 |
if (this.hide_without_segment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
190 |
if (!_timeRange && !this.media.getTimeRange()) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
191 |
var _currentTime = this.media.getCurrentTime(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
192 |
var _currentSegments = this.segments.filter(function (_segment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
193 |
return ( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
194 |
_currentTime >= _segment.begin && _currentTime <= _segment.end |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
195 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
196 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
197 |
if (_currentSegments.length == 0) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
198 |
this.currentSegment = false; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
199 |
this.selectedAnnotation = false; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
200 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
201 |
this.currentSegment = _currentSegments[0]; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
202 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
203 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
204 |
var _segmentBegin = _timeRange |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
205 |
? _timeRange[0] |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
206 |
: this.media.getTimeRange()[0], |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
207 |
_segmentEnd = _timeRange |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
208 |
? _timeRange[1] |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
209 |
: this.media.getTimeRange()[1]; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
210 |
if ( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
211 |
!this.currentSegment || |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
212 |
this.currentSegment.begin != _segmentBegin || |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
213 |
this.currentSegment.end != _segmentEnd |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
214 |
) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
215 |
var _currentSegments = this.segments.filter(function (_segment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
216 |
return ( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
217 |
_segment.begin == _segmentBegin && _segment.end == _segmentEnd |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
218 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
219 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
220 |
if (_currentSegments.length > 0) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
221 |
this.selectedAnnotation = false; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
222 |
this.currentSegment = _currentSegments[0]; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
223 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
224 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
225 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
226 |
if (!this.currentSegment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
227 |
if (this.visible) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
228 |
this.hide(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
229 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
230 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
231 |
if (!this.visible) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
232 |
this.show(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
233 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
234 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
235 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
236 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
237 |
if (this.visible && !this.selectedAnnotation) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
238 |
var _list = this.getWidgetAnnotations(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
239 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
240 |
if (this.filter_by_segment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
241 |
if (!this.currentSegment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
242 |
_list = _list.filter(function (_annotation) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
243 |
return false; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
244 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
245 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
246 |
_list = _list.filter(function (_annotation) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
247 |
_annotationTime = (_annotation.begin + _annotation.end) / 2; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
248 |
return ( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
249 |
_this.currentSegment.begin <= _annotationTime && |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
250 |
_this.currentSegment.end >= _annotationTime |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
251 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
252 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
253 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
254 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
255 |
_list = _list.sortBy(function (_annotation) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
256 |
return _annotation.created; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
257 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
258 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
259 |
var _latestAnnotation = false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
260 |
_html = "", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
261 |
_user_display_string = "", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
262 |
_user = {}; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
263 |
if (_list.length != 0) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
264 |
_latestAnnotation = _list.pop(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
265 |
_users = this.source.users_data.filter(function (_user_data) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
266 |
return _user_data.username == _latestAnnotation.creator; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
267 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
268 |
if (_users.length == 0) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
269 |
_user.username = _latestAnnotation.creator; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
270 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
271 |
_user = _users[0]; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
272 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
273 |
_user_display_string = this.make_name_string_function(_user); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
274 |
_html = Mustache.render(this.annotationTemplate, { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
275 |
annotation_created: |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
276 |
_latestAnnotation.created.toLocaleDateString() + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
277 |
", " + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
278 |
_latestAnnotation.created.toLocaleTimeString(), |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
279 |
annotation_creator: _user_display_string, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
280 |
annotation_title: _latestAnnotation.title, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
281 |
annotation_content: _latestAnnotation.description, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
282 |
copy_and_edit_button: this.copy_and_edit_button, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
283 |
button_text: this.l10n.copy_and_edit, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
284 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
285 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
286 |
var _empty_message = this.l10n.empty; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
287 |
if (this.empty_message) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
288 |
_empty_message = this.empty_message; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
289 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
290 |
_html = |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
291 |
"<div class='Ldt-LatestAnnotation-Element Ldt-LatestAnnotation-NoAnnotation'>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
292 |
_empty_message + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
293 |
"</div>"; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
294 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
295 |
this.annotationContainer_$.html(_html); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
296 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
297 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
298 |
if (this.copy_and_edit_button) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
299 |
this.copyAndEditButton_$ = this.$.find( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
300 |
".Ldt-LatestAnnotation-CopyEditButton" |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
301 |
); |
|
1046
eb77616c245f
Updated LatestAnnotation, CurrentSegmentInfobox, AnnotationController and AnnotationList widgets to use timerange to find the current segment when the corresponding option is used + CurrentSegmentInfobox now has an option for editing the current segment + LatestAnnotation now has a "Copy and edit" button that allows to use the text from the currently displayed annotation into the CreateAnnotation widget textarea
durandn
parents:
1041
diff
changeset
|
302 |
this.copyAndEditButton_$.click(this.functionWrapper("copy_and_edit")); |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
303 |
} |
|
1069
2409cb4cebaf
getting various changes from github
ymh <ymh.work@gmail.com>
parents:
1056
diff
changeset
|
304 |
} |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
305 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
306 |
copy_and_edit() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
307 |
this.player.trigger("CreateAnnotation.show"); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
308 |
if (this.hide_annotations_list) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
309 |
this.player.trigger("AnnotationsList.hide"); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
310 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
311 |
annotationText = $(".Ldt-LatestAnnotation-Content").get(0).innerHTML; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
312 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
313 |
$(".Ldt-CreateAnnotation-Description").removeClass("empty"); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
314 |
$(".Ldt-CreateAnnotation-Description").val(annotationText); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
315 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
316 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
317 |
hide() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
318 |
if (this.visible) { |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
319 |
this.visible = false; |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
320 |
this.$.find(".Ldt-LatestAnnotation-header").hide(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
321 |
this.annotationContainer_$.hide(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
322 |
} |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
323 |
} |
|
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
324 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
325 |
show() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
326 |
if (!this.visible) { |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
327 |
this.visible = true; |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
328 |
this.$.find(".Ldt-LatestAnnotation-header").show(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
329 |
this.annotationContainer_$.show(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
330 |
} |
|
1041
423a8c6f9c4d
New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff
changeset
|
331 |
} |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
332 |
}; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
333 |
}; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
334 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
335 |
export { LatestAnnotation, latestAnnotationStyles }; |