@northdata/fomantic-ui 2.8.722 → 2.9.401

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