@ntlab/ntjs-assets 2.0.2 → 2.0.3

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