rails-active-ui 0.3.0 → 0.3.2

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 (197) hide show
  1. checksums.yaml +4 -4
  2. data/app/javascript/ui/controllers/turbo_modal_controller.js +36 -0
  3. data/config/importmap.rb +1 -0
  4. data/formantic-ui/components/accordion.css +369 -0
  5. data/formantic-ui/components/accordion.js +595 -0
  6. data/formantic-ui/components/accordion.min.css +9 -0
  7. data/formantic-ui/components/accordion.min.js +11 -0
  8. data/formantic-ui/components/ad.css +264 -0
  9. data/formantic-ui/components/ad.min.css +10 -0
  10. data/formantic-ui/components/api.js +1225 -0
  11. data/formantic-ui/components/api.min.js +11 -0
  12. data/formantic-ui/components/breadcrumb.css +135 -0
  13. data/formantic-ui/components/breadcrumb.min.css +9 -0
  14. data/formantic-ui/components/button.css +4058 -0
  15. data/formantic-ui/components/button.min.css +9 -0
  16. data/formantic-ui/components/calendar.css +327 -0
  17. data/formantic-ui/components/calendar.js +2045 -0
  18. data/formantic-ui/components/calendar.min.css +9 -0
  19. data/formantic-ui/components/calendar.min.js +11 -0
  20. data/formantic-ui/components/card.css +1881 -0
  21. data/formantic-ui/components/card.min.css +9 -0
  22. data/formantic-ui/components/checkbox.css +785 -0
  23. data/formantic-ui/components/checkbox.js +888 -0
  24. data/formantic-ui/components/checkbox.min.css +9 -0
  25. data/formantic-ui/components/checkbox.min.js +11 -0
  26. data/formantic-ui/components/comment.css +283 -0
  27. data/formantic-ui/components/comment.min.css +9 -0
  28. data/formantic-ui/components/container.css +300 -0
  29. data/formantic-ui/components/container.min.css +9 -0
  30. data/formantic-ui/components/dimmer.css +367 -0
  31. data/formantic-ui/components/dimmer.js +732 -0
  32. data/formantic-ui/components/dimmer.min.css +9 -0
  33. data/formantic-ui/components/dimmer.min.js +11 -0
  34. data/formantic-ui/components/divider.css +287 -0
  35. data/formantic-ui/components/divider.min.css +9 -0
  36. data/formantic-ui/components/dropdown.css +2087 -0
  37. data/formantic-ui/components/dropdown.js +4432 -0
  38. data/formantic-ui/components/dropdown.min.css +9 -0
  39. data/formantic-ui/components/dropdown.min.js +11 -0
  40. data/formantic-ui/components/embed.css +155 -0
  41. data/formantic-ui/components/embed.js +688 -0
  42. data/formantic-ui/components/embed.min.css +9 -0
  43. data/formantic-ui/components/embed.min.js +11 -0
  44. data/formantic-ui/components/emoji.css +15311 -0
  45. data/formantic-ui/components/emoji.min.css +9 -0
  46. data/formantic-ui/components/feed.css +799 -0
  47. data/formantic-ui/components/feed.min.css +9 -0
  48. data/formantic-ui/components/flag.css +1149 -0
  49. data/formantic-ui/components/flag.min.css +9 -0
  50. data/formantic-ui/components/flyout.css +546 -0
  51. data/formantic-ui/components/flyout.js +1551 -0
  52. data/formantic-ui/components/flyout.min.css +9 -0
  53. data/formantic-ui/components/flyout.min.js +11 -0
  54. data/formantic-ui/components/form.css +1885 -0
  55. data/formantic-ui/components/form.js +2199 -0
  56. data/formantic-ui/components/form.min.css +9 -0
  57. data/formantic-ui/components/form.min.js +11 -0
  58. data/formantic-ui/components/grid.css +1952 -0
  59. data/formantic-ui/components/grid.min.css +9 -0
  60. data/formantic-ui/components/header.css +778 -0
  61. data/formantic-ui/components/header.min.css +9 -0
  62. data/formantic-ui/components/icon.css +7066 -0
  63. data/formantic-ui/components/icon.min.css +9 -0
  64. data/formantic-ui/components/image.css +315 -0
  65. data/formantic-ui/components/image.min.css +9 -0
  66. data/formantic-ui/components/input.css +1566 -0
  67. data/formantic-ui/components/input.min.css +9 -0
  68. data/formantic-ui/components/item.css +534 -0
  69. data/formantic-ui/components/item.min.css +9 -0
  70. data/formantic-ui/components/label.css +2114 -0
  71. data/formantic-ui/components/label.min.css +9 -0
  72. data/formantic-ui/components/list.css +955 -0
  73. data/formantic-ui/components/list.min.css +9 -0
  74. data/formantic-ui/components/loader.css +787 -0
  75. data/formantic-ui/components/loader.min.css +9 -0
  76. data/formantic-ui/components/menu.css +2131 -0
  77. data/formantic-ui/components/menu.min.css +9 -0
  78. data/formantic-ui/components/message.css +619 -0
  79. data/formantic-ui/components/message.min.css +9 -0
  80. data/formantic-ui/components/modal.css +779 -0
  81. data/formantic-ui/components/modal.js +1637 -0
  82. data/formantic-ui/components/modal.min.css +9 -0
  83. data/formantic-ui/components/modal.min.js +11 -0
  84. data/formantic-ui/components/nag.css +290 -0
  85. data/formantic-ui/components/nag.js +566 -0
  86. data/formantic-ui/components/nag.min.css +9 -0
  87. data/formantic-ui/components/nag.min.js +11 -0
  88. data/formantic-ui/components/placeholder.css +228 -0
  89. data/formantic-ui/components/placeholder.min.css +9 -0
  90. data/formantic-ui/components/popup.css +1184 -0
  91. data/formantic-ui/components/popup.js +1561 -0
  92. data/formantic-ui/components/popup.min.css +9 -0
  93. data/formantic-ui/components/popup.min.js +11 -0
  94. data/formantic-ui/components/progress.css +761 -0
  95. data/formantic-ui/components/progress.js +979 -0
  96. data/formantic-ui/components/progress.min.css +9 -0
  97. data/formantic-ui/components/progress.min.js +11 -0
  98. data/formantic-ui/components/rail.css +147 -0
  99. data/formantic-ui/components/rail.min.css +9 -0
  100. data/formantic-ui/components/rating.css +414 -0
  101. data/formantic-ui/components/rating.js +540 -0
  102. data/formantic-ui/components/rating.min.css +9 -0
  103. data/formantic-ui/components/rating.min.js +11 -0
  104. data/formantic-ui/components/reset.css +386 -0
  105. data/formantic-ui/components/reset.min.css +9 -0
  106. data/formantic-ui/components/reveal.css +277 -0
  107. data/formantic-ui/components/reveal.min.css +9 -0
  108. data/formantic-ui/components/search.css +541 -0
  109. data/formantic-ui/components/search.js +1641 -0
  110. data/formantic-ui/components/search.min.css +9 -0
  111. data/formantic-ui/components/search.min.js +11 -0
  112. data/formantic-ui/components/segment.css +1053 -0
  113. data/formantic-ui/components/segment.min.css +9 -0
  114. data/formantic-ui/components/shape.css +144 -0
  115. data/formantic-ui/components/shape.js +797 -0
  116. data/formantic-ui/components/shape.min.css +9 -0
  117. data/formantic-ui/components/shape.min.js +11 -0
  118. data/formantic-ui/components/sidebar.css +539 -0
  119. data/formantic-ui/components/sidebar.js +1054 -0
  120. data/formantic-ui/components/sidebar.min.css +9 -0
  121. data/formantic-ui/components/sidebar.min.js +11 -0
  122. data/formantic-ui/components/site.css +286 -0
  123. data/formantic-ui/components/site.js +455 -0
  124. data/formantic-ui/components/site.min.css +9 -0
  125. data/formantic-ui/components/site.min.js +11 -0
  126. data/formantic-ui/components/slider.css +926 -0
  127. data/formantic-ui/components/slider.js +1546 -0
  128. data/formantic-ui/components/slider.min.css +9 -0
  129. data/formantic-ui/components/slider.min.js +11 -0
  130. data/formantic-ui/components/state.js +697 -0
  131. data/formantic-ui/components/state.min.js +11 -0
  132. data/formantic-ui/components/statistic.css +586 -0
  133. data/formantic-ui/components/statistic.min.css +9 -0
  134. data/formantic-ui/components/step.css +1538 -0
  135. data/formantic-ui/components/step.min.css +9 -0
  136. data/formantic-ui/components/sticky.css +73 -0
  137. data/formantic-ui/components/sticky.js +917 -0
  138. data/formantic-ui/components/sticky.min.css +9 -0
  139. data/formantic-ui/components/sticky.min.js +11 -0
  140. data/formantic-ui/components/tab.css +84 -0
  141. data/formantic-ui/components/tab.js +967 -0
  142. data/formantic-ui/components/tab.min.css +9 -0
  143. data/formantic-ui/components/tab.min.js +11 -0
  144. data/formantic-ui/components/table.css +3473 -0
  145. data/formantic-ui/components/table.min.css +9 -0
  146. data/formantic-ui/components/text.css +155 -0
  147. data/formantic-ui/components/text.min.css +9 -0
  148. data/formantic-ui/components/toast.css +751 -0
  149. data/formantic-ui/components/toast.js +964 -0
  150. data/formantic-ui/components/toast.min.css +9 -0
  151. data/formantic-ui/components/toast.min.js +11 -0
  152. data/formantic-ui/components/transition.css +1148 -0
  153. data/formantic-ui/components/transition.js +1034 -0
  154. data/formantic-ui/components/transition.min.css +9 -0
  155. data/formantic-ui/components/transition.min.js +11 -0
  156. data/formantic-ui/components/visibility.js +1292 -0
  157. data/formantic-ui/components/visibility.min.js +11 -0
  158. data/formantic-ui/semantic.css +78485 -0
  159. data/formantic-ui/semantic.js +31036 -0
  160. data/formantic-ui/semantic.min.css +11 -0
  161. data/formantic-ui/semantic.min.js +11 -0
  162. data/formantic-ui/themes/basic/assets/fonts/LICENSE.txt +91 -0
  163. data/formantic-ui/themes/basic/assets/fonts/icons.woff +0 -0
  164. data/formantic-ui/themes/basic/assets/fonts/icons.woff2 +0 -0
  165. data/formantic-ui/themes/default/assets/fonts/LICENSE_Lato.txt +94 -0
  166. data/formantic-ui/themes/default/assets/fonts/LICENSE_icons.txt +165 -0
  167. data/formantic-ui/themes/default/assets/fonts/Lato-Bold.woff +0 -0
  168. data/formantic-ui/themes/default/assets/fonts/Lato-Bold.woff2 +0 -0
  169. data/formantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff +0 -0
  170. data/formantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  171. data/formantic-ui/themes/default/assets/fonts/Lato-Italic.woff +0 -0
  172. data/formantic-ui/themes/default/assets/fonts/Lato-Italic.woff2 +0 -0
  173. data/formantic-ui/themes/default/assets/fonts/Lato-Regular.woff +0 -0
  174. data/formantic-ui/themes/default/assets/fonts/Lato-Regular.woff2 +0 -0
  175. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
  176. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
  177. data/formantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff +0 -0
  178. data/formantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff2 +0 -0
  179. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff +0 -0
  180. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff2 +0 -0
  181. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
  182. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
  183. data/formantic-ui/themes/default/assets/fonts/brand-icons.woff +0 -0
  184. data/formantic-ui/themes/default/assets/fonts/brand-icons.woff2 +0 -0
  185. data/formantic-ui/themes/default/assets/fonts/icons.woff +0 -0
  186. data/formantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
  187. data/formantic-ui/themes/default/assets/fonts/outline-icons.woff +0 -0
  188. data/formantic-ui/themes/default/assets/fonts/outline-icons.woff2 +0 -0
  189. data/formantic-ui/themes/famfamfam/assets/images/flags.png +0 -0
  190. data/formantic-ui/themes/github/assets/fonts/LICENSE.txt +94 -0
  191. data/formantic-ui/themes/github/assets/fonts/octicons.woff +0 -0
  192. data/formantic-ui/themes/github/assets/fonts/octicons.woff2 +0 -0
  193. data/formantic-ui/themes/material/assets/fonts/LICENSE.txt +202 -0
  194. data/formantic-ui/themes/material/assets/fonts/icons.woff +0 -0
  195. data/formantic-ui/themes/material/assets/fonts/icons.woff2 +0 -0
  196. data/lib/ui/version.rb +1 -1
  197. metadata +194 -1
