{"version":3,"file":"scripts.js","sources":["webpack:///webpack/bootstrap","webpack:///../node_modules/jquery-backstretch/jquery.backstretch.js","webpack:///../node_modules/jquery-lazy/jquery.lazy.js","webpack:///../node_modules/jquery-popup-overlay/index.js","webpack:///../node_modules/jquery-popup-overlay/jquery.popupoverlay.js","webpack:///../node_modules/parallax-js/dist/parallax.js","webpack:///../node_modules/slick-carousel/slick/slick.js","webpack:///../node_modules/waypoints/lib/jquery.waypoints.js","webpack:///../node_modules/waypoints/lib/shortcuts/sticky.js","webpack:///../node_modules/webpack/buildin/global.js","webpack:///./scripts.js","webpack:///./src/ThirdParty/jquery.fancybox.min.js","webpack:///./src/master.js","webpack:///./src/mobile-menu.js"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./scripts.js\");\n","/*\r\n * Backstretch\r\n * http://srobbin.com/jquery-plugins/backstretch/\r\n *\r\n * Copyright (c) 2013 Scott Robbin\r\n * Licensed under the MIT license.\r\n */\r\n\r\n;(function ($, window, undefined) {\r\n 'use strict';\r\n\r\n /** @const */\r\n var YOUTUBE_REGEXP = /^.*(youtu\\.be\\/|youtube\\.com\\/v\\/|youtube\\.com\\/embed\\/|youtube\\.com\\/watch\\?v=|youtube\\.com\\/watch\\?.*\\&v=)([^#\\&\\?]*).*/i;\r\n\r\n /* PLUGIN DEFINITION\r\n * ========================= */\r\n\r\n $.fn.backstretch = function (images, options) {\r\n var args = arguments;\r\n\r\n /*\r\n * Scroll the page one pixel to get the right window height on iOS\r\n * Pretty harmless for everyone else\r\n */\r\n if ($(window).scrollTop() === 0) {\r\n window.scrollTo(0, 0);\r\n }\r\n\r\n var returnValues;\r\n\r\n this.each(function (eachIndex) {\r\n var $this = $(this)\r\n , obj = $this.data('backstretch');\r\n\r\n // Do we already have an instance attached to this element?\r\n if (obj) {\r\n\r\n // Is this a method they're trying to execute?\r\n if (typeof args[0] === 'string' &&\r\n typeof obj[args[0]] === 'function') {\r\n\r\n // Call the method\r\n var returnValue = obj[args[0]].apply(obj, Array.prototype.slice.call(args, 1));\r\n if (returnValue === obj) { // If a method is chaining\r\n returnValue = undefined;\r\n }\r\n if (returnValue !== undefined) {\r\n returnValues = returnValues || [];\r\n returnValues[eachIndex] = returnValue;\r\n }\r\n\r\n return; // Nothing further to do\r\n }\r\n\r\n // Merge the old options with the new\r\n options = $.extend(obj.options, options);\r\n\r\n // Remove the old instance\r\n if (typeof obj === 'object' && 'destroy' in obj) {\r\n obj.destroy(true);\r\n }\r\n }\r\n\r\n // We need at least one image\r\n if (!images || (images && images.length === 0)) {\r\n var cssBackgroundImage = $this.css('background-image');\r\n if (cssBackgroundImage && cssBackgroundImage !== 'none') {\r\n images = [{url: $this.css('backgroundImage').replace(/url\\(|\\)|\"|'/g, \"\")}];\r\n }\r\n else {\r\n $.error('No images were supplied for Backstretch, or element must have a CSS-defined background image.');\r\n }\r\n }\r\n\r\n obj = new Backstretch(this, images, options || {});\r\n $this.data('backstretch', obj);\r\n });\r\n\r\n return returnValues ? returnValues.length === 1 ? returnValues[0] : returnValues : this;\r\n };\r\n\r\n // If no element is supplied, we'll attach to body\r\n $.backstretch = function (images, options) {\r\n // Return the instance\r\n return $('body')\r\n .backstretch(images, options)\r\n .data('backstretch');\r\n };\r\n\r\n // Custom selector\r\n $.expr[':'].backstretch = function (elem) {\r\n return $(elem).data('backstretch') !== undefined;\r\n };\r\n\r\n /* DEFAULTS\r\n * ========================= */\r\n\r\n $.fn.backstretch.defaults = {\r\n duration: 5000 // Amount of time in between slides (if slideshow)\r\n , transition: 'fade' // Type of transition between slides\r\n , transitionDuration: 0 // Duration of transition between slides\r\n , animateFirst: true // Animate the transition of first image of slideshow in?\r\n , alignX: 0.5 // The x-alignment for the image, can be 'left'|'center'|'right' or any number between 0.0 and 1.0\r\n , alignY: 0.5 // The y-alignment for the image, can be 'top'|'center'|'bottom' or any number between 0.0 and 1.0\r\n , paused: false // Whether the images should slide after given duration\r\n , start: 0 // Index of the first image to show\r\n , preload: 2 // How many images preload at a time?\r\n , preloadSize: 1 // How many images can we preload in parallel?\r\n , resolutionRefreshRate: 2500 // How long to wait before switching resolution?\r\n , resolutionChangeRatioThreshold: 0.1 // How much a change should it be before switching resolution?\r\n };\r\n\r\n /* STYLES\r\n *\r\n * Baked-in styles that we'll apply to our elements.\r\n * In an effort to keep the plugin simple, these are not exposed as options.\r\n * That said, anyone can override these in their own stylesheet.\r\n * ========================= */\r\n var styles = {\r\n wrap: {\r\n left: 0\r\n , top: 0\r\n , overflow: 'hidden'\r\n , margin: 0\r\n , padding: 0\r\n , height: '100%'\r\n , width: '100%'\r\n , zIndex: -999999\r\n }\r\n , itemWrapper: {\r\n position: 'absolute'\r\n , display: 'none'\r\n , margin: 0\r\n , padding: 0\r\n , border: 'none'\r\n , width: '100%'\r\n , height: '100%'\r\n , zIndex: -999999\r\n }\r\n , item: {\r\n position: 'absolute'\r\n , margin: 0\r\n , padding: 0\r\n , border: 'none'\r\n , width: '100%'\r\n , height: '100%'\r\n , maxWidth: 'none'\r\n }\r\n };\r\n\r\n /* Given an array of different options for an image,\r\n * choose the optimal image for the container size.\r\n *\r\n * Given an image template (a string with {{ width }} and/or\r\n * {{height}} inside) and a container object, returns the\r\n * image url with the exact values for the size of that\r\n * container.\r\n *\r\n * Returns an array of urls optimized for the specified resolution.\r\n *\r\n */\r\n var optimalSizeImages = (function () {\r\n\r\n /* Sorts the array of image sizes based on width */\r\n var widthInsertSort = function (arr) {\r\n for (var i = 1; i < arr.length; i++) {\r\n var tmp = arr[i],\r\n j = i;\r\n while (arr[j - 1] && parseInt(arr[j - 1].width, 10) > parseInt(tmp.width, 10)) {\r\n arr[j] = arr[j - 1];\r\n --j;\r\n }\r\n arr[j] = tmp;\r\n }\r\n\r\n return arr;\r\n };\r\n\r\n /* Given an array of various sizes of the same image and a container width,\r\n * return the best image.\r\n */\r\n var selectBest = function (containerWidth, containerHeight, imageSizes) {\r\n\r\n var devicePixelRatio = window.devicePixelRatio || 1;\r\n var deviceOrientation = getDeviceOrientation();\r\n var windowOrientation = getWindowOrientation();\r\n var wrapperOrientation = (containerHeight > containerWidth) ?\r\n 'portrait' :\r\n (containerWidth > containerHeight ? 'landscape' : 'square');\r\n\r\n var lastAllowedImage = 0;\r\n var testWidth;\r\n\r\n for (var j = 0, image; j < imageSizes.length; j++) {\r\n\r\n image = imageSizes[j];\r\n\r\n // In case a new image was pushed in, process it:\r\n if (typeof image === 'string') {\r\n image = imageSizes[j] = {url: image};\r\n }\r\n\r\n if (image.pixelRatio && image.pixelRatio !== 'auto' && parseFloat(image.pixelRatio) !== devicePixelRatio) {\r\n // We disallowed choosing this image for current device pixel ratio,\r\n // So skip this one.\r\n continue;\r\n }\r\n\r\n if (image.deviceOrientation && image.deviceOrientation !== deviceOrientation) {\r\n // We disallowed choosing this image for current device orientation,\r\n // So skip this one.\r\n continue;\r\n }\r\n\r\n if (image.windowOrientation && image.windowOrientation !== deviceOrientation) {\r\n // We disallowed choosing this image for current window orientation,\r\n // So skip this one.\r\n continue;\r\n }\r\n\r\n if (image.orientation && image.orientation !== wrapperOrientation) {\r\n // We disallowed choosing this image for current element's orientation,\r\n // So skip this one.\r\n continue;\r\n }\r\n\r\n // Mark this one as the last one we investigated\r\n // which does not violate device pixel ratio rules.\r\n // We may choose this one later if there's no match.\r\n lastAllowedImage = j;\r\n\r\n // For most images, we match the specified width against element width,\r\n // And enforcing a limit depending on the \"pixelRatio\" property if specified.\r\n // But if a pixelRatio=\"auto\", then we consider the width as the physical width of the image,\r\n // And match it while considering the device's pixel ratio.\r\n testWidth = containerWidth;\r\n if (image.pixelRatio === 'auto') {\r\n containerWidth *= devicePixelRatio;\r\n }\r\n\r\n // Stop when the width of the image is larger or equal to the container width\r\n if (image.width >= testWidth) {\r\n break;\r\n }\r\n }\r\n\r\n // Use the image located at where we stopped\r\n return imageSizes[Math.min(j, lastAllowedImage)];\r\n };\r\n\r\n var replaceTagsInUrl = function (url, templateReplacer) {\r\n\r\n if (typeof url === 'string') {\r\n url = url.replace(/{{(width|height)}}/g, templateReplacer);\r\n }\r\n else if (url instanceof Array) {\r\n for (var i = 0; i < url.length; i++) {\r\n if (url[i].src) {\r\n url[i].src = replaceTagsInUrl(url[i].src, templateReplacer);\r\n }\r\n else {\r\n url[i] = replaceTagsInUrl(url[i], templateReplacer);\r\n }\r\n }\r\n }\r\n\r\n return url;\r\n };\r\n\r\n return function ($container, images) {\r\n var containerWidth = $container.width(),\r\n containerHeight = $container.height();\r\n\r\n var chosenImages = [];\r\n\r\n var templateReplacer = function (match, key) {\r\n if (key === 'width') {\r\n return containerWidth;\r\n }\r\n if (key === 'height') {\r\n return containerHeight;\r\n }\r\n return match;\r\n };\r\n\r\n for (var i = 0; i < images.length; i++) {\r\n if ($.isArray(images[i])) {\r\n images[i] = widthInsertSort(images[i]);\r\n var chosen = selectBest(containerWidth, containerHeight, images[i]);\r\n chosenImages.push(chosen);\r\n }\r\n else {\r\n // In case a new image was pushed in, process it:\r\n if (typeof images[i] === 'string') {\r\n images[i] = {url: images[i]};\r\n }\r\n\r\n var item = $.extend({}, images[i]);\r\n item.url = replaceTagsInUrl(item.url, templateReplacer);\r\n chosenImages.push(item);\r\n }\r\n }\r\n return chosenImages;\r\n };\r\n\r\n })();\r\n\r\n var isVideoSource = function (source) {\r\n return YOUTUBE_REGEXP.test(source.url) || source.isVideo;\r\n };\r\n\r\n /* Preload images */\r\n var preload = (function (sources, startAt, count, batchSize, callback) {\r\n // Plugin cache\r\n var cache = [];\r\n\r\n // Wrapper for cache\r\n var caching = function (image) {\r\n for (var i = 0; i < cache.length; i++) {\r\n if (cache[i].src === image.src) {\r\n return cache[i];\r\n }\r\n }\r\n cache.push(image);\r\n return image;\r\n };\r\n\r\n // Execute callback\r\n var exec = function (sources, callback, last) {\r\n if (typeof callback === 'function') {\r\n callback.call(sources, last);\r\n }\r\n };\r\n\r\n // Closure to hide cache\r\n return function preload(sources, startAt, count, batchSize, callback) {\r\n // Check input data\r\n if (typeof sources === 'undefined') {\r\n return;\r\n }\r\n if (!$.isArray(sources)) {\r\n sources = [sources];\r\n }\r\n\r\n if (arguments.length < 5 && typeof arguments[arguments.length - 1] === 'function') {\r\n callback = arguments[arguments.length - 1];\r\n }\r\n\r\n startAt = (typeof startAt === 'function' || !startAt) ? 0 : startAt;\r\n count = (typeof count === 'function' || !count || count < 0) ? sources.length : Math.min(count, sources.length);\r\n batchSize = (typeof batchSize === 'function' || !batchSize) ? 1 : batchSize;\r\n\r\n if (startAt >= sources.length) {\r\n startAt = 0;\r\n count = 0;\r\n }\r\n if (batchSize < 0) {\r\n batchSize = count;\r\n }\r\n batchSize = Math.min(batchSize, count);\r\n\r\n var next = sources.slice(startAt + batchSize, count - batchSize);\r\n sources = sources.slice(startAt, batchSize);\r\n count = sources.length;\r\n\r\n // If sources array is empty\r\n if (!count) {\r\n exec(sources, callback, true);\r\n return;\r\n }\r\n\r\n // Image loading callback\r\n var countLoaded = 0;\r\n\r\n var loaded = function () {\r\n countLoaded++;\r\n if (countLoaded !== count) {\r\n return;\r\n }\r\n\r\n exec(sources, callback, !next);\r\n preload(next, 0, 0, batchSize, callback);\r\n };\r\n\r\n // Loop sources to preload\r\n var image;\r\n\r\n for (var i = 0; i < sources.length; i++) {\r\n\r\n if (isVideoSource(sources[i])) {\r\n\r\n // Do not preload videos. There are issues with that.\r\n // First - we need to keep an instance of the preloaded and use that exactly, not a copy.\r\n // Second - there are memory issues.\r\n // If there will be a requirement from users - I'll try to implement this.\r\n\r\n continue;\r\n\r\n }\r\n else {\r\n\r\n image = new Image();\r\n image.src = sources[i].url;\r\n\r\n image = caching(image);\r\n\r\n if (image.complete) {\r\n loaded();\r\n }\r\n else {\r\n $(image).on('load error', loaded);\r\n }\r\n\r\n }\r\n\r\n }\r\n };\r\n })();\r\n\r\n /* Process images array */\r\n var processImagesArray = function (images) {\r\n var processed = [];\r\n for (var i = 0; i < images.length; i++) {\r\n if (typeof images[i] === 'string') {\r\n processed.push({url: images[i]});\r\n }\r\n else if ($.isArray(images[i])) {\r\n processed.push(processImagesArray(images[i]));\r\n }\r\n else {\r\n processed.push(processOptions(images[i]));\r\n }\r\n }\r\n return processed;\r\n };\r\n\r\n /* Process options */\r\n var processOptions = function (options, required) {\r\n\r\n // Convert old options\r\n\r\n // centeredX/centeredY are deprecated\r\n if (options.centeredX || options.centeredY) {\r\n if (window.console && window.console.log) {\r\n window.console.log('jquery.backstretch: `centeredX`/`centeredY` is deprecated, please use `alignX`/`alignY`');\r\n }\r\n if (options.centeredX) {\r\n options.alignX = 0.5;\r\n }\r\n if (options.centeredY) {\r\n options.alignY = 0.5;\r\n }\r\n }\r\n\r\n // Deprecated spec\r\n if (options.speed !== undefined) {\r\n\r\n if (window.console && window.console.log) {\r\n window.console.log('jquery.backstretch: `speed` is deprecated, please use `transitionDuration`');\r\n }\r\n\r\n options.transitionDuration = options.speed;\r\n options.transition = 'fade';\r\n }\r\n\r\n // Typo\r\n if (options.resolutionChangeRatioTreshold !== undefined) {\r\n window.console.log('jquery.backstretch: `treshold` is a typo!');\r\n options.resolutionChangeRatioThreshold = options.resolutionChangeRatioTreshold;\r\n }\r\n\r\n // Current spec that needs processing\r\n\r\n if (options.fadeFirst !== undefined) {\r\n options.animateFirst = options.fadeFirst;\r\n }\r\n\r\n if (options.fade !== undefined) {\r\n options.transitionDuration = options.fade;\r\n options.transition = 'fade';\r\n }\r\n\r\n if (options.scale) {\r\n options.scale = validScale(options.scale);\r\n }\r\n\r\n return processAlignOptions(options);\r\n };\r\n\r\n /* Process align options */\r\n var processAlignOptions = function (options, required) {\r\n if (options.alignX === 'left') {\r\n options.alignX = 0.0;\r\n }\r\n else if (options.alignX === 'center') {\r\n options.alignX = 0.5;\r\n }\r\n else if (options.alignX === 'right') {\r\n options.alignX = 1.0;\r\n }\r\n else {\r\n if (options.alignX !== undefined || required) {\r\n options.alignX = parseFloat(options.alignX);\r\n if (isNaN(options.alignX)) {\r\n options.alignX = 0.5;\r\n }\r\n }\r\n }\r\n\r\n if (options.alignY === 'top') {\r\n options.alignY = 0.0;\r\n }\r\n else if (options.alignY === 'center') {\r\n options.alignY = 0.5;\r\n }\r\n else if (options.alignY === 'bottom') {\r\n options.alignY = 1.0;\r\n }\r\n else {\r\n if (options.alignX !== undefined || required) {\r\n options.alignY = parseFloat(options.alignY);\r\n if (isNaN(options.alignY)) {\r\n options.alignY = 0.5;\r\n }\r\n }\r\n }\r\n\r\n return options;\r\n };\r\n\r\n var SUPPORTED_SCALE_OPTIONS = {\r\n 'cover': 'cover',\r\n 'fit': 'fit',\r\n 'fit-smaller': 'fit-smaller',\r\n 'fill': 'fill'\r\n };\r\n\r\n function validScale(scale) {\r\n if (!SUPPORTED_SCALE_OPTIONS.hasOwnProperty(scale)) {\r\n return 'cover';\r\n }\r\n return scale;\r\n }\r\n\r\n /* CLASS DEFINITION\r\n * ========================= */\r\n var Backstretch = function (container, images, options) {\r\n this.options = $.extend({}, $.fn.backstretch.defaults, options || {});\r\n\r\n this.firstShow = true;\r\n\r\n // Process options\r\n processOptions(this.options, true);\r\n\r\n /* In its simplest form, we allow Backstretch to be called on an image path.\r\n * e.g. $.backstretch('/path/to/image.jpg')\r\n * So, we need to turn this back into an array.\r\n */\r\n this.images = processImagesArray($.isArray(images) ? images : [images]);\r\n\r\n /**\r\n * Paused-Option\r\n */\r\n if (this.options.paused) {\r\n this.paused = true;\r\n }\r\n\r\n /**\r\n * Start-Option (Index)\r\n */\r\n if (this.options.start >= this.images.length) {\r\n this.options.start = this.images.length - 1;\r\n }\r\n if (this.options.start < 0) {\r\n this.options.start = 0;\r\n }\r\n\r\n // Convenience reference to know if the container is body.\r\n this.isBody = container === document.body;\r\n\r\n /* We're keeping track of a few different elements\r\n *\r\n * Container: the element that Backstretch was called on.\r\n * Wrap: a DIV that we place the image into, so we can hide the overflow.\r\n * Root: Convenience reference to help calculate the correct height.\r\n */\r\n var $window = $(window);\r\n this.$container = $(container);\r\n this.$root = this.isBody ? supportsFixedPosition ? $window : $(document) : this.$container;\r\n\r\n this.originalImages = this.images;\r\n this.images = optimalSizeImages(\r\n this.options.alwaysTestWindowResolution ? $window : this.$root,\r\n this.originalImages);\r\n\r\n /**\r\n * Pre-Loading.\r\n * This is the first image, so we will preload a minimum of 1 images.\r\n */\r\n preload(this.images, this.options.start || 0, this.options.preload || 1);\r\n\r\n // Don't create a new wrap if one already exists (from a previous instance of Backstretch)\r\n var $existing = this.$container.children(\".backstretch\").first();\r\n this.$wrap = $existing.length ? $existing :\r\n $('
')\r\n .css(this.options.bypassCss ? {} : styles.wrap)\r\n .appendTo(this.$container);\r\n\r\n if (!this.options.bypassCss) {\r\n\r\n // Non-body elements need some style adjustments\r\n if (!this.isBody) {\r\n // If the container is statically positioned, we need to make it relative,\r\n // and if no zIndex is defined, we should set it to zero.\r\n var position = this.$container.css('position')\r\n , zIndex = this.$container.css('zIndex');\r\n\r\n this.$container.css({\r\n position: position === 'static' ? 'relative' : position\r\n , zIndex: zIndex === 'auto' ? 0 : zIndex\r\n });\r\n\r\n // Needs a higher z-index\r\n this.$wrap.css({zIndex: -999998});\r\n }\r\n\r\n // Fixed or absolute positioning?\r\n this.$wrap.css({\r\n position: this.isBody && supportsFixedPosition ? 'fixed' : 'absolute'\r\n });\r\n\r\n }\r\n\r\n // Set the first image\r\n this.index = this.options.start;\r\n this.show(this.index);\r\n\r\n // Listen for resize\r\n $window.on('resize.backstretch', $.proxy(this.resize, this))\r\n .on('orientationchange.backstretch', $.proxy(function () {\r\n // Need to do this in order to get the right window height\r\n if (this.isBody && window.pageYOffset === 0) {\r\n window.scrollTo(0, 1);\r\n this.resize();\r\n }\r\n }, this));\r\n };\r\n\r\n var performTransition = function (options) {\r\n\r\n var transition = options.transition || 'fade';\r\n\r\n // Look for multiple options\r\n if (typeof transition === 'string' && transition.indexOf('|') > -1) {\r\n transition = transition.split('|');\r\n }\r\n\r\n if (transition instanceof Array) {\r\n transition = transition[Math.round(Math.random() * (transition.length - 1))];\r\n }\r\n\r\n var $new = options['new'];\r\n var $old = options['old'] ? options['old'] : $([]);\r\n\r\n switch (transition.toString().toLowerCase()) {\r\n\r\n default:\r\n case 'fade':\r\n $new.fadeIn({\r\n duration: options.duration,\r\n complete: options.complete,\r\n easing: options.easing || undefined\r\n });\r\n break;\r\n\r\n case 'fadeinout':\r\n case 'fade_in_out':\r\n\r\n var fadeInNew = function () {\r\n $new.fadeIn({\r\n duration: options.duration / 2,\r\n complete: options.complete,\r\n easing: options.easing || undefined\r\n });\r\n };\r\n\r\n if ($old.length) {\r\n $old.fadeOut({\r\n duration: options.duration / 2,\r\n complete: fadeInNew,\r\n easing: options.easing || undefined\r\n });\r\n }\r\n else {\r\n fadeInNew();\r\n }\r\n\r\n break;\r\n\r\n case 'pushleft':\r\n case 'push_left':\r\n case 'pushright':\r\n case 'push_right':\r\n case 'pushup':\r\n case 'push_up':\r\n case 'pushdown':\r\n case 'push_down':\r\n case 'coverleft':\r\n case 'cover_left':\r\n case 'coverright':\r\n case 'cover_right':\r\n case 'coverup':\r\n case 'cover_up':\r\n case 'coverdown':\r\n case 'cover_down':\r\n\r\n var transitionParts = transition.match(/^(cover|push)_?(.*)$/);\r\n\r\n var animProp = transitionParts[2] === 'left' ? 'right' :\r\n transitionParts[2] === 'right' ? 'left' :\r\n transitionParts[2] === 'down' ? 'top' :\r\n transitionParts[2] === 'up' ? 'bottom' :\r\n 'right';\r\n\r\n var newCssStart = {\r\n 'display': ''\r\n }, newCssAnim = {};\r\n newCssStart[animProp] = '-100%';\r\n newCssAnim[animProp] = 0;\r\n\r\n $new\r\n .css(newCssStart)\r\n .animate(newCssAnim, {\r\n duration: options.duration,\r\n complete: function () {\r\n $new.css(animProp, '');\r\n options.complete.apply(this, arguments);\r\n },\r\n easing: options.easing || undefined\r\n });\r\n\r\n if (transitionParts[1] === 'push' && $old.length) {\r\n var oldCssAnim = {};\r\n oldCssAnim[animProp] = '100%';\r\n\r\n $old\r\n .animate(oldCssAnim, {\r\n duration: options.duration,\r\n complete: function () {\r\n $old.css('display', 'none');\r\n },\r\n easing: options.easing || undefined\r\n });\r\n }\r\n\r\n break;\r\n }\r\n\r\n };\r\n\r\n /* PUBLIC METHODS\r\n * ========================= */\r\n Backstretch.prototype = {\r\n\r\n resize: function () {\r\n try {\r\n\r\n // Check for a better suited image after the resize\r\n var $resTest = this.options.alwaysTestWindowResolution ? $(window) : this.$root;\r\n var newContainerWidth = $resTest.width();\r\n var newContainerHeight = $resTest.height();\r\n var changeRatioW = newContainerWidth / (this._lastResizeContainerWidth || 0);\r\n var changeRatioH = newContainerHeight / (this._lastResizeContainerHeight || 0);\r\n var resolutionChangeRatioThreshold = this.options.resolutionChangeRatioThreshold || 0.0;\r\n\r\n // check for big changes in container size\r\n if ((newContainerWidth !== this._lastResizeContainerWidth ||\r\n newContainerHeight !== this._lastResizeContainerHeight) &&\r\n ((Math.abs(changeRatioW - 1) >= resolutionChangeRatioThreshold || isNaN(changeRatioW)) ||\r\n (Math.abs(changeRatioH - 1) >= resolutionChangeRatioThreshold || isNaN(changeRatioH)))) {\r\n\r\n this._lastResizeContainerWidth = newContainerWidth;\r\n this._lastResizeContainerHeight = newContainerHeight;\r\n\r\n // Big change: rebuild the entire images array\r\n this.images = optimalSizeImages($resTest, this.originalImages);\r\n\r\n // Preload them (they will be automatically inserted on the next cycle)\r\n if (this.options.preload) {\r\n preload(this.images, (this.index + 1) % this.images.length, this.options.preload);\r\n }\r\n\r\n // In case there is no cycle and the new source is different than the current\r\n if (this.images.length === 1 &&\r\n this._currentImage.url !== this.images[0].url) {\r\n\r\n // Wait a little an update the image being showed\r\n var that = this;\r\n clearTimeout(that._selectAnotherResolutionTimeout);\r\n that._selectAnotherResolutionTimeout = setTimeout(function () {\r\n that.show(0);\r\n }, this.options.resolutionRefreshRate);\r\n }\r\n }\r\n\r\n var bgCSS = {left: 0, top: 0, right: 'auto', bottom: 'auto'}\r\n\r\n , boxWidth = this.isBody ? this.$root.width() : this.$root.innerWidth()\r\n , boxHeight = this.isBody\r\n ? (window.innerHeight ? window.innerHeight : this.$root.height())\r\n : this.$root.innerHeight()\r\n\r\n , naturalWidth = this.$itemWrapper.data('width')\r\n , naturalHeight = this.$itemWrapper.data('height')\r\n\r\n , ratio = (naturalWidth / naturalHeight) || 1\r\n\r\n , alignX = this._currentImage.alignX === undefined ? this.options.alignX : this._currentImage.alignX\r\n , alignY = this._currentImage.alignY === undefined ? this.options.alignY : this._currentImage.alignY\r\n , scale = validScale(this._currentImage.scale || this.options.scale);\r\n\r\n var width, height;\r\n\r\n if (scale === 'fit' || scale === 'fit-smaller') {\r\n width = naturalWidth;\r\n height = naturalHeight;\r\n\r\n if (width > boxWidth ||\r\n height > boxHeight ||\r\n scale === 'fit-smaller') {\r\n var boxRatio = boxWidth / boxHeight;\r\n if (boxRatio > ratio) {\r\n width = Math.floor(boxHeight * ratio);\r\n height = boxHeight;\r\n }\r\n else if (boxRatio < ratio) {\r\n width = boxWidth;\r\n height = Math.floor(boxWidth / ratio);\r\n }\r\n else {\r\n width = boxWidth;\r\n height = boxHeight;\r\n }\r\n }\r\n }\r\n else if (scale === 'fill') {\r\n width = boxWidth;\r\n height = boxHeight;\r\n }\r\n else { // 'cover'\r\n width = Math.max(boxHeight * ratio, boxWidth);\r\n height = Math.max(width / ratio, boxHeight);\r\n }\r\n\r\n // Make adjustments based on image ratio\r\n bgCSS.top = -(height - boxHeight) * alignY;\r\n bgCSS.left = -(width - boxWidth) * alignX;\r\n bgCSS.width = width;\r\n bgCSS.height = height;\r\n\r\n if (!this.options.bypassCss) {\r\n\r\n this.$wrap\r\n .css({width: boxWidth, height: boxHeight})\r\n .find('>.backstretch-item').not('.deleteable')\r\n .each(function () {\r\n var $wrapper = $(this);\r\n $wrapper.find('img,video,iframe')\r\n .css(bgCSS);\r\n });\r\n }\r\n\r\n var evt = $.Event('backstretch.resize', {\r\n relatedTarget: this.$container[0]\r\n });\r\n this.$container.trigger(evt, this);\r\n\r\n }\r\n catch (err) {\r\n // IE7 seems to trigger resize before the image is loaded.\r\n // This try/catch block is a hack to let it fail gracefully.\r\n }\r\n\r\n return this;\r\n }\r\n\r\n // Show the slide at a certain position\r\n , show: function (newIndex, overrideOptions) {\r\n\r\n // Validate index\r\n if (Math.abs(newIndex) > this.images.length - 1) {\r\n return;\r\n }\r\n\r\n // Vars\r\n var that = this\r\n , $oldItemWrapper = that.$wrap.find('>.backstretch-item').addClass('deleteable')\r\n , oldVideoWrapper = that.videoWrapper\r\n , evtOptions = {relatedTarget: that.$container[0]};\r\n\r\n // Trigger the \"before\" event\r\n that.$container.trigger($.Event('backstretch.before', evtOptions), [that, newIndex]);\r\n\r\n // Set the new frame index\r\n this.index = newIndex;\r\n var selectedImage = that.images[newIndex];\r\n\r\n // Pause the slideshow\r\n clearTimeout(that._cycleTimeout);\r\n\r\n // New image\r\n\r\n delete that.videoWrapper; // Current item may not be a video\r\n\r\n var isVideo = isVideoSource(selectedImage);\r\n if (isVideo) {\r\n that.videoWrapper = new VideoWrapper(selectedImage);\r\n that.$item = that.videoWrapper.$video.css('pointer-events', 'none');\r\n }\r\n else {\r\n that.$item = $('