root / drupal7 / sites / all / modules / colorbox / js / colorbox.js @ b08fce64
1 |
/**
|
---|---|
2 |
* @file
|
3 |
* Colorbox module init js.
|
4 |
*/
|
5 |
|
6 |
(function ($) { |
7 |
|
8 |
Drupal.behaviors.initColorbox = { |
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 |
// Disable Colorbox for small screens.
|
16 |
var mq = window.matchMedia("(max-device-width: " + settings.colorbox.mobiledevicewidth + ")"); |
17 |
if (mq.matches) {
|
18 |
return;
|
19 |
} |
20 |
} |
21 |
|
22 |
// Use "data-colorbox-gallery" if set otherwise use "rel".
|
23 |
settings.colorbox.rel = function () { |
24 |
if ($(this).data('colorbox-gallery')) { |
25 |
return $(this).data('colorbox-gallery'); |
26 |
} |
27 |
else {
|
28 |
return $(this).attr('rel'); |
29 |
} |
30 |
}; |
31 |
|
32 |
$('.colorbox', context) |
33 |
.once('init-colorbox')
|
34 |
.colorbox(settings.colorbox); |
35 |
|
36 |
$(context).bind('cbox_complete', function () { |
37 |
Drupal.attachBehaviors('#cboxLoadedContent');
|
38 |
}); |
39 |
} |
40 |
}; |
41 |
|
42 |
})(jQuery); |