PageSourceSearch

https://rascalpowermobility.com/js/xzoom.js

js rascalpowermobility.com collected 2026-10-09 23:35:29 UTC 30,747 bytes, 938 lines download raw bytes

1/*!-----------------------------------------------------
2 * xZoom v1.0.14
3 * (c) 2013 by Azat Ahmedov & Elman Guseynov
4 * https://github.com/payalord
5 * https://dribbble.com/elmanvebs
6 * Apache License 2.0
7 *------------------------------------------------------*/
8window.requestAnimFrame = (function(){
9  return window.requestAnimationFrame ||
10  window.webkitRequestAnimationFrame ||
11  window.mozRequestAnimationFrame ||
12  window.oRequestAnimationFrame ||
13  window.msRequestAnimationFrame ||
14  function(callback){
15    window.setTimeout(callback, 20);
16  };
17})();
18
19function detect_old_ie() {
20  if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
21   var ieversion=new Number(RegExp.$1);
22   if (ieversion>=9)
23    return false
24   else if (ieversion>=8)
25    return true
26   else if (ieversion>=7)
27    return true
28   else if (ieversion>=6)
29    return true
30   else if (ieversion>=5)
31    return true
32  } else return false;
33}
34
35(function ($) {
36  //Compatibility between old and new versions of jQuery
37  $.fn.xon = $.fn.on || $.fn.bind;
38  $.fn.xoff = $.fn.off || $.fn.bind;
39
40  function xobject(mObj, opts) {
41    //Properties
42    this.xzoom = true;
43    var current = this;
44    var parent;
45    var xzoomID = {};
46
47    var sw, sh, mw, mh, moffset, stop, sleft, mtop, mleft, ctop, cleft, mx, my;
48    var source, tint, preview, loading, trans, transImg, sobjects = new Array();
49    var imageGallery = new Array(), index = 0, cindex = 0;
50    var img, imgObj, lens, lensImg;
51    var lw, lh, ll, lt, llc, ltc, ocofx, ocofy, cofx, cofy, c1, c2, iwh, scale = 0;
52    var imgObjwidth, imgObjheight;
53    var flag, u = 0, v = 0, su = 0, sv = 0, lsu = 0, lsv = 0, lu = 0, lv = 0, llu = 0, llv = 0;
54    var ie = detect_old_ie(), aie = /MSIE (\d+\.\d+);/.test(navigator.userAgent), iex, iey;
55    var active, title = '', caption, caption_container;
56
57    //Adaptive properties
58    var wsw, wsh, osw, osh, tsw, tsh, oposition, reverse;//, smoothNormal;
59
60    this.adaptive = function() {
61      if (osw == 0 || osh == 0) {
62        mObj.css('width', '');
63        mObj.css('height', '');
64        osw = mObj.width();
65        osh = mObj.height();
66      }
67
68      xremove();
69      wsw = $(window).width();
70      wsh = $(window).height();
71
72      tsw = mObj.width();
73      tsh = mObj.height();
74
75      var update = false;
76      if (osw>wsw || osh>wsh) update = true;
77
78      if (tsw > osw) tsw = osw;
79      if (tsh > osh) tsh = osh;
80      if (update) {
81        mObj.width('100%');
82      } else {
83        if (osw != 0) mObj.width(osw);
84      }
85      if (oposition != 'fullscreen') if (adaptive_position_fit()) current.options.position = oposition; else current.options.position = current.options.mposition;
86      if (!current.options.lensReverse) reverse = current.options.adaptiveReverse && current.options.position == current.options.mposition;
87    }
88
89    function spos() {
90      var doc = document.documentElement;
91      var left = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
92      var top = (window.pageYOffset || doc.scrollTop)  - (doc.clientTop || 0);
93
94      return {left: left, top: top};
95    }
96
97    function adaptive_position_fit() {
98      var moffset = mObj.offset();
99
100      if (current.options.zoomWidth == 'auto') mw = tsw; else mw = current.options.zoomWidth; //tsw/osw * current.options.zoomWidth;
101      if (current.options.zoomHeight == 'auto') mh = tsh; else mh = current.options.zoomHeight; //tsw/osh * current.options.zoomHeight;
102
103      if (current.options.position.substr(0,1) == '#') xzoomID = $(current.options.position); else xzoomID.length = 0;
104      if (xzoomID.length != 0) return true;
105
106      switch(oposition) {
107        case 'lens':
108        case 'inside':
109        return true;
110        break;
111        case 'top':
112          stop = moffset.top;
113          sleft = moffset.left;
114          mtop = stop - mh; //tsh;
115          mleft = sleft;
116        break;
117        case 'left':
118          stop = moffset.top;
119          sleft = moffset.left;
120          mtop = stop;
121          mleft = sleft - mw; //tsw;
122        break;
123        case 'bottom':
124          stop = moffset.top;
125          sleft = moffset.left;
126          mtop = stop + tsh;
127          mleft = sleft;
128        break;
129        case 'right':
130        default:
131          stop = moffset.top;
132          sleft = moffset.left;
133          mtop = stop;
134          mleft = sleft + tsw;
135      }
136      if (mleft+mw>wsw || mleft<0) return false; //if (mtop+mh>wsh || mtop<0) return false;
137      return true;
138    }
139
140    this.xscroll = function(event) {
141      mx = event.pageX || event.originalEvent.pageX;
142      my = event.pageY || event.originalEvent.pageY;
143
144      event.preventDefault();
145
146      if (event.xscale) {
147        scale = event.xscale;
148        xscale(mx, my);
149      } else {
150        var delta = -event.originalEvent.detail || event.originalEvent.wheelDelta || event.xdelta;
151        var x = mx;
152        var y = my;
153        if (ie) {
154          x = iex;
155          y = iey;
156        }
157
158        if (delta > 0) delta = -0.05; else delta = 0.05;
159
160        scale += delta;
161
162        xscale(x, y);
163      }
164    }
165
166    function lensShape() {
167      if (current.options.lensShape == 'circle' && current.options.position == 'lens') {
168        //this function must be called before set_lens()
169        lw = lh = Math.max(lw, lh);
170        var radius = (lw + Math.max(ltc,llc) * 2) / 2;
171        lens.css({'-moz-border-radius': radius, '-webkit-border-radius': radius, 'border-radius': radius});
172      }
173    }
174
175    function lensOutput(x, y, sx, sy) {
176      if (current.options.position == 'lens') {
177        imgObj.css({top: -(y-stop) * cofy + (lh / 2), left: -(x-sleft) * cofx + (lw / 2)});
178        if (current.options.bg) {
179          lens.css({'background-image': 'url('+imgObj.attr('src')+')', 'background-repeat': 'no-repeat', 'background-position': (-(x-sleft) * cofx + (lw / 2))+'px '+(-(y-stop) * cofy + (lh / 2))+'px'});
180          if (sx && sy) lens.css({'background-size': sx+'px '+sy+'px'});
181        }
182      } else {
183        imgObj.css({top: -lt * cofy, left: -ll * cofx});
184      }
185    }
186
187    function xscale(x, y) {
188      if (scale < -1) scale = -1;
189      if (scale > 1) scale = 1;
190
191      var cc, iw, ih;
192
193      if (c1 < c2) {
194        cc = c1 - (c1 - 1) * scale;
195        iw = mw * cc;
196        ih = iw / iwh;
197      } else {
198        cc = c2 - (c2 - 1) * scale;
199        ih = mh * cc;
200        iw = ih * iwh;
201      }
202
203      if (flag) {
204        //If smoothMove
205        u = x;
206        v = y;
207        su = iw;
208        sv = ih;
209      } else {
210        if (!flag) {
211          lsu = su = iw;
212          lsv = sv = ih;
213        }
214        cofx = iw / sw;
215        cofy = ih / sh;
216        lw = mw / cofx;
217        lh = mh / cofy;
218        lensShape();
219        set_lens(x, y);
220
221        imgObj.width(iw);
222        imgObj.height(ih);
223        lens.width(lw);
224        lens.height(lh);
225
226        lens.css({top: lt - ltc, left: ll - llc});
227        lensImg.css({top: -lt, left: -ll});
228        lensOutput(x, y, iw, ih);
229      }
230    }
231
232    function loopZoom() {
233      var x = lu;
234      var y = lv;
235      var x2 = llu;
236      var y2 = llv;
237      var sx = lsu;
238      var sy = lsv;
239      x += (u - x) / current.options.smoothLensMove;
240      y += (v - y) / current.options.smoothLensMove;
241
242      x2 += (u - x2) / current.options.smoothZoomMove;
243      y2 += (v - y2) / current.options.smoothZoomMove;
244
245      sx += (su - sx) / current.options.smoothScale;
246      sy += (sv - sy) / current.options.smoothScale;
247
248      cofx = sx / sw;
249      cofy = sy / sh;
250
251      lw = mw / cofx;
252      lh = mh / cofy;
253      lensShape();
254      set_lens(x, y);
255
256      imgObj.width(sx);
257      imgObj.height(sy);
258
259      lens.width(lw);
260      lens.height(lh);
261
262      lens.css({top: lt - ltc, left: ll - llc});
263      lensImg.css({top: -lt, left: -ll});
264
265      set_lens(x2, y2);
266      lensOutput(x, y, sx, sy);
267
268      lu = x;
269      lv = y;
270      llu = x2;
271      llv = y2;
272      lsu = sx;
273      lsv = sy;
274
275      if (flag) requestAnimFrame(loopZoom);
276    }
277
278    function set_lens(x, y) {
279      x -= sleft;
280      y -= stop;
281      ll = x - (lw / 2);
282      lt = y - (lh / 2);
283
284      if (current.options.position != 'lens' && current.options.lensCollision) {
285        if (ll < 0) ll = 0;
286        if (sw >= lw && ll > sw - lw) ll = sw - lw;
287        if (sw < lw) ll = sw / 2 - lw / 2;
288        if (lt < 0) lt = 0;
289        if (sh >= lh && lt > sh - lh) lt = sh - lh;
290        if (sh < lh) lt = sh / 2 - lh / 2;
291      }
292    }
293
294    function xremove() {
295      if (typeof source != "undefined") source.remove();
296      if (typeof preview != "undefined") preview.remove();
297      if (typeof caption_container != "undefined") caption_container.remove();
298    }
299
300    function prepare_zoom(x, y) {
301      if (current.options.position == 'fullscreen') {
302        sw = $(window).width();
303        sh = $(window).height();
304      } else {
305        sw = mObj.width();
306        sh = mObj.height();
307      }
308
309      loading.css({top: sh / 2 - loading.height() / 2, left: sw / 2 - loading.width() / 2});
310
311      if (current.options.rootOutput || current.options.position == 'fullscreen') {
312        moffset = mObj.offset();
313      } else {
314        moffset = mObj.position();
315      }
316
317      //Round
318      moffset.top = Math.round(moffset.top);
319      moffset.left = Math.round(moffset.left);
320
321      switch(current.options.position) {
322        case 'fullscreen':
323          stop = spos().top;
324          sleft = spos().left;
325          mtop = 0;
326          mleft = 0;
327        break;
328        case 'inside':
329          stop = moffset.top;
330          sleft = moffset.left;
331          mtop = 0;
332          mleft = 0;
333        break;
334        case 'top':
335          stop = moffset.top;
336          sleft = moffset.left;
337          mtop = stop - mh;
338          mleft = sleft;
339        break;
340        case 'left':
341          stop = moffset.top;
342          sleft = moffset.left;
343          mtop = stop;
344          mleft = sleft - mw;
345        break;
346        case 'bottom':
347          stop = moffset.top;
348          sleft = moffset.left;
349          mtop = stop + sh;
350          mleft = sleft;
351        break;
352        case 'right':
353        default:
354          stop = moffset.top;
355          sleft = moffset.left;
356          mtop = stop;
357          mleft = sleft + sw;
358      }
359
360      //Correct source position
361      stop -= source.outerHeight() / 2;
362      sleft -= source.outerWidth() / 2;
363
364      if (current.options.position.substr(0,1) == '#') xzoomID = $(current.options.position); else xzoomID.length = 0;
365      if (xzoomID.length == 0 && current.options.position != 'inside' && current.options.position!= 'fullscreen') {
366
367        if (!current.options.adaptive || !osw || !osh) {osw = sw; osh = sh;}
368        if (current.options.zoomWidth == 'auto') mw = sw; else mw = current.options.zoomWidth; //sw/osw * current.options.zoomWidth;
369        if (current.options.zoomHeight == 'auto') mh = sh; else mh = current.options.zoomHeight; //sw/osh * current.options.zoomHeight;
370
371        //Add offset
372        mtop += current.options.Yoffset;
373        mleft += current.options.Xoffset;
374
375        preview.css({width: mw + 'px', height: mh + 'px', top: mtop, left: mleft});
376        if (current.options.position != 'lens') parent.append(preview);
377      } else if (current.options.position == 'inside' || current.options.position == 'fullscreen') {
378        mw = sw;
379        mh = sh;
380
381        preview.css({width: mw + 'px', height: mh + 'px'});
382        source.append(preview);
383      } else {
384        mw = xzoomID.width();
385        mh = xzoomID.height();
386
387        if (current.options.rootOutput) {
388          mtop = xzoomID.offset().top;
389          mleft = xzoomID.offset().left;
390
391          parent.append(preview);
392        } else {
393          mtop = xzoomID.position().top;
394          mleft = xzoomID.position().left;
395
396          xzoomID.parent().append(preview);
397        }
398
399        mtop += (xzoomID.outerHeight() - mh - preview.outerHeight()) / 2;
400        mleft += (xzoomID.outerWidth() - mw - preview.outerWidth()) / 2;
401        preview.css({width: mw + 'px', height: mh + 'px', top: mtop, left: mleft});
402      }
403
404      if (current.options.title && title != '') {
405        if (current.options.position == 'inside' || current.options.position == 'lens' || current.options.position == 'fullscreen') {
406          ctop = mtop;
407          cleft = mleft;
408          source.append(caption_container);
409        } else {
410          ctop = mtop + (preview.outerHeight()-mh)/2;
411          cleft = mleft + (preview.outerWidth()-mw)/2;
412          parent.append(caption_container);
413        }
414        caption_container.css({width: mw + 'px', height: mh + 'px', top: ctop, left: cleft});
415      }
416
417      source.css({width: sw + 'px', height: sh + 'px', top: stop, left: sleft});
418      tint.css({width: sw + 'px', height: sh + 'px'});
419      if (current.options.tint && (current.options.position != 'inside' && current.options.position != 'fullscreen'))
420        tint.css('background-color', current.options.tint)
421      else if (ie) {
422        tint.css({'background-image': 'url('+mObj.attr('src')+')', 'background-color': '#fff'});
423      }
424
425      //Image object
426      img = new Image();
427
428      var timestamp = '';
429      if (aie) timestamp = '?r='+(new Date()).getTime();
430      img.src = mObj.attr('xoriginal')+timestamp;
431
432      imgObj = $(img);
433      imgObj.css('position', 'absolute');
434      //debug
435      //imgObj.css('opacity', '0.5');
436
437      img = new Image();
438      img.src = mObj.attr('src');
439
440      lensImg = $(img);
441      lensImg.css('position', 'absolute');
442      lensImg.width(sw);
443
444      //Append image
445      switch (current.options.position) {
446        case 'fullscreen':
447        case 'inside':
448          preview.append(imgObj);
449        break;
450        case 'lens':
451          lens.append(imgObj);
452          if (current.options.bg) imgObj.css({display: 'none'});
453        break;
454        default:
455          preview.append(imgObj);
456          lens.append(lensImg);
457      }
458    }
459
460    this.openzoom = function (event) {
461        mx = event.pageX; my = event.pageY;
462
463        if (current.options.adaptive) current.adaptive();
464        scale = current.options.defaultScale; flag = false;
465
466        //Source container
467        source = $('<div></div>');
468        if (current.options.sourceClass != '') source.addClass(current.options.sourceClass);
469        source.css('position', 'absolute');
470
471        //Loading container
472        loading = $('<div></div>');
473        if (current.options.loadingClass != '') loading.addClass(current.options.loadingClass);
474        loading.css('position', 'absolute');
475
476        tint = $('<div style="position: absolute; top: 0; left: 0;"></div>');
477
478        source.append(loading);
479
480        //Preview container
481        preview = $('<div></div>');
482        if (current.options.zoomClass != '' && current.options.position != 'fullscreen') preview.addClass(current.options.zoomClass);
483        preview.css({position: 'absolute', overflow: 'hidden', opacity: 1});
484
485        //Caption
486        if (current.options.title && title != '') {
487          caption_container = $('<div></div>');
488          caption = $('<div></div>');
489          caption_container.css({position: 'absolute', opacity: 1});
490          if (current.options.titleClass) caption.addClass(current.options.titleClass);
491          caption.html('<span>'+title+'</span>');
492          caption_container.append(caption);
493          if (current.options.fadeIn) caption_container.css({opacity:0});
494        }
495
496        //Lens object
497        lens = $('<div></div>');
498        if (current.options.lensClass != '') lens.addClass(current.options.lensClass);
499        lens.css({position: 'absolute', overflow: 'hidden'});
500
501        //Lens tint
502        if (current.options.lens) {
503          lenstint = $('<div></div>');
504          lenstint.css({position: 'absolute', background: current.options.lens, opacity: current.options.lensOpacity, width: '100%', height: '100%', top: 0, left: 0, 'z-index': 9999});
505          lens.append(lenstint);
506        }
507
508        prepare_zoom(mx, my);
509
510        if (current.options.position != 'inside' && current.options.position != 'fullscreen') {
511          if (current.options.tint || ie) source.append(tint);
512
513          if (current.options.fadeIn) {
514            tint.css({opacity:0});
515            lens.css({opacity:0});
516            preview.css({opacity:0});
517          }
518          parent.append(source);
519        } else {
520          if (current.options.fadeIn) preview.css({opacity:0});
521          parent.append(source);
522        }
523
524        //Add event on mouse move
525        current.eventmove(source);
526
527        //On mouse leave delete containers
528        current.eventleave(source);
529
530        //Correct preview
531        switch(current.options.position) {
532          case 'inside':
533            mtop -= (preview.outerHeight() - preview.height()) / 2;
534            mleft -= (preview.outerWidth() - preview.width()) / 2;
535          break;
536          case 'top':
537            mtop -= preview.outerHeight() - preview.height();
538            mleft -= (preview.outerWidth() - preview.width()) / 2;
539          break;
540          case 'left':
541            mtop -= (preview.outerHeight()  - preview.height()) / 2;
542            mleft -= preview.outerWidth() - preview.width();
543          break;
544          case 'bottom':
545            mleft -= (preview.outerWidth() - preview.width()) / 2;
546          break;
547          case 'right':
548            mtop -= (preview.outerHeight() - preview.height()) / 2;
549        }
550
551        preview.css({top: mtop, left: mleft});
552
553        //We must be sure that image has been loaded
554        imgObj.xon('load', function(e) {
555          loading.remove();
556
557          if (!current.options.openOnSmall && (imgObj.width() < mw || imgObj.height() < mh)) {
558            current.closezoom();
559            e.preventDefault();
560            return false;
561          }
562
563          //Scroll functionality
564          if (current.options.scroll) current.eventscroll(source);
565
566          if (current.options.position != 'inside' && current.options.position != 'fullscreen') {
567            //Append lens to source container
568            source.append(lens);
569            if (current.options.fadeIn) {
570              tint.fadeTo(300, current.options.tintOpacity);
571              lens.fadeTo(300, 1);
572              preview.fadeTo(300,1);
573            } else {
574              tint.css({opacity: current.options.tintOpacity});
575              lens.css({opacity: 1});
576              preview.css({opacity: 1});
577            }
578          } else {
579            if (current.options.fadeIn) {
580              preview.fadeTo(300,1);
581            } else {
582              preview.css({opacity: 1});
583            }
584          }
585
586          if (current.options.title && title != '') {
587            if (current.options.fadeIn) caption_container.fadeTo(300,1); else caption_container.css({opacity: 1});
588          }
589
590          imgObjwidth = imgObj.width();
591          imgObjheight = imgObj.height();
592
593          if (current.options.adaptive) {
594          //Images corrections for adaptive
595            if (sw<osw || sh<osh) {
596              lensImg.width(sw);
597              lensImg.height(sh);
598
599              imgObjwidth = sw/osw * imgObjwidth;
600              imgObjheight = sh/osh * imgObjheight;
601
602              imgObj.width(imgObjwidth);
603              imgObj.height(imgObjheight);
604            }
605          }
606
607          //Calculate lens size
608          lsu = su = imgObjwidth;
609          lsv = sv = imgObjheight;
610          iwh = imgObjwidth / imgObjheight;
611          c1 = imgObjwidth / mw;
612          c2 = imgObjheight / mh;
613
614          //outerHeight and outerWidth work wrong sometimes, especially when we use init() function
615          //ltc = lens.outerHeight() / 2;
616          //llc = lens.outerWidth() / 2;
617          //Issue #2 Test .css() function that can return NaN and break lens object position
618          var t, o = ['padding-','border-'];
619          ltc = llc = 0;
620          for(var i = 0; i<o.length;i++) {
621            t = parseFloat(lens.css(o[i]+'top-width'));
622            ltc += t !== t ? 0 : t;
623            t = parseFloat(lens.css(o[i]+'bottom-width'));
624            ltc += t !== t ? 0 : t;
625            t = parseFloat(lens.css(o[i]+'left-width'));
626            llc += t !== t ? 0 : t;
627            t = parseFloat(lens.css(o[i]+'right-width'));
628            llc += t !== t ? 0 : t;
629          }
630          ltc /= 2;
631          llc /= 2;
632          //ltc = (parseFloat(lens.css('padding-top-width')) + parseFloat(lens.css('padding-bottom-width')) + parseFloat(lens.css('border-top-width')) + parseFloat(lens.css('border-bottom-width'))) / 2;
633          //llc = (parseFloat(lens.css('padding-left-width')) + parseFloat(lens.css('padding-right-width')) + parseFloat(lens.css('border-left-width')) + parseFloat(lens.css('border-right-width'))) / 2;
634          //ltc = (pb(lens, 'padding', 1) + pb(lens, 'border', 1)) / 2;
635          //llc = (pb(lens, 'padding', 0) + pb(lens, 'border', 0)) / 2;
636          llu = lu = u = mx;
637          llv = lv = v = my;
638          xscale(mx, my);
639
640          if (current.options.smooth) {flag = true;
640 requestAnimFrame(loopZoom);}
641
642          current.eventclick(source);
643        });
644    }
645
646    /*function pb(obj, name, dir) {
647      if (dir) {
648        return parseFloat(obj.css(name + '-top')) + parseFloat(obj.css(name + '-bottom'));
649      } else {
650        return parseFloat(obj.css(name + '-left')) + parseFloat(obj.css(name + '-right'));
651      }
652    }*/
653
654    this.movezoom = function(event) {
655      mx = event.pageX;
656      my = event.pageY;
657      if (ie) {
658        iex = mx;
659        iey = my;
660      }
661
662      var x = mx - sleft;
663      var y = my - stop;
664
665      if (reverse) {
666        event.pageX -= (x - sw / 2) * 2;
667        event.pageY -= (y - sh / 2) * 2;
668      }
669
670      if (x < 0 || x > sw || y < 0 || y > sh) source.trigger('mouseleave');
671      if (current.options.smooth) {
672        u = event.pageX;
673        v = event.pageY;
674      } else {
675        //Calculate zoom image position
676        lensShape();
677        set_lens(event.pageX, event.pageY);
678        lens.css({top: lt - ltc, left: ll - llc});
679        lensImg.css({top: -lt, left: -ll});
680        lensOutput(event.pageX,event.pageY, 0, 0);
681      }
682    }
683
684    this.eventdefault = function() {
685      current.eventopen = function(element) {
686        element.xon('mouseenter', current.openzoom);
687      }
688
689      current.eventleave = function(element) {
690        element.xon('mouseleave', current.closezoom);
691      }
692
693      current.eventmove = function(element) {
694        element.xon('mousemove', current.movezoom);
695      }
696
697      current.eventscroll = function(element) {
698        element.xon('mousewheel DOMMouseScroll', current.xscroll);
699      }
700
701      current.eventclick = function(element) {
702        element.xon('click', function(event) {
703          mObj.trigger('click');
704        });
705      }
706    }
707
708    this.eventunbind = function() {
709      mObj.xoff('mouseenter');
710      current.eventopen = function(element) {}
711      current.eventleave = function(element) {}
712      current.eventmove = function(element) {}
713      current.eventscroll = function(element) {}
714      current.eventclick = function(element) {}
715    }
716
717    this.init = function (options) {
718      //Default options
719      current.options = $.extend({},$.fn.xzoom.defaults, options);
720
721      if (current.options.rootOutput) {
722        parent = $("body");
723      } else {
724        parent = mObj.parent();
725      }
726
727      oposition = current.options.position; //ocof,
728
729      reverse = current.options.lensReverse && current.options.position == 'inside';
730
731      //Limits
732      if (current.options.smoothZoomMove < 1) current.options.smoothZoomMove = 1;
733      if (current.options.smoothLensMove < 1) current.options.smoothLensMove = 1;
734      if (current.options.smoothScale < 1) current.options.smoothScale = 1;
735
736      //smoothNormal = current.options.smoothZoomMove && current.options.smoothLensMove && current.options.smoothScale;
737
738      //Adaptive
739      if (current.options.adaptive) {
740        $(window).xon('load',function(){
741          osw = mObj.width();
742          osh = mObj.height();
743
744          current.adaptive();
745          $(window).resize(current.adaptive);
746        });
747      }
748      current.eventdefault();
749      current.eventopen(mObj);
750    }
751
752    this.destroy = function() {
753      current.eventunbind();
754    }
755
756    this.closezoom = function() {
757      flag = false;
758      if (current.options.fadeOut) {
759        if (current.options.title && title != '') caption_container.fadeOut(299);
760        if (current.options.position != 'inside' || current.options.position != 'fullscreen') {
761          preview.fadeOut(299);
762          source.fadeOut(300, function(){xremove()});
763        } else {
764          source.fadeOut(300, function(){xremove()});
765        }
766      } else {
767        xremove();
768      }
769    }
770
771    this.gallery = function() {
772      var g = new Array();
773      var i,j = 0;
774      for (i = cindex; i<imageGallery.length; i++) {
775        g[j] = imageGallery[i];j++;
776      }
777      for (i = 0; i<cindex; i++) {
778        g[j] = imageGallery[i];j++;
779      }
780
781      return {index: cindex, ogallery: imageGallery, cgallery: g};
782    }
783
784    function get_title(element) {
785      var otitle = element.attr('title');
786      var xotitle = element.attr('xtitle');
787      if (xotitle) {
788        return xotitle;
789      } else if (otitle) {
790        return otitle
791      } else {
792        return '';
793      }
794    }
795
796    this.xappend = function(Obj) {
797      var link = Obj.parent();
798      //Add original image to image gallery
799      imageGallery[index] = link.attr('href');
800      link.data('xindex', index);
801      if (index == 0 && current.options.activeClass) {active = Obj; active.addClass(current.options.activeClass)}
802      if (index == 0 && current.options.title) title = get_title(Obj);
803      index++;
804
805      function thumbchange(event) {
806        xremove();
807        event.preventDefault();
808        if (current.options.activeClass) {
809          active.removeClass(current.options.activeClass);
810          active = Obj;
811          active.addClass(current.options.activeClass);
812        }
813        cindex = $(this).data('xindex');
814        if (current.options.fadeTrans) {
815          transImg = new Image();
816          transImg.src = mObj.attr('src');
817          trans = $(transImg);
818          trans.css({position: 'absolute', top: mObj.offset().top, left: mObj.offset().left, width: mObj.width(), height: mObj.height()});
819          $(document.body).append(trans);
820          trans.fadeOut(200, function() {trans.remove()});
821        }
822        var _xorig = link.attr('href');
823        var _prev = Obj.attr('xpreview') || Obj.attr('src');
824
825        title = get_title(Obj);
826        if (Obj.attr('title')) mObj.attr('title',Obj.attr('title'));
827
828        //imgObj.attr('src',_xorig);
829        mObj.attr('xoriginal',_xorig);
830        mObj.removeAttr('style');
831        mObj.attr('src', _prev);
832        if (current.options.adaptive) {
833          osw = mObj.width();
834          osh = mObj.height();
835        }
836        //Prevent submit on click
837        //return false;
838      }
839
840      if (current.options.hover) {
841        link.xon('mouseenter', link, thumbchange);
842      }
843      link.xon('click', link, thumbchange);
844    }
845
846    this.init(opts);
847  }
848
849    $.fn.xzoom = function(options) {
850      var mainObj;
851      var secObj;
852
853      if (this.selector) {
854        var el = this.selector.split(",");
855        for (var i in el) el[i] = $.trim(el[i]);
856        this.each(function(index) {
857          if (el.length == 1) {
858            if (index == 0) {
859              //Main window element
860              mainObj = $(this);
861            if (typeof(mainObj.data('xzoom')) !== 'undefined') return mainObj.data('xzoom');
862              mainObj.x = new xobject(mainObj, options);
863            } else if(typeof(mainObj.x) !== 'undefined') {
864              //Thumbs
865              secObj = $(this);
866              mainObj.x.xappend(secObj);
867            }
868          } else {
869            if ($(this).is(el[0]) && index == 0) {
870              //Main window element
871              mainObj = $(this);
872            if (typeof(mainObj.data('xzoom')) !== 'undefined') return mainObj.data('xzoom');
873              mainObj.x = new xobject(mainObj, options);
874            } else if(typeof(mainObj.x) !== 'undefined' && !$(this).is(el[0])) {
875              //Thumbs
876              secObj = $(this);
877              mainObj.x.xappend(secObj);
878            }
879          }
880        });
881      } else this.each(function(index) {
882        if (index == 0) {
883          //Main window element
884          mainObj = $(this);
885          if (typeof(mainObj.data('xzoom')) !== 'undefined') return mainObj.data('xzoom');
886          mainObj.x = new xobject(mainObj, options);
887        } else if(typeof(mainObj.x) !== 'undefined') {
888          //Thumbs
889          secObj = $(this);
890          mainObj.x.xappend(secObj);
891        }
892      });
893      if (typeof(mainObj) === 'undefined') return false;
894      mainObj.data('xzoom', mainObj.x);
895
896      //Fire event xzoom init
897      $(mainObj).trigger('xzoom_ready');
898      return mainObj.x;
899    }
900
901  $.fn.xzoom.defaults = {
902    position: 'right', //top, left, right, bottom, inside, lens, fullscreen, #ID
903    mposition: 'inside', //inside, fullscreen
904    rootOutput: true,
905    Xoffset: 0,
906    Yoffset: 0,
907    fadeIn: true,
908    fadeTrans: true,
909    fadeOut: false,
910    smooth: true,
911    smoothZoomMove: 3,
912    smoothLensMove: 1,
913    smoothScale: 6,
914    defaultScale: 0, //from -1 to 1, that means -100% till 100% scale
915    scroll: true,
916    tint: false, //'#color'
917    tintOpacity: 0.5,
918    lens: false, //'#color'
919    lensOpacity: 0.5,
920    lensShape: 'box', //'box', 'circle'
921    lensCollision: true,
922    lensReverse: false,
923    openOnSmall: true,
924    zoomWidth: 'auto',
925    zoomHeight: 'auto',
926    sourceClass: 'xzoom-source',
927    loadingClass: 'xzoom-loading',
928    lensClass: 'xzoom-lens',
929    zoomClass: 'xzoom-preview',
930    activeClass: 'xactive',
931    hover: false,
932    adaptive: true,
933    adaptiveReverse: false,
934    title: false,
935    titleClass: 'xzoom-caption',
936    bg: false //zoom image output as background
937  };
938})(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.