@finqu/cool 1.2.29 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/README.md +694 -1
  2. package/dist/css/cool.css +26902 -14322
  3. package/dist/css/cool.css.map +1 -154
  4. package/dist/css/cool.min.css +2 -7
  5. package/dist/css/cool.min.css.map +1 -1
  6. package/dist/js/cool.bundle.js +16191 -5588
  7. package/dist/js/cool.bundle.js.map +1 -1
  8. package/dist/js/cool.bundle.min.js +13 -8
  9. package/dist/js/cool.bundle.min.js.map +1 -1
  10. package/dist/js/cool.esm.js +4722 -4812
  11. package/dist/js/cool.esm.js.map +1 -1
  12. package/dist/js/cool.esm.min.js +4 -9
  13. package/dist/js/cool.esm.min.js.map +1 -1
  14. package/dist/js/cool.js +5143 -5240
  15. package/dist/js/cool.js.map +1 -1
  16. package/dist/js/cool.min.js +4 -9
  17. package/dist/js/cool.min.js.map +1 -1
  18. package/package.json +125 -60
  19. package/scss/LISENCE +1 -1
  20. package/scss/_badge.scss +134 -102
  21. package/scss/_button-group.scss +80 -129
  22. package/scss/_buttons.scss +257 -201
  23. package/scss/_dark.scss +637 -0
  24. package/scss/_dialog.scss +314 -123
  25. package/scss/_dropdown.scss +165 -233
  26. package/scss/_forms.scss +555 -200
  27. package/scss/_frame.scss +945 -624
  28. package/scss/_grid.scss +215 -35
  29. package/scss/_input-group.scss +326 -285
  30. package/scss/_list-group.scss +127 -82
  31. package/scss/_media.scss +439 -0
  32. package/scss/_navbar.scss +116 -284
  33. package/scss/_notification.scss +111 -9
  34. package/scss/_pagination.scss +82 -88
  35. package/scss/_popover.scss +61 -167
  36. package/scss/_reboot.scss +306 -284
  37. package/scss/_root.scss +848 -15
  38. package/scss/_section.scss +735 -977
  39. package/scss/_select.scss +559 -187
  40. package/scss/_tables.scss +471 -595
  41. package/scss/_tabs.scss +50 -178
  42. package/scss/_toast.scss +242 -147
  43. package/scss/_tooltip.scss +130 -101
  44. package/scss/_typography.scss +166 -0
  45. package/scss/_variables.scss +1154 -748
  46. package/scss/cool.scss +64 -32
  47. package/scss/utilities/_align.scss +51 -41
  48. package/scss/utilities/_animation.scss +165 -0
  49. package/scss/utilities/_background.scss +72 -14
  50. package/scss/utilities/_borders.scss +205 -146
  51. package/scss/utilities/_collapse.scss +20 -25
  52. package/scss/utilities/_cursor.scss +160 -22
  53. package/scss/utilities/_display.scss +116 -16
  54. package/scss/utilities/_embed.scss +89 -78
  55. package/scss/utilities/_fill.scss +79 -0
  56. package/scss/utilities/_filters.scss +233 -0
  57. package/scss/utilities/_flex.scss +216 -52
  58. package/scss/utilities/_grid.scss +136 -0
  59. package/scss/utilities/_opacity.scss +131 -0
  60. package/scss/utilities/_overflow.scss +242 -6
  61. package/scss/utilities/_perfect-scrollbar.scss +147 -141
  62. package/scss/utilities/_pointer-events.scss +125 -0
  63. package/scss/utilities/_position.scss +130 -30
  64. package/scss/utilities/_screen-readers.scss +95 -0
  65. package/scss/utilities/_shadows.scss +195 -0
  66. package/scss/utilities/_sizing.scss +288 -32
  67. package/scss/utilities/_spacing.scss +168 -92
  68. package/scss/utilities/_stroke.scss +124 -0
  69. package/scss/utilities/_text.scss +420 -99
  70. package/scss/utilities/_transform.scss +232 -0
  71. package/scss/utilities/_transitions.scss +147 -0
  72. package/scss/utilities/_user-select.scss +89 -10
  73. package/scss/utilities/_visibility.scss +62 -6
  74. package/scss/utilities/_z-index.scss +169 -0
  75. package/.babelrc.js +0 -20
  76. package/.browserslistrc +0 -13
  77. package/build/.eslintrc.json +0 -10
  78. package/build/banner.js +0 -14
  79. package/build/build-plugins.js +0 -92
  80. package/build/rollup.config.js +0 -46
  81. package/dist/css/cool-grid.css +0 -4390
  82. package/dist/css/cool-grid.css.map +0 -30
  83. package/dist/css/cool-grid.min.css +0 -7
  84. package/dist/css/cool-grid.min.css.map +0 -1
  85. package/dist/css/cool-reboot.css +0 -286
  86. package/dist/css/cool-reboot.css.map +0 -62
  87. package/dist/css/cool-reboot.min.css +0 -7
  88. package/dist/css/cool-reboot.min.css.map +0 -1
  89. package/html/index.html +0 -2703
  90. package/js/dist/collapse.js +0 -5535
  91. package/js/dist/collapse.js.map +0 -1
  92. package/js/dist/common.js +0 -21996
  93. package/js/dist/common.js.map +0 -1
  94. package/js/dist/cooldropdown.js +0 -467
  95. package/js/dist/cooldropdown.js.map +0 -1
  96. package/js/dist/coolpopover.js +0 -391
  97. package/js/dist/coolpopover.js.map +0 -1
  98. package/js/dist/coolsectiontabs.js +0 -256
  99. package/js/dist/coolsectiontabs.js.map +0 -1
  100. package/js/dist/coolselect.js +0 -796
  101. package/js/dist/coolselect.js.map +0 -1
  102. package/js/dist/cooltooltip.js +0 -360
  103. package/js/dist/cooltooltip.js.map +0 -1
  104. package/js/dist/coolui.js +0 -73
  105. package/js/dist/coolui.js.map +0 -1
  106. package/js/dist/dropdown.js +0 -27421
  107. package/js/dist/dropdown.js.map +0 -1
  108. package/js/dist/popover.js +0 -9472
  109. package/js/dist/popover.js.map +0 -1
  110. package/js/dist/sectiontabs.js +0 -4483
  111. package/js/dist/sectiontabs.js.map +0 -1
  112. package/js/dist/select.js +0 -37080
  113. package/js/dist/select.js.map +0 -1
  114. package/js/dist/tooltip.js +0 -8786
  115. package/js/dist/tooltip.js.map +0 -1
  116. package/js/index.esm.js +0 -21
  117. package/js/index.umd.js +0 -21
  118. package/js/src/abstract-ui-component.js +0 -81
  119. package/js/src/collapse.js +0 -286
  120. package/js/src/common.js +0 -296
  121. package/js/src/dialog.js +0 -579
  122. package/js/src/dropdown.js +0 -525
  123. package/js/src/popover.js +0 -632
  124. package/js/src/section-tabs.js +0 -215
  125. package/js/src/select.js +0 -1342
  126. package/js/src/toast.js +0 -581
  127. package/js/src/tooltip.js +0 -591
  128. package/js/src/util/animate-css.js +0 -22
  129. package/js/src/util/index.js +0 -122
  130. package/js/src/util/perfect-scrollbar.js +0 -1316
  131. package/less/alert.less +0 -345
  132. package/less/badge.less +0 -38
  133. package/less/bootstrap-noconflict.less +0 -23
  134. package/less/bootstrap.less +0 -23
  135. package/less/button-group.less +0 -153
  136. package/less/buttons.less +0 -287
  137. package/less/dialog-noconflict.less +0 -174
  138. package/less/dialog.less +0 -203
  139. package/less/dropdown.less +0 -209
  140. package/less/forms.less +0 -770
  141. package/less/images.less +0 -242
  142. package/less/input-group.less +0 -163
  143. package/less/list-group.less +0 -73
  144. package/less/mixins/aspect-ratio.less +0 -23
  145. package/less/mixins/border-radius.less +0 -24
  146. package/less/mixins/box-shadow.less +0 -4
  147. package/less/mixins/buttons.less +0 -17
  148. package/less/mixins/caret.less +0 -51
  149. package/less/mixins/clearfix.less +0 -10
  150. package/less/mixins/gradients.less +0 -34
  151. package/less/mixins/nav-divider.less +0 -7
  152. package/less/mixins/object-fit.less +0 -13
  153. package/less/mixins/reset-text.less +0 -16
  154. package/less/mixins.less +0 -11
  155. package/less/package.json +0 -11
  156. package/less/pagination.less +0 -69
  157. package/less/popover.less +0 -143
  158. package/less/project.sublime-workspace +0 -774
  159. package/less/reboot.less +0 -235
  160. package/less/section.less +0 -793
  161. package/less/select.less +0 -150
  162. package/less/tables.less +0 -737
  163. package/less/tabs.less +0 -162
  164. package/less/tooltip.less +0 -87
  165. package/less/type.less +0 -71
  166. package/less/utilities/align.less +0 -27
  167. package/less/utilities/animate.less +0 -3512
  168. package/less/utilities/background.less +0 -70
  169. package/less/utilities/borders.less +0 -16
  170. package/less/utilities/color.less +0 -70
  171. package/less/utilities/cursor.less +0 -8
  172. package/less/utilities/display.less +0 -38
  173. package/less/utilities/embed.less +0 -61
  174. package/less/utilities/flex.less +0 -76
  175. package/less/utilities/jquery-ui.less +0 -116
  176. package/less/utilities/lazyload.less +0 -29
  177. package/less/utilities/overflow.less +0 -11
  178. package/less/utilities/pace.less +0 -25
  179. package/less/utilities/placeholder.less +0 -60
  180. package/less/utilities/position.less +0 -42
  181. package/less/utilities/scrollbar.less +0 -152
  182. package/less/utilities/spacing.less +0 -197
  183. package/less/utilities/text.less +0 -68
  184. package/less/utilities/transform.less +0 -7
  185. package/less/utilities.less +0 -21
  186. package/less/variables.less +0 -343
  187. package/scss/_alert.scss +0 -102
  188. package/scss/_custom-forms.scss +0 -444
  189. package/scss/_functions.scss +0 -124
  190. package/scss/_images.scss +0 -361
  191. package/scss/_mixins.scss +0 -34
  192. package/scss/_type.scss +0 -129
  193. package/scss/_utilities.scss +0 -23
  194. package/scss/cool-grid.scss +0 -29
  195. package/scss/cool-reboot.scss +0 -11
  196. package/scss/mixins/_alert-variant.scss +0 -20
  197. package/scss/mixins/_aspect-ratio.scss +0 -29
  198. package/scss/mixins/_background-variant.scss +0 -25
  199. package/scss/mixins/_badge-variant.scss +0 -36
  200. package/scss/mixins/_breakpoints.scss +0 -102
  201. package/scss/mixins/_buttons.scss +0 -104
  202. package/scss/mixins/_caret.scss +0 -80
  203. package/scss/mixins/_clearfix.scss +0 -10
  204. package/scss/mixins/_float.scss +0 -14
  205. package/scss/mixins/_forms.scss +0 -67
  206. package/scss/mixins/_gradients.scss +0 -40
  207. package/scss/mixins/_grid-framework.scss +0 -72
  208. package/scss/mixins/_grid.scss +0 -60
  209. package/scss/mixins/_nav-divider.scss +0 -9
  210. package/scss/mixins/_notification-variant.scss +0 -7
  211. package/scss/mixins/_object-fit.scss +0 -16
  212. package/scss/mixins/_reset-text.scss +0 -19
  213. package/scss/mixins/_text-emphasis.scss +0 -21
  214. package/scss/mixins/_text-hide.scss +0 -10
  215. package/scss/mixins/_text-truncate.scss +0 -81
  216. package/scss/mixins/_visibility.scss +0 -7
  217. package/scss/project.sublime-workspace +0 -491
  218. package/scss/utilities/_animate.scss +0 -3512
  219. package/scss/utilities/_clearfix.scss +0 -6
  220. package/scss/utilities/_lazyload.scss +0 -31
  221. package/scss/utilities/_placeholder.scss +0 -77
