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