This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
forked from andreknieriem/photobooth
-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
tools.js
62 lines (52 loc) · 1.54 KB
/
tools.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* globals i18n */
const photoboothTools = (function () {
// vars
const api = {};
api.console = {
log: function (...content) {
console.log('[', new Date().toISOString(), ']:', content);
},
logDev: function (...content) {
if (config.dev.enabled) {
console.log('[', new Date().toISOString(), ']:', content);
}
}
};
api.getTranslation = function (key) {
const translation = i18n(key, config.ui.language);
const fallbackTranslation = i18n(key, 'en');
if (translation) {
return translation;
} else if (fallbackTranslation) {
return fallbackTranslation;
}
return key;
};
api.modal = {
open: function (selector) {
$(selector).addClass('modal--show');
},
close: function (selector) {
if ($(selector).hasClass('modal--show')) {
$(selector).removeClass('modal--show');
return true;
}
return false;
},
toggle: function (selector) {
$(selector).toggleClass('modal--show');
},
empty: function (selector) {
api.modal.close(selector);
$(selector).find('.modal__body').empty();
}
};
api.reloadPage = function () {
window.location.reload();
};
return api;
})();
// Init on domready
$(function () {
photoboothTools.console.log('Dev mode:', config.dev.enabled ? 'enabled' : 'disabled');
});