j1-template 2021.1.4 → 2021.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/themes/j1/modules/connectors/ad/google-adsense.html +7 -15
  3. data/_includes/themes/j1/modules/connectors/analytic/google-analytics.html +9 -5
  4. data/_includes/themes/j1/modules/navigator/generator.html +2 -2
  5. data/_layouts/default.html +4 -7
  6. data/assets/data/cookieconsent.html +249 -0
  7. data/assets/data/quicklinks.html +18 -16
  8. data/assets/themes/j1/adapter/js/{cookiebar.js → cookieConsent.js} +102 -54
  9. data/assets/themes/j1/adapter/js/j1.js +40 -15
  10. data/assets/themes/j1/core/css/themes/uno-light/bootstrap.css +2 -2
  11. data/assets/themes/j1/core/css/themes/uno-light/bootstrap.min.css +1 -1
  12. data/assets/themes/j1/core/js/template.js +3 -9
  13. data/assets/themes/j1/core/js/template.js.map +1 -1
  14. data/assets/themes/j1/core/js/template.min.js +3 -9
  15. data/assets/themes/j1/core/js/template.min.js.map +1 -1
  16. data/assets/themes/j1/modules/cookieConsent/LICENSE +21 -0
  17. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +286 -0
  18. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js +28 -0
  19. data/assets/themes/j1/modules/iframeResizer/examples/frame.absolute.html +4 -2
  20. data/assets/themes/j1/modules/iframeResizer/examples/frame.content.html +4 -3
  21. data/assets/themes/j1/modules/iframeResizer/examples/frame.hover.html +4 -2
  22. data/assets/themes/j1/modules/iframeResizer/examples/frame.nested.html +4 -2
  23. data/assets/themes/j1/modules/iframeResizer/examples/frame.textarea.html +4 -2
  24. data/assets/themes/j1/modules/iframeResizer/examples/frame.tolerance.html +4 -2
  25. data/assets/themes/j1/modules/iframeResizer/examples/index.html +2 -0
  26. data/assets/themes/j1/modules/iframeResizer/examples/two.html +4 -2
  27. data/assets/themes/j1/modules/util/js/domready.js +146 -0
  28. data/assets/themes/j1/modules/util/js/gtag-opt-in.js +1 -0
  29. data/lib/j1/version.rb +3 -3
  30. data/lib/starter_web/Gemfile +1 -1
  31. data/lib/starter_web/_config.yml +2 -1
  32. data/lib/starter_web/_data/_defaults/resources.yml +11 -8
  33. data/lib/starter_web/_data/modules/{cookiebar.yml → cookieconsent.yml} +4 -4
  34. data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +135 -0
  35. data/lib/starter_web/_data/pages/builder.yml +7 -7
  36. data/lib/starter_web/_data/private.yml +6 -6
  37. data/lib/starter_web/_data/resources.yml +9 -7
  38. data/lib/starter_web/_includes/attributes.asciidoc +10 -1
  39. data/lib/starter_web/_plugins/lunr_index.rb +1 -1
  40. data/lib/starter_web/assets/images/modules/attics/{cookies-1920x1200-bw.jpg → cookies-1920x1200.jpg} +0 -0
  41. data/lib/starter_web/assets/images/modules/attics/lianhao-1920x1280.jpg +0 -0
  42. data/lib/starter_web/collections/posts/public/featured/_posts/2020-01-01-about-cookies.adoc +2 -2
  43. data/lib/starter_web/package.json +1 -1
  44. data/lib/starter_web/pages/public/cookieConsent.adoc +93 -0
  45. data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +2 -1
  46. data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +104 -209
  47. data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
  48. data/lib/starter_web/utilsrv/package.json +1 -1
  49. metadata +14 -13
  50. data/_includes/themes/j1/modules/navigator/generator.org.html +0 -232
  51. data/assets/data/cookiebar.html +0 -288
  52. data/assets/data/footer.new.1.html +0 -256
  53. data/assets/data/footer.new.2.html +0 -256
  54. data/assets/data/footer.org.html +0 -249
  55. data/assets/themes/j1/adapter/js/j1.new.js +0 -1878
  56. data/assets/themes/j1/adapter/js/j1.org.js +0 -1874
  57. data/lib/starter_web/_data/modules/defaults/cookiebar.yml +0 -133
