fomantic-ui-sass 2.9.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/fonts/semantic-ui/Lato-Bold.woff +0 -0
  3. data/app/assets/fonts/semantic-ui/Lato-Bold.woff2 +0 -0
  4. data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff +0 -0
  5. data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff2 +0 -0
  6. data/app/assets/fonts/semantic-ui/Lato-Italic.woff +0 -0
  7. data/app/assets/fonts/semantic-ui/Lato-Italic.woff2 +0 -0
  8. data/app/assets/fonts/semantic-ui/Lato-Regular.woff +0 -0
  9. data/app/assets/fonts/semantic-ui/Lato-Regular.woff2 +0 -0
  10. data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff +0 -0
  11. data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff2 +0 -0
  12. data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff +0 -0
  13. data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff2 +0 -0
  14. data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff +0 -0
  15. data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff2 +0 -0
  16. data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff +0 -0
  17. data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff2 +0 -0
  18. data/app/assets/fonts/semantic-ui/brand-icons.woff +0 -0
  19. data/app/assets/fonts/semantic-ui/brand-icons.woff2 +0 -0
  20. data/app/assets/fonts/semantic-ui/icons.woff +0 -0
  21. data/app/assets/fonts/semantic-ui/icons.woff2 +0 -0
  22. data/app/assets/fonts/semantic-ui/outline-icons.woff +0 -0
  23. data/app/assets/fonts/semantic-ui/outline-icons.woff2 +0 -0
  24. data/app/assets/javascripts/semantic-ui/accordion.js +569 -596
  25. data/app/assets/javascripts/semantic-ui/api.js +1158 -1180
  26. data/app/assets/javascripts/semantic-ui/calendar.js +1935 -1810
  27. data/app/assets/javascripts/semantic-ui/checkbox.js +843 -842
  28. data/app/assets/javascripts/semantic-ui/dimmer.js +707 -738
  29. data/app/assets/javascripts/semantic-ui/dropdown.js +4196 -4237
  30. data/app/assets/javascripts/semantic-ui/embed.js +646 -676
  31. data/app/assets/javascripts/semantic-ui/flyout.js +1515 -1466
  32. data/app/assets/javascripts/semantic-ui/form.js +2023 -2005
  33. data/app/assets/javascripts/semantic-ui/modal.js +1545 -1487
  34. data/app/assets/javascripts/semantic-ui/nag.js +521 -527
  35. data/app/assets/javascripts/semantic-ui/popup.js +1457 -1457
  36. data/app/assets/javascripts/semantic-ui/progress.js +970 -998
  37. data/app/assets/javascripts/semantic-ui/rating.js +508 -524
  38. data/app/assets/javascripts/semantic-ui/search.js +1521 -1535
  39. data/app/assets/javascripts/semantic-ui/shape.js +784 -811
  40. data/app/assets/javascripts/semantic-ui/sidebar.js +1062 -1100
  41. data/app/assets/javascripts/semantic-ui/site.js +437 -477
  42. data/app/assets/javascripts/semantic-ui/slider.js +1311 -1312
  43. data/app/assets/javascripts/semantic-ui/state.js +639 -658
  44. data/app/assets/javascripts/semantic-ui/sticky.js +848 -902
  45. data/app/assets/javascripts/semantic-ui/tab.js +903 -967
  46. data/app/assets/javascripts/semantic-ui/toast.js +911 -885
  47. data/app/assets/javascripts/semantic-ui/transition.js +1049 -1078
  48. data/app/assets/javascripts/semantic-ui/visibility.js +1214 -1246
  49. data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +7 -7
  50. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +246 -341
  51. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +185 -331
  52. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +272 -433
  53. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +127 -199
  54. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +549 -776
  55. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +711 -1123
  56. data/app/assets/stylesheets/semantic-ui/elements/_container.scss +9 -8
  57. data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +45 -63
  58. data/app/assets/stylesheets/semantic-ui/elements/_emoji.scss +3556 -3556
  59. data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +272 -270
  60. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +120 -144
  61. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +667 -747
  62. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +41 -65
  63. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +358 -276
  64. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +361 -412
  65. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +51 -72
  66. data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +69 -157
  67. data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +24 -44
  68. data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +17 -22
  69. data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +46 -85
  70. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +150 -226
  71. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +79 -152
  72. data/app/assets/stylesheets/semantic-ui/elements/_text.scss +33 -33
  73. data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +10 -15
  74. data/app/assets/stylesheets/semantic-ui/globals/_site.scss +30 -43
  75. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +37 -55
  76. data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +26 -29
  77. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +122 -193
  78. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +55 -174
  79. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +254 -388
  80. data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +20 -31
  81. data/app/assets/stylesheets/semantic-ui/modules/_flyout.scss +97 -143
  82. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +122 -156
  83. data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +55 -65
  84. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +426 -204
  85. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +108 -213
  86. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +83 -124
  87. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +71 -100
  88. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +16 -32
  89. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +105 -208
  90. data/app/assets/stylesheets/semantic-ui/modules/_slider.scss +93 -121
  91. data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +3 -7
  92. data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +12 -16
  93. data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +71 -149
  94. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +371 -1282
  95. data/app/assets/stylesheets/semantic-ui/views/_ad.scss +36 -47
  96. data/app/assets/stylesheets/semantic-ui/views/_card.scss +221 -367
  97. data/app/assets/stylesheets/semantic-ui/views/_comment.scss +43 -61
  98. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +37 -59
  99. data/app/assets/stylesheets/semantic-ui/views/_item.scss +86 -133
  100. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +77 -118
  101. data/lib/fomantic/ui/sass/version.rb +2 -2
  102. data/tasks/converter.rb +1 -1
  103. metadata +17 -1
