fomantic-ui-sass 2.9.0 → 2.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/app/assets/fonts/semantic-ui/Lato-Bold.woff +0 -0
  4. data/app/assets/fonts/semantic-ui/Lato-Bold.woff2 +0 -0
  5. data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff +0 -0
  6. data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff2 +0 -0
  7. data/app/assets/fonts/semantic-ui/Lato-Italic.woff +0 -0
  8. data/app/assets/fonts/semantic-ui/Lato-Italic.woff2 +0 -0
  9. data/app/assets/fonts/semantic-ui/Lato-Regular.woff +0 -0
  10. data/app/assets/fonts/semantic-ui/Lato-Regular.woff2 +0 -0
  11. data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff +0 -0
  12. data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff2 +0 -0
  13. data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff +0 -0
  14. data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff2 +0 -0
  15. data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff +0 -0
  16. data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff2 +0 -0
  17. data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff +0 -0
  18. data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff2 +0 -0
  19. data/app/assets/fonts/semantic-ui/brand-icons.woff +0 -0
  20. data/app/assets/fonts/semantic-ui/brand-icons.woff2 +0 -0
  21. data/app/assets/fonts/semantic-ui/icons.woff +0 -0
  22. data/app/assets/fonts/semantic-ui/icons.woff2 +0 -0
  23. data/app/assets/fonts/semantic-ui/outline-icons.woff +0 -0
  24. data/app/assets/fonts/semantic-ui/outline-icons.woff2 +0 -0
  25. data/app/assets/javascripts/semantic-ui/accordion.js +569 -596
  26. data/app/assets/javascripts/semantic-ui/api.js +1158 -1180
  27. data/app/assets/javascripts/semantic-ui/calendar.js +1935 -1810
  28. data/app/assets/javascripts/semantic-ui/checkbox.js +843 -842
  29. data/app/assets/javascripts/semantic-ui/dimmer.js +707 -738
  30. data/app/assets/javascripts/semantic-ui/dropdown.js +4196 -4237
  31. data/app/assets/javascripts/semantic-ui/embed.js +646 -676
  32. data/app/assets/javascripts/semantic-ui/flyout.js +1503 -1466
  33. data/app/assets/javascripts/semantic-ui/form.js +2035 -2007
  34. data/app/assets/javascripts/semantic-ui/modal.js +1552 -1487
  35. data/app/assets/javascripts/semantic-ui/nag.js +521 -527
  36. data/app/assets/javascripts/semantic-ui/popup.js +1469 -1457
  37. data/app/assets/javascripts/semantic-ui/progress.js +944 -998
  38. data/app/assets/javascripts/semantic-ui/rating.js +508 -524
  39. data/app/assets/javascripts/semantic-ui/search.js +1521 -1535
  40. data/app/assets/javascripts/semantic-ui/shape.js +762 -811
  41. data/app/assets/javascripts/semantic-ui/sidebar.js +1042 -1100
  42. data/app/assets/javascripts/semantic-ui/site.js +437 -477
  43. data/app/assets/javascripts/semantic-ui/slider.js +1311 -1312
  44. data/app/assets/javascripts/semantic-ui/state.js +639 -658
  45. data/app/assets/javascripts/semantic-ui/sticky.js +848 -902
  46. data/app/assets/javascripts/semantic-ui/tab.js +903 -967
  47. data/app/assets/javascripts/semantic-ui/toast.js +911 -885
  48. data/app/assets/javascripts/semantic-ui/transition.js +998 -1078
  49. data/app/assets/javascripts/semantic-ui/visibility.js +1214 -1246
  50. data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +7 -7
  51. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +311 -377
  52. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +191 -331
  53. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +302 -439
  54. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +127 -199
  55. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +549 -776
  56. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +711 -1123
  57. data/app/assets/stylesheets/semantic-ui/elements/_container.scss +9 -8
  58. data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +45 -63
  59. data/app/assets/stylesheets/semantic-ui/elements/_emoji.scss +3558 -3558
  60. data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +272 -270
  61. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +120 -144
  62. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +667 -747
  63. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +41 -65
  64. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +416 -300
  65. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +361 -412
  66. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +51 -72
  67. data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +69 -157
  68. data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +24 -44
  69. data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +17 -22
  70. data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +46 -85
  71. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +173 -227
  72. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +79 -152
  73. data/app/assets/stylesheets/semantic-ui/elements/_text.scss +34 -34
  74. data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +10 -15
  75. data/app/assets/stylesheets/semantic-ui/globals/_site.scss +29 -51
  76. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +37 -55
  77. data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +26 -29
  78. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +159 -230
  79. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +55 -174
  80. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +261 -393
  81. data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +21 -32
  82. data/app/assets/stylesheets/semantic-ui/modules/_flyout.scss +97 -143
  83. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +122 -156
  84. data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +55 -65
  85. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +573 -206
  86. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +108 -213
  87. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +83 -124
  88. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +71 -100
  89. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +16 -32
  90. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +105 -208
  91. data/app/assets/stylesheets/semantic-ui/modules/_slider.scss +102 -127
  92. data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +3 -7
  93. data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +12 -16
  94. data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +71 -149
  95. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +371 -1282
  96. data/app/assets/stylesheets/semantic-ui/views/_ad.scss +36 -47
  97. data/app/assets/stylesheets/semantic-ui/views/_card.scss +221 -367
  98. data/app/assets/stylesheets/semantic-ui/views/_comment.scss +43 -61
  99. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +37 -59
  100. data/app/assets/stylesheets/semantic-ui/views/_item.scss +87 -134
  101. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +77 -118
  102. data/lib/fomantic/ui/sass/version.rb +2 -2
  103. data/tasks/converter.rb +1 -1
  104. metadata +17 -1
