fomantic-ui 2.9.1-beta.17 → 2.9.1-beta.19

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 (252) hide show
  1. package/.eslintrc.js +109 -0
  2. package/.github/workflows/ci.yml +13 -3
  3. package/dist/components/accordion.css +1 -1
  4. package/dist/components/accordion.js +569 -598
  5. package/dist/components/accordion.min.css +1 -1
  6. package/dist/components/accordion.min.js +2 -2
  7. package/dist/components/ad.css +1 -1
  8. package/dist/components/ad.min.css +1 -1
  9. package/dist/components/api.js +1161 -1184
  10. package/dist/components/api.min.js +2 -2
  11. package/dist/components/breadcrumb.css +1 -1
  12. package/dist/components/breadcrumb.min.css +1 -1
  13. package/dist/components/button.css +1 -1
  14. package/dist/components/button.min.css +1 -1
  15. package/dist/components/calendar.css +1 -1
  16. package/dist/components/calendar.js +1895 -1818
  17. package/dist/components/calendar.min.css +1 -1
  18. package/dist/components/calendar.min.js +2 -2
  19. package/dist/components/card.css +1 -1
  20. package/dist/components/card.min.css +1 -1
  21. package/dist/components/checkbox.css +1 -1
  22. package/dist/components/checkbox.js +842 -841
  23. package/dist/components/checkbox.min.css +1 -1
  24. package/dist/components/checkbox.min.js +2 -2
  25. package/dist/components/comment.css +1 -1
  26. package/dist/components/comment.min.css +1 -1
  27. package/dist/components/container.css +3 -1
  28. package/dist/components/container.min.css +2 -2
  29. package/dist/components/dimmer.css +1 -1
  30. package/dist/components/dimmer.js +708 -737
  31. package/dist/components/dimmer.min.css +1 -1
  32. package/dist/components/dimmer.min.js +2 -2
  33. package/dist/components/divider.css +1 -1
  34. package/dist/components/divider.min.css +1 -1
  35. package/dist/components/dropdown.css +11 -8
  36. package/dist/components/dropdown.js +4161 -4238
  37. package/dist/components/dropdown.min.css +2 -2
  38. package/dist/components/dropdown.min.js +2 -2
  39. package/dist/components/embed.css +1 -1
  40. package/dist/components/embed.js +651 -675
  41. package/dist/components/embed.min.css +1 -1
  42. package/dist/components/embed.min.js +2 -2
  43. package/dist/components/feed.css +1 -1
  44. package/dist/components/feed.min.css +1 -1
  45. package/dist/components/flag.css +1 -1
  46. package/dist/components/flag.min.css +1 -1
  47. package/dist/components/flyout.css +6 -3
  48. package/dist/components/flyout.js +1464 -1467
  49. package/dist/components/flyout.min.css +2 -2
  50. package/dist/components/flyout.min.js +2 -2
  51. package/dist/components/form.css +1 -1
  52. package/dist/components/form.js +1979 -2004
  53. package/dist/components/form.min.css +1 -1
  54. package/dist/components/form.min.js +2 -2
  55. package/dist/components/grid.css +1 -1
  56. package/dist/components/grid.min.css +1 -1
  57. package/dist/components/header.css +1 -1
  58. package/dist/components/header.min.css +1 -1
  59. package/dist/components/icon.css +1 -1
  60. package/dist/components/icon.min.css +1 -1
  61. package/dist/components/image.css +1 -1
  62. package/dist/components/image.min.css +1 -1
  63. package/dist/components/input.css +1 -1
  64. package/dist/components/input.min.css +1 -1
  65. package/dist/components/item.css +1 -1
  66. package/dist/components/item.min.css +1 -1
  67. package/dist/components/label.css +1 -1
  68. package/dist/components/label.min.css +1 -1
  69. package/dist/components/list.css +1 -1
  70. package/dist/components/list.min.css +1 -1
  71. package/dist/components/loader.css +1 -1
  72. package/dist/components/loader.min.css +1 -1
  73. package/dist/components/message.css +1 -1
  74. package/dist/components/message.min.css +1 -1
  75. package/dist/components/modal.css +7 -1
  76. package/dist/components/modal.js +1491 -1487
  77. package/dist/components/modal.min.css +2 -2
  78. package/dist/components/modal.min.js +2 -2
  79. package/dist/components/nag.css +1 -1
  80. package/dist/components/nag.js +518 -529
  81. package/dist/components/nag.min.css +1 -1
  82. package/dist/components/nag.min.js +2 -2
  83. package/dist/components/placeholder.css +1 -1
  84. package/dist/components/placeholder.min.css +1 -1
  85. package/dist/components/popup.css +1 -1
  86. package/dist/components/popup.js +1437 -1456
  87. package/dist/components/popup.min.css +1 -1
  88. package/dist/components/popup.min.js +2 -2
  89. package/dist/components/progress.css +1 -1
  90. package/dist/components/progress.js +969 -997
  91. package/dist/components/progress.min.css +1 -1
  92. package/dist/components/progress.min.js +2 -2
  93. package/dist/components/rail.css +1 -1
  94. package/dist/components/rail.min.css +1 -1
  95. package/dist/components/rating.css +1 -1
  96. package/dist/components/rating.js +505 -523
  97. package/dist/components/rating.min.css +1 -1
  98. package/dist/components/rating.min.js +2 -2
  99. package/dist/components/reset.css +1 -1
  100. package/dist/components/reset.min.css +1 -1
  101. package/dist/components/reveal.css +1 -1
  102. package/dist/components/reveal.min.css +1 -1
  103. package/dist/components/search.css +3 -1
  104. package/dist/components/search.js +1498 -1534
  105. package/dist/components/search.min.css +2 -2
  106. package/dist/components/search.min.js +2 -2
  107. package/dist/components/segment.css +3 -1
  108. package/dist/components/segment.min.css +2 -2
  109. package/dist/components/shape.css +1 -1
  110. package/dist/components/shape.js +792 -809
  111. package/dist/components/shape.min.css +1 -1
  112. package/dist/components/shape.min.js +2 -2
  113. package/dist/components/sidebar.css +3 -1
  114. package/dist/components/sidebar.js +1071 -1098
  115. package/dist/components/sidebar.min.css +2 -2
  116. package/dist/components/sidebar.min.js +2 -2
  117. package/dist/components/site.css +1 -1
  118. package/dist/components/site.js +462 -471
  119. package/dist/components/site.min.css +1 -1
  120. package/dist/components/site.min.js +2 -2
  121. package/dist/components/slider.js +1287 -1311
  122. package/dist/components/slider.min.js +2 -2
  123. package/dist/components/state.js +639 -657
  124. package/dist/components/state.min.js +2 -2
  125. package/dist/components/statistic.css +1 -1
  126. package/dist/components/statistic.min.css +1 -1
  127. package/dist/components/step.css +1 -1
  128. package/dist/components/step.min.css +1 -1
  129. package/dist/components/sticky.css +1 -1
  130. package/dist/components/sticky.js +857 -903
  131. package/dist/components/sticky.min.css +1 -1
  132. package/dist/components/sticky.min.js +2 -2
  133. package/dist/components/tab.css +1 -1
  134. package/dist/components/tab.js +922 -963
  135. package/dist/components/tab.min.css +1 -1
  136. package/dist/components/tab.min.js +2 -2
  137. package/dist/components/table.css +5 -1
  138. package/dist/components/table.min.css +2 -2
  139. package/dist/components/text.css +1 -1
  140. package/dist/components/text.min.css +1 -1
  141. package/dist/components/toast.css +1 -1
  142. package/dist/components/toast.js +886 -890
  143. package/dist/components/toast.min.css +1 -1
  144. package/dist/components/toast.min.js +2 -2
  145. package/dist/components/transition.css +1 -1
  146. package/dist/components/transition.js +1041 -1077
  147. package/dist/components/transition.min.css +1 -1
  148. package/dist/components/transition.min.js +2 -2
  149. package/dist/components/visibility.js +1220 -1244
  150. package/dist/components/visibility.min.js +2 -2
  151. package/dist/semantic.css +84 -60
  152. package/dist/semantic.js +28949 -29435
  153. package/dist/semantic.min.css +2 -2
  154. package/dist/semantic.min.js +2 -2
  155. package/examples/assets/show-examples.js +13 -13
  156. package/gulpfile.js +9 -10
  157. package/package.json +5 -2
  158. package/scripts/nightly-version.js +81 -75
  159. package/src/definitions/behaviors/api.js +1162 -1185
  160. package/src/definitions/behaviors/form.js +1978 -2003
  161. package/src/definitions/behaviors/state.js +645 -663
  162. package/src/definitions/behaviors/visibility.js +1219 -1243
  163. package/src/definitions/collections/table.less +2 -0
  164. package/src/definitions/elements/container.less +1 -0
  165. package/src/definitions/elements/segment.less +1 -0
  166. package/src/definitions/globals/site.js +461 -470
  167. package/src/definitions/modules/accordion.js +568 -597
  168. package/src/definitions/modules/calendar.js +1894 -1817
  169. package/src/definitions/modules/checkbox.js +841 -840
  170. package/src/definitions/modules/dimmer.js +707 -736
  171. package/src/definitions/modules/dropdown.js +4160 -4237
  172. package/src/definitions/modules/dropdown.less +5 -8
  173. package/src/definitions/modules/embed.js +650 -674
  174. package/src/definitions/modules/flyout.js +1463 -1466
  175. package/src/definitions/modules/flyout.less +15 -12
  176. package/src/definitions/modules/modal.js +1490 -1486
  177. package/src/definitions/modules/modal.less +3 -0
  178. package/src/definitions/modules/nag.js +517 -528
  179. package/src/definitions/modules/popup.js +1436 -1455
  180. package/src/definitions/modules/progress.js +968 -996
  181. package/src/definitions/modules/rating.js +504 -522
  182. package/src/definitions/modules/search.js +1497 -1533
  183. package/src/definitions/modules/search.less +1 -0
  184. package/src/definitions/modules/shape.js +791 -808
  185. package/src/definitions/modules/sidebar.js +1070 -1097
  186. package/src/definitions/modules/sidebar.less +1 -0
  187. package/src/definitions/modules/slider.js +1286 -1310
  188. package/src/definitions/modules/sticky.js +873 -919
  189. package/src/definitions/modules/tab.js +921 -962
  190. package/src/definitions/modules/toast.js +885 -889
  191. package/src/definitions/modules/transition.js +1040 -1076
  192. package/src/themes/default/elements/container.variables +0 -7
  193. package/src/themes/default/elements/segment.variables +0 -7
  194. package/src/themes/default/globals/site.variables +7 -0
  195. package/src/themes/default/globals/variation.variables +1 -0
  196. package/tasks/admin/components/create.js +274 -276
  197. package/tasks/admin/components/init.js +123 -130
  198. package/tasks/admin/components/update.js +149 -157
  199. package/tasks/admin/distributions/create.js +184 -187
  200. package/tasks/admin/distributions/init.js +123 -130
  201. package/tasks/admin/distributions/update.js +145 -152
  202. package/tasks/admin/publish.js +5 -7
  203. package/tasks/admin/register.js +36 -38
  204. package/tasks/admin/release.js +8 -10
  205. package/tasks/build/assets.js +42 -39
  206. package/tasks/build/css.js +225 -216
  207. package/tasks/build/javascript.js +118 -113
  208. package/tasks/build.js +10 -10
  209. package/tasks/check-install.js +14 -16
  210. package/tasks/clean.js +5 -5
  211. package/tasks/collections/admin.js +34 -36
  212. package/tasks/collections/build.js +18 -20
  213. package/tasks/collections/docs.js +9 -11
  214. package/tasks/collections/install.js +9 -11
  215. package/tasks/collections/rtl.js +9 -11
  216. package/tasks/collections/various.js +8 -10
  217. package/tasks/config/admin/github.js +17 -17
  218. package/tasks/config/admin/oauth.example.js +4 -4
  219. package/tasks/config/admin/release.js +98 -98
  220. package/tasks/config/admin/templates/component-package.js +9 -10
  221. package/tasks/config/admin/templates/css-package.js +18 -20
  222. package/tasks/config/admin/templates/less-package.js +11 -13
  223. package/tasks/config/defaults.js +116 -116
  224. package/tasks/config/docs.js +23 -23
  225. package/tasks/config/npm/gulpfile.js +8 -9
  226. package/tasks/config/project/config.js +127 -134
  227. package/tasks/config/project/install.js +715 -713
  228. package/tasks/config/project/release.js +32 -38
  229. package/tasks/config/tasks.js +163 -164
  230. package/tasks/config/user.js +23 -29
  231. package/tasks/docs/build.js +97 -95
  232. package/tasks/docs/metadata.js +90 -96
  233. package/tasks/docs/serve.js +80 -81
  234. package/tasks/install.js +370 -378
  235. package/tasks/rtl/build.js +2 -2
  236. package/tasks/rtl/watch.js +2 -2
  237. package/tasks/version.js +4 -4
  238. package/tasks/watch.js +28 -30
  239. package/test/meteor/assets.js +10 -13
  240. package/test/meteor/fonts.js +12 -13
  241. package/test/modules/accordion.spec.js +6 -8
  242. package/test/modules/checkbox.spec.js +5 -7
  243. package/test/modules/dropdown.spec.js +5 -7
  244. package/test/modules/modal.spec.js +6 -8
  245. package/test/modules/module.spec.js +158 -178
  246. package/test/modules/popup.spec.js +5 -7
  247. package/test/modules/search.spec.js +5 -7
  248. package/test/modules/shape.spec.js +5 -7
  249. package/test/modules/sidebar.spec.js +5 -7
  250. package/test/modules/tab.spec.js +6 -8
  251. package/test/modules/transition.spec.js +5 -7
  252. package/test/modules/video.spec.js +5 -7
@@ -8,1525 +8,1522 @@
8
8
  *
9
9
  */
10
10
 