@@ -0,0 +1,1637 @@
1
+ /*!
2
+ * # Fomantic-UI 2.9.4 - Modal
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.modal = function (parameters) {
23
+ var
24
+ $allModules = $(this),
25
+ $window = $(window),
26
+ $document = $(document),
27
+ $body = $('body'),
28
+
29
+ time = Date.now(),
30
+ performance = [],
31
+
32
+ query = arguments[0],
33
+ methodInvoked = typeof query === 'string',
34
+ queryArguments = [].slice.call(arguments, 1),
35
+ contextCheck = function (context, win) {
36
+ var $context;
37
+ if ([window, document].indexOf(context) >= 0) {
38
+ $context = $body;
39
+ } else {
40
+ $context = $(win.document).find(context);
41
+ if ($context.length === 0) {
42
+ $context = win.frameElement ? contextCheck(context, win.parent) : $body;
43
+ }
44
+ }
45
+
46
+ return $context;
47
+ },
48
+ returnedValue
49
+ ;
50
+
51
+ $allModules.each(function () {
52
+ var
53
+ settings = $.isPlainObject(parameters)
54
+ ? $.extend(true, {}, $.fn.modal.settings, parameters)
55
+ : $.extend({}, $.fn.modal.settings),
56
+
57
+ selector = settings.selector,
58
+ className = settings.className,
59
+ namespace = settings.namespace,
60
+ fields = settings.fields,
61
+ error = settings.error,
62
+
63
+ eventNamespace = '.' + namespace,
64
+ moduleNamespace = 'module-' + namespace,
65
+
66
+ $module = $(this),
67
+ $context = contextCheck(settings.context, window),
68
+ isBody = $context[0] === $body[0],
69
+ $closeIcon = $module.find(selector.closeIcon),
70
+ $inputs,
71
+
72
+ $allModals,
73
+ $otherModals,
74
+ $focusedElement,
75
+ $dimmable,
76
+ $dimmer,
77
+
78
+ isModalComponent = $module.hasClass('modal'),
79
+
80
+ element = this,
81
+ instance = isModalComponent ? $module.data(moduleNamespace) : undefined,
82
+
83
+ ignoreRepeatedEvents = false,
84
+
85
+ initialMouseDownInModal,
86
+ initialMouseDownInScrollbar,
87
+ initialBodyMargin = '',
88
+ tempBodyMargin = '',
89
+ keepScrollingClass = false,
90
+ hadScrollbar = false,
91
+ windowRefocused = false,
92
+
93
+ elementEventNamespace,
94
+ id,
95
+ observer,
96
+ observeAttributes = false,
97
+ module
98
+ ;
99
+ module = {
100
+
101
+ initialize: function () {
102
+ module.create.id();
103
+ if (!isModalComponent) {
104
+ module.create.modal();
105
+ if (!isFunction(settings.onHidden)) {
106
+ settings.onHidden = function () {
107
+ module.destroy();
108
+ $module.remove();
109
+ };
110
+ }
111
+ }
112
+ $module.addClass(settings.class);
113
+ if (settings.title !== '') {
114
+ $module.find(selector.title).html(module.helpers.escape(settings.title, settings.preserveHTML)).addClass(settings.classTitle);
115
+ }
116
+ if (settings.content !== '') {
117
+ $module.find(selector.content).html(module.helpers.escape(settings.content, settings.preserveHTML)).addClass(settings.classContent);
118
+ }
119
+ if (module.has.configActions()) {
120
+ var $actions = $module.find(selector.actions).addClass(settings.classActions);
121
+ if ($actions.length === 0) {
122
+ $actions = $('<div/>', { class: className.actions + ' ' + (settings.classActions || '') }).appendTo($module);
123
+ } else {
124
+ $actions.empty();
125
+ }
126
+ settings.actions.forEach(function (el) {
127
+ var
128
+ icon = el[fields.icon]
129
+ ? '<i ' + (el[fields.text] ? 'aria-hidden="true"' : '') + ' class="' + module.helpers.deQuote(el[fields.icon]) + ' icon"></i>'
130
+ : '',
131
+ text = module.helpers.escape(el[fields.text] || '', settings.preserveHTML),
132
+ cls = module.helpers.deQuote(el[fields.class] || ''),
133
+ click = el[fields.click] && isFunction(el[fields.click])
134
+ ? el[fields.click]
135
+ : function () {}
136
+ ;
137
+ $actions.append($('<button/>', {
138
+ html: icon + text,
139
+ 'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g, ''),
140
+ class: className.button + ' ' + cls,
141
+ on: {
142
+ click: function () {
143
+ var button = $(this);
144
+ if (button.is(selector.approve) || button.is(selector.deny) || click.call(element, $module) === false) {
145
+ return;
146
+ }
147
+ module.hide();
148
+ },
149
+ },
150
+ }));
151
+ });
152
+ }
153
+ module.cache = {};
154
+ module.verbose('Initializing dimmer', $context);
155
+
156
+ module.create.dimmer();
157
+
158
+ if (settings.allowMultiple) {
159
+ module.create.innerDimmer();
160
+ }
161
+ if (!settings.centered) {
162
+ $module.addClass('top aligned');
163
+ }
164
+ module.refreshModals();
165
+ module.bind.events();
166
+ module.observeChanges();
167
+ module.instantiate();
168
+ if (settings.autoShow) {
169
+ module.show();
170
+ }
171
+ },
172
+
173
+ instantiate: function () {
174
+ module.verbose('Storing instance of modal');
175
+ instance = module;
176
+ $module
177
+ .data(moduleNamespace, instance)
178
+ ;
179
+ },
180
+
181
+ create: {
182
+ modal: function () {
183
+ $module = $('<div/>', { class: className.modal, role: 'dialog', 'aria-modal': true });
184
+ if (settings.closeIcon) {
185
+ $closeIcon = $('<i/>', {
186
+ class: className.close,
187
+ role: 'button',
188
+ tabindex: 0,
189
+ 'aria-label': settings.text.close,
190
+ });
191
+ $module.append($closeIcon);
192
+ }
193
+ if (settings.title !== '') {
194
+ var titleId = '_' + module.get.id() + 'title';
195
+ $module.attr('aria-labelledby', titleId);
196
+ $('<div/>', { class: className.title, id: titleId }).appendTo($module);
197
+ }
198
+ if (settings.content !== '') {
199
+ var descId = '_' + module.get.id() + 'desc';
200
+ $module.attr('aria-describedby', descId);
201
+ $('<div/>', { class: className.content, id: descId }).appendTo($module);
202
+ }
203
+ if (module.has.configActions()) {
204
+ $('<div/>', { class: className.actions }).appendTo($module);
205
+ }
206
+ $context.append($module);
207
+ element = $module[0];
208
+ },
209
+ dimmer: function () {
210
+ var
211
+ defaultSettings = {
212
+ debug: settings.debug,
213
+ dimmerName: 'modals',
214
+ },
215
+ dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
216
+ ;
217
+ if ($.fn.dimmer === undefined) {
218
+ module.error(error.dimmer);
219
+
220
+ return;
221
+ }
222
+ module.debug('Creating dimmer');
223
+ $dimmable = $context.dimmer(dimmerSettings);
224
+ keepScrollingClass = module.is.scrolling();
225
+ if (settings.detachable) {
226
+ module.verbose('Modal is detachable, moving content into dimmer');
227
+ $dimmable.dimmer('add content', $module);
228
+ } else {
229
+ module.set.undetached();
230
+ }
231
+ $dimmer = $dimmable.dimmer('get dimmer');
232
+ },
233
+ id: function () {
234
+ id = (Math.random().toString(16) + '000000000').slice(2, 10);
235
+ elementEventNamespace = '.' + id;
236
+ module.verbose('Creating unique id for element', id);
237
+ },
238
+ innerDimmer: function () {
239
+ if ($module.find(selector.dimmer).length === 0) {
240
+ $('<div/>', { class: className.innerDimmer }).prependTo($module);
241
+ }
242
+ },
243
+ },
244
+
245
+ destroy: function () {
246
+ if (observer) {
247
+ observer.disconnect();
248
+ }
249
+ module.verbose('Destroying previous modal');
250
+ $module
251
+ .removeData(moduleNamespace)
252
+ .off(eventNamespace)
253
+ ;
254
+ $window.off(elementEventNamespace);
255
+ $context.off(elementEventNamespace);
256
+ $dimmer.off(elementEventNamespace);
257
+ $closeIcon.off(elementEventNamespace);
258
+ if ($inputs) {
259
+ $inputs.off(elementEventNamespace);
260
+ }
261
+ $context.dimmer('destroy');
262
+ },
263
+
264
+ observeChanges: function () {
265
+ if ('MutationObserver' in window) {
266
+ observer = new MutationObserver(function (mutations) {
267
+ var collectNodes = function (parent) {
268
+ var nodes = [];
269
+ for (var c = 0, cl = parent.length; c < cl; c++) {
270
+ Array.prototype.push.apply(nodes, collectNodes(parent[c].childNodes));
271
+ nodes.push(parent[c]);
272
+ }
273
+
274
+ return nodes;
275
+ },
276
+ shouldRefresh = false,
277
+ shouldRefreshInputs = false,
278
+ ignoreAutofocus = true
279
+ ;
280
+ mutations.every(function (mutation) {
281
+ if (mutation.type === 'attributes') {
282
+ if (observeAttributes && (mutation.attributeName === 'disabled' || $(mutation.target).find(':input').addBack(':input').filter(':visible').length > 0)) {
283
+ shouldRefreshInputs = true;
284
+ }
285
+ } else {
286
+ shouldRefresh = true;
287
+ // mutationobserver only provides the parent nodes
288
+ // so let's collect all childs as well to find nested inputs
289
+ var $addedInputs = $(collectNodes(mutation.addedNodes)).filter('a[href], [tabindex], :input:enabled').filter(':visible'),
290
+ $removedInputs = $(collectNodes(mutation.removedNodes)).filter('a[href], [tabindex], :input');
291
+ if ($addedInputs.length > 0 || $removedInputs.length > 0) {
292
+ shouldRefreshInputs = true;
293
+ if ($addedInputs.filter(':input').length > 0 || $removedInputs.filter(':input').length > 0) {
294
+ ignoreAutofocus = false;
295
+ }
296
+ }
297
+ }
298
+
299
+ return !shouldRefreshInputs;
300
+ });
301
+
302
+ if (shouldRefresh && settings.observeChanges) {
303
+ module.debug('DOM tree modified, refreshing');
304
+ module.refresh();
305
+ }
306
+ if (shouldRefreshInputs) {
307
+ module.refreshInputs(ignoreAutofocus);
308
+ }
309
+ });
310
+ observer.observe(element, {
311
+ attributeFilter: ['class', 'disabled'],
312
+ attributes: true,
313
+ childList: true,
314
+ subtree: true,
315
+ });
316
+ module.debug('Setting up mutation observer', observer);
317
+ }
318
+ },
319
+
320
+ refresh: function () {
321
+ module.remove.scrolling();
322
+ module.cacheSizes();
323
+ if (!module.can.useFlex()) {
324
+ module.set.modalOffset();
325
+ }
326
+ module.set.screenHeight();
327
+ module.set.type();
328
+ },
329
+
330
+ refreshModals: function () {
331
+ $otherModals = $module.siblings(selector.modal);
332
+ $allModals = $otherModals.add($module);
333
+ },
334
+
335
+ refreshInputs: function (ignoreAutofocus) {
336
+ if ($inputs) {
337
+ $inputs
338
+ .off('keydown' + elementEventNamespace)
339
+ ;
340
+ }
341
+ $inputs = $module.find('a[href], [tabindex], :input:enabled').filter(':visible').filter(function () {
342
+ return $(this).closest('.disabled').length === 0;
343
+ });
344
+ if ($inputs.filter(':input').length === 0) {
345
+ $inputs = $module.add($inputs);
346
+ $module.attr('tabindex', -1);
347
+ } else {
348
+ $module.removeAttr('tabindex');
349
+ }
350
+ $inputs.first()
351
+ .on('keydown' + elementEventNamespace, module.event.inputKeyDown.first)
352
+ ;
353
+ $inputs.last()
354
+ .on('keydown' + elementEventNamespace, module.event.inputKeyDown.last)
355
+ ;
356
+ if (!ignoreAutofocus && settings.autofocus && $inputs.filter(':focus').length === 0) {
357
+ module.set.autofocus();
358
+ }
359
+ },
360
+
361
+ attachEvents: function (selector, event) {
362
+ var
363
+ $toggle = $(selector)
364
+ ;
365
+ event = isFunction(module[event])
366
+ ? module[event]
367
+ : module.toggle;
368
+ if ($toggle.length > 0) {
369
+ module.debug('Attaching modal events to element', selector, event);
370
+ $toggle
371
+ .off(eventNamespace)
372
+ .on('click' + eventNamespace, event)
373
+ ;
374
+ } else {
375
+ module.error(error.notFound, selector);
376
+ }
377
+ },
378
+
379
+ bind: {
380
+ events: function () {
381
+ module.verbose('Attaching events');
382
+ $module
383
+ .on('click' + eventNamespace, selector.close, module.event.close)
384
+ .on('click' + eventNamespace, selector.approve, module.event.approve)
385
+ .on('click' + eventNamespace, selector.deny, module.event.deny)
386
+ ;
387
+ $closeIcon
388
+ .on('keyup' + elementEventNamespace, module.event.closeKeyUp)
389
+ ;
390
+ $window
391
+ .on('resize' + elementEventNamespace, module.event.resize)
392
+ .on('focus' + elementEventNamespace, module.event.focus)
393
+ ;
394
+ $context
395
+ .on('click' + elementEventNamespace, module.event.click)
396
+ ;
397
+ },
398
+ scrollLock: function () {
399
+ // touch events default to passive, due to changes in chrome to optimize mobile perf
400
+ $dimmable[0].addEventListener('touchmove', module.event.preventScroll, { passive: false });
401
+ },
402
+ },
403
+
404
+ unbind: {
405
+ scrollLock: function () {
406
+ $dimmable[0].removeEventListener('touchmove', module.event.preventScroll, { passive: false });
407
+ },
408
+ },
409
+
410
+ get: {
411
+ id: function () {
412
+ return id;
413
+ },
414
+ element: function () {
415
+ return $module;
416
+ },
417
+ settings: function () {
418
+ return settings;
419
+ },
420
+ },
421
+
422
+ event: {
423
+ approve: function () {
424
+ if (ignoreRepeatedEvents || settings.onApprove.call(element, $(this)) === false) {
425
+ module.verbose('Approve callback returned false cancelling hide');
426
+
427
+ return;
428
+ }
429
+ ignoreRepeatedEvents = true;
430
+ module.hide(function () {
431
+ ignoreRepeatedEvents = false;
432
+ });
433
+ },
434
+ preventScroll: function (event) {
435
+ if (event.target.className.indexOf('dimmer') !== -1) {
436
+ event.preventDefault();
437
+ }
438
+ },
439
+ deny: function () {
440
+ if (ignoreRepeatedEvents || settings.onDeny.call(element, $(this)) === false) {
441
+ module.verbose('Deny callback returned false cancelling hide');
442
+
443
+ return;
444
+ }
445
+ ignoreRepeatedEvents = true;
446
+ module.hide(function () {
447
+ ignoreRepeatedEvents = false;
448
+ });
449
+ },
450
+ close: function () {
451
+ module.hide();
452
+ },
453
+ closeKeyUp: function (event) {
454
+ var
455
+ keyCode = event.which
456
+ ;
457
+ if ((keyCode === settings.keys.enter || keyCode === settings.keys.space) && $module.hasClass(className.front)) {
458
+ module.hide();
459
+ }
460
+ },
461
+ inputKeyDown: {
462
+ first: function (event) {
463
+ var
464
+ keyCode = event.which
465
+ ;
466
+ if (keyCode === settings.keys.tab && event.shiftKey) {
467
+ $inputs.last().trigger('focus');
468
+ event.preventDefault();
469
+ }
470
+ },
471
+ last: function (event) {
472
+ var
473
+ keyCode = event.which
474
+ ;
475
+ if (keyCode === settings.keys.tab && !event.shiftKey) {
476
+ $inputs.first().trigger('focus');
477
+ event.preventDefault();
478
+ }
479
+ },
480
+ },
481
+ mousedown: function (event) {
482
+ var
483
+ $target = $(event.target),
484
+ isRtl = module.is.rtl()
485
+ ;
486
+ initialMouseDownInModal = $target.closest(selector.modal).length > 0;
487
+ if (initialMouseDownInModal) {
488
+ module.verbose('Mouse down event registered inside the modal');
489
+ }
490
+ initialMouseDownInScrollbar = module.is.scrolling() && ((!isRtl && $window.outerWidth() - settings.scrollbarWidth <= event.clientX) || (isRtl && settings.scrollbarWidth >= event.clientX));
491
+ if (initialMouseDownInScrollbar) {
492
+ module.verbose('Mouse down event registered inside the scrollbar');
493
+ }
494
+ },
495
+ mouseup: function (event) {
496
+ if (!settings.closable) {
497
+ module.verbose('Dimmer clicked but closable setting is disabled');
498
+
499
+ return;
500
+ }
501
+ if (initialMouseDownInModal) {
502
+ module.debug('Dimmer clicked but mouse down was initially registered inside the modal');
503
+
504
+ return;
505
+ }
506
+ if (initialMouseDownInScrollbar) {
507
+ module.debug('Dimmer clicked but mouse down was initially registered inside the scrollbar');
508
+
509
+ return;
510
+ }
511
+ var
512
+ $target = $(event.target),
513
+ isInModal = $target.closest(selector.modal).length > 0,
514
+ isInDOM = $.contains(document.documentElement, event.target)
515
+ ;
516
+ if (!isInModal && isInDOM && module.is.active() && $module.hasClass(className.front)) {
517
+ module.debug('Dimmer clicked, hiding all modals');
518
+ if (settings.allowMultiple) {
519
+ if (!module.hideAll()) {
520
+ return;
521
+ }
522
+ } else if (!module.hide()) {
523
+ return;
524
+ }
525
+ module.remove.clickaway();
526
+ }
527
+ },
528
+ debounce: function (method, delay) {
529
+ clearTimeout(module.timer);
530
+ module.timer = setTimeout(function () {
531
+ method();
532
+ }, delay);
533
+ },
534
+ keyboard: function (event) {
535
+ var
536
+ keyCode = event.which
537
+ ;
538
+ if (keyCode === settings.keys.escape) {
539
+ if (settings.closable) {
540
+ module.debug('Escape key pressed hiding modal');
541
+ if ($module.hasClass(className.front)) {
542
+ module.hide();
543
+ }
544
+ } else {
545
+ module.debug('Escape key pressed, but closable is set to false');
546
+ }
547
+ event.preventDefault();
548
+ }
549
+ },
550
+ resize: function () {
551
+ if ($dimmable.dimmer('is active') && (module.is.animating() || module.is.active())) {
552
+ requestAnimationFrame(module.refresh);
553
+ }
554
+ },
555
+ focus: function () {
556
+ windowRefocused = true;
557
+ },
558
+ click: function (event) {
559
+ if (windowRefocused && document.activeElement !== event.target && $dimmable.dimmer('is active') && module.is.active() && settings.autofocus && $(document.activeElement).closest(selector.modal).length === 0) {
560
+ requestAnimationFrame(module.set.autofocus);
561
+ }
562
+ windowRefocused = false;
563
+ },
564
+ },
565
+
566
+ toggle: function () {
567
+ if (module.is.active() || module.is.animating()) {
568
+ module.hide();
569
+ } else {
570
+ module.show();
571
+ }
572
+ },
573
+
574
+ show: function (callback) {
575
+ callback = isFunction(callback)
576
+ ? callback
577
+ : function () {};
578
+ module.refreshModals();
579
+ module.set.dimmerSettings();
580
+ module.set.dimmerStyles();
581
+
582
+ module.showModal(callback);
583
+ },
584
+
585
+ hide: function (callback) {
586
+ callback = isFunction(callback)
587
+ ? callback
588
+ : function () {};
589
+ module.refreshModals();
590
+
591
+ return module.hideModal(callback);
592
+ },
593
+
594
+ showModal: function (callback) {
595
+ callback = isFunction(callback)
596
+ ? callback
597
+ : function () {};
598
+ if (module.is.animating() || !module.is.active()) {
599
+ if (settings.onShow.call(element) === false) {
600
+ module.verbose('Show callback returned false cancelling show');
601
+
602
+ return;
603
+ }
604
+ hadScrollbar = module.has.scrollbar();
605
+ module.showDimmer();
606
+ module.cacheSizes();
607
+ if (hadScrollbar) {
608
+ module.set.bodyMargin();
609
+ }
610
+ if (module.can.useFlex()) {
611
+ module.remove.legacy();
612
+ } else {
613
+ module.set.legacy();
614
+ module.set.modalOffset();
615
+ module.debug('Using non-flex legacy modal positioning.');
616
+ }
617
+ module.set.screenHeight();
618
+ module.set.type();
619
+ module.set.clickaway();
620
+
621
+ if (!settings.allowMultiple && module.others.active()) {
622
+ module.hideOthers(module.showModal);
623
+ } else {
624
+ ignoreRepeatedEvents = false;
625
+ if (settings.allowMultiple) {
626
+ if (module.others.active()) {
627
+ $otherModals.filter('.' + className.active).find(selector.dimmer).removeClass('out').addClass('transition fade in active');
628
+ }
629
+
630
+ if (settings.detachable) {
631
+ $module.detach().appendTo($dimmer);
632
+ }
633
+ }
634
+ if (settings.transition && $.fn.transition !== undefined) {
635
+ module.debug('Showing modal with css animations');
636
+ module.set.observeAttributes(false);
637
+ $module
638
+ .transition({
639
+ debug: settings.debug,
640
+ verbose: settings.verbose,
641
+ silent: settings.silent,
642
+ animation: (settings.transition.showMethod || settings.transition) + ' in',
643
+ queue: settings.queue,
644
+ duration: settings.transition.showDuration || settings.duration,
645
+ useFailSafe: true,
646
+ onComplete: function () {
647
+ settings.onVisible.apply(element);
648
+ if (settings.keyboardShortcuts) {
649
+ module.add.keyboardShortcuts();
650
+ }
651
+ module.save.focus();
652
+ module.set.active();
653
+ module.refreshInputs();
654
+ requestAnimationFrame(module.set.observeAttributes);
655
+ callback();
656
+ },
657
+ })
658
+ ;
659
+ } else {
660
+ module.error(error.noTransition);
661
+ }
662
+ }
663
+ } else {
664
+ module.debug('Modal is already visible');
665
+ }
666
+ },
667
+
668
+ hideModal: function (callback, keepDimmed, hideOthersToo) {
669
+ var
670
+ $previousModal = $otherModals.filter('.' + className.active).last()
671
+ ;
672
+ callback = isFunction(callback)
673
+ ? callback
674
+ : function () {};
675
+ if (settings.onHide.call(element, $(this)) === false) {
676
+ module.verbose('Hide callback returned false cancelling hide');
677
+ ignoreRepeatedEvents = false;
678
+
679
+ return false;
680
+ }
681
+
682
+ if (module.is.animating() || module.is.active()) {
683
+ module.debug('Hiding modal');
684
+ if (settings.transition && $.fn.transition !== undefined) {
685
+ module.remove.active();
686
+ module.set.observeAttributes(false);
687
+ $module
688
+ .transition({
689
+ debug: settings.debug,
690
+ verbose: settings.verbose,
691
+ silent: settings.silent,
692
+ animation: (settings.transition.hideMethod || settings.transition) + ' out',
693
+ queue: settings.queue,
694
+ duration: settings.transition.hideDuration || settings.duration,
695
+ useFailSafe: true,
696
+ onStart: function () {
697
+ if (!module.others.active() && !module.others.animating() && !keepDimmed) {
698
+ module.hideDimmer();
699
+ } else if (settings.allowMultiple) {
700
+ (hideOthersToo ? $allModals : $previousModal).find(selector.dimmer).removeClass('in').addClass('out');
701
+ }
702
+ if (settings.keyboardShortcuts && !module.others.active()) {
703
+ module.remove.keyboardShortcuts();
704
+ }
705
+ },
706
+ onComplete: function () {
707
+ module.unbind.scrollLock();
708
+ module.remove.active();
709
+ if (settings.allowMultiple) {
710
+ $previousModal.addClass(className.front);
711
+ $module.removeClass(className.front);
712
+
713
+ (hideOthersToo ? $allModals : $previousModal).find(selector.dimmer).removeClass('active');
714
+ }
715
+ if (isFunction(settings.onHidden)) {
716
+ settings.onHidden.call(element);
717
+ }
718
+ module.remove.dimmerStyles();
719
+ module.restore.focus();
720
+ callback();
721
+ },
722
+ })
723
+ ;
724
+ } else {
725
+ module.error(error.noTransition);
726
+ }
727
+ }
728
+ },
729
+
730
+ showDimmer: function () {
731
+ if ($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active')) {
732
+ if (hadScrollbar) {
733
+ if (!isBody) {
734
+ $dimmer.css('top', $dimmable.scrollTop());
735
+ }
736
+ module.save.bodyMargin();
737
+ }
738
+ module.debug('Showing dimmer');
739
+ $dimmable.dimmer('show');
740
+ } else {
741
+ module.debug('Dimmer already visible');
742
+ }
743
+ },
744
+
745
+ hideDimmer: function () {
746
+ if ($dimmable.dimmer('is animating') || $dimmable.dimmer('is active')) {
747
+ module.unbind.scrollLock();
748
+ $dimmable.dimmer('hide', function () {
749
+ if (hadScrollbar) {
750
+ module.restore.bodyMargin();
751
+ }
752
+ module.remove.clickaway();
753
+ module.remove.screenHeight();
754
+ });
755
+ } else {
756
+ module.debug('Dimmer is not visible cannot hide');
757
+ }
758
+ },
759
+
760
+ hideAll: function (callback) {
761
+ var
762
+ $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating)
763
+ ;
764
+ callback = isFunction(callback)
765
+ ? callback
766
+ : function () {};
767
+ if ($visibleModals.length > 0) {
768
+ module.debug('Hiding all visible modals');
769
+ var hideOk = true;
770
+ // check in reverse order trying to hide most top displayed modal first
771
+ $($visibleModals.get().reverse()).each(function (index, element) {
772
+ if (hideOk) {
773
+ hideOk = $(element).modal('hide modal', callback, false, true);
774
+ }
775
+ });
776
+ if (hideOk) {
777
+ module.hideDimmer();
778
+ }
779
+
780
+ return hideOk;
781
+ }
782
+ },
783
+
784
+ hideOthers: function (callback) {
785
+ var
786
+ $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating)
787
+ ;
788
+ callback = isFunction(callback)
789
+ ? callback
790
+ : function () {};
791
+ if ($visibleModals.length > 0) {
792
+ module.debug('Hiding other modals', $otherModals);
793
+ $visibleModals
794
+ .modal('hide modal', callback, true)
795
+ ;
796
+ }
797
+ },
798
+
799
+ others: {
800
+ active: function () {
801
+ return $otherModals.filter('.' + className.active).length > 0;
802
+ },
803
+ animating: function () {
804
+ return $otherModals.filter('.' + className.animating).length > 0;
805
+ },
806
+ },
807
+
808
+ add: {
809
+ keyboardShortcuts: function () {
810
+ module.verbose('Adding keyboard shortcuts');
811
+ $document
812
+ .on('keydown' + eventNamespace, module.event.keyboard)
813
+ ;
814
+ },
815
+ },
816
+
817
+ save: {
818
+ focus: function () {
819
+ var
820
+ $activeElement = $(document.activeElement),
821
+ inCurrentModal = $activeElement.closest($module).length > 0
822
+ ;
823
+ if (!inCurrentModal) {
824
+ $focusedElement = $(document.activeElement).trigger('blur');
825
+ }
826
+ },
827
+ bodyMargin: function () {
828
+ initialBodyMargin = $context.css((isBody ? 'margin-' : 'padding-') + (module.can.leftBodyScrollbar() ? 'left' : 'right'));
829
+ var
830
+ bodyMarginRightPixel = parseInt(initialBodyMargin.replace(/[^\d.]/g, ''), 10),
831
+ bodyScrollbarWidth = isBody ? window.innerWidth - document.documentElement.clientWidth : $context[0].offsetWidth - $context[0].clientWidth
832
+ ;
833
+ tempBodyMargin = bodyMarginRightPixel + bodyScrollbarWidth;
834
+ },
835
+ },
836
+
837
+ restore: {
838
+ focus: function () {
839
+ if ($focusedElement && $focusedElement.length > 0 && settings.restoreFocus) {
840
+ $focusedElement.trigger('focus');
841
+ }
842
+ },
843
+ bodyMargin: function () {
844
+ var position = module.can.leftBodyScrollbar() ? 'left' : 'right';
845
+ $context.css((isBody ? 'margin-' : 'padding-') + position, initialBodyMargin);
846
+ $context.find(selector.bodyFixed.replace('right', position)).each(function () {
847
+ var
848
+ el = $(this),
849
+ attribute = el.css('position') === 'fixed' ? 'padding-' + position : position
850
+ ;
851
+ el.css(attribute, '');
852
+ });
853
+ },
854
+ },
855
+
856
+ remove: {
857
+ active: function () {
858
+ $module.removeClass(className.active);
859
+ },
860
+ legacy: function () {
861
+ $module.removeClass(className.legacy);
862
+ },
863
+ clickaway: function () {
864
+ if (!settings.detachable) {
865
+ $module
866
+ .off('mousedown' + elementEventNamespace)
867
+ ;
868
+ }
869
+ $dimmer
870
+ .off('mousedown' + elementEventNamespace)
871
+ ;
872
+ $dimmer
873
+ .off('mouseup' + elementEventNamespace)
874
+ ;
875
+ },
876
+ dimmerStyles: function () {
877
+ $dimmer.removeClass(className.inverted);
878
+ $dimmable.removeClass(className.blurring);
879
+ },
880
+ bodyStyle: function () {
881
+ if ($context.attr('style') === '') {
882
+ module.verbose('Removing style attribute');
883
+ $context.removeAttr('style');
884
+ }
885
+ },
886
+ screenHeight: function () {
887
+ module.debug('Removing page height');
888
+ $context
889
+ .css('height', '')
890
+ ;
891
+ module.remove.bodyStyle();
892
+ },
893
+ keyboardShortcuts: function () {
894
+ module.verbose('Removing keyboard shortcuts');
895
+ $document
896
+ .off('keydown' + eventNamespace)
897
+ ;
898
+ },
899
+ scrolling: function () {
900
+ if (!keepScrollingClass) {
901
+ $dimmable.removeClass(className.scrolling);
902
+ }
903
+ $module.removeClass(className.scrolling);
904
+ },
905
+ },
906
+
907
+ cacheSizes: function () {
908
+ $module.addClass(className.loading);
909
+ var
910
+ scrollHeight = $module.prop('scrollHeight'),
911
+ modalWidth = $module.outerWidth(),
912
+ modalHeight = $module.outerHeight()
913
+ ;
914
+ if (module.cache.pageHeight === undefined || modalHeight !== 0) {
915
+ $.extend(module.cache, {
916
+ pageHeight: $document.outerHeight(),
917
+ width: modalWidth,
918
+ height: modalHeight + settings.offset,
919
+ scrollHeight: scrollHeight + settings.offset,
920
+ contextHeight: isBody
921
+ ? $window.height()
922
+ : $dimmable.height(),
923
+ });
924
+ module.cache.topOffset = -(module.cache.height / 2);
925
+ }
926
+ $module.removeClass(className.loading);
927
+ module.debug('Caching modal and container sizes', module.cache);
928
+ },
929
+ helpers: {
930
+ deQuote: function (string) {
931
+ return String(string).replace(/"/g, '');
932
+ },
933
+ escape: function (string, preserveHTML) {
934
+ if (preserveHTML) {
935
+ return string;
936
+ }
937
+ var
938
+ badChars = /["'<>`]/g,
939
+ shouldEscape = /["&'<>`]/,
940
+ escape = {
941
+ '<': '&lt;',
942
+ '>': '&gt;',
943
+ '"': '&quot;',
944
+ "'": '&#x27;',
945
+ '`': '&#x60;',
946
+ },
947
+ escapedChar = function (chr) {
948
+ return escape[chr];
949
+ }
950
+ ;
951
+ if (shouldEscape.test(string)) {
952
+ string = string.replace(/&(?![\d#a-z]{1,12};)/gi, '&amp;');
953
+
954
+ return string.replace(badChars, escapedChar);
955
+ }
956
+
957
+ return string;
958
+ },
959
+ },
960
+ can: {
961
+ leftBodyScrollbar: function () {
962
+ if (module.cache.leftBodyScrollbar === undefined) {
963
+ module.cache.leftBodyScrollbar = module.is.rtl() && ((module.is.iframe && !module.is.firefox()) || module.is.safari() || module.is.edge() || module.is.ie());
964
+ }
965
+
966
+ return module.cache.leftBodyScrollbar;
967
+ },
968
+ useFlex: function () {
969
+ if (settings.useFlex === 'auto') {
970
+ return settings.detachable && !module.is.ie();
971
+ }
972
+ if (settings.useFlex && module.is.ie()) {
973
+ module.debug('useFlex true is not supported in IE');
974
+ } else if (settings.useFlex && !settings.detachable) {
975
+ module.debug('useFlex true in combination with detachable false is not supported');
976
+ }
977
+
978
+ return settings.useFlex;
979
+ },
980
+ fit: function () {
981
+ var
982
+ contextHeight = module.cache.contextHeight,
983
+ verticalCenter = module.cache.contextHeight / 2,
984
+ topOffset = module.cache.topOffset,
985
+ scrollHeight = module.cache.scrollHeight,
986
+ height = module.cache.height,
987
+ paddingHeight = settings.padding,
988
+ startPosition = verticalCenter + topOffset
989
+ ;
990
+
991
+ return scrollHeight > height
992
+ ? startPosition + scrollHeight + paddingHeight < contextHeight
993
+ : height + (paddingHeight * 2) < contextHeight;
994
+ },
995
+ },
996
+ has: {
997
+ configActions: function () {
998
+ return Array.isArray(settings.actions) && settings.actions.length > 0;
999
+ },
1000
+ scrollbar: function () {
1001
+ return isBody || $context.css('overflow-y') !== 'hidden';
1002
+ },
1003
+ },
1004
+ is: {
1005
+ active: function () {
1006
+ return $module.hasClass(className.active);
1007
+ },
1008
+ ie: function () {
1009
+ if (module.cache.isIE === undefined) {
1010
+ var
1011
+ isIE11 = !window.ActiveXObject && 'ActiveXObject' in window,
1012
+ isIE = 'ActiveXObject' in window
1013
+ ;
1014
+ module.cache.isIE = isIE11 || isIE;
1015
+ }
1016
+
1017
+ return module.cache.isIE;
1018
+ },
1019
+ animating: function () {
1020
+ return $module.transition('is animating');
1021
+ },
1022
+ scrolling: function () {
1023
+ return $dimmable.hasClass(className.scrolling);
1024
+ },
1025
+ modernBrowser: function () {
1026
+ // appName for IE11 reports 'Netscape' can no longer use
1027
+ return !(window.ActiveXObject || 'ActiveXObject' in window);
1028
+ },
1029
+ rtl: function () {
1030
+ if (module.cache.isRTL === undefined) {
1031
+ module.cache.isRTL = $module.attr('dir') === 'rtl' || $module.css('direction') === 'rtl' || $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl' || $context.attr('dir') === 'rtl' || $context.css('direction') === 'rtl';
1032
+ }
1033
+
1034
+ return module.cache.isRTL;
1035
+ },
1036
+ safari: function () {
1037
+ if (module.cache.isSafari === undefined) {
1038
+ module.cache.isSafari = /constructor/i.test(window.HTMLElement) || !!window.ApplePaySession;
1039
+ }
1040
+
1041
+ return module.cache.isSafari;
1042
+ },
1043
+ edge: function () {
1044
+ if (module.cache.isEdge === undefined) {
1045
+ module.cache.isEdge = !!window.setImmediate && !module.is.ie();
1046
+ }
1047
+
1048
+ return module.cache.isEdge;
1049
+ },
1050
+ firefox: function () {
1051
+ if (module.cache.isFirefox === undefined) {
1052
+ module.cache.isFirefox = !!window.InstallTrigger;
1053
+ }
1054
+
1055
+ return module.cache.isFirefox;
1056
+ },
1057
+ iframe: function () {
1058
+ return !(self === top);
1059
+ },
1060
+ },
1061
+
1062
+ set: {
1063
+ observeAttributes: function (state) {
1064
+ observeAttributes = state !== false;
1065
+ },
1066
+ autofocus: function () {
1067
+ var
1068
+ $autofocus = $inputs.filter('[autofocus]'),
1069
+ $rawInputs = $inputs.filter(':input'),
1070
+ $input = ($autofocus.length > 0
1071
+ ? $autofocus
1072
+ : ($rawInputs.length > 0
1073
+ ? $rawInputs
1074
+ : $module)
1075
+ ).first()
1076
+ ;
1077
+ $input.trigger('focus');
1078
+ },
1079
+ bodyMargin: function () {
1080
+ var position = module.can.leftBodyScrollbar() ? 'left' : 'right';
1081
+ if (settings.detachable || module.can.fit()) {
1082
+ $context.css((isBody ? 'margin-' : 'padding-') + position, tempBodyMargin + 'px');
1083
+ }
1084
+ $context.find(selector.bodyFixed.replace('right', position)).each(function () {
1085
+ var
1086
+ el = $(this),
1087
+ attribute = el.css('position') === 'fixed' ? 'padding-' + position : position
1088
+ ;
1089
+ el.css(attribute, 'calc(' + el.css(attribute) + ' + ' + tempBodyMargin + 'px)');
1090
+ });
1091
+ },
1092
+ clickaway: function () {
1093
+ if (!settings.detachable) {
1094
+ $module
1095
+ .on('mousedown' + elementEventNamespace, module.event.mousedown)
1096
+ ;
1097
+ }
1098
+ $dimmer
1099
+ .on('mousedown' + elementEventNamespace, module.event.mousedown)
1100
+ ;
1101
+ $dimmer
1102
+ .on('mouseup' + elementEventNamespace, module.event.mouseup)
1103
+ ;
1104
+ },
1105
+ dimmerSettings: function () {
1106
+ if ($.fn.dimmer === undefined) {
1107
+ module.error(error.dimmer);
1108
+
1109
+ return;
1110
+ }
1111
+ var
1112
+ defaultSettings = {
1113
+ debug: settings.debug,
1114
+ dimmerName: 'modals',
1115
+ closable: 'auto',
1116
+ useFlex: module.can.useFlex(),
1117
+ duration: {
1118
+ show: settings.transition.showDuration || settings.duration,
1119
+ hide: settings.transition.hideDuration || settings.duration,
1120
+ },
1121
+ },
1122
+ dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
1123
+ ;
1124
+ if (settings.inverted) {
1125
+ dimmerSettings.variation = dimmerSettings.variation !== undefined
1126
+ ? dimmerSettings.variation + ' inverted'
1127
+ : 'inverted';
1128
+ }
1129
+ $context.dimmer('setting', dimmerSettings);
1130
+ },
1131
+ dimmerStyles: function () {
1132
+ if (settings.inverted) {
1133
+ $dimmer.addClass(className.inverted);
1134
+ } else {
1135
+ $dimmer.removeClass(className.inverted);
1136
+ }
1137
+ if (settings.blurring) {
1138
+ $dimmable.addClass(className.blurring);
1139
+ } else {
1140
+ $dimmable.removeClass(className.blurring);
1141
+ }
1142
+ },
1143
+ modalOffset: function () {
1144
+ if (!settings.detachable) {
1145
+ var canFit = module.can.fit();
1146
+ $module
1147
+ .css({
1148
+ top: !$module.hasClass('aligned') && canFit
1149
+ ? $document.scrollTop() + (module.cache.contextHeight - module.cache.height) / 2
1150
+ : (!canFit || $module.hasClass('top')
1151
+ ? $document.scrollTop() + settings.padding
1152
+ : $document.scrollTop() + (module.cache.contextHeight - module.cache.height - settings.padding)),
1153
+ marginLeft: -(module.cache.width / 2),
1154
+ })
1155
+ ;
1156
+ } else {
1157
+ $module
1158
+ .css({
1159
+ marginTop: !$module.hasClass('aligned') && module.can.fit()
1160
+ ? -(module.cache.height / 2)
1161
+ : settings.padding / 2,
1162
+ marginLeft: -(module.cache.width / 2),
1163
+ })
1164
+ ;
1165
+ }
1166
+ module.verbose('Setting modal offset for legacy mode');
1167
+ },
1168
+ screenHeight: function () {
1169
+ if (module.can.fit()) {
1170
+ $context.css('height', '');
1171
+ } else if (!$module.hasClass('bottom')) {
1172
+ module.debug('Modal is taller than page content, resizing page height');
1173
+ $context
1174
+ .css('height', module.cache.height + (settings.padding * 2) + 'px')
1175
+ ;
1176
+ }
1177
+ },
1178
+ active: function () {
1179
+ $module.addClass(className.active + ' ' + className.front);
1180
+ $otherModals.filter('.' + className.active).removeClass(className.front);
1181
+ },
1182
+ scrolling: function () {
1183
+ $dimmable.addClass(className.scrolling);
1184
+ $module.addClass(className.scrolling);
1185
+ module.unbind.scrollLock();
1186
+ },
1187
+ legacy: function () {
1188
+ $module.addClass(className.legacy);
1189
+ },
1190
+ type: function () {
1191
+ if (module.can.fit()) {
1192
+ module.verbose('Modal fits on screen');
1193
+ if (!module.others.active() && !module.others.animating()) {
1194
+ module.remove.scrolling();
1195
+ module.bind.scrollLock();
1196
+ }
1197
+ } else if (!$module.hasClass('bottom')) {
1198
+ module.verbose('Modal cannot fit on screen setting to scrolling');
1199
+ module.set.scrolling();
1200
+ } else {
1201
+ module.verbose('Bottom aligned modal not fitting on screen is unsupported for scrolling');
1202
+ }
1203
+ },
1204
+ undetached: function () {
1205
+ $dimmable.addClass(className.undetached);
1206
+ },
1207
+ },
1208
+
1209
+ setting: function (name, value) {
1210
+ module.debug('Changing setting', name, value);
1211
+ if ($.isPlainObject(name)) {
1212
+ $.extend(true, settings, name);
1213
+ } else if (value !== undefined) {
1214
+ if ($.isPlainObject(settings[name])) {
1215
+ $.extend(true, settings[name], value);
1216
+ } else {
1217
+ settings[name] = value;
1218
+ }
1219
+ } else {
1220
+ return settings[name];
1221
+ }
1222
+ },
1223
+ internal: function (name, value) {
1224
+ if ($.isPlainObject(name)) {
1225
+ $.extend(true, module, name);
1226
+ } else if (value !== undefined) {
1227
+ module[name] = value;
1228
+ } else {
1229
+ return module[name];
1230
+ }
1231
+ },
1232
+ debug: function () {
1233
+ if (!settings.silent && settings.debug) {
1234
+ if (settings.performance) {
1235
+ module.performance.log(arguments);
1236
+ } else {
1237
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1238
+ module.debug.apply(console, arguments);
1239
+ }
1240
+ }
1241
+ },
1242
+ verbose: function () {
1243
+ if (!settings.silent && settings.verbose && settings.debug) {
1244
+ if (settings.performance) {
1245
+ module.performance.log(arguments);
1246
+ } else {
1247
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1248
+ module.verbose.apply(console, arguments);
1249
+ }
1250
+ }
1251
+ },
1252
+ error: function () {
1253
+ if (!settings.silent) {
1254
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1255
+ module.error.apply(console, arguments);
1256
+ }
1257
+ },
1258
+ performance: {
1259
+ log: function (message) {
1260
+ var
1261
+ currentTime,
1262
+ executionTime,
1263
+ previousTime
1264
+ ;
1265
+ if (settings.performance) {
1266
+ currentTime = Date.now();
1267
+ previousTime = time || currentTime;
1268
+ executionTime = currentTime - previousTime;
1269
+ time = currentTime;
1270
+ performance.push({
1271
+ Name: message[0],
1272
+ Arguments: [].slice.call(message, 1) || '',
1273
+ Element: element,
1274
+ 'Execution Time': executionTime,
1275
+ });
1276
+ }
1277
+ clearTimeout(module.performance.timer);
1278
+ module.performance.timer = setTimeout(function () {
1279
+ module.performance.display();
1280
+ }, 500);
1281
+ },
1282
+ display: function () {
1283
+ var
1284
+ title = settings.name + ':',
1285
+ totalTime = 0
1286
+ ;
1287
+ time = false;
1288
+ clearTimeout(module.performance.timer);
1289
+ $.each(performance, function (index, data) {
1290
+ totalTime += data['Execution Time'];
1291
+ });
1292
+ title += ' ' + totalTime + 'ms';
1293
+ if (performance.length > 0) {
1294
+ console.groupCollapsed(title);
1295
+ if (console.table) {
1296
+ console.table(performance);
1297
+ } else {
1298
+ $.each(performance, function (index, data) {
1299
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
1300
+ });
1301
+ }
1302
+ console.groupEnd();
1303
+ }
1304
+ performance = [];
1305
+ },
1306
+ },
1307
+ invoke: function (query, passedArguments, context) {
1308
+ var
1309
+ object = instance,
1310
+ maxDepth,
1311
+ found,
1312
+ response
1313
+ ;
1314
+ passedArguments = passedArguments || queryArguments;
1315
+ context = context || element;
1316
+ if (typeof query === 'string' && object !== undefined) {
1317
+ query = query.split(/[ .]/);
1318
+ maxDepth = query.length - 1;
1319
+ $.each(query, function (depth, value) {
1320
+ var camelCaseValue = depth !== maxDepth
1321
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1322
+ : query;
1323
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
1324
+ object = object[camelCaseValue];
1325
+ } else if (object[camelCaseValue] !== undefined) {
1326
+ found = object[camelCaseValue];
1327
+
1328
+ return false;
1329
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
1330
+ object = object[value];
1331
+ } else if (object[value] !== undefined) {
1332
+ found = object[value];
1333
+
1334
+ return false;
1335
+ } else {
1336
+ module.error(error.method, query);
1337
+
1338
+ return false;
1339
+ }
1340
+ });
1341
+ }
1342
+ if (isFunction(found)) {
1343
+ response = found.apply(context, passedArguments);
1344
+ } else if (found !== undefined) {
1345
+ response = found;
1346
+ }
1347
+ if (Array.isArray(returnedValue)) {
1348
+ returnedValue.push(response);
1349
+ } else if (returnedValue !== undefined) {
1350
+ returnedValue = [returnedValue, response];
1351
+ } else if (response !== undefined) {
1352
+ returnedValue = response;
1353
+ }
1354
+
1355
+ return found;
1356
+ },
1357
+ };
1358
+
1359
+ if (methodInvoked) {
1360
+ if (instance === undefined) {
1361
+ if (isFunction(settings.templates[query])) {
1362
+ settings.autoShow = true;
1363
+ settings.className.modal = settings.className.template;
1364
+ settings = $.extend(true, {}, settings, settings.templates[query].apply(module, queryArguments));
1365
+
1366
+ // reassign shortcuts
1367
+ className = settings.className;
1368
+ namespace = settings.namespace;
1369
+ fields = settings.fields;
1370
+ error = settings.error;
1371
+ }
1372
+ module.initialize();
1373
+ }
1374
+ if (!isFunction(settings.templates[query])) {
1375
+ module.invoke(query);
1376
+ }
1377
+ } else {
1378
+ if (instance !== undefined) {
1379
+ instance.invoke('destroy');
1380
+ }
1381
+ module.initialize();
1382
+ returnedValue = $module;
1383
+ }
1384
+ });
1385
+
1386
+ return returnedValue !== undefined
1387
+ ? returnedValue
1388
+ : this;
1389
+ };
1390
+ $.modal = $.fn.modal;
1391
+
1392
+ $.fn.modal.settings = {
1393
+
1394
+ name: 'Modal',
1395
+ namespace: 'modal',
1396
+
1397
+ useFlex: 'auto',
1398
+ offset: 0,
1399
+
1400
+ silent: false,
1401
+ debug: false,
1402
+ verbose: false,
1403
+ performance: true,
1404
+
1405
+ observeChanges: false,
1406
+
1407
+ allowMultiple: false,
1408
+ detachable: true,
1409
+ closable: true,
1410
+ autofocus: true,
1411
+ restoreFocus: true,
1412
+ autoShow: false,
1413
+
1414
+ inverted: false,
1415
+ blurring: false,
1416
+
1417
+ centered: true,
1418
+
1419
+ dimmerSettings: {
1420
+ closable: false,
1421
+ useCSS: true,
1422
+ },
1423
+
1424
+ // whether to use keyboard shortcuts
1425
+ keyboardShortcuts: true,
1426
+
1427
+ context: 'body',
1428
+
1429
+ queue: false,
1430
+ duration: 500,
1431
+ transition: 'scale',
1432
+
1433
+ // padding with edge of page
1434
+ padding: 50,
1435
+ scrollbarWidth: 10,
1436
+
1437
+ // dynamic content
1438
+ title: '',
1439
+ content: '',
1440
+ class: '',
1441
+ classTitle: '',
1442
+ classContent: '',
1443
+ classActions: '',
1444
+ closeIcon: false,
1445
+ actions: false,
1446
+ preserveHTML: true,
1447
+
1448
+ fields: {
1449
+ class: 'class',
1450
+ text: 'text',
1451
+ icon: 'icon',
1452
+ click: 'click',
1453
+ },
1454
+
1455
+ // called before show animation
1456
+ onShow: function () {},
1457
+
1458
+ // called after show animation
1459
+ onVisible: function () {},
1460
+
1461
+ // called before hide animation
1462
+ onHide: function () {
1463
+ return true;
1464
+ },
1465
+
1466
+ // called after hide animation
1467
+ onHidden: false,
1468
+
1469
+ // called after approve selector match
1470
+ onApprove: function () {
1471
+ return true;
1472
+ },
1473
+
1474
+ // called after deny selector match
1475
+ onDeny: function () {
1476
+ return true;
1477
+ },
1478
+
1479
+ keys: {
1480
+ space: 32,
1481
+ enter: 13,
1482
+ escape: 27,
1483
+ tab: 9,
1484
+ },
1485
+
1486
+ selector: {
1487
+ title: '> .header',
1488
+ content: '> .content',
1489
+ actions: '> .actions',
1490
+ close: '> .close',
1491
+ closeIcon: '> .close',
1492
+ approve: '.actions .positive, .actions .approve, .actions .ok',
1493
+ deny: '.actions .negative, .actions .deny, .actions .cancel',
1494
+ modal: '.ui.modal',
1495
+ dimmer: '> .ui.dimmer',
1496
+ bodyFixed: '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar, > .ui.fixed.nag, > .ui.fixed.nag > .close',
1497
+ prompt: '.ui.input > input',
1498
+ },
1499
+ error: {
1500
+ dimmer: 'UI Dimmer, a required component is not included in this page',
1501
+ method: 'The method you called is not defined.',
1502
+ notFound: 'The element you specified could not be found',
1503
+ },
1504
+ className: {
1505
+ active: 'active',
1506
+ animating: 'animating',
1507
+ blurring: 'blurring',
1508
+ inverted: 'inverted',
1509
+ legacy: 'legacy',
1510
+ loading: 'loading',
1511
+ scrolling: 'scrolling',
1512
+ undetached: 'undetached',
1513
+ front: 'front',
1514
+ close: 'close icon',
1515
+ button: 'ui button',
1516
+ modal: 'ui modal',
1517
+ title: 'header',
1518
+ content: 'content',
1519
+ actions: 'actions',
1520
+ template: 'ui tiny modal',
1521
+ ok: 'positive',
1522
+ cancel: 'negative',
1523
+ prompt: 'ui fluid input',
1524
+ innerDimmer: 'ui inverted dimmer',
1525
+ },
1526
+ text: {
1527
+ ok: 'Ok',
1528
+ cancel: 'Cancel',
1529
+ close: 'Close',
1530
+ },
1531
+ };
1532
+
1533
+ $.fn.modal.settings.templates = {
1534
+ getArguments: function (args) {
1535
+ var queryArguments = [].slice.call(args);
1536
+ if ($.isPlainObject(queryArguments[0])) {
1537
+ return $.extend({
1538
+ handler: function () {},
1539
+ content: '',
1540
+ title: '',
1541
+ }, queryArguments[0]);
1542
+ }
1543
+ if (!isFunction(queryArguments[queryArguments.length - 1])) {
1544
+ queryArguments.push(function () {});
1545
+ }
1546
+
1547
+ return {
1548
+ handler: queryArguments.pop(),
1549
+ content: queryArguments.pop() || '',
1550
+ title: queryArguments.pop() || '',
1551
+ };
1552
+ },
1553
+ alert: function () {
1554
+ var
1555
+ settings = this.get.settings(),
1556
+ args = settings.templates.getArguments(arguments),
1557
+ approveFn = args.handler
1558
+ ;
1559
+
1560
+ return {
1561
+ title: args.title,
1562
+ content: args.content,
1563
+ onApprove: approveFn,
1564
+ actions: [{
1565
+ text: settings.text.ok,
1566
+ class: settings.className.ok,
1567
+ click: approveFn,
1568
+ }],
1569
+ };
1570
+ },
1571
+ confirm: function () {
1572
+ var
1573
+ settings = this.get.settings(),
1574
+ args = settings.templates.getArguments(arguments),
1575
+ approveFn = function () {
1576
+ args.handler(true);
1577
+ },
1578
+ denyFn = function () {
1579
+ args.handler(false);
1580
+ }
1581
+ ;
1582
+
1583
+ return {
1584
+ title: args.title,
1585
+ content: args.content,
1586
+ onApprove: approveFn,
1587
+ onDeny: denyFn,
1588
+ actions: [{
1589
+ text: settings.text.ok,
1590
+ class: settings.className.ok,
1591
+ click: approveFn,
1592
+ }, {
1593
+ text: settings.text.cancel,
1594
+ class: settings.className.cancel,
1595
+ click: denyFn,
1596
+ }],
1597
+ };
1598
+ },
1599
+ prompt: function () {
1600
+ var
1601
+ $this = this,
1602
+ settings = this.get.settings(),
1603
+ args = settings.templates.getArguments(arguments),
1604
+ input = $($.parseHTML(args.content)).filter('.ui.input'),
1605
+ approveFn = function () {
1606
+ var
1607
+ settings = $this.get.settings(),
1608
+ inputField = $this.get.element().find(settings.selector.prompt)[0]
1609
+ ;
1610
+ args.handler($(inputField).val());
1611
+ },
1612
+ denyFn = function () {
1613
+ args.handler(null);
1614
+ }
1615
+ ;
1616
+ if (input.length === 0) {
1617
+ args.content += '<p><div class="' + this.helpers.deQuote(settings.className.prompt) + '"><input placeholder="' + this.helpers.deQuote(args.placeholder || '') + '" type="text" value="' + this.helpers.deQuote(args.defaultValue || '') + '"></div></p>';
1618
+ }
1619
+
1620
+ return {
1621
+ title: args.title,
1622
+ content: args.content,
1623
+ onApprove: approveFn,
1624
+ onDeny: denyFn,
1625
+ actions: [{
1626
+ text: settings.text.ok,
1627
+ class: settings.className.ok,
1628
+ click: approveFn,
1629
+ }, {
1630
+ text: settings.text.cancel,
1631
+ class: settings.className.cancel,
1632
+ click: denyFn,
1633
+ }],
1634
+ };
1635
+ },
1636
+ };
1637
+ })(jQuery, window, document);