@@ -1,1535 +1,1547 @@
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
+ module.set.invisible();
129
+ $offsetParent = module.get.offsetParent();
130
+ module.remove.invisible();
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')) {
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) {
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
+ ;
905
+ module.set.invisible();
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.invisible();
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.invisible();
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
+ loading: function () {
953
+ $popup.addClass(className.loading);
954
+ },
955
+
956
+ invisible: function () {
957
+ $popup.addClass(className.invisible);
958
+ },
959
+
960
+ variation: function (variation) {
961
+ variation = variation || module.get.variation();
962
+ if (variation && module.has.popup()) {
963
+ module.verbose('Adding variation to popup', variation);
964
+ $popup.addClass(variation);
965
+ }
966
+ },
967
+
968
+ visible: function () {
969
+ $module.addClass(className.visible);
970
+ },
971
+ },
972
+
973
+ remove: {
974
+ loading: function () {
975
+ $popup.removeClass(className.loading);
976
+ },
977
+ invisible: function () {
978
+ $popup.removeClass(className.invisible);
979
+ },
980
+ variation: function (variation) {
981
+ variation = variation || module.get.variation();
982
+ if (variation) {
983
+ module.verbose('Removing variation', variation);
984
+ $popup.removeClass(variation);
985
+ }
986
+ },
987
+ visible: function () {
988
+ $module.removeClass(className.visible);
989
+ },
990
+ attempts: function () {
991
+ module.verbose('Resetting all searched positions');
992
+ searchDepth = 0;
993
+ triedPositions = false;
994
+ },
995
+ },
996
+
997
+ bind: {
998
+ events: function () {
999
+ module.debug('Binding popup events to module');
1000
+ if (settings.on === 'click') {
1001
+ $module
1002
+ .on(clickEvent + eventNamespace, module.toggle)
1003
+ ;
1004
+ }
1005
+ if (settings.on === 'hover') {
1006
+ $module
1007
+ .on('touchstart' + eventNamespace, module.event.touchstart)
1008
+ ;
1009
+ }
1010
+ if (module.get.startEvent()) {
1011
+ $module
1012
+ .on(module.get.startEvent() + eventNamespace, module.event.start)
1013
+ .on(module.get.endEvent() + eventNamespace, module.event.end)
1014
+ ;
1015
+ }
1016
+ if (settings.target) {
1017
+ module.debug('Target set to element', $target);
1018
+ }
1019
+ $window.on('resize' + elementNamespace, module.event.resize);
1020
+ },
1021
+ popup: function () {
1022
+ module.verbose('Allowing hover events on popup to prevent closing');
1023
+ if ($popup && module.has.popup()) {
1024
+ $popup
1025
+ .on('mouseenter' + eventNamespace, module.event.start)
1026
+ .on('mouseleave' + eventNamespace, module.event.end)
1027
+ ;
1028
+ }
1029
+ },
1030
+ close: function () {
1031
+ if (settings.hideOnScroll === true || (settings.hideOnScroll === 'auto' && settings.on !== 'click')) {
1032
+ module.bind.closeOnScroll();
1033
+ }
1034
+ if (module.is.closable()) {
1035
+ module.bind.clickaway();
1036
+ } else if (settings.on === 'hover' && openedWithTouch) {
1037
+ module.bind.touchClose();
1038
+ }
1039
+ },
1040
+ closeOnScroll: function () {
1041
+ module.verbose('Binding scroll close event to document');
1042
+ $scrollContext
1043
+ .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully)
1044
+ ;
1045
+ },
1046
+ touchClose: function () {
1047
+ module.verbose('Binding popup touchclose event to document');
1048
+ $document
1049
+ .on('touchstart' + elementNamespace, function (event) {
1050
+ module.verbose('Touched away from popup');
1051
+ module.event.hideGracefully.call(element, event);
1052
+ })
1053
+ ;
1054
+ },
1055
+ clickaway: function () {
1056
+ module.verbose('Binding popup close event to document');
1057
+ $document
1058
+ .on(clickEvent + elementNamespace, function (event) {
1059
+ module.verbose('Clicked away from popup');
1060
+ module.event.hideGracefully.call(element, event);
1061
+ })
1062
+ ;
1063
+ },
1064
+ },
1065
+
1066
+ unbind: {
1067
+ events: function () {
1068
+ $window
1069
+ .off(elementNamespace)
1070
+ ;
1071
+ $module
1072
+ .off(eventNamespace)
1073
+ ;
1074
+ },
1075
+ close: function () {
1076
+ $document
1077
+ .off(elementNamespace)
1078
+ ;
1079
+ $scrollContext
1080
+ .off(elementNamespace)
1081
+ ;
1082
+ },
1083
+ },
1084
+
1085
+ can: {
1086
+ useElement: function (element) {
1087
+ if ($.fn[element] !== undefined) {
1088
+ return true;
1089
+ }
1090
+ module.error(error.noElement.replace('{element}', element));
1091
+
1092
+ return false;
1093
+ },
1094
+ },
1095
+
1096
+ has: {
1097
+ popup: function () {
1098
+ return $popup && $popup.length > 0;
1099
+ },
1100
+ },
1101
+
1102
+ should: {
1103
+ centerArrow: function (calculations) {
1104
+ return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2);
1105
+ },
1106
+ },
1107
+
1108
+ is: {
1109
+ closable: function () {
1110
+ if (settings.closable === 'auto') {
1111
+ return settings.on !== 'hover';
1112
+ }
1113
+
1114
+ return settings.closable;
1115
+ },
1116
+ offstage: function (distanceFromBoundary, position) {
1117
+ var
1118
+ offstage = []
1119
+ ;
1120
+ // return boundaries that have been surpassed
1121
+ $.each(distanceFromBoundary, function (direction, distance) {
1122
+ if (distance < -settings.jitter) {
1123
+ module.debug('Position exceeds allowable distance from edge', direction, distance, position);
1124
+ offstage.push(direction);
1125
+ }
1126
+ });
1127
+
1128
+ return offstage.length > 0;
1129
+ },
1130
+ svg: function (element) {
1131
+ return module.supports.svg() && (element instanceof SVGGraphicsElement);
1132
+ },
1133
+ basic: function () {
1134
+ return $module.hasClass(className.basic);
1135
+ },
1136
+ active: function () {
1137
+ return $module.hasClass(className.active);
1138
+ },
1139
+ animating: function () {
1140
+ return $popup !== undefined && $popup.hasClass(className.animating);
1141
+ },
1142
+ fluid: function () {
1143
+ return $popup !== undefined && $popup.hasClass(className.fluid);
1144
+ },
1145
+ visible: function () {
1146
+ return $popup !== undefined && $popup.hasClass(className.popupVisible);
1147
+ },
1148
+ dropdown: function () {
1149
+ return $module.hasClass(className.dropdown);
1150
+ },
1151
+ hidden: function () {
1152
+ return !module.is.visible();
1153
+ },
1154
+ rtl: function () {
1155
+ 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';
1156
+ },
1157
+ },
1158
+
1159
+ reset: function () {
1160
+ module.remove.visible();
1161
+ if (settings.preserve) {
1162
+ if ($.fn.transition !== undefined) {
1163
+ $popup
1164
+ .transition('remove transition')
1165
+ ;
1166
+ }
1167
+ } else {
1168
+ module.removePopup();
1169
+ }
1170
+ },
1171
+
1172
+ setting: function (name, value) {
1173
+ if ($.isPlainObject(name)) {
1174
+ $.extend(true, settings, name);
1175
+ } else if (value !== undefined) {
1176
+ settings[name] = value;
1177
+ } else {
1178
+ return settings[name];
1179
+ }
1180
+ },
1181
+ internal: function (name, value) {
1182
+ if ($.isPlainObject(name)) {
1183
+ $.extend(true, module, name);
1184
+ } else if (value !== undefined) {
1185
+ module[name] = value;
1186
+ } else {
1187
+ return module[name];
1188
+ }
1189
+ },
1190
+ debug: function () {
1191
+ if (!settings.silent && settings.debug) {
1192
+ if (settings.performance) {
1193
+ module.performance.log(arguments);
1194
+ } else {
1195
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1196
+ module.debug.apply(console, arguments);
1197
+ }
1198
+ }
1199
+ },
1200
+ verbose: function () {
1201
+ if (!settings.silent && settings.verbose && settings.debug) {
1202
+ if (settings.performance) {
1203
+ module.performance.log(arguments);
1204
+ } else {
1205
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1206
+ module.verbose.apply(console, arguments);
1207
+ }
1208
+ }
1209
+ },
1210
+ error: function () {
1211
+ if (!settings.silent) {
1212
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1213
+ module.error.apply(console, arguments);
1214
+ }
1215
+ },
1216
+ performance: {
1217
+ log: function (message) {
1218
+ var
1219
+ currentTime,
1220
+ executionTime,
1221
+ previousTime
1222
+ ;
1223
+ if (settings.performance) {
1224
+ currentTime = Date.now();
1225
+ previousTime = time || currentTime;
1226
+ executionTime = currentTime - previousTime;
1227
+ time = currentTime;
1228
+ performance.push({
1229
+ Name: message[0],
1230
+ Arguments: [].slice.call(message, 1) || '',
1231
+ Element: element,
1232
+ 'Execution Time': executionTime,
1233
+ });
1234
+ }
1235
+ clearTimeout(module.performance.timer);
1236
+ module.performance.timer = setTimeout(module.performance.display, 500);
1237
+ },
1238
+ display: function () {
1239
+ var
1240
+ title = settings.name + ':',
1241
+ totalTime = 0
1242
+ ;
1243
+ time = false;
1244
+ clearTimeout(module.performance.timer);
1245
+ $.each(performance, function (index, data) {
1246
+ totalTime += data['Execution Time'];
1247
+ });
1248
+ title += ' ' + totalTime + 'ms';
1249
+ if (moduleSelector) {
1250
+ title += ' \'' + moduleSelector + '\'';
1251
+ }
1252
+ if (performance.length > 0) {
1253
+ console.groupCollapsed(title);
1254
+ if (console.table) {
1255
+ console.table(performance);
1256
+ } else {
1257
+ $.each(performance, function (index, data) {
1258
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
1259
+ });
1260
+ }
1261
+ console.groupEnd();
1262
+ }
1263
+ performance = [];
1264
+ },
1265
+ },
1266
+ invoke: function (query, passedArguments, context) {
1267
+ var
1268
+ object = instance,
1269
+ maxDepth,
1270
+ found,
1271
+ response
1272
+ ;
1273
+ passedArguments = passedArguments || queryArguments;
1274
+ context = context || element;
1275
+ if (typeof query === 'string' && object !== undefined) {
1276
+ query = query.split(/[ .]/);
1277
+ maxDepth = query.length - 1;
1278
+ $.each(query, function (depth, value) {
1279
+ var camelCaseValue = depth !== maxDepth
1280
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1281
+ : query
1282
+ ;
1283
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
1284
+ object = object[camelCaseValue];
1285
+ } else if (object[camelCaseValue] !== undefined) {
1286
+ found = object[camelCaseValue];
1287
+
1288
+ return false;
1289
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
1290
+ object = object[value];
1291
+ } else if (object[value] !== undefined) {
1292
+ found = object[value];
1293
+
1294
+ return false;
1295
+ } else {
1296
+ module.error(error.method, query);
1297
+
1298
+ return false;
1299
+ }
1300
+ });
1301
+ }
1302
+ if (isFunction(found)) {
1303
+ response = found.apply(context, passedArguments);
1304
+ } else if (found !== undefined) {
1305
+ response = found;
1306
+ }
1307
+ if (Array.isArray(returnedValue)) {
1308
+ returnedValue.push(response);
1309
+ } else if (returnedValue !== undefined) {
1310
+ returnedValue = [returnedValue, response];
1311
+ } else if (response !== undefined) {
1312
+ returnedValue = response;
1313
+ }
1314
+
1315
+ return found;
1316
+ },
685
1317
  };
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();
1318
+
1319
+ if (methodInvoked) {
1320
+ if (instance === undefined) {
1321
+ module.initialize();
1322
+ }
1323
+ module.invoke(query);
1324
+ } else {
1325
+ if (instance !== undefined) {
1326
+ instance.invoke('destroy');
1327
+ }
1328
+ module.initialize();
721
1329
  }