11
- ;(function ($, window, document, undefined) {
12
-
13
- 'use strict';
14
-
15
- function isFunction(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
- $.flyout = $.fn.flyout = function(parameters) {
27
- var
28
- $allModules = $(this),
29
- $window = $(window),
30
- $document = $(document),
31
- $html = $('html'),
32
- $head = $('head'),
33
- $body = $('body'),
34
-
35
- moduleSelector = $allModules.selector || '',
36
-
37
- time = new Date().getTime(),
38
- performance = [],
39
-
40
- query = arguments[0],
41
- methodInvoked = (typeof query == 'string'),
42
- queryArguments = [].slice.call(arguments, 1),
43
-
44
- requestAnimationFrame = window.requestAnimationFrame
45
- || window.mozRequestAnimationFrame
46
- || window.webkitRequestAnimationFrame
47
- || window.msRequestAnimationFrame
48
- || function(callback) { setTimeout(callback, 0); },
49
-
50
- returnedValue
51
- ;
52
-
53
- $allModules
54
- .each(function() {
55
- var
56
- settings = ( $.isPlainObject(parameters) )
57
- ? $.extend(true, {}, $.fn.flyout.settings, parameters)
58
- : $.extend({}, $.fn.flyout.settings),
59
-
60
- selector = settings.selector,
61
- className = settings.className,
62
- namespace = settings.namespace,
63
- fields = settings.fields,
64
- regExp = settings.regExp,
65
- error = settings.error,
66
-
67
- eventNamespace = '.' + namespace,
68
- moduleNamespace = 'module-' + namespace,
69
-
70
- $module = $(this),
71
- $context = [window,document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $body,
72
- $closeIcon = $module.find(selector.close),
73
- $inputs,
74
- $focusedElement,
75
-
76
- $flyouts = $module.children(selector.flyout),
77
- $pusher = $context.children(selector.pusher),
78
- $style,
79
-
80
- isFlyoutComponent = $module.hasClass('flyout'),
81
-
82
- element = this,
83
- instance = isFlyoutComponent ? $module.data(moduleNamespace) : undefined,
84
-
85
- ignoreRepeatedEvents = false,
86
- isBody = $context[0] === $body[0],
87
- initialBodyMargin = '',
88
- tempBodyMargin = '',
89
- hadScrollbar = false,
90
-
91
- elementNamespace,
92
- id,
93
- observer,
94
- currentScroll,
95
- transitionEvent,
96
-
97
- module
98
- ;
99
-
100
- module = {
101
-
102
- initialize: function() {
103
- module.debug('Initializing flyout', parameters);
104
-
105
- module.create.id();
106
- if(!isFlyoutComponent) {
107
- module.create.flyout();
108
- if(!isFunction(settings.onHidden)) {
109
- settings.onHidden = function () {
110
- module.destroy();
111
- $module.remove();
112
- };
113
- }
114
- if(!settings.autoShow) {
115
- settings.autoShow = true;
116
- }
117
- }
118
- $module.addClass(settings.class);
119
- if (settings.title !== '') {
120
- $module.find(selector.header).html(module.helpers.escape(settings.title, settings.preserveHTML)).addClass(settings.classTitle);
121
- }
122
- if (settings.content !== '') {
123
- $module.find(selector.content).html(module.helpers.escape(settings.content, settings.preserveHTML)).addClass(settings.classContent);
124
- }
125
- if(module.has.configActions()){
126
- var $actions = $module.find(selector.actions).addClass(settings.classActions);
127
- if ($actions.length === 0) {
128
- $actions = $('<div/>', {class: className.actions + ' ' + (settings.classActions || '')}).appendTo($module);
129
- } else {
130
- $actions.empty();
131
- }
132
- settings.actions.forEach(function (el) {
133
- var
134
- icon = el[fields.icon] ? '<i '+(el[fields.text] ? 'aria-hidden="true"' : '')+' class="' + module.helpers.deQuote(el[fields.icon]) + ' icon"></i>' : '',
135
- text = module.helpers.escape(el[fields.text] || '', settings.preserveHTML),
136
- cls = module.helpers.deQuote(el[fields.class] || ''),
137
- click = el[fields.click] && isFunction(el[fields.click]) ? el[fields.click] : function () {}
138
- ;
139
- $actions.append($('<button/>', {
140
- html: icon + text,
141
- 'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g,''),
142
- class: className.button + ' ' + cls,
143
- on: {
144
- click: function () {
145
- if (click.call(element, $module) === false) {
146
- return;
147
- }
148
- module.hide();
149
- }
150
- }
151
- }));
152
- });
153
- }
154
-
155
- transitionEvent = module.get.transitionEvent();
156
-
157
- // avoids locking rendering if initialized in onReady
158
- if(settings.delaySetup) {
159
- requestAnimationFrame(module.setup.layout);
160
- }
161
- else {
162
- module.setup.layout();
163
- }
164
-
165
- requestAnimationFrame(function() {
166
- module.setup.cache();
167
- });
168
-
169
- if (module.get.direction() == 'left' || module.get.direction() == 'right') {
170
- module.setup.heights();
171
- module.bind.resize();
172
- }
173
- module.bind.events();
174
- module.observeChanges();
175
- module.instantiate();
176
-
177
- if(settings.autoShow){
178
- module.show();
179
- }
180
- },
11
+ (function ($, window, document, undefined) {
12
+ 'use strict';
181
13
 
182
- instantiate: function() {
183
- module.verbose('Storing instance of module', module);
184
- instance = module;
185
- $module
186
- .data(moduleNamespace, instance)
187
- ;
188
- },
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
189
17
 
190
- create: {
191
- flyout: function() {
192
- module.verbose('Programmaticaly create flyout', $context);
193
- $module = $('<div/>', {class: className.flyout, role: 'dialog', 'aria-modal': settings.dimPage});
194
- if (settings.closeIcon) {
195
- $closeIcon = $('<i/>', {class: className.close, role: 'button', tabindex: 0, 'aria-label': settings.text.close})
196
- $module.append($closeIcon);
197
- }
198
- if (settings.title !== '') {
199
- var titleId = '_' + module.get.id() + 'title';
200
- $module.attr('aria-labelledby', titleId);
201
- $('<div/>', {class: className.header, id: titleId}).appendTo($module);
202
- }
203
- if (settings.content !== '') {
204
- var descId = '_' + module.get.id() + 'desc';
205
- $module.attr('aria-describedby', descId);
206
- $('<div/>', {class: className.content, id: descId}).appendTo($module);
207
- }
208
- if (module.has.configActions()) {
209
- $('<div/>', {class: className.actions}).appendTo($module);
210
- }
211
- $module.prependTo($context);
212
- element = $module[0];
213
- },
214
- id: function() {
215
- id = (Math.random().toString(16) + '000000000').slice(2, 10);
216
- elementNamespace = '.' + id;
217
- module.verbose('Creating unique id for element', id);
218
- }
219
- },
18
+ window = (typeof window != 'undefined' && window.Math == Math)
19
+ ? window
20
+ : globalThis;
21
+
22
+ $.flyout = $.fn.flyout = function (parameters) {
23
+ var
24
+ $allModules = $(this),
25
+ $window = $(window),
26
+ $document = $(document),
27
+ $html = $('html'),
28
+ $head = $('head'),
29
+ $body = $('body'),
30
+
31
+ moduleSelector = $allModules.selector || '',
32
+
33
+ time = new Date().getTime(),
34
+ performance = [],
35
+
36
+ query = arguments[0],
37
+ methodInvoked = (typeof query == 'string'),
38
+ queryArguments = [].slice.call(arguments, 1),
39
+
40
+ requestAnimationFrame = window.requestAnimationFrame
41
+ || window.mozRequestAnimationFrame
42
+ || window.webkitRequestAnimationFrame
43
+ || window.msRequestAnimationFrame
44
+ || function (callback) {
45
+ setTimeout(callback, 0);
46
+ },
220
47
 
221
- destroy: function() {
222
- if (observer) {
223
- observer.disconnect();
224
- }
225
- module.verbose('Destroying previous module for', $module);
226
- $module
227
- .off(eventNamespace)
228
- .removeData(moduleNamespace)
229
- ;
230
- if(module.is.ios()) {
231
- module.remove.ios();
232
- }
233
- $closeIcon.off(elementNamespace);
234
- if($inputs) {
235
- $inputs.off(elementNamespace);
236
- }
237
- // bound by uuid
238
- $context.off(elementNamespace);
239
- $window.off(elementNamespace);
240
- $document.off(elementNamespace);
241
- },
48
+ returnedValue
49
+ ;
242
50
 
243
- event: {
244
- keyboard: function(event) {
245
- var
246
- keyCode = event.which
247
- ;
248
- if(keyCode === settings.keys.escape) {
249
- if(settings.closable) {
250
- module.debug('Escape key pressed hiding flyout');
251
- module.hide();
252
- }
253
- else {
254
- module.debug('Escape key pressed, but closable is set to false');
255
- }
256
- event.preventDefault();
257
- }
258
- },
259
- resize: function() {
260
- module.setup.heights();
261
- },
262
- clickaway: function(event) {
263
- if(settings.closable){
264
- var
265
- clickedInPusher = ($pusher.find(event.target).length > 0 || $pusher.is(event.target)),
266
- clickedContext = ($context.is(event.target))
267
- ;
268
- if(clickedInPusher) {
269
- module.verbose('User clicked on dimmed page');
270
- module.hide();
271
- }
272
- if(clickedContext) {
273
- module.verbose('User clicked on dimmable context (scaled out page)');
274
- module.hide();
275
- }
276
- }
277
- },
278
- close: function(event) {
279
- module.hide();
280
- },
281
- closeKeyUp: function(event){
51
+ $allModules.each(function () {
282
52
  var
283
- keyCode = event.which
53
+ settings = ($.isPlainObject(parameters))
54
+ ? $.extend(true, {}, $.fn.flyout.settings, parameters)
55
+ : $.extend({}, $.fn.flyout.settings),
56
+
57
+ selector = settings.selector,
58
+ className = settings.className,
59
+ namespace = settings.namespace,
60
+ fields = settings.fields,
61
+ regExp = settings.regExp,
62
+ error = settings.error,
63
+
64
+ eventNamespace = '.' + namespace,
65
+ moduleNamespace = 'module-' + namespace,
66
+
67
+ $module = $(this),
68
+ $context = [window, document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $body,
69
+ $closeIcon = $module.find(selector.close),
70
+ $inputs,
71
+ $focusedElement,
72
+
73
+ $flyouts = $module.children(selector.flyout),
74
+ $pusher = $context.children(selector.pusher),
75
+ $style,
76
+
77
+ isFlyoutComponent = $module.hasClass('flyout'),
78
+
79
+ element = this,
80
+ instance = isFlyoutComponent ? $module.data(moduleNamespace) : undefined,
81
+
82
+ ignoreRepeatedEvents = false,
83
+ isBody = $context[0] === $body[0],
84
+ initialBodyMargin = '',
85
+ tempBodyMargin = '',
86
+ hadScrollbar = false,
87
+
88
+ elementNamespace,
89
+ id,
90
+ observer,
91
+ currentScroll,
92
+ transitionEvent,
93
+
94
+ module
284
95
  ;
285
- if (keyCode === settings.keys.enter || keyCode === settings.keys.space) {
286
- module.hide();
287
- }
288
- },
289
- inputKeyDown: {
290
- first: function(event) {
291
- var
292
- keyCode = event.which
293
- ;
294
- if (keyCode === settings.keys.tab && event.shiftKey) {
295
- $inputs.last().trigger('focus');
296
- event.preventDefault();
297
- }
298
- },
299
- last: function(event) {
300
- var
301
- keyCode = event.which
302
- ;
303
- if (keyCode === settings.keys.tab && !event.shiftKey) {
304
- $inputs.first().trigger('focus');
305
- event.preventDefault();
306
- }
307
- }
308
- },
309
- approve: function(event) {
310
- if (ignoreRepeatedEvents || settings.onApprove.call(module.element, $(this)) === false) {
311
- module.verbose('Approve callback returned false cancelling close');
312
- return;
313
- }
314
- ignoreRepeatedEvents = true;
315
- module.hide(function() {
316
- ignoreRepeatedEvents = false;
317
- });
318
- },
319
- deny: function(event) {
320
- if (ignoreRepeatedEvents || settings.onDeny.call(module.element, $(this)) === false) {
321
- module.verbose('Deny callback returned false cancelling close');
322
- return;
323
- }
324
- ignoreRepeatedEvents = true;
325
- module.hide(function() {
326
- ignoreRepeatedEvents = false;
327
- });
328
- },
329
- touch: function(event) {
330
- //event.stopPropagation();
331
- },
332
- containScroll: function(event) {
333
- if(element.scrollTop <= 0) {
334
- element.scrollTop = 1;
335
- }
336
- if((element.scrollTop + element.offsetHeight) >= element.scrollHeight) {
337
- element.scrollTop = element.scrollHeight - element.offsetHeight - 1;
338
- }
339
- },
340
- scroll: function(event) {
341
- if( $(event.target).closest(selector.flyout).length === 0 ) {
342
- event.preventDefault();
343
- }
344
- }
345
- },
346
96
 
347
- bind: {
348
- resize: function() {
349
- module.verbose('Adding resize event to window', $window);
350
- $window.on('resize' + elementNamespace, module.event.resize);
351
- },
352
- events: function() {
353
- module.verbose('Attaching events');
354
- $module
355
- .on('click' + eventNamespace, selector.close, module.event.close)
356
- .on('click' + eventNamespace, selector.approve, module.event.approve)
357
- .on('click' + eventNamespace, selector.deny, module.event.deny)
358
- ;
359
- $closeIcon
360
- .on('keyup' + elementNamespace, module.event.closeKeyUp)
361
- ;
362
- },
363
- clickaway: function() {
364
- module.verbose('Adding clickaway events to context', $context);
365
- $context
366
- .on('click' + elementNamespace, module.event.clickaway)
367
- .on('touchend' + elementNamespace, module.event.clickaway)
368
- ;
369
- },
370
- scrollLock: function() {
371
- if(settings.scrollLock) {
372
- module.debug('Disabling page scroll');
373
- hadScrollbar = module.has.scrollbar();
374
- if(hadScrollbar) {
375
- module.save.bodyMargin();
376
- module.set.bodyMargin();
377
- }
378
- $context.addClass(className.locked);
379
- }
380
- module.verbose('Adding events to contain flyout scroll');
381
- $document
382
- .on('touchmove' + elementNamespace, module.event.touch)
383
- ;
384
- $module
385
- .on('scroll' + eventNamespace, module.event.containScroll)
386
- ;
387
- }
388
- },
389
- unbind: {
390
- clickaway: function() {
391
- module.verbose('Removing clickaway events from context', $context);
392
- $context.off(elementNamespace);
393
- },
394
- scrollLock: function() {
395
- module.verbose('Removing scroll lock from page');
396
- if(hadScrollbar) {
397
- module.restore.bodyMargin();
398
- }
399
- $context.removeClass(className.locked);
400
- $document.off(elementNamespace);
401
- $module.off('scroll' + eventNamespace);
402
- }
403
- },
97
+ module = {
98
+
99
+ initialize: function () {
100
+ module.debug('Initializing flyout', parameters);
101
+
102
+ module.create.id();
103
+ if (!isFlyoutComponent) {
104
+ module.create.flyout();
105
+ if (!isFunction(settings.onHidden)) {
106
+ settings.onHidden = function () {
107
+ module.destroy();
108
+ $module.remove();
109
+ };
110
+ }
111
+ if (!settings.autoShow) {
112
+ settings.autoShow = true;
113
+ }
114
+ }
115
+ $module.addClass(settings.class);
116
+ if (settings.title !== '') {
117
+ $module.find(selector.header).html(module.helpers.escape(settings.title, settings.preserveHTML)).addClass(settings.classTitle);
118
+ }
119
+ if (settings.content !== '') {
120
+ $module.find(selector.content).html(module.helpers.escape(settings.content, settings.preserveHTML)).addClass(settings.classContent);
121
+ }
122
+ if (module.has.configActions()) {
123
+ var $actions = $module.find(selector.actions).addClass(settings.classActions);
124
+ if ($actions.length === 0) {
125
+ $actions = $('<div/>', { class: className.actions + ' ' + (settings.classActions || '') }).appendTo($module);
126
+ } else {
127
+ $actions.empty();
128
+ }
129
+ settings.actions.forEach(function (el) {
130
+ var
131
+ icon = el[fields.icon] ? '<i ' + (el[fields.text] ? 'aria-hidden="true"' : '') + ' class="' + module.helpers.deQuote(el[fields.icon]) + ' icon"></i>' : '',
132
+ text = module.helpers.escape(el[fields.text] || '', settings.preserveHTML),
133
+ cls = module.helpers.deQuote(el[fields.class] || ''),
134
+ click = el[fields.click] && isFunction(el[fields.click]) ? el[fields.click] : function () {}
135
+ ;
136
+ $actions.append($('<button/>', {
137
+ html: icon + text,
138
+ 'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g, ''),
139
+ class: className.button + ' ' + cls,
140
+ on: {
141
+ click: function () {
142
+ if (click.call(element, $module) === false) {
143
+ return;
144
+ }
145
+ module.hide();
146
+ },
147
+ },
148
+ }));
149
+ });
150
+ }
404
151
 
405
- add: {
406
- inlineCSS: function() {
407
- var
408
- width = module.cache.width || $module.outerWidth(),
409
- height = module.cache.height || $module.outerHeight(),
410
- isRTL = module.is.rtl(),
411
- direction = module.get.direction(),
412
- distance = {
413
- left : width,
414
- right : -width,
415
- top : height,
416
- bottom : -height
417
- },
418
- style
419
- ;
152
+ transitionEvent = module.get.transitionEvent();
420
153
 
421
- if(isRTL){
422
- module.verbose('RTL detected, flipping widths');
423
- distance.left = -width;
424
- distance.right = width;
425
- }
154
+ // avoids locking rendering if initialized in onReady
155
+ if (settings.delaySetup) {
156
+ requestAnimationFrame(module.setup.layout);
157
+ } else {
158
+ module.setup.layout();
159
+ }
426
160
 
427
- style = '<style>';
428
-
429
- if(direction === 'left' || direction === 'right') {
430
- module.debug('Adding CSS rules for animation distance', width);
431
- style += ''
432
- + ' .ui.visible.' + direction + '.flyout ~ .fixed,'
433
- + ' .ui.visible.' + direction + '.flyout ~ .pusher {'
434
- + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);'
435
- + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);'
436
- + ' }'
437
- ;
438
- }
439
- else if(direction === 'top' || direction == 'bottom') {
440
- style += ''
441
- + ' .ui.visible.' + direction + '.flyout ~ .fixed,'
442
- + ' .ui.visible.' + direction + '.flyout ~ .pusher {'
443
- + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
444
- + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
445
- + ' }'
446
- ;
447
- }
161
+ requestAnimationFrame(function () {
162
+ module.setup.cache();
163
+ });
448
164
 
449
- /* IE is only browser not to create context with transforms */
450
- /* https://www.w3.org/Bugs/Public/show_bug.cgi?id=16328 */
451
- if( module.is.ie() ) {
452
- if(direction === 'left' || direction === 'right') {
453
- module.debug('Adding CSS rules for animation distance', width);
454
- style += ''
455
- + ' body.pushable > .ui.visible.' + direction + '.flyout ~ .pusher::after {'
456
- + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);'
457
- + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);'
458
- + ' }'
459
- ;
460
- }
461
- else if(direction === 'top' || direction == 'bottom') {
462
- style += ''
463
- + ' body.pushable > .ui.visible.' + direction + '.flyout ~ .pusher::after {'
464
- + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
465
- + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
466
- + ' }'
467
- ;
468
- }
469
- /* opposite sides visible forces content overlay */
470
- style += ''
471
- + ' body.pushable > .ui.visible.left.flyout ~ .ui.visible.right.flyout ~ .pusher::after,'
472
- + ' body.pushable > .ui.visible.right.flyout ~ .ui.visible.left.flyout ~ .pusher::after {'
473
- + ' -webkit-transform: translate3d(0, 0, 0);'
474
- + ' transform: translate3d(0, 0, 0);'
475
- + ' }'
476
- ;
477
- }
478
- style += '</style>';
479
- $style = $(style)
480
- .appendTo($head)
481
- ;
482
- module.debug('Adding sizing css to head', $style);
483
- },
484
- keyboardShortcuts: function() {
485
- module.verbose('Adding keyboard shortcuts');
486
- $document
487
- .on('keydown' + eventNamespace, module.event.keyboard)
488
- ;
489
- }
490
- },
491
- observeChanges: function() {
492
- if('MutationObserver' in window) {
493
- observer = new MutationObserver(function(mutations) {
494
- module.refreshInputs();
495
- });
496
- observer.observe(element, {
497
- childList : true,
498
- subtree : true
499
- });
500
- module.debug('Setting up mutation observer', observer);
501
- }
502
- },
503
- refresh: function() {
504
- module.verbose('Refreshing selector cache');
505
- $context = [window,document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $body;
506
- module.refreshFlyouts();
507
- $pusher = $context.children(selector.pusher);
508
- module.clear.cache();
509
- },
165
+ if (module.get.direction() == 'left' || module.get.direction() == 'right') {
166
+ module.setup.heights();
167
+ module.bind.resize();
168
+ }
169
+ module.bind.events();
170
+ module.observeChanges();
171
+ module.instantiate();
510
172
 
511
- refreshFlyouts: function() {
512
- module.verbose('Refreshing other flyouts');
513
- $flyouts = $context.children(selector.flyout);
514
- },
173
+ if (settings.autoShow) {
174
+ module.show();
175
+ }
176
+ },
515
177
 
516
- refreshInputs: function(){
517
- if($inputs){
518
- $inputs
519
- .off('keydown' + elementNamespace)
520
- ;
521
- }
522
- if(!settings.dimPage){
523
- return;
524
- }
525
- $inputs = $module.find('[tabindex], :input').filter(':visible').filter(function() {
526
- return $(this).closest('.disabled').length === 0;
527
- });
528
- $inputs.first()
529
- .on('keydown' + elementNamespace, module.event.inputKeyDown.first)
530
- ;
531
- $inputs.last()
532
- .on('keydown' + elementNamespace, module.event.inputKeyDown.last)
533
- ;
534
- },
178
+ instantiate: function () {
179
+ module.verbose('Storing instance of module', module);
180
+ instance = module;
181
+ $module
182
+ .data(moduleNamespace, instance)
183
+ ;
184
+ },
535
185
 
536
- setup: {
537
- cache: function() {
538
- module.cache = {
539
- width : $module.outerWidth(),
540
- height : $module.outerHeight()
541
- };
542
- },
543
- layout: function() {
544
- if( $context.children(selector.pusher).length === 0 ) {
545
- module.debug('Adding wrapper element for flyout');
546
- module.error(error.pusher);
547
- $pusher = $('<div class="pusher" />');
548
- $context
549
- .children()
550
- .not(selector.omitted)
551
- .not($flyouts)
552
- .wrapAll($pusher)
553
- ;
554
- module.refresh();
555
- }
556
- if($module.nextAll(selector.pusher).length === 0 || $module.nextAll(selector.pusher)[0] !== $pusher[0]) {
557
- module.debug('Moved flyout to correct parent element');
558
- module.error(error.movedFlyout, element);
559
- $module.detach().prependTo($context);
560
- module.refresh();
561
- }
562
- if( module.is.mobile() ) {
563
- $module.addClass(className.fullscreen);
564
- }
565
- module.clear.cache();
566
- module.set.pushable();
567
- module.set.direction();
568
- },
569
- heights: function() {
570
- module.debug('Setting up heights', $module);
571
- var
572
- $header = $module.children(selector.header),
573
- $content = $module.children(selector.content),
574
- $actions = $module.children(selector.actions)
575
- ;
576
- $content.css('min-height', ($context.height() - $header.outerHeight() - $actions.outerHeight()) + 'px');
577
- }
578
- },
186
+ create: {
187
+ flyout: function () {
188
+ module.verbose('Programmaticaly create flyout', $context);
189
+ $module = $('<div/>', { class: className.flyout, role: 'dialog', 'aria-modal': settings.dimPage });
190
+ if (settings.closeIcon) {
191
+ $closeIcon = $('<i/>', {
192
+ class: className.close,
193
+ role: 'button',
194
+ tabindex: 0,
195
+ 'aria-label': settings.text.close,
196
+ });
197
+ $module.append($closeIcon);
198
+ }
199
+ if (settings.title !== '') {
200
+ var titleId = '_' + module.get.id() + 'title';
201
+ $module.attr('aria-labelledby', titleId);
202
+ $('<div/>', { class: className.header, id: titleId }).appendTo($module);
203
+ }
204
+ if (settings.content !== '') {
205
+ var descId = '_' + module.get.id() + 'desc';
206
+ $module.attr('aria-describedby', descId);
207
+ $('<div/>', { class: className.content, id: descId }).appendTo($module);
208
+ }
209
+ if (module.has.configActions()) {
210
+ $('<div/>', { class: className.actions }).appendTo($module);
211
+ }
212
+ $module.prependTo($context);
213
+ element = $module[0];
214
+ },
215
+ id: function () {
216
+ id = (Math.random().toString(16) + '000000000').slice(2, 10);
217
+ elementNamespace = '.' + id;
218
+ module.verbose('Creating unique id for element', id);
219
+ },
220
+ },
579
221
 
580
- attachEvents: function(selector, event) {
581
- var
582
- $toggle = $(selector)
583
- ;
584
- event = isFunction(module[event])
585
- ? module[event]
586
- : module.toggle
587
- ;
588
- if($toggle.length > 0) {
589
- module.debug('Attaching flyout events to element', selector, event);
590
- $toggle
591
- .on('click' + eventNamespace, event)
592
- ;
593
- }
594
- else {
595
- module.error(error.notFound, selector);
596
- }
597
- },
222
+ destroy: function () {
223
+ if (observer) {
224
+ observer.disconnect();
225
+ }
226
+ module.verbose('Destroying previous module for', $module);
227
+ $module
228
+ .off(eventNamespace)
229
+ .removeData(moduleNamespace)
230
+ ;
231
+ if (module.is.ios()) {
232
+ module.remove.ios();
233
+ }
234
+ $closeIcon.off(elementNamespace);
235
+ if ($inputs) {
236
+ $inputs.off(elementNamespace);
237
+ }
238
+ // bound by uuid
239
+ $context.off(elementNamespace);
240
+ $window.off(elementNamespace);
241
+ $document.off(elementNamespace);
242
+ },
598
243
 
599
- show: function(callback) {
600
- callback = isFunction(callback)
601
- ? callback
602
- : function(){}
603
- ;
604
- if(module.is.hidden()) {
605
- if(settings.onShow.call(element) === false) {
606
- module.verbose('Show callback returned false cancelling show');
607
- return;
608
- }
609
- module.refresh();
610
- if(module.othersActive()) {
611
- module.debug('Other flyouts currently visible');
612
- if(settings.exclusive) {
613
- module.hideOthers();
614
- } else {
615
- ignoreRepeatedEvents = false;
616
- }
617
- }
618
- module.set.dimmerStyles();
619
- module.pushPage(function() {
620
- callback.call(element);
621
- settings.onVisible.call(element);
622
- if(settings.keyboardShortcuts) {
623
- module.add.keyboardShortcuts();
624
- }
625
- module.save.focus();
626
- module.refreshInputs();
627
- if(settings.autofocus) {
628
- module.set.autofocus();
629
- }
630
- });
631
- settings.onChange.call(element);
632
- }
633
- else {
634
- module.debug('Flyout is already visible');
635
- }
636
- },
244
+ event: {
245
+ keyboard: function (event) {
246
+ var
247
+ keyCode = event.which
248
+ ;
249
+ if (keyCode === settings.keys.escape) {
250
+ if (settings.closable) {
251
+ module.debug('Escape key pressed hiding flyout');
252
+ module.hide();
253
+ } else {
254
+ module.debug('Escape key pressed, but closable is set to false');
255
+ }
256
+ event.preventDefault();
257
+ }
258
+ },
259
+ resize: function () {
260
+ module.setup.heights();
261
+ },
262
+ clickaway: function (event) {
263
+ if (settings.closable) {
264
+ var
265
+ clickedInPusher = ($pusher.find(event.target).length > 0 || $pusher.is(event.target)),
266
+ clickedContext = ($context.is(event.target))
267
+ ;
268
+ if (clickedInPusher) {
269
+ module.verbose('User clicked on dimmed page');
270
+ module.hide();
271
+ }
272
+ if (clickedContext) {
273
+ module.verbose('User clicked on dimmable context (scaled out page)');
274
+ module.hide();
275
+ }
276
+ }
277
+ },
278
+ close: function (event) {
279
+ module.hide();
280
+ },
281
+ closeKeyUp: function (event) {
282
+ var
283
+ keyCode = event.which
284
+ ;
285
+ if (keyCode === settings.keys.enter || keyCode === settings.keys.space) {
286
+ module.hide();
287
+ }
288
+ },
289
+ inputKeyDown: {
290
+ first: function (event) {
291
+ var
292
+ keyCode = event.which
293
+ ;
294
+ if (keyCode === settings.keys.tab && event.shiftKey) {
295
+ $inputs.last().trigger('focus');
296
+ event.preventDefault();
297
+ }
298
+ },
299
+ last: function (event) {
300
+ var
301
+ keyCode = event.which
302
+ ;
303
+ if (keyCode === settings.keys.tab && !event.shiftKey) {
304
+ $inputs.first().trigger('focus');
305
+ event.preventDefault();
306
+ }
307
+ },
308
+ },
309
+ approve: function (event) {
310
+ if (ignoreRepeatedEvents || settings.onApprove.call(module.element, $(this)) === false) {
311
+ module.verbose('Approve callback returned false cancelling close');
312
+
313
+ return;
314
+ }
315
+ ignoreRepeatedEvents = true;
316
+ module.hide(function () {
317
+ ignoreRepeatedEvents = false;
318
+ });
319
+ },
320
+ deny: function (event) {
321
+ if (ignoreRepeatedEvents || settings.onDeny.call(module.element, $(this)) === false) {
322
+ module.verbose('Deny callback returned false cancelling close');
323
+
324
+ return;
325
+ }
326
+ ignoreRepeatedEvents = true;
327
+ module.hide(function () {
328
+ ignoreRepeatedEvents = false;
329
+ });
330
+ },
331
+ touch: function (event) {
332
+ // event.stopPropagation();
333
+ },
334
+ containScroll: function (event) {
335
+ if (element.scrollTop <= 0) {
336
+ element.scrollTop = 1;
337
+ }
338
+ if ((element.scrollTop + element.offsetHeight) >= element.scrollHeight) {
339
+ element.scrollTop = element.scrollHeight - element.offsetHeight - 1;
340
+ }
341
+ },
342
+ scroll: function (event) {
343
+ if ($(event.target).closest(selector.flyout).length === 0) {
344
+ event.preventDefault();
345
+ }
346
+ },
347
+ },
637
348
 
638
- hide: function(callback) {
639
- callback = isFunction(callback)
640
- ? callback
641
- : function(){}
642
- ;
643
- if(settings.onHide.call(element, $(this)) === false) {
644
- module.verbose('Hide callback returned false cancelling hide');
645
- ignoreRepeatedEvents = false;
646
- return false;
647
- }
648
- if(module.is.visible() || module.is.animating()) {
649
- module.debug('Hiding flyout', callback);
650
- module.refreshFlyouts();
651
- module.pullPage(function() {
652
- callback.call(element);
653
- if(isFunction(settings.onHidden)) {
654
- settings.onHidden.call(element);
655
- }
656
- module.restore.focus();
657
- });
658
- settings.onChange.call(element);
659
- }
660
- },
349
+ bind: {
350
+ resize: function () {
351
+ module.verbose('Adding resize event to window', $window);
352
+ $window.on('resize' + elementNamespace, module.event.resize);
353
+ },
354
+ events: function () {
355
+ module.verbose('Attaching events');
356
+ $module
357
+ .on('click' + eventNamespace, selector.close, module.event.close)
358
+ .on('click' + eventNamespace, selector.approve, module.event.approve)
359
+ .on('click' + eventNamespace, selector.deny, module.event.deny)
360
+ ;
361
+ $closeIcon
362
+ .on('keyup' + elementNamespace, module.event.closeKeyUp)
363
+ ;
364
+ },
365
+ clickaway: function () {
366
+ module.verbose('Adding clickaway events to context', $context);
367
+ $context
368
+ .on('click' + elementNamespace, module.event.clickaway)
369
+ .on('touchend' + elementNamespace, module.event.clickaway)
370
+ ;
371
+ },
372
+ scrollLock: function () {
373
+ if (settings.scrollLock) {
374
+ module.debug('Disabling page scroll');
375
+ hadScrollbar = module.has.scrollbar();
376
+ if (hadScrollbar) {
377
+ module.save.bodyMargin();
378
+ module.set.bodyMargin();
379
+ }
380
+ $context.addClass(className.locked);
381
+ }
382
+ module.verbose('Adding events to contain flyout scroll');
383
+ $document
384
+ .on('touchmove' + elementNamespace, module.event.touch)
385
+ ;
386
+ $module
387
+ .on('scroll' + eventNamespace, module.event.containScroll)
388
+ ;
389
+ },
390
+ },
391
+ unbind: {
392
+ clickaway: function () {
393
+ module.verbose('Removing clickaway events from context', $context);
394
+ $context.off(elementNamespace);
395
+ },
396
+ scrollLock: function () {
397
+ module.verbose('Removing scroll lock from page');
398
+ if (hadScrollbar) {
399
+ module.restore.bodyMargin();
400
+ }
401
+ $context.removeClass(className.locked);
402
+ $document.off(elementNamespace);
403
+ $module.off('scroll' + eventNamespace);
404
+ },
405
+ },
661
406
 
662
- othersAnimating: function() {
663
- return ($flyouts.not($module).filter('.' + className.animating).length > 0);
664
- },
665
- othersVisible: function() {
666
- return ($flyouts.not($module).filter('.' + className.visible).length > 0);
667
- },
668
- othersActive: function() {
669
- return(module.othersVisible() || module.othersAnimating());
670
- },
407
+ add: {
408
+ inlineCSS: function () {
409
+ var
410
+ width = module.cache.width || $module.outerWidth(),
411
+ height = module.cache.height || $module.outerHeight(),
412
+ isRTL = module.is.rtl(),
413
+ direction = module.get.direction(),
414
+ distance = {
415
+ left: width,
416
+ right: -width,
417
+ top: height,
418
+ bottom: -height,
419
+ },
420
+ style
421
+ ;
422
+
423
+ if (isRTL) {
424
+ module.verbose('RTL detected, flipping widths');
425
+ distance.left = -width;
426
+ distance.right = width;
427
+ }
428
+
429
+ style = '<style>';
430
+
431
+ if (direction === 'left' || direction === 'right') {
432
+ module.debug('Adding CSS rules for animation distance', width);
433
+ style += ''
434
+ + ' .ui.visible.' + direction + '.flyout ~ .fixed,'
435
+ + ' .ui.visible.' + direction + '.flyout ~ .pusher {'
436
+ + ' -webkit-transform: translate3d(' + distance[direction] + 'px, 0, 0);'
437
+ + ' transform: translate3d(' + distance[direction] + 'px, 0, 0);'
438
+ + ' }';
439
+ } else if (direction === 'top' || direction == 'bottom') {
440
+ style += ''
441
+ + ' .ui.visible.' + direction + '.flyout ~ .fixed,'
442
+ + ' .ui.visible.' + direction + '.flyout ~ .pusher {'
443
+ + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
444
+ + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
445
+ + ' }';
446
+ }
447
+
448
+ /* IE is only browser not to create context with transforms */
449
+ /* https://www.w3.org/Bugs/Public/show_bug.cgi?id=16328 */
450
+ if (module.is.ie()) {
451
+ if (direction === 'left' || direction === 'right') {
452
+ module.debug('Adding CSS rules for animation distance', width);
453
+ style += ''
454
+ + ' body.pushable > .ui.visible.' + direction + '.flyout ~ .pusher::after {'
455
+ + ' -webkit-transform: translate3d(' + distance[direction] + 'px, 0, 0);'
456
+ + ' transform: translate3d(' + distance[direction] + 'px, 0, 0);'
457
+ + ' }';
458
+ } else if (direction === 'top' || direction == 'bottom') {
459
+ style += ''
460
+ + ' body.pushable > .ui.visible.' + direction + '.flyout ~ .pusher::after {'
461
+ + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
462
+ + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
463
+ + ' }';
464
+ }
465
+ /* opposite sides visible forces content overlay */
466
+ style += ''
467
+ + ' body.pushable > .ui.visible.left.flyout ~ .ui.visible.right.flyout ~ .pusher::after,'
468
+ + ' body.pushable > .ui.visible.right.flyout ~ .ui.visible.left.flyout ~ .pusher::after {'
469
+ + ' -webkit-transform: translate3d(0, 0, 0);'
470
+ + ' transform: translate3d(0, 0, 0);'
471
+ + ' }';
472
+ }
473
+ style += '</style>';
474
+ $style = $(style)
475
+ .appendTo($head)
476
+ ;
477
+ module.debug('Adding sizing css to head', $style);
478
+ },
479
+ keyboardShortcuts: function () {
480
+ module.verbose('Adding keyboard shortcuts');
481
+ $document
482
+ .on('keydown' + eventNamespace, module.event.keyboard)
483
+ ;
484
+ },
485
+ },
486
+ observeChanges: function () {
487
+ if ('MutationObserver' in window) {
488
+ observer = new MutationObserver(function (mutations) {
489
+ module.refreshInputs();
490
+ });
491
+ observer.observe(element, {
492
+ childList: true,
493
+ subtree: true,
494
+ });
495
+ module.debug('Setting up mutation observer', observer);
496
+ }
497
+ },
498
+ refresh: function () {
499
+ module.verbose('Refreshing selector cache');
500
+ $context = [window, document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $body;
501
+ module.refreshFlyouts();
502
+ $pusher = $context.children(selector.pusher);
503
+ module.clear.cache();
504
+ },
671
505
 
672
- hideOthers: function(callback) {
673
- var
674
- $otherFlyouts = $flyouts.not($module).filter('.' + className.visible),
675
- flyoutCount = $otherFlyouts.length,
676
- callbackCount = 0
677
- ;
678
- callback = callback || function(){};
679
- $otherFlyouts
680
- .flyout('hide', function() {
681
- callbackCount++;
682
- if(callbackCount == flyoutCount) {
683
- callback();
684
- }
685
- })
686
- ;
687
- },
506
+ refreshFlyouts: function () {
507
+ module.verbose('Refreshing other flyouts');
508
+ $flyouts = $context.children(selector.flyout);
509
+ },
688
510
 
689
- toggle: function() {
690
- module.verbose('Determining toggled direction');
691
- if(module.is.hidden()) {
692
- module.show();
693
- }
694
- else {
695
- module.hide();
696
- }
697
- },
511
+ refreshInputs: function () {
512
+ if ($inputs) {
513
+ $inputs
514
+ .off('keydown' + elementNamespace)
515
+ ;
516
+ }
517
+ if (!settings.dimPage) {
518
+ return;
519
+ }
520
+ $inputs = $module.find('[tabindex], :input').filter(':visible').filter(function () {
521
+ return $(this).closest('.disabled').length === 0;
522
+ });
523
+ $inputs.first()
524
+ .on('keydown' + elementNamespace, module.event.inputKeyDown.first)
525
+ ;
526
+ $inputs.last()
527
+ .on('keydown' + elementNamespace, module.event.inputKeyDown.last)
528
+ ;
529
+ },
698
530
 
699
- pushPage: function(callback) {
700
- var
701
- animate,
702
- dim,
703
- transitionEnd
704
- ;
705
- callback = isFunction(callback)
706
- ? callback
707
- : function(){}
708
- ;
709
- module.set.overlay();
710
- if(settings.returnScroll) {
711
- currentScroll = (isBody ? $window : $context).scrollTop();
712
- }
713
- module.bind.scrollLock();
714
- animate = function() {
715
- module.bind.clickaway();
716
- module.add.inlineCSS();
717
- module.set.animating();
718
- module.set.visible();
719
- };
720
- dim = function() {
721
- module.set.dimmed();
722
- };
723
- transitionEnd = function(event) {
724
- if( event.target == $module[0] ) {
725
- $module.off(transitionEvent + elementNamespace, transitionEnd);
726
- module.remove.animating();
727
- callback.call(element);
728
- }
729
- };
730
- $module.off(transitionEvent + elementNamespace);
731
- $module.on(transitionEvent + elementNamespace, transitionEnd);
732
- requestAnimationFrame(animate);
733
- if(settings.dimPage && !module.othersVisible()) {
734
- requestAnimationFrame(dim);
735
- }
736
- },
531
+ setup: {
532
+ cache: function () {
533
+ module.cache = {
534
+ width: $module.outerWidth(),
535
+ height: $module.outerHeight(),
536
+ };
537
+ },
538
+ layout: function () {
539
+ if ($context.children(selector.pusher).length === 0) {
540
+ module.debug('Adding wrapper element for flyout');
541
+ module.error(error.pusher);
542
+ $pusher = $('<div class="pusher" />');
543
+ $context
544
+ .children()
545
+ .not(selector.omitted)
546
+ .not($flyouts)
547
+ .wrapAll($pusher)
548
+ ;
549
+ module.refresh();
550
+ }
551
+ if ($module.nextAll(selector.pusher).length === 0 || $module.nextAll(selector.pusher)[0] !== $pusher[0]) {
552
+ module.debug('Moved flyout to correct parent element');
553
+ module.error(error.movedFlyout, element);
554
+ $module.detach().prependTo($context);
555
+ module.refresh();
556
+ }
557
+ if (module.is.mobile()) {
558
+ $module.addClass(className.fullscreen);
559
+ }
560
+ module.clear.cache();
561
+ module.set.pushable();
562
+ module.set.direction();
563
+ },
564
+ heights: function () {
565
+ module.debug('Setting up heights', $module);
566
+ var
567
+ $header = $module.children(selector.header),
568
+ $content = $module.children(selector.content),
569
+ $actions = $module.children(selector.actions)
570
+ ;
571
+ $content.css('min-height', ($context.height() - $header.outerHeight() - $actions.outerHeight()) + 'px');
572
+ },
573
+ },
737
574
 
738
- pullPage: function(callback) {
739
- var
740
- animate,
741
- transitionEnd
742
- ;
743
- callback = isFunction(callback)
744
- ? callback
745
- : function(){}
746
- ;
747
- module.verbose('Removing context push state', module.get.direction());
748
-
749
- module.unbind.clickaway();
750
- if(!module.othersActive()) {
751
- module.unbind.scrollLock();
752
- if( settings.keyboardShortcuts ) {
753
- module.remove.keyboardShortcuts();
754
- }
755
- }
575
+ attachEvents: function (selector, event) {
576
+ var
577
+ $toggle = $(selector)
578
+ ;
579
+ event = isFunction(module[event])
580
+ ? module[event]
581
+ : module.toggle;
582
+ if ($toggle.length > 0) {
583
+ module.debug('Attaching flyout events to element', selector, event);
584
+ $toggle
585
+ .on('click' + eventNamespace, event)
586
+ ;
587
+ } else {
588
+ module.error(error.notFound, selector);
589
+ }
590
+ },
756
591
 
592
+ show: function (callback) {
593
+ callback = isFunction(callback)
594
+ ? callback
595
+ : function () {};
596
+ if (module.is.hidden()) {
597
+ if (settings.onShow.call(element) === false) {
598
+ module.verbose('Show callback returned false cancelling show');
599
+
600
+ return;
601
+ }
602
+ module.refresh();
603
+ if (module.othersActive()) {
604
+ module.debug('Other flyouts currently visible');
605
+ if (settings.exclusive) {
606
+ module.hideOthers();
607
+ } else {
608
+ ignoreRepeatedEvents = false;
609
+ }
610
+ }
611
+ module.set.dimmerStyles();
612
+ module.pushPage(function () {
613
+ callback.call(element);
614
+ settings.onVisible.call(element);
615
+ if (settings.keyboardShortcuts) {
616
+ module.add.keyboardShortcuts();
617
+ }
618
+ module.save.focus();
619
+ module.refreshInputs();
620
+ if (settings.autofocus) {
621
+ module.set.autofocus();
622
+ }
623
+ });
624
+ settings.onChange.call(element);
625
+ } else {
626
+ module.debug('Flyout is already visible');
627
+ }
628
+ },
757
629
 
758
- animate = function() {
759
- module.set.overlay();
760
- module.set.animating();
761
- if(settings.dimPage && !module.othersVisible()) {
762
- module.set.closing();
763
- }
764
- module.remove.visible();
765
- };
766
- transitionEnd = function(event) {
767
- if( event.target == $module[0] ) {
768
- $module.off(transitionEvent + elementNamespace, transitionEnd);
769
- module.remove.animating();
770
- module.remove.closing();
771
- module.remove.overlay();
772
- module.remove.inlineCSS();
773
- if(settings.returnScroll) {
774
- module.scrollBack();
775
- }
776
- if (settings.dimPage && !module.othersVisible()) {
777
- $pusher.removeClass(className.dimmed);
778
- }
779
- callback.call(element);
780
- }
781
- };
782
- $module.off(transitionEvent + elementNamespace);
783
- $module.on(transitionEvent + elementNamespace, transitionEnd);
784
- requestAnimationFrame(animate);
785
- },
630
+ hide: function (callback) {
631
+ callback = isFunction(callback)
632
+ ? callback
633
+ : function () {};
634
+ if (settings.onHide.call(element, $(this)) === false) {
635
+ module.verbose('Hide callback returned false cancelling hide');
636
+ ignoreRepeatedEvents = false;
786
637
 
787
- scrollToTop: function() {
788
- module.verbose('Scrolling to top of page to avoid animation issues');
789
- $module.scrollTop(0);
790
- (isBody ? $window : $context)[0].scrollTo(0, 0);
791
- },
638
+ return false;
639
+ }
640
+ if (module.is.visible() || module.is.animating()) {
641
+ module.debug('Hiding flyout', callback);
642
+ module.refreshFlyouts();
643
+ module.pullPage(function () {
644
+ callback.call(element);
645
+ if (isFunction(settings.onHidden)) {
646
+ settings.onHidden.call(element);
647
+ }
648
+ module.restore.focus();
649
+ });
650
+ settings.onChange.call(element);
651
+ }
652
+ },
792
653
 
793
- scrollBack: function() {
794
- module.verbose('Scrolling back to original page position');
795
- (isBody ? $window : $context)[0].scrollTo(0, currentScroll);
796
- },
654
+ othersAnimating: function () {
655
+ return ($flyouts.not($module).filter('.' + className.animating).length > 0);
656
+ },
657
+ othersVisible: function () {
658
+ return ($flyouts.not($module).filter('.' + className.visible).length > 0);
659
+ },
660
+ othersActive: function () {
661
+ return (module.othersVisible() || module.othersAnimating());
662
+ },
797
663
 
798
- clear: {
799
- cache: function() {
800
- module.verbose('Clearing cached dimensions');
801
- module.cache = {};
802
- }
803
- },
664
+ hideOthers: function (callback) {
665
+ var
666
+ $otherFlyouts = $flyouts.not($module).filter('.' + className.visible),
667
+ flyoutCount = $otherFlyouts.length,
668
+ callbackCount = 0
669
+ ;
670
+ callback = callback || function () {};
671
+ $otherFlyouts
672
+ .flyout('hide', function () {
673
+ callbackCount++;
674
+ if (callbackCount == flyoutCount) {
675
+ callback();
676
+ }
677
+ })
678
+ ;
679
+ },
804
680
 
805
- set: {
806
- autofocus: function() {
807
- var
808
- $autofocus = $inputs.filter('[autofocus]'),
809
- $input = ($autofocus.length > 0)
810
- ? $autofocus.first()
811
- : ($inputs.length > 1 ? $inputs.filter(':not(i.close)') : $inputs).first()
812
- ;
813
- if($input.length > 0) {
814
- $input.trigger('focus');
815
- }
816
- },
817
- dimmerStyles: function() {
818
- if(settings.blurring) {
819
- $pusher.addClass(className.blurring);
820
- }
821
- else {
822
- $pusher.removeClass(className.blurring);
681
+ toggle: function () {
682
+ module.verbose('Determining toggled direction');
683
+ if (module.is.hidden()) {
684
+ module.show();
685
+ } else {
686
+ module.hide();
687
+ }
688
+ },
689
+
690
+ pushPage: function (callback) {
691
+ var
692
+ animate,
693
+ dim,
694
+ transitionEnd
695
+ ;
696
+ callback = isFunction(callback)
697
+ ? callback
698
+ : function () {};
699
+ module.set.overlay();
700
+ if (settings.returnScroll) {
701
+ currentScroll = (isBody ? $window : $context).scrollTop();
702
+ }
703
+ module.bind.scrollLock();
704
+ animate = function () {
705
+ module.bind.clickaway();
706
+ module.add.inlineCSS();
707
+ module.set.animating();
708
+ module.set.visible();
709
+ };
710
+ dim = function () {
711
+ module.set.dimmed();
712
+ };
713
+ transitionEnd = function (event) {
714
+ if (event.target == $module[0]) {
715
+ $module.off(transitionEvent + elementNamespace, transitionEnd);
716
+ module.remove.animating();
717
+ callback.call(element);
718
+ }
719
+ };
720
+ $module.off(transitionEvent + elementNamespace);
721
+ $module.on(transitionEvent + elementNamespace, transitionEnd);
722
+ requestAnimationFrame(animate);
723
+ if (settings.dimPage && !module.othersVisible()) {
724
+ requestAnimationFrame(dim);
725
+ }
726
+ },
727
+
728
+ pullPage: function (callback) {
729
+ var
730
+ animate,
731
+ transitionEnd
732
+ ;
733
+ callback = isFunction(callback)
734
+ ? callback
735
+ : function () {};
736
+ module.verbose('Removing context push state', module.get.direction());
737
+
738
+ module.unbind.clickaway();
739
+ if (!module.othersActive()) {
740
+ module.unbind.scrollLock();
741
+ if (settings.keyboardShortcuts) {
742
+ module.remove.keyboardShortcuts();
743
+ }
744
+ }
745
+
746
+ animate = function () {
747
+ module.set.overlay();
748
+ module.set.animating();
749
+ if (settings.dimPage && !module.othersVisible()) {
750
+ module.set.closing();
751
+ }
752
+ module.remove.visible();
753
+ };
754
+ transitionEnd = function (event) {
755
+ if (event.target == $module[0]) {
756
+ $module.off(transitionEvent + elementNamespace, transitionEnd);
757
+ module.remove.animating();
758
+ module.remove.closing();
759
+ module.remove.overlay();
760
+ module.remove.inlineCSS();
761
+ if (settings.returnScroll) {
762
+ module.scrollBack();
763
+ }
764
+ if (settings.dimPage && !module.othersVisible()) {
765
+ $pusher.removeClass(className.dimmed);
766
+ }
767
+ callback.call(element);
768
+ }
769
+ };
770
+ $module.off(transitionEvent + elementNamespace);
771
+ $module.on(transitionEvent + elementNamespace, transitionEnd);
772
+ requestAnimationFrame(animate);
773
+ },
774
+
775
+ scrollToTop: function () {
776
+ module.verbose('Scrolling to top of page to avoid animation issues');
777
+ $module.scrollTop(0);
778
+ (isBody ? $window : $context)[0].scrollTo(0, 0);
779
+ },
780
+
781
+ scrollBack: function () {
782
+ module.verbose('Scrolling back to original page position');
783
+ (isBody ? $window : $context)[0].scrollTo(0, currentScroll);
784
+ },
785
+
786
+ clear: {
787
+ cache: function () {
788
+ module.verbose('Clearing cached dimensions');
789
+ module.cache = {};
790
+ },
791
+ },
792
+
793
+ set: {
794
+ autofocus: function () {
795
+ var
796
+ $autofocus = $inputs.filter('[autofocus]'),
797
+ $input = ($autofocus.length > 0)
798
+ ? $autofocus.first()
799
+ : ($inputs.length > 1 ? $inputs.filter(':not(i.close)') : $inputs).first()
800
+ ;
801
+ if ($input.length > 0) {
802
+ $input.trigger('focus');
803
+ }
804
+ },
805
+ dimmerStyles: function () {
806
+ if (settings.blurring) {
807
+ $pusher.addClass(className.blurring);
808
+ } else {
809
+ $pusher.removeClass(className.blurring);
810
+ }
811
+ },
812
+ bodyMargin: function () {
813
+ var position = module.can.leftBodyScrollbar() ? 'left' : 'right';
814
+ $context.css((isBody ? 'margin-' : 'padding-') + position, tempBodyMargin + 'px');
815
+ $context.find(selector.bodyFixed.replace('right', position)).each(function () {
816
+ var
817
+ el = $(this),
818
+ attribute = el.css('position') === 'fixed' ? 'padding-' + position : position
819
+ ;
820
+ el.css(attribute, 'calc(' + el.css(attribute) + ' + ' + tempBodyMargin + 'px)');
821
+ });
822
+ },
823
+
824
+ // ios only (scroll on html not document). This prevent auto-resize canvas/scroll in ios
825
+ // (This is no longer necessary in latest iOS)
826
+ ios: function () {
827
+ $html.addClass(className.ios);
828
+ },
829
+
830
+ // container
831
+ pushed: function () {
832
+ $context.addClass(className.pushed);
833
+ },
834
+ pushable: function () {
835
+ $context.addClass(className.pushable);
836
+ },
837
+
838
+ // pusher
839
+ dimmed: function () {
840
+ $pusher.addClass(className.dimmed);
841
+ },
842
+
843
+ // flyout
844
+ active: function () {
845
+ $module.addClass(className.active);
846
+ },
847
+ animating: function () {
848
+ $module.addClass(className.animating);
849
+ },
850
+ closing: function () {
851
+ $pusher.addClass(className.closing);
852
+ },
853
+ direction: function (direction) {
854
+ direction = direction || module.get.direction();
855
+ $module.addClass(className[direction]);
856
+ },
857
+ visible: function () {
858
+ $module.addClass(className.visible);
859
+ },
860
+ overlay: function () {
861
+ $module.addClass(className.overlay);
862
+ },
863
+ },
864
+ remove: {
865
+
866
+ inlineCSS: function () {
867
+ module.debug('Removing inline css styles', $style);
868
+ if ($style && $style.length > 0) {
869
+ $style.remove();
870
+ }
871
+ },
872
+ keyboardShortcuts: function () {
873
+ module.verbose('Removing keyboard shortcuts');
874
+ $document
875
+ .off('keydown' + eventNamespace)
876
+ ;
877
+ },
878
+
879
+ // ios scroll on html not document
880
+ ios: function () {
881
+ $html.removeClass(className.ios);
882
+ },
883
+
884
+ // context
885
+ pushed: function () {
886
+ $context.removeClass(className.pushed);
887
+ },
888
+ pushable: function () {
889
+ $context.removeClass(className.pushable);
890
+ },
891
+
892
+ // flyout
893
+ active: function () {
894
+ $module.removeClass(className.active);
895
+ },
896
+ animating: function () {
897
+ $module.removeClass(className.animating);
898
+ },
899
+ closing: function () {
900
+ $pusher.removeClass(className.closing);
901
+ },
902
+ direction: function (direction) {
903
+ direction = direction || module.get.direction();
904
+ $module.removeClass(className[direction]);
905
+ },
906
+ visible: function () {
907
+ $module.removeClass(className.visible);
908
+ },
909
+ overlay: function () {
910
+ $module.removeClass(className.overlay);
911
+ },
912
+ },
913
+
914
+ get: {
915
+ direction: function () {
916
+ if ($module.hasClass(className.top)) {
917
+ return className.top;
918
+ } else if ($module.hasClass(className.right)) {
919
+ return className.right;
920
+ } else if ($module.hasClass(className.bottom)) {
921
+ return className.bottom;
922
+ }
923
+
924
+ return className.left;
925
+ },
926
+ transitionEvent: function () {
927
+ var
928
+ element = document.createElement('element'),
929
+ transitions = {
930
+ transition: 'transitionend',
931
+ OTransition: 'oTransitionEnd',
932
+ MozTransition: 'transitionend',
933
+ WebkitTransition: 'webkitTransitionEnd',
934
+ },
935
+ transition
936
+ ;
937
+ for (transition in transitions) {
938
+ if (element.style[transition] !== undefined) {
939
+ return transitions[transition];
940
+ }
941
+ }
942
+ },
943
+ id: function () {
944
+ return id;
945
+ },
946
+ element: function () {
947
+ return $module;
948
+ },
949
+ settings: function () {
950
+ return settings;
951
+ },
952
+ },
953
+
954
+ can: {
955
+ leftBodyScrollbar: function () {
956
+ if (module.cache.leftBodyScrollbar === undefined) {
957
+ module.cache.leftBodyScrollbar = module.is.rtl() && ((module.is.iframe && !module.is.firefox()) || module.is.safari() || module.is.edge() || module.is.ie());
958
+ }
959
+
960
+ return module.cache.leftBodyScrollbar;
961
+ },
962
+ },
963
+
964
+ save: {
965
+ focus: function () {
966
+ var
967
+ $activeElement = $(document.activeElement),
968
+ inCurrentFlyout = $activeElement.closest($module).length > 0
969
+ ;
970
+ if (!inCurrentFlyout) {
971
+ $focusedElement = $(document.activeElement).trigger('blur');
972
+ }
973
+ },
974
+ bodyMargin: function () {
975
+ initialBodyMargin = $context.css((isBody ? 'margin-' : 'padding-') + (module.can.leftBodyScrollbar() ? 'left' : 'right'));
976
+ var
977
+ bodyMarginRightPixel = parseInt(initialBodyMargin.replace(/[^\d.]/g, '')),
978
+ bodyScrollbarWidth = isBody ? window.innerWidth - document.documentElement.clientWidth : $context[0].offsetWidth - $context[0].clientWidth
979
+ ;
980
+ tempBodyMargin = bodyMarginRightPixel + bodyScrollbarWidth;
981
+ },
982
+ },
983
+
984
+ is: {
985
+ safari: function () {
986
+ if (module.cache.isSafari === undefined) {
987
+ module.cache.isSafari = /constructor/i.test(window.HTMLElement) || !!window.ApplePaySession;
988
+ }
989
+
990
+ return module.cache.isSafari;
991
+ },
992
+ edge: function () {
993
+ if (module.cache.isEdge === undefined) {
994
+ module.cache.isEdge = !!window.setImmediate && !module.is.ie();
995
+ }
996
+
997
+ return module.cache.isEdge;
998
+ },
999
+ firefox: function () {
1000
+ if (module.cache.isFirefox === undefined) {
1001
+ module.cache.isFirefox = !!window.InstallTrigger;
1002
+ }
1003
+
1004
+ return module.cache.isFirefox;
1005
+ },
1006
+ iframe: function () {
1007
+ return !(self === top);
1008
+ },
1009
+ ie: function () {
1010
+ if (module.cache.isIE === undefined) {
1011
+ var
1012
+ isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
1013
+ isIE = ('ActiveXObject' in window)
1014
+ ;
1015
+ module.cache.isIE = (isIE11 || isIE);
1016
+ }
1017
+
1018
+ return module.cache.isIE;
1019
+ },
1020
+ ios: function () {
1021
+ var
1022
+ userAgent = navigator.userAgent,
1023
+ isIOS = userAgent.match(regExp.ios),
1024
+ isMobileChrome = userAgent.match(regExp.mobileChrome)
1025
+ ;
1026
+ if (isIOS && !isMobileChrome) {
1027
+ module.verbose('Browser was found to be iOS', userAgent);
1028
+
1029
+ return true;
1030
+ } else {
1031
+ return false;
1032
+ }
1033
+ },
1034
+ mobile: function () {
1035
+ var
1036
+ userAgent = navigator.userAgent,
1037
+ isMobile = userAgent.match(regExp.mobile)
1038
+ ;
1039
+ if (isMobile) {
1040
+ module.verbose('Browser was found to be mobile', userAgent);
1041
+
1042
+ return true;
1043
+ } else {
1044
+ module.verbose('Browser is not mobile, using regular transition', userAgent);
1045
+
1046
+ return false;
1047
+ }
1048
+ },
1049
+ hidden: function () {
1050
+ return !module.is.visible();
1051
+ },
1052
+ visible: function () {
1053
+ return $module.hasClass(className.visible);
1054
+ },
1055
+ animating: function () {
1056
+ return $context.hasClass(className.animating);
1057
+ },
1058
+ rtl: function () {
1059
+ if (module.cache.isRTL === undefined) {
1060
+ 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';
1061
+ }
1062
+
1063
+ return module.cache.isRTL;
1064
+ },
1065
+ },
1066
+
1067
+ has: {
1068
+ configActions: function () {
1069
+ return Array.isArray(settings.actions) && settings.actions.length > 0;
1070
+ },
1071
+ scrollbar: function () {
1072
+ return isBody || $context.css('overflow-y') !== 'hidden';
1073
+ },
1074
+ },
1075
+
1076
+ restore: {
1077
+ focus: function () {
1078
+ if ($focusedElement && $focusedElement.length > 0 && settings.restoreFocus) {
1079
+ $focusedElement.trigger('focus');
1080
+ }
1081
+ },
1082
+ bodyMargin: function () {
1083
+ var position = module.can.leftBodyScrollbar() ? 'left' : 'right';
1084
+ $context.css((isBody ? 'margin-' : 'padding-') + position, initialBodyMargin);
1085
+ $context.find(selector.bodyFixed.replace('right', position)).each(function () {
1086
+ var
1087
+ el = $(this),
1088
+ attribute = el.css('position') === 'fixed' ? 'padding-' + position : position
1089
+ ;
1090
+ el.css(attribute, '');
1091
+ });
1092
+ },
1093
+ },
1094
+
1095
+ helpers: {
1096
+ deQuote: function (string) {
1097
+ return String(string).replace(/"/g, '');
1098
+ },
1099
+ escape: function (string, preserveHTML) {
1100
+ if (preserveHTML) {
1101
+ return string;
1102
+ }
1103
+ var
1104
+ badChars = /[<>"'`]/g,
1105
+ shouldEscape = /[&<>"'`]/,
1106
+ escape = {
1107
+ '<': '&lt;',
1108
+ '>': '&gt;',
1109
+ '"': '&quot;',
1110
+ "'": '&#x27;',
1111
+ '`': '&#x60;',
1112
+ },
1113
+ escapedChar = function (chr) {
1114
+ return escape[chr];
1115
+ }
1116
+ ;
1117
+ if (shouldEscape.test(string)) {
1118
+ string = string.replace(/&(?![a-z0-9#]{1,12};)/gi, '&amp;');
1119
+
1120
+ return string.replace(badChars, escapedChar);
1121
+ }
1122
+
1123
+ return string;
1124
+ },
1125
+ },
1126
+
1127
+ setting: function (name, value) {
1128
+ module.debug('Changing setting', name, value);
1129
+ if ($.isPlainObject(name)) {
1130
+ $.extend(true, settings, name);
1131
+ } else if (value !== undefined) {
1132
+ if ($.isPlainObject(settings[name])) {
1133
+ $.extend(true, settings[name], value);
1134
+ } else {
1135
+ settings[name] = value;
1136
+ }
1137
+ } else {
1138
+ return settings[name];
1139
+ }
1140
+ },
1141
+ internal: function (name, value) {
1142
+ if ($.isPlainObject(name)) {
1143
+ $.extend(true, module, name);
1144
+ } else if (value !== undefined) {
1145
+ module[name] = value;
1146
+ } else {
1147
+ return module[name];
1148
+ }
1149
+ },
1150
+ debug: function () {
1151
+ if (!settings.silent && settings.debug) {
1152
+ if (settings.performance) {
1153
+ module.performance.log(arguments);
1154
+ } else {
1155
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1156
+ module.debug.apply(console, arguments);
1157
+ }
1158
+ }
1159
+ },
1160
+ verbose: function () {
1161
+ if (!settings.silent && settings.verbose && settings.debug) {
1162
+ if (settings.performance) {
1163
+ module.performance.log(arguments);
1164
+ } else {
1165
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1166
+ module.verbose.apply(console, arguments);
1167
+ }
1168
+ }
1169
+ },
1170
+ error: function () {
1171
+ if (!settings.silent) {
1172
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1173
+ module.error.apply(console, arguments);
1174
+ }
1175
+ },
1176
+ performance: {
1177
+ log: function (message) {
1178
+ var
1179
+ currentTime,
1180
+ executionTime,
1181
+ previousTime
1182
+ ;
1183
+ if (settings.performance) {
1184
+ currentTime = new Date().getTime();
1185
+ previousTime = time || currentTime;
1186
+ executionTime = currentTime - previousTime;
1187
+ time = currentTime;
1188
+ performance.push({
1189
+ Name: message[0],
1190
+ Arguments: [].slice.call(message, 1) || '',
1191
+ Element: element,
1192
+ 'Execution Time': executionTime,
1193
+ });
1194
+ }
1195
+ clearTimeout(module.performance.timer);
1196
+ module.performance.timer = setTimeout(module.performance.display, 500);
1197
+ },
1198
+ display: function () {
1199
+ var
1200
+ title = settings.name + ':',
1201
+ totalTime = 0
1202
+ ;
1203
+ time = false;
1204
+ clearTimeout(module.performance.timer);
1205
+ $.each(performance, function (index, data) {
1206
+ totalTime += data['Execution Time'];
1207
+ });
1208
+ title += ' ' + totalTime + 'ms';
1209
+ if (moduleSelector) {
1210
+ title += ' \'' + moduleSelector + '\'';
1211
+ }
1212
+ if ((console.group !== undefined || console.table !== undefined) && performance.length > 0) {
1213
+ console.groupCollapsed(title);
1214
+ if (console.table) {
1215
+ console.table(performance);
1216
+ } else {
1217
+ $.each(performance, function (index, data) {
1218
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
1219
+ });
1220
+ }
1221
+ console.groupEnd();
1222
+ }
1223
+ performance = [];
1224
+ },
1225
+ },
1226
+ invoke: function (query, passedArguments, context) {
1227
+ var
1228
+ object = instance,
1229
+ maxDepth,
1230
+ found,
1231
+ response
1232
+ ;
1233
+ passedArguments = passedArguments || queryArguments;
1234
+ context = element || context;
1235
+ if (typeof query == 'string' && object !== undefined) {
1236
+ query = query.split(/[\. ]/);
1237
+ maxDepth = query.length - 1;
1238
+ $.each(query, function (depth, value) {
1239
+ var camelCaseValue = (depth != maxDepth)
1240
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1241
+ : query
1242
+ ;
1243
+ if ($.isPlainObject(object[camelCaseValue]) && (depth != maxDepth)) {
1244
+ object = object[camelCaseValue];
1245
+ } else if (object[camelCaseValue] !== undefined) {
1246
+ found = object[camelCaseValue];
1247
+
1248
+ return false;
1249
+ } else if ($.isPlainObject(object[value]) && (depth != maxDepth)) {
1250
+ object = object[value];
1251
+ } else if (object[value] !== undefined) {
1252
+ found = object[value];
1253
+
1254
+ return false;
1255
+ } else {
1256
+ module.error(error.method, query);
1257
+
1258
+ return false;
1259
+ }
1260
+ });
1261
+ }
1262
+ if (isFunction(found)) {
1263
+ response = found.apply(context, passedArguments);
1264
+ } else if (found !== undefined) {
1265
+ response = found;
1266
+ }
1267
+ if (Array.isArray(returnedValue)) {
1268
+ returnedValue.push(response);
1269
+ } else if (returnedValue !== undefined) {
1270
+ returnedValue = [returnedValue, response];
1271
+ } else if (response !== undefined) {
1272
+ returnedValue = response;
1273
+ }
1274
+
1275
+ return found;
1276
+ },
1277
+ };
1278
+
1279
+ if (methodInvoked) {
1280
+ if (instance === undefined) {
1281
+ if (isFunction(settings.templates[query])) {
1282
+ settings.autoShow = true;
1283
+ settings.className.flyout = settings.className.template;
1284
+ settings = $.extend(true, {}, settings, settings.templates[query].apply(module, queryArguments));
1285
+
1286
+ // reassign shortcuts
1287
+ className = settings.className;
1288
+ namespace = settings.namespace;
1289
+ fields = settings.fields;
1290
+ error = settings.error;
1291
+ }
1292
+ module.initialize();
1293
+ }
1294
+ if (!isFunction(settings.templates[query])) {
1295
+ module.invoke(query);
1296
+ }
1297
+ } else {
1298
+ if (instance !== undefined) {
1299
+ instance.invoke('destroy');
1300
+ }
1301
+ module.initialize();
1302
+ returnedValue = $module;
823
1303
  }
824
- },
825
- bodyMargin: function() {
826
- var position = module.can.leftBodyScrollbar() ? 'left':'right';
827
- $context.css((isBody ? 'margin-':'padding-')+position, tempBodyMargin + 'px');
828
- $context.find(selector.bodyFixed.replace('right',position)).each(function(){
829
- var el = $(this),
830
- attribute = el.css('position') === 'fixed' ? 'padding-'+position : position
831
- ;
832
- el.css(attribute, 'calc(' + el.css(attribute) + ' + ' + tempBodyMargin + 'px)');
833
- });
834
- },
835
-
836
- // ios only (scroll on html not document). This prevent auto-resize canvas/scroll in ios
837
- // (This is no longer necessary in latest iOS)
838
- ios: function() {
839
- $html.addClass(className.ios);
840
- },
841
-
842
- // container
843
- pushed: function() {
844
- $context.addClass(className.pushed);
845
- },
846
- pushable: function() {
847
- $context.addClass(className.pushable);
848
- },
849
-
850
- // pusher
851
- dimmed: function() {
852
- $pusher.addClass(className.dimmed);
853
- },
854
-
855
- // flyout
856
- active: function() {
857
- $module.addClass(className.active);
858
- },
859
- animating: function() {
860
- $module.addClass(className.animating);
861
- },
862
- closing: function() {
863
- $pusher.addClass(className.closing);
864
- },
865
- direction: function(direction) {
866
- direction = direction || module.get.direction();
867
- $module.addClass(className[direction]);
868
- },
869
- visible: function() {
870
- $module.addClass(className.visible);
871
- },
872
- overlay: function() {
873
- $module.addClass(className.overlay);
874
- }
1304
+ });
1305
+
1306
+ return (returnedValue !== undefined)
1307
+ ? returnedValue
1308
+ : this;
1309
+ };
1310
+
1311
+ $.fn.flyout.settings = {
1312
+
1313
+ name: 'Flyout',
1314
+ namespace: 'flyout',
1315
+
1316
+ silent: false,
1317
+ debug: false,
1318
+ verbose: false,
1319
+ performance: true,
1320
+
1321
+ context: 'body',
1322
+ exclusive: false,
1323
+ closable: true,
1324
+ autofocus: true,
1325
+ restoreFocus: true,
1326
+ dimPage: true,
1327
+ scrollLock: false,
1328
+ returnScroll: false,
1329
+ delaySetup: false,
1330
+ autoShow: false,
1331
+
1332
+ keyboardShortcuts: true,
1333
+
1334
+ // dynamic content
1335
+ title: '',
1336
+ content: '',
1337
+ class: '',
1338
+ classTitle: '',
1339
+ classContent: '',
1340
+ classActions: '',
1341
+ closeIcon: false,
1342
+ actions: false,
1343
+ preserveHTML: true,
1344
+
1345
+ fields: {
1346
+ class: 'class',
1347
+ text: 'text',
1348
+ icon: 'icon',
1349
+ click: 'click',
875
1350
  },
876
- remove: {
877
1351
 
878
- inlineCSS: function() {
879
- module.debug('Removing inline css styles', $style);
880
- if($style && $style.length > 0) {
881
- $style.remove();
882
- }
883
- },
884
- keyboardShortcuts: function() {
885
- module.verbose('Removing keyboard shortcuts');
886
- $document
887
- .off('keydown' + eventNamespace)
888
- ;
889
- },
890
-
891
- // ios scroll on html not document
892
- ios: function() {
893
- $html.removeClass(className.ios);
894
- },
895
-
896
- // context
897
- pushed: function() {
898
- $context.removeClass(className.pushed);
899
- },
900
- pushable: function() {
901
- $context.removeClass(className.pushable);
902
- },
903
-
904
- // flyout
905
- active: function() {
906
- $module.removeClass(className.active);
907
- },
908
- animating: function() {
909
- $module.removeClass(className.animating);
910
- },
911
- closing: function() {
912
- $pusher.removeClass(className.closing);
913
- },
914
- direction: function(direction) {
915
- direction = direction || module.get.direction();
916
- $module.removeClass(className[direction]);
917
- },
918
- visible: function() {
919
- $module.removeClass(className.visible);
920
- },
921
- overlay: function() {
922
- $module.removeClass(className.overlay);
923
- }
1352
+ onChange: function () {},
1353
+ onShow: function () {},
1354
+ onHide: function () {
1355
+ return true;
924
1356
  },
925
1357
 
926
- get: {
927
- direction: function() {
928
- if($module.hasClass(className.top)) {
929
- return className.top;
930
- }
931
- else if($module.hasClass(className.right)) {
932
- return className.right;
933
- }
934
- else if($module.hasClass(className.bottom)) {
935
- return className.bottom;
936
- }
937
- return className.left;
938
- },
939
- transitionEvent: function() {
940
- var
941
- element = document.createElement('element'),
942
- transitions = {
943
- 'transition' :'transitionend',
944
- 'OTransition' :'oTransitionEnd',
945
- 'MozTransition' :'transitionend',
946
- 'WebkitTransition' :'webkitTransitionEnd'
947
- },
948
- transition
949
- ;
950
- for(transition in transitions){
951
- if( element.style[transition] !== undefined ){
952
- return transitions[transition];
953
- }
954
- }
955
- },
956
- id: function() {
957
- return id;
958
- },
959
- element: function() {
960
- return $module;
961
- },
962
- settings: function() {
963
- return settings;
964
- }
1358
+ onHidden: false,
1359
+ onVisible: function () {},
1360
+
1361
+ onApprove: function () {},
1362
+ onDeny: function () {},
1363
+
1364
+ keys: {
1365
+ space: 32,
1366
+ enter: 13,
1367
+ escape: 27,
1368
+ tab: 9,
965
1369
  },
966
1370
 
967
- can: {
968
- leftBodyScrollbar: function () {
969
- if (module.cache.leftBodyScrollbar === undefined) {
970
- module.cache.leftBodyScrollbar = module.is.rtl() && ((module.is.iframe && !module.is.firefox()) || module.is.safari() || module.is.edge() || module.is.ie());
971
- }
972
- return module.cache.leftBodyScrollbar;
973
- }
1371
+ className: {
1372
+ flyout: 'ui flyout',
1373
+ close: 'close icon',
1374
+ header: 'ui header',
1375
+ content: 'content',
1376
+ actions: 'actions',
1377
+ active: 'active',
1378
+ animating: 'animating',
1379
+ blurring: 'blurring',
1380
+ closing: 'closing',
1381
+ dimmed: 'dimmed',
1382
+ ios: 'ios',
1383
+ locked: 'locked',
1384
+ pushable: 'pushable',
1385
+ pushed: 'pushed',
1386
+ right: 'right',
1387
+ top: 'top',
1388
+ left: 'left',
1389
+ bottom: 'bottom',
1390
+ visible: 'visible',
1391
+ overlay: 'overlay',
1392
+ fullscreen: 'fullscreen',
1393
+ template: 'ui flyout',
1394
+ button: 'ui button',
1395
+ ok: 'positive',
1396
+ cancel: 'negative',
1397
+ prompt: 'ui fluid input',
974
1398
  },
975
1399
 
976
- save: {
977
- focus: function() {
978
- var
979
- $activeElement = $(document.activeElement),
980
- inCurrentFlyout = $activeElement.closest($module).length > 0
981
- ;
982
- if(!inCurrentFlyout) {
983
- $focusedElement = $(document.activeElement).trigger('blur');
984
- }
985
- },
986
- bodyMargin: function() {
987
- initialBodyMargin = $context.css((isBody ? 'margin-':'padding-')+(module.can.leftBodyScrollbar() ? 'left':'right'));
988
- var bodyMarginRightPixel = parseInt(initialBodyMargin.replace(/[^\d.]/g, '')),
989
- bodyScrollbarWidth = isBody ? window.innerWidth - document.documentElement.clientWidth : $context[0].offsetWidth - $context[0].clientWidth;
990
- tempBodyMargin = bodyMarginRightPixel + bodyScrollbarWidth;
991
- }
1400
+ selector: {
1401
+ bodyFixed: '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar, > .ui.right.flyout, > .ui.fixed.nag, > .ui.fixed.nag > .close',
1402
+ fixed: '.fixed',
1403
+ omitted: 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed',
1404
+ pusher: '.pusher',
1405
+ flyout: '.ui.flyout',
1406
+ header: '.ui.header',
1407
+ content: '.content',
1408
+ actions: '.actions',
1409
+ close: '.close',
1410
+ approve: '.actions .positive, .actions .approve, .actions .ok',
1411
+ deny: '.actions .negative, .actions .deny, .actions .cancel',
992
1412
  },
993
1413
 
994
- is: {
995
- safari: function() {
996
- if(module.cache.isSafari === undefined) {
997
- module.cache.isSafari = /constructor/i.test(window.HTMLElement) || !!window.ApplePaySession;
998
- }
999
- return module.cache.isSafari;
1000
- },
1001
- edge: function(){
1002
- if(module.cache.isEdge === undefined) {
1003
- module.cache.isEdge = !!window.setImmediate && !module.is.ie();
1004
- }
1005
- return module.cache.isEdge;
1006
- },
1007
- firefox: function(){
1008
- if(module.cache.isFirefox === undefined) {
1009
- module.cache.isFirefox = !!window.InstallTrigger;
1010
- }
1011
- return module.cache.isFirefox;
1012
- },
1013
- iframe: function() {
1014
- return !(self === top);
1015
- },
1016
- ie: function() {
1017
- if(module.cache.isIE === undefined) {
1018
- var
1019
- isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
1020
- isIE = ('ActiveXObject' in window)
1021
- ;
1022
- module.cache.isIE = (isIE11 || isIE);
1023
- }
1024
- return module.cache.isIE;
1025
- },
1026
- ios: function() {
1027
- var
1028
- userAgent = navigator.userAgent,
1029
- isIOS = userAgent.match(regExp.ios),
1030
- isMobileChrome = userAgent.match(regExp.mobileChrome)
1031
- ;
1032
- if(isIOS && !isMobileChrome) {
1033
- module.verbose('Browser was found to be iOS', userAgent);
1034
- return true;
1035
- }
1036
- else {
1037
- return false;
1038
- }
1039
- },
1040
- mobile: function() {
1041
- var
1042
- userAgent = navigator.userAgent,
1043
- isMobile = userAgent.match(regExp.mobile)
1044
- ;
1045
- if(isMobile) {
1046
- module.verbose('Browser was found to be mobile', userAgent);
1047
- return true;
1048
- }
1049
- else {
1050
- module.verbose('Browser is not mobile, using regular transition', userAgent);
1051
- return false;
1052
- }
1053
- },
1054
- hidden: function() {
1055
- return !module.is.visible();
1056
- },
1057
- visible: function() {
1058
- return $module.hasClass(className.visible);
1059
- },
1060
- animating: function() {
1061
- return $context.hasClass(className.animating);
1062
- },
1063
- rtl: function () {
1064
- if(module.cache.isRTL === undefined) {
1065
- 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';
1066
- }
1067
- return module.cache.isRTL;
1068
- }
1414
+ regExp: {
1415
+ ios: /(iPad|iPhone|iPod)/g,
1416
+ mobileChrome: /(CriOS)/g,
1417
+ mobile: /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g,
1069
1418
  },
1070
1419
 
1071
- has: {
1072
- configActions: function () {
1073
- return Array.isArray(settings.actions) && settings.actions.length > 0;
1074
- },
1075
- scrollbar: function() {
1076
- return isBody || $context.css('overflow-y') !== 'hidden';
1077
- }
1420
+ error: {
1421
+ method: 'The method you called is not defined.',
1422
+ pusher: 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element',
1423
+ movedFlyout: 'Had to move flyout. For optimal performance make sure flyout and pusher are direct children of your body tag',
1424
+ notFound: 'There were no elements that matched the specified selector',
1078
1425
  },
1079
1426
 
1080
- restore: {
1081
- focus: function() {
1082
- if($focusedElement && $focusedElement.length > 0 && settings.restoreFocus) {
1083
- $focusedElement.trigger('focus');
1084
- }
1085
- },
1086
- bodyMargin: function() {
1087
- var position = module.can.leftBodyScrollbar() ? 'left':'right';
1088
- $context.css((isBody ? 'margin-':'padding-')+position, initialBodyMargin);
1089
- $context.find(selector.bodyFixed.replace('right',position)).each(function(){
1090
- var el = $(this),
1091
- attribute = el.css('position') === 'fixed' ? 'padding-'+position : position
1092
- ;
1093
- el.css(attribute, '');
1094
- });
1095
- }
1427
+ text: {
1428
+ ok: 'Ok',
1429
+ cancel: 'Cancel',
1430
+ close: 'Close',
1096
1431
  },
1432
+ };
1433
+
1434
+ $.fn.flyout.settings.templates = {
1435
+ getArguments: function (args) {
1436
+ var queryArguments = [].slice.call(args);
1437
+ if ($.isPlainObject(queryArguments[0])) {
1438
+ return $.extend({
1439
+ handler: function () {},
1440
+ content: '',
1441
+ title: '',
1442
+ }, queryArguments[0]);
1443
+ } else {
1444
+ if (!isFunction(queryArguments[queryArguments.length - 1])) {
1445
+ queryArguments.push(function () {});
1446
+ }
1097
1447
 
1098
- helpers: {
1099
- deQuote: function(string) {
1100
- return String(string).replace(/"/g,"");
1101
- },
1102
- escape: function(string, preserveHTML) {
1103
- if (preserveHTML){
1104
- return string;
1448
+ return {
1449
+ handler: queryArguments.pop(),
1450
+ content: queryArguments.pop() || '',
1451
+ title: queryArguments.pop() || '',
1452
+ };
1105
1453
  }
1454
+ },
1455
+ alert: function () {
1106
1456
  var
1107
- badChars = /[<>"'`]/g,
1108
- shouldEscape = /[&<>"'`]/,
1109
- escape = {
1110
- "<": "&lt;",
1111
- ">": "&gt;",
1112
- '"': "&quot;",
1113
- "'": "&#x27;",
1114
- "`": "&#x60;"
1115
- },
1116
- escapedChar = function(chr) {
1117
- return escape[chr];
1118
- }
1457
+ settings = this.get.settings(),
1458
+ args = settings.templates.getArguments(arguments)
1119
1459
  ;
1120
- if(shouldEscape.test(string)) {
1121
- string = string.replace(/&(?![a-z0-9#]{1,12};)/gi, "&amp;");
1122
- return string.replace(badChars, escapedChar);
1123
- }
1124
- return string;
1125
- }
1126
- },
1127
1460
 
1128
- setting: function(name, value) {
1129
- module.debug('Changing setting', name, value);
1130
- if( $.isPlainObject(name) ) {
1131
- $.extend(true, settings, name);
1132
- }
1133
- else if(value !== undefined) {
1134
- if($.isPlainObject(settings[name])) {
1135
- $.extend(true, settings[name], value);
1136
- }
1137
- else {
1138
- settings[name] = value;
1139
- }
1140
- }
1141
- else {
1142
- return settings[name];
1143
- }
1144
- },
1145
- internal: function(name, value) {
1146
- if( $.isPlainObject(name) ) {
1147
- $.extend(true, module, name);
1148
- }
1149
- else if(value !== undefined) {
1150
- module[name] = value;
1151
- }
1152
- else {
1153
- return module[name];
1154
- }
1155
- },
1156
- debug: function() {
1157
- if(!settings.silent && settings.debug) {
1158
- if(settings.performance) {
1159
- module.performance.log(arguments);
1160
- }
1161
- else {
1162
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1163
- module.debug.apply(console, arguments);
1164
- }
1165
- }
1166
- },
1167
- verbose: function() {
1168
- if(!settings.silent && settings.verbose && settings.debug) {
1169
- if(settings.performance) {
1170
- module.performance.log(arguments);
1171
- }
1172
- else {
1173
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1174
- module.verbose.apply(console, arguments);
1175
- }
1176
- }
1177
- },
1178
- error: function() {
1179
- if(!settings.silent) {
1180
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1181
- module.error.apply(console, arguments);
1182
- }
1461
+ return {
1462
+ title: args.title,
1463
+ content: args.content,
1464
+ actions: [{
1465
+ text: settings.text.ok,
1466
+ class: settings.className.ok,
1467
+ click: args.handler,
1468
+ }],
1469
+ };
1183
1470
  },
1184
- performance: {
1185
- log: function(message) {
1471
+ confirm: function () {
1186
1472
  var
1187
- currentTime,
1188
- executionTime,
1189
- previousTime
1473
+ settings = this.get.settings(),
1474
+ args = settings.templates.getArguments(arguments)
1190
1475
  ;
1191
- if(settings.performance) {
1192
- currentTime = new Date().getTime();
1193
- previousTime = time || currentTime;
1194
- executionTime = currentTime - previousTime;
1195
- time = currentTime;
1196
- performance.push({
1197
- 'Name' : message[0],
1198
- 'Arguments' : [].slice.call(message, 1) || '',
1199
- 'Element' : element,
1200
- 'Execution Time' : executionTime
1201
- });
1202
- }
1203
- clearTimeout(module.performance.timer);
1204
- module.performance.timer = setTimeout(module.performance.display, 500);
1205
- },
1206
- display: function() {
1476
+
1477
+ return {
1478
+ title: args.title,
1479
+ content: args.content,
1480
+ actions: [{
1481
+ text: settings.text.ok,
1482
+ class: settings.className.ok,
1483
+ click: function () {
1484
+ args.handler(true);
1485
+ },
1486
+ }, {
1487
+ text: settings.text.cancel,
1488
+ class: settings.className.cancel,
1489
+ click: function () {
1490
+ args.handler(false);
1491
+ },
1492
+ }],
1493
+ };
1494
+ },
1495
+ prompt: function () {
1207
1496
  var
1208
- title = settings.name + ':',
1209
- totalTime = 0
1497
+ $this = this,
1498
+ settings = this.get.settings(),
1499
+ args = settings.templates.getArguments(arguments),
1500
+ input = $($.parseHTML(args.content)).filter('.ui.input')
1210
1501
  ;
1211
- time = false;
1212
- clearTimeout(module.performance.timer);
1213
- $.each(performance, function(index, data) {
1214
- totalTime += data['Execution Time'];
1215
- });
1216
- title += ' ' + totalTime + 'ms';
1217
- if(moduleSelector) {
1218
- title += ' \'' + moduleSelector + '\'';
1219
- }
1220
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
1221
- console.groupCollapsed(title);
1222
- if(console.table) {
1223
- console.table(performance);
1224
- }
1225
- else {
1226
- $.each(performance, function(index, data) {
1227
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
1228
- });
1229
- }
1230
- console.groupEnd();
1502
+ if (input.length === 0) {
1503
+ args.content += '<p><div class="' + settings.className.prompt + '"><input placeholder="' + this.helpers.deQuote(args.placeholder || '') + '" type="text" value="' + this.helpers.deQuote(args.defaultValue || '') + '"></div></p>';
1231
1504
  }
1232
- performance = [];
1233
- }
1234
- },
1235
- invoke: function(query, passedArguments, context) {
1236
- var
1237
- object = instance,
1238
- maxDepth,
1239
- found,
1240
- response
1241
- ;
1242
- passedArguments = passedArguments || queryArguments;
1243
- context = element || context;
1244
- if(typeof query == 'string' && object !== undefined) {
1245
- query = query.split(/[\. ]/);
1246
- maxDepth = query.length - 1;
1247
- $.each(query, function(depth, value) {
1248
- var camelCaseValue = (depth != maxDepth)
1249
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1250
- : query
1251
- ;
1252
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
1253
- object = object[camelCaseValue];
1254
- }
1255
- else if( object[camelCaseValue] !== undefined ) {
1256
- found = object[camelCaseValue];
1257
- return false;
1258
- }
1259
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
1260
- object = object[value];
1261
- }
1262
- else if( object[value] !== undefined ) {
1263
- found = object[value];
1264
- return false;
1265
- }
1266
- else {
1267
- module.error(error.method, query);
1268
- return false;
1269
- }
1270
- });
1271
- }
1272
- if ( isFunction( found ) ) {
1273
- response = found.apply(context, passedArguments);
1274
- }
1275
- else if(found !== undefined) {
1276
- response = found;
1277
- }
1278
- if(Array.isArray(returnedValue)) {
1279
- returnedValue.push(response);
1280
- }
1281
- else if(returnedValue !== undefined) {
1282
- returnedValue = [returnedValue, response];
1283
- }
1284
- else if(response !== undefined) {
1285
- returnedValue = response;
1286
- }
1287
- return found;
1288
- }
1289
- }
1290
- ;
1291
-
1292
- if(methodInvoked) {
1293
- if(instance === undefined) {
1294
- if (isFunction(settings.templates[query])) {
1295
- settings.autoShow = true;
1296
- settings.className.flyout = settings.className.template;
1297
- settings = $.extend(true, {}, settings, settings.templates[query].apply(module ,queryArguments));
1298
-
1299
- // reassign shortcuts
1300
- className = settings.className;
1301
- namespace = settings.namespace;
1302
- fields = settings.fields;
1303
- error = settings.error;
1304
- }
1305
- module.initialize();
1306
- }
1307
- if (!isFunction(settings.templates[query])) {
1308
- module.invoke(query);
1309
- }
1310
- }
1311
- else {
1312
- if(instance !== undefined) {
1313
- instance.invoke('destroy');
1314
- }
1315
- module.initialize();
1316
- returnedValue = $module;
1317
- }
1318
- });
1319
-
1320
- return (returnedValue !== undefined)
1321
- ? returnedValue
1322
- : this
1323
- ;
1324
- };
1325
-
1326
- $.fn.flyout.settings = {
1327
-
1328
- name : 'Flyout',
1329
- namespace : 'flyout',
1330
-
1331
- silent : false,
1332
- debug : false,
1333
- verbose : false,
1334
- performance : true,
1335
-
1336
- context : 'body',
1337
- exclusive : false,
1338
- closable : true,
1339
- autofocus : true,
1340
- restoreFocus : true,
1341
- dimPage : true,
1342
- scrollLock : false,
1343
- returnScroll : false,
1344
- delaySetup : false,
1345
- autoShow : false,
1346
-
1347
- keyboardShortcuts: true,
1348
-
1349
- //dynamic content
1350
- title : '',
1351
- content : '',
1352
- class : '',
1353
- classTitle : '',
1354
- classContent : '',
1355
- classActions : '',
1356
- closeIcon : false,
1357
- actions : false,
1358
- preserveHTML : true,
1359
-
1360
- fields : {
1361
- class : 'class',
1362
- text : 'text',
1363
- icon : 'icon',
1364
- click : 'click'
1365
- },
1366
-
1367
- onChange : function(){},
1368
- onShow : function(){},
1369
- onHide : function(){ return true; },
1370
-
1371
- onHidden : false,
1372
- onVisible : function(){},
1373
-
1374
- onApprove : function(){},
1375
- onDeny : function(){},
1376
-
1377
- keys : {
1378
- space : 32,
1379
- enter : 13,
1380
- escape : 27,
1381
- tab : 9,
1382
- },
1383
-
1384
- className : {
1385
- flyout : 'ui flyout',
1386
- close : 'close icon',
1387
- header : 'ui header',
1388
- content : 'content',
1389
- actions : 'actions',
1390
- active : 'active',
1391
- animating : 'animating',
1392
- blurring : 'blurring',
1393
- closing : 'closing',
1394
- dimmed : 'dimmed',
1395
- ios : 'ios',
1396
- locked : 'locked',
1397
- pushable : 'pushable',
1398
- pushed : 'pushed',
1399
- right : 'right',
1400
- top : 'top',
1401
- left : 'left',
1402
- bottom : 'bottom',
1403
- visible : 'visible',
1404
- overlay : 'overlay',
1405
- fullscreen : 'fullscreen',
1406
- template : 'ui flyout',
1407
- button : 'ui button',
1408
- ok : 'positive',
1409
- cancel : 'negative',
1410
- prompt : 'ui fluid input'
1411
- },
1412
-
1413
- selector: {
1414
- bodyFixed: '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar, > .ui.right.flyout, > .ui.fixed.nag, > .ui.fixed.nag > .close',
1415
- fixed : '.fixed',
1416
- omitted : 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed',
1417
- pusher : '.pusher',
1418
- flyout : '.ui.flyout',
1419
- header : '.ui.header',
1420
- content : '.content',
1421
- actions : '.actions',
1422
- close : '.close',
1423
- approve : '.actions .positive, .actions .approve, .actions .ok',
1424
- deny : '.actions .negative, .actions .deny, .actions .cancel'
1425
- },
1426
-
1427
- regExp: {
1428
- ios : /(iPad|iPhone|iPod)/g,
1429
- mobileChrome : /(CriOS)/g,
1430
- mobile : /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g
1431
- },
1432
-
1433
- error : {
1434
- method : 'The method you called is not defined.',
1435
- pusher : 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element',
1436
- movedFlyout : 'Had to move flyout. For optimal performance make sure flyout and pusher are direct children of your body tag',
1437
- notFound : 'There were no elements that matched the specified selector'
1438
- },
1439
-
1440
- text: {
1441
- ok : 'Ok',
1442
- cancel : 'Cancel',
1443
- close : 'Close'
1444
- }
1445
- };
1446
-
1447
- $.fn.flyout.settings.templates = {
1448
- getArguments: function(args) {
1449
- var queryArguments = [].slice.call(args);
1450
- if($.isPlainObject(queryArguments[0])){
1451
- return $.extend({
1452
- handler:function(){},
1453
- content:'',
1454
- title: ''
1455
- }, queryArguments[0]);
1456
- } else {
1457
- if(!isFunction(queryArguments[queryArguments.length-1])) {
1458
- queryArguments.push(function() {});
1459
- }
1460
- return {
1461
- handler: queryArguments.pop(),
1462
- content: queryArguments.pop() || '',
1463
- title: queryArguments.pop() || ''
1464
- };
1465
- }
1466
- },
1467
- alert: function () {
1468
- var
1469
- settings = this.get.settings(),
1470
- args = settings.templates.getArguments(arguments)
1471
- ;
1472
- return {
1473
- title : args.title,
1474
- content: args.content,
1475
- actions: [{
1476
- text : settings.text.ok,
1477
- class: settings.className.ok,
1478
- click: args.handler
1479
- }]
1480
- }
1481
- },
1482
- confirm: function () {
1483
- var
1484
- settings = this.get.settings(),
1485
- args = settings.templates.getArguments(arguments)
1486
- ;
1487
- return {
1488
- title : args.title,
1489
- content: args.content,
1490
- actions: [{
1491
- text : settings.text.ok,
1492
- class: settings.className.ok,
1493
- click: function(){args.handler(true)}
1494
- },{
1495
- text: settings.text.cancel,
1496
- class: settings.className.cancel,
1497
- click: function(){args.handler(false)}
1498
- }]
1499
- }
1500
- },
1501
- prompt: function () {
1502
- var
1503
- $this = this,
1504
- settings = this.get.settings(),
1505
- args = settings.templates.getArguments(arguments),
1506
- input = $($.parseHTML(args.content)).filter('.ui.input')
1507
- ;
1508
- if (input.length === 0) {
1509
- args.content += '<p><div class="'+settings.className.prompt+'"><input placeholder="'+this.helpers.deQuote(args.placeholder || '')+'" type="text" value="'+this.helpers.deQuote(args.defaultValue || '')+'"></div></p>';
1510
- }
1511
- return {
1512
- title : args.title,
1513
- content: args.content,
1514
- actions: [{
1515
- text: settings.text.ok,
1516
- class: settings.className.ok,
1517
- click: function(){
1518
- var settings = $this.get.settings(),
1519
- inputField = $this.get.element().find(settings.selector.prompt)[0]
1520
- ;
1521
- args.handler($(inputField).val());
1522
- }
1523
- },{
1524
- text: settings.text.cancel,
1525
- class: settings.className.cancel,
1526
- click: function(){args.handler(null)}
1527
- }]
1528
- }
1529
- }
1530
- };
1531
1505
 
1532
- })( jQuery, window, document );
1506
+ return {
1507
+ title: args.title,
1508
+ content: args.content,
1509
+ actions: [{
1510
+ text: settings.text.ok,
1511
+ class: settings.className.ok,
1512
+ click: function () {
1513
+ var
1514
+ settings = $this.get.settings(),
1515
+ inputField = $this.get.element().find(settings.selector.prompt)[0]
1516
+ ;
1517
+ args.handler($(inputField).val());
1518
+ },
1519
+ }, {
1520
+ text: settings.text.cancel,
1521
+ class: settings.className.cancel,
1522
+ click: function () {
1523
+ args.handler(null);
1524
+ },
1525
+ }],
1526
+ };
1527
+ },
1528
+ };
1529
+ })(jQuery, window, document);