@@ -1,1874 +0,0 @@
1
- ---
2
- regenerate: true
3
- ---
4
-
5
- {% capture cache %}
6
-
7
- {% comment %}
8
- # -----------------------------------------------------------------------------
9
- # ~/assets/themes/j1/core/js/j1.js
10
- # Liquid template to initialize J1 Template Core functions
11
- #
12
- # Product/Info:
13
- # https://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 procedures
26
- -------------------------------------------------------------------------------- {% endcomment %}
27
-
28
- {% comment %} Set global settings
29
- -------------------------------------------------------------------------------- {% endcomment %}
30
- {% assign environment = site.environment %}
31
- {% assign template_version = site.version %}
32
-
33
- {% if site.permalink == 'none' %}
34
- {% capture page_url %}{{ site.url }}.html{% endcapture %}
35
- {% else %}
36
- {% capture page_url %}{{ site.url }}{% endcapture %}
37
- {% endif %}
38
-
39
- {% comment %} Process YML config data
40
- ================================================================================ {% endcomment %}
41
-
42
- {% comment %} Set config files
43
- -------------------------------------------------------------------------------- {% endcomment %}
44
- {% assign template_config = site.data.j1_config %}
45
- {% assign blocks = site.data.blocks %}
46
- {% assign modules = site.data.modules %}
47
-
48
- {% comment %} Set config data
49
- -------------------------------------------------------------------------------- {% endcomment %}
50
- {% assign banner_config_defaults = blocks.defaults.banner.defaults %}
51
- {% assign banner_config_settings = blocks.banner.settings %}
52
- {% assign panel_config_defaults = blocks.defaults.panel.defaults %}
53
- {% assign panel_config_settings = blocks.panel.settings %}
54
- {% assign footer_config_defaults = blocks.defaults.footer.defaults %}
55
- {% assign toccer_defaults = modules.defaults.toccer.defaults %}
56
- {% assign toccer_settings = modules.toccer.settings %}
57
- {% assign themer_defaults = modules.defaults.themer.defaults %}
58
- {% assign themer_settings = modules.themer.settings %}
59
-
60
- {% assign authentication_defaults = modules.defaults.authentication.defaults %}
61
- {% assign authentication_settings = modules.authentication.settings %}
62
-
63
- {% comment %} Set config options
64
- -------------------------------------------------------------------------------- {% endcomment %}
65
- {% assign toccer_options = toccer_defaults | merge: toccer_settings %}
66
- {% assign themer_options = themer_defaults | merge: themer_settings %}
67
-
68
- {% assign authentication_options = authentication_defaults | merge: authentication_settings %}
69
-
70
- {% assign footer_id = footer_config_defaults.container-id %}
71
- {% assign footer_data_path = footer_config_defaults.data_path %}
72
- {% assign banner_data_path = banner_config_defaults.data_path %}
73
- {% assign panel_data_path = panel_config_defaults.data_path %}
74
-
75
- {% assign hideOnReload = modules.themer_options.hideOnReload %}
76
-
77
- {% assign production = false %}
78
- {% if environment == 'prod' or environment == 'production' %}
79
- {% assign production = true %}
80
- {% endif %}
81
-
82
- /*
83
- # -----------------------------------------------------------------------------
84
- # ~/assets/themes/j1/adapter/js/j1_template.js
85
- # JS Adapter for J1 Template
86
- #
87
- # Product/Info:
88
- # https://jekyll.one
89
- #
90
- # Copyright (C) 2021 Juergen Adams
91
- #
92
- # J1 Template is licensed under the MIT License.
93
- # For details, see https://jekyll.one
94
- # -----------------------------------------------------------------------------
95
- # TODO:
96
- # MANAGE themeExtensionCss is to be checked
97
- #
98
- # -----------------------------------------------------------------------------
99
- # Adapter generated: {{site.time}}
100
- # -----------------------------------------------------------------------------
101
- */
102
-
103
- // -----------------------------------------------------------------------------
104
- // ESLint shimming
105
- // -----------------------------------------------------------------------------
106
- /* eslint indent: "off" */
107
- /* eslint quotes: "off" */
108
- /* eslint semi: "off" */
109
- // -----------------------------------------------------------------------------
110
- 'use strict';
111
-
112
- var j1 = (function () {
113
-
114
- // ---------------------------------------------------------------------------
115
- // globals
116
- // ---------------------------------------------------------------------------
117
- var rePager = new RegExp('navigator|dateview|tagview|archive');
118
- var environment = '{{environment}}';
119
- var moduleOptions = {};
120
- var j1_runtime_data = {};
121
-
122
- // Status information
123
- var state = 'not_started';
124
- var mode = 'not_detected';
125
-
126
- var current_user_data;
127
- var current_page;
128
- var previous_page;
129
- var last_pager;
130
- var last_pager_url;
131
- var app_detected;
132
- var user_session_detected;
133
-
134
- // Connector settings
135
- var translation_enabled = {{template_config.translation.enabled}};
136
-
137
- // Theme information
138
- var themeName;
139
- var themeCss;
140
- var themeExtensionCss = environment === 'production' ? '/assets/themes/j1/core/css/themes/theme-extensions.min.css' : '/assets/themes/j1/core/css/themes/theme-extensions.css';
141
-
142
- // Pathes of J1 data files
143
- var colors_data_path = '{{template_config.colors_data_path}}';
144
- var font_size_data_path = '{{template_config.font_size_data_path}}';
145
- var runtime_data_path = '{{template_config.runtime_data_path}}';
146
- var message_catalog_data_path = '{{template_config.message_catalog_data_path}}';
147
-
148
- // Logger
149
- var logger;
150
- var logText;
151
-
152
- var _this;
153
- var settings;
154
- var json_data;
155
- var ep;
156
- var baseUrl;
157
- var referrer;
158
-
159
- // var default_theme_css = environment === 'production' ? '/assets/themes/j1/core/css/themes/uno-light/bootstrap.min.css' : '/assets/themes/j1/core/css/themes/uno-light/bootstrap.css';
160
- // // TODO: check what property is used default_theme|default_theme_name ?
161
- // var default_theme_display_name = 'Uno (light)';
162
- // var default_theme_name = 'uno-light';
163
- // var default_theme_author = 'J1 Team';
164
- // var default_theme_link = 'https://jekyll.one/';
165
- var default_white_listed_pages = [];
166
-
167
- var cookie_names = {
168
- 'app_session': '{{template_config.cookies.app_session}}',
169
- 'user_session': '{{template_config.cookies.user_session}}',
170
- 'user_state': '{{template_config.cookies.user_state}}'
171
- };
172
-
173
- // user SESSION cookie (initial values)
174
- var user_session = {
175
- 'mode': 'web',
176
- 'writer': 'web',
177
- 'locale': navigator.language || navigator.userLanguage,
178
- 'user_name': '{{template_config.user.user_name}}',
179
- 'provider': '{{template_config.user.provider}}',
180
- 'provider_membership': '{{template_config.user.provider_membership}}',
181
- 'provider_permissions': 'public,{{template_config.user.provider_permissions}}',
182
- 'provider_site_url': '{{template_config.user.provider_site_url}}',
183
- 'provider_home_url': '{{template_config.user.provider_home_url}}',
184
- 'provider_blog_url': '{{template_config.user.provider_blog_url}}',
185
- 'provider_member_url': '{{template_config.user.provider_member_url}}',
186
- 'provider_privacy_url': '{{template_config.user.provider_privacy_url}}',
187
- 'requested_page': 'na',
188
- 'previous_page': 'na',
189
- 'last_pager': '/pages/public/blog/navigator/'
190
- };
191
-
192
- // user STATE cookie (initial values)
193
- var user_state = {
194
- 'theme_css': "",
195
- 'theme_name': "",
196
- 'theme_author': "",
197
- 'theme_version': '{{site.version}}',
198
- 'cookies_accepted': 'pending',
199
- 'whitelistedPages': default_white_listed_pages,
200
- 'deleteOnDecline': false,
201
- 'showConsentOnPending': false,
202
- 'stopScrolling': true,
203
- 'session_active': false,
204
- 'last_session_ts': '',
205
- 'cc_authenticated': false
206
- };
207
-
208
- // ---------------------------------------------------------------------------
209
- // helper functions
210
- // ---------------------------------------------------------------------------
211
-
212
- function executeFunctionByName(functionName, context /*, args */) {
213
- // See: https://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string
214
- //
215
- var args = Array.prototype.slice.call(arguments, 2);
216
- var namespaces = functionName.split('.');
217
- var func = namespaces.pop();
218
- for(var i = 0; i < namespaces.length; i++) {
219
- context = context[namespaces[i]];
220
- }
221
- return context[func].apply(context, args);
222
- }
223
-
224
- // ---------------------------------------------------------------------------
225
- // main object
226
- // ---------------------------------------------------------------------------
227
- return {
228
-
229
- // -------------------------------------------------------------------------
230
- // init()
231
- // initializer
232
- // -------------------------------------------------------------------------
233
- init: function (options) {
234
-
235
- // -----------------------------------------------------------------------
236
- // global var (function)
237
- // -----------------------------------------------------------------------
238
- var logger = log4javascript.getLogger('j1.init');
239
- var url = new liteURL(window.location.href);
240
- var baseUrl = url.origin;
241
- // moment not used anymore
242
- // var epoch = Math.floor(Date.now()/1000);
243
- // var timestamp_now = moment.unix(epoch).format('YYYY-MM-DD HH:mm:ss');
244
- var date = new Date();
245
- var timestamp_now = date.toISOString();
246
- var curr_state = 'started';
247
- // var date = new Date();
248
- // var my_timestamp = date.toISOString();
249
-
250
-
251
- // -----------------------------------------------------------------------
252
- // options loader
253
- // -----------------------------------------------------------------------
254
- var settings = $.extend(
255
- {
256
- foo: 'foo_option',
257
- bar: 'bar_option'
258
- },
259
- options
260
- );
261
-
262
- // -----------------------------------------------------------------------
263
- // status settings
264
- // save status into the adapter object for (later) global access
265
- // -----------------------------------------------------------------------
266
- j1['xhrDataState'] = {};
267
- j1['xhrDOMState'] = {};
268
-
269
- // -----------------------------------------------------------------------
270
- // session ON_CLOSE event
271
- // wrapup if ALL browser windows get closed. Update user STATE
272
- // cookie on window CLOSE.
273
- // see: https://stackoverflow.com/questions/3888902/detect-browser-or-tab-closing
274
- // -----------------------------------------------------------------------
275
- window.addEventListener('beforeunload', function (event) {
276
- var cookie_names = j1.getCookieNames();
277
- var cookie_user_state_name = cookie_names.user_state;
278
- var cookie_user_session_name = cookie_names.user_session;
279
- // moment not used anymore
280
- // var epoch = Math.floor(Date.now()/1000);
281
- // var timestamp_now = moment.unix(epoch).format('YYYY-MM-DD HH:mm:ss');
282
- var date = new Date();
283
- var timestamp_now = date.toISOString();
284
- var user_state = j1.readCookie(cookie_user_state_name);
285
- var ep_status;
286
- var url;
287
- var baseUrl;
288
-
289
- // update cookie only, if (already) exists
290
- //
291
- if (user_state) {
292
- user_state.session_active = false;
293
- user_state.last_session_ts = timestamp_now;
294
-
295
- j1.writeCookie({
296
- name: cookie_user_state_name,
297
- data: user_state,
298
- expires: 365
299
- });
300
- }
301
-
302
- });
303
-
304
- // -----------------------------------------------------------------------
305
- // initialize|load (existing) user cookies
306
- // -----------------------------------------------------------------------
307
- user_session.created = timestamp_now;
308
- user_session.timestamp = timestamp_now;
309
-
310
- user_session = j1.existsCookie(cookie_names.user_session)
311
- ? j1.readCookie(cookie_names.user_session)
312
- : j1.writeCookie({
313
- name: cookie_names.user_session,
314
- data: user_session,
315
- });
316
-
317
- user_state = j1.existsCookie(cookie_names.user_state)
318
- ? j1.readCookie(cookie_names.user_state)
319
- : j1.writeCookie({
320
- name: cookie_names.user_state,
321
- data: user_state,
322
- expires: 365
323
- });
324
-
325
- user_state.session_active = true;
326
- j1.writeCookie({
327
- name: cookie_names.user_state,
328
- data: user_state,
329
- expires: 365
330
- });
331
-
332
- // detect middleware (mode 'app') and update user session cookie
333
- // -----------------------------------------------------------------------
334
- // if (user_session.mode === 'na' || user_session.mode === 'app') {
335
- if (user_session.mode === 'app') {
336
- var url = new liteURL(window.location.href);
337
- var ep_status = baseUrl + '/status' + '?page=' + window.location.pathname;
338
- var detectTimeout = 50;
339
-
340
- baseUrl = url.origin;
341
-
342
- // see: https://stackoverflow.com/questions/3709597/wait-until-all-jquery-ajax-requests-are-done
343
- $.when (
344
- $.ajax(ep_status)
345
- )
346
- .then(function(data) {
347
- var logger = log4javascript.getLogger('j1.init');
348
- user_session = j1.readCookie(cookie_names.user_session);
349
- user_session.mode = 'app';
350
- user_session.requested_page = window.location.pathname;
351
- user_session.timestamp = timestamp_now;
352
- user_session = j1.mergeData(user_session, data);
353
- logText = 'mode detected: ' + user_session.mode;
354
-
355
- logger.info(logText);
356
- logger.info('update user session cookie');
357
- j1.writeCookie({
358
- name: cookie_names.user_session,
359
- data: user_session
360
- });
361
- j1.setState(curr_state);
362
- logger.info('state: ' + j1.getState());
363
-
364
-
365
-
366
-
367
- var dependencies_met_page_displayed = setInterval (function () {
368
- if (j1.getState() == 'finished') {
369
- if (j1.authEnabled()) {
370
- if (user_session.authenticated === 'true') {
371
- // set signout
372
- logger.info('show signout icon');
373
- $('#navLinkSignInOut').attr('data-target','#modalOmniSignOut');
374
- $('#iconSignInOut').removeClass('mdi-login').addClass('mdi-logout');
375
- } else {
376
- // set signin
377
- logger.info('show signin icon');
378
- $('#navLinkSignInOut').attr('data-target','#modalOmniSignIn');
379
- $('#iconSignInOut').removeClass('mdi-logout').addClass('mdi-login');
380
- }
381
- logger.info('authentication detected as: ' + user_session.authenticated);
382
- $('#quickLinksSignInOutButton').css('display', 'block');
383
- logger.info('met dependencies for: j1');
384
- clearInterval(dependencies_met_page_displayed);
385
- }
386
- }
387
- }, 25); // END dependencies_met_page_displayed
388
- })
389
- .catch(function(error) {
390
- // jadams, 2018-08-31: Why a hell a setTimeout is needed ???
391
- setTimeout (function() {
392
- var logger = log4javascript.getLogger('j1.init');
393
- user_session = j1.readCookie(cookie_names.user_session);
394
- user_session.mode = 'web';
395
- user_session.requested_page = window.location.pathname;
396
- user_session.timestamp = timestamp_now;
397
- logText = 'mode detected: ' + user_session.mode;
398
-
399
- logger.info(logText);
400
- j1.writeCookie({
401
- name: cookie_names.user_session,
402
- data: user_session
403
- });
404
- j1.setState(curr_state);
405
- logger.info('state: ' + j1.getState());
406
- }, detectTimeout);
407
- });
408
- } else { // app mode
409
- state = 'started';
410
- logger.info('state: ' + state);
411
- logger.info('page is being initialized');
412
- }
413
-
414
- // jadams: for testing only
415
- // display page
416
- // $('#no_flicker').css('display', 'block');
417
-
418
- state = 'started';
419
- logger.info('state: ' + state);
420
- logger.info('page is being initialized');
421
-
422
- if ( settings.scrollbar === 'false' ) {
423
- $('body').addClass('hide-scrollbar');
424
- $('html').addClass('hide-scrollbar-moz');
425
- }
426
-
427
- logger.info('read user state from cookie');
428
- user_session = j1.readCookie(cookie_names.user_session);
429
-
430
- // process|update user state cookie
431
- themeName = user_session.theme_name;
432
- themeCss = user_session.theme_css;
433
- themeExtensionCss = user_session.theme_extension_css;
434
-
435
- // save last page access
436
- // see: https://stackoverflow.com/questions/3528324/how-to-get-the-previous-url-in-javascript
437
- // see: https://developer.mozilla.org/de/docs/Web/API/Window/history
438
- //
439
- user_session.timestamp = timestamp_now;
440
- referrer = new liteURL(document.referrer);
441
- current_page = window.location.pathname;
442
- user_session.requested_page = current_page;
443
- user_session.previous_page = referrer.search === '' ?
444
- (referrer.pathname === '' ? current_page : referrer.pathname) :
445
- (user_session.previous_page === '' || user_session.previous_page === 'na'
446
- ? '/'
447
- : user_session.previous_page
448
- );
449
-
450
- // calculate last 'pager' if any
451
- if (rePager.test(user_session.previous_page)) {
452
- last_pager = user_session.previous_page;
453
- user_session.last_pager = last_pager;
454
- } else {
455
- last_pager = user_session.last_pager;
456
- }
457
-
458
- // jadams: for testing only
459
- // display page
460
- //$('#no_flicker').css('display', 'block');
461
-
462
- logger.info('update user session cookie');
463
- j1.writeCookie({
464
- name: cookie_names.user_session,
465
- data: user_session
466
- });
467
-
468
- // initialize page resources for blocks
469
- // (asynchronous, should be rewitten to xhrData)
470
- j1.initBanner(settings);
471
- j1.initPanel(settings);
472
- j1.initFooter(settings);
473
-
474
- state = 'running';
475
- logger.info('state: ' + state);
476
- logger.info(logText);
477
-
478
- user_session.timestamp = timestamp_now;
479
- j1.writeCookie({
480
- name: cookie_names.user_session,
481
- data: user_session
482
- });
483
-
484
- // -----------------------------------------------------------------------
485
- // additional BS helpers from j1.core
486
- // -----------------------------------------------------------------------
487
- j1.core.bsFormClearButton();
488
-
489
- // finalize and display page
490
- j1.displayPage();
491
-
492
- }, // END init
493
-
494
- // -------------------------------------------------------------------------
495
- // initBanner()
496
- // AJAX fetcher to load and place all banner used for a page
497
- // -------------------------------------------------------------------------
498
- initBanner: function (options) {
499
- var logger = log4javascript.getLogger('j1.initBanner');
500
- var banner = [];
501
- var bannerOptions = [];
502
- var mod = 'j1';
503
- var logText;
504
-
505
- {% comment %}
506
- Closure to pass additional data (e.g. #banner_id) to AJAX load callback
507
- See: http://stackoverflow.com/questions/939032/jquery-pass-more-parameters-into-callback
508
- -------------------------------------------------------------------------- {% endcomment %}
509
- var cb_load_closure = function(banner_id) {
510
- return function ( responseTxt, statusTxt, xhr ) {
511
- if ( statusTxt == 'success' ) {
512
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
513
- logText = 'loading banner completed on id: ' +banner_id;
514
- logger.info(logText);
515
- j1.setXhrDataState(banner_id, statusTxt);
516
- j1.setXhrDomState(banner_id, statusTxt);
517
- logger.info('XHR data loaded in the DOM: ' + banner_id);
518
- }
519
- if ( statusTxt == 'error' ) {
520
- logText = 'loading banner failed on id: ' +banner_id+ ', error: ' + xhr.status + ': ' + xhr.statusText;
521
- logger.error(logText);
522
- j1.setXhrDataState(banner_id, statusTxt);
523
- j1.setXhrDomState(banner_id, statusTxt);
524
- // Set|Log status
525
- state = 'failed';
526
- logger.error('state: ' + state);
527
- }
528
- };
529
- };
530
-
531
- {% comment %} Collect all banner id|s configured
532
- -------------------------------------------------------------------------- {% endcomment %}
533
- {% for items in banner_config_settings %}
534
- {% assign key = items[0] %}
535
- {% assign value = items[1] %}
536
-
537
- {% if key == 'divider' %} {% assign banner_config = value %} {% endif %}
538
- {% if key == 'teaser' %} {% assign banner_config = value %} {% endif %}
539
- {% if key == 'image' %} {% assign banner_config = value %} {% endif %}
540
- {% if key == 'parallax' %} {% assign banner_config = value %} {% endif %}
541
- {% if key == 'exception' %} {% assign banner_config = value %} {% endif %}
542
-
543
- {% for items in banner_config %}
544
- {% for banners in items %}
545
-
546
- {% for banner in banners %}
547
- {% for item in banner %}
548
- {% assign key = item[0] %}
549
- {% assign value = item[1] %}
550
-
551
- {% if key and debug %} item:value {{key}}:{{value}} {% endif %}
552
-
553
- {% if key == 'id' %} {% assign id = value %} {% endif %}
554
- {% if key == 'enabled' %} {% assign enabled = value %} {% endif %}
555
- {% endfor %}
556
- {% endfor %}
557
-
558
- {% if id and enabled %}
559
-
560
- {% comment %} Register current banner
561
- -------------------------------------------------------------------- {% endcomment %}
562
- banner.push('{{id}}');
563
- {% endif %}
564
-
565
- {% endfor %} {% comment %} END banners {% endcomment %}
566
-
567
- {% comment %} Reset (Liquid) element variables
568
- ---------------------------------------------------------------------- {% endcomment %}
569
- {% assign id = nil %}
570
- {% assign enabled = nil %}
571
- {% assign banner_config = nil %}
572
-
573
- {% endfor %} {% comment %} END banner_config {% endcomment %}
574
- {% endfor %} {% comment %} END banner_config_settings {% endcomment %}
575
-
576
- {% comment %} REGISTER exceptions container
577
- -------------------------------------------------------------------------- {% endcomment %}
578
- banner.push('exception_container');
579
-
580
- {% comment %} LOAD all banner registered
581
- -------------------------------------------------------------------------- {% endcomment %}
582
- if ( banner.length ) {
583
- for (var i in banner) {
584
- var id = '#' + banner[i];
585
- var selector = $(id);
586
- if (selector.length) {
587
- logText = 'loading banner on id: ' +banner[i];
588
- logger.info(logText);
589
- var banner_data_path = '{{banner_data_path}} ' + id + ' > *';
590
- selector.load(banner_data_path, cb_load_closure(id));
591
- }
592
- } // END for
593
- } else {
594
- logText = 'no banner found in site';
595
- logger.info(logText);
596
- return false;
597
- }
598
- return true;
599
- }, // END initBanner
600
-
601
- // -------------------------------------------------------------------------
602
- // initPanel()
603
- // AJAX fetcher to load and place all panel used for a page
604
- // -------------------------------------------------------------------------
605
- // ToDo:
606
- initPanel: function ( options ) {
607
- var logger = log4javascript.getLogger('j1.initPanel');
608
- var panel = [];
609
- var mod = 'j1';
610
- var logText;
611
-
612
- {% comment %} Closure to pass additional data (e.g. panel_id) to AJAX load callback
613
- See: http://stackoverflow.com/questions/939032/jquery-pass-more-parameters-into-callback
614
- -------------------------------------------------------------------------- {% endcomment %}
615
-
616
- {% comment %} NOTE
617
- strategy for MutationObserver callbacks to monitor DOM changes
618
- needs to be checked if multiple containers are chenaged in a row
619
- -------------------------------------------------------------------------- {% endcomment %}
620
- var cb_load_closure = function(panel_id) {
621
- return function ( responseTxt, statusTxt, xhr ) {
622
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
623
- if ( statusTxt == 'success' ) {
624
- logText = 'loading panel completed on id: ' +panel_id;
625
- logger.info(logText);
626
- j1.setXhrDataState(panel_id, statusTxt);
627
- j1.setXhrDomState(panel_id, statusTxt);
628
- logger.info('XHR data loaded in the DOM: ' + panel_id);
629
- }
630
- if ( statusTxt == 'error' ) {
631
- logText = 'loading panel failed on id: ' +panel_id+ ', error ' + xhr.status + ': ' + xhr.statusText;
632
- logger.error(logText);
633
- j1.setXhrDataState(panel_id, statusTxt);
634
- j1.setXhrDomState(panel_id, statusTxt);
635
- // Set|Log status
636
- state = 'Error';
637
- logger.error('state: ' + state);
638
- }
639
- };
640
- };
641
-
642
- {% comment %} Collect all panel id|s configured
643
- -------------------------------------------------------------------------- {% endcomment %}
644
- {% for items in panel_config_settings %}
645
- {% assign key = items[0] %}
646
- {% assign value = items[1] %}
647
-
648
- {% if key == 'intro' %} {% assign panel_config = value %} {% endif %}
649
- {% if key == 'service' %} {% assign panel_config = value %} {% endif %}
650
- {% if key == 'step' %} {% assign panel_config = value %} {% endif %}
651
- {% if key == 'news' %} {% assign panel_config = value %} {% endif %}
652
- {% if key == 'exception' %} {% assign panel_config = value %} {% endif %}
653
-
654
- {% for items in panel_config %}
655
- {% for panels in items %}
656
-
657
- {% for panel in panels %}
658
- {% for item in panel %}
659
- {% assign key = item[0] %}
660
- {% assign value = item[1] %}
661
-
662
- {% if key and debug %} item:value {{key}}:{{value}} {% endif %}
663
-
664
- {% if key == 'id' %} {% assign id = value %} {% endif %}
665
- {% if key == 'enabled' %} {% assign enabled = value %} {% endif %}
666
- {% endfor %}
667
- {% endfor %}
668
-
669
- {% comment %} Register current panel
670
- -------------------------------------------------------------------------- {% endcomment %}
671
- {% if id and enabled %}
672
- panel.push('{{id}}');
673
- {% endif %}
674
-
675
- {% comment %} Reset (Liquid) element variables
676
- -------------------------------------------------------------------------- {% endcomment %}
677
- {% assign id = nil %}
678
- {% assign enabled = nil %}
679
- {% assign panel_config = nil %}
680
-
681
- {% endfor %} {% comment %} END panels {% endcomment %}
682
- {% endfor %} {% comment %} END panel_config {% endcomment %}
683
- {% endfor %} {% comment %} END panel_config_settings {% endcomment %}
684
-
685
- if (panel.length) {
686
- for (var i in panel) {
687
- var id = '#' + panel[i];
688
- var selector = $(id);
689
- if ( selector.length ) {
690
- logText = 'loading panel on id: ' +panel[i];
691
- logger.info(logText);
692
- var panel_data_path = '{{panel_data_path}} ' + id + ' > *';
693
- selector.load(panel_data_path, cb_load_closure(id));
694
- }
695
- } // END for
696
- } else {
697
- logText = 'no panel found in site';
698
- logger.info(logText);
699
- return false;
700
- }
701
- return true;
702
- }, // END initPanel
703
-
704
- // -------------------------------------------------------------------------
705
- // initFooter()
706
- // AJAX fetcher to load and place the footer used for a page
707
- // -------------------------------------------------------------------------
708
- initFooter: function ( options ) {
709
- var logger = log4javascript.getLogger('j1.initFooter');
710
- var mod = 'j1';
711
- var logText;
712
-
713
- logText = 'loading footer started';
714
- logger.info(logText);
715
-
716
- var cb_load_closure = function(footer_id) {
717
- return function ( responseTxt, statusTxt, xhr ) {
718
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
719
- if ( statusTxt == 'success' ) {
720
- logText = 'footer loaded successfully on id: ' + footer_id;
721
- logger.info(logText);
722
- j1.setXhrDataState(footer_id, statusTxt);
723
- j1.setXhrDomState(footer_id, statusTxt);
724
- logger.info('XHR data loaded in the DOM: ' + footer_id);
725
-
726
- // jadams, 2020-07-21: intermediate state DISABLED
727
- // state = 'footer_loaded';
728
- // logger.info('set state for module ' + mod + ': ' + state);
729
- // executeFunctionByName(mod + '.setState', window, state);
730
-
731
- logText = 'initialization finished';
732
- logger.info(logText);
733
- }
734
- if ( statusTxt == 'error' ) {
735
- logText = 'loading footer failed on id: ' +footer_id+ ', error ' + xhr.status + ': ' + xhr.statusText;
736
- logger.error(logText);
737
- j1.setXhrDataState(footer_id, statusTxt);
738
- j1.setXhrDomState(footer_id, statusTxt);
739
-
740
- // Set|Log status
741
- state = 'failed';
742
- logger.error('state: ' + state);
743
- logText = 'initialization finished';
744
- logger.info(logText);
745
- }
746
- };
747
- };
748
-
749
- var id = '#' + '{{footer_id}}';
750
- var selector = $(id);
751
- if ( selector.length ) {
752
- var footer_data_path = '{{footer_data_path}}' + id + ' > *';
753
- selector.load(footer_data_path, cb_load_closure(id));
754
- } else {
755
- logText = 'data not loaded';
756
- logger.warn(logText);
757
- j1.setXhrDataState(id, 'not loaded');
758
- j1.setXhrDomState(id, 'pending');
759
- return false;
760
- }
761
- return true;
762
- }, // END initFooter
763
-
764
- // -------------------------------------------------------------------------
765
- // displayPage
766
- // show the page after timeout of {{flickerTimeout}} ms
767
- // -------------------------------------------------------------------------
768
- // NOTE:
769
- // jadams, 2019-08-21: for unknown reason, the user state data
770
- // (read from cookie) seems not correct (or loaded too late).
771
- // To make correct data sure for APP mode, a status request is done
772
- // to load the current state from the middleware (skipped in WEB mode)
773
- // -------------------------------------------------------------------------
774
- displayPage: function (options) {
775
- var logger = log4javascript.getLogger('j1.adapter.displayPage');
776
- var flickerTimeout = {{template_config.flicker_timeout}};
777
- var url = new liteURL(window.location.href);
778
- var baseUrl = url.origin;
779
- var ep_status = baseUrl + '/status' + '?page=' + window.location.pathname;
780
- var user_session = j1.readCookie(cookie_names.user_session);
781
- var user_state = j1.readCookie(cookie_names.user_state);
782
- var current_url = new liteURL(window.location.href);
783
- var providerPermissions = {};
784
- var provider;
785
- var previous_page;
786
- var appDetected;
787
- var categoryAllowed;
788
-
789
- logger.info('finalize page');
790
- j1.setCss();
791
-
792
- logText= 'loading page partials: started';
793
- logger.info(logText);
794
-
795
- if (j1.appDetected()) { // app mode
796
- logger.info('mode detected: app');
797
-
798
- $.when ($.ajax(ep_status))
799
- .then(function(data) {
800
- var logger = log4javascript.getLogger('j1.displayPage');
801
-
802
- user_session = j1.mergeData(user_session, data);
803
-
804
- user_session.current_page = current_url.pathname;
805
- j1.writeCookie({
806
- name: cookie_names.user_session,
807
- data: user_session
808
- });
809
-
810
- providerPermissions = user_session.provider_permissions;
811
- categoryAllowed = providerPermissions.includes(user_session.page_permission);
812
-
813
- // check protected pages (applies for APP only)
814
- // make sure that protected pages are ALWAYS checked for permissions
815
- // -------------------------------------------------------------------
816
- if (
817
- j1.authEnabled() &&
818
- user_session.page_permission !== 'public' &&
819
- categoryAllowed === false
820
- ){
821
- // redirect to middleware|page_authentication
822
- if (data.authenticated === 'true') {
823
- var ep_post_authentication = baseUrl + '/post_authentication';
824
- window.location.href = ep_post_authentication;
825
- } else if (j1.authEnabled()) {
826
- var ep_page_validation = baseUrl + '/page_validation?page=' + window.location.pathname;
827
- window.location.href = ep_page_validation;
828
- return false;
829
- }
830
- } // END check protected pages
831
-
832
- // show the page delayed
833
- setTimeout (function() {
834
- // display page
835
- $('#no_flicker').css('display', 'block');
836
-
837
- // show|hide cookie icon (should MOVED to Cookiebar ???)
838
- if (user_state.cookies_accepted === 'accepted') {
839
- // Display cookie icon
840
- logText = 'show cookie icon';
841
- logger.info(logText);
842
- $('#quickLinksCookieButton').css('display', 'block');
843
- } else {
844
- logText = 'hide cookie icon';
845
- logger.info(logText);
846
- // Display cookie icon
847
- $('#quickLinksCookieButton').css('display', 'none');
848
- }
849
-
850
- // show|hide translator icon
851
- if (translation_enabled) {
852
- logger.info('translator detected: google');
853
- logger.info('initialize language selector');
854
- $('.goog-te-combo').addClass('form-control');
855
- }
856
-
857
- // show cc icon
858
- // $('#quickLinksControlCenterButton').css('display', 'block');
859
-
860
- if (j1.authEnabled()) {
861
- if (user_session.authenticated === 'true') {
862
- // set signout
863
- logger.info('show signout icon');
864
- $('#navLinkSignInOut').attr('data-target','#modalOmniSignOut');
865
- $('#iconSignInOut').removeClass('mdi-login').addClass('mdi-logout');
866
- } else {
867
- // set signin
868
- logger.info('show signin icon');
869
- $('#navLinkSignInOut').attr('data-target','#modalOmniSignIn');
870
- $('#iconSignInOut').removeClass('mdi-logout').addClass('mdi-login');
871
- }
872
- logger.info('authentication detected as: ' + user_session.authenticated);
873
- $('#quickLinksSignInOutButton').css('display', 'block');
874
- }
875
-
876
- // if the page requested contains an anchor element,
877
- // do a smooth scroll to
878
- j1.scrollTo();
879
-
880
- if (user_session.previous_page !== user_session.current_page) {
881
- logText = 'page change detected';
882
- logger.info(logText);
883
- logText = 'previous page: ' + user_session.previous_page;
884
- logger.info(logText);
885
- logText = 'current page: ' + user_session.current_page;
886
- logger.info(logText);
887
- }
888
-
889
- // update sidebar for changed theme data
890
- logger.info('update sidebar');
891
- user_state = j1.readCookie(cookie_names.user_state);
892
- current_user_data = j1.mergeData(user_session, user_state);
893
- j1.core.navigator.updateSidebar(current_user_data);
894
-
895
- // Set|Log status
896
- state = 'finished';
897
- logText = 'state: ' + state;
898
- logger.info(logText);
899
- logText = 'page finalized successfully';
900
- logger.info(logText);
901
-
902
- }, flickerTimeout);
903
- }); // END APP mode
904
- } else { // web mode
905
- // show the page delayed
906
- setTimeout (function() {
907
- j1.setState('finished');
908
- logger.info('state: finished');
909
- logger.info('page initialization: finished');
910
-
911
- // display page
912
- $('#no_flicker').css('display', 'block');
913
-
914
- logger.info('mode detected: web');
915
- logger.info('hide signin icon');
916
- $('#quickLinksSignInOutButton').css('display', 'none');
917
-
918
- user_session.current_page = current_url.pathname;
919
- j1.writeCookie({
920
- name: cookie_names.user_session,
921
- data: user_session
922
- });
923
-
924
- // show|hide translator icon
925
- if (translation_enabled) {
926
- logger.info('translator detected: google');
927
- logger.info('initialize language selector');
928
- $('.goog-te-combo').addClass('form-control');
929
- }
930
-
931
- // show|hide cookie icon (should MOVED to Cookiebar ???)
932
- if (user_state.cookies_accepted === 'accepted') {
933
- // Display cookie icon
934
- logText = 'show cookie icon';
935
- logger.info(logText);
936
- $('#quickLinksCookieButton').css('display', 'block');
937
- } else {
938
- logText = 'hide cookie icon';
939
- logger.info(logText);
940
- // Display cookie icon
941
- $('#quickLinksCookieButton').css('display', 'none');
942
- }
943
-
944
- // If the page requested contains an anchor element,
945
- // do a smooth scroll to
946
- j1.scrollTo();
947
-
948
- if (user_session.previous_page !== user_session.current_page) {
949
- logText = 'page change detected';
950
- logger.info(logText);
951
- logText = 'previous page: ' + user_session.previous_page;
952
- logger.info(logText);
953
- logText = 'current page: ' + user_session.current_page;
954
- logger.info(logText);
955
- }
956
-
957
- // update sidebar for changed theme data
958
- logger.info('update sidebar');
959
- user_state = j1.readCookie(cookie_names.user_state);
960
- current_user_data = j1.mergeData(user_session, user_state);
961
- j1.core.navigator.updateSidebar(current_user_data);
962
-
963
- // set|log status
964
- state = 'finished';
965
- logText = 'state: ' + state;
966
- logger.info(logText);
967
- logText = 'page finalized successfully';
968
- logger.info(logText);
969
-
970
- }, flickerTimeout);
971
- } // END WEB mode
972
- }, // END displayPage
973
-
974
- // -------------------------------------------------------------------------
975
- // Helper functions
976
- // -------------------------------------------------------------------------
977
-
978
- // -------------------------------------------------------------------------
979
- // mergeData()
980
- // merge two objects (properties) and returns the resulting object
981
- // see: https://stackoverflow.com/questions/43109229/merge-default-options-containing-object-with-json-object
982
- // TODO: Improve comment, give synopsis and example
983
- // -------------------------------------------------------------------------
984
- mergeData: function () {
985
- var a = [].slice.call(arguments), o = a.shift();
986
-
987
- for(var i=0,l=a.length; i<l; i++){
988
- for(var p in a[i]){
989
- o[p] = a[i][p];
990
- }
991
- }
992
- return o;
993
- }, // END mergeData
994
-
995
- // -------------------------------------------------------------------------
996
- // getPrevPage()
997
- // Returns the last vistited page
998
- // -------------------------------------------------------------------------
999
- getPrevPage: function () {
1000
- return previous_page;
1001
- }, // END getPrevPage
1002
-
1003
- // -------------------------------------------------------------------------
1004
- // getLanguage()
1005
- // Returns the preferred language taken form window.navigator
1006
- // See:
1007
- // https://stackoverflow.com/questions/1043339/javascript-for-detecting-browser-language-preference
1008
- // -------------------------------------------------------------------------
1009
- getLanguage: function () {
1010
- var language = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage);
1011
- }, // END getLanguage
1012
-
1013
- // -------------------------------------------------------------------------
1014
- // getTemplateVersion()
1015
- // Returns the template version taken from site config (_config.yml)
1016
- // -------------------------------------------------------------------------
1017
- getTemplateVersion: function () {
1018
- return '{{template_version}}';
1019
- }, // END getTemplateVersion
1020
-
1021
- // -------------------------------------------------------------------------
1022
- // scrollTo()
1023
- // Scrolls smooth to any anchor referenced by an page URL on
1024
- // e.g. a page reload. Values for delay|offset are taken from
1025
- // TOCCER module
1026
- // -------------------------------------------------------------------------
1027
- scrollTo: function () {
1028
- var anchor = window.location.href.split('#')[1];
1029
- var anchor_id = '#' + anchor;
1030
- var selector;
1031
-
1032
- var logger = log4javascript.getLogger('j1.scrollTo');
1033
-
1034
- var toccerScrollDuration = {{toccer_options.scrollSmoothDuration}};
1035
- var toccerScrollOffset = {{toccer_options.scrollSmoothOffset}};
1036
-
1037
- // calculate offset for correct (smooth) scroll position
1038
- //
1039
- var $pagehead = $('.attic');
1040
- var $navbar = $('nav.navbar');
1041
- var $adblock = $('#adblock');
1042
-
1043
- var navbarType = $navbar.hasClass('navbar-fixed') ? 'fixed' : 'scrolled';
1044
- var fontSize = $('body').css('font-size').replace('px','');
1045
- var start = window.pageYOffset;
1046
-
1047
- var l = parseInt(fontSize);
1048
-
1049
- var h = $pagehead.length ? $pagehead.height() : 0;
1050
- var n = $navbar.length ? $navbar.height() : 0;
1051
- var a = $adblock.length ? $adblock.height() : 0;
1052
-
1053
- var scrollOffset = navbarType == 'fixed' ? -1*(n + a + l) : -1*(h + n + a + l);
1054
-
1055
- // static offset, to be checked why this is needed
1056
- //
1057
- scrollOffset = scrollOffset + toccerScrollOffset;
1058
-
1059
- if (anchor_id && anchor_id !== '#') {
1060
- // scroll only, if an anchor is given with URL
1061
- selector = $(anchor_id);
1062
- if (selector.length) {
1063
- j1.core.scrollSmooth.scroll( anchor_id, {
1064
- duration: toccerScrollDuration,
1065
- offset: scrollOffset,
1066
- callback: null
1067
- });
1068
- } else {
1069
- // scroll the page one pixel back and forth (trigger)
1070
- // to get the right position for the Toccer and adjust the
1071
- // Navigator to display the (tranparent) navbar correctly
1072
- //
1073
- $(window).scrollTop($(window).scrollTop()+1);
1074
- $(window).scrollTop($(window).scrollTop()-1);
1075
- } // END if anchor_id
1076
- } else if (anchor_id === '#') {
1077
- logger.info('bound click event to "#", suppress default action');
1078
- $(window).scrollTop($(window).scrollTop()+1);
1079
- $(window).scrollTop($(window).scrollTop()-1);
1080
- return false;
1081
- }
1082
- }, // END scrollTo
1083
-
1084
- // -------------------------------------------------------------------------
1085
- // authEnabled()
1086
- // Returns the state of the authentication module
1087
- // -------------------------------------------------------------------------
1088
- authEnabled: function () {
1089
- var logger = log4javascript.getLogger('j1.authentication');
1090
- var authEnabled = {{authentication_options.j1_auth.enabled}};
1091
-
1092
- return authEnabled;
1093
- }, // END authEnabled
1094
-
1095
- // -------------------------------------------------------------------------
1096
- // appDetected()
1097
- // Returns true if a web session cookie exists
1098
- // -------------------------------------------------------------------------
1099
- appDetected: function () {
1100
- var user_session;
1101
- var cookieExists = j1.existsCookie(cookie_names.user_session);
1102
- var detected = false;
1103
-
1104
- if (cookieExists) {
1105
- user_session = j1.readCookie(cookie_names.user_session);
1106
- detected = user_session.mode === 'app' ? true : false;
1107
- } else {
1108
- // detected = 'unknown';
1109
- detected = false;
1110
- }
1111
- return detected;
1112
- }, // END appDetected
1113
-
1114
- // -------------------------------------------------------------------------
1115
- // xhrData()
1116
- // Load data asychronously using XHR|jQuery on an HTML element (e.g. <div>)
1117
- // specified by xhr_container_id, xhr_data_path (options)
1118
- // -------------------------------------------------------------------------
1119
- xhrData: function (options, mod, status) {
1120
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
1121
- var selector = $('#' + options.xhr_container_id);
1122
- var state = status;
1123
- var observer_options = {
1124
- attributes: false,
1125
- childList: true,
1126
- characterData: false,
1127
- subtree: true
1128
- };
1129
- var observer;
1130
- var logText;
1131
-
1132
- var cb_load_closure = function(mod, id) {
1133
- return function (responseTxt, statusTxt, xhr) {
1134
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
1135
- if ( statusTxt === 'success' ) {
1136
- // jadams, 2020-07-21: intermediate state should DISABLED
1137
- // if (state) {
1138
- // logger.info('set state for ' +mod+ ' to: ' + state);
1139
- // executeFunctionByName(mod + '.setState', window, state);
1140
- // }
1141
- j1.setXhrDataState(id, statusTxt);
1142
- j1.setXhrDomState(id, 'pending');
1143
-
1144
- logText = 'data loaded successfully on id: ' +id;
1145
- logger.info(logText);
1146
- state = true;
1147
- }
1148
- if ( statusTxt === 'error' ) {
1149
- // jadams, 2020-07-21: to be checked why id could be UNDEFINED
1150
- if (typeof(id) != "undefined") {
1151
- state = 'failed';
1152
- logger.info('set state for ' +mod+ ' to: ' + state);
1153
- // jadams, 2020-07-21: intermediate state should DISABLED
1154
- // executeFunctionByName(mod + '.setState', window, state);
1155
- j1.setXhrDataState(id, statusTxt);
1156
- j1.setXhrDomState(id, 'pending');
1157
- logText = 'loading data failed on id: ' +id+ ', error ' + xhr.status + ': ' + xhr.statusText;
1158
- logger.error(logText);
1159
- state = false;
1160
- }
1161
- }
1162
- };
1163
- };
1164
- // see: https://stackoverflow.com/questions/20420577/detect-added-element-to-dom-with-mutation-observer
1165
- var html_data_path;
1166
- var id = '#' + options.xhr_container_id;
1167
- var $selector = $(id);
1168
-
1169
- if ( $selector.length ) {
1170
- if (options.xhr_data_element) {
1171
- html_data_path = options.xhr_data_path + ' #' + options.xhr_data_element + ' > *';
1172
- } else {
1173
- html_data_path = options.xhr_data_path + ' > *';
1174
- }
1175
- $selector.load( html_data_path, cb_load_closure( mod, id ) );
1176
-
1177
- var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
1178
- var xhrObserver = new MutationObserver (mutationHandler);
1179
- var obsConfig = {
1180
- childList: true,
1181
- characterData: false,
1182
- attributes: false,
1183
- subtree: false };
1184
-
1185
- selector.each(function(){
1186
- xhrObserver.observe(this, obsConfig);
1187
- } );
1188
-
1189
- function mutationHandler (mutationRecords) {
1190
- mutationRecords.forEach ( function (mutation) {
1191
- if (mutation.addedNodes.length) {
1192
- logger.info('XHR data loaded in the DOM: ' + id);
1193
- j1.setXhrDomState(id, 'success');
1194
- }
1195
- });
1196
- }
1197
- } else {
1198
- // jadams, 2020-07-21: To be clarified why a id is "undefined"
1199
- if (id != '#undefined') {
1200
- logText = 'data not loaded on id:' + id;
1201
- logger.warn(logText);
1202
- j1.setXhrDataState(id, 'not loaded');
1203
- j1.setXhrDomState(id, 'not loaded');
1204
- // Set processing state to 'finished' to complete module load
1205
- state = 'finished';
1206
- logger.info('state: ' + state);
1207
- // jadams, 2020-07-21: intermediate state should DISABLED
1208
- // executeFunctionByName(mod + '.setState', window, state);
1209
- state = false;
1210
- }
1211
- }
1212
- return state;
1213
- }, // END xhrData
1214
-
1215
- // -------------------------------------------------------------------------
1216
- // readCookie()
1217
- // -------------------------------------------------------------------------
1218
- readCookie: function (name) {
1219
- var data;
1220
- var data_json;
1221
- var cookieExists = j1.existsCookie(name);
1222
-
1223
- if (cookieExists) {
1224
- data_json = window.atob(Cookies.get(name));
1225
- data = JSON.parse(data_json);
1226
-
1227
- if (data) {
1228
- return data;
1229
- } else {
1230
- return false;
1231
- }
1232
- } else {
1233
- return false;
1234
- }
1235
- }, // END readCookie
1236
-
1237
- // -------------------------------------------------------------------------
1238
- // writeCookie()
1239
- // Write 'data' to a cookie 'name'. If not exists, the cookie gets
1240
- // created. Returns 'true' if cookie was written, otherwise 'false'.
1241
- // -------------------------------------------------------------------------
1242
- // NOTE:
1243
- // https://web.dev/samesite-cookies-explained/
1244
- // https://developer.mozilla.org/de/docs/Web/HTTP/Headers/Set-Cookie/SameSite
1245
- // https://www.smarketer.de/blog/chrome-update-80-cookies/
1246
- // -------------------------------------------------------------------------
1247
- // TODO:
1248
- // Change attribute "Secure" to true, if HTTPS is used.
1249
- // Checks and config changes are to be done.
1250
- // -------------------------------------------------------------------------
1251
- // TODO:
1252
- // Handling of attribute "SameSite".
1253
- // Config to use this attribute should be configurable
1254
- // (what config file?).
1255
- // Disabled use for now in general.
1256
- //
1257
- // The SameSite attribute of the Set-Cookie HTTP response header
1258
- // allows you to declare if your cookie should be restricted to a
1259
- // first-party or same-site context. Cookies with SameSite=None
1260
- // must now also specify the Secure attribute (they require a secure
1261
- // context/HTTPS).
1262
- // -------------------------------------------------------------------------
1263
- //
1264
- writeCookie: function (options /*name, data, [path, expires, SameSite, secure]*/) {
1265
- var defaults = {
1266
- data: {},
1267
- name: '',
1268
- expires: 0,
1269
- path: '/',
1270
- // SameSite: 'Strict',
1271
- // SameSite: 'Lax',
1272
- http_only: false,
1273
- secure: false
1274
- };
1275
- var settings = $.extend(defaults, options);
1276
- // moment not used anymore
1277
- // var epoch = Math.floor(Date.now()/1000);
1278
- // var timestamp_now = moment.unix(epoch).format('YYYY-MM-DD HH:mm:ss');
1279
- var date = new Date();
1280
- var timestamp_now = date.toISOString();
1281
- var cookie_data = {};
1282
- var data_json;
1283
- var data_encoded;
1284
-
1285
- if (j1.existsCookie(settings.name)) {
1286
- cookie_data = j1.readCookie(settings.name);
1287
- cookie_data.timestamp = timestamp_now;
1288
- cookie_data = j1.mergeData(cookie_data, settings.data);
1289
- data_json = JSON.stringify( cookie_data );
1290
- data_encoded = window.btoa(data_json);
1291
-
1292
- if (settings.expires > 0) {
1293
- Cookies.set(settings.name, data_encoded, {
1294
- expires: settings.expires,
1295
- SameSite: settings.SameSite
1296
- });
1297
- } else {
1298
- Cookies.set(settings.name, data_encoded, {
1299
- SameSite: settings.SameSite
1300
- });
1301
- }
1302
- } else {
1303
- cookie_data = settings.data;
1304
- data_json = JSON.stringify(settings.data);
1305
- data_encoded = window.btoa(data_json);
1306
- if (settings.expires > 0) {
1307
- Cookies.set(settings.name, data_encoded, {
1308
- expires: settings.expires,
1309
- SameSite: settings.SameSite
1310
- });
1311
- } else {
1312
- Cookies.set(settings.name, data_encoded, {
1313
- SameSite: settings.SameSite
1314
- });
1315
- }
1316
- }
1317
-
1318
- if (j1.existsCookie(settings.name)) {
1319
- return cookie_data;
1320
- } else {
1321
- return false;
1322
- }
1323
-
1324
- }, // END writeCookie
1325
-
1326
- // -------------------------------------------------------------------------
1327
- // Clears all given cookies by name (except cookies set to httpOnly).
1328
- // For all cookies the expire date is set in the past, those cookies
1329
- // are 'session' cookies. All session cookies are deleted (automatically)
1330
- // by the browser if the last session (browser window) is closed.
1331
- // See: https://stackoverflow.com/questions/179355/clearing-all-cookies-with-javascript
1332
- // -------------------------------------------------------------------------
1333
- removeCookie: function (options /*name [, path]*/) {
1334
- var cookieExists;
1335
- var defaults = {
1336
- name: '',
1337
- path: '/'
1338
- };
1339
- var settings = $.extend(defaults, options);
1340
-
1341
- Cookies.remove(settings.name, { path: settings.path });
1342
-
1343
- }, // END removeCookie
1344
-
1345
- // -------------------------------------------------------------------------
1346
- // Clears all given cookies by name (except cookies set to httpOnly).
1347
- // For all cookies the expire date is set in the past, those cookies
1348
- // are 'session' cookies. All session cookies are deleted (automatically)
1349
- // by the browser if the last session (browser window) is closed.
1350
- // See: https://stackoverflow.com/questions/179355/clearing-all-cookies-with-javascript
1351
- // -------------------------------------------------------------------------
1352
- deleteCookie: function (options) {
1353
- var name = options;
1354
- var all_cookies = document.cookie.split('; ');
1355
-
1356
- if ( name === 'all' ) {
1357
- for (var c = 0; c < all_cookies.length; c++) {
1358
- var d = window.location.hostname.split('.');
1359
- while (d.length > 0) {
1360
- var cookieBase = encodeURIComponent(all_cookies[c].split(';')[0].split('=')[0]) + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; domain=' + d.join('.') + ' ;path=';
1361
- var p = location.pathname.split('/');
1362
- document.cookie = cookieBase + '/';
1363
- while (p.length > 0) {
1364
- document.cookie = cookieBase + p.join('/');
1365
- p.pop();
1366
- };
1367
- d.shift();
1368
- }
1369
- }
1370
- } else {
1371
- document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT';
1372
- }
1373
-
1374
- return true;
1375
- }, // END deleteCookie
1376
-
1377
- // -------------------------------------------------------------------------
1378
- // returns true if a given cookie exists
1379
- // -------------------------------------------------------------------------
1380
- existsCookie: function (name) {
1381
- var dc = document.cookie;
1382
- var prefix = name + '=';
1383
- var begin = dc.indexOf('; ' + prefix);
1384
- var end = dc.length; // default to end of the string
1385
- var cookieExists = false;
1386
- var cookieContent = '';
1387
-
1388
- // found, and not in first position
1389
- if (begin !== -1) {
1390
- // exclude the "; "
1391
- begin += 2;
1392
- } else {
1393
- //see if cookie is in first position
1394
- begin = dc.indexOf(prefix);
1395
- // not found at all or found as a portion of another cookie name
1396
- if (begin === -1 || begin !== 0 ) return false;
1397
- }
1398
-
1399
- // if ";" is found somewhere after the prefix position then "end" is
1400
- // that position, otherwise it defaults to the end of the string
1401
- if (dc.indexOf(';', begin) !== -1) {
1402
- end = dc.indexOf(';', begin);
1403
- }
1404
-
1405
- cookieContent = decodeURI(dc.substring(begin + prefix.length, end) ).replace(/"/g, '');
1406
- cookieExists = cookieContent.length ? true : false;
1407
-
1408
- return cookieExists;
1409
- }, // END existsCookie
1410
-
1411
- // -------------------------------------------------------------------------
1412
- // Resolve MACROs
1413
- //
1414
- // See:
1415
- // https://stackoverflow.com/questions/5376431/wildcards-in-jquery-selectors
1416
- // https://stackoverflow.com/questions/16400072/jquery-each-only-affects-last-element
1417
- // https://dzone.com/articles/why-does-javascript-loop-only-use-last-value
1418
- // https://stackoverflow.com/questions/179713/how-to-change-the-href-for-a-hyperlink-using-jquery
1419
- // https://stackoverflow.com/questions/5223/length-of-a-javascript-object
1420
- // -------------------------------------------------------------------------
1421
- resolveMacros: function (user_data) {
1422
- var logger = log4javascript.getLogger('j1.resolveMacros');
1423
-
1424
- var sidebarLoaded = setInterval(function() {
1425
- if ($('#sidebar_mmenu').length) {
1426
- if (Object.keys(user_data).length) {
1427
- $('[id^=macro-]').each(function() {
1428
-
1429
- $('#macro-provider').each(function() {
1430
- var $this = $(this);
1431
- var $html = $this.html();
1432
- $this.html($html.replace('??provider', user_data.provider));
1433
- this.href = this.href.replace(/.*\/??provider-site-url/, user_data.provider_site_url);
1434
- });
1435
- $('#macro-user-name').each(function() {
1436
- var $this = $(this);
1437
- var $html = $this.html();
1438
- $this.html($html.replace('??user-name', user_data.user_name));
1439
- this.href = this.href.replace(/.*\/??provider_member_url/, user_data.provider_member_url);
1440
- });
1441
- $('#macro-provider-permissions').each(function() {
1442
- var $this = $(this);
1443
- var $html = $this.html();
1444
- $this.html($html.replace('??provider-permissions', user_data.provider_permissions));
1445
- this.href = this.href.replace(/.*\/??provider_member_url/, user_data.provider_member_url);
1446
- });
1447
- $('#macro-provider-membership').each(function() {
1448
- var $this = $(this);
1449
- var $html = $this.html();
1450
- $this.html($html.replace('??provider-membership', user_data.provider_membership));
1451
- this.href = this.href.replace(/.*\/??provider_member_url/, user_data.provider_member_url);
1452
- });
1453
- $('#macro-cookie-state').each(function() {
1454
- var $this = $(this);
1455
- var $html = $this.html();
1456
- $this.html($html.replace('??cookie-state', user_data.cookies_accepted));
1457
- this.href = this.href.replace(/.*\/??provider_privacy_url/, user_data.provider_privacy_url);
1458
- });
1459
- $('#macro-theme-name').each(function() {
1460
- var $this = $(this);
1461
- var $html = $this.html();
1462
- $this.html($html.replace('??theme-name', user_data.theme_name));
1463
- });
1464
- $('#macro-theme-author').each(function() {
1465
- var $this = $(this);
1466
- var $html = $this.html();
1467
- $this.html($html.replace('??theme-author', user_data.theme_author));
1468
- this.href = this.href.replace(/.*\/??theme-author-url/, user_data.theme_author_url);
1469
- });
1470
- $('#macro-theme-version').each(function() {
1471
- var $this = $(this);
1472
- var $html = $this.html();
1473
- $this.html($html.replace('??theme-version', user_data.theme_version));
1474
- });
1475
-
1476
- });
1477
- logger.info('met dependencies for: sidebarLoaded');
1478
- clearInterval(sidebarLoaded);
1479
- return true;
1480
- } else {
1481
- logger.error('no user data provided');
1482
- clearInterval(sidebarLoaded);
1483
- return false;
1484
- }
1485
- }
1486
- }, 25); // END 'sidebarLoaded'
1487
- }, // END resolveMacros
1488
-
1489
- // -------------------------------------------------------------------------
1490
- // Update MACROs
1491
- // Update the values, NOT the placeholders
1492
- // -------------------------------------------------------------------------
1493
- updateMacros: function (user_data) {
1494
- var logger = log4javascript.getLogger('j1.updateMacros');
1495
-
1496
- var sidebarLoaded = setInterval(function() {
1497
- if ($('#sidebar_mmenu').length) {
1498
-
1499
- if (Object.keys(user_data).length) {
1500
- $('[id^=macro-]').each(function() {
1501
-
1502
- $('#macro-provider').each(function() {
1503
- var $this = $(this);
1504
- var $html = $this.html();
1505
- $this.html($html.replace(/Provider:.*/, 'Provider: ' + user_data.provider));
1506
- $('#macro-provider').attr('href', user_data.provider_site_url);
1507
- });
1508
- $('#macro-user-name').each(function() {
1509
- var $this = $(this);
1510
- var $html = $this.html();
1511
- $this.html($html.replace(/User:.*/, 'User: ' + user_data.user_name));
1512
- $('#macro-user-name').attr('href', user_data.provider_member_url);
1513
- });
1514
- $('#macro-provider-permissions').each(function() {
1515
- var $this = $(this);
1516
- var $html = $this.html();
1517
- // $this.html($html.replace(/public|protected|private|blocked/, user_data.provider_permissions));
1518
- $this.html($html.replace(/public.*|protected.*|private.*|blocked.*/, user_data.provider_permissions));
1519
- $('#macro-provider-permissions').attr('href', user_data.provider_member_url);
1520
- });
1521
- $('#macro-provider-membership').each(function() {
1522
- var $this = $(this);
1523
- var $html = $this.html();
1524
- $this.html($html.replace(/guest|member/, user_data.provider_membership));
1525
- $('#macro-provider-membership').attr('href', user_data.provider_member_url);
1526
- });
1527
- $('#macro-cookie-state').each(function() {
1528
- var $this = $(this);
1529
- var $html = $this.html();
1530
- $this.html($html.replace(/accepted|declined|pending/, user_data.cookies_accepted));
1531
- $('#macro-cookie-state').attr('href', user_data.provider_privacy_url);
1532
- });
1533
-
1534
- });
1535
- logger.info('met dependencies for: sidebarLoaded');
1536
- clearInterval(sidebarLoaded);
1537
- return true;
1538
- } else {
1539
- logger.error('no user data provided');
1540
- clearInterval(sidebarLoaded);
1541
- return false;
1542
- }
1543
- }
1544
- }, 25); // END 'sidebarLoaded'
1545
- }, // END updateMacros
1546
-
1547
- // -------------------------------------------------------------------------
1548
- // getMessage
1549
- // Get a log message from the log message catalog object
1550
- // -------------------------------------------------------------------------
1551
- getMessage: function (level, message, property) {
1552
- var message = j1.messages[level][message]['message'][property];
1553
-
1554
- return message;
1555
- }, // END getMessage
1556
-
1557
- // -------------------------------------------------------------------------
1558
- // logger
1559
- // Log a message
1560
- // -------------------------------------------------------------------------
1561
- logger: function (logger, level, message) {
1562
- var logger = log4javascript.getLogger(logger);
1563
-
1564
- logger[level](message);
1565
-
1566
- return true;
1567
- }, // END logger
1568
-
1569
- // -------------------------------------------------------------------------
1570
- // Send message
1571
- // -------------------------------------------------------------------------
1572
- sendMessage: function ( sender, receiver, message ) {
1573
- var logger = log4javascript.getLogger('j1.sendMessage');
1574
- // var json_message = JSON.stringify(message, undefined, 2); // multiline
1575
- var json_message = JSON.stringify(message);
1576
-
1577
- if ( receiver === 'j1' ) {
1578
- logText = 'send message from ' + sender + ' to' + receiver + ': ' + json_message;
1579
- logger.debug(logText);
1580
- executeFunctionByName('j1' + '.messageHandler', window, sender, message);
1581
- } else {
1582
- logText = 'send message from ' + sender + ' to ' + receiver + ': ' + json_message;
1583
- logger.debug(logText);
1584
- //executeFunctionByName('j1.' + receiver + '.messageHandler', window, sender, message)
1585
- executeFunctionByName(receiver + '.messageHandler', window, sender, message);
1586
- }
1587
-
1588
- }, // END sendMessage
1589
-
1590
- // -------------------------------------------------------------------------
1591
- // messageHandler: MessageHandler for J1 CookieConsent module
1592
- // Manage messages send from other J1 modules
1593
- // -------------------------------------------------------------------------
1594
- messageHandler: function ( sender, message ) {
1595
- // var json_message = JSON.stringify(message, undefined, 2); // multiline
1596
- var json_message = JSON.stringify(message);
1597
-
1598
- logText = 'received message from ' + sender + ': ' + json_message;
1599
- logger.debug(logText);
1600
-
1601
- // -----------------------------------------------------------------------
1602
- // Process commands|actions
1603
- // -----------------------------------------------------------------------
1604
- if ( message.type === 'command' && message.action === 'module_initialized' ) {
1605
- _this.setState('finished');
1606
- logger.info(message.text);
1607
- }
1608
-
1609
- //
1610
- // Place handling of other command|action here
1611
- //
1612
-
1613
- return true;
1614
- }, // END messageHandler
1615
-
1616
- // -------------------------------------------------------------------------
1617
- // getStyleValue:
1618
- // Returns the value of a style from a css class definition
1619
- // example: j1.getStyleValue('uno-primary', 'background-color')
1620
- getStyleValue: function (className, style) {
1621
- var elementId = 'test-' + className,
1622
- testElement = document.getElementById(elementId),
1623
- val;
1624
-
1625
- if (testElement === null) {
1626
- testElement = document.createElement('div');
1627
- testElement.className = className;
1628
- testElement.style.display = 'none';
1629
- document.body.appendChild(testElement);
1630
- }
1631
- val = $(testElement).css(style);
1632
- document.body.removeChild(testElement);
1633
-
1634
- return val;
1635
- }, // END getStyleValue
1636
-
1637
- // -------------------------------------------------------------------------
1638
- // getStyleSheetLoaded:
1639
- // NOTE:
1640
- // EXAMPLE: getStyleSheetLoaded('bootstrap');
1641
- //
1642
- getStyleSheetLoaded: function (styleSheet) {
1643
- // var styleSheet = styleSheetName.toLowerCase() + '.css';
1644
- var sheets = document.styleSheets, stylesheet = sheets[(sheets.length - 1)];
1645
-
1646
- // find CSS file 'styleSheetName' in document
1647
- for(var i in document.styleSheets) {
1648
- if(sheets[i].href && sheets[i].href.indexOf(styleSheet) > -1) {
1649
- return true;;
1650
- }
1651
- }
1652
- },
1653
-
1654
- // -------------------------------------------------------------------------
1655
- // Returns the names of cookies used for J1 Template
1656
- // -------------------------------------------------------------------------
1657
- getCookieNames: function () {
1658
- return cookie_names;
1659
- }, // end getCookieNames
1660
-
1661
- // -------------------------------------------------------------------------
1662
- // Set dynamic styles
1663
- // -------------------------------------------------------------------------
1664
- setCss: function () {
1665
- var logger = log4javascript.getLogger('j1.setCss');
1666
- var bg_primary = j1.getStyleValue('bg-primary', 'background-color');
1667
- var bg_secondary = j1.getStyleValue('bg-secondary', 'background-color');
1668
-
1669
- logger.info('set color scheme for selected theme');
1670
-
1671
- // globals
1672
- // -----------------------------------------------------------------------
1673
- $('head').append('<style>.g-bg-primary { background-color: ' +bg_primary+ ' !important; }</style>');
1674
-
1675
- // Set color of timeline bullet
1676
- // -----------------------------------------------------------------------
1677
- // $('head').append('<style>.tmicon { background: ' +bg_primary+ ' !important; }</style>');
1678
- // $('head').append('<style>.timeline-panel:after { border-left-color: ' +bg_primary+ ' !important; }</style>');
1679
- // $('head').append('<style>.timeline-panel:after { border-right-color: ' +bg_primary+ ' !important; }</style>');
1680
-
1681
- // mdi icons
1682
- // -----------------------------------------------------------------------
1683
- $('head').append('<style>.iconify-md-bg-primary { color: ' +bg_primary+ ' !important; }</style>');
1684
- $('head').append('<style>.fa-md-bg-primary { color: ' +bg_primary+ ' !important; }</style>');
1685
- $('head').append('<style>.fas-md-bg-primary { color: ' +bg_primary+ ' !important; }</style>');
1686
- $('head').append('<style>.mdi-md-bg-primary { color: ' +bg_primary+ ' !important; }</style>');
1687
-
1688
- // asciidoc
1689
- // -----------------------------------------------------------------------
1690
- var admonitionblock_note_color = bg_primary;
1691
- var admonitionblock_tip_color = j1.getStyleValue('btn-success', 'background-color');
1692
- var admonitionblock_important_color = j1.getStyleValue('btn-info', 'background-color');
1693
- var admonitionblock_warning_color = j1.getStyleValue('icon-warning', 'color');
1694
- var admonitionblock_caution_color = j1.getStyleValue('btn-danger', 'background-color');
1695
-
1696
- $('head').append('<style>.icon-note { color: ' +admonitionblock_note_color+ ' !important; }</style>');
1697
- $('head').append('<style>.icon-tip { color: ' +admonitionblock_tip_color+ ' !important; }</style>');
1698
- $('head').append('<style>.icon-important { color: ' +admonitionblock_important_color+ ' !important; }</style>');
1699
- $('head').append('<style>.icon-warning { color: ' +admonitionblock_warning_color+ ' !important; }</style>');
1700
- $('head').append('<style>.icon-caution { color: ' +admonitionblock_caution_color+ ' !important; }</style>');
1701
-
1702
- // bs base styles (2020-09-20: diabled. Taken for BS CSS code)
1703
- // -----------------------------------------------------------------------
1704
- // $('head').append('<style>code { color: ' +bg_secondary+ ' !important; }</style>');
1705
-
1706
- // bs tool tips
1707
- // -----------------------------------------------------------------------
1708
- $('head').append('<style>.tooltip-inner { background-color: ' +bg_primary+ ' !important; }</style>');
1709
- // $('head').append('<style>.tooltip-arrow { background-color: ' +bg_primary+ ' !important; }</style>');
1710
- $('head').append('<style>.bs-tooltip-auto[x-placement^=bottom] .arrow::before, .bs-tooltip-bottom .arrow::before { border-bottom-color: ' +bg_primary+ ' !important; }</style>');
1711
-
1712
- // asciidoc results viewer
1713
- // -----------------------------------------------------------------------
1714
- $('head').append('<style>.btn-viewer:hover { background-color: ' +bg_primary+ ' !important; }</style>');
1715
-
1716
- // extended modals
1717
- // -----------------------------------------------------------------------
1718
- // var tabs_pills_link_color_active = j1.setColorData('md_blue'); // j1.getStyleValue('btn-info', 'background-color');
1719
- // var tabs_pills_link_color_hover = j1.setColorData('md_gray_300'); // j1.getStyleValue('btn-secondary', 'background-color');
1720
-
1721
- // var tabs_pills_link_color_active = 'mdi-blue';
1722
- // var tabs_pills_link_color_hover = 'mdi-gray-300';
1723
-
1724
- // nav module
1725
- // -----------------------------------------------------------------------
1726
- // $('head').append('<style>.nav-link:hover { background-color: ' +tabs_pills_link_color_hover+ ' !important; }</style>');
1727
- // $('head').append('<style>.nav-link.active { background-color: ' +tabs_pills_link_color_active+ ' !important; }</style>');
1728
-
1729
- return true;
1730
- }, // END setCss
1731
-
1732
- // -------------------------------------------------------------------------
1733
- // setState()
1734
- // Set the current (processing) state of the module
1735
- // -------------------------------------------------------------------------
1736
- setState: function (stat) {
1737
- state = stat;
1738
- }, // end setState
1739
-
1740
- // -------------------------------------------------------------------------
1741
- // getState()
1742
- // Returns the current (processing) state of the module
1743
- // -------------------------------------------------------------------------
1744
- getState: function () {
1745
- return state;
1746
- }, // end getState
1747
-
1748
- // -------------------------------------------------------------------------
1749
- // setXhrDataState()
1750
- // Set the final (loading) state of an element (partial) loaded via Xhr
1751
- // -------------------------------------------------------------------------
1752
- setXhrDataState: function (obj, stat) {
1753
- j1.xhrDataState[obj] = stat;
1754
- }, // END setXhrDataState
1755
-
1756
- // -------------------------------------------------------------------------
1757
- // getXhrDataState()
1758
- // Returns the final (loading) state of an element (partial) loaded via Xhr
1759
- // -------------------------------------------------------------------------
1760
- getXhrDataState: function (obj) {
1761
- return j1.xhrDataState[obj];
1762
- }, // END getXhrDataState
1763
-
1764
- // -------------------------------------------------------------------------
1765
- // setXhrDomState()
1766
- // Set the state of an element loaded via Xhr that is
1767
- // successfully added to the DOM
1768
- // -------------------------------------------------------------------------
1769
- setXhrDomState: function (obj, stat) {
1770
- j1.xhrDOMState[obj] = stat;
1771
- }, // END setXhrDomState
1772
-
1773
- // -------------------------------------------------------------------------
1774
- // getXhrDataState()
1775
- // Returns the state of an element loaded via Xhr that is
1776
- // successfully added to the DOM
1777
- // -------------------------------------------------------------------------
1778
- getXhrDOMState: function (obj) {
1779
- return j1.xhrDOMState[obj];
1780
- }, // END getXhrDOMState
1781
-
1782
- // -------------------------------------------------------------------------
1783
- // setMode()
1784
- // Set the current mode of the site (web|app)
1785
- // -------------------------------------------------------------------------
1786
- setMode: function (mod) {
1787
- mode = mod;
1788
- }, // END setMode
1789
-
1790
- // -------------------------------------------------------------------------
1791
- // getMode()
1792
- // Returns the current mode of the site (web|app)
1793
- // -------------------------------------------------------------------------
1794
- getMode: function () {
1795
- return mode;
1796
- }, // END getMode
1797
-
1798
- // -------------------------------------------------------------------------
1799
- // checkUserAgent()
1800
- // Returns the name (UA) of the web browser
1801
- // -------------------------------------------------------------------------
1802
- checkUserAgent: function () {
1803
- if (navigator.userAgent.search(ua_name) >= 0) {
1804
- return true;
1805
- } else {
1806
- return false;
1807
- }
1808
- }, // END checkUserAgent
1809
-
1810
- // -------------------------------------------------------------------------
1811
- // generateId()
1812
- // Generate a unique (thread) id used by the logger
1813
- // -------------------------------------------------------------------------
1814
- generateId: function (length) {
1815
- var result = '';
1816
- var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
1817
- var charactersLength = characters.length;
1818
- for ( var i = 0; i < length; i++ ) {
1819
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
1820
- }
1821
- return result;
1822
- }, // END generateId
1823
-
1824
- // -------------------------------------------------------------------------
1825
- // getTrue()
1826
- // Returns always true (for testing purposes)
1827
- // -------------------------------------------------------------------------
1828
- getTrue: function () {
1829
- return true;
1830
- }, // END isTrue
1831
-
1832
- // -------------------------------------------------------------------------
1833
- // getFalse()
1834
- // Returns always false (for testing purposes)
1835
- // -------------------------------------------------------------------------
1836
- getFalse: function () {
1837
- return false;
1838
- }, // END isTrue
1839
-
1840
- // -------------------------------------------------------------------------
1841
- // goHome()
1842
- // Redirect current page to the browser homepage
1843
- // -------------------------------------------------------------------------
1844
- goHome: function () {
1845
- // most browsers
1846
- if (typeof window.home == 'function') {
1847
- window.home();
1848
- } else if (document.all) {
1849
- // for IE
1850
- window.location.href = 'about:home';
1851
- } else {
1852
- window.location.href = 'about:blank';
1853
- }
1854
- }, // END gohome
1855
-
1856
- // -------------------------------------------------------------------------
1857
- // goBack()
1858
- // Redirect current page to last visited page (referrer)
1859
- // -------------------------------------------------------------------------
1860
- goBack: function () {
1861
- // where visitor has come from
1862
- window.location.href = document.referrer;
1863
- } // END goBack
1864
-
1865
- }; // END j1 (return)
1866
- }) (j1, window);
1867
-
1868
- {% endcapture %}
1869
- {% if production %}
1870
- {{ cache | minifyJS }}
1871
- {% else %}
1872
- {{ cache | strip_empty_lines }}
1873
- {% endif %}
1874
- {% assign cache = nil %}