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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/app/assets/fonts/semantic-ui/Lato-Bold.woff +0 -0
- data/app/assets/fonts/semantic-ui/Lato-Bold.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff +0 -0
- data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/Lato-Italic.woff +0 -0
- data/app/assets/fonts/semantic-ui/Lato-Italic.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/Lato-Regular.woff +0 -0
- data/app/assets/fonts/semantic-ui/Lato-Regular.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff +0 -0
- data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff +0 -0
- data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff +0 -0
- data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff +0 -0
- data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/brand-icons.eot +0 -0
- data/app/assets/fonts/semantic-ui/brand-icons.svg +41 -6
- data/app/assets/fonts/semantic-ui/brand-icons.ttf +0 -0
- data/app/assets/fonts/semantic-ui/brand-icons.woff +0 -0
- data/app/assets/fonts/semantic-ui/brand-icons.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/icons.eot +0 -0
- data/app/assets/fonts/semantic-ui/icons.svg +245 -7
- data/app/assets/fonts/semantic-ui/icons.ttf +0 -0
- data/app/assets/fonts/semantic-ui/icons.woff +0 -0
- data/app/assets/fonts/semantic-ui/icons.woff2 +0 -0
- data/app/assets/fonts/semantic-ui/outline-icons.eot +0 -0
- data/app/assets/fonts/semantic-ui/outline-icons.svg +2 -2
- data/app/assets/fonts/semantic-ui/outline-icons.ttf +0 -0
- data/app/assets/fonts/semantic-ui/outline-icons.woff +0 -0
- data/app/assets/fonts/semantic-ui/outline-icons.woff2 +0 -0
- data/app/assets/javascripts/semantic-ui/accordion.js +569 -590
- data/app/assets/javascripts/semantic-ui/api.js +1153 -1116
- data/app/assets/javascripts/semantic-ui/calendar.js +1941 -1698
- data/app/assets/javascripts/semantic-ui/checkbox.js +862 -854
- data/app/assets/javascripts/semantic-ui/dimmer.js +697 -713
- data/app/assets/javascripts/semantic-ui/dropdown.js +4196 -4192
- data/app/assets/javascripts/semantic-ui/embed.js +646 -672
- data/app/assets/javascripts/semantic-ui/flyout.js +1579 -0
- data/app/assets/javascripts/semantic-ui/form.js +2024 -2000
- data/app/assets/javascripts/semantic-ui/modal.js +1546 -1384
- data/app/assets/javascripts/semantic-ui/nag.js +521 -527
- data/app/assets/javascripts/semantic-ui/popup.js +1457 -1463
- data/app/assets/javascripts/semantic-ui/progress.js +970 -995
- data/app/assets/javascripts/semantic-ui/rating.js +508 -520
- data/app/assets/javascripts/semantic-ui/search.js +1521 -1508
- data/app/assets/javascripts/semantic-ui/shape.js +784 -811
- data/app/assets/javascripts/semantic-ui/sidebar.js +1061 -1002
- data/app/assets/javascripts/semantic-ui/site.js +437 -477
- data/app/assets/javascripts/semantic-ui/slider.js +1311 -1297
- data/app/assets/javascripts/semantic-ui/state.js +639 -658
- data/app/assets/javascripts/semantic-ui/sticky.js +848 -891
- data/app/assets/javascripts/semantic-ui/tab.js +895 -941
- data/app/assets/javascripts/semantic-ui/toast.js +911 -851
- data/app/assets/javascripts/semantic-ui/transition.js +1049 -1073
- data/app/assets/javascripts/semantic-ui/visibility.js +1214 -1246
- data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +7 -7
- data/app/assets/stylesheets/semantic-ui/collections/_form.scss +389 -407
- data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +203 -345
- data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +372 -501
- data/app/assets/stylesheets/semantic-ui/collections/_message.scss +154 -226
- data/app/assets/stylesheets/semantic-ui/collections/_table.scss +2065 -880
- data/app/assets/stylesheets/semantic-ui/elements/_button.scss +867 -1232
- data/app/assets/stylesheets/semantic-ui/elements/_container.scss +101 -6
- data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +75 -93
- data/app/assets/stylesheets/semantic-ui/elements/_emoji.scss +11148 -9190
- data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1037 -929
- data/app/assets/stylesheets/semantic-ui/elements/_header.scss +124 -146
- data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +2728 -2759
- data/app/assets/stylesheets/semantic-ui/elements/_image.scss +41 -65
- data/app/assets/stylesheets/semantic-ui/elements/_input.scss +982 -163
- data/app/assets/stylesheets/semantic-ui/elements/_label.scss +432 -479
- data/app/assets/stylesheets/semantic-ui/elements/_list.scss +80 -101
- data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +452 -540
- data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +56 -76
- data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +17 -22
- data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +46 -85
- data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +263 -255
- data/app/assets/stylesheets/semantic-ui/elements/_step.scss +106 -179
- data/app/assets/stylesheets/semantic-ui/elements/_text.scss +33 -33
- data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +14 -18
- data/app/assets/stylesheets/semantic-ui/globals/_site.scss +132 -48
- data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +196 -74
- data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +43 -29
- data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +210 -280
- data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +78 -182
- data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +339 -423
- data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +24 -35
- data/app/assets/stylesheets/semantic-ui/modules/_flyout.scss +546 -0
- data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +150 -153
- data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +55 -65
- data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +530 -310
- data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +108 -213
- data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +88 -168
- data/app/assets/stylesheets/semantic-ui/modules/_search.scss +73 -102
- data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +16 -32
- data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +126 -215
- data/app/assets/stylesheets/semantic-ui/modules/_slider.scss +110 -138
- data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +3 -7
- data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +16 -20
- data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +111 -141
- data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +371 -1282
- data/app/assets/stylesheets/semantic-ui/views/_ad.scss +39 -50
- data/app/assets/stylesheets/semantic-ui/views/_card.scss +949 -458
- data/app/assets/stylesheets/semantic-ui/views/_comment.scss +44 -62
- data/app/assets/stylesheets/semantic-ui/views/_feed.scss +50 -72
- data/app/assets/stylesheets/semantic-ui/views/_item.scss +89 -136
- data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +78 -119
- data/lib/fomantic/ui/sass/version.rb +2 -2
- data/tasks/converter.rb +1 -1
- metadata +21 -3
@@ -1,1541 +1,1535 @@
|
|
1
1
|
/*!
|
2
2
|
* # Fomantic-UI - Popup
|
3
|
-
*
|
3
|
+
* https://github.com/fomantic/Fomantic-UI/
|
4
4
|
*
|
5
5
|
*
|
6
6
|
* Released under the MIT license
|
7
|
-
*
|
7
|
+
* https://opensource.org/licenses/MIT
|
8
8
|
*
|
9
9
|
*/
|
10
10
|
|
11
|
-
|
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
|
-
|
105
|
-
|
106
|
-
|
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
|
-
|
113
|
-
|
114
|
-
|
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
|
-
|
124
|
-
|
125
|
-
$
|
126
|
-
|
127
|
-
|
128
|
-
|
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
|
-
|
163
|
-
module.refresh();
|
164
|
-
module.set.position();
|
165
|
-
},
|
29
|
+
moduleSelector = $allModules.selector || '',
|
166
30
|
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
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
|
-
|
234
|
-
|
235
|
-
|
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
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
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
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
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
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
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
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
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
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
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
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
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
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
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
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
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
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
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
|
-
|
480
|
-
|
481
|
-
|
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
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
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
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
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
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
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
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
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
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
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
|
-
|
722
|
-
|
1321
|
+
return returnedValue !== undefined
|
1322
|
+
? returnedValue
|
1323
|
+
: this;
|
1324
|
+
};
|
723
1325
|
|
724
|
-
|
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
|
-
|
745
|
-
position: function(position, calculations) {
|
1328
|
+
name: 'Popup',
|
746
1329
|
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
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
|
-
|
764
|
-
|
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
|
-
|
787
|
-
|
788
|
-
return false;
|
789
|
-
}
|
1340
|
+
// callback only when element added to dom
|
1341
|
+
onCreate: function () {},
|
790
1342
|
|
791
|
-
|
792
|
-
|
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
|
-
|
1346
|
+
// callback before show animation
|
1347
|
+
onShow: function () {},
|
808
1348
|
|
809
|
-
|
810
|
-
|
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
|
-
|
820
|
-
|
821
|
-
position = settings.lastResort;
|
822
|
-
}
|
1352
|
+
// callback before hide animation
|
1353
|
+
onHide: function () {},
|
823
1354
|
|
824
|
-
|
825
|
-
|
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
|
-
|
1358
|
+
// callback after hide animation
|
1359
|
+
onHidden: function () {},
|
895
1360
|
|
896
|
-
|
897
|
-
|
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
|
-
|
1364
|
+
// element to use to determine if popup is out of boundary
|
1365
|
+
boundary: window,
|
905
1366
|
|
906
|
-
|
907
|
-
|
1367
|
+
// whether to add touchstart events when using hover
|
1368
|
+
addTouchEvents: true,
|
908
1369
|
|
909
|
-
|
910
|
-
|
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
|
-
|
959
|
-
|
960
|
-
}
|
961
|
-
},
|
1373
|
+
// if given position should be used regardless if popup fits
|
1374
|
+
forcePosition: false,
|
962
1375
|
|
963
|
-
|
964
|
-
|
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
|
-
|
985
|
-
|
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
|
-
|
1055
|
-
|
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
|
-
|
1074
|
-
|
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
|
-
|
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
|
-
|
1086
|
-
|
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
|
-
|
1143
|
-
|
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
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
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
|
-
|
1420
|
-
|
1406
|
+
// whether automatically close on clickaway when on click
|
1407
|
+
closable: true,
|
1421
1408
|
|
1422
|
-
|
1423
|
-
|
1409
|
+
// automatically hide on scroll
|
1410
|
+
hideOnScroll: 'auto',
|
1424
1411
|
|
1425
|
-
|
1426
|
-
|
1412
|
+
// hide other popups on show
|
1413
|
+
exclusive: false,
|
1427
1414
|
|
1428
|
-
|
1429
|
-
|
1415
|
+
// context to attach popups
|
1416
|
+
context: 'body',
|
1430
1417
|
|
1431
|
-
|
1432
|
-
|
1418
|
+
// context for binding scroll events
|
1419
|
+
scrollContext: window,
|
1433
1420
|
|
1434
|
-
|
1435
|
-
|
1421
|
+
// position to prefer when calculating new position
|
1422
|
+
prefer: 'opposite',
|
1436
1423
|
|
1437
|
-
|
1438
|
-
|
1439
|
-
show : 50,
|
1440
|
-
hide : 70
|
1441
|
-
},
|
1424
|
+
// specify position to appear even if it doesn't fit
|
1425
|
+
lastResort: false,
|
1442
1426
|
|
1443
|
-
|
1444
|
-
|
1427
|
+
// number of pixels from edge of popup to pointing arrow center (used from centering)
|
1428
|
+
arrowPixelsFromEdge: 20,
|
1445
1429
|
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
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
|
-
|
1451
|
-
|
1439
|
+
// transition settings
|
1440
|
+
duration: 200,
|
1441
|
+
transition: 'scale',
|
1452
1442
|
|
1453
|
-
|
1454
|
-
|
1443
|
+
// distance away from activating element in px
|
1444
|
+
distanceAway: 0,
|
1455
1445
|
|
1456
|
-
|
1457
|
-
|
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
|
-
|
1460
|
-
|
1449
|
+
// offset on aligning axis from calculated position
|
1450
|
+
offset: 0,
|
1461
1451
|
|
1462
|
-
|
1463
|
-
|
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
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
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
|
-
"<": "<",
|
1504
|
-
">": ">",
|
1505
|
-
'"': """,
|
1506
|
-
"'": "'",
|
1507
|
-
"`": "`"
|
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};)/, "&");
|
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
|
+
'<': '<',
|
1497
|
+
'>': '>',
|
1498
|
+
'"': '"',
|
1499
|
+
"'": ''',
|
1500
|
+
'`': '`',
|
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, '&');
|
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
|
-
}
|
1534
|
+
};
|
1535
|
+
})(jQuery, window, document);
|