| author | ymh <ymh.work@gmail.com> |
| Wed, 04 Sep 2024 17:32:50 +0200 | |
| changeset 1072 | ac1eacb3aa33 |
| parent 1069 | 2409cb4cebaf |
| permissions | -rw-r--r-- |
|
1040
be314c4ea4ac
New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff
changeset
|
1 |
/* Widget displays info on the current segment, with possibility of config for editing description and tags */ |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
2 |
// CurrentSegmentInfobox |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
3 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
4 |
import currentSegmentInfoboxStyles from "./CurrentSegmentInfobox.module.css"; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
5 |
import Mustache from "mustache"; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
6 |
import _ from "lodash"; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
7 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
8 |
const CurrentSegmentInfobox = function (ns) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
9 |
return class extends ns.Widgets.Widget { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
10 |
constructor(player, config) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
11 |
super(player, config); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
12 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
13 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
14 |
static defaults = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
15 |
annotation_type: "chap", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
16 |
editable_segments: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
17 |
empty_message: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
18 |
project_id: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
19 |
api_serializer: "ldt_annotate", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
20 |
api_method: "PUT", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
21 |
api_endpoint_template: "", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
22 |
new_tag_button: true, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
23 |
show_headers: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
24 |
custom_edit_text: false, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
25 |
empty_description_placeholder: 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 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
28 |
static template = |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
29 |
'<div class="Ldt-CurrentSegmentInfobox">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
30 |
'<div class="Ldt-CurrentSegmentInfobox-SelectedSegment">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
31 |
'{{#editable_segments}}<div class="Ldt-CurrentSegmentInfobox-EditButton">{{edit}}</div>{{/editable_segments}}' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
32 |
'<div class="Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-Title">{{title}}</div>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
33 |
'<div class="Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-Description">{{description}}</div>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
34 |
'{{^description}}{{^tags.length}}{{#description_placeholder}}<div class="Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-Description-placeholder">{{description_placeholder}}</div>{{/description_placeholder}}{{/tags.length}}{{/description}}' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
35 |
'<div class="Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-Tags">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
36 |
"{{#tags.length}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
37 |
'<ul class="Ldt-CurrentSegmentInfobox-Tags-Ul">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
38 |
"{{#tags}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
39 |
"{{#.}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
40 |
'<li class="Ldt-CurrentSegmentInfobox-Tags-Li">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
41 |
"<span>{{.}}</span>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
42 |
"</li>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
43 |
"{{/.}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
44 |
"{{/tags}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
45 |
"</ul>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
46 |
"{{/tags.length}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
47 |
"</div>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
48 |
"</div>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
49 |
"</div>"; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
50 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
51 |
static editTemplate = |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
52 |
'<div class="Ldt-CurrentSegmentInfobox">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
53 |
'<div class="Ldt-CurrentSegmentInfobox-SelectedSegment">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
54 |
'{{#headers}}<div class="Ldt-CurrentSegmentInfobox-FieldsHeader">{{fields_header}}</div>{{/headers}}' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
55 |
'<input type="text" class="Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-TitleInput Ldt-CurrentSegmentInfobox-Title" value="{{title}}"></input>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
56 |
'<textarea class="Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-DescriptionInput Ldt-CurrentSegmentInfobox-Description">{{description}}</textarea>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
57 |
'<div class="Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-Tags">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
58 |
'{{#headers}}<div class="Ldt-CurrentSegmentInfobox-TagsHeader">{{tags_header}}</div>{{/headers}}' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
59 |
"{{#new_tag_button}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
60 |
'<div class="Ldt-CurrentSegmentInfobox-CreateTagButton">{{new_tag}}</div>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
61 |
"{{/new_tag_button}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
62 |
"{{^new_tag_button}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
63 |
'<input class="Ldt-CurrentSegmentInfobox-CreateTagInput" placeholder="{{new_tag}}"></input>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
64 |
'<div class="Ldt-CurrentSegmentInfobox-CreateTagInput-Add">+</div>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
65 |
"{{/new_tag_button}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
66 |
'<ul class="Ldt-CurrentSegmentInfobox-Tags-Ul">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
67 |
"{{#tags}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
68 |
"{{#.}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
69 |
'<li class="Ldt-CurrentSegmentInfobox-Tags-Li">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
70 |
'<input type="text" class="Ldt-CurrentSegmentInfobox-Tags-Li-Input" value="{{.}}"></input>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
71 |
'<div class="Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton">{{delete_tag}}</div>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
72 |
"</li>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
73 |
"{{/.}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
74 |
"{{/tags}}" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
75 |
"</ul>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
76 |
"</div>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
77 |
'<div class="Ldt-CurrentSegmentInfobox-SubmitButton">{{submit}}</div>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
78 |
'<div class="Ldt-CurrentSegmentInfobox-CancelButton">{{cancel}}</div>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
79 |
"</div>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
80 |
"</div>"; |
|
1040
be314c4ea4ac
New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff
changeset
|
81 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
82 |
static messages = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
83 |
fr: { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
84 |
submit: "Soumettre", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
85 |
cancel: "Annuler", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
86 |
edit: "Editer", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
87 |
new_tag: "Nouveau tag", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
88 |
delete_tag: "Supprimer", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
89 |
fields_header: "Commentaire associé à ce segment", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
90 |
tags_header: "Mots-clés associés à ce segment", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
91 |
empty: "Le player vidéo ne lit actuellement aucun segment", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
92 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
93 |
en: { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
94 |
submit: "Submit", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
95 |
cancel: "Cancel", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
96 |
edit: "Edit", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
97 |
new_tag: "New tag", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
98 |
delete_tag: "Delete tag", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
99 |
fields_header: "Current segment content", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
100 |
tags_header: "Current segment tags", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
101 |
empty: "The player currently doesn't read any segment", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
102 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
103 |
}; |
|
1040
be314c4ea4ac
New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff
changeset
|
104 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
105 |
draw() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
106 |
var _this = this; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
107 |
this.segments = this.getWidgetAnnotations(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
108 |
this.renderTemplate(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
109 |
this.currentSegment = false; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
110 |
this.clearBox(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
111 |
this.refresh(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
112 |
this.onMediaEvent("timeupdate", "refresh"); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
113 |
this.onMediaEvent("settimerange", function (_timeRange) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
114 |
var _segmentBegin = _timeRange[0], |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
115 |
_segmentEnd = _timeRange[1], |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
116 |
_list = _this.segments.filter(function (_segment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
117 |
return ( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
118 |
_segment.begin.milliseconds == _segmentBegin.milliseconds && |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
119 |
_segment.end.milliseconds == _segmentEnd.milliseconds |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
120 |
); |
|
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 (_list.length > 0) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
123 |
_this.$.toggleClass("editing", false); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
124 |
if (_this.currentSegment.id != _list[0].id) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
125 |
_this.currentSegment = _list[0]; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
126 |
_data = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
127 |
editable_segments: _this.editable_segments, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
128 |
edit: _this.custom_edit_text |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
129 |
? _this.custom_edit_text |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
130 |
: _this.l10n.edit, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
131 |
title: _this.currentSegment.title, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
132 |
description: _this.currentSegment.description, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
133 |
description_placeholder: _this.empty_description_placeholder, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
134 |
tags: _this.currentSegment.getTagTexts(), |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
135 |
}; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
136 |
_this.$.html(Mustache.render(_this.template, _data)); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
137 |
if (_this.editable_segments && _this.currentSegment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
138 |
_this.$.find(".Ldt-CurrentSegmentInfobox").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
139 |
_this.functionWrapper("enableEditMode") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
140 |
); |
|
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 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
143 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
144 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
145 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
146 |
if (this.editable_segments && this.currentSegment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
147 |
this.$.find(".Ldt-CurrentSegmentInfobox").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
148 |
_this.functionWrapper("enableEditMode") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
149 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
150 |
} |
|
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 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
153 |
enableEditMode() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
154 |
var _this = this; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
155 |
if (this.currentSegment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
156 |
_data = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
157 |
title: this.currentSegment.title, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
158 |
description: this.currentSegment.description, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
159 |
tags: this.currentSegment.getTagTexts(), |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
160 |
submit: this.l10n.submit, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
161 |
cancel: this.l10n.cancel, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
162 |
headers: this.show_headers, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
163 |
tags_header: this.custom_tags_header |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
164 |
? this.custom_tags_header |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
165 |
: this.l10n.tags_header, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
166 |
fields_header: this.custom_fields_header |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
167 |
? this.custom_fields_header |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
168 |
: this.l10n.fields_header, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
169 |
new_tag: this.l10n.new_tag, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
170 |
delete_tag: this.l10n.delete_tag, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
171 |
new_tag_button: this.new_tag_button, |
|
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 |
this.$.toggleClass("editing", true); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
174 |
this.$.html(Mustache.render(this.editTemplate, _data)); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
175 |
this.$.find(".Ldt-CurrentSegmentInfobox-CancelButton").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
176 |
this.functionWrapper("disableEditMode") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
177 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
178 |
if (this.new_tag_button) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
179 |
this.$.find(".Ldt-CurrentSegmentInfobox-CreateTagButton").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
180 |
this.functionWrapper("insertTagInput") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
181 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
182 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
183 |
this.$.find(".Ldt-CurrentSegmentInfobox-CreateTagInput").keypress( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
184 |
this.functionWrapper("insertTagInputKeypress") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
185 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
186 |
this.$.find(".Ldt-CurrentSegmentInfobox-CreateTagInput-Add").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
187 |
this.functionWrapper("insertTagInputKeypress") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
188 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
189 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
190 |
this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
191 |
this.functionWrapper("deleteTagInput") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
192 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
193 |
this.$.find(".Ldt-CurrentSegmentInfobox-SubmitButton").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
194 |
this.functionWrapper("onSubmit") |
|
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 |
} |
|
1040
be314c4ea4ac
New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff
changeset
|
198 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
199 |
disableEditMode() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
200 |
if (this.currentSegment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
201 |
_data = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
202 |
editable_segments: this.editable_segments, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
203 |
edit: this.custom_edit_text ? this.custom_edit_text : this.l10n.edit, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
204 |
title: this.currentSegment.title, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
205 |
description: this.currentSegment.description, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
206 |
description_placeholder: this.empty_description_placeholder, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
207 |
tags: this.currentSegment.getTagTexts(), |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
208 |
}; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
209 |
this.$.toggleClass("editing", false); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
210 |
this.$.html(Mustache.render(this.template, _data)); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
211 |
this.$.find(".Ldt-CurrentSegmentInfobox").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
212 |
this.functionWrapper("enableEditMode") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
213 |
); |
|
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 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
216 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
217 |
insertTagInput() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
218 |
if ( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
219 |
!this.currentSegment.getTagTexts().length && |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
220 |
!this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Ul").length |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
221 |
) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
222 |
this.$.find(".Ldt-CurrentSegmentInfobox-Tags").prepend( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
223 |
'<ul class="Ldt-CurrentSegmentInfobox-Tags-Ul"></ul>' |
|
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 |
this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Ul").append( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
227 |
'<li class="Ldt-CurrentSegmentInfobox-Tags-Li">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
228 |
'<input type="text" class="Ldt-CurrentSegmentInfobox-Tags-Li-Input" value=""></input>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
229 |
'<div class="Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
230 |
this.l10n.delete_tag + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
231 |
"</div>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
232 |
"</li>" |
|
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 |
this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
235 |
this.functionWrapper("deleteTagInput") |
|
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 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
238 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
239 |
insertTagInputKeypress(event) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
240 |
var keycode = event.keyCode ? event.keyCode : event.which; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
241 |
if (keycode == "13" || event.type == "click") { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
242 |
if ( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
243 |
!this.currentSegment.getTagTexts().length && |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
244 |
!this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Ul").length |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
245 |
) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
246 |
this.$.find(".Ldt-CurrentSegmentInfobox-Tags").prepend( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
247 |
'<ul class="Ldt-CurrentSegmentInfobox-Tags-Ul"></ul>' |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
248 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
249 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
250 |
this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Ul").append( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
251 |
'<li class="Ldt-CurrentSegmentInfobox-Tags-Li">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
252 |
'<input type="text" class="Ldt-CurrentSegmentInfobox-Tags-Li-Input" value="' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
253 |
this.$.find(".Ldt-CurrentSegmentInfobox-CreateTagInput").val() + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
254 |
'"></input>' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
255 |
'<div class="Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton">' + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
256 |
this.l10n.delete_tag + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
257 |
"</div>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
258 |
"</li>" |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
259 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
260 |
this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
261 |
this.functionWrapper("deleteTagInput") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
262 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
263 |
this.$.find(".Ldt-CurrentSegmentInfobox-CreateTagInput").val(""); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
264 |
return false; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
265 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
266 |
} |
|
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 |
deleteTagInput(clickEvent) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
269 |
$(clickEvent.currentTarget).parent().remove(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
270 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
271 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
272 |
onSubmit() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
273 |
new_tags_titles = this.$.find( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
274 |
".Ldt-CurrentSegmentInfobox-Tags-Li-Input" |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
275 |
).map(function () { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
276 |
if ($(this).val()) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
277 |
return $(this).val(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
278 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
279 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
280 |
new_title = this.$.find(".Ldt-CurrentSegmentInfobox-TitleInput").val(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
281 |
new_description = this.$.find( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
282 |
".Ldt-CurrentSegmentInfobox-DescriptionInput" |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
283 |
).val(); |
|
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 |
var _this = this, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
286 |
_exportedAnnotations = new ns.Model.List( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
287 |
this.player.sourceManager |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
288 |
) /* We create an Annotations List to send to the server */, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
289 |
_export = this.player.sourceManager.newLocalSource({ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
290 |
serializer: ns.serializers[this.api_serializer], |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
291 |
}) /* We create a source object using a specific serializer for export */, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
292 |
_annotation = new ns.Model.Annotation( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
293 |
this.currentSegment.id, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
294 |
_export |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
295 |
); /* We create an annotation in the source with a generated ID (param. false) */ |
|
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 |
_annotation.setAnnotationType(this.currentSegment.getAnnotationType().id); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
298 |
_annotation.setMedia(this.currentSegment.getMedia().id); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
299 |
_annotation.setBegin(this.currentSegment.begin); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
300 |
_annotation.setEnd(this.currentSegment.end); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
301 |
_annotation.created = this.currentSegment.created; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
302 |
_annotation.creator = this.currentSegment.creator; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
303 |
_annotation.title = new_title; /* Title field */ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
304 |
_annotation.description = new_description; /* Description field */ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
305 |
var _tagIds = _(new_tags_titles).map(function (_title) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
306 |
var _tags = _this.source.getTags(true).searchByTitle(_title, true); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
307 |
if (_tags.length) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
308 |
var _tag = _tags[0]; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
309 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
310 |
_tag = new ns.Model.Tag(_title.replace(/\W/g, "_"), _this.source); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
311 |
_tag.title = _title; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
312 |
_this.source.getTags().push(_tag); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
313 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
314 |
return _tag.id; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
315 |
}).value(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
316 |
_annotation.setTags(_tagIds); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
317 |
_annotation.project_id = this.project_id; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
318 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
319 |
_exportedAnnotations.push( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
320 |
_annotation |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
321 |
); /* We add the annotation in the list to export */ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
322 |
_export.addList( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
323 |
"annotation", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
324 |
_exportedAnnotations |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
325 |
); /* We add the list to the source object */ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
326 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
327 |
_url = Mustache.render(this.api_endpoint_template, { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
328 |
annotation_id: this.currentSegment.id, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
329 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
330 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
331 |
ns.jQuery.ajax({ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
332 |
url: _url, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
333 |
type: this.api_method, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
334 |
contentType: "application/json", |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
335 |
data: _export.serialize() /* Source is serialized */, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
336 |
success: function (_data) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
337 |
_export |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
338 |
.getAnnotations() |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
339 |
.removeElement( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
340 |
_annotation, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
341 |
true |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
342 |
); /* We delete the sent annotation to avoid redundancy */ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
343 |
_export.deSerialize(_data); /* Data deserialization */ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
344 |
_this.source.merge( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
345 |
_export |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
346 |
); /* We merge the deserialized data with the current source data */ |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
347 |
_this.segments.forEach(function (_segment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
348 |
if (_segment.id == _annotation.id) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
349 |
_this.segments.removeElement(_segment); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
350 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
351 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
352 |
_this.segments.push(_annotation); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
353 |
_this.currentSegment = _annotation; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
354 |
_data = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
355 |
editable_segments: _this.editable_segments, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
356 |
edit: _this.custom_edit_text |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
357 |
? _this.custom_edit_text |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
358 |
: _this.l10n.edit, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
359 |
title: _this.currentSegment.title, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
360 |
description: _this.currentSegment.description, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
361 |
description_placeholder: _this.empty_description_placeholder, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
362 |
tags: _this.currentSegment.getTagTexts(), |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
363 |
}; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
364 |
_this.$.html(Mustache.render(_this.template, _data)); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
365 |
if (_this.editable_segments && _this.currentSegment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
366 |
_this.$.find(".Ldt-CurrentSegmentInfobox").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
367 |
_this.functionWrapper("enableEditMode") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
368 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
369 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
370 |
_this.$.toggleClass("editing", false); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
371 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
372 |
error: function (_xhr, _error, _thrown) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
373 |
ns.log("Error when sending annotation", _thrown); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
374 |
_export.getAnnotations().removeElement(_annotation, true); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
375 |
}, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
376 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
377 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
378 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
379 |
refresh() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
380 |
if (!this.media.getTimeRange()) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
381 |
var _currentTime = this.media.getCurrentTime(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
382 |
var _list = this.segments.filter(function (_segment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
383 |
return _segment.begin <= _currentTime && _segment.end >= _currentTime; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
384 |
}); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
385 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
386 |
if (_list.length > 0) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
387 |
if (this.currentSegment.id != _list[0].id) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
388 |
this.currentSegment = _list[0]; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
389 |
_data = { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
390 |
editable_segments: this.editable_segments, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
391 |
edit: this.custom_edit_text |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
392 |
? this.custom_edit_text |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
393 |
: this.l10n.edit, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
394 |
title: this.currentSegment.title, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
395 |
description: this.currentSegment.description, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
396 |
description_placeholder: this.empty_description_placeholder, |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
397 |
tags: this.currentSegment.getTagTexts(), |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
398 |
}; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
399 |
this.$.html(Mustache.render(this.template, _data)); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
400 |
if (this.editable_segments && this.currentSegment) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
401 |
this.$.find(".Ldt-CurrentSegmentInfobox").click( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
402 |
this.functionWrapper("enableEditMode") |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
403 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
404 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
405 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
406 |
} else { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
407 |
this.currentSegment = false; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
408 |
this.clearBox(); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
409 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
410 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
411 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
412 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
413 |
clearBox() { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
414 |
var _empty_message = this.l10n.empty; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
415 |
if (this.empty_message) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
416 |
_empty_message = this.empty_message; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
417 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
418 |
this.$.find(".Ldt-CurrentSegmentInfobox").html( |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
419 |
"<div class='Ldt-CurrentSegmentInfobox-Element Ldt-CurrentSegmentInfobox-NoSegment'>" + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
420 |
_empty_message + |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
421 |
"</div>" |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
422 |
); |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
423 |
} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
424 |
}; |
|
1040
be314c4ea4ac
New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff
changeset
|
425 |
}; |
|
be314c4ea4ac
New widget CurrentSegmentInfobox that displays infos on currently viewed Segment (future features will allow for possibility to edit title descriptions and tags for current segment)
durandn
parents:
diff
changeset
|
426 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1069
diff
changeset
|
427 |
export { CurrentSegmentInfobox, currentSegmentInfoboxStyles }; |