rails-active-ui 0.1.0

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 (167) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +6 -0
  3. data/app/assets/stylesheets.css +73555 -0
  4. data/app/components/accordion_component.rb +34 -0
  5. data/app/components/ad_component.rb +28 -0
  6. data/app/components/api_component.rb +24 -0
  7. data/app/components/breadcrumb_component.rb +26 -0
  8. data/app/components/button_component.rb +49 -0
  9. data/app/components/calendar_component.rb +34 -0
  10. data/app/components/card_component.rb +56 -0
  11. data/app/components/checkbox_component.rb +41 -0
  12. data/app/components/column_component.rb +62 -0
  13. data/app/components/comment_component.rb +45 -0
  14. data/app/components/concerns/alignable.rb +21 -0
  15. data/app/components/concerns/attachable.rb +16 -0
  16. data/app/components/concerns/orientable.rb +21 -0
  17. data/app/components/concerns/positionable.rb +21 -0
  18. data/app/components/concerns/sizeable.rb +18 -0
  19. data/app/components/container_component.rb +23 -0
  20. data/app/components/dimmer_component.rb +30 -0
  21. data/app/components/divider_component.rb +30 -0
  22. data/app/components/dropdown_component.rb +63 -0
  23. data/app/components/embed_component.rb +32 -0
  24. data/app/components/emoji_component.rb +15 -0
  25. data/app/components/feed_component.rb +22 -0
  26. data/app/components/flag_component.rb +15 -0
  27. data/app/components/flyout_component.rb +41 -0
  28. data/app/components/form_component.rb +39 -0
  29. data/app/components/grid_component.rb +85 -0
  30. data/app/components/h_stack_component.rb +67 -0
  31. data/app/components/header_component.rb +60 -0
  32. data/app/components/icon_component.rb +41 -0
  33. data/app/components/image_component.rb +46 -0
  34. data/app/components/input_component.rb +52 -0
  35. data/app/components/item_component.rb +39 -0
  36. data/app/components/item_group_component.rb +30 -0
  37. data/app/components/label_component.rb +49 -0
  38. data/app/components/link_component.rb +23 -0
  39. data/app/components/list_component.rb +39 -0
  40. data/app/components/loader_component.rb +33 -0
  41. data/app/components/menu_component.rb +64 -0
  42. data/app/components/menu_item_component.rb +52 -0
  43. data/app/components/message_component.rb +54 -0
  44. data/app/components/modal_component.rb +50 -0
  45. data/app/components/nag_component.rb +25 -0
  46. data/app/components/overlay_component.rb +16 -0
  47. data/app/components/placeholder_component.rb +39 -0
  48. data/app/components/popup_component.rb +31 -0
  49. data/app/components/progress_component.rb +48 -0
  50. data/app/components/pusher_component.rb +18 -0
  51. data/app/components/rail_component.rb +31 -0
  52. data/app/components/rating_component.rb +41 -0
  53. data/app/components/reset_component.rb +12 -0
  54. data/app/components/reveal_component.rb +39 -0
  55. data/app/components/row_component.rb +39 -0
  56. data/app/components/search_component.rb +44 -0
  57. data/app/components/segment_component.rb +57 -0
  58. data/app/components/segment_group_component.rb +36 -0
  59. data/app/components/shape_component.rb +25 -0
  60. data/app/components/sidebar_component.rb +33 -0
  61. data/app/components/site_component.rb +12 -0
  62. data/app/components/slider_component.rb +46 -0
  63. data/app/components/state_component.rb +25 -0
  64. data/app/components/statistic_component.rb +43 -0
  65. data/app/components/step_component.rb +56 -0
  66. data/app/components/step_group_component.rb +38 -0
  67. data/app/components/sticky_component.rb +22 -0
  68. data/app/components/sub_header_component.rb +15 -0
  69. data/app/components/sub_menu_component.rb +24 -0
  70. data/app/components/tab_component.rb +24 -0
  71. data/app/components/table_cell_component.rb +60 -0
  72. data/app/components/table_component.rb +160 -0
  73. data/app/components/table_row_component.rb +43 -0
  74. data/app/components/text_component.rb +73 -0
  75. data/app/components/toast_component.rb +36 -0
  76. data/app/components/transition_component.rb +32 -0
  77. data/app/components/v_stack_component.rb +31 -0
  78. data/app/components/visibility_component.rb +22 -0
  79. data/app/helpers/component_helper.rb +109 -0
  80. data/app/helpers/fui_helper.rb +53 -0
  81. data/app/javascript/accordion.js +547 -0
  82. data/app/javascript/accordion.min.js +11 -0
  83. data/app/javascript/api.js +1112 -0
  84. data/app/javascript/api.min.js +11 -0
  85. data/app/javascript/calendar.js +1960 -0
  86. data/app/javascript/calendar.min.js +11 -0
  87. data/app/javascript/checkbox.js +819 -0
  88. data/app/javascript/checkbox.min.js +11 -0
  89. data/app/javascript/dimmer.js +686 -0
  90. data/app/javascript/dimmer.min.js +11 -0
  91. data/app/javascript/dropdown.js +4019 -0
  92. data/app/javascript/dropdown.min.js +11 -0
  93. data/app/javascript/embed.js +646 -0
  94. data/app/javascript/embed.min.js +11 -0
  95. data/app/javascript/flyout.js +1405 -0
  96. data/app/javascript/flyout.min.js +11 -0
  97. data/app/javascript/form.js +2070 -0
  98. data/app/javascript/form.min.js +11 -0
  99. data/app/javascript/jquery.js +10716 -0
  100. data/app/javascript/jquery.min.js +2 -0
  101. data/app/javascript/modal.js +1507 -0
  102. data/app/javascript/modal.min.js +11 -0
  103. data/app/javascript/nag.js +522 -0
  104. data/app/javascript/nag.min.js +11 -0
  105. data/app/javascript/popup.js +1457 -0
  106. data/app/javascript/popup.min.js +11 -0
  107. data/app/javascript/progress.js +922 -0
  108. data/app/javascript/progress.min.js +11 -0
  109. data/app/javascript/rating.js +496 -0
  110. data/app/javascript/rating.min.js +11 -0
  111. data/app/javascript/search.js +1519 -0
  112. data/app/javascript/search.min.js +11 -0
  113. data/app/javascript/shape.js +721 -0
  114. data/app/javascript/shape.min.js +11 -0
  115. data/app/javascript/sidebar.js +952 -0
  116. data/app/javascript/sidebar.min.js +11 -0
  117. data/app/javascript/site.js +415 -0
  118. data/app/javascript/site.min.js +11 -0
  119. data/app/javascript/slider.js +1449 -0
  120. data/app/javascript/slider.min.js +11 -0
  121. data/app/javascript/state.js +653 -0
  122. data/app/javascript/state.min.js +11 -0
  123. data/app/javascript/sticky.js +852 -0
  124. data/app/javascript/sticky.min.js +11 -0
  125. data/app/javascript/tab.js +867 -0
  126. data/app/javascript/tab.min.js +11 -0
  127. data/app/javascript/toast.js +916 -0
  128. data/app/javascript/toast.min.js +11 -0
  129. data/app/javascript/transition.js +955 -0
  130. data/app/javascript/transition.min.js +11 -0
  131. data/app/javascript/ui/controllers/fui_accordion_controller.js +45 -0
  132. data/app/javascript/ui/controllers/fui_api_controller.js +80 -0
  133. data/app/javascript/ui/controllers/fui_calendar_controller.js +66 -0
  134. data/app/javascript/ui/controllers/fui_checkbox_controller.js +48 -0
  135. data/app/javascript/ui/controllers/fui_dimmer_controller.js +45 -0
  136. data/app/javascript/ui/controllers/fui_dropdown_controller.js +68 -0
  137. data/app/javascript/ui/controllers/fui_embed_controller.js +49 -0
  138. data/app/javascript/ui/controllers/fui_flyout_controller.js +49 -0
  139. data/app/javascript/ui/controllers/fui_form_controller.js +62 -0
  140. data/app/javascript/ui/controllers/fui_modal_controller.js +61 -0
  141. data/app/javascript/ui/controllers/fui_nag_controller.js +52 -0
  142. data/app/javascript/ui/controllers/fui_popup_controller.js +58 -0
  143. data/app/javascript/ui/controllers/fui_progress_controller.js +60 -0
  144. data/app/javascript/ui/controllers/fui_rating_controller.js +49 -0
  145. data/app/javascript/ui/controllers/fui_search_controller.js +76 -0
  146. data/app/javascript/ui/controllers/fui_shape_controller.js +45 -0
  147. data/app/javascript/ui/controllers/fui_sidebar_controller.js +48 -0
  148. data/app/javascript/ui/controllers/fui_site_controller.js +29 -0
  149. data/app/javascript/ui/controllers/fui_slider_controller.js +53 -0
  150. data/app/javascript/ui/controllers/fui_state_controller.js +63 -0
  151. data/app/javascript/ui/controllers/fui_sticky_controller.js +50 -0
  152. data/app/javascript/ui/controllers/fui_tab_controller.js +57 -0
  153. data/app/javascript/ui/controllers/fui_toast_controller.js +60 -0
  154. data/app/javascript/ui/controllers/fui_transition_controller.js +60 -0
  155. data/app/javascript/ui/controllers/fui_visibility_controller.js +55 -0
  156. data/app/javascript/ui/index.js +114 -0
  157. data/app/javascript/visibility.js +1196 -0
  158. data/app/javascript/visibility.min.js +11 -0
  159. data/app/lib/component.rb +63 -0
  160. data/config/importmap.rb +27 -0
  161. data/config/initializers/ruby_template_handler.rb +31 -0
  162. data/config/routes.rb +2 -0
  163. data/lib/tasks/ui_tasks.rake +4 -0
  164. data/lib/ui/engine.rb +27 -0
  165. data/lib/ui/version.rb +3 -0
  166. data/lib/ui.rb +6 -0
  167. metadata +220 -0
