fomantic-ui-sass 2.8.8.1 → 2.9.1

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