-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
50 lines (43 loc) · 1.53 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
Popup.js
A Popper.js extension for displaying popup windows.
Copyright (c)2010 Sourcey
http://sourcey.com
Distributed under The MIT License.
*/
(function ($) {
// Static constructor
$.popup = function(method) {
if (typeof method === "undefined")
method = {}
if (Popper.methods[method])
return Popper.methods[method](Array.prototype.slice.call(arguments, 1));
else if (typeof method === "object")
return Popper.methods.create(method).load();
else
$.error("Method '" + method + "' does not exist for $.popup");
}
// Jquery selector extension
$.fn.popup = function(options) {
options = options || {};
return this.each(function () {
if (this.href) {
$(this).click(function() {
// Support for rel="popup.className.className2" syntax to add a class.
var classNames = this.rel.split('.');
if (classNames.length) {
classNames.shift();
options.className += classNames.join(' ');
}
options.url = this.href;
Popper.methods.create(options).load();
return false;
})
}
else {
options.element = $(this);
Popper.methods.create(options).load();
}
});
}
})(jQuery);