rails-active-ui 0.2.2 → 0.3.1

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