Projet

Général

Profil

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

root / drupal7 / sites / all / modules / colorbox / js / colorbox.js @ 73ab1d0a

1 b08fce64 Assos Assos
/**
2
 * @file
3
 * Colorbox module init js.
4
 */
5
6 85ad3d82 Assos Assos
(function ($) {
7
8
Drupal.behaviors.initColorbox = {
9
  attach: function (context, settings) {
10 62f5c69e Assos Assos
    if (!$.isFunction($.colorbox) || typeof settings.colorbox === 'undefined') {
11 85ad3d82 Assos Assos
      return;
12
    }
13
14
    if (settings.colorbox.mobiledetect && window.matchMedia) {
15
      // Disable Colorbox for small screens.
16 91f42c9e Assos Assos
      var mq = window.matchMedia("(max-device-width: " + settings.colorbox.mobiledevicewidth + ")");
17 85ad3d82 Assos Assos
      if (mq.matches) {
18
        return;
19
      }
20
    }
21
22 39a3d70c Assos Assos
    // 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 85ad3d82 Assos Assos
    $('.colorbox', context)
33
      .once('init-colorbox')
34
      .colorbox(settings.colorbox);
35 91f42c9e Assos Assos
36
    $(context).bind('cbox_complete', function () {
37
      Drupal.attachBehaviors('#cboxLoadedContent');
38
    });
39 85ad3d82 Assos Assos
  }
40
};
41
42
})(jQuery);