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,797 @@
1
+ /*!
2
+ * # Fomantic-UI 2.9.4 - Shape
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.shape = function (parameters) {
23
+ var
24
+ $allModules = $(this),
25
+
26
+ time = Date.now(),
27
+ performance = [],
28
+
29
+ query = arguments[0],
30
+ methodInvoked = typeof query === 'string',
31
+ queryArguments = [].slice.call(arguments, 1),
32
+
33
+ returnedValue
34
+ ;
35
+
36
+ $allModules.each(function () {
37
+ var
38
+ settings = $.isPlainObject(parameters)
39
+ ? $.extend(true, {}, $.fn.shape.settings, parameters)
40
+ : $.extend({}, $.fn.shape.settings),
41
+
42
+ // internal aliases
43
+ namespace = settings.namespace,
44
+ selector = settings.selector,
45
+ error = settings.error,
46
+ className = settings.className,
47
+
48
+ // define namespaces for modules
49
+ eventNamespace = '.' + namespace,
50
+ moduleNamespace = 'module-' + namespace,
51
+
52
+ // selector cache
53
+ $module = $(this),
54
+ $sides = $module.find('>' + selector.sides),
55
+ $side = $sides.find('>' + selector.side),
56
+
57
+ // private variables
58
+ nextIndex = false,
59
+ $activeSide,
60
+ $nextSide,
61
+
62
+ // standard module
63
+ element = this,
64
+ instance = $module.data(moduleNamespace),
65
+ module
66
+ ;
67
+
68
+ module = {
69
+
70
+ initialize: function () {
71
+ module.verbose('Initializing module for', element);
72
+ module.set.defaultSide();
73
+ module.instantiate();
74
+ },
75
+
76
+ instantiate: function () {
77
+ module.verbose('Storing instance of module', module);
78
+ instance = module;
79
+ $module
80
+ .data(moduleNamespace, instance)
81
+ ;
82
+ },
83
+
84
+ destroy: function () {
85
+ module.verbose('Destroying previous module for', element);
86
+ $module
87
+ .removeData(moduleNamespace)
88
+ .off(eventNamespace)
89
+ ;
90
+ },
91
+
92
+ refresh: function () {
93
+ module.verbose('Refreshing selector cache for', element);
94
+ $module = $(element);
95
+ $sides = $(this).find(selector.sides);
96
+ $side = $(this).find(selector.side);
97
+ },
98
+
99
+ repaint: function () {
100
+ module.verbose('Forcing repaint event');
101
+ var
102
+ shape = $sides[0] || document.createElement('div'),
103
+ fakeAssignment = shape.offsetWidth
104
+ ;
105
+ },
106
+
107
+ animate: function (propertyObject, callback) {
108
+ module.verbose('Animating box with properties', propertyObject);
109
+ callback = callback || function (event) {
110
+ module.verbose('Executing animation callback');
111
+ if (event !== undefined) {
112
+ event.stopPropagation();
113
+ }
114
+ module.reset();
115
+ module.set.active();
116
+ };
117
+ settings.onBeforeChange.call($nextSide[0]);
118
+ module.verbose('Starting CSS animation');
119
+ $module
120
+ .addClass(className.animating)
121
+ ;
122
+ $sides
123
+ .css(propertyObject)
124
+ .one('transitionend', callback)
125
+ ;
126
+ module.set.duration(settings.duration);
127
+ requestAnimationFrame(function () {
128
+ $module
129
+ .addClass(className.animating)
130
+ ;
131
+ $activeSide
132
+ .addClass(className.hidden)
133
+ ;
134
+ });
135
+ },
136
+
137
+ queue: function (method) {
138
+ module.debug('Queueing animation of', method);
139
+ $sides
140
+ .one('transitionend', function () {
141
+ module.debug('Executing queued animation');
142
+ setTimeout(function () {
143
+ $module.shape(method);
144
+ }, 0);
145
+ })
146
+ ;
147
+ },
148
+
149
+ reset: function () {
150
+ module.verbose('Animating states reset');
151
+ $module
152
+ .removeClass(className.animating)
153
+ .attr('style', '')
154
+ .removeAttr('style')
155
+ ;
156
+ // removeAttr style does not consistently work in safari
157
+ $sides
158
+ .attr('style', '')
159
+ .removeAttr('style')
160
+ ;
161
+ $side
162
+ .attr('style', '')
163
+ .removeAttr('style')
164
+ .removeClass(className.hidden)
165
+ ;
166
+ $nextSide
167
+ .removeClass(className.animating)
168
+ .attr('style', '')
169
+ .removeAttr('style')
170
+ ;
171
+ },
172
+
173
+ is: {
174
+ complete: function () {
175
+ return $side.filter('.' + className.active)[0] === $nextSide[0];
176
+ },
177
+ animating: function () {
178
+ return $module.hasClass(className.animating);
179
+ },
180
+ hidden: function () {
181
+ return $module.closest(':hidden').length > 0;
182
+ },
183
+ },
184
+
185
+ set: {
186
+
187
+ defaultSide: function () {
188
+ $activeSide = $side.filter('.' + className.active);
189
+ $nextSide = $activeSide.next(selector.side).length > 0
190
+ ? $activeSide.next(selector.side)
191
+ : $side.first();
192
+ nextIndex = false;
193
+ module.verbose('Active side set to', $activeSide);
194
+ module.verbose('Next side set to', $nextSide);
195
+ },
196
+
197
+ duration: function (duration) {
198
+ duration = duration || settings.duration;
199
+ duration = typeof duration === 'number'
200
+ ? duration + 'ms'
201
+ : duration;
202
+ module.verbose('Setting animation duration', duration);
203
+ if (settings.duration || settings.duration === 0) {
204
+ $sides.add($side)
205
+ .css({
206
+ 'transition-duration': duration,
207
+ })
208
+ ;
209
+ }
210
+ },
211
+
212
+ currentStageSize: function () {
213
+ var
214
+ $activeSide = $side.filter('.' + className.active),
215
+ width = $activeSide.outerWidth(true),
216
+ height = $activeSide.outerHeight(true)
217
+ ;
218
+ $module
219
+ .css({
220
+ width: width,
221
+ height: height,
222
+ })
223
+ ;
224
+ },
225
+
226
+ stageSize: function () {
227
+ var
228
+ $clone = $module.clone().addClass(className.loading),
229
+ $side = $clone.find('>' + selector.sides + '>' + selector.side),
230
+ $activeSide = $side.filter('.' + className.active),
231
+ $nextSide = nextIndex
232
+ ? $side.eq(nextIndex)
233
+ : ($activeSide.next(selector.side).length > 0
234
+ ? $activeSide.next(selector.side)
235
+ : $side.first()),
236
+ newWidth = settings.width === 'next'
237
+ ? $nextSide.outerWidth(true)
238
+ : (settings.width === 'initial'
239
+ ? $module.width()
240
+ : settings.width),
241
+ newHeight = settings.height === 'next'
242
+ ? $nextSide.outerHeight(true)
243
+ : (settings.height === 'initial'
244
+ ? $module.height()
245
+ : settings.height)
246
+ ;
247
+ $activeSide.removeClass(className.active);
248
+ $nextSide.addClass(className.active);
249
+ $clone.insertAfter($module);
250
+ $clone.remove();
251
+ if (settings.width !== 'auto') {
252
+ $module.css('width', newWidth + settings.jitter);
253
+ module.verbose('Specifying width during animation', newWidth);
254
+ }
255
+ if (settings.height !== 'auto') {
256
+ $module.css('height', newHeight + settings.jitter);
257
+ module.verbose('Specifying height during animation', newHeight);
258
+ }
259
+ },
260
+
261
+ nextSide: function (selector) {
262
+ nextIndex = selector;
263
+ $nextSide = $side.filter(selector);
264
+ nextIndex = $side.index($nextSide);
265
+ if ($nextSide.length === 0) {
266
+ module.set.defaultSide();
267
+ module.error(error.side);
268
+ }
269
+ module.verbose('Next side manually set to', $nextSide);
270
+ },
271
+
272
+ active: function () {
273
+ module.verbose('Setting new side to active', $nextSide);
274
+ $side
275
+ .removeClass(className.active)
276
+ ;
277
+ $nextSide
278
+ .addClass(className.active)
279
+ ;
280
+ settings.onChange.call($nextSide[0]);
281
+ module.set.defaultSide();
282
+ },
283
+ },
284
+
285
+ flip: {
286
+ to: function (type, stage) {
287
+ if (module.is.hidden()) {
288
+ module.debug('Module not visible', $nextSide);
289
+
290
+ return;
291
+ }
292
+ if (module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
293
+ module.debug('Side already visible', $nextSide);
294
+
295
+ return;
296
+ }
297
+ var
298
+ transform = module.get.transform[type]()
299
+ ;
300
+ if (!module.is.animating()) {
301
+ module.debug('Flipping ' + type, $nextSide);
302
+ module.set.stageSize();
303
+ module.stage[stage]();
304
+ module.animate(transform);
305
+ } else {
306
+ module.queue('flip ' + type);
307
+ }
308
+ },
309
+
310
+ up: function () {
311
+ module.flip.to('up', 'above');
312
+ },
313
+
314
+ down: function () {
315
+ module.flip.to('down', 'below');
316
+ },
317
+
318
+ left: function () {
319
+ module.flip.to('left', 'left');
320
+ },
321
+
322
+ right: function () {
323
+ module.flip.to('right', 'right');
324
+ },
325
+
326
+ over: function () {
327
+ module.flip.to('over', 'behind');
328
+ },
329
+
330
+ back: function () {
331
+ module.flip.to('back', 'behind');
332
+ },
333
+
334
+ },
335
+
336
+ get: {
337
+
338
+ transform: {
339
+ up: function () {
340
+ var
341
+ translateZ = $activeSide.outerHeight(true) / 2,
342
+ translateY = $nextSide.outerHeight(true) - translateZ
343
+ ;
344
+
345
+ return {
346
+ transform: 'translateY(' + translateY + 'px) translateZ(-' + translateZ + 'px) rotateX(-90deg)',
347
+ };
348
+ },
349
+
350
+ down: function () {
351
+ var
352
+ translate = {
353
+ z: $activeSide.outerHeight(true) / 2,
354
+ }
355
+ ;
356
+
357
+ return {
358
+ transform: 'translateY(-' + translate.z + 'px) translateZ(-' + translate.z + 'px) rotateX(90deg)',
359
+ };
360
+ },
361
+
362
+ left: function () {
363
+ var
364
+ translateZ = $activeSide.outerWidth(true) / 2,
365
+ translateX = $nextSide.outerWidth(true) - translateZ
366
+ ;
367
+
368
+ return {
369
+ transform: 'translateX(' + translateX + 'px) translateZ(-' + translateZ + 'px) rotateY(90deg)',
370
+ };
371
+ },
372
+
373
+ right: function () {
374
+ var
375
+ translate = {
376
+ z: $activeSide.outerWidth(true) / 2,
377
+ }
378
+ ;
379
+
380
+ return {
381
+ transform: 'translateX(-' + translate.z + 'px) translateZ(-' + translate.z + 'px) rotateY(-90deg)',
382
+ };
383
+ },
384
+
385
+ over: function () {
386
+ var
387
+ translate = {
388
+ x: -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
389
+ }
390
+ ;
391
+
392
+ return {
393
+ transform: 'translateX(' + translate.x + 'px) rotateY(180deg)',
394
+ };
395
+ },
396
+
397
+ back: function () {
398
+ var
399
+ translate = {
400
+ x: -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
401
+ }
402
+ ;
403
+
404
+ return {
405
+ transform: 'translateX(' + translate.x + 'px) rotateY(-180deg)',
406
+ };
407
+ },
408
+ },
409
+
410
+ nextSide: function () {
411
+ return $activeSide.next(selector.side).length > 0
412
+ ? $activeSide.next(selector.side)
413
+ : $side.first();
414
+ },
415
+
416
+ },
417
+
418
+ stage: {
419
+
420
+ above: function () {
421
+ var
422
+ box = {
423
+ origin: ($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2,
424
+ depth: {
425
+ active: $nextSide.outerHeight(true) / 2,
426
+ next: $activeSide.outerHeight(true) / 2,
427
+ },
428
+ }
429
+ ;
430
+ module.verbose('Setting the initial animation position as above', $nextSide, box);
431
+ $activeSide
432
+ .css({
433
+ transform: 'rotateX(0deg)',
434
+ })
435
+ ;
436
+ $nextSide
437
+ .addClass(className.animating)
438
+ .css({
439
+ top: box.origin + 'px',
440
+ transform: 'rotateX(90deg) translateZ(' + box.depth.next + 'px) translateY(-' + box.depth.active + 'px)',
441
+ })
442
+ ;
443
+ },
444
+
445
+ below: function () {
446
+ var
447
+ box = {
448
+ origin: ($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2,
449
+ depth: {
450
+ active: $nextSide.outerHeight(true) / 2,
451
+ next: $activeSide.outerHeight(true) / 2,
452
+ },
453
+ }
454
+ ;
455
+ module.verbose('Setting the initial animation position as below', $nextSide, box);
456
+ $activeSide
457
+ .css({
458
+ transform: 'rotateX(0deg)',
459
+ })
460
+ ;
461
+ $nextSide
462
+ .addClass(className.animating)
463
+ .css({
464
+ top: box.origin + 'px',
465
+ transform: 'rotateX(-90deg) translateZ(' + box.depth.next + 'px) translateY(' + box.depth.active + 'px)',
466
+ })
467
+ ;
468
+ },
469
+
470
+ left: function () {
471
+ var
472
+ height = {
473
+ active: $activeSide.outerWidth(true),
474
+ next: $nextSide.outerWidth(true),
475
+ },
476
+ box = {
477
+ origin: (height.active - height.next) / 2,
478
+ depth: {
479
+ active: height.next / 2,
480
+ next: height.active / 2,
481
+ },
482
+ }
483
+ ;
484
+ module.verbose('Setting the initial animation position as left', $nextSide, box);
485
+ $activeSide
486
+ .css({
487
+ transform: 'rotateY(0deg)',
488
+ })
489
+ ;
490
+ $nextSide
491
+ .addClass(className.animating)
492
+ .css({
493
+ left: box.origin + 'px',
494
+ transform: 'rotateY(-90deg) translateZ(' + box.depth.next + 'px) translateX(-' + box.depth.active + 'px)',
495
+ })
496
+ ;
497
+ },
498
+
499
+ right: function () {
500
+ var
501
+ height = {
502
+ active: $activeSide.outerWidth(true),
503
+ next: $nextSide.outerWidth(true),
504
+ },
505
+ box = {
506
+ origin: (height.active - height.next) / 2,
507
+ depth: {
508
+ active: height.next / 2,
509
+ next: height.active / 2,
510
+ },
511
+ }
512
+ ;
513
+ module.verbose('Setting the initial animation position as right', $nextSide, box);
514
+ $activeSide
515
+ .css({
516
+ transform: 'rotateY(0deg)',
517
+ })
518
+ ;
519
+ $nextSide
520
+ .addClass(className.animating)
521
+ .css({
522
+ left: box.origin + 'px',
523
+ transform: 'rotateY(90deg) translateZ(' + box.depth.next + 'px) translateX(' + box.depth.active + 'px)',
524
+ })
525
+ ;
526
+ },
527
+
528
+ behind: function () {
529
+ var
530
+ height = {
531
+ active: $activeSide.outerWidth(true),
532
+ next: $nextSide.outerWidth(true),
533
+ },
534
+ box = {
535
+ origin: (height.active - height.next) / 2,
536
+ depth: {
537
+ active: height.next / 2,
538
+ next: height.active / 2,
539
+ },
540
+ }
541
+ ;
542
+ module.verbose('Setting the initial animation position as behind', $nextSide, box);
543
+ $activeSide
544
+ .css({
545
+ transform: 'rotateY(0deg)',
546
+ })
547
+ ;
548
+ $nextSide
549
+ .addClass(className.animating)
550
+ .css({
551
+ left: box.origin + 'px',
552
+ transform: 'rotateY(-180deg)',
553
+ })
554
+ ;
555
+ },
556
+ },
557
+ setting: function (name, value) {
558
+ module.debug('Changing setting', name, value);
559
+ if ($.isPlainObject(name)) {
560
+ $.extend(true, settings, name);
561
+ } else if (value !== undefined) {
562
+ if ($.isPlainObject(settings[name])) {
563
+ $.extend(true, settings[name], value);
564
+ } else {
565
+ settings[name] = value;
566
+ }
567
+ } else {
568
+ return settings[name];
569
+ }
570
+ },
571
+ internal: function (name, value) {
572
+ if ($.isPlainObject(name)) {
573
+ $.extend(true, module, name);
574
+ } else if (value !== undefined) {
575
+ module[name] = value;
576
+ } else {
577
+ return module[name];
578
+ }
579
+ },
580
+ debug: function () {
581
+ if (!settings.silent && settings.debug) {
582
+ if (settings.performance) {
583
+ module.performance.log(arguments);
584
+ } else {
585
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
586
+ module.debug.apply(console, arguments);
587
+ }
588
+ }
589
+ },
590
+ verbose: function () {
591
+ if (!settings.silent && settings.verbose && settings.debug) {
592
+ if (settings.performance) {
593
+ module.performance.log(arguments);
594
+ } else {
595
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
596
+ module.verbose.apply(console, arguments);
597
+ }
598
+ }
599
+ },
600
+ error: function () {
601
+ if (!settings.silent) {
602
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
603
+ module.error.apply(console, arguments);
604
+ }
605
+ },
606
+ performance: {
607
+ log: function (message) {
608
+ var
609
+ currentTime,
610
+ executionTime,
611
+ previousTime
612
+ ;
613
+ if (settings.performance) {
614
+ currentTime = Date.now();
615
+ previousTime = time || currentTime;
616
+ executionTime = currentTime - previousTime;
617
+ time = currentTime;
618
+ performance.push({
619
+ Name: message[0],
620
+ Arguments: [].slice.call(message, 1) || '',
621
+ Element: element,
622
+ 'Execution Time': executionTime,
623
+ });
624
+ }
625
+ clearTimeout(module.performance.timer);
626
+ module.performance.timer = setTimeout(function () {
627
+ module.performance.display();
628
+ }, 500);
629
+ },
630
+ display: function () {
631
+ var
632
+ title = settings.name + ':',
633
+ totalTime = 0
634
+ ;
635
+ time = false;
636
+ clearTimeout(module.performance.timer);
637
+ $.each(performance, function (index, data) {
638
+ totalTime += data['Execution Time'];
639
+ });
640
+ title += ' ' + totalTime + 'ms';
641
+ if ($allModules.length > 1) {
642
+ title += ' (' + $allModules.length + ')';
643
+ }
644
+ if (performance.length > 0) {
645
+ console.groupCollapsed(title);
646
+ if (console.table) {
647
+ console.table(performance);
648
+ } else {
649
+ $.each(performance, function (index, data) {
650
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
651
+ });
652
+ }
653
+ console.groupEnd();
654
+ }
655
+ performance = [];
656
+ },
657
+ },
658
+ invoke: function (query, passedArguments, context) {
659
+ var
660
+ object = instance,
661
+ maxDepth,
662
+ found,
663
+ response
664
+ ;
665
+ passedArguments = passedArguments || queryArguments;
666
+ context = context || element;
667
+ if (typeof query === 'string' && object !== undefined) {
668
+ query = query.split(/[ .]/);
669
+ maxDepth = query.length - 1;
670
+ $.each(query, function (depth, value) {
671
+ var camelCaseValue = depth !== maxDepth
672
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
673
+ : query
674
+ ;
675
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
676
+ object = object[camelCaseValue];
677
+ } else if (object[camelCaseValue] !== undefined) {
678
+ found = object[camelCaseValue];
679
+
680
+ return false;
681
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
682
+ object = object[value];
683
+ } else if (object[value] !== undefined) {
684
+ found = object[value];
685
+
686
+ return false;
687
+ } else {
688
+ module.error(error.method, query);
689
+
690
+ return false;
691
+ }
692
+ });
693
+ }
694
+ if (isFunction(found)) {
695
+ response = found.apply(context, passedArguments);
696
+ } else if (found !== undefined) {
697
+ response = found;
698
+ }
699
+ if (Array.isArray(returnedValue)) {
700
+ returnedValue.push(response);
701
+ } else if (returnedValue !== undefined) {
702
+ returnedValue = [returnedValue, response];
703
+ } else if (response !== undefined) {
704
+ returnedValue = response;
705
+ }
706
+
707
+ return found;
708
+ },
709
+ };
710
+
711
+ if (methodInvoked) {
712
+ if (instance === undefined) {
713
+ module.initialize();
714
+ }
715
+ var $inputs = $module.find('input');
716
+ if ($inputs.length > 0) {
717
+ $inputs.trigger('blur');
718
+ setTimeout(function () {
719
+ module.invoke(query);
720
+ }, 150);
721
+ } else {
722
+ module.invoke(query);
723
+ }
724
+ } else {
725
+ if (instance !== undefined) {
726
+ instance.invoke('destroy');
727
+ }
728
+ module.initialize();
729
+ }
730
+ });
731
+
732
+ return returnedValue !== undefined
733
+ ? returnedValue
734
+ : this;
735
+ };
736
+
737
+ $.fn.shape.settings = {
738
+
739
+ // module info
740
+ name: 'Shape',
741
+
742
+ // hide all debug content
743
+ silent: false,
744
+
745
+ // debug content outputted to console
746
+ debug: false,
747
+
748
+ // verbose debug output
749
+ verbose: false,
750
+
751
+ // fudge factor in pixels when swapping from 2d to 3d (can be useful to correct rounding errors)
752
+ jitter: 0,
753
+
754
+ // performance data output
755
+ performance: true,
756
+
757
+ // event namespace
758
+ namespace: 'shape',
759
+
760
+ // width during animation, can be set to 'auto', initial', 'next' or pixel amount
761
+ width: 'initial',
762
+
763
+ // height during animation, can be set to 'auto', 'initial', 'next' or pixel amount
764
+ height: 'initial',
765
+
766
+ // callback occurs on side change
767
+ onBeforeChange: function () {},
768
+ onChange: function () {},
769
+
770
+ // allow animation to same side
771
+ allowRepeats: false,
772
+
773
+ // animation duration
774
+ duration: false,
775
+
776
+ // possible errors
777
+ error: {
778
+ side: 'You tried to switch to a side that does not exist.',
779
+ method: 'The method you called is not defined',
780
+ },
781
+
782
+ // classnames used
783
+ className: {
784
+ animating: 'animating',
785
+ hidden: 'hidden',
786
+ loading: 'loading',
787
+ active: 'active',
788
+ },
789
+
790
+ // selectors used
791
+ selector: {
792
+ sides: '.sides',
793
+ side: '.side',
794
+ },
795
+
796
+ };
797
+ })(jQuery, window, document);