1 |
85ad3d82
|
Assos Assos
|
(function ($) {
|
2 |
|
|
|
3 |
|
|
Drupal.behaviors.initColorboxLoad = {
|
4 |
|
|
attach: function (context, settings) {
|
5 |
|
|
if (!$.isFunction($.colorbox)) {
|
6 |
|
|
return;
|
7 |
|
|
}
|
8 |
|
|
$.urlParams = function (url) {
|
9 |
|
|
var p = {},
|
10 |
|
|
e,
|
11 |
|
|
a = /\+/g,
|
12 |
|
|
r = /([^&=]+)=?([^&]*)/g,
|
13 |
|
|
d = function (s) { return decodeURIComponent(s.replace(a, ' ')); },
|
14 |
|
|
q = url.split('?');
|
15 |
|
|
while (e = r.exec(q[1])) {
|
16 |
|
|
e[1] = d(e[1]);
|
17 |
|
|
e[2] = d(e[2]);
|
18 |
|
|
switch (e[2].toLowerCase()) {
|
19 |
|
|
case 'true':
|
20 |
|
|
case 'yes':
|
21 |
|
|
e[2] = true;
|
22 |
|
|
break;
|
23 |
|
|
case 'false':
|
24 |
|
|
case 'no':
|
25 |
|
|
e[2] = false;
|
26 |
|
|
break;
|
27 |
|
|
}
|
28 |
|
|
if (e[1] == 'width') { e[1] = 'innerWidth'; }
|
29 |
|
|
if (e[1] == 'height') { e[1] = 'innerHeight'; }
|
30 |
|
|
p[e[1]] = e[2];
|
31 |
|
|
}
|
32 |
|
|
return p;
|
33 |
|
|
};
|
34 |
|
|
$('.colorbox-load', context)
|
35 |
|
|
.once('init-colorbox-load', function () {
|
36 |
|
|
var params = $.urlParams($(this).attr('href'));
|
37 |
|
|
$(this).colorbox($.extend({}, settings.colorbox, params));
|
38 |
|
|
});
|
39 |
|
|
}
|
40 |
|
|
};
|
41 |
|
|
|
42 |
|
|
})(jQuery); |