j1-template 2021.1.4 → 2021.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/themes/j1/layouts/layout_metadata_generator.html +4 -4
  3. data/_includes/themes/j1/modules/connectors/ad/google-adsense.html +7 -15
  4. data/_includes/themes/j1/modules/connectors/ads +18 -7
  5. data/_includes/themes/j1/modules/connectors/analytic/google-analytics.html +7 -3
  6. data/_includes/themes/j1/modules/connectors/analytics +17 -3
  7. data/_includes/themes/j1/modules/connectors/comments +22 -8
  8. data/_includes/themes/j1/modules/connectors/translator +20 -6
  9. data/_includes/themes/j1/modules/navigator/generator.html +2 -2
  10. data/_includes/themes/j1/procedures/global/select_location.proc +3 -3
  11. data/_layouts/default.html +4 -7
  12. data/assets/data/cookieconsent.html +249 -0
  13. data/assets/data/quicklinks.html +18 -16
  14. data/assets/data/themes.json +6 -6
  15. data/assets/error_pages/HTTP204.html +30 -10
  16. data/assets/error_pages/HTTP400.html +29 -8
  17. data/assets/error_pages/HTTP401.html +29 -9
  18. data/assets/error_pages/HTTP403.html +29 -8
  19. data/assets/error_pages/HTTP404.html +29 -8
  20. data/assets/error_pages/HTTP500.html +29 -8
  21. data/assets/error_pages/HTTP501.html +29 -8
  22. data/assets/error_pages/HTTP502.html +29 -8
  23. data/assets/error_pages/HTTP503.html +30 -8
  24. data/assets/themes/j1/adapter/js/cookieConsent.js +290 -0
  25. data/assets/themes/j1/adapter/js/fam.js +2 -1
  26. data/assets/themes/j1/adapter/js/j1.js +154 -153
  27. data/assets/themes/j1/adapter/js/navigator.js +157 -200
  28. data/assets/themes/j1/adapter/js/themer.1.js +326 -0
  29. data/assets/themes/j1/adapter/js/themer.js +41 -57
  30. data/assets/themes/j1/adapter/js/toccer.js +4 -45
  31. data/assets/themes/j1/core/css/themes/uno-light/bootstrap.css +2 -2
  32. data/assets/themes/j1/core/css/themes/uno-light/bootstrap.min.css +1 -1
  33. data/assets/themes/j1/core/js/template.js +3 -9
  34. data/assets/themes/j1/core/js/template.js.map +1 -1
  35. data/assets/themes/j1/core/js/template.min.js +3 -9
  36. data/assets/themes/j1/core/js/template.min.js.map +1 -1
  37. data/assets/themes/j1/modules/cookieConsent/LICENSE +21 -0
  38. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +301 -0
  39. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js +301 -0
  40. data/assets/themes/j1/modules/fam/css/{uno → theme/uno}/fam.css +0 -0
  41. data/assets/themes/j1/modules/fam/css/theme/uno/fam.min.css +15 -0
  42. data/assets/themes/j1/modules/fam/js/fam.js +1 -6
  43. data/assets/themes/j1/modules/iframeResizer/examples/frame.absolute.html +4 -2
  44. data/assets/themes/j1/modules/iframeResizer/examples/frame.content.html +4 -3
  45. data/assets/themes/j1/modules/iframeResizer/examples/frame.hover.html +4 -2
  46. data/assets/themes/j1/modules/iframeResizer/examples/frame.nested.html +4 -2
  47. data/assets/themes/j1/modules/iframeResizer/examples/frame.textarea.html +4 -2
  48. data/assets/themes/j1/modules/iframeResizer/examples/frame.tolerance.html +4 -2
  49. data/assets/themes/j1/modules/iframeResizer/examples/index.html +2 -0
  50. data/assets/themes/j1/modules/iframeResizer/examples/two.html +4 -2
  51. data/assets/themes/j1/modules/mmenuLight/css/{mmenu.css → mmenu-light.css} +0 -0
  52. data/assets/themes/j1/modules/mmenuLight/css/{mmenu.min.css → mmenu-light.min.css} +0 -0
  53. data/assets/themes/j1/modules/mmenuLight/css/theme/{uno.css → uno/mmenu.css} +0 -0
  54. data/assets/themes/j1/modules/mmenuLight/css/theme/{uno.min.css → uno/mmenu.min.css} +0 -0
  55. data/assets/themes/j1/modules/rtable/css/theme/{uno.css → uno/rtable.css} +0 -0
  56. data/assets/themes/j1/modules/rtable/css/theme/{uno.min.css → uno/rtable.min.css} +0 -0
  57. data/assets/themes/j1/modules/themeSwitcher/js/switcher.js +34 -49
  58. data/assets/themes/j1/modules/themeSwitcher/js/switcher.min.js +410 -2
  59. data/assets/themes/j1/modules/util/js/domready.js +146 -0
  60. data/assets/themes/j1/modules/util/js/gtag-opt-in.js +1 -0
  61. data/lib/j1/version.rb +3 -3
  62. data/lib/j1_app/j1_auth_manager/auth_manager.rb +2 -3
  63. data/lib/starter_web/Gemfile +1 -1
  64. data/lib/starter_web/_config.yml +19 -10
  65. data/lib/starter_web/_data/_defaults/resources.yml +11 -8
  66. data/lib/starter_web/_data/j1_config.yml +21 -18
  67. data/lib/starter_web/_data/modules/{cookiebar.yml → cookieconsent.yml} +5 -4
  68. data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +136 -0
  69. data/lib/starter_web/_data/modules/defaults/themer.yml +2 -1
  70. data/lib/starter_web/_data/pages/builder.yml +7 -7
  71. data/lib/starter_web/_data/private.default.yml +119 -0
  72. data/lib/starter_web/_data/private.yml +6 -6
  73. data/lib/starter_web/_data/resources.yml +15 -14
  74. data/lib/starter_web/_includes/attributes.asciidoc +10 -1
  75. data/lib/starter_web/_plugins/lunr_index.rb +1 -1
  76. data/lib/starter_web/assets/images/modules/attics/{cookies-1920x1200-bw.jpg → cookies-1920x1200.jpg} +0 -0
  77. data/lib/starter_web/assets/images/modules/attics/lianhao-1920x1280.jpg +0 -0
  78. data/lib/starter_web/collections/posts/public/featured/_posts/2020-01-01-about-cookies.adoc +2 -2
  79. data/lib/starter_web/dot.gitignore +1 -1
  80. data/lib/starter_web/index.html +3 -3
  81. data/lib/starter_web/package.json +2 -2
  82. data/lib/starter_web/pages/public/blog/navigator/archive.html +5 -3
  83. data/lib/starter_web/pages/public/blog/navigator/archive/categoryview.html +3 -2
  84. data/lib/starter_web/pages/public/blog/navigator/archive/dateview.html +6 -4
  85. data/lib/starter_web/pages/public/blog/navigator/archive/tagview.html +23 -5
  86. data/lib/starter_web/pages/public/cookieConsent.adoc +93 -0
  87. data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +2 -1
  88. data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +111 -213
  89. data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
  90. data/lib/starter_web/utilsrv/package.json +1 -1
  91. metadata +24 -76
  92. data/_includes/themes/j1/modules/navigator/generator.org.html +0 -232
  93. data/assets/data/cookiebar.html +0 -288
  94. data/assets/data/footer.new.1.html +0 -256
  95. data/assets/data/footer.new.2.html +0 -256
  96. data/assets/data/footer.org.html +0 -249
  97. data/assets/error_pages/HTTP520.html +0 -68
  98. data/assets/error_pages/HTTP521.html +0 -68
  99. data/assets/error_pages/HTTP533.html +0 -68
  100. data/assets/themes/j1/adapter/js/cookiebar.js +0 -212
  101. data/assets/themes/j1/adapter/js/j1.new.js +0 -1878
  102. data/assets/themes/j1/adapter/js/j1.org.js +0 -1874
  103. data/assets/themes/j1/modules/_lightGallery/css/core/lg-fb-comment-box.css +0 -58
  104. data/assets/themes/j1/modules/_lightGallery/css/core/lg-fb-comment-box.min.css +0 -5
  105. data/assets/themes/j1/modules/_lightGallery/css/core/lg-transitions.css +0 -778
  106. data/assets/themes/j1/modules/_lightGallery/css/core/lg-transitions.min.css +0 -5
  107. data/assets/themes/j1/modules/_lightGallery/css/core/lightgallery.css +0 -981
  108. data/assets/themes/j1/modules/_lightGallery/css/core/lightgallery.min.css +0 -5
  109. data/assets/themes/j1/modules/_lightGallery/css/fonts/lg.eot +0 -0
  110. data/assets/themes/j1/modules/_lightGallery/css/fonts/lg.svg +0 -47
  111. data/assets/themes/j1/modules/_lightGallery/css/fonts/lg.ttf +0 -0
  112. data/assets/themes/j1/modules/_lightGallery/css/fonts/lg.woff +0 -0
  113. data/assets/themes/j1/modules/_lightGallery/css/img/loading.gif +0 -0
  114. data/assets/themes/j1/modules/_lightGallery/css/img/video-play.png +0 -0
  115. data/assets/themes/j1/modules/_lightGallery/css/img/vimeo-play.png +0 -0
  116. data/assets/themes/j1/modules/_lightGallery/css/img/youtube-play.png +0 -0
  117. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/animation-w.png +0 -0
  118. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/customize-w.png +0 -0
  119. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/dynamic-w.png +0 -0
  120. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/facebook-icon.svg +0 -10
  121. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/googleplus-icon.svg +0 -30
  122. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/html5-w.png +0 -0
  123. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/linked-in.png +0 -0
  124. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/module-w.png +0 -0
  125. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/play-button.png +0 -0
  126. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/responsive-w.png +0 -0
  127. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/thumb-w.png +0 -0
  128. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/touch-w.png +0 -0
  129. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/twitter-icon.svg +0 -15
  130. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/twitter.png +0 -0
  131. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/video1-w.png +0 -0
  132. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/zoom-w.png +0 -0
  133. data/assets/themes/j1/modules/_lightGallery/css/themes/icons/zoom.png +0 -0
  134. data/assets/themes/j1/modules/_lightGallery/css/themes/uno.css +0 -262
  135. data/assets/themes/j1/modules/_lightGallery/css/themes/uno.min.css +0 -15
  136. data/assets/themes/j1/modules/_lightGallery/js/core/lightgallery.js +0 -1362
  137. data/assets/themes/j1/modules/_lightGallery/js/core/lightgallery.min.js +0 -4
  138. data/assets/themes/j1/modules/_lightGallery/js/modules/j1/j1-video.js +0 -402
  139. data/assets/themes/j1/modules/_lightGallery/js/modules/j1/j1-video.min.js +0 -8
  140. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-autoplay.js +0 -206
  141. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-autoplay.min.js +0 -5
  142. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-fullscreen.js +0 -126
  143. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-fullscreen.min.js +0 -5
  144. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-hash.js +0 -101
  145. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-hash.min.js +0 -5
  146. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-pager.js +0 -105
  147. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-pager.min.js +0 -5
  148. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-share.js +0 -107
  149. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-share.min.js +0 -5
  150. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-thumbnail.js +0 -478
  151. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-thumbnail.min.js +0 -5
  152. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-video.js +0 -342
  153. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-video.min.js +0 -5
  154. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-zoom.js +0 -527
  155. data/assets/themes/j1/modules/_lightGallery/js/modules/lg-zoom.min.js +0 -5
  156. data/lib/starter_web/_data/modules/defaults/cookiebar.yml +0 -133
