diff --git a/packages/Webkul/Velocity/publishable/assets/js/jquery.ez-plus.js b/packages/Webkul/Velocity/publishable/assets/js/jquery.ez-plus.js index cf1ecf0b6..35c6d36a0 100644 --- a/packages/Webkul/Velocity/publishable/assets/js/jquery.ez-plus.js +++ b/packages/Webkul/Velocity/publishable/assets/js/jquery.ez-plus.js @@ -1,1859 +1 @@ -/* jshint -W071, -W074 */ -/* global jQuery:false */ - -/* Disabled options are: - * W071: This function has too many statements - * W074: This function's cyclomatic complexity is too high - */ - -/* - * jQuery ezPlus 1.1.6 - * Demo's and documentation: - * http://igorlino.github.io/elevatezoom-plus/ - * - * licensed under MIT license. - * http://en.wikipedia.org/wiki/MIT_License - * - */ - -if (typeof Object.create !== 'function') { - Object.create = function (obj) { - function F() { - } - - F.prototype = obj; - return new F(); - }; -} - -(function ($, window, document, undefined) { - var EZP = { - init: function (options, elem) { - var self = this; - var $galleries; - - self.elem = elem; - self.$elem = $(elem); - - self.imageSrc = self.$elem.data('zoom-image') ? self.$elem.data('zoom-image') : self.$elem.attr('src'); - - self.options = $.extend({}, $.fn.ezPlus.options, self.responsiveConfig(options || {})); - - if (!self.options.enabled) { - return; - } - - //TINT OVERRIDE SETTINGS - if (self.options.tint) { - self.options.lensColour = 'none'; //colour of the lens background - self.options.lensOpacity = '1'; //opacity of the lens - } - //INNER OVERRIDE SETTINGS - if (self.options.zoomType === 'inner') { - self.options.showLens = false; - } - - //Remove alt on hover - - self.$elem.parent().removeAttr('title').removeAttr('alt'); - - self.zoomImage = self.imageSrc; - - self.refresh(1); - - //Create the image swap from the gallery - $galleries = $(self.options.gallery ? ('#' + self.options.gallery) : self.options.gallerySelector); - $galleries.on('click.zoom', self.options.galleryItem, function (e) { - - //Set a class on the currently active gallery image - if (self.options.galleryActiveClass) { - $(self.options.galleryItem, $galleries).removeClass(self.options.galleryActiveClass); - $(this).addClass(self.options.galleryActiveClass); - } - //stop any link on the a tag from working - if (this.tagName === 'A') { - e.preventDefault(); - } - - //call the swap image function - if ($(this).data('zoom-image')) { - self.zoomImagePre = $(this).data('zoom-image'); - } - else { - self.zoomImagePre = $(this).data('image'); - } - self.swaptheimage($(this).data('image'), self.zoomImagePre); - if (this.tagName === 'A') { - return false; - } - }); - }, - refresh: function (length) { - var self = this; - - setTimeout(function () { - self.fetch(self.imageSrc); - - }, length || self.options.refresh); - }, - fetch: function (imgsrc) { - //get the image - var self = this; - var newImg = new Image(); - newImg.onload = function () { - //set the large image dimensions - used to calculte ratio's - self.largeWidth = newImg.width; - self.largeHeight = newImg.height; - //once image is loaded start the calls - self.startZoom(); - self.currentImage = self.imageSrc; - //let caller know image has been loaded - self.options.onZoomedImageLoaded(self.$elem); - }; - self.setImageSource(newImg, imgsrc); // this must be done AFTER setting onload - - return; - }, - setImageSource: function (image, src) { - //sets an image's source. - image.src = src; - }, - startZoom: function () { - var self = this; - //get dimensions of the non zoomed image - self.nzWidth = self.$elem.width(); - self.nzHeight = self.$elem.height(); - - //activated elements - self.isWindowActive = false; - self.isLensActive = false; - self.isTintActive = false; - self.overWindow = false; - - //CrossFade Wrapper - if (self.options.imageCrossfade) { - self.zoomWrap = self.$elem.wrap('
'); - self.$elem.css('position', 'absolute'); - } - - self.zoomLock = 1; - self.scrollingLock = false; - self.changeBgSize = false; - self.currentZoomLevel = self.options.zoomLevel; - - //get offset of the non zoomed image - self.nzOffset = self.$elem.offset(); - //calculate the width ratio of the large/small image - self.widthRatio = (self.largeWidth / self.currentZoomLevel) / self.nzWidth; - self.heightRatio = (self.largeHeight / self.currentZoomLevel) / self.nzHeight; - - function getWindowZoomStyle() { - return 'overflow: hidden;' + - 'background-position: 0px 0px;text-align:center;' + - 'background-color: ' + String(self.options.zoomWindowBgColour) + ';' + - 'width: ' + String(self.options.zoomWindowWidth) + 'px;' + - 'height: ' + String(self.options.zoomWindowHeight) + 'px;' + - 'float: left;' + - 'background-size: ' + self.largeWidth / self.currentZoomLevel + 'px ' + self.largeHeight / self.currentZoomLevel + 'px;' + - 'display: none;z-index:100;' + - 'border: ' + String(self.options.borderSize) + 'px solid ' + self.options.borderColour + ';' + - 'background-repeat: no-repeat;' + - 'position: absolute;'; - } - - //if window zoom - if (self.options.zoomType === 'window') { - self.zoomWindowStyle = getWindowZoomStyle(); - } - - function getInnerZoomStyle() { - //has a border been put on the image? Lets cater for this - var borderWidth = self.$elem.css('border-left-width'); - - return 'overflow: hidden;' + - 'margin-left: ' + String(borderWidth) + ';' + - 'margin-top: ' + String(borderWidth) + ';' + - 'background-position: 0px 0px;' + - 'width: ' + String(self.nzWidth) + 'px;' + - 'height: ' + String(self.nzHeight) + 'px;' + - 'float: left;' + - 'display: none;' + - 'cursor:' + (self.options.cursor) + ';' + - 'px solid ' + self.options.borderColour + ';' + - 'background-repeat: no-repeat;' + - 'position: absolute;'; - } - - //if inner zoom - if (self.options.zoomType === 'inner') { - self.zoomWindowStyle = getInnerZoomStyle(); - } - - function getWindowLensStyle() { - var lensHeight, lensWidth; - // adjust images less than the window height - - if (self.nzHeight < self.options.zoomWindowHeight / self.heightRatio) { - lensHeight = self.nzHeight; - } - else { - lensHeight = String(self.options.zoomWindowHeight / self.heightRatio); - } - if (self.largeWidth < self.options.zoomWindowWidth) { - lensWidth = self.nzWidth; - } - else { - lensWidth = String(self.options.zoomWindowWidth / self.widthRatio); - } - - return 'background-position: 0px 0px;width: ' + String((self.options.zoomWindowWidth) / self.widthRatio) + 'px;' + - 'height: ' + String((self.options.zoomWindowHeight) / self.heightRatio) + - 'px;float: right;display: none;' + - 'overflow: hidden;' + - 'z-index: 999;' + - 'opacity:' + (self.options.lensOpacity) + ';filter: alpha(opacity = ' + (self.options.lensOpacity * 100) + '); zoom:1;' + - 'width:' + lensWidth + 'px;' + - 'height:' + lensHeight + 'px;' + - 'background-color:' + (self.options.lensColour) + ';' + - 'cursor:' + (self.options.cursor) + ';' + - 'border: ' + (self.options.lensBorderSize) + 'px' + - ' solid ' + (self.options.lensBorderColour) + ';background-repeat: no-repeat;position: absolute;'; - } - - //lens style for window zoom - if (self.options.zoomType === 'window') { - self.lensStyle = getWindowLensStyle(); - } - - //tint style - self.tintStyle = 'display: block;' + - 'position: absolute;' + - 'background-color: ' + self.options.tintColour + ';' + - 'filter:alpha(opacity=0);' + - 'opacity: 0;' + - 'width: ' + self.nzWidth + 'px;' + - 'height: ' + self.nzHeight + 'px;'; - - //lens style for lens zoom with optional round for modern browsers - self.lensRound = ''; - - if (self.options.zoomType === 'lens') { - self.lensStyle = 'background-position: 0px 0px;' + - 'float: left;display: none;' + - 'border: ' + String(self.options.borderSize) + 'px solid ' + self.options.borderColour + ';' + - 'width:' + String(self.options.lensSize) + 'px;' + - 'height:' + String(self.options.lensSize) + 'px;' + - 'background-repeat: no-repeat;position: absolute;'; - } - - //does not round in all browsers - if (self.options.lensShape === 'round') { - self.lensRound = 'border-top-left-radius: ' + String(self.options.lensSize / 2 + self.options.borderSize) + 'px;' + - 'border-top-right-radius: ' + String(self.options.lensSize / 2 + self.options.borderSize) + 'px;' + - 'border-bottom-left-radius: ' + String(self.options.lensSize / 2 + self.options.borderSize) + 'px;' + - 'border-bottom-right-radius: ' + String(self.options.lensSize / 2 + self.options.borderSize) + 'px;'; - } - - //create the div's + "" - //self.zoomContainer = $('
').addClass('zoomContainer').css({"position":"relative", "height":self.nzHeight, "width":self.nzWidth}); - - self.zoomContainer = - $('
'); - $(self.options.zoomContainerAppendTo).append(self.zoomContainer); - - //this will add overflow hidden and contrain the lens on lens mode - if (self.options.containLensZoom && self.options.zoomType === 'lens') { - self.zoomContainer.css('overflow', 'hidden'); - } - if (self.options.zoomType !== 'inner') { - self.zoomLens = $('
 
') - .appendTo(self.zoomContainer) - .click(function () { - self.$elem.trigger('click'); - }); - - if (self.options.tint) { - self.tintContainer = $('
').addClass('tintContainer'); - self.zoomTint = $('
'); - - self.zoomLens.wrap(self.tintContainer); - - self.zoomTintcss = self.zoomLens.after(self.zoomTint); - - //if tint enabled - set an image to show over the tint - - self.zoomTintImage = $('') - .appendTo(self.zoomLens) - .click(function () { - - self.$elem.trigger('click'); - }); - } - } - - var targetZoomContainer = isNaN(self.options.zoomWindowPosition) ? 'body' : self.zoomContainer; - //create zoom window - self.zoomWindow = $('
 
') - .appendTo(targetZoomContainer).click(function () { - self.$elem.trigger('click'); - }); - self.zoomWindowContainer = $('
').addClass('zoomWindowContainer').css('width', self.options.zoomWindowWidth); - self.zoomWindow.wrap(self.zoomWindowContainer); - - // self.captionStyle = "text-align: left;background-color: black;'+ - // 'color: white;font-weight: bold;padding: 10px;font-family: sans-serif;font-size: 11px"; - // self.zoomCaption = $('
INSERT ALT TAG
').appendTo(self.zoomWindow.parent()); - - if (self.options.zoomType === 'lens') { - self.zoomLens.css('background-image', 'url("' + self.imageSrc + '")'); - } - if (self.options.zoomType === 'window') { - self.zoomWindow.css('background-image', 'url("' + self.imageSrc + '")'); - } - if (self.options.zoomType === 'inner') { - self.zoomWindow.css('background-image', 'url("' + self.imageSrc + '")'); - } - - /*-------------------END THE ZOOM WINDOW AND LENS----------------------------------*/ - if (self.options.touchEnabled) { - //touch events - self.$elem.bind('touchmove', function (e) { - e.preventDefault(); - var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; - self.setPosition(touch); - }); - self.zoomContainer.bind('touchmove', function (e) { - if (self.options.zoomType === 'inner') { - self.showHideWindow('show'); - - } - e.preventDefault(); - var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; - self.setPosition(touch); - - }); - self.zoomContainer.bind('touchend', function (e) { - self.showHideWindow('hide'); - if (self.options.showLens) { - self.showHideLens('hide'); - } - if (self.options.tint && self.options.zoomType !== 'inner') { - self.showHideTint('hide'); - } - }); - - self.$elem.bind('touchend', function (e) { - self.showHideWindow('hide'); - if (self.options.showLens) { - self.showHideLens('hide'); - } - if (self.options.tint && self.options.zoomType !== 'inner') { - self.showHideTint('hide'); - } - }); - if (self.options.showLens) { - self.zoomLens.bind('touchmove', function (e) { - - e.preventDefault(); - var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; - self.setPosition(touch); - }); - - self.zoomLens.bind('touchend', function (e) { - self.showHideWindow('hide'); - if (self.options.showLens) { - self.showHideLens('hide'); - } - if (self.options.tint && self.options.zoomType !== 'inner') { - self.showHideTint('hide'); - } - }); - } - } - //Needed to work in IE - self.$elem.bind('mousemove', function (e) { - if (self.overWindow === false) { - self.setElements('show'); - } - //make sure on orientation change the setposition is not fired - if (self.lastX !== e.clientX || self.lastY !== e.clientY) { - self.setPosition(e); - self.currentLoc = e; - } - self.lastX = e.clientX; - self.lastY = e.clientY; - - }); - - self.zoomContainer.bind('click', self.options.onImageClick); - - self.zoomContainer.bind('mousemove', function (e) { - if (self.overWindow === false) { - self.setElements('show'); - } - mouseMoveZoomHandler(e); - }); - - function mouseMoveZoomHandler(e) { - //self.overWindow = true; - //make sure on orientation change the setposition is not fired - if (self.lastX !== e.clientX || self.lastY !== e.clientY) { - self.setPosition(e); - self.currentLoc = e; - } - self.lastX = e.clientX; - self.lastY = e.clientY; - } - - var elementToTrack = null; - if (self.options.zoomType !== 'inner') { - elementToTrack = self.zoomLens; - } - if (self.options.tint && self.options.zoomType !== 'inner') { - elementToTrack = self.zoomTint; - } - if (self.options.zoomType === 'inner') { - elementToTrack = self.zoomWindow; - } - - //register the mouse tracking - if (elementToTrack) { - elementToTrack.bind('mousemove', mouseMoveZoomHandler); - } - - // lensFadeOut: 500, zoomTintFadeIn - self.zoomContainer.add(self.$elem).mouseenter(function () { - if (self.overWindow === false) { - self.setElements('show'); - } - }).mouseleave(function () { - if (!self.scrollLock) { - self.setElements('hide'); - self.options.onDestroy(self.$elem); - } - }); - //end ove image - - if (self.options.zoomType !== 'inner') { - self.zoomWindow.mouseenter(function () { - self.overWindow = true; - self.setElements('hide'); - }).mouseleave(function () { - self.overWindow = false; - }); - } - //end ove image - - // var delta = parseInt(e.originalEvent.wheelDelta || -e.originalEvent.detail); - - // $(this).empty(); - // return false; - - //fix for initial zoom setting - //if (self.options.zoomLevel !== 1) { - // self.changeZoomLevel(self.currentZoomLevel); - //} - //set the min zoomlevel - if (self.options.minZoomLevel) { - self.minZoomLevel = self.options.minZoomLevel; - } - else { - self.minZoomLevel = self.options.scrollZoomIncrement * 2; - } - - if (self.options.scrollZoom) { - self.zoomContainer.add(self.$elem).bind('wheel DOMMouseScroll MozMousePixelScroll', function (e) { - // in IE there is issue with firing of mouseleave - So check whether still scrolling - // and on mouseleave check if scrolllock - self.scrollLock = true; - clearTimeout($.data(this, 'timer')); - $.data(this, 'timer', setTimeout(function () { - self.scrollLock = false; - //do something - }, 250)); - - var theEvent = e.originalEvent.deltaY || e.originalEvent.detail * -1; - - //this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30; - // e.preventDefault(); - - e.stopImmediatePropagation(); - e.stopPropagation(); - e.preventDefault(); - - if (theEvent / 120 > 0) { - //scrolling up - if (self.currentZoomLevel >= self.minZoomLevel) { - self.changeZoomLevel(self.currentZoomLevel - self.options.scrollZoomIncrement); - } - } - else { - //scrolling down - - //Check if it has to maintain original zoom window aspect ratio or not - if ((!self.fullheight && !self.fullwidth) || !self.options.mantainZoomAspectRatio) { - if (self.options.maxZoomLevel) { - if (self.currentZoomLevel <= self.options.maxZoomLevel) { - self.changeZoomLevel(parseFloat(self.currentZoomLevel) + self.options.scrollZoomIncrement); - } - } - else { - //andy - self.changeZoomLevel(parseFloat(self.currentZoomLevel) + self.options.scrollZoomIncrement); - } - } - } - return false; - }); - } - }, - setElements: function (type) { - var self = this; - if (!self.options.zoomEnabled) { - return false; - } - if (type === 'show') { - if (self.isWindowSet) { - if (self.options.zoomType === 'inner') { - self.showHideWindow('show'); - } - if (self.options.zoomType === 'window') { - self.showHideWindow('show'); - } - if (self.options.showLens) { - self.showHideLens('show'); - } - if (self.options.tint && self.options.zoomType !== 'inner') { - self.showHideTint('show'); - } - } - } - - if (type === 'hide') { - if (self.options.zoomType === 'window') { - self.showHideWindow('hide'); - } - if (!self.options.tint) { - self.showHideWindow('hide'); - } - if (self.options.showLens) { - self.showHideLens('hide'); - } - if (self.options.tint) { - self.showHideTint('hide'); - } - } - }, - setPosition: function (e) { - - var self = this; - - if (!self.options.zoomEnabled) { - return false; - } - - //recaclc offset each time in case the image moves - //this can be caused by other on page elements - self.nzHeight = self.$elem.height(); - self.nzWidth = self.$elem.width(); - self.nzOffset = self.$elem.offset(); - - if (self.options.tint && self.options.zoomType !== 'inner') { - self.zoomTint.css({ - top: 0, - left: 0 - }); - } - //set responsive - //will checking if the image needs changing before running this code work faster? - if (self.options.responsive && !self.options.scrollZoom) { - if (self.options.showLens) { - var lensHeight, lensWidth; - if (self.nzHeight < self.options.zoomWindowWidth / self.widthRatio) { - lensHeight = self.nzHeight; - } - else { - lensHeight = String((self.options.zoomWindowHeight / self.heightRatio)); - } - if (self.largeWidth < self.options.zoomWindowWidth) { - lensWidth = self.nzWidth; - } - else { - lensWidth = (self.options.zoomWindowWidth / self.widthRatio); - } - self.widthRatio = self.largeWidth / self.nzWidth; - self.heightRatio = self.largeHeight / self.nzHeight; - if (self.options.zoomType !== 'lens') { - //possibly dont need to keep recalcalculating - //if the lens is heigher than the image, then set lens size to image size - if (self.nzHeight < self.options.zoomWindowWidth / self.widthRatio) { - lensHeight = self.nzHeight; - - } - else { - lensHeight = String((self.options.zoomWindowHeight / self.heightRatio)); - } - - if (self.nzWidth < self.options.zoomWindowHeight / self.heightRatio) { - lensWidth = self.nzWidth; - } - else { - lensWidth = String((self.options.zoomWindowWidth / self.widthRatio)); - } - - self.zoomLens.css({ - 'width': lensWidth, - 'height': lensHeight - }); - - if (self.options.tint) { - self.zoomTintImage.css({ - 'width': self.nzWidth, - 'height': self.nzHeight - }); - } - - } - if (self.options.zoomType === 'lens') { - self.zoomLens.css({ - width: String(self.options.lensSize) + 'px', - height: String(self.options.lensSize) + 'px' - }); - } - //end responsive image change - } - } - - //container fix - self.zoomContainer.css({ - top: self.nzOffset.top, - left: self.nzOffset.left - }); - self.mouseLeft = parseInt(e.pageX - self.nzOffset.left); - self.mouseTop = parseInt(e.pageY - self.nzOffset.top); - //calculate the Location of the Lens - - //calculate the bound regions - but only if zoom window - if (self.options.zoomType === 'window') { - var zoomLensHeight = self.zoomLens.height() / 2; - var zoomLensWidth = self.zoomLens.width() / 2; - self.Etoppos = (self.mouseTop < 0 + zoomLensHeight); - self.Eboppos = (self.mouseTop > self.nzHeight - zoomLensHeight - (self.options.lensBorderSize * 2)); - self.Eloppos = (self.mouseLeft < 0 + zoomLensWidth); - self.Eroppos = (self.mouseLeft > (self.nzWidth - zoomLensWidth - (self.options.lensBorderSize * 2))); - } - //calculate the bound regions - but only for inner zoom - if (self.options.zoomType === 'inner') { - self.Etoppos = (self.mouseTop < ((self.nzHeight / 2) / self.heightRatio)); - self.Eboppos = (self.mouseTop > (self.nzHeight - ((self.nzHeight / 2) / self.heightRatio))); - self.Eloppos = (self.mouseLeft < 0 + (((self.nzWidth / 2) / self.widthRatio))); - self.Eroppos = (self.mouseLeft > (self.nzWidth - (self.nzWidth / 2) / self.widthRatio - (self.options.lensBorderSize * 2))); - } - - // if the mouse position of the slider is one of the outerbounds, then hide window and lens - if (self.mouseLeft < 0 || self.mouseTop < 0 || self.mouseLeft > self.nzWidth || self.mouseTop > self.nzHeight) { - self.setElements('hide'); - return; - } - //else continue with operations - else { - //lens options - if (self.options.showLens) { - // self.showHideLens('show'); - //set background position of lens - self.lensLeftPos = String(Math.floor(self.mouseLeft - self.zoomLens.width() / 2)); - self.lensTopPos = String(Math.floor(self.mouseTop - self.zoomLens.height() / 2)); - } - //adjust the background position if the mouse is in one of the outer regions - - //Top region - if (self.Etoppos) { - self.lensTopPos = 0; - } - //Left Region - if (self.Eloppos) { - self.windowLeftPos = 0; - self.lensLeftPos = 0; - self.tintpos = 0; - } - //Set bottom and right region for window mode - if (self.options.zoomType === 'window') { - if (self.Eboppos) { - self.lensTopPos = Math.max((self.nzHeight) - self.zoomLens.height() - (self.options.lensBorderSize * 2), 0); - } - if (self.Eroppos) { - self.lensLeftPos = (self.nzWidth - (self.zoomLens.width()) - (self.options.lensBorderSize * 2)); - } - } - //Set bottom and right region for inner mode - if (self.options.zoomType === 'inner') { - if (self.Eboppos) { - self.lensTopPos = Math.max(((self.nzHeight) - (self.options.lensBorderSize * 2)), 0); - } - if (self.Eroppos) { - self.lensLeftPos = (self.nzWidth - (self.nzWidth) - (self.options.lensBorderSize * 2)); - } - } - //if lens zoom - if (self.options.zoomType === 'lens') { - - self.windowLeftPos = String(((e.pageX - self.nzOffset.left) * self.widthRatio - self.zoomLens.width() / 2) * (-1)); - self.windowTopPos = String(((e.pageY - self.nzOffset.top) * self.heightRatio - self.zoomLens.height() / 2) * (-1)); - self.zoomLens.css('background-position', self.windowLeftPos + 'px ' + self.windowTopPos + 'px'); - - if (self.changeBgSize) { - if (self.nzHeight > self.nzWidth) { - if (self.options.zoomType === 'lens') { - self.zoomLens.css('background-size', - self.largeWidth / self.newvalueheight + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - - self.zoomWindow.css('background-size', - self.largeWidth / self.newvalueheight + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - else { - if (self.options.zoomType === 'lens') { - self.zoomLens.css('background-size', - self.largeWidth / self.newvaluewidth + 'px ' + - self.largeHeight / self.newvaluewidth + 'px'); - } - self.zoomWindow.css('background-size', - self.largeWidth / self.newvaluewidth + 'px ' + - self.largeHeight / self.newvaluewidth + 'px'); - } - self.changeBgSize = false; - } - - self.setWindowPosition(e); - } - //if tint zoom - if (self.options.tint && self.options.zoomType !== 'inner') { - self.setTintPosition(e); - } - //set the css background position - if (self.options.zoomType === 'window') { - self.setWindowPosition(e); - } - if (self.options.zoomType === 'inner') { - self.setWindowPosition(e); - } - if (self.options.showLens) { - if (self.fullwidth && self.options.zoomType !== 'lens') { - self.lensLeftPos = 0; - } - self.zoomLens.css({ - left: self.lensLeftPos + 'px', - top: self.lensTopPos + 'px' - }); - } - - } //end else - }, - showHideZoomContainer: function (change) { - var self = this; - if (change === 'show') { - if (self.zoomContainer) { - self.zoomContainer.show(); - } - } - if (change === 'hide') { - if (self.zoomContainer) { - self.zoomContainer.hide(); - } - } - }, - showHideWindow: function (change) { - var self = this; - if (change === 'show') { - if (!self.isWindowActive && self.zoomWindow) { - self.options.onShow(self); - if (self.options.zoomWindowFadeIn) { - self.zoomWindow.stop(true, true, false).fadeIn(self.options.zoomWindowFadeIn); - } - else { - self.zoomWindow.show(); - } - self.isWindowActive = true; - } - } - if (change === 'hide') { - if (self.isWindowActive) { - if (self.options.zoomWindowFadeOut) { - self.zoomWindow.stop(true, true).fadeOut(self.options.zoomWindowFadeOut, function () { - if (self.loop) { - //stop moving the zoom window when zoom window is faded out - clearInterval(self.loop); - self.loop = false; - } - }); - } - else { - self.zoomWindow.hide(); - } - self.isWindowActive = false; - } - } - }, - showHideLens: function (change) { - var self = this; - if (change === 'show') { - if (!self.isLensActive) { - if (self.options.lensFadeIn && self.zoomLens) { - self.zoomLens.stop(true, true, false).fadeIn(self.options.lensFadeIn); - } - else { - self.zoomLens.show(); - } - self.isLensActive = true; - } - } - if (change === 'hide') { - if (self.isLensActive) { - if (self.options.lensFadeOut) { - self.zoomLens.stop(true, true).fadeOut(self.options.lensFadeOut); - } - else { - self.zoomLens.hide(); - } - self.isLensActive = false; - } - } - }, - showHideTint: function (change) { - var self = this; - if (change === 'show') { - if (!self.isTintActive && self.zoomTint) { - - if (self.options.zoomTintFadeIn) { - self.zoomTint.css('opacity', self.options.tintOpacity).animate().stop(true, true).fadeIn('slow'); - } - else { - self.zoomTint.css('opacity', self.options.tintOpacity).animate(); - self.zoomTint.show(); - } - self.isTintActive = true; - } - } - if (change === 'hide') { - if (self.isTintActive) { - - if (self.options.zoomTintFadeOut) { - self.zoomTint.stop(true, true).fadeOut(self.options.zoomTintFadeOut); - } - else { - self.zoomTint.hide(); - } - self.isTintActive = false; - } - } - }, - - setLensPosition: function (e) { - }, - - setWindowPosition: function (e) { - //return obj.slice( 0, count ); - var self = this; - - if (!isNaN(self.options.zoomWindowPosition)) { - - switch (self.options.zoomWindowPosition) { - case 1: //done - self.windowOffsetTop = (self.options.zoomWindowOffsetY);//DONE - 1 - self.windowOffsetLeft = (+self.nzWidth); //DONE 1, 2, 3, 4, 16 - break; - case 2: - if (self.options.zoomWindowHeight > self.nzHeight) { //positive margin - - self.windowOffsetTop = ((self.options.zoomWindowHeight / 2) - (self.nzHeight / 2)) * (-1); - self.windowOffsetLeft = (self.nzWidth); //DONE 1, 2, 3, 4, 16 - } - else { //negative margin - $.noop(); - } - break; - case 3: //done - self.windowOffsetTop = (self.nzHeight - self.zoomWindow.height() - (self.options.borderSize * 2)); //DONE 3,9 - self.windowOffsetLeft = (self.nzWidth); //DONE 1, 2, 3, 4, 16 - break; - case 4: //done - self.windowOffsetTop = (self.nzHeight); //DONE - 4,5,6,7,8 - self.windowOffsetLeft = (self.nzWidth); //DONE 1, 2, 3, 4, 16 - break; - case 5: //done - self.windowOffsetTop = (self.nzHeight); //DONE - 4,5,6,7,8 - self.windowOffsetLeft = (self.nzWidth - self.zoomWindow.width() - (self.options.borderSize * 2)); //DONE - 5,15 - break; - case 6: - if (self.options.zoomWindowHeight > self.nzHeight) { //positive margin - self.windowOffsetTop = (self.nzHeight); //DONE - 4,5,6,7,8 - - self.windowOffsetLeft = ((self.options.zoomWindowWidth / 2) - (self.nzWidth / 2) + (self.options.borderSize * 2)) * (-1); - } - else { //negative margin - $.noop(); - } - - break; - case 7: //done - self.windowOffsetTop = (self.nzHeight); //DONE - 4,5,6,7,8 - self.windowOffsetLeft = 0; //DONE 7, 13 - break; - case 8: //done - self.windowOffsetTop = (self.nzHeight); //DONE - 4,5,6,7,8 - self.windowOffsetLeft = (self.zoomWindow.width() + (self.options.borderSize * 2)) * (-1); //DONE 8,9,10,11,12 - break; - case 9: //done - self.windowOffsetTop = (self.nzHeight - self.zoomWindow.height() - (self.options.borderSize * 2)); //DONE 3,9 - self.windowOffsetLeft = (self.zoomWindow.width() + (self.options.borderSize * 2)) * (-1); //DONE 8,9,10,11,12 - break; - case 10: - if (self.options.zoomWindowHeight > self.nzHeight) { //positive margin - - self.windowOffsetTop = ((self.options.zoomWindowHeight / 2) - (self.nzHeight / 2)) * (-1); - self.windowOffsetLeft = (self.zoomWindow.width() + (self.options.borderSize * 2)) * (-1); //DONE 8,9,10,11,12 - } - else { //negative margin - $.noop(); - } - break; - case 11: - self.windowOffsetTop = (self.options.zoomWindowOffsetY); - self.windowOffsetLeft = (self.zoomWindow.width() + (self.options.borderSize * 2)) * (-1); //DONE 8,9,10,11,12 - break; - case 12: //done - self.windowOffsetTop = (self.zoomWindow.height() + (self.options.borderSize * 2)) * (-1); //DONE 12,13,14,15,16 - self.windowOffsetLeft = (self.zoomWindow.width() + (self.options.borderSize * 2)) * (-1); //DONE 8,9,10,11,12 - break; - case 13: //done - self.windowOffsetTop = (self.zoomWindow.height() + (self.options.borderSize * 2)) * (-1); //DONE 12,13,14,15,16 - self.windowOffsetLeft = (0); //DONE 7, 13 - break; - case 14: - if (self.options.zoomWindowHeight > self.nzHeight) { //positive margin - self.windowOffsetTop = (self.zoomWindow.height() + (self.options.borderSize * 2)) * (-1); //DONE 12,13,14,15,16 - - self.windowOffsetLeft = ((self.options.zoomWindowWidth / 2) - (self.nzWidth / 2) + (self.options.borderSize * 2)) * (-1); - } - else { //negative margin - $.noop(); - } - break; - case 15://done - self.windowOffsetTop = (self.zoomWindow.height() + (self.options.borderSize * 2)) * (-1); //DONE 12,13,14,15,16 - self.windowOffsetLeft = (self.nzWidth - self.zoomWindow.width() - (self.options.borderSize * 2)); //DONE - 5,15 - break; - case 16: //done - self.windowOffsetTop = (self.zoomWindow.height() + (self.options.borderSize * 2)) * (-1); //DONE 12,13,14,15,16 - self.windowOffsetLeft = (self.nzWidth); //DONE 1, 2, 3, 4, 16 - break; - default: //done - self.windowOffsetTop = (self.options.zoomWindowOffsetY);//DONE - 1 - self.windowOffsetLeft = (self.nzWidth); //DONE 1, 2, 3, 4, 16 - } - } //end isNAN - else { - //WE CAN POSITION IN A CLASS - ASSUME THAT ANY STRING PASSED IS - self.externalContainer = $('#' + self.options.zoomWindowPosition); - self.externalContainerWidth = self.externalContainer.width(); - self.externalContainerHeight = self.externalContainer.height(); - self.externalContainerOffset = self.externalContainer.offset(); - - self.windowOffsetTop = self.externalContainerOffset.top;//DONE - 1 - self.windowOffsetLeft = self.externalContainerOffset.left; //DONE 1, 2, 3, 4, 16 - - } - self.isWindowSet = true; - self.windowOffsetTop = self.windowOffsetTop + self.options.zoomWindowOffsetY; - self.windowOffsetLeft = self.windowOffsetLeft + self.options.zoomWindowOffsetX; - - self.zoomWindow.css({ - top: self.windowOffsetTop, - left: self.windowOffsetLeft - }); - - if (self.options.zoomType === 'inner') { - self.zoomWindow.css({ - top: 0, - left: 0 - }); - - } - - self.windowLeftPos = String(((e.pageX - self.nzOffset.left) * self.widthRatio - self.zoomWindow.width() / 2) * (-1)); - self.windowTopPos = String(((e.pageY - self.nzOffset.top) * self.heightRatio - self.zoomWindow.height() / 2) * (-1)); - if (self.Etoppos) { - self.windowTopPos = 0; - } - if (self.Eloppos) { - self.windowLeftPos = 0; - } - if (self.Eboppos) { - self.windowTopPos = (self.largeHeight / self.currentZoomLevel - self.zoomWindow.height()) * (-1); - } - if (self.Eroppos) { - self.windowLeftPos = ((self.largeWidth / self.currentZoomLevel - self.zoomWindow.width()) * (-1)); - } - - //stops micro movements - if (self.fullheight) { - self.windowTopPos = 0; - } - if (self.fullwidth) { - self.windowLeftPos = 0; - } - - //set the css background position - if (self.options.zoomType === 'window' || self.options.zoomType === 'inner') { - - if (self.zoomLock === 1) { - //overrides for images not zoomable - if (self.widthRatio <= 1) { - self.windowLeftPos = 0; - } - if (self.heightRatio <= 1) { - self.windowTopPos = 0; - } - } - // adjust images less than the window height - - if (self.options.zoomType === 'window') { - if (self.largeHeight < self.options.zoomWindowHeight) { - self.windowTopPos = 0; - } - if (self.largeWidth < self.options.zoomWindowWidth) { - self.windowLeftPos = 0; - } - } - //set the zoomwindow background position - if (self.options.easing) { - - // if(self.changeZoom){ - // clearInterval(self.loop); - // self.changeZoom = false; - // self.loop = false; - - // } - //set the pos to 0 if not set - if (!self.xp) { - self.xp = 0; - } - if (!self.yp) { - self.yp = 0; - } - //if loop not already started, then run it - if (!self.loop) { - self.loop = setInterval(function () { - //using zeno's paradox - - self.xp += (self.windowLeftPos - self.xp) / self.options.easingAmount; - self.yp += (self.windowTopPos - self.yp) / self.options.easingAmount; - if (self.scrollingLock) { - - clearInterval(self.loop); - self.xp = self.windowLeftPos; - self.yp = self.windowTopPos; - - self.xp = ((e.pageX - self.nzOffset.left) * self.widthRatio - self.zoomWindow.width() / 2) * (-1); - self.yp = (((e.pageY - self.nzOffset.top) * self.heightRatio - self.zoomWindow.height() / 2) * (-1)); - - if (self.changeBgSize) { - if (self.nzHeight > self.nzWidth) { - if (self.options.zoomType === 'lens') { - self.zoomLens.css('background-size', - self.largeWidth / self.newvalueheight + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - self.zoomWindow.css('background-size', - self.largeWidth / self.newvalueheight + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - else { - if (self.options.zoomType !== 'lens') { - self.zoomLens.css('background-size', - self.largeWidth / self.newvaluewidth + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - self.zoomWindow.css('background-size', - self.largeWidth / self.newvaluewidth + 'px ' + - self.largeHeight / self.newvaluewidth + 'px'); - } - - /* - if(!self.bgxp){self.bgxp = self.largeWidth/self.newvalue;} - if(!self.bgyp){self.bgyp = self.largeHeight/self.newvalue ;} - if (!self.bgloop){ - self.bgloop = setInterval(function(){ - - self.bgxp += (self.largeWidth/self.newvalue - self.bgxp) / self.options.easingAmount; - self.bgyp += (self.largeHeight/self.newvalue - self.bgyp) / self.options.easingAmount; - - self.zoomWindow.css('background-size', self.bgxp + 'px ' + self.bgyp + 'px' ); - - - }, 16); - - } - */ - self.changeBgSize = false; - } - - self.zoomWindow.css('background-position', self.windowLeftPos + 'px ' + self.windowTopPos + 'px'); - self.scrollingLock = false; - self.loop = false; - - } - else if (Math.round(Math.abs(self.xp - self.windowLeftPos) + Math.abs(self.yp - self.windowTopPos)) < 1) { - //stops micro movements - clearInterval(self.loop); - self.zoomWindow.css('background-position', self.windowLeftPos + 'px ' + self.windowTopPos + 'px'); - self.loop = false; - } - else { - if (self.changeBgSize) { - if (self.nzHeight > self.nzWidth) { - if (self.options.zoomType === 'lens') { - self.zoomLens.css('background-size', - self.largeWidth / self.newvalueheight + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - self.zoomWindow.css('background-size', - self.largeWidth / self.newvalueheight + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - else { - if (self.options.zoomType !== 'lens') { - self.zoomLens.css('background-size', - self.largeWidth / self.newvaluewidth + 'px ' + - self.largeHeight / self.newvaluewidth + 'px'); - } - self.zoomWindow.css('background-size', - self.largeWidth / self.newvaluewidth + 'px ' + - self.largeHeight / self.newvaluewidth + 'px'); - } - self.changeBgSize = false; - } - - self.zoomWindow.css('background-position', self.xp + 'px ' + self.yp + 'px'); - } - }, 16); - } - } - else { - if (self.changeBgSize) { - if (self.nzHeight > self.nzWidth) { - if (self.options.zoomType === 'lens') { - self.zoomLens.css('background-size', - self.largeWidth / self.newvalueheight + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - - self.zoomWindow.css('background-size', - self.largeWidth / self.newvalueheight + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - else { - if (self.options.zoomType === 'lens') { - self.zoomLens.css('background-size', - self.largeWidth / self.newvaluewidth + 'px ' + - self.largeHeight / self.newvaluewidth + 'px'); - } - if ((self.largeHeight / self.newvaluewidth) < self.options.zoomWindowHeight) { - - self.zoomWindow.css('background-size', - self.largeWidth / self.newvaluewidth + 'px ' + - self.largeHeight / self.newvaluewidth + 'px'); - } - else { - - self.zoomWindow.css('background-size', - self.largeWidth / self.newvalueheight + 'px ' + - self.largeHeight / self.newvalueheight + 'px'); - } - - } - self.changeBgSize = false; - } - - self.zoomWindow.css('background-position', - self.windowLeftPos + 'px ' + - self.windowTopPos + 'px'); - } - } - }, - - setTintPosition: function (e) { - var self = this; - var zoomLensWidth = self.zoomLens.width(); - var zoomLensHeight = self.zoomLens.height(); - self.nzOffset = self.$elem.offset(); - self.tintpos = String(((e.pageX - self.nzOffset.left) - (zoomLensWidth / 2)) * (-1)); - self.tintposy = String(((e.pageY - self.nzOffset.top) - zoomLensHeight / 2) * (-1)); - if (self.Etoppos) { - self.tintposy = 0; - } - if (self.Eloppos) { - self.tintpos = 0; - } - if (self.Eboppos) { - self.tintposy = (self.nzHeight - zoomLensHeight - (self.options.lensBorderSize * 2)) * (-1); - } - if (self.Eroppos) { - self.tintpos = ((self.nzWidth - zoomLensWidth - (self.options.lensBorderSize * 2)) * (-1)); - } - if (self.options.tint) { - //stops micro movements - if (self.fullheight) { - self.tintposy = 0; - - } - if (self.fullwidth) { - self.tintpos = 0; - - } - self.zoomTintImage.css({ - 'left': self.tintpos + 'px', - 'top': self.tintposy + 'px' - }); - } - }, - - swaptheimage: function (smallimage, largeimage) { - var self = this; - var newImg = new Image(); - - if (self.options.loadingIcon) { - self.spinner = $('
'); - self.$elem.after(self.spinner); - } - - self.options.onImageSwap(self.$elem); - - newImg.onload = function () { - self.largeWidth = newImg.width; - self.largeHeight = newImg.height; - self.zoomImage = largeimage; - self.zoomWindow.css('background-size', self.largeWidth + 'px ' + self.largeHeight + 'px'); - - self.swapAction(smallimage, largeimage); - return; - }; - self.setImageSource(newImg, largeimage); // this must be done AFTER setting onload - }, - - swapAction: function (smallimage, largeimage) { - var self = this; - var elemWidth = self.$elem.width(); - var elemHeight = self.$elem.height(); - var newImg2 = new Image(); - newImg2.onload = function () { - //re-calculate values - self.nzHeight = newImg2.height; - self.nzWidth = newImg2.width; - self.options.onImageSwapComplete(self.$elem); - - self.doneCallback(); - return; - }; - self.setImageSource(newImg2, smallimage); - - //reset the zoomlevel to that initially set in options - self.currentZoomLevel = self.options.zoomLevel; - self.options.maxZoomLevel = false; - - //swaps the main image - //self.$elem.attr('src',smallimage); - //swaps the zoom image - if (self.options.zoomType === 'lens') { - self.zoomLens.css('background-image', 'url("' + largeimage + '")'); - } - if (self.options.zoomType === 'window') { - self.zoomWindow.css('background-image', 'url("' + largeimage + '")'); - } - if (self.options.zoomType === 'inner') { - self.zoomWindow.css('background-image', 'url("' + largeimage + '")'); - } - - self.currentImage = largeimage; - - if (self.options.imageCrossfade) { - var oldImg = self.$elem; - var newImg = oldImg.clone(); - self.$elem.attr('src', smallimage); - self.$elem.after(newImg); - newImg.stop(true).fadeOut(self.options.imageCrossfade, function () { - $(this).remove(); - }); - - // if(self.options.zoomType === 'inner'){ - //remove any attributes on the cloned image so we can resize later - self.$elem.width('auto').removeAttr('width'); - self.$elem.height('auto').removeAttr('height'); - // } - - oldImg.fadeIn(self.options.imageCrossfade); - - if (self.options.tint && self.options.zoomType !== 'inner') { - - var oldImgTint = self.zoomTintImage; - var newImgTint = oldImgTint.clone(); - self.zoomTintImage.attr('src', largeimage); - self.zoomTintImage.after(newImgTint); - newImgTint.stop(true).fadeOut(self.options.imageCrossfade, function () { - $(this).remove(); - }); - - oldImgTint.fadeIn(self.options.imageCrossfade); - - //self.zoomTintImage.attr('width',elem.data('image')); - - //resize the tint window - self.zoomTint.css({ - height: elemHeight, - width: elemWidth - }); - } - - self.zoomContainer.css({ - 'height': elemHeight, - 'width': elemWidth - }); - - if (self.options.zoomType === 'inner') { - if (!self.options.constrainType) { - self.zoomWrap.parent().css({ - 'height': elemHeight, - 'width': elemWidth - }); - - self.zoomWindow.css({ - 'height': elemHeight, - 'width': elemWidth - }); - } - } - - if (self.options.imageCrossfade) { - self.zoomWrap.css({ - 'height': elemHeight, - 'width': elemWidth - }); - } - } - else { - self.$elem.attr('src', smallimage); - if (self.options.tint) { - self.zoomTintImage.attr('src', largeimage); - //self.zoomTintImage.attr('width',elem.data('image')); - self.zoomTintImage.attr('height', elemHeight); - //self.zoomTintImage.attr('src') = elem.data('image'); - self.zoomTintImage.css('height', elemHeight); - self.zoomTint.css('height', elemHeight); - - } - self.zoomContainer.css({ - 'height': elemHeight, - 'width': elemWidth - }); - - if (self.options.imageCrossfade) { - self.zoomWrap.css({ - 'height': elemHeight, - 'width': elemWidth - }); - } - } - if (self.options.constrainType) { - - //This will contrain the image proportions - if (self.options.constrainType === 'height') { - - var autoWDimension = { - 'height': self.options.constrainSize, - 'width': 'auto' - }; - self.zoomContainer.css(autoWDimension); - - if (self.options.imageCrossfade) { - self.zoomWrap.css(autoWDimension); - self.constwidth = self.zoomWrap.width(); - } - else { - self.$elem.css(autoWDimension); - self.constwidth = elemWidth; - } - - var constWDim = { - 'height': self.options.constrainSize, - 'width': self.constwidth - }; - if (self.options.zoomType === 'inner') { - - self.zoomWrap.parent().css(constWDim); - self.zoomWindow.css(constWDim); - } - if (self.options.tint) { - self.tintContainer.css(constWDim); - self.zoomTint.css(constWDim); - self.zoomTintImage.css(constWDim); - } - - } - if (self.options.constrainType === 'width') { - var autoHDimension = { - 'height': 'auto', - 'width': self.options.constrainSize - }; - self.zoomContainer.css(autoHDimension); - - if (self.options.imageCrossfade) { - self.zoomWrap.css(autoHDimension); - self.constheight = self.zoomWrap.height(); - } - else { - self.$elem.css(autoHDimension); - self.constheight = elemHeight; - } - - var constHDim = { - 'height': self.constheight, - 'width': self.options.constrainSize - }; - if (self.options.zoomType === 'inner') { - self.zoomWrap.parent().css(constHDim); - self.zoomWindow.css(constHDim); - } - if (self.options.tint) { - self.tintContainer.css(constHDim); - self.zoomTint.css(constHDim); - self.zoomTintImage.css(constHDim); - } - } - } - }, - - doneCallback: function () { - var self = this; - if (self.options.loadingIcon) { - self.spinner.hide(); - } - - self.nzOffset = self.$elem.offset(); - self.nzWidth = self.$elem.width(); - self.nzHeight = self.$elem.height(); - - // reset the zoomlevel back to default - self.currentZoomLevel = self.options.zoomLevel; - - //ratio of the large to small image - self.widthRatio = self.largeWidth / self.nzWidth; - self.heightRatio = self.largeHeight / self.nzHeight; - - //NEED TO ADD THE LENS SIZE FOR ROUND - // adjust images less than the window height - if (self.options.zoomType === 'window') { - var lensHeight, lensWidth; - - if (self.nzHeight < self.options.zoomWindowHeight / self.heightRatio) { - lensHeight = self.nzHeight; - - } - else { - lensHeight = String((self.options.zoomWindowHeight / self.heightRatio)); - } - - if (self.nzWidth < self.options.zoomWindowWidth) { - lensWidth = self.nzWidth; - } - else { - lensWidth = (self.options.zoomWindowWidth / self.widthRatio); - } - - if (self.zoomLens) { - self.zoomLens.css({ - 'width': lensWidth, - 'height': lensHeight - }); - } - } - }, - - getCurrentImage: function () { - var self = this; - return self.zoomImage; - }, - - getGalleryList: function () { - var self = this; - //loop through the gallery options and set them in list for fancybox - self.gallerylist = []; - if (self.options.gallery) { - $('#' + self.options.gallery + ' a').each(function () { - - var imgSrc = ''; - if ($(this).data('zoom-image')) { - imgSrc = $(this).data('zoom-image'); - } - else if ($(this).data('image')) { - imgSrc = $(this).data('image'); - } - //put the current image at the start - if (imgSrc === self.zoomImage) { - self.gallerylist.unshift({ - href: '' + imgSrc + '', - title: $(this).find('img').attr('title') - }); - } - else { - self.gallerylist.push({ - href: '' + imgSrc + '', - title: $(this).find('img').attr('title') - }); - } - }); - } - //if no gallery - return current image - else { - self.gallerylist.push({ - href: '' + self.zoomImage + '', - title: $(this).find('img').attr('title') - }); - } - return self.gallerylist; - }, - - changeZoomLevel: function (value) { - var self = this; - - //flag a zoom, so can adjust the easing during setPosition - self.scrollingLock = true; - - //round to two decimal places - self.newvalue = parseFloat(value).toFixed(2); - var newvalue = self.newvalue; - - //maxwidth & Maxheight of the image - var maxheightnewvalue = self.largeHeight / ((self.options.zoomWindowHeight / self.nzHeight) * self.nzHeight); - var maxwidthtnewvalue = self.largeWidth / ((self.options.zoomWindowWidth / self.nzWidth) * self.nzWidth); - - //calculate new heightratio - if (self.options.zoomType !== 'inner') { - if (maxheightnewvalue <= newvalue) { - self.heightRatio = (self.largeHeight / maxheightnewvalue) / self.nzHeight; - self.newvalueheight = maxheightnewvalue; - self.fullheight = true; - } - else { - self.heightRatio = (self.largeHeight / newvalue) / self.nzHeight; - self.newvalueheight = newvalue; - self.fullheight = false; - } - - // calculate new width ratio - - if (maxwidthtnewvalue <= newvalue) { - self.widthRatio = (self.largeWidth / maxwidthtnewvalue) / self.nzWidth; - self.newvaluewidth = maxwidthtnewvalue; - self.fullwidth = true; - } - else { - self.widthRatio = (self.largeWidth / newvalue) / self.nzWidth; - self.newvaluewidth = newvalue; - self.fullwidth = false; - } - if (self.options.zoomType === 'lens') { - if (maxheightnewvalue <= newvalue) { - self.fullwidth = true; - self.newvaluewidth = maxheightnewvalue; - } else { - self.widthRatio = (self.largeWidth / newvalue) / self.nzWidth; - self.newvaluewidth = newvalue; - - self.fullwidth = false; - } - } - } - - if (self.options.zoomType === 'inner') { - maxheightnewvalue = parseFloat(self.largeHeight / self.nzHeight).toFixed(2); - maxwidthtnewvalue = parseFloat(self.largeWidth / self.nzWidth).toFixed(2); - if (newvalue > maxheightnewvalue) { - newvalue = maxheightnewvalue; - } - if (newvalue > maxwidthtnewvalue) { - newvalue = maxwidthtnewvalue; - } - - if (maxheightnewvalue <= newvalue) { - self.heightRatio = (self.largeHeight / newvalue) / self.nzHeight; - if (newvalue > maxheightnewvalue) { - self.newvalueheight = maxheightnewvalue; - } else { - self.newvalueheight = newvalue; - } - self.fullheight = true; - } - else { - self.heightRatio = (self.largeHeight / newvalue) / self.nzHeight; - - if (newvalue > maxheightnewvalue) { - - self.newvalueheight = maxheightnewvalue; - } else { - self.newvalueheight = newvalue; - } - self.fullheight = false; - } - - if (maxwidthtnewvalue <= newvalue) { - - self.widthRatio = (self.largeWidth / newvalue) / self.nzWidth; - if (newvalue > maxwidthtnewvalue) { - - self.newvaluewidth = maxwidthtnewvalue; - } else { - self.newvaluewidth = newvalue; - } - - self.fullwidth = true; - } - else { - self.widthRatio = (self.largeWidth / newvalue) / self.nzWidth; - self.newvaluewidth = newvalue; - self.fullwidth = false; - } - } //end inner - var scrcontinue = false; - - if (self.options.zoomType === 'inner') { - if (self.nzWidth >= self.nzHeight) { - if (self.newvaluewidth <= maxwidthtnewvalue) { - scrcontinue = true; - } - else { - scrcontinue = false; - self.fullheight = true; - self.fullwidth = true; - } - } - if (self.nzHeight > self.nzWidth) { - if (self.newvaluewidth <= maxwidthtnewvalue) { - scrcontinue = true; - } - else { - scrcontinue = false; - self.fullheight = true; - self.fullwidth = true; - } - } - } - - if (self.options.zoomType !== 'inner') { - scrcontinue = true; - } - - if (scrcontinue) { - self.zoomLock = 0; - self.changeZoom = true; - - //if lens height is less than image height - if (((self.options.zoomWindowHeight) / self.heightRatio) <= self.nzHeight) { - self.currentZoomLevel = self.newvalueheight; - if (self.options.zoomType !== 'lens' && self.options.zoomType !== 'inner') { - self.changeBgSize = true; - self.zoomLens.css('height', String(self.options.zoomWindowHeight / self.heightRatio) + 'px'); - } - if (self.options.zoomType === 'lens' || self.options.zoomType === 'inner') { - self.changeBgSize = true; - } - } - - if ((self.options.zoomWindowWidth / self.widthRatio) <= self.nzWidth) { - if (self.options.zoomType !== 'inner') { - if (self.newvaluewidth > self.newvalueheight) { - self.currentZoomLevel = self.newvaluewidth; - } - } - - if (self.options.zoomType !== 'lens' && self.options.zoomType !== 'inner') { - self.changeBgSize = true; - - self.zoomLens.css('width', String(self.options.zoomWindowWidth / self.widthRatio) + 'px'); - } - if (self.options.zoomType === 'lens' || self.options.zoomType === 'inner') { - self.changeBgSize = true; - } - - } - if (self.options.zoomType === 'inner') { - self.changeBgSize = true; - - if (self.nzWidth > self.nzHeight) { - self.currentZoomLevel = self.newvaluewidth; - } - if (self.nzHeight > self.nzWidth) { - self.currentZoomLevel = self.newvaluewidth; - } - } - } //under - - //sets the boundry change, called in setWindowPos - self.setPosition(self.currentLoc); - // - }, - - closeAll: function () { - var self = this; - if (self.zoomWindow) { - self.zoomWindow.hide(); - } - if (self.zoomLens) { - self.zoomLens.hide(); - } - if (self.zoomTint) { - self.zoomTint.hide(); - } - }, - - changeState: function (value) { - var self = this; - if (value === 'enable') { - self.options.zoomEnabled = true; - } - if (value === 'disable') { - self.options.zoomEnabled = false; - } - }, - - responsiveConfig: function (options) { - if (options.respond && options.respond.length > 0) { - return $.extend({}, options, this.configByScreenWidth(options)); - } - return options; - }, - - configByScreenWidth: function (options) { - var screenWidth = $(window).width(); - - var config = $.grep(options.respond, function (item) { - var range = item.range.split('-'); - return (screenWidth >= range[0]) && (screenWidth <= range[1]); - }); - - if (config.length > 0) { - return config[0]; - } else { - return options; - } - } - }; - - $.fn.ezPlus = function (options) { - return this.each(function () { - var elevate = Object.create(EZP); - - elevate.init(options, this); - - $.data(this, 'ezPlus', elevate); - - }); - }; - - $.fn.ezPlus.options = { - borderColour: '#888', - borderSize: 4, - constrainSize: false, //in pixels the dimensions you want to constrain on - constrainType: false, //width or height - containLensZoom: false, - cursor: 'inherit', // user should set to what they want the cursor as, if they have set a click function - debug: false, - easing: false, - easingAmount: 12, - enabled: true, - - gallery: false, - galleryActiveClass: 'zoomGalleryActive', - gallerySelector: false, - galleryItem: 'a', - - imageCrossfade: false, - - lensBorderColour: '#000', - lensBorderSize: 1, - lensColour: 'white', //colour of the lens background - lensFadeIn: false, - lensFadeOut: false, - lensOpacity: 0.4, //opacity of the lens - lensShape: 'square', //can be 'round' - lensSize: 200, - lenszoom: false, - - loadingIcon: false, //http://www.example.com/spinner.gif - - // This change will allow to decide if you want to decrease - // zoom of one of the dimensions once the other reached it's top value, - // or keep the aspect ratio, default behaviour still being as always, - // allow to continue zooming out, so it keeps retrocompatibility. - mantainZoomAspectRatio: false, - maxZoomLevel: false, - minZoomLevel: false, - - onComplete: $.noop, - onDestroy: $.noop, - onImageClick: $.noop, - onImageSwap: $.noop, - onImageSwapComplete: $.noop, - onShow: $.noop, - onZoomedImageLoaded: $.noop, - - preloading: 1, //by default, load all the images, if 0, then only load images after activated (PLACEHOLDER FOR NEXT VERSION) - respond: [], - responsive: true, - scrollZoom: false, //allow zoom on mousewheel, true to activate - scrollZoomIncrement: 0.1, //steps of the scrollzoom - showLens: true, - tint: false, //enable the tinting - tintColour: '#333', //default tint color, can be anything, red, #ccc, rgb(0,0,0) - tintOpacity: 0.4, //opacity of the tint - touchEnabled: true, - - zoomActivation: 'hover', // Can also be click (PLACEHOLDER FOR NEXT VERSION) - zoomContainerAppendTo: 'body', //zoom container parent selector - zoomLevel: 1, //default zoom level of image - zoomTintFadeIn: false, - zoomTintFadeOut: false, - zoomType: 'window', //window is default, also 'lens' available - - zoomWindowAlwaysShow: false, - zoomWindowBgColour: '#fff', - zoomWindowFadeIn: false, - zoomWindowFadeOut: false, - zoomWindowHeight: 400, - zoomWindowOffsetX: 0, - zoomWindowOffsetY: 0, - zoomWindowPosition: 1, - zoomWindowWidth: 400, - zoomEnabled: true, //false disables zoomwindow from showing - zIndex: 999 - }; - -})(jQuery, window, document); \ No newline at end of file +"function"!=typeof Object.create&&(Object.create=function(o){function i(){}return i.prototype=o,new i}),function(o,i,t,e){var n={init:function(i,t){var e,n=this;n.elem=t,n.$elem=o(t),n.imageSrc=n.$elem.data("zoom-image")?n.$elem.data("zoom-image"):n.$elem.attr("src"),n.options=o.extend({},o.fn.ezPlus.options,n.responsiveConfig(i||{})),n.options.enabled&&(n.options.tint&&(n.options.lensColour="none",n.options.lensOpacity="1"),"inner"===n.options.zoomType&&(n.options.showLens=!1),n.$elem.parent().removeAttr("title").removeAttr("alt"),n.zoomImage=n.imageSrc,n.refresh(1),(e=o(n.options.gallery?"#"+n.options.gallery:n.options.gallerySelector)).on("click.zoom",n.options.galleryItem,function(i){if(n.options.galleryActiveClass&&(o(n.options.galleryItem,e).removeClass(n.options.galleryActiveClass),o(this).addClass(n.options.galleryActiveClass)),"A"===this.tagName&&i.preventDefault(),o(this).data("zoom-image")?n.zoomImagePre=o(this).data("zoom-image"):n.zoomImagePre=o(this).data("image"),n.swaptheimage(o(this).data("image"),n.zoomImagePre),"A"===this.tagName)return!1}))},refresh:function(o){var i=this;setTimeout(function(){i.fetch(i.imageSrc)},o||i.options.refresh)},fetch:function(o){var i=this,t=new Image;t.onload=function(){i.largeWidth=t.width,i.largeHeight=t.height,i.startZoom(),i.currentImage=i.imageSrc,i.options.onZoomedImageLoaded(i.$elem)},i.setImageSource(t,o)},setImageSource:function(o,i){o.src=i},startZoom:function(){var i,t,e,n=this;n.nzWidth=n.$elem.width(),n.nzHeight=n.$elem.height(),n.isWindowActive=!1,n.isLensActive=!1,n.isTintActive=!1,n.overWindow=!1,n.options.imageCrossfade&&(n.zoomWrap=n.$elem.wrap('
'),n.$elem.css("position","absolute")),n.zoomLock=1,n.scrollingLock=!1,n.changeBgSize=!1,n.currentZoomLevel=n.options.zoomLevel,n.nzOffset=n.$elem.offset(),n.widthRatio=n.largeWidth/n.currentZoomLevel/n.nzWidth,n.heightRatio=n.largeHeight/n.currentZoomLevel/n.nzHeight,"window"===n.options.zoomType&&(n.zoomWindowStyle="overflow: hidden;background-position: 0px 0px;text-align:center;background-color: "+String(n.options.zoomWindowBgColour)+";width: "+String(n.options.zoomWindowWidth)+"px;height: "+String(n.options.zoomWindowHeight)+"px;float: left;background-size: "+n.largeWidth/n.currentZoomLevel+"px "+n.largeHeight/n.currentZoomLevel+"px;display: none;z-index:100;border: "+String(n.options.borderSize)+"px solid "+n.options.borderColour+";background-repeat: no-repeat;position: absolute;"),"inner"===n.options.zoomType&&(n.zoomWindowStyle=(i=n.$elem.css("border-left-width"),"overflow: hidden;margin-left: "+String(i)+";margin-top: "+String(i)+";background-position: 0px 0px;width: "+String(n.nzWidth)+"px;height: "+String(n.nzHeight)+"px;float: left;display: none;cursor:"+n.options.cursor+";px solid "+n.options.borderColour+";background-repeat: no-repeat;position: absolute;")),"window"===n.options.zoomType&&(n.lensStyle=(t=n.nzHeight
'),o(n.options.zoomContainerAppendTo).append(n.zoomContainer),n.options.containLensZoom&&"lens"===n.options.zoomType&&n.zoomContainer.css("overflow","hidden"),"inner"!==n.options.zoomType&&(n.zoomLens=o('
 
').appendTo(n.zoomContainer).click(function(){n.$elem.trigger("click")}),n.options.tint&&(n.tintContainer=o("
").addClass("tintContainer"),n.zoomTint=o('
'),n.zoomLens.wrap(n.tintContainer),n.zoomTintcss=n.zoomLens.after(n.zoomTint),n.zoomTintImage=o('').appendTo(n.zoomLens).click(function(){n.$elem.trigger("click")})));var s=isNaN(n.options.zoomWindowPosition)?"body":n.zoomContainer;function h(o){n.lastX===o.clientX&&n.lastY===o.clientY||(n.setPosition(o),n.currentLoc=o),n.lastX=o.clientX,n.lastY=o.clientY}n.zoomWindow=o('
 
').appendTo(s).click(function(){n.$elem.trigger("click")}),n.zoomWindowContainer=o("
").addClass("zoomWindowContainer").css("width",n.options.zoomWindowWidth),n.zoomWindow.wrap(n.zoomWindowContainer),"lens"===n.options.zoomType&&n.zoomLens.css("background-image",'url("'+n.imageSrc+'")'),"window"===n.options.zoomType&&n.zoomWindow.css("background-image",'url("'+n.imageSrc+'")'),"inner"===n.options.zoomType&&n.zoomWindow.css("background-image",'url("'+n.imageSrc+'")'),n.options.touchEnabled&&(n.$elem.bind("touchmove",function(o){o.preventDefault();var i=o.originalEvent.touches[0]||o.originalEvent.changedTouches[0];n.setPosition(i)}),n.zoomContainer.bind("touchmove",function(o){"inner"===n.options.zoomType&&n.showHideWindow("show"),o.preventDefault();var i=o.originalEvent.touches[0]||o.originalEvent.changedTouches[0];n.setPosition(i)}),n.zoomContainer.bind("touchend",function(o){n.showHideWindow("hide"),n.options.showLens&&n.showHideLens("hide"),n.options.tint&&"inner"!==n.options.zoomType&&n.showHideTint("hide")}),n.$elem.bind("touchend",function(o){n.showHideWindow("hide"),n.options.showLens&&n.showHideLens("hide"),n.options.tint&&"inner"!==n.options.zoomType&&n.showHideTint("hide")}),n.options.showLens&&(n.zoomLens.bind("touchmove",function(o){o.preventDefault();var i=o.originalEvent.touches[0]||o.originalEvent.changedTouches[0];n.setPosition(i)}),n.zoomLens.bind("touchend",function(o){n.showHideWindow("hide"),n.options.showLens&&n.showHideLens("hide"),n.options.tint&&"inner"!==n.options.zoomType&&n.showHideTint("hide")}))),n.$elem.bind("mousemove",function(o){!1===n.overWindow&&n.setElements("show"),n.lastX===o.clientX&&n.lastY===o.clientY||(n.setPosition(o),n.currentLoc=o),n.lastX=o.clientX,n.lastY=o.clientY}),n.zoomContainer.bind("click",n.options.onImageClick),n.zoomContainer.bind("mousemove",function(o){!1===n.overWindow&&n.setElements("show"),h(o)});var d=null;"inner"!==n.options.zoomType&&(d=n.zoomLens),n.options.tint&&"inner"!==n.options.zoomType&&(d=n.zoomTint),"inner"===n.options.zoomType&&(d=n.zoomWindow),d&&d.bind("mousemove",h),n.zoomContainer.add(n.$elem).mouseenter(function(){!1===n.overWindow&&n.setElements("show")}).mouseleave(function(){n.scrollLock||(n.setElements("hide"),n.options.onDestroy(n.$elem))}),"inner"!==n.options.zoomType&&n.zoomWindow.mouseenter(function(){n.overWindow=!0,n.setElements("hide")}).mouseleave(function(){n.overWindow=!1}),n.options.minZoomLevel?n.minZoomLevel=n.options.minZoomLevel:n.minZoomLevel=2*n.options.scrollZoomIncrement,n.options.scrollZoom&&n.zoomContainer.add(n.$elem).bind("wheel DOMMouseScroll MozMousePixelScroll",function(i){n.scrollLock=!0,clearTimeout(o.data(this,"timer")),o.data(this,"timer",setTimeout(function(){n.scrollLock=!1},250));var t=i.originalEvent.deltaY||-1*i.originalEvent.detail;return i.stopImmediatePropagation(),i.stopPropagation(),i.preventDefault(),t/120>0?n.currentZoomLevel>=n.minZoomLevel&&n.changeZoomLevel(n.currentZoomLevel-n.options.scrollZoomIncrement):(n.fullheight||n.fullwidth)&&n.options.mantainZoomAspectRatio||(n.options.maxZoomLevel?n.currentZoomLevel<=n.options.maxZoomLevel&&n.changeZoomLevel(parseFloat(n.currentZoomLevel)+n.options.scrollZoomIncrement):n.changeZoomLevel(parseFloat(n.currentZoomLevel)+n.options.scrollZoomIncrement)),!1})},setElements:function(o){if(!this.options.zoomEnabled)return!1;"show"===o&&this.isWindowSet&&("inner"===this.options.zoomType&&this.showHideWindow("show"),"window"===this.options.zoomType&&this.showHideWindow("show"),this.options.showLens&&this.showHideLens("show"),this.options.tint&&"inner"!==this.options.zoomType&&this.showHideTint("show")),"hide"===o&&("window"===this.options.zoomType&&this.showHideWindow("hide"),this.options.tint||this.showHideWindow("hide"),this.options.showLens&&this.showHideLens("hide"),this.options.tint&&this.showHideTint("hide"))},setPosition:function(o){var i,t;if(!this.options.zoomEnabled)return!1;(this.nzHeight=this.$elem.height(),this.nzWidth=this.$elem.width(),this.nzOffset=this.$elem.offset(),this.options.tint&&"inner"!==this.options.zoomType&&this.zoomTint.css({top:0,left:0}),this.options.responsive&&!this.options.scrollZoom)&&(this.options.showLens&&(i=this.nzHeightthis.nzHeight-e-2*this.options.lensBorderSize,this.Eloppos=this.mouseLeft<0+n,this.Eroppos=this.mouseLeft>this.nzWidth-n-2*this.options.lensBorderSize}"inner"===this.options.zoomType&&(this.Etoppos=this.mouseTopthis.nzHeight-this.nzHeight/2/this.heightRatio,this.Eloppos=this.mouseLeft<0+this.nzWidth/2/this.widthRatio,this.Eroppos=this.mouseLeft>this.nzWidth-this.nzWidth/2/this.widthRatio-2*this.options.lensBorderSize),this.mouseLeft<0||this.mouseTop<0||this.mouseLeft>this.nzWidth||this.mouseTop>this.nzHeight?this.setElements("hide"):(this.options.showLens&&(this.lensLeftPos=String(Math.floor(this.mouseLeft-this.zoomLens.width()/2)),this.lensTopPos=String(Math.floor(this.mouseTop-this.zoomLens.height()/2))),this.Etoppos&&(this.lensTopPos=0),this.Eloppos&&(this.windowLeftPos=0,this.lensLeftPos=0,this.tintpos=0),"window"===this.options.zoomType&&(this.Eboppos&&(this.lensTopPos=Math.max(this.nzHeight-this.zoomLens.height()-2*this.options.lensBorderSize,0)),this.Eroppos&&(this.lensLeftPos=this.nzWidth-this.zoomLens.width()-2*this.options.lensBorderSize)),"inner"===this.options.zoomType&&(this.Eboppos&&(this.lensTopPos=Math.max(this.nzHeight-2*this.options.lensBorderSize,0)),this.Eroppos&&(this.lensLeftPos=this.nzWidth-this.nzWidth-2*this.options.lensBorderSize)),"lens"===this.options.zoomType&&(this.windowLeftPos=String(-1*((o.pageX-this.nzOffset.left)*this.widthRatio-this.zoomLens.width()/2)),this.windowTopPos=String(-1*((o.pageY-this.nzOffset.top)*this.heightRatio-this.zoomLens.height()/2)),this.zoomLens.css("background-position",this.windowLeftPos+"px "+this.windowTopPos+"px"),this.changeBgSize&&(this.nzHeight>this.nzWidth?("lens"===this.options.zoomType&&this.zoomLens.css("background-size",this.largeWidth/this.newvalueheight+"px "+this.largeHeight/this.newvalueheight+"px"),this.zoomWindow.css("background-size",this.largeWidth/this.newvalueheight+"px "+this.largeHeight/this.newvalueheight+"px")):("lens"===this.options.zoomType&&this.zoomLens.css("background-size",this.largeWidth/this.newvaluewidth+"px "+this.largeHeight/this.newvaluewidth+"px"),this.zoomWindow.css("background-size",this.largeWidth/this.newvaluewidth+"px "+this.largeHeight/this.newvaluewidth+"px")),this.changeBgSize=!1),this.setWindowPosition(o)),this.options.tint&&"inner"!==this.options.zoomType&&this.setTintPosition(o),"window"===this.options.zoomType&&this.setWindowPosition(o),"inner"===this.options.zoomType&&this.setWindowPosition(o),this.options.showLens&&(this.fullwidth&&"lens"!==this.options.zoomType&&(this.lensLeftPos=0),this.zoomLens.css({left:this.lensLeftPos+"px",top:this.lensTopPos+"px"})))},showHideZoomContainer:function(o){"show"===o&&this.zoomContainer&&this.zoomContainer.show(),"hide"===o&&this.zoomContainer&&this.zoomContainer.hide()},showHideWindow:function(o){var i=this;"show"===o&&!i.isWindowActive&&i.zoomWindow&&(i.options.onShow(i),i.options.zoomWindowFadeIn?i.zoomWindow.stop(!0,!0,!1).fadeIn(i.options.zoomWindowFadeIn):i.zoomWindow.show(),i.isWindowActive=!0),"hide"===o&&i.isWindowActive&&(i.options.zoomWindowFadeOut?i.zoomWindow.stop(!0,!0).fadeOut(i.options.zoomWindowFadeOut,function(){i.loop&&(clearInterval(i.loop),i.loop=!1)}):i.zoomWindow.hide(),i.isWindowActive=!1)},showHideLens:function(o){"show"===o&&(this.isLensActive||(this.options.lensFadeIn&&this.zoomLens?this.zoomLens.stop(!0,!0,!1).fadeIn(this.options.lensFadeIn):this.zoomLens.show(),this.isLensActive=!0)),"hide"===o&&this.isLensActive&&(this.options.lensFadeOut?this.zoomLens.stop(!0,!0).fadeOut(this.options.lensFadeOut):this.zoomLens.hide(),this.isLensActive=!1)},showHideTint:function(o){"show"===o&&!this.isTintActive&&this.zoomTint&&(this.options.zoomTintFadeIn?this.zoomTint.css("opacity",this.options.tintOpacity).animate().stop(!0,!0).fadeIn("slow"):(this.zoomTint.css("opacity",this.options.tintOpacity).animate(),this.zoomTint.show()),this.isTintActive=!0),"hide"===o&&this.isTintActive&&(this.options.zoomTintFadeOut?this.zoomTint.stop(!0,!0).fadeOut(this.options.zoomTintFadeOut):this.zoomTint.hide(),this.isTintActive=!1)},setLensPosition:function(o){},setWindowPosition:function(i){var t=this;if(isNaN(t.options.zoomWindowPosition))t.externalContainer=o("#"+t.options.zoomWindowPosition),t.externalContainerWidth=t.externalContainer.width(),t.externalContainerHeight=t.externalContainer.height(),t.externalContainerOffset=t.externalContainer.offset(),t.windowOffsetTop=t.externalContainerOffset.top,t.windowOffsetLeft=t.externalContainerOffset.left;else switch(t.options.zoomWindowPosition){case 1:t.windowOffsetTop=t.options.zoomWindowOffsetY,t.windowOffsetLeft=+t.nzWidth;break;case 2:t.options.zoomWindowHeight>t.nzHeight?(t.windowOffsetTop=-1*(t.options.zoomWindowHeight/2-t.nzHeight/2),t.windowOffsetLeft=t.nzWidth):o.noop();break;case 3:t.windowOffsetTop=t.nzHeight-t.zoomWindow.height()-2*t.options.borderSize,t.windowOffsetLeft=t.nzWidth;break;case 4:t.windowOffsetTop=t.nzHeight,t.windowOffsetLeft=t.nzWidth;break;case 5:t.windowOffsetTop=t.nzHeight,t.windowOffsetLeft=t.nzWidth-t.zoomWindow.width()-2*t.options.borderSize;break;case 6:t.options.zoomWindowHeight>t.nzHeight?(t.windowOffsetTop=t.nzHeight,t.windowOffsetLeft=-1*(t.options.zoomWindowWidth/2-t.nzWidth/2+2*t.options.borderSize)):o.noop();break;case 7:t.windowOffsetTop=t.nzHeight,t.windowOffsetLeft=0;break;case 8:t.windowOffsetTop=t.nzHeight,t.windowOffsetLeft=-1*(t.zoomWindow.width()+2*t.options.borderSize);break;case 9:t.windowOffsetTop=t.nzHeight-t.zoomWindow.height()-2*t.options.borderSize,t.windowOffsetLeft=-1*(t.zoomWindow.width()+2*t.options.borderSize);break;case 10:t.options.zoomWindowHeight>t.nzHeight?(t.windowOffsetTop=-1*(t.options.zoomWindowHeight/2-t.nzHeight/2),t.windowOffsetLeft=-1*(t.zoomWindow.width()+2*t.options.borderSize)):o.noop();break;case 11:t.windowOffsetTop=t.options.zoomWindowOffsetY,t.windowOffsetLeft=-1*(t.zoomWindow.width()+2*t.options.borderSize);break;case 12:t.windowOffsetTop=-1*(t.zoomWindow.height()+2*t.options.borderSize),t.windowOffsetLeft=-1*(t.zoomWindow.width()+2*t.options.borderSize);break;case 13:t.windowOffsetTop=-1*(t.zoomWindow.height()+2*t.options.borderSize),t.windowOffsetLeft=0;break;case 14:t.options.zoomWindowHeight>t.nzHeight?(t.windowOffsetTop=-1*(t.zoomWindow.height()+2*t.options.borderSize),t.windowOffsetLeft=-1*(t.options.zoomWindowWidth/2-t.nzWidth/2+2*t.options.borderSize)):o.noop();break;case 15:t.windowOffsetTop=-1*(t.zoomWindow.height()+2*t.options.borderSize),t.windowOffsetLeft=t.nzWidth-t.zoomWindow.width()-2*t.options.borderSize;break;case 16:t.windowOffsetTop=-1*(t.zoomWindow.height()+2*t.options.borderSize),t.windowOffsetLeft=t.nzWidth;break;default:t.windowOffsetTop=t.options.zoomWindowOffsetY,t.windowOffsetLeft=t.nzWidth}t.isWindowSet=!0,t.windowOffsetTop=t.windowOffsetTop+t.options.zoomWindowOffsetY,t.windowOffsetLeft=t.windowOffsetLeft+t.options.zoomWindowOffsetX,t.zoomWindow.css({top:t.windowOffsetTop,left:t.windowOffsetLeft}),"inner"===t.options.zoomType&&t.zoomWindow.css({top:0,left:0}),t.windowLeftPos=String(-1*((i.pageX-t.nzOffset.left)*t.widthRatio-t.zoomWindow.width()/2)),t.windowTopPos=String(-1*((i.pageY-t.nzOffset.top)*t.heightRatio-t.zoomWindow.height()/2)),t.Etoppos&&(t.windowTopPos=0),t.Eloppos&&(t.windowLeftPos=0),t.Eboppos&&(t.windowTopPos=-1*(t.largeHeight/t.currentZoomLevel-t.zoomWindow.height())),t.Eroppos&&(t.windowLeftPos=-1*(t.largeWidth/t.currentZoomLevel-t.zoomWindow.width())),t.fullheight&&(t.windowTopPos=0),t.fullwidth&&(t.windowLeftPos=0),"window"!==t.options.zoomType&&"inner"!==t.options.zoomType||(1===t.zoomLock&&(t.widthRatio<=1&&(t.windowLeftPos=0),t.heightRatio<=1&&(t.windowTopPos=0)),"window"===t.options.zoomType&&(t.largeHeightt.nzWidth?("lens"===t.options.zoomType&&t.zoomLens.css("background-size",t.largeWidth/t.newvalueheight+"px "+t.largeHeight/t.newvalueheight+"px"),t.zoomWindow.css("background-size",t.largeWidth/t.newvalueheight+"px "+t.largeHeight/t.newvalueheight+"px")):("lens"!==t.options.zoomType&&t.zoomLens.css("background-size",t.largeWidth/t.newvaluewidth+"px "+t.largeHeight/t.newvalueheight+"px"),t.zoomWindow.css("background-size",t.largeWidth/t.newvaluewidth+"px "+t.largeHeight/t.newvaluewidth+"px")),t.changeBgSize=!1),t.zoomWindow.css("background-position",t.windowLeftPos+"px "+t.windowTopPos+"px"),t.scrollingLock=!1,t.loop=!1):Math.round(Math.abs(t.xp-t.windowLeftPos)+Math.abs(t.yp-t.windowTopPos))<1?(clearInterval(t.loop),t.zoomWindow.css("background-position",t.windowLeftPos+"px "+t.windowTopPos+"px"),t.loop=!1):(t.changeBgSize&&(t.nzHeight>t.nzWidth?("lens"===t.options.zoomType&&t.zoomLens.css("background-size",t.largeWidth/t.newvalueheight+"px "+t.largeHeight/t.newvalueheight+"px"),t.zoomWindow.css("background-size",t.largeWidth/t.newvalueheight+"px "+t.largeHeight/t.newvalueheight+"px")):("lens"!==t.options.zoomType&&t.zoomLens.css("background-size",t.largeWidth/t.newvaluewidth+"px "+t.largeHeight/t.newvaluewidth+"px"),t.zoomWindow.css("background-size",t.largeWidth/t.newvaluewidth+"px "+t.largeHeight/t.newvaluewidth+"px")),t.changeBgSize=!1),t.zoomWindow.css("background-position",t.xp+"px "+t.yp+"px"))},16))):(t.changeBgSize&&(t.nzHeight>t.nzWidth?("lens"===t.options.zoomType&&t.zoomLens.css("background-size",t.largeWidth/t.newvalueheight+"px "+t.largeHeight/t.newvalueheight+"px"),t.zoomWindow.css("background-size",t.largeWidth/t.newvalueheight+"px "+t.largeHeight/t.newvalueheight+"px")):("lens"===t.options.zoomType&&t.zoomLens.css("background-size",t.largeWidth/t.newvaluewidth+"px "+t.largeHeight/t.newvaluewidth+"px"),t.largeHeight/t.newvaluewidth
'),e.$elem.after(e.spinner)),e.options.onImageSwap(e.$elem),n.onload=function(){e.largeWidth=n.width,e.largeHeight=n.height,e.zoomImage=t,e.zoomWindow.css("background-size",e.largeWidth+"px "+e.largeHeight+"px"),e.swapAction(i,t)},e.setImageSource(n,t)},swapAction:function(i,t){var e=this,n=e.$elem.width(),s=e.$elem.height(),h=new Image;if(h.onload=function(){e.nzHeight=h.height,e.nzWidth=h.width,e.options.onImageSwapComplete(e.$elem),e.doneCallback()},e.setImageSource(h,i),e.currentZoomLevel=e.options.zoomLevel,e.options.maxZoomLevel=!1,"lens"===e.options.zoomType&&e.zoomLens.css("background-image",'url("'+t+'")'),"window"===e.options.zoomType&&e.zoomWindow.css("background-image",'url("'+t+'")'),"inner"===e.options.zoomType&&e.zoomWindow.css("background-image",'url("'+t+'")'),e.currentImage=t,e.options.imageCrossfade){var d=e.$elem,a=d.clone();if(e.$elem.attr("src",i),e.$elem.after(a),a.stop(!0).fadeOut(e.options.imageCrossfade,function(){o(this).remove()}),e.$elem.width("auto").removeAttr("width"),e.$elem.height("auto").removeAttr("height"),d.fadeIn(e.options.imageCrossfade),e.options.tint&&"inner"!==e.options.zoomType){var p=e.zoomTintImage,r=p.clone();e.zoomTintImage.attr("src",t),e.zoomTintImage.after(r),r.stop(!0).fadeOut(e.options.imageCrossfade,function(){o(this).remove()}),p.fadeIn(e.options.imageCrossfade),e.zoomTint.css({height:s,width:n})}e.zoomContainer.css({height:s,width:n}),"inner"===e.options.zoomType&&(e.options.constrainType||(e.zoomWrap.parent().css({height:s,width:n}),e.zoomWindow.css({height:s,width:n}))),e.options.imageCrossfade&&e.zoomWrap.css({height:s,width:n})}else e.$elem.attr("src",i),e.options.tint&&(e.zoomTintImage.attr("src",t),e.zoomTintImage.attr("height",s),e.zoomTintImage.css("height",s),e.zoomTint.css("height",s)),e.zoomContainer.css({height:s,width:n}),e.options.imageCrossfade&&e.zoomWrap.css({height:s,width:n});if(e.options.constrainType){if("height"===e.options.constrainType){var l={height:e.options.constrainSize,width:"auto"};e.zoomContainer.css(l),e.options.imageCrossfade?(e.zoomWrap.css(l),e.constwidth=e.zoomWrap.width()):(e.$elem.css(l),e.constwidth=n);var m={height:e.options.constrainSize,width:e.constwidth};"inner"===e.options.zoomType&&(e.zoomWrap.parent().css(m),e.zoomWindow.css(m)),e.options.tint&&(e.tintContainer.css(m),e.zoomTint.css(m),e.zoomTintImage.css(m))}if("width"===e.options.constrainType){var w={height:"auto",width:e.options.constrainSize};e.zoomContainer.css(w),e.options.imageCrossfade?(e.zoomWrap.css(w),e.constheight=e.zoomWrap.height()):(e.$elem.css(w),e.constheight=s);var g={height:e.constheight,width:e.options.constrainSize};"inner"===e.options.zoomType&&(e.zoomWrap.parent().css(g),e.zoomWindow.css(g)),e.options.tint&&(e.tintContainer.css(g),e.zoomTint.css(g),e.zoomTintImage.css(g))}}},doneCallback:function(){var o,i;(this.options.loadingIcon&&this.spinner.hide(),this.nzOffset=this.$elem.offset(),this.nzWidth=this.$elem.width(),this.nzHeight=this.$elem.height(),this.currentZoomLevel=this.options.zoomLevel,this.widthRatio=this.largeWidth/this.nzWidth,this.heightRatio=this.largeHeight/this.nzHeight,"window"===this.options.zoomType)&&(o=this.nzHeight(t=parseFloat(this.largeHeight/this.nzHeight).toFixed(2))&&(i=t),i>(e=parseFloat(this.largeWidth/this.nzWidth).toFixed(2))&&(i=e),t<=i?(this.heightRatio=this.largeHeight/i/this.nzHeight,this.newvalueheight=i>t?t:i,this.fullheight=!0):(this.heightRatio=this.largeHeight/i/this.nzHeight,this.newvalueheight=i>t?t:i,this.fullheight=!1),e<=i?(this.widthRatio=this.largeWidth/i/this.nzWidth,this.newvaluewidth=i>e?e:i,this.fullwidth=!0):(this.widthRatio=this.largeWidth/i/this.nzWidth,this.newvaluewidth=i,this.fullwidth=!1));var n=!1;"inner"===this.options.zoomType&&(this.nzWidth>=this.nzHeight&&(this.newvaluewidth<=e?n=!0:(n=!1,this.fullheight=!0,this.fullwidth=!0)),this.nzHeight>this.nzWidth&&(this.newvaluewidth<=e?n=!0:(n=!1,this.fullheight=!0,this.fullwidth=!0))),"inner"!==this.options.zoomType&&(n=!0),n&&(this.zoomLock=0,this.changeZoom=!0,this.options.zoomWindowHeight/this.heightRatio<=this.nzHeight&&(this.currentZoomLevel=this.newvalueheight,"lens"!==this.options.zoomType&&"inner"!==this.options.zoomType&&(this.changeBgSize=!0,this.zoomLens.css("height",String(this.options.zoomWindowHeight/this.heightRatio)+"px")),"lens"!==this.options.zoomType&&"inner"!==this.options.zoomType||(this.changeBgSize=!0)),this.options.zoomWindowWidth/this.widthRatio<=this.nzWidth&&("inner"!==this.options.zoomType&&this.newvaluewidth>this.newvalueheight&&(this.currentZoomLevel=this.newvaluewidth),"lens"!==this.options.zoomType&&"inner"!==this.options.zoomType&&(this.changeBgSize=!0,this.zoomLens.css("width",String(this.options.zoomWindowWidth/this.widthRatio)+"px")),"lens"!==this.options.zoomType&&"inner"!==this.options.zoomType||(this.changeBgSize=!0)),"inner"===this.options.zoomType&&(this.changeBgSize=!0,this.nzWidth>this.nzHeight&&(this.currentZoomLevel=this.newvaluewidth),this.nzHeight>this.nzWidth&&(this.currentZoomLevel=this.newvaluewidth))),this.setPosition(this.currentLoc)},closeAll:function(){this.zoomWindow&&this.zoomWindow.hide(),this.zoomLens&&this.zoomLens.hide(),this.zoomTint&&this.zoomTint.hide()},changeState:function(o){"enable"===o&&(this.options.zoomEnabled=!0),"disable"===o&&(this.options.zoomEnabled=!1)},responsiveConfig:function(i){return i.respond&&i.respond.length>0?o.extend({},i,this.configByScreenWidth(i)):i},configByScreenWidth:function(t){var e=o(i).width(),n=o.grep(t.respond,function(o){var i=o.range.split("-");return e>=i[0]&&e<=i[1]});return n.length>0?n[0]:t}};o.fn.ezPlus=function(i){return this.each(function(){var t=Object.create(n);t.init(i,this),o.data(this,"ezPlus",t)})},o.fn.ezPlus.options={borderColour:"#888",borderSize:4,constrainSize:!1,constrainType:!1,containLensZoom:!1,cursor:"inherit",debug:!1,easing:!1,easingAmount:12,enabled:!0,gallery:!1,galleryActiveClass:"zoomGalleryActive",gallerySelector:!1,galleryItem:"a",imageCrossfade:!1,lensBorderColour:"#000",lensBorderSize:1,lensColour:"white",lensFadeIn:!1,lensFadeOut:!1,lensOpacity:.4,lensShape:"square",lensSize:200,lenszoom:!1,loadingIcon:!1,mantainZoomAspectRatio:!1,maxZoomLevel:!1,minZoomLevel:!1,onComplete:o.noop,onDestroy:o.noop,onImageClick:o.noop,onImageSwap:o.noop,onImageSwapComplete:o.noop,onShow:o.noop,onZoomedImageLoaded:o.noop,preloading:1,respond:[],responsive:!0,scrollZoom:!1,scrollZoomIncrement:.1,showLens:!0,tint:!1,tintColour:"#333",tintOpacity:.4,touchEnabled:!0,zoomActivation:"hover",zoomContainerAppendTo:"body",zoomLevel:1,zoomTintFadeIn:!1,zoomTintFadeOut:!1,zoomType:"window",zoomWindowAlwaysShow:!1,zoomWindowBgColour:"#fff",zoomWindowFadeIn:!1,zoomWindowFadeOut:!1,zoomWindowHeight:400,zoomWindowOffsetX:0,zoomWindowOffsetY:0,zoomWindowPosition:1,zoomWindowWidth:400,zoomEnabled:!0,zIndex:999}}(jQuery,window,document); \ No newline at end of file