j1-template 2024.3.13 → 2024.3.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/themes/j1/layouts/content_generator_news_panel_posts.html +1 -1
  3. data/_includes/themes/j1/layouts/layout_resource_generator.html +1 -4
  4. data/_includes/themes/j1/procedures/blocks/footer/boxes/social_media_icons.proc +24 -23
  5. data/_includes/themes/j1/procedures/layouts/content_writer.proc +4 -3
  6. data/_includes/themes/j1/procedures/layouts/default_writer.proc +37 -6
  7. data/_includes/themes/j1/procedures/layouts/module_writer.proc +31 -95
  8. data/_includes/themes/j1/procedures/layouts/resource_writer.proc +51 -29
  9. data/assets/data/amplitude.28.html +887 -0
  10. data/assets/data/amplitude.29.html +923 -0
  11. data/assets/data/amplitude.html +311 -46
  12. data/assets/data/banner.html +9 -7
  13. data/assets/data/masterslider.html +128 -7
  14. data/assets/data/panel.html +16 -65
  15. data/assets/theme/j1/adapter/js/amplitude.23.js +1165 -0
  16. data/assets/theme/j1/adapter/js/amplitude.24.js +1164 -0
  17. data/assets/theme/j1/adapter/js/amplitude.25.js +1268 -0
  18. data/assets/theme/j1/adapter/js/amplitude.js +294 -117
  19. data/assets/theme/j1/adapter/js/attic.js +14 -11
  20. data/assets/theme/j1/adapter/js/docsearch.js +2 -2
  21. data/assets/theme/j1/adapter/js/fab.js +2 -2
  22. data/assets/theme/j1/adapter/js/j1.js +8 -8
  23. data/assets/theme/j1/adapter/js/lazyLoader.js +60 -10
  24. data/assets/theme/j1/adapter/js/masonry.js +1 -1
  25. data/assets/theme/j1/adapter/js/masterslider.js +2 -2
  26. data/assets/theme/j1/adapter/js/particles.js +2 -2
  27. data/assets/theme/j1/adapter/js/scroller.js +2 -2
  28. data/assets/theme/j1/adapter/js/slick.js +2 -2
  29. data/assets/theme/j1/adapter/js/themes.js +1 -1
  30. data/assets/theme/j1/adapter/js/translator.js +2 -2
  31. data/assets/theme/j1/adapter/js/waves.js +1 -1
  32. data/assets/theme/j1/core/css/animate.css +1634 -1070
  33. data/assets/theme/j1/core/css/animate.css.map +1 -0
  34. data/assets/theme/j1/core/css/animate.min.css +2 -1
  35. data/assets/theme/j1/core/css/animate.min.css.map +1 -0
  36. data/assets/theme/j1/core/css/icon-fonts/fontawesome.css +3060 -1538
  37. data/assets/theme/j1/core/css/icon-fonts/fontawesome.css.map +1 -0
  38. data/assets/theme/j1/core/css/icon-fonts/fontawesome.min.css +2 -1
  39. data/assets/theme/j1/core/css/icon-fonts/fontawesome.min.css.map +1 -0
  40. data/assets/theme/j1/core/css/icon-fonts/iconify.css +2308 -1153
  41. data/assets/theme/j1/core/css/icon-fonts/iconify.css.map +1 -0
  42. data/assets/theme/j1/core/css/icon-fonts/iconify.min.css +2 -1
  43. data/assets/theme/j1/core/css/icon-fonts/iconify.min.css.map +1 -0
  44. data/assets/theme/j1/core/css/icon-fonts/mdi.css +16716 -8423
  45. data/assets/theme/j1/core/css/icon-fonts/mdi.css.map +1 -0
  46. data/assets/theme/j1/core/css/icon-fonts/mdi.min.css +2 -1
  47. data/assets/theme/j1/core/css/icon-fonts/mdi.min.css.map +1 -0
  48. data/assets/theme/j1/core/css/icon-fonts/mdib.css +5554 -2766
  49. data/assets/theme/j1/core/css/icon-fonts/mdib.css.map +1 -0
  50. data/assets/theme/j1/core/css/icon-fonts/mdib.min.css +2 -1
  51. data/assets/theme/j1/core/css/icon-fonts/mdib.min.css.map +1 -0
  52. data/assets/theme/j1/core/css/icon-fonts/mdil.css +742 -441
  53. data/assets/theme/j1/core/css/icon-fonts/mdil.css.map +1 -0
  54. data/assets/theme/j1/core/css/icon-fonts/mdil.min.css +2 -1
  55. data/assets/theme/j1/core/css/icon-fonts/mdil.min.css.map +1 -0
  56. data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.css +6552 -3980
  57. data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.css.map +1 -0
  58. data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.min.css +2 -5
  59. data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.min.css.map +1 -0
  60. data/assets/theme/j1/core/css/themes/unodark/bootstrap.css +6818 -4131
  61. data/assets/theme/j1/core/css/themes/unodark/bootstrap.css.map +1 -0
  62. data/assets/theme/j1/core/css/themes/unodark/bootstrap.min.css +2 -5
  63. data/assets/theme/j1/core/css/themes/unodark/bootstrap.min.css.map +1 -0
  64. data/assets/theme/j1/core/css/themes/unolight/bootstrap.css +18568 -11577
  65. data/assets/theme/j1/core/css/themes/unolight/bootstrap.css.map +1 -0
  66. data/assets/theme/j1/core/css/themes/unolight/bootstrap.min.css +2 -35
  67. data/assets/theme/j1/core/css/themes/unolight/bootstrap.min.css.map +1 -0
  68. data/assets/theme/j1/core/css/vendor.css +1771 -1043
  69. data/assets/theme/j1/core/css/vendor.css.map +1 -0
  70. data/assets/theme/j1/core/css/vendor.min.css +2 -1
  71. data/assets/theme/j1/core/css/vendor.min.css.map +1 -0
  72. data/assets/theme/j1/core/js/template.js +399 -447
  73. data/assets/theme/j1/core/js/template.min.js +7 -7
  74. data/assets/theme/j1/core/js/template.min.js.map +1 -1
  75. data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/amplitude.css +4 -2
  76. data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/compact.css +39 -4
  77. data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/compact.min.css +1 -1
  78. data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/large.css +57 -17
  79. data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/large.min.css +1 -1
  80. data/assets/theme/j1/modules/amplitudejs/icons/player/blue/pause.png +0 -0
  81. data/assets/theme/j1/modules/amplitudejs/icons/player/blue/play.png +0 -0
  82. data/assets/theme/j1/modules/amplitudejs/icons/player/blue/play.svg +87 -0
  83. data/assets/theme/j1/modules/amplitudejs/icons/player/dark/skip-backward.svg +60 -0
  84. data/assets/theme/j1/modules/amplitudejs/icons/player/dark/skip-forward.svg +59 -0
  85. data/assets/theme/j1/modules/amplitudejs/js/amplitude.js +65 -21
  86. data/assets/theme/j1/modules/amplitudejs/js/amplitude.min.js +1 -1
  87. data/assets/theme/j1/modules/amplitudejs/js/tech/ytp.js +113 -0
  88. data/assets/theme/j1/modules/iconPicker/js/universal-icon-picker.js +471 -471
  89. data/assets/theme/j1/modules/j1LazyLoader/LICENSE +21 -0
  90. data/assets/theme/j1/modules/j1LazyLoader/js/j1Lazy.js +870 -0
  91. data/assets/theme/j1/modules/js-cookies/js/js.cookie.js +3 -3
  92. data/assets/theme/j1/modules/lazyCssLoader/js/main.0.js +166 -0
  93. data/assets/theme/j1/modules/lazyCssLoader/js/main.1.js +65 -0
  94. data/assets/theme/j1/modules/lazyCssLoader/js/main.js +66 -0
  95. data/assets/theme/j1/modules/lazyCssLoader/js/plugins/examplePlugin.js +13 -0
  96. data/assets/theme/j1/modules/lazyCssLoader/js/plugins/my-plugin.js +25 -0
  97. data/assets/theme/j1/modules/lazyCssLoader/js/plugins/plugin-interface.js +9 -0
  98. data/assets/theme/j1/modules/lazyCssLoader/js/plugins/pluginA.js +46 -0
  99. data/assets/theme/j1/modules/lazyLoader/js/plugins/README.md +324 -0
  100. data/assets/theme/j1/modules/lazyLoader/js/plugins/jquery.lazy.picture.js +188 -0
  101. data/assets/theme/j1/modules/lightGallery/js/lightgallery.js +1 -1
  102. data/assets/theme/j1/modules/lightGallery/js/plugins/lg-video.0.js +794 -0
  103. data/assets/theme/j1/modules/lightGallery/js/plugins/lg-video.js +151 -67
  104. data/assets/theme/j1/modules/slimSelect/js/select.js +1 -1
  105. data/assets/theme/j1/modules/slimSelect/js/select.min.js +3 -3
  106. data/assets/theme/j1/modules/themeSwitcher/js/switcher.js +2 -1
  107. data/assets/theme/j1/modules/videojs/js/plugins/players/dm/dailymotion.min.js +1 -1
  108. data/assets/theme/j1/modules/videojs/js/plugins/players/dm/icon/scalable/dailymotion.svg +62 -0
  109. data/assets/theme/j1/modules/videojs/js/plugins/players/yt/v3.0.0/youtube.js +832 -0
  110. data/assets/theme/j1/modules/videojs/js/plugins/players/yt/v3.0.0/youtube.min.js +17 -0
  111. data/assets/theme/j1/modules/videojs/js/plugins/players/yt/youtube.min.js +1 -1
  112. data/assets/theme/j1/modules/videojs/js/video.js +2 -2
  113. data/lib/j1/version.rb +1 -1
  114. data/lib/starter_web/README.md +577 -560
  115. data/lib/starter_web/_config.yml +2 -2
  116. data/lib/starter_web/_data/blocks/footer.yml +10 -5
  117. data/lib/starter_web/_data/blocks/panel.yml +2 -2
  118. data/lib/starter_web/_data/layouts/default.yml +14 -3
  119. data/lib/starter_web/_data/modules/amplitude.yml +145 -0
  120. data/lib/starter_web/_data/modules/defaults/amplitude.yml +29 -7
  121. data/lib/starter_web/_data/modules/defaults/lazyLoader.yml +2 -2
  122. data/lib/starter_web/_data/modules/gallery.yml +136 -0
  123. data/lib/starter_web/_data/modules/lazyLoader.0.yml +118 -0
  124. data/lib/starter_web/_data/modules/lazyLoader.yml +68 -31
  125. data/lib/starter_web/_data/modules/masonry.yml +4 -4
  126. data/lib/starter_web/_data/modules/masterslider.yml +118 -12
  127. data/lib/starter_web/_data/modules/navigator_menu.yml +831 -803
  128. data/lib/starter_web/_data/resources.yml +154 -190
  129. data/lib/starter_web/_data/templates/feed.xml +1 -1
  130. data/lib/starter_web/_includes/attributes.asciidoc +1 -0
  131. data/lib/starter_web/_plugins/asciidoctor/amplitude-block.rb +1 -1
  132. data/lib/starter_web/_plugins/asciidoctor/dailymotion-block.rb +1 -1
  133. data/lib/starter_web/_plugins/asciidoctor/gallery-block.rb +4 -2
  134. data/lib/starter_web/_plugins/asciidoctor/masonry-block.rb +1 -1
  135. data/lib/starter_web/_plugins/asciidoctor/videojs-block.rb +58 -46
  136. data/lib/starter_web/_plugins/asciidoctor/vimeo-block.rb +26 -19
  137. data/lib/starter_web/_plugins/asciidoctor/youtube-block.rb +30 -40
  138. data/lib/starter_web/_plugins/index/lunr.rb +1 -1
  139. data/lib/starter_web/assets/image/icons/lanus/favicon.ico +0 -0
  140. data/lib/starter_web/assets/image/icons/lanus/lanus-512x512.png +0 -0
  141. data/lib/starter_web/assets/image/icons/lanus/lanus.ico +0 -0
  142. data/lib/starter_web/assets/image/icons/lanus/lanus.png +0 -0
  143. data/lib/starter_web/assets/image/icons/lanus/scalable/lanus.svg +76 -0
  144. data/lib/starter_web/assets/image/icons/lanus/scalable/lanus_sw.svg +62 -0
  145. data/lib/starter_web/assets/image/modules/icons/social/scalable/icon-twitter-x-28 - social.svg +86 -0
  146. data/lib/starter_web/assets/image/modules/icons/social/scalable/icon-twitter-x-28.svg +64 -0
  147. data/lib/starter_web/assets/image/modules/icons/social/scalable/icon-twitter-x.svg +1 -0
  148. data/lib/starter_web/assets/image/modules/icons/social/twitter_x.png +0 -0
  149. data/lib/starter_web/package.json +7 -18
  150. data/lib/starter_web/pages/public/amplitude_yt_tester.adoc +218 -0
  151. data/lib/starter_web/pages/public/features/template.adoc +18 -8
  152. data/lib/starter_web/pages/public/features/template.asciidoc +758 -0
  153. data/lib/starter_web/pages/public/lazy_loader_tester.adoc +402 -0
  154. data/lib/starter_web/pages/public/manuals/ytdl/man.adoc +3020 -0
  155. data/lib/starter_web/pages/public/manuals/ytdl/man.md +2378 -0
  156. data/lib/starter_web/pages/public/tools/previewer/_includes/attributes.asciidoc +0 -16
  157. data/lib/starter_web/pages/public/tools/previewer/_includes/documents/amplitudejs.large.css.asciidoc +505 -0
  158. data/lib/starter_web/pages/public/tools/previewer/_includes/documents/frame.hover.html +69 -0
  159. data/lib/starter_web/pages/public/tools/previewer/_includes/documents/frame.nested.html +75 -0
  160. data/lib/starter_web/pages/public/tools/previewer/_includes/documents/frame.textarea.html +57 -0
  161. data/lib/starter_web/pages/public/tools/previewer/_includes/documents/my.content.html +112 -0
  162. data/lib/starter_web/pages/public/tools/previewer/preview_amplitudejs.adoc +172 -0
  163. data/lib/starter_web/pages/public/tour/_includes/attributes.asciidoc +2 -2
  164. data/lib/starter_web/pages/public/tour/_includes/documents/419_advanced_modals_demo.asciidoc +16 -16
  165. data/lib/starter_web/pages/public/tour/asciidoc_extensions.adoc +13 -3
  166. data/lib/starter_web/pages/public/tour/bootstrap_themes.adoc +12 -3
  167. data/lib/starter_web/pages/public/tour/highlghter_rouge.adoc +13 -3
  168. data/lib/starter_web/pages/public/tour/icon_fonts.adoc +12 -3
  169. data/lib/starter_web/pages/public/tour/modal_extentions.adoc +12 -6
  170. data/lib/starter_web/pages/public/tour/{playback_audio.adoc → play_audio.adoc} +207 -188
  171. data/lib/starter_web/pages/public/tour/{playback_video.adoc → play_video.adoc} +49 -51
  172. data/lib/starter_web/pages/public/tour/present_images.adoc +27 -5
  173. data/lib/starter_web/pages/public/tour/quicksearch.adoc +13 -3
  174. data/lib/starter_web/pages/public/tour/responsive_tables.adoc +13 -4
  175. data/lib/starter_web/pages/public/tour/typography.adoc +12 -3
  176. metadata +90 -22
  177. /data/assets/theme/j1/modules/{lazyLoader → j1LazyLoader/js}/plugins/README.md +0 -0
  178. /data/assets/theme/j1/modules/{lazyLoader/plugins/jquery.lazy.picture.js → j1LazyLoader/js/plugins/picture.js} +0 -0
  179. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.ajax.js +0 -0
  180. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.ajax.min.js +0 -0
  181. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.av.js +0 -0
  182. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.av.min.js +0 -0
  183. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.iframe.js +0 -0
  184. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.iframe.min.js +0 -0
  185. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.noop.js +0 -0
  186. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.noop.min.js +0 -0
  187. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.picture.min.js +0 -0
  188. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.script.js +0 -0
  189. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.script.min.js +0 -0
  190. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.vimeo.js +0 -0
  191. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.vimeo.min.js +0 -0
  192. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.youtube.js +0 -0
  193. /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.youtube.min.js +0 -0
