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,955 @@
1
+ /*!
2
+ * # Fomantic-UI 2.9.4 - Transition
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.transition = function (...args) {
23
+ const $allModules = $(this);
24
+
25
+ let time = Date.now();
26
+ let performance = [];
27
+
28
+ const moduleArguments = args;
29
+ const parameters = args[0];
30
+ const queryArguments = args.slice(1);
31
+ let methodInvoked = typeof parameters === 'string';
32
+
33
+ let returnedValue;
34
+ $allModules.each(function (index) {
35
+ const $module = $(this);
36
+ const element = this;
37
+
38
+ // set at run time
39
+ let settings;
40
+ let instance;
41
+
42
+ let error;
43
+ let className;
44
+ let metadata;
45
+
46
+ let moduleNamespace;
47
+ let eventNamespace;
48
+
49
+ const module = {
50
+
51
+ initialize: function () {
52
+ // get full settings
53
+ settings = module.get.settings(...moduleArguments);
54
+
55
+ // shorthand
56
+ className = settings.className;
57
+ error = settings.error;
58
+ metadata = settings.metadata;
59
+
60
+ // define namespace
61
+ eventNamespace = '.' + settings.namespace;
62
+ moduleNamespace = 'module-' + settings.namespace;
63
+ instance = $module.data(moduleNamespace) || module;
64
+
65
+ if (methodInvoked) {
66
+ methodInvoked = module.invoke(parameters);
67
+ }
68
+
69
+ // method not invoked, lets run an animation
70
+ if (methodInvoked === false) {
71
+ module.verbose('Converted arguments into settings object', settings);
72
+ if (settings.interval) {
73
+ module.delay(settings.interval);
74
+ } else {
75
+ module.animate();
76
+ }
77
+ module.instantiate();
78
+ }
79
+ },
80
+
81
+ instantiate: function () {
82
+ module.verbose('Storing instance of module', module);
83
+ instance = module;
84
+ $module
85
+ .data(moduleNamespace, instance);
86
+ },
87
+
88
+ destroy: function () {
89
+ module.verbose('Destroying previous module for', element);
90
+ $module
91
+ .removeData(moduleNamespace);
92
+ },
93
+
94
+ refresh: function () {
95
+ module.verbose('Refreshing display type on next animation');
96
+ delete module.displayType;
97
+ },
98
+
99
+ forceRepaint: function () {
100
+ module.verbose('Forcing element repaint');
101
+ const $parentElement = $module.parent();
102
+ const $nextElement = $module.next();
103
+ if ($nextElement.length === 0) {
104
+ $module.detach().appendTo($parentElement);
105
+ } else {
106
+ $module.detach().insertBefore($nextElement);
107
+ }
108
+ },
109
+
110
+ repaint: function () {
111
+ module.verbose('Repainting element');
112
+ const fakeAssignment = element.offsetWidth;
113
+ },
114
+
115
+ delay: function (interval = settings.interval) {
116
+ let direction = module.get.animationDirection();
117
+ if (!direction) {
118
+ direction = module.can.transition()
119
+ ? module.get.direction()
120
+ : 'static';
121
+ }
122
+ const shouldReverse = settings.reverse === 'auto' && direction === className.outward;
123
+ const delay = shouldReverse || settings.reverse === true
124
+ ? ($allModules.length - index) * interval
125
+ : index * interval;
126
+ module.debug('Delaying animation by', delay);
127
+ setTimeout(function () {
128
+ module.animate();
129
+ }, delay);
130
+ },
131
+
132
+ animate: function (overrideSettings = settings) {
133
+ settings = overrideSettings;
134
+
135
+ module.debug('Preparing animation', settings.animation);
136
+ if (module.is.animating()) {
137
+ if (settings.queue) {
138
+ if (!settings.allowRepeats && module.has.direction() && module.is.occurring() && module.queuing !== true) {
139
+ module.debug('Animation is currently occurring, preventing queueing same animation', settings.animation);
140
+ } else {
141
+ module.queue(settings.animation);
142
+ }
143
+
144
+ return false;
145
+ }
146
+ if (!settings.allowRepeats && module.is.occurring()) {
147
+ module.debug('Animation is already occurring, will not execute repeated animation', settings.animation);
148
+
149
+ return false;
150
+ }
151
+
152
+ module.debug('New animation started, completing previous early', settings.animation);
153
+ instance.complete();
154
+ }
155
+ if (module.can.animate()) {
156
+ module.set.animating(settings.animation);
157
+ } else {
158
+ module.error(error.noAnimation, settings.animation, element);
159
+ }
160
+ },
161
+
162
+ reset: function () {
163
+ module.debug('Resetting animation to beginning conditions');
164
+ module.remove.animationCallbacks();
165
+ module.restore.conditions();
166
+ module.remove.animating();
167
+ },
168
+
169
+ queue: function (animation) {
170
+ module.debug('Queueing animation of', animation);
171
+ module.queuing = true;
172
+ $module
173
+ .one('animationend.queue' + eventNamespace, function () {
174
+ module.queuing = false;
175
+ module.repaint();
176
+ module.animate.call(this, settings);
177
+ });
178
+ },
179
+
180
+ complete: function (event) {
181
+ if (event && event.target === element) {
182
+ event.stopPropagation();
183
+ }
184
+ module.debug('Animation complete', settings.animation);
185
+ module.remove.completeCallback();
186
+ module.remove.failSafe();
187
+ if (!module.is.looping()) {
188
+ if (module.is.outward()) {
189
+ module.verbose('Animation is outward, hiding element');
190
+ module.restore.conditions();
191
+ module.hide();
192
+ } else if (module.is.inward()) {
193
+ module.verbose('Animation is inward, showing element');
194
+ module.restore.conditions();
195
+ module.show();
196
+ } else {
197
+ module.verbose('Static animation completed');
198
+ module.restore.conditions();
199
+ settings.onComplete.call(element);
200
+ }
201
+ }
202
+ },
203
+
204
+ force: {
205
+ visible: function () {
206
+ const style = $module.attr('style');
207
+ const userStyle = module.get.userStyle(style);
208
+ const displayType = module.get.displayType();
209
+ const overrideStyle = userStyle + 'display: ' + displayType + ' !important;';
210
+ const inlineDisplay = $module[0].style.display;
211
+ const mustStayHidden = !displayType || (inlineDisplay === 'none' && settings.skipInlineHidden) || $module[0].tagName.match(/(script|link|style)/i);
212
+ if (mustStayHidden) {
213
+ module.remove.transition();
214
+
215
+ return false;
216
+ }
217
+ module.verbose('Overriding default display to show element', displayType);
218
+ $module
219
+ .attr('style', overrideStyle);
220
+
221
+ return true;
222
+ },
223
+ hidden: function () {
224
+ const style = $module.attr('style');
225
+ const currentDisplay = $module.css('display');
226
+ const emptyStyle = style === undefined || style === '';
227
+ if (currentDisplay !== 'none' && !module.is.hidden()) {
228
+ module.verbose('Overriding default display to hide element');
229
+ $module
230
+ .css('display', 'none');
231
+ } else if (emptyStyle) {
232
+ $module
233
+ .removeAttr('style');
234
+ }
235
+ },
236
+ },
237
+
238
+ has: {
239
+ direction: function (animation) {
240
+ let hasDirection = false;
241
+ animation = animation || settings.animation;
242
+ if (typeof animation === 'string') {
243
+ animation = animation.split(' ');
244
+ $.each(animation, function (index, word) {
245
+ if (word === className.inward || word === className.outward) {
246
+ hasDirection = true;
247
+ }
248
+ });
249
+ }
250
+
251
+ return hasDirection;
252
+ },
253
+ inlineDisplay: function () {
254
+ const style = $module.attr('style') || '';
255
+
256
+ return Array.isArray(style.match(/display.*?;/, ''));
257
+ },
258
+ },
259
+
260
+ set: {
261
+ animating: function (animation) {
262
+ // remove previous callbacks
263
+ module.remove.completeCallback();
264
+
265
+ // determine exact animation
266
+ animation = animation || settings.animation;
267
+ const animationClass = module.get.animationClass(animation);
268
+
269
+ // save animation class in cache to restore class names
270
+ module.save.animation(animationClass);
271
+
272
+ if (module.force.visible()) {
273
+ module.remove.hidden();
274
+ module.remove.direction();
275
+
276
+ module.start.animation(animationClass);
277
+ }
278
+ },
279
+ duration: function (duration = settings.duration) {
280
+ duration = typeof duration === 'number'
281
+ ? duration + 'ms'
282
+ : duration;
283
+ if (duration || duration === 0) {
284
+ module.verbose('Setting animation duration', duration);
285
+ $module
286
+ .css({
287
+ 'animation-duration': duration,
288
+ });
289
+ }
290
+ },
291
+ direction: function (direction = module.get.direction()) {
292
+ if (direction === className.inward) {
293
+ module.set.inward();
294
+ } else {
295
+ module.set.outward();
296
+ }
297
+ },
298
+ looping: function () {
299
+ module.debug('Transition set to loop');
300
+ $module
301
+ .addClass(className.looping);
302
+ },
303
+ hidden: function () {
304
+ $module
305
+ .addClass(className.transition)
306
+ .addClass(className.hidden);
307
+ },
308
+ inward: function () {
309
+ module.debug('Setting direction to inward');
310
+ $module
311
+ .removeClass(className.outward)
312
+ .addClass(className.inward);
313
+ },
314
+ outward: function () {
315
+ module.debug('Setting direction to outward');
316
+ $module
317
+ .removeClass(className.inward)
318
+ .addClass(className.outward);
319
+ },
320
+ visible: function () {
321
+ $module
322
+ .addClass(className.transition)
323
+ .addClass(className.visible);
324
+ },
325
+ },
326
+
327
+ start: {
328
+ animation: function (animationClass = module.get.animationClass()) {
329
+ module.debug('Starting tween', animationClass);
330
+ $module
331
+ .addClass(animationClass)
332
+ .one('animationend.complete' + eventNamespace, module.complete);
333
+ if (settings.useFailSafe) {
334
+ module.add.failSafe();
335
+ }
336
+ module.set.duration(settings.duration);
337
+ settings.onStart.call(element);
338
+ },
339
+ },
340
+
341
+ save: {
342
+ animation: function (animation) {
343
+ if (!module.cache) {
344
+ module.cache = {};
345
+ }
346
+ module.cache.animation = animation;
347
+ },
348
+ displayType: function (displayType) {
349
+ if (displayType !== 'none') {
350
+ $module.data(metadata.displayType, displayType);
351
+ }
352
+ },
353
+ transitionExists: function (animation, exists) {
354
+ $.fn.transition.exists[animation] = exists;
355
+ module.verbose('Saving existence of transition', animation, exists);
356
+ },
357
+ },
358
+
359
+ restore: {
360
+ conditions: function () {
361
+ const animation = module.get.currentAnimation();
362
+ if (animation) {
363
+ $module
364
+ .removeClass(animation);
365
+ module.verbose('Removing animation class', module.cache);
366
+ }
367
+ module.remove.duration();
368
+ },
369
+ },
370
+
371
+ add: {
372
+ failSafe: function () {
373
+ const duration = module.get.duration();
374
+ module.timer = setTimeout(function () {
375
+ $module.triggerHandler('animationend');
376
+ }, duration + settings.failSafeDelay);
377
+ module.verbose('Adding fail safe timer', module.timer);
378
+ },
379
+ },
380
+
381
+ remove: {
382
+ animating: function () {
383
+ $module.removeClass(className.animating);
384
+ },
385
+ animationCallbacks: function () {
386
+ module.remove.queueCallback();
387
+ module.remove.completeCallback();
388
+ },
389
+ queueCallback: function () {
390
+ $module.off('.queue' + eventNamespace);
391
+ },
392
+ completeCallback: function () {
393
+ $module.off('.complete' + eventNamespace);
394
+ },
395
+ display: function () {
396
+ $module.css('display', '');
397
+ },
398
+ direction: function () {
399
+ $module
400
+ .removeClass(className.inward)
401
+ .removeClass(className.outward);
402
+ },
403
+ duration: function () {
404
+ $module
405
+ .css('animation-duration', '');
406
+ },
407
+ failSafe: function () {
408
+ module.verbose('Removing fail safe timer', module.timer);
409
+ if (module.timer) {
410
+ clearTimeout(module.timer);
411
+ }
412
+ },
413
+ hidden: function () {
414
+ $module.removeClass(className.hidden);
415
+ },
416
+ visible: function () {
417
+ $module.removeClass(className.visible);
418
+ },
419
+ looping: function () {
420
+ module.debug('Transitions are no longer looping');
421
+ if (module.is.looping()) {
422
+ module.reset();
423
+ $module
424
+ .removeClass(className.looping);
425
+ }
426
+ },
427
+ transition: function () {
428
+ $module
429
+ .removeClass(className.transition)
430
+ .removeClass(className.visible)
431
+ .removeClass(className.hidden);
432
+ },
433
+ },
434
+ get: {
435
+ settings: function (animation, duration, onComplete) {
436
+ if (typeof animation === 'object') { // single settings object
437
+ return $.extend(true, {}, $.fn.transition.settings, animation);
438
+ }
439
+ if (typeof onComplete === 'function') { // all arguments provided
440
+ return $.extend({}, $.fn.transition.settings, {
441
+ animation: animation,
442
+ onComplete: onComplete,
443
+ duration: duration,
444
+ });
445
+ }
446
+ if (typeof duration === 'string' || typeof duration === 'number') { // only duration provided
447
+ return $.extend({}, $.fn.transition.settings, {
448
+ animation: animation,
449
+ duration: duration,
450
+ });
451
+ }
452
+ if (typeof duration === 'object') { // duration is actually settings object
453
+ return $.extend({}, $.fn.transition.settings, duration, {
454
+ animation: animation,
455
+ });
456
+ }
457
+ if (typeof duration === 'function') { // duration is actually callback
458
+ return $.extend({}, $.fn.transition.settings, {
459
+ animation: animation,
460
+ onComplete: duration,
461
+ });
462
+ }
463
+
464
+ // only animation provided
465
+ return $.extend({}, $.fn.transition.settings, {
466
+ animation: animation,
467
+ });
468
+ },
469
+ animationClass: function (animationClass = settings.animation) {
470
+ const directionClass = module.can.transition() && !module.has.direction()
471
+ ? module.get.direction() + ' '
472
+ : '';
473
+
474
+ return className.animating + ' '
475
+ + className.transition + ' '
476
+ + directionClass
477
+ + animationClass;
478
+ },
479
+ currentAnimation: function () {
480
+ return module.cache && module.cache.animation !== undefined
481
+ ? module.cache.animation
482
+ : false;
483
+ },
484
+ currentDirection: function () {
485
+ return module.is.inward()
486
+ ? className.inward
487
+ : className.outward;
488
+ },
489
+ direction: function () {
490
+ return module.is.hidden() || !module.is.visible()
491
+ ? className.inward
492
+ : className.outward;
493
+ },
494
+ animationDirection: function (animation = settings.animation) {
495
+ let direction;
496
+ if (typeof animation === 'string') {
497
+ animation = animation.split(' ');
498
+ // search animation name for out/in class
499
+ $.each(animation, function (index, word) {
500
+ if (word === className.inward) {
501
+ direction = className.inward;
502
+ } else if (word === className.outward) {
503
+ direction = className.outward;
504
+ }
505
+ });
506
+ }
507
+ // return found direction
508
+ if (direction) {
509
+ return direction;
510
+ }
511
+
512
+ return false;
513
+ },
514
+ duration: function (duration = settings.duration) {
515
+ if (duration === false) {
516
+ duration = $module.css('animation-duration') || 0;
517
+ }
518
+
519
+ return typeof duration === 'string'
520
+ ? (duration.includes('ms')
521
+ ? Number.parseFloat(duration)
522
+ : Number.parseFloat(duration) * 1000)
523
+ : duration;
524
+ },
525
+ displayType: function (shouldDetermine = true) {
526
+ if (settings.displayType) {
527
+ return settings.displayType;
528
+ }
529
+ if (shouldDetermine && $module.data(metadata.displayType) === undefined) {
530
+ const currentDisplay = $module.css('display');
531
+ if (currentDisplay === '' || currentDisplay === 'none') {
532
+ // create a fake element to determine display state
533
+ module.can.transition(true);
534
+ } else {
535
+ module.save.displayType(currentDisplay);
536
+ }
537
+ }
538
+
539
+ return $module.data(metadata.displayType);
540
+ },
541
+ userStyle: function (style) {
542
+ style = style || $module.attr('style') || '';
543
+
544
+ return style.replace(/display.*?;/, '');
545
+ },
546
+ transitionExists: function (animation) {
547
+ return $.fn.transition.exists[animation];
548
+ },
549
+ },
550
+
551
+ can: {
552
+ transition: function (forced) {
553
+ const animation = settings.animation;
554
+ const transitionExists = module.get.transitionExists(animation);
555
+ let displayType = module.get.displayType(false);
556
+ let elementClass;
557
+ let tagName;
558
+ let $clone;
559
+ let currentAnimation;
560
+ let inAnimation;
561
+ let directionExists;
562
+ if (transitionExists === undefined || forced) {
563
+ module.verbose('Determining whether animation exists');
564
+ elementClass = $module.attr('class');
565
+ tagName = $module.prop('tagName');
566
+
567
+ $clone = $('<' + tagName + ' />').addClass(elementClass).insertAfter($module);
568
+ currentAnimation = $clone
569
+ .addClass(animation)
570
+ .removeClass(className.inward)
571
+ .removeClass(className.outward)
572
+ .addClass(className.animating)
573
+ .addClass(className.transition)
574
+ .css('animationName');
575
+ $clone.detach().insertAfter($module);
576
+ inAnimation = $clone
577
+ .addClass(className.inward)
578
+ .css('animationName');
579
+ if (!displayType) {
580
+ $clone.detach().insertAfter($module);
581
+ displayType = $clone
582
+ .attr('class', elementClass)
583
+ .removeAttr('style')
584
+ .removeClass(className.hidden)
585
+ .removeClass(className.visible)
586
+ .show()
587
+ .css('display');
588
+ module.verbose('Determining final display state', displayType);
589
+ module.save.displayType(displayType);
590
+ }
591
+
592
+ $clone.remove();
593
+ if (currentAnimation !== inAnimation) {
594
+ module.debug('Direction exists for animation', animation);
595
+ directionExists = true;
596
+ } else if (currentAnimation === 'none' || !currentAnimation) {
597
+ module.debug('No animation defined in css', animation);
598
+
599
+ return;
600
+ } else {
601
+ module.debug('Static animation found', animation, displayType);
602
+ directionExists = false;
603
+ }
604
+ module.save.transitionExists(animation, directionExists);
605
+ }
606
+
607
+ return transitionExists !== undefined
608
+ ? transitionExists
609
+ : directionExists;
610
+ },
611
+ animate: function () {
612
+ // can transition does not return a value if animation does not exist
613
+ return module.can.transition() !== undefined;
614
+ },
615
+ },
616
+
617
+ is: {
618
+ animating: function () {
619
+ return $module.hasClass(className.animating);
620
+ },
621
+ inward: function () {
622
+ return $module.hasClass(className.inward);
623
+ },
624
+ outward: function () {
625
+ return $module.hasClass(className.outward);
626
+ },
627
+ looping: function () {
628
+ return $module.hasClass(className.looping);
629
+ },
630
+ occurring: function (animation = settings.animation) {
631
+ animation = '.' + animation.replace(' ', '.');
632
+
633
+ return $module.filter(animation).length > 0;
634
+ },
635
+ visible: function () {
636
+ return $module.is(':visible');
637
+ },
638
+ hidden: function () {
639
+ return $module.css('visibility') === 'hidden';
640
+ },
641
+ supported: function () {
642
+ // keep method for backward compatibility until 2.10.0
643
+ return true;
644
+ },
645
+ },
646
+
647
+ hide: function () {
648
+ if (settings.onHide.call(element) === false) {
649
+ module.verbose('Hide callback returned false cancelling hide');
650
+
651
+ return false;
652
+ }
653
+ module.verbose('Hiding element');
654
+ if (module.is.animating()) {
655
+ module.reset();
656
+ }
657
+ element.blur();
658
+ module.remove.display();
659
+ module.remove.visible();
660
+ settings.onBeforeHide.call(element, module.hideNow);
661
+ },
662
+
663
+ hideNow: function () {
664
+ module.set.hidden();
665
+ module.force.hidden();
666
+ settings.onHidden.call(element);
667
+ settings.onComplete.call(element);
668
+ },
669
+
670
+ show: function (display) {
671
+ if (module.force.visible() && settings.onShow.call(element) !== false) {
672
+ module.verbose('Showing element', display);
673
+ module.remove.hidden();
674
+ settings.onBeforeShow.call(element, module.showNow);
675
+ }
676
+ },
677
+
678
+ showNow: function () {
679
+ module.set.visible();
680
+ settings.onVisible.call(element);
681
+ settings.onComplete.call(element);
682
+ },
683
+
684
+ toggle: function () {
685
+ if (module.is.visible()) {
686
+ module.hide();
687
+ } else {
688
+ module.show();
689
+ }
690
+ },
691
+
692
+ stop: function () {
693
+ module.debug('Stopping current animation');
694
+ $module.triggerHandler('animationend');
695
+ },
696
+
697
+ stopAll: function () {
698
+ module.debug('Stopping all animation');
699
+ module.remove.queueCallback();
700
+ $module.triggerHandler('animationend');
701
+ },
702
+
703
+ clear: {
704
+ queue: function () {
705
+ module.debug('Clearing animation queue');
706
+ module.remove.queueCallback();
707
+ },
708
+ },
709
+
710
+ enable: function () {
711
+ module.verbose('Starting animation');
712
+ $module.removeClass(className.disabled);
713
+ },
714
+
715
+ disable: function () {
716
+ module.debug('Stopping animation');
717
+ $module.addClass(className.disabled);
718
+ },
719
+
720
+ setting: function (name, value) {
721
+ module.debug('Changing setting', name, value);
722
+ if ($.isPlainObject(name)) {
723
+ $.extend(true, settings, name);
724
+ } else if (value !== undefined) {
725
+ if ($.isPlainObject(settings[name])) {
726
+ $.extend(true, settings[name], value);
727
+ } else {
728
+ settings[name] = value;
729
+ }
730
+ } else {
731
+ return settings[name];
732
+ }
733
+ },
734
+ internal: function (name, value) {
735
+ if ($.isPlainObject(name)) {
736
+ $.extend(true, module, name);
737
+ } else if (value !== undefined) {
738
+ module[name] = value;
739
+ } else {
740
+ return module[name];
741
+ }
742
+ },
743
+ debug: function (...args) {
744
+ if (!settings.silent && settings.debug) {
745
+ if (settings.performance) {
746
+ module.performance.log(args);
747
+ } else {
748
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
749
+ module.debug.apply(console, args);
750
+ }
751
+ }
752
+ },
753
+ verbose: function (...args) {
754
+ if (!settings.silent && settings.verbose && settings.debug) {
755
+ if (settings.performance) {
756
+ module.performance.log(args);
757
+ } else {
758
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
759
+ module.verbose.apply(console, args);
760
+ }
761
+ }
762
+ },
763
+ error: function (...args) {
764
+ if (!settings.silent) {
765
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
766
+ module.error.apply(console, args);
767
+ }
768
+ },
769
+ performance: {
770
+ log: function (message) {
771
+ let currentTime;
772
+ let executionTime;
773
+ let previousTime;
774
+ if (settings.performance) {
775
+ currentTime = Date.now();
776
+ previousTime = time || currentTime;
777
+ executionTime = currentTime - previousTime;
778
+ time = currentTime;
779
+ performance.push({
780
+ Name: message[0],
781
+ Arguments: message.slice(1),
782
+ Element: element,
783
+ 'Execution Time': executionTime,
784
+ });
785
+ }
786
+ clearTimeout(module.performance.timer);
787
+ module.performance.timer = setTimeout(function () {
788
+ module.performance.display();
789
+ }, 500);
790
+ },
791
+ display: function () {
792
+ let title = settings.name + ':';
793
+ let totalTime = 0;
794
+ time = false;
795
+ clearTimeout(module.performance.timer);
796
+ $.each(performance, function (index, data) {
797
+ totalTime += data['Execution Time'];
798
+ });
799
+ title += ' ' + totalTime + 'ms';
800
+ if ($allModules.length > 1) {
801
+ title += ' (' + $allModules.length + ')';
802
+ }
803
+ if (performance.length > 0) {
804
+ console.groupCollapsed(title);
805
+ console.table(performance);
806
+ console.groupEnd();
807
+ }
808
+ performance = [];
809
+ },
810
+ },
811
+ // modified for transition to return invoke success
812
+ invoke: function (query, passedArguments = queryArguments, context = element) {
813
+ let object = instance;
814
+ let maxDepth;
815
+ let found;
816
+ let response;
817
+ if (typeof query === 'string' && object !== undefined) {
818
+ query = query.split(/[ .]/);
819
+ maxDepth = query.length - 1;
820
+ $.each(query, function (depth, value) {
821
+ const camelCaseValue = depth !== maxDepth
822
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
823
+ : query;
824
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
825
+ object = object[camelCaseValue];
826
+ } else if (object[camelCaseValue] !== undefined) {
827
+ found = object[camelCaseValue];
828
+
829
+ return false;
830
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
831
+ object = object[value];
832
+ } else if (object[value] !== undefined) {
833
+ found = object[value];
834
+
835
+ return false;
836
+ } else {
837
+ return false;
838
+ }
839
+ });
840
+ }
841
+ if (isFunction(found)) {
842
+ response = found.apply(context, passedArguments);
843
+ } else if (found !== undefined) {
844
+ response = found;
845
+ }
846
+
847
+ if (Array.isArray(returnedValue)) {
848
+ returnedValue.push(response);
849
+ } else if (returnedValue !== undefined) {
850
+ returnedValue = [returnedValue, response];
851
+ } else if (response !== undefined) {
852
+ returnedValue = response;
853
+ }
854
+
855
+ return found !== undefined
856
+ ? found
857
+ : false;
858
+ },
859
+ };
860
+ module.initialize();
861
+ });
862
+
863
+ return returnedValue !== undefined
864
+ ? returnedValue
865
+ : this;
866
+ };
867
+
868
+ // Records if CSS transition is available
869
+ $.fn.transition.exists = {};
870
+
871
+ $.fn.transition.settings = {
872
+
873
+ // module info
874
+ name: 'Transition',
875
+
876
+ // hide all output from this component regardless of other settings
877
+ silent: false,
878
+
879
+ // debug content outputted to console
880
+ debug: false,
881
+
882
+ // verbose debug output
883
+ verbose: false,
884
+
885
+ // performance data output
886
+ performance: true,
887
+
888
+ // event namespace
889
+ namespace: 'transition',
890
+
891
+ // delay between animations in a group
892
+ interval: 0,
893
+
894
+ // whether group animations should be reversed
895
+ reverse: 'auto',
896
+
897
+ // animation callback event
898
+ onStart: function () {},
899
+ onComplete: function () {},
900
+ onShow: function () {},
901
+ onBeforeShow: function (callback) {
902
+ callback.call(this);
903
+ },
904
+ onVisible: function () {},
905
+ onHide: function () {},
906
+ onHidden: function () {},
907
+ onBeforeHide: function (callback) {
908
+ callback.call(this);
909
+ },
910
+
911
+ // whether timeout should be used to ensure callback fires in cases animationend does not
912
+ useFailSafe: true,
913
+
914
+ // delay in ms for fail-safe
915
+ failSafeDelay: 100,
916
+
917
+ // whether EXACT animation can occur twice in a row
918
+ allowRepeats: false,
919
+
920
+ // Override the final display type on visible
921
+ displayType: false,
922
+
923
+ // animation duration
924
+ animation: 'fade',
925
+ duration: false,
926
+
927
+ // new animations will occur after previous ones
928
+ queue: true,
929
+
930
+ // whether initially inline hidden objects should be skipped for transition
931
+ skipInlineHidden: false,
932
+
933
+ metadata: {
934
+ displayType: 'display',
935
+ },
936
+
937
+ className: {
938
+ animating: 'animating',
939
+ disabled: 'disabled',
940
+ hidden: 'hidden',
941
+ inward: 'in',
942
+ loading: 'loading',
943
+ looping: 'looping',
944
+ outward: 'out',
945
+ transition: 'transition',
946
+ visible: 'visible',
947
+ },
948
+
949
+ // possible errors
950
+ error: {
951
+ noAnimation: 'Element is no longer attached to DOM. Unable to animate. Use silent setting to suppress this warning in production.',
952
+ },
953
+
954
+ };
955
+ })(jQuery, window, document);