fomantic-ui-sass 2.9.0 → 2.9.2

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