fomantic-ui-sass 2.8.8.1 → 2.9.1

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