j1-template 2024.2.0 → 2024.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/assets/data/gemini-ui.html +2 -2
  3. data/assets/themes/j1/adapter/js/advertising.js +2 -10
  4. data/assets/themes/j1/adapter/js/analytics.js +1 -5
  5. data/assets/themes/j1/adapter/js/bmd.js +195 -195
  6. data/assets/themes/j1/adapter/js/carousel.js +786 -786
  7. data/assets/themes/j1/adapter/js/clipboard.js +1 -0
  8. data/assets/themes/j1/adapter/js/comments.js +1 -0
  9. data/assets/themes/j1/adapter/js/cookieConsent.js +460 -466
  10. data/assets/themes/j1/adapter/js/customModule.js +5 -4
  11. data/assets/themes/j1/adapter/js/docsearch.js +1 -0
  12. data/assets/themes/j1/adapter/js/dropdowns.js +1 -0
  13. data/assets/themes/j1/adapter/js/fab.js +1 -0
  14. data/assets/themes/j1/adapter/js/gallery.js +495 -494
  15. data/assets/themes/j1/adapter/js/gemini.js +154 -128
  16. data/assets/themes/j1/adapter/js/iconPicker.js +257 -255
  17. data/assets/themes/j1/adapter/js/iconPickerPage.js +279 -279
  18. data/assets/themes/j1/adapter/js/iframer.js +3 -2
  19. data/assets/themes/j1/adapter/js/j1.js +3285 -3285
  20. data/assets/themes/j1/adapter/js/lazyLoader.js +241 -241
  21. data/assets/themes/j1/adapter/js/lightbox.js +242 -241
  22. data/assets/themes/j1/adapter/js/logger.js +1 -0
  23. data/assets/themes/j1/adapter/js/lunr.js +6 -10
  24. data/assets/themes/j1/adapter/js/masonry.js +427 -426
  25. data/assets/themes/j1/adapter/js/masterslider.js +526 -526
  26. data/assets/themes/j1/adapter/js/mmenu.js +1 -0
  27. data/assets/themes/j1/adapter/js/navigator.js +2 -2
  28. data/assets/themes/j1/adapter/js/particles.js +1 -0
  29. data/assets/themes/j1/adapter/js/rangeSlider.js +1 -0
  30. data/assets/themes/j1/adapter/js/rouge.js +288 -287
  31. data/assets/themes/j1/adapter/js/rtable.js +309 -309
  32. data/assets/themes/j1/adapter/js/slick.js +487 -487
  33. data/assets/themes/j1/adapter/js/slimSelect.js +3 -5
  34. data/assets/themes/j1/adapter/js/themeToggler.js +281 -280
  35. data/assets/themes/j1/adapter/js/themes.js +0 -1
  36. data/assets/themes/j1/adapter/js/toccer.js +1 -0
  37. data/assets/themes/j1/adapter/js/translator.js +1 -0
  38. data/assets/themes/j1/adapter/js/waves.js +1 -0
  39. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +23 -17
  40. data/assets/themes/j1/modules/js-cookies/js/js.cookie.js +147 -0
  41. data/assets/themes/j1/modules/js-cookies/js/js.cookie.min.js +2 -0
  42. data/lib/j1/version.rb +1 -1
  43. data/lib/starter_web/README.md +5 -5
  44. data/lib/starter_web/_config.yml +1 -1
  45. data/lib/starter_web/_data/modules/defaults/themes.yml +171 -171
  46. data/lib/starter_web/_data/resources.yml +26 -0
  47. data/lib/starter_web/_data/templates/feed.xml +1 -1
  48. data/lib/starter_web/_plugins/index/lunr.rb +1 -1
  49. data/lib/starter_web/package.json +1 -1
  50. data/lib/starter_web/pages/public/learn/roundtrip/present_images.adoc +500 -500
  51. metadata +4 -2
