@northdata/fomantic-ui 2.8.722 → 2.9.400

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 (133) hide show
  1. package/lib/semantic-ui/dist/components/accordion.css +62 -69
  2. package/lib/semantic-ui/dist/components/accordion.js +595 -618
  3. package/lib/semantic-ui/dist/components/accordion.min.css +4 -4
  4. package/lib/semantic-ui/dist/components/accordion.min.js +6 -6
  5. package/lib/semantic-ui/dist/components/api.js +1225 -1177
  6. package/lib/semantic-ui/dist/components/api.min.js +6 -6
  7. package/lib/semantic-ui/dist/components/button.css +291 -634
  8. package/lib/semantic-ui/dist/components/button.min.css +4 -4
  9. package/lib/semantic-ui/dist/components/calendar.css +149 -33
  10. package/lib/semantic-ui/dist/components/calendar.js +2045 -1774
  11. package/lib/semantic-ui/dist/components/calendar.min.css +4 -4
  12. package/lib/semantic-ui/dist/components/calendar.min.js +6 -6
  13. package/lib/semantic-ui/dist/components/card.css +147 -537
  14. package/lib/semantic-ui/dist/components/card.min.css +4 -4
  15. package/lib/semantic-ui/dist/components/checkbox.css +215 -405
  16. package/lib/semantic-ui/dist/components/checkbox.js +888 -876
  17. package/lib/semantic-ui/dist/components/checkbox.min.css +4 -4
  18. package/lib/semantic-ui/dist/components/checkbox.min.js +6 -6
  19. package/lib/semantic-ui/dist/components/container.css +20 -21
  20. package/lib/semantic-ui/dist/components/container.min.css +4 -4
  21. package/lib/semantic-ui/dist/components/dimmer.css +76 -184
  22. package/lib/semantic-ui/dist/components/dimmer.js +732 -753
  23. package/lib/semantic-ui/dist/components/dimmer.min.css +4 -4
  24. package/lib/semantic-ui/dist/components/dimmer.min.js +6 -6
  25. package/lib/semantic-ui/dist/components/divider.css +81 -88
  26. package/lib/semantic-ui/dist/components/divider.min.css +4 -4
  27. package/lib/semantic-ui/dist/components/dropdown.css +431 -450
  28. package/lib/semantic-ui/dist/components/dropdown.js +4432 -4238
  29. package/lib/semantic-ui/dist/components/dropdown.min.css +4 -4
  30. package/lib/semantic-ui/dist/components/dropdown.min.js +6 -6
  31. package/lib/semantic-ui/dist/components/feed.css +130 -87
  32. package/lib/semantic-ui/dist/components/feed.min.css +4 -4
  33. package/lib/semantic-ui/dist/components/flag.css +541 -511
  34. package/lib/semantic-ui/dist/components/flag.min.css +4 -4
  35. package/lib/semantic-ui/dist/components/form.css +437 -476
  36. package/lib/semantic-ui/dist/components/form.js +2199 -2033
  37. package/lib/semantic-ui/dist/components/form.min.css +4 -4
  38. package/lib/semantic-ui/dist/components/form.min.js +6 -6
  39. package/lib/semantic-ui/dist/components/grid.css +151 -306
  40. package/lib/semantic-ui/dist/components/grid.min.css +4 -4
  41. package/lib/semantic-ui/dist/components/header.css +82 -99
  42. package/lib/semantic-ui/dist/components/header.min.css +4 -4
  43. package/lib/semantic-ui/dist/components/icon.css +2744 -2706
  44. package/lib/semantic-ui/dist/components/icon.min.css +4 -4
  45. package/lib/semantic-ui/dist/components/image.css +38 -73
  46. package/lib/semantic-ui/dist/components/image.min.css +4 -4
  47. package/lib/semantic-ui/dist/components/input.css +344 -254
  48. package/lib/semantic-ui/dist/components/input.min.css +4 -4
  49. package/lib/semantic-ui/dist/components/item.css +91 -139
  50. package/lib/semantic-ui/dist/components/item.min.css +4 -4
  51. package/lib/semantic-ui/dist/components/label.css +244 -267
  52. package/lib/semantic-ui/dist/components/label.min.css +4 -4
  53. package/lib/semantic-ui/dist/components/list.css +75 -113
  54. package/lib/semantic-ui/dist/components/list.min.css +4 -4
  55. package/lib/semantic-ui/dist/components/loader.css +142 -601
  56. package/lib/semantic-ui/dist/components/loader.min.css +4 -4
  57. package/lib/semantic-ui/dist/components/menu.css +398 -638
  58. package/lib/semantic-ui/dist/components/menu.min.css +9 -1
  59. package/lib/semantic-ui/dist/components/message.css +116 -332
  60. package/lib/semantic-ui/dist/components/message.min.css +4 -4
  61. package/lib/semantic-ui/dist/components/modal.css +149 -138
  62. package/lib/semantic-ui/dist/components/modal.js +1637 -1209
  63. package/lib/semantic-ui/dist/components/modal.min.css +4 -4
  64. package/lib/semantic-ui/dist/components/modal.min.js +6 -6
  65. package/lib/semantic-ui/dist/components/popup.css +284 -277
  66. package/lib/semantic-ui/dist/components/popup.js +1561 -1541
  67. package/lib/semantic-ui/dist/components/popup.min.css +4 -4
  68. package/lib/semantic-ui/dist/components/popup.min.js +6 -6
  69. package/lib/semantic-ui/dist/components/reset.css +12 -17
  70. package/lib/semantic-ui/dist/components/reset.min.css +4 -4
  71. package/lib/semantic-ui/dist/components/search.css +99 -137
  72. package/lib/semantic-ui/dist/components/search.js +1641 -1565
  73. package/lib/semantic-ui/dist/components/search.min.css +4 -4
  74. package/lib/semantic-ui/dist/components/search.min.js +6 -6
  75. package/lib/semantic-ui/dist/components/segment.css +149 -275
  76. package/lib/semantic-ui/dist/components/segment.min.css +4 -4
  77. package/lib/semantic-ui/dist/components/site.css +40 -48
  78. package/lib/semantic-ui/dist/components/site.js +455 -493
  79. package/lib/semantic-ui/dist/components/site.min.css +4 -4
  80. package/lib/semantic-ui/dist/components/site.min.js +6 -6
  81. package/lib/semantic-ui/dist/components/tab.css +16 -20
  82. package/lib/semantic-ui/dist/components/tab.js +967 -1001
  83. package/lib/semantic-ui/dist/components/tab.min.css +4 -4
  84. package/lib/semantic-ui/dist/components/tab.min.js +6 -6
  85. package/lib/semantic-ui/dist/components/table.css +465 -424
  86. package/lib/semantic-ui/dist/components/table.min.css +4 -4
  87. package/lib/semantic-ui/dist/components/transition.css +264 -1282
  88. package/lib/semantic-ui/dist/components/transition.js +1034 -1109
  89. package/lib/semantic-ui/dist/components/transition.min.css +4 -4
  90. package/lib/semantic-ui/dist/components/transition.min.js +6 -6
  91. package/lib/semantic-ui/dist/semantic-packed.css +5619 -6592
  92. package/lib/semantic-ui/dist/semantic.css +8547 -11697
  93. package/lib/semantic-ui/dist/semantic.full.css +14698 -11227
  94. package/lib/semantic-ui/dist/semantic.full.min.css +6 -262
  95. package/lib/semantic-ui/dist/semantic.js +19428 -19253
  96. package/lib/semantic-ui/dist/semantic.min.css +128 -128
  97. package/lib/semantic-ui/dist/semantic.min.js +6 -6
  98. package/lib/semantic-ui/dist/themes/basic/assets/fonts/LICENSE.txt +91 -0
  99. package/lib/semantic-ui/dist/themes/basic/assets/fonts/icons.woff2 +0 -0
  100. package/lib/semantic-ui/dist/themes/default/assets/fonts/LICENSE_icons.txt +165 -0
  101. package/lib/semantic-ui/dist/themes/default/assets/fonts/brand-icons.woff +0 -0
  102. package/lib/semantic-ui/dist/themes/default/assets/fonts/brand-icons.woff2 +0 -0
  103. package/lib/semantic-ui/dist/themes/default/assets/fonts/icons.woff +0 -0
  104. package/lib/semantic-ui/dist/themes/default/assets/fonts/icons.woff2 +0 -0
  105. package/lib/semantic-ui/dist/themes/default/assets/fonts/outline-icons.woff +0 -0
  106. package/lib/semantic-ui/dist/themes/default/assets/fonts/outline-icons.woff2 +0 -0
  107. package/package.json +17 -7
  108. package/lib/semantic-ui/dist/components/shape.css +0 -160
  109. package/lib/semantic-ui/dist/components/shape.js +0 -848
  110. package/lib/semantic-ui/dist/components/shape.min.css +0 -9
  111. package/lib/semantic-ui/dist/components/shape.min.js +0 -11
  112. package/lib/semantic-ui/dist/themes/basic/assets/fonts/icons.eot +0 -0
  113. package/lib/semantic-ui/dist/themes/basic/assets/fonts/icons.svg +0 -450
  114. package/lib/semantic-ui/dist/themes/basic/assets/fonts/icons.ttf +0 -0
  115. package/lib/semantic-ui/dist/themes/default/assets/fonts/brand-icons.eot +0 -0
  116. package/lib/semantic-ui/dist/themes/default/assets/fonts/brand-icons.svg +0 -3570
  117. package/lib/semantic-ui/dist/themes/default/assets/fonts/brand-icons.ttf +0 -0
  118. package/lib/semantic-ui/dist/themes/default/assets/fonts/icons.eot +0 -0
  119. package/lib/semantic-ui/dist/themes/default/assets/fonts/icons.svg +0 -4938
  120. package/lib/semantic-ui/dist/themes/default/assets/fonts/icons.ttf +0 -0
  121. package/lib/semantic-ui/dist/themes/default/assets/fonts/outline-icons.eot +0 -0
  122. package/lib/semantic-ui/dist/themes/default/assets/fonts/outline-icons.svg +0 -803
  123. package/lib/semantic-ui/dist/themes/default/assets/fonts/outline-icons.ttf +0 -0
  124. package/lib/semantic-ui/dist/themes/github/assets/fonts/octicons-local.ttf +0 -0
  125. package/lib/semantic-ui/dist/themes/github/assets/fonts/octicons.svg +0 -200
  126. package/lib/semantic-ui/dist/themes/github/assets/fonts/octicons.ttf +0 -0
  127. package/lib/semantic-ui/dist/themes/github/assets/fonts/octicons.woff +0 -0
  128. package/lib/semantic-ui/dist/themes/material/assets/fonts/icons.eot +0 -0
  129. package/lib/semantic-ui/dist/themes/material/assets/fonts/icons.svg +0 -2373
  130. package/lib/semantic-ui/dist/themes/material/assets/fonts/icons.ttf +0 -0
  131. package/lib/semantic-ui/dist/themes/material/assets/fonts/icons.woff +0 -0
  132. package/lib/semantic-ui/dist/themes/material/assets/fonts/icons.woff2 +0 -0
  133. /package/lib/semantic-ui/dist/themes/{default → famfamfam}/assets/images/flags.png +0 -0
