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,732 @@
1
+ /*!
2
+ * # Fomantic-UI 2.9.4 - Dimmer
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.dimmer = 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.dimmer.settings, parameters)
40
+ : $.extend({}, $.fn.dimmer.settings),
41
+
42
+ selector = settings.selector,
43
+ namespace = settings.namespace,
44
+ className = settings.className,
45
+ error = settings.error,
46
+
47
+ eventNamespace = '.' + namespace,
48
+ moduleNamespace = 'module-' + namespace,
49
+
50
+ clickEvent = 'ontouchstart' in document.documentElement
51
+ ? 'touchstart'
52
+ : 'click',
53
+
54
+ $module = $(this),
55
+ $dimmer,
56
+ $dimmable,
57
+
58
+ element = this,
59
+ instance = $module.data(moduleNamespace),
60
+ module
61
+ ;
62
+
63
+ module = {
64
+
65
+ preinitialize: function () {
66
+ if (module.is.dimmer()) {
67
+ $dimmable = $module.parent();
68
+ $dimmer = $module;
69
+ } else {
70
+ $dimmable = $module;
71
+ if (module.has.dimmer()) {
72
+ $dimmer = settings.dimmerName
73
+ ? $dimmable.find(selector.dimmer).filter('.' + settings.dimmerName)
74
+ : $dimmable.find(selector.dimmer);
75
+ } else {
76
+ $dimmer = module.create();
77
+ }
78
+ }
79
+ },
80
+
81
+ initialize: function () {
82
+ module.debug('Initializing dimmer', settings);
83
+
84
+ module.bind.events();
85
+ module.set.dimmable();
86
+ module.instantiate();
87
+ },
88
+
89
+ instantiate: function () {
90
+ module.verbose('Storing instance of module', module);
91
+ instance = module;
92
+ $module
93
+ .data(moduleNamespace, instance)
94
+ ;
95
+ },
96
+
97
+ destroy: function () {
98
+ module.verbose('Destroying previous module', $dimmer);
99
+ module.unbind.events();
100
+ module.remove.variation();
101
+ $dimmable
102
+ .off(eventNamespace)
103
+ ;
104
+ },
105
+
106
+ bind: {
107
+ events: function () {
108
+ if (settings.on === 'hover') {
109
+ $dimmable
110
+ .on('mouseenter' + eventNamespace, module.show)
111
+ .on('mouseleave' + eventNamespace, module.hide)
112
+ ;
113
+ } else if (settings.on === 'click') {
114
+ $dimmable
115
+ .on(clickEvent + eventNamespace, module.toggle)
116
+ ;
117
+ }
118
+ if (module.is.page()) {
119
+ module.debug('Setting as a page dimmer', $dimmable);
120
+ module.set.pageDimmer();
121
+ }
122
+
123
+ if (module.is.closable()) {
124
+ module.verbose('Adding dimmer close event', $dimmer);
125
+ $dimmable
126
+ .on(clickEvent + eventNamespace, selector.dimmer, module.event.click)
127
+ ;
128
+ }
129
+ },
130
+ },
131
+
132
+ unbind: {
133
+ events: function () {
134
+ $module
135
+ .removeData(moduleNamespace)
136
+ ;
137
+ $dimmable
138
+ .off(eventNamespace)
139
+ ;
140
+ },
141
+ },
142
+
143
+ event: {
144
+ click: function (event) {
145
+ module.verbose('Determining if event occurred on dimmer', event);
146
+ if ($dimmer.find(event.target).length === 0 || $(event.target).is(selector.content)) {
147
+ module.hide();
148
+ event.stopImmediatePropagation();
149
+ }
150
+ },
151
+ },
152
+
153
+ addContent: function (element) {
154
+ var
155
+ $content = $(element)
156
+ ;
157
+ module.debug('Add content to dimmer', $content);
158
+ if ($content.parent()[0] !== $dimmer[0]) {
159
+ $content.detach().appendTo($dimmer);
160
+ }
161
+ },
162
+
163
+ create: function () {
164
+ var
165
+ $element = $(settings.template.dimmer(settings))
166
+ ;
167
+ if (settings.dimmerName) {
168
+ module.debug('Creating named dimmer', settings.dimmerName);
169
+ $element.addClass(settings.dimmerName);
170
+ }
171
+ $element
172
+ .appendTo($dimmable)
173
+ ;
174
+
175
+ return $element;
176
+ },
177
+
178
+ show: function (callback) {
179
+ callback = isFunction(callback)
180
+ ? callback
181
+ : function () {};
182
+ if ((!module.is.dimmed() || module.is.animating()) && module.is.enabled()) {
183
+ if (settings.onShow.call(element) === false) {
184
+ module.verbose('Show callback returned false cancelling dimmer show');
185
+
186
+ return;
187
+ }
188
+ module.debug('Showing dimmer', $dimmer, settings);
189
+ module.set.variation();
190
+ module.animate.show(callback);
191
+ settings.onChange.call(element);
192
+ } else {
193
+ module.debug('Dimmer is already shown or disabled');
194
+ }
195
+ },
196
+
197
+ hide: function (callback) {
198
+ callback = isFunction(callback)
199
+ ? callback
200
+ : function () {};
201
+ if (module.is.dimmed() || module.is.animating()) {
202
+ if (settings.onHide.call(element) === false) {
203
+ module.verbose('Hide callback returned false cancelling dimmer hide');
204
+
205
+ return;
206
+ }
207
+ module.debug('Hiding dimmer', $dimmer);
208
+ module.animate.hide(callback);
209
+ settings.onChange.call(element);
210
+ } else {
211
+ module.debug('Dimmer is not visible');
212
+ }
213
+ },
214
+
215
+ toggle: function () {
216
+ module.verbose('Toggling dimmer visibility', $dimmer);
217
+ if (!module.is.dimmed()) {
218
+ module.show();
219
+ } else {
220
+ if (module.is.closable()) {
221
+ module.hide();
222
+ }
223
+ }
224
+ },
225
+
226
+ animate: {
227
+ show: function (callback) {
228
+ callback = isFunction(callback)
229
+ ? callback
230
+ : function () {};
231
+ if (settings.useCSS && $.fn.transition !== undefined) {
232
+ if (settings.useFlex) {
233
+ module.debug('Using flex dimmer');
234
+ module.remove.legacy();
235
+ } else {
236
+ module.debug('Using legacy non-flex dimmer');
237
+ module.set.legacy();
238
+ }
239
+ if (settings.opacity !== 'auto') {
240
+ module.set.opacity();
241
+ }
242
+ $dimmer
243
+ .transition({
244
+ debug: settings.debug,
245
+ verbose: settings.verbose,
246
+ silent: settings.silent,
247
+ displayType: settings.useFlex
248
+ ? 'flex'
249
+ : 'block',
250
+ animation: (settings.transition.showMethod || settings.transition) + ' in',
251
+ queue: false,
252
+ duration: module.get.duration(),
253
+ useFailSafe: true,
254
+ onStart: function () {
255
+ module.set.dimmed();
256
+ },
257
+ onComplete: function () {
258
+ module.set.active();
259
+ settings.onVisible.call($dimmer);
260
+ callback();
261
+ },
262
+ })
263
+ ;
264
+ } else {
265
+ module.verbose('Showing dimmer animation with javascript');
266
+ module.set.dimmed();
267
+ if (settings.opacity === 'auto') {
268
+ settings.opacity = 0.8;
269
+ }
270
+ $dimmer
271
+ .stop()
272
+ .css({
273
+ opacity: 0,
274
+ width: '100%',
275
+ height: '100%',
276
+ })
277
+ .fadeTo(module.get.duration(), settings.opacity, function () {
278
+ $dimmer.removeAttr('style');
279
+ module.set.active();
280
+ settings.onVisible.call($dimmer);
281
+ callback();
282
+ })
283
+ ;
284
+ }
285
+ },
286
+ hide: function (callback) {
287
+ callback = isFunction(callback)
288
+ ? callback
289
+ : function () {};
290
+ if (settings.useCSS && $.fn.transition !== undefined) {
291
+ module.verbose('Hiding dimmer with css');
292
+ $dimmer
293
+ .transition({
294
+ debug: settings.debug,
295
+ verbose: settings.verbose,
296
+ silent: settings.silent,
297
+ displayType: settings.useFlex
298
+ ? 'flex'
299
+ : 'block',
300
+ animation: (settings.transition.hideMethod || settings.transition) + ' out',
301
+ queue: false,
302
+ duration: module.get.duration(),
303
+ useFailSafe: true,
304
+ onComplete: function () {
305
+ module.remove.dimmed();
306
+ module.remove.variation();
307
+ module.remove.active();
308
+ settings.onHidden.call($dimmer);
309
+ callback();
310
+ },
311
+ })
312
+ ;
313
+ } else {
314
+ module.verbose('Hiding dimmer with javascript');
315
+ $dimmer
316
+ .stop()
317
+ .fadeOut(module.get.duration(), function () {
318
+ module.remove.dimmed();
319
+ module.remove.active();
320
+ $dimmer.removeAttr('style');
321
+ settings.onHidden.call($dimmer);
322
+ callback();
323
+ })
324
+ ;
325
+ }
326
+ },
327
+ },
328
+
329
+ get: {
330
+ dimmer: function () {
331
+ return $dimmer;
332
+ },
333
+ duration: function () {
334
+ if (module.is.active()) {
335
+ return settings.transition.hideDuration || settings.duration.hide || settings.duration;
336
+ }
337
+
338
+ return settings.transition.showDuration || settings.duration.show || settings.duration;
339
+ },
340
+ },
341
+
342
+ has: {
343
+ dimmer: function () {
344
+ if (settings.dimmerName) {
345
+ return $module.find(selector.dimmer).filter('.' + settings.dimmerName).length > 0;
346
+ }
347
+
348
+ return $module.find(selector.dimmer).length > 0;
349
+ },
350
+ },
351
+
352
+ is: {
353
+ active: function () {
354
+ return $dimmer.hasClass(className.active);
355
+ },
356
+ animating: function () {
357
+ return $dimmer.is(':animated') || $dimmer.hasClass(className.animating);
358
+ },
359
+ closable: function () {
360
+ if (settings.closable === 'auto') {
361
+ return settings.on !== 'hover';
362
+ }
363
+
364
+ return settings.closable;
365
+ },
366
+ dimmer: function () {
367
+ return $module.hasClass(className.dimmer);
368
+ },
369
+ dimmable: function () {
370
+ return $module.hasClass(className.dimmable);
371
+ },
372
+ dimmed: function () {
373
+ return $dimmable.hasClass(className.dimmed);
374
+ },
375
+ disabled: function () {
376
+ return $dimmable.hasClass(className.disabled);
377
+ },
378
+ enabled: function () {
379
+ return !module.is.disabled();
380
+ },
381
+ page: function () {
382
+ return $dimmable.is('body');
383
+ },
384
+ pageDimmer: function () {
385
+ return $dimmer.hasClass(className.pageDimmer);
386
+ },
387
+ },
388
+
389
+ can: {
390
+ show: function () {
391
+ return !$dimmer.hasClass(className.disabled);
392
+ },
393
+ },
394
+
395
+ set: {
396
+ opacity: function (opacity) {
397
+ var
398
+ color = $dimmer.css('background-color'),
399
+ colorArray = color.split(','),
400
+ isRGB = colorArray && colorArray.length >= 3
401
+ ;
402
+ opacity = settings.opacity === 0 ? 0 : settings.opacity || opacity;
403
+ if (isRGB) {
404
+ colorArray[2] = colorArray[2].replace(')', '');
405
+ colorArray[3] = opacity + ')';
406
+ color = colorArray.join(',');
407
+ } else {
408
+ color = 'rgba(0, 0, 0, ' + opacity + ')';
409
+ }
410
+ module.debug('Setting opacity to', opacity);
411
+ $dimmer.css('background-color', color);
412
+ },
413
+ legacy: function () {
414
+ $dimmer.addClass(className.legacy);
415
+ },
416
+ active: function () {
417
+ $dimmer.addClass(className.active);
418
+ },
419
+ dimmable: function () {
420
+ $dimmable.addClass(className.dimmable);
421
+ },
422
+ dimmed: function () {
423
+ $dimmable.addClass(className.dimmed);
424
+ },
425
+ pageDimmer: function () {
426
+ $dimmer.addClass(className.pageDimmer);
427
+ },
428
+ disabled: function () {
429
+ $dimmer.addClass(className.disabled);
430
+ },
431
+ variation: function (variation) {
432
+ variation = variation || settings.variation;
433
+ if (variation) {
434
+ $dimmer.addClass(variation);
435
+ }
436
+ },
437
+ },
438
+
439
+ remove: {
440
+ active: function () {
441
+ $dimmer
442
+ .removeClass(className.active)
443
+ ;
444
+ },
445
+ legacy: function () {
446
+ $dimmer.removeClass(className.legacy);
447
+ },
448
+ dimmed: function () {
449
+ $dimmable.removeClass(className.dimmed);
450
+ },
451
+ disabled: function () {
452
+ $dimmer.removeClass(className.disabled);
453
+ },
454
+ variation: function (variation) {
455
+ variation = variation || settings.variation;
456
+ if (variation) {
457
+ $dimmer.removeClass(variation);
458
+ }
459
+ },
460
+ },
461
+
462
+ setting: function (name, value) {
463
+ module.debug('Changing setting', name, value);
464
+ if ($.isPlainObject(name)) {
465
+ $.extend(true, settings, name);
466
+ } else if (value !== undefined) {
467
+ if ($.isPlainObject(settings[name])) {
468
+ $.extend(true, settings[name], value);
469
+ } else {
470
+ settings[name] = value;
471
+ }
472
+ } else {
473
+ return settings[name];
474
+ }
475
+ },
476
+ internal: function (name, value) {
477
+ if ($.isPlainObject(name)) {
478
+ $.extend(true, module, name);
479
+ } else if (value !== undefined) {
480
+ module[name] = value;
481
+ } else {
482
+ return module[name];
483
+ }
484
+ },
485
+ debug: function () {
486
+ if (!settings.silent && settings.debug) {
487
+ if (settings.performance) {
488
+ module.performance.log(arguments);
489
+ } else {
490
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
491
+ module.debug.apply(console, arguments);
492
+ }
493
+ }
494
+ },
495
+ verbose: function () {
496
+ if (!settings.silent && settings.verbose && settings.debug) {
497
+ if (settings.performance) {
498
+ module.performance.log(arguments);
499
+ } else {
500
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
501
+ module.verbose.apply(console, arguments);
502
+ }
503
+ }
504
+ },
505
+ error: function () {
506
+ if (!settings.silent) {
507
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
508
+ module.error.apply(console, arguments);
509
+ }
510
+ },
511
+ performance: {
512
+ log: function (message) {
513
+ var
514
+ currentTime,
515
+ executionTime,
516
+ previousTime
517
+ ;
518
+ if (settings.performance) {
519
+ currentTime = Date.now();
520
+ previousTime = time || currentTime;
521
+ executionTime = currentTime - previousTime;
522
+ time = currentTime;
523
+ performance.push({
524
+ Name: message[0],
525
+ Arguments: [].slice.call(message, 1) || '',
526
+ Element: element,
527
+ 'Execution Time': executionTime,
528
+ });
529
+ }
530
+ clearTimeout(module.performance.timer);
531
+ module.performance.timer = setTimeout(function () {
532
+ module.performance.display();
533
+ }, 500);
534
+ },
535
+ display: function () {
536
+ var
537
+ title = settings.name + ':',
538
+ totalTime = 0
539
+ ;
540
+ time = false;
541
+ clearTimeout(module.performance.timer);
542
+ $.each(performance, function (index, data) {
543
+ totalTime += data['Execution Time'];
544
+ });
545
+ title += ' ' + totalTime + 'ms';
546
+ if ($allModules.length > 1) {
547
+ title += ' (' + $allModules.length + ')';
548
+ }
549
+ if (performance.length > 0) {
550
+ console.groupCollapsed(title);
551
+ if (console.table) {
552
+ console.table(performance);
553
+ } else {
554
+ $.each(performance, function (index, data) {
555
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
556
+ });
557
+ }
558
+ console.groupEnd();
559
+ }
560
+ performance = [];
561
+ },
562
+ },
563
+ invoke: function (query, passedArguments, context) {
564
+ var
565
+ object = instance,
566
+ maxDepth,
567
+ found,
568
+ response
569
+ ;
570
+ passedArguments = passedArguments || queryArguments;
571
+ context = context || element;
572
+ if (typeof query === 'string' && object !== undefined) {
573
+ query = query.split(/[ .]/);
574
+ maxDepth = query.length - 1;
575
+ $.each(query, function (depth, value) {
576
+ var camelCaseValue = depth !== maxDepth
577
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
578
+ : query
579
+ ;
580
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
581
+ object = object[camelCaseValue];
582
+ } else if (object[camelCaseValue] !== undefined) {
583
+ found = object[camelCaseValue];
584
+
585
+ return false;
586
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
587
+ object = object[value];
588
+ } else if (object[value] !== undefined) {
589
+ found = object[value];
590
+
591
+ return false;
592
+ } else {
593
+ module.error(error.method, query);
594
+
595
+ return false;
596
+ }
597
+ });
598
+ }
599
+ if (isFunction(found)) {
600
+ response = found.apply(context, passedArguments);
601
+ } else if (found !== undefined) {
602
+ response = found;
603
+ }
604
+ if (Array.isArray(returnedValue)) {
605
+ returnedValue.push(response);
606
+ } else if (returnedValue !== undefined) {
607
+ returnedValue = [returnedValue, response];
608
+ } else if (response !== undefined) {
609
+ returnedValue = response;
610
+ }
611
+
612
+ return found;
613
+ },
614
+ };
615
+
616
+ module.preinitialize();
617
+
618
+ if (methodInvoked) {
619
+ if (instance === undefined) {
620
+ module.initialize();
621
+ }
622
+ module.invoke(query);
623
+ } else {
624
+ if (instance !== undefined) {
625
+ instance.invoke('destroy');
626
+ }
627
+ module.initialize();
628
+ }
629
+ });
630
+
631
+ return returnedValue !== undefined
632
+ ? returnedValue
633
+ : this;
634
+ };
635
+
636
+ $.fn.dimmer.settings = {
637
+
638
+ name: 'Dimmer',
639
+ namespace: 'dimmer',
640
+
641
+ silent: false,
642
+ debug: false,
643
+ verbose: false,
644
+ performance: true,
645
+
646
+ // whether should use flex layout
647
+ useFlex: true,
648
+
649
+ // name to distinguish between multiple dimmers in context
650
+ dimmerName: false,
651
+
652
+ // whether to add a variation type
653
+ variation: false,
654
+
655
+ // whether to bind close events
656
+ closable: 'auto',
657
+
658
+ // whether to use css animations
659
+ useCSS: true,
660
+
661
+ // css animation to use
662
+ transition: 'fade',
663
+
664
+ // event to bind to
665
+ on: false,
666
+
667
+ // overriding opacity value
668
+ opacity: 'auto',
669
+
670
+ // transition durations
671
+ duration: {
672
+ show: 500,
673
+ hide: 500,
674
+ },
675
+ // whether the dynamically created dimmer should have a loader
676
+ displayLoader: false,
677
+ loaderText: false,
678
+ loaderVariation: '',
679
+
680
+ onChange: function () {},
681
+ onShow: function () {},
682
+ onHide: function () {},
683
+ onVisible: function () {},
684
+ onHidden: function () {},
685
+
686
+ error: {
687
+ method: 'The method you called is not defined.',
688
+ },
689
+
690
+ className: {
691
+ active: 'active',
692
+ animating: 'animating',
693
+ dimmable: 'dimmable',
694
+ dimmed: 'dimmed',
695
+ dimmer: 'dimmer',
696
+ disabled: 'disabled',
697
+ hide: 'hide',
698
+ legacy: 'legacy',
699
+ pageDimmer: 'page',
700
+ show: 'show',
701
+ loader: 'ui loader',
702
+ },
703
+
704
+ selector: {
705
+ dimmer: '> .ui.dimmer',
706
+ content: '.ui.dimmer > .content, .ui.dimmer > .content > .center',
707
+ },
708
+
709
+ template: {
710
+ dimmer: function (settings) {
711
+ var
712
+ d = $('<div/>').addClass('ui dimmer'),
713
+ l
714
+ ;
715
+ if (settings.displayLoader) {
716
+ l = $('<div/>')
717
+ .addClass(settings.className.loader)
718
+ .addClass(settings.loaderVariation)
719
+ ;
720
+ if (settings.loaderText) {
721
+ l.text(settings.loaderText);
722
+ l.addClass('text');
723
+ }
724
+ d.append(l);
725
+ }
726
+
727
+ return d;
728
+ },
729
+ },
730
+
731
+ };
732
+ })(jQuery, window, document);