rails-active-ui 0.2.2 → 0.3.1

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