@@ -1,494 +1,495 @@
1
- ---
2
- regenerate: true
3
- ---
4
-
5
- {% capture cache %}
6
-
7
- {% comment %}
8
- # -----------------------------------------------------------------------------
9
- # ~/assets/themes/j1/adapter/js/gallery.js
10
- # Liquid template to create the J1 Adapter for J1 Gallery
11
- #
12
- # Product/Info:
13
- # https://jekyll.one
14
- #
15
- # Copyright (C) 2023, 2024 Juergen Adams
16
- #
17
- # J1 Template is licensed under the MIT License.
18
- # See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md
19
- # -----------------------------------------------------------------------------
20
- {% endcomment %}
21
-
22
- {% comment %} Liquid procedures
23
- -------------------------------------------------------------------------------- {% endcomment %}
24
-
25
- {% comment %} Set global settings
26
- -------------------------------------------------------------------------------- {% endcomment %}
27
- {% assign environment = site.environment %}
28
- {% assign template_version = site.version %}
29
-
30
- {% comment %} Process YML config data
31
- ================================================================================ {% endcomment %}
32
-
33
- {% comment %} Set config files
34
- -------------------------------------------------------------------------------- {% endcomment %}
35
- {% assign template_config = site.data.j1_config %}
36
- {% assign apps = site.data.apps %}
37
- {% assign modules = site.data.modules %}
38
-
39
- {% comment %} Set config data
40
- -------------------------------------------------------------------------------- {% endcomment %}
41
- {% assign gallery_defaults = modules.defaults.gallery.defaults %}
42
- {% assign gallery_settings = modules.gallery.settings %}
43
-
44
- {% comment %} Set config options
45
- -------------------------------------------------------------------------------- {% endcomment %}
46
- {% assign gallery_options = gallery_defaults | merge: gallery_settings %}
47
-
48
- {% comment %} Detect prod mode
49
- -------------------------------------------------------------------------------- {% endcomment %}
50
- {% assign production = false %}
51
- {% if environment == 'prod' or environment == 'production' %}
52
- {% assign production = true %}
53
- {% endif %}
54
-
55
- /*
56
- # -----------------------------------------------------------------------------
57
- # ~/assets/themes/j1/adapter/js/gallery.js
58
- # JS Adapter for J1 Gallery
59
- #
60
- # Product/Info:
61
- # https://jekyll.one
62
- # https://github.com/miromannino/Justified-Gallery
63
- #
64
- # Copyright (C) 2020 Miro Mannino
65
- # Copyright (C) 2023 Sachin Neravath
66
- # Copyright (C) 2023, 2024 Juergen Adams
67
- #
68
- # J1 Template is licensed under the MIT License.
69
- # See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md
70
- # Justified Gallery is licensed under the MIT license
71
- # See: https://github.com/miromannino/Justified-Gallery/blob/master/LICENSE
72
- # lightGallery is licensed under the GPLv3 license
73
- # See: https://github.com/sachinchoolur/lightGallery/blob/master/LICENSE
74
- # -----------------------------------------------------------------------------
75
- # Adapter generated: {{site.time}}
76
- # -----------------------------------------------------------------------------
77
- */
78
-
79
- // -----------------------------------------------------------------------------
80
- // ESLint shimming
81
- // -----------------------------------------------------------------------------
82
- /* eslint indent: "off" */
83
- // -----------------------------------------------------------------------------
84
- 'use strict';
85
- j1.adapter.gallery = ((j1, window) => {
86
-
87
- {% comment %} Global variables
88
- ------------------------------------------------------------------------------ {% endcomment %}
89
- var environment = '{{environment}}';
90
- var state = 'not_started';
91
- var play_button = '/assets/themes/j1/modules/lightGallery/css/themes/uno/icons/play-button.png';
92
- var url;
93
- var origin;
94
- var galleryDefaults;
95
- var gallerySettings;
96
- var galleryOptions;
97
- var frontmatterOptions;
98
-
99
- var _this;
100
- var logger;
101
- var logText;
102
-
103
- // date|time
104
- var startTime;
105
- var endTime;
106
- var startTimeModule;
107
- var endTimeModule;
108
- var timeSeconds;
109
-
110
- // ---------------------------------------------------------------------------
111
- // helper functions
112
- // ---------------------------------------------------------------------------
113
-
114
- // ---------------------------------------------------------------------------
115
- // main
116
- // ---------------------------------------------------------------------------
117
- return {
118
-
119
- // -------------------------------------------------------------------------
120
- // adapter initializer
121
- // -------------------------------------------------------------------------
122
- init: (options) => {
123
- url = new URL(window.location.href);
124
- origin = url.origin;
125
-
126
- // flag used for Chromium browser workaround
127
- j1['jg'] = {
128
- callback: {},
129
- };
130
-
131
- // -----------------------------------------------------------------------
132
- // default module settings
133
- // -----------------------------------------------------------------------
134
- var settings = $.extend({
135
- module_name: 'j1.adapter.gallery',
136
- generated: '{{site.time}}'
137
- }, options);
138
-
139
- // -----------------------------------------------------------------------
140
- // global variable settings
141
- // -----------------------------------------------------------------------
142
- _this = j1.adapter.gallery;
143
- logger = log4javascript.getLogger('j1.adapter.gallery');
144
-
145
- // create settings object from frontmatter (page settings)
146
- frontmatterOptions = options != null ? $.extend({}, options) : {};
147
-
148
- // Load module DEFAULTS|CONFIG
149
- galleryDefaults = $.extend({}, {{gallery_defaults | replace: 'nil', 'null' | replace: '=>', ':' }});
150
- gallerySettings = $.extend({}, {{gallery_settings | replace: 'nil', 'null' | replace: '=>', ':' }});
151
- galleryOptions = $.extend(true, {}, galleryDefaults, gallerySettings, frontmatterOptions);
152
-
153
- // load HTML portion for all grids
154
- console.debug('loading HTML portion for all galleries configured');
155
- _this.loadGalleryHTML(galleryOptions, galleryOptions.galleries);
156
-
157
- // -----------------------------------------------------------------------
158
- // module initializer
159
- // -----------------------------------------------------------------------
160
- var dependency_met_page_ready = setInterval (() => {
161
- var pageState = $('#content').css("display");
162
- var pageVisible = (pageState === 'block') ? true : false;
163
- var j1CoreFinished = (j1.getState() === 'finished') ? true : false;
164
-
165
- if (j1CoreFinished && pageVisible) {
166
- startTimeModule = Date.now();
167
-
168
- // initialize state flag
169
- _this.setState('started');
170
- logger.debug('\n' + 'state: ' + _this.getState());
171
- logger.info('\n' + 'module is being initialized');
172
-
173
- _this.initialize(galleryOptions);
174
- _this.setState('finished');
175
-
176
- logger.debug('\n' + 'state: ' + _this.getState());
177
- logger.info('\n' + 'module initialized successfully');
178
-
179
- endTimeModule = Date.now();
180
- logger.info('\n' + 'module initializing time: ' + (endTimeModule-startTimeModule) + 'ms');
181
-
182
- clearInterval(dependency_met_page_ready);
183
- } // END 'finished' && 'pageVisible'
184
- }, 10); // END dependency_met_page_ready
185
- }, // END init
186
-
187
- // -----------------------------------------------------------------------
188
- // Load AJAX data and initialize the jg gallery
189
- // -----------------------------------------------------------------------
190
- initialize: (options) => {
191
- var xhrLoadState = 'pending'; // (initial) load state for the HTML portion of the slider
192
- var load_dependencies = {};
193
- var dependency;
194
-
195
- logger = log4javascript.getLogger('j1.adapter.gallery');
196
-
197
- _this.setState('running');
198
- logger.debug('\n' + 'state: ' + _this.getState());
199
-
200
- {% for gallery in gallery_options.galleries %}
201
-
202
- {% if gallery.enabled %}
203
- {% assign gallery_id = gallery.id %}
204
- logger.info('\n' + 'found gallery on id: ' + '{{gallery_id}}');
205
-
206
- // create dynamic loader variable to setup the grid on id {{gallery_id}}
207
- dependency = 'dependencies_met_html_loaded_{{gallery_id}}';
208
- load_dependencies[dependency] = '';
209
-
210
- // initialize the gallery if HTML portion successfully loaded
211
- //
212
- load_dependencies['dependencies_met_html_loaded_{{gallery_id}}'] = setInterval (() => {
213
- // check if HTML portion of the gallery is loaded successfully
214
- xhrLoadState = j1.xhrDOMState['#{{gallery_id}}_parent'];
215
- if (xhrLoadState === 'success') {
216
- var $grid_{{gallery_id}} = $('#{{gallery_id}}'); // used for later access
217
-
218
- logger.debug('\n' + 'dyn_loader, initialize gallery on id: ' + '{{gallery_id}}');
219
-
220
- j1.jg.callback.{{gallery_id}} = 'waiting';
221
-
222
- /* eslint-disable */
223
- $('#{{gallery_id}}').justifiedGallery({
224
- {% for option in gallery.gallery_options %}
225
- {% if option[0] contains "gutters" %}
226
- {{'margins' | json}}: {{option[1] | json}},
227
- {% continue %}
228
- {% endif %}
229
- {{option[0] | json}}: {{option[1] | json}},
230
- {% endfor %}
231
- })
232
- .on('jg.complete', (evt) => {
233
- evt.stopPropagation();
234
-
235
- j1.jg.callback.{{gallery_id}} = 'successful';
236
-
237
- // setup the lightbox
238
- //
239
- logger.debug('\n' + 'dyn_loader, callback "jg.complete" entered on id: ' + '{{gallery_id}}');
240
- logger.debug('\n' + 'dyn_loader, initialize lightGallery on id: ' + '{{gallery_id}}');
241
-
242
- var lg = document.getElementById("{{gallery_id}}");
243
- lightGallery(lg, {
244
- "plugins": [{{gallery.lightGallery.plugins}}],
245
- {% for option in gallery.lightGallery.options %}
246
- {{option[0] | json}}: {{option[1] | json}},
247
- {% endfor %}
248
- "galleryId": "{{gallery_id}}",
249
- "selector": ".lg-item",
250
- {% if gallery.video == 'html5' and gallery.lightGallery.videojsOptions.enabled %}
251
- "videojsOptions": {
252
- {% for option in gallery.lightGallery.videojsOptions %}
253
- {% if option[0] contains "enabled" %}
254
- {% continue %}
255
- {% endif %}
256
- {{option[0] | json}}: {{option[1] | json}},
257
- {% endfor %}
258
- }
259
- {% endif %}
260
-
261
- {% if gallery.video == 'youtube' and gallery.lightGallery.playerParams.enabled %}
262
- "youTubePlayerParams": {
263
- {% for option in gallery.lightGallery.playerParams %}
264
- {% if option[0] contains "enabled" %}
265
- {% continue %}
266
- {% endif %}
267
- {{option[0] | json}}: {{option[1] | json}},
268
- {% endfor %}
269
- "origin": "origin"
270
- }
271
- {% endif %}
272
-
273
- {% if gallery.video == 'vimeo' and gallery.lightGallery.playerParams.enabled %}
274
- "vimeoPlayerParams": {
275
- {% for option in gallery.lightGallery.playerParams %}
276
- {% if option[0] contains "enabled" %}
277
- {% continue %}
278
- {% endif %}
279
- {{option[0] | json}}: {{option[1] | json}},
280
- {% endfor %}
281
- }
282
- {% endif %}
283
-
284
- {% if gallery.video == 'dailymotion' and gallery.lightGallery.playerParams.enabled %}
285
- "dailymotionPlayerParams": {
286
- {% for option in gallery.lightGallery.playerParams %}
287
- {% if option[0] contains "enabled" %}
288
- {% continue %}
289
- {% endif %}
290
- {{option[0] | json}}: {{option[1] | json}},
291
- {% endfor %}
292
- }
293
- {% endif %}
294
-
295
- {% if gallery.video == 'wistia' and gallery.lightGallery.playerParams.enabled %}
296
- "wistiaPlayerParams": {
297
- {% for option in gallery.lightGallery.playerParams %}
298
- {% if option[0] contains "enabled" %}
299
- {% continue %}
300
- {% endif %}
301
- {{option[0] | json}}: {{option[1] | json}},
302
- {% endfor %}
303
- }
304
- {% endif %}
305
-
306
- {% if gallery.video == 'tiktok' and gallery.lightGallery.playerParams.enabled %}
307
- "tiktokPlayerParams": {
308
- {% for option in gallery.lightGallery.playerParams %}
309
- {% if option[0] contains "enabled" %}
310
- {% continue %}
311
- {% endif %}
312
- {{option[0] | json}}: {{option[1] | json}},
313
- {% endfor %}
314
- }
315
- {% endif %}
316
-
317
- }); // END lightGallery
318
-
319
- }); // END justifiedGallery on('jg.complete)
320
- /* eslint-enable */
321
-
322
- // workaround for Chromium brwosers if callback jg.complete
323
- // NOT fired
324
- //
325
- setTimeout(() => {
326
- if (j1.jg.callback.{{gallery_id}} == 'waiting') {
327
- logger.debug('\n' + 'dyn_loader, callback "jg.callback": ' + j1.jg.callback.{{gallery_id}})
328
- logger.debug('\n' + 'dyn_loader, initialize lightGallery on id: ' + '{{gallery_id}}');
329
-
330
- var lg = document.getElementById("{{gallery_id}}");
331
- lightGallery(lg, {
332
- "plugins": [{{gallery.lightGallery.plugins}}],
333
- {% for option in gallery.lightGallery.options %}
334
- {{option[0] | json}}: {{option[1] | json}},
335
- {% endfor %}
336
- "galleryId": "{{gallery_id}}",
337
- "selector": ".lg-item",
338
- {% if gallery.video == 'html5' and gallery.lightGallery.videojsOptions.enabled %}
339
- "videojsOptions": {
340
- {% for option in gallery.lightGallery.videojsOptions %}
341
- {% if option[0] contains "enabled" %}
342
- {% continue %}
343
- {% endif %}
344
- {{option[0] | json}}: {{option[1] | json}},
345
- {% endfor %}
346
- }
347
- {% endif %}
348
-
349
- {% if gallery.video == 'youtube' and gallery.lightGallery.playerParams.enabled %}
350
- "youTubePlayerParams": {
351
- {% for option in gallery.lightGallery.playerParams %}
352
- {% if option[0] contains "enabled" %}
353
- {% continue %}
354
- {% endif %}
355
- {{option[0] | json}}: {{option[1] | json}},
356
- {% endfor %}
357
- "origin": "origin"
358
- }
359
- {% endif %}
360
-
361
- {% if gallery.video == 'vimeo' and gallery.lightGallery.playerParams.enabled %}
362
- "vimeoPlayerParams": {
363
- {% for option in gallery.lightGallery.playerParams %}
364
- {% if option[0] contains "enabled" %}
365
- {% continue %}
366
- {% endif %}
367
- {{option[0] | json}}: {{option[1] | json}},
368
- {% endfor %}
369
- }
370
- {% endif %}
371
-
372
- {% if gallery.video == 'dailymotion' and gallery.lightGallery.playerParams.enabled %}
373
- "dailymotionPlayerParams": {
374
- {% for option in gallery.lightGallery.playerParams %}
375
- {% if option[0] contains "enabled" %}
376
- {% continue %}
377
- {% endif %}
378
- {{option[0] | json}}: {{option[1] | json}},
379
- {% endfor %}
380
- }
381
- {% endif %}
382
-
383
- {% if gallery.video == 'wistia' and gallery.lightGallery.playerParams.enabled %}
384
- "wistiaPlayerParams": {
385
- {% for option in gallery.lightGallery.playerParams %}
386
- {% if option[0] contains "enabled" %}
387
- {% continue %}
388
- {% endif %}
389
- {{option[0] | json}}: {{option[1] | json}},
390
- {% endfor %}
391
- }
392
- {% endif %}
393
-
394
- }); // END lightGallery
395
- } // END if j1.jg.callback
396
- }, 1000); // END timeout
397
-
398
- clearInterval(load_dependencies['dependencies_met_html_loaded_{{gallery_id}}']);
399
- } // END if xhrLoadState === 'success'
400
- }, 10); // END dependencies_met_html_loaded
401
-
402
- {% endif %} // ENDIF gallery enabled
403
- {% endfor %}
404
- }, // END initialize
405
-
406
- // -------------------------------------------------------------------------
407
- // loadGalleryHTML()
408
- // loads the HTML portion via AJAX for all galleries configured.
409
- // NOTE: Make sure the placeholder DIV is available in the content
410
- // page as generated using the Asciidoc extension gallery::
411
- // -------------------------------------------------------------------------
412
- loadGalleryHTML: (options, gallery) => {
413
- var numGalleries = Object.keys(gallery).length;
414
- var active_grids = numGalleries;
415
- var xhr_data_path = options.xhr_data_path + '/index.html';
416
- var xhr_container_id;
417
-
418
- console.debug('number of galleries found: ' + active_grids);
419
-
420
- _this.setState('load_data');
421
- Object.keys(gallery).forEach((key) => {
422
- if (gallery[key].enabled) {
423
- xhr_container_id = gallery[key].id + '_parent';
424
-
425
- console.debug('load HTML portion on gallery id: ' + gallery[key].id);
426
- j1.loadHTML({
427
- xhr_container_id: xhr_container_id,
428
- xhr_data_path: xhr_data_path,
429
- xhr_data_element: gallery[key].id
430
- });
431
- } else {
432
- console.debug('gallery found disabled on id: ' + gallery[key].id);
433
- active_grids--;
434
- }
435
- });
436
- console.debug('galleries loaded in page enabled|all: ' + active_grids + '|' + numGalleries);
437
- _this.setState('data_loaded');
438
- }, // END loadGalleryHTML
439
-
440
- // -------------------------------------------------------------------------
441
- // messageHandler()
442
- // manage messages send from other J1 modules
443
- // -------------------------------------------------------------------------
444
- messageHandler: (sender, message) => {
445
- var json_message = JSON.stringify(message, undefined, 2);
446
-
447
- logText = '\n' + 'received message from ' + sender + ': ' + json_message;
448
- logger.debug(logText);
449
-
450
- // -----------------------------------------------------------------------
451
- // process commands|actions
452
- // -----------------------------------------------------------------------
453
- if (message.type === 'command' && message.action === 'module_initialized') {
454
-
455
- //
456
- // place handling of command|action here
457
- //
458
-
459
- logger.info('\n' + message.text);
460
- }
461
-
462
- //
463
- // place handling of other command|action here
464
- //
465
-
466
- return true;
467
- }, // END messageHandler
468
-
469
- // -------------------------------------------------------------------------
470
- // setState()
471
- // sets the current (processing) state of the module
472
- // -------------------------------------------------------------------------
473
- setState: (stat) => {
474
- _this.state = stat;
475
- }, // END setState
476
-
477
- // -------------------------------------------------------------------------
478
- // getState()
479
- // Returns the current (processing) state of the module
480
- // -------------------------------------------------------------------------
481
- getState: () => {
482
- return _this.state;
483
- } // END getState
484
-
485
- }; // END main (return)
486
- })(j1, window);
487
-
488
- {% endcapture %}
489
- {% if production %}
490
- {{ cache | minifyJS }}
491
- {% else %}
492
- {{ cache | strip_empty_lines }}
493
- {% endif %}
494
- {% assign cache = nil %}
1
+ ---
2
+ regenerate: true
3
+ ---
4
+
5
+ {% capture cache %}
6
+
7
+ {% comment %}
8
+ # -----------------------------------------------------------------------------
9
+ # ~/assets/themes/j1/adapter/js/gallery.js
10
+ # Liquid template to create the J1 Adapter for J1 Gallery
11
+ #
12
+ # Product/Info:
13
+ # https://jekyll.one
14
+ #
15
+ # Copyright (C) 2023, 2024 Juergen Adams
16
+ #
17
+ # J1 Template is licensed under the MIT License.
18
+ # See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md
19
+ # -----------------------------------------------------------------------------
20
+ {% endcomment %}
21
+
22
+ {% comment %} Liquid procedures
23
+ -------------------------------------------------------------------------------- {% endcomment %}
24
+
25
+ {% comment %} Set global settings
26
+ -------------------------------------------------------------------------------- {% endcomment %}
27
+ {% assign environment = site.environment %}
28
+ {% assign template_version = site.version %}
29
+
30
+ {% comment %} Process YML config data
31
+ ================================================================================ {% endcomment %}
32
+
33
+ {% comment %} Set config files
34
+ -------------------------------------------------------------------------------- {% endcomment %}
35
+ {% assign template_config = site.data.j1_config %}
36
+ {% assign apps = site.data.apps %}
37
+ {% assign modules = site.data.modules %}
38
+
39
+ {% comment %} Set config data
40
+ -------------------------------------------------------------------------------- {% endcomment %}
41
+ {% assign gallery_defaults = modules.defaults.gallery.defaults %}
42
+ {% assign gallery_settings = modules.gallery.settings %}
43
+
44
+ {% comment %} Set config options
45
+ -------------------------------------------------------------------------------- {% endcomment %}
46
+ {% assign gallery_options = gallery_defaults | merge: gallery_settings %}
47
+
48
+ {% comment %} Detect prod mode
49
+ -------------------------------------------------------------------------------- {% endcomment %}
50
+ {% assign production = false %}
51
+ {% if environment == 'prod' or environment == 'production' %}
52
+ {% assign production = true %}
53
+ {% endif %}
54
+
55
+ /*
56
+ # -----------------------------------------------------------------------------
57
+ # ~/assets/themes/j1/adapter/js/gallery.js
58
+ # JS Adapter for J1 Gallery
59
+ #
60
+ # Product/Info:
61
+ # https://jekyll.one
62
+ # https://github.com/miromannino/Justified-Gallery
63
+ #
64
+ # Copyright (C) 2020 Miro Mannino
65
+ # Copyright (C) 2023 Sachin Neravath
66
+ # Copyright (C) 2023, 2024 Juergen Adams
67
+ #
68
+ # J1 Template is licensed under the MIT License.
69
+ # See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md
70
+ # Justified Gallery is licensed under the MIT license
71
+ # See: https://github.com/miromannino/Justified-Gallery/blob/master/LICENSE
72
+ # lightGallery is licensed under the GPLv3 license
73
+ # See: https://github.com/sachinchoolur/lightGallery/blob/master/LICENSE
74
+ # -----------------------------------------------------------------------------
75
+ # Adapter generated: {{site.time}}
76
+ # -----------------------------------------------------------------------------
77
+ */
78
+
79
+ // -----------------------------------------------------------------------------
80
+ // ESLint shimming
81
+ // -----------------------------------------------------------------------------
82
+ /* eslint indent: "off" */
83
+ // -----------------------------------------------------------------------------
84
+ 'use strict';
85
+ j1.adapter.gallery = ((j1, window) => {
86
+
87
+ {% comment %} Global variables
88
+ ------------------------------------------------------------------------------ {% endcomment %}
89
+ var environment = '{{environment}}';
90
+ var state = 'not_started';
91
+ var play_button = '/assets/themes/j1/modules/lightGallery/css/themes/uno/icons/play-button.png';
92
+
93
+ var url;
94
+ var origin;
95
+ var galleryDefaults;
96
+ var gallerySettings;
97
+ var galleryOptions;
98
+ var frontmatterOptions;
99
+
100
+ var _this;
101
+ var logger;
102
+ var logText;
103
+
104
+ // date|time
105
+ var startTime;
106
+ var endTime;
107
+ var startTimeModule;
108
+ var endTimeModule;
109
+ var timeSeconds;
110
+
111
+ // ---------------------------------------------------------------------------
112
+ // helper functions
113
+ // ---------------------------------------------------------------------------
114
+
115
+ // ---------------------------------------------------------------------------
116
+ // main
117
+ // ---------------------------------------------------------------------------
118
+ return {
119
+
120
+ // -------------------------------------------------------------------------
121
+ // adapter initializer
122
+ // -------------------------------------------------------------------------
123
+ init: (options) => {
124
+ url = new URL(window.location.href);
125
+ origin = url.origin;
126
+
127
+ // flag used for Chromium browser workaround
128
+ j1['jg'] = {
129
+ callback: {},
130
+ };
131
+
132
+ // -----------------------------------------------------------------------
133
+ // default module settings
134
+ // -----------------------------------------------------------------------
135
+ var settings = $.extend({
136
+ module_name: 'j1.adapter.gallery',
137
+ generated: '{{site.time}}'
138
+ }, options);
139
+
140
+ // -----------------------------------------------------------------------
141
+ // global variable settings
142
+ // -----------------------------------------------------------------------
143
+ _this = j1.adapter.gallery;
144
+ logger = log4javascript.getLogger('j1.adapter.gallery');
145
+
146
+ // create settings object from frontmatter (page settings)
147
+ frontmatterOptions = options != null ? $.extend({}, options) : {};
148
+
149
+ // Load module DEFAULTS|CONFIG
150
+ galleryDefaults = $.extend({}, {{gallery_defaults | replace: 'nil', 'null' | replace: '=>', ':' }});
151
+ gallerySettings = $.extend({}, {{gallery_settings | replace: 'nil', 'null' | replace: '=>', ':' }});
152
+ galleryOptions = $.extend(true, {}, galleryDefaults, gallerySettings, frontmatterOptions);
153
+
154
+ // load HTML portion for all grids
155
+ console.debug('loading HTML portion for all galleries configured');
156
+ _this.loadGalleryHTML(galleryOptions, galleryOptions.galleries);
157
+
158
+ // -----------------------------------------------------------------------
159
+ // module initializer
160
+ // -----------------------------------------------------------------------
161
+ var dependency_met_page_ready = setInterval (() => {
162
+ var pageState = $('#content').css("display");
163
+ var pageVisible = (pageState === 'block') ? true : false;
164
+ var j1CoreFinished = (j1.getState() === 'finished') ? true : false;
165
+
166
+ if (j1CoreFinished && pageVisible) {
167
+ startTimeModule = Date.now();
168
+
169
+ // initialize state flag
170
+ _this.setState('started');
171
+ logger.debug('\n' + 'state: ' + _this.getState());
172
+ logger.info('\n' + 'module is being initialized');
173
+
174
+ _this.initialize(galleryOptions);
175
+ _this.setState('finished');
176
+
177
+ logger.debug('\n' + 'state: ' + _this.getState());
178
+ logger.info('\n' + 'module initialized successfully');
179
+
180
+ endTimeModule = Date.now();
181
+ logger.info('\n' + 'module initializing time: ' + (endTimeModule-startTimeModule) + 'ms');
182
+
183
+ clearInterval(dependency_met_page_ready);
184
+ } // END 'finished' && 'pageVisible'
185
+ }, 10); // END dependency_met_page_ready
186
+ }, // END init
187
+
188
+ // -----------------------------------------------------------------------
189
+ // Load AJAX data and initialize the jg gallery
190
+ // -----------------------------------------------------------------------
191
+ initialize: (options) => {
192
+ var xhrLoadState = 'pending'; // (initial) load state for the HTML portion of the slider
193
+ var load_dependencies = {};
194
+ var dependency;
195
+
196
+ logger = log4javascript.getLogger('j1.adapter.gallery');
197
+
198
+ _this.setState('running');
199
+ logger.debug('\n' + 'state: ' + _this.getState());
200
+
201
+ {% for gallery in gallery_options.galleries %}
202
+
203
+ {% if gallery.enabled %}
204
+ {% assign gallery_id = gallery.id %}
205
+ logger.info('\n' + 'found gallery on id: ' + '{{gallery_id}}');
206
+
207
+ // create dynamic loader variable to setup the grid on id {{gallery_id}}
208
+ dependency = 'dependencies_met_html_loaded_{{gallery_id}}';
209
+ load_dependencies[dependency] = '';
210
+
211
+ // initialize the gallery if HTML portion successfully loaded
212
+ //
213
+ load_dependencies['dependencies_met_html_loaded_{{gallery_id}}'] = setInterval (() => {
214
+ // check if HTML portion of the gallery is loaded successfully
215
+ xhrLoadState = j1.xhrDOMState['#{{gallery_id}}_parent'];
216
+ if (xhrLoadState === 'success') {
217
+ var $grid_{{gallery_id}} = $('#{{gallery_id}}'); // used for later access
218
+
219
+ logger.debug('\n' + 'dyn_loader, initialize gallery on id: ' + '{{gallery_id}}');
220
+
221
+ j1.jg.callback.{{gallery_id}} = 'waiting';
222
+
223
+ /* eslint-disable */
224
+ $('#{{gallery_id}}').justifiedGallery({
225
+ {% for option in gallery.gallery_options %}
226
+ {% if option[0] contains "gutters" %}
227
+ {{'margins' | json}}: {{option[1] | json}},
228
+ {% continue %}
229
+ {% endif %}
230
+ {{option[0] | json}}: {{option[1] | json}},
231
+ {% endfor %}
232
+ })
233
+ .on('jg.complete', (evt) => {
234
+ evt.stopPropagation();
235
+
236
+ j1.jg.callback.{{gallery_id}} = 'successful';
237
+
238
+ // setup the lightbox
239
+ //
240
+ logger.debug('\n' + 'dyn_loader, callback "jg.complete" entered on id: ' + '{{gallery_id}}');
241
+ logger.debug('\n' + 'dyn_loader, initialize lightGallery on id: ' + '{{gallery_id}}');
242
+
243
+ var lg = document.getElementById("{{gallery_id}}");
244
+ lightGallery(lg, {
245
+ "plugins": [{{gallery.lightGallery.plugins}}],
246
+ {% for option in gallery.lightGallery.options %}
247
+ {{option[0] | json}}: {{option[1] | json}},
248
+ {% endfor %}
249
+ "galleryId": "{{gallery_id}}",
250
+ "selector": ".lg-item",
251
+ {% if gallery.video == 'html5' and gallery.lightGallery.videojsOptions.enabled %}
252
+ "videojsOptions": {
253
+ {% for option in gallery.lightGallery.videojsOptions %}
254
+ {% if option[0] contains "enabled" %}
255
+ {% continue %}
256
+ {% endif %}
257
+ {{option[0] | json}}: {{option[1] | json}},
258
+ {% endfor %}
259
+ }
260
+ {% endif %}
261
+
262
+ {% if gallery.video == 'youtube' and gallery.lightGallery.playerParams.enabled %}
263
+ "youTubePlayerParams": {
264
+ {% for option in gallery.lightGallery.playerParams %}
265
+ {% if option[0] contains "enabled" %}
266
+ {% continue %}
267
+ {% endif %}
268
+ {{option[0] | json}}: {{option[1] | json}},
269
+ {% endfor %}
270
+ "origin": "origin"
271
+ }
272
+ {% endif %}
273
+
274
+ {% if gallery.video == 'vimeo' and gallery.lightGallery.playerParams.enabled %}
275
+ "vimeoPlayerParams": {
276
+ {% for option in gallery.lightGallery.playerParams %}
277
+ {% if option[0] contains "enabled" %}
278
+ {% continue %}
279
+ {% endif %}
280
+ {{option[0] | json}}: {{option[1] | json}},
281
+ {% endfor %}
282
+ }
283
+ {% endif %}
284
+
285
+ {% if gallery.video == 'dailymotion' and gallery.lightGallery.playerParams.enabled %}
286
+ "dailymotionPlayerParams": {
287
+ {% for option in gallery.lightGallery.playerParams %}
288
+ {% if option[0] contains "enabled" %}
289
+ {% continue %}
290
+ {% endif %}
291
+ {{option[0] | json}}: {{option[1] | json}},
292
+ {% endfor %}
293
+ }
294
+ {% endif %}
295
+
296
+ {% if gallery.video == 'wistia' and gallery.lightGallery.playerParams.enabled %}
297
+ "wistiaPlayerParams": {
298
+ {% for option in gallery.lightGallery.playerParams %}
299
+ {% if option[0] contains "enabled" %}
300
+ {% continue %}
301
+ {% endif %}
302
+ {{option[0] | json}}: {{option[1] | json}},
303
+ {% endfor %}
304
+ }
305
+ {% endif %}
306
+
307
+ {% if gallery.video == 'tiktok' and gallery.lightGallery.playerParams.enabled %}
308
+ "tiktokPlayerParams": {
309
+ {% for option in gallery.lightGallery.playerParams %}
310
+ {% if option[0] contains "enabled" %}
311
+ {% continue %}
312
+ {% endif %}
313
+ {{option[0] | json}}: {{option[1] | json}},
314
+ {% endfor %}
315
+ }
316
+ {% endif %}
317
+
318
+ }); // END lightGallery
319
+
320
+ }); // END justifiedGallery on('jg.complete)
321
+ /* eslint-enable */
322
+
323
+ // workaround for Chromium brwosers if callback jg.complete
324
+ // NOT fired
325
+ //
326
+ setTimeout(() => {
327
+ if (j1.jg.callback.{{gallery_id}} == 'waiting') {
328
+ logger.debug('\n' + 'dyn_loader, callback "jg.callback": ' + j1.jg.callback.{{gallery_id}})
329
+ logger.debug('\n' + 'dyn_loader, initialize lightGallery on id: ' + '{{gallery_id}}');
330
+
331
+ var lg = document.getElementById("{{gallery_id}}");
332
+ lightGallery(lg, {
333
+ "plugins": [{{gallery.lightGallery.plugins}}],
334
+ {% for option in gallery.lightGallery.options %}
335
+ {{option[0] | json}}: {{option[1] | json}},
336
+ {% endfor %}
337
+ "galleryId": "{{gallery_id}}",
338
+ "selector": ".lg-item",
339
+ {% if gallery.video == 'html5' and gallery.lightGallery.videojsOptions.enabled %}
340
+ "videojsOptions": {
341
+ {% for option in gallery.lightGallery.videojsOptions %}
342
+ {% if option[0] contains "enabled" %}
343
+ {% continue %}
344
+ {% endif %}
345
+ {{option[0] | json}}: {{option[1] | json}},
346
+ {% endfor %}
347
+ }
348
+ {% endif %}
349
+
350
+ {% if gallery.video == 'youtube' and gallery.lightGallery.playerParams.enabled %}
351
+ "youTubePlayerParams": {
352
+ {% for option in gallery.lightGallery.playerParams %}
353
+ {% if option[0] contains "enabled" %}
354
+ {% continue %}
355
+ {% endif %}
356
+ {{option[0] | json}}: {{option[1] | json}},
357
+ {% endfor %}
358
+ "origin": "origin"
359
+ }
360
+ {% endif %}
361
+
362
+ {% if gallery.video == 'vimeo' and gallery.lightGallery.playerParams.enabled %}
363
+ "vimeoPlayerParams": {
364
+ {% for option in gallery.lightGallery.playerParams %}
365
+ {% if option[0] contains "enabled" %}
366
+ {% continue %}
367
+ {% endif %}
368
+ {{option[0] | json}}: {{option[1] | json}},
369
+ {% endfor %}
370
+ }
371
+ {% endif %}
372
+
373
+ {% if gallery.video == 'dailymotion' and gallery.lightGallery.playerParams.enabled %}
374
+ "dailymotionPlayerParams": {
375
+ {% for option in gallery.lightGallery.playerParams %}
376
+ {% if option[0] contains "enabled" %}
377
+ {% continue %}
378
+ {% endif %}
379
+ {{option[0] | json}}: {{option[1] | json}},
380
+ {% endfor %}
381
+ }
382
+ {% endif %}
383
+
384
+ {% if gallery.video == 'wistia' and gallery.lightGallery.playerParams.enabled %}
385
+ "wistiaPlayerParams": {
386
+ {% for option in gallery.lightGallery.playerParams %}
387
+ {% if option[0] contains "enabled" %}
388
+ {% continue %}
389
+ {% endif %}
390
+ {{option[0] | json}}: {{option[1] | json}},
391
+ {% endfor %}
392
+ }
393
+ {% endif %}
394
+
395
+ }); // END lightGallery
396
+ } // END if j1.jg.callback
397
+ }, 1000); // END timeout
398
+
399
+ clearInterval(load_dependencies['dependencies_met_html_loaded_{{gallery_id}}']);
400
+ } // END if xhrLoadState === 'success'
401
+ }, 10); // END dependencies_met_html_loaded
402
+
403
+ {% endif %} // ENDIF gallery enabled
404
+ {% endfor %}
405
+ }, // END initialize
406
+
407
+ // -------------------------------------------------------------------------
408
+ // loadGalleryHTML()
409
+ // loads the HTML portion via AJAX for all galleries configured.
410
+ // NOTE: Make sure the placeholder DIV is available in the content
411
+ // page as generated using the Asciidoc extension gallery::
412
+ // -------------------------------------------------------------------------
413
+ loadGalleryHTML: (options, gallery) => {
414
+ var numGalleries = Object.keys(gallery).length;
415
+ var active_grids = numGalleries;
416
+ var xhr_data_path = options.xhr_data_path + '/index.html';
417
+ var xhr_container_id;
418
+
419
+ console.debug('number of galleries found: ' + active_grids);
420
+
421
+ _this.setState('load_data');
422
+ Object.keys(gallery).forEach((key) => {
423
+ if (gallery[key].enabled) {
424
+ xhr_container_id = gallery[key].id + '_parent';
425
+
426
+ console.debug('load HTML portion on gallery id: ' + gallery[key].id);
427
+ j1.loadHTML({
428
+ xhr_container_id: xhr_container_id,
429
+ xhr_data_path: xhr_data_path,
430
+ xhr_data_element: gallery[key].id
431
+ });
432
+ } else {
433
+ console.debug('gallery found disabled on id: ' + gallery[key].id);
434
+ active_grids--;
435
+ }
436
+ });
437
+ console.debug('galleries loaded in page enabled|all: ' + active_grids + '|' + numGalleries);
438
+ _this.setState('data_loaded');
439
+ }, // END loadGalleryHTML
440
+
441
+ // -------------------------------------------------------------------------
442
+ // messageHandler()
443
+ // manage messages send from other J1 modules
444
+ // -------------------------------------------------------------------------
445
+ messageHandler: (sender, message) => {
446
+ var json_message = JSON.stringify(message, undefined, 2);
447
+
448
+ logText = '\n' + 'received message from ' + sender + ': ' + json_message;
449
+ logger.debug(logText);
450
+
451
+ // -----------------------------------------------------------------------
452
+ // process commands|actions
453
+ // -----------------------------------------------------------------------
454
+ if (message.type === 'command' && message.action === 'module_initialized') {
455
+
456
+ //
457
+ // place handling of command|action here
458
+ //
459
+
460
+ logger.info('\n' + message.text);
461
+ }
462
+
463
+ //
464
+ // place handling of other command|action here
465
+ //
466
+
467
+ return true;
468
+ }, // END messageHandler
469
+
470
+ // -------------------------------------------------------------------------
471
+ // setState()
472
+ // sets the current (processing) state of the module
473
+ // -------------------------------------------------------------------------
474
+ setState: (stat) => {
475
+ _this.state = stat;
476
+ }, // END setState
477
+
478
+ // -------------------------------------------------------------------------
479
+ // getState()
480
+ // Returns the current (processing) state of the module
481
+ // -------------------------------------------------------------------------
482
+ getState: () => {
483
+ return _this.state;
484
+ } // END getState
485
+
486
+ }; // END main (return)
487
+ })(j1, window);
488
+
489
+ {% endcapture %}
490
+ {% if production %}
491
+ {{ cache | minifyJS }}
492
+ {% else %}
493
+ {{ cache | strip_empty_lines }}
494
+ {% endif %}
495
+ {% assign cache = nil %}