@@ -18,476 +18,476 @@ const iconPickerUrl = document.currentScript.src.replace(/js\/([a-z\.-]+)$/gm, '
18
18
  const loadedDependencies = [];
19
19
 
20
20
  (function (root, factory) {
21
- if (typeof define === 'function' && define.amd) {
22
- define([], factory('UniversalIconPicker'));
23
- } else if (typeof exports === 'object') {
24
- module.exports = factory('UniversalIconPicker');
25
- } else {
26
- root['UniversalIconPicker'] = factory('UniversalIconPicker');
27
- }
21
+ if (typeof define === 'function' && define.amd) {
22
+ define([], factory('UniversalIconPicker'));
23
+ } else if (typeof exports === 'object') {
24
+ module.exports = factory('UniversalIconPicker');
25
+ } else {
26
+ root['UniversalIconPicker'] = factory('UniversalIconPicker');
27
+ }
28
28
  }(this, function () {
29
- 'use strict';
30
-
31
- const createDomEle = function (string) {
32
- const ele = document.createElement('div');
33
- ele.innerHTML = string;
34
- return ele.firstChild;
35
- }
36
-
37
- const debounce = function (func, wait, immediate) {
38
- let timeout;
39
- return function () {
40
- const context = this,
41
- args = arguments;
42
- const later = function () {
43
- timeout = null;
44
- if (!immediate) func.apply(context, args);
45
- };
46
- const callNow = immediate && !timeout;
47
- clearTimeout(timeout);
48
- timeout = setTimeout(later, wait);
49
- if (callNow) func.apply(context, args);
50
- };
51
- };
52
-
53
- const escapeHtml = function (text) {
54
- const map = {
55
- '&': '&',
56
- '<': '&lt;',
57
- '>': '&gt;',
58
- '"': '&quot;',
59
- "'": '&#039;'
60
- };
61
-
62
- return text.replace(/[&<>"']/g, function (m) { return map[m]; });
63
- };
64
-
65
- /**
66
- * Merge defaults with user options
67
- * @param {Object} defaults Default settings
68
- * @param {Object} options User options
69
- */
70
- const extend = function (defaults, options) {
71
- let prop, extended = {};
72
- for (prop in defaults) {
73
- if (Object.prototype.hasOwnProperty.call(defaults, prop)) {
74
- extended[prop] = defaults[prop];
75
- }
76
- }
77
- for (prop in options) {
78
- if (Object.prototype.hasOwnProperty.call(options, prop)) {
79
- extended[prop] = options[prop];
80
- }
81
- }
82
-
83
- return extended;
84
- };
85
-
86
- const getLibraryName = function (string) {
87
- return string.replace(/([A-Z])/g, ' $1');
88
- }
89
-
90
- /**
91
- * Plugin Object
92
- * @param selector The html selector to initialize
93
- * @param {Object} options User options
94
- * @constructor
95
- */
96
- function UniversalIconPicker (selector, options) {
97
- this.selector = selector;
98
-
99
- let defaults = {
100
- allowEmpty: true,
101
- iconLibraries: null,
102
- iconLibrariesCss: null,
103
- mode: 'autoload', // autoload | onrequest
104
- onBeforeOpen: null,
105
- onReset: null,
106
- onSelect: null,
107
- resetSelector: null,
108
- loadCustomCss: false
109
- };
110
- this.options = extend(defaults, options);
111
-
112
- this.activeLibraryId = '';
113
- this.filterIcon = '';
114
- this.iconEventsLoaded = false;
115
- this.iconLibraries = {};
116
- this.iconLibrariesLoaded = false;
117
- this.iconMarkup = '';
118
- this.iconWrap = '';
119
- this.idSuffix = '-' + this.selector.replace(/[#\s[\]="]/g, '');
120
- this.sideBarBtn = '';
121
- this.sideBarList = [];
122
-
123
- this.universalWrap = '<div class="uip-modal uip-open" id="uip-modal' + this.idSuffix + '"><div class="uip-modal--content"><div class="uip-modal--header"><div class="uip-modal--header-logo-area"><span class="uip-modal--header-logo-title">Icon Picker</span></div><div class="uip-modal--header-close-btn"><img src="' + iconPickerUrl + '/images/xmark-solid.svg" width="40" height="40" alt="Close" title="Close"></div></div><div class="uip-modal--body"><div id="uip-modal--sidebar' + this.idSuffix + '" class="uip-modal--sidebar"><div class="uip-modal--sidebar-tabs"></div></div><div id="uip-modal--icon-preview-wrap' + this.idSuffix + '" class="uip-modal--icon-preview-wrap"><div class="uip-modal--icon-search"><input name="" value="" placeholder="Filter by name..."><img src="' + iconPickerUrl + '/images/magnifying-glass-solid.svg" width="20" height="16" alt="Search" title="Search"></div><div class="uip-modal--icon-preview-inner"><div id="uip-modal--icon-preview' + this.idSuffix + '" class="uip-modal--icon-preview"></div></div></div></div><div class="uip-modal--footer"><button class="uip-insert-icon-button mt-3 mb-3 mr-6">Copy to clipboard</button></div></div></div>';
124
-
125
- this.universalDomEle = createDomEle(this.universalWrap);
126
- this.sidebarTabs = this.universalDomEle.querySelector('.uip-modal--sidebar-tabs');
127
- this.previewWrap = this.universalDomEle.querySelector('#uip-modal--icon-preview' + this.idSuffix);
128
- this.searchInput = this.universalDomEle.querySelector('.uip-modal--icon-search input');
129
- if (this.options.mode === 'autoload') {
130
- this.init();
131
- } else {
132
- document.querySelector(this.selector).addEventListener('click', this.init.bind(this), { once: true });
133
- }
134
- }
135
-
136
-
137
- // Plugin prototype
138
- UniversalIconPicker.prototype = {
139
-
140
- /* Public functions
141
- ------------------------------------------------------------------------ */
142
-
143
- init: function () {
144
- this._loadCssFiles();
145
- if (this.options.mode !== 'autoload') {
146
- this._onBeforeOpen().then(() => {
147
- this.open();
148
- });
149
- }
150
- document.querySelector(this.selector).addEventListener('click', () => {
151
- this._onBeforeOpen().then(() => {
152
- this.open();
153
- });
154
- });
155
-
156
- //Remove selected icon
157
- if (this.options.resetSelector) {
158
- document.querySelector(this.options.resetSelector).addEventListener('click', this.options.onReset);
159
- }
160
- },
161
-
162
- open: function () {
163
- this._loadIconLibraries().then(() => {
164
- this.iconLibrariesLoaded = true;
165
- if (!document.getElementById('uip-modal' + this.idSuffix)) {
166
- // push universal dom to body
167
- document.body.appendChild(this.universalDomEle);
168
-
169
- // jadams, 2023-05-21: disable page scrolling if modal is OPEN
170
- document.body.classList.add('stop-scrolling');
171
-
172
- // Icon library close by clicking close button
173
- this.universalDomEle.querySelector('.uip-modal--header-close-btn').addEventListener('click', () => {
174
- this.universalDomEle.classList.add('uip-close');
175
- this.universalDomEle.classList.remove('uip-open');
176
- // jadams, 2023-05-21: (re-)enable page scrolling if modal is CLOSED
177
- document.body.classList.remove('stop-scrolling');
178
- });
179
-
180
- // Insert button
181
- this.universalDomEle.querySelector('.uip-insert-icon-button').addEventListener('click', () => {
182
- let selected = this.universalDomEle.querySelector('.universal-selected');
183
-
184
- if (selected) {
185
- let iconHtml = selected.querySelector('i').outerHTML;
186
- let jsonOutput = {
187
- 'libraryId': selected.dataset.libraryId,
188
- 'libraryName': selected.dataset.libraryName,
189
- 'iconHtml': null,
190
- 'iconMarkup': null,
191
- 'iconClass': null,
192
- 'iconText': null
193
- };
194
- if (!selected.querySelector('i').classList.value.match('uip-icon-none')) {
195
- jsonOutput.iconHtml = iconHtml;
196
- jsonOutput.iconMarkup = escapeHtml(iconHtml);
197
- jsonOutput.iconClass = selected.querySelector('i').classList.value;
198
- jsonOutput.iconText = selected.querySelector('i').innerText;
199
- }
200
-
201
- this.options.onSelect(jsonOutput);
202
- }
203
- // jadams, 2023-05-21: disable modal CLOSE on a select
204
- // this.universalDomEle.classList.add('uip-close');
205
- // this.universalDomEle.classList.remove('uip-open');
206
- });
207
- } else {
208
- // Icon library open if dom element exist
209
- this.universalDomEle.classList.remove('uip-close');
210
- this.universalDomEle.classList.add('uip-open');
211
- // jadams, 2023-05-21: disable page scrolling if modal is OPEN
212
- document.body.classList.add('stop-scrolling');
213
- }
214
-
215
- if (!this.iconEventsLoaded) {
216
- // selected icon highlighted by adding class
217
- this.universalDomEle.querySelectorAll('.uip-icon-item').forEach((item) => {
218
- item.addEventListener('click', (evt) => {
219
- this.iconWrap.forEach((el) => {
220
- el.classList.remove('universal-selected');
221
- });
222
- evt.currentTarget.classList.toggle('universal-selected');
223
- });
224
- item.addEventListener('dblclick', (evt) => {
225
- this.universalDomEle.querySelector('.uip-insert-icon-button').click();
226
- });
227
- });
228
- this.iconEventsLoaded = true;
229
- }
230
-
231
- this.universalDomEle.querySelector('.uip-modal--icon-search input').focus();
232
- });
233
- },
234
-
235
- setOptions: function (opts) {
236
- this.options = extend(this.options, opts);
237
- if (opts.iconLibrariesCss) {
238
- this._loadCssFiles();
239
- }
240
- if (opts.iconLibraries) {
241
- // dom icon events need to be reloaded
242
- this.iconEventsLoaded = false;
243
- this.iconLibrariesLoaded = false;
244
- this._resetIconAndSidebarList();
245
- }
246
- },
247
-
248
- /* Private functions
249
- ------------------------------------------------------------------------ */
250
-
251
- _clickHandlerFunc: function (e) {
252
- if (!e.currentTarget.classList.contains('universal-active')) {
253
- this.sideBarBtn.forEach(function (item) {
254
- item.classList.remove('universal-active');
255
- });
256
- e.currentTarget.classList.add('universal-active')
257
- }
258
- this._sidebarFilterFunc(e.currentTarget.dataset['libraryId']);
259
- },
260
-
261
- _iconItemMarkup: function (libraryName, libraryItem) {
262
- let markup = '',
263
- library = libraryItem['icon-style'],
264
- prefix = libraryItem['prefix'];
265
-
266
- if (this.options.allowEmpty) {
267
- markup += '<div class="uip-icon-item" data-library-id="' + library + '" data-filter="" data-library-name="' + libraryName + '"><div class="uip-icon-item-inner"><i class="' + prefix + ' uip-icon-none">&nbsp;</i><div class="uip-icon-item-name" title="None">None</div></div></div>';
268
- }
269
- if (prefix.match(/^material-icons/)) {
270
- libraryItem['icons'].forEach(function (item) {
271
- markup += '<div class="uip-icon-item" data-library-id="' + library + '" data-filter="' + item + '" data-library-name="' + libraryName + '"><div class="uip-icon-item-inner"><i class="' + prefix + '">' + item + '</i><div class="uip-icon-item-name" title="' + item + '">' + item.replace("-", " ") + '</div></div></div>';
272
- });
273
- } else {
274
- libraryItem['icons'].forEach(function (item) {
275
- markup += '<div class="uip-icon-item" data-library-id="' + library + '" data-filter="' + item + '" data-library-name="' + libraryName + '"><div class="uip-icon-item-inner"><i class="' + [prefix, item].join('') + '"></i><div class="uip-icon-item-name" title="' + item + '">' + item.replace("-", " ") + '</div></div></div>';
276
- });
277
- }
278
-
279
- return markup;
280
- },
281
-
282
- _iconItemPush: function (arrayList) {
283
- this.previewWrap.innerHTML = '';
284
- arrayList.forEach((item) => {
285
- this.previewWrap.appendChild(item[1]);
286
- });
287
- },
288
-
289
- _loadCssFiles: function () {
290
- let link = document.createElement('link');
291
- if (!loadedDependencies.includes('universal-icon-picker.min.css') & !this.options.loadCustomCss) {
292
- link.rel = 'stylesheet';
293
- link.type = 'text/css';
294
- link.href = iconPickerUrl + 'css/universal-icon-picker.min.css';
295
- link.media = 'screen';
296
- document.head.appendChild(link);
297
- loadedDependencies.push('universal-icon-picker.min.css');
298
- }
299
- if (this.options.iconLibrariesCss) {
300
- this.options.iconLibrariesCss.forEach(cssFile => {
301
- if (!loadedDependencies.includes(cssFile)) {
302
- let cssFileLink = iconPickerUrl + 'css/' + cssFile;
303
- if (cssFile.match(/^http|^\/\//)) {
304
- cssFileLink = cssFile;
305
- link = document.createElement('link');
306
- link.rel = 'stylesheet';
307
- link.type = 'text/css';
308
- link.href = cssFileLink;
309
- link.media = 'screen';
310
- document.head.appendChild(link);
311
- loadedDependencies.push(cssFile);
312
- }
313
- }
314
- });
315
- }
316
- },
317
-
318
- _loadIconLibraries: async function (i = 0) {
319
- if (!this.options.iconLibraries) {
320
- console.error('Universal icon picker - no icon library loaded');
321
- return false;
322
- }
323
- if (this.iconLibrariesLoaded) {
324
- return true;
325
- }
326
- if (i === 0 && this.options.iconLibraries.length > 1) {
327
- this.sideBarList.push({
328
- "title": "all icons",
329
- "list-icon": "",
330
- "library-id": "all",
331
- "prefix": ""
332
- });
333
- }
334
-
335
- let iconLib = this.options.iconLibraries[i];
336
-
337
- await fetch(iconPickerUrl + 'icons-libraries/' + iconLib)
338
- .then(response => response.json())
339
- .then(data => {
340
- // Success!
341
- const camelCasedIconLibrary = iconLib.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); }).replace(/\.[a-z.]+$/, '');
342
- let newLibrary = {};
343
- newLibrary[camelCasedIconLibrary] = data;
344
- Object.assign(this.iconLibraries, newLibrary); // new icon library merge
345
- if (i + 1 === this.options.iconLibraries.length) {
346
- //set icon and sidebar list
347
- this._setIconAndSidebarList();
348
-
349
- this.activeLibraryId = this.sideBarList[0]['library-id'];
350
-
351
- //sidebar list markup push
352
- this.sidebarTabs.innerHTML = this._sideBarListMarkup(this.sideBarList);
353
-
354
- //icon markup push
355
- this.previewWrap.innerHTML = this.iconMarkup;
356
-
357
- // get all icon wrapper dom element
358
- this.iconWrap = this.previewWrap.querySelectorAll('.uip-icon-item');
359
-
360
- //set event lisner to search input
361
- this.searchInput.addEventListener('keyup', debounce(this._searchFunc, 100).bind(this), false);
362
-
363
- //get all sidebar list item wrapper dom element
364
- this.sideBarBtn = this.sidebarTabs.querySelectorAll('.uip-modal--sidebar-tab-item');
365
-
366
- //set click event lisner to sidebar list item
367
- this.sideBarBtn.forEach((item) => {
368
- item.addEventListener('click', this._clickHandlerFunc.bind(this), false);
369
- });
370
-
371
- return true;
372
- } else {
373
- return this._loadIconLibraries(i + 1);
374
- }
375
- }).catch((error) => {
376
- console.log(error);
377
- return error;
378
- });
379
- },
380
-
381
- _onBeforeOpen: async function () {
382
- if (typeof (this.options.onBeforeOpen) === 'function') {
383
- return this.options.onBeforeOpen();
384
- }
385
- },
386
-
387
- _resetIconAndSidebarList: function () {
388
- this.sideBarList = [];
389
- this.iconMarkup = '';
390
- this.iconLibraries = {};
391
- this.iconWrap = '';
392
- this.filterIcon = '';
393
- this.sideBarBtn = '';
394
- this.activeLibraryId = '';
395
- },
396
-
397
- _searchFunc: function (e) {
398
- // console.log(this.value.toLowerCase());
399
-
400
- const searchText = e.target.value.toLowerCase();
401
- this._searchFilterFunc(searchText, 'filter');
402
-
403
- },
404
-
405
- _searchFilterFunc: function (filterText, dataName) {
406
- this.filterIcon = Object.entries(this.iconWrap).filter((item) => {
407
- if (-1 == item[1].dataset[dataName].indexOf(filterText) || (this.activeLibraryId !== 'all' && item[1].dataset['libraryId'] !== this.activeLibraryId)) {
408
- return false;
409
- }
410
- return true;
411
- });
412
-
413
- this._iconItemPush(this.filterIcon);
414
-
415
- },
416
-
417
- _setIconAndSidebarList: function () {
418
- for (const [libraryName, libraryContent] of Object.entries(this.iconLibraries)) {
419
- this._setSideBarList(getLibraryName(libraryName), libraryContent);
420
- this._setIconMarkup(libraryName, libraryContent);
421
- }
422
- },
423
-
424
- _setIconMarkup: function (libraryName, libraryContent) {
425
- if (libraryContent.icons !== undefined) {
426
- this.iconMarkup += this._iconItemMarkup(libraryName, libraryContent)
427
- } else {
428
- Object.entries(libraryContent).forEach((item) => {
429
- this.iconMarkup += this._iconItemMarkup(libraryName, item[1])
430
- });
431
- }
432
- },
433
-
434
- _sidebarFilterFunc: function (filterText) {
435
- this.activeLibraryId = filterText;
436
- this.filterIcon = Object.entries(this.iconWrap).filter(function (item) {
437
- if ('all' === filterText || filterText === item[1].dataset['libraryId']) {
438
- return true;
439
- }
440
- return false;
441
- });
442
-
443
- this._iconItemPush(this.filterIcon);
444
-
445
- },
446
-
447
- _setSideBarList: function (libraryName, libraryContent) {
448
- let listItem;
449
- if (libraryContent.icons !== undefined) {
450
- listItem = {
451
- 'title': libraryName,
452
- 'prefix': libraryContent['prefix'] !== undefined ? libraryContent['prefix'] : '',
453
- 'list-icon': libraryContent['list-icon'] !== undefined ? libraryContent['list-icon'] : '',
454
- 'library-id': libraryContent['icon-style'] !== undefined ? libraryContent['icon-style'] : 'all',
455
- };
456
- this.sideBarList.push(listItem);
457
- } else {
458
- Object.entries(libraryContent).forEach(item => {
459
- listItem = {
460
- "title": libraryName + ' - ' + item[0],
461
- "prefix": item[1]['prefix'] !== undefined ? item[1]['prefix'] : '',
462
- "list-icon": item[1]['list-icon'] !== undefined ? item[1]['list-icon'] : "",
463
- "library-id": item[1]['icon-style'] !== undefined ? item[1]['icon-style'] : "all",
464
- };
465
- this.sideBarList.push(listItem)
466
- });
467
- }
468
- },
469
-
470
- _sideBarListMarkup: function (sideBarList) {
471
- let markup = '';
472
- sideBarList.forEach((item) => {
473
- let activeClazz = '';
474
- if (item['library-id'] === this.activeLibraryId) {
475
- activeClazz = ' universal-active';
476
- }
477
- if ('all' !== item['library-id']) {
478
- let iconTag = '<i class="' + item['list-icon'] + '"></i>';
479
- if (item['prefix'].match(/^material-icons/)) {
480
- iconTag = '<i class="' + item['prefix'] + '">' + item['list-icon'] + '</i>';
481
- }
482
- markup += '<div class="uip-modal--sidebar-tab-item' + activeClazz + '" data-library-id="' + item['library-id'] + '">' + iconTag + item['title'] + '</div>';
483
- } else {
484
- markup += '<div class="uip-modal--sidebar-tab-item' + activeClazz + '" data-library-id="' + item['library-id'] + '"><img src="' + iconPickerUrl + '/images/star-of-life-solid.svg" width="13.125px" height="auto" alt="All" title="All">' + item['title'] + '</div>';
485
- }
486
- });
487
-
488
- return markup;
489
- }
490
- };
491
-
492
- return UniversalIconPicker;
29
+ "use strict";
30
+
31
+ const createDomEle = function (string) {
32
+ const ele = document.createElement('div');
33
+ ele.innerHTML = string;
34
+ return ele.firstChild;
35
+ }
36
+
37
+ const debounce = function (func, wait, immediate) {
38
+ let timeout;
39
+ return function () {
40
+ const context = this,
41
+ args = arguments;
42
+ const later = function () {
43
+ timeout = null;
44
+ if (!immediate) func.apply(context, args);
45
+ };
46
+ const callNow = immediate && !timeout;
47
+ clearTimeout(timeout);
48
+ timeout = setTimeout(later, wait);
49
+ if (callNow) func.apply(context, args);
50
+ };
51
+ };
52
+
53
+ const escapeHtml = function (text) {
54
+ const map = {
55
+ '&': '&amp;',
56
+ '<': '&lt;',
57
+ '>': '&gt;',
58
+ '"': '&quot;',
59
+ "'": '&#039;'
60
+ };
61
+
62
+ return text.replace(/[&<>"']/g, function (m) { return map[m]; });
63
+ };
64
+
65
+ /**
66
+ * Merge defaults with user options
67
+ * @param {Object} defaults Default settings
68
+ * @param {Object} options User options
69
+ */
70
+ const extend = function (defaults, options) {
71
+ let prop, extended = {};
72
+ for (prop in defaults) {
73
+ if (Object.prototype.hasOwnProperty.call(defaults, prop)) {
74
+ extended[prop] = defaults[prop];
75
+ }
76
+ }
77
+ for (prop in options) {
78
+ if (Object.prototype.hasOwnProperty.call(options, prop)) {
79
+ extended[prop] = options[prop];
80
+ }
81
+ }
82
+
83
+ return extended;
84
+ };
85
+
86
+ const getLibraryName = function (string) {
87
+ return string.replace(/([A-Z])/g, ' $1');
88
+ }
89
+
90
+ /**
91
+ * Plugin Object
92
+ * @param selector The html selector to initialize
93
+ * @param {Object} options User options
94
+ * @constructor
95
+ */
96
+ function UniversalIconPicker (selector, options) {
97
+ this.selector = selector;
98
+
99
+ let defaults = {
100
+ allowEmpty: true,
101
+ iconLibraries: null,
102
+ iconLibrariesCss: null,
103
+ mode: 'autoload', // autoload | onrequest
104
+ onBeforeOpen: null,
105
+ onReset: null,
106
+ onSelect: null,
107
+ resetSelector: null,
108
+ loadCustomCss: false
109
+ };
110
+ this.options = extend(defaults, options);
111
+
112
+ this.activeLibraryId = '';
113
+ this.filterIcon = '';
114
+ this.iconEventsLoaded = false;
115
+ this.iconLibraries = {};
116
+ this.iconLibrariesLoaded = false;
117
+ this.iconMarkup = '';
118
+ this.iconWrap = '';
119
+ this.idSuffix = '-' + this.selector.replace(/[#\s[\]="]/g, '');
120
+ this.sideBarBtn = '';
121
+ this.sideBarList = [];
122
+
123
+ this.universalWrap = '<div class="uip-modal uip-open" id="uip-modal' + this.idSuffix + '"><div class="uip-modal--content"><div class="uip-modal--header"><div class="uip-modal--header-logo-area"><span class="uip-modal--header-logo-title">Icon Picker</span></div><div class="uip-modal--header-close-btn"><img src="' + iconPickerUrl + '/images/xmark-solid.svg" width="40" height="40" alt="Close" title="Close"></div></div><div class="uip-modal--body"><div id="uip-modal--sidebar' + this.idSuffix + '" class="uip-modal--sidebar"><div class="uip-modal--sidebar-tabs"></div></div><div id="uip-modal--icon-preview-wrap' + this.idSuffix + '" class="uip-modal--icon-preview-wrap"><div class="uip-modal--icon-search"><input name="" value="" placeholder="Filter by name..."><img src="' + iconPickerUrl + '/images/magnifying-glass-solid.svg" width="20" height="16" alt="Search" title="Search"></div><div class="uip-modal--icon-preview-inner"><div id="uip-modal--icon-preview' + this.idSuffix + '" class="uip-modal--icon-preview"></div></div></div></div><div class="uip-modal--footer"><button class="uip-insert-icon-button mt-3 mb-3 mr-6">Copy to clipboard</button></div></div></div>';
124
+
125
+ this.universalDomEle = createDomEle(this.universalWrap);
126
+ this.sidebarTabs = this.universalDomEle.querySelector('.uip-modal--sidebar-tabs');
127
+ this.previewWrap = this.universalDomEle.querySelector('#uip-modal--icon-preview' + this.idSuffix);
128
+ this.searchInput = this.universalDomEle.querySelector('.uip-modal--icon-search input');
129
+ if (this.options.mode === 'autoload') {
130
+ this.init();
131
+ } else {
132
+ document.querySelector(this.selector).addEventListener('click', this.init.bind(this), { once: true });
133
+ }
134
+ }
135
+
136
+
137
+ // Plugin prototype
138
+ UniversalIconPicker.prototype = {
139
+
140
+ /* Public functions
141
+ ------------------------------------------------------------------------ */
142
+
143
+ init: function () {
144
+ this._loadCssFiles();
145
+ if (this.options.mode !== 'autoload') {
146
+ this._onBeforeOpen().then(() => {
147
+ this.open();
148
+ });
149
+ }
150
+ document.querySelector(this.selector).addEventListener('click', () => {
151
+ this._onBeforeOpen().then(() => {
152
+ this.open();
153
+ });
154
+ });
155
+
156
+ //Remove selected icon
157
+ if (this.options.resetSelector) {
158
+ document.querySelector(this.options.resetSelector).addEventListener('click', this.options.onReset);
159
+ }
160
+ },
161
+
162
+ open: function () {
163
+ this._loadIconLibraries().then(() => {
164
+ this.iconLibrariesLoaded = true;
165
+ if (!document.getElementById('uip-modal' + this.idSuffix)) {
166
+ // push universal dom to body
167
+ document.body.appendChild(this.universalDomEle);
168
+
169
+ // jadams, 2023-05-21: disable page scrolling if modal is OPEN
170
+ document.body.classList.add('stop-scrolling');
171
+
172
+ // Icon library close by clicking close button
173
+ this.universalDomEle.querySelector('.uip-modal--header-close-btn').addEventListener('click', () => {
174
+ this.universalDomEle.classList.add('uip-close');
175
+ this.universalDomEle.classList.remove('uip-open');
176
+ // jadams, 2023-05-21: (re-)enable page scrolling if modal is CLOSED
177
+ document.body.classList.remove('stop-scrolling');
178
+ });
179
+
180
+ // Insert button
181
+ this.universalDomEle.querySelector('.uip-insert-icon-button').addEventListener('click', () => {
182
+ let selected = this.universalDomEle.querySelector('.universal-selected');
183
+
184
+ if (selected) {
185
+ let iconHtml = selected.querySelector('i').outerHTML;
186
+ let jsonOutput = {
187
+ 'libraryId': selected.dataset.libraryId,
188
+ 'libraryName': selected.dataset.libraryName,
189
+ 'iconHtml': null,
190
+ 'iconMarkup': null,
191
+ 'iconClass': null,
192
+ 'iconText': null
193
+ };
194
+ if (!selected.querySelector('i').classList.value.match('uip-icon-none')) {
195
+ jsonOutput.iconHtml = iconHtml;
196
+ jsonOutput.iconMarkup = escapeHtml(iconHtml);
197
+ jsonOutput.iconClass = selected.querySelector('i').classList.value;
198
+ jsonOutput.iconText = selected.querySelector('i').innerText;
199
+ }
200
+
201
+ this.options.onSelect(jsonOutput);
202
+ }
203
+ // jadams, 2023-05-21: disable modal CLOSE on a select
204
+ // this.universalDomEle.classList.add('uip-close');
205
+ // this.universalDomEle.classList.remove('uip-open');
206
+ });
207
+ } else {
208
+ // Icon library open if dom element exist
209
+ this.universalDomEle.classList.remove('uip-close');
210
+ this.universalDomEle.classList.add('uip-open');
211
+ // jadams, 2023-05-21: disable page scrolling if modal is OPEN
212
+ document.body.classList.add('stop-scrolling');
213
+ }
214
+
215
+ if (!this.iconEventsLoaded) {
216
+ // selected icon highlighted by adding class
217
+ this.universalDomEle.querySelectorAll('.uip-icon-item').forEach((item) => {
218
+ item.addEventListener('click', (evt) => {
219
+ this.iconWrap.forEach((el) => {
220
+ el.classList.remove('universal-selected');
221
+ });
222
+ evt.currentTarget.classList.toggle('universal-selected');
223
+ });
224
+ item.addEventListener('dblclick', (evt) => {
225
+ this.universalDomEle.querySelector('.uip-insert-icon-button').click();
226
+ });
227
+ });
228
+ this.iconEventsLoaded = true;
229
+ }
230
+
231
+ this.universalDomEle.querySelector('.uip-modal--icon-search input').focus();
232
+ });
233
+ },
234
+
235
+ setOptions: function (opts) {
236
+ this.options = extend(this.options, opts);
237
+ if (opts.iconLibrariesCss) {
238
+ this._loadCssFiles();
239
+ }
240
+ if (opts.iconLibraries) {
241
+ // dom icon events need to be reloaded
242
+ this.iconEventsLoaded = false;
243
+ this.iconLibrariesLoaded = false;
244
+ this._resetIconAndSidebarList();
245
+ }
246
+ },
247
+
248
+ /* Private functions
249
+ ------------------------------------------------------------------------ */
250
+
251
+ _clickHandlerFunc: function (e) {
252
+ if (!e.currentTarget.classList.contains('universal-active')) {
253
+ this.sideBarBtn.forEach(function (item) {
254
+ item.classList.remove('universal-active');
255
+ });
256
+ e.currentTarget.classList.add('universal-active')
257
+ }
258
+ this._sidebarFilterFunc(e.currentTarget.dataset['libraryId']);
259
+ },
260
+
261
+ _iconItemMarkup: function (libraryName, libraryItem) {
262
+ let markup = '',
263
+ library = libraryItem['icon-style'],
264
+ prefix = libraryItem['prefix'];
265
+
266
+ if (this.options.allowEmpty) {
267
+ markup += '<div class="uip-icon-item" data-library-id="' + library + '" data-filter="" data-library-name="' + libraryName + '"><div class="uip-icon-item-inner"><i class="' + prefix + ' uip-icon-none">&nbsp;</i><div class="uip-icon-item-name" title="None">None</div></div></div>';
268
+ }
269
+ if (prefix.match(/^material-icons/)) {
270
+ libraryItem['icons'].forEach(function (item) {
271
+ markup += '<div class="uip-icon-item" data-library-id="' + library + '" data-filter="' + item + '" data-library-name="' + libraryName + '"><div class="uip-icon-item-inner"><i class="' + prefix + '">' + item + '</i><div class="uip-icon-item-name" title="' + item + '">' + item.replace("-", " ") + '</div></div></div>';
272
+ });
273
+ } else {
274
+ libraryItem['icons'].forEach(function (item) {
275
+ markup += '<div class="uip-icon-item" data-library-id="' + library + '" data-filter="' + item + '" data-library-name="' + libraryName + '"><div class="uip-icon-item-inner"><i class="' + [prefix, item].join('') + '"></i><div class="uip-icon-item-name" title="' + item + '">' + item.replace("-", " ") + '</div></div></div>';
276
+ });
277
+ }
278
+
279
+ return markup;
280
+ },
281
+
282
+ _iconItemPush: function (arrayList) {
283
+ this.previewWrap.innerHTML = '';
284
+ arrayList.forEach((item) => {
285
+ this.previewWrap.appendChild(item[1]);
286
+ });
287
+ },
288
+
289
+ _loadCssFiles: function () {
290
+ let link = document.createElement('link');
291
+ if (!loadedDependencies.includes('universal-icon-picker.min.css') & !this.options.loadCustomCss) {
292
+ link.rel = 'stylesheet';
293
+ link.type = 'text/css';
294
+ link.href = iconPickerUrl + 'css/universal-icon-picker.min.css';
295
+ link.media = 'screen';
296
+ document.head.appendChild(link);
297
+ loadedDependencies.push('universal-icon-picker.min.css');
298
+ }
299
+ if (this.options.iconLibrariesCss) {
300
+ this.options.iconLibrariesCss.forEach(cssFile => {
301
+ if (!loadedDependencies.includes(cssFile)) {
302
+ let cssFileLink = iconPickerUrl + 'css/' + cssFile;
303
+ if (cssFile.match(/^http|^\/\//)) {
304
+ cssFileLink = cssFile;
305
+ link = document.createElement('link');
306
+ link.rel = 'stylesheet';
307
+ link.type = 'text/css';
308
+ link.href = cssFileLink;
309
+ link.media = 'screen';
310
+ document.head.appendChild(link);
311
+ loadedDependencies.push(cssFile);
312
+ }
313
+ }
314
+ });
315
+ }
316
+ },
317
+
318
+ _loadIconLibraries: async function (i = 0) {
319
+ if (!this.options.iconLibraries) {
320
+ console.error('Universal icon picker - no icon library loaded');
321
+ return false;
322
+ }
323
+ if (this.iconLibrariesLoaded) {
324
+ return true;
325
+ }
326
+ if (i === 0 && this.options.iconLibraries.length > 1) {
327
+ this.sideBarList.push({
328
+ "title": "all icons",
329
+ "list-icon": "",
330
+ "library-id": "all",
331
+ "prefix": ""
332
+ });
333
+ }
334
+
335
+ let iconLib = this.options.iconLibraries[i];
336
+
337
+ await fetch(iconPickerUrl + 'icons-libraries/' + iconLib)
338
+ .then(response => response.json())
339
+ .then(data => {
340
+ // Success!
341
+ const camelCasedIconLibrary = iconLib.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); }).replace(/\.[a-z.]+$/, '');
342
+ let newLibrary = {};
343
+ newLibrary[camelCasedIconLibrary] = data;
344
+ Object.assign(this.iconLibraries, newLibrary); // new icon library merge
345
+ if (i + 1 === this.options.iconLibraries.length) {
346
+ //set icon and sidebar list
347
+ this._setIconAndSidebarList();
348
+
349
+ this.activeLibraryId = this.sideBarList[0]['library-id'];
350
+
351
+ //sidebar list markup push
352
+ this.sidebarTabs.innerHTML = this._sideBarListMarkup(this.sideBarList);
353
+
354
+ //icon markup push
355
+ this.previewWrap.innerHTML = this.iconMarkup;
356
+
357
+ // get all icon wrapper dom element
358
+ this.iconWrap = this.previewWrap.querySelectorAll('.uip-icon-item');
359
+
360
+ //set event lisner to search input
361
+ this.searchInput.addEventListener('keyup', debounce(this._searchFunc, 100).bind(this), false);
362
+
363
+ //get all sidebar list item wrapper dom element
364
+ this.sideBarBtn = this.sidebarTabs.querySelectorAll('.uip-modal--sidebar-tab-item');
365
+
366
+ //set click event lisner to sidebar list item
367
+ this.sideBarBtn.forEach((item) => {
368
+ item.addEventListener('click', this._clickHandlerFunc.bind(this), false);
369
+ });
370
+
371
+ return true;
372
+ } else {
373
+ return this._loadIconLibraries(i + 1);
374
+ }
375
+ }).catch((error) => {
376
+ console.log(error);
377
+ return error;
378
+ });
379
+ },
380
+
381
+ _onBeforeOpen: async function () {
382
+ if (typeof (this.options.onBeforeOpen) === 'function') {
383
+ return this.options.onBeforeOpen();
384
+ }
385
+ },
386
+
387
+ _resetIconAndSidebarList: function () {
388
+ this.sideBarList = [];
389
+ this.iconMarkup = '';
390
+ this.iconLibraries = {};
391
+ this.iconWrap = '';
392
+ this.filterIcon = '';
393
+ this.sideBarBtn = '';
394
+ this.activeLibraryId = '';
395
+ },
396
+
397
+ _searchFunc: function (e) {
398
+ // console.log(this.value.toLowerCase());
399
+
400
+ const searchText = e.target.value.toLowerCase();
401
+ this._searchFilterFunc(searchText, 'filter');
402
+
403
+ },
404
+
405
+ _searchFilterFunc: function (filterText, dataName) {
406
+ this.filterIcon = Object.entries(this.iconWrap).filter((item) => {
407
+ if (-1 == item[1].dataset[dataName].indexOf(filterText) || (this.activeLibraryId !== 'all' && item[1].dataset['libraryId'] !== this.activeLibraryId)) {
408
+ return false;
409
+ }
410
+ return true;
411
+ });
412
+
413
+ this._iconItemPush(this.filterIcon);
414
+
415
+ },
416
+
417
+ _setIconAndSidebarList: function () {
418
+ for (const [libraryName, libraryContent] of Object.entries(this.iconLibraries)) {
419
+ this._setSideBarList(getLibraryName(libraryName), libraryContent);
420
+ this._setIconMarkup(libraryName, libraryContent);
421
+ }
422
+ },
423
+
424
+ _setIconMarkup: function (libraryName, libraryContent) {
425
+ if (libraryContent.icons !== undefined) {
426
+ this.iconMarkup += this._iconItemMarkup(libraryName, libraryContent)
427
+ } else {
428
+ Object.entries(libraryContent).forEach((item) => {
429
+ this.iconMarkup += this._iconItemMarkup(libraryName, item[1])
430
+ });
431
+ }
432
+ },
433
+
434
+ _sidebarFilterFunc: function (filterText) {
435
+ this.activeLibraryId = filterText;
436
+ this.filterIcon = Object.entries(this.iconWrap).filter(function (item) {
437
+ if ('all' === filterText || filterText === item[1].dataset['libraryId']) {
438
+ return true;
439
+ }
440
+ return false;
441
+ });
442
+
443
+ this._iconItemPush(this.filterIcon);
444
+
445
+ },
446
+
447
+ _setSideBarList: function (libraryName, libraryContent) {
448
+ let listItem;
449
+ if (libraryContent.icons !== undefined) {
450
+ listItem = {
451
+ 'title': libraryName,
452
+ 'prefix': libraryContent['prefix'] !== undefined ? libraryContent['prefix'] : '',
453
+ 'list-icon': libraryContent['list-icon'] !== undefined ? libraryContent['list-icon'] : '',
454
+ 'library-id': libraryContent['icon-style'] !== undefined ? libraryContent['icon-style'] : 'all',
455
+ };
456
+ this.sideBarList.push(listItem);
457
+ } else {
458
+ Object.entries(libraryContent).forEach(item => {
459
+ listItem = {
460
+ "title": libraryName + ' - ' + item[0],
461
+ "prefix": item[1]['prefix'] !== undefined ? item[1]['prefix'] : '',
462
+ "list-icon": item[1]['list-icon'] !== undefined ? item[1]['list-icon'] : "",
463
+ "library-id": item[1]['icon-style'] !== undefined ? item[1]['icon-style'] : "all",
464
+ };
465
+ this.sideBarList.push(listItem)
466
+ });
467
+ }
468
+ },
469
+
470
+ _sideBarListMarkup: function (sideBarList) {
471
+ let markup = '';
472
+ sideBarList.forEach((item) => {
473
+ let activeClazz = '';
474
+ if (item['library-id'] === this.activeLibraryId) {
475
+ activeClazz = ' universal-active';
476
+ }
477
+ if ('all' !== item['library-id']) {
478
+ let iconTag = '<i class="' + item['list-icon'] + '"></i>';
479
+ if (item['prefix'].match(/^material-icons/)) {
480
+ iconTag = '<i class="' + item['prefix'] + '">' + item['list-icon'] + '</i>';
481
+ }
482
+ markup += '<div class="uip-modal--sidebar-tab-item' + activeClazz + '" data-library-id="' + item['library-id'] + '">' + iconTag + item['title'] + '</div>';
483
+ } else {
484
+ markup += '<div class="uip-modal--sidebar-tab-item' + activeClazz + '" data-library-id="' + item['library-id'] + '"><img src="' + iconPickerUrl + '/images/star-of-life-solid.svg" width="13.125px" height="auto" alt="All" title="All">' + item['title'] + '</div>';
485
+ }
486
+ });
487
+
488
+ return markup;
489
+ }
490
+ };
491
+
492
+ return UniversalIconPicker;
493
493
  }));