@@ -0,0 +1,1457 @@
1
+ /*!
2
+ * # Fomantic-UI 2.9.4 - Popup
3
+ * https://github.com/fomantic/Fomantic-UI/
4
+ *
5
+ *
6
+ * Released under the MIT license
7
+ * https://opensource.org/licenses/MIT
8
+ *
9
+ */
10
+
11
+ (function ($, window, document) {
12
+ 'use strict';
13
+
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
17
+
18
+ window = window !== undefined && window.Math === Math
19
+ ? window
20
+ : globalThis;
21
+
22
+ $.fn.popup = function (...args) {
23
+ const $allModules = $(this);
24
+ const $document = $(document);
25
+ const $window = $(window);
26
+ const $body = $('body');
27
+
28
+ const clickEvent = 'ontouchstart' in document.documentElement
29
+ ? 'touchstart'
30
+ : 'click';
31
+
32
+ let time = Date.now();
33
+ let performance = [];
34
+
35
+ const parameters = args[0];
36
+ const methodInvoked = typeof parameters === 'string';
37
+ const queryArguments = args.slice(1);
38
+ const contextCheck = function (context, win) {
39
+ let $context;
40
+ if ([window, document].includes(context)) {
41
+ $context = $(context);
42
+ } else {
43
+ $context = $(win.document).find(context);
44
+ if ($context.length === 0) {
45
+ $context = win.frameElement ? contextCheck(context, win.parent) : $body;
46
+ }
47
+ }
48
+
49
+ return $context;
50
+ };
51
+
52
+ let returnedValue;
53
+ $allModules.each(function () {
54
+ const settings = $.isPlainObject(parameters)
55
+ ? $.extend(true, {}, $.fn.popup.settings, parameters)
56
+ : $.extend({}, $.fn.popup.settings);
57
+
58
+ const selector = settings.selector;
59
+ const className = settings.className;
60
+ const error = settings.error;
61
+ const metadata = settings.metadata;
62
+ const namespace = settings.namespace;
63
+
64
+ const eventNamespace = '.' + settings.namespace;
65
+ const moduleNamespace = 'module-' + namespace;
66
+
67
+ const $module = $(this);
68
+ const $context = contextCheck(settings.context, window);
69
+ const $scrollContext = contextCheck(settings.scrollContext, window);
70
+ const $boundary = contextCheck(settings.boundary, window);
71
+ const $target = settings.target ? contextCheck(settings.target, window) : $module;
72
+
73
+ let $popup;
74
+ let $offsetParent;
75
+
76
+ let searchDepth = 0;
77
+ let triedPositions = false;
78
+ let openedWithTouch = false;
79
+
80
+ const element = this;
81
+ let instance = $module.data(moduleNamespace);
82
+
83
+ let documentObserver;
84
+ let elementNamespace;
85
+ let id;
86
+
87
+ const module = {
88
+
89
+ // binds events
90
+ initialize: function () {
91
+ module.debug('Initializing', $module);
92
+ module.createID();
93
+ module.bind.events();
94
+ if (!module.exists() && settings.preserve) {
95
+ module.create();
96
+ }
97
+ if (settings.observeChanges) {
98
+ module.observeChanges();
99
+ }
100
+ module.instantiate();
101
+ },
102
+
103
+ instantiate: function () {
104
+ module.verbose('Storing instance', module);
105
+ instance = module;
106
+ $module
107
+ .data(moduleNamespace, instance);
108
+ },
109
+
110
+ observeChanges: function () {
111
+ documentObserver = new MutationObserver(module.event.documentChanged);
112
+ documentObserver.observe(document, {
113
+ childList: true,
114
+ subtree: true,
115
+ });
116
+ module.debug('Setting up mutation observer', documentObserver);
117
+ },
118
+
119
+ refresh: function () {
120
+ if (settings.popup) {
121
+ $popup = $document.find(settings.popup).eq(0);
122
+ } else if (settings.inline) {
123
+ $popup = $target.nextAll(selector.popup).eq(0);
124
+ settings.popup = $popup;
125
+ }
126
+ if (settings.popup) {
127
+ module.set.invisible();
128
+ $offsetParent = module.get.offsetParent();
129
+ module.remove.invisible();
130
+ if (settings.movePopup && module.has.popup() && module.get.offsetParent($popup)[0] !== $offsetParent[0]) {
131
+ module.debug('Moving popup to the same offset parent as target');
132
+ $popup
133
+ .detach()
134
+ .appendTo($offsetParent);
135
+ }
136
+ } else {
137
+ $offsetParent = settings.inline
138
+ ? module.get.offsetParent($target)
139
+ : (module.has.popup()
140
+ ? module.get.offsetParent($popup)
141
+ : $body);
142
+ }
143
+ if ($offsetParent.is('html') && $offsetParent[0] !== $body[0]) {
144
+ module.debug('Setting page as offset parent');
145
+ $offsetParent = $body;
146
+ }
147
+ if (module.get.variation()) {
148
+ module.set.variation();
149
+ }
150
+ },
151
+
152
+ reposition: function () {
153
+ module.refresh();
154
+ module.set.position();
155
+ },
156
+
157
+ destroy: function () {
158
+ module.debug('Destroying previous module');
159
+ if (documentObserver) {
160
+ documentObserver.disconnect();
161
+ }
162
+ // remove the element only if was created dynamically
163
+ if ($popup && !settings.preserve) {
164
+ module.removePopup();
165
+ }
166
+ // clear all timeouts
167
+ clearTimeout(module.hideTimer);
168
+ clearTimeout(module.showTimer);
169
+ // remove events
170
+ module.unbind.close();
171
+ module.unbind.events();
172
+ $module
173
+ .removeData(moduleNamespace);
174
+ },
175
+
176
+ event: {
177
+ start: function (event) {
178
+ const delay = $.isPlainObject(settings.delay)
179
+ ? settings.delay.show
180
+ : settings.delay;
181
+ clearTimeout(module.hideTimer);
182
+ if (!openedWithTouch || (openedWithTouch && settings.addTouchEvents)) {
183
+ module.showTimer = setTimeout(function () {
184
+ module.show();
185
+ }, delay);
186
+ }
187
+ },
188
+ end: function () {
189
+ const delay = $.isPlainObject(settings.delay)
190
+ ? settings.delay.hide
191
+ : settings.delay;
192
+ clearTimeout(module.showTimer);
193
+ module.hideTimer = setTimeout(function () {
194
+ module.hide();
195
+ }, delay);
196
+ },
197
+ touchstart: function (event) {
198
+ openedWithTouch = true;
199
+ if (settings.addTouchEvents) {
200
+ module.show();
201
+ }
202
+ },
203
+ resize: function () {
204
+ if (module.is.visible()) {
205
+ module.set.position();
206
+ }
207
+ },
208
+ documentChanged: function (mutations) {
209
+ for (const mutation of mutations) {
210
+ for (const node of mutation.removedNodes) {
211
+ if (node === element || $(node).find(element).length > 0) {
212
+ module.debug('Element removed from DOM, tearing down events');
213
+ module.destroy();
214
+ }
215
+ }
216
+ }
217
+ },
218
+ hideGracefully: function (event) {
219
+ const $target = $(event.target);
220
+ const isInDOM = document.documentElement.contains(event.target);
221
+ const inPopup = $target.closest(selector.popup).length > 0;
222
+ // don't close on clicks inside popup
223
+ if (event && !inPopup && isInDOM) {
224
+ module.debug('Click occurred outside popup hiding popup');
225
+ module.hide();
226
+ } else {
227
+ module.debug('Click was inside popup, keeping popup open');
228
+ }
229
+ },
230
+ },
231
+
232
+ // generates popup html from metadata
233
+ create: function () {
234
+ const targetSibling = $target.next(selector.popup);
235
+ const contentFallback = !settings.popup && targetSibling.length === 0 ? $module.attr('title') : false;
236
+ let html = module.get.html();
237
+ const title = module.get.title();
238
+ const content = module.get.content(contentFallback);
239
+
240
+ if (html || content || title) {
241
+ module.debug('Creating pop-up html');
242
+ if (!html) {
243
+ html = settings.templates.popup({
244
+ title: title,
245
+ content: content,
246
+ });
247
+ }
248
+ $popup = $('<div/>')
249
+ .addClass(className.popup)
250
+ .data(metadata.activator, $module)
251
+ .html(html);
252
+ if (settings.inline) {
253
+ module.verbose('Inserting popup element inline', $popup);
254
+ $popup
255
+ .insertAfter($module);
256
+ } else {
257
+ module.verbose('Appending popup element to body', $popup);
258
+ $popup
259
+ .appendTo($context);
260
+ }
261
+ module.refresh();
262
+ module.set.variation();
263
+
264
+ if (settings.hoverable) {
265
+ module.bind.popup();
266
+ }
267
+ settings.onCreate.call($popup, element);
268
+ } else if (settings.popup) {
269
+ $document.find(settings.popup).data(metadata.activator, $module);
270
+ module.verbose('Used popup specified in settings');
271
+ module.refresh();
272
+ if (settings.hoverable) {
273
+ module.bind.popup();
274
+ }
275
+ } else if (targetSibling.length > 0) {
276
+ module.verbose('Pre-existing popup found');
277
+ settings.inline = true;
278
+ settings.popup = targetSibling.data(metadata.activator, $module);
279
+ module.refresh();
280
+ if (settings.hoverable) {
281
+ module.bind.popup();
282
+ }
283
+ } else {
284
+ module.debug('No content specified skipping display', element);
285
+ }
286
+ },
287
+
288
+ createID: function () {
289
+ id = (Math.random().toString(16) + '000000000').slice(2, 10);
290
+ elementNamespace = '.' + id;
291
+ module.verbose('Creating unique id for element', id);
292
+ },
293
+
294
+ // determines popup state
295
+ toggle: function () {
296
+ module.debug('Toggling pop-up');
297
+ if (module.is.hidden()) {
298
+ module.debug('Popup is hidden, showing pop-up');
299
+ module.unbind.close();
300
+ module.show();
301
+ } else {
302
+ module.debug('Popup is visible, hiding pop-up');
303
+ module.hide();
304
+ }
305
+ },
306
+
307
+ show: function (callback = function () {}) {
308
+ module.debug('Showing pop-up', settings.transition);
309
+ if (module.is.hidden() && !(module.is.active() && module.is.dropdown())) {
310
+ if (!module.exists()) {
311
+ module.create();
312
+ }
313
+ if (settings.onShow.call($popup, element) === false) {
314
+ module.debug('onShow callback returned false, cancelling popup animation');
315
+
316
+ return;
317
+ }
318
+ if (!settings.preserve && !settings.popup) {
319
+ module.refresh();
320
+ }
321
+ if ($popup && module.set.position()) {
322
+ module.save.conditions();
323
+ if (settings.exclusive) {
324
+ module.hideAll();
325
+ }
326
+ module.animate.show(callback);
327
+ }
328
+ }
329
+ },
330
+
331
+ hide: function (callback = function () {}) {
332
+ if (module.is.visible() || module.is.animating()) {
333
+ if (settings.onHide.call($popup, element) === false) {
334
+ module.debug('onHide callback returned false, cancelling popup animation');
335
+
336
+ return;
337
+ }
338
+ module.remove.visible();
339
+ module.unbind.close();
340
+ module.restore.conditions();
341
+ module.animate.hide(callback);
342
+ }
343
+ },
344
+
345
+ hideAll: function () {
346
+ $document.find(selector.popup)
347
+ .filter('.' + className.popupVisible)
348
+ .each(function () {
349
+ $(this)
350
+ .data(metadata.activator)
351
+ .popup('hide');
352
+ });
353
+ },
354
+ exists: function () {
355
+ if (!$popup) {
356
+ return false;
357
+ }
358
+ if (settings.inline || settings.popup) {
359
+ return module.has.popup();
360
+ }
361
+
362
+ return $popup.closest($context).length > 0;
363
+ },
364
+
365
+ removePopup: function () {
366
+ if (module.has.popup() && !settings.popup) {
367
+ module.debug('Removing popup', $popup);
368
+ $popup.remove();
369
+ $popup = undefined;
370
+ settings.onRemove.call($popup, element);
371
+ }
372
+ },
373
+
374
+ save: {
375
+ conditions: function () {
376
+ module.cache = {
377
+ title: $module.attr('title'),
378
+ };
379
+ if (module.cache.title) {
380
+ $module.removeAttr('title');
381
+ }
382
+ module.verbose('Saving original attributes', module.cache.title);
383
+ },
384
+ },
385
+ restore: {
386
+ conditions: function () {
387
+ if (module.cache && module.cache.title) {
388
+ $module.attr('title', module.cache.title);
389
+ module.verbose('Restoring original attributes', module.cache.title);
390
+ }
391
+
392
+ return true;
393
+ },
394
+ },
395
+ supports: {
396
+ svg: function () {
397
+ return typeof SVGGraphicsElement !== 'undefined';
398
+ },
399
+ },
400
+ animate: {
401
+ show: function (callback) {
402
+ callback = isFunction(callback) ? callback : function () {};
403
+ if (settings.transition && module.can.useElement('transition')) {
404
+ module.set.visible();
405
+ $popup
406
+ .transition({
407
+ animation: (settings.transition.showMethod || settings.transition) + ' in',
408
+ queue: false,
409
+ debug: settings.debug,
410
+ verbose: settings.verbose,
411
+ silent: settings.silent,
412
+ duration: settings.transition.showDuration || settings.duration,
413
+ onComplete: function () {
414
+ module.bind.close();
415
+ callback.call($popup, element);
416
+ settings.onVisible.call($popup, element);
417
+ },
418
+ });
419
+ }
420
+ },
421
+ hide: function (callback) {
422
+ callback = isFunction(callback) ? callback : function () {};
423
+ module.debug('Hiding pop-up');
424
+ if (settings.transition && $.fn.transition !== undefined) {
425
+ $popup
426
+ .transition({
427
+ animation: (settings.transition.hideMethod || settings.transition) + ' out',
428
+ queue: false,
429
+ duration: settings.transition.hideDuration || settings.duration,
430
+ debug: settings.debug,
431
+ verbose: settings.verbose,
432
+ silent: settings.silent,
433
+ onComplete: function () {
434
+ module.reset();
435
+ callback.call($popup, element);
436
+ settings.onHidden.call($popup, element);
437
+ },
438
+ });
439
+ } else {
440
+ module.error(error.noTransition);
441
+ }
442
+ },
443
+ },
444
+
445
+ change: {
446
+ content: function (html) {
447
+ $popup.html(html);
448
+ },
449
+ },
450
+
451
+ get: {
452
+ html: function () {
453
+ $module.removeData(metadata.html);
454
+
455
+ return $module.data(metadata.html) || settings.html;
456
+ },
457
+ title: function () {
458
+ $module.removeData(metadata.title);
459
+
460
+ return $module.data(metadata.title) || settings.title;
461
+ },
462
+ content: function (fallback) {
463
+ $module.removeData(metadata.content);
464
+
465
+ return $module.data(metadata.content) || settings.content || fallback;
466
+ },
467
+ variation: function () {
468
+ $module.removeData(metadata.variation);
469
+
470
+ return $module.data(metadata.variation) || settings.variation;
471
+ },
472
+ popup: function () {
473
+ return $popup;
474
+ },
475
+ popupOffset: function () {
476
+ return $popup.offset();
477
+ },
478
+ calculations: function () {
479
+ const $popupOffsetParent = module.get.offsetParent($popup);
480
+ const targetElement = $target[0];
481
+ const isWindowEl = $boundary[0] === window;
482
+ const targetOffset = $target.offset();
483
+ const parentOffset = settings.inline || (settings.popup && settings.movePopup)
484
+ ? $target.offsetParent().offset()
485
+ : { top: 0, left: 0 };
486
+ const screenPosition = isWindowEl
487
+ ? { top: 0, left: 0 }
488
+ : $boundary.offset();
489
+ const scroll = isWindowEl
490
+ ? { top: $window.scrollTop(), left: $window.scrollLeft() }
491
+ : { top: 0, left: 0 };
492
+ const calculations = {
493
+ // element which is launching popup
494
+ target: {
495
+ element: $target[0],
496
+ width: $target.outerWidth(),
497
+ height: $target.outerHeight(),
498
+ top: targetOffset.top - parentOffset.top,
499
+ left: targetOffset.left - parentOffset.left,
500
+ margin: {},
501
+ },
502
+ // popup itself
503
+ popup: {
504
+ width: $popup.outerWidth(),
505
+ height: $popup.outerHeight(),
506
+ },
507
+ // offset container (or 3d context)
508
+ parent: {
509
+ width: $offsetParent.outerWidth(),
510
+ height: $offsetParent.outerHeight(),
511
+ },
512
+ // screen boundaries
513
+ screen: {
514
+ top: screenPosition.top,
515
+ left: screenPosition.left,
516
+ scroll: {
517
+ top: scroll.top,
518
+ left: scroll.left,
519
+ },
520
+ width: $boundary.width(),
521
+ height: $boundary.height(),
522
+ },
523
+ };
524
+
525
+ // if popup offset context is different from target, then adjust calculations
526
+ if ($popupOffsetParent[0] !== $offsetParent[0]) {
527
+ const popupOffset = $popupOffsetParent.offset();
528
+ calculations.target.top -= popupOffset.top;
529
+ calculations.target.left -= popupOffset.left;
530
+ calculations.parent.width = $popupOffsetParent.outerWidth();
531
+ calculations.parent.height = $popupOffsetParent.outerHeight();
532
+ }
533
+
534
+ // add in container calcs if fluid
535
+ if (settings.setFluidWidth && module.is.fluid()) {
536
+ calculations.container = {
537
+ width: $popup.parent().outerWidth(),
538
+ };
539
+ calculations.popup.width = calculations.container.width;
540
+ }
541
+
542
+ // add in margins if inline
543
+ calculations.target.margin.top = settings.inline
544
+ ? Number.parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
545
+ : 0;
546
+ calculations.target.margin.left = settings.inline
547
+ ? (module.is.rtl()
548
+ ? Number.parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-right'), 10)
549
+ : Number.parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10))
550
+ : 0;
551
+ // calculate screen boundaries
552
+ const screen = calculations.screen;
553
+ calculations.boundary = {
554
+ top: screen.top + screen.scroll.top,
555
+ bottom: screen.top + screen.scroll.top + screen.height,
556
+ left: screen.left + screen.scroll.left,
557
+ right: screen.left + screen.scroll.left + screen.width,
558
+ };
559
+
560
+ return calculations;
561
+ },
562
+ id: function () {
563
+ return id;
564
+ },
565
+ startEvent: function () {
566
+ if (settings.on === 'hover') {
567
+ return 'mouseenter';
568
+ }
569
+ if (settings.on === 'focus') {
570
+ return 'focus';
571
+ }
572
+
573
+ return false;
574
+ },
575
+ scrollEvent: function () {
576
+ return 'scroll';
577
+ },
578
+ endEvent: function () {
579
+ if (settings.on === 'hover') {
580
+ return 'mouseleave';
581
+ }
582
+ if (settings.on === 'focus') {
583
+ return 'blur';
584
+ }
585
+
586
+ return false;
587
+ },
588
+ distanceFromBoundary: function (offset, calculations = module.get.calculations()) {
589
+ let distanceFromBoundary = {};
590
+
591
+ // shorthand
592
+ const popup = calculations.popup;
593
+ const boundary = calculations.boundary;
594
+
595
+ if (offset) {
596
+ distanceFromBoundary = {
597
+ top: offset.top - boundary.top,
598
+ left: offset.left - boundary.left,
599
+ right: boundary.right - (offset.left + popup.width),
600
+ bottom: boundary.bottom - (offset.top + popup.height),
601
+ };
602
+ module.verbose('Distance from boundaries determined', offset, distanceFromBoundary);
603
+ }
604
+
605
+ return distanceFromBoundary;
606
+ },
607
+ offsetParent: function ($element) {
608
+ const element = $element !== undefined
609
+ ? $element[0]
610
+ : $target[0];
611
+ let parentNode = element.parentNode;
612
+ let $node = $(parentNode);
613
+ if (parentNode) {
614
+ let is2D = $node.css('transform') === 'none';
615
+ let isStatic = $node.css('position') === 'static';
616
+ let isBody = $node.is('body');
617
+ while (parentNode && !isBody && isStatic && is2D) {
618
+ parentNode = parentNode.parentNode;
619
+ $node = $(parentNode);
620
+ is2D = $node.css('transform') === 'none';
621
+ isStatic = $node.css('position') === 'static';
622
+ isBody = $node.is('body');
623
+ }
624
+ }
625
+
626
+ return $node && $node.length > 0
627
+ ? $node
628
+ : $();
629
+ },
630
+ positions: function () {
631
+ return {
632
+ 'top left': false,
633
+ 'top center': false,
634
+ 'top right': false,
635
+ 'bottom left': false,
636
+ 'bottom center': false,
637
+ 'bottom right': false,
638
+ 'left center': false,
639
+ 'right center': false,
640
+ };
641
+ },
642
+ nextPosition: function (position) {
643
+ const positions = position.split(' ');
644
+ const verticalPosition = positions[0];
645
+ const horizontalPosition = positions[1];
646
+ const opposite = {
647
+ top: 'bottom',
648
+ bottom: 'top',
649
+ left: 'right',
650
+ right: 'left',
651
+ };
652
+ const adjacent = {
653
+ left: 'center',
654
+ center: 'right',
655
+ right: 'left',
656
+ };
657
+ const backup = {
658
+ 'top left': 'top center',
659
+ 'top center': 'top right',
660
+ 'top right': 'right center',
661
+ 'right center': 'bottom right',
662
+ 'bottom right': 'bottom center',
663
+ 'bottom center': 'bottom left',
664
+ 'bottom left': 'left center',
665
+ 'left center': 'top left',
666
+ };
667
+ const adjacentsAvailable = verticalPosition === 'top' || verticalPosition === 'bottom';
668
+ let oppositeTried = false;
669
+ let adjacentTried = false;
670
+ let nextPosition = false;
671
+ if (!triedPositions) {
672
+ module.verbose('All available positions available');
673
+ triedPositions = module.get.positions();
674
+ }
675
+
676
+ module.debug('Recording last position tried', position);
677
+ triedPositions[position] = true;
678
+
679
+ if (settings.prefer === 'opposite') {
680
+ nextPosition = [opposite[verticalPosition], horizontalPosition];
681
+ nextPosition = nextPosition.join(' ');
682
+ oppositeTried = triedPositions[nextPosition] === true;
683
+ module.debug('Trying opposite strategy', nextPosition);
684
+ }
685
+ if ((settings.prefer === 'adjacent') && adjacentsAvailable) {
686
+ nextPosition = [verticalPosition, adjacent[horizontalPosition]];
687
+ nextPosition = nextPosition.join(' ');
688
+ adjacentTried = triedPositions[nextPosition] === true;
689
+ module.debug('Trying adjacent strategy', nextPosition);
690
+ }
691
+ if (adjacentTried || oppositeTried) {
692
+ module.debug('Using backup position', nextPosition);
693
+ nextPosition = backup[position];
694
+ }
695
+
696
+ return nextPosition;
697
+ },
698
+ },
699
+
700
+ set: {
701
+ position: function (position = $module.data(metadata.position) || settings.position, calculations = module.get.calculations()) {
702
+ // exit conditions
703
+ if ($target.length === 0 || $popup.length === 0) {
704
+ module.error(error.notFound);
705
+
706
+ return;
707
+ }
708
+ let offset;
709
+ let distanceAway;
710
+ let positioning;
711
+
712
+ offset = $module.data(metadata.offset) || settings.offset;
713
+ distanceAway = settings.distanceAway;
714
+
715
+ // shorthand
716
+ const target = calculations.target;
717
+ const popup = calculations.popup;
718
+ const parent = calculations.parent;
719
+
720
+ if (module.should.centerArrow(calculations)) {
721
+ module.verbose('Adjusting offset to center arrow on small target element');
722
+ if (position === 'top left' || position === 'bottom left') {
723
+ offset += target.width / 2;
724
+ offset -= settings.arrowPixelsFromEdge;
725
+ }
726
+ if (position === 'top right' || position === 'bottom right') {
727
+ offset -= target.width / 2;
728
+ offset += settings.arrowPixelsFromEdge;
729
+ }
730
+ }
731
+
732
+ if (target.width === 0 && target.height === 0 && !module.is.svg(target.element)) {
733
+ module.debug('Popup target is hidden, no action taken');
734
+
735
+ return false;
736
+ }
737
+
738
+ if (settings.inline) {
739
+ module.debug('Adding margin to calculation', target.margin);
740
+ if (position === 'left center' || position === 'right center') {
741
+ offset += target.margin.top;
742
+ distanceAway += -target.margin.left;
743
+ } else if (position === 'top left' || position === 'top center' || position === 'top right') {
744
+ offset += target.margin.left;
745
+ distanceAway -= target.margin.top;
746
+ } else {
747
+ offset += target.margin.left;
748
+ distanceAway += target.margin.top;
749
+ }
750
+ }
751
+
752
+ module.debug('Determining popup position from calculations', position, calculations);
753
+
754
+ if (module.is.rtl()) {
755
+ position = position.replace(/left|right/g, function (match) {
756
+ return match === 'left'
757
+ ? 'right'
758
+ : 'left';
759
+ });
760
+ module.debug('RTL: Popup position updated', position);
761
+ }
762
+
763
+ // if last attempt, use specified last resort position
764
+ if (searchDepth === settings.maxSearchDepth && typeof settings.lastResort === 'string') {
765
+ position = settings.lastResort;
766
+ }
767
+
768
+ switch (position) {
769
+ case 'top left': {
770
+ positioning = {
771
+ top: 'auto',
772
+ bottom: parent.height - target.top + distanceAway,
773
+ left: target.left + offset,
774
+ right: 'auto',
775
+ };
776
+
777
+ break;
778
+ }
779
+ case 'top center': {
780
+ positioning = {
781
+ bottom: parent.height - target.top + distanceAway,
782
+ left: target.left + (target.width / 2) - (popup.width / 2) + offset,
783
+ top: 'auto',
784
+ right: 'auto',
785
+ };
786
+
787
+ break;
788
+ }
789
+ case 'top right': {
790
+ positioning = {
791
+ bottom: parent.height - target.top + distanceAway,
792
+ right: parent.width - target.left - target.width - offset,
793
+ top: 'auto',
794
+ left: 'auto',
795
+ };
796
+
797
+ break;
798
+ }
799
+ case 'left center': {
800
+ positioning = {
801
+ top: target.top + (target.height / 2) - (popup.height / 2) + offset,
802
+ right: parent.width - target.left + distanceAway,
803
+ left: 'auto',
804
+ bottom: 'auto',
805
+ };
806
+
807
+ break;
808
+ }
809
+ case 'right center': {
810
+ positioning = {
811
+ top: target.top + (target.height / 2) - (popup.height / 2) + offset,
812
+ left: target.left + target.width + distanceAway,
813
+ bottom: 'auto',
814
+ right: 'auto',
815
+ };
816
+
817
+ break;
818
+ }
819
+ case 'bottom left': {
820
+ positioning = {
821
+ top: target.top + target.height + distanceAway,
822
+ left: target.left + offset,
823
+ bottom: 'auto',
824
+ right: 'auto',
825
+ };
826
+
827
+ break;
828
+ }
829
+ case 'bottom center': {
830
+ positioning = {
831
+ top: target.top + target.height + distanceAway,
832
+ left: target.left + (target.width / 2) - (popup.width / 2) + offset,
833
+ bottom: 'auto',
834
+ right: 'auto',
835
+ };
836
+
837
+ break;
838
+ }
839
+ case 'bottom right': {
840
+ positioning = {
841
+ top: target.top + target.height + distanceAway,
842
+ right: parent.width - target.left - target.width - offset,
843
+ left: 'auto',
844
+ bottom: 'auto',
845
+ };
846
+
847
+ break;
848
+ }
849
+ // no default
850
+ }
851
+ if (positioning === undefined) {
852
+ module.error(error.invalidPosition, position);
853
+ }
854
+
855
+ module.debug('Calculated popup positioning values', positioning);
856
+
857
+ // tentatively place on stage
858
+ $popup
859
+ .css(positioning)
860
+ .removeClass(className.position)
861
+ .addClass(position);
862
+ module.set.invisible();
863
+
864
+ const popupOffset = module.get.popupOffset();
865
+
866
+ // see if any boundaries are surpassed with this tentative position
867
+ const distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations);
868
+
869
+ if (!settings.forcePosition && module.is.offstage(distanceFromBoundary, position)) {
870
+ module.debug('Position is outside viewport', position);
871
+ if (searchDepth < settings.maxSearchDepth) {
872
+ searchDepth++;
873
+ position = module.get.nextPosition(position);
874
+ module.debug('Trying new position', position);
875
+
876
+ return $popup
877
+ ? module.set.position(position, calculations)
878
+ : false;
879
+ }
880
+ if (settings.lastResort) {
881
+ module.debug('No position found, showing with last position');
882
+ } else {
883
+ module.debug('Popup could not find a position to display', $popup);
884
+ module.error(error.cannotPlace, element);
885
+ module.remove.attempts();
886
+ module.remove.invisible();
887
+ module.reset();
888
+ settings.onUnplaceable.call($popup, element);
889
+
890
+ return false;
891
+ }
892
+ }
893
+ module.debug('Position is on stage', position);
894
+ module.remove.attempts();
895
+ module.remove.invisible();
896
+ if (settings.setFluidWidth && module.is.fluid()) {
897
+ module.set.fluidWidth(calculations);
898
+ }
899
+
900
+ return true;
901
+ },
902
+
903
+ fluidWidth: function (calculations = module.get.calculations()) {
904
+ module.debug('Automatically setting element width to parent width', calculations.parent.width);
905
+ $popup.css('width', calculations.container.width);
906
+ },
907
+
908
+ loading: function () {
909
+ $popup.addClass(className.loading);
910
+ },
911
+
912
+ invisible: function () {
913
+ $popup.addClass(className.invisible);
914
+ },
915
+
916
+ variation: function (variation = module.get.variation()) {
917
+ if (variation && module.has.popup()) {
918
+ module.verbose('Adding variation to popup', variation);
919
+ $popup.addClass(variation);
920
+ }
921
+ },
922
+
923
+ visible: function () {
924
+ $module.addClass(className.visible);
925
+ },
926
+ },
927
+
928
+ remove: {
929
+ loading: function () {
930
+ $popup.removeClass(className.loading);
931
+ },
932
+ invisible: function () {
933
+ $popup.removeClass(className.invisible);
934
+ },
935
+ variation: function (variation = module.get.variation()) {
936
+ if (variation) {
937
+ module.verbose('Removing variation', variation);
938
+ $popup.removeClass(variation);
939
+ }
940
+ },
941
+ visible: function () {
942
+ $module.removeClass(className.visible);
943
+ },
944
+ attempts: function () {
945
+ module.verbose('Resetting all searched positions');
946
+ searchDepth = 0;
947
+ triedPositions = false;
948
+ },
949
+ },
950
+
951
+ bind: {
952
+ events: function () {
953
+ module.debug('Binding popup events to module');
954
+ if (settings.on === 'click') {
955
+ $module
956
+ .on(clickEvent + eventNamespace, module.toggle);
957
+ }
958
+ if (settings.on === 'hover') {
959
+ $module
960
+ .on('touchstart' + eventNamespace, module.event.touchstart);
961
+ }
962
+ if (module.get.startEvent()) {
963
+ $module
964
+ .on(module.get.startEvent() + eventNamespace, module.event.start)
965
+ .on(module.get.endEvent() + eventNamespace, module.event.end);
966
+ }
967
+ if (settings.target) {
968
+ module.debug('Target set to element', $target);
969
+ }
970
+ $window.on('resize' + elementNamespace, module.event.resize);
971
+ },
972
+ popup: function () {
973
+ module.verbose('Allowing hover events on popup to prevent closing');
974
+ if ($popup && module.has.popup()) {
975
+ $popup
976
+ .on('mouseenter' + eventNamespace, module.event.start)
977
+ .on('mouseleave' + eventNamespace, module.event.end);
978
+ }
979
+ },
980
+ close: function () {
981
+ if (settings.hideOnScroll === true || (settings.hideOnScroll === 'auto' && settings.on !== 'click')) {
982
+ module.bind.closeOnScroll();
983
+ }
984
+ if (module.is.closable()) {
985
+ module.bind.clickaway();
986
+ } else if (settings.on === 'hover' && openedWithTouch) {
987
+ module.bind.touchClose();
988
+ }
989
+ },
990
+ closeOnScroll: function () {
991
+ module.verbose('Binding scroll close event to document');
992
+ $scrollContext
993
+ .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully);
994
+ },
995
+ touchClose: function () {
996
+ module.verbose('Binding popup touchclose event to document');
997
+ $document
998
+ .on('touchstart' + elementNamespace, function (event) {
999
+ module.verbose('Touched away from popup');
1000
+ module.event.hideGracefully.call(element, event);
1001
+ });
1002
+ },
1003
+ clickaway: function () {
1004
+ module.verbose('Binding popup close event to document');
1005
+ $document
1006
+ .on(clickEvent + elementNamespace, function (event) {
1007
+ module.verbose('Clicked away from popup');
1008
+ module.event.hideGracefully.call(element, event);
1009
+ });
1010
+ },
1011
+ },
1012
+
1013
+ unbind: {
1014
+ events: function () {
1015
+ $window
1016
+ .off(elementNamespace);
1017
+ $module
1018
+ .off(eventNamespace);
1019
+ },
1020
+ close: function () {
1021
+ $document
1022
+ .off(elementNamespace);
1023
+ $scrollContext
1024
+ .off(elementNamespace);
1025
+ },
1026
+ },
1027
+
1028
+ can: {
1029
+ useElement: function (element) {
1030
+ if ($.fn[element] !== undefined) {
1031
+ return true;
1032
+ }
1033
+ module.error(error.noElement.replace('{element}', element));
1034
+
1035
+ return false;
1036
+ },
1037
+ },
1038
+
1039
+ has: {
1040
+ popup: function () {
1041
+ return $popup && $popup.length > 0;
1042
+ },
1043
+ },
1044
+
1045
+ should: {
1046
+ centerArrow: function (calculations) {
1047
+ return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2);
1048
+ },
1049
+ },
1050
+
1051
+ is: {
1052
+ closable: function () {
1053
+ if (settings.closable === 'auto') {
1054
+ return settings.on !== 'hover';
1055
+ }
1056
+
1057
+ return settings.closable;
1058
+ },
1059
+ offstage: function (distanceFromBoundary, position) {
1060
+ const offstage = [];
1061
+ // return boundaries that have been surpassed
1062
+ $.each(distanceFromBoundary, function (direction, distance) {
1063
+ if (distance < -settings.jitter) {
1064
+ module.debug('Position exceeds allowable distance from edge', direction, distance, position);
1065
+ offstage.push(direction);
1066
+ }
1067
+ });
1068
+
1069
+ return offstage.length > 0;
1070
+ },
1071
+ svg: function (element) {
1072
+ return module.supports.svg() && (element instanceof SVGGraphicsElement);
1073
+ },
1074
+ basic: function () {
1075
+ return $module.hasClass(className.basic);
1076
+ },
1077
+ active: function () {
1078
+ return $module.hasClass(className.active);
1079
+ },
1080
+ animating: function () {
1081
+ return $popup !== undefined && $popup.hasClass(className.animating);
1082
+ },
1083
+ fluid: function () {
1084
+ return $popup !== undefined && $popup.hasClass(className.fluid);
1085
+ },
1086
+ visible: function () {
1087
+ return $popup !== undefined && $popup.hasClass(className.popupVisible);
1088
+ },
1089
+ dropdown: function () {
1090
+ return $module.hasClass(className.dropdown);
1091
+ },
1092
+ hidden: function () {
1093
+ return !module.is.visible();
1094
+ },
1095
+ rtl: function () {
1096
+ return $module.attr('dir') === 'rtl' || $module.css('direction') === 'rtl' || $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl' || $context.attr('dir') === 'rtl' || $context.css('direction') === 'rtl';
1097
+ },
1098
+ },
1099
+
1100
+ reset: function () {
1101
+ module.remove.visible();
1102
+ if (settings.preserve) {
1103
+ if ($.fn.transition !== undefined) {
1104
+ $popup
1105
+ .transition('remove transition');
1106
+ }
1107
+ } else {
1108
+ module.removePopup();
1109
+ }
1110
+ },
1111
+
1112
+ setting: function (name, value) {
1113
+ if ($.isPlainObject(name)) {
1114
+ $.extend(true, settings, name);
1115
+ } else if (value !== undefined) {
1116
+ settings[name] = value;
1117
+ } else {
1118
+ return settings[name];
1119
+ }
1120
+ },
1121
+ internal: function (name, value) {
1122
+ if ($.isPlainObject(name)) {
1123
+ $.extend(true, module, name);
1124
+ } else if (value !== undefined) {
1125
+ module[name] = value;
1126
+ } else {
1127
+ return module[name];
1128
+ }
1129
+ },
1130
+ debug: function (...args) {
1131
+ if (!settings.silent && settings.debug) {
1132
+ if (settings.performance) {
1133
+ module.performance.log(args);
1134
+ } else {
1135
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1136
+ module.debug.apply(console, args);
1137
+ }
1138
+ }
1139
+ },
1140
+ verbose: function (...args) {
1141
+ if (!settings.silent && settings.verbose && settings.debug) {
1142
+ if (settings.performance) {
1143
+ module.performance.log(args);
1144
+ } else {
1145
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1146
+ module.verbose.apply(console, args);
1147
+ }
1148
+ }
1149
+ },
1150
+ error: function (...args) {
1151
+ if (!settings.silent) {
1152
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1153
+ module.error.apply(console, args);
1154
+ }
1155
+ },
1156
+ performance: {
1157
+ log: function (message) {
1158
+ let currentTime;
1159
+ let executionTime;
1160
+ let previousTime;
1161
+ if (settings.performance) {
1162
+ currentTime = Date.now();
1163
+ previousTime = time || currentTime;
1164
+ executionTime = currentTime - previousTime;
1165
+ time = currentTime;
1166
+ performance.push({
1167
+ Name: message[0],
1168
+ Arguments: message.slice(1),
1169
+ Element: element,
1170
+ 'Execution Time': executionTime,
1171
+ });
1172
+ }
1173
+ clearTimeout(module.performance.timer);
1174
+ module.performance.timer = setTimeout(function () {
1175
+ module.performance.display();
1176
+ }, 500);
1177
+ },
1178
+ display: function () {
1179
+ let title = settings.name + ':';
1180
+ let totalTime = 0;
1181
+ time = false;
1182
+ clearTimeout(module.performance.timer);
1183
+ $.each(performance, function (index, data) {
1184
+ totalTime += data['Execution Time'];
1185
+ });
1186
+ title += ' ' + totalTime + 'ms';
1187
+ if (performance.length > 0) {
1188
+ console.groupCollapsed(title);
1189
+ console.table(performance);
1190
+ console.groupEnd();
1191
+ }
1192
+ performance = [];
1193
+ },
1194
+ },
1195
+ invoke: function (query, passedArguments = queryArguments, context = element) {
1196
+ let object = instance;
1197
+ let maxDepth;
1198
+ let found;
1199
+ let response;
1200
+ if (typeof query === 'string' && object !== undefined) {
1201
+ query = query.split(/[ .]/);
1202
+ maxDepth = query.length - 1;
1203
+ $.each(query, function (depth, value) {
1204
+ const camelCaseValue = depth !== maxDepth
1205
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1206
+ : query;
1207
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
1208
+ object = object[camelCaseValue];
1209
+ } else if (object[camelCaseValue] !== undefined) {
1210
+ found = object[camelCaseValue];
1211
+
1212
+ return false;
1213
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
1214
+ object = object[value];
1215
+ } else if (object[value] !== undefined) {
1216
+ found = object[value];
1217
+
1218
+ return false;
1219
+ } else {
1220
+ module.error(error.method, query);
1221
+
1222
+ return false;
1223
+ }
1224
+ });
1225
+ }
1226
+ if (isFunction(found)) {
1227
+ response = found.apply(context, passedArguments);
1228
+ } else if (found !== undefined) {
1229
+ response = found;
1230
+ }
1231
+ if (Array.isArray(returnedValue)) {
1232
+ returnedValue.push(response);
1233
+ } else if (returnedValue !== undefined) {
1234
+ returnedValue = [returnedValue, response];
1235
+ } else if (response !== undefined) {
1236
+ returnedValue = response;
1237
+ }
1238
+
1239
+ return found;
1240
+ },
1241
+ };
1242
+
1243
+ if (methodInvoked) {
1244
+ if (instance === undefined) {
1245
+ module.initialize();
1246
+ }
1247
+ module.invoke(parameters);
1248
+ } else {
1249
+ if (instance !== undefined) {
1250
+ instance.invoke('destroy');
1251
+ }
1252
+ module.initialize();
1253
+ }
1254
+ });
1255
+
1256
+ return returnedValue !== undefined
1257
+ ? returnedValue
1258
+ : this;
1259
+ };
1260
+
1261
+ $.fn.popup.settings = {
1262
+
1263
+ name: 'Popup',
1264
+
1265
+ // module settings
1266
+ silent: false,
1267
+ debug: false,
1268
+ verbose: false,
1269
+ performance: true,
1270
+ namespace: 'popup',
1271
+
1272
+ // whether it should use dom mutation observers
1273
+ observeChanges: true,
1274
+
1275
+ // callback only when the element was added to dom
1276
+ onCreate: function () {},
1277
+
1278
+ // callback before element removed from dom
1279
+ onRemove: function () {},
1280
+
1281
+ // callback before show animation
1282
+ onShow: function () {},
1283
+
1284
+ // callback after show animation
1285
+ onVisible: function () {},
1286
+
1287
+ // callback before hide animation
1288
+ onHide: function () {},
1289
+
1290
+ // callback when popup cannot be positioned in visible screen
1291
+ onUnplaceable: function () {},
1292
+
1293
+ // callback after hide animation
1294
+ onHidden: function () {},
1295
+
1296
+ // when to show popup
1297
+ on: 'hover',
1298
+
1299
+ // element to use to determine if popup is out of boundary
1300
+ boundary: window,
1301
+
1302
+ // whether to add touchstart events when using hover
1303
+ addTouchEvents: true,
1304
+
1305
+ // default position relative to element
1306
+ position: 'top left',
1307
+
1308
+ // if given position should be used regardless if popup fits
1309
+ forcePosition: false,
1310
+
1311
+ // name of variation to use
1312
+ variation: '',
1313
+
1314
+ // whether popup should be moved to context
1315
+ movePopup: true,
1316
+
1317
+ // element which popup should be relative to
1318
+ target: false,
1319
+
1320
+ // jQuery selector or element that should be used as a popup
1321
+ popup: false,
1322
+
1323
+ // popup should remain inline next to activator
1324
+ inline: false,
1325
+
1326
+ // popup should be removed from page on hide
1327
+ preserve: false,
1328
+
1329
+ // popup should not close when being hovered on
1330
+ hoverable: false,
1331
+
1332
+ // explicitly set content
1333
+ content: false,
1334
+
1335
+ // explicitly set HTML
1336
+ html: false,
1337
+
1338
+ // explicitly set title
1339
+ title: false,
1340
+
1341
+ // whether automatically close on clickaway when on click
1342
+ closable: true,
1343
+
1344
+ // automatically hide on scroll
1345
+ hideOnScroll: 'auto',
1346
+
1347
+ // hide other popups on show
1348
+ exclusive: false,
1349
+
1350
+ // context to attach popups
1351
+ context: 'body',
1352
+
1353
+ // context for binding scroll events
1354
+ scrollContext: window,
1355
+
1356
+ // position to prefer when calculating new position
1357
+ prefer: 'opposite',
1358
+
1359
+ // specify position to appear even if it doesn't fit
1360
+ lastResort: false,
1361
+
1362
+ // number of pixels from edge of popup to pointing arrow center (used from centering)
1363
+ arrowPixelsFromEdge: 20,
1364
+
1365
+ // delay used to prevent accidental refiring of animations due to user error
1366
+ delay: {
1367
+ show: 50,
1368
+ hide: 70,
1369
+ },
1370
+
1371
+ // whether fluid variation should assign width explicitly
1372
+ setFluidWidth: true,
1373
+
1374
+ // transition settings
1375
+ duration: 200,
1376
+ transition: 'scale',
1377
+
1378
+ // distance away from the activating element in px
1379
+ distanceAway: 0,
1380
+
1381
+ // number of pixels an element is allowed to be "offstage" for a position to be chosen (allows for rounding)
1382
+ jitter: 2,
1383
+
1384
+ // offset on aligning axis from calculated position
1385
+ offset: 0,
1386
+
1387
+ // maximum times to look for a position before failing (9 positions total)
1388
+ maxSearchDepth: 15,
1389
+
1390
+ error: {
1391
+ invalidPosition: 'The position you specified is not a valid position',
1392
+ cannotPlace: 'Popup does not fit within the boundaries of the viewport',
1393
+ method: 'The method you called is not defined.',
1394
+ noElement: 'This module requires ui {element}',
1395
+ notFound: 'The target or popup you specified does not exist on the page',
1396
+ },
1397
+
1398
+ metadata: {
1399
+ activator: 'activator',
1400
+ content: 'content',
1401
+ html: 'html',
1402
+ offset: 'offset',
1403
+ position: 'position',
1404
+ title: 'title',
1405
+ variation: 'variation',
1406
+ },
1407
+
1408
+ className: {
1409
+ active: 'active',
1410
+ basic: 'basic',
1411
+ animating: 'animating',
1412
+ dropdown: 'dropdown',
1413
+ invisible: 'invisible',
1414
+ fluid: 'fluid',
1415
+ loading: 'loading',
1416
+ popup: 'ui popup',
1417
+ position: 'top left center bottom right',
1418
+ visible: 'visible',
1419
+ popupVisible: 'visible',
1420
+ },
1421
+
1422
+ selector: {
1423
+ popup: '.ui.popup',
1424
+ },
1425
+
1426
+ templates: {
1427
+ escape: function (string) {
1428
+ const escapeMap = {
1429
+ '"': '&quot;',
1430
+ '&': '&amp;',
1431
+ "'": '&apos;',
1432
+ '<': '&lt;',
1433
+ '>': '&gt;',
1434
+ };
1435
+
1436
+ return String(string).replace(/["&'<>]/g, (chr) => escapeMap[chr]);
1437
+ },
1438
+ popup: function (text) {
1439
+ let html = '';
1440
+ const escape = $.fn.popup.settings.templates.escape;
1441
+ if (text !== undefined) {
1442
+ if (text.title) {
1443
+ text.title = escape(text.title);
1444
+ html += '<div class="header">' + text.title + '</div>';
1445
+ }
1446
+ if (text.content) {
1447
+ text.content = escape(text.content);
1448
+ html += '<div class="content">' + text.content + '</div>';
1449
+ }
1450
+ }
1451
+
1452
+ return html;
1453
+ },
1454
+ },
1455
+
1456
+ };
1457
+ })(jQuery, window, document);