@@ -1,1535 +1,1535 @@
1
1
  /*!
2
2
  * # Fomantic-UI - Popup
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
- $.fn.popup = function(parameters) {
27
- var
28
- $allModules = $(this),
29
- $document = $(document),
30
- $window = $(window),
31
- $body = $('body'),
32
-
33
- moduleSelector = $allModules.selector || '',
34
-
35
- clickEvent = ('ontouchstart' in document.documentElement)
36
- ? 'touchstart'
37
- : 'click',
38
-
39
- time = new Date().getTime(),
40
- performance = [],
41
-
42
- query = arguments[0],
43
- methodInvoked = (typeof query == 'string'),
44
- queryArguments = [].slice.call(arguments, 1),
45
-
46
- returnedValue
47
- ;
48
- $allModules
49
- .each(function() {
50
- var
51
- settings = ( $.isPlainObject(parameters) )
52
- ? $.extend(true, {}, $.fn.popup.settings, parameters)
53
- : $.extend({}, $.fn.popup.settings),
54
-
55
- selector = settings.selector,
56
- className = settings.className,
57
- error = settings.error,
58
- metadata = settings.metadata,
59
- namespace = settings.namespace,
60
-
61
- eventNamespace = '.' + settings.namespace,
62
- moduleNamespace = 'module-' + namespace,
63
-
64
- $module = $(this),
65
- $context = [window,document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $(settings.context),
66
- $scrollContext = [window,document].indexOf(settings.scrollContext) < 0 ? $document.find(settings.scrollContext) : $(settings.scrollContext),
67
- $boundary = [window,document].indexOf(settings.boundary) < 0 ? $document.find(settings.boundary) : $(settings.boundary),
68
- $target = (settings.target)
69
- ? ([window,document].indexOf(settings.target) < 0 ? $document.find(settings.target) : $(settings.target))
70
- : $module,
71
-
72
- $popup,
73
- $offsetParent,
74
-
75
- searchDepth = 0,
76
- triedPositions = false,
77
- openedWithTouch = false,
78
-
79
- element = this,
80
- instance = $module.data(moduleNamespace),
81
-
82
- documentObserver,
83
- elementNamespace,
84
- id,
85
- module
86
- ;
87
-
88
- module = {
89
-
90
- // binds events
91
- initialize: function() {
92
- module.debug('Initializing', $module);
93
- module.createID();
94
- module.bind.events();
95
- if(!module.exists() && settings.preserve) {
96
- module.create();
97
- }
98
- if(settings.observeChanges) {
99
- module.observeChanges();
100
- }
101
- module.instantiate();
102
- },
11
+ (function ($, window, document) {
12
+ 'use strict';
103
13
 
104
- instantiate: function() {
105
- module.verbose('Storing instance', module);
106
- instance = module;
107
- $module
108
- .data(moduleNamespace, instance)
109
- ;
110
- },
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
111
17
 
112
- observeChanges: function() {
113
- if('MutationObserver' in window) {
114
- documentObserver = new MutationObserver(module.event.documentChanged);
115
- documentObserver.observe(document, {
116
- childList : true,
117
- subtree : true
118
- });
119
- module.debug('Setting up mutation observer', documentObserver);
120
- }
121
- },
18
+ window = window !== undefined && window.Math === Math
19
+ ? window
20
+ : globalThis;
122
21
 
123
- refresh: function() {
124
- if(settings.popup) {
125
- $popup = $document.find(settings.popup).eq(0);
126
- }
127
- else {
128
- if(settings.inline) {
129
- $popup = $target.nextAll(selector.popup).eq(0);
130
- settings.popup = $popup;
131
- }
132
- }
133
- if(settings.popup) {
134
- $popup.addClass(className.loading);
135
- $offsetParent = module.get.offsetParent();
136
- $popup.removeClass(className.loading);
137
- if(settings.movePopup && module.has.popup() && module.get.offsetParent($popup)[0] !== $offsetParent[0]) {
138
- module.debug('Moving popup to the same offset parent as target');
139
- $popup
140
- .detach()
141
- .appendTo($offsetParent)
142
- ;
143
- }
144
- }
145
- else {
146
- $offsetParent = (settings.inline)
147
- ? module.get.offsetParent($target)
148
- : module.has.popup()
149
- ? module.get.offsetParent($popup)
150
- : $body
151
- ;
152
- }
153
- if( $offsetParent.is('html') && $offsetParent[0] !== $body[0] ) {
154
- module.debug('Setting page as offset parent');
155
- $offsetParent = $body;
156
- }
157
- if( module.get.variation() ) {
158
- module.set.variation();
159
- }
160
- },
22
+ $.fn.popup = function (parameters) {
23
+ var
24
+ $allModules = $(this),
25
+ $document = $(document),
26
+ $window = $(window),
27
+ $body = $('body'),
161
28
 
162
- reposition: function() {
163
- module.refresh();
164
- module.set.position();
165
- },
29
+ moduleSelector = $allModules.selector || '',
166
30
 
167
- destroy: function() {
168
- module.debug('Destroying previous module');
169
- if(documentObserver) {
170
- documentObserver.disconnect();
171
- }
172
- // remove element only if was created dynamically
173
- if($popup && !settings.preserve) {
174
- module.removePopup();
175
- }
176
- // clear all timeouts
177
- clearTimeout(module.hideTimer);
178
- clearTimeout(module.showTimer);
179
- // remove events
180
- module.unbind.close();
181
- module.unbind.events();
182
- $module
183
- .removeData(moduleNamespace)
184
- ;
185
- },
31
+ clickEvent = 'ontouchstart' in document.documentElement
32
+ ? 'touchstart'
33
+ : 'click',
186
34
 
187
- event: {
188
- start: function(event) {
189
- var
190
- delay = ($.isPlainObject(settings.delay))
191
- ? settings.delay.show
192
- : settings.delay
193
- ;
194
- clearTimeout(module.hideTimer);
195
- if(!openedWithTouch || (openedWithTouch && settings.addTouchEvents) ) {
196
- module.showTimer = setTimeout(module.show, delay);
197
- }
198
- },
199
- end: function() {
200
- var
201
- delay = ($.isPlainObject(settings.delay))
202
- ? settings.delay.hide
203
- : settings.delay
204
- ;
205
- clearTimeout(module.showTimer);
206
- module.hideTimer = setTimeout(module.hide, delay);
207
- },
208
- touchstart: function(event) {
209
- openedWithTouch = true;
210
- if(settings.addTouchEvents) {
211
- module.show();
212
- }
213
- },
214
- resize: function() {
215
- if( module.is.visible() ) {
216
- module.set.position();
217
- }
218
- },
219
- documentChanged: function(mutations) {
220
- [].forEach.call(mutations, function(mutation) {
221
- if(mutation.removedNodes) {
222
- [].forEach.call(mutation.removedNodes, function(node) {
223
- if(node == element || $(node).find(element).length > 0) {
224
- module.debug('Element removed from DOM, tearing down events');
225
- module.destroy();
226
- }
227
- });
228
- }
229
- });
230
- },
231
- hideGracefully: function(event) {
35
+ time = Date.now(),
36
+ performance = [],
37
+
38
+ query = arguments[0],
39
+ methodInvoked = typeof query === 'string',
40
+ queryArguments = [].slice.call(arguments, 1),
41
+
42
+ returnedValue
43
+ ;
44
+ $allModules.each(function () {
232
45
  var
233
- $target = $(event.target),
234
- isInDOM = $.contains(document.documentElement, event.target),
235
- inPopup = ($target.closest(selector.popup).length > 0)
46
+ settings = $.isPlainObject(parameters)
47
+ ? $.extend(true, {}, $.fn.popup.settings, parameters)
48
+ : $.extend({}, $.fn.popup.settings),
49
+
50
+ selector = settings.selector,
51
+ className = settings.className,
52
+ error = settings.error,
53
+ metadata = settings.metadata,
54
+ namespace = settings.namespace,
55
+
56
+ eventNamespace = '.' + settings.namespace,
57
+ moduleNamespace = 'module-' + namespace,
58
+
59
+ $module = $(this),
60
+ $context = [window, document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $(settings.context),
61
+ $scrollContext = [window, document].indexOf(settings.scrollContext) < 0 ? $document.find(settings.scrollContext) : $(settings.scrollContext),
62
+ $boundary = [window, document].indexOf(settings.boundary) < 0 ? $document.find(settings.boundary) : $(settings.boundary),
63
+ $target = settings.target
64
+ ? ([window, document].indexOf(settings.target) < 0 ? $document.find(settings.target) : $(settings.target))
65
+ : $module,
66
+
67
+ $popup,
68
+ $offsetParent,
69
+
70
+ searchDepth = 0,
71
+ triedPositions = false,
72
+ openedWithTouch = false,
73
+
74
+ element = this,
75
+ instance = $module.data(moduleNamespace),
76
+
77
+ documentObserver,
78
+ elementNamespace,
79
+ id,
80
+ module
236
81
  ;
237
- // don't close on clicks inside popup
238
- if(event && !inPopup && isInDOM) {
239
- module.debug('Click occurred outside popup hiding popup');
240
- module.hide();
241
- }
242
- else {
243
- module.debug('Click was inside popup, keeping popup open');
244
- }
245
- }
246
- },
247
82
 
248
- // generates popup html from metadata
249
- create: function() {
250
- var
251
- html = module.get.html(),
252
- title = module.get.title(),
253
- content = module.get.content()
254
- ;
255
-
256
- if(html || content || title) {
257
- module.debug('Creating pop-up html');
258
- if(!html) {
259
- html = settings.templates.popup({
260
- title : title,
261
- content : content
262
- });
263
- }
264
- $popup = $('<div/>')
265
- .addClass(className.popup)
266
- .data(metadata.activator, $module)
267
- .html(html)
268
- ;
269
- if(settings.inline) {
270
- module.verbose('Inserting popup element inline', $popup);
271
- $popup
272
- .insertAfter($module)
273
- ;
274
- }
275
- else {
276
- module.verbose('Appending popup element to body', $popup);
277
- $popup
278
- .appendTo( $context )
279
- ;
280
- }
281
- module.refresh();
282
- module.set.variation();
83
+ module = {
84
+
85
+ // binds events
86
+ initialize: function () {
87
+ module.debug('Initializing', $module);
88
+ module.createID();
89
+ module.bind.events();
90
+ if (!module.exists() && settings.preserve) {
91
+ module.create();
92
+ }
93
+ if (settings.observeChanges) {
94
+ module.observeChanges();
95
+ }
96
+ module.instantiate();
97
+ },
283
98
 
284
- if(settings.hoverable) {
285
- module.bind.popup();
286
- }
287
- settings.onCreate.call($popup, element);
288
- }
289
- else if(settings.popup) {
290
- $document.find(settings.popup).data(metadata.activator, $module);
291
- module.verbose('Used popup specified in settings');
292
- module.refresh();
293
- if(settings.hoverable) {
294
- module.bind.popup();
295
- }
296
- }
297
- else if($target.next(selector.popup).length !== 0) {
298
- module.verbose('Pre-existing popup found');
299
- settings.inline = true;
300
- settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
301
- module.refresh();
302
- if(settings.hoverable) {
303
- module.bind.popup();
304
- }
305
- }
306
- else {
307
- module.debug('No content specified skipping display', element);
308
- }
309
- },
99
+ instantiate: function () {
100
+ module.verbose('Storing instance', module);
101
+ instance = module;
102
+ $module
103
+ .data(moduleNamespace, instance)
104
+ ;
105
+ },
310
106
 
311
- createID: function() {
312
- id = (Math.random().toString(16) + '000000000').slice(2, 10);
313
- elementNamespace = '.' + id;
314
- module.verbose('Creating unique id for element', id);
315
- },
107
+ observeChanges: function () {
108
+ if ('MutationObserver' in window) {
109
+ documentObserver = new MutationObserver(module.event.documentChanged);
110
+ documentObserver.observe(document, {
111
+ childList: true,
112
+ subtree: true,
113
+ });
114
+ module.debug('Setting up mutation observer', documentObserver);
115
+ }
116
+ },
316
117
 
317
- // determines popup state
318
- toggle: function() {
319
- module.debug('Toggling pop-up');
320
- if( module.is.hidden() ) {
321
- module.debug('Popup is hidden, showing pop-up');
322
- module.unbind.close();
323
- module.show();
324
- }
325
- else {
326
- module.debug('Popup is visible, hiding pop-up');
327
- module.hide();
328
- }
329
- },
118
+ refresh: function () {
119
+ if (settings.popup) {
120
+ $popup = $document.find(settings.popup).eq(0);
121
+ } else {
122
+ if (settings.inline) {
123
+ $popup = $target.nextAll(selector.popup).eq(0);
124
+ settings.popup = $popup;
125
+ }
126
+ }
127
+ if (settings.popup) {
128
+ $popup.addClass(className.loading);
129
+ $offsetParent = module.get.offsetParent();
130
+ $popup.removeClass(className.loading);
131
+ if (settings.movePopup && module.has.popup() && module.get.offsetParent($popup)[0] !== $offsetParent[0]) {
132
+ module.debug('Moving popup to the same offset parent as target');
133
+ $popup
134
+ .detach()
135
+ .appendTo($offsetParent)
136
+ ;
137
+ }
138
+ } else {
139
+ $offsetParent = settings.inline
140
+ ? module.get.offsetParent($target)
141
+ : (module.has.popup()
142
+ ? module.get.offsetParent($popup)
143
+ : $body);
144
+ }
145
+ if ($offsetParent.is('html') && $offsetParent[0] !== $body[0]) {
146
+ module.debug('Setting page as offset parent');
147
+ $offsetParent = $body;
148
+ }
149
+ if (module.get.variation()) {
150
+ module.set.variation();
151
+ }
152
+ },
330
153
 
331
- show: function(callback) {
332
- callback = callback || function(){};
333
- module.debug('Showing pop-up', settings.transition);
334
- if(module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) {
335
- if( !module.exists() ) {
336
- module.create();
337
- }
338
- if(settings.onShow.call($popup, element) === false) {
339
- module.debug('onShow callback returned false, cancelling popup animation');
340
- return;
341
- }
342
- else if(!settings.preserve && !settings.popup) {
343
- module.refresh();
344
- }
345
- if( $popup && module.set.position() ) {
346
- module.save.conditions();
347
- if(settings.exclusive) {
348
- module.hideAll();
349
- }
350
- module.animate.show(callback);
351
- }
352
- }
353
- },
154
+ reposition: function () {
155
+ module.refresh();
156
+ module.set.position();
157
+ },
354
158
 
159
+ destroy: function () {
160
+ module.debug('Destroying previous module');
161
+ if (documentObserver) {
162
+ documentObserver.disconnect();
163
+ }
164
+ // remove element only if was created dynamically
165
+ if ($popup && !settings.preserve) {
166
+ module.removePopup();
167
+ }
168
+ // clear all timeouts
169
+ clearTimeout(module.hideTimer);
170
+ clearTimeout(module.showTimer);
171
+ // remove events
172
+ module.unbind.close();
173
+ module.unbind.events();
174
+ $module
175
+ .removeData(moduleNamespace)
176
+ ;
177
+ },
355
178
 
356
- hide: function(callback) {
357
- callback = callback || function(){};
358
- if( module.is.visible() || module.is.animating() ) {
359
- if(settings.onHide.call($popup, element) === false) {
360
- module.debug('onHide callback returned false, cancelling popup animation');
361
- return;
362
- }
363
- module.remove.visible();
364
- module.unbind.close();
365
- module.restore.conditions();
366
- module.animate.hide(callback);
367
- }
368
- },
179
+ event: {
180
+ start: function (event) {
181
+ var
182
+ delay = $.isPlainObject(settings.delay)
183
+ ? settings.delay.show
184
+ : settings.delay
185
+ ;
186
+ clearTimeout(module.hideTimer);
187
+ if (!openedWithTouch || (openedWithTouch && settings.addTouchEvents)) {
188
+ module.showTimer = setTimeout(module.show, delay);
189
+ }
190
+ },
191
+ end: function () {
192
+ var
193
+ delay = $.isPlainObject(settings.delay)
194
+ ? settings.delay.hide
195
+ : settings.delay
196
+ ;
197
+ clearTimeout(module.showTimer);
198
+ module.hideTimer = setTimeout(module.hide, delay);
199
+ },
200
+ touchstart: function (event) {
201
+ openedWithTouch = true;
202
+ if (settings.addTouchEvents) {
203
+ module.show();
204
+ }
205
+ },
206
+ resize: function () {
207
+ if (module.is.visible()) {
208
+ module.set.position();
209
+ }
210
+ },
211
+ documentChanged: function (mutations) {
212
+ [].forEach.call(mutations, function (mutation) {
213
+ if (mutation.removedNodes) {
214
+ [].forEach.call(mutation.removedNodes, function (node) {
215
+ if (node === element || $(node).find(element).length > 0) {
216
+ module.debug('Element removed from DOM, tearing down events');
217
+ module.destroy();
218
+ }
219
+ });
220
+ }
221
+ });
222
+ },
223
+ hideGracefully: function (event) {
224
+ var
225
+ $target = $(event.target),
226
+ isInDOM = $.contains(document.documentElement, event.target),
227
+ inPopup = $target.closest(selector.popup).length > 0
228
+ ;
229
+ // don't close on clicks inside popup
230
+ if (event && !inPopup && isInDOM) {
231
+ module.debug('Click occurred outside popup hiding popup');
232
+ module.hide();
233
+ } else {
234
+ module.debug('Click was inside popup, keeping popup open');
235
+ }
236
+ },
237
+ },
369
238
 
370
- hideAll: function() {
371
- $document.find(selector.popup)
372
- .filter('.' + className.popupVisible)
373
- .each(function() {
374
- $(this)
375
- .data(metadata.activator)
376
- .popup('hide')
377
- ;
378
- })
379
- ;
380
- },
381
- exists: function() {
382
- if(!$popup) {
383
- return false;
384
- }
385
- if(settings.inline || settings.popup) {
386
- return ( module.has.popup() );
387
- }
388
- else {
389
- return ( $popup.closest($context).length >= 1 )
390
- ? true
391
- : false
392
- ;
393
- }
394
- },
239
+ // generates popup html from metadata
240
+ create: function () {
241
+ var
242
+ html = module.get.html(),
243
+ title = module.get.title(),
244
+ content = module.get.content()
245
+ ;
246
+
247
+ if (html || content || title) {
248
+ module.debug('Creating pop-up html');
249
+ if (!html) {
250
+ html = settings.templates.popup({
251
+ title: title,
252
+ content: content,
253
+ });
254
+ }
255
+ $popup = $('<div/>')
256
+ .addClass(className.popup)
257
+ .data(metadata.activator, $module)
258
+ .html(html)
259
+ ;
260
+ if (settings.inline) {
261
+ module.verbose('Inserting popup element inline', $popup);
262
+ $popup
263
+ .insertAfter($module)
264
+ ;
265
+ } else {
266
+ module.verbose('Appending popup element to body', $popup);
267
+ $popup
268
+ .appendTo($context)
269
+ ;
270
+ }
271
+ module.refresh();
272
+ module.set.variation();
273
+
274
+ if (settings.hoverable) {
275
+ module.bind.popup();
276
+ }
277
+ settings.onCreate.call($popup, element);
278
+ } else if (settings.popup) {
279
+ $document.find(settings.popup).data(metadata.activator, $module);
280
+ module.verbose('Used popup specified in settings');
281
+ module.refresh();
282
+ if (settings.hoverable) {
283
+ module.bind.popup();
284
+ }
285
+ } else if ($target.next(selector.popup).length > 0) {
286
+ module.verbose('Pre-existing popup found');
287
+ settings.inline = true;
288
+ settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
289
+ module.refresh();
290
+ if (settings.hoverable) {
291
+ module.bind.popup();
292
+ }
293
+ } else {
294
+ module.debug('No content specified skipping display', element);
295
+ }
296
+ },
395
297
 
396
- removePopup: function() {
397
- if( module.has.popup() && !settings.popup) {
398
- module.debug('Removing popup', $popup);
399
- $popup.remove();
400
- $popup = undefined;
401
- settings.onRemove.call($popup, element);
402
- }
403
- },
298
+ createID: function () {
299
+ id = (Math.random().toString(16) + '000000000').slice(2, 10);
300
+ elementNamespace = '.' + id;
301
+ module.verbose('Creating unique id for element', id);
302
+ },
404
303
 
405
- save: {
406
- conditions: function() {
407
- module.cache = {
408
- title: $module.attr('title')
409
- };
410
- if (module.cache.title) {
411
- $module.removeAttr('title');
412
- }
413
- module.verbose('Saving original attributes', module.cache.title);
414
- }
415
- },
416
- restore: {
417
- conditions: function() {
418
- if(module.cache && module.cache.title) {
419
- $module.attr('title', module.cache.title);
420
- module.verbose('Restoring original attributes', module.cache.title);
421
- }
422
- return true;
423
- }
424
- },
425
- supports: {
426
- svg: function() {
427
- return (typeof SVGGraphicsElement !== 'undefined');
428
- }
429
- },
430
- animate: {
431
- show: function(callback) {
432
- callback = $.isFunction(callback) ? callback : function(){};
433
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
434
- module.set.visible();
435
- $popup
436
- .transition({
437
- animation : (settings.transition.showMethod || settings.transition) + ' in',
438
- queue : false,
439
- debug : settings.debug,
440
- verbose : settings.verbose,
441
- silent : settings.silent,
442
- duration : settings.transition.showDuration || settings.duration,
443
- onComplete : function() {
444
- module.bind.close();
445
- callback.call($popup, element);
446
- settings.onVisible.call($popup, element);
447
- }
448
- })
449
- ;
450
- }
451
- else {
452
- module.error(error.noTransition);
453
- }
454
- },
455
- hide: function(callback) {
456
- callback = $.isFunction(callback) ? callback : function(){};
457
- module.debug('Hiding pop-up');
458
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
459
- $popup
460
- .transition({
461
- animation : (settings.transition.hideMethod || settings.transition) + ' out',
462
- queue : false,
463
- duration : settings.transition.hideDuration || settings.duration,
464
- debug : settings.debug,
465
- verbose : settings.verbose,
466
- silent : settings.silent,
467
- onComplete : function() {
468
- module.reset();
469
- callback.call($popup, element);
470
- settings.onHidden.call($popup, element);
471
- }
472
- })
473
- ;
474
- }
475
- else {
476
- module.error(error.noTransition);
477
- }
478
- }
479
- },
304
+ // determines popup state
305
+ toggle: function () {
306
+ module.debug('Toggling pop-up');
307
+ if (module.is.hidden()) {
308
+ module.debug('Popup is hidden, showing pop-up');
309
+ module.unbind.close();
310
+ module.show();
311
+ } else {
312
+ module.debug('Popup is visible, hiding pop-up');
313
+ module.hide();
314
+ }
315
+ },
480
316
 
481
- change: {
482
- content: function(html) {
483
- $popup.html(html);
484
- }
485
- },
317
+ show: function (callback) {
318
+ callback = callback || function () {};
319
+ module.debug('Showing pop-up', settings.transition);
320
+ if (module.is.hidden() && !(module.is.active() && module.is.dropdown())) {
321
+ if (!module.exists()) {
322
+ module.create();
323
+ }
324
+ if (settings.onShow.call($popup, element) === false) {
325
+ module.debug('onShow callback returned false, cancelling popup animation');
326
+
327
+ return;
328
+ }
329
+ if (!settings.preserve && !settings.popup) {
330
+ module.refresh();
331
+ }
332
+ if ($popup && module.set.position()) {
333
+ module.save.conditions();
334
+ if (settings.exclusive) {
335
+ module.hideAll();
336
+ }
337
+ module.animate.show(callback);
338
+ }
339
+ }
340
+ },
486
341
 
487
- get: {
488
- html: function() {
489
- $module.removeData(metadata.html);
490
- return $module.data(metadata.html) || settings.html;
491
- },
492
- title: function() {
493
- $module.removeData(metadata.title);
494
- return $module.data(metadata.title) || settings.title;
495
- },
496
- content: function() {
497
- $module.removeData(metadata.content);
498
- return $module.data(metadata.content) || settings.content || $module.attr('title');
499
- },
500
- variation: function() {
501
- $module.removeData(metadata.variation);
502
- return $module.data(metadata.variation) || settings.variation;
503
- },
504
- popup: function() {
505
- return $popup;
506
- },
507
- popupOffset: function() {
508
- return $popup.offset();
509
- },
510
- calculations: function() {
511
- var
512
- $popupOffsetParent = module.get.offsetParent($popup),
513
- targetElement = $target[0],
514
- isWindow = ($boundary[0] == window),
515
- targetOffset = $target.offset(),
516
- parentOffset = settings.inline || (settings.popup && settings.movePopup)
517
- ? $target.offsetParent().offset()
518
- : { top: 0, left: 0 },
519
- screenPosition = (isWindow)
520
- ? { top: 0, left: 0 }
521
- : $boundary.offset(),
522
- calculations = {},
523
- scroll = (isWindow)
524
- ? { top: $window.scrollTop(), left: $window.scrollLeft() }
525
- : { top: 0, left: 0},
526
- screen
527
- ;
528
- calculations = {
529
- // element which is launching popup
530
- target : {
531
- element : $target[0],
532
- width : $target.outerWidth(),
533
- height : $target.outerHeight(),
534
- top : targetOffset.top - parentOffset.top,
535
- left : targetOffset.left - parentOffset.left,
536
- margin : {}
537
- },
538
- // popup itself
539
- popup : {
540
- width : $popup.outerWidth(),
541
- height : $popup.outerHeight()
542
- },
543
- // offset container (or 3d context)
544
- parent : {
545
- width : $offsetParent.outerWidth(),
546
- height : $offsetParent.outerHeight()
547
- },
548
- // screen boundaries
549
- screen : {
550
- top : screenPosition.top,
551
- left : screenPosition.left,
552
- scroll: {
553
- top : scroll.top,
554
- left : scroll.left
342
+ hide: function (callback) {
343
+ callback = callback || function () {};
344
+ if (module.is.visible() || module.is.animating()) {
345
+ if (settings.onHide.call($popup, element) === false) {
346
+ module.debug('onHide callback returned false, cancelling popup animation');
347
+
348
+ return;
349
+ }
350
+ module.remove.visible();
351
+ module.unbind.close();
352
+ module.restore.conditions();
353
+ module.animate.hide(callback);
354
+ }
555
355
  },
556
- width : $boundary.width(),
557
- height : $boundary.height()
558
- }
559
- };
560
356
 
561
- // if popup offset context is not same as target, then adjust calculations
562
- if($popupOffsetParent[0] !== $offsetParent[0]) {
563
- var
564
- popupOffset = $popupOffsetParent.offset()
565
- ;
566
- calculations.target.top -= popupOffset.top;
567
- calculations.target.left -= popupOffset.left;
568
- calculations.parent.width = $popupOffsetParent.outerWidth();
569
- calculations.parent.height = $popupOffsetParent.outerHeight();
570
- }
357
+ hideAll: function () {
358
+ $document.find(selector.popup)
359
+ .filter('.' + className.popupVisible)
360
+ .each(function () {
361
+ $(this)
362
+ .data(metadata.activator)
363
+ .popup('hide')
364
+ ;
365
+ })
366
+ ;
367
+ },
368
+ exists: function () {
369
+ if (!$popup) {
370
+ return false;
371
+ }
372
+ if (settings.inline || settings.popup) {
373
+ return module.has.popup();
374
+ }
375
+
376
+ return $popup.closest($context).length > 0;
377
+ },
571
378
 
572
- // add in container calcs if fluid
573
- if( settings.setFluidWidth && module.is.fluid() ) {
574
- calculations.container = {
575
- width: $popup.parent().outerWidth()
576
- };
577
- calculations.popup.width = calculations.container.width;
578
- }
379
+ removePopup: function () {
380
+ if (module.has.popup() && !settings.popup) {
381
+ module.debug('Removing popup', $popup);
382
+ $popup.remove();
383
+ $popup = undefined;
384
+ settings.onRemove.call($popup, element);
385
+ }
386
+ },
579
387
 
580
- // add in margins if inline
581
- calculations.target.margin.top = (settings.inline)
582
- ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
583
- : 0
584
- ;
585
- calculations.target.margin.left = (settings.inline)
586
- ? module.is.rtl()
587
- ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-right'), 10)
588
- : parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10)
589
- : 0
590
- ;
591
- // calculate screen boundaries
592
- screen = calculations.screen;
593
- calculations.boundary = {
594
- top : screen.top + screen.scroll.top,
595
- bottom : screen.top + screen.scroll.top + screen.height,
596
- left : screen.left + screen.scroll.left,
597
- right : screen.left + screen.scroll.left + screen.width
598
- };
599
- return calculations;
600
- },
601
- id: function() {
602
- return id;
603
- },
604
- startEvent: function() {
605
- if(settings.on == 'hover') {
606
- return 'mouseenter';
607
- }
608
- else if(settings.on == 'focus') {
609
- return 'focus';
610
- }
611
- return false;
612
- },
613
- scrollEvent: function() {
614
- return 'scroll';
615
- },
616
- endEvent: function() {
617
- if(settings.on == 'hover') {
618
- return 'mouseleave';
619
- }
620
- else if(settings.on == 'focus') {
621
- return 'blur';
622
- }
623
- return false;
624
- },
625
- distanceFromBoundary: function(offset, calculations) {
626
- var
627
- distanceFromBoundary = {},
628
- popup,
629
- boundary
630
- ;
631
- calculations = calculations || module.get.calculations();
632
-
633
- // shorthand
634
- popup = calculations.popup;
635
- boundary = calculations.boundary;
636
-
637
- if(offset) {
638
- distanceFromBoundary = {
639
- top : (offset.top - boundary.top),
640
- left : (offset.left - boundary.left),
641
- right : (boundary.right - (offset.left + popup.width) ),
642
- bottom : (boundary.bottom - (offset.top + popup.height) )
643
- };
644
- module.verbose('Distance from boundaries determined', offset, distanceFromBoundary);
645
- }
646
- return distanceFromBoundary;
647
- },
648
- offsetParent: function($element) {
649
- var
650
- element = ($element !== undefined)
651
- ? $element[0]
652
- : $target[0],
653
- parentNode = element.parentNode,
654
- $node = $(parentNode)
655
- ;
656
- if(parentNode) {
657
- var
658
- is2D = ($node.css('transform') === 'none'),
659
- isStatic = ($node.css('position') === 'static'),
660
- isBody = $node.is('body')
661
- ;
662
- while(parentNode && !isBody && isStatic && is2D) {
663
- parentNode = parentNode.parentNode;
664
- $node = $(parentNode);
665
- is2D = ($node.css('transform') === 'none');
666
- isStatic = ($node.css('position') === 'static');
667
- isBody = $node.is('body');
668
- }
669
- }
670
- return ($node && $node.length > 0)
671
- ? $node
672
- : $()
673
- ;
674
- },
675
- positions: function() {
676
- return {
677
- 'top left' : false,
678
- 'top center' : false,
679
- 'top right' : false,
680
- 'bottom left' : false,
681
- 'bottom center' : false,
682
- 'bottom right' : false,
683
- 'left center' : false,
684
- 'right center' : false
388
+ save: {
389
+ conditions: function () {
390
+ module.cache = {
391
+ title: $module.attr('title'),
392
+ };
393
+ if (module.cache.title) {
394
+ $module.removeAttr('title');
395
+ }
396
+ module.verbose('Saving original attributes', module.cache.title);
397
+ },
398
+ },
399
+ restore: {
400
+ conditions: function () {
401
+ if (module.cache && module.cache.title) {
402
+ $module.attr('title', module.cache.title);
403
+ module.verbose('Restoring original attributes', module.cache.title);
404
+ }
405
+
406
+ return true;
407
+ },
408
+ },
409
+ supports: {
410
+ svg: function () {
411
+ return typeof SVGGraphicsElement !== 'undefined';
412
+ },
413
+ },
414
+ animate: {
415
+ show: function (callback) {
416
+ callback = isFunction(callback) ? callback : function () {};
417
+ if (settings.transition && module.can.useElement('transition') && $module.transition('is supported')) {
418
+ module.set.visible();
419
+ $popup
420
+ .transition({
421
+ animation: (settings.transition.showMethod || settings.transition) + ' in',
422
+ queue: false,
423
+ debug: settings.debug,
424
+ verbose: settings.verbose,
425
+ silent: settings.silent,
426
+ duration: settings.transition.showDuration || settings.duration,
427
+ onComplete: function () {
428
+ module.bind.close();
429
+ callback.call($popup, element);
430
+ settings.onVisible.call($popup, element);
431
+ },
432
+ })
433
+ ;
434
+ }
435
+ },
436
+ hide: function (callback) {
437
+ callback = isFunction(callback) ? callback : function () {};
438
+ module.debug('Hiding pop-up');
439
+ if (settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
440
+ $popup
441
+ .transition({
442
+ animation: (settings.transition.hideMethod || settings.transition) + ' out',
443
+ queue: false,
444
+ duration: settings.transition.hideDuration || settings.duration,
445
+ debug: settings.debug,
446
+ verbose: settings.verbose,
447
+ silent: settings.silent,
448
+ onComplete: function () {
449
+ module.reset();
450
+ callback.call($popup, element);
451
+ settings.onHidden.call($popup, element);
452
+ },
453
+ })
454
+ ;
455
+ } else {
456
+ module.error(error.noTransition);
457
+ }
458
+ },
459
+ },
460
+
461
+ change: {
462
+ content: function (html) {
463
+ $popup.html(html);
464
+ },
465
+ },
466
+
467
+ get: {
468
+ html: function () {
469
+ $module.removeData(metadata.html);
470
+
471
+ return $module.data(metadata.html) || settings.html;
472
+ },
473
+ title: function () {
474
+ $module.removeData(metadata.title);
475
+
476
+ return $module.data(metadata.title) || settings.title;
477
+ },
478
+ content: function () {
479
+ $module.removeData(metadata.content);
480
+
481
+ return $module.data(metadata.content) || settings.content || $module.attr('title');
482
+ },
483
+ variation: function () {
484
+ $module.removeData(metadata.variation);
485
+
486
+ return $module.data(metadata.variation) || settings.variation;
487
+ },
488
+ popup: function () {
489
+ return $popup;
490
+ },
491
+ popupOffset: function () {
492
+ return $popup.offset();
493
+ },
494
+ calculations: function () {
495
+ var
496
+ $popupOffsetParent = module.get.offsetParent($popup),
497
+ targetElement = $target[0],
498
+ isWindowEl = $boundary[0] === window,
499
+ targetOffset = $target.offset(),
500
+ parentOffset = settings.inline || (settings.popup && settings.movePopup)
501
+ ? $target.offsetParent().offset()
502
+ : { top: 0, left: 0 },
503
+ screenPosition = isWindowEl
504
+ ? { top: 0, left: 0 }
505
+ : $boundary.offset(),
506
+ calculations = {},
507
+ scroll = isWindowEl
508
+ ? { top: $window.scrollTop(), left: $window.scrollLeft() }
509
+ : { top: 0, left: 0 },
510
+ screen
511
+ ;
512
+ calculations = {
513
+ // element which is launching popup
514
+ target: {
515
+ element: $target[0],
516
+ width: $target.outerWidth(),
517
+ height: $target.outerHeight(),
518
+ top: targetOffset.top - parentOffset.top,
519
+ left: targetOffset.left - parentOffset.left,
520
+ margin: {},
521
+ },
522
+ // popup itself
523
+ popup: {
524
+ width: $popup.outerWidth(),
525
+ height: $popup.outerHeight(),
526
+ },
527
+ // offset container (or 3d context)
528
+ parent: {
529
+ width: $offsetParent.outerWidth(),
530
+ height: $offsetParent.outerHeight(),
531
+ },
532
+ // screen boundaries
533
+ screen: {
534
+ top: screenPosition.top,
535
+ left: screenPosition.left,
536
+ scroll: {
537
+ top: scroll.top,
538
+ left: scroll.left,
539
+ },
540
+ width: $boundary.width(),
541
+ height: $boundary.height(),
542
+ },
543
+ };
544
+
545
+ // if popup offset context is not same as target, then adjust calculations
546
+ if ($popupOffsetParent[0] !== $offsetParent[0]) {
547
+ var
548
+ popupOffset = $popupOffsetParent.offset()
549
+ ;
550
+ calculations.target.top -= popupOffset.top;
551
+ calculations.target.left -= popupOffset.left;
552
+ calculations.parent.width = $popupOffsetParent.outerWidth();
553
+ calculations.parent.height = $popupOffsetParent.outerHeight();
554
+ }
555
+
556
+ // add in container calcs if fluid
557
+ if (settings.setFluidWidth && module.is.fluid()) {
558
+ calculations.container = {
559
+ width: $popup.parent().outerWidth(),
560
+ };
561
+ calculations.popup.width = calculations.container.width;
562
+ }
563
+
564
+ // add in margins if inline
565
+ calculations.target.margin.top = settings.inline
566
+ ? parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
567
+ : 0;
568
+ calculations.target.margin.left = settings.inline
569
+ ? (module.is.rtl()
570
+ ? parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-right'), 10)
571
+ : parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10))
572
+ : 0;
573
+ // calculate screen boundaries
574
+ screen = calculations.screen;
575
+ calculations.boundary = {
576
+ top: screen.top + screen.scroll.top,
577
+ bottom: screen.top + screen.scroll.top + screen.height,
578
+ left: screen.left + screen.scroll.left,
579
+ right: screen.left + screen.scroll.left + screen.width,
580
+ };
581
+
582
+ return calculations;
583
+ },
584
+ id: function () {
585
+ return id;
586
+ },
587
+ startEvent: function () {
588
+ if (settings.on === 'hover') {
589
+ return 'mouseenter';
590
+ }
591
+ if (settings.on === 'focus') {
592
+ return 'focus';
593
+ }
594
+
595
+ return false;
596
+ },
597
+ scrollEvent: function () {
598
+ return 'scroll';
599
+ },
600
+ endEvent: function () {
601
+ if (settings.on === 'hover') {
602
+ return 'mouseleave';
603
+ }
604
+ if (settings.on === 'focus') {
605
+ return 'blur';
606
+ }
607
+
608
+ return false;
609
+ },
610
+ distanceFromBoundary: function (offset, calculations) {
611
+ var
612
+ distanceFromBoundary = {},
613
+ popup,
614
+ boundary
615
+ ;
616
+ calculations = calculations || module.get.calculations();
617
+
618
+ // shorthand
619
+ popup = calculations.popup;
620
+ boundary = calculations.boundary;
621
+
622
+ if (offset) {
623
+ distanceFromBoundary = {
624
+ top: offset.top - boundary.top,
625
+ left: offset.left - boundary.left,
626
+ right: boundary.right - (offset.left + popup.width),
627
+ bottom: boundary.bottom - (offset.top + popup.height),
628
+ };
629
+ module.verbose('Distance from boundaries determined', offset, distanceFromBoundary);
630
+ }
631
+
632
+ return distanceFromBoundary;
633
+ },
634
+ offsetParent: function ($element) {
635
+ var
636
+ element = $element !== undefined
637
+ ? $element[0]
638
+ : $target[0],
639
+ parentNode = element.parentNode,
640
+ $node = $(parentNode)
641
+ ;
642
+ if (parentNode) {
643
+ var
644
+ is2D = $node.css('transform') === 'none',
645
+ isStatic = $node.css('position') === 'static',
646
+ isBody = $node.is('body')
647
+ ;
648
+ while (parentNode && !isBody && isStatic && is2D) {
649
+ parentNode = parentNode.parentNode;
650
+ $node = $(parentNode);
651
+ is2D = $node.css('transform') === 'none';
652
+ isStatic = $node.css('position') === 'static';
653
+ isBody = $node.is('body');
654
+ }
655
+ }
656
+
657
+ return $node && $node.length > 0
658
+ ? $node
659
+ : $();
660
+ },
661
+ positions: function () {
662
+ return {
663
+ 'top left': false,
664
+ 'top center': false,
665
+ 'top right': false,
666
+ 'bottom left': false,
667
+ 'bottom center': false,
668
+ 'bottom right': false,
669
+ 'left center': false,
670
+ 'right center': false,
671
+ };
672
+ },
673
+ nextPosition: function (position) {
674
+ var
675
+ positions = position.split(' '),
676
+ verticalPosition = positions[0],
677
+ horizontalPosition = positions[1],
678
+ opposite = {
679
+ top: 'bottom',
680
+ bottom: 'top',
681
+ left: 'right',
682
+ right: 'left',
683
+ },
684
+ adjacent = {
685
+ left: 'center',
686
+ center: 'right',
687
+ right: 'left',
688
+ },
689
+ backup = {
690
+ 'top left': 'top center',
691
+ 'top center': 'top right',
692
+ 'top right': 'right center',
693
+ 'right center': 'bottom right',
694
+ 'bottom right': 'bottom center',
695
+ 'bottom center': 'bottom left',
696
+ 'bottom left': 'left center',
697
+ 'left center': 'top left',
698
+ },
699
+ adjacentsAvailable = verticalPosition === 'top' || verticalPosition === 'bottom',
700
+ oppositeTried = false,
701
+ adjacentTried = false,
702
+ nextPosition = false
703
+ ;
704
+ if (!triedPositions) {
705
+ module.verbose('All available positions available');
706
+ triedPositions = module.get.positions();
707
+ }
708
+
709
+ module.debug('Recording last position tried', position);
710
+ triedPositions[position] = true;
711
+
712
+ if (settings.prefer === 'opposite') {
713
+ nextPosition = [opposite[verticalPosition], horizontalPosition];
714
+ nextPosition = nextPosition.join(' ');
715
+ oppositeTried = triedPositions[nextPosition] === true;
716
+ module.debug('Trying opposite strategy', nextPosition);
717
+ }
718
+ if ((settings.prefer === 'adjacent') && adjacentsAvailable) {
719
+ nextPosition = [verticalPosition, adjacent[horizontalPosition]];
720
+ nextPosition = nextPosition.join(' ');
721
+ adjacentTried = triedPositions[nextPosition] === true;
722
+ module.debug('Trying adjacent strategy', nextPosition);
723
+ }
724
+ if (adjacentTried || oppositeTried) {
725
+ module.debug('Using backup position', nextPosition);
726
+ nextPosition = backup[position];
727
+ }
728
+
729
+ return nextPosition;
730
+ },
731
+ },
732
+
733
+ set: {
734
+ position: function (position, calculations) {
735
+ // exit conditions
736
+ if ($target.length === 0 || $popup.length === 0) {
737
+ module.error(error.notFound);
738
+
739
+ return;
740
+ }
741
+ var
742
+ offset,
743
+ distanceAway,
744
+ target,
745
+ popup,
746
+ parent,
747
+ positioning,
748
+ popupOffset,
749
+ distanceFromBoundary
750
+ ;
751
+
752
+ calculations = calculations || module.get.calculations();
753
+ position = position || $module.data(metadata.position) || settings.position;
754
+
755
+ offset = $module.data(metadata.offset) || settings.offset;
756
+ distanceAway = settings.distanceAway;
757
+
758
+ // shorthand
759
+ target = calculations.target;
760
+ popup = calculations.popup;
761
+ parent = calculations.parent;
762
+
763
+ if (module.should.centerArrow(calculations)) {
764
+ module.verbose('Adjusting offset to center arrow on small target element');
765
+ if (position === 'top left' || position === 'bottom left') {
766
+ offset += target.width / 2;
767
+ offset -= settings.arrowPixelsFromEdge;
768
+ }
769
+ if (position === 'top right' || position === 'bottom right') {
770
+ offset -= target.width / 2;
771
+ offset += settings.arrowPixelsFromEdge;
772
+ }
773
+ }
774
+
775
+ if (target.width === 0 && target.height === 0 && !module.is.svg(target.element)) {
776
+ module.debug('Popup target is hidden, no action taken');
777
+
778
+ return false;
779
+ }
780
+
781
+ if (settings.inline) {
782
+ module.debug('Adding margin to calculation', target.margin);
783
+ if (position === 'left center' || position === 'right center') {
784
+ offset += target.margin.top;
785
+ distanceAway += -target.margin.left;
786
+ } else if (position === 'top left' || position === 'top center' || position === 'top right') {
787
+ offset += target.margin.left;
788
+ distanceAway -= target.margin.top;
789
+ } else {
790
+ offset += target.margin.left;
791
+ distanceAway += target.margin.top;
792
+ }
793
+ }
794
+
795
+ module.debug('Determining popup position from calculations', position, calculations);
796
+
797
+ if (module.is.rtl()) {
798
+ position = position.replace(/left|right/g, function (match) {
799
+ return match === 'left'
800
+ ? 'right'
801
+ : 'left';
802
+ });
803
+ module.debug('RTL: Popup position updated', position);
804
+ }
805
+
806
+ // if last attempt use specified last resort position
807
+ if (searchDepth === settings.maxSearchDepth && typeof settings.lastResort === 'string') {
808
+ position = settings.lastResort;
809
+ }
810
+
811
+ switch (position) {
812
+ case 'top left': {
813
+ positioning = {
814
+ top: 'auto',
815
+ bottom: parent.height - target.top + distanceAway,
816
+ left: target.left + offset,
817
+ right: 'auto',
818
+ };
819
+
820
+ break;
821
+ }
822
+ case 'top center': {
823
+ positioning = {
824
+ bottom: parent.height - target.top + distanceAway,
825
+ left: target.left + (target.width / 2) - (popup.width / 2) + offset,
826
+ top: 'auto',
827
+ right: 'auto',
828
+ };
829
+
830
+ break;
831
+ }
832
+ case 'top right': {
833
+ positioning = {
834
+ bottom: parent.height - target.top + distanceAway,
835
+ right: parent.width - target.left - target.width - offset,
836
+ top: 'auto',
837
+ left: 'auto',
838
+ };
839
+
840
+ break;
841
+ }
842
+ case 'left center': {
843
+ positioning = {
844
+ top: target.top + (target.height / 2) - (popup.height / 2) + offset,
845
+ right: parent.width - target.left + distanceAway,
846
+ left: 'auto',
847
+ bottom: 'auto',
848
+ };
849
+
850
+ break;
851
+ }
852
+ case 'right center': {
853
+ positioning = {
854
+ top: target.top + (target.height / 2) - (popup.height / 2) + offset,
855
+ left: target.left + target.width + distanceAway,
856
+ bottom: 'auto',
857
+ right: 'auto',
858
+ };
859
+
860
+ break;
861
+ }
862
+ case 'bottom left': {
863
+ positioning = {
864
+ top: target.top + target.height + distanceAway,
865
+ left: target.left + offset,
866
+ bottom: 'auto',
867
+ right: 'auto',
868
+ };
869
+
870
+ break;
871
+ }
872
+ case 'bottom center': {
873
+ positioning = {
874
+ top: target.top + target.height + distanceAway,
875
+ left: target.left + (target.width / 2) - (popup.width / 2) + offset,
876
+ bottom: 'auto',
877
+ right: 'auto',
878
+ };
879
+
880
+ break;
881
+ }
882
+ case 'bottom right': {
883
+ positioning = {
884
+ top: target.top + target.height + distanceAway,
885
+ right: parent.width - target.left - target.width - offset,
886
+ left: 'auto',
887
+ bottom: 'auto',
888
+ };
889
+
890
+ break;
891
+ }
892
+ }
893
+ if (positioning === undefined) {
894
+ module.error(error.invalidPosition, position);
895
+ }
896
+
897
+ module.debug('Calculated popup positioning values', positioning);
898
+
899
+ // tentatively place on stage
900
+ $popup
901
+ .css(positioning)
902
+ .removeClass(className.position)
903
+ .addClass(position)
904
+ .addClass(className.loading)
905
+ ;
906
+
907
+ popupOffset = module.get.popupOffset();
908
+
909
+ // see if any boundaries are surpassed with this tentative position
910
+ distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations);
911
+
912
+ if (!settings.forcePosition && module.is.offstage(distanceFromBoundary, position)) {
913
+ module.debug('Position is outside viewport', position);
914
+ if (searchDepth < settings.maxSearchDepth) {
915
+ searchDepth++;
916
+ position = module.get.nextPosition(position);
917
+ module.debug('Trying new position', position);
918
+
919
+ return $popup
920
+ ? module.set.position(position, calculations)
921
+ : false;
922
+ }
923
+ if (settings.lastResort) {
924
+ module.debug('No position found, showing with last position');
925
+ } else {
926
+ module.debug('Popup could not find a position to display', $popup);
927
+ module.error(error.cannotPlace, element);
928
+ module.remove.attempts();
929
+ module.remove.loading();
930
+ module.reset();
931
+ settings.onUnplaceable.call($popup, element);
932
+
933
+ return false;
934
+ }
935
+ }
936
+ module.debug('Position is on stage', position);
937
+ module.remove.attempts();
938
+ module.remove.loading();
939
+ if (settings.setFluidWidth && module.is.fluid()) {
940
+ module.set.fluidWidth(calculations);
941
+ }
942
+
943
+ return true;
944
+ },
945
+
946
+ fluidWidth: function (calculations) {
947
+ calculations = calculations || module.get.calculations();
948
+ module.debug('Automatically setting element width to parent width', calculations.parent.width);
949
+ $popup.css('width', calculations.container.width);
950
+ },
951
+
952
+ variation: function (variation) {
953
+ variation = variation || module.get.variation();
954
+ if (variation && module.has.popup()) {
955
+ module.verbose('Adding variation to popup', variation);
956
+ $popup.addClass(variation);
957
+ }
958
+ },
959
+
960
+ visible: function () {
961
+ $module.addClass(className.visible);
962
+ },
963
+ },
964
+
965
+ remove: {
966
+ loading: function () {
967
+ $popup.removeClass(className.loading);
968
+ },
969
+ variation: function (variation) {
970
+ variation = variation || module.get.variation();
971
+ if (variation) {
972
+ module.verbose('Removing variation', variation);
973
+ $popup.removeClass(variation);
974
+ }
975
+ },
976
+ visible: function () {
977
+ $module.removeClass(className.visible);
978
+ },
979
+ attempts: function () {
980
+ module.verbose('Resetting all searched positions');
981
+ searchDepth = 0;
982
+ triedPositions = false;
983
+ },
984
+ },
985
+
986
+ bind: {
987
+ events: function () {
988
+ module.debug('Binding popup events to module');
989
+ if (settings.on === 'click') {
990
+ $module
991
+ .on(clickEvent + eventNamespace, module.toggle)
992
+ ;
993
+ }
994
+ if (settings.on === 'hover') {
995
+ $module
996
+ .on('touchstart' + eventNamespace, module.event.touchstart)
997
+ ;
998
+ }
999
+ if (module.get.startEvent()) {
1000
+ $module
1001
+ .on(module.get.startEvent() + eventNamespace, module.event.start)
1002
+ .on(module.get.endEvent() + eventNamespace, module.event.end)
1003
+ ;
1004
+ }
1005
+ if (settings.target) {
1006
+ module.debug('Target set to element', $target);
1007
+ }
1008
+ $window.on('resize' + elementNamespace, module.event.resize);
1009
+ },
1010
+ popup: function () {
1011
+ module.verbose('Allowing hover events on popup to prevent closing');
1012
+ if ($popup && module.has.popup()) {
1013
+ $popup
1014
+ .on('mouseenter' + eventNamespace, module.event.start)
1015
+ .on('mouseleave' + eventNamespace, module.event.end)
1016
+ ;
1017
+ }
1018
+ },
1019
+ close: function () {
1020
+ if (settings.hideOnScroll === true || (settings.hideOnScroll === 'auto' && settings.on !== 'click')) {
1021
+ module.bind.closeOnScroll();
1022
+ }
1023
+ if (module.is.closable()) {
1024
+ module.bind.clickaway();
1025
+ } else if (settings.on === 'hover' && openedWithTouch) {
1026
+ module.bind.touchClose();
1027
+ }
1028
+ },
1029
+ closeOnScroll: function () {
1030
+ module.verbose('Binding scroll close event to document');
1031
+ $scrollContext
1032
+ .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully)
1033
+ ;
1034
+ },
1035
+ touchClose: function () {
1036
+ module.verbose('Binding popup touchclose event to document');
1037
+ $document
1038
+ .on('touchstart' + elementNamespace, function (event) {
1039
+ module.verbose('Touched away from popup');
1040
+ module.event.hideGracefully.call(element, event);
1041
+ })
1042
+ ;
1043
+ },
1044
+ clickaway: function () {
1045
+ module.verbose('Binding popup close event to document');
1046
+ $document
1047
+ .on(clickEvent + elementNamespace, function (event) {
1048
+ module.verbose('Clicked away from popup');
1049
+ module.event.hideGracefully.call(element, event);
1050
+ })
1051
+ ;
1052
+ },
1053
+ },
1054
+
1055
+ unbind: {
1056
+ events: function () {
1057
+ $window
1058
+ .off(elementNamespace)
1059
+ ;
1060
+ $module
1061
+ .off(eventNamespace)
1062
+ ;
1063
+ },
1064
+ close: function () {
1065
+ $document
1066
+ .off(elementNamespace)
1067
+ ;
1068
+ $scrollContext
1069
+ .off(elementNamespace)
1070
+ ;
1071
+ },
1072
+ },
1073
+
1074
+ can: {
1075
+ useElement: function (element) {
1076
+ if ($.fn[element] !== undefined) {
1077
+ return true;
1078
+ }
1079
+ module.error(error.noElement.replace('{element}', element));
1080
+
1081
+ return false;
1082
+ },
1083
+ },
1084
+
1085
+ has: {
1086
+ popup: function () {
1087
+ return $popup && $popup.length > 0;
1088
+ },
1089
+ },
1090
+
1091
+ should: {
1092
+ centerArrow: function (calculations) {
1093
+ return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2);
1094
+ },
1095
+ },
1096
+
1097
+ is: {
1098
+ closable: function () {
1099
+ if (settings.closable === 'auto') {
1100
+ return settings.on !== 'hover';
1101
+ }
1102
+
1103
+ return settings.closable;
1104
+ },
1105
+ offstage: function (distanceFromBoundary, position) {
1106
+ var
1107
+ offstage = []
1108
+ ;
1109
+ // return boundaries that have been surpassed
1110
+ $.each(distanceFromBoundary, function (direction, distance) {
1111
+ if (distance < -settings.jitter) {
1112
+ module.debug('Position exceeds allowable distance from edge', direction, distance, position);
1113
+ offstage.push(direction);
1114
+ }
1115
+ });
1116
+
1117
+ return offstage.length > 0;
1118
+ },
1119
+ svg: function (element) {
1120
+ return module.supports.svg() && (element instanceof SVGGraphicsElement);
1121
+ },
1122
+ basic: function () {
1123
+ return $module.hasClass(className.basic);
1124
+ },
1125
+ active: function () {
1126
+ return $module.hasClass(className.active);
1127
+ },
1128
+ animating: function () {
1129
+ return $popup !== undefined && $popup.hasClass(className.animating);
1130
+ },
1131
+ fluid: function () {
1132
+ return $popup !== undefined && $popup.hasClass(className.fluid);
1133
+ },
1134
+ visible: function () {
1135
+ return $popup !== undefined && $popup.hasClass(className.popupVisible);
1136
+ },
1137
+ dropdown: function () {
1138
+ return $module.hasClass(className.dropdown);
1139
+ },
1140
+ hidden: function () {
1141
+ return !module.is.visible();
1142
+ },
1143
+ rtl: function () {
1144
+ return $module.attr('dir') === 'rtl' || $module.css('direction') === 'rtl' || $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl' || $context.attr('dir') === 'rtl' || $context.css('direction') === 'rtl';
1145
+ },
1146
+ },
1147
+
1148
+ reset: function () {
1149
+ module.remove.visible();
1150
+ if (settings.preserve) {
1151
+ if ($.fn.transition !== undefined) {
1152
+ $popup
1153
+ .transition('remove transition')
1154
+ ;
1155
+ }
1156
+ } else {
1157
+ module.removePopup();
1158
+ }
1159
+ },
1160
+
1161
+ setting: function (name, value) {
1162
+ if ($.isPlainObject(name)) {
1163
+ $.extend(true, settings, name);
1164
+ } else if (value !== undefined) {
1165
+ settings[name] = value;
1166
+ } else {
1167
+ return settings[name];
1168
+ }
1169
+ },
1170
+ internal: function (name, value) {
1171
+ if ($.isPlainObject(name)) {
1172
+ $.extend(true, module, name);
1173
+ } else if (value !== undefined) {
1174
+ module[name] = value;
1175
+ } else {
1176
+ return module[name];
1177
+ }
1178
+ },
1179
+ debug: function () {
1180
+ if (!settings.silent && settings.debug) {
1181
+ if (settings.performance) {
1182
+ module.performance.log(arguments);
1183
+ } else {
1184
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1185
+ module.debug.apply(console, arguments);
1186
+ }
1187
+ }
1188
+ },
1189
+ verbose: function () {
1190
+ if (!settings.silent && settings.verbose && settings.debug) {
1191
+ if (settings.performance) {
1192
+ module.performance.log(arguments);
1193
+ } else {
1194
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1195
+ module.verbose.apply(console, arguments);
1196
+ }
1197
+ }
1198
+ },
1199
+ error: function () {
1200
+ if (!settings.silent) {
1201
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1202
+ module.error.apply(console, arguments);
1203
+ }
1204
+ },
1205
+ performance: {
1206
+ log: function (message) {
1207
+ var
1208
+ currentTime,
1209
+ executionTime,
1210
+ previousTime
1211
+ ;
1212
+ if (settings.performance) {
1213
+ currentTime = Date.now();
1214
+ previousTime = time || currentTime;
1215
+ executionTime = currentTime - previousTime;
1216
+ time = currentTime;
1217
+ performance.push({
1218
+ Name: message[0],
1219
+ Arguments: [].slice.call(message, 1) || '',
1220
+ Element: element,
1221
+ 'Execution Time': executionTime,
1222
+ });
1223
+ }
1224
+ clearTimeout(module.performance.timer);
1225
+ module.performance.timer = setTimeout(module.performance.display, 500);
1226
+ },
1227
+ display: function () {
1228
+ var
1229
+ title = settings.name + ':',
1230
+ totalTime = 0
1231
+ ;
1232
+ time = false;
1233
+ clearTimeout(module.performance.timer);
1234
+ $.each(performance, function (index, data) {
1235
+ totalTime += data['Execution Time'];
1236
+ });
1237
+ title += ' ' + totalTime + 'ms';
1238
+ if (moduleSelector) {
1239
+ title += ' \'' + moduleSelector + '\'';
1240
+ }
1241
+ if (performance.length > 0) {
1242
+ console.groupCollapsed(title);
1243
+ if (console.table) {
1244
+ console.table(performance);
1245
+ } else {
1246
+ $.each(performance, function (index, data) {
1247
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
1248
+ });
1249
+ }
1250
+ console.groupEnd();
1251
+ }
1252
+ performance = [];
1253
+ },
1254
+ },
1255
+ invoke: function (query, passedArguments, context) {
1256
+ var
1257
+ object = instance,
1258
+ maxDepth,
1259
+ found,
1260
+ response
1261
+ ;
1262
+ passedArguments = passedArguments || queryArguments;
1263
+ context = context || element;
1264
+ if (typeof query === 'string' && object !== undefined) {
1265
+ query = query.split(/[ .]/);
1266
+ maxDepth = query.length - 1;
1267
+ $.each(query, function (depth, value) {
1268
+ var camelCaseValue = depth !== maxDepth
1269
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1270
+ : query
1271
+ ;
1272
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
1273
+ object = object[camelCaseValue];
1274
+ } else if (object[camelCaseValue] !== undefined) {
1275
+ found = object[camelCaseValue];
1276
+
1277
+ return false;
1278
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
1279
+ object = object[value];
1280
+ } else if (object[value] !== undefined) {
1281
+ found = object[value];
1282
+
1283
+ return false;
1284
+ } else {
1285
+ module.error(error.method, query);
1286
+
1287
+ return false;
1288
+ }
1289
+ });
1290
+ }
1291
+ if (isFunction(found)) {
1292
+ response = found.apply(context, passedArguments);
1293
+ } else if (found !== undefined) {
1294
+ response = found;
1295
+ }
1296
+ if (Array.isArray(returnedValue)) {
1297
+ returnedValue.push(response);
1298
+ } else if (returnedValue !== undefined) {
1299
+ returnedValue = [returnedValue, response];
1300
+ } else if (response !== undefined) {
1301
+ returnedValue = response;
1302
+ }
1303
+
1304
+ return found;
1305
+ },
685
1306
  };
686
- },
687
- nextPosition: function(position) {
688
- var
689
- positions = position.split(' '),
690
- verticalPosition = positions[0],
691
- horizontalPosition = positions[1],
692
- opposite = {
693
- top : 'bottom',
694
- bottom : 'top',
695
- left : 'right',
696
- right : 'left'
697
- },
698
- adjacent = {
699
- left : 'center',
700
- center : 'right',
701
- right : 'left'
702
- },
703
- backup = {
704
- 'top left' : 'top center',
705
- 'top center' : 'top right',
706
- 'top right' : 'right center',
707
- 'right center' : 'bottom right',
708
- 'bottom right' : 'bottom center',
709
- 'bottom center' : 'bottom left',
710
- 'bottom left' : 'left center',
711
- 'left center' : 'top left'
712
- },
713
- adjacentsAvailable = (verticalPosition == 'top' || verticalPosition == 'bottom'),
714
- oppositeTried = false,
715
- adjacentTried = false,
716
- nextPosition = false
717
- ;
718
- if(!triedPositions) {
719
- module.verbose('All available positions available');
720
- triedPositions = module.get.positions();
1307
+
1308
+ if (methodInvoked) {
1309
+ if (instance === undefined) {
1310
+ module.initialize();
1311
+ }
1312
+ module.invoke(query);
1313
+ } else {
1314
+ if (instance !== undefined) {
1315
+ instance.invoke('destroy');
1316
+ }
1317
+ module.initialize();
721
1318
  }
1319
+ });
722
1320
 
723
- module.debug('Recording last position tried', position);
724
- triedPositions[position] = true;
1321
+ return returnedValue !== undefined
1322
+ ? returnedValue
1323
+ : this;
1324
+ };
725
1325
 
726
- if(settings.prefer === 'opposite') {
727
- nextPosition = [opposite[verticalPosition], horizontalPosition];
728
- nextPosition = nextPosition.join(' ');
729
- oppositeTried = (triedPositions[nextPosition] === true);
730
- module.debug('Trying opposite strategy', nextPosition);
731
- }
732
- if((settings.prefer === 'adjacent') && adjacentsAvailable ) {
733
- nextPosition = [verticalPosition, adjacent[horizontalPosition]];
734
- nextPosition = nextPosition.join(' ');
735
- adjacentTried = (triedPositions[nextPosition] === true);
736
- module.debug('Trying adjacent strategy', nextPosition);
737
- }
738
- if(adjacentTried || oppositeTried) {
739
- module.debug('Using backup position', nextPosition);
740
- nextPosition = backup[position];
741
- }
742
- return nextPosition;
743
- }
744
- },
1326
+ $.fn.popup.settings = {
745
1327
 
746
- set: {
747
- position: function(position, calculations) {
1328
+ name: 'Popup',
748
1329
 
749
- // exit conditions
750
- if($target.length === 0 || $popup.length === 0) {
751
- module.error(error.notFound);
752
- return;
753
- }
754
- var
755
- offset,
756
- distanceAway,
757
- target,
758
- popup,
759
- parent,
760
- positioning,
761
- popupOffset,
762
- distanceFromBoundary
763
- ;
1330
+ // module settings
1331
+ silent: false,
1332
+ debug: false,
1333
+ verbose: false,
1334
+ performance: true,
1335
+ namespace: 'popup',
764
1336
 
765
- calculations = calculations || module.get.calculations();
766
- position = position || $module.data(metadata.position) || settings.position;
767
-
768
- offset = $module.data(metadata.offset) || settings.offset;
769
- distanceAway = settings.distanceAway;
770
-
771
- // shorthand
772
- target = calculations.target;
773
- popup = calculations.popup;
774
- parent = calculations.parent;
775
-
776
- if(module.should.centerArrow(calculations)) {
777
- module.verbose('Adjusting offset to center arrow on small target element');
778
- if(position == 'top left' || position == 'bottom left') {
779
- offset += (target.width / 2);
780
- offset -= settings.arrowPixelsFromEdge;
781
- }
782
- if(position == 'top right' || position == 'bottom right') {
783
- offset -= (target.width / 2);
784
- offset += settings.arrowPixelsFromEdge;
785
- }
786
- }
1337
+ // whether it should use dom mutation observers
1338
+ observeChanges: true,
787
1339
 
788
- if(target.width === 0 && target.height === 0 && !module.is.svg(target.element)) {
789
- module.debug('Popup target is hidden, no action taken');
790
- return false;
791
- }
1340
+ // callback only when element added to dom
1341
+ onCreate: function () {},
792
1342
 
793
- if(settings.inline) {
794
- module.debug('Adding margin to calculation', target.margin);
795
- if(position == 'left center' || position == 'right center') {
796
- offset += target.margin.top;
797
- distanceAway += -target.margin.left;
798
- }
799
- else if (position == 'top left' || position == 'top center' || position == 'top right') {
800
- offset += target.margin.left;
801
- distanceAway -= target.margin.top;
802
- }
803
- else {
804
- offset += target.margin.left;
805
- distanceAway += target.margin.top;
806
- }
807
- }
1343
+ // callback before element removed from dom
1344
+ onRemove: function () {},
808
1345
 
809
- module.debug('Determining popup position from calculations', position, calculations);
1346
+ // callback before show animation
1347
+ onShow: function () {},
810
1348
 
811
- if (module.is.rtl()) {
812
- position = position.replace(/left|right/g, function (match) {
813
- return (match == 'left')
814
- ? 'right'
815
- : 'left'
816
- ;
817
- });
818
- module.debug('RTL: Popup position updated', position);
819
- }
1349
+ // callback after show animation
1350
+ onVisible: function () {},
820
1351
 
821
- // if last attempt use specified last resort position
822
- if(searchDepth == settings.maxSearchDepth && typeof settings.lastResort === 'string') {
823
- position = settings.lastResort;
824
- }
1352
+ // callback before hide animation
1353
+ onHide: function () {},
825
1354
 
826
- switch (position) {
827
- case 'top left':
828
- positioning = {
829
- top : 'auto',
830
- bottom : parent.height - target.top + distanceAway,
831
- left : target.left + offset,
832
- right : 'auto'
833
- };
834
- break;
835
- case 'top center':
836
- positioning = {
837
- bottom : parent.height - target.top + distanceAway,
838
- left : target.left + (target.width / 2) - (popup.width / 2) + offset,
839
- top : 'auto',
840
- right : 'auto'
841
- };
842
- break;
843
- case 'top right':
844
- positioning = {
845
- bottom : parent.height - target.top + distanceAway,
846
- right : parent.width - target.left - target.width - offset,
847
- top : 'auto',
848
- left : 'auto'
849
- };
850
- break;
851
- case 'left center':
852
- positioning = {
853
- top : target.top + (target.height / 2) - (popup.height / 2) + offset,
854
- right : parent.width - target.left + distanceAway,
855
- left : 'auto',
856
- bottom : 'auto'
857
- };
858
- break;
859
- case 'right center':
860
- positioning = {
861
- top : target.top + (target.height / 2) - (popup.height / 2) + offset,
862
- left : target.left + target.width + distanceAway,
863
- bottom : 'auto',
864
- right : 'auto'
865
- };
866
- break;
867
- case 'bottom left':
868
- positioning = {
869
- top : target.top + target.height + distanceAway,
870
- left : target.left + offset,
871
- bottom : 'auto',
872
- right : 'auto'
873
- };
874
- break;
875
- case 'bottom center':
876
- positioning = {
877
- top : target.top + target.height + distanceAway,
878
- left : target.left + (target.width / 2) - (popup.width / 2) + offset,
879
- bottom : 'auto',
880
- right : 'auto'
881
- };
882
- break;
883
- case 'bottom right':
884
- positioning = {
885
- top : target.top + target.height + distanceAway,
886
- right : parent.width - target.left - target.width - offset,
887
- left : 'auto',
888
- bottom : 'auto'
889
- };
890
- break;
891
- }
892
- if(positioning === undefined) {
893
- module.error(error.invalidPosition, position);
894
- }
1355
+ // callback when popup cannot be positioned in visible screen
1356
+ onUnplaceable: function () {},
895
1357
 
896
- module.debug('Calculated popup positioning values', positioning);
1358
+ // callback after hide animation
1359
+ onHidden: function () {},
897
1360
 
898
- // tentatively place on stage
899
- $popup
900
- .css(positioning)
901
- .removeClass(className.position)
902
- .addClass(position)
903
- .addClass(className.loading)
904
- ;
1361
+ // when to show popup
1362
+ on: 'hover',
905
1363
 
906
- popupOffset = module.get.popupOffset();
1364
+ // element to use to determine if popup is out of boundary
1365
+ boundary: window,
907
1366
 
908
- // see if any boundaries are surpassed with this tentative position
909
- distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations);
1367
+ // whether to add touchstart events when using hover
1368
+ addTouchEvents: true,
910
1369
 
911
- if(!settings.forcePosition && module.is.offstage(distanceFromBoundary, position) ) {
912
- module.debug('Position is outside viewport', position);
913
- if(searchDepth < settings.maxSearchDepth) {
914
- searchDepth++;
915
- position = module.get.nextPosition(position);
916
- module.debug('Trying new position', position);
917
- return ($popup)
918
- ? module.set.position(position, calculations)
919
- : false
920
- ;
921
- }
922
- else {
923
- if(settings.lastResort) {
924
- module.debug('No position found, showing with last position');
925
- }
926
- else {
927
- module.debug('Popup could not find a position to display', $popup);
928
- module.error(error.cannotPlace, element);
929
- module.remove.attempts();
930
- module.remove.loading();
931
- module.reset();
932
- settings.onUnplaceable.call($popup, element);
933
- return false;
934
- }
935
- }
936
- }
937
- module.debug('Position is on stage', position);
938
- module.remove.attempts();
939
- module.remove.loading();
940
- if( settings.setFluidWidth && module.is.fluid() ) {
941
- module.set.fluidWidth(calculations);
942
- }
943
- return true;
944
- },
945
-
946
- fluidWidth: function(calculations) {
947
- calculations = calculations || module.get.calculations();
948
- module.debug('Automatically setting element width to parent width', calculations.parent.width);
949
- $popup.css('width', calculations.container.width);
950
- },
951
-
952
- variation: function(variation) {
953
- variation = variation || module.get.variation();
954
- if(variation && module.has.popup() ) {
955
- module.verbose('Adding variation to popup', variation);
956
- $popup.addClass(variation);
957
- }
958
- },
1370
+ // default position relative to element
1371
+ position: 'top left',
959
1372
 
960
- visible: function() {
961
- $module.addClass(className.visible);
962
- }
963
- },
1373
+ // if given position should be used regardless if popup fits
1374
+ forcePosition: false,
964
1375
 
965
- remove: {
966
- loading: function() {
967
- $popup.removeClass(className.loading);
968
- },
969
- variation: function(variation) {
970
- variation = variation || module.get.variation();
971
- if(variation) {
972
- module.verbose('Removing variation', variation);
973
- $popup.removeClass(variation);
974
- }
975
- },
976
- visible: function() {
977
- $module.removeClass(className.visible);
978
- },
979
- attempts: function() {
980
- module.verbose('Resetting all searched positions');
981
- searchDepth = 0;
982
- triedPositions = false;
983
- }
984
- },
1376
+ // name of variation to use
1377
+ variation: '',
985
1378
 
986
- bind: {
987
- events: function() {
988
- module.debug('Binding popup events to module');
989
- if(settings.on == 'click') {
990
- $module
991
- .on(clickEvent + eventNamespace, module.toggle)
992
- ;
993
- }
994
- if(settings.on == 'hover') {
995
- $module
996
- .on('touchstart' + eventNamespace, module.event.touchstart)
997
- ;
998
- }
999
- if( module.get.startEvent() ) {
1000
- $module
1001
- .on(module.get.startEvent() + eventNamespace, module.event.start)
1002
- .on(module.get.endEvent() + eventNamespace, module.event.end)
1003
- ;
1004
- }
1005
- if(settings.target) {
1006
- module.debug('Target set to element', $target);
1007
- }
1008
- $window.on('resize' + elementNamespace, module.event.resize);
1009
- },
1010
- popup: function() {
1011
- module.verbose('Allowing hover events on popup to prevent closing');
1012
- if( $popup && module.has.popup() ) {
1013
- $popup
1014
- .on('mouseenter' + eventNamespace, module.event.start)
1015
- .on('mouseleave' + eventNamespace, module.event.end)
1016
- ;
1017
- }
1018
- },
1019
- close: function() {
1020
- if(settings.hideOnScroll === true || (settings.hideOnScroll == 'auto' && settings.on != 'click')) {
1021
- module.bind.closeOnScroll();
1022
- }
1023
- if(module.is.closable()) {
1024
- module.bind.clickaway();
1025
- }
1026
- else if(settings.on == 'hover' && openedWithTouch) {
1027
- module.bind.touchClose();
1028
- }
1029
- },
1030
- closeOnScroll: function() {
1031
- module.verbose('Binding scroll close event to document');
1032
- $scrollContext
1033
- .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully)
1034
- ;
1035
- },
1036
- touchClose: function() {
1037
- module.verbose('Binding popup touchclose event to document');
1038
- $document
1039
- .on('touchstart' + elementNamespace, function(event) {
1040
- module.verbose('Touched away from popup');
1041
- module.event.hideGracefully.call(element, event);
1042
- })
1043
- ;
1044
- },
1045
- clickaway: function() {
1046
- module.verbose('Binding popup close event to document');
1047
- $document
1048
- .on(clickEvent + elementNamespace, function(event) {
1049
- module.verbose('Clicked away from popup');
1050
- module.event.hideGracefully.call(element, event);
1051
- })
1052
- ;
1053
- }
1054
- },
1379
+ // whether popup should be moved to context
1380
+ movePopup: true,
1055
1381
 
1056
- unbind: {
1057
- events: function() {
1058
- $window
1059
- .off(elementNamespace)
1060
- ;
1061
- $module
1062
- .off(eventNamespace)
1063
- ;
1064
- },
1065
- close: function() {
1066
- $document
1067
- .off(elementNamespace)
1068
- ;
1069
- $scrollContext
1070
- .off(elementNamespace)
1071
- ;
1072
- },
1073
- },
1382
+ // element which popup should be relative to
1383
+ target: false,
1074
1384
 
1075
- has: {
1076
- popup: function() {
1077
- return ($popup && $popup.length > 0);
1078
- }
1079
- },
1385
+ // jq selector or element that should be used as popup
1386
+ popup: false,
1080
1387
 
1081
- should: {
1082
- centerArrow: function(calculations) {
1083
- return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2);
1084
- },
1085
- },
1388
+ // popup should remain inline next to activator
1389
+ inline: false,
1086
1390
 
1087
- is: {
1088
- closable: function() {
1089
- if(settings.closable == 'auto') {
1090
- return settings.on != 'hover';
1091
- }
1092
- return settings.closable;
1093
- },
1094
- offstage: function(distanceFromBoundary, position) {
1095
- var
1096
- offstage = []
1097
- ;
1098
- // return boundaries that have been surpassed
1099
- $.each(distanceFromBoundary, function(direction, distance) {
1100
- if(distance < -settings.jitter) {
1101
- module.debug('Position exceeds allowable distance from edge', direction, distance, position);
1102
- offstage.push(direction);
1103
- }
1104
- });
1105
- return offstage.length > 0;
1106
- },
1107
- svg: function(element) {
1108
- return module.supports.svg() && (element instanceof SVGGraphicsElement);
1109
- },
1110
- basic: function() {
1111
- return $module.hasClass(className.basic);
1112
- },
1113
- active: function() {
1114
- return $module.hasClass(className.active);
1115
- },
1116
- animating: function() {
1117
- return ($popup !== undefined && $popup.hasClass(className.animating) );
1118
- },
1119
- fluid: function() {
1120
- return ($popup !== undefined && $popup.hasClass(className.fluid));
1121
- },
1122
- visible: function() {
1123
- return ($popup !== undefined && $popup.hasClass(className.popupVisible));
1124
- },
1125
- dropdown: function() {
1126
- return $module.hasClass(className.dropdown);
1127
- },
1128
- hidden: function() {
1129
- return !module.is.visible();
1130
- },
1131
- rtl: function () {
1132
- return $module.attr('dir') === 'rtl' || $module.css('direction') === 'rtl' || $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl' || $context.attr('dir') === 'rtl' || $context.css('direction') === 'rtl';
1133
- }
1134
- },
1391
+ // popup should be removed from page on hide
1392
+ preserve: false,
1135
1393
 
1136
- reset: function() {
1137
- module.remove.visible();
1138
- if(settings.preserve) {
1139
- if($.fn.transition !== undefined) {
1140
- $popup
1141
- .transition('remove transition')
1142
- ;
1143
- }
1144
- }
1145
- else {
1146
- module.removePopup();
1147
- }
1148
- },
1394
+ // popup should not close when being hovered on
1395
+ hoverable: false,
1149
1396
 
1150
- setting: function(name, value) {
1151
- if( $.isPlainObject(name) ) {
1152
- $.extend(true, settings, name);
1153
- }
1154
- else if(value !== undefined) {
1155
- settings[name] = value;
1156
- }
1157
- else {
1158
- return settings[name];
1159
- }
1160
- },
1161
- internal: function(name, value) {
1162
- if( $.isPlainObject(name) ) {
1163
- $.extend(true, module, name);
1164
- }
1165
- else if(value !== undefined) {
1166
- module[name] = value;
1167
- }
1168
- else {
1169
- return module[name];
1170
- }
1171
- },
1172
- debug: function() {
1173
- if(!settings.silent && settings.debug) {
1174
- if(settings.performance) {
1175
- module.performance.log(arguments);
1176
- }
1177
- else {
1178
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1179
- module.debug.apply(console, arguments);
1180
- }
1181
- }
1182
- },
1183
- verbose: function() {
1184
- if(!settings.silent && settings.verbose && settings.debug) {
1185
- if(settings.performance) {
1186
- module.performance.log(arguments);
1187
- }
1188
- else {
1189
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1190
- module.verbose.apply(console, arguments);
1191
- }
1192
- }
1193
- },
1194
- error: function() {
1195
- if(!settings.silent) {
1196
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1197
- module.error.apply(console, arguments);
1198
- }
1199
- },
1200
- performance: {
1201
- log: function(message) {
1202
- var
1203
- currentTime,
1204
- executionTime,
1205
- previousTime
1206
- ;
1207
- if(settings.performance) {
1208
- currentTime = new Date().getTime();
1209
- previousTime = time || currentTime;
1210
- executionTime = currentTime - previousTime;
1211
- time = currentTime;
1212
- performance.push({
1213
- 'Name' : message[0],
1214
- 'Arguments' : [].slice.call(message, 1) || '',
1215
- 'Element' : element,
1216
- 'Execution Time' : executionTime
1217
- });
1218
- }
1219
- clearTimeout(module.performance.timer);
1220
- module.performance.timer = setTimeout(module.performance.display, 500);
1221
- },
1222
- display: function() {
1223
- var
1224
- title = settings.name + ':',
1225
- totalTime = 0
1226
- ;
1227
- time = false;
1228
- clearTimeout(module.performance.timer);
1229
- $.each(performance, function(index, data) {
1230
- totalTime += data['Execution Time'];
1231
- });
1232
- title += ' ' + totalTime + 'ms';
1233
- if(moduleSelector) {
1234
- title += ' \'' + moduleSelector + '\'';
1235
- }
1236
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
1237
- console.groupCollapsed(title);
1238
- if(console.table) {
1239
- console.table(performance);
1240
- }
1241
- else {
1242
- $.each(performance, function(index, data) {
1243
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
1244
- });
1245
- }
1246
- console.groupEnd();
1247
- }
1248
- performance = [];
1249
- }
1250
- },
1251
- invoke: function(query, passedArguments, context) {
1252
- var
1253
- object = instance,
1254
- maxDepth,
1255
- found,
1256
- response
1257
- ;
1258
- passedArguments = passedArguments || queryArguments;
1259
- context = context || element;
1260
- if(typeof query == 'string' && object !== undefined) {
1261
- query = query.split(/[\. ]/);
1262
- maxDepth = query.length - 1;
1263
- $.each(query, function(depth, value) {
1264
- var camelCaseValue = (depth != maxDepth)
1265
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1266
- : query
1267
- ;
1268
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
1269
- object = object[camelCaseValue];
1270
- }
1271
- else if( object[camelCaseValue] !== undefined ) {
1272
- found = object[camelCaseValue];
1273
- return false;
1274
- }
1275
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
1276
- object = object[value];
1277
- }
1278
- else if( object[value] !== undefined ) {
1279
- found = object[value];
1280
- return false;
1281
- }
1282
- else {
1283
- return false;
1284
- }
1285
- });
1286
- }
1287
- if ( $.isFunction( found ) ) {
1288
- response = found.apply(context, passedArguments);
1289
- }
1290
- else if(found !== undefined) {
1291
- response = found;
1292
- }
1293
- if(Array.isArray(returnedValue)) {
1294
- returnedValue.push(response);
1295
- }
1296
- else if(returnedValue !== undefined) {
1297
- returnedValue = [returnedValue, response];
1298
- }
1299
- else if(response !== undefined) {
1300
- returnedValue = response;
1301
- }
1302
- return found;
1303
- }
1304
- };
1305
-
1306
- if(methodInvoked) {
1307
- if(instance === undefined) {
1308
- module.initialize();
1309
- }
1310
- module.invoke(query);
1311
- }
1312
- else {
1313
- if(instance !== undefined) {
1314
- instance.invoke('destroy');
1315
- }
1316
- module.initialize();
1317
- }
1318
- })
1319
- ;
1320
-
1321
- return (returnedValue !== undefined)
1322
- ? returnedValue
1323
- : this
1324
- ;
1325
- };
1326
-
1327
- $.fn.popup.settings = {
1328
-
1329
- name : 'Popup',
1330
-
1331
- // module settings
1332
- silent : false,
1333
- debug : false,
1334
- verbose : false,
1335
- performance : true,
1336
- namespace : 'popup',
1337
-
1338
- // whether it should use dom mutation observers
1339
- observeChanges : true,
1340
-
1341
- // callback only when element added to dom
1342
- onCreate : function(){},
1343
-
1344
- // callback before element removed from dom
1345
- onRemove : function(){},
1346
-
1347
- // callback before show animation
1348
- onShow : function(){},
1349
-
1350
- // callback after show animation
1351
- onVisible : function(){},
1352
-
1353
- // callback before hide animation
1354
- onHide : function(){},
1355
-
1356
- // callback when popup cannot be positioned in visible screen
1357
- onUnplaceable : function(){},
1358
-
1359
- // callback after hide animation
1360
- onHidden : function(){},
1361
-
1362
- // when to show popup
1363
- on : 'hover',
1364
-
1365
- // element to use to determine if popup is out of boundary
1366
- boundary : window,
1367
-
1368
- // whether to add touchstart events when using hover
1369
- addTouchEvents : true,
1370
-
1371
- // default position relative to element
1372
- position : 'top left',
1373
-
1374
- // if given position should be used regardless if popup fits
1375
- forcePosition : false,
1376
-
1377
- // name of variation to use
1378
- variation : '',
1379
-
1380
- // whether popup should be moved to context
1381
- movePopup : true,
1382
-
1383
- // element which popup should be relative to
1384
- target : false,
1385
-
1386
- // jq selector or element that should be used as popup
1387
- popup : false,
1388
-
1389
- // popup should remain inline next to activator
1390
- inline : false,
1391
-
1392
- // popup should be removed from page on hide
1393
- preserve : false,
1394
-
1395
- // popup should not close when being hovered on
1396
- hoverable : false,
1397
-
1398
- // explicitly set content
1399
- content : false,
1400
-
1401
- // explicitly set html
1402
- html : false,
1403
-
1404
- // explicitly set title
1405
- title : false,
1406
-
1407
- // whether automatically close on clickaway when on click
1408
- closable : true,
1409
-
1410
- // automatically hide on scroll
1411
- hideOnScroll : 'auto',
1397
+ // explicitly set content
1398
+ content: false,
1399
+
1400
+ // explicitly set html
1401
+ html: false,
1402
+
1403
+ // explicitly set title
1404
+ title: false,
1412
1405
 
1413
- // hide other popups on show
1414
- exclusive : false,
1406
+ // whether automatically close on clickaway when on click
1407
+ closable: true,
1415
1408
 
1416
- // context to attach popups
1417
- context : 'body',
1409
+ // automatically hide on scroll
1410
+ hideOnScroll: 'auto',
1418
1411
 
1419
- // context for binding scroll events
1420
- scrollContext : window,
1412
+ // hide other popups on show
1413
+ exclusive: false,
1421
1414
 
1422
- // position to prefer when calculating new position
1423
- prefer : 'opposite',
1415
+ // context to attach popups
1416
+ context: 'body',
1424
1417
 
1425
- // specify position to appear even if it doesn't fit
1426
- lastResort : false,
1418
+ // context for binding scroll events
1419
+ scrollContext: window,
1427
1420
 
1428
- // number of pixels from edge of popup to pointing arrow center (used from centering)
1429
- arrowPixelsFromEdge: 20,
1421
+ // position to prefer when calculating new position
1422
+ prefer: 'opposite',
1430
1423
 
1431
- // delay used to prevent accidental refiring of animations due to user error
1432
- delay : {
1433
- show : 50,
1434
- hide : 70
1435
- },
1424
+ // specify position to appear even if it doesn't fit
1425
+ lastResort: false,
1436
1426
 
1437
- // whether fluid variation should assign width explicitly
1438
- setFluidWidth : true,
1427
+ // number of pixels from edge of popup to pointing arrow center (used from centering)
1428
+ arrowPixelsFromEdge: 20,
1439
1429
 
1440
- // transition settings
1441
- duration : 200,
1442
- transition : 'scale',
1430
+ // delay used to prevent accidental refiring of animations due to user error
1431
+ delay: {
1432
+ show: 50,
1433
+ hide: 70,
1434
+ },
1435
+
1436
+ // whether fluid variation should assign width explicitly
1437
+ setFluidWidth: true,
1443
1438
 
1444
- // distance away from activating element in px
1445
- distanceAway : 0,
1439
+ // transition settings
1440
+ duration: 200,
1441
+ transition: 'scale',
1446
1442
 
1447
- // number of pixels an element is allowed to be "offstage" for a position to be chosen (allows for rounding)
1448
- jitter : 2,
1443
+ // distance away from activating element in px
1444
+ distanceAway: 0,
1449
1445
 
1450
- // offset on aligning axis from calculated position
1451
- offset : 0,
1446
+ // number of pixels an element is allowed to be "offstage" for a position to be chosen (allows for rounding)
1447
+ jitter: 2,
1452
1448
 
1453
- // maximum times to look for a position before failing (9 positions total)
1454
- maxSearchDepth : 15,
1449
+ // offset on aligning axis from calculated position
1450
+ offset: 0,
1455
1451
 
1456
- error: {
1457
- invalidPosition : 'The position you specified is not a valid position',
1458
- cannotPlace : 'Popup does not fit within the boundaries of the viewport',
1459
- method : 'The method you called is not defined.',
1460
- noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>',
1461
- notFound : 'The target or popup you specified does not exist on the page'
1462
- },
1452
+ // maximum times to look for a position before failing (9 positions total)
1453
+ maxSearchDepth: 15,
1463
1454
 
1464
- metadata: {
1465
- activator : 'activator',
1466
- content : 'content',
1467
- html : 'html',
1468
- offset : 'offset',
1469
- position : 'position',
1470
- title : 'title',
1471
- variation : 'variation'
1472
- },
1473
-
1474
- className : {
1475
- active : 'active',
1476
- basic : 'basic',
1477
- animating : 'animating',
1478
- dropdown : 'dropdown',
1479
- fluid : 'fluid',
1480
- loading : 'loading',
1481
- popup : 'ui popup',
1482
- position : 'top left center bottom right',
1483
- visible : 'visible',
1484
- popupVisible : 'visible'
1485
- },
1486
-
1487
- selector : {
1488
- popup : '.ui.popup'
1489
- },
1490
-
1491
- templates: {
1492
- escape: function(string) {
1493
- var
1494
- badChars = /[<>"'`]/g,
1495
- shouldEscape = /[&<>"'`]/,
1496
- escape = {
1497
- "<": "&lt;",
1498
- ">": "&gt;",
1499
- '"': "&quot;",
1500
- "'": "&#x27;",
1501
- "`": "&#x60;"
1455
+ error: {
1456
+ invalidPosition: 'The position you specified is not a valid position',
1457
+ cannotPlace: 'Popup does not fit within the boundaries of the viewport',
1458
+ method: 'The method you called is not defined.',
1459
+ noElement: 'This module requires ui {element}',
1460
+ notFound: 'The target or popup you specified does not exist on the page',
1502
1461
  },
1503
- escapedChar = function(chr) {
1504
- return escape[chr];
1505
- }
1506
- ;
1507
- if(shouldEscape.test(string)) {
1508
- string = string.replace(/&(?![a-z0-9#]{1,12};)/gi, "&amp;");
1509
- return string.replace(badChars, escapedChar);
1510
- }
1511
- return string;
1512
- },
1513
- popup: function(text) {
1514
- var
1515
- html = '',
1516
- escape = $.fn.popup.settings.templates.escape
1517
- ;
1518
- if(typeof text !== undefined) {
1519
- if(typeof text.title !== undefined && text.title) {
1520
- text.title = escape(text.title);
1521
- html += '<div class="header">' + text.title + '</div>';
1522
- }
1523
- if(typeof text.content !== undefined && text.content) {
1524
- text.content = escape(text.content);
1525
- html += '<div class="content">' + text.content + '</div>';
1526
- }
1527
- }
1528
- return html;
1529
- }
1530
- }
1531
1462
 
1532
- };
1463
+ metadata: {
1464
+ activator: 'activator',
1465
+ content: 'content',
1466
+ html: 'html',
1467
+ offset: 'offset',
1468
+ position: 'position',
1469
+ title: 'title',
1470
+ variation: 'variation',
1471
+ },
1472
+
1473
+ className: {
1474
+ active: 'active',
1475
+ basic: 'basic',
1476
+ animating: 'animating',
1477
+ dropdown: 'dropdown',
1478
+ fluid: 'fluid',
1479
+ loading: 'loading',
1480
+ popup: 'ui popup',
1481
+ position: 'top left center bottom right',
1482
+ visible: 'visible',
1483
+ popupVisible: 'visible',
1484
+ },
1485
+
1486
+ selector: {
1487
+ popup: '.ui.popup',
1488
+ },
1489
+
1490
+ templates: {
1491
+ escape: function (string) {
1492
+ var
1493
+ badChars = /["'<>`]/g,
1494
+ shouldEscape = /["&'<>`]/,
1495
+ escape = {
1496
+ '<': '&lt;',
1497
+ '>': '&gt;',
1498
+ '"': '&quot;',
1499
+ "'": '&#x27;',
1500
+ '`': '&#x60;',
1501
+ },
1502
+ escapedChar = function (chr) {
1503
+ return escape[chr];
1504
+ }
1505
+ ;
1506
+ if (shouldEscape.test(string)) {
1507
+ string = string.replace(/&(?![\d#a-z]{1,12};)/gi, '&amp;');
1533
1508
 
1509
+ return string.replace(badChars, escapedChar);
1510
+ }
1511
+
1512
+ return string;
1513
+ },
1514
+ popup: function (text) {
1515
+ var
1516
+ html = '',
1517
+ escape = $.fn.popup.settings.templates.escape
1518
+ ;
1519
+ if (text !== undefined) {
1520
+ if (text.title) {
1521
+ text.title = escape(text.title);
1522
+ html += '<div class="header">' + text.title + '</div>';
1523
+ }
1524
+ if (text.content) {
1525
+ text.content = escape(text.content);
1526
+ html += '<div class="content">' + text.content + '</div>';
1527
+ }
1528
+ }
1529
+
1530
+ return html;
1531
+ },
1532
+ },
1534
1533
 
1535
- })( jQuery, window, document );
1534
+ };
1535
+ })(jQuery, window, document);