j1-template 2021.2.10 → 2021.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/blocks/footer/boxes/contacts_box.proc +1 -1
- data/_includes/themes/j1/layouts/content_generator_article_navigator.html +2 -2
- data/_includes/themes/j1/layouts/content_generator_blog_archive.html +2 -2
- data/_includes/themes/j1/layouts/content_generator_news_panel_posts.html +2 -2
- data/_includes/themes/j1/modules/boards/news_pin_board.html +10 -10
- data/_includes/themes/j1/modules/connectors/translators/google-translator.html +18 -3
- data/_includes/themes/j1/modules/navigator/generator.html +6 -6
- data/_includes/themes/j1/procedures/posts/collate_calendar.proc +3 -3
- data/_includes/themes/j1/procedures/posts/create_series_header.proc +1 -1
- data/_includes/themes/j1/procedures/posts/pager.proc +1 -1
- data/assets/data/gallery_customizer.html +1 -1
- data/assets/data/menu.html +17 -17
- data/assets/data/mmenu.html +17 -17
- data/assets/data/quicklinks.html +3 -3
- data/assets/themes/j1/adapter/js/j1.js +1 -1
- data/assets/themes/j1/adapter/js/translator.js +17 -3
- data/assets/themes/j1/modules/backstretch/js/backstretch.min.js +1 -1
- data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.full.js +1 -1
- data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.js +1 -1
- data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.min.js +1 -1
- data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js +1 -1
- data/assets/themes/j1/modules/datatables/js/datatables.js +1 -1
- data/assets/themes/j1/modules/datatables/js/datatables.min.js +5 -5
- data/assets/themes/j1/modules/iframeResizer/examples/frame.absolute.html +3 -3
- data/assets/themes/j1/modules/iframeResizer/examples/frame.content.html +6 -6
- data/assets/themes/j1/modules/iframeResizer/examples/frame.tolerance.html +2 -2
- data/assets/themes/j1/modules/iframeResizer/js/client/iframeResizer.contentWindow.js +1 -1
- data/assets/themes/j1/modules/iframeResizer/js/client/iframeResizer.contentWindow.min.js +1 -1
- data/assets/themes/j1/modules/iframeResizer/js/resizer.min.js +1 -1
- data/assets/themes/j1/modules/j1Deepl/js/j1deepl.min.js +1 -1
- data/assets/themes/j1/modules/j1Scroll/js/j1scroll.js +1 -1
- data/assets/themes/j1/modules/j1Scroll/js/j1scroll.min.js +1 -1
- data/assets/themes/j1/modules/jquery/js/jquery.js +2 -2
- data/assets/themes/j1/modules/jquery/js/jquery.min.js +1 -1
- data/assets/themes/j1/modules/jquery/js/jqueryUI.js +7 -7
- data/assets/themes/j1/modules/jquery/js/jqueryUI.min.js +3 -3
- data/assets/themes/j1/modules/lightGallery/js/core/j1/lightgallery-x.min.js +1 -1
- data/assets/themes/j1/modules/lightGallery/js/core/lightgallery.min.js +1 -1
- data/assets/themes/j1/modules/lightGallery/js/modules/j1/j1-video.min.js +1 -1
- data/assets/themes/j1/modules/lightGallery/js/modules/j1/j1-x-video.min.js +1 -1
- data/assets/themes/j1/modules/lightbox/js/lightbox.js +1 -1
- data/assets/themes/j1/modules/lightbox/js/lightbox.min.js +1 -1
- data/assets/themes/j1/modules/lunrSearch/js/mustache.js +1 -1
- data/assets/themes/j1/modules/lunrSearch/js/mustache.min.js +1 -1
- data/assets/themes/j1/modules/lunrSearch/js/uri.js +1 -1
- data/assets/themes/j1/modules/lunrSearch/js/uri.min.js +7 -7
- data/assets/themes/j1/modules/mdiPreviewer/js/previewer.min.js +1 -1
- data/assets/themes/j1/modules/mdilPreviewer/js/previewer.min.js +1 -1
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.js +1 -1
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.min.js +1 -1
- data/assets/themes/j1/modules/translator/js/translator.js +4 -2
- data/assets/themes/j1/modules/translator/js/translator.min.js +1 -1
- data/assets/themes/j1/modules/twemoji/js/picker/twemoji-picker.js +1 -1
- data/assets/themes/j1/modules/twemoji/js/picker/twemoji-picker.min.js +1 -1
- data/assets/themes/j1/modules/videojs/js/video.min.js +2 -2
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/Gemfile +1 -1
- data/lib/starter_web/_config.yml +1 -1
- data/lib/starter_web/_data/apps/carousel.yml +4 -4
- data/lib/starter_web/_data/blocks/defaults/footer.yml +2 -2
- data/lib/starter_web/_data/blocks/footer.yml +2 -2
- data/lib/starter_web/_data/modules/attics.yml +1 -1
- data/lib/starter_web/_data/modules/defaults/attics.yml +2 -2
- data/lib/starter_web/_data/modules/defaults/translator.yml +1 -0
- data/lib/starter_web/_data/modules/translator.yml +3 -0
- data/lib/starter_web/_includes/attributes.asciidoc +1 -1
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/blog/navigator/archive/dateview.html +2 -2
- data/lib/starter_web/pages/public/blog/navigator/archive/tagview.html +3 -3
- data/lib/starter_web/pages/public/previewer/preview_bootstrap_theme.adoc +85 -85
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +2 -3
- data/assets/themes/j1/adapter/js/translator.1.js +0 -525
@@ -1,525 +0,0 @@
|
|
1
|
-
---
|
2
|
-
regenerate: true
|
3
|
-
---
|
4
|
-
|
5
|
-
{% capture cache %}
|
6
|
-
|
7
|
-
{% comment %}
|
8
|
-
# -----------------------------------------------------------------------------
|
9
|
-
# ~/assets/themes/j1/adapter/js/translator.js
|
10
|
-
# Liquid template to create the Template Adapter for J1 Translator
|
11
|
-
#
|
12
|
-
# Product/Info:
|
13
|
-
# http://jekyll.one
|
14
|
-
#
|
15
|
-
# Copyright (C) 2021 Juergen Adams
|
16
|
-
#
|
17
|
-
# J1 Template is licensed under the MIT License.
|
18
|
-
# For details, see https://jekyll.one
|
19
|
-
# -----------------------------------------------------------------------------
|
20
|
-
# Test data:
|
21
|
-
# {{ liquid_var | debug }}
|
22
|
-
# -----------------------------------------------------------------------------
|
23
|
-
{% endcomment %}
|
24
|
-
|
25
|
-
{% comment %} Liquid var initialization
|
26
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
27
|
-
|
28
|
-
{% comment %} Set config files
|
29
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
30
|
-
{% assign environment = site.environment %}
|
31
|
-
{% assign blocks = site.data.blocks %}
|
32
|
-
{% assign modules = site.data.modules %}
|
33
|
-
{% assign template_config = site.data.j1_config %}
|
34
|
-
|
35
|
-
{% comment %} Set config data
|
36
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
37
|
-
{% assign translator_defaults = modules.defaults.translator.defaults %}
|
38
|
-
{% assign translator_settings = modules.translator.settings %}
|
39
|
-
{% assign tracking_enabled = template_config.analytics.enabled %}
|
40
|
-
|
41
|
-
|
42
|
-
{% comment %} Set config options
|
43
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
44
|
-
{% assign translator_options = translator_defaults | merge: translator_settings %}
|
45
|
-
|
46
|
-
{% assign production = false %}
|
47
|
-
{% if environment == 'prod' or environment == 'production' %}
|
48
|
-
{% assign production = true %}
|
49
|
-
{% endif %}
|
50
|
-
|
51
|
-
/*
|
52
|
-
# -----------------------------------------------------------------------------
|
53
|
-
# ~/assets/themes/j1/adapter/js/translator.js
|
54
|
-
# JS Adapter for J1 Translate
|
55
|
-
#
|
56
|
-
# Product/Info:
|
57
|
-
# http://jekyll.one
|
58
|
-
#
|
59
|
-
# Copyright (C) 2021 Juergen Adams
|
60
|
-
#
|
61
|
-
# J1 Template is licensed under MIT License.
|
62
|
-
# See: https://github.com/jekyll-one/J1 Template/blob/master/LICENSE
|
63
|
-
# -----------------------------------------------------------------------------
|
64
|
-
# Adapter generated: {{site.time}}
|
65
|
-
# -----------------------------------------------------------------------------
|
66
|
-
*/
|
67
|
-
|
68
|
-
// -----------------------------------------------------------------------------
|
69
|
-
// ESLint shimming
|
70
|
-
// -----------------------------------------------------------------------------
|
71
|
-
/* eslint indent: "off" */
|
72
|
-
/* eslint quotes: "off" */
|
73
|
-
// -----------------------------------------------------------------------------
|
74
|
-
// https://github.com/EdwardBalaj/Simple-DeepL-API-Integration
|
75
|
-
// https://github.com/marghoobsuleman/ms-Dropdown
|
76
|
-
// https://www.marghoobsuleman.com/image-dropdown/help
|
77
|
-
// https://www.marghoobsuleman.com/image-dropdown/advanced-help
|
78
|
-
'use strict';
|
79
|
-
|
80
|
-
{% comment %} Main
|
81
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
82
|
-
j1.adapter['translator'] = (function (j1, window) {
|
83
|
-
|
84
|
-
var environment = '{{environment}}';
|
85
|
-
var tracking_enabled = ('{{tracking_enabled}}' === 'true') ? true: false; // Analytics/GA enabled?
|
86
|
-
var moduleOptions = {};
|
87
|
-
var user_translate = {};
|
88
|
-
var _this;
|
89
|
-
var $modal;
|
90
|
-
var domain;
|
91
|
-
var cookie_names;
|
92
|
-
var user_consent;
|
93
|
-
var logger;
|
94
|
-
var url;
|
95
|
-
var baseUrl;
|
96
|
-
var hostname;
|
97
|
-
var domain;
|
98
|
-
var cookie_sub_domains;
|
99
|
-
var secure;
|
100
|
-
var logText;
|
101
|
-
var cookie_written;
|
102
|
-
var modal_language;
|
103
|
-
var navigator_language;
|
104
|
-
var translation_language;
|
105
|
-
var ddSourceLanguage;
|
106
|
-
var head;
|
107
|
-
var script;
|
108
|
-
var languageList;
|
109
|
-
|
110
|
-
// ---------------------------------------------------------------------------
|
111
|
-
// helper functions
|
112
|
-
// ---------------------------------------------------------------------------
|
113
|
-
|
114
|
-
// ---------------------------------------------------------------------------
|
115
|
-
// setCookie()
|
116
|
-
// writes a flat cookie (not using an encoded JSON string)
|
117
|
-
// ---------------------------------------------------------------------------
|
118
|
-
function setCookie(options /*cName, cValue, expDays*/) {
|
119
|
-
var defaults = {};
|
120
|
-
var settings;
|
121
|
-
var document_cookie;
|
122
|
-
var stringifiedAttributes = '';
|
123
|
-
|
124
|
-
defaults = {
|
125
|
-
name: '',
|
126
|
-
path: '/',
|
127
|
-
expires: 0,
|
128
|
-
domain: 'localhost',
|
129
|
-
samesite: 'Strict',
|
130
|
-
http_only: false,
|
131
|
-
secure: false
|
132
|
-
};
|
133
|
-
settings = $.extend(defaults, options);
|
134
|
-
|
135
|
-
stringifiedAttributes += '; ' + 'path=' + settings.path;
|
136
|
-
|
137
|
-
if (settings.expires > 0) {
|
138
|
-
date.setTime(date.getTime() + (settings.expires * 24 * 60 * 60 * 1000));
|
139
|
-
stringifiedAttributes += '; ' + 'expires=' + date.toUTCString();
|
140
|
-
}
|
141
|
-
|
142
|
-
stringifiedAttributes += '; ' + 'SameSite=' + settings.samesite;
|
143
|
-
|
144
|
-
if (settings.secure) {
|
145
|
-
stringifiedAttributes += '; ' + 'secure=' + settings.secure;
|
146
|
-
}
|
147
|
-
|
148
|
-
// document_cookie = settings.name + '=' + settings.data + '; path=' + settings.path + '; ' + 'domain=' + settings.domain + '; ' + 'SameSite=' + settings.samesite + ';';
|
149
|
-
document_cookie = settings.name + '=' + settings.data + stringifiedAttributes;
|
150
|
-
|
151
|
-
document.cookie = document_cookie;
|
152
|
-
};
|
153
|
-
|
154
|
-
// ---------------------------------------------------------------------------
|
155
|
-
// Main object
|
156
|
-
// ---------------------------------------------------------------------------
|
157
|
-
return {
|
158
|
-
|
159
|
-
// -------------------------------------------------------------------------
|
160
|
-
// Initializer
|
161
|
-
// -------------------------------------------------------------------------
|
162
|
-
init: function (options) {
|
163
|
-
|
164
|
-
// -----------------------------------------------------------------------
|
165
|
-
// globals
|
166
|
-
// -----------------------------------------------------------------------
|
167
|
-
_this = j1.adapter.translator;
|
168
|
-
logger = log4javascript.getLogger('j1.adapter.translator');
|
169
|
-
url = new liteURL(window.location.href);
|
170
|
-
baseUrl = url.origin;
|
171
|
-
hostname = url.hostname;
|
172
|
-
domain = hostname.substring(hostname.lastIndexOf('.', hostname.lastIndexOf('.') - 1) + 1);
|
173
|
-
secure = (url.protocol.includes('https')) ? true : false;
|
174
|
-
modal_language = "{{site.language}}";
|
175
|
-
navigator_language = navigator.language || navigator.userLanguage; // userLanguage for MS IE compatibility
|
176
|
-
translation_language = navigator_language.split('-')[0];
|
177
|
-
cookie_names = j1.getCookieNames();
|
178
|
-
head = document.getElementsByTagName('head')[0];
|
179
|
-
script = document.createElement('script');
|
180
|
-
script.id = 'google-translate';
|
181
|
-
script.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
|
182
|
-
|
183
|
-
user_translate = {
|
184
|
-
'translatorName': 'google',
|
185
|
-
'translationEnabled': false,
|
186
|
-
'analysis': true,
|
187
|
-
'personalization': true,
|
188
|
-
'translateAllPages': true,
|
189
|
-
'useLanguageFromBrowser': true,
|
190
|
-
'translationLanguage': translation_language,
|
191
|
-
};
|
192
|
-
|
193
|
-
// set domain used by cookies
|
194
|
-
if(domain !== 'localhost') {
|
195
|
-
cookie_sub_domains = '.' + hostname;
|
196
|
-
} else {
|
197
|
-
cookie_sub_domains = hostname;
|
198
|
-
}
|
199
|
-
|
200
|
-
if (j1.existsCookie(cookie_names.user_translate)) {
|
201
|
-
user_translate = j1.readCookie(cookie_names.user_translate);
|
202
|
-
} else {
|
203
|
-
logger.debug('\n' + 'write to cookie : ' + cookie_names.user_translate);
|
204
|
-
cookie_written = j1.writeCookie({
|
205
|
-
name: cookie_names.user_translate,
|
206
|
-
data: user_translate,
|
207
|
-
samesite: 'Strict',
|
208
|
-
expires: 365
|
209
|
-
});
|
210
|
-
}
|
211
|
-
|
212
|
-
// set domain used by cookies
|
213
|
-
if(domain !== 'localhost') {
|
214
|
-
cookie_sub_domains = '.' + hostname;
|
215
|
-
} else {
|
216
|
-
cookie_sub_domains = hostname;
|
217
|
-
}
|
218
|
-
|
219
|
-
// initialize state flag
|
220
|
-
_this.state = 'pending';
|
221
|
-
// _this.settings.languageList = '/assets/data/ms_select.json';
|
222
|
-
|
223
|
-
// -----------------------------------------------------------------------
|
224
|
-
// Default module settings
|
225
|
-
// -----------------------------------------------------------------------
|
226
|
-
var settings = $.extend({
|
227
|
-
module_name: 'j1.adapter.translator',
|
228
|
-
generated: '{{site.time}}'
|
229
|
-
}, options);
|
230
|
-
|
231
|
-
{% comment %} Load module config from yml data
|
232
|
-
-------------------------------------------------------------------------- {% endcomment %}
|
233
|
-
// Load module DEFAULTS|CONFIG
|
234
|
-
/* eslint-disable */
|
235
|
-
moduleOptions = $.extend({}, {{translator_options | replace: '=>', ':' | replace: 'nil', '""'}});
|
236
|
-
/* eslint-enable */
|
237
|
-
|
238
|
-
if (typeof settings !== 'undefined') {
|
239
|
-
moduleOptions = j1.mergeData(moduleOptions, settings);
|
240
|
-
}
|
241
|
-
|
242
|
-
// -----------------------------------------------------------------------
|
243
|
-
// initializer
|
244
|
-
// -----------------------------------------------------------------------
|
245
|
-
var dependencies_met_page_ready = setInterval (function (options) {
|
246
|
-
user_consent = j1.readCookie(cookie_names.user_consent);
|
247
|
-
|
248
|
-
if ( j1.getState() === 'finished' ) {
|
249
|
-
_this.setState('started');
|
250
|
-
logger.info('\n' + 'state: ' + _this.getState());
|
251
|
-
logger.info('\n' + 'module is being initialized');
|
252
|
-
|
253
|
-
if ($('google_translate_element')) {
|
254
|
-
$('google_translate_element').hide();
|
255
|
-
}
|
256
|
-
|
257
|
-
// show|hide translate button if enabled
|
258
|
-
if (moduleOptions.hideTranslatorIcon) {
|
259
|
-
if (!user_consent.analysis || !user_consent.personalization) {
|
260
|
-
// disable google translate button if visible
|
261
|
-
if ($('#quickLinksTranslateButton').css('display') === 'block') {
|
262
|
-
$('#quickLinksTranslateButton').css('display', 'none');
|
263
|
-
}
|
264
|
-
}
|
265
|
-
if (user_consent.analysis && user_consent.personalization) {
|
266
|
-
// enable google translate button if not visible
|
267
|
-
if ($('#quickLinksTranslateButton').css('display') === 'none') {
|
268
|
-
$('#quickLinksTranslateButton').css('display', 'block');
|
269
|
-
}
|
270
|
-
}
|
271
|
-
}
|
272
|
-
|
273
|
-
// update user_translate cookie
|
274
|
-
user_translate.analysis = user_consent.analysis;
|
275
|
-
user_translate.personalization = user_consent.personalization;
|
276
|
-
cookie_written = j1.writeCookie({
|
277
|
-
name: cookie_names.user_translate,
|
278
|
-
data: user_translate,
|
279
|
-
samesite: 'Strict',
|
280
|
-
secure: secure
|
281
|
-
});
|
282
|
-
|
283
|
-
j1.translator = new Translator({
|
284
|
-
contentURL: moduleOptions.contentURL, // dialog content (modals) for all supported languages
|
285
|
-
cookieName: moduleOptions.cookieName, // the name of the User State Cookie (primary data)
|
286
|
-
cookieConsentName: moduleOptions.cookieConsentName, // the name of the Cookie Consent Cookie (secondary data)
|
287
|
-
disableLanguageSelector: moduleOptions.disableLanguageSelector, // disable language dropdown for translation in dialog (modal)
|
288
|
-
dialogContainerID: moduleOptions.dialogContainerID, // dest container, the dialog modal is loaded (dynamically)
|
289
|
-
dialogLanguage: moduleOptions.dialogLanguage, // language for the dialog (modal)
|
290
|
-
translationLanguage: moduleOptions.translationLanguage, // default language for translation
|
291
|
-
translationLanguages: moduleOptions.google.translationLanguages,// supported languages for translation
|
292
|
-
translationEnabled: moduleOptions.translationEnabled, // run translation enabled|disabled
|
293
|
-
translatorName: moduleOptions.translatorName, // translator used for translation
|
294
|
-
xhrDataElement: moduleOptions.xhrDataElement, // container for all language-specific dialogs (modals)
|
295
|
-
postSelectionCallback: moduleOptions.google.postSelectionCallback
|
296
|
-
});
|
297
|
-
|
298
|
-
if (user_consent.analysis && user_consent.personalization && user_translate.translationEnabled) {
|
299
|
-
if (moduleOptions.translatorName === 'google') {
|
300
|
-
head.appendChild(script);
|
301
|
-
if ($('google_translate_element')) {
|
302
|
-
$('google_translate_element').hide();
|
303
|
-
}
|
304
|
-
}
|
305
|
-
} else {
|
306
|
-
if (moduleOptions.translatorName === 'google') {
|
307
|
-
j1.removeCookie({name: 'googtrans', domain: domain});
|
308
|
-
}
|
309
|
-
}
|
310
|
-
|
311
|
-
_this.setState('finished');
|
312
|
-
logger.info('\n' + 'state: ' + _this.getState());
|
313
|
-
logger.debug('\n' + 'module initialized successfully');
|
314
|
-
clearInterval(dependencies_met_page_ready);
|
315
|
-
}
|
316
|
-
});
|
317
|
-
}, // END init
|
318
|
-
|
319
|
-
// -------------------------------------------------------------------------
|
320
|
-
// messageHandler: MessageHandler for J1 google_translate module
|
321
|
-
// Manage messages send from other J1 modules
|
322
|
-
// -------------------------------------------------------------------------
|
323
|
-
messageHandler: function (sender, message) {
|
324
|
-
var json_message = JSON.stringify(message, undefined, 2);
|
325
|
-
|
326
|
-
logText = '\n' + 'received message from ' + sender + ': ' + json_message;
|
327
|
-
logger.debug(logText);
|
328
|
-
|
329
|
-
// -----------------------------------------------------------------------
|
330
|
-
// Process commands|actions
|
331
|
-
// -----------------------------------------------------------------------
|
332
|
-
if (message.type === 'command' && message.action === 'module_initialized') {
|
333
|
-
//
|
334
|
-
// Place handling of command|action here
|
335
|
-
//
|
336
|
-
logger.info('\n' + message.text);
|
337
|
-
}
|
338
|
-
|
339
|
-
//
|
340
|
-
// Place handling of other command|action here
|
341
|
-
//
|
342
|
-
|
343
|
-
return true;
|
344
|
-
}, // END messageHandler
|
345
|
-
|
346
|
-
// -------------------------------------------------------------------------
|
347
|
-
// setState()
|
348
|
-
// Sets the current (processing) state of the module
|
349
|
-
// -------------------------------------------------------------------------
|
350
|
-
setState: function (stat) {
|
351
|
-
_this.state = stat;
|
352
|
-
}, // END setState
|
353
|
-
|
354
|
-
// -------------------------------------------------------------------------
|
355
|
-
// getState()
|
356
|
-
// Returns the current (processing) state of the module
|
357
|
-
// -------------------------------------------------------------------------
|
358
|
-
getState: function () {
|
359
|
-
return _this.state;
|
360
|
-
}, // END getState
|
361
|
-
|
362
|
-
// -------------------------------------------------------------------------
|
363
|
-
// postTranslateElementInit()
|
364
|
-
// ???
|
365
|
-
// -------------------------------------------------------------------------
|
366
|
-
postTranslateElementInit: function () {
|
367
|
-
// var transCode = '/en/de';
|
368
|
-
//
|
369
|
-
// // set the transCode cookie (googtrans)
|
370
|
-
// setCookie({
|
371
|
-
// name: 'googtrans',
|
372
|
-
// data: transCode
|
373
|
-
// });
|
374
|
-
// j1.removeCookie({name: 'googtrans', domain: domain});
|
375
|
-
return;
|
376
|
-
}, // END postTranslateElementInit
|
377
|
-
|
378
|
-
// -------------------------------------------------------------------------
|
379
|
-
// cbGoogle()
|
380
|
-
// Called by the translator CORE module after the user
|
381
|
-
// has made the lanuage selection for translation (callback)
|
382
|
-
// -------------------------------------------------------------------------
|
383
|
-
cbGoogle: function () {
|
384
|
-
var cookie_names = j1.getCookieNames();
|
385
|
-
var user_state = j1.readCookie(cookie_names.user_state);
|
386
|
-
var user_consent = j1.readCookie(cookie_names.user_consent);
|
387
|
-
var user_translate = j1.readCookie(cookie_names.user_translate);
|
388
|
-
var msDropdownLang = document.getElementById('dropdownJSON').msDropdown;
|
389
|
-
var msDropdown = document.getElementById('dropdownJSON').msDropdown;
|
390
|
-
var head;
|
391
|
-
var script;
|
392
|
-
var srcLang;
|
393
|
-
var destLang;
|
394
|
-
var transCode;
|
395
|
-
var cookie_written;
|
396
|
-
var htmlScriptElement;
|
397
|
-
var selectedTranslationLanguage;
|
398
|
-
|
399
|
-
logger.info('\n' + 'entered post selection callback from google_translate');
|
400
|
-
logger.debug('\n' + 'current values from cookie consent: ' + JSON.stringify(user_consent));
|
401
|
-
logger.debug('\n' + 'current values from user state: ' + JSON.stringify(user_state));
|
402
|
-
|
403
|
-
selectedTranslationLanguage = msDropdownLang.value;
|
404
|
-
logger.info('\n' + 'selected translation language: ' + selectedTranslationLanguage);
|
405
|
-
|
406
|
-
// update cookie consent settings
|
407
|
-
user_consent.analysis = user_translate.analysis;
|
408
|
-
user_consent.personalization = user_translate.personalization;
|
409
|
-
|
410
|
-
cookie_written = j1.writeCookie({
|
411
|
-
name: cookie_names.user_consent,
|
412
|
-
data: user_consent,
|
413
|
-
samesite: 'Strict',
|
414
|
-
secure: secure,
|
415
|
-
expires: 0
|
416
|
-
});
|
417
|
-
|
418
|
-
// translation allowed
|
419
|
-
if (user_consent.analysis && user_consent.personalization) {
|
420
|
-
head = document.getElementsByTagName('head')[0];
|
421
|
-
script = document.createElement('script');
|
422
|
-
script.id = 'google-translate';
|
423
|
-
script.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
|
424
|
-
htmlScriptElement = document.getElementById(script.id);
|
425
|
-
|
426
|
-
if (user_translate.translationEnabled && moduleOptions.translatorName === 'google') {
|
427
|
-
// head.appendChild(script);
|
428
|
-
|
429
|
-
if ($('google_translate_element')) {
|
430
|
-
$('google_translate_element').hide();
|
431
|
-
}
|
432
|
-
|
433
|
-
// set transCode settings
|
434
|
-
srcLang = "{{site.language}}";
|
435
|
-
destLang = translation_language;
|
436
|
-
transCode = '/' + srcLang + '/' + selectedTranslationLanguage;
|
437
|
-
|
438
|
-
// set the transCode cookie (googtrans)
|
439
|
-
setCookie({
|
440
|
-
name: 'googtrans',
|
441
|
-
data: transCode
|
442
|
-
});
|
443
|
-
|
444
|
-
// enable google transalate button if not visible
|
445
|
-
if ($('#quickLinksTranslateButton').css('display') === 'none') {
|
446
|
-
$('#quickLinksTranslateButton').css('display', 'block');
|
447
|
-
}
|
448
|
-
} else { // translation NOT allowed
|
449
|
-
|
450
|
-
// update cookie user translate settings
|
451
|
-
user_translate.translationEnabled = false;
|
452
|
-
cookie_written = j1.writeCookie({
|
453
|
-
name: cookie_names.user_translate,
|
454
|
-
data: user_translate,
|
455
|
-
samesite: 'Strict',
|
456
|
-
secure: secure
|
457
|
-
});
|
458
|
-
|
459
|
-
// stop translation for all pages
|
460
|
-
if (htmlScriptElement) { htmlScriptElement.remove(); }
|
461
|
-
j1.removeCookie({name: 'googtrans', domain: domain});
|
462
|
-
}
|
463
|
-
}
|
464
|
-
|
465
|
-
// translation NOT allowed
|
466
|
-
if (!user_translate.analysis || !user_translate.personalization) {
|
467
|
-
head = document.getElementsByTagName('head')[0];
|
468
|
-
script = document.createElement('script');
|
469
|
-
script.id = 'google-translate';
|
470
|
-
|
471
|
-
// update cookie consent settings
|
472
|
-
user_consent.analysis = user_translate.analysis;
|
473
|
-
user_consent.personalization = user_translate.personalization;
|
474
|
-
cookie_written = j1.writeCookie({
|
475
|
-
name: cookie_names.user_consent,
|
476
|
-
data: user_consent,
|
477
|
-
samesite: 'Strict',
|
478
|
-
secure: secure,
|
479
|
-
expires: 0
|
480
|
-
});
|
481
|
-
|
482
|
-
// update cookie user translate settings
|
483
|
-
user_translate.translationEnabled = false;
|
484
|
-
cookie_written = j1.writeCookie({
|
485
|
-
name: cookie_names.user_translate,
|
486
|
-
data: user_consent,
|
487
|
-
samesite: 'Strict',
|
488
|
-
secure: secure,
|
489
|
-
expires: 0
|
490
|
-
});
|
491
|
-
|
492
|
-
// stop translation for all pages
|
493
|
-
if (htmlScriptElement) { htmlScriptElement.remove(); }
|
494
|
-
j1.removeCookie({name: 'googtrans', domain: domain});
|
495
|
-
}
|
496
|
-
|
497
|
-
if (moduleOptions.reloadPageOnChange) {
|
498
|
-
// reload current page (skip cache)
|
499
|
-
location.reload(true);
|
500
|
-
}
|
501
|
-
|
502
|
-
// disable google translate button if visible
|
503
|
-
if ($('#quickLinksTranslateButton').css('display') === 'block') {
|
504
|
-
$('#quickLinksTranslateButton').css('display', 'none');
|
505
|
-
}
|
506
|
-
|
507
|
-
}, // END cbGoogle
|
508
|
-
|
509
|
-
// -------------------------------------------------------------------------
|
510
|
-
// cbDeepl()
|
511
|
-
// Called by the translator CORE module after the user
|
512
|
-
// has made the lanuage selection for translation (callback)
|
513
|
-
// -------------------------------------------------------------------------
|
514
|
-
cbDeepl: function () {
|
515
|
-
|
516
|
-
// code for post procession on Deepl translations
|
517
|
-
|
518
|
-
} // END cbDeepl
|
519
|
-
|
520
|
-
}; // END return
|
521
|
-
})(j1, window);
|
522
|
-
|
523
|
-
{% endcapture %}
|
524
|
-
{{ cache | strip_empty_lines }}
|
525
|
-
{% assign cache = nil %}
|