1330
+ });
722
1331
 
723
- module.debug('Recording last position tried', position);
724
- triedPositions[position] = true;
1332
+ return returnedValue !== undefined
1333
+ ? returnedValue
1334
+ : this;
1335
+ };
725
1336
 
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
- },
1337
+ $.fn.popup.settings = {
745
1338
 
746
- set: {
747
- position: function(position, calculations) {
1339
+ name: 'Popup',
748
1340
 
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
- ;
1341
+ // module settings
1342
+ silent: false,
1343
+ debug: false,
1344
+ verbose: false,
1345
+ performance: true,
1346
+ namespace: 'popup',
764
1347
 
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
- }
1348
+ // whether it should use dom mutation observers
1349
+ observeChanges: true,
787
1350
 
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
- }
1351
+ // callback only when element added to dom
1352
+ onCreate: function () {},
792
1353
 
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
- }
1354
+ // callback before element removed from dom
1355
+ onRemove: function () {},
808
1356
 
809
- module.debug('Determining popup position from calculations', position, calculations);
1357
+ // callback before show animation
1358
+ onShow: function () {},
810
1359
 
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
- }
1360
+ // callback after show animation
1361
+ onVisible: function () {},
820
1362
 
821
- // if last attempt use specified last resort position
822
- if(searchDepth == settings.maxSearchDepth && typeof settings.lastResort === 'string') {
823
- position = settings.lastResort;
824
- }
1363
+ // callback before hide animation
1364
+ onHide: function () {},
825
1365
 
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
- }
1366
+ // callback when popup cannot be positioned in visible screen
1367
+ onUnplaceable: function () {},
895
1368
 
