PageSourceSearch

https://www.fhf.fr/modules/custom/fhf_content_display/modules/fhf_colorbox/js/jquery.zoom.min.js?v=1.x

js fhf.fr collected 2026-09-24 09:27:14 UTC 6,941 bytes, 237 lines download raw bytes

1/*!
2	Zoom 1.7.21
3	license: MIT
4	http://www.jacklmoore.com/zoom
5*/
6(function ($) {
7  var defaults = {
8    url: false,
9    callback: false,
10    target: false,
11    duration: 120,
12    on: 'mouseover', // other options: grab, click, toggle
13    touch: true, // enables a touch fallback
14    onZoomIn: false,
15    onZoomOut: false,
16    magnify: 1
17  };
18
19  // Core Zoom Logic, independent of event listeners.
20  $.zoom = function(target, source, img, magnify) {
21    var targetHeight,
22      targetWidth,
23      sourceHeight,
24      sourceWidth,
25      xRatio,
26      yRatio,
27      offset,
28      $target = $(target),
29      position = $target.css('position'),
30      $source = $(source);
31
32    // The parent element needs positioning so that the zoomed element can be correctly positioned within.
33    target.style.position = /(absolute|fixed)/.test(position) ? position : 'relative';
34    target.style.overflow = 'hidden';
35    img.style.width = img.style.height = '';
36
37    $(img)
38      .addClass('zoomImg')
39      .css({
40        position: 'absolute',
41        top: 0,
42        left: 0,
43        opacity: 0,
44        width: img.width * magnify,
45        height: img.height * magnify,
46        border: 'none',
47        maxWidth: 'none',
48        maxHeight: 'none'
49      })
50      .appendTo(target);
51
52    return {
53      init: function() {
54        targetWidth = $target.outerWidth();
55        targetHeight = $target.outerHeight();
56
57        if (source === target) {
58          sourceWidth = targetWidth;
59          sourceHeight = targetHeight;
60        } else {
61          sourceWidth = $source.outerWidth();
62          sourceHeight = $source.outerHeight();
63        }
64
65        xRatio = (img.width - targetWidth) / sourceWidth;
66        yRatio = (img.height - targetHeight) / sourceHeight;
67
68        offset = $source.offset();
69      },
70      move: function (e) {
71        var left = (e.pageX - offset.left),
72          top = (e.pageY - offset.top);
73
74        top = Math.max(Math.min(top, sourceHeight), 0);
75        left = Math.max(Math.min(left, sourceWidth), 0);
76
77        img.style.left = (left * -xRatio) + 'px';
78        img.style.top = (top * -yRatio) + 'px';
79      }
80    };
81  };
82
83  $.fn.zoom = function (options) {
84
85    return this.each(function () {
86      var
87        settings = $.extend({}, defaults, options || {}),
88        //target will display the zoomed image
89        target = settings.target && $(settings.target)[0] || this,
90        //source will provide zoom location info (thumbnail)
91        source = this,
92        $source = $(source),
93        img = document.createElement('img'),
94        $img = $(img),
95        mousemove = 'mousemove.zoom',
96        clicked = false,
97        touched = false;
98
99      // If a url wasn't specified, look for an image element.
100      if (!settings.url) {
101        var srcElement = source.querySelector('img');
102        if (srcElement) {
103          settings.url = srcElement.getAttribute('data-src') || srcElement.currentSrc || srcElement.src;
104        }
105        if (!settings.url) {
106          return;
107        }
108      }
109
110      $source.one('zoom.destroy', function(position, overflow){
111        $source.off(".zoom");
112        target.style.position = position;
113        target.style.overflow = overflow;
114        img.onload = null;
115        $img.remove();
116      }.bind(this, target.style.position, target.style.overflow));
117
118      img.onload = function () {
119        var zoom = $.zoom(target, source, img, settings.magnify);
120
121        function start(e) {
122          zoom.init();
123          zoom.move(e);
124
125          // Skip the fade-in for IE8 and lower since it chokes on fading-in
126          // and changing position based on mousemovement at the same time.
127          $img.stop()
128            .fadeTo($.support.opacity ? settings.duration : 0, 1, $.isFunction(settings.onZoomIn) ? settings.onZoomIn.call(img) : false);
129        }
130
131        function stop() {
132          $img.stop()
133            .fadeTo(settings.duration, 0, $.isFunction(settings.onZoomOut) ? settings.onZoomOut.call(img) : false);
134        }
135
136        // Mouse events
137        if (settings.on === 'grab') {
138          $source
139            .on('mousedown.zoom',
140              function (e) {
141                if (e.which === 1) {
142                  $(document).one('mouseup.zoom',
143                    function () {
144                      stop();
145
146                      $(document).off(mousemove, zoom.move);
147                    }
148                  );
149
150                  start(e);
151
152                  $(document).on(mousemove, zoom.move);
153
154                  e.preventDefault();
155                }
156              }
157            );
158        } else if (settings.on === 'click') {
159          $source.on('click.zoom',
160            function (e) {
161              if (clicked) {
162                // bubble the event up to the document to trigger the unbind.
163                return;
164              } else {
165                clicked = true;
166                start(e);
167                $(document).on(mousemove, zoom.move);
168                $(document).one('click.zoom',
169                  function () {
170                    stop();
171                    clicked = false;
172                    $(document).off(mousemove, zoom.move);
173                  }
174                );
175                return false;
176              }
177            }
178          );
179        } else if (settings.on === 'toggle') {
180          $source.on('click.zoom',
181            function (e) {
182              if (clicked) {
183                stop();
184              } else {
185                start(e);
186              }
187              clicked = !clicked;
188            }
189          );
190        } else if (settings.on === 'mouseover') {
191          zoom.init(); // Preemptively call init because IE7 will fire the mousemove handler before the hover handler.
192
193          $source
194            .on('mouseenter.zoom', start)
195            .on('mouseleave.zoom', stop)
196            .on(mousemove, zoom.move);
197        }
198
199        // Touch fallback
200        if (settings.touch) {
201          $source
202            .on('touchstart.zoom', function (e) {
203              e.preventDefault();
204              if (touched) {
205                touched = false;
206                stop();
207              } else {
208                touched = true;
209                start( e.originalEvent.touches[0] || e.originalEvent.changedTouches[0] );
210              }
211            })
212            .on('touchmove.zoom', function (e) {
213              e.preventDefault();
214              zoom.move( e.originalEvent.touches[0] || e.originalEvent.changedTouches[0] );
215            })
216            .on('touchend.zoom', function (e) {
217              e.preventDefault();
218              if (touched) {
219                touched = false;
220                stop();
221              }
222            });
223        }
224
225        if ($.isFunction(settings.callback)) {
226          settings.callback.call(img);
227        }
228      };
229
230      img.setAttribute('role', 'presentation');
231      img.alt = '';
232      img.src = settings.url;
233    });
234  };
235
236  $.fn.zoom.defaults = defaults;
237}(window.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.