@@ -66,16 +66,7 @@
66
66
  this.settings = $.extend({}, $.fn.bootstrapThemeSwitcher.defaults, options);
67
67
  this.themesList = [];
68
68
 
69
- // $.when (
70
- // this.getThemes()
71
- // )
72
- // .then(function(data) {
73
- // logger.info('loading local themes (json) finished');
74
- // })
75
- // .catch(function(error) {
76
- // logger.error('loading local themes (json) failed: ' + error);
77
- // });
78
-
69
+ // loading local themes
79
70
  this.getThemes();
80
71
  return this;
81
72
  };
@@ -98,9 +89,9 @@
98
89
  // checkStyleSheetByName
99
90
  // -------------------------------------------------------------------------
100
91
  checkStyleSheetByName: function (name) {
101
- var found = false;
102
- var test = '\/' + name + '\/';
103
- var re = new RegExp(test, 'i');
92
+ var found = false;
93
+ var test = '\/' + name + '\/';
94
+ var re = new RegExp(test, 'i');
104
95
 
105
96
  for(var i = 0; i < document.styleSheets.length; i++){
106
97
  if(re.test(document.styleSheets[i].href)){
@@ -131,29 +122,26 @@
131
122
  var debug = settings.debug;
132
123
  var includeCSS = this.settings.includeBootswatch;
133
124
 
134
- // Detect|Set J1 UserState
125
+ // detect|set user state cookie
135
126
  user_state_detected = j1.existsCookie ( 'j1.user.state' );
136
127
  if ( user_state_detected ) {
137
- logger.debug('user state cookie found');
128
+ logger.debug('cookie found: j1.user.state');
138
129
  j1_user_state = j1.readCookie(user_state_cookie_name);
139
130
  } else {
140
- logger.error('user state NOT cookie found');
131
+ logger.error('cookie not found: j1.user.state');
141
132
  }
142
133
 
143
134
  themeName = j1_user_state.theme_name;
144
135
  theme_css = j1_user_state.theme_css;
145
- theme_extension_css = j1_user_state.theme_extension_css;
146
136
 
147
- if ( cssFile === undefined ) { cssFile = this.settings.defaultCssFile; }
148
- if ( name === undefined ) { name = cssFile; }
149
- // Clear 'includeCSS' if NO theme extension CSS is needed
150
- if ( name === this.settings.skipIncludeBootswatch ) { includeCSS = ''; }
137
+ if (typeof cssFile === 'undefined') { cssFile = this.settings.defaultCssFile; }
138
+ if (typeof name === 'undefined') { name = cssFile; }
151
139
 
152
140
  // check if theme is to be saved to cookie
153
- if ( settings.saveToCookie ) {
154
- if ( Cookies === undefined ) {
141
+ if (settings.saveToCookie) {
142
+ if ( typeof Cookies === 'undefined' ) {
155
143
  if ( debug === 'true' ) {
156
- logger.error('saveToCookie is set to true but Cookies library is not present');
144
+ logger.error('cookies library not present');
157
145
  }
158
146
  return false;
159
147
  }
@@ -162,19 +150,19 @@
162
150
  j1_user_state.theme_css = cssFile;
163
151
 
164
152
  if (!(j1_user_state.theme_name.includes('Uno') || j1_user_state.theme_name == 'Bootstrap')) {
165
- j1_user_state.theme_author = 'Bootswatch';
166
- j1_user_state.theme_author_url = 'https://bootswatch.com/';
153
+ j1_user_state.theme_author = 'Bootswatch';
154
+ j1_user_state.theme_author_url = 'https://bootswatch.com/';
167
155
  } else {
168
- j1_user_state.theme_author = 'J1 Team';
169
- j1_user_state.theme_author_url = 'https://jekyll.one/';
156
+ j1_user_state.theme_author = 'J1 Team';
157
+ j1_user_state.theme_author_url = 'https://jekyll.one/';
170
158
  }
171
159
 
172
160
  j1.writeCookie({
173
161
  name: user_state_cookie_name,
174
162
  data: j1_user_state
175
163
  });
176
- // force reload the page from the server (skip cache)
177
- // and detect selected theme from cookie
164
+
165
+ // reload current page (skip cache)
178
166
  location.reload(true);
179
167
  } else {
180
168
  logger.warn('write to cookie : disabled');
@@ -188,20 +176,21 @@
188
176
  // -------------------------------------------------------------------------
189
177
  loadThemeFromCookie: function (options) {
190
178
 
191
- if ( Cookies === undefined ) {
192
- logger.error('loadThemeFromCookie was called but Cookies library is not present');
179
+ if ( typeof Cookies === 'undefined' ) {
180
+ logger.error('cookies library not present');
193
181
  return false;
194
182
  }
195
183
 
196
184
  var settings = $.extend({}, $.fn.bootstrapThemeSwitcher.defaults, options);
197
185
 
198
- // Detect|Set J1 UserState
186
+ // detect|set user state cookie
199
187
  user_state_detected = j1.existsCookie ( 'j1.user.state' );
188
+
200
189
  if ( user_state_detected ) {
201
- logger.info('User state cookie found');
190
+ logger.info('cookie found: j1.user.state');
202
191
  j1_user_state = j1.readCookie(user_state_cookie_name);
203
192
  } else {
204
- logger.error('User state NOT cookie found');
193
+ logger.error('cookie not found: j1.user.state');
205
194
  }
206
195
 
207
196
  var themeName = j1_user_state.theme_name;
@@ -214,8 +203,8 @@
214
203
  // addTheme
215
204
  // -------------------------------------------------------------------------
216
205
  addTheme: function(name, cssFile, start, deleteCount) {
217
- if (start === undefined) { start = 0; }
218
- if (deleteCount === undefined) { deleteCount = 0; }
206
+ if (typeof start === 'undefined') { start = 0; }
207
+ if (typeof deleteCount === 'undefined') { deleteCount = 0; }
219
208
  this.themesList.splice(start, deleteCount, {name: name, css: cssFile});
220
209
  this.addThemesToControl();
221
210
  }, // END addTheme
@@ -224,11 +213,11 @@
224
213
  // addThemesToControl
225
214
  // -------------------------------------------------------------------------
226
215
  addThemesToControl: function() {
227
- if (this.$element === undefined) {
216
+ if (typeof this.$element === 'undefined') {
228
217
  logger.error('bootstrapThemeSelector|addThemesToControl: Element is undefined');
229
218
  return false;
230
219
  }
231
- if (this.themesList === undefined) {
220
+ if (typeof this.themesList === 'undefined') {
232
221
  logger.error('bootstrapThemeSelector|addThemesToControl: Themes is undefined');
233
222
  return false;
234
223
  }
@@ -264,7 +253,7 @@
264
253
  var themeName;
265
254
  var debug = settings.debug;
266
255
 
267
- // Detect|Set J1 UserState
256
+ // detect|set user state cookie
268
257
  user_state_detected = j1.existsCookie ( 'j1.user.state' );
269
258
  if ( user_state_detected ) {
270
259
  logger.debug('User state cookie found');
@@ -308,7 +297,7 @@
308
297
  } else {
309
298
  base.switchTheme(value.name, value.cssCdn);
310
299
  }
311
- //Remove previous "active" class and apply to latest clicked element
300
+ // remove previous "active" class and apply to latest clicked element
312
301
  $(this).parent().find('li').removeClass('active');
313
302
  $(this).addClass('active');
314
303
  });
@@ -355,8 +344,6 @@
355
344
  $.ajax({
356
345
  url: this.settings.localFeed,
357
346
  // jadams 2016-10-10: removed the setting for sychronous XMLHttpRequest
358
- // because deprecated by jQuery on the MAIN thread. Because the Theme Manager
359
- // is initialized very early, no blocking (sychronous) AJAX call is needed
360
347
  // async: false,
361
348
  dataType: 'json',
362
349
  success: function (data) {
@@ -373,12 +360,10 @@
373
360
  $.ajax({
374
361
  url: this.settings.bootswatchApiUrl + '/' + this.settings.bootswatchApiVersion + '.json',
375
362
  // jadams 2016-10-10: removed the setting for sychronous XMLHttpRequest
376
- // because deprecated by jQuery on the main thread. Because the Theme Manager
377
- // is initialized very early, no blocking|sychronous AJAX call is needed
378
363
  // async: false,
379
364
  dataType: 'json',
380
365
  success: function (data) {
381
- if (data.themes === undefined) {
366
+ if (typeof data.themes === 'undefined') {
382
367
  return null;
383
368
  }
384
369
  base.themesList = data.themes;
@@ -393,7 +378,7 @@
393
378
  // themes
394
379
  // -------------------------------------------------------------------------
395
380
  themes : function (newThemeList) {
396
- if (newThemeList === undefined) {
381
+ if (typeof newThemeList === 'undefined') {
397
382
  return this.themesList;
398
383
  }
399
384
  else {
@@ -419,7 +404,7 @@
419
404
  if (typeof option === 'string') {
420
405
  methodReturn = data[ option ].apply(data, args);
421
406
  }
422
- return ( methodReturn === undefined ) ? $this : methodReturn;
407
+ return ( typeof methodReturn === 'undefined' ) ? $this : methodReturn;
423
408
  };
424
409
 
425
410
  $.fn.bootstrapThemeSwitcher.defaults = {
@@ -430,7 +415,7 @@
430
415
  cookieThemeCss: 'boostrapTheme.css',
431
416
  cookieExpiration: 365,
432
417
  cookiePath: '/',
433
- defaultCssFile: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css',
418
+ defaultCssFile: 'https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css',
434
419
  bootswatchApiUrl: 'https://bootswatch.com/api/',
435
420
  bootswatchApiVersion: '4',
436
421
  loadFromBootswatch: true,
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  # -----------------------------------------------------------------------------
3
- # ~/assets/themes/j1/modules/bsThemeSwitcher/js/switcher.min.js
3
+ # ~/assets/themes/j1/modules/bsThemeSwitcher/js/switcher.js
4
4
  # Provides Javascript functions for Bootstrap ThemeSwitcher
5
5
  #
6
6
  # Product/Info:
@@ -15,7 +15,26 @@
15
15
  # Bootstrap Theme Switcher is licensed under the MIT License.
16
16
  # See: https://github.com/jguadagno/bootstrapThemeSwitcher
17
17
  # -----------------------------------------------------------------------------
18
+ # NOTE: This modules is MODIFIED to be used with MobileMenu (mmenuLight).
19
+ # The original version cannot be used with J1 for theme menu creation!
20
+ # -----------------------------------------------------------------------------
18
21
  */
22
+ 'use strict';
23
+
24
+ // -----------------------------------------------------------------------------
25
+ // ESLint shimming
26
+ // -----------------------------------------------------------------------------
27
+ /* eslint indent: "off" */
28
+ /* eslint no-console: ["error", { allow: ["log", "warn", "error"] }] */
29
+ /* eslint no-unused-vars: "off" */
30
+ /* eslint no-undef: "off" */
31
+ /* eslint no-useless-escape: "off" */
32
+ /* eslint no-prototype-builtins: "off" */
33
+ /* eslint no-shadow-restricted-names: "off" */
34
+ /* global jQuery */
35
+ /* global Cookies */
36
+ // -----------------------------------------------------------------------------
37
+
19
38
  /**
20
39
  * jQuery Twitter Bootstrap Theme Switcher v1.1.5
21
40
  * https://github.com/jguadagno/bootstrapThemeSwitcher
@@ -23,4 +42,393 @@
23
42
  * Copyright 2014, Joseph Guadagno
24
43
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
25
44
  */
26
- "use strict";(function(h,i,j,e){var d=h.fn.bootstrapThemeSwitcher;var f=j1.getCookieNames();const n=f.user_state;var m=log4javascript.getLogger("j1.core.switcher");var a;var g;var b={};var k;var c;var l=function(p,o){this.$element=h(p);this.settings=h.extend({},h.fn.bootstrapThemeSwitcher.defaults,o);this.themesList=[];this.getThemes();return this};l.prototype={clear:function(){m.debug("bootstrapThemeSwitcher.clear");return this.$element.each(function(){this.$element.empty()})},update:function(){m.debug("bootstrapThemeSwitcher.update");this.getThemes()},checkStyleSheetByName:function(o){var r=false;var s="/"+o+"/";var q=new RegExp(s,"i");for(var p=0;p<j.styleSheets.length;p++){if(q.test(j.styleSheets[p].href)){r=true;break}}return r},switchTheme:function(p,u){var v=h(this);var r=h.extend({},h.fn.bootstrapThemeSwitcher.defaults,v.data("bootstrapThemeSwitcher"));var t;var x;var w;var q=r.cssThemeLink;var o=r.debug;var s=this.settings.includeBootswatch;g=j1.existsCookie("j1.user.state");if(g){m.debug("user state cookie found");b=j1.readCookie(n)}else{m.error("user state NOT cookie found")}t=b.theme_name;x=b.theme_css;w=b.theme_extension_css;if(u===e){u=this.settings.defaultCssFile}if(p===e){p=u}if(p===this.settings.skipIncludeBootswatch){s=""}if(r.saveToCookie){if(Cookies===e){if(o==="true"){m.error("saveToCookie is set to true but Cookies library is not present")}return false}b.theme_name=p;b.theme_css=u;if(!(b.theme_name.includes("Uno")||b.theme_name=="Bootstrap")){b.theme_author="Bootswatch";b.theme_author_url="https://bootswatch.com/"}else{b.theme_author="J1 Team";b.theme_author_url="https://jekyll.one/"}j1.writeCookie({name:n,data:b});location.reload(true)}else{m.warn("write to cookie : disabled");m.warn("selected theme not activated: "+p)}},loadThemeFromCookie:function(o){if(Cookies===e){m.error("loadThemeFromCookie was called but Cookies library is not present");return false}var p=h.extend({},h.fn.bootstrapThemeSwitcher.defaults,o);g=j1.existsCookie("j1.user.state");if(g){m.info("User state cookie found");b=j1.readCookie(n)}else{m.error("User state NOT cookie found")}var r=b.theme_name;var q=b.theme_css;this.switchTheme(r,q)},addTheme:function(p,o,r,q){if(r===e){r=0}if(q===e){q=0}this.themesList.splice(r,q,{name:p,css:o});this.addThemesToControl()},addThemesToControl:function(){if(this.$element===e){m.error("bootstrapThemeSelector|addThemesToControl: Element is undefined");return false}if(this.themesList===e){m.error("bootstrapThemeSelector|addThemesToControl: Themes is undefined");return false}if(this.settings.excludeBootswatch){var v;if(this.settings.excludeBootswatch.indexOf(",")!==-1){v=this.settings.excludeBootswatch.replace(/ /g,"").split(",")}else{v=[];v.push(this.settings.excludeBootswatch)}var r=this.themesList;h.each(r,function(z,A){if(A&&A.name){if(h.inArray(A.name,v)!==-1){r.splice(z,1)}}});this.themesList=r}var q=this;if(this.$element.is("ul")){var w=h(this);var s=h.extend({},h.fn.bootstrapThemeSwitcher.defaults,w.data("bootstrapThemeSwitcher"));var p=s.cssThemeLink;var t;var o=s.debug;g=j1.existsCookie("j1.user.state");if(g){m.debug("User state cookie found");b=j1.readCookie(n)}else{m.error("User state NOT cookie found")}t=b.theme_name;if(o==="true"){m.debug("bootstrapThemeSelector: UL element selected")}this.$element.empty();var y;var x="#9E9E9E";h.each(this.themesList,function(A,B){if(q.$element[0].id.includes("mmenu")){y="mmenu-item"}else{y="dropdown-item"}if(B.name===t){if(q.$element[0].id.includes("mmenu")){y="mmenu-item active"}else{y="dropdown-item active"}}var z=h("<li />").attr("class",y).append('<a href="#"><i class="mdi mdi-view-quilt mdi-18px mr-2" style="color: '+x+'"></i>'+B.name+"</a>").on("click",function(){if(s.loadFromBootswatch){q.switchTheme(B.name,B.css)}else{q.switchTheme(B.name,B.cssCdn)}h(this).parent().find("li").removeClass("active");h(this).addClass("active")});q.$element.append(z)})}else{if(this.$element.is("select")){m.debug("bootstrapThemeSelector: SELECT element selected");this.$element.empty();var u;h.each(this.themesList,function(z,A){u=null;if(A.name===t){u="selected"}if(s.loadFromBootswatch){q.$element.append("<option "+u+" value='"+A.css+"'>"+A.name+"</option>")}else{q.$element.append("<option "+u+" value='"+A.cssCdn+"'>"+A.name+"</option>")}});this.$element.on("change",function(){var z=h("option:selected",this);q.switchTheme(z.text(),z.val())})}else{m.info("bootstrapThemeSelector: no UL or SELECT element found");m.error("bootstrapThemeSelector: failed")}}},getThemes:function(){var o=this;if(this.settings.localFeed!==null&&this.settings.localFeed!==""){h.ajax({url:this.settings.localFeed,dataType:"json",success:function(p){o.themesList=p.themes;o.addThemesToControl()},error:function(p,r,q){m.error("Failed to retrieve the local feed from: '"+o.settings.localFeed+"'")}})}else{h.ajax({url:this.settings.bootswatchApiUrl+"/"+this.settings.bootswatchApiVersion+".json",dataType:"json",success:function(p){if(p.themes===e){return null}o.themesList=p.themes;o.themesList.splice(0,0,{name:"default",css:o.settings.defaultCssFile});o.addThemesToControl()}})}},themes:function(o){if(o===e){return this.themesList}else{this.themesList=o}}};h.fn.bootstrapThemeSwitcher=function(q){var s;var p=Array.prototype.slice.call(arguments,1);var t=h(this);var r=t.data("bootstrapThemeSwitcher");var o=typeof q==="object"&&q;if(!r){t.data("bootstrapThemeSwitcher",(r=new l(this,o)))}if(typeof q==="string"){s=r[q].apply(r,p)}return(s===e)?t:s};h.fn.bootstrapThemeSwitcher.defaults={debug:false,saveToCookie:true,cssThemeLink:"bootstrapTheme",cookieThemeName:"bootstrapTheme.name",cookieThemeCss:"boostrapTheme.css",cookieExpiration:365,cookiePath:"/",defaultCssFile:"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css",bootswatchApiUrl:"https://bootswatch.com/api/",bootswatchApiVersion:"4",loadFromBootswatch:true,localFeed:"",excludeBootswatch:""};h.fn.bootstrapThemeSwitcher.Constructor=l;h.fn.bootstrapThemeSwitcher.noConflict=function(){h.fn.BootstrapThemeSwitcher=d;return this}})(jQuery,window,document);
45
+
46
+ (function ($, window, document, undefined) {
47
+
48
+ var old = $.fn.bootstrapThemeSwitcher;
49
+
50
+ var cookie_names = j1.getCookieNames();
51
+ const user_state_cookie_name = cookie_names.user_state;
52
+
53
+ var logger = log4javascript.getLogger('j1.core.switcher');
54
+ var logText;
55
+
56
+ var user_state_detected;
57
+ var j1_user_state = {};
58
+ var j1_user_state_json;
59
+ var j1_user_state_cookie;
60
+
61
+ // Constructor
62
+ // ---------------------------------------------------------------------------
63
+ var BootstrapThemeSwitcher = function (element, options) {
64
+
65
+ this.$element = $(element);
66
+ this.settings = $.extend({}, $.fn.bootstrapThemeSwitcher.defaults, options);
67
+ this.themesList = [];
68
+
69
+ // loading local themes
70
+ this.getThemes();
71
+ return this;
72
+ };
73
+
74
+ // Prototype
75
+ // ---------------------------------------------------------------------------
76
+ BootstrapThemeSwitcher.prototype = {
77
+ clear: function () {
78
+ logger.debug('bootstrapThemeSwitcher.clear');
79
+ return this.$element.each(function () {
80
+ this.$element.empty();
81
+ });
82
+ },
83
+ update: function () {
84
+ logger.debug('bootstrapThemeSwitcher.update');
85
+ this.getThemes();
86
+ },
87
+
88
+ // -------------------------------------------------------------------------
89
+ // checkStyleSheetByName
90
+ // -------------------------------------------------------------------------
91
+ checkStyleSheetByName: function (name) {
92
+ var found = false;
93
+ var test = '\/' + name + '\/';
94
+ var re = new RegExp(test, 'i');
95
+
96
+ for(var i = 0; i < document.styleSheets.length; i++){
97
+ if(re.test(document.styleSheets[i].href)){
98
+ found=true;
99
+ break;
100
+ }
101
+ }
102
+ return found;
103
+ },
104
+
105
+ // -------------------------------------------------------------------------
106
+ // switchTheme
107
+ // -------------------------------------------------------------------------
108
+ // NOTE:
109
+ // For J1 template, switchTheme set only the cookies contents. The theme
110
+ // switch is done by a page reload. The reload triggers the theme_generator
111
+ // to load theme CSS from cookies, finally.
112
+ // -------------------------------------------------------------------------
113
+ switchTheme: function (name, cssFile) {
114
+
115
+ var $this = $(this);
116
+ var settings = $.extend({}, $.fn.bootstrapThemeSwitcher.defaults, $this.data('bootstrapThemeSwitcher'));
117
+ var themeName;
118
+ var theme_css;
119
+ var theme_extension_css;
120
+
121
+ var id = settings.cssThemeLink;
122
+ var debug = settings.debug;
123
+ var includeCSS = this.settings.includeBootswatch;
124
+
125
+ // detect|set user state cookie
126
+ user_state_detected = j1.existsCookie ( 'j1.user.state' );
127
+ if ( user_state_detected ) {
128
+ logger.debug('cookie found: j1.user.state');
129
+ j1_user_state = j1.readCookie(user_state_cookie_name);
130
+ } else {
131
+ logger.error('cookie not found: j1.user.state');
132
+ }
133
+
134
+ themeName = j1_user_state.theme_name;
135
+ theme_css = j1_user_state.theme_css;
136
+
137
+ if (typeof cssFile === 'undefined') { cssFile = this.settings.defaultCssFile; }
138
+ if (typeof name === 'undefined') { name = cssFile; }
139
+
140
+ // check if theme is to be saved to cookie
141
+ if (settings.saveToCookie) {
142
+ if ( typeof Cookies === 'undefined' ) {
143
+ if ( debug === 'true' ) {
144
+ logger.error('cookies library not present');
145
+ }
146
+ return false;
147
+ }
148
+
149
+ j1_user_state.theme_name = name;
150
+ j1_user_state.theme_css = cssFile;
151
+
152
+ if (!(j1_user_state.theme_name.includes('Uno') || j1_user_state.theme_name == 'Bootstrap')) {
153
+ j1_user_state.theme_author = 'Bootswatch';
154
+ j1_user_state.theme_author_url = 'https://bootswatch.com/';
155
+ } else {
156
+ j1_user_state.theme_author = 'J1 Team';
157
+ j1_user_state.theme_author_url = 'https://jekyll.one/';
158
+ }
159
+
160
+ j1.writeCookie({
161
+ name: user_state_cookie_name,
162
+ data: j1_user_state
163
+ });
164
+
165
+ // force reload the page from the server (skip cache)
166
+ // and detect selected theme from cookie
167
+ location.reload(true);
168
+ } else {
169
+ logger.warn('write to cookie : disabled');
170
+ logger.warn('selected theme not activated: ' + name);
171
+ } // END if saveToCookie
172
+
173
+ }, // END switchTheme
174
+
175
+ // -------------------------------------------------------------------------
176
+ // loadThemeFromCookie
177
+ // -------------------------------------------------------------------------
178
+ loadThemeFromCookie: function (options) {
179
+
180
+ if ( typeof Cookies === 'undefined' ) {
181
+ logger.error('cookies library not present');
182
+ return false;
183
+ }
184
+
185
+ var settings = $.extend({}, $.fn.bootstrapThemeSwitcher.defaults, options);
186
+
187
+ // detect|set user state cookie
188
+ user_state_detected = j1.existsCookie ( 'j1.user.state' );
189
+
190
+ if ( user_state_detected ) {
191
+ logger.info('cookie found: j1.user.state');
192
+ j1_user_state = j1.readCookie(user_state_cookie_name);
193
+ } else {
194
+ logger.error('cookie not found: j1.user.state');
195
+ }
196
+
197
+ var themeName = j1_user_state.theme_name;
198
+ var themeCss = j1_user_state.theme_css;
199
+ this.switchTheme(themeName, themeCss);
200
+
201
+ }, // END loadThemeFromCookie
202
+
203
+ // -------------------------------------------------------------------------
204
+ // addTheme
205
+ // -------------------------------------------------------------------------
206
+ addTheme: function(name, cssFile, start, deleteCount) {
207
+ if (typeof start === 'undefined') { start = 0; }
208
+ if (typeof deleteCount === 'undefined') { deleteCount = 0; }
209
+ this.themesList.splice(start, deleteCount, {name: name, css: cssFile});
210
+ this.addThemesToControl();
211
+ }, // END addTheme
212
+
213
+ // -------------------------------------------------------------------------
214
+ // addThemesToControl
215
+ // -------------------------------------------------------------------------
216
+ addThemesToControl: function() {
217
+ if (typeof this.$element === 'undefined') {
218
+ logger.error('bootstrapThemeSelector|addThemesToControl: Element is undefined');
219
+ return false;
220
+ }
221
+ if (typeof this.themesList === 'undefined') {
222
+ logger.error('bootstrapThemeSelector|addThemesToControl: Themes is undefined');
223
+ return false;
224
+ }
225
+
226
+ // if BootSwatch excludes are set
227
+ if(this.settings.excludeBootswatch){
228
+ var excludeBootswatchs;
229
+ // split the string on ,
230
+ if(this.settings.excludeBootswatch.indexOf(',') !== -1){
231
+ excludeBootswatchs = this.settings.excludeBootswatch.replace(/ /g, '').split(',');
232
+ } else {
233
+ excludeBootswatchs = [];
234
+ excludeBootswatchs.push(this.settings.excludeBootswatch);
235
+ }
236
+
237
+ var tempThemeList = this.themesList;
238
+ $.each(tempThemeList, function (i, value) {
239
+ if(value && value.name){
240
+ if( $.inArray( value.name, excludeBootswatchs ) !== -1 ){
241
+ tempThemeList.splice(i,1);
242
+ }
243
+ }
244
+ });
245
+ this.themesList = tempThemeList;
246
+ }
247
+
248
+ var base = this;
249
+
250
+ if (this.$element.is('ul')) {
251
+ var $this = $(this);
252
+ var settings = $.extend({}, $.fn.bootstrapThemeSwitcher.defaults, $this.data('bootstrapThemeSwitcher'));
253
+ var id = settings.cssThemeLink;
254
+ var themeName;
255
+ var debug = settings.debug;
256
+
257
+ // detect|set user state cookie
258
+ user_state_detected = j1.existsCookie ( 'j1.user.state' );
259
+ if ( user_state_detected ) {
260
+ logger.debug('User state cookie found');
261
+ j1_user_state = j1.readCookie(user_state_cookie_name);
262
+ } else {
263
+ logger.error('User state NOT cookie found');
264
+ }
265
+
266
+ themeName = j1_user_state.theme_name;
267
+
268
+ if ( debug === 'true' ) {
269
+ logger.debug('bootstrapThemeSelector: UL element selected');
270
+ }
271
+ this.$element.empty();
272
+
273
+ var cssClass;
274
+ var iconColor = '#9E9E9E';
275
+ $.each(this.themesList, function (i, value) {
276
+ // Use DIFFERENT class for MobileMenu
277
+ //if (base.$element[0].id.includes('MMenu')) {
278
+ if (base.$element[0].id.includes('mmenu')) {
279
+ cssClass = 'mmenu-item';
280
+ } else {
281
+ cssClass = 'dropdown-item';
282
+ }
283
+ // Add class "active" to the current theme selected
284
+ if ( value.name === themeName ) {
285
+ // if (base.$element[0].id.includes('MMenu')) {
286
+ if (base.$element[0].id.includes('mmenu')) {
287
+ cssClass = 'mmenu-item active';
288
+ } else {
289
+ cssClass = 'dropdown-item active';
290
+ }
291
+ }
292
+ var li = $('<li />')
293
+ .attr('class',cssClass)
294
+ .append('<a href="#"><i class="mdi mdi-view-quilt mdi-18px mr-2" style="color: ' +iconColor+ '"></i>' +value.name+ '</a>')
295
+ .on('click', function () {
296
+ if (settings.loadFromBootswatch) {
297
+ base.switchTheme(value.name, value.css);
298
+ } else {
299
+ base.switchTheme(value.name, value.cssCdn);
300
+ }
301
+ // remove previous "active" class and apply to latest clicked element
302
+ $(this).parent().find('li').removeClass('active');
303
+ $(this).addClass('active');
304
+ });
305
+ base.$element.append(li);
306
+ });
307
+
308
+ } else if (this.$element.is('select')) {
309
+ logger.debug('bootstrapThemeSelector: SELECT element selected');
310
+ this.$element.empty();
311
+
312
+ var optionSelectedMarker;
313
+ $.each(this.themesList, function (i, value) {
314
+ optionSelectedMarker = null;
315
+ if ( value.name === themeName ) {
316
+ optionSelectedMarker = 'selected';
317
+ }
318
+ if (settings.loadFromBootswatch) {
319
+ base.$element.append('<option ' + optionSelectedMarker + ' value=\'' + value.css + '\'>' + value.name + '</option>');
320
+ } else {
321
+ base.$element.append('<option ' + optionSelectedMarker + ' value=\'' + value.cssCdn + '\'>' + value.name + '</option>');
322
+ }
323
+ });
324
+ this.$element.on('change', function () {
325
+ var optionSelected = $('option:selected', this);
326
+ base.switchTheme(optionSelected.text(), optionSelected.val());
327
+ });
328
+
329
+ } else {
330
+ // no container found to add Theme list
331
+ logger.info('bootstrapThemeSelector: no UL or SELECT element found');
332
+ logger.error('bootstrapThemeSelector: failed');
333
+ // console.warn('bootstrapThemeSelector only works with ul or select elements');
334
+ }
335
+ }, // END addThemesToControl
336
+
337
+ // -------------------------------------------------------------------------
338
+ // getThemes
339
+ // -------------------------------------------------------------------------
340
+ getThemes: function() {
341
+ var base = this;
342
+
343
+ if (this.settings.localFeed !== null && this.settings.localFeed !== '') {
344
+ // Deferred loading themes from local themes (json file)
345
+ $.ajax({
346
+ url: this.settings.localFeed,
347
+ // jadams 2016-10-10: removed the setting for sychronous XMLHttpRequest
348
+ // async: false,
349
+ dataType: 'json',
350
+ success: function (data) {
351
+ base.themesList = data.themes;
352
+ base.addThemesToControl();
353
+ },
354
+ error: function (jqXHR, textStatus, errorThrown) {
355
+ logger.error('Failed to retrieve the local feed from: \'' + base.settings.localFeed + '\'');
356
+ }
357
+ });
358
+ } else {
359
+ // Deferred loading remote themes from Bootswatch API
360
+ // -----------------------------------------------------------------------
361
+ $.ajax({
362
+ url: this.settings.bootswatchApiUrl + '/' + this.settings.bootswatchApiVersion + '.json',
363
+ // jadams 2016-10-10: removed the setting for sychronous XMLHttpRequest
364
+ // async: false,
365
+ dataType: 'json',
366
+ success: function (data) {
367
+ if (typeof data.themes === 'undefined') {
368
+ return null;
369
+ }
370
+ base.themesList = data.themes;
371
+ base.themesList.splice(0,0, {name: 'default', css: base.settings.defaultCssFile});
372
+ base.addThemesToControl();
373
+ }
374
+ });
375
+ }
376
+ }, // END getThemes
377
+
378
+ // -------------------------------------------------------------------------
379
+ // themes
380
+ // -------------------------------------------------------------------------
381
+ themes : function (newThemeList) {
382
+ if (typeof newThemeList === 'undefined') {
383
+ return this.themesList;
384
+ }
385
+ else {
386
+ // TODO: Set the associated control.
387
+ this.themesList = newThemeList;
388
+ }
389
+ } // END themes
390
+
391
+ }; // END prototype
392
+
393
+ // Plugin definition
394
+ // ---------------------------------------------------------------------------
395
+ $.fn.bootstrapThemeSwitcher = function (option) {
396
+ var methodReturn;
397
+ var args = Array.prototype.slice.call(arguments, 1);
398
+ var $this = $(this);
399
+ var data = $this.data('bootstrapThemeSwitcher');
400
+ var options = typeof option === 'object' && option;
401
+
402
+ if (!data) {
403
+ $this.data('bootstrapThemeSwitcher', (data = new BootstrapThemeSwitcher(this, options) ));
404
+ }
405
+ if (typeof option === 'string') {
406
+ methodReturn = data[ option ].apply(data, args);
407
+ }
408
+ return ( typeof methodReturn === 'undefined' ) ? $this : methodReturn;
409
+ };
410
+
411
+ $.fn.bootstrapThemeSwitcher.defaults = {
412
+ debug: false,
413
+ saveToCookie: true,
414
+ cssThemeLink: 'bootstrapTheme',
415
+ cookieThemeName: 'bootstrapTheme.name',
416
+ cookieThemeCss: 'boostrapTheme.css',
417
+ cookieExpiration: 365,
418
+ cookiePath: '/',
419
+ defaultCssFile: 'https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css',
420
+ bootswatchApiUrl: 'https://bootswatch.com/api/',
421
+ bootswatchApiVersion: '4',
422
+ loadFromBootswatch: true,
423
+ localFeed: '',
424
+ excludeBootswatch: ''
425
+ };
426
+
427
+ $.fn.bootstrapThemeSwitcher.Constructor = BootstrapThemeSwitcher;
428
+
429
+ $.fn.bootstrapThemeSwitcher.noConflict = function () {
430
+ $.fn.BootstrapThemeSwitcher = old;
431
+ return this;
432
+ };
433
+
434
+ })(jQuery, window, document);