896
- module.debug('Calculated popup positioning values', positioning);
1369
+ // callback after hide animation
1370
+ onHidden: function () {},
897
1371
 
898
- // tentatively place on stage
899
- $popup
900
- .css(positioning)
901
- .removeClass(className.position)
902
- .addClass(position)
903
- .addClass(className.loading)
904
- ;
1372
+ // when to show popup
1373
+ on: 'hover',
905
1374
 
906
- popupOffset = module.get.popupOffset();
1375
+ // element to use to determine if popup is out of boundary
1376
+ boundary: window,
907
1377
 
908
- // see if any boundaries are surpassed with this tentative position
909
- distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations);
1378
+ // whether to add touchstart events when using hover
1379
+ addTouchEvents: true,
910
1380
 
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
- },
1381
+ // default position relative to element
1382
+ position: 'top left',
959
1383
 
960
- visible: function() {
961
- $module.addClass(className.visible);
962
- }
963
- },
1384
+ // if given position should be used regardless if popup fits
1385
+ forcePosition: false,
964
1386
 
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
- },
1387
+ // name of variation to use
1388
+ variation: '',
985
1389
 
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
- },
1390
+ // whether popup should be moved to context
1391
+ movePopup: true,
1055
1392
 
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
- },
1393
+ // element which popup should be relative to
1394
+ target: false,
1074
1395
 