@@ -1,1209 +1,1637 @@
1
- /*!
2
- * # Fomantic-UI - Modal
3
- * http://github.com/fomantic/Fomantic-UI/
4
- *
5
- *
6
- * Released under the MIT license
7
- * http://opensource.org/licenses/MIT
8
- *
9
- */
10
-
11
- ;(function ($, window, document, undefined) {
12
-
13
- 'use strict';
14
-
15
- $.isFunction = $.isFunction || function(obj) {
16
- return typeof obj === "function" && typeof obj.nodeType !== "number";
17
- };
18
-
19
- window = (typeof window != 'undefined' && window.Math == Math)
20
- ? window
21
- : (typeof self != 'undefined' && self.Math == Math)
22
- ? self
23
- : Function('return this')()
24
- ;
25
-
26
- $.fn.modal = function(parameters) {
27
- var
28
- $allModules = $(this),
29
- $window = $(window),
30
- $document = $(document),
31
- $body = $('body'),
32
-
33
- moduleSelector = $allModules.selector || '',
34
-
35
- time = new Date().getTime(),
36
- performance = [],
37
-
38
- query = arguments[0],
39
- methodInvoked = (typeof query == 'string'),
40
- queryArguments = [].slice.call(arguments, 1),
41
-
42
- requestAnimationFrame = window.requestAnimationFrame
43
- || window.mozRequestAnimationFrame
44
- || window.webkitRequestAnimationFrame
45
- || window.msRequestAnimationFrame
46
- || function(callback) { setTimeout(callback, 0); },
47
-
48
- returnedValue
49
- ;
50
-
51
- $allModules
52
- .each(function() {
53
- var
54
- settings = ( $.isPlainObject(parameters) )
55
- ? $.extend(true, {}, $.fn.modal.settings, parameters)
56
- : $.extend({}, $.fn.modal.settings),
57
-
58
- selector = settings.selector,
59
- className = settings.className,
60
- namespace = settings.namespace,
61
- error = settings.error,
62
-
63
- eventNamespace = '.' + namespace,
64
- moduleNamespace = 'module-' + namespace,
65
-
66
- $module = $(this),
67
- $context = $(settings.context),
68
- $close = $module.find(selector.close),
69
-
70
- $allModals,
71
- $otherModals,
72
- $focusedElement,
73
- $dimmable,
74
- $dimmer,
75
-
76
- element = this,
77
- instance = $module.data(moduleNamespace),
78
-
79
- ignoreRepeatedEvents = false,
80
-
81
- initialMouseDownInModal,
82
- initialMouseDownInScrollbar,
83
- initialBodyMargin = '',
84
- tempBodyMargin = '',
85
-
86
- elementEventNamespace,
87
- id,
88
- observer,
89
- module
90
- ;
91
- module = {
92
-
93
- initialize: function() {
94
- module.cache = {};
95
- module.verbose('Initializing dimmer', $context);
96
-
97
- module.create.id();
98
- module.create.dimmer();
99
-
100
- if ( settings.allowMultiple ) {
101
- module.create.innerDimmer();
102
- }
103
- if (!settings.centered){
104
- $module.addClass('top aligned');
105
- }
106
- module.refreshModals();
107
-
108
- module.bind.events();
109
- if(settings.observeChanges) {
110
- module.observeChanges();
111
- }
112
- module.instantiate();
113
- },
114
-
115
- instantiate: function() {
116
- module.verbose('Storing instance of modal');
117
- instance = module;
118
- $module
119
- .data(moduleNamespace, instance)
120
- ;
121
- },
122
-
123
- create: {
124
- dimmer: function() {
125
- var
126
- defaultSettings = {
127
- debug : settings.debug,
128
- dimmerName : 'modals'
129
- },
130
- dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
131
- ;
132
- if($.fn.dimmer === undefined) {
133
- module.error(error.dimmer);
134
- return;
135
- }
136
- module.debug('Creating dimmer');
137
- $dimmable = $context.dimmer(dimmerSettings);
138
- if(settings.detachable) {
139
- module.verbose('Modal is detachable, moving content into dimmer');
140
- $dimmable.dimmer('add content', $module);
141
- }
142
- else {
143
- module.set.undetached();
144
- }
145
- $dimmer = $dimmable.dimmer('get dimmer');
146
- },
147
- id: function() {
148
- id = (Math.random().toString(16) + '000000000').substr(2, 8);
149
- elementEventNamespace = '.' + id;
150
- module.verbose('Creating unique id for element', id);
151
- },
152
- innerDimmer: function() {
153
- if ( $module.find(selector.dimmer).length == 0 ) {
154
- $module.prepend('<div class="ui inverted dimmer"></div>');
155
- }
156
- }
157
- },
158
-
159
- destroy: function() {
160
- if (observer) {
161
- observer.disconnect();
162
- }
163
- module.verbose('Destroying previous modal');
164
- $module
165
- .removeData(moduleNamespace)
166
- .off(eventNamespace)
167
- ;
168
- $window.off(elementEventNamespace);
169
- $dimmer.off(elementEventNamespace);
170
- $close.off(eventNamespace);
171
- $context.dimmer('destroy');
172
- },
173
-
174
- observeChanges: function() {
175
- if('MutationObserver' in window) {
176
- observer = new MutationObserver(function(mutations) {
177
- module.debug('DOM tree modified, refreshing');
178
- module.refresh();
179
- });
180
- observer.observe(element, {
181
- childList : true,
182
- subtree : true
183
- });
184
- module.debug('Setting up mutation observer', observer);
185
- }
186
- },
187
-
188
- refresh: function() {
189
- module.remove.scrolling();
190
- module.cacheSizes();
191
- if(!module.can.useFlex()) {
192
- module.set.modalOffset();
193
- }
194
- module.set.screenHeight();
195
- module.set.type();
196
- },
197
-
198
- refreshModals: function() {
199
- $otherModals = $module.siblings(selector.modal);
200
- $allModals = $otherModals.add($module);
201
- },
202
-
203
- attachEvents: function(selector, event) {
204
- var
205
- $toggle = $(selector)
206
- ;
207
- event = $.isFunction(module[event])
208
- ? module[event]
209
- : module.toggle
210
- ;
211
- if($toggle.length > 0) {
212
- module.debug('Attaching modal events to element', selector, event);
213
- $toggle
214
- .off(eventNamespace)
215
- .on('click' + eventNamespace, event)
216
- ;
217
- }
218
- else {
219
- module.error(error.notFound, selector);
220
- }
221
- },
222
-
223
- bind: {
224
- events: function() {
225
- module.verbose('Attaching events');
226
- $module
227
- .on('click' + eventNamespace, selector.close, module.event.close)
228
- .on('click' + eventNamespace, selector.approve, module.event.approve)
229
- .on('click' + eventNamespace, selector.deny, module.event.deny)
230
- ;
231
- $window
232
- .on('resize' + elementEventNamespace, module.event.resize)
233
- ;
234
- },
235
- scrollLock: function() {
236
- // touch events default to passive, due to changes in chrome to optimize mobile perf
237
- $dimmable.get(0).addEventListener('touchmove', module.event.preventScroll, { passive: false });
238
- }
239
- },
240
-
241
- unbind: {
242
- scrollLock: function() {
243
- $dimmable.get(0).removeEventListener('touchmove', module.event.preventScroll, { passive: false });
244
- }
245
- },
246
-
247
- get: {
248
- id: function() {
249
- return (Math.random().toString(16) + '000000000').substr(2, 8);
250
- }
251
- },
252
-
253
- event: {
254
- approve: function() {
255
- if(ignoreRepeatedEvents || settings.onApprove.call(element, $(this)) === false) {
256
- module.verbose('Approve callback returned false cancelling hide');
257
- return;
258
- }
259
- ignoreRepeatedEvents = true;
260
- module.hide(function() {
261
- ignoreRepeatedEvents = false;
262
- });
263
- },
264
- preventScroll: function(event) {
265
- if(event.target.className.indexOf('dimmer') !== -1) {
266
- event.preventDefault();
267
- }
268
- },
269
- deny: function() {
270
- if(ignoreRepeatedEvents || settings.onDeny.call(element, $(this)) === false) {
271
- module.verbose('Deny callback returned false cancelling hide');
272
- return;
273
- }
274
- ignoreRepeatedEvents = true;
275
- module.hide(function() {
276
- ignoreRepeatedEvents = false;
277
- });
278
- },
279
- close: function() {
280
- module.hide();
281
- },
282
- mousedown: function(event) {
283
- var
284
- $target = $(event.target),
285
- isRtl = module.is.rtl();
286
- ;
287
- initialMouseDownInModal = ($target.closest(selector.modal).length > 0);
288
- if(initialMouseDownInModal) {
289
- module.verbose('Mouse down event registered inside the modal');
290
- }
291
- initialMouseDownInScrollbar = module.is.scrolling() && ((!isRtl && $(window).outerWidth() - settings.scrollbarWidth <= event.clientX) || (isRtl && settings.scrollbarWidth >= event.clientX));
292
- if(initialMouseDownInScrollbar) {
293
- module.verbose('Mouse down event registered inside the scrollbar');
294
- }
295
- },
296
- mouseup: function(event) {
297
- if(!settings.closable) {
298
- module.verbose('Dimmer clicked but closable setting is disabled');
299
- return;
300
- }
301
- if(initialMouseDownInModal) {
302
- module.debug('Dimmer clicked but mouse down was initially registered inside the modal');
303
- return;
304
- }
305
- if(initialMouseDownInScrollbar){
306
- module.debug('Dimmer clicked but mouse down was initially registered inside the scrollbar');
307
- return;
308
- }
309
- var
310
- $target = $(event.target),
311
- isInModal = ($target.closest(selector.modal).length > 0),
312
- isInDOM = $.contains(document.documentElement, event.target)
313
- ;
314
- if(!isInModal && isInDOM && module.is.active() && $module.hasClass(className.front) ) {
315
- module.debug('Dimmer clicked, hiding all modals');
316
- if(settings.allowMultiple) {
317
- if(!module.hideAll()) {
318
- return;
319
- }
320
- }
321
- else if(!module.hide()){
322
- return;
323
- }
324
- module.remove.clickaway();
325
- }
326
- },
327
- debounce: function(method, delay) {
328
- clearTimeout(module.timer);
329
- module.timer = setTimeout(method, delay);
330
- },
331
- keyboard: function(event) {
332
- var
333
- keyCode = event.which,
334
- escapeKey = 27
335
- ;
336
- if(keyCode == escapeKey) {
337
- if(settings.closable) {
338
- module.debug('Escape key pressed hiding modal');
339
- if ( $module.hasClass(className.front) ) {
340
- module.hide();
341
- }
342
- }
343
- else {
344
- module.debug('Escape key pressed, but closable is set to false');
345
- }
346
- event.preventDefault();
347
- }
348
- },
349
- resize: function() {
350
- if( $dimmable.dimmer('is active') && ( module.is.animating() || module.is.active() ) ) {
351
- requestAnimationFrame(module.refresh);
352
- }
353
- }
354
- },
355
-
356
- toggle: function() {
357
- if( module.is.active() || module.is.animating() ) {
358
- module.hide();
359
- }
360
- else {
361
- module.show();
362
- }
363
- },
364
-
365
- show: function(callback) {
366
- callback = $.isFunction(callback)
367
- ? callback
368
- : function(){}
369
- ;
370
- module.refreshModals();
371
- module.set.dimmerSettings();
372
- module.set.dimmerStyles();
373
-
374
- module.showModal(callback);
375
- },
376
-
377
- hide: function(callback) {
378
- callback = $.isFunction(callback)
379
- ? callback
380
- : function(){}
381
- ;
382
- module.refreshModals();
383
- return module.hideModal(callback);
384
- },
385
-
386
- showModal: function(callback) {
387
- callback = $.isFunction(callback)
388
- ? callback
389
- : function(){}
390
- ;
391
- if( module.is.animating() || !module.is.active() ) {
392
- module.showDimmer();
393
- module.cacheSizes();
394
- module.set.bodyMargin();
395
- if(module.can.useFlex()) {
396
- module.remove.legacy();
397
- }
398
- else {
399
- module.set.legacy();
400
- module.set.modalOffset();
401
- module.debug('Using non-flex legacy modal positioning.');
402
- }
403
- module.set.screenHeight();
404
- module.set.type();
405
- module.set.clickaway();
406
-
407
- if( !settings.allowMultiple && module.others.active() ) {
408
- module.hideOthers(module.showModal);
409
- }
410
- else {
411
- ignoreRepeatedEvents = false;
412
- if( settings.allowMultiple ) {
413
- if ( module.others.active() ) {
414
- $otherModals.filter('.' + className.active).find(selector.dimmer).addClass('active');
415
- }
416
-
417
- if ( settings.detachable ) {
418
- $module.detach().appendTo($dimmer);
419
- }
420
- }
421
- settings.onShow.call(element);
422
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
423
- module.debug('Showing modal with css animations');
424
- $module
425
- .transition({
426
- debug : settings.debug,
427
- animation : settings.transition + ' in',
428
- queue : settings.queue,
429
- duration : settings.duration,
430
- useFailSafe : true,
431
- onComplete : function() {
432
- settings.onVisible.apply(element);
433
- if(settings.keyboardShortcuts) {
434
- module.add.keyboardShortcuts();
435
- }
436
- module.save.focus();
437
- module.set.active();
438
- if(settings.autofocus) {
439
- module.set.autofocus();
440
- }
441
- callback();
442
- }
443
- })
444
- ;
445
- }
446
- else {
447
- module.error(error.noTransition);
448
- }
449
- }
450
- }
451
- else {
452
- module.debug('Modal is already visible');
453
- }
454
- },
455
-
456
- hideModal: function(callback, keepDimmed, hideOthersToo) {
457
- var
458
- $previousModal = $otherModals.filter('.' + className.active).last()
459
- ;
460
- callback = $.isFunction(callback)
461
- ? callback
462
- : function(){}
463
- ;
464
- module.debug('Hiding modal');
465
- if(settings.onHide.call(element, $(this)) === false) {
466
- module.verbose('Hide callback returned false cancelling hide');
467
- ignoreRepeatedEvents = false;
468
- return false;
469
- }
470
-
471
- if( module.is.animating() || module.is.active() ) {
472
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
473
- module.remove.active();
474
- $module
475
- .transition({
476
- debug : settings.debug,
477
- animation : settings.transition + ' out',
478
- queue : settings.queue,
479
- duration : settings.duration,
480
- useFailSafe : true,
481
- onStart : function() {
482
- if(!module.others.active() && !module.others.animating() && !keepDimmed) {
483
- module.hideDimmer();
484
- }
485
- if( settings.keyboardShortcuts && !module.others.active() ) {
486
- module.remove.keyboardShortcuts();
487
- }
488
- },
489
- onComplete : function() {
490
- module.unbind.scrollLock();
491
- if ( settings.allowMultiple ) {
492
- $previousModal.addClass(className.front);
493
- $module.removeClass(className.front);
494
-
495
- if ( hideOthersToo ) {
496
- $allModals.find(selector.dimmer).removeClass('active');
497
- }
498
- else {
499
- $previousModal.find(selector.dimmer).removeClass('active');
500
- }
501
- }
502
- settings.onHidden.call(element);
503
- module.remove.dimmerStyles();
504
- module.restore.focus();
505
- callback();
506
- }
507
- })
508
- ;
509
- }
510
- else {
511
- module.error(error.noTransition);
512
- }
513
- }
514
- },
515
-
516
- showDimmer: function() {
517
- if($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active') ) {
518
- module.save.bodyMargin();
519
- module.debug('Showing dimmer');
520
- $dimmable.dimmer('show');
521
- }
522
- else {
523
- module.debug('Dimmer already visible');
524
- }
525
- },
526
-
527
- hideDimmer: function() {
528
- if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) {
529
- module.unbind.scrollLock();
530
- $dimmable.dimmer('hide', function() {
531
- module.restore.bodyMargin();
532
- module.remove.clickaway();
533
- module.remove.screenHeight();
534
- });
535
- }
536
- else {
537
- module.debug('Dimmer is not visible cannot hide');
538
- return;
539
- }
540
- },
541
-
542
- hideAll: function(callback) {
543
- var
544
- $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating)
545
- ;
546
- callback = $.isFunction(callback)
547
- ? callback
548
- : function(){}
549
- ;
550
- if( $visibleModals.length > 0 ) {
551
- module.debug('Hiding all visible modals');
552
- var hideOk = true;
553
- //check in reverse order trying to hide most top displayed modal first
554
- $($visibleModals.get().reverse()).each(function(index,element){
555
- if(hideOk){
556
- hideOk = $(element).modal('hide modal', callback, false, true);
557
- }
558
- });
559
- if(hideOk) {
560
- module.hideDimmer();
561
- }
562
- return hideOk;
563
- }
564
- },
565
-
566
- hideOthers: function(callback) {
567
- var
568
- $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating)
569
- ;
570
- callback = $.isFunction(callback)
571
- ? callback
572
- : function(){}
573
- ;
574
- if( $visibleModals.length > 0 ) {
575
- module.debug('Hiding other modals', $otherModals);
576
- $visibleModals
577
- .modal('hide modal', callback, true)
578
- ;
579
- }
580
- },
581
-
582
- others: {
583
- active: function() {
584
- return ($otherModals.filter('.' + className.active).length > 0);
585
- },
586
- animating: function() {
587
- return ($otherModals.filter('.' + className.animating).length > 0);
588
- }
589
- },
590
-
591
-
592
- add: {
593
- keyboardShortcuts: function() {
594
- module.verbose('Adding keyboard shortcuts');
595
- $document
596
- .on('keyup' + eventNamespace, module.event.keyboard)
597
- ;
598
- }
599
- },
600
-
601
- save: {
602
- focus: function() {
603
- var
604
- $activeElement = $(document.activeElement),
605
- inCurrentModal = $activeElement.closest($module).length > 0
606
- ;
607
- if(!inCurrentModal) {
608
- $focusedElement = $(document.activeElement).blur();
609
- }
610
- },
611
- bodyMargin: function() {
612
- initialBodyMargin = $body.css('margin-'+(module.can.leftBodyScrollbar() ? 'left':'right'));
613
- var bodyMarginRightPixel = parseInt(initialBodyMargin.replace(/[^\d.]/g, '')),
614
- bodyScrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
615
- tempBodyMargin = bodyMarginRightPixel + bodyScrollbarWidth;
616
- }
617
- },
618
-
619
- restore: {
620
- focus: function() {
621
- if($focusedElement && $focusedElement.length > 0 && settings.restoreFocus) {
622
- $focusedElement.focus();
623
- }
624
- },
625
- bodyMargin: function() {
626
- var position = module.can.leftBodyScrollbar() ? 'left':'right';
627
- $body.css('margin-'+position, initialBodyMargin);
628
- $body.find(selector.bodyFixed.replace('right',position)).css('padding-'+position, initialBodyMargin);
629
- }
630
- },
631
-
632
- remove: {
633
- active: function() {
634
- $module.removeClass(className.active);
635
- },
636
- legacy: function() {
637
- $module.removeClass(className.legacy);
638
- },
639
- clickaway: function() {
640
- if (!settings.detachable) {
641
- $module
642
- .off('mousedown' + elementEventNamespace)
643
- ;
644
- }
645
- $dimmer
646
- .off('mousedown' + elementEventNamespace)
647
- ;
648
- $dimmer
649
- .off('mouseup' + elementEventNamespace)
650
- ;
651
- },
652
- dimmerStyles: function() {
653
- $dimmer.removeClass(className.inverted);
654
- $dimmable.removeClass(className.blurring);
655
- },
656
- bodyStyle: function() {
657
- if($body.attr('style') === '') {
658
- module.verbose('Removing style attribute');
659
- $body.removeAttr('style');
660
- }
661
- },
662
- screenHeight: function() {
663
- module.debug('Removing page height');
664
- $body
665
- .css('height', '')
666
- ;
667
- },
668
- keyboardShortcuts: function() {
669
- module.verbose('Removing keyboard shortcuts');
670
- $document
671
- .off('keyup' + eventNamespace)
672
- ;
673
- },
674
- scrolling: function() {
675
- $dimmable.removeClass(className.scrolling);
676
- $module.removeClass(className.scrolling);
677
- }
678
- },
679
-
680
- cacheSizes: function() {
681
- $module.addClass(className.loading);
682
- var
683
- scrollHeight = $module.prop('scrollHeight'),
684
- modalWidth = $module.outerWidth(),
685
- modalHeight = $module.outerHeight()
686
- ;
687
- if(module.cache.pageHeight === undefined || modalHeight !== 0) {
688
- $.extend(module.cache, {
689
- pageHeight : $(document).outerHeight(),
690
- width : modalWidth,
691
- height : modalHeight + settings.offset,
692
- scrollHeight : scrollHeight + settings.offset,
693
- contextHeight : (settings.context == 'body')
694
- ? $(window).height()
695
- : $dimmable.height(),
696
- });
697
- module.cache.topOffset = -(module.cache.height / 2);
698
- }
699
- $module.removeClass(className.loading);
700
- module.debug('Caching modal and container sizes', module.cache);
701
- },
702
-
703
- can: {
704
- leftBodyScrollbar: function(){
705
- if(module.cache.leftBodyScrollbar === undefined) {
706
- module.cache.leftBodyScrollbar = module.is.rtl() && ((module.is.iframe && !module.is.firefox()) || module.is.safari() || module.is.edge() || module.is.ie());
707
- }
708
- return module.cache.leftBodyScrollbar;
709
- },
710
- useFlex: function() {
711
- if (settings.useFlex === 'auto') {
712
- return settings.detachable && !module.is.ie();
713
- }
714
- if(settings.useFlex && module.is.ie()) {
715
- module.debug('useFlex true is not supported in IE');
716
- } else if(settings.useFlex && !settings.detachable) {
717
- module.debug('useFlex true in combination with detachable false is not supported');
718
- }
719
- return settings.useFlex;
720
- },
721
- fit: function() {
722
- var
723
- contextHeight = module.cache.contextHeight,
724
- verticalCenter = module.cache.contextHeight / 2,
725
- topOffset = module.cache.topOffset,
726
- scrollHeight = module.cache.scrollHeight,
727
- height = module.cache.height,
728
- paddingHeight = settings.padding,
729
- startPosition = (verticalCenter + topOffset)
730
- ;
731
- return (scrollHeight > height)
732
- ? (startPosition + scrollHeight + paddingHeight < contextHeight)
733
- : (height + (paddingHeight * 2) < contextHeight)
734
- ;
735
- }
736
- },
737
-
738
- is: {
739
- active: function() {
740
- return $module.hasClass(className.active);
741
- },
742
- ie: function() {
743
- if(module.cache.isIE === undefined) {
744
- var
745
- isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
746
- isIE = ('ActiveXObject' in window)
747
- ;
748
- module.cache.isIE = (isIE11 || isIE);
749
- }
750
- return module.cache.isIE;
751
- },
752
- animating: function() {
753
- return $module.transition('is supported')
754
- ? $module.transition('is animating')
755
- : $module.is(':visible')
756
- ;
757
- },
758
- scrolling: function() {
759
- return $dimmable.hasClass(className.scrolling);
760
- },
761
- modernBrowser: function() {
762
- // appName for IE11 reports 'Netscape' can no longer use
763
- return !(window.ActiveXObject || 'ActiveXObject' in window);
764
- },
765
- rtl: function() {
766
- if(module.cache.isRTL === undefined) {
767
- module.cache.isRTL = $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl';
768
- }
769
- return module.cache.isRTL;
770
- },
771
- safari: function() {
772
- if(module.cache.isSafari === undefined) {
773
- module.cache.isSafari = /constructor/i.test(window.HTMLElement) || !!window.ApplePaySession;
774
- }
775
- return module.cache.isSafari;
776
- },
777
- edge: function(){
778
- if(module.cache.isEdge === undefined) {
779
- module.cache.isEdge = !!window.setImmediate && !module.is.ie();
780
- }
781
- return module.cache.isEdge;
782
- },
783
- firefox: function(){
784
- if(module.cache.isFirefox === undefined) {
785
- module.cache.isFirefox = !!window.InstallTrigger;
786
- }
787
- return module.cache.isFirefox;
788
- },
789
- iframe: function() {
790
- return !(self === top);
791
- }
792
- },
793
-
794
- set: {
795
- autofocus: function() {
796
- var
797
- $inputs = $module.find('[tabindex], :input').filter(':visible').filter(function() {
798
- return $(this).closest('.disabled').length === 0;
799
- }),
800
- $autofocus = $inputs.filter('[autofocus]'),
801
- $input = ($autofocus.length > 0)
802
- ? $autofocus.first()
803
- : $inputs.first()
804
- ;
805
- if($input.length > 0) {
806
- $input.focus();
807
- }
808
- },
809
- bodyMargin: function() {
810
- var position = module.can.leftBodyScrollbar() ? 'left':'right';
811
- if(settings.detachable || module.can.fit()) {
812
- $body.css('margin-'+position, tempBodyMargin + 'px');
813
- }
814
- $body.find(selector.bodyFixed.replace('right',position)).css('padding-'+position, tempBodyMargin + 'px');
815
- },
816
- clickaway: function() {
817
- if (!settings.detachable) {
818
- $module
819
- .on('mousedown' + elementEventNamespace, module.event.mousedown)
820
- ;
821
- }
822
- $dimmer
823
- .on('mousedown' + elementEventNamespace, module.event.mousedown)
824
- ;
825
- $dimmer
826
- .on('mouseup' + elementEventNamespace, module.event.mouseup)
827
- ;
828
- },
829
- dimmerSettings: function() {
830
- if($.fn.dimmer === undefined) {
831
- module.error(error.dimmer);
832
- return;
833
- }
834
- var
835
- defaultSettings = {
836
- debug : settings.debug,
837
- dimmerName : 'modals',
838
- closable : 'auto',
839
- useFlex : module.can.useFlex(),
840
- duration : {
841
- show : settings.duration,
842
- hide : settings.duration
843
- }
844
- },
845
- dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
846
- ;
847
- if(settings.inverted) {
848
- dimmerSettings.variation = (dimmerSettings.variation !== undefined)
849
- ? dimmerSettings.variation + ' inverted'
850
- : 'inverted'
851
- ;
852
- }
853
- $context.dimmer('setting', dimmerSettings);
854
- },
855
- dimmerStyles: function() {
856
- if(settings.inverted) {
857
- $dimmer.addClass(className.inverted);
858
- }
859
- else {
860
- $dimmer.removeClass(className.inverted);
861
- }
862
- if(settings.blurring) {
863
- $dimmable.addClass(className.blurring);
864
- }
865
- else {
866
- $dimmable.removeClass(className.blurring);
867
- }
868
- },
869
- modalOffset: function() {
870
- if (!settings.detachable) {
871
- var canFit = module.can.fit();
872
- $module
873
- .css({
874
- top: (!$module.hasClass('aligned') && canFit)
875
- ? $(document).scrollTop() + (module.cache.contextHeight - module.cache.height) / 2
876
- : !canFit || $module.hasClass('top')
877
- ? $(document).scrollTop() + settings.padding
878
- : $(document).scrollTop() + (module.cache.contextHeight - module.cache.height - settings.padding),
879
- marginLeft: -(module.cache.width / 2)
880
- })
881
- ;
882
- } else {
883
- $module
884
- .css({
885
- marginTop: (!$module.hasClass('aligned') && module.can.fit())
886
- ? -(module.cache.height / 2)
887
- : settings.padding / 2,
888
- marginLeft: -(module.cache.width / 2)
889
- })
890
- ;
891
- }
892
- module.verbose('Setting modal offset for legacy mode');
893
- },
894
- screenHeight: function() {
895
- if( module.can.fit() ) {
896
- $body.css('height', '');
897
- }
898
- else if(!$module.hasClass('bottom')) {
899
- module.debug('Modal is taller than page content, resizing page height');
900
- $body
901
- .css('height', module.cache.height + (settings.padding * 2) )
902
- ;
903
- }
904
- },
905
- active: function() {
906
- $module.addClass(className.active + ' ' + className.front);
907
- $otherModals.filter('.' + className.active).removeClass(className.front);
908
- },
909
- scrolling: function() {
910
- $dimmable.addClass(className.scrolling);
911
- $module.addClass(className.scrolling);
912
- module.unbind.scrollLock();
913
- },
914
- legacy: function() {
915
- $module.addClass(className.legacy);
916
- },
917
- type: function() {
918
- if(module.can.fit()) {
919
- module.verbose('Modal fits on screen');
920
- if(!module.others.active() && !module.others.animating()) {
921
- module.remove.scrolling();
922
- module.bind.scrollLock();
923
- }
924
- }
925
- else if (!$module.hasClass('bottom')){
926
- module.verbose('Modal cannot fit on screen setting to scrolling');
927
- module.set.scrolling();
928
- } else {
929
- module.verbose('Bottom aligned modal not fitting on screen is unsupported for scrolling');
930
- }
931
- },
932
- undetached: function() {
933
- $dimmable.addClass(className.undetached);
934
- }
935
- },
936
-
937
- setting: function(name, value) {
938
- module.debug('Changing setting', name, value);
939
- if( $.isPlainObject(name) ) {
940
- $.extend(true, settings, name);
941
- }
942
- else if(value !== undefined) {
943
- if($.isPlainObject(settings[name])) {
944
- $.extend(true, settings[name], value);
945
- }
946
- else {
947
- settings[name] = value;
948
- }
949
- }
950
- else {
951
- return settings[name];
952
- }
953
- },
954
- internal: function(name, value) {
955
- if( $.isPlainObject(name) ) {
956
- $.extend(true, module, name);
957
- }
958
- else if(value !== undefined) {
959
- module[name] = value;
960
- }
961
- else {
962
- return module[name];
963
- }
964
- },
965
- debug: function() {
966
- if(!settings.silent && settings.debug) {
967
- if(settings.performance) {
968
- module.performance.log(arguments);
969
- }
970
- else {
971
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
972
- module.debug.apply(console, arguments);
973
- }
974
- }
975
- },
976
- verbose: function() {
977
- if(!settings.silent && settings.verbose && settings.debug) {
978
- if(settings.performance) {
979
- module.performance.log(arguments);
980
- }
981
- else {
982
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
983
- module.verbose.apply(console, arguments);
984
- }
985
- }
986
- },
987
- error: function() {
988
- if(!settings.silent) {
989
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
990
- module.error.apply(console, arguments);
991
- }
992
- },
993
- performance: {
994
- log: function(message) {
995
- var
996
- currentTime,
997
- executionTime,
998
- previousTime
999
- ;
1000
- if(settings.performance) {
1001
- currentTime = new Date().getTime();
1002
- previousTime = time || currentTime;
1003
- executionTime = currentTime - previousTime;
1004
- time = currentTime;
1005
- performance.push({
1006
- 'Name' : message[0],
1007
- 'Arguments' : [].slice.call(message, 1) || '',
1008
- 'Element' : element,
1009
- 'Execution Time' : executionTime
1010
- });
1011
- }
1012
- clearTimeout(module.performance.timer);
1013
- module.performance.timer = setTimeout(module.performance.display, 500);
1014
- },
1015
- display: function() {
1016
- var
1017
- title = settings.name + ':',
1018
- totalTime = 0
1019
- ;
1020
- time = false;
1021
- clearTimeout(module.performance.timer);
1022
- $.each(performance, function(index, data) {
1023
- totalTime += data['Execution Time'];
1024
- });
1025
- title += ' ' + totalTime + 'ms';
1026
- if(moduleSelector) {
1027
- title += ' \'' + moduleSelector + '\'';
1028
- }
1029
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
1030
- console.groupCollapsed(title);
1031
- if(console.table) {
1032
- console.table(performance);
1033
- }
1034
- else {
1035
- $.each(performance, function(index, data) {
1036
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
1037
- });
1038
- }
1039
- console.groupEnd();
1040
- }
1041
- performance = [];
1042
- }
1043
- },
1044
- invoke: function(query, passedArguments, context) {
1045
- var
1046
- object = instance,
1047
- maxDepth,
1048
- found,
1049
- response
1050
- ;
1051
- passedArguments = passedArguments || queryArguments;
1052
- context = element || context;
1053
- if(typeof query == 'string' && object !== undefined) {
1054
- query = query.split(/[\. ]/);
1055
- maxDepth = query.length - 1;
1056
- $.each(query, function(depth, value) {
1057
- var camelCaseValue = (depth != maxDepth)
1058
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1059
- : query
1060
- ;
1061
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
1062
- object = object[camelCaseValue];
1063
- }
1064
- else if( object[camelCaseValue] !== undefined ) {
1065
- found = object[camelCaseValue];
1066
- return false;
1067
- }
1068
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
1069
- object = object[value];
1070
- }
1071
- else if( object[value] !== undefined ) {
1072
- found = object[value];
1073
- return false;
1074
- }
1075
- else {
1076
- return false;
1077
- }
1078
- });
1079
- }
1080
- if ( $.isFunction( found ) ) {
1081
- response = found.apply(context, passedArguments);
1082
- }
1083
- else if(found !== undefined) {
1084
- response = found;
1085
- }
1086
- if(Array.isArray(returnedValue)) {
1087
- returnedValue.push(response);
1088
- }
1089
- else if(returnedValue !== undefined) {
1090
- returnedValue = [returnedValue, response];
1091
- }
1092
- else if(response !== undefined) {
1093
- returnedValue = response;
1094
- }
1095
- return found;
1096
- }
1097
- };
1098
-
1099
- if(methodInvoked) {
1100
- if(instance === undefined) {
1101
- module.initialize();
1102
- }
1103
- module.invoke(query);
1104
- }
1105
- else {
1106
- if(instance !== undefined) {
1107
- instance.invoke('destroy');
1108
- }
1109
- module.initialize();
1110
- }
1111
- })
1112
- ;
1113
-
1114
- return (returnedValue !== undefined)
1115
- ? returnedValue
1116
- : this
1117
- ;
1118
- };
1119
-
1120
- $.fn.modal.settings = {
1121
-
1122
- name : 'Modal',
1123
- namespace : 'modal',
1124
-
1125
- useFlex : 'auto',
1126
- offset : 0,
1127
-
1128
- silent : false,
1129
- debug : false,
1130
- verbose : false,
1131
- performance : true,
1132
-
1133
- observeChanges : false,
1134
-
1135
- allowMultiple : false,
1136
- detachable : true,
1137
- closable : true,
1138
- autofocus : true,
1139
- restoreFocus : true,
1140
-
1141
- inverted : false,
1142
- blurring : false,
1143
-
1144
- centered : true,
1145
-
1146
- dimmerSettings : {
1147
- closable : false,
1148
- useCSS : true
1149
- },
1150
-
1151
- // whether to use keyboard shortcuts
1152
- keyboardShortcuts: true,
1153
-
1154
- context : 'body',
1155
-
1156
- queue : false,
1157
- duration : 500,
1158
- transition : 'scale',
1159
-
1160
- // padding with edge of page
1161
- padding : 50,
1162
- scrollbarWidth: 10,
1163
-
1164
- // called before show animation
1165
- onShow : function(){},
1166
-
1167
- // called after show animation
1168
- onVisible : function(){},
1169
-
1170
- // called before hide animation
1171
- onHide : function(){ return true; },
1172
-
1173
- // called after hide animation
1174
- onHidden : function(){},
1175
-
1176
- // called after approve selector match
1177
- onApprove : function(){ return true; },
1178
-
1179
- // called after deny selector match
1180
- onDeny : function(){ return true; },
1181
-
1182
- selector : {
1183
- close : '> .close',
1184
- approve : '.actions .positive, .actions .approve, .actions .ok',
1185
- deny : '.actions .negative, .actions .deny, .actions .cancel',
1186
- modal : '.ui.modal',
1187
- dimmer : '> .ui.dimmer',
1188
- bodyFixed: '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar'
1189
- },
1190
- error : {
1191
- dimmer : 'UI Dimmer, a required component is not included in this page',
1192
- method : 'The method you called is not defined.',
1193
- notFound : 'The element you specified could not be found'
1194
- },
1195
- className : {
1196
- active : 'active',
1197
- animating : 'animating',
1198
- blurring : 'blurring',
1199
- inverted : 'inverted',
1200
- legacy : 'legacy',
1201
- loading : 'loading',
1202
- scrolling : 'scrolling',
1203
- undetached : 'undetached',
1204
- front : 'front'
1205
- }
1206
- };
1207
-
1208
-
1209
- })( jQuery, window, document );
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);