1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
(function ($) {
|
7
|
|
8
|
Drupal.behaviors.initColorboxInline = {
|
9
|
attach: function (context, settings) {
|
10
|
if (!$.isFunction($.colorbox) || typeof settings.colorbox === 'undefined') {
|
11
|
return;
|
12
|
}
|
13
|
|
14
|
if (settings.colorbox.mobiledetect && window.matchMedia) {
|
15
|
|
16
|
var mq = window.matchMedia("(max-device-width: " + settings.colorbox.mobiledevicewidth + ")");
|
17
|
if (mq.matches) {
|
18
|
return;
|
19
|
}
|
20
|
}
|
21
|
|
22
|
$.urlParam = function(name, url){
|
23
|
if (name == 'fragment') {
|
24
|
var results = new RegExp('(#[^&#]*)').exec(url);
|
25
|
}
|
26
|
else {
|
27
|
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
|
28
|
}
|
29
|
if (!results) { return ''; }
|
30
|
return results[1] || '';
|
31
|
};
|
32
|
$('.colorbox-inline', context).once('init-colorbox-inline').colorbox({
|
33
|
transition:settings.colorbox.transition,
|
34
|
speed:settings.colorbox.speed,
|
35
|
opacity:settings.colorbox.opacity,
|
36
|
slideshow:settings.colorbox.slideshow,
|
37
|
slideshowAuto:settings.colorbox.slideshowAuto,
|
38
|
slideshowSpeed:settings.colorbox.slideshowSpeed,
|
39
|
slideshowStart:settings.colorbox.slideshowStart,
|
40
|
slideshowStop:settings.colorbox.slideshowStop,
|
41
|
current:settings.colorbox.current,
|
42
|
previous:settings.colorbox.previous,
|
43
|
next:settings.colorbox.next,
|
44
|
close:settings.colorbox.close,
|
45
|
overlayClose:settings.colorbox.overlayClose,
|
46
|
maxWidth:settings.colorbox.maxWidth,
|
47
|
maxHeight:settings.colorbox.maxHeight,
|
48
|
innerWidth:function(){
|
49
|
return $.urlParam('width', $(this).attr('href'));
|
50
|
},
|
51
|
innerHeight:function(){
|
52
|
return $.urlParam('height', $(this).attr('href'));
|
53
|
},
|
54
|
title:function(){
|
55
|
return decodeURIComponent($.urlParam('title', $(this).attr('href')));
|
56
|
},
|
57
|
iframe:function(){
|
58
|
return $.urlParam('iframe', $(this).attr('href'));
|
59
|
},
|
60
|
inline:function(){
|
61
|
return $.urlParam('inline', $(this).attr('href'));
|
62
|
},
|
63
|
href:function(){
|
64
|
return $.urlParam('fragment', $(this).attr('href'));
|
65
|
}
|
66
|
});
|
67
|
}
|
68
|
};
|
69
|
|
70
|
})(jQuery);
|