1075
- has: {
1076
- popup: function() {
1077
- return ($popup && $popup.length > 0);
1078
- }
1079
- },
1396
+ // jq selector or element that should be used as popup
1397
+ popup: false,
1080
1398
 
1081
- should: {
1082
- centerArrow: function(calculations) {
1083
- return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2);
1084
- },
1085
- },
1399
+ // popup should remain inline next to activator
1400
+ inline: false,
1086
1401
 
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
- },
1402
+ // popup should be removed from page on hide
1403
+ preserve: false,
1135
1404
 
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
- },
1405
+ // popup should not close when being hovered on
1406
+ hoverable: false,
1149
1407
 
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',
1408
+ // explicitly set content
1409
+ content: false,
1410
+
1411
+ // explicitly set html
1412
+ html: false,
1413
+
1414
+ // explicitly set title
1415
+ title: false,
1412
1416
 
1413
- // hide other popups on show
1414
- exclusive : false,
1417
+ // whether automatically close on clickaway when on click
1418
+ closable: true,
1415
1419
 
1416
- // context to attach popups
1417
- context : 'body',
1420
+ // automatically hide on scroll
1421
+ hideOnScroll: 'auto',
1418
1422
 
1419
- // context for binding scroll events
1420
- scrollContext : window,
1423
+ // hide other popups on show
1424
+ exclusive: false,
1421
1425
 
