{"version":3,"file":"/pc/all/libs/lightbox/viewer.js.map","sources":["/pc/all/libs/lightbox/viewer.js"],"sourcesContent":["/* global define */\r\n\r\n// TODO: external controls like carousel?\r\n// TODO: Add swipe next/previous when zoomed out?\r\n\r\n(function(factory) {\r\n if (typeof define === \"function\" && define.amd) {\r\n define([\r\n \"jquery\",\r\n \"./core\",\r\n \"./transition\"\r\n ], factory);\r\n } else {\r\n factory(jQuery, Formstone);\r\n }\r\n }(function($, Formstone) {\r\n\r\n \"use strict\";\r\n\r\n /**\r\n * @method private\r\n * @name setup\r\n * @description Setup plugin.\r\n */\r\n\r\n function setup() {\r\n scroll();\r\n $Window.on(\"scroll\", scroll);\r\n $Body = Formstone.$body;\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name resize\r\n * @description Handles window resize\r\n */\r\n\r\n function resize() {\r\n Functions.iterate.call($Instances, resizeInstance);\r\n // Functions.iterate.call($LazyInstances, cacheScrollPosition);\r\n // Functions.iterate.call($LazyInstances, checkScrollPosition);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name scroll\r\n * @description Handles window scroll\r\n */\r\n\r\n function scroll() {\r\n ScrollTop = $Window.scrollTop() + Formstone.windowHeight;\r\n\r\n if (ScrollTop < 0) {\r\n ScrollTop = 0;\r\n }\r\n\r\n // Functions.iterate.call($LazyInstances, checkScrollPosition);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name raf\r\n * @description Handles request animation frame\r\n */\r\n\r\n function raf() {\r\n Functions.iterate.call($Instances, renderRAF);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name cacheInstances\r\n * @description Caches active instances\r\n */\r\n\r\n function cacheInstances() {\r\n $Instances = $(Classes.base);\r\n // $LazyInstances = $(Classes.lazy);\r\n\r\n // Functions.iterate.call($LazyInstances, cacheScrollPosition);\r\n\r\n if ($Instances.length) {\r\n Functions.lockViewport(Namespace);\r\n } else {\r\n Functions.unlockViewport(Namespace);\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name construct\r\n * @description Builds instance.\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function construct(data) {\r\n var $image,\r\n imageData,\r\n html = '',\r\n controlPrevClasses = [RawClasses.control, RawClasses.control_previous].join(\" \"),\r\n controlNextClasses = [RawClasses.control, RawClasses.control_next].join(\" \"),\r\n controlZoomInClasses = [RawClasses.control, RawClasses.control_zoom_in].join(\" \"),\r\n controlZoomOutClasses = [RawClasses.control, RawClasses.control_zoom_out].join(\" \");\r\n\r\n data.thisClasses = [RawClasses.base, RawClasses.loading, data.customClass, data.theme];\r\n data.images = [];\r\n data.source = false;\r\n data.gallery = false;\r\n data.tapTimer = null;\r\n data.action = false;\r\n data.isRendering = false;\r\n data.isZooming = false;\r\n data.isAnimating = false;\r\n\r\n data.keyDownTime = 1;\r\n\r\n data.$images = this.find(\"img\").addClass(RawClasses.source);\r\n data.index = 0;\r\n data.total = data.$images.length - 1;\r\n\r\n // Check custom controls\r\n data.customControls = ($.type(data.controls) === \"object\" && data.controls.zoom_in && data.controls.zoom_out);\r\n\r\n if (data.$images.length > 1) {\r\n data.gallery = true;\r\n data.thisClasses.push(RawClasses.gallery);\r\n\r\n // Requie zoom for gallery custom controls\r\n if (data.customControls && (!data.controls.previous || !data.controls.next)) {\r\n data.customControls = false;\r\n }\r\n }\r\n\r\n for (var i = 0; i < data.$images.length; i++) {\r\n $image = data.$images.eq(i);\r\n data.images.push($image.attr(\"src\"));\r\n }\r\n\r\n html += '
';\r\n html += '
';\r\n html += '
';\r\n html += '
'; // wrapper\r\n\r\n if (data.controls && !data.customControls) {\r\n html += '
';\r\n html += '';\r\n html += '';\r\n html += '';\r\n html += '';\r\n html += '
'; // controls\r\n }\r\n\r\n this.addClass(data.thisClasses.join(\" \"))\r\n .prepend(html);\r\n\r\n data.$wrapper = this.find(Classes.wrapper);\r\n data.$viewport = this.find(Classes.viewport);\r\n\r\n if (data.customControls) {\r\n data.$controls = $(data.controls.container).addClass([RawClasses.controls, RawClasses.controls_custom].join(\" \"));\r\n data.$controlPrevious = $(data.controls.previous).addClass(controlPrevClasses);\r\n data.$controlNext = $(data.controls.next).addClass(controlNextClasses);\r\n data.$controlZoomIn = $(data.controls.zoom_in).addClass(controlZoomInClasses);\r\n data.$controlZoomOut = $(data.controls.zoom_out).addClass(controlZoomOutClasses);\r\n } else {\r\n data.$controls = this.find(Classes.controls);\r\n data.$controlPrevious = this.find(Classes.control_previous);\r\n data.$controlNext = this.find(Classes.control_next);\r\n data.$controlZoomIn = this.find(Classes.control_zoom_in);\r\n data.$controlZoomOut = this.find(Classes.control_zoom_out);\r\n }\r\n\r\n data.$controlItems = data.$controlPrevious.add(data.$controlNext);\r\n data.$controlZooms = data.$controlZoomIn.add(data.$controlZoomOut);\r\n\r\n cacheInstances();\r\n\r\n data.$controlItems.on(Events.click, data, advanceGallery);\r\n data.$controlZooms.on([Events.touchStart, Events.mouseDown].join(\" \"), data, onZoomStart)\r\n .on([Events.touchEnd, Events.mouseUp].join(\" \"), data, onClearZoom);\r\n\r\n // if (data.lazy) {\r\n // checkScrollPosition(data);\r\n // } else {\r\n loadImage(data, data.images[data.index], true);\r\n // }\r\n\r\n updateControls(data);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name destruct\r\n * @description Tears down instance.\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function destruct(data) {\r\n data.$wrapper.remove();\r\n\r\n data.$image.removeClass(RawClasses.source);\r\n\r\n if (data.controls && !data.customControls) {\r\n data.$controls.remove();\r\n }\r\n\r\n if (data.customControls) {\r\n data.$controls.removeClass([RawClasses.controls, RawClasses.controls_custom].join(\" \"));\r\n data.$controlItems.off(Events.click).removeClass([RawClasses.control, RawClasses.control_previous, RawClasses.control_next].join(\" \"));\r\n data.$controlZooms.off([Events.touchStart, Events.mouseDown].join(\" \"))\r\n .off([Events.touchStart, Events.mouseDown].join(\" \"))\r\n .off([Events.touchEnd, Events.mouseUp].join(\" \"))\r\n .removeClass([RawClasses.control, RawClasses.control_zoom_in, RawClasses.control_zoom_out].join(\" \"));\r\n }\r\n\r\n this.removeClass(data.thisClasses.join(\" \"))\r\n .off(Events.namespace);\r\n\r\n cacheInstances();\r\n }\r\n\r\n /**\r\n * @method\r\n * @name load\r\n * @description Loads source image\r\n * @param source [string OR array] \"Source image (string) or array of images (array)\"\r\n * @example $(\".target\").viewer(\"load\", \"path/to/image.jpg\");\r\n * @example $(\".target\").viewer(\"load\", [\"path/to/image-1.jpg\",\"path/to/image-2.jpg\"]);\r\n */\r\n\r\n function load(data, source) {\r\n data.index = 0;\r\n\r\n if (typeof source === \"string\") {\r\n data.total = 0;\r\n data.images = [source];\r\n data.gallery = false;\r\n\r\n data.$el.removeClass(RawClasses.gallery);\r\n } else {\r\n data.total = source.length - 1;\r\n data.images = source;\r\n\r\n if (source.length > 1) {\r\n data.gallery = true;\r\n data.$el.addClass(RawClasses.gallery);\r\n }\r\n\r\n source = data.images[data.index];\r\n }\r\n\r\n unloadImage(data, function() {\r\n loadImage(data, source);\r\n });\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name loadInitialImage\r\n * @description Loads first source image\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function loadInitialImage(data) {\r\n loadImage(data, data.images[data.index]);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name loadImage\r\n * @description Loads source image\r\n * @param data [object] \"Instance data\"\r\n * @param source [string] \"Source image\"\r\n * @param initialLoad [boolean] \"Is initial load\"\r\n */\r\n\r\n function loadImage(data, source, initialLoad) {\r\n if (!data.isAnimating) {\r\n data.isAnimating = true;\r\n\r\n data.$container = $('
');\r\n data.$image = data.$container.find(\"img\");\r\n\r\n data.$viewport.append(data.$container);\r\n\r\n // Load image\r\n data.$image.one(Events.load, function() {\r\n onImageReady(data);\r\n\r\n data.isAnimating = false;\r\n\r\n // Transition in\r\n data.$container.fsTransition({\r\n property: \"opacity\"\r\n },\r\n function() {\r\n // Loaded\r\n });\r\n\r\n data.$el.removeClass(RawClasses.loading);\r\n\r\n data.$container.fsTouch({\r\n pan: true,\r\n scale: true\r\n }).on(Events.scaleStart, data, onScaleStart)\r\n .on(Events.scaleEnd, data, onScaleEnd)\r\n .on(Events.scale, data, onScale);\r\n\r\n data.$el.trigger(Events.loaded);\r\n }).one(Events.error, data, loadError)\r\n .attr(\"src\", source)\r\n .addClass(RawClasses.image);\r\n\r\n // Check if image is cached\r\n if (data.$image[0].complete || data.$image[0].readyState === 4) {\r\n data.$image.trigger(Events.load);\r\n }\r\n\r\n data.source = source;\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name loadError\r\n * @description Error when resource fails to load.\r\n */\r\n\r\n function loadError(e) {\r\n var data = e.data;\r\n\r\n data.$el.trigger(Events.error);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name onImageReady\r\n * @description Sets up image data\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n // on initial load\r\n function onImageReady(data) {\r\n // Cache image properties\r\n // First for container\r\n cacheImageProps(data);\r\n\r\n // Cache viewport properties\r\n cacheViewportProps(data);\r\n\r\n // Set initial container position\r\n data.containerTop = (data.viewportHeight / 2);\r\n data.containerLeft = (data.viewportWidth / 2);\r\n\r\n // Cache image min max\r\n cacheImageMinMax(data);\r\n\r\n // Set initial image size\r\n data.imageHeight = data.naturalHeight;\r\n data.imageWidth = data.naturalWidth;\r\n\r\n // Size the image to fit into the viewport\r\n fitToViewport(data);\r\n\r\n // Cache container min max\r\n cacheContainerMinMax(data);\r\n\r\n // Cache image top left\r\n cacheImageTopLeft(data);\r\n\r\n // Cache last props\r\n cacheLastProps(data);\r\n\r\n // Cache render props\r\n cacheRenderProps(data);\r\n\r\n // Update dom\r\n var props = {\r\n containerTop: data.containerTop,\r\n containerLeft: data.containerLeft,\r\n imageHeight: data.imageHeight,\r\n imageWidth: data.imageWidth,\r\n imageTop: data.imageTop,\r\n imageLeft: data.imageLeft,\r\n };\r\n\r\n setSizeAndPosition(data, props);\r\n\r\n data.isRendering = true;\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name cacheImageProps\r\n * @description Caches image properties\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function cacheImageProps(data) {\r\n var naturalSize = calculateNaturalSize(data.$image);\r\n\r\n data.naturalHeight = naturalSize.naturalHeight;\r\n data.naturalWidth = naturalSize.naturalWidth;\r\n\r\n data.ratioHorizontal = data.naturalHeight / data.naturalWidth;\r\n data.ratioVertical = data.naturalWidth / data.naturalHeight;\r\n\r\n data.isWide = (data.naturalWidth > data.naturalHeight);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name cacheViewportProps\r\n * @description Caches viewport properties\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function cacheViewportProps(data) {\r\n data.viewportHeight = data.$viewport.outerHeight();\r\n data.viewportWidth = data.$viewport.outerWidth();\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name cacheContainerProps\r\n * @description Caches container properties\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function cacheContainerMinMax(data) {\r\n if (data.imageHeight <= data.viewportHeight) {\r\n data.containerMinTop = (data.viewportHeight / 2);\r\n data.containerMaxTop = (data.viewportHeight / 2);\r\n } else {\r\n data.containerMinTop = data.viewportHeight - (data.imageHeight / 2);\r\n data.containerMaxTop = (data.imageHeight / 2);\r\n }\r\n\r\n if (data.imageWidth <= data.viewportWidth) {\r\n data.containerMinLeft = (data.viewportWidth / 2);\r\n data.containerMaxLeft = (data.viewportWidth / 2);\r\n } else {\r\n data.containerMinLeft = data.viewportWidth - (data.imageWidth / 2);\r\n data.containerMaxLeft = (data.imageWidth / 2);\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name cacheImageMinMax\r\n * @description Caches image min and max based on viewport and size\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function cacheImageMinMax(data) {\r\n // Set min\r\n if (data.isWide) {\r\n //WIDE\r\n data.imageMinWidth = data.viewportWidth;\r\n data.imageMinHeight = data.imageMinWidth * data.ratioHorizontal;\r\n\r\n if (data.imageMinHeight > data.viewportHeight) {\r\n data.imageMinHeight = data.viewportHeight;\r\n data.imageMinWidth = data.imageMinHeight * data.ratioVertical;\r\n }\r\n } else {\r\n //TALL\r\n data.imageMinHeight = data.viewportHeight;\r\n data.imageMinWidth = data.imageMinHeight * data.ratioVertical;\r\n\r\n if (data.imageMinWidth > data.viewportWidth) {\r\n data.imageMinWidth = data.viewportWidth;\r\n data.imageMinHeight = data.imageMinWidth * data.ratioHorizontal;\r\n }\r\n }\r\n\r\n // Check natural max against new min\r\n if (data.imageMinWidth > data.naturalWidth || data.imageMinHeight > data.naturalHeight) {\r\n data.imageMinHeight = data.naturalHeight;\r\n data.imageMinWidth = data.naturalWidth;\r\n }\r\n\r\n // Set max\r\n data.imageMaxHeight = data.naturalHeight;\r\n data.imageMaxWidth = data.naturalWidth;\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name cacheImageTopLeft\r\n * @description Caches image top and left based on viewport and size\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function cacheImageTopLeft(data) {\r\n data.imageTop = -(data.imageHeight / 2);\r\n data.imageLeft = -(data.imageWidth / 2);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name cacheLastProps\r\n * @description Caches last container and image properties\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function cacheLastProps(data) {\r\n data.lastContainerTop = data.containerTop;\r\n data.lastContainerLeft = data.containerLeft;\r\n\r\n data.lastImageHeight = data.imageHeight;\r\n data.lastImageWidth = data.imageWidth;\r\n\r\n data.lastImageTop = data.imageTop;\r\n data.lastImageLeft = data.imageLeft;\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name cacheRenderProps\r\n * @description Caches container and image render properties\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function cacheRenderProps(data) {\r\n data.renderContainerTop = data.lastContainerTop;\r\n data.renderContainerLeft = data.lastContainerLeft;\r\n\r\n data.renderImageTop = data.lastImageTop;\r\n data.renderImageLeft = data.lastImageLeft;\r\n\r\n data.renderImageHeight = data.lastImageHeight;\r\n data.renderImageWidth = data.lastImageWidth;\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name fitToViewport\r\n * @description Fits image to viewport size\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function fitToViewport(data) {\r\n data.imageHeight = data.imageMinHeight;\r\n data.imageWidth = data.imageMinWidth;\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name checkImageMinMax\r\n * @description Checks image properties against min and max\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n // on scale\r\n function checkImageMinMax(data) {\r\n if (data.imageHeight < data.imageMinHeight) {\r\n data.imageHeight = data.imageMinHeight;\r\n }\r\n if (data.imageHeight > data.imageMaxHeight) {\r\n data.imageHeight = data.imageMaxHeight;\r\n }\r\n\r\n if (data.imageWidth < data.imageMinWidth) {\r\n data.imageWidth = data.imageMinWidth;\r\n }\r\n if (data.imageWidth > data.imageMaxWidth) {\r\n data.imageWidth = data.imageMaxWidth;\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name checkContainerTopLeft\r\n * @description Checks container properties against top and left\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function checkContainerTopLeft(data) {\r\n if (data.containerTop < data.containerMinTop) {\r\n data.containerTop = data.containerMinTop;\r\n }\r\n if (data.containerTop > data.containerMaxTop) {\r\n data.containerTop = data.containerMaxTop;\r\n }\r\n\r\n if (data.containerLeft < data.containerMinLeft) {\r\n data.containerLeft = data.containerMinLeft;\r\n }\r\n if (data.containerLeft > data.containerMaxLeft) {\r\n data.containerLeft = data.containerMaxLeft;\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name checkDoubleTap\r\n * @description Checks is double tapping\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function checkDoubleTap(data) {\r\n if (data.tapTimer === null) {\r\n data.tapTimer = Functions.startTimer(data.tapTimer, 500, function() {\r\n clearDoubleTap(data);\r\n });\r\n } else {\r\n clearDoubleTap(data);\r\n onImageZoom(data);\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name clearDoubleTap\r\n * @description Clears double tap timer\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function clearDoubleTap(data) {\r\n Functions.clearTimer(data.tapTimer);\r\n data.tapTimer = null;\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name setSizeAndPosition\r\n * @description Updates image and container DOM\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function setSizeAndPosition(data, props) {\r\n if (Formstone.transform) {\r\n var scaleX = props.imageWidth / data.naturalWidth,\r\n scaleY = props.imageHeight / data.naturalHeight;\r\n\r\n data.$container.css(Formstone.transform, \"translate3d(\" + props.containerLeft + \"px, \" + props.containerTop + \"px, 0)\");\r\n data.$image.css(Formstone.transform, \"translate3d(-50%, -50%, 0) scale(\" + scaleX + \",\" + scaleY + \")\");\r\n } else {\r\n data.$container.css({\r\n top: props.containerTop,\r\n left: props.containerLeft\r\n });\r\n\r\n data.$image.css({\r\n height: props.imageHeight,\r\n width: props.imageWidth,\r\n top: props.imageTop,\r\n left: props.imageLeft\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name onScaleStart\r\n * @description Handles scale start event\r\n * @param e [object] \"Event data\"\r\n */\r\n\r\n function onScaleStart(e) {\r\n var data = e.data;\r\n\r\n // Check double tap\r\n checkDoubleTap(data);\r\n\r\n // Cache previous values\r\n cacheLastProps(data);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name onScale\r\n * @description Handles scale event\r\n * @param e [object] \"Event data\"\r\n */\r\n\r\n function onScale(e) {\r\n var data = e.data;\r\n\r\n // Clear double tap\r\n clearDoubleTap(data);\r\n\r\n data.isRendering = false;\r\n data.isZooming = false;\r\n\r\n var zoomed = (data.imageHeight > data.imageMinHeight + 1);\r\n\r\n // Change container position\r\n data.containerTop = data.lastContainerTop + e.deltaY;\r\n data.containerLeft = data.lastContainerLeft + e.deltaX;\r\n\r\n /*\r\n var diffX = data.lastContainerLeft - data.containerLeft,\r\n diffY = data.lastContainerTop - data.containerTop;\r\n\r\n data.containerLeft -= diffX;\r\n data.containerTop -= diffY;\r\n */\r\n\r\n // Change image size\r\n data.imageHeight = data.lastImageHeight * e.scale;\r\n data.imageWidth = data.lastImageWidth * e.scale;\r\n\r\n // Cache container min max\r\n cacheContainerMinMax(data);\r\n\r\n // Check container top left\r\n checkContainerTopLeft(data);\r\n\r\n // Check image min max\r\n checkImageMinMax(data);\r\n\r\n // Cache image top left\r\n cacheImageTopLeft(data);\r\n\r\n // Update dom\r\n var props = {\r\n containerTop: data.containerTop,\r\n containerLeft: data.containerLeft,\r\n imageHeight: data.imageHeight,\r\n imageWidth: data.imageWidth,\r\n imageTop: data.imageTop,\r\n imageLeft: data.imageLeft,\r\n };\r\n\r\n setSizeAndPosition(data, props);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name onScaleEnd\r\n * @description Handles scale end event\r\n * @param e [object] \"Event data\"\r\n */\r\n\r\n function onScaleEnd(e) {\r\n var data = e.data;\r\n\r\n if (!data.isZooming) {\r\n // Cache last properties\r\n cacheLastProps(data);\r\n\r\n // Cache rander properties\r\n cacheRenderProps(data);\r\n\r\n data.isRendering = true;\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name onImageZoom\r\n * @description Zooms image in or out depending on current size\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function onImageZoom(data) {\r\n var zoomed = (data.imageHeight > data.imageMinHeight + 1);\r\n\r\n data.isZooming = true;\r\n\r\n // Cache last properties\r\n cacheLastProps(data);\r\n\r\n // Cache rander properties\r\n cacheRenderProps(data);\r\n\r\n if (zoomed) {\r\n // zoomed in (go to min)\r\n data.imageHeight = data.imageMinHeight;\r\n data.imageWidth = data.imageMinWidth;\r\n } else {\r\n // zoomed out (go to max)\r\n data.imageHeight = data.imageMaxHeight;\r\n data.imageWidth = data.imageMaxWidth;\r\n }\r\n\r\n // Cache container min max\r\n cacheContainerMinMax(data);\r\n\r\n // Check container top left\r\n checkContainerTopLeft(data);\r\n\r\n // Cache image top left\r\n cacheImageTopLeft(data);\r\n\r\n data.isRendering = true;\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name onZoomStart\r\n * @description Handle zoom start\r\n * @param e [object] \"Event data\"\r\n */\r\n\r\n function onZoomStart(e) {\r\n Functions.killEvent(e);\r\n\r\n var $target = $(e.currentTarget),\r\n data = e.data,\r\n direction = ($target.hasClass(RawClasses.control_zoom_out)) ? 'out' : 'in';\r\n\r\n if (direction === 'out') {\r\n onZoomOut(data);\r\n } else {\r\n onZoomIn(data);\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name onZoomIn\r\n * @description Handle zoom in\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function onZoomIn(data) {\r\n data.keyDownTime = 1;\r\n data.action = 'zoom_in';\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name onZoomOut\r\n * @description Handle zoom out\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function onZoomOut(data) {\r\n data.keyDownTime = 1;\r\n data.action = 'zoom_out';\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name onClearZoom\r\n * @description Handle clear zoom\r\n * @param e [object] \"Event data\"\r\n */\r\n\r\n function onClearZoom(e) {\r\n var data = e.data;\r\n\r\n data.action = false;\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name renderRAF\r\n * @description Updates DOM based on animation values\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function renderRAF(data) {\r\n if (data.isRendering) {\r\n if (data.action) {\r\n data.keyDownTime += data.zoomIncrement;\r\n\r\n var delta = ((data.action === \"zoom_out\") ? -1 : 1) * Math.round((data.imageWidth * data.keyDownTime) - data.imageWidth);\r\n\r\n if (delta > data.zoomDelta) {\r\n delta = data.zoomDelta;\r\n }\r\n\r\n if (data.isWide) {\r\n data.imageWidth += delta;\r\n data.imageHeight = Math.round(data.imageWidth / data.ratioVertical);\r\n } else {\r\n data.imageHeight += delta;\r\n data.imageWidth = Math.round(data.imageHeight / data.ratioHorizontal);\r\n }\r\n\r\n // Check image min max\r\n checkImageMinMax(data);\r\n\r\n // Cache image top left\r\n cacheImageTopLeft(data);\r\n\r\n // Cache container min max\r\n cacheContainerMinMax(data);\r\n\r\n // Check container top left\r\n checkContainerTopLeft(data);\r\n }\r\n\r\n data.renderContainerTop += Math.round((data.containerTop - data.renderContainerTop) * data.zoomEnertia);\r\n data.renderContainerLeft += Math.round((data.containerLeft - data.renderContainerLeft) * data.zoomEnertia);\r\n\r\n data.renderImageTop += Math.round((data.imageTop - data.renderImageTop) * data.zoomEnertia);\r\n data.renderImageLeft += Math.round((data.imageLeft - data.renderImageLeft) * data.zoomEnertia);\r\n\r\n data.renderImageHeight += Math.round((data.imageHeight - data.renderImageHeight) * data.zoomEnertia);\r\n data.renderImageWidth += Math.round((data.imageWidth - data.renderImageWidth) * data.zoomEnertia);\r\n\r\n // Update DOM\r\n\r\n var props = {\r\n containerTop: data.renderContainerTop,\r\n containerLeft: data.renderContainerLeft,\r\n imageHeight: data.renderImageHeight,\r\n imageWidth: data.renderImageWidth,\r\n imageTop: data.renderImageTop,\r\n imageLeft: data.renderImageLeft,\r\n };\r\n\r\n setSizeAndPosition(data, props);\r\n }\r\n }\r\n\r\n /**\r\n * @method\r\n * @name unload\r\n * @description Unloads current image\r\n * @example $(\".target\").viewer(\"unload\");\r\n */\r\n\r\n function unload(data) {\r\n unloadImage(data);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name unloadImage\r\n * @description Unloads current image\r\n * @param data [object] \"Instance data\"\r\n * @param callback [function] \"Callback function\"\r\n */\r\n\r\n function unloadImage(data, callback) {\r\n if (!data.isAnimating) {\r\n clearDoubleTap(data);\r\n\r\n data.isAnimating = true;\r\n data.isRendering = false;\r\n data.isZooming = false;\r\n\r\n clearTouch(data);\r\n\r\n data.$container.fsTransition({\r\n property: \"opacity\"\r\n },\r\n function() {\r\n data.isAnimating = false;\r\n\r\n data.$container.remove();\r\n\r\n if (typeof callback === \"function\") {\r\n callback.call(window, data);\r\n }\r\n });\r\n\r\n data.$el.addClass(RawClasses.loading);\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name advanceGallery\r\n * @description Advances gallery\r\n * @param e [object] \"Event data\"\r\n */\r\n\r\n function advanceGallery(e) {\r\n Functions.killEvent(e);\r\n\r\n var $target = $(e.currentTarget),\r\n data = e.data,\r\n index = data.index + (($target.hasClass(RawClasses.control_next)) ? 1 : -1);\r\n\r\n if (!data.isAnimating) {\r\n if (index < 0) {\r\n index = 0;\r\n }\r\n\r\n if (index > data.total) {\r\n index = data.total;\r\n }\r\n\r\n if (index !== data.index) {\r\n data.index = index;\r\n\r\n unloadImage(data, function() {\r\n loadImage(data, data.images[data.index]);\r\n });\r\n }\r\n\r\n updateControls(data);\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name updateControls\r\n * @description Update control states\r\n * @param data [object] Instance data\r\n */\r\n\r\n function updateControls(data) {\r\n data.$controlItems.removeClass(RawClasses.control_disabled);\r\n\r\n if (data.index === 0) {\r\n data.$controlPrevious.addClass(RawClasses.control_disabled);\r\n }\r\n if (data.index === data.images.length - 1) {\r\n data.$controlNext.addClass(RawClasses.control_disabled);\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name resize\r\n * @description Resize target instance\r\n * @example $(\".target\").viewer(\"resize\");\r\n */\r\n\r\n /**\r\n * @method private\r\n * @name resizeInstance\r\n * @description Handle window resize event\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function resizeInstance(data) {\r\n cacheViewportProps(data);\r\n\r\n cacheContainerMinMax(data);\r\n\r\n cacheImageMinMax(data);\r\n\r\n cacheImageTopLeft(data);\r\n\r\n cacheContainerMinMax(data);\r\n\r\n checkContainerTopLeft(data);\r\n\r\n checkImageMinMax(data);\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name clearTouch\r\n * @description Clears current touch action.\r\n */\r\n\r\n function clearTouch(data) {\r\n if (data.$container && data.$container.length) {\r\n data.$container.fsTouch(\"destroy\")\r\n .off(Events.scaleStart, onScaleStart)\r\n .off(Events.scaleEnd, onScaleEnd)\r\n .off(Events.scale, onScale);\r\n }\r\n }\r\n\r\n /**\r\n * @method private\r\n * @name cacheScrollPosition\r\n * @description Cahce target scroll position\r\n * @param data [object] \"Instance data\"\r\n */\r\n\r\n function cacheScrollPosition(data) {\r\n data.scrollTop = data.$el.offset().top;\r\n }\r\n\r\n // /**\r\n // * @method private\r\n // * @name checkScrollPosition\r\n // * @description Check target scroll position against window\r\n // * @param data [object] \"Instance data\"\r\n // */\r\n //\r\n // function checkScrollPosition(data) {\r\n // if (!data.visible && data.scrollTop < ScrollTop + data.lazyEdge) {\r\n // data.visible = true;\r\n // loadInitialImage(data);\r\n // }\r\n // }\r\n\r\n /**\r\n * @method private\r\n * @name calculateNaturalSize\r\n * @description Determines natural size of target image.\r\n * @param $img [jQuery object] \"Source image object\"\r\n * @return [object | boolean] \"Object containing natural height and width values or false\"\r\n */\r\n\r\n function calculateNaturalSize($img) {\r\n var node = $img[0],\r\n img = new Image();\r\n\r\n if (typeof node.naturalHeight !== \"undefined\") {\r\n return {\r\n naturalHeight: node.naturalHeight,\r\n naturalWidth: node.naturalWidth\r\n };\r\n } else {\r\n if (node.tagName.toLowerCase() === 'img') {\r\n img.src = node.src;\r\n return {\r\n naturalHeight: img.height,\r\n naturalWidth: img.width\r\n };\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * @plugin\r\n * @name Viewer\r\n * @description A jQuery plugin for image exploration.\r\n * @type widget\r\n * @main viewer.js\r\n * @main viewer.css\r\n * @dependency jQuery\r\n * @dependency core.js\r\n * @dependency touch.js\r\n * @dependency transition.js\r\n */\r\n\r\n var Plugin = Formstone.Plugin(\"viewer\", {\r\n widget: true,\r\n\r\n /**\r\n * @options\r\n * @param controls [boolean or object] \"Flag to draw controls OR object containing container, next, previous, zoom_in and zoom_out control selectors (Must be fully qualified selectors)\"\r\n * @param customClass [string] <''> \"Class applied to instance\"\r\n // param lazy [boolean] \"Lazy load with scroll\"\r\n // param lazyEdge [int] <100> \"Lazy load edge\"\r\n * @param labels.count [string] <'of'> \"Gallery count separator text\"\r\n * @param labels.next [string] <'Next'> \"Gallery control text\"\r\n * @param labels.previous [string] <'Previous'> \"Gallery control text\"\r\n * @param labels.zoom_in [string] <'Zoom In'> \"Image zoom text\"\r\n * @param labels.zoom_out [string] <'Zoom Out'> \"Image zoom text\"\r\n * @param theme [string] <\"fs-light\"> \"Theme class name\"\r\n * @param zoomDelta [int] <100> \"Max zoom change\"\r\n * @param zoomEnertia [float] <0.2> \"Enertia for zoom\"\r\n * @param zoomIncrement [float] <0.01> \"Increment for zoom buttons\"\r\n */\r\n\r\n defaults: {\r\n controls: true,\r\n customClass: \"\",\r\n // lazy : false,\r\n // lazyEdge : 100,\r\n labels: {\r\n count: \"of\",\r\n next: \"Next\",\r\n previous: \"Previous\",\r\n zoom_in: \"Zoom In\",\r\n zoom_out: \"Zoom Out\"\r\n },\r\n theme: \"fs-light\",\r\n zoomDelta: 100,\r\n zoomEnertia: 0.2,\r\n zoomIncrement: 0.01\r\n },\r\n\r\n classes: [\r\n \"source\",\r\n \"wrapper\",\r\n \"viewport\",\r\n \"container\",\r\n \"image\",\r\n \"gallery\",\r\n \"loading_icon\",\r\n\r\n \"controls\",\r\n \"controls_custom\",\r\n \"control\",\r\n \"control_previous\",\r\n \"control_next\",\r\n \"control_zoom_in\",\r\n \"control_zoom_out\",\r\n \"control_disabled\",\r\n // \"lazy\"\r\n \"loading\"\r\n ],\r\n\r\n /**\r\n * @events\r\n * @event loaded.viewer \"Image loaded\"\r\n * @event ready.viewer \"Image ready\"\r\n */\r\n\r\n events: {\r\n loaded: \"loaded\",\r\n ready: \"ready\"\r\n },\r\n\r\n methods: {\r\n _construct: construct,\r\n _destruct: destruct,\r\n _resize: resize,\r\n _raf: raf,\r\n\r\n resize: resizeInstance,\r\n load: load,\r\n unload: unload\r\n }\r\n }),\r\n\r\n // Localize References\r\n\r\n Namespace = Plugin.namespace,\r\n Classes = Plugin.classes,\r\n RawClasses = Classes.raw,\r\n Events = Plugin.events,\r\n Functions = Plugin.functions,\r\n\r\n Window = Formstone.window,\r\n $Window = Formstone.$window,\r\n $Body,\r\n ScrollTop = 0,\r\n $Instances = [],\r\n ViewportSetup = false;\n\n // Setup\n\n Formstone.Ready(setup);\r\n\r\n })\r\n\r\n);\r\n"],"names":["factory","define","amd","jQuery","Formstone","$","setup","scroll","$Window","on","$Body","$body","resize","Functions","iterate","call","$Instances","resizeInstance","ScrollTop","scrollTop","windowHeight","raf","renderRAF","cacheInstances","Classes","base","length","lockViewport","Namespace","unlockViewport","construct","data","$image","html","controlPrevClasses","RawClasses","control","control_previous","join","controlNextClasses","control_next","controlZoomInClasses","control_zoom_in","controlZoomOutClasses","control_zoom_out","thisClasses","loading","customClass","theme","images","source","gallery","tapTimer","action","isRendering","isZooming","isAnimating","keyDownTime","$images","this","find","addClass","index","total","customControls","type","controls","zoom_in","zoom_out","push","previous","next","i","eq","attr","wrapper","loading_icon","viewport","labels","prepend","$wrapper","$viewport","$controls","container","controls_custom","$controlPrevious","$controlNext","$controlZoomIn","$controlZoomOut","$controlItems","add","$controlZooms","Events","click","advanceGallery","touchStart","mouseDown","onZoomStart","touchEnd","mouseUp","onClearZoom","loadImage","updateControls","destruct","remove","removeClass","off","namespace","load","$el","unloadImage","$container","append","one","onImageReady","fsTransition","property","fsTouch","pan","scale","scaleStart","onScaleStart","scaleEnd","onScaleEnd","onScale","trigger","loaded","error","loadError","image","complete","readyState","e","cacheImageProps","cacheViewportProps","containerTop","viewportHeight","containerLeft","viewportWidth","cacheImageMinMax","imageHeight","naturalHeight","imageWidth","naturalWidth","fitToViewport","cacheContainerMinMax","cacheImageTopLeft","cacheLastProps","cacheRenderProps","props","imageTop","imageLeft","setSizeAndPosition","naturalSize","calculateNaturalSize","ratioHorizontal","ratioVertical","isWide","outerHeight","outerWidth","containerMinTop","containerMaxTop","containerMinLeft","containerMaxLeft","imageMinWidth","imageMinHeight","imageMaxHeight","imageMaxWidth","lastContainerTop","lastContainerLeft","lastImageHeight","lastImageWidth","lastImageTop","lastImageLeft","renderContainerTop","renderContainerLeft","renderImageTop","renderImageLeft","renderImageHeight","renderImageWidth","checkImageMinMax","checkContainerTopLeft","checkDoubleTap","startTimer","clearDoubleTap","onImageZoom","clearTimer","transform","scaleX","scaleY","css","top","left","height","width","deltaY","deltaX","zoomed","killEvent","$target","currentTarget","direction","hasClass","onZoomOut","onZoomIn","zoomIncrement","delta","Math","round","zoomDelta","zoomEnertia","unload","callback","clearTouch","window","control_disabled","$img","node","img","Image","tagName","toLowerCase","src","Plugin","widget","defaults","count","classes","events","ready","methods","_construct","_destruct","_resize","_raf","raw","functions","$window","Ready"],"mappings":"CAKC,SAASA,GACgB,kBAAXC,SAAyBA,OAAOC,IACzCD,QACE,SACA,SACA,gBACCD,GAEHA,EAAQG,OAAQC,YAElB,SAASC,EAAGD,GAEZ,YAQA,SAASE,KACPC,IACAC,EAAQC,GAAG,SAAUF,GACrBG,EAAQN,EAAUO,MASpB,QAASC,KACPC,EAAUC,QAAQC,KAAKC,EAAYC,GAWrC,QAASV,KACPW,EAAYV,EAAQW,YAAcf,EAAUgB,aAE5B,EAAZF,IACFA,EAAY,GAYhB,QAASG,KACPR,EAAUC,QAAQC,KAAKC,EAAYM,GASrC,QAASC,KACPP,EAAaX,EAAEmB,EAAQC,MAKnBT,EAAWU,OACbb,EAAUc,aAAaC,GAEvBf,EAAUgB,eAAeD,GAW7B,QAASE,GAAUC,GACjB,GAAIC,GAEFC,EAAO,GACPC,GAAsBC,EAAWC,QAASD,EAAWE,kBAAkBC,KAAK,KAC5EC,GAAsBJ,EAAWC,QAASD,EAAWK,cAAcF,KAAK,KACxEG,GAAwBN,EAAWC,QAASD,EAAWO,iBAAiBJ,KAAK,KAC7EK,GAAyBR,EAAWC,QAASD,EAAWS,kBAAkBN,KAAK,IAEjFP,GAAKc,aAAeV,EAAWV,KAAMU,EAAWW,QAASf,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