@@ -1,796 +0,0 @@
1
- /*!
2
- * Cool UI coolselect.js v1.0.0 (https://finqu.fi)
3
- * Copyright 2011-2019 Finqu Oy
4
- * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
- */
6
- (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
8
- typeof define === 'function' && define.amd ? define(factory) :
9
- (global = global || self, global.CoolSelect = factory());
10
- }(this, function () { 'use strict';
11
-
12
- const {
13
- jQuery
14
- } = window;
15
-
16
- const debounce = function (func, wait, immediate) {
17
- var timeout;
18
- return function () {
19
- var context = this,
20
- args = arguments;
21
-
22
- var later = function () {
23
- timeout = null;
24
- if (!immediate) func.apply(context, args);
25
- };
26
-
27
- var callNow = immediate && !timeout;
28
- clearTimeout(timeout);
29
- timeout = setTimeout(later, wait);
30
- if (callNow) func.apply(context, args);
31
- };
32
- };
33
-
34
- const touchEvents = function () {
35
- if ('ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch) {
36
- return true;
37
- }
38
- };
39
-
40
- class AbstractUIComponent {
41
- // Create callback
42
- onCreate() {
43
- var onCreate = this.opts.onCreate;
44
-
45
- if (typeof onCreate === 'function') {
46
- onCreate.call(this.el);
47
- }
48
- } // Update callback
49
-
50
-
51
- onUpdate() {
52
- var onUpdate = this.opts.onUpdate;
53
-
54
- if (typeof onUpdate === 'function') {
55
- onUpdate.call(this.el);
56
- }
57
- } // Destroy callback
58
-
59
-
60
- onDestroy() {
61
- var onDestroy = this.opts.onDestroy;
62
-
63
- if (typeof onDestroy === 'function') {
64
- onDestroy.call(this.el);
65
- }
66
- } // Show callback
67
-
68
-
69
- onShow() {
70
- var onShow = this.opts.onShow;
71
-
72
- if (typeof onShow === 'function') {
73
- onShow.call(this.el);
74
- }
75
- } // Close callback
76
-
77
-
78
- onClose() {
79
- var onClose = this.opts.onClose;
80
-
81
- if (typeof onClose === 'function') {
82
- onClose.call(this.el);
83
- }
84
- }
85
-
86
- debug(...args) {
87
- if (this.opts.debug) {
88
- if (typeof this.opts.debug === 'function') {
89
- this.opts.debug(...args);
90
- } else {
91
- console.log(...args);
92
- }
93
- }
94
- }
95
-
96
- }
97
-
98
- const NAME = 'coolSelect';
99
- const DATA_KEY = 'plugin_coolSelect';
100
-
101
- class CoolSelect extends AbstractUIComponent {
102
- constructor(el, opts) {
103
- super();
104
- this.el = el;
105
- this.opts = jQuery.extend({}, jQuery.fn[NAME].defaults, opts);
106
- this.name = null;
107
- this.scrollContentHeight = null;
108
- this.items = [];
109
- this.data = {};
110
- this.searchData = []; // search api URL to query data
111
-
112
- this.searchApi = this.opts.searchApi; // Tells which type the select objects are (radio|select)
113
-
114
- this.type = null; // Is the content visible?
115
-
116
- this.contentOpen = null; // Tells if we have a search in our element
117
-
118
- this.showSearch = null; // Tells if we have a footer in our element
119
-
120
- this.showFooter = null; // For custom scroll function callback to store the object
121
- // in order to update the scroll
122
-
123
- this.scroll = null;
124
- this.init();
125
- } // Init plugin
126
-
127
-
128
- init() {
129
- jQuery.when(this.buildCache()).then(() => {
130
- this.buildScroll();
131
- this.bindEvents();
132
-
133
- if (this.data[this.name].length > 0) {
134
- this.setData();
135
- }
136
-
137
- this.onCreate();
138
- });
139
- } // Remove plugin instance completely
140
-
141
-
142
- destroy() {
143
- this.unbindEvents();
144
- this.$el.removeData();
145
- this.onDestroy();
146
- } // Update plugin data
147
-
148
-
149
- update() {
150
- this.buildCache();
151
- this.bindEvents();
152
- this.onUpdate();
153
- } // Cache DOM nodes for performance
154
-
155
-
156
- buildCache() {
157
- this.$el = jQuery(this.el);
158
- this.$selectHeader = this.$el.find('.select-header');
159
- this.$selectIconContainer = this.$selectHeader.find('.select-icon');
160
- this.name = this.$el.data('name') ? this.$el.data('name') : this.opts.name;
161
- this.scrollContentHeight = this.$el.data('scrollContentHeight') ? this.$el.data('scrollContentHeight') : this.opts.scrollContentHeight;
162
- this.items = this.$el.data('items') ? this.$el.data('items') : this.opts.items;
163
- this.data = {};
164
- this.data[this.name] = [];
165
- this.searchData = [];
166
- this.searchApi = this.$el.data('searchApi') ? this.$el.data('searchApi') : this.opts.searchApi;
167
- this.type = this.$el.data('type') ? this.$el.data('type') : this.opts.type;
168
- this.contentOpen = false;
169
-
170
- if (this.$el.data('setData') && this.$el.data('setData') != '') {
171
- this.data = this.$el.data('setData');
172
- }
173
-
174
- if (this.$el.find('.select-search')) {
175
- this.showSearch = true;
176
- } else {
177
- this.showSearch = this.$el.data('showSearch') ? this.$el.data('showSearch') : this.opts.showSearch;
178
- }
179
-
180
- if (this.$el.find('.select-footer')) {
181
- this.showFooter = true;
182
- } else {
183
- this.showFooter = this.$el.data('showFooter') ? this.$el.data('showFooter') : this.opts.showFooter;
184
- }
185
-
186
- if (this.items.length) {
187
- let items = this._renderItemList(this.items);
188
-
189
- this.$select = jQuery(`
190
- <div class="select-content">
191
-
192
- ${this._renderSearch()}
193
-
194
- <div class="select-scrollable-content">${items}</div>
195
-
196
- ${this._renderFooter()}
197
-
198
- </div>
199
- `);
200
- this.$el.append(this.$select);
201
- this.$scrollableContent = this.$select.find('.select-scrollable-content') ? this.$select.find('.select-scrollable-content') : false;
202
- this.$selectItems = this.$select.find('.select-item');
203
- this.$selectLabels = this.$select.find('[data-label]');
204
-
205
- if (this.showSearch) {
206
- this.$searchContainer = this.$select.find('.select-search');
207
- this.$searchInput = this.$select.find('[name="select-search"]');
208
- this.$searchIconContainer = this.$select.find('.select-search-icon');
209
- this.$clearSearchButton = this.$select.find('[data-clear-search]');
210
- }
211
-
212
- if (this.showFooter) {
213
- this.$footerContainer = this.$select.find('.select-footer');
214
- this.$closeButton = this.$select.find('[data-select-close]');
215
- }
216
-
217
- jQuery.each(this.$selectLabels, function (i, el) {
218
- this.searchData.push({
219
- id: i,
220
- val: jQuery(el).text().trim()
221
- });
222
- });
223
-
224
- if (this.opts.debug) {
225
- this.debug(this.$el);
226
- this.debug(this.$select);
227
- this.debug(this.$scrollableContent);
228
- this.debug('Name: ' + this.name);
229
- this.debug('Show search: ' + this.showSearch);
230
- this.debug('Show footer: ' + this.showFooter);
231
- this.debug('Scroll content height: ' + this.scrollContentHeight + 'px');
232
- this.debug(this.items);
233
- this.debug(this.searchData);
234
- }
235
- } else {
236
- this.$select = this.$el.find('.select-content');
237
- this.$scrollableContent = this.$select.find('.select-scrollable-content');
238
- this.$selectItems = this.$select.find('.select-item');
239
- this.$selectLabels = this.$select.find('[data-label]');
240
-
241
- if (this.showSearch) {
242
- this.$searchContainer = this.$select.find('.select-search');
243
- this.$searchInput = this.$select.find('[name="select-search"]');
244
- this.$searchIconContainer = this.$select.find('.select-search-icon');
245
- this.$clearSearchButton = this.$select.find('[data-clear-search]');
246
- }
247
-
248
- if (this.showFooter) {
249
- this.$footerContainer = this.$select.find('.select-footer');
250
- this.$closeButton = this.$select.find('[data-select-close]');
251
- }
252
-
253
- jQuery.each(this.$selectLabels, (i, el) => {
254
- this.searchData.push({
255
- id: i,
256
- val: jQuery(el).text().trim()
257
- });
258
- });
259
-
260
- if (this.opts.debug) {
261
- this.debug(this.$el);
262
- this.debug(this.$select);
263
- this.debug(this.$scrollableContent);
264
- this.debug('Name: ' + this.name);
265
- this.debug('Show search: ' + this.showSearch);
266
- this.debug('Show footer: ' + this.showFooter);
267
- this.debug('Scroll content height: ' + this.scrollContentHeight + 'px');
268
- this.debug(this.items);
269
- this.debug(this.searchData);
270
- }
271
-
272
- return true;
273
- }
274
- } // Build scroll
275
-
276
-
277
- buildScroll() {
278
- if (this.$scrollableContent.length > 0) {
279
- var scrollContentHeight = this.scrollContentHeight;
280
-
281
- if (this.showSearch) {
282
- scrollContentHeight = scrollContentHeight - (this.$searchContainer.outerHeight(true) || 0);
283
- }
284
-
285
- if (this.showFooter) {
286
- scrollContentHeight = scrollContentHeight - (this.$footerContainer.outerHeight(true) || 0);
287
- }
288
-
289
- this.$scrollableContent.css({
290
- 'max-height': scrollContentHeight - parseInt(this.$scrollableContent.css('marginTop'), 10) - parseInt(this.$scrollableContent.css('marginBottom'), 10) + 'px'
291
- });
292
-
293
- if (touchEvents || typeof this.opts.buildScroll !== 'function') {
294
- this.$scrollableContent.css({
295
- 'overflow-y': 'auto'
296
- });
297
- } else if (typeof this.opts.buildScroll === 'function') {
298
- this.scroll = this.opts.buildScroll(this.$scrollableContent); // this.$scrollableContent.addClass('ps-dark');
299
- // this.scroll = new PerfectScrollbar(this.$scrollableContent[0], {
300
- // wheelSpeed: 1,
301
- // wheelPropagation: false,
302
- // minScrollbarLength: 20,
303
- // scrollYMarginOffset : -1,
304
- // suppressScrollY: true,
305
- // suppressScrollX: true,
306
- // });
307
- // if (this.$scrollableContent[0].offsetHeight < this.$scrollableContent[0].scrollHeight) {
308
- // this.$scrollableContent.addClass('ps-show-rail-y');
309
- // this.scroll.settings.suppressScrollY = false;
310
- // }
311
- }
312
- }
313
- } // Bind events that trigger methods
314
-
315
-
316
- bindEvents() {
317
- var plugin = this;
318
- plugin.$selectHeader.on('click' + '.' + NAME, function () {
319
- if (plugin.contentOpen) {
320
- plugin.close.call(plugin);
321
- } else {
322
- plugin.show.call(plugin);
323
- }
324
- });
325
- plugin.$el.on('change' + '.' + NAME, 'input[type="checkbox"]', function () {
326
- var val = jQuery(this).val();
327
-
328
- if (this.checked) {
329
- plugin.data[plugin.name].indexOf(val) === -1 ? plugin.data[plugin.name].push(val) : false;
330
- } else {
331
- plugin.data[plugin.name] = plugin.data[plugin.name].filter(n => n != val);
332
- }
333
-
334
- plugin.onSelect(this);
335
- });
336
- plugin.$el.on('change' + '.' + NAME, 'input[type="radio"]', function () {
337
- var val = jQuery(this).val();
338
-
339
- if (this.checked) {
340
- plugin.data[plugin.name] = val;
341
- plugin.$select.find('input[type="radio"]').not(jQuery(this)).prop('checked', false);
342
- plugin.$select.find('input[type="radio"]').not(jQuery(this)).removeClass('checked');
343
- } else {
344
- plugin.data[plugin.name] = [];
345
- }
346
- });
347
- plugin.$el.on('click' + '.' + NAME, 'input[type="radio"]', function () {
348
- if (jQuery(this).hasClass('checked')) {
349
- plugin.data[plugin.name] = [];
350
- jQuery(this).prop('checked', false);
351
- jQuery(this).removeClass('checked');
352
- } else {
353
- jQuery(this).addClass('checked');
354
- }
355
-
356
- plugin.onSelect(this);
357
- }); // if (this.scroll) {
358
- // plugin.$scrollableContent.find('.ps__thumb-y').mousedown(function() {
359
- // plugin.$scrollableContent.addClass('ps-mousedown-scroll');
360
- // });
361
- // $(document).mouseup(function() {
362
- // if (plugin.$scrollableContent.hasClass('ps-mousedown-scroll')) {
363
- // plugin.$scrollableContent.removeClass('ps-mousedown-scroll');
364
- // }
365
- // });
366
- // }
367
-
368
- if (this.showSearch) {
369
- plugin.$searchInput.on('keydown' + '.' + NAME, debounce(function () {
370
- plugin.searchString = jQuery(this).val().trim();
371
- plugin.search.call(plugin);
372
- }, 250));
373
- plugin.$searchInput.on('focusin' + '.' + NAME, function () {
374
- plugin.$searchContainer.addClass('focused');
375
- });
376
- plugin.$searchInput.on('focusout' + '.' + NAME, function () {
377
- plugin.$searchContainer.removeClass('focused');
378
- });
379
- plugin.$clearSearchButton.on('click' + '.' + NAME, function () {
380
- if (plugin.searchString.length) {
381
- plugin.$searchInput.val('');
382
- plugin.searchString = '';
383
- plugin.search.call(plugin);
384
- } else {
385
- return;
386
- }
387
- });
388
- }
389
-
390
- if (this.showFooter) {
391
- plugin.$closeButton.on('click' + '.' + NAME, function () {
392
- plugin.close.call(plugin);
393
- });
394
- }
395
-
396
- jQuery(document).on('touchstart click', function (e) {
397
- if (!plugin.$el.is(e.target) && plugin.$el.has(e.target).length === 0 && plugin.contentOpen) {
398
- plugin.close.call(plugin);
399
- }
400
- });
401
- } // Unbind events that trigger methods
402
-
403
-
404
- unbindEvents() {
405
- this.$el.off('.' + NAME);
406
- } // Get data
407
-
408
-
409
- getData(data) {
410
- if (data) {
411
- return this.data[data];
412
- } else {
413
- return this.data;
414
- }
415
- } // Set data
416
-
417
-
418
- setData() {
419
- var plugin = this;
420
- var type = null;
421
- this.$selectIconContainer.html('<i class="' + this.opts.faPro ? 'fal' : 'fas' + ' fa-check text-green icon"></i>');
422
-
423
- if (this.searchApi.length) {
424
- var searchUrl = this.searchApi;
425
- var itemCount = this.data[this.name].length;
426
- var currentCount = 0;
427
- this.data[this.name].forEach(function (value) {
428
- searchUrl += encodeURIComponent('#' + value);
429
- currentCount++;
430
-
431
- if (currentCount !== itemCount) {
432
- searchUrl += '+';
433
- }
434
- });
435
- app.request(searchUrl).success(function (data) {
436
- var items = data.map(function (item) {
437
- if (item.name) {
438
- var label = item.name;
439
- } else if (item.label) {
440
- var label = item.label;
441
- } else if (item.value) {
442
- var label = item.value;
443
- }
444
-
445
- return {
446
- id: item.id.toString(),
447
- label: label
448
- };
449
- });
450
- var items = items.filter(function (item) {
451
- return plugin.data[plugin.name].indexOf(item.id) > -1;
452
- });
453
- var result = jQuery(plugin._renderItemList(items)); // var result = $(plugin.hbs['ui/select/templates/partials/select-item']({
454
- // selectType: plugin.type,
455
- // selectName: plugin.name,
456
- // items: items
457
- // })).i18n();
458
-
459
- jQuery.when(plugin.$scrollableContent.append(result)).then(function () {
460
- if (plugin.scroll && typeof plugin.scroll.update === 'function') {
461
- plugin.scroll.update();
462
- } // if (plugin.$scrollableContent[0].offsetHeight < plugin.$scrollableContent[0].scrollHeight) {
463
- // plugin.scroll.update();
464
- // plugin.scroll.settings.suppressScrollY = false;
465
- // plugin.$scrollableContent.addClass('ps-show-rail-y');
466
- // } else {
467
- // plugin.scroll.update();
468
- // plugin.scroll.settings.suppressScrollY = true;
469
- // plugin.$scrollableContent.removeClass('ps-show-rail-y');
470
- // }
471
-
472
-
473
- if (plugin.$select.find(':input[type="checkbox"]').length) {
474
- type = 'checkbox';
475
- } else if (plugin.$select.find(':input[type="radio"]').length) {
476
- type = 'radio';
477
- }
478
-
479
- if (type == 'checkbox') {
480
- plugin.data[plugin.name].forEach(function (value) {
481
- var $input = plugin.$select.find(':input').filter(function () {
482
- return this.value == value;
483
- });
484
- $input.prop('checked', true);
485
- plugin.onSelect($input[0]);
486
- });
487
- } else if (type == 'radio') {
488
- var $input = plugin.$select.find(':input').filter(function () {
489
- return this.value == plugin.data[plugin.name];
490
- });
491
- $input.prop('checked', true);
492
- $input.addClass('checked');
493
- plugin.onSelect($input[0]);
494
- }
495
- });
496
- }).get();
497
- } else {
498
- if (plugin.$select.find(':input[type="checkbox"]').length) {
499
- type = 'checkbox';
500
- } else if (plugin.$select.find(':input[type="radio"]').length) {
501
- type = 'radio';
502
- }
503
-
504
- if (type == 'checkbox') {
505
- this.data[this.name].forEach(function (value) {
506
- var $input = plugin.$select.find(':input').filter(function () {
507
- return this.value == value;
508
- });
509
- $input.prop('checked', true);
510
- plugin.onSelect($input[0]);
511
- });
512
- } else if (type == 'radio') {
513
- var $input = plugin.$select.find(':input').filter(function () {
514
- return this.value == plugin.data[plugin.name];
515
- });
516
- $input.prop('checked', true);
517
- $input.addClass('checked');
518
- plugin.onSelect($input[0]);
519
- }
520
- }
521
- } // Search
522
-
523
-
524
- search() {
525
- var plugin = this;
526
-
527
- if (this.searchString.length) {
528
- if (this.searchApi.length) {
529
- this.$scrollableContent.find('input:not(:checked)').parents('.select-item').not('.static-item').remove();
530
- app.request(this.searchApi + this.searchString).success(function (data) {
531
- var items = data.map(function (item) {
532
- return {
533
- id: item.id.toString(),
534
- label: item.name || item.label || item.value || null
535
- };
536
- });
537
- var items = items.filter(function (item) {
538
- return !(plugin.data[plugin.name].indexOf(item.id) > -1);
539
- }); // Remove 0 id from results
540
-
541
- var items = items.filter(function (item) {
542
- return [0].indexOf(item.id) > -1;
543
- });
544
- var result = jQuery(plugin._renderItemList(items));
545
- jQuery.when(plugin.$scrollableContent.append(result)).then(function () {
546
- if (this.scroll && typeof this.scroll.update === 'function') {
547
- this.scroll.update();
548
- } // plugin.$searchIconContainer.html('<i class="fal fa-times icon"></i>');
549
- // plugin.$searchIconContainer.attr('data-clear-search', 'true');
550
- // if (plugin.$scrollableContent[0].offsetHeight < plugin.$scrollableContent[0].scrollHeight) {
551
- // plugin.scroll.update();
552
- // plugin.scroll.settings.suppressScrollY = false;
553
- // plugin.$scrollableContent.addClass('ps-show-rail-y');
554
- // } else {
555
- // plugin.scroll.update();
556
- // plugin.scroll.settings.suppressScrollY = true;
557
- // plugin.$scrollableContent.removeClass('ps-show-rail-y');
558
- // }
559
-
560
- });
561
- }).get();
562
- } else {
563
- var results = this.searchData.filter(function (item) {
564
- return item.val.toLocaleLowerCase().indexOf(plugin.searchString.toLocaleLowerCase()) > -1;
565
- });
566
- this.$selectItems.removeClass('d-none');
567
- this.$selectItems.removeClass('visible');
568
- results.forEach(function (item) {
569
- jQuery(plugin.$selectItems[item.id]).addClass('visible');
570
- });
571
- this.$selectItems.not('.visible').addClass('d-none');
572
- this.$searchIconContainer.html('<i class="' + this.opts.faPro ? 'fal' : 'fas' + ' fa-times icon"></i>');
573
- this.$searchIconContainer.attr('data-clear-search', 'true');
574
- }
575
- } else {
576
- if (this.searchApi.length) {
577
- this.$scrollableContent.find('input:not(:checked)').parents('.select-item').not('.static-item').remove();
578
- this.$searchIconContainer.html('<i class="' + this.opts.faPro ? 'fal' : 'fas' + ' fa-search icon"></i>');
579
- this.$searchIconContainer.attr('data-clear-search', '');
580
- } else {
581
- this.$selectItems.removeClass('d-none');
582
- this.$selectItems.removeClass('visible');
583
- this.$searchIconContainer.html('<i class="' + this.opts.faPro ? 'fal' : 'fas' + ' fa-search icon"></i>');
584
- this.$searchIconContainer.attr('data-clear-search', '');
585
- }
586
- }
587
-
588
- if (this.scroll && typeof this.scroll.update === 'function') {
589
- this.scroll.update();
590
- }
591
-
592
- this.onUpdate();
593
- } // Show
594
-
595
-
596
- show() {
597
- if (this.$el.hasClass('show')) {
598
- return;
599
- }
600
-
601
- var $otherSelects = jQuery('.select.show');
602
-
603
- if ($otherSelects.length) {
604
- var zindex = parseInt($otherSelects.first().css('z-index'), 10) + 2;
605
- }
606
-
607
- this.$el.css({
608
- 'max-height': this.scrollContentHeight + this.$selectHeader.outerHeight(true) + 'px'
609
- });
610
- this.$el.addClass('show');
611
-
612
- if (!$otherSelects.length) {
613
- var zindex = parseInt(this.$el.css('z-index'), 10) + 1;
614
- }
615
-
616
- this.$el.css({
617
- 'z-index': zindex
618
- });
619
-
620
- if (this.scroll && typeof this.scroll.show === 'function') {
621
- this.scroll.update(); // if (this.$scrollableContent[0].offsetHeight < this.$scrollableContent[0].scrollHeight) {
622
- // this.$scrollableContent[0].scrollTop = 1;
623
- // this.$scrollableContent[0].scrollTop = 0;
624
- // }
625
- }
626
-
627
- this.$selectIconContainer.html(`<i class="${this.opts.faPro ? 'fal' : 'fas'} fa-angle-up"></i`);
628
- this.contentOpen = true;
629
- this.onShow();
630
- } // Close
631
-
632
-
633
- close() {
634
- var plugin = this;
635
- this.$el.css('max-height', '');
636
- this.$el.removeClass('show');
637
- setTimeout(() => {
638
- plugin.$el.removeAttr('style');
639
- }, 300);
640
-
641
- if (this.data[this.name].length > 0) {
642
- this.$selectIconContainer.html(`<i class="${this.opts.faPro ? 'fal' : 'fas'} fa-check text-green icon"></i>`);
643
- } else {
644
- this.$selectIconContainer.html(`<i class="${this.opts.faPro ? 'fal' : 'fas'} fa-angle-down"></i>`);
645
- }
646
-
647
- this.contentOpen = false;
648
- this.onClose();
649
- }
650
-
651
- onSelect(el) {
652
- var onSelect = this.opts.onSelect;
653
-
654
- if (typeof onSelect === 'function') {
655
- onSelect.call(el);
656
- }
657
- }
658
-
659
- _renderItemList(items) {
660
- let html = '';
661
-
662
- for (let i = 0; i < items.length; ++i) {
663
- html += `
664
- <div class="select-item">
665
-
666
- <div class="select-item-${this.type}">
667
-
668
- <div class="styled-${this.type}">">
669
-
670
- <input type="${this.type}">" id="select-${this.name}-${items[i].id}" value="${items[i].id}">
671
-
672
- <label for="select-${this.name}-${items[i].id}">
673
-
674
- <span class="radio-inner">
675
- <svg viewBox="0 0 18 18">
676
- <polyline points="1.5 6 4.5 9 10.5 1"></polyline>
677
- </svg>
678
- </span>
679
-
680
- <span class="${this.type}">-label" data-label>
681
- ${items[i].label}
682
- </span>
683
-
684
- </label>
685
-
686
- </div>
687
-
688
- </div>
689
-
690
- </div>
691
- `;
692
- }
693
- }
694
-
695
- _renderSearch() {
696
- if (!this.showSearch) {
697
- return '';
698
- }
699
-
700
- return `
701
- <div class="select-search">
702
-
703
- <div class="select-search-input">
704
-
705
- <input type="text" name="select-search" value="" placeholder="${this.opts.searchPlaceholder}">
706
-
707
- </div>
708
-
709
- <div class="select-search-icon">
710
-
711
- <i class="${this.opts.faPro ? 'fal' : 'fas'} fa-search icon"></i>
712
-
713
- </div>
714
-
715
- </div>
716
- `;
717
- }
718
-
719
- _renderFooter() {
720
- if (!this.showFooter) {
721
- return '';
722
- }
723
-
724
- return `
725
- <div class="select-footer">
726
-
727
- <button class="btn btn-primary" type="button" data-select-close>
728
- ${this.opts.btnCloseText}
729
- </button>
730
-
731
- </div>
732
- `;
733
- }
734
-
735
- static _jQueryInterface(config) {
736
- return this.each(function () {
737
- let data = jQuery(this).data(DATA_KEY);
738
-
739
- const _config = typeof config === 'object' && config;
740
-
741
- if (!data) {
742
- data = new CoolSelect(this, _config);
743
- jQuery(this).data(DATA_KEY, data);
744
- }
745
-
746
- if (typeof config === 'string') {
747
- if (typeof data[config] === 'undefined') {
748
- throw new TypeError(`No method named "${config}"`);
749
- }
750
-
751
- data[config]();
752
- }
753
- });
754
- }
755
-
756
- }
757
-
758
- if (typeof jQuery !== 'undefined') {
759
- // jQuery
760
- const JQUERY_NO_CONFLICT = jQuery.fn[NAME];
761
- jQuery.fn[NAME] = CoolSelect._jQueryInterface;
762
- jQuery.fn[NAME].Constructor = CoolSelect;
763
-
764
- jQuery.fn[NAME].noConflict = () => {
765
- jQuery.fn[NAME] = JQUERY_NO_CONFLICT;
766
- return CoolSelect._jQueryInterface;
767
- };
768
-
769
- jQuery.fn[NAME].defaults = {
770
- name: '',
771
- type: 'checkbox',
772
- scrollContentHeight: 100,
773
- faPro: false,
774
- items: [],
775
- showSearch: false,
776
- showFooter: false,
777
- searchApi: false,
778
- onCreate: null,
779
- onUpdate: null,
780
- onDestroy: null,
781
- onShow: null,
782
- onClose: null,
783
- onSearch: null,
784
- onSelect: null,
785
- // function that should return object with update method
786
- buildScroll: null,
787
- searchPlaceholder: null,
788
- btnCloseText: null,
789
- debug: false
790
- };
791
- }
792
-
793
- return CoolSelect;
794
-
795
- }));
796
- //# sourceMappingURL=coolselect.js.map