PageSourceSearch

https://www.uni-gr.eu/sites/all/modules/resp_img/resp_img.js?tlrnh7

js uni-gr.eu collected 2026-10-01 11:50:13 UTC 4,664 bytes, 144 lines download raw bytes

1(function ($) {
2  Drupal.behaviors.respImg = {
3    attach: function (context) {
4      Drupal.respImg_processSuffixes();
5      $(window).resize(function() {
6        if ($(window).width() > 10) {
7          Drupal.respImg_processSuffixes();
8        }
9      });
10    }
11  }
12
13  Drupal.respImg_getOptimalSuffix = function() {
14    var devicePixelRatio = 1;
15    if(window.devicePixelRatio !== undefined && Drupal.settings.respImg.useDevicePixelRatio) {
16      devicePixelRatio = window.devicePixelRatio;
17    }
18    $.cookie(
19      "respimg_ratio",
20      devicePixelRatio,
21      {
22        path: Drupal.settings.basePath,
23        expires: 1
24      }
25    );
26    // Helper function to calculate width off border and scrollbars
27    function borderAndScroll() {
28      if (typeof borderAndScroll.current == 'undefined' ) {
29        borderAndScroll.current = 0;
30        if (window.innerWidth && window.outerWidth) {
31          borderAndScroll.current = window.outerWidth - window.innerWidth;
32        }
33        else if (document.body.offsetWidth && document.body.clientWidth) {
34          borderAndScroll.current = document.body.offsetWidth - document.body.clientWidth;
35        }
36      }
37      return borderAndScroll.current;
38    }
39
40    var suffix = '';
41    var suffix_set = false;
42    var cookie_set = false;
43    $.each(Drupal.settings.respImg.suffixes, function(index, value) {
44      var breakpoint = value - borderAndScroll();
45      if (breakpoint <= $(window).width() && !cookie_set) {
46        // set cookie with new width
47        $.cookie(
48          "respimg",
49          value,
50          {
51            path: Drupal.settings.basePath,
52            expires: 1
53          }
54        );
55        cookie_set = true;
56      }
57      if ((breakpoint / devicePixelRatio) <= $(window).width() && !suffix_set) {
58        suffix = index;
59        suffix_set = true;
60      }
61      if (cookie_set && suffix_set) {
62        return false; // break .each
63      }
64    });
65    return suffix;
66  }
67
68  Drupal.respImg_processSuffixes = function() {
69    // Redirect user if needed / wanted
70    if (Drupal.settings.respImg.current_suffix === false && Drupal.settings.respImg.forceRedirect == "1") {
71      // Make sure browser accepts cookies
72      if (Drupal.respImg_cookiesEnabled()) {
73        var suffix = Drupal.respImg_getOptimalSuffix();
74        location.replace(location.href);
75        return;
76      }
77    }
78
79    // get currently used suffix, or default
80    var current_suffix = Drupal.settings.respImg.current_suffix;
81    if (Drupal.settings.respImg.current_suffix === false) {
82      current_suffix = Drupal.settings.respImg.default_suffix;
83    }
84
85    // get optimal suffix
86    var suffix = Drupal.respImg_getOptimalSuffix();
87
88    if (Drupal.settings.respImg.reloadOnResize == "1" && suffix !== '' && suffix !== current_suffix && Drupal.respImg_cookiesEnabled()) {
89      setTimeout(function() {location.reload(true)}, 100);
90      return;
91    }
92
93    if (Drupal.settings.respImg.forceResize == "1" && suffix !== '' && suffix !== current_suffix) {
94      // support for images
95      $('img').each(function() {
96        var img = $(this);
97        var src = img.attr('src').replace(current_suffix, suffix);
98        img.attr('src', src);
99        img.removeAttr('width');
100        img.removeAttr('height');
101      });
102
103      // support for colorbox links
104      $('a.colorbox').each(function() {
105        var a = $(this);
106        var href = a.attr('href').replace(current_suffix, suffix);
107        a.attr('href', href);
108      });
109
110      // support for field_slideshow (kind of)
111      if (typeof(Drupal.behaviors.field_slideshow) == "object") {
112        $('div.field-slideshow-processed')
113          .cycle('destroy')
114          .removeClass('field-slideshow-processed')
115          .css('width', '')
116          .css('height', '')
117          .css('padding-bottom', '')
118          .each(function() {
119            var $field = $(this);
120            var $child = $field.children('div.field-slideshow-slide').first();
121            console.log($child);
122            console.log($child.css('width'));
123            $field.css('width', $child.css('width'));
124          });
125        $('div.field-slideshow-slide').css('width', '').css('height', '');
126        Drupal.behaviors.field_slideshow.attach();
127      }
128
129      // store last used suffix
130      Drupal.settings.respImg.current_suffix = suffix;
131    }
132  }
133
134  Drupal.respImg_cookiesEnabled = function() {
135    var cookieEnabled = (navigator.cookieEnabled) ? true : false;
136
137    if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled)
138    {
139        $.cookie('respimg_test', 'ok');
140        cookieEnabled = ($cookie('respimg_test') === 'ok');
141    }
142    return cookieEnabled;
143  }
144} (jQuery));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.