1422
- // position to prefer when calculating new position
1423
- prefer : 'opposite',
1426
+ // context to attach popups
1427
+ context: 'body',
1424
1428
 
1425
- // specify position to appear even if it doesn't fit
1426
- lastResort : false,
1429
+ // context for binding scroll events
1430
+ scrollContext: window,
1427
1431
 
1428
- // number of pixels from edge of popup to pointing arrow center (used from centering)
1429
- arrowPixelsFromEdge: 20,
1432
+ // position to prefer when calculating new position
1433
+ prefer: 'opposite',
1430
1434
 
1431
- // delay used to prevent accidental refiring of animations due to user error
1432
- delay : {
1433
- show : 50,
1434
- hide : 70
1435
- },
1435
+ // specify position to appear even if it doesn't fit
1436
+ lastResort: false,
1436
1437
 
1437
- // whether fluid variation should assign width explicitly
1438
- setFluidWidth : true,
1438
+ // number of pixels from edge of popup to pointing arrow center (used from centering)
1439
+ arrowPixelsFromEdge: 20,
1439
1440
 
1440
- // transition settings
1441
- duration : 200,
1442
- transition : 'scale',
1441
+ // delay used to prevent accidental refiring of animations due to user error
1442
+ delay: {
1443
+ show: 50,
1444
+ hide: 70,
1445
+ },
1446
+
1447
+ // whether fluid variation should assign width explicitly
1448
+ setFluidWidth: true,
1443
1449
 
1444
- // distance away from activating element in px
1445
- distanceAway : 0,
1450
+ // transition settings
1451
+ duration: 200,
1452
+ transition: 'scale',
1446
1453
 
1447
- // number of pixels an element is allowed to be "offstage" for a position to be chosen (allows for rounding)
1448
- jitter : 2,
1454
+ // distance away from activating element in px
1455
+ distanceAway: 0,
1449
1456
 
1450
- // offset on aligning axis from calculated position
1451
- offset : 0,
1457
+ // number of pixels an element is allowed to be "offstage" for a position to be chosen (allows for rounding)
1458
+ jitter: 2,
1452
1459
 
1453
- // maximum times to look for a position before failing (9 positions total)
1454
- maxSearchDepth : 15,
1460
+ // offset on aligning axis from calculated position
1461
+ offset: 0,
1455
1462
 
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
- },
1463
+ // maximum times to look for a position before failing (9 positions total)
1464
+ maxSearchDepth: 15,
1463
1465
 
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;"
1466
+ error: {
1467
+ invalidPosition: 'The position you specified is not a valid position',
1468
+ cannotPlace: 'Popup does not fit within the boundaries of the viewport',
1469
+ method: 'The method you called is not defined.',
1470
+ noElement: 'This module requires ui {element}',
1471
+ notFound: 'The target or popup you specified does not exist on the page',
1502
1472
  },
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
1473
 
1532
- };
1474
+ metadata: {
1475
+ activator: 'activator',
1476
+ content: 'content',
1477
+ html: 'html',
1478
+ offset: 'offset',
1479
+ position: 'position',
1480
+ title: 'title',
1481
+ variation: 'variation',
1482
+ },
1483
+
1484
+ className: {
1485
+ active: 'active',
1486
+ basic: 'basic',
1487
+ animating: 'animating',
1488
+ dropdown: 'dropdown',
1489
+ invisible: 'invisible',
1490
+ fluid: 'fluid',
1491
+ loading: 'loading',
1492
+ popup: 'ui popup',
1493
+ position: 'top left center bottom right',
1494
+ visible: 'visible',
1495
+ popupVisible: 'visible',
1496
+ },
1497
+
1498
+ selector: {
1499
+ popup: '.ui.popup',
1500
+ },
1501
+
1502
+ templates: {
1503
+ escape: function (string) {
1504
+ var
1505
+ badChars = /["'<>`]/g,
1506
+ shouldEscape = /["&'<>`]/,
1507
+ escape = {
1508
+ '<': '&lt;',
1509
+ '>': '&gt;',
1510
+ '"': '&quot;',
1511
+ "'": '&#x27;',
1512
+ '`': '&#x60;',
1513
+ },
1514
+ escapedChar = function (chr) {
1515
+ return escape[chr];
1516
+ }
1517
+ ;
1518
+ if (shouldEscape.test(string)) {
1519
+ string = string.replace(/&(?![\d#a-z]{1,12};)/gi, '&amp;');
1533
1520
 
1521
+ return string.replace(badChars, escapedChar);
1522
+ }
1523
+
1524
+ return string;
1525
+ },
1526
+ popup: function (text) {
1527
+ var
1528
+ html = '',
1529
+ escape = $.fn.popup.settings.templates.escape
1530
+ ;
1531
+ if (text !== undefined) {
1532
+ if (text.title) {
1533
+ text.title = escape(text.title);
1534
+ html += '<div class="header">' + text.title + '</div>';
1535
+ }
1536
+ if (text.content) {
1537
+ text.content = escape(text.content);
1538
+ html += '<div class="content">' + text.content + '</div>';
1539
+ }
1540
+ }
1541
+
1542
+ return html;
1543
+ },
1544
+ },
1534
1545
 
1535
- })( jQuery, window, document );
1546
+ };
1547
+ })(jQuery, window, document);