Projet

Général

Profil

Paste
Télécharger (2,08 ko) Statistiques
| Branche: | Révision:

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

1
(function ($) {
2

    
3
Drupal.behaviors.initColorboxInline = {
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
    $.urlParam = function(name, url){
18
      if (name == 'fragment') {
19
        var results = new RegExp('(#[^&#]*)').exec(url);
20
      }
21
      else {
22
        var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
23
      }
24
      if (!results) { return ''; }
25
      return results[1] || '';
26
    };
27
    $('.colorbox-inline', context).once('init-colorbox-inline').colorbox({
28
      transition:settings.colorbox.transition,
29
      speed:settings.colorbox.speed,
30
      opacity:settings.colorbox.opacity,
31
      slideshow:settings.colorbox.slideshow,
32
      slideshowAuto:settings.colorbox.slideshowAuto,
33
      slideshowSpeed:settings.colorbox.slideshowSpeed,
34
      slideshowStart:settings.colorbox.slideshowStart,
35
      slideshowStop:settings.colorbox.slideshowStop,
36
      current:settings.colorbox.current,
37
      previous:settings.colorbox.previous,
38
      next:settings.colorbox.next,
39
      close:settings.colorbox.close,
40
      overlayClose:settings.colorbox.overlayClose,
41
      maxWidth:settings.colorbox.maxWidth,
42
      maxHeight:settings.colorbox.maxHeight,
43
      innerWidth:function(){
44
        return $.urlParam('width', $(this).attr('href'));
45
      },
46
      innerHeight:function(){
47
        return $.urlParam('height', $(this).attr('href'));
48
      },
49
      title:function(){
50
        return decodeURIComponent($.urlParam('title', $(this).attr('href')));
51
      },
52
      iframe:function(){
53
        return $.urlParam('iframe', $(this).attr('href'));
54
      },
55
      inline:function(){
56
        return $.urlParam('inline', $(this).attr('href'));
57
      },
58
      href:function(){
59
        return $.urlParam('fragment', $(this).attr('href'));
60
      }
61
    });
62
  }
63
};
64

    
65
})(jQuery);