Projet

Général

Profil

Paste
Télécharger (956 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / colorbox / js / colorbox.js @ a2bb1a14

1
(function ($) {
2

    
3
Drupal.behaviors.initColorbox = {
4
  attach: function (context, settings) {
5
    if (!$.isFunction($.colorbox) || typeof settings.colorbox === 'undefined') {
6
      return;
7
    }
8

    
9
    if (settings.colorbox.mobiledetect && window.matchMedia) {
10
      // Disable Colorbox for small screens.
11
      var mq = window.matchMedia("(max-device-width: " + settings.colorbox.mobiledevicewidth + ")");
12
      if (mq.matches) {
13
        return;
14
      }
15
    }
16

    
17
    // Use "data-colorbox-gallery" if set otherwise use "rel".
18
    settings.colorbox.rel = function () {
19
      if ($(this).data('colorbox-gallery')) {
20
        return $(this).data('colorbox-gallery');
21
      }
22
      else {
23
        return $(this).attr('rel');
24
      }
25
    };
26

    
27
    $('.colorbox', context)
28
      .once('init-colorbox')
29
      .colorbox(settings.colorbox);
30

    
31
    $(context).bind('cbox_complete', function () {
32
      Drupal.attachBehaviors('#cboxLoadedContent');
33
    });
34
  }
35
};
36

    
37
})(jQuery);