1 |
efrain |
1 |
define(['jquery', 'core/modal_factory'], function ($, modalFactory) {
|
|
|
2 |
var Main = (function () {
|
|
|
3 |
function Main() {
|
|
|
4 |
}
|
|
|
5 |
Main.prototype.init = function (rawUserParams) {
|
|
|
6 |
var pluginParams = window['amanote_params'];
|
|
|
7 |
var moodleUserParams = Main.parseParams(rawUserParams);
|
|
|
8 |
if (!pluginParams || !moodleUserParams) {
|
|
|
9 |
return;
|
|
|
10 |
}
|
|
|
11 |
MoodleService.init(pluginParams, moodleUserParams, modalFactory);
|
|
|
12 |
var courseModuleFilter = new CourseModuleFilter();
|
|
|
13 |
courseModuleFilter.addButtonToCourseModules();
|
|
|
14 |
};
|
|
|
15 |
Main.parseParams = function (rawParams) {
|
|
|
16 |
try {
|
|
|
17 |
return JSON.parse(rawParams);
|
|
|
18 |
}
|
|
|
19 |
catch (error) {
|
|
|
20 |
console.error(error);
|
|
|
21 |
return null;
|
|
|
22 |
}
|
|
|
23 |
};
|
|
|
24 |
return Main;
|
|
|
25 |
}());
|
|
|
26 |
var MoodleService = (function () {
|
|
|
27 |
function MoodleService(pluginParams, moodleUserParams, modalFactory) {
|
|
|
28 |
this.pluginParams = pluginParams;
|
|
|
29 |
this.moodleUserParams = moodleUserParams;
|
|
|
30 |
this.modalFactory = modalFactory;
|
|
|
31 |
if (MoodleService.instance) {
|
|
|
32 |
throw new Error("Error - Use MoodleService.getInstance()");
|
|
|
33 |
}
|
|
|
34 |
try {
|
|
|
35 |
var userOpeningMode = localStorage.getItem(StorageKeysEnum.OpeningMode);
|
|
|
36 |
if (userOpeningMode !== null) {
|
|
|
37 |
this.pluginParams.plugin.openingMode = userOpeningMode;
|
|
|
38 |
}
|
|
|
39 |
}
|
|
|
40 |
catch (error) {
|
|
|
41 |
console.log(error);
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
MoodleService.prototype.getPluginParams = function () {
|
|
|
45 |
return this.pluginParams;
|
|
|
46 |
};
|
|
|
47 |
MoodleService.prototype.getUserParams = function () {
|
|
|
48 |
return this.moodleUserParams;
|
|
|
49 |
};
|
|
|
50 |
MoodleService.prototype.getModalFactory = function () {
|
|
|
51 |
return this.modalFactory;
|
|
|
52 |
};
|
|
|
53 |
MoodleService.prototype.getAnnotatableByCmId = function (cmid) {
|
|
|
54 |
return (this.pluginParams.annotatables || [])
|
|
|
55 |
.filter(function (cm) { return cm.cmid == cmid; }).pop();
|
|
|
56 |
};
|
|
|
57 |
MoodleService.prototype.getAnnotatableById = function (id) {
|
|
|
58 |
return (this.pluginParams.annotatables || [])
|
|
|
59 |
.filter(function (a) { return a.id == id; }).pop();
|
|
|
60 |
};
|
|
|
61 |
MoodleService.prototype.getAnnotatableByContentPath = function (path) {
|
|
|
62 |
var annotatable = this.pluginParams.annotatables || [];
|
|
|
63 |
for (var i = 0; i < annotatable.length; i++) {
|
|
|
64 |
if (annotatable[i].url === path) {
|
|
|
65 |
return annotatable[i];
|
|
|
66 |
}
|
|
|
67 |
else if (annotatable[i].internal) {
|
|
|
68 |
var path1 = annotatable[i].url;
|
|
|
69 |
var path2 = path.split('pluginfile.php')[1]
|
|
|
70 |
.split('?')[0]
|
|
|
71 |
.replace('intro/0', 'intro')
|
|
|
72 |
.replace('content/0/', 'content/1/');
|
|
|
73 |
path1 = decodeURIComponent(path1 || '');
|
|
|
74 |
path2 = decodeURIComponent(path2 || '');
|
|
|
75 |
if (path1 && path2 && path1 === path2) {
|
|
|
76 |
return annotatable[i];
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
}
|
|
|
80 |
return null;
|
|
|
81 |
};
|
|
|
82 |
MoodleService.prototype.getSavedNoteFilenameForAnnotatable = function (annotatable) {
|
|
|
83 |
var savedNotes = this.pluginParams.savedNotes || {};
|
|
|
84 |
if (savedNotes[annotatable.id + '.ama']) {
|
|
|
85 |
return savedNotes[annotatable.id + '.ama'].filename;
|
|
|
86 |
}
|
|
|
87 |
else if (annotatable.legacyid && savedNotes[annotatable.legacyid + '.ama']) {
|
|
|
88 |
return savedNotes[annotatable.legacyid + '.ama'].filename;
|
|
|
89 |
}
|
|
|
90 |
return null;
|
|
|
91 |
};
|
|
|
92 |
MoodleService.prototype.getLogoForAnnotatable = function (annotatable) {
|
|
|
93 |
if (this.getSavedNoteFilenameForAnnotatable(annotatable)) {
|
|
|
94 |
return this.pluginParams.plugin.annotatedLogo;
|
|
|
95 |
}
|
|
|
96 |
return this.pluginParams.plugin.logo;
|
|
|
97 |
};
|
|
|
98 |
MoodleService.prototype.generateAmanoteURL = function (annotatable, route) {
|
|
|
99 |
if (route === void 0) { route = 'note-taking'; }
|
|
|
100 |
if (!annotatable) {
|
|
|
101 |
return '';
|
|
|
102 |
}
|
|
|
103 |
if (route === 'note-taking' && this.pluginParams.plugin.target != OpeningTargetEnum.Amanote) {
|
|
|
104 |
return "".concat(this.pluginParams.siteURL, "/filter/amanote/annotate.php?annotatableId=").concat(annotatable.id);
|
|
|
105 |
}
|
|
|
106 |
var filePath = annotatable.url;
|
|
|
107 |
if (annotatable.internal && filePath.indexOf('pluginfile.php') >= 0) {
|
|
|
108 |
filePath = filePath.split('pluginfile.php')[1].replace('content/0/', 'content/1/');
|
|
|
109 |
}
|
|
|
110 |
else {
|
|
|
111 |
filePath = encodeURIComponent(filePath);
|
|
|
112 |
}
|
|
|
113 |
var noteFilename = this.getSavedNoteFilenameForAnnotatable(annotatable) || "".concat(annotatable.id, ".ama");
|
|
|
114 |
var amaPath = this.pluginParams.privateFilePath + noteFilename;
|
|
|
115 |
var protocol = 'https';
|
|
|
116 |
if (this.pluginParams.siteURL.indexOf('https') < 0) {
|
|
|
117 |
protocol = 'http';
|
|
|
118 |
}
|
|
|
119 |
if (route === 'note-taking' && annotatable.kind === ContentKindEnum.Video) {
|
|
|
120 |
route = "/note-taking/moodle/video/".concat(annotatable.id);
|
|
|
121 |
}
|
|
|
122 |
else {
|
|
|
123 |
route = "/moodle/".concat(route);
|
|
|
124 |
}
|
|
|
125 |
return protocol + '://app.amanote.com/' + this.pluginParams.language + route + '?' +
|
|
|
126 |
'siteURL=' + this.pluginParams.siteURL + '&' +
|
|
|
127 |
'accessToken=' + this.moodleUserParams.token.value + '&' +
|
|
|
128 |
'tokenExpDate=' + this.moodleUserParams.token.expiration + '&' +
|
|
|
129 |
'userId=' + this.moodleUserParams.id + '&' +
|
|
|
130 |
'filePath=' + filePath + '&' +
|
|
|
131 |
'mimeType=' + annotatable.mimetype + '&' +
|
|
|
132 |
'amaPath=' + amaPath + '&' +
|
|
|
133 |
'resourceId=' + annotatable.id + '&' +
|
|
|
134 |
'legacyResourceId=' + (annotatable.legacyid || annotatable.id) + '&' +
|
|
|
135 |
'saveInProvider=' + (this.pluginParams.plugin.saveInProvider ? '1' : '0') + '&' +
|
|
|
136 |
'providerVersion=' + this.pluginParams.moodle.version + '&' +
|
|
|
137 |
'pluginVersion=' + this.pluginParams.plugin.version + '&' +
|
|
|
138 |
'key=' + this.pluginParams.plugin.key + '&' +
|
|
|
139 |
'worksheet=' + (this.pluginParams.plugin.worksheet ? '1' : '0') + '&' +
|
|
|
140 |
'anonymous=' + (this.pluginParams.plugin.anonymous ? '1' : '0');
|
|
|
141 |
};
|
|
|
142 |
MoodleService.init = function (pluginParams, moodleUserParams, modalFactory) {
|
|
|
143 |
MoodleService.instance = new MoodleService(pluginParams, moodleUserParams, modalFactory);
|
|
|
144 |
};
|
|
|
145 |
MoodleService.getInstance = function () {
|
|
|
146 |
return MoodleService.instance;
|
|
|
147 |
};
|
|
|
148 |
return MoodleService;
|
|
|
149 |
}());
|
|
|
150 |
var CourseModuleFilter = (function () {
|
|
|
151 |
function CourseModuleFilter() {
|
|
|
152 |
this.menuModal = new MenuModal();
|
|
|
153 |
this.moodleService = MoodleService.getInstance();
|
|
|
154 |
this.params = this.moodleService.getPluginParams();
|
|
|
155 |
this.userParams = this.moodleService.getUserParams();
|
|
|
156 |
}
|
|
|
157 |
CourseModuleFilter.prototype.addButtonToCourseModules = function () {
|
|
|
158 |
var _this = this;
|
|
|
159 |
this.addAmanoteButtons();
|
|
|
160 |
if (this.observer) {
|
|
|
161 |
this.observer.disconnect();
|
|
|
162 |
}
|
|
|
163 |
this.observer = new MutationObserver(function (mutationsList) {
|
|
|
164 |
if (_this.doesMutationsContainAnActivity(mutationsList)) {
|
|
|
165 |
_this.addAmanoteButtons();
|
|
|
166 |
}
|
|
|
167 |
});
|
|
|
168 |
var targetNode = document.getElementById('page-content');
|
|
|
169 |
this.observer.observe(targetNode, { childList: true, subtree: true });
|
|
|
170 |
};
|
|
|
171 |
CourseModuleFilter.prototype.doesMutationsContainAnActivity = function (mutationsList) {
|
|
|
172 |
for (var i = 0; i < mutationsList.length; i++) {
|
|
|
173 |
var mutation = mutationsList[i];
|
|
|
174 |
if (mutation.type !== 'childList') {
|
|
|
175 |
continue;
|
|
|
176 |
}
|
|
|
177 |
for (var j = 0; j < mutation.addedNodes.length; j++) {
|
|
|
178 |
var addedNode = mutation.addedNodes[j];
|
|
|
179 |
if ($(addedNode).find('.activityinstance, .activity-instance').length > 0) {
|
|
|
180 |
return true;
|
|
|
181 |
}
|
|
|
182 |
}
|
|
|
183 |
}
|
|
|
184 |
return false;
|
|
|
185 |
};
|
|
|
186 |
CourseModuleFilter.prototype.addAmanoteButtons = function () {
|
|
|
187 |
var _this = this;
|
|
|
188 |
this.forEachNewInstances(['modtype_resource', 'modtype_url'], function (element) {
|
|
|
189 |
var annotatable = _this.getAnnotatableFromElement(element);
|
|
|
190 |
if (!annotatable) {
|
|
|
191 |
return;
|
|
|
192 |
}
|
|
|
193 |
var activityLink = $(element).find('.activitytitle').find('a').first();
|
|
|
194 |
if (activityLink.length === 0) {
|
|
|
195 |
activityLink = $(element).find('a').first();
|
|
|
196 |
}
|
|
|
197 |
if (_this.openWithButton()) {
|
|
|
198 |
var button = _this.generateAmanoteButton(annotatable);
|
|
|
199 |
activityLink.css('display', 'inline-block');
|
|
|
200 |
activityLink.removeClass('stretched-link');
|
|
|
201 |
if ($(element).find('.activity-instance').length > 0) {
|
|
|
202 |
$(element).find('.activity-instance').find('.activityname').children().first().after(button);
|
|
|
203 |
}
|
|
|
204 |
else if ($(element).find('.activity-basis').length > 0) {
|
|
|
205 |
$(element).find('.activity-basis').first().children().children().first().after(button);
|
|
|
206 |
}
|
|
|
207 |
else {
|
|
|
208 |
$(element).find('.activityinstance').first().children().first().after(button);
|
|
|
209 |
}
|
|
|
210 |
}
|
|
|
211 |
else {
|
|
|
212 |
_this.replaceLink(activityLink, annotatable);
|
|
|
213 |
var iconLink = $(element).find('a.activity-icon').first();
|
|
|
214 |
if (iconLink.length > 0) {
|
|
|
215 |
_this.replaceLink(iconLink, annotatable);
|
|
|
216 |
}
|
|
|
217 |
}
|
|
|
218 |
_this.addOnDeleteWarning($(element));
|
|
|
219 |
});
|
|
|
220 |
this.forEachNewInstances(['fp-filename-icon'], function (element) {
|
|
|
221 |
var fileLink = $(element).find('a').first();
|
|
|
222 |
if (fileLink.length !== 1) {
|
|
|
223 |
return;
|
|
|
224 |
}
|
|
|
225 |
var filePath = fileLink.attr('href');
|
|
|
226 |
var annotatable = _this.moodleService.getAnnotatableByContentPath(filePath);
|
|
|
227 |
if (!annotatable) {
|
|
|
228 |
return;
|
|
|
229 |
}
|
|
|
230 |
if (_this.openWithButton()) {
|
|
|
231 |
var button = _this.generateAmanoteButton(annotatable);
|
|
|
232 |
fileLink.css('display', 'inline-block');
|
|
|
233 |
fileLink.after(button);
|
|
|
234 |
}
|
|
|
235 |
else {
|
|
|
236 |
_this.replaceLink(fileLink, annotatable);
|
|
|
237 |
}
|
|
|
238 |
});
|
|
|
239 |
this.forEachNewInstances(['modtype_folder'], function (element) {
|
|
|
240 |
_this.addOnDeleteWarning($(element));
|
|
|
241 |
});
|
|
|
242 |
this.forEachNewInstances(['modtype_label'], function (element) {
|
|
|
243 |
var annotatable = _this.getAnnotatableFromElement(element);
|
|
|
244 |
if (!annotatable) {
|
|
|
245 |
return;
|
|
|
246 |
}
|
|
|
247 |
if (_this.openWithButton()) {
|
|
|
248 |
var button = _this.generateAmanoteButton(annotatable);
|
|
|
249 |
$(element).find('.mediaplugin').first().children().children().first().after(button);
|
|
|
250 |
}
|
|
|
251 |
else {
|
|
|
252 |
_this.replaceLink($(element).find('a').first(), annotatable);
|
|
|
253 |
}
|
|
|
254 |
_this.addOnDeleteWarning($(element));
|
|
|
255 |
});
|
|
|
256 |
setTimeout(function () {
|
|
|
257 |
$(".".concat(CourseModuleFilter.amanoteButtonClass)).on('click', function (event) {
|
|
|
258 |
event.preventDefault();
|
|
|
259 |
var annotatableId = $(event.currentTarget).attr(CourseModuleFilter.annotatableIDAttribute);
|
|
|
260 |
var annotatable = _this.moodleService.getAnnotatableById(annotatableId);
|
|
|
261 |
if (_this.params.plugin.openingMode === OpeningModeEnum.FileClick) {
|
|
|
262 |
annotatable.openInMoodleURL = event.currentTarget.href;
|
|
|
263 |
}
|
|
|
264 |
if ((_this.params.plugin.openingMode !== OpeningModeEnum.FileClick || _this.params.plugin.preventDownload) && !_this.userParams.isTeacher) {
|
|
|
265 |
window.open(_this.moodleService.generateAmanoteURL(annotatable, 'note-taking'), 'blank');
|
|
|
266 |
return;
|
|
|
267 |
}
|
|
|
268 |
_this.menuModal.open(annotatable);
|
|
|
269 |
});
|
|
|
270 |
}, 500);
|
|
|
271 |
};
|
|
|
272 |
CourseModuleFilter.prototype.getAnnotatableFromElement = function (element) {
|
|
|
273 |
var elementId = $(element).attr('id');
|
|
|
274 |
if (!elementId || elementId.indexOf('module-') < 0) {
|
|
|
275 |
return;
|
|
|
276 |
}
|
|
|
277 |
var courseModuleId = parseInt(elementId.replace('module-', ''), 10);
|
|
|
278 |
return this.moodleService.getAnnotatableByCmId(courseModuleId);
|
|
|
279 |
};
|
|
|
280 |
CourseModuleFilter.prototype.openWithButton = function () {
|
|
|
281 |
return this.params.plugin.openingMode !== OpeningModeEnum.FileClick;
|
|
|
282 |
};
|
|
|
283 |
CourseModuleFilter.prototype.forEachNewInstances = function (classNames, action) {
|
|
|
284 |
$('.' + classNames.join(', .')).each(function (index, element) {
|
|
|
285 |
if ($(element).find('.' + CourseModuleFilter.amanoteButtonClass).length > 0) {
|
|
|
286 |
return;
|
|
|
287 |
}
|
|
|
288 |
action(element);
|
|
|
289 |
});
|
|
|
290 |
};
|
|
|
291 |
CourseModuleFilter.prototype.generateAmanoteButton = function (annotatable) {
|
|
|
292 |
var _a;
|
|
|
293 |
var moodleService = MoodleService.getInstance();
|
|
|
294 |
var logo = moodleService.getLogoForAnnotatable(annotatable);
|
|
|
295 |
var widthByMode = (_a = {},
|
|
|
296 |
_a[OpeningModeEnum.FileClick] = 90,
|
|
|
297 |
_a[OpeningModeEnum.LogoNextToFile] = 90,
|
|
|
298 |
_a[OpeningModeEnum.IconNextToFile] = 40,
|
|
|
299 |
_a[OpeningModeEnum.IconNextToFileWithText] = 130,
|
|
|
300 |
_a);
|
|
|
301 |
var width = widthByMode[this.params.plugin.openingMode] || 90;
|
|
|
302 |
var a = $("<a class=\"mx-4 my-2 amanote-button\"><img src=\"".concat(logo, "\" width=\"").concat(width, "px\" alt=\"Open in Amanote\"></a>"));
|
|
|
303 |
a.css('display', 'inline-block');
|
|
|
304 |
a.css('cursor', 'pointer');
|
|
|
305 |
a.css('margin', 'auto');
|
|
|
306 |
if (this.params.plugin.openingMode === OpeningModeEnum.LogoNextToFile) {
|
|
|
307 |
a.css('min-width', '110px');
|
|
|
308 |
}
|
|
|
309 |
a.attr(CourseModuleFilter.annotatableIDAttribute, annotatable.id);
|
|
|
310 |
return a;
|
|
|
311 |
};
|
|
|
312 |
CourseModuleFilter.prototype.replaceLink = function (link, annotatable) {
|
|
|
313 |
link.attr(CourseModuleFilter.annotatableIDAttribute, annotatable.id);
|
|
|
314 |
link.addClass('amanote-button');
|
|
|
315 |
link.css('cursor', 'pointer');
|
|
|
316 |
};
|
|
|
317 |
CourseModuleFilter.prototype.addOnDeleteWarning = function (activity) {
|
|
|
318 |
var _this = this;
|
|
|
319 |
activity.find('.editing_delete').first().on('click', function () {
|
|
|
320 |
setTimeout(function () { _this.menuModal.showDeleteWarning(); }, 500);
|
|
|
321 |
});
|
|
|
322 |
};
|
|
|
323 |
CourseModuleFilter.annotatableIDAttribute = 'annotatable-id';
|
|
|
324 |
CourseModuleFilter.amanoteButtonClass = 'amanote-button';
|
|
|
325 |
return CourseModuleFilter;
|
|
|
326 |
}());
|
|
|
327 |
var MenuModal = (function () {
|
|
|
328 |
function MenuModal() {
|
|
|
329 |
this.moodleService = MoodleService.getInstance();
|
|
|
330 |
this.modalFactory = this.moodleService.getModalFactory();
|
|
|
331 |
this.pluginParams = this.moodleService.getPluginParams();
|
|
|
332 |
this.moodleUserParams = this.moodleService.getUserParams();
|
|
|
333 |
}
|
|
|
334 |
MenuModal.prototype.open = function (annotatable) {
|
|
|
335 |
if (!annotatable) {
|
|
|
336 |
return;
|
|
|
337 |
}
|
|
|
338 |
var modalParams = {
|
|
|
339 |
title: 'Amanote',
|
|
|
340 |
body: this.generateModalBodyHTML(annotatable),
|
|
|
341 |
footer: '',
|
|
|
342 |
};
|
|
|
343 |
return this.modalFactory.create(modalParams)
|
|
|
344 |
.then(function (modal) {
|
|
|
345 |
modal.show();
|
|
|
346 |
});
|
|
|
347 |
};
|
|
|
348 |
MenuModal.prototype.showDeleteWarning = function () {
|
|
|
349 |
var hideDeleteWarningExp = localStorage.getItem(StorageKeysEnum.HideDeleteWarningExp);
|
|
|
350 |
if (hideDeleteWarningExp && !isNaN(Date.parse(hideDeleteWarningExp))) {
|
|
|
351 |
var hideDate = new Date(hideDeleteWarningExp);
|
|
|
352 |
var now = new Date();
|
|
|
353 |
if ((now.getTime() - hideDate.getTime()) < (30 * 24 * 60 * 60 * 1000)) {
|
|
|
354 |
return;
|
|
|
355 |
}
|
|
|
356 |
}
|
|
|
357 |
var guideLink = 'https://help.amanote.com/en/support/solutions/articles/36000448676';
|
|
|
358 |
var message = "<div class=\"alert alert-warning\">\n <strong>Warning</strong>\n <p>".concat(this.pluginParams.strings.deletefilewarning, "</p>\n <p><a href=\"").concat(guideLink, "\" target=\"_blank\">").concat(this.pluginParams.strings.seeguide, "</a></p>\n </div>\n <div style=\"text-align: center; margin-top: 1rem;\">\n <a class=\"text-muted\" style=\"cursor: pointer;\" data-action=\"hide\"\n onclick=\"localStorage.setItem('").concat(StorageKeysEnum.HideDeleteWarningExp, "', new Date().toISOString());\">\n ").concat(this.pluginParams.strings.stopmodal, "\n </a>\n </div>");
|
|
|
359 |
var modalParams = {
|
|
|
360 |
title: 'Amanote Warning',
|
|
|
361 |
body: message,
|
|
|
362 |
footer: '',
|
|
|
363 |
};
|
|
|
364 |
this.modalFactory.create(modalParams)
|
|
|
365 |
.then(function (modal) {
|
|
|
366 |
modal.show();
|
|
|
367 |
});
|
|
|
368 |
};
|
|
|
369 |
MenuModal.prototype.generateModalBodyHTML = function (annotatable) {
|
|
|
370 |
var openInAmanoteURL = this.moodleService.generateAmanoteURL(annotatable, 'note-taking');
|
|
|
371 |
var body = "<p class=\"mb-0 text-muted\">".concat(this.pluginParams.strings.modalDescription, "</p>");
|
|
|
372 |
body += MenuModal.generateButtonHTML(openInAmanoteURL, this.pluginParams.strings.annotateResource, 'fa fa-edit', 'font-weight: 600; background: #2cdf90; color: #03341f; border: none');
|
|
|
373 |
if (this.pluginParams.plugin.openingMode === OpeningModeEnum.FileClick && !this.pluginParams.plugin.preventDownload) {
|
|
|
374 |
body += MenuModal.generateButtonHTML(annotatable.openInMoodleURL, this.pluginParams.strings.viewResource, 'fa fa-eye', 'font-weight: 600;');
|
|
|
375 |
}
|
|
|
376 |
if (this.moodleUserParams.isTeacher && annotatable.kind === ContentKindEnum.Document) {
|
|
|
377 |
body += '<hr style="margin-bottom: 0px">';
|
|
|
378 |
var openAnalyticsURL = this.moodleService.generateAmanoteURL(annotatable, "document-analytics/".concat(annotatable.id, "/view"));
|
|
|
379 |
body += MenuModal.generateButtonHTML(openAnalyticsURL, this.pluginParams.strings.openAnalytics);
|
|
|
380 |
if (this.pluginParams.plugin.key && !this.pluginParams.plugin.anonymous) {
|
|
|
381 |
var openPodcastCreatorURL = this.moodleService.generateAmanoteURL(annotatable, 'podcast/creator');
|
|
|
382 |
body += MenuModal.generateButtonHTML(openPodcastCreatorURL, this.pluginParams.strings.openPodcastCreator);
|
|
|
383 |
}
|
|
|
384 |
if (this.pluginParams.plugin.worksheet && !this.pluginParams.plugin.anonymous) {
|
|
|
385 |
var openStudentWorkURL = this.moodleService.generateAmanoteURL(annotatable, "document-analytics/".concat(annotatable.id, "/notes"));
|
|
|
386 |
body += MenuModal.generateButtonHTML(openStudentWorkURL, this.pluginParams.strings.openStudentsWorks);
|
|
|
387 |
}
|
|
|
388 |
}
|
|
|
389 |
if (this.pluginParams.plugin.openingMode === OpeningModeEnum.FileClick &&
|
|
|
390 |
!this.moodleUserParams.isTeacher &&
|
|
|
391 |
!this.pluginParams.plugin.preventDownload) {
|
|
|
392 |
body += "\n <div style=\"text-align: center; margin-top: 1rem;\">\n <a class=\"text-muted\" style=\"cursor: pointer;\" data-action=\"hide\"\n onclick=\"localStorage.setItem('".concat(StorageKeysEnum.OpeningMode, "', '").concat(OpeningModeEnum.LogoNextToFile, "'); location.reload()\">\n ").concat(this.pluginParams.strings.stopmodal, "\n </a>\n </div>");
|
|
|
393 |
}
|
|
|
394 |
return body;
|
|
|
395 |
};
|
|
|
396 |
MenuModal.generateButtonHTML = function (href, title, faIconClass, style) {
|
|
|
397 |
if (style === void 0) { style = ''; }
|
|
|
398 |
var faIconHTML = '';
|
|
|
399 |
if (faIconClass) {
|
|
|
400 |
faIconHTML = "<i class=\"".concat(faIconClass, " mr-2\"></i> ");
|
|
|
401 |
}
|
|
|
402 |
return "<a class=\"btn btn-secondary\" style=\"width: 100%; margin-top: 1rem; ".concat(style, "\" href=\"").concat(href, "\" target=\"_blank\">").concat(faIconHTML).concat(title, "</a>");
|
|
|
403 |
};
|
|
|
404 |
return MenuModal;
|
|
|
405 |
}());
|
|
|
406 |
return new Main();
|
|
|
407 |
});
|
|
|
408 |
var OpeningModeEnum;
|
|
|
409 |
(function (OpeningModeEnum) {
|
|
|
410 |
OpeningModeEnum["FileClick"] = "0";
|
|
|
411 |
OpeningModeEnum["LogoNextToFile"] = "1";
|
|
|
412 |
OpeningModeEnum["IconNextToFile"] = "2";
|
|
|
413 |
OpeningModeEnum["IconNextToFileWithText"] = "3";
|
|
|
414 |
})(OpeningModeEnum || (OpeningModeEnum = {}));
|
|
|
415 |
var OpeningTargetEnum;
|
|
|
416 |
(function (OpeningTargetEnum) {
|
|
|
417 |
OpeningTargetEnum["Amanote"] = "0";
|
|
|
418 |
OpeningTargetEnum["MoodleFullscreen"] = "1";
|
|
|
419 |
OpeningTargetEnum["MoodleEmbedded"] = "2";
|
|
|
420 |
})(OpeningTargetEnum || (OpeningTargetEnum = {}));
|
|
|
421 |
var ContentKindEnum;
|
|
|
422 |
(function (ContentKindEnum) {
|
|
|
423 |
ContentKindEnum["Document"] = "document";
|
|
|
424 |
ContentKindEnum["Video"] = "video";
|
|
|
425 |
})(ContentKindEnum || (ContentKindEnum = {}));
|
|
|
426 |
var StorageKeysEnum;
|
|
|
427 |
(function (StorageKeysEnum) {
|
|
|
428 |
StorageKeysEnum["OpeningMode"] = "amanote.preferences.openingMode";
|
|
|
429 |
StorageKeysEnum["HideDeleteWarningExp"] = "amanote.preferences.hideDeleteWarningExp";
|
|
|
430 |
})(StorageKeysEnum || (StorageKeysEnum = {}));
|
|
|
431 |
//# sourceMappingURL=main.js.map
|