From c7ed245af4543b80fc833e1c6c053abe86bca67b Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 9 Mar 2015 10:02:44 -0400 Subject: [PATCH] Update member profile pages Adding tho photoswipe for photo gallery --- Toolkit/Members/css/member.css | 16 +- Toolkit/Members/templates/memberDetail.tpl | 14 +- Toolkit/Template/Page/Member.php | 7 +- libjs/photoGallery.js | 79 + photoswipe/MIT-license.txt | 21 + photoswipe/code.photoswipe-3.0.5.js | 6690 +++++++++++++++++ photoswipe/code.photoswipe-3.0.5.min.js | 172 + photoswipe/code.photoswipe.jquery-3.0.5.js | 6425 ++++++++++++++++ .../code.photoswipe.jquery-3.0.5.min.js | 164 + .../code.photoswipe.jquery-3.0.5_bak.js | 6425 ++++++++++++++++ photoswipe/error.gif | Bin 0 -> 3431 bytes photoswipe/icons.png | Bin 0 -> 3346 bytes photoswipe/icons@2x.png | Bin 0 -> 5445 bytes photoswipe/lib/klass.min.js | 8 + photoswipe/loader.gif | Bin 0 -> 3208 bytes .../noutil/code.photoswipe.noutil-3.0.5.js | 4344 +++++++++++ .../code.photoswipe.noutil-3.0.5.min.js | 119 + .../code.photoswipe.noutil.jquery-3.0.5.js | 4344 +++++++++++ ...code.photoswipe.noutil.jquery-3.0.5.min.js | 119 + photoswipe/photoswipe.css | 172 + photoswipe/photoswipe.js | 273 + 21 files changed, 29377 insertions(+), 15 deletions(-) create mode 100644 libjs/photoGallery.js create mode 100755 photoswipe/MIT-license.txt create mode 100755 photoswipe/code.photoswipe-3.0.5.js create mode 100755 photoswipe/code.photoswipe-3.0.5.min.js create mode 100755 photoswipe/code.photoswipe.jquery-3.0.5.js create mode 100755 photoswipe/code.photoswipe.jquery-3.0.5.min.js create mode 100755 photoswipe/code.photoswipe.jquery-3.0.5_bak.js create mode 100755 photoswipe/error.gif create mode 100755 photoswipe/icons.png create mode 100755 photoswipe/icons@2x.png create mode 100755 photoswipe/lib/klass.min.js create mode 100755 photoswipe/loader.gif create mode 100755 photoswipe/noutil/code.photoswipe.noutil-3.0.5.js create mode 100755 photoswipe/noutil/code.photoswipe.noutil-3.0.5.min.js create mode 100755 photoswipe/noutil/code.photoswipe.noutil.jquery-3.0.5.js create mode 100755 photoswipe/noutil/code.photoswipe.noutil.jquery-3.0.5.min.js create mode 100755 photoswipe/photoswipe.css create mode 100755 photoswipe/photoswipe.js diff --git a/Toolkit/Members/css/member.css b/Toolkit/Members/css/member.css index 0ee1a1c..5ecbc65 100755 --- a/Toolkit/Members/css/member.css +++ b/Toolkit/Members/css/member.css @@ -472,11 +472,15 @@ Restaurant, Hotels and Golf Courses /* Icons */ .mReservations { background-image: url(http://app.gaslightmedia.com/assets/icons/book_open.png); } /* Photo Gallery on member detail pages */ -#member-detail #photo-gallery { +#description #photo-gallery { clear: both; - margin: 0; - border-top: 1px dotted #aaa; - padding-top: 1em; + margin: 40px 0 0 0; +} +#description #photo-gallery img { + margin: 0 0 10px; +} +.captionWrapper h2 { + color: #fff; } div.pBox { -moz-box-sizing: border-box; @@ -750,12 +754,12 @@ ul#mColumnSoc { .pBox ul li { display: list-item; } -.course-item { +.course-item, .package-item { border: 1px solid #a5c0c0; padding: 5px 10px; margin: 0 0 10px; } -.course-item h3 { +.course-item h3, .package-item h3 { margin-top: 10px !important; } body .content #toolbox #description .course-item p.ital { diff --git a/Toolkit/Members/templates/memberDetail.tpl b/Toolkit/Members/templates/memberDetail.tpl index d03d361..9e218c6 100644 --- a/Toolkit/Members/templates/memberDetail.tpl +++ b/Toolkit/Members/templates/memberDetail.tpl @@ -35,7 +35,7 @@ catid="catid" />

Packages and Offers

{foreach:packages,v} -
+

{v[title]:h}

{if:v[image]} {v[image]:h} @@ -77,13 +77,13 @@ catid="catid" /> {end:} {end:} - + +
diff --git a/Toolkit/Template/Page/Member.php b/Toolkit/Template/Page/Member.php index 1be2cea..499139f 100644 --- a/Toolkit/Template/Page/Member.php +++ b/Toolkit/Template/Page/Member.php @@ -348,8 +348,11 @@ class Toolkit_Template_Page_Member extends Toolkit_Template_Page_Toolbox */ public function getContent() { - $GLOBALS['bottomScripts'][] - = MEDIA_APP_BASE_URL . 'libjs/member-link.js'; + $GLOBALS['styleSheets'][] = MEDIA_BASE_URL . 'photoswipe/photoswipe.css'; + $GLOBALS['bottomScripts'][] = GLM_APP_BASE_URL . 'libjs/member-link.js'; + $GLOBALS['bottomScripts'][] = MEDIA_BASE_URL . 'photoswipe/lib/klass.min.js'; + $GLOBALS['bottomScripts'][] = MEDIA_BASE_URL . 'photoswipe/code.photoswipe.jquery-3.0.5.js'; + $GLOBALS['bottomScripts'][] = MEDIA_BASE_URL . 'libjs/photoGallery.js'; $breadCrumbsBuilder = $this->breadCrumbsFactory->createBreadCrumbsHelper(); $page = $this->pageGateway->find($this->id); diff --git a/libjs/photoGallery.js b/libjs/photoGallery.js new file mode 100644 index 0000000..044ed74 --- /dev/null +++ b/libjs/photoGallery.js @@ -0,0 +1,79 @@ +(function(window, PhotoSwipe){ + if ($(".photoimg").length > 0) { + if(document.addEventListener) { + document.addEventListener('DOMContentLoaded', function(){ + var + options = { + getImageCaption: function(el){ + var captionText, captionDesc, captionId, captionEl; + if (el.nodeName === "A") { + captionText = el.getAttribute('title'); + captionDesc = el.getAttribute('rel'); + captionId = el.getAttribute('data-photoid'); + } + // Return a DOM element with custom styling + if((captionText != null && captionText != "") || (captionDesc != null && captionDesc != "")) { + captionEl = document.createElement('div'); + captionEl.className = 'captionWrapper'; + // Add Caption Title. + if(captionText != null && captionText != "") { + captionTitleOutput = document.createElement('h2'); + captionTitleOutput.className = "captionTitleWrapper"; + captionTitleOutput.appendChild(document.createTextNode(captionText)); + captionEl.appendChild(captionTitleOutput); + } + // Add Caption Description. + if(captionDesc != null && captionDesc != "") { + captionDescOutput = document.createElement('p'); + captionDescOutput.className = "captionDescWrapper"; + captionDescOutput.appendChild(document.createTextNode(captionDesc)); + captionEl.appendChild(captionDescOutput); + } + } else { + captionEl = ""; + } + return captionEl; + }, captionAndToolbarAutoHideDelay:0, imageScaleMethod: "fitNoUpscale", captionAndToolbarFlipPosition: true, backButtonHideEnabled: true + }, + instance = PhotoSwipe.attach( window.document.querySelectorAll('a.photoimg'), options ); + }, false); + } else { // You are using IE8- and you should feel bad. + document.attachEvent('onreadystatechange', function(){ + var + options = { + getImageCaption: function(el){ + var captionText, captionDesc, captionId, captionEl; + if (el.nodeName === "A") { + captionText = el.getAttribute('title'); + captionDesc = el.getAttribute('rel'); + captionId = el.getAttribute('data-photoid'); + } + // Return a DOM element with custom styling + if((captionText != null && captionText != "") || (captionDesc != null && captionDesc != "")) { + captionEl = $('
'); + captionEl.addClass = 'captionWrapper'; + // Add Caption Title. + if(captionText != null && captionText != "") { + captionTitleOutput = $('

'); + captionTitleOutput.addClass = "captionTitleWrapper"; + captionTitleOutput.append(captionText); + captionEl.append(captionTitleOutput); + } + // Add Caption Description. + if(captionDesc != null && captionDesc != "") { + captionDescOutput = $('

'); + captionDescOutput.addClass = "captionDescWrapper"; + captionDescOutput.append(document.createTextNode(captionDesc)); + captionEl.append(captionDescOutput); + } + } else { + captionEl = ""; + } + return captionEl; + }, captionAndToolbarAutoHideDelay:0, imageScaleMethod: "fitNoUpscale", captionAndToolbarFlipPosition: true, backButtonHideEnabled: true + }, + instance = PhotoSwipe.attach( window.document.querySelectorAll('a.photoimg'), options ); + }, false); + } + } +}(window, window.Code.PhotoSwipe)); \ No newline at end of file diff --git a/photoswipe/MIT-license.txt b/photoswipe/MIT-license.txt new file mode 100755 index 0000000..59700af --- /dev/null +++ b/photoswipe/MIT-license.txt @@ -0,0 +1,21 @@ +The MIT License + +Copyright (C) 2011 by Code Computerlove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE diff --git a/photoswipe/code.photoswipe-3.0.5.js b/photoswipe/code.photoswipe-3.0.5.js new file mode 100755 index 0000000..d3954c9 --- /dev/null +++ b/photoswipe/code.photoswipe-3.0.5.js @@ -0,0 +1,6690 @@ +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function (window) { + + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind + if (!Function.prototype.bind ) { + + Function.prototype.bind = function( obj ) { + var slice = [].slice, + args = slice.call(arguments, 1), + self = this, + nop = function () {}, + bound = function () { + return self.apply( this instanceof nop ? this : ( obj || {} ), + args.concat( slice.call(arguments) ) ); + }; + + nop.prototype = self.prototype; + + bound.prototype = new nop(); + + return bound; + }; + } + + + + if (typeof window.Code === "undefined") { + window.Code = {}; + } + + + + window.Code.Util = { + + + /* + * Function: registerNamespace + */ + registerNamespace: function () { + var + args = arguments, obj = null, i, j, ns, nsParts, root, argsLen, nsPartsLens; + for (i=0, argsLen=args.length; i Util.DOM.windowHeight()); + } + }; + + Util.Browser._detect(); + +} +( + window, + window.Code.Util +)) +; +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function (window, Util) { + + Util.extend(Util, { + + Events: { + + + /* + * Function: add + * Add an event handler + */ + add: function(obj, type, handler){ + + this._checkHandlersProperty(obj); + + if (type === 'mousewheel'){ + type = this._normaliseMouseWheelType(); + } + + if (typeof obj.__eventHandlers[type] === 'undefined'){ + obj.__eventHandlers[type] = []; + } + obj.__eventHandlers[type].push(handler); + + // DOM element + if (this._isBrowserObject(obj)){ + obj.addEventListener(type, handler, false); + } + + }, + + + + /* + * Function: remove + * Removes a handler or all handlers associated with a type + */ + remove: function(obj, type, handler){ + + this._checkHandlersProperty(obj); + + if (type === 'mousewheel'){ + type = this._normaliseMouseWheelType(); + } + + if (obj.__eventHandlers[type] instanceof Array){ + + var + i, j, + handlers = obj.__eventHandlers[type]; + + // Removing all handlers for a type + if (Util.isNothing(handler)){ + + if (this._isBrowserObject(obj)){ + for (i=0, j=handlers.length; i= 1){ + parentEl.removeChild(parentEl.childNodes[parentEl.childNodes.length -1]); + } + + } + + }, + + + + /* + * Function: hasAttribute + */ + hasAttribute: function(el, attributeName){ + + return !Util.isNothing(el.getAttribute(attributeName)); + + }, + + + + /* + * Function: getAttribute + */ + getAttribute: function(el, attributeName, defaultValue){ + + var retval = el.getAttribute(attributeName); + if (Util.isNothing(retval) && !Util.isNothing(defaultValue)){ + retval = defaultValue; + } + return retval; + + }, + + + + /* + * Function: el, attributeName + */ + setAttribute: function(el, attributeName, value){ + + if (Util.isLikeArray(el)){ + var i, len; + for (i=0, len=el.length; i= 1){ + Util.DOM.setStyle(el, 'opacity', 0); + } + + if (Util.Browser.isCSSTransformSupported){ + this._applyTransition(el, 'opacity', opacity, speed, callback, timingFunction); + } + else if (!Util.isNothing(window.jQuery)){ + window.jQuery(el).fadeTo(speed, opacity, callback); + } + + }, + + + + /* + * Function: fadeTo + */ + fadeTo: function(el, opacity, speed, callback, timingFunction){ + this.fadeIn(el, speed, callback, timingFunction, opacity); + }, + + + + /* + * Function: fadeOut + */ + fadeOut: function(el, speed, callback, timingFunction){ + + if (speed <= 0){ + Util.DOM.setStyle(el, 'opacity', 0); + if (!Util.isNothing(callback)){ + callback(el); + return; + } + } + + if (Util.Browser.isCSSTransformSupported){ + + this._applyTransition(el, 'opacity', 0, speed, callback, timingFunction); + + } + else{ + + window.jQuery(el).fadeTo(speed, 0, callback); + + } + + }, + + + + /* + * Function: slideBy + */ + slideBy: function(el, x, y, speed, callback, timingFunction){ + + var style = {}; + + x = Util.coalesce(x, 0); + y = Util.coalesce(y, 0); + timingFunction = Util.coalesce(timingFunction, 'ease-out'); + + style[this._transitionPrefix + 'Property'] = 'all'; + style[this._transitionPrefix + 'Delay'] = '0'; + + if (speed === 0){ + style[this._transitionPrefix + 'Duration'] = ''; + style[this._transitionPrefix + 'TimingFunction'] = ''; + } + else{ + style[this._transitionPrefix + 'Duration'] = speed + 'ms'; + style[this._transitionPrefix + 'TimingFunction'] = Util.coalesce(timingFunction, 'ease-out'); + + Util.Events.add(el, this._transitionEndLabel, this._getTransitionEndHandler()); + + } + + style[this._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(' + x + 'px, ' + y + 'px, 0px)' : 'translate(' + x + 'px, ' + y + 'px)'; + + if (!Util.isNothing(callback)){ + el.cclallcallback = callback; + } + + Util.DOM.setStyle(el, style); + + if (speed === 0){ + window.setTimeout(function(){ + this._leaveTransforms(el); + }.bind(this), this._applyTransitionDelay); + } + + }, + + + + /* + * Function: + */ + resetTranslate: function(el){ + + var style = {}; + style[this._transformLabel] = style[this._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(0px, 0px, 0px)' : 'translate(0px, 0px)'; + Util.DOM.setStyle(el, style); + + }, + + + + /* + * Function: _applyTransition + */ + _applyTransition: function(el, property, val, speed, callback, timingFunction){ + + var style = {}; + + timingFunction = Util.coalesce(timingFunction, 'ease-in'); + + style[this._transitionPrefix + 'Property'] = property; + style[this._transitionPrefix + 'Duration'] = speed + 'ms'; + style[this._transitionPrefix + 'TimingFunction'] = timingFunction; + style[this._transitionPrefix + 'Delay'] = '0'; + + Util.Events.add(el, this._transitionEndLabel, this._getTransitionEndHandler()); + + Util.DOM.setStyle(el, style); + + if (!Util.isNothing(callback)){ + el['ccl' + property + 'callback'] = callback; + } + + window.setTimeout(function(){ + Util.DOM.setStyle(el, property, val); + }, this._applyTransitionDelay); + + }, + + + + /* + * Function: _onTransitionEnd + */ + _onTransitionEnd: function(e){ + + Util.Events.remove(e.currentTarget, this._transitionEndLabel, this._getTransitionEndHandler()); + this._leaveTransforms(e.currentTarget); + + }, + + + + /* + * Function: _leaveTransforms + */ + _leaveTransforms: function(el){ + + var + property = el.style[this._transitionPrefix + 'Property'], + callbackLabel = (property !== '') ? 'ccl' + property + 'callback' : 'cclallcallback', + callback, + transform = Util.coalesce(el.style.webkitTransform, el.style.MozTransform, el.style.transform), + transformMatch, + transformExploded, + domX = window.parseInt(Util.DOM.getStyle(el, 'left'), 0), + domY = window.parseInt(Util.DOM.getStyle(el, 'top'), 0), + transformedX, + transformedY, + style = {}; + + if (transform !== ''){ + if (Util.Browser.is3dSupported){ + transformMatch = transform.match( /translate3d\((.*?)\)/ ); + } + else{ + transformMatch = transform.match( /translate\((.*?)\)/ ); + } + if (!Util.isNothing(transformMatch)){ + transformExploded = transformMatch[1].split(', '); + transformedX = window.parseInt(transformExploded[0], 0); + transformedY = window.parseInt(transformExploded[1], 0); + } + } + + style[this._transitionPrefix + 'Property'] = ''; + style[this._transitionPrefix + 'Duration'] = ''; + style[this._transitionPrefix + 'TimingFunction'] = ''; + style[this._transitionPrefix + 'Delay'] = ''; + + Util.DOM.setStyle(el, style); + + window.setTimeout(function(){ + + if(!Util.isNothing(transformExploded)){ + + style = {}; + style[this._transformLabel] = ''; + style.left = (domX + transformedX) + 'px'; + style.top = (domY + transformedY) + 'px'; + + Util.DOM.setStyle(el, style); + + } + + if (!Util.isNothing(el[callbackLabel])){ + callback = el[callbackLabel]; + delete el[callbackLabel]; + callback(el); + } + + }.bind(this), this._applyTransitionDelay); + + } + + + } + + + }); + + +} +( + window, + window.Code.Util +)); +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.Util.TouchElement'); + + + Util.TouchElement.EventTypes = { + + onTouch: 'CodeUtilTouchElementOnTouch' + + }; + + + Util.TouchElement.ActionTypes = { + + touchStart: 'touchStart', + touchMove: 'touchMove', + touchEnd: 'touchEnd', + touchMoveEnd: 'touchMoveEnd', + tap: 'tap', + doubleTap: 'doubleTap', + swipeLeft: 'swipeLeft', + swipeRight: 'swipeRight', + swipeUp: 'swipeUp', + swipeDown: 'swipeDown', + gestureStart: 'gestureStart', + gestureChange: 'gestureChange', + gestureEnd: 'gestureEnd' + + }; + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.Util.TouchElement'); + + + Util.TouchElement.TouchElementClass = klass({ + + el: null, + + captureSettings: null, + + touchStartPoint: null, + touchEndPoint: null, + touchStartTime: null, + doubleTapTimeout: null, + + touchStartHandler: null, + touchMoveHandler: null, + touchEndHandler: null, + + mouseDownHandler: null, + mouseMoveHandler: null, + mouseUpHandler: null, + mouseOutHandler: null, + + gestureStartHandler: null, + gestureChangeHandler: null, + gestureEndHandler: null, + + swipeThreshold: null, + swipeTimeThreshold: null, + doubleTapSpeed: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.removeEventHandlers(); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(el, captureSettings){ + + this.el = el; + + this.captureSettings = { + swipe: false, + move: false, + gesture: false, + doubleTap: false, + preventDefaultTouchEvents: true + }; + + Util.extend(this.captureSettings, captureSettings); + + this.swipeThreshold = 50; + this.swipeTimeThreshold = 250; + this.doubleTapSpeed = 250; + + this.touchStartPoint = { x: 0, y: 0 }; + this.touchEndPoint = { x: 0, y: 0 }; + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.isNothing(this.touchStartHandler)){ + this.touchStartHandler = this.onTouchStart.bind(this); + this.touchMoveHandler = this.onTouchMove.bind(this); + this.touchEndHandler = this.onTouchEnd.bind(this); + this.mouseDownHandler = this.onMouseDown.bind(this); + this.mouseMoveHandler = this.onMouseMove.bind(this); + this.mouseUpHandler = this.onMouseUp.bind(this); + this.mouseOutHandler = this.onMouseOut.bind(this); + this.gestureStartHandler = this.onGestureStart.bind(this); + this.gestureChangeHandler = this.onGestureChange.bind(this); + this.gestureEndHandler = this.onGestureEnd.bind(this); + } + + Util.Events.add(this.el, 'touchstart', this.touchStartHandler); + if (this.captureSettings.move){ + Util.Events.add(this.el, 'touchmove', this.touchMoveHandler); + } + Util.Events.add(this.el, 'touchend', this.touchEndHandler); + + Util.Events.add(this.el, 'mousedown', this.mouseDownHandler); + + if (Util.Browser.isGestureSupported && this.captureSettings.gesture){ + Util.Events.add(this.el, 'gesturestart', this.gestureStartHandler); + Util.Events.add(this.el, 'gesturechange', this.gestureChangeHandler); + Util.Events.add(this.el, 'gestureend', this.gestureEndHandler); + } + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + Util.Events.remove(this.el, 'touchstart', this.touchStartHandler); + if (this.captureSettings.move){ + Util.Events.remove(this.el, 'touchmove', this.touchMoveHandler); + } + Util.Events.remove(this.el, 'touchend', this.touchEndHandler); + Util.Events.remove(this.el, 'mousedown', this.mouseDownHandler); + + if (Util.Browser.isGestureSupported && this.captureSettings.gesture){ + Util.Events.remove(this.el, 'gesturestart', this.gestureStartHandler); + Util.Events.remove(this.el, 'gesturechange', this.gestureChangeHandler); + Util.Events.remove(this.el, 'gestureend', this.gestureEndHandler); + } + + }, + + + + /* + * Function: getTouchPoint + */ + getTouchPoint: function(touches){ + + return { + x: touches[0].pageX, + y: touches[0].pageY + }; + + }, + + + + /* + * Function: fireTouchEvent + */ + fireTouchEvent: function(e){ + + var + action, + distX = 0, + distY = 0, + dist = 0, + self, + endTime, + diffTime; + + distX = this.touchEndPoint.x - this.touchStartPoint.x; + distY = this.touchEndPoint.y - this.touchStartPoint.y; + dist = Math.sqrt( (distX * distX) + (distY * distY) ); + + if (this.captureSettings.swipe){ + endTime = new Date(); + diffTime = endTime - this.touchStartTime; + + // See if there was a swipe gesture + if (diffTime <= this.swipeTimeThreshold){ + + if (window.Math.abs(distX) >= this.swipeThreshold){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: (distX < 0) ? Util.TouchElement.ActionTypes.swipeLeft : Util.TouchElement.ActionTypes.swipeRight, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + + } + + + if (window.Math.abs(distY) >= this.swipeThreshold){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: (distY < 0) ? Util.TouchElement.ActionTypes.swipeUp : Util.TouchElement.ActionTypes.swipeDown, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + + } + + } + } + + + if (dist > 1){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchMoveEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + } + + + if (!this.captureSettings.doubleTap){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: Util.TouchElement.ActionTypes.tap, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + + } + + if (Util.isNothing(this.doubleTapTimeout)){ + + this.doubleTapTimeout = window.setTimeout(function(){ + + this.doubleTapTimeout = null; + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: Util.TouchElement.ActionTypes.tap, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }.bind(this), this.doubleTapSpeed); + + return; + + } + else{ + + window.clearTimeout(this.doubleTapTimeout); + this.doubleTapTimeout = null; + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: Util.TouchElement.ActionTypes.doubleTap, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + } + + }, + + + + /* + * Function: onTouchStart + */ + onTouchStart: function(e){ + + if (this.captureSettings.preventDefaultTouchEvents){ + e.preventDefault(); + } + + // No longer need mouse events + Util.Events.remove(this.el, 'mousedown', this.mouseDownHandler); + + var + touchEvent = Util.Events.getTouchEvent(e), + touches = touchEvent.touches; + + if (touches.length > 1 && this.captureSettings.gesture){ + this.isGesture = true; + return; + } + + this.touchStartTime = new Date(); + this.isGesture = false; + this.touchStartPoint = this.getTouchPoint(touches); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchStart, + point: this.touchStartPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + + }, + + + + /* + * Function: onTouchMove + */ + onTouchMove: function(e){ + + if (this.captureSettings.preventDefaultTouchEvents){ + e.preventDefault(); + } + + if (this.isGesture && this.captureSettings.gesture){ + return; + } + + var + touchEvent = Util.Events.getTouchEvent(e), + touches = touchEvent.touches; + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchMove, + point: this.getTouchPoint(touches), + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onTouchEnd + */ + onTouchEnd: function(e){ + + if (this.isGesture && this.captureSettings.gesture){ + return; + } + + if (this.captureSettings.preventDefaultTouchEvents){ + e.preventDefault(); + } + + // http://backtothecode.blogspot.com/2009/10/javascript-touch-and-gesture-events.html + // iOS removed the current touch from e.touches on "touchend" + // Need to look into e.changedTouches + + var + touchEvent = Util.Events.getTouchEvent(e), + touches = (!Util.isNothing(touchEvent.changedTouches)) ? touchEvent.changedTouches : touchEvent.touches; + + this.touchEndPoint = this.getTouchPoint(touches); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + this.fireTouchEvent(e); + + }, + + + + /* + * Function: onMouseDown + */ + onMouseDown: function(e){ + + e.preventDefault(); + + // No longer need touch events + Util.Events.remove(this.el, 'touchstart', this.mouseDownHandler); + Util.Events.remove(this.el, 'touchmove', this.touchMoveHandler); + Util.Events.remove(this.el, 'touchend', this.touchEndHandler); + + // Add move/up/out + if (this.captureSettings.move){ + Util.Events.add(this.el, 'mousemove', this.mouseMoveHandler); + } + Util.Events.add(this.el, 'mouseup', this.mouseUpHandler); + Util.Events.add(this.el, 'mouseout', this.mouseOutHandler); + + this.touchStartTime = new Date(); + this.isGesture = false; + this.touchStartPoint = Util.Events.getMousePosition(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchStart, + point: this.touchStartPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onMouseMove + */ + onMouseMove: function(e){ + + e.preventDefault(); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchMove, + point: Util.Events.getMousePosition(e), + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onMouseUp + */ + onMouseUp: function(e){ + + e.preventDefault(); + + if (this.captureSettings.move){ + Util.Events.remove(this.el, 'mousemove', this.mouseMoveHandler); + } + Util.Events.remove(this.el, 'mouseup', this.mouseUpHandler); + Util.Events.remove(this.el, 'mouseout', this.mouseOutHandler); + + this.touchEndPoint = Util.Events.getMousePosition(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + this.fireTouchEvent(e); + + }, + + + + /* + * Function: onMouseOut + */ + onMouseOut: function(e){ + + /* + * http://blog.stchur.com/2007/03/15/mouseenter-and-mouseleave-events-for-firefox-and-other-non-ie-browsers/ + */ + var relTarget = e.relatedTarget; + if (this.el === relTarget || Util.DOM.isChildOf(relTarget, this.el)){ + return; + } + + e.preventDefault(); + + if (this.captureSettings.move){ + Util.Events.remove(this.el, 'mousemove', this.mouseMoveHandler); + } + Util.Events.remove(this.el, 'mouseup', this.mouseUpHandler); + Util.Events.remove(this.el, 'mouseout', this.mouseOutHandler); + + this.touchEndPoint = Util.Events.getMousePosition(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + this.fireTouchEvent(e); + + }, + + + + /* + * Function: onGestureStart + */ + onGestureStart: function(e){ + + e.preventDefault(); + + var touchEvent = Util.Events.getTouchEvent(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.gestureStart, + scale: touchEvent.scale, + rotation: touchEvent.rotation, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onGestureChange + */ + onGestureChange: function(e){ + + e.preventDefault(); + + var touchEvent = Util.Events.getTouchEvent(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.gestureChange, + scale: touchEvent.scale, + rotation: touchEvent.rotation, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onGestureEnd + */ + onGestureEnd: function(e){ + + e.preventDefault(); + + var touchEvent = Util.Events.getTouchEvent(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.gestureEnd, + scale: touchEvent.scale, + rotation: touchEvent.rotation, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.EventTypes = { + + onLoad: 'onLoad', + onError: 'onError' + + }; + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.ImageClass = klass({ + + + + refObj: null, + imageEl: null, + src: null, + caption: null, + metaData: null, + imageLoadHandler: null, + imageErrorHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i; + + this.shrinkImage(); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(refObj, src, caption, metaData){ + + this.refObj = refObj; + // This is needed. Webkit resolves the src + // value which means we can't compare against it in the load function + this.originalSrc = src; + this.src = src; + this.caption = caption; + this.metaData = metaData; + + this.imageEl = new window.Image(); + + this.imageLoadHandler = this.onImageLoad.bind(this); + this.imageErrorHandler = this.onImageError.bind(this); + + }, + + + + /* + * Function: load + */ + load: function(){ + + this.imageEl.originalSrc = Util.coalesce(this.imageEl.originalSrc, ''); + + if (this.imageEl.originalSrc === this.src){ + + if (this.imageEl.isError){ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + } + else{ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + } + return; + } + + this.imageEl.isError = false; + this.imageEl.isLoading = true; + this.imageEl.naturalWidth = null; + this.imageEl.naturalHeight = null; + this.imageEl.isLandscape = false; + this.imageEl.onload = this.imageLoadHandler; + this.imageEl.onerror = this.imageErrorHandler; + this.imageEl.onabort = this.imageErrorHandler; + this.imageEl.originalSrc = this.src; + this.imageEl.src = this.src; + + }, + + + + /* + * Function: shrinkImage + */ + shrinkImage: function(){ + + if (Util.isNothing(this.imageEl)){ + return; + } + + if (this.imageEl.src.indexOf(this.src) > -1){ + this.imageEl.src = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='; + if (!Util.isNothing(this.imageEl.parentNode)){ + Util.DOM.removeChild(this.imageEl, this.imageEl.parentNode); + } + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + this.imageEl.onload = null; + this.imageEl.naturalWidth = Util.coalesce(this.imageEl.naturalWidth, this.imageEl.width); + this.imageEl.naturalHeight = Util.coalesce(this.imageEl.naturalHeight, this.imageEl.height); + this.imageEl.isLandscape = (this.imageEl.naturalWidth > this.imageEl.naturalHeight); + this.imageEl.isLoading = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + this.imageEl.onload = null; + this.imageEl.onerror = null; + this.imageEl.onabort = null; + this.imageEl.isLoading = false; + this.imageEl.isError = true; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Cache'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Cache.Mode = { + + normal: 'normal', + aggressive: 'aggressive' + + }; + + + + PhotoSwipe.Cache.Functions = { + + /* + * Function: getImageSource + * Default method for returning an image's source + */ + getImageSource: function(el){ + return el.href; + }, + + + + /* + * Function: getImageCaption + * Default method for returning an image's caption + * Assumes the el is an anchor and the first child is the + * image. The returned value is the "alt" attribute of the + * image. + */ + getImageCaption: function(el){ + + if (el.nodeName === "IMG"){ + return Util.DOM.getAttribute(el, 'alt'); + } + var i, j, childEl; + for (i=0, j=el.childNodes.length; i height){ + height = Util.DOM.windowHeight(); + } + + } + else{ + + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + + } + + Util.DOM.setStyle(this.el, { + width: width, + height: height, + top: top + }); + + }, + + + + /* + * Function: fadeIn + */ + fadeIn: function(speed, callback){ + + this.resetPosition(); + + Util.DOM.setStyle(this.el, 'opacity', 0); + Util.DOM.show(this.el); + + Util.Animation.fadeIn(this.el, speed, callback); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Carousel.EventTypes = { + + onSlideByEnd: 'PhotoSwipeCarouselOnSlideByEnd', + onSlideshowStart: 'PhotoSwipeCarouselOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeCarouselOnSlideshowStop' + + }; + + + + PhotoSwipe.Carousel.CssClasses = { + carousel: 'ps-carousel', + content: 'ps-carousel-content', + item: 'ps-carousel-item', + itemLoading: 'ps-carousel-item-loading', + itemError: 'ps-carousel-item-error' + }; + + + + PhotoSwipe.Carousel.SlideByAction = { + previous: 'previous', + current: 'current', + next: 'next' + }; + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = klass({ + + + + el: null, + contentEl: null, + settings: null, + cache: null, + slideByEndHandler: null, + currentCacheIndex: null, + isSliding: null, + isSlideshowActive: null, + lastSlideByAction: null, + touchStartPoint: null, + touchStartPosition: null, + imageLoadHandler: null, + imageErrorHandler: null, + slideshowTimeout: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i, j; + + for (i=0, j=this.cache.images.length; i 0){ + Util.DOM.setStyle(itemEl, { + marginRight: this.settings.margin + 'px' + }); + } + + Util.DOM.appendChild(itemEl, this.contentEl); + + } + + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + }, + + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, height, top, itemWidth, itemEls, contentWidth, i, j, itemEl, imageEl; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + } + + itemWidth = (this.settings.margin > 0) ? width + this.settings.margin : width; + itemEls = Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + contentWidth = itemWidth * itemEls.length; + + + // Set the height and width to fill the document + Util.DOM.setStyle(this.el, { + top: top, + width: width, + height: height + }); + + + // Set the height and width of the content el + Util.DOM.setStyle(this.contentEl, { + width: contentWidth, + height: height + }); + + + // Set the height and width of item elements + for (i=0, j=itemEls.length; i maxWidth){ + scale = maxWidth / newWidth; + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + if (newHeight > maxHeight){ + scale = maxHeight / newHeight; + newHeight = Math.round(newHeight * scale); + newWidth = Math.round(newWidth * scale); + } + + } + else{ + + if (imageEl.isLandscape) { + // Ensure the width fits the screen + scale = maxWidth / imageEl.naturalWidth; + } + else { + // Ensure the height fits the screen + scale = maxHeight / imageEl.naturalHeight; + } + + newWidth = Math.round(imageEl.naturalWidth * scale); + newHeight = Math.round(imageEl.naturalHeight * scale); + + if (this.settings.imageScaleMethod === 'zoom'){ + + scale = 1; + if (newHeight < maxHeight){ + scale = maxHeight /newHeight; + } + else if (newWidth < maxWidth){ + scale = maxWidth /newWidth; + } + + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + } + else if (this.settings.imageScaleMethod === 'fit') { + // Rescale again to ensure full image fits into the viewport + scale = 1; + if (newWidth > maxWidth) { + scale = maxWidth / newWidth; + } + else if (newHeight > maxHeight) { + scale = maxHeight / newHeight; + } + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + } + + } + + newTop = Math.round( ((maxHeight - newHeight) / 2) ) + 'px'; + newLeft = Math.round( ((maxWidth - newWidth) / 2) ) + 'px'; + + Util.DOM.setStyle(imageEl, { + position: 'absolute', + width: newWidth, + height: newHeight, + top: newTop, + left: newLeft, + display: 'block' + }); + + }, + + + + /* + * Function: setContentLeftPosition + */ + setContentLeftPosition: function(){ + + var width, itemEls, left; + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + } + else{ + width = Util.DOM.width(this.settings.target); + } + + itemEls = this.getItemEls(); + left = 0; + + if (this.settings.loop){ + left = (width + this.settings.margin) * -1; + } + else{ + + if (this.currentCacheIndex === this.cache.images.length-1){ + left = ((itemEls.length-1) * (width + this.settings.margin)) * -1; + } + else if (this.currentCacheIndex > 0){ + left = (width + this.settings.margin) * -1; + } + + } + + Util.DOM.setStyle(this.contentEl, { + left: left + 'px' + }); + + }, + + + + /* + * Function: + */ + show: function(index){ + + this.currentCacheIndex = index; + this.resetPosition(); + this.setImages(false); + Util.DOM.show(this.el); + + Util.Animation.resetTranslate(this.contentEl); + var + itemEls = this.getItemEls(), + i, j; + for (i=0, j=itemEls.length; i this.cache.images.length-1){ + nextCacheIndex = 0; + } + if (previousCacheIndex < 0){ + previousCacheIndex = this.cache.images.length-1; + } + + cacheImages = this.cache.getImages([ + previousCacheIndex, + this.currentCacheIndex, + nextCacheIndex + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + + } + else{ + + if (itemEls.length === 1){ + if (!ignoreCurrent){ + // Current + cacheImages = this.cache.getImages([ + this.currentCacheIndex + ]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + } + else if (itemEls.length === 2){ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + else{ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1, + this.currentCacheIndex + 2 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + else if (this.currentCacheIndex === this.cache.images.length-1){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 2, + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + + } + + }, + + + + /* + * Function: addCacheImageToItemEl + */ + addCacheImageToItemEl: function(cacheImage, itemEl){ + + Util.DOM.removeClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemError); + Util.DOM.addClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemLoading); + + Util.DOM.removeChildren(itemEl); + + Util.DOM.setStyle(cacheImage.imageEl, { + display: 'none' + }); + Util.DOM.appendChild(cacheImage.imageEl, itemEl); + + Util.Animation.resetTranslate(cacheImage.imageEl); + + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + cacheImage.load(); + + }, + + + + /* + * Function: slideCarousel + */ + slideCarousel: function(point, action, speed){ + + if (this.isSliding){ + return; + } + + var width, diffX, slideBy; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth() + this.settings.margin; + } + else{ + width = Util.DOM.width(this.settings.target) + this.settings.margin; + } + + speed = Util.coalesce(speed, this.settings.slideSpeed); + + if (window.Math.abs(diffX) < 1){ + return; + } + + + switch (action){ + + case Util.TouchElement.ActionTypes.swipeLeft: + + slideBy = width * -1; + break; + + case Util.TouchElement.ActionTypes.swipeRight: + + slideBy = width; + break; + + default: + + diffX = point.x - this.touchStartPoint.x; + + if (window.Math.abs(diffX) > width / 2){ + slideBy = (diffX > 0) ? width : width * -1; + } + else{ + slideBy = 0; + } + break; + + } + + if (slideBy < 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.next; + } + else if (slideBy > 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.previous; + } + else{ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + + // Check for non-looping carousels + // If we are at the start or end, spring back to the current item element + if (!this.settings.loop){ + if ( (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous && this.currentCacheIndex === 0 ) || (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next && this.currentCacheIndex === this.cache.images.length-1) ){ + slideBy = 0; + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + } + + this.isSliding = true; + this.doSlideCarousel(slideBy, speed); + + }, + + + + /* + * Function: + */ + moveCarousel: function(point){ + + if (this.isSliding){ + return; + } + + if (!this.settings.enableDrag){ + return; + } + + this.doMoveCarousel(point.x - this.touchStartPoint.x); + + }, + + + + /* + * Function: getItemEls + */ + getItemEls: function(){ + + return Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeRight, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: next + */ + next: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: slideshowNext + */ + slideshowNext: function(){ + + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft); + + }, + + + + + /* + * Function: startSlideshow + */ + startSlideshow: function(){ + + this.stopSlideshow(); + + this.isSlideshowActive = true; + + this.slideshowTimeout = window.setTimeout(this.slideshowNext.bind(this), this.settings.slideshowDelay); + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: stopSlideshow + */ + stopSlideshow: function(){ + + if (!Util.isNothing(this.slideshowTimeout)){ + + window.clearTimeout(this.slideshowTimeout); + this.slideshowTimeout = null; + this.isSlideshowActive = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStop, + target: this + }); + + } + + }, + + + + /* + * Function: onSlideByEnd + */ + onSlideByEnd: function(e){ + + if (Util.isNothing(this.isSliding)){ + return; + } + + var itemEls = this.getItemEls(); + + this.isSliding = false; + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + this.currentCacheIndex = this.currentCacheIndex + 1; + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + this.currentCacheIndex = this.currentCacheIndex - 1; + } + + if (this.settings.loop){ + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + + if (this.currentCacheIndex < 0){ + this.currentCacheIndex = this.cache.images.length - 1; + } + else if (this.currentCacheIndex === this.cache.images.length){ + this.currentCacheIndex = 0; + } + + } + else{ + + if (this.cache.images.length > 3){ + + if (this.currentCacheIndex > 1 && this.currentCacheIndex < this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === 1){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + } + + } + + + } + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.setContentLeftPosition(); + this.setImages(true); + } + + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideByEnd, + target: this, + action: this.lastSlideByAction, + cacheIndex: this.currentCacheIndex + }); + + + if (this.isSlideshowActive){ + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.startSlideshow(); + } + else{ + this.stopSlideshow(); + } + + } + + + }, + + + + /* + * Function: onTouch + */ + onTouch: function(action, point){ + + this.stopSlideshow(); + + switch(action){ + + case Util.TouchElement.ActionTypes.touchStart: + this.touchStartPoint = point; + this.touchStartPosition = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.moveCarousel(point); + break; + + case Util.TouchElement.ActionTypes.touchMoveEnd: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + this.slideCarousel(point, action); + break; + + case Util.TouchElement.ActionTypes.tap: + break; + + case Util.TouchElement.ActionTypes.doubleTap: + break; + + + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + this.resetImagePosition(cacheImage.imageEl); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + Util.DOM.addClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemError); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util, TouchElement){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = PhotoSwipe.Carousel.CarouselClass.extend({ + + + /* + * Function: getStartingPos + */ + getStartingPos: function(){ + + var startingPos = this.touchStartPosition; + + if (Util.isNothing(startingPos)){ + startingPos = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + } + + return startingPos; + + }, + + + + /* + * Function: doMoveCarousel + */ + doMoveCarousel: function(xVal){ + + var style; + + if (Util.Browser.isCSSTransformSupported){ + + style = {}; + + style[Util.Animation._transitionPrefix + 'Property'] = 'all'; + style[Util.Animation._transitionPrefix + 'Duration'] = ''; + style[Util.Animation._transitionPrefix + 'TimingFunction'] = ''; + style[Util.Animation._transitionPrefix + 'Delay'] = '0'; + style[Util.Animation._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(' + xVal + 'px, 0px, 0px)' : 'translate(' + xVal + 'px, 0px)'; + + Util.DOM.setStyle(this.contentEl, style); + + } + else if (!Util.isNothing(window.jQuery)){ + + + window.jQuery(this.contentEl).stop().css('left', this.getStartingPos().x + xVal + 'px'); + + } + + }, + + + + /* + * Function: doSlideCarousel + */ + doSlideCarousel: function(xVal, speed){ + + var animateProps, transform; + + if (speed <= 0){ + + this.slideByEndHandler(); + return; + + } + + + if (Util.Browser.isCSSTransformSupported){ + + transform = Util.coalesce(this.contentEl.style.webkitTransform, this.contentEl.style.MozTransform, this.contentEl.style.transform, ''); + if (transform.indexOf('translate3d(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + else if (transform.indexOf('translate(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + + Util.Animation.slideBy(this.contentEl, xVal, 0, speed, this.slideByEndHandler, this.settings.slideTimingFunction); + + } + else if (!Util.isNothing(window.jQuery)){ + + animateProps = { + left: this.getStartingPos().x + xVal + 'px' + }; + + if (this.settings.animationTimingFunction === 'ease-out'){ + this.settings.animationTimingFunction = 'easeOutQuad'; + } + + if ( Util.isNothing(window.jQuery.easing[this.settings.animationTimingFunction]) ){ + this.settings.animationTimingFunction = 'linear'; + } + + window.jQuery(this.contentEl).animate( + animateProps, + this.settings.slideSpeed, + this.settings.animationTimingFunction, + this.slideByEndHandler + ); + + } + + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.TouchElement +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.CssClasses = { + toolbar: 'ps-toolbar', + toolbarContent: 'ps-toolbar-content', + toolbarTop: 'ps-toolbar-top', + caption: 'ps-caption', + captionBottom: 'ps-caption-bottom', + captionContent: 'ps-caption-content', + close: 'ps-toolbar-close', + play: 'ps-toolbar-play', + previous: 'ps-toolbar-previous', + previousDisabled: 'ps-toolbar-previous-disabled', + next: 'ps-toolbar-next', + nextDisabled: 'ps-toolbar-next-disabled' + }; + + + + PhotoSwipe.Toolbar.ToolbarAction = { + close: 'close', + play: 'play', + next: 'next', + previous: 'previous', + none: 'none' + }; + + + + PhotoSwipe.Toolbar.EventTypes = { + onTap: 'PhotoSwipeToolbarOnClick', + onBeforeShow: 'PhotoSwipeToolbarOnBeforeShow', + onShow: 'PhotoSwipeToolbarOnShow', + onBeforeHide: 'PhotoSwipeToolbarOnBeforeHide', + onHide: 'PhotoSwipeToolbarOnHide' + }; + + + + PhotoSwipe.Toolbar.getToolbar = function(){ + + return '
'; + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.ToolbarClass = klass({ + + + + toolbarEl: null, + closeEl: null, + playEl: null, + previousEl: null, + nextEl: null, + captionEl: null, + captionContentEl: null, + currentCaption: null, + settings: null, + cache: null, + timeout: null, + isVisible: null, + fadeOutHandler: null, + touchStartHandler: null, + touchMoveHandler: null, + clickHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.clearTimeout(); + + this.removeEventHandlers(); + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + Util.DOM.removeChild(this.toolbarEl, this.toolbarEl.parentNode); + Util.DOM.removeChild(this.captionEl, this.captionEl.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(cache, options){ + + var cssClass; + + this.settings = options; + this.cache = cache; + this.isVisible = false; + + this.fadeOutHandler = this.onFadeOut.bind(this); + this.touchStartHandler = this.onTouchStart.bind(this); + this.touchMoveHandler = this.onTouchMove.bind(this); + this.clickHandler = this.onClick.bind(this); + + + cssClass = PhotoSwipe.Toolbar.CssClasses.toolbar; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.toolbarTop; + } + + + // Toolbar + this.toolbarEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + this.settings.getToolbar() + ); + + + Util.DOM.setStyle(this.toolbarEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.toolbarEl); + } + else{ + Util.DOM.appendChild(this.toolbarEl, this.settings.target); + } + Util.DOM.hide(this.toolbarEl); + + this.closeEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.close, this.toolbarEl)[0]; + if (this.settings.preventHide && !Util.isNothing(this.closeEl)){ + Util.DOM.hide(this.closeEl); + } + + this.playEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.play, this.toolbarEl)[0]; + if (this.settings.preventSlideshow && !Util.isNothing(this.playEl)){ + Util.DOM.hide(this.playEl); + } + + this.nextEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.next, this.toolbarEl)[0]; + this.previousEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.previous, this.toolbarEl)[0]; + + + // Caption + cssClass = PhotoSwipe.Toolbar.CssClasses.caption; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.captionBottom; + } + + this.captionEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + '' + ); + Util.DOM.setStyle(this.captionEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.captionEl); + } + else{ + Util.DOM.appendChild(this.captionEl, this.settings.target); + } + Util.DOM.hide(this.captionEl); + + this.captionContentEl = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.Toolbar.CssClasses.captionContent + }, + '' + ); + Util.DOM.appendChild(this.captionContentEl, this.captionEl); + + this.addEventHandlers(); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, toolbarTop, captionTop; + + if (this.settings.target === window){ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = Util.DOM.windowScrollTop(); + captionTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.captionEl); + } + else { + toolbarTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.toolbarEl); + captionTop = Util.DOM.windowScrollTop(); + } + width = Util.DOM.windowWidth(); + } + else{ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = '0'; + captionTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.captionEl); + } + else{ + toolbarTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.toolbarEl); + captionTop = 0; + } + width = Util.DOM.width(this.settings.target); + } + + Util.DOM.setStyle(this.toolbarEl, { + top: toolbarTop + 'px', + width: width + }); + + Util.DOM.setStyle(this.captionEl, { + top: captionTop + 'px', + width: width + }); + }, + + + + /* + * Function: toggleVisibility + */ + toggleVisibility: function(index){ + + if (this.isVisible){ + this.fadeOut(); + } + else{ + this.show(index); + } + + }, + + + + /* + * Function: show + */ + show: function(index){ + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + this.resetPosition(); + this.setToolbarStatus(index); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeShow, + target: this + }); + + this.showToolbar(); + this.setCaption(index); + this.showCaption(); + + this.isVisible = true; + + this.setTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onShow, + target: this + }); + + }, + + + + /* + * Function: setTimeout + */ + setTimeout: function(){ + + if (this.settings.captionAndToolbarAutoHideDelay > 0){ + // Set a timeout to hide the toolbar + this.clearTimeout(); + this.timeout = window.setTimeout(this.fadeOut.bind(this), this.settings.captionAndToolbarAutoHideDelay); + } + + }, + + + + /* + * Function: clearTimeout + */ + clearTimeout: function(){ + + if (!Util.isNothing(this.timeout)){ + window.clearTimeout(this.timeout); + this.timeout = null; + } + + }, + + + + /* + * Function: fadeOut + */ + fadeOut: function(){ + + this.clearTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeHide, + target: this + }); + + Util.Animation.fadeOut(this.toolbarEl, this.settings.fadeOutSpeed); + Util.Animation.fadeOut(this.captionEl, this.settings.fadeOutSpeed, this.fadeOutHandler); + + this.isVisible = false; + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.add(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.add(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.add(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.add(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.remove(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.remove(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.remove(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: handleTap + */ + handleTap: function(e){ + + this.clearTimeout(); + + var action; + + if (e.target === this.nextEl || Util.DOM.isChildOf(e.target, this.nextEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.next; + } + else if (e.target === this.previousEl || Util.DOM.isChildOf(e.target, this.previousEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.previous; + } + else if (e.target === this.closeEl || Util.DOM.isChildOf(e.target, this.closeEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.close; + } + else if (e.target === this.playEl || Util.DOM.isChildOf(e.target, this.playEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.play; + } + + this.setTimeout(); + + if (Util.isNothing(action)){ + action = PhotoSwipe.Toolbar.ToolbarAction.none; + } + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onTap, + target: this, + action: action, + tapTarget: e.target + }); + + }, + + + + /* + * Function: setCaption + */ + setCaption: function(index){ + + Util.DOM.removeChildren(this.captionContentEl); + + this.currentCaption = Util.coalesce(this.cache.images[index].caption, '\u00A0'); + + if (Util.isObject(this.currentCaption)){ + Util.DOM.appendChild(this.currentCaption, this.captionContentEl); + } + else{ + if (this.currentCaption === ''){ + this.currentCaption = '\u00A0'; + } + Util.DOM.appendText(this.currentCaption, this.captionContentEl); + } + + this.currentCaption = (this.currentCaption === '\u00A0') ? '' : this.currentCaption; + this.resetPosition(); + + }, + + + + /* + * Function: showToolbar + */ + showToolbar: function(){ + + Util.DOM.setStyle(this.toolbarEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.toolbarEl); + + }, + + + + /* + * Function: showCaption + */ + showCaption: function(){ + + if (this.currentCaption === '' || this.captionContentEl.childNodes.length < 1){ + // Empty caption + if (!this.settings.captionAndToolbarShowEmptyCaptions){ + Util.DOM.hide(this.captionEl); + return; + } + } + Util.DOM.setStyle(this.captionEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.captionEl); + + }, + + + + /* + * Function: setToolbarStatus + */ + setToolbarStatus: function(index){ + + if (this.settings.loop){ + return; + } + + Util.DOM.removeClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + Util.DOM.removeClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + + if (index > 0 && index < this.cache.images.length-1){ + return; + } + + if (index === 0){ + if (!Util.isNothing(this.previousEl)){ + Util.DOM.addClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + } + } + + if (index === this.cache.images.length-1){ + if (!Util.isNothing(this.nextEl)){ + Util.DOM.addClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + } + } + + }, + + + + /* + * Function: onFadeOut + */ + onFadeOut: function(){ + + Util.DOM.hide(this.toolbarEl); + Util.DOM.hide(this.captionEl); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onHide, + target: this + }); + + }, + + + + /* + * Function: onTouchStart + */ + onTouchStart: function(e){ + + e.preventDefault(); + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + this.handleTap(e); + + }, + + + + /* + * Function: onTouchMove + */ + onTouchMove: function(e){ + + e.preventDefault(); + + }, + + + + /* + * Function: onClick + */ + onClick: function(e){ + + e.preventDefault(); + this.handleTap(e); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.UILayer.CssClasses = { + uiLayer: 'ps-uilayer' + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.UILayer.UILayerClass = Util.TouchElement.TouchElementClass.extend({ + + + + el: null, + settings: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.removeEventHandlers(); + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options){ + + this.settings = options; + + // Main container + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.UILayer.CssClasses.uiLayer + }, + '' + ); + Util.DOM.setStyle(this.el, { + display: 'block', + position: 'absolute', + left: 0, + top: 0, + overflow: 'hidden', + zIndex: this.settings.zIndex, + opacity: 0 + }); + Util.DOM.hide(this.el); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + this.supr(this.el, { + swipe: true, + move: true, + gesture: Util.Browser.iOS, + doubleTap: true, + preventDefaultTouchEvents: this.settings.preventDefaultTouchEvents + }); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + // Set the height and width to fill the document + if (this.settings.target === window){ + Util.DOM.setStyle(this.el, { + top: Util.DOM.windowScrollTop() + 'px', + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }); + } + else{ + Util.DOM.setStyle(this.el, { + top: '0px', + width: Util.DOM.width(this.settings.target), + height: Util.DOM.height(this.settings.target) + }); + } + + }, + + + + /* + * Function: show + */ + show: function(){ + + this.resetPosition(); + Util.DOM.show(this.el); + this.addEventHandlers(); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + this.supr(); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + this.supr(); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.ZoomPanRotate.CssClasses = { + zoomPanRotate: 'ps-zoom-pan-rotate' + }; + + + PhotoSwipe.ZoomPanRotate.EventTypes = { + + onTransform: 'PhotoSwipeZoomPanRotateOnTransform' + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.ZoomPanRotate.ZoomPanRotateClass = klass({ + + el: null, + settings: null, + containerEl: null, + imageEl: null, + transformSettings: null, + panStartingPoint: null, + transformEl: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options, cacheImage, uiLayer){ + + var parentEl, width, height, top; + + this.settings = options; + + if (this.settings.target === window){ + parentEl = document.body; + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + parentEl = this.settings.target; + width = Util.DOM.width(parentEl); + height = Util.DOM.height(parentEl); + top = '0px'; + } + + this.imageEl = cacheImage.imageEl.cloneNode(false); + Util.DOM.setStyle(this.imageEl, { + + zIndex: 1 + + }); + + this.transformSettings = { + + startingScale: 1.0, + scale: 1.0, + startingRotation: 0, + rotation: 0, + startingTranslateX: 0, + startingTranslateY: 0, + translateX: 0, + translateY: 0 + + }; + + + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.ZoomPanRotate.CssClasses.zoomPanRotate + }, + '' + ); + Util.DOM.setStyle(this.el, { + left: 0, + top: top, + position: 'absolute', + width: width, + height: height, + zIndex: this.settings.zIndex, + display: 'block' + }); + + Util.DOM.insertBefore(this.el, uiLayer.el, parentEl); + + if (Util.Browser.iOS){ + this.containerEl = Util.DOM.createElement('div','',''); + Util.DOM.setStyle(this.containerEl, { + left: 0, + top: 0, + width: width, + height: height, + position: 'absolute', + zIndex: 1 + }); + Util.DOM.appendChild(this.imageEl, this.containerEl); + Util.DOM.appendChild(this.containerEl, this.el); + Util.Animation.resetTranslate(this.containerEl); + Util.Animation.resetTranslate(this.imageEl); + this.transformEl = this.containerEl; + } + else{ + Util.DOM.appendChild(this.imageEl, this.el); + this.transformEl = this.imageEl; + } + + }, + + + + /* + * Function: setStartingTranslateFromCurrentTransform + */ + setStartingTranslateFromCurrentTransform: function(){ + + var + transformValue = Util.coalesce(this.transformEl.style.webkitTransform, this.transformEl.style.MozTransform, this.transformEl.style.transform), + transformExploded; + + if (!Util.isNothing(transformValue)){ + + transformExploded = transformValue.match( /translate\((.*?)\)/ ); + + if (!Util.isNothing(transformExploded)){ + + transformExploded = transformExploded[1].split(', '); + this.transformSettings.startingTranslateX = window.parseInt(transformExploded[0], 10); + this.transformSettings.startingTranslateY = window.parseInt(transformExploded[1], 10); + + } + + } + + }, + + + + /* + * Function: getScale + */ + getScale: function(scaleValue){ + + var scale = this.transformSettings.startingScale * scaleValue; + + if (this.settings.minUserZoom !== 0 && scale < this.settings.minUserZoom){ + scale = this.settings.minUserZoom; + } + else if (this.settings.maxUserZoom !== 0 && scale > this.settings.maxUserZoom){ + scale = this.settings.maxUserZoom; + } + + return scale; + + }, + + + + /* + * Function: setStartingScaleAndRotation + */ + setStartingScaleAndRotation: function(scaleValue, rotationValue){ + + this.transformSettings.startingScale = this.getScale(scaleValue); + + this.transformSettings.startingRotation = + (this.transformSettings.startingRotation + rotationValue) % 360; + + }, + + + + /* + * Function: zoomRotate + */ + zoomRotate: function(scaleValue, rotationValue){ + + this.transformSettings.scale = this.getScale(scaleValue); + + this.transformSettings.rotation = + this.transformSettings.startingRotation + rotationValue; + + this.applyTransform(); + + }, + + + + /* + * Function: panStart + */ + panStart: function(point){ + + this.setStartingTranslateFromCurrentTransform(); + + this.panStartingPoint = { + x: point.x, + y: point.y + }; + + }, + + + + /* + * Function: pan + */ + pan: function(point){ + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale , + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + this.transformSettings.startingTranslateX + dxScaleAdjust; + + this.transformSettings.translateY = + this.transformSettings.startingTranslateY + dyScaleAdjust; + + this.applyTransform(); + + }, + + + + /* + * Function: zoomAndPanToPoint + */ + zoomAndPanToPoint: function(scaleValue, point){ + + + if (this.settings.target === window){ + + this.panStart({ + x: Util.DOM.windowWidth() / 2, + y: Util.DOM.windowHeight() / 2 + }); + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale, + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + (this.transformSettings.startingTranslateX + dxScaleAdjust) * -1; + + this.transformSettings.translateY = + (this.transformSettings.startingTranslateY + dyScaleAdjust) * -1; + + } + + + this.setStartingScaleAndRotation(scaleValue, 0); + this.transformSettings.scale = this.transformSettings.startingScale; + + this.transformSettings.rotation = 0; + + this.applyTransform(); + + }, + + + + /* + * Function: applyTransform + */ + applyTransform: function(){ + + var + rotationDegs = this.transformSettings.rotation % 360, + translateX = window.parseInt(this.transformSettings.translateX, 10), + translateY = window.parseInt(this.transformSettings.translateY, 10), + transform = 'scale(' + this.transformSettings.scale + ') rotate(' + rotationDegs + 'deg) translate(' + translateX + 'px, ' + translateY + 'px)'; + + Util.DOM.setStyle(this.transformEl, { + webkitTransform: transform, + MozTransform: transform, + msTransform: transform, + transform: transform + }); + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, + scale: this.transformSettings.scale, + rotation: this.transformSettings.rotation, + rotationDegs: rotationDegs, + translateX: translateX, + translateY: translateY + }); + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, Util){ + + + Util.registerNamespace('Code.PhotoSwipe'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.CssClasses = { + buildingBody: 'ps-building', + activeBody: 'ps-active' + }; + + + + PhotoSwipe.EventTypes = { + + onBeforeShow: 'PhotoSwipeOnBeforeShow', + onShow: 'PhotoSwipeOnShow', + onBeforeHide: 'PhotoSwipeOnBeforeHide', + onHide: 'PhotoSwipeOnHide', + onDisplayImage: 'PhotoSwipeOnDisplayImage', + onResetPosition: 'PhotoSwipeOnResetPosition', + onSlideshowStart: 'PhotoSwipeOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeOnSlideshowStop', + onTouch: 'PhotoSwipeOnTouch', + onBeforeCaptionAndToolbarShow: 'PhotoSwipeOnBeforeCaptionAndToolbarShow', + onCaptionAndToolbarShow: 'PhotoSwipeOnCaptionAndToolbarShow', + onBeforeCaptionAndToolbarHide: 'PhotoSwipeOnBeforeCaptionAndToolbarHide', + onCaptionAndToolbarHide: 'PhotoSwipeOnCaptionAndToolbarHide', + onToolbarTap: 'PhotoSwipeOnToolbarTap', + onBeforeZoomPanRotateShow: 'PhotoSwipeOnBeforeZoomPanRotateShow', + onZoomPanRotateShow: 'PhotoSwipeOnZoomPanRotateShow', + onBeforeZoomPanRotateHide: 'PhotoSwipeOnBeforeZoomPanRotateHide', + onZoomPanRotateHide: 'PhotoSwipeOnZoomPanRotateHide', + onZoomPanRotateTransform: 'PhotoSwipeOnZoomPanRotateTransform' + + }; + + + + PhotoSwipe.instances = []; + PhotoSwipe.activeInstances = []; + + + + /* + * Function: Code.PhotoSwipe.setActivateInstance + */ + PhotoSwipe.setActivateInstance = function(instance){ + + // Can only have one instance per target (i.e. window or div) + var index = Util.arrayIndexOf(instance.settings.target, PhotoSwipe.activeInstances, 'target'); + if (index > -1){ + throw 'Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target'; + } + PhotoSwipe.activeInstances.push({ + target: instance.settings.target, + instance: instance + }); + + }; + + + + /* + * Function: Code.PhotoSwipe.unsetActivateInstance + */ + PhotoSwipe.unsetActivateInstance = function(instance){ + + var index = Util.arrayIndexOf(instance, PhotoSwipe.activeInstances, 'instance'); + PhotoSwipe.activeInstances.splice(index, 1); + + }; + + + + /* + * Function: Code.PhotoSwipe.attach + */ + PhotoSwipe.attach = function(images, options, id){ + + var i, j, instance, image; + + instance = PhotoSwipe.createInstance(images, options, id); + + // Add click event handlers if applicable + for (i=0, j=images.length; i= 2.1){ + this.isBackEventSupported = true; + } + } + + if (!this.isBackEventSupported){ + this.isBackEventSupported = Util.objectHasProperty(window, 'onhashchange'); + } + + this.settings = { + + // General + fadeInSpeed: 250, + fadeOutSpeed: 250, + preventHide: false, + preventSlideshow: false, + zIndex: 1000, + backButtonHideEnabled: true, + enableKeyboard: true, + enableMouseWheel: true, + mouseWheelSpeed: 350, + autoStartSlideshow: false, + jQueryMobile: ( !Util.isNothing(window.jQuery) && !Util.isNothing(window.jQuery.mobile) ), + jQueryMobileDialogHash: '&ui-state=dialog', + enableUIWebViewRepositionTimeout: false, + uiWebViewResetPositionDelay: 500, + target: window, + preventDefaultTouchEvents: true, + + + // Carousel + loop: true, + slideSpeed: 250, + nextPreviousSlideSpeed: 0, + enableDrag: true, + swipeThreshold: 50, + swipeTimeThreshold: 250, + slideTimingFunction: 'ease-out', + slideshowDelay: 3000, + doubleTapSpeed: 250, + margin: 20, + imageScaleMethod: 'fit', // Either "fit", "fitNoUpscale" or "zoom", + + + // Toolbar + captionAndToolbarHide: false, + captionAndToolbarFlipPosition: false, + captionAndToolbarAutoHideDelay: 5000, + captionAndToolbarOpacity: 0.8, + captionAndToolbarShowEmptyCaptions: true, + getToolbar: PhotoSwipe.Toolbar.getToolbar, + + + // ZoomPanRotate + allowUserZoom: true, + allowRotationOnUserZoom: false, + maxUserZoom: 5.0, + minUserZoom: 0.5, + doubleTapZoomLevel: 2.5, + + + // Cache + getImageSource: PhotoSwipe.Cache.Functions.getImageSource, + getImageCaption: PhotoSwipe.Cache.Functions.getImageCaption, + getImageMetaData: PhotoSwipe.Cache.Functions.getImageMetaData, + cacheMode: PhotoSwipe.Cache.Mode.normal + + }; + + Util.extend(this.settings, options); + + if (this.settings.target !== window){ + targetPosition = Util.DOM.getStyle(this.settings.target, 'position'); + if (targetPosition !== 'relative' || targetPosition !== 'absolute'){ + Util.DOM.setStyle(this.settings.target, 'position', 'relative'); + } + } + + if (this.settings.target !== window){ + this.isBackEventSupported = false; + this.settings.backButtonHideEnabled = false; + } + else{ + if (this.settings.preventHide){ + this.settings.backButtonHideEnabled = false; + } + } + + this.cache = new Cache.CacheClass(images, this.settings); + + }, + + + + /* + * Function: show + */ + show: function(obj){ + + var i, j; + + this._isResettingPosition = false; + this.backButtonClicked = false; + + // Work out what the starting index is + if (Util.isNumber(obj)){ + this.currentIndex = obj; + } + else{ + + this.currentIndex = -1; + for (i=0, j=this.originalImages.length; i this.originalImages.length-1){ + throw "Code.PhotoSwipe.PhotoSwipeClass.show: Starting index out of range"; + } + + // Store a reference to the current window dimensions + // Use this later to double check that a window has actually + // been resized. + this.isAlreadyGettingPage = this.getWindowDimensions(); + + // Set this instance to be the active instance + PhotoSwipe.setActivateInstance(this); + + this.windowDimensions = this.getWindowDimensions(); + + // Create components + if (this.settings.target === window){ + Util.DOM.addClass(window.document.body, PhotoSwipe.CssClasses.buildingBody); + } + else{ + Util.DOM.addClass(this.settings.target, PhotoSwipe.CssClasses.buildingBody); + } + this.createComponents(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeShow, + target: this + }); + + // Fade in the document overlay + this.documentOverlay.fadeIn(this.settings.fadeInSpeed, this.onDocumentOverlayFadeIn.bind(this)); + + }, + + + + /* + * Function: getWindowDimensions + */ + getWindowDimensions: function(){ + + return { + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }; + + }, + + + + /* + * Function: createComponents + */ + createComponents: function(){ + + this.documentOverlay = new DocumentOverlay.DocumentOverlayClass(this.settings); + this.carousel = new Carousel.CarouselClass(this.cache, this.settings); + this.uiLayer = new UILayer.UILayerClass(this.settings); + if (!this.settings.captionAndToolbarHide){ + this.toolbar = new Toolbar.ToolbarClass(this.cache, this.settings); + } + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + if (this._isResettingPosition){ + return; + } + + var newWindowDimensions = this.getWindowDimensions(); + if (!Util.isNothing(this.windowDimensions)){ + if (newWindowDimensions.width === this.windowDimensions.width && newWindowDimensions.height === this.windowDimensions.height){ + // This was added as a fudge for iOS + return; + } + } + + this._isResettingPosition = true; + + this.windowDimensions = newWindowDimensions; + + this.destroyZoomPanRotate(); + + this.documentOverlay.resetPosition(); + this.carousel.resetPosition(); + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.resetPosition(); + } + + this.uiLayer.resetPosition(); + + this._isResettingPosition = false; + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onResetPosition, + target: this + }); + + }, + + + + /* + * Function: addEventHandler + */ + addEventHandler: function(type, handler){ + + Util.Events.add(this, type, handler); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.isNothing(this.windowOrientationChangeHandler)){ + + this.windowOrientationChangeHandler = this.onWindowOrientationChange.bind(this); + this.windowScrollHandler = this.onWindowScroll.bind(this); + this.keyDownHandler = this.onKeyDown.bind(this); + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + this.uiLayerTouchHandler = this.onUILayerTouch.bind(this); + this.carouselSlideByEndHandler = this.onCarouselSlideByEnd.bind(this); + this.carouselSlideshowStartHandler = this.onCarouselSlideshowStart.bind(this); + this.carouselSlideshowStopHandler = this.onCarouselSlideshowStop.bind(this); + this.toolbarTapHandler = this.onToolbarTap.bind(this); + this.toolbarBeforeShowHandler = this.onToolbarBeforeShow.bind(this); + this.toolbarShowHandler = this.onToolbarShow.bind(this); + this.toolbarBeforeHideHandler = this.onToolbarBeforeHide.bind(this); + this.toolbarHideHandler = this.onToolbarHide.bind(this); + this.mouseWheelHandler = this.onMouseWheel.bind(this); + this.zoomPanRotateTransformHandler = this.onZoomPanRotateTransform.bind(this); + + } + + // Set window handlers + if (Util.Browser.android){ + // For some reason, resize was more stable than orientationchange in Android + this.orientationEventName = 'resize'; + } + else if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.add(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + else{ + var supportsOrientationChange = !Util.isNothing(window.onorientationchange); + this.orientationEventName = supportsOrientationChange ? 'orientationchange' : 'resize'; + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.add(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + if (this.settings.target === window){ + Util.Events.add(window, 'scroll', this.windowScrollHandler); + } + + if (this.settings.enableKeyboard){ + Util.Events.add(window.document, 'keydown', this.keyDownHandler); + } + + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + + if (this.settings.jQueryMobile){ + window.location.hash = this.settings.jQueryMobileDialogHash; + } + else{ + this.currentHistoryHashValue = 'PhotoSwipe' + new Date().getTime().toString(); + window.location.hash = this.currentHistoryHashValue; + } + + Util.Events.add(window, 'hashchange', this.windowHashChangeHandler); + + } + + if (this.settings.enableMouseWheel){ + Util.Events.add(window, 'mousewheel', this.mouseWheelHandler); + } + + Util.Events.add(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + + if (!Util.isNothing(this.toolbar)){ + Util.Events.add(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.remove(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.remove(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + + Util.Events.remove(window, 'scroll', this.windowScrollHandler); + + if (this.settings.enableKeyboard){ + Util.Events.remove(window.document, 'keydown', this.keyDownHandler); + } + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + Util.Events.remove(window, 'hashchange', this.windowHashChangeHandler); + } + + if (this.settings.enableMouseWheel){ + Util.Events.remove(window, 'mousewheel', this.mouseWheelHandler); + } + + if (!Util.isNothing(this.uiLayer)){ + Util.Events.remove(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + + /* + * Function: hide + */ + hide: function(){ + + if (this.settings.preventHide){ + return; + } + + if (Util.isNothing(this.documentOverlay)){ + throw "Code.PhotoSwipe.PhotoSwipeClass.hide: PhotoSwipe instance is already hidden"; + } + + if (!Util.isNothing(this.hiding)){ + return; + } + + this.clearUIWebViewResetPositionTimeout(); + + this.destroyZoomPanRotate(); + + this.removeEventHandlers(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeHide, + target: this + }); + + this.uiLayer.dispose(); + this.uiLayer = null; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.dispose(); + this.toolbar = null; + } + + this.carousel.dispose(); + this.carousel = null; + + Util.DOM.removeClass(window.document.body, PhotoSwipe.CssClasses.activeBody); + + this.documentOverlay.dispose(); + this.documentOverlay = null; + + this._isResettingPosition = false; + + // Deactive this instance + PhotoSwipe.unsetActivateInstance(this); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onHide, + target: this + }); + + this.goBackInHistory(); + + }, + + + + /* + * Function: goBackInHistory + */ + goBackInHistory: function(){ + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + if ( !this.backButtonClicked ){ + window.history.back(); + } + } + + }, + + + + /* + * Function: play + */ + play: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!this.settings.preventSlideshow){ + if (!Util.isNothing(this.carousel)){ + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + this.carousel.startSlideshow(); + } + } + + }, + + + + /* + * Function: stop + */ + stop: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.stopSlideshow(); + } + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.previous(); + } + + }, + + + + /* + * Function: next + */ + next: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.next(); + } + + }, + + + + /* + * Function: toggleToolbar + */ + toggleToolbar: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.toggleVisibility(this.currentIndex); + } + + }, + + + + /* + * Function: fadeOutToolbarIfVisible + */ + fadeOutToolbarIfVisible: function(){ + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible && this.settings.captionAndToolbarAutoHideDelay > 0){ + this.toolbar.fadeOut(); + } + + }, + + + + /* + * Function: createZoomPanRotate + */ + createZoomPanRotate: function(){ + + this.stop(); + + if (this.canUserZoom() && !this.isZoomActive()){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateShow); + + this.zoomPanRotate = new ZoomPanRotate.ZoomPanRotateClass( + this.settings, + this.cache.images[this.currentIndex], + this.uiLayer + ); + + // If we don't override this in the event of false + // you will be unable to pan around a zoomed image effectively + this.uiLayer.captureSettings.preventDefaultTouchEvents = true; + + Util.Events.add(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateShow); + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + + } + + }, + + + + /* + * Function: destroyZoomPanRotate + */ + destroyZoomPanRotate: function(){ + + if (!Util.isNothing(this.zoomPanRotate)){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateHide); + + Util.Events.remove(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + this.zoomPanRotate.dispose(); + this.zoomPanRotate = null; + + // Set the preventDefaultTouchEvents back to it was + this.uiLayer.captureSettings.preventDefaultTouchEvents = this.settings.preventDefaultTouchEvents; + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateHide); + + } + + }, + + + + /* + * Function: canUserZoom + */ + canUserZoom: function(){ + + var testEl, cacheImage; + + if (Util.Browser.msie){ + testEl = document.createElement('div'); + if (Util.isNothing(testEl.style.msTransform)){ + return false; + } + } + else if (!Util.Browser.isCSSTransformSupported){ + return false; + } + + if (!this.settings.allowUserZoom){ + return false; + } + + + if (this.carousel.isSliding){ + return false; + } + + cacheImage = this.cache.images[this.currentIndex]; + + if (Util.isNothing(cacheImage)){ + return false; + } + + if (cacheImage.isLoading){ + return false; + } + + return true; + + }, + + + + /* + * Function: isZoomActive + */ + isZoomActive: function(){ + + return (!Util.isNothing(this.zoomPanRotate)); + + }, + + + + /* + * Function: getCurrentImage + */ + getCurrentImage: function(){ + + return this.cache.images[this.currentIndex]; + + }, + + + + /* + * Function: onDocumentOverlayFadeIn + */ + onDocumentOverlayFadeIn: function(e){ + + window.setTimeout(function(){ + + var el = (this.settings.target === window) ? window.document.body : this.settings.target; + + Util.DOM.removeClass(el, PhotoSwipe.CssClasses.buildingBody); + Util.DOM.addClass(el, PhotoSwipe.CssClasses.activeBody); + + this.addEventHandlers(); + + this.carousel.show(this.currentIndex); + + this.uiLayer.show(); + + if (this.settings.autoStartSlideshow){ + this.play(); + } + else if (!Util.isNothing(this.toolbar)){ + this.toolbar.show(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onShow, + target: this + }); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), 250); + + + }, + + + + /* + * Function: setUIWebViewResetPositionTimeout + */ + setUIWebViewResetPositionTimeout: function(){ + + if (!this.settings.enableUIWebViewRepositionTimeout){ + return; + } + + if (!(Util.Browser.iOS && (!Util.Browser.safari))){ + return; + } + + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + this._uiWebViewResetPositionTimeout = window.setTimeout(function(){ + + this.resetPosition(); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), this.settings.uiWebViewResetPositionDelay); + + }, + + + + /* + * Function: clearUIWebViewResetPositionTimeout + */ + clearUIWebViewResetPositionTimeout: function(){ + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + }, + + + + /* + * Function: onWindowScroll + */ + onWindowScroll: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowOrientationChange + */ + onWindowOrientationChange: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowHashChange + */ + onWindowHashChange: function(e){ + + var compareHash = '#' + + ((this.settings.jQueryMobile) ? this.settings.jQueryMobileDialogHash : this.currentHistoryHashValue); + + if (window.location.hash !== compareHash){ + this.backButtonClicked = true; + this.hide(); + } + + }, + + + + /* + * Function: onKeyDown + */ + onKeyDown: function(e){ + + if (e.keyCode === 37) { // Left + e.preventDefault(); + this.previous(); + } + else if (e.keyCode === 39) { // Right + e.preventDefault(); + this.next(); + } + else if (e.keyCode === 38 || e.keyCode === 40) { // Up and down + e.preventDefault(); + } + else if (e.keyCode === 27) { // Escape + e.preventDefault(); + this.hide(); + } + else if (e.keyCode === 32) { // Spacebar + if (!this.settings.hideToolbar){ + this.toggleToolbar(); + } + else{ + this.hide(); + } + e.preventDefault(); + } + else if (e.keyCode === 13) { // Enter + e.preventDefault(); + this.play(); + } + + }, + + + + /* + * Function: onUILayerTouch + */ + onUILayerTouch: function(e){ + + if (this.isZoomActive()){ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.gestureChange: + this.zoomPanRotate.zoomRotate(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.gestureEnd: + this.zoomPanRotate.setStartingScaleAndRotation(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.touchStart: + this.zoomPanRotate.panStart(e.point); + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.zoomPanRotate.pan(e.point); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + this.destroyZoomPanRotate(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeLeft: + this.destroyZoomPanRotate(); + this.next(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeRight: + this.destroyZoomPanRotate(); + this.previous(); + this.toggleToolbar(); + break; + } + + } + else{ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.touchMove: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + + // Hide the toolbar if need be + this.fadeOutToolbarIfVisible(); + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.touchStart: + case Util.TouchElement.ActionTypes.touchMoveEnd: + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.tap: + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + + // Take into consideration the window scroll + if (this.settings.target === window){ + e.point.x -= Util.DOM.windowScrollLeft(); + e.point.y -= Util.DOM.windowScrollTop(); + } + + // Just make sure that if the user clicks out of the image + // that the image does not pan out of view! + var + cacheImageEl = this.cache.images[this.currentIndex].imageEl, + + imageTop = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'top'), 10), + imageLeft = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'left'), 10), + imageRight = imageLeft + Util.DOM.width(cacheImageEl), + imageBottom = imageTop + Util.DOM.height(cacheImageEl); + + if (e.point.x < imageLeft){ + e.point.x = imageLeft; + } + else if (e.point.x > imageRight){ + e.point.x = imageRight; + } + + if (e.point.y < imageTop){ + e.point.y = imageTop; + } + else if (e.point.y > imageBottom){ + e.point.y = imageBottom; + } + + this.createZoomPanRotate(); + if (this.isZoomActive()){ + this.zoomPanRotate.zoomAndPanToPoint(this.settings.doubleTapZoomLevel, e.point); + } + + break; + + case Util.TouchElement.ActionTypes.gestureStart: + this.createZoomPanRotate(); + break; + } + + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onTouch, + target: this, + point: e.point, + action: e.action + }); + + }, + + + + /* + * Function: onCarouselSlideByEnd + */ + onCarouselSlideByEnd: function(e){ + + this.currentIndex = e.cacheIndex; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.setCaption(this.currentIndex); + this.toolbar.setToolbarStatus(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onDisplayImage, + target: this, + action: e.action, + index: e.cacheIndex + }); + + }, + + + + /* + * Function: onToolbarTap + */ + onToolbarTap: function(e){ + + switch(e.action){ + + case Toolbar.ToolbarAction.next: + this.next(); + break; + + case Toolbar.ToolbarAction.previous: + this.previous(); + break; + + case Toolbar.ToolbarAction.close: + this.hide(); + break; + + case Toolbar.ToolbarAction.play: + this.play(); + break; + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onToolbarTap, + target: this, + toolbarAction: e.action, + tapTarget: e.tapTarget + }); + + }, + + + + /* + * Function: onMouseWheel + */ + onMouseWheel: function(e){ + + var + delta = Util.Events.getWheelDelta(e), + dt = e.timeStamp - (this.mouseWheelStartTime || 0); + + if (dt < this.settings.mouseWheelSpeed) { + return; + } + + this.mouseWheelStartTime = e.timeStamp; + + if (this.settings.invertMouseWheel){ + delta = delta * -1; + } + + if (delta < 0){ + this.next(); + } + else if (delta > 0){ + this.previous(); + } + + }, + + + + /* + * Function: onCarouselSlideshowStart + */ + onCarouselSlideshowStart: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: onCarouselSlideshowStop + */ + onCarouselSlideshowStop: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStop, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeShow + */ + onToolbarBeforeShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarShow + */ + onToolbarShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeHide + */ + onToolbarBeforeHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onToolbarHide + */ + onToolbarHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onZoomPanRotateTransform + */ + onZoomPanRotateTransform: function(e){ + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.EventTypes.onZoomPanRotateTransform, + scale: e.scale, + rotation: e.rotation, + rotationDegs: e.rotationDegs, + translateX: e.translateX, + translateY: e.translateY + }); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.Cache, + window.Code.PhotoSwipe.DocumentOverlay, + window.Code.PhotoSwipe.Carousel, + window.Code.PhotoSwipe.Toolbar, + window.Code.PhotoSwipe.UILayer, + window.Code.PhotoSwipe.ZoomPanRotate +)); diff --git a/photoswipe/code.photoswipe-3.0.5.min.js b/photoswipe/code.photoswipe-3.0.5.min.js new file mode 100755 index 0000000..7c18191 --- /dev/null +++ b/photoswipe/code.photoswipe-3.0.5.min.js @@ -0,0 +1,172 @@ +// PhotoSwipe - http://www.photoswipe.com/ +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 +(function(e){if(!Function.prototype.bind)Function.prototype.bind=function(c){var a=[].slice,b=a.call(arguments,1),d=this,f=function(){},g=function(){return d.apply(this instanceof f?this:c||{},b.concat(a.call(arguments)))};f.prototype=d.prototype;g.prototype=new f;return g};if(typeof e.Code==="undefined")e.Code={};e.Code.Util={registerNamespace:function(){var c=arguments,a=null,b,d,f,g,h;b=0;for(g=c.length;bc.DOM.windowHeight()}};c.Browser._detect()})(window,window.Code.Util); +(function(e,c){c.extend(c,{Events:{add:function(a,b,d){this._checkHandlersProperty(a);b==="mousewheel"&&(b=this._normaliseMouseWheelType());typeof a.__eventHandlers[b]==="undefined"&&(a.__eventHandlers[b]=[]);a.__eventHandlers[b].push(d);this._isBrowserObject(a)&&a.addEventListener(b,d,!1)},remove:function(a,b,d){this._checkHandlersProperty(a);b==="mousewheel"&&(b=this._normaliseMouseWheelType());if(a.__eventHandlers[b]instanceof Array){var f,g,e=a.__eventHandlers[b];if(c.isNothing(d)){if(this._isBrowserObject(a)){f= +0;for(g=e.length;f=1;)a.removeChild(a.childNodes[a.childNodes.length-1])},hasAttribute:function(a,b){return!c.isNothing(a.getAttribute(b))},getAttribute:function(a,b,d){a=a.getAttribute(b);c.isNothing(a)&&!c.isNothing(d)&&(a=d);return a},setAttribute:function(a,b,d){if(c.isLikeArray(a)){var f,g;f=0;for(g=a.length;f=1&&c.DOM.setStyle(a,"opacity",0);c.Browser.isCSSTransformSupported?this._applyTransition(a,"opacity",g,b,d,f):c.isNothing(e.jQuery)||e.jQuery(a).fadeTo(b,g,d)},fadeTo:function(a,b,d,f,c){this.fadeIn(a, +d,f,c,b)},fadeOut:function(a,b,d,f){if(b<=0&&(c.DOM.setStyle(a,"opacity",0),!c.isNothing(d))){d(a);return}c.Browser.isCSSTransformSupported?this._applyTransition(a,"opacity",0,b,d,f):e.jQuery(a).fadeTo(b,0,d)},slideBy:function(a,b,d,f,g,h){var j={},b=c.coalesce(b,0),d=c.coalesce(d,0),h=c.coalesce(h,"ease-out");j[this._transitionPrefix+"Property"]="all";j[this._transitionPrefix+"Delay"]="0";f===0?(j[this._transitionPrefix+"Duration"]="",j[this._transitionPrefix+"TimingFunction"]=""):(j[this._transitionPrefix+ +"Duration"]=f+"ms",j[this._transitionPrefix+"TimingFunction"]=c.coalesce(h,"ease-out"),c.Events.add(a,this._transitionEndLabel,this._getTransitionEndHandler()));j[this._transformLabel]=c.Browser.is3dSupported?"translate3d("+b+"px, "+d+"px, 0px)":"translate("+b+"px, "+d+"px)";if(!c.isNothing(g))a.cclallcallback=g;c.DOM.setStyle(a,j);f===0&&e.setTimeout(function(){this._leaveTransforms(a)}.bind(this),this._applyTransitionDelay)},resetTranslate:function(a){var b={};b[this._transformLabel]=b[this._transformLabel]= +c.Browser.is3dSupported?"translate3d(0px, 0px, 0px)":"translate(0px, 0px)";c.DOM.setStyle(a,b)},_applyTransition:function(a,b,d,f,g,h){var j={},h=c.coalesce(h,"ease-in");j[this._transitionPrefix+"Property"]=b;j[this._transitionPrefix+"Duration"]=f+"ms";j[this._transitionPrefix+"TimingFunction"]=h;j[this._transitionPrefix+"Delay"]="0";c.Events.add(a,this._transitionEndLabel,this._getTransitionEndHandler());c.DOM.setStyle(a,j);c.isNothing(g)||(a["ccl"+b+"callback"]=g);e.setTimeout(function(){c.DOM.setStyle(a, +b,d)},this._applyTransitionDelay)},_onTransitionEnd:function(a){c.Events.remove(a.currentTarget,this._transitionEndLabel,this._getTransitionEndHandler());this._leaveTransforms(a.currentTarget)},_leaveTransforms:function(a){var b=a.style[this._transitionPrefix+"Property"],d=b!==""?"ccl"+b+"callback":"cclallcallback",f,b=c.coalesce(a.style.webkitTransform,a.style.MozTransform,a.style.transform),g,h=e.parseInt(c.DOM.getStyle(a,"left"),0),j=e.parseInt(c.DOM.getStyle(a,"top"),0),i,l,k={};b!==""&&(b=c.Browser.is3dSupported? +b.match(/translate3d\((.*?)\)/):b.match(/translate\((.*?)\)/),c.isNothing(b)||(g=b[1].split(", "),i=e.parseInt(g[0],0),l=e.parseInt(g[1],0)));k[this._transitionPrefix+"Property"]="";k[this._transitionPrefix+"Duration"]="";k[this._transitionPrefix+"TimingFunction"]="";k[this._transitionPrefix+"Delay"]="";c.DOM.setStyle(a,k);e.setTimeout(function(){if(!c.isNothing(g))k={},k[this._transformLabel]="",k.left=h+i+"px",k.top=j+l+"px",c.DOM.setStyle(a,k);c.isNothing(a[d])||(f=a[d],delete a[d],f(a))}.bind(this), +this._applyTransitionDelay)}}})})(window,window.Code.Util); +(function(e,c,a){a.registerNamespace("Code.Util.TouchElement");a.TouchElement.EventTypes={onTouch:"CodeUtilTouchElementOnTouch"};a.TouchElement.ActionTypes={touchStart:"touchStart",touchMove:"touchMove",touchEnd:"touchEnd",touchMoveEnd:"touchMoveEnd",tap:"tap",doubleTap:"doubleTap",swipeLeft:"swipeLeft",swipeRight:"swipeRight",swipeUp:"swipeUp",swipeDown:"swipeDown",gestureStart:"gestureStart",gestureChange:"gestureChange",gestureEnd:"gestureEnd"}})(window,window.klass,window.Code.Util); +(function(e,c,a){a.registerNamespace("Code.Util.TouchElement");a.TouchElement.TouchElementClass=c({el:null,captureSettings:null,touchStartPoint:null,touchEndPoint:null,touchStartTime:null,doubleTapTimeout:null,touchStartHandler:null,touchMoveHandler:null,touchEndHandler:null,mouseDownHandler:null,mouseMoveHandler:null,mouseUpHandler:null,mouseOutHandler:null,gestureStartHandler:null,gestureChangeHandler:null,gestureEndHandler:null,swipeThreshold:null,swipeTimeThreshold:null,doubleTapSpeed:null,dispose:function(){var b; +this.removeEventHandlers();for(b in this)a.objectHasProperty(this,b)&&(this[b]=null)},initialize:function(b,d){this.el=b;this.captureSettings={swipe:!1,move:!1,gesture:!1,doubleTap:!1,preventDefaultTouchEvents:!0};a.extend(this.captureSettings,d);this.swipeThreshold=50;this.doubleTapSpeed=this.swipeTimeThreshold=250;this.touchStartPoint={x:0,y:0};this.touchEndPoint={x:0,y:0}},addEventHandlers:function(){if(a.isNothing(this.touchStartHandler))this.touchStartHandler=this.onTouchStart.bind(this),this.touchMoveHandler= +this.onTouchMove.bind(this),this.touchEndHandler=this.onTouchEnd.bind(this),this.mouseDownHandler=this.onMouseDown.bind(this),this.mouseMoveHandler=this.onMouseMove.bind(this),this.mouseUpHandler=this.onMouseUp.bind(this),this.mouseOutHandler=this.onMouseOut.bind(this),this.gestureStartHandler=this.onGestureStart.bind(this),this.gestureChangeHandler=this.onGestureChange.bind(this),this.gestureEndHandler=this.onGestureEnd.bind(this);a.Events.add(this.el,"touchstart",this.touchStartHandler);this.captureSettings.move&& +a.Events.add(this.el,"touchmove",this.touchMoveHandler);a.Events.add(this.el,"touchend",this.touchEndHandler);a.Events.add(this.el,"mousedown",this.mouseDownHandler);a.Browser.isGestureSupported&&this.captureSettings.gesture&&(a.Events.add(this.el,"gesturestart",this.gestureStartHandler),a.Events.add(this.el,"gesturechange",this.gestureChangeHandler),a.Events.add(this.el,"gestureend",this.gestureEndHandler))},removeEventHandlers:function(){a.Events.remove(this.el,"touchstart",this.touchStartHandler); +this.captureSettings.move&&a.Events.remove(this.el,"touchmove",this.touchMoveHandler);a.Events.remove(this.el,"touchend",this.touchEndHandler);a.Events.remove(this.el,"mousedown",this.mouseDownHandler);a.Browser.isGestureSupported&&this.captureSettings.gesture&&(a.Events.remove(this.el,"gesturestart",this.gestureStartHandler),a.Events.remove(this.el,"gesturechange",this.gestureChangeHandler),a.Events.remove(this.el,"gestureend",this.gestureEndHandler))},getTouchPoint:function(a){return{x:a[0].pageX, +y:a[0].pageY}},fireTouchEvent:function(b){var d=0,f=0,c=0,h,d=this.touchEndPoint.x-this.touchStartPoint.x,f=this.touchEndPoint.y-this.touchStartPoint.y,c=Math.sqrt(d*d+f*f);if(this.captureSettings.swipe&&(h=new Date,h-=this.touchStartTime,h<=this.swipeTimeThreshold)){if(e.Math.abs(d)>=this.swipeThreshold){a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint,action:d<0?a.TouchElement.ActionTypes.swipeLeft:a.TouchElement.ActionTypes.swipeRight,targetEl:b.target, +currentTargetEl:b.currentTarget});return}if(e.Math.abs(f)>=this.swipeThreshold){a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint,action:f<0?a.TouchElement.ActionTypes.swipeUp:a.TouchElement.ActionTypes.swipeDown,targetEl:b.target,currentTargetEl:b.currentTarget});return}}c>1?a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchMoveEnd,point:this.touchEndPoint,targetEl:b.target,currentTargetEl:b.currentTarget}): +this.captureSettings.doubleTap?a.isNothing(this.doubleTapTimeout)?this.doubleTapTimeout=e.setTimeout(function(){this.doubleTapTimeout=null;a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint,action:a.TouchElement.ActionTypes.tap,targetEl:b.target,currentTargetEl:b.currentTarget})}.bind(this),this.doubleTapSpeed):(e.clearTimeout(this.doubleTapTimeout),this.doubleTapTimeout=null,a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint, +action:a.TouchElement.ActionTypes.doubleTap,targetEl:b.target,currentTargetEl:b.currentTarget})):a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint,action:a.TouchElement.ActionTypes.tap,targetEl:b.target,currentTargetEl:b.currentTarget})},onTouchStart:function(b){this.captureSettings.preventDefaultTouchEvents&&b.preventDefault();a.Events.remove(this.el,"mousedown",this.mouseDownHandler);var d=a.Events.getTouchEvent(b).touches;d.length>1&&this.captureSettings.gesture? +this.isGesture=!0:(this.touchStartTime=new Date,this.isGesture=!1,this.touchStartPoint=this.getTouchPoint(d),a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchStart,point:this.touchStartPoint,targetEl:b.target,currentTargetEl:b.currentTarget}))},onTouchMove:function(b){this.captureSettings.preventDefaultTouchEvents&&b.preventDefault();if(!this.isGesture||!this.captureSettings.gesture){var d=a.Events.getTouchEvent(b).touches;a.Events.fire(this, +{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchMove,point:this.getTouchPoint(d),targetEl:b.target,currentTargetEl:b.currentTarget})}},onTouchEnd:function(b){if(!this.isGesture||!this.captureSettings.gesture){this.captureSettings.preventDefaultTouchEvents&&b.preventDefault();var d=a.Events.getTouchEvent(b);this.touchEndPoint=this.getTouchPoint(!a.isNothing(d.changedTouches)?d.changedTouches:d.touches);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch, +target:this,action:a.TouchElement.ActionTypes.touchEnd,point:this.touchEndPoint,targetEl:b.target,currentTargetEl:b.currentTarget});this.fireTouchEvent(b)}},onMouseDown:function(b){b.preventDefault();a.Events.remove(this.el,"touchstart",this.mouseDownHandler);a.Events.remove(this.el,"touchmove",this.touchMoveHandler);a.Events.remove(this.el,"touchend",this.touchEndHandler);this.captureSettings.move&&a.Events.add(this.el,"mousemove",this.mouseMoveHandler);a.Events.add(this.el,"mouseup",this.mouseUpHandler); +a.Events.add(this.el,"mouseout",this.mouseOutHandler);this.touchStartTime=new Date;this.isGesture=!1;this.touchStartPoint=a.Events.getMousePosition(b);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchStart,point:this.touchStartPoint,targetEl:b.target,currentTargetEl:b.currentTarget})},onMouseMove:function(b){b.preventDefault();a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchMove, +point:a.Events.getMousePosition(b),targetEl:b.target,currentTargetEl:b.currentTarget})},onMouseUp:function(b){b.preventDefault();this.captureSettings.move&&a.Events.remove(this.el,"mousemove",this.mouseMoveHandler);a.Events.remove(this.el,"mouseup",this.mouseUpHandler);a.Events.remove(this.el,"mouseout",this.mouseOutHandler);this.touchEndPoint=a.Events.getMousePosition(b);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchEnd,point:this.touchEndPoint, +targetEl:b.target,currentTargetEl:b.currentTarget});this.fireTouchEvent(b)},onMouseOut:function(b){var d=b.relatedTarget;if(!(this.el===d||a.DOM.isChildOf(d,this.el)))b.preventDefault(),this.captureSettings.move&&a.Events.remove(this.el,"mousemove",this.mouseMoveHandler),a.Events.remove(this.el,"mouseup",this.mouseUpHandler),a.Events.remove(this.el,"mouseout",this.mouseOutHandler),this.touchEndPoint=a.Events.getMousePosition(b),a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this, +action:a.TouchElement.ActionTypes.touchEnd,point:this.touchEndPoint,targetEl:b.target,currentTargetEl:b.currentTarget}),this.fireTouchEvent(b)},onGestureStart:function(b){b.preventDefault();var d=a.Events.getTouchEvent(b);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.gestureStart,scale:d.scale,rotation:d.rotation,targetEl:b.target,currentTargetEl:b.currentTarget})},onGestureChange:function(b){b.preventDefault();var d=a.Events.getTouchEvent(b); +a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.gestureChange,scale:d.scale,rotation:d.rotation,targetEl:b.target,currentTargetEl:b.currentTarget})},onGestureEnd:function(b){b.preventDefault();var d=a.Events.getTouchEvent(b);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.gestureEnd,scale:d.scale,rotation:d.rotation,targetEl:b.target,currentTargetEl:b.currentTarget})}})})(window,window.klass, +window.Code.Util);(function(e,c,a){a.registerNamespace("Code.PhotoSwipe.Image");e.Code.PhotoSwipe.Image.EventTypes={onLoad:"onLoad",onError:"onError"}})(window,window.klass,window.Code.Util); +(function(e,c,a){a.registerNamespace("Code.PhotoSwipe.Image");var b=e.Code.PhotoSwipe;b.Image.ImageClass=c({refObj:null,imageEl:null,src:null,caption:null,metaData:null,imageLoadHandler:null,imageErrorHandler:null,dispose:function(){var d;this.shrinkImage();for(d in this)a.objectHasProperty(this,d)&&(this[d]=null)},initialize:function(a,b,c,h){this.refObj=a;this.src=this.originalSrc=b;this.caption=c;this.metaData=h;this.imageEl=new e.Image;this.imageLoadHandler=this.onImageLoad.bind(this);this.imageErrorHandler= +this.onImageError.bind(this)},load:function(){this.imageEl.originalSrc=a.coalesce(this.imageEl.originalSrc,"");this.imageEl.originalSrc===this.src?this.imageEl.isError?a.Events.fire(this,{type:b.Image.EventTypes.onError,target:this}):a.Events.fire(this,{type:b.Image.EventTypes.onLoad,target:this}):(this.imageEl.isError=!1,this.imageEl.isLoading=!0,this.imageEl.naturalWidth=null,this.imageEl.naturalHeight=null,this.imageEl.isLandscape=!1,this.imageEl.onload=this.imageLoadHandler,this.imageEl.onerror= +this.imageErrorHandler,this.imageEl.onabort=this.imageErrorHandler,this.imageEl.originalSrc=this.src,this.imageEl.src=this.src)},shrinkImage:function(){if(!a.isNothing(this.imageEl)&&this.imageEl.src.indexOf(this.src)>-1)this.imageEl.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",a.isNothing(this.imageEl.parentNode)||a.DOM.removeChild(this.imageEl,this.imageEl.parentNode)},onImageLoad:function(){this.imageEl.onload=null;this.imageEl.naturalWidth=a.coalesce(this.imageEl.naturalWidth, +this.imageEl.width);this.imageEl.naturalHeight=a.coalesce(this.imageEl.naturalHeight,this.imageEl.height);this.imageEl.isLandscape=this.imageEl.naturalWidth>this.imageEl.naturalHeight;this.imageEl.isLoading=!1;a.Events.fire(this,{type:b.Image.EventTypes.onLoad,target:this})},onImageError:function(){this.imageEl.onload=null;this.imageEl.onerror=null;this.imageEl.onabort=null;this.imageEl.isLoading=!1;this.imageEl.isError=!0;a.Events.fire(this,{type:b.Image.EventTypes.onError,target:this})}})})(window, +window.klass,window.Code.Util); +(function(e,c,a){a.registerNamespace("Code.PhotoSwipe.Cache");e=e.Code.PhotoSwipe;e.Cache.Mode={normal:"normal",aggressive:"aggressive"};e.Cache.Functions={getImageSource:function(a){return a.href},getImageCaption:function(b){if(b.nodeName==="IMG")return a.DOM.getAttribute(b,"alt");var d,f,c;d=0;for(f=b.childNodes.length;df&& +(f=a.DOM.windowHeight())}else b=a.DOM.width(this.settings.target),f=a.DOM.height(this.settings.target),c="0px";a.DOM.setStyle(this.el,{width:b,height:f,top:c})},fadeIn:function(b,f){this.resetPosition();a.DOM.setStyle(this.el,"opacity",0);a.DOM.show(this.el);a.Animation.fadeIn(this.el,b,f)}})})(window,window.klass,window.Code.Util); +(function(e,c,a){a.registerNamespace("Code.PhotoSwipe.Carousel");e=e.Code.PhotoSwipe;e.Carousel.EventTypes={onSlideByEnd:"PhotoSwipeCarouselOnSlideByEnd",onSlideshowStart:"PhotoSwipeCarouselOnSlideshowStart",onSlideshowStop:"PhotoSwipeCarouselOnSlideshowStop"};e.Carousel.CssClasses={carousel:"ps-carousel",content:"ps-carousel-content",item:"ps-carousel-item",itemLoading:"ps-carousel-item-loading",itemError:"ps-carousel-item-error"};e.Carousel.SlideByAction={previous:"previous",current:"current",next:"next"}})(window, +window.klass,window.Code.Util); +(function(e,c,a){a.registerNamespace("Code.PhotoSwipe.Carousel");var b=e.Code.PhotoSwipe;b.Carousel.CarouselClass=c({el:null,contentEl:null,settings:null,cache:null,slideByEndHandler:null,currentCacheIndex:null,isSliding:null,isSlideshowActive:null,lastSlideByAction:null,touchStartPoint:null,touchStartPosition:null,imageLoadHandler:null,imageErrorHandler:null,slideshowTimeout:null,dispose:function(){var d,f,c;f=0;for(c=this.cache.images.length;f0&&a.DOM.setStyle(j,{marginRight:this.settings.margin+"px"}),a.DOM.appendChild(j,this.contentEl);this.settings.target===e?a.DOM.appendToBody(this.el):a.DOM.appendChild(this.el,this.settings.target)}, +resetPosition:function(){var d,f,c,h,j,i;this.settings.target===e?(d=a.DOM.windowWidth(),f=a.DOM.windowHeight(),c=a.DOM.windowScrollTop()+"px"):(d=a.DOM.width(this.settings.target),f=a.DOM.height(this.settings.target),c="0px");h=this.settings.margin>0?d+this.settings.margin:d;j=a.DOM.find("."+b.Carousel.CssClasses.item,this.contentEl);h*=j.length;a.DOM.setStyle(this.el,{top:c,width:d,height:f});a.DOM.setStyle(this.contentEl,{width:h,height:f});c=0;for(h=j.length;cj&&(c=j/e,e=Math.round(e*c),h=Math.round(h*c)),h>i&&(c=i/h,h=Math.round(h*c),e=Math.round(e*c))):(c=b.isLandscape?j/b.naturalWidth:i/b.naturalHeight,e=Math.round(b.naturalWidth* +c),h=Math.round(b.naturalHeight*c),this.settings.imageScaleMethod==="zoom"?(c=1,hj?c=j/e:h>i&&(c=i/h),c!==1&&(e=Math.round(e*c),h=Math.round(h*c))));a.DOM.setStyle(b,{position:"absolute",width:e,height:h,top:Math.round((i-h)/2)+"px",left:Math.round((j-e)/2)+"px",display:"block"})}},setContentLeftPosition:function(){var b,c,g;b=this.settings.target===e?a.DOM.windowWidth():a.DOM.width(this.settings.target); +c=this.getItemEls();g=0;this.settings.loop?g=(b+this.settings.margin)*-1:this.currentCacheIndex===this.cache.images.length-1?g=(c.length-1)*(b+this.settings.margin)*-1:this.currentCacheIndex>0&&(g=(b+this.settings.margin)*-1);a.DOM.setStyle(this.contentEl,{left:g+"px"})},show:function(d){this.currentCacheIndex=d;this.resetPosition();this.setImages(!1);a.DOM.show(this.el);a.Animation.resetTranslate(this.contentEl);var d=this.getItemEls(),c,e;c=0;for(e=d.length;cthis.cache.images.length-1&&(b=0),e<0&&(e=this.cache.images.length-1),b=this.cache.getImages([e,this.currentCacheIndex,b]),a||this.addCacheImageToItemEl(b[1],c[1]),this.addCacheImageToItemEl(b[2],c[2]),this.addCacheImageToItemEl(b[0], +c[0])):c.length===1?a||(b=this.cache.getImages([this.currentCacheIndex]),this.addCacheImageToItemEl(b[0],c[0])):c.length===2?this.currentCacheIndex===0?(b=this.cache.getImages([this.currentCacheIndex,this.currentCacheIndex+1]),a||this.addCacheImageToItemEl(b[0],c[0]),this.addCacheImageToItemEl(b[1],c[1])):(b=this.cache.getImages([this.currentCacheIndex-1,this.currentCacheIndex]),a||this.addCacheImageToItemEl(b[1],c[1]),this.addCacheImageToItemEl(b[0],c[0])):this.currentCacheIndex===0?(b=this.cache.getImages([this.currentCacheIndex, +this.currentCacheIndex+1,this.currentCacheIndex+2]),a||this.addCacheImageToItemEl(b[0],c[0]),this.addCacheImageToItemEl(b[1],c[1]),this.addCacheImageToItemEl(b[2],c[2])):(this.currentCacheIndex===this.cache.images.length-1?(b=this.cache.getImages([this.currentCacheIndex-2,this.currentCacheIndex-1,this.currentCacheIndex]),a||this.addCacheImageToItemEl(b[2],c[2]),this.addCacheImageToItemEl(b[1],c[1])):(b=this.cache.getImages([this.currentCacheIndex-1,this.currentCacheIndex,this.currentCacheIndex+1]), +a||this.addCacheImageToItemEl(b[1],c[1]),this.addCacheImageToItemEl(b[2],c[2])),this.addCacheImageToItemEl(b[0],c[0]))},addCacheImageToItemEl:function(d,c){a.DOM.removeClass(c,b.Carousel.CssClasses.itemError);a.DOM.addClass(c,b.Carousel.CssClasses.itemLoading);a.DOM.removeChildren(c);a.DOM.setStyle(d.imageEl,{display:"none"});a.DOM.appendChild(d.imageEl,c);a.Animation.resetTranslate(d.imageEl);a.Events.add(d,b.Image.EventTypes.onLoad,this.imageLoadHandler);a.Events.add(d,b.Image.EventTypes.onError, +this.imageErrorHandler);d.load()},slideCarousel:function(d,c,g){if(!this.isSliding){var h,j;h=this.settings.target===e?a.DOM.windowWidth()+this.settings.margin:a.DOM.width(this.settings.target)+this.settings.margin;g=a.coalesce(g,this.settings.slideSpeed);if(!(e.Math.abs(j)<1)){switch(c){case a.TouchElement.ActionTypes.swipeLeft:d=h*-1;break;case a.TouchElement.ActionTypes.swipeRight:d=h;break;default:j=d.x-this.touchStartPoint.x,d=e.Math.abs(j)>h/2?j>0?h:h*-1:0}this.lastSlideByAction=d<0?b.Carousel.SlideByAction.next: +d>0?b.Carousel.SlideByAction.previous:b.Carousel.SlideByAction.current;if(!this.settings.loop&&(this.lastSlideByAction===b.Carousel.SlideByAction.previous&&this.currentCacheIndex===0||this.lastSlideByAction===b.Carousel.SlideByAction.next&&this.currentCacheIndex===this.cache.images.length-1))d=0,this.lastSlideByAction=b.Carousel.SlideByAction.current;this.isSliding=!0;this.doSlideCarousel(d,g)}}},moveCarousel:function(a){this.isSliding||this.settings.enableDrag&&this.doMoveCarousel(a.x-this.touchStartPoint.x)}, +getItemEls:function(){return a.DOM.find("."+b.Carousel.CssClasses.item,this.contentEl)},previous:function(){this.stopSlideshow();this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeRight,this.settings.nextPreviousSlideSpeed)},next:function(){this.stopSlideshow();this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeLeft,this.settings.nextPreviousSlideSpeed)},slideshowNext:function(){this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeLeft)},startSlideshow:function(){this.stopSlideshow(); +this.isSlideshowActive=!0;this.slideshowTimeout=e.setTimeout(this.slideshowNext.bind(this),this.settings.slideshowDelay);a.Events.fire(this,{type:b.Carousel.EventTypes.onSlideshowStart,target:this})},stopSlideshow:function(){if(!a.isNothing(this.slideshowTimeout))e.clearTimeout(this.slideshowTimeout),this.slideshowTimeout=null,this.isSlideshowActive=!1,a.Events.fire(this,{type:b.Carousel.EventTypes.onSlideshowStop,target:this})},onSlideByEnd:function(){if(!a.isNothing(this.isSliding)){var d=this.getItemEls(); +this.isSliding=!1;this.lastSlideByAction===b.Carousel.SlideByAction.next?this.currentCacheIndex+=1:this.lastSlideByAction===b.Carousel.SlideByAction.previous&&(this.currentCacheIndex-=1);if(this.settings.loop)if(this.lastSlideByAction===b.Carousel.SlideByAction.next?a.DOM.appendChild(d[0],this.contentEl):this.lastSlideByAction===b.Carousel.SlideByAction.previous&&a.DOM.insertBefore(d[d.length-1],d[0],this.contentEl),this.currentCacheIndex<0)this.currentCacheIndex=this.cache.images.length-1;else{if(this.currentCacheIndex=== +this.cache.images.length)this.currentCacheIndex=0}else this.cache.images.length>3&&(this.currentCacheIndex>1&&this.currentCacheIndex
'}})(window,window.klass,window.Code.Util); +(function(e,c,a){a.registerNamespace("Code.PhotoSwipe.Toolbar");var b=e.Code.PhotoSwipe;b.Toolbar.ToolbarClass=c({toolbarEl:null,closeEl:null,playEl:null,previousEl:null,nextEl:null,captionEl:null,captionContentEl:null,currentCaption:null,settings:null,cache:null,timeout:null,isVisible:null,fadeOutHandler:null,touchStartHandler:null,touchMoveHandler:null,clickHandler:null,dispose:function(){var b;this.clearTimeout();this.removeEventHandlers();a.Animation.stop(this.toolbarEl);a.Animation.stop(this.captionEl); +a.DOM.removeChild(this.toolbarEl,this.toolbarEl.parentNode);a.DOM.removeChild(this.captionEl,this.captionEl.parentNode);for(b in this)a.objectHasProperty(this,b)&&(this[b]=null)},initialize:function(d,c){var g;this.settings=c;this.cache=d;this.isVisible=!1;this.fadeOutHandler=this.onFadeOut.bind(this);this.touchStartHandler=this.onTouchStart.bind(this);this.touchMoveHandler=this.onTouchMove.bind(this);this.clickHandler=this.onClick.bind(this);g=b.Toolbar.CssClasses.toolbar;this.settings.captionAndToolbarFlipPosition&& +(g=g+" "+b.Toolbar.CssClasses.toolbarTop);this.toolbarEl=a.DOM.createElement("div",{"class":g},this.settings.getToolbar());a.DOM.setStyle(this.toolbarEl,{left:0,position:"absolute",overflow:"hidden",zIndex:this.settings.zIndex});this.settings.target===e?a.DOM.appendToBody(this.toolbarEl):a.DOM.appendChild(this.toolbarEl,this.settings.target);a.DOM.hide(this.toolbarEl);this.closeEl=a.DOM.find("."+b.Toolbar.CssClasses.close,this.toolbarEl)[0];this.settings.preventHide&&!a.isNothing(this.closeEl)&&a.DOM.hide(this.closeEl); +this.playEl=a.DOM.find("."+b.Toolbar.CssClasses.play,this.toolbarEl)[0];this.settings.preventSlideshow&&!a.isNothing(this.playEl)&&a.DOM.hide(this.playEl);this.nextEl=a.DOM.find("."+b.Toolbar.CssClasses.next,this.toolbarEl)[0];this.previousEl=a.DOM.find("."+b.Toolbar.CssClasses.previous,this.toolbarEl)[0];g=b.Toolbar.CssClasses.caption;this.settings.captionAndToolbarFlipPosition&&(g=g+" "+b.Toolbar.CssClasses.captionBottom);this.captionEl=a.DOM.createElement("div",{"class":g},"");a.DOM.setStyle(this.captionEl, +{left:0,position:"absolute",overflow:"hidden",zIndex:this.settings.zIndex});this.settings.target===e?a.DOM.appendToBody(this.captionEl):a.DOM.appendChild(this.captionEl,this.settings.target);a.DOM.hide(this.captionEl);this.captionContentEl=a.DOM.createElement("div",{"class":b.Toolbar.CssClasses.captionContent},"");a.DOM.appendChild(this.captionContentEl,this.captionEl);this.addEventHandlers()},resetPosition:function(){var b,c,g;this.settings.target===e?(this.settings.captionAndToolbarFlipPosition? +(c=a.DOM.windowScrollTop(),g=a.DOM.windowScrollTop()+a.DOM.windowHeight()-a.DOM.height(this.captionEl)):(c=a.DOM.windowScrollTop()+a.DOM.windowHeight()-a.DOM.height(this.toolbarEl),g=a.DOM.windowScrollTop()),b=a.DOM.windowWidth()):(this.settings.captionAndToolbarFlipPosition?(c="0",g=a.DOM.height(this.settings.target)-a.DOM.height(this.captionEl)):(c=a.DOM.height(this.settings.target)-a.DOM.height(this.toolbarEl),g=0),b=a.DOM.width(this.settings.target));a.DOM.setStyle(this.toolbarEl,{top:c+"px", +width:b});a.DOM.setStyle(this.captionEl,{top:g+"px",width:b})},toggleVisibility:function(a){this.isVisible?this.fadeOut():this.show(a)},show:function(d){a.Animation.stop(this.toolbarEl);a.Animation.stop(this.captionEl);this.resetPosition();this.setToolbarStatus(d);a.Events.fire(this,{type:b.Toolbar.EventTypes.onBeforeShow,target:this});this.showToolbar();this.setCaption(d);this.showCaption();this.isVisible=!0;this.setTimeout();a.Events.fire(this,{type:b.Toolbar.EventTypes.onShow,target:this})},setTimeout:function(){if(this.settings.captionAndToolbarAutoHideDelay> +0)this.clearTimeout(),this.timeout=e.setTimeout(this.fadeOut.bind(this),this.settings.captionAndToolbarAutoHideDelay)},clearTimeout:function(){if(!a.isNothing(this.timeout))e.clearTimeout(this.timeout),this.timeout=null},fadeOut:function(){this.clearTimeout();a.Events.fire(this,{type:b.Toolbar.EventTypes.onBeforeHide,target:this});a.Animation.fadeOut(this.toolbarEl,this.settings.fadeOutSpeed);a.Animation.fadeOut(this.captionEl,this.settings.fadeOutSpeed,this.fadeOutHandler);this.isVisible=!1},addEventHandlers:function(){a.Browser.isTouchSupported&& +(a.Browser.blackberry||a.Events.add(this.toolbarEl,"touchstart",this.touchStartHandler),a.Events.add(this.toolbarEl,"touchmove",this.touchMoveHandler),a.Events.add(this.captionEl,"touchmove",this.touchMoveHandler));a.Events.add(this.toolbarEl,"click",this.clickHandler)},removeEventHandlers:function(){a.Browser.isTouchSupported&&(a.Browser.blackberry||a.Events.remove(this.toolbarEl,"touchstart",this.touchStartHandler),a.Events.remove(this.toolbarEl,"touchmove",this.touchMoveHandler),a.Events.remove(this.captionEl, +"touchmove",this.touchMoveHandler));a.Events.remove(this.toolbarEl,"click",this.clickHandler)},handleTap:function(d){this.clearTimeout();var c;if(d.target===this.nextEl||a.DOM.isChildOf(d.target,this.nextEl))c=b.Toolbar.ToolbarAction.next;else if(d.target===this.previousEl||a.DOM.isChildOf(d.target,this.previousEl))c=b.Toolbar.ToolbarAction.previous;else if(d.target===this.closeEl||a.DOM.isChildOf(d.target,this.closeEl))c=b.Toolbar.ToolbarAction.close;else if(d.target===this.playEl||a.DOM.isChildOf(d.target, +this.playEl))c=b.Toolbar.ToolbarAction.play;this.setTimeout();if(a.isNothing(c))c=b.Toolbar.ToolbarAction.none;a.Events.fire(this,{type:b.Toolbar.EventTypes.onTap,target:this,action:c,tapTarget:d.target})},setCaption:function(b){a.DOM.removeChildren(this.captionContentEl);this.currentCaption=a.coalesce(this.cache.images[b].caption,"\u00a0");if(a.isObject(this.currentCaption))a.DOM.appendChild(this.currentCaption,this.captionContentEl);else{if(this.currentCaption==="")this.currentCaption="\u00a0"; +a.DOM.appendText(this.currentCaption,this.captionContentEl)}this.currentCaption=this.currentCaption==="\u00a0"?"":this.currentCaption;this.resetPosition()},showToolbar:function(){a.DOM.setStyle(this.toolbarEl,{opacity:this.settings.captionAndToolbarOpacity});a.DOM.show(this.toolbarEl)},showCaption:function(){(this.currentCaption===""||this.captionContentEl.childNodes.length<1)&&!this.settings.captionAndToolbarShowEmptyCaptions?a.DOM.hide(this.captionEl):(a.DOM.setStyle(this.captionEl,{opacity:this.settings.captionAndToolbarOpacity}), +a.DOM.show(this.captionEl))},setToolbarStatus:function(d){this.settings.loop||(a.DOM.removeClass(this.previousEl,b.Toolbar.CssClasses.previousDisabled),a.DOM.removeClass(this.nextEl,b.Toolbar.CssClasses.nextDisabled),d>0&&dthis.settings.maxUserZoom)a=this.settings.maxUserZoom;return a},setStartingScaleAndRotation:function(a,b){this.transformSettings.startingScale=this.getScale(a);this.transformSettings.startingRotation=(this.transformSettings.startingRotation+b)%360},zoomRotate:function(a,b){this.transformSettings.scale=this.getScale(a);this.transformSettings.rotation=this.transformSettings.startingRotation+b;this.applyTransform()},panStart:function(a){this.setStartingTranslateFromCurrentTransform();this.panStartingPoint= +{x:a.x,y:a.y}},pan:function(a){var b=(a.y-this.panStartingPoint.y)/this.transformSettings.scale;this.transformSettings.translateX=this.transformSettings.startingTranslateX+(a.x-this.panStartingPoint.x)/this.transformSettings.scale;this.transformSettings.translateY=this.transformSettings.startingTranslateY+b;this.applyTransform()},zoomAndPanToPoint:function(b,c){if(this.settings.target===e){this.panStart({x:a.DOM.windowWidth()/2,y:a.DOM.windowHeight()/2});var g=(c.y-this.panStartingPoint.y)/this.transformSettings.scale; +this.transformSettings.translateX=(this.transformSettings.startingTranslateX+(c.x-this.panStartingPoint.x)/this.transformSettings.scale)*-1;this.transformSettings.translateY=(this.transformSettings.startingTranslateY+g)*-1}this.setStartingScaleAndRotation(b,0);this.transformSettings.scale=this.transformSettings.startingScale;this.transformSettings.rotation=0;this.applyTransform()},applyTransform:function(){var c=this.transformSettings.rotation%360,f=e.parseInt(this.transformSettings.translateX,10), +g=e.parseInt(this.transformSettings.translateY,10),h="scale("+this.transformSettings.scale+") rotate("+c+"deg) translate("+f+"px, "+g+"px)";a.DOM.setStyle(this.transformEl,{webkitTransform:h,MozTransform:h,msTransform:h,transform:h});a.Events.fire(this,{target:this,type:b.ZoomPanRotate.EventTypes.onTransform,scale:this.transformSettings.scale,rotation:this.transformSettings.rotation,rotationDegs:c,translateX:f,translateY:g})}})})(window,window.klass,window.Code.Util); +(function(e,c){c.registerNamespace("Code.PhotoSwipe");var a=e.Code.PhotoSwipe;a.CssClasses={buildingBody:"ps-building",activeBody:"ps-active"};a.EventTypes={onBeforeShow:"PhotoSwipeOnBeforeShow",onShow:"PhotoSwipeOnShow",onBeforeHide:"PhotoSwipeOnBeforeHide",onHide:"PhotoSwipeOnHide",onDisplayImage:"PhotoSwipeOnDisplayImage",onResetPosition:"PhotoSwipeOnResetPosition",onSlideshowStart:"PhotoSwipeOnSlideshowStart",onSlideshowStop:"PhotoSwipeOnSlideshowStop",onTouch:"PhotoSwipeOnTouch",onBeforeCaptionAndToolbarShow:"PhotoSwipeOnBeforeCaptionAndToolbarShow", +onCaptionAndToolbarShow:"PhotoSwipeOnCaptionAndToolbarShow",onBeforeCaptionAndToolbarHide:"PhotoSwipeOnBeforeCaptionAndToolbarHide",onCaptionAndToolbarHide:"PhotoSwipeOnCaptionAndToolbarHide",onToolbarTap:"PhotoSwipeOnToolbarTap",onBeforeZoomPanRotateShow:"PhotoSwipeOnBeforeZoomPanRotateShow",onZoomPanRotateShow:"PhotoSwipeOnZoomPanRotateShow",onBeforeZoomPanRotateHide:"PhotoSwipeOnBeforeZoomPanRotateHide",onZoomPanRotateHide:"PhotoSwipeOnZoomPanRotateHide",onZoomPanRotateTransform:"PhotoSwipeOnZoomPanRotateTransform"}; +a.instances=[];a.activeInstances=[];a.setActivateInstance=function(b){if(c.arrayIndexOf(b.settings.target,a.activeInstances,"target")>-1)throw"Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target";a.activeInstances.push({target:b.settings.target,instance:b})};a.unsetActivateInstance=function(b){b=c.arrayIndexOf(b,a.activeInstances,"instance");a.activeInstances.splice(b,1)};a.attach=function(b,d,e){var g,h;g=a.createInstance(b,d,e);d=0;for(e= +b.length;d=2.1)this.isBackEventSupported=!0;if(!this.isBackEventSupported)this.isBackEventSupported=a.objectHasProperty(e,"onhashchange");this.settings={fadeInSpeed:250,fadeOutSpeed:250,preventHide:!1,preventSlideshow:!1,zIndex:1E3,backButtonHideEnabled:!0,enableKeyboard:!0,enableMouseWheel:!0, +mouseWheelSpeed:350,autoStartSlideshow:!1,jQueryMobile:!a.isNothing(e.jQuery)&&!a.isNothing(e.jQuery.mobile),jQueryMobileDialogHash:"&ui-state=dialog",enableUIWebViewRepositionTimeout:!1,uiWebViewResetPositionDelay:500,target:e,preventDefaultTouchEvents:!0,loop:!0,slideSpeed:250,nextPreviousSlideSpeed:0,enableDrag:!0,swipeThreshold:50,swipeTimeThreshold:250,slideTimingFunction:"ease-out",slideshowDelay:3E3,doubleTapSpeed:250,margin:20,imageScaleMethod:"fit",captionAndToolbarHide:!1,captionAndToolbarFlipPosition:!1, +captionAndToolbarAutoHideDelay:5E3,captionAndToolbarOpacity:0.8,captionAndToolbarShowEmptyCaptions:!0,getToolbar:i.Toolbar.getToolbar,allowUserZoom:!0,allowRotationOnUserZoom:!1,maxUserZoom:5,minUserZoom:0.5,doubleTapZoomLevel:2.5,getImageSource:i.Cache.Functions.getImageSource,getImageCaption:i.Cache.Functions.getImageCaption,getImageMetaData:i.Cache.Functions.getImageMetaData,cacheMode:i.Cache.Mode.normal};a.extend(this.settings,d);this.settings.target!==e&&(d=a.DOM.getStyle(this.settings.target, +"position"),(d!=="relative"||d!=="absolute")&&a.DOM.setStyle(this.settings.target,"position","relative"));if(this.settings.target!==e)this.isBackEventSupported=!1,this.settings.backButtonHideEnabled=!1;else if(this.settings.preventHide)this.settings.backButtonHideEnabled=!1;this.cache=new b.CacheClass(c,this.settings)},show:function(b){var c,d;this.backButtonClicked=this._isResettingPosition=!1;if(a.isNumber(b))this.currentIndex=b;else{this.currentIndex=-1;c=0;for(d=this.originalImages.length;cthis.originalImages.length-1)throw"Code.PhotoSwipe.PhotoSwipeClass.show: Starting index out of range";this.isAlreadyGettingPage=this.getWindowDimensions();i.setActivateInstance(this);this.windowDimensions=this.getWindowDimensions();this.settings.target===e?a.DOM.addClass(e.document.body,i.CssClasses.buildingBody):a.DOM.addClass(this.settings.target,i.CssClasses.buildingBody);this.createComponents();a.Events.fire(this,{type:i.EventTypes.onBeforeShow, +target:this});this.documentOverlay.fadeIn(this.settings.fadeInSpeed,this.onDocumentOverlayFadeIn.bind(this))},getWindowDimensions:function(){return{width:a.DOM.windowWidth(),height:a.DOM.windowHeight()}},createComponents:function(){this.documentOverlay=new d.DocumentOverlayClass(this.settings);this.carousel=new f.CarouselClass(this.cache,this.settings);this.uiLayer=new h.UILayerClass(this.settings);if(!this.settings.captionAndToolbarHide)this.toolbar=new g.ToolbarClass(this.cache,this.settings)}, +resetPosition:function(){if(!this._isResettingPosition){var b=this.getWindowDimensions();if(a.isNothing(this.windowDimensions)||!(b.width===this.windowDimensions.width&&b.height===this.windowDimensions.height))this._isResettingPosition=!0,this.windowDimensions=b,this.destroyZoomPanRotate(),this.documentOverlay.resetPosition(),this.carousel.resetPosition(),a.isNothing(this.toolbar)||this.toolbar.resetPosition(),this.uiLayer.resetPosition(),this._isResettingPosition=!1,a.Events.fire(this,{type:i.EventTypes.onResetPosition, +target:this})}},addEventHandler:function(b,c){a.Events.add(this,b,c)},addEventHandlers:function(){if(a.isNothing(this.windowOrientationChangeHandler))this.windowOrientationChangeHandler=this.onWindowOrientationChange.bind(this),this.windowScrollHandler=this.onWindowScroll.bind(this),this.keyDownHandler=this.onKeyDown.bind(this),this.windowHashChangeHandler=this.onWindowHashChange.bind(this),this.uiLayerTouchHandler=this.onUILayerTouch.bind(this),this.carouselSlideByEndHandler=this.onCarouselSlideByEnd.bind(this), +this.carouselSlideshowStartHandler=this.onCarouselSlideshowStart.bind(this),this.carouselSlideshowStopHandler=this.onCarouselSlideshowStop.bind(this),this.toolbarTapHandler=this.onToolbarTap.bind(this),this.toolbarBeforeShowHandler=this.onToolbarBeforeShow.bind(this),this.toolbarShowHandler=this.onToolbarShow.bind(this),this.toolbarBeforeHideHandler=this.onToolbarBeforeHide.bind(this),this.toolbarHideHandler=this.onToolbarHide.bind(this),this.mouseWheelHandler=this.onMouseWheel.bind(this),this.zoomPanRotateTransformHandler= +this.onZoomPanRotateTransform.bind(this);a.Browser.android?this.orientationEventName="resize":a.Browser.iOS&&!a.Browser.safari?a.Events.add(e.document.body,"orientationchange",this.windowOrientationChangeHandler):this.orientationEventName=!a.isNothing(e.onorientationchange)?"orientationchange":"resize";a.isNothing(this.orientationEventName)||a.Events.add(e,this.orientationEventName,this.windowOrientationChangeHandler);this.settings.target===e&&a.Events.add(e,"scroll",this.windowScrollHandler);this.settings.enableKeyboard&& +a.Events.add(e.document,"keydown",this.keyDownHandler);if(this.isBackEventSupported&&this.settings.backButtonHideEnabled)this.windowHashChangeHandler=this.onWindowHashChange.bind(this),this.settings.jQueryMobile?e.location.hash=this.settings.jQueryMobileDialogHash:(this.currentHistoryHashValue="PhotoSwipe"+(new Date).getTime().toString(),e.location.hash=this.currentHistoryHashValue),a.Events.add(e,"hashchange",this.windowHashChangeHandler);this.settings.enableMouseWheel&&a.Events.add(e,"mousewheel", +this.mouseWheelHandler);a.Events.add(this.uiLayer,a.TouchElement.EventTypes.onTouch,this.uiLayerTouchHandler);a.Events.add(this.carousel,f.EventTypes.onSlideByEnd,this.carouselSlideByEndHandler);a.Events.add(this.carousel,f.EventTypes.onSlideshowStart,this.carouselSlideshowStartHandler);a.Events.add(this.carousel,f.EventTypes.onSlideshowStop,this.carouselSlideshowStopHandler);a.isNothing(this.toolbar)||(a.Events.add(this.toolbar,g.EventTypes.onTap,this.toolbarTapHandler),a.Events.add(this.toolbar, +g.EventTypes.onBeforeShow,this.toolbarBeforeShowHandler),a.Events.add(this.toolbar,g.EventTypes.onShow,this.toolbarShowHandler),a.Events.add(this.toolbar,g.EventTypes.onBeforeHide,this.toolbarBeforeHideHandler),a.Events.add(this.toolbar,g.EventTypes.onHide,this.toolbarHideHandler))},removeEventHandlers:function(){a.Browser.iOS&&!a.Browser.safari&&a.Events.remove(e.document.body,"orientationchange",this.windowOrientationChangeHandler);a.isNothing(this.orientationEventName)||a.Events.remove(e,this.orientationEventName, +this.windowOrientationChangeHandler);a.Events.remove(e,"scroll",this.windowScrollHandler);this.settings.enableKeyboard&&a.Events.remove(e.document,"keydown",this.keyDownHandler);this.isBackEventSupported&&this.settings.backButtonHideEnabled&&a.Events.remove(e,"hashchange",this.windowHashChangeHandler);this.settings.enableMouseWheel&&a.Events.remove(e,"mousewheel",this.mouseWheelHandler);a.isNothing(this.uiLayer)||a.Events.remove(this.uiLayer,a.TouchElement.EventTypes.onTouch,this.uiLayerTouchHandler); +a.isNothing(this.toolbar)||(a.Events.remove(this.carousel,f.EventTypes.onSlideByEnd,this.carouselSlideByEndHandler),a.Events.remove(this.carousel,f.EventTypes.onSlideshowStart,this.carouselSlideshowStartHandler),a.Events.remove(this.carousel,f.EventTypes.onSlideshowStop,this.carouselSlideshowStopHandler));a.isNothing(this.toolbar)||(a.Events.remove(this.toolbar,g.EventTypes.onTap,this.toolbarTapHandler),a.Events.remove(this.toolbar,g.EventTypes.onBeforeShow,this.toolbarBeforeShowHandler),a.Events.remove(this.toolbar, +g.EventTypes.onShow,this.toolbarShowHandler),a.Events.remove(this.toolbar,g.EventTypes.onBeforeHide,this.toolbarBeforeHideHandler),a.Events.remove(this.toolbar,g.EventTypes.onHide,this.toolbarHideHandler))},hide:function(){if(!this.settings.preventHide){if(a.isNothing(this.documentOverlay))throw"Code.PhotoSwipe.PhotoSwipeClass.hide: PhotoSwipe instance is already hidden";if(a.isNothing(this.hiding)){this.clearUIWebViewResetPositionTimeout();this.destroyZoomPanRotate();this.removeEventHandlers();a.Events.fire(this, +{type:i.EventTypes.onBeforeHide,target:this});this.uiLayer.dispose();this.uiLayer=null;if(!a.isNothing(this.toolbar))this.toolbar.dispose(),this.toolbar=null;this.carousel.dispose();this.carousel=null;a.DOM.removeClass(e.document.body,i.CssClasses.activeBody);this.documentOverlay.dispose();this.documentOverlay=null;this._isResettingPosition=!1;i.unsetActivateInstance(this);a.Events.fire(this,{type:i.EventTypes.onHide,target:this});this.goBackInHistory()}}},goBackInHistory:function(){this.isBackEventSupported&& +this.settings.backButtonHideEnabled&&(this.backButtonClicked||e.history.back())},play:function(){!this.isZoomActive()&&!this.settings.preventSlideshow&&!a.isNothing(this.carousel)&&(!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.toolbar.fadeOut(),this.carousel.startSlideshow())},stop:function(){this.isZoomActive()||a.isNothing(this.carousel)||this.carousel.stopSlideshow()},previous:function(){this.isZoomActive()||a.isNothing(this.carousel)||this.carousel.previous()},next:function(){this.isZoomActive()|| +a.isNothing(this.carousel)||this.carousel.next()},toggleToolbar:function(){this.isZoomActive()||a.isNothing(this.toolbar)||this.toolbar.toggleVisibility(this.currentIndex)},fadeOutToolbarIfVisible:function(){!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.settings.captionAndToolbarAutoHideDelay>0&&this.toolbar.fadeOut()},createZoomPanRotate:function(){this.stop();if(this.canUserZoom()&&!this.isZoomActive())a.Events.fire(this,i.EventTypes.onBeforeZoomPanRotateShow),this.zoomPanRotate=new j.ZoomPanRotateClass(this.settings, +this.cache.images[this.currentIndex],this.uiLayer),this.uiLayer.captureSettings.preventDefaultTouchEvents=!0,a.Events.add(this.zoomPanRotate,i.ZoomPanRotate.EventTypes.onTransform,this.zoomPanRotateTransformHandler),a.Events.fire(this,i.EventTypes.onZoomPanRotateShow),!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.toolbar.fadeOut()},destroyZoomPanRotate:function(){if(!a.isNothing(this.zoomPanRotate))a.Events.fire(this,i.EventTypes.onBeforeZoomPanRotateHide),a.Events.remove(this.zoomPanRotate, +i.ZoomPanRotate.EventTypes.onTransform,this.zoomPanRotateTransformHandler),this.zoomPanRotate.dispose(),this.zoomPanRotate=null,this.uiLayer.captureSettings.preventDefaultTouchEvents=this.settings.preventDefaultTouchEvents,a.Events.fire(this,i.EventTypes.onZoomPanRotateHide)},canUserZoom:function(){var b;if(a.Browser.msie){if(b=document.createElement("div"),a.isNothing(b.style.msTransform))return!1}else if(!a.Browser.isCSSTransformSupported)return!1;if(!this.settings.allowUserZoom)return!1;if(this.carousel.isSliding)return!1; +b=this.cache.images[this.currentIndex];if(a.isNothing(b))return!1;if(b.isLoading)return!1;return!0},isZoomActive:function(){return!a.isNothing(this.zoomPanRotate)},getCurrentImage:function(){return this.cache.images[this.currentIndex]},onDocumentOverlayFadeIn:function(){e.setTimeout(function(){var b=this.settings.target===e?e.document.body:this.settings.target;a.DOM.removeClass(b,i.CssClasses.buildingBody);a.DOM.addClass(b,i.CssClasses.activeBody);this.addEventHandlers();this.carousel.show(this.currentIndex); +this.uiLayer.show();this.settings.autoStartSlideshow?this.play():a.isNothing(this.toolbar)||this.toolbar.show(this.currentIndex);a.Events.fire(this,{type:i.EventTypes.onShow,target:this});this.setUIWebViewResetPositionTimeout()}.bind(this),250)},setUIWebViewResetPositionTimeout:function(){if(this.settings.enableUIWebViewRepositionTimeout&&a.Browser.iOS&&!a.Browser.safari)a.isNothing(this._uiWebViewResetPositionTimeout)||e.clearTimeout(this._uiWebViewResetPositionTimeout),this._uiWebViewResetPositionTimeout= +e.setTimeout(function(){this.resetPosition();this.setUIWebViewResetPositionTimeout()}.bind(this),this.settings.uiWebViewResetPositionDelay)},clearUIWebViewResetPositionTimeout:function(){a.isNothing(this._uiWebViewResetPositionTimeout)||e.clearTimeout(this._uiWebViewResetPositionTimeout)},onWindowScroll:function(){this.resetPosition()},onWindowOrientationChange:function(){this.resetPosition()},onWindowHashChange:function(){if(e.location.hash!=="#"+(this.settings.jQueryMobile?this.settings.jQueryMobileDialogHash: +this.currentHistoryHashValue))this.backButtonClicked=!0,this.hide()},onKeyDown:function(a){a.keyCode===37?(a.preventDefault(),this.previous()):a.keyCode===39?(a.preventDefault(),this.next()):a.keyCode===38||a.keyCode===40?a.preventDefault():a.keyCode===27?(a.preventDefault(),this.hide()):a.keyCode===32?(this.settings.hideToolbar?this.hide():this.toggleToolbar(),a.preventDefault()):a.keyCode===13&&(a.preventDefault(),this.play())},onUILayerTouch:function(b){if(this.isZoomActive())switch(b.action){case a.TouchElement.ActionTypes.gestureChange:this.zoomPanRotate.zoomRotate(b.scale, +this.settings.allowRotationOnUserZoom?b.rotation:0);break;case a.TouchElement.ActionTypes.gestureEnd:this.zoomPanRotate.setStartingScaleAndRotation(b.scale,this.settings.allowRotationOnUserZoom?b.rotation:0);break;case a.TouchElement.ActionTypes.touchStart:this.zoomPanRotate.panStart(b.point);break;case a.TouchElement.ActionTypes.touchMove:this.zoomPanRotate.pan(b.point);break;case a.TouchElement.ActionTypes.doubleTap:this.destroyZoomPanRotate();this.toggleToolbar();break;case a.TouchElement.ActionTypes.swipeLeft:this.destroyZoomPanRotate(); +this.next();this.toggleToolbar();break;case a.TouchElement.ActionTypes.swipeRight:this.destroyZoomPanRotate(),this.previous(),this.toggleToolbar()}else switch(b.action){case a.TouchElement.ActionTypes.touchMove:case a.TouchElement.ActionTypes.swipeLeft:case a.TouchElement.ActionTypes.swipeRight:this.fadeOutToolbarIfVisible();this.carousel.onTouch(b.action,b.point);break;case a.TouchElement.ActionTypes.touchStart:case a.TouchElement.ActionTypes.touchMoveEnd:this.carousel.onTouch(b.action,b.point); +break;case a.TouchElement.ActionTypes.tap:this.toggleToolbar();break;case a.TouchElement.ActionTypes.doubleTap:this.settings.target===e&&(b.point.x-=a.DOM.windowScrollLeft(),b.point.y-=a.DOM.windowScrollTop());var c=this.cache.images[this.currentIndex].imageEl,d=e.parseInt(a.DOM.getStyle(c,"top"),10),f=e.parseInt(a.DOM.getStyle(c,"left"),10),g=f+a.DOM.width(c),c=d+a.DOM.height(c);if(b.point.xg)b.point.x=g;if(b.point.yc)b.point.y=c; +this.createZoomPanRotate();this.isZoomActive()&&this.zoomPanRotate.zoomAndPanToPoint(this.settings.doubleTapZoomLevel,b.point);break;case a.TouchElement.ActionTypes.gestureStart:this.createZoomPanRotate()}a.Events.fire(this,{type:i.EventTypes.onTouch,target:this,point:b.point,action:b.action})},onCarouselSlideByEnd:function(b){this.currentIndex=b.cacheIndex;a.isNothing(this.toolbar)||(this.toolbar.setCaption(this.currentIndex),this.toolbar.setToolbarStatus(this.currentIndex));a.Events.fire(this,{type:i.EventTypes.onDisplayImage, +target:this,action:b.action,index:b.cacheIndex})},onToolbarTap:function(b){switch(b.action){case g.ToolbarAction.next:this.next();break;case g.ToolbarAction.previous:this.previous();break;case g.ToolbarAction.close:this.hide();break;case g.ToolbarAction.play:this.play()}a.Events.fire(this,{type:i.EventTypes.onToolbarTap,target:this,toolbarAction:b.action,tapTarget:b.tapTarget})},onMouseWheel:function(b){var c=a.Events.getWheelDelta(b);if(!(b.timeStamp-(this.mouseWheelStartTime||0)0&&this.previous()},onCarouselSlideshowStart:function(){a.Events.fire(this,{type:i.EventTypes.onSlideshowStart,target:this})},onCarouselSlideshowStop:function(){a.Events.fire(this,{type:i.EventTypes.onSlideshowStop,target:this})},onToolbarBeforeShow:function(){a.Events.fire(this,{type:i.EventTypes.onBeforeCaptionAndToolbarShow,target:this})},onToolbarShow:function(){a.Events.fire(this,{type:i.EventTypes.onCaptionAndToolbarShow, +target:this})},onToolbarBeforeHide:function(){a.Events.fire(this,{type:i.EventTypes.onBeforeCaptionAndToolbarHide,target:this})},onToolbarHide:function(){a.Events.fire(this,{type:i.EventTypes.onCaptionAndToolbarHide,target:this})},onZoomPanRotateTransform:function(b){a.Events.fire(this,{target:this,type:i.EventTypes.onZoomPanRotateTransform,scale:b.scale,rotation:b.rotation,rotationDegs:b.rotationDegs,translateX:b.translateX,translateY:b.translateY})}})})(window,window.klass,window.Code.Util,window.Code.PhotoSwipe.Cache, +window.Code.PhotoSwipe.DocumentOverlay,window.Code.PhotoSwipe.Carousel,window.Code.PhotoSwipe.Toolbar,window.Code.PhotoSwipe.UILayer,window.Code.PhotoSwipe.ZoomPanRotate); diff --git a/photoswipe/code.photoswipe.jquery-3.0.5.js b/photoswipe/code.photoswipe.jquery-3.0.5.js new file mode 100755 index 0000000..15b5841 --- /dev/null +++ b/photoswipe/code.photoswipe.jquery-3.0.5.js @@ -0,0 +1,6425 @@ +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function (window) { + + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind + if (!Function.prototype.bind ) { + + Function.prototype.bind = function( obj ) { + var slice = [].slice, + args = slice.call(arguments, 1), + self = this, + nop = function () {}, + bound = function () { + return self.apply( this instanceof nop ? this : ( obj || {} ), + args.concat( slice.call(arguments) ) ); + }; + + nop.prototype = self.prototype; + + bound.prototype = new nop(); + + return bound; + }; + } + + + + if (typeof window.Code === "undefined") { + window.Code = {}; + } + + + + window.Code.Util = { + + + /* + * Function: registerNamespace + */ + registerNamespace: function () { + var + args = arguments, obj = null, i, j, ns, nsParts, root, argsLen, nsPartsLens; + for (i=0, argsLen=args.length; i Util.DOM.windowHeight()); + } + }; + + Util.Browser._detect(); + +} +( + window, + window.Code.Util +)) +; +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function (window, $, Util) { + + Util.extend(Util, { + + Events: { + + + /* + * Function: add + * Add an event handler + */ + add: function(obj, type, handler){ + + $(obj).bind(type, handler); + + }, + + + + /* + * Function: remove + * Removes a handler or all handlers associated with a type + */ + remove: function(obj, type, handler){ + + $(obj).unbind(type, handler); + + }, + + + /* + * Function: fire + * Fire an event + */ + fire: function(obj, type){ + + var + event, + args = Array.prototype.slice.call(arguments).splice(2); + + if (typeof type === "string"){ + event = { type: type }; + } + else{ + event = type; + } + + $(obj).trigger( $.Event(event.type, event), args); + + }, + + + /* + * Function: getMousePosition + */ + getMousePosition: function(event){ + + var retval = { + x: event.pageX, + y: event.pageY + }; + + return retval; + + }, + + + /* + * Function: getTouchEvent + */ + getTouchEvent: function(event){ + + return event.originalEvent; + + }, + + + + /* + * Function: getWheelDelta + */ + getWheelDelta: function(event){ + + var delta = 0; + + if (!Util.isNothing(event.wheelDelta)){ + delta = event.wheelDelta / 120; + } + else if (!Util.isNothing(event.detail)){ + delta = -event.detail / 3; + } + + return delta; + + }, + + + /* + * Function: domReady + */ + domReady: function(handler){ + + $(document).ready(handler); + + } + + + } + + + }); + + +} +( + window, + window.jQuery, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function (window, $, Util) { + + Util.extend(Util, { + + DOM: { + + + + /* + * Function: setData + */ + setData: function(el, key, value){ + + if (Util.isLikeArray(el)){ + var i, len; + for (i=0, len=el.length; i'); + retval.attr(attributes); + retval.append(content); + + return retval[0]; + + }, + + + + /* + * Function: appendChild + */ + appendChild: function(childEl, parentEl){ + + $(parentEl).append(childEl); + + }, + + + + /* + * Function: insertBefore + */ + insertBefore: function(newEl, refEl, parentEl){ + + $(newEl).insertBefore(refEl); + + }, + + + + /* + * Function: appendText + */ + appendText: function(text, parentEl){ + + $(parentEl).text(text); + + }, + + + + /* + * Function: appendToBody + */ + appendToBody: function(childEl){ + + $('body').append(childEl); + + }, + + + + /* + * Function: removeChild + */ + removeChild: function(childEl, parentEl){ + + $(childEl).empty().remove(); + + }, + + + + /* + * Function: removeChildren + */ + removeChildren: function(parentEl){ + + $(parentEl).empty(); + + }, + + + + /* + * Function: hasAttribute + */ + hasAttribute: function(el, attributeName){ + + return !Util.isNothing( $(el).attr(attributeName) ); + + }, + + + + /* + * Function: getAttribute + */ + getAttribute: function(el, attributeName, defaultValue){ + + var retval = $(el).attr(attributeName); + if (Util.isNothing(retval) && !Util.isNothing(defaultValue)){ + retval = defaultValue; + } + return retval; + + }, + + + + /* + * Function: el, attributeName + */ + setAttribute: function(el, attributeName, value){ + + if (Util.isLikeArray(el)){ + var i, len; + for (i=0, len=el.length; i= 1){ + Util.DOM.setStyle(el, 'opacity', 0); + } + + if (Util.Browser.isCSSTransformSupported){ + this._applyTransition(el, 'opacity', opacity, speed, callback, timingFunction); + } + else if (!Util.isNothing(window.jQuery)){ + window.jQuery(el).fadeTo(speed, opacity, callback); + } + + }, + + + + /* + * Function: fadeTo + */ + fadeTo: function(el, opacity, speed, callback, timingFunction){ + this.fadeIn(el, speed, callback, timingFunction, opacity); + }, + + + + /* + * Function: fadeOut + */ + fadeOut: function(el, speed, callback, timingFunction){ + + if (speed <= 0){ + Util.DOM.setStyle(el, 'opacity', 0); + if (!Util.isNothing(callback)){ + callback(el); + return; + } + } + + if (Util.Browser.isCSSTransformSupported){ + + this._applyTransition(el, 'opacity', 0, speed, callback, timingFunction); + + } + else{ + + window.jQuery(el).fadeTo(speed, 0, callback); + + } + + }, + + + + /* + * Function: slideBy + */ + slideBy: function(el, x, y, speed, callback, timingFunction){ + + var style = {}; + + x = Util.coalesce(x, 0); + y = Util.coalesce(y, 0); + timingFunction = Util.coalesce(timingFunction, 'ease-out'); + + style[this._transitionPrefix + 'Property'] = 'all'; + style[this._transitionPrefix + 'Delay'] = '0'; + + if (speed === 0){ + style[this._transitionPrefix + 'Duration'] = ''; + style[this._transitionPrefix + 'TimingFunction'] = ''; + } + else{ + style[this._transitionPrefix + 'Duration'] = speed + 'ms'; + style[this._transitionPrefix + 'TimingFunction'] = Util.coalesce(timingFunction, 'ease-out'); + + Util.Events.add(el, this._transitionEndLabel, this._getTransitionEndHandler()); + + } + + style[this._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(' + x + 'px, ' + y + 'px, 0px)' : 'translate(' + x + 'px, ' + y + 'px)'; + + if (!Util.isNothing(callback)){ + el.cclallcallback = callback; + } + + Util.DOM.setStyle(el, style); + + if (speed === 0){ + window.setTimeout(function(){ + this._leaveTransforms(el); + }.bind(this), this._applyTransitionDelay); + } + + }, + + + + /* + * Function: + */ + resetTranslate: function(el){ + + var style = {}; + style[this._transformLabel] = style[this._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(0px, 0px, 0px)' : 'translate(0px, 0px)'; + Util.DOM.setStyle(el, style); + + }, + + + + /* + * Function: _applyTransition + */ + _applyTransition: function(el, property, val, speed, callback, timingFunction){ + + var style = {}; + + timingFunction = Util.coalesce(timingFunction, 'ease-in'); + + style[this._transitionPrefix + 'Property'] = property; + style[this._transitionPrefix + 'Duration'] = speed + 'ms'; + style[this._transitionPrefix + 'TimingFunction'] = timingFunction; + style[this._transitionPrefix + 'Delay'] = '0'; + + Util.Events.add(el, this._transitionEndLabel, this._getTransitionEndHandler()); + + Util.DOM.setStyle(el, style); + + if (!Util.isNothing(callback)){ + el['ccl' + property + 'callback'] = callback; + } + + window.setTimeout(function(){ + Util.DOM.setStyle(el, property, val); + }, this._applyTransitionDelay); + + }, + + + + /* + * Function: _onTransitionEnd + */ + _onTransitionEnd: function(e){ + + Util.Events.remove(e.currentTarget, this._transitionEndLabel, this._getTransitionEndHandler()); + this._leaveTransforms(e.currentTarget); + + }, + + + + /* + * Function: _leaveTransforms + */ + _leaveTransforms: function(el){ + + var + property = el.style[this._transitionPrefix + 'Property'], + callbackLabel = (property !== '') ? 'ccl' + property + 'callback' : 'cclallcallback', + callback, + transform = Util.coalesce(el.style.webkitTransform, el.style.MozTransform, el.style.transform), + transformMatch, + transformExploded, + domX = window.parseInt(Util.DOM.getStyle(el, 'left'), 0), + domY = window.parseInt(Util.DOM.getStyle(el, 'top'), 0), + transformedX, + transformedY, + style = {}; + + if (transform !== ''){ + if (Util.Browser.is3dSupported){ + transformMatch = transform.match( /translate3d\((.*?)\)/ ); + } + else{ + transformMatch = transform.match( /translate\((.*?)\)/ ); + } + if (!Util.isNothing(transformMatch)){ + transformExploded = transformMatch[1].split(', '); + transformedX = window.parseInt(transformExploded[0], 0); + transformedY = window.parseInt(transformExploded[1], 0); + } + } + + style[this._transitionPrefix + 'Property'] = ''; + style[this._transitionPrefix + 'Duration'] = ''; + style[this._transitionPrefix + 'TimingFunction'] = ''; + style[this._transitionPrefix + 'Delay'] = ''; + + Util.DOM.setStyle(el, style); + + window.setTimeout(function(){ + + if(!Util.isNothing(transformExploded)){ + + style = {}; + style[this._transformLabel] = ''; + style.left = (domX + transformedX) + 'px'; + style.top = (domY + transformedY) + 'px'; + + Util.DOM.setStyle(el, style); + + } + + if (!Util.isNothing(el[callbackLabel])){ + callback = el[callbackLabel]; + delete el[callbackLabel]; + callback(el); + } + + }.bind(this), this._applyTransitionDelay); + + } + + + } + + + }); + + +} +( + window, + window.Code.Util +)); +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.Util.TouchElement'); + + + Util.TouchElement.EventTypes = { + + onTouch: 'CodeUtilTouchElementOnTouch' + + }; + + + Util.TouchElement.ActionTypes = { + + touchStart: 'touchStart', + touchMove: 'touchMove', + touchEnd: 'touchEnd', + touchMoveEnd: 'touchMoveEnd', + tap: 'tap', + doubleTap: 'doubleTap', + swipeLeft: 'swipeLeft', + swipeRight: 'swipeRight', + swipeUp: 'swipeUp', + swipeDown: 'swipeDown', + gestureStart: 'gestureStart', + gestureChange: 'gestureChange', + gestureEnd: 'gestureEnd' + + }; + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.Util.TouchElement'); + + + Util.TouchElement.TouchElementClass = klass({ + + el: null, + + captureSettings: null, + + touchStartPoint: null, + touchEndPoint: null, + touchStartTime: null, + doubleTapTimeout: null, + + touchStartHandler: null, + touchMoveHandler: null, + touchEndHandler: null, + + mouseDownHandler: null, + mouseMoveHandler: null, + mouseUpHandler: null, + mouseOutHandler: null, + + gestureStartHandler: null, + gestureChangeHandler: null, + gestureEndHandler: null, + + swipeThreshold: null, + swipeTimeThreshold: null, + doubleTapSpeed: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.removeEventHandlers(); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(el, captureSettings){ + + this.el = el; + + this.captureSettings = { + swipe: false, + move: false, + gesture: false, + doubleTap: false, + preventDefaultTouchEvents: true + }; + + Util.extend(this.captureSettings, captureSettings); + + this.swipeThreshold = 50; + this.swipeTimeThreshold = 250; + this.doubleTapSpeed = 250; + + this.touchStartPoint = { x: 0, y: 0 }; + this.touchEndPoint = { x: 0, y: 0 }; + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.isNothing(this.touchStartHandler)){ + this.touchStartHandler = this.onTouchStart.bind(this); + this.touchMoveHandler = this.onTouchMove.bind(this); + this.touchEndHandler = this.onTouchEnd.bind(this); + this.mouseDownHandler = this.onMouseDown.bind(this); + this.mouseMoveHandler = this.onMouseMove.bind(this); + this.mouseUpHandler = this.onMouseUp.bind(this); + this.mouseOutHandler = this.onMouseOut.bind(this); + this.gestureStartHandler = this.onGestureStart.bind(this); + this.gestureChangeHandler = this.onGestureChange.bind(this); + this.gestureEndHandler = this.onGestureEnd.bind(this); + } + + Util.Events.add(this.el, 'touchstart', this.touchStartHandler); + if (this.captureSettings.move){ + Util.Events.add(this.el, 'touchmove', this.touchMoveHandler); + } + Util.Events.add(this.el, 'touchend', this.touchEndHandler); + + Util.Events.add(this.el, 'mousedown', this.mouseDownHandler); + + if (Util.Browser.isGestureSupported && this.captureSettings.gesture){ + Util.Events.add(this.el, 'gesturestart', this.gestureStartHandler); + Util.Events.add(this.el, 'gesturechange', this.gestureChangeHandler); + Util.Events.add(this.el, 'gestureend', this.gestureEndHandler); + } + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + Util.Events.remove(this.el, 'touchstart', this.touchStartHandler); + if (this.captureSettings.move){ + Util.Events.remove(this.el, 'touchmove', this.touchMoveHandler); + } + Util.Events.remove(this.el, 'touchend', this.touchEndHandler); + Util.Events.remove(this.el, 'mousedown', this.mouseDownHandler); + + if (Util.Browser.isGestureSupported && this.captureSettings.gesture){ + Util.Events.remove(this.el, 'gesturestart', this.gestureStartHandler); + Util.Events.remove(this.el, 'gesturechange', this.gestureChangeHandler); + Util.Events.remove(this.el, 'gestureend', this.gestureEndHandler); + } + + }, + + + + /* + * Function: getTouchPoint + */ + getTouchPoint: function(touches){ + + return { + x: touches[0].pageX, + y: touches[0].pageY + }; + + }, + + + + /* + * Function: fireTouchEvent + */ + fireTouchEvent: function(e){ + + var + action, + distX = 0, + distY = 0, + dist = 0, + self, + endTime, + diffTime; + + distX = this.touchEndPoint.x - this.touchStartPoint.x; + distY = this.touchEndPoint.y - this.touchStartPoint.y; + dist = Math.sqrt( (distX * distX) + (distY * distY) ); + + if (this.captureSettings.swipe){ + endTime = new Date(); + diffTime = endTime - this.touchStartTime; + + // See if there was a swipe gesture + if (diffTime <= this.swipeTimeThreshold){ + + if (window.Math.abs(distX) >= this.swipeThreshold){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: (distX < 0) ? Util.TouchElement.ActionTypes.swipeLeft : Util.TouchElement.ActionTypes.swipeRight, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + + } + + + if (window.Math.abs(distY) >= this.swipeThreshold){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: (distY < 0) ? Util.TouchElement.ActionTypes.swipeUp : Util.TouchElement.ActionTypes.swipeDown, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + + } + + } + } + + + if (dist > 1){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchMoveEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + } + + + if (!this.captureSettings.doubleTap){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: Util.TouchElement.ActionTypes.tap, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + + } + + if (Util.isNothing(this.doubleTapTimeout)){ + + this.doubleTapTimeout = window.setTimeout(function(){ + + this.doubleTapTimeout = null; + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: Util.TouchElement.ActionTypes.tap, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }.bind(this), this.doubleTapSpeed); + + return; + + } + else{ + + window.clearTimeout(this.doubleTapTimeout); + this.doubleTapTimeout = null; + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: Util.TouchElement.ActionTypes.doubleTap, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + } + + }, + + + + /* + * Function: onTouchStart + */ + onTouchStart: function(e){ + + if (this.captureSettings.preventDefaultTouchEvents){ + e.preventDefault(); + } + + // No longer need mouse events + Util.Events.remove(this.el, 'mousedown', this.mouseDownHandler); + + var + touchEvent = Util.Events.getTouchEvent(e), + touches = touchEvent.touches; + + if (touches.length > 1 && this.captureSettings.gesture){ + this.isGesture = true; + return; + } + + this.touchStartTime = new Date(); + this.isGesture = false; + this.touchStartPoint = this.getTouchPoint(touches); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchStart, + point: this.touchStartPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + + }, + + + + /* + * Function: onTouchMove + */ + onTouchMove: function(e){ + + if (this.captureSettings.preventDefaultTouchEvents){ + e.preventDefault(); + } + + if (this.isGesture && this.captureSettings.gesture){ + return; + } + + var + touchEvent = Util.Events.getTouchEvent(e), + touches = touchEvent.touches; + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchMove, + point: this.getTouchPoint(touches), + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onTouchEnd + */ + onTouchEnd: function(e){ + + if (this.isGesture && this.captureSettings.gesture){ + return; + } + + if (this.captureSettings.preventDefaultTouchEvents){ + e.preventDefault(); + } + + // http://backtothecode.blogspot.com/2009/10/javascript-touch-and-gesture-events.html + // iOS removed the current touch from e.touches on "touchend" + // Need to look into e.changedTouches + + var + touchEvent = Util.Events.getTouchEvent(e), + touches = (!Util.isNothing(touchEvent.changedTouches)) ? touchEvent.changedTouches : touchEvent.touches; + + this.touchEndPoint = this.getTouchPoint(touches); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + this.fireTouchEvent(e); + + }, + + + + /* + * Function: onMouseDown + */ + onMouseDown: function(e){ + + e.preventDefault(); + + // No longer need touch events + Util.Events.remove(this.el, 'touchstart', this.mouseDownHandler); + Util.Events.remove(this.el, 'touchmove', this.touchMoveHandler); + Util.Events.remove(this.el, 'touchend', this.touchEndHandler); + + // Add move/up/out + if (this.captureSettings.move){ + Util.Events.add(this.el, 'mousemove', this.mouseMoveHandler); + } + Util.Events.add(this.el, 'mouseup', this.mouseUpHandler); + Util.Events.add(this.el, 'mouseout', this.mouseOutHandler); + + this.touchStartTime = new Date(); + this.isGesture = false; + this.touchStartPoint = Util.Events.getMousePosition(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchStart, + point: this.touchStartPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onMouseMove + */ + onMouseMove: function(e){ + + e.preventDefault(); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchMove, + point: Util.Events.getMousePosition(e), + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onMouseUp + */ + onMouseUp: function(e){ + + e.preventDefault(); + + if (this.captureSettings.move){ + Util.Events.remove(this.el, 'mousemove', this.mouseMoveHandler); + } + Util.Events.remove(this.el, 'mouseup', this.mouseUpHandler); + Util.Events.remove(this.el, 'mouseout', this.mouseOutHandler); + + this.touchEndPoint = Util.Events.getMousePosition(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + this.fireTouchEvent(e); + + }, + + + + /* + * Function: onMouseOut + */ + onMouseOut: function(e){ + + /* + * http://blog.stchur.com/2007/03/15/mouseenter-and-mouseleave-events-for-firefox-and-other-non-ie-browsers/ + */ + var relTarget = e.relatedTarget; + if (this.el === relTarget || Util.DOM.isChildOf(relTarget, this.el)){ + return; + } + + e.preventDefault(); + + if (this.captureSettings.move){ + Util.Events.remove(this.el, 'mousemove', this.mouseMoveHandler); + } + Util.Events.remove(this.el, 'mouseup', this.mouseUpHandler); + Util.Events.remove(this.el, 'mouseout', this.mouseOutHandler); + + this.touchEndPoint = Util.Events.getMousePosition(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + this.fireTouchEvent(e); + + }, + + + + /* + * Function: onGestureStart + */ + onGestureStart: function(e){ + + e.preventDefault(); + + var touchEvent = Util.Events.getTouchEvent(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.gestureStart, + scale: touchEvent.scale, + rotation: touchEvent.rotation, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onGestureChange + */ + onGestureChange: function(e){ + + e.preventDefault(); + + var touchEvent = Util.Events.getTouchEvent(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.gestureChange, + scale: touchEvent.scale, + rotation: touchEvent.rotation, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onGestureEnd + */ + onGestureEnd: function(e){ + + e.preventDefault(); + + var touchEvent = Util.Events.getTouchEvent(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.gestureEnd, + scale: touchEvent.scale, + rotation: touchEvent.rotation, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.EventTypes = { + + onLoad: 'onLoad', + onError: 'onError' + + }; + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.ImageClass = klass({ + + + + refObj: null, + imageEl: null, + src: null, + caption: null, + metaData: null, + imageLoadHandler: null, + imageErrorHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i; + + this.shrinkImage(); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(refObj, src, caption, metaData){ + + this.refObj = refObj; + // This is needed. Webkit resolves the src + // value which means we can't compare against it in the load function + this.originalSrc = src; + this.src = src; + this.caption = caption; + this.metaData = metaData; + + this.imageEl = new window.Image(); + + this.imageLoadHandler = this.onImageLoad.bind(this); + this.imageErrorHandler = this.onImageError.bind(this); + + }, + + + + /* + * Function: load + */ + load: function(){ + + this.imageEl.originalSrc = Util.coalesce(this.imageEl.originalSrc, ''); + + if (this.imageEl.originalSrc === this.src){ + + if (this.imageEl.isError){ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + } + else{ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + } + return; + } + + this.imageEl.isError = false; + this.imageEl.isLoading = true; + this.imageEl.naturalWidth = null; + this.imageEl.naturalHeight = null; + this.imageEl.isLandscape = false; + this.imageEl.onload = this.imageLoadHandler; + this.imageEl.onerror = this.imageErrorHandler; + this.imageEl.onabort = this.imageErrorHandler; + this.imageEl.originalSrc = this.src; + this.imageEl.src = this.src; + + }, + + + + /* + * Function: shrinkImage + */ + shrinkImage: function(){ + + if (Util.isNothing(this.imageEl)){ + return; + } + + if (this.imageEl.src.indexOf(this.src) > -1){ + this.imageEl.src = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='; + if (!Util.isNothing(this.imageEl.parentNode)){ + Util.DOM.removeChild(this.imageEl, this.imageEl.parentNode); + } + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + this.imageEl.onload = null; + this.imageEl.naturalWidth = Util.coalesce(this.imageEl.naturalWidth, this.imageEl.width); + this.imageEl.naturalHeight = Util.coalesce(this.imageEl.naturalHeight, this.imageEl.height); + this.imageEl.isLandscape = (this.imageEl.naturalWidth > this.imageEl.naturalHeight); + this.imageEl.isLoading = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + this.imageEl.onload = null; + this.imageEl.onerror = null; + this.imageEl.onabort = null; + this.imageEl.isLoading = false; + this.imageEl.isError = true; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Cache'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Cache.Mode = { + + normal: 'normal', + aggressive: 'aggressive' + + }; + + + + PhotoSwipe.Cache.Functions = { + + /* + * Function: getImageSource + * Default method for returning an image's source + */ + getImageSource: function(el){ + return el.href; + }, + + + + /* + * Function: getImageCaption + * Default method for returning an image's caption + * Assumes the el is an anchor and the first child is the + * image. The returned value is the "alt" attribute of the + * image. + */ + getImageCaption: function(el){ + + if (el.nodeName === "IMG"){ + return Util.DOM.getAttribute(el, 'alt'); + } + var i, j, childEl; + for (i=0, j=el.childNodes.length; i height){ + height = Util.DOM.windowHeight(); + } + + } + else{ + + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + + } + + Util.DOM.setStyle(this.el, { + width: width, + height: height, + top: top + }); + + }, + + + + /* + * Function: fadeIn + */ + fadeIn: function(speed, callback){ + + this.resetPosition(); + + Util.DOM.setStyle(this.el, 'opacity', 0); + Util.DOM.show(this.el); + + Util.Animation.fadeIn(this.el, speed, callback); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Carousel.EventTypes = { + + onSlideByEnd: 'PhotoSwipeCarouselOnSlideByEnd', + onSlideshowStart: 'PhotoSwipeCarouselOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeCarouselOnSlideshowStop' + + }; + + + + PhotoSwipe.Carousel.CssClasses = { + carousel: 'ps-carousel', + content: 'ps-carousel-content', + item: 'ps-carousel-item', + itemLoading: 'ps-carousel-item-loading', + itemError: 'ps-carousel-item-error' + }; + + + + PhotoSwipe.Carousel.SlideByAction = { + previous: 'previous', + current: 'current', + next: 'next' + }; + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = klass({ + + + + el: null, + contentEl: null, + settings: null, + cache: null, + slideByEndHandler: null, + currentCacheIndex: null, + isSliding: null, + isSlideshowActive: null, + lastSlideByAction: null, + touchStartPoint: null, + touchStartPosition: null, + imageLoadHandler: null, + imageErrorHandler: null, + slideshowTimeout: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i, j; + + for (i=0, j=this.cache.images.length; i 0){ + Util.DOM.setStyle(itemEl, { + marginRight: this.settings.margin + 'px' + }); + } + + Util.DOM.appendChild(itemEl, this.contentEl); + + } + + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + }, + + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, height, top, itemWidth, itemEls, contentWidth, i, j, itemEl, imageEl; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + } + + itemWidth = (this.settings.margin > 0) ? width + this.settings.margin : width; + itemEls = Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + contentWidth = itemWidth * itemEls.length; + + + // Set the height and width to fill the document + Util.DOM.setStyle(this.el, { + top: top, + width: width, + height: height + }); + + + // Set the height and width of the content el + Util.DOM.setStyle(this.contentEl, { + width: contentWidth, + height: height + }); + + + // Set the height and width of item elements + for (i=0, j=itemEls.length; i maxWidth){ + scale = maxWidth / newWidth; + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + if (newHeight > maxHeight){ + scale = maxHeight / newHeight; + newHeight = Math.round(newHeight * scale); + newWidth = Math.round(newWidth * scale); + } + + } + else{ + + if (imageEl.isLandscape) { + // Ensure the width fits the screen + scale = maxWidth / imageEl.naturalWidth; + } + else { + // Ensure the height fits the screen + scale = maxHeight / imageEl.naturalHeight; + } + + newWidth = Math.round(imageEl.naturalWidth * scale); + newHeight = Math.round(imageEl.naturalHeight * scale); + + if (this.settings.imageScaleMethod === 'zoom'){ + + scale = 1; + if (newHeight < maxHeight){ + scale = maxHeight /newHeight; + } + else if (newWidth < maxWidth){ + scale = maxWidth /newWidth; + } + + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + } + else if (this.settings.imageScaleMethod === 'fit') { + // Rescale again to ensure full image fits into the viewport + scale = 1; + if (newWidth > maxWidth) { + scale = maxWidth / newWidth; + } + else if (newHeight > maxHeight) { + scale = maxHeight / newHeight; + } + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + } + + } + + newTop = Math.round( ((maxHeight - newHeight) / 2) ) + 'px'; + newLeft = Math.round( ((maxWidth - newWidth) / 2) ) + 'px'; + + Util.DOM.setStyle(imageEl, { + position: 'absolute', + width: newWidth, + height: newHeight, + top: newTop, + left: newLeft, + display: 'block' + }); + + }, + + + + /* + * Function: setContentLeftPosition + */ + setContentLeftPosition: function(){ + + var width, itemEls, left; + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + } + else{ + width = Util.DOM.width(this.settings.target); + } + + itemEls = this.getItemEls(); + left = 0; + + if (this.settings.loop){ + left = (width + this.settings.margin) * -1; + } + else{ + + if (this.currentCacheIndex === this.cache.images.length-1){ + left = ((itemEls.length-1) * (width + this.settings.margin)) * -1; + } + else if (this.currentCacheIndex > 0){ + left = (width + this.settings.margin) * -1; + } + + } + + Util.DOM.setStyle(this.contentEl, { + left: left + 'px' + }); + + }, + + + + /* + * Function: + */ + show: function(index){ + + this.currentCacheIndex = index; + this.resetPosition(); + this.setImages(false); + Util.DOM.show(this.el); + + Util.Animation.resetTranslate(this.contentEl); + var + itemEls = this.getItemEls(), + i, j; + for (i=0, j=itemEls.length; i this.cache.images.length-1){ + nextCacheIndex = 0; + } + if (previousCacheIndex < 0){ + previousCacheIndex = this.cache.images.length-1; + } + + cacheImages = this.cache.getImages([ + previousCacheIndex, + this.currentCacheIndex, + nextCacheIndex + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + + } + else{ + + if (itemEls.length === 1){ + if (!ignoreCurrent){ + // Current + cacheImages = this.cache.getImages([ + this.currentCacheIndex + ]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + } + else if (itemEls.length === 2){ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + else{ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1, + this.currentCacheIndex + 2 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + else if (this.currentCacheIndex === this.cache.images.length-1){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 2, + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + + } + + }, + + + + /* + * Function: addCacheImageToItemEl + */ + addCacheImageToItemEl: function(cacheImage, itemEl){ + + Util.DOM.removeClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemError); + Util.DOM.addClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemLoading); + + Util.DOM.removeChildren(itemEl); + + Util.DOM.setStyle(cacheImage.imageEl, { + display: 'none' + }); + Util.DOM.appendChild(cacheImage.imageEl, itemEl); + + Util.Animation.resetTranslate(cacheImage.imageEl); + + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + cacheImage.load(); + + }, + + + + /* + * Function: slideCarousel + */ + slideCarousel: function(point, action, speed){ + + if (this.isSliding){ + return; + } + + var width, diffX, slideBy; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth() + this.settings.margin; + } + else{ + width = Util.DOM.width(this.settings.target) + this.settings.margin; + } + + speed = Util.coalesce(speed, this.settings.slideSpeed); + + if (window.Math.abs(diffX) < 1){ + return; + } + + + switch (action){ + + case Util.TouchElement.ActionTypes.swipeLeft: + + slideBy = width * -1; + break; + + case Util.TouchElement.ActionTypes.swipeRight: + + slideBy = width; + break; + + default: + + diffX = point.x - this.touchStartPoint.x; + + if (window.Math.abs(diffX) > width / 2){ + slideBy = (diffX > 0) ? width : width * -1; + } + else{ + slideBy = 0; + } + break; + + } + + if (slideBy < 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.next; + } + else if (slideBy > 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.previous; + } + else{ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + + // Check for non-looping carousels + // If we are at the start or end, spring back to the current item element + if (!this.settings.loop){ + if ( (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous && this.currentCacheIndex === 0 ) || (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next && this.currentCacheIndex === this.cache.images.length-1) ){ + slideBy = 0; + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + } + + this.isSliding = true; + this.doSlideCarousel(slideBy, speed); + + }, + + + + /* + * Function: + */ + moveCarousel: function(point){ + + if (this.isSliding){ + return; + } + + if (!this.settings.enableDrag){ + return; + } + + this.doMoveCarousel(point.x - this.touchStartPoint.x); + + }, + + + + /* + * Function: getItemEls + */ + getItemEls: function(){ + + return Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeRight, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: next + */ + next: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: slideshowNext + */ + slideshowNext: function(){ + + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft); + + }, + + + + + /* + * Function: startSlideshow + */ + startSlideshow: function(){ + + this.stopSlideshow(); + + this.isSlideshowActive = true; + + this.slideshowTimeout = window.setTimeout(this.slideshowNext.bind(this), this.settings.slideshowDelay); + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: stopSlideshow + */ + stopSlideshow: function(){ + + if (!Util.isNothing(this.slideshowTimeout)){ + + window.clearTimeout(this.slideshowTimeout); + this.slideshowTimeout = null; + this.isSlideshowActive = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStop, + target: this + }); + + } + + }, + + + + /* + * Function: onSlideByEnd + */ + onSlideByEnd: function(e){ + + if (Util.isNothing(this.isSliding)){ + return; + } + + var itemEls = this.getItemEls(); + + this.isSliding = false; + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + this.currentCacheIndex = this.currentCacheIndex + 1; + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + this.currentCacheIndex = this.currentCacheIndex - 1; + } + + if (this.settings.loop){ + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + + if (this.currentCacheIndex < 0){ + this.currentCacheIndex = this.cache.images.length - 1; + } + else if (this.currentCacheIndex === this.cache.images.length){ + this.currentCacheIndex = 0; + } + + } + else{ + + if (this.cache.images.length > 3){ + + if (this.currentCacheIndex > 1 && this.currentCacheIndex < this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === 1){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + } + + } + + + } + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.setContentLeftPosition(); + this.setImages(true); + } + + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideByEnd, + target: this, + action: this.lastSlideByAction, + cacheIndex: this.currentCacheIndex + }); + + + if (this.isSlideshowActive){ + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.startSlideshow(); + } + else{ + this.stopSlideshow(); + } + + } + + + }, + + + + /* + * Function: onTouch + */ + onTouch: function(action, point){ + + this.stopSlideshow(); + + switch(action){ + + case Util.TouchElement.ActionTypes.touchStart: + this.touchStartPoint = point; + this.touchStartPosition = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.moveCarousel(point); + break; + + case Util.TouchElement.ActionTypes.touchMoveEnd: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + this.slideCarousel(point, action); + break; + + case Util.TouchElement.ActionTypes.tap: + break; + + case Util.TouchElement.ActionTypes.doubleTap: + break; + + + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + this.resetImagePosition(cacheImage.imageEl); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + Util.DOM.addClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemError); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util, TouchElement){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = PhotoSwipe.Carousel.CarouselClass.extend({ + + + /* + * Function: getStartingPos + */ + getStartingPos: function(){ + + var startingPos = this.touchStartPosition; + + if (Util.isNothing(startingPos)){ + startingPos = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + } + + return startingPos; + + }, + + + + /* + * Function: doMoveCarousel + */ + doMoveCarousel: function(xVal){ + + var style; + + if (Util.Browser.isCSSTransformSupported){ + + style = {}; + + style[Util.Animation._transitionPrefix + 'Property'] = 'all'; + style[Util.Animation._transitionPrefix + 'Duration'] = ''; + style[Util.Animation._transitionPrefix + 'TimingFunction'] = ''; + style[Util.Animation._transitionPrefix + 'Delay'] = '0'; + style[Util.Animation._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(' + xVal + 'px, 0px, 0px)' : 'translate(' + xVal + 'px, 0px)'; + + Util.DOM.setStyle(this.contentEl, style); + + } + else if (!Util.isNothing(window.jQuery)){ + + + window.jQuery(this.contentEl).stop().css('left', this.getStartingPos().x + xVal + 'px'); + + } + + }, + + + + /* + * Function: doSlideCarousel + */ + doSlideCarousel: function(xVal, speed){ + + var animateProps, transform; + + if (speed <= 0){ + + this.slideByEndHandler(); + return; + + } + + + if (Util.Browser.isCSSTransformSupported){ + + transform = Util.coalesce(this.contentEl.style.webkitTransform, this.contentEl.style.MozTransform, this.contentEl.style.transform, ''); + if (transform.indexOf('translate3d(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + else if (transform.indexOf('translate(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + + Util.Animation.slideBy(this.contentEl, xVal, 0, speed, this.slideByEndHandler, this.settings.slideTimingFunction); + + } + else if (!Util.isNothing(window.jQuery)){ + + animateProps = { + left: this.getStartingPos().x + xVal + 'px' + }; + + if (this.settings.animationTimingFunction === 'ease-out'){ + this.settings.animationTimingFunction = 'easeOutQuad'; + } + + if ( Util.isNothing(window.jQuery.easing[this.settings.animationTimingFunction]) ){ + this.settings.animationTimingFunction = 'linear'; + } + + window.jQuery(this.contentEl).animate( + animateProps, + this.settings.slideSpeed, + this.settings.animationTimingFunction, + this.slideByEndHandler + ); + + } + + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.TouchElement +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.CssClasses = { + toolbar: 'ps-toolbar', + toolbarContent: 'ps-toolbar-content', + toolbarTop: 'ps-toolbar-top', + caption: 'ps-caption', + captionBottom: 'ps-caption-bottom', + captionContent: 'ps-caption-content', + close: 'ps-toolbar-close', + play: 'ps-toolbar-play', + previous: 'ps-toolbar-previous', + previousDisabled: 'ps-toolbar-previous-disabled', + next: 'ps-toolbar-next', + nextDisabled: 'ps-toolbar-next-disabled' + }; + + + + PhotoSwipe.Toolbar.ToolbarAction = { + close: 'close', + play: 'play', + next: 'next', + previous: 'previous', + none: 'none' + }; + + + + PhotoSwipe.Toolbar.EventTypes = { + onTap: 'PhotoSwipeToolbarOnClick', + onBeforeShow: 'PhotoSwipeToolbarOnBeforeShow', + onShow: 'PhotoSwipeToolbarOnShow', + onBeforeHide: 'PhotoSwipeToolbarOnBeforeHide', + onHide: 'PhotoSwipeToolbarOnHide' + }; + + + + PhotoSwipe.Toolbar.getToolbar = function(){ + + return '
'; + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.ToolbarClass = klass({ + + + + toolbarEl: null, + closeEl: null, + playEl: null, + previousEl: null, + nextEl: null, + captionEl: null, + captionContentEl: null, + currentCaption: null, + settings: null, + cache: null, + timeout: null, + isVisible: null, + fadeOutHandler: null, + touchStartHandler: null, + touchMoveHandler: null, + clickHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.clearTimeout(); + + this.removeEventHandlers(); + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + Util.DOM.removeChild(this.toolbarEl, this.toolbarEl.parentNode); + Util.DOM.removeChild(this.captionEl, this.captionEl.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(cache, options){ + + var cssClass; + + this.settings = options; + this.cache = cache; + this.isVisible = false; + + this.fadeOutHandler = this.onFadeOut.bind(this); + this.touchStartHandler = this.onTouchStart.bind(this); + this.touchMoveHandler = this.onTouchMove.bind(this); + this.clickHandler = this.onClick.bind(this); + + + cssClass = PhotoSwipe.Toolbar.CssClasses.toolbar; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.toolbarTop; + } + + + // Toolbar + this.toolbarEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + this.settings.getToolbar() + ); + + + Util.DOM.setStyle(this.toolbarEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.toolbarEl); + } + else{ + Util.DOM.appendChild(this.toolbarEl, this.settings.target); + } + Util.DOM.hide(this.toolbarEl); + + this.closeEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.close, this.toolbarEl)[0]; + if (this.settings.preventHide && !Util.isNothing(this.closeEl)){ + Util.DOM.hide(this.closeEl); + } + + this.playEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.play, this.toolbarEl)[0]; + if (this.settings.preventSlideshow && !Util.isNothing(this.playEl)){ + Util.DOM.hide(this.playEl); + } + + this.nextEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.next, this.toolbarEl)[0]; + this.previousEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.previous, this.toolbarEl)[0]; + + + // Caption + cssClass = PhotoSwipe.Toolbar.CssClasses.caption; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.captionBottom; + } + + this.captionEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + '' + ); + Util.DOM.setStyle(this.captionEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.captionEl); + } + else{ + Util.DOM.appendChild(this.captionEl, this.settings.target); + } + Util.DOM.hide(this.captionEl); + + this.captionContentEl = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.Toolbar.CssClasses.captionContent + }, + '' + ); + Util.DOM.appendChild(this.captionContentEl, this.captionEl); + + this.addEventHandlers(); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, toolbarTop, captionTop; + + if (this.settings.target === window){ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = Util.DOM.windowScrollTop(); + captionTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.captionEl); + } + else { + toolbarTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.toolbarEl); + captionTop = Util.DOM.windowScrollTop(); + } + width = Util.DOM.windowWidth(); + } + else{ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = '0'; + captionTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.captionEl); + } + else{ + toolbarTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.toolbarEl); + captionTop = 0; + } + width = Util.DOM.width(this.settings.target); + } + + Util.DOM.setStyle(this.toolbarEl, { + top: toolbarTop + 'px', + width: width + }); + + Util.DOM.setStyle(this.captionEl, { + top: captionTop + 'px', + width: width + }); + }, + + + + /* + * Function: toggleVisibility + */ + toggleVisibility: function(index){ + + if (this.isVisible){ + this.fadeOut(); + } + else{ + this.show(index); + } + + }, + + + + /* + * Function: show + */ + show: function(index){ + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + this.resetPosition(); + this.setToolbarStatus(index); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeShow, + target: this + }); + + this.showToolbar(); + this.setCaption(index); + this.showCaption(); + + this.isVisible = true; + + this.setTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onShow, + target: this + }); + + }, + + + + /* + * Function: setTimeout + */ + setTimeout: function(){ + + if (this.settings.captionAndToolbarAutoHideDelay > 0){ + // Set a timeout to hide the toolbar + this.clearTimeout(); + this.timeout = window.setTimeout(this.fadeOut.bind(this), this.settings.captionAndToolbarAutoHideDelay); + } + + }, + + + + /* + * Function: clearTimeout + */ + clearTimeout: function(){ + + if (!Util.isNothing(this.timeout)){ + window.clearTimeout(this.timeout); + this.timeout = null; + } + + }, + + + + /* + * Function: fadeOut + */ + fadeOut: function(){ + + this.clearTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeHide, + target: this + }); + + Util.Animation.fadeOut(this.toolbarEl, this.settings.fadeOutSpeed); + Util.Animation.fadeOut(this.captionEl, this.settings.fadeOutSpeed, this.fadeOutHandler); + + this.isVisible = false; + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.add(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.add(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.add(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.add(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.remove(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.remove(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.remove(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: handleTap + */ + handleTap: function(e){ + + this.clearTimeout(); + + var action; + + if (e.target === this.nextEl || Util.DOM.isChildOf(e.target, this.nextEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.next; + } + else if (e.target === this.previousEl || Util.DOM.isChildOf(e.target, this.previousEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.previous; + } + else if (e.target === this.closeEl || Util.DOM.isChildOf(e.target, this.closeEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.close; + } + else if (e.target === this.playEl || Util.DOM.isChildOf(e.target, this.playEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.play; + } + + this.setTimeout(); + + if (Util.isNothing(action)){ + action = PhotoSwipe.Toolbar.ToolbarAction.none; + } + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onTap, + target: this, + action: action, + tapTarget: e.target + }); + + }, + + + + /* + * Function: setCaption + */ + setCaption: function(index){ + + Util.DOM.removeChildren(this.captionContentEl); + + this.currentCaption = Util.coalesce(this.cache.images[index].caption, '\u00A0'); + + if (Util.isObject(this.currentCaption)){ + Util.DOM.appendChild(this.currentCaption, this.captionContentEl); + } + else{ + if (this.currentCaption === ''){ + this.currentCaption = '\u00A0'; + } + Util.DOM.appendText(this.currentCaption, this.captionContentEl); + } + + this.currentCaption = (this.currentCaption === '\u00A0') ? '' : this.currentCaption; + this.resetPosition(); + + }, + + + + /* + * Function: showToolbar + */ + showToolbar: function(){ + + Util.DOM.setStyle(this.toolbarEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.toolbarEl); + + }, + + + + /* + * Function: showCaption + */ + showCaption: function(){ + + if (this.currentCaption === '' || this.captionContentEl.childNodes.length < 1){ + // Empty caption + if (!this.settings.captionAndToolbarShowEmptyCaptions){ + Util.DOM.hide(this.captionEl); + return; + } + } + Util.DOM.setStyle(this.captionEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.captionEl); + + }, + + + + /* + * Function: setToolbarStatus + */ + setToolbarStatus: function(index){ + + if (this.settings.loop){ + return; + } + + Util.DOM.removeClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + Util.DOM.removeClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + + if (index > 0 && index < this.cache.images.length-1){ + return; + } + + if (index === 0){ + if (!Util.isNothing(this.previousEl)){ + Util.DOM.addClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + } + } + + if (index === this.cache.images.length-1){ + if (!Util.isNothing(this.nextEl)){ + Util.DOM.addClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + } + } + + }, + + + + /* + * Function: onFadeOut + */ + onFadeOut: function(){ + + Util.DOM.hide(this.toolbarEl); + Util.DOM.hide(this.captionEl); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onHide, + target: this + }); + + }, + + + + /* + * Function: onTouchStart + */ + onTouchStart: function(e){ + + e.preventDefault(); + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + this.handleTap(e); + + }, + + + + /* + * Function: onTouchMove + */ + onTouchMove: function(e){ + + e.preventDefault(); + + }, + + + + /* + * Function: onClick + */ + onClick: function(e){ + + e.preventDefault(); + this.handleTap(e); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.UILayer.CssClasses = { + uiLayer: 'ps-uilayer' + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.UILayer.UILayerClass = Util.TouchElement.TouchElementClass.extend({ + + + + el: null, + settings: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.removeEventHandlers(); + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options){ + + this.settings = options; + + // Main container + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.UILayer.CssClasses.uiLayer + }, + '' + ); + Util.DOM.setStyle(this.el, { + display: 'block', + position: 'absolute', + left: 0, + top: 0, + overflow: 'hidden', + zIndex: this.settings.zIndex, + opacity: 0 + }); + Util.DOM.hide(this.el); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + this.supr(this.el, { + swipe: true, + move: true, + gesture: Util.Browser.iOS, + doubleTap: true, + preventDefaultTouchEvents: this.settings.preventDefaultTouchEvents + }); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + // Set the height and width to fill the document + if (this.settings.target === window){ + Util.DOM.setStyle(this.el, { + top: Util.DOM.windowScrollTop() + 'px', + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }); + } + else{ + Util.DOM.setStyle(this.el, { + top: '0px', + width: Util.DOM.width(this.settings.target), + height: Util.DOM.height(this.settings.target) + }); + } + + }, + + + + /* + * Function: show + */ + show: function(){ + + this.resetPosition(); + Util.DOM.show(this.el); + this.addEventHandlers(); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + this.supr(); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + this.supr(); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.ZoomPanRotate.CssClasses = { + zoomPanRotate: 'ps-zoom-pan-rotate' + }; + + + PhotoSwipe.ZoomPanRotate.EventTypes = { + + onTransform: 'PhotoSwipeZoomPanRotateOnTransform' + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.ZoomPanRotate.ZoomPanRotateClass = klass({ + + el: null, + settings: null, + containerEl: null, + imageEl: null, + transformSettings: null, + panStartingPoint: null, + transformEl: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options, cacheImage, uiLayer){ + + var parentEl, width, height, top; + + this.settings = options; + + if (this.settings.target === window){ + parentEl = document.body; + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + parentEl = this.settings.target; + width = Util.DOM.width(parentEl); + height = Util.DOM.height(parentEl); + top = '0px'; + } + + this.imageEl = cacheImage.imageEl.cloneNode(false); + Util.DOM.setStyle(this.imageEl, { + + zIndex: 1 + + }); + + this.transformSettings = { + + startingScale: 1.0, + scale: 1.0, + startingRotation: 0, + rotation: 0, + startingTranslateX: 0, + startingTranslateY: 0, + translateX: 0, + translateY: 0 + + }; + + + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.ZoomPanRotate.CssClasses.zoomPanRotate + }, + '' + ); + Util.DOM.setStyle(this.el, { + left: 0, + top: top, + position: 'absolute', + width: width, + height: height, + zIndex: this.settings.zIndex, + display: 'block' + }); + + Util.DOM.insertBefore(this.el, uiLayer.el, parentEl); + + if (Util.Browser.iOS){ + this.containerEl = Util.DOM.createElement('div','',''); + Util.DOM.setStyle(this.containerEl, { + left: 0, + top: 0, + width: width, + height: height, + position: 'absolute', + zIndex: 1 + }); + Util.DOM.appendChild(this.imageEl, this.containerEl); + Util.DOM.appendChild(this.containerEl, this.el); + Util.Animation.resetTranslate(this.containerEl); + Util.Animation.resetTranslate(this.imageEl); + this.transformEl = this.containerEl; + } + else{ + Util.DOM.appendChild(this.imageEl, this.el); + this.transformEl = this.imageEl; + } + + }, + + + + /* + * Function: setStartingTranslateFromCurrentTransform + */ + setStartingTranslateFromCurrentTransform: function(){ + + var + transformValue = Util.coalesce(this.transformEl.style.webkitTransform, this.transformEl.style.MozTransform, this.transformEl.style.transform), + transformExploded; + + if (!Util.isNothing(transformValue)){ + + transformExploded = transformValue.match( /translate\((.*?)\)/ ); + + if (!Util.isNothing(transformExploded)){ + + transformExploded = transformExploded[1].split(', '); + this.transformSettings.startingTranslateX = window.parseInt(transformExploded[0], 10); + this.transformSettings.startingTranslateY = window.parseInt(transformExploded[1], 10); + + } + + } + + }, + + + + /* + * Function: getScale + */ + getScale: function(scaleValue){ + + var scale = this.transformSettings.startingScale * scaleValue; + + if (this.settings.minUserZoom !== 0 && scale < this.settings.minUserZoom){ + scale = this.settings.minUserZoom; + } + else if (this.settings.maxUserZoom !== 0 && scale > this.settings.maxUserZoom){ + scale = this.settings.maxUserZoom; + } + + return scale; + + }, + + + + /* + * Function: setStartingScaleAndRotation + */ + setStartingScaleAndRotation: function(scaleValue, rotationValue){ + + this.transformSettings.startingScale = this.getScale(scaleValue); + + this.transformSettings.startingRotation = + (this.transformSettings.startingRotation + rotationValue) % 360; + + }, + + + + /* + * Function: zoomRotate + */ + zoomRotate: function(scaleValue, rotationValue){ + + this.transformSettings.scale = this.getScale(scaleValue); + + this.transformSettings.rotation = + this.transformSettings.startingRotation + rotationValue; + + this.applyTransform(); + + }, + + + + /* + * Function: panStart + */ + panStart: function(point){ + + this.setStartingTranslateFromCurrentTransform(); + + this.panStartingPoint = { + x: point.x, + y: point.y + }; + + }, + + + + /* + * Function: pan + */ + pan: function(point){ + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale , + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + this.transformSettings.startingTranslateX + dxScaleAdjust; + + this.transformSettings.translateY = + this.transformSettings.startingTranslateY + dyScaleAdjust; + + this.applyTransform(); + + }, + + + + /* + * Function: zoomAndPanToPoint + */ + zoomAndPanToPoint: function(scaleValue, point){ + + + if (this.settings.target === window){ + + this.panStart({ + x: Util.DOM.windowWidth() / 2, + y: Util.DOM.windowHeight() / 2 + }); + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale, + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + (this.transformSettings.startingTranslateX + dxScaleAdjust) * -1; + + this.transformSettings.translateY = + (this.transformSettings.startingTranslateY + dyScaleAdjust) * -1; + + } + + + this.setStartingScaleAndRotation(scaleValue, 0); + this.transformSettings.scale = this.transformSettings.startingScale; + + this.transformSettings.rotation = 0; + + this.applyTransform(); + + }, + + + + /* + * Function: applyTransform + */ + applyTransform: function(){ + + var + rotationDegs = this.transformSettings.rotation % 360, + translateX = window.parseInt(this.transformSettings.translateX, 10), + translateY = window.parseInt(this.transformSettings.translateY, 10), + transform = 'scale(' + this.transformSettings.scale + ') rotate(' + rotationDegs + 'deg) translate(' + translateX + 'px, ' + translateY + 'px)'; + + Util.DOM.setStyle(this.transformEl, { + webkitTransform: transform, + MozTransform: transform, + msTransform: transform, + transform: transform + }); + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, + scale: this.transformSettings.scale, + rotation: this.transformSettings.rotation, + rotationDegs: rotationDegs, + translateX: translateX, + translateY: translateY + }); + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, Util){ + + + Util.registerNamespace('Code.PhotoSwipe'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.CssClasses = { + buildingBody: 'ps-building', + activeBody: 'ps-active' + }; + + + + PhotoSwipe.EventTypes = { + + onBeforeShow: 'PhotoSwipeOnBeforeShow', + onShow: 'PhotoSwipeOnShow', + onBeforeHide: 'PhotoSwipeOnBeforeHide', + onHide: 'PhotoSwipeOnHide', + onDisplayImage: 'PhotoSwipeOnDisplayImage', + onResetPosition: 'PhotoSwipeOnResetPosition', + onSlideshowStart: 'PhotoSwipeOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeOnSlideshowStop', + onTouch: 'PhotoSwipeOnTouch', + onBeforeCaptionAndToolbarShow: 'PhotoSwipeOnBeforeCaptionAndToolbarShow', + onCaptionAndToolbarShow: 'PhotoSwipeOnCaptionAndToolbarShow', + onBeforeCaptionAndToolbarHide: 'PhotoSwipeOnBeforeCaptionAndToolbarHide', + onCaptionAndToolbarHide: 'PhotoSwipeOnCaptionAndToolbarHide', + onToolbarTap: 'PhotoSwipeOnToolbarTap', + onBeforeZoomPanRotateShow: 'PhotoSwipeOnBeforeZoomPanRotateShow', + onZoomPanRotateShow: 'PhotoSwipeOnZoomPanRotateShow', + onBeforeZoomPanRotateHide: 'PhotoSwipeOnBeforeZoomPanRotateHide', + onZoomPanRotateHide: 'PhotoSwipeOnZoomPanRotateHide', + onZoomPanRotateTransform: 'PhotoSwipeOnZoomPanRotateTransform' + + }; + + + + PhotoSwipe.instances = []; + PhotoSwipe.activeInstances = []; + + + + /* + * Function: Code.PhotoSwipe.setActivateInstance + */ + PhotoSwipe.setActivateInstance = function(instance){ + + // Can only have one instance per target (i.e. window or div) + var index = Util.arrayIndexOf(instance.settings.target, PhotoSwipe.activeInstances, 'target'); + if (index > -1){ + throw 'Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target'; + } + PhotoSwipe.activeInstances.push({ + target: instance.settings.target, + instance: instance + }); + + }; + + + + /* + * Function: Code.PhotoSwipe.unsetActivateInstance + */ + PhotoSwipe.unsetActivateInstance = function(instance){ + + var index = Util.arrayIndexOf(instance, PhotoSwipe.activeInstances, 'instance'); + PhotoSwipe.activeInstances.splice(index, 1); + + }; + + + + /* + * Function: Code.PhotoSwipe.attach + */ + PhotoSwipe.attach = function(images, options, id){ + + var i, j, instance, image; + + instance = PhotoSwipe.createInstance(images, options, id); + + // Add click event handlers if applicable + for (i=0, j=images.length; i= 2.1){ + this.isBackEventSupported = true; + } + } + + if (!this.isBackEventSupported){ + this.isBackEventSupported = Util.objectHasProperty(window, 'onhashchange'); + } + + this.settings = { + + // General + fadeInSpeed: 250, + fadeOutSpeed: 250, + preventHide: false, + preventSlideshow: false, + zIndex: 1000, + backButtonHideEnabled: true, + enableKeyboard: true, + enableMouseWheel: true, + mouseWheelSpeed: 350, + autoStartSlideshow: false, + jQueryMobile: ( !Util.isNothing(window.jQuery) && !Util.isNothing(window.jQuery.mobile) ), + jQueryMobileDialogHash: '&ui-state=dialog', + enableUIWebViewRepositionTimeout: false, + uiWebViewResetPositionDelay: 500, + target: window, + preventDefaultTouchEvents: true, + + + // Carousel + loop: true, + slideSpeed: 250, + nextPreviousSlideSpeed: 0, + enableDrag: true, + swipeThreshold: 50, + swipeTimeThreshold: 250, + slideTimingFunction: 'ease-out', + slideshowDelay: 3000, + doubleTapSpeed: 250, + margin: 20, + imageScaleMethod: 'fit', // Either "fit", "fitNoUpscale" or "zoom", + + + // Toolbar + captionAndToolbarHide: false, + captionAndToolbarFlipPosition: false, + captionAndToolbarAutoHideDelay: 5000, + captionAndToolbarOpacity: 0.8, + captionAndToolbarShowEmptyCaptions: true, + getToolbar: PhotoSwipe.Toolbar.getToolbar, + + + // ZoomPanRotate + allowUserZoom: true, + allowRotationOnUserZoom: false, + maxUserZoom: 5.0, + minUserZoom: 0.5, + doubleTapZoomLevel: 2.5, + + + // Cache + getImageSource: PhotoSwipe.Cache.Functions.getImageSource, + getImageCaption: PhotoSwipe.Cache.Functions.getImageCaption, + getImageMetaData: PhotoSwipe.Cache.Functions.getImageMetaData, + cacheMode: PhotoSwipe.Cache.Mode.normal + + }; + + Util.extend(this.settings, options); + + if (this.settings.target !== window){ + targetPosition = Util.DOM.getStyle(this.settings.target, 'position'); + if (targetPosition !== 'relative' || targetPosition !== 'absolute'){ + Util.DOM.setStyle(this.settings.target, 'position', 'relative'); + } + } + + if (this.settings.target !== window){ + this.isBackEventSupported = false; + this.settings.backButtonHideEnabled = false; + } + else{ + if (this.settings.preventHide){ + this.settings.backButtonHideEnabled = false; + } + } + + this.cache = new Cache.CacheClass(images, this.settings); + + }, + + + + /* + * Function: show + */ + show: function(obj){ + + var i, j; + + this._isResettingPosition = false; + this.backButtonClicked = false; + + // Work out what the starting index is + if (Util.isNumber(obj)){ + this.currentIndex = obj; + } + else{ + + this.currentIndex = -1; + for (i=0, j=this.originalImages.length; i this.originalImages.length-1){ + throw "Code.PhotoSwipe.PhotoSwipeClass.show: Starting index out of range"; + } + + // Store a reference to the current window dimensions + // Use this later to double check that a window has actually + // been resized. + this.isAlreadyGettingPage = this.getWindowDimensions(); + + // Set this instance to be the active instance + PhotoSwipe.setActivateInstance(this); + + this.windowDimensions = this.getWindowDimensions(); + + // Create components + if (this.settings.target === window){ + Util.DOM.addClass(window.document.body, PhotoSwipe.CssClasses.buildingBody); + } + else{ + Util.DOM.addClass(this.settings.target, PhotoSwipe.CssClasses.buildingBody); + } + this.createComponents(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeShow, + target: this + }); + + // Fade in the document overlay + this.documentOverlay.fadeIn(this.settings.fadeInSpeed, this.onDocumentOverlayFadeIn.bind(this)); + + }, + + + + /* + * Function: getWindowDimensions + */ + getWindowDimensions: function(){ + + return { + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }; + + }, + + + + /* + * Function: createComponents + */ + createComponents: function(){ + + this.documentOverlay = new DocumentOverlay.DocumentOverlayClass(this.settings); + this.carousel = new Carousel.CarouselClass(this.cache, this.settings); + this.uiLayer = new UILayer.UILayerClass(this.settings); + if (!this.settings.captionAndToolbarHide){ + this.toolbar = new Toolbar.ToolbarClass(this.cache, this.settings); + } + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + if (this._isResettingPosition){ + return; + } + + var newWindowDimensions = this.getWindowDimensions(); + if (!Util.isNothing(this.windowDimensions)){ + if (newWindowDimensions.width === this.windowDimensions.width && newWindowDimensions.height === this.windowDimensions.height){ + // This was added as a fudge for iOS + return; + } + } + + this._isResettingPosition = true; + + this.windowDimensions = newWindowDimensions; + + this.destroyZoomPanRotate(); + + this.documentOverlay.resetPosition(); + this.carousel.resetPosition(); + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.resetPosition(); + } + + this.uiLayer.resetPosition(); + + this._isResettingPosition = false; + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onResetPosition, + target: this + }); + + }, + + + + /* + * Function: addEventHandler + */ + addEventHandler: function(type, handler){ + + Util.Events.add(this, type, handler); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.isNothing(this.windowOrientationChangeHandler)){ + + this.windowOrientationChangeHandler = this.onWindowOrientationChange.bind(this); + this.windowScrollHandler = this.onWindowScroll.bind(this); + this.keyDownHandler = this.onKeyDown.bind(this); + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + this.uiLayerTouchHandler = this.onUILayerTouch.bind(this); + this.carouselSlideByEndHandler = this.onCarouselSlideByEnd.bind(this); + this.carouselSlideshowStartHandler = this.onCarouselSlideshowStart.bind(this); + this.carouselSlideshowStopHandler = this.onCarouselSlideshowStop.bind(this); + this.toolbarTapHandler = this.onToolbarTap.bind(this); + this.toolbarBeforeShowHandler = this.onToolbarBeforeShow.bind(this); + this.toolbarShowHandler = this.onToolbarShow.bind(this); + this.toolbarBeforeHideHandler = this.onToolbarBeforeHide.bind(this); + this.toolbarHideHandler = this.onToolbarHide.bind(this); + this.mouseWheelHandler = this.onMouseWheel.bind(this); + this.zoomPanRotateTransformHandler = this.onZoomPanRotateTransform.bind(this); + + } + + // Set window handlers + if (Util.Browser.android){ + // For some reason, resize was more stable than orientationchange in Android + this.orientationEventName = 'resize'; + } + else if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.add(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + else{ + var supportsOrientationChange = !Util.isNothing(window.onorientationchange); + this.orientationEventName = supportsOrientationChange ? 'orientationchange' : 'resize'; + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.add(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + if (this.settings.target === window){ + Util.Events.add(window, 'scroll', this.windowScrollHandler); + } + + if (this.settings.enableKeyboard){ + Util.Events.add(window.document, 'keydown', this.keyDownHandler); + } + + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + + if (this.settings.jQueryMobile){ + window.location.hash = this.settings.jQueryMobileDialogHash; + } + else{ + this.currentHistoryHashValue = 'PhotoSwipe' + new Date().getTime().toString(); + window.location.hash = this.currentHistoryHashValue; + } + + Util.Events.add(window, 'hashchange', this.windowHashChangeHandler); + + } + + if (this.settings.enableMouseWheel){ + Util.Events.add(window, 'mousewheel', this.mouseWheelHandler); + } + + Util.Events.add(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + + if (!Util.isNothing(this.toolbar)){ + Util.Events.add(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.remove(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.remove(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + + Util.Events.remove(window, 'scroll', this.windowScrollHandler); + + if (this.settings.enableKeyboard){ + Util.Events.remove(window.document, 'keydown', this.keyDownHandler); + } + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + Util.Events.remove(window, 'hashchange', this.windowHashChangeHandler); + } + + if (this.settings.enableMouseWheel){ + Util.Events.remove(window, 'mousewheel', this.mouseWheelHandler); + } + + if (!Util.isNothing(this.uiLayer)){ + Util.Events.remove(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + + /* + * Function: hide + */ + hide: function(){ + + if (this.settings.preventHide){ + return; + } + + if (Util.isNothing(this.documentOverlay)){ + throw "Code.PhotoSwipe.PhotoSwipeClass.hide: PhotoSwipe instance is already hidden"; + } + + if (!Util.isNothing(this.hiding)){ + return; + } + + this.clearUIWebViewResetPositionTimeout(); + + this.destroyZoomPanRotate(); + + this.removeEventHandlers(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeHide, + target: this + }); + + this.uiLayer.dispose(); + this.uiLayer = null; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.dispose(); + this.toolbar = null; + } + + this.carousel.dispose(); + this.carousel = null; + + Util.DOM.removeClass(window.document.body, PhotoSwipe.CssClasses.activeBody); + + this.documentOverlay.dispose(); + this.documentOverlay = null; + + this._isResettingPosition = false; + + // Deactive this instance + PhotoSwipe.unsetActivateInstance(this); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onHide, + target: this + }); + + this.goBackInHistory(); + + }, + + + + /* + * Function: goBackInHistory + */ + goBackInHistory: function(){ + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + if ( !this.backButtonClicked ){ + window.history.back(); + } + } + + }, + + + + /* + * Function: play + */ + play: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!this.settings.preventSlideshow){ + if (!Util.isNothing(this.carousel)){ + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + this.carousel.startSlideshow(); + } + } + + }, + + + + /* + * Function: stop + */ + stop: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.stopSlideshow(); + } + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.previous(); + } + + }, + + + + /* + * Function: next + */ + next: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.next(); + } + + }, + + + + /* + * Function: toggleToolbar + */ + toggleToolbar: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.toggleVisibility(this.currentIndex); + } + + }, + + + + /* + * Function: fadeOutToolbarIfVisible + */ + fadeOutToolbarIfVisible: function(){ + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible && this.settings.captionAndToolbarAutoHideDelay > 0){ + this.toolbar.fadeOut(); + } + + }, + + + + /* + * Function: createZoomPanRotate + */ + createZoomPanRotate: function(){ + + this.stop(); + + if (this.canUserZoom() && !this.isZoomActive()){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateShow); + + this.zoomPanRotate = new ZoomPanRotate.ZoomPanRotateClass( + this.settings, + this.cache.images[this.currentIndex], + this.uiLayer + ); + + // If we don't override this in the event of false + // you will be unable to pan around a zoomed image effectively + this.uiLayer.captureSettings.preventDefaultTouchEvents = true; + + Util.Events.add(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateShow); + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + + } + + }, + + + + /* + * Function: destroyZoomPanRotate + */ + destroyZoomPanRotate: function(){ + + if (!Util.isNothing(this.zoomPanRotate)){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateHide); + + Util.Events.remove(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + this.zoomPanRotate.dispose(); + this.zoomPanRotate = null; + + // Set the preventDefaultTouchEvents back to it was + this.uiLayer.captureSettings.preventDefaultTouchEvents = this.settings.preventDefaultTouchEvents; + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateHide); + + } + + }, + + + + /* + * Function: canUserZoom + */ + canUserZoom: function(){ + + var testEl, cacheImage; + + if (Util.Browser.msie){ + testEl = document.createElement('div'); + if (Util.isNothing(testEl.style.msTransform)){ + return false; + } + } + else if (!Util.Browser.isCSSTransformSupported){ + return false; + } + + if (!this.settings.allowUserZoom){ + return false; + } + + + if (this.carousel.isSliding){ + return false; + } + + cacheImage = this.cache.images[this.currentIndex]; + + if (Util.isNothing(cacheImage)){ + return false; + } + + if (cacheImage.isLoading){ + return false; + } + + return true; + + }, + + + + /* + * Function: isZoomActive + */ + isZoomActive: function(){ + + return (!Util.isNothing(this.zoomPanRotate)); + + }, + + + + /* + * Function: getCurrentImage + */ + getCurrentImage: function(){ + + return this.cache.images[this.currentIndex]; + + }, + + + + /* + * Function: onDocumentOverlayFadeIn + */ + onDocumentOverlayFadeIn: function(e){ + + window.setTimeout(function(){ + + var el = (this.settings.target === window) ? window.document.body : this.settings.target; + + Util.DOM.removeClass(el, PhotoSwipe.CssClasses.buildingBody); + Util.DOM.addClass(el, PhotoSwipe.CssClasses.activeBody); + + this.addEventHandlers(); + + this.carousel.show(this.currentIndex); + + this.uiLayer.show(); + + if (this.settings.autoStartSlideshow){ + this.play(); + } + else if (!Util.isNothing(this.toolbar)){ + this.toolbar.show(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onShow, + target: this + }); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), 250); + + + }, + + + + /* + * Function: setUIWebViewResetPositionTimeout + */ + setUIWebViewResetPositionTimeout: function(){ + + if (!this.settings.enableUIWebViewRepositionTimeout){ + return; + } + + if (!(Util.Browser.iOS && (!Util.Browser.safari))){ + return; + } + + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + this._uiWebViewResetPositionTimeout = window.setTimeout(function(){ + + this.resetPosition(); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), this.settings.uiWebViewResetPositionDelay); + + }, + + + + /* + * Function: clearUIWebViewResetPositionTimeout + */ + clearUIWebViewResetPositionTimeout: function(){ + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + }, + + + + /* + * Function: onWindowScroll + */ + onWindowScroll: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowOrientationChange + */ + onWindowOrientationChange: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowHashChange + */ + onWindowHashChange: function(e){ + + var compareHash = '#' + + ((this.settings.jQueryMobile) ? this.settings.jQueryMobileDialogHash : this.currentHistoryHashValue); + + if (window.location.hash !== compareHash){ + this.backButtonClicked = true; + this.hide(); + } + + }, + + + + /* + * Function: onKeyDown + */ + onKeyDown: function(e){ + + if (e.keyCode === 37) { // Left + e.preventDefault(); + this.previous(); + } + else if (e.keyCode === 39) { // Right + e.preventDefault(); + this.next(); + } + else if (e.keyCode === 38 || e.keyCode === 40) { // Up and down + e.preventDefault(); + } + else if (e.keyCode === 27) { // Escape + e.preventDefault(); + this.hide(); + } + else if (e.keyCode === 32) { // Spacebar + if (!this.settings.hideToolbar){ + this.toggleToolbar(); + } + else{ + this.hide(); + } + e.preventDefault(); + } + else if (e.keyCode === 13) { // Enter + e.preventDefault(); + this.play(); + } + + }, + + + + /* + * Function: onUILayerTouch + */ + onUILayerTouch: function(e){ + + if (this.isZoomActive()){ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.gestureChange: + this.zoomPanRotate.zoomRotate(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.gestureEnd: + this.zoomPanRotate.setStartingScaleAndRotation(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.touchStart: + this.zoomPanRotate.panStart(e.point); + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.zoomPanRotate.pan(e.point); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + this.destroyZoomPanRotate(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeLeft: + this.destroyZoomPanRotate(); + this.next(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeRight: + this.destroyZoomPanRotate(); + this.previous(); + this.toggleToolbar(); + break; + } + + } + else{ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.touchMove: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + + // Hide the toolbar if need be + this.fadeOutToolbarIfVisible(); + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.touchStart: + case Util.TouchElement.ActionTypes.touchMoveEnd: + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.tap: + //this.toggleToolbar(); + this.hide(); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + + // Take into consideration the window scroll + if (this.settings.target === window){ + e.point.x -= Util.DOM.windowScrollLeft(); + e.point.y -= Util.DOM.windowScrollTop(); + } + + // Just make sure that if the user clicks out of the image + // that the image does not pan out of view! + var + cacheImageEl = this.cache.images[this.currentIndex].imageEl, + + imageTop = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'top'), 10), + imageLeft = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'left'), 10), + imageRight = imageLeft + Util.DOM.width(cacheImageEl), + imageBottom = imageTop + Util.DOM.height(cacheImageEl); + + if (e.point.x < imageLeft){ + e.point.x = imageLeft; + } + else if (e.point.x > imageRight){ + e.point.x = imageRight; + } + + if (e.point.y < imageTop){ + e.point.y = imageTop; + } + else if (e.point.y > imageBottom){ + e.point.y = imageBottom; + } + + this.createZoomPanRotate(); + if (this.isZoomActive()){ + this.zoomPanRotate.zoomAndPanToPoint(this.settings.doubleTapZoomLevel, e.point); + } + + break; + + case Util.TouchElement.ActionTypes.gestureStart: + this.createZoomPanRotate(); + break; + } + + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onTouch, + target: this, + point: e.point, + action: e.action + }); + + }, + + + + /* + * Function: onCarouselSlideByEnd + */ + onCarouselSlideByEnd: function(e){ + + this.currentIndex = e.cacheIndex; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.setCaption(this.currentIndex); + this.toolbar.setToolbarStatus(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onDisplayImage, + target: this, + action: e.action, + index: e.cacheIndex + }); + + }, + + + + /* + * Function: onToolbarTap + */ + onToolbarTap: function(e){ + + switch(e.action){ + + case Toolbar.ToolbarAction.next: + this.next(); + break; + + case Toolbar.ToolbarAction.previous: + this.previous(); + break; + + case Toolbar.ToolbarAction.close: + this.hide(); + break; + + case Toolbar.ToolbarAction.play: + this.play(); + break; + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onToolbarTap, + target: this, + toolbarAction: e.action, + tapTarget: e.tapTarget + }); + + }, + + + + /* + * Function: onMouseWheel + */ + onMouseWheel: function(e){ + + var + delta = Util.Events.getWheelDelta(e), + dt = e.timeStamp - (this.mouseWheelStartTime || 0); + + if (dt < this.settings.mouseWheelSpeed) { + return; + } + + this.mouseWheelStartTime = e.timeStamp; + + if (this.settings.invertMouseWheel){ + delta = delta * -1; + } + + if (delta < 0){ + this.next(); + } + else if (delta > 0){ + this.previous(); + } + + }, + + + + /* + * Function: onCarouselSlideshowStart + */ + onCarouselSlideshowStart: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: onCarouselSlideshowStop + */ + onCarouselSlideshowStop: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStop, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeShow + */ + onToolbarBeforeShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarShow + */ + onToolbarShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeHide + */ + onToolbarBeforeHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onToolbarHide + */ + onToolbarHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onZoomPanRotateTransform + */ + onZoomPanRotateTransform: function(e){ + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.EventTypes.onZoomPanRotateTransform, + scale: e.scale, + rotation: e.rotation, + rotationDegs: e.rotationDegs, + translateX: e.translateX, + translateY: e.translateY + }); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.Cache, + window.Code.PhotoSwipe.DocumentOverlay, + window.Code.PhotoSwipe.Carousel, + window.Code.PhotoSwipe.Toolbar, + window.Code.PhotoSwipe.UILayer, + window.Code.PhotoSwipe.ZoomPanRotate +)); diff --git a/photoswipe/code.photoswipe.jquery-3.0.5.min.js b/photoswipe/code.photoswipe.jquery-3.0.5.min.js new file mode 100755 index 0000000..ad55d00 --- /dev/null +++ b/photoswipe/code.photoswipe.jquery-3.0.5.min.js @@ -0,0 +1,164 @@ +// PhotoSwipe - http://www.photoswipe.com/ +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 +(function(e){if(!Function.prototype.bind)Function.prototype.bind=function(d){var a=[].slice,b=a.call(arguments,1),c=this,g=function(){},f=function(){return c.apply(this instanceof g?this:d||{},b.concat(a.call(arguments)))};g.prototype=c.prototype;f.prototype=new g;return f};if(typeof e.Code==="undefined")e.Code={};e.Code.Util={registerNamespace:function(){var d=arguments,a=null,b,c,g,f,i;b=0;for(f=d.length;bd.DOM.windowHeight()}};d.Browser._detect()})(window,window.Code.Util); +(function(e,d,a){a.extend(a,{Events:{add:function(a,c,g){d(a).bind(c,g)},remove:function(a,c,g){d(a).unbind(c,g)},fire:function(a,c){var g,f=Array.prototype.slice.call(arguments).splice(2);g=typeof c==="string"?{type:c}:c;d(a).trigger(d.Event(g.type,g),f)},getMousePosition:function(a){return{x:a.pageX,y:a.pageY}},getTouchEvent:function(a){return a.originalEvent},getWheelDelta:function(b){var c=0;a.isNothing(b.wheelDelta)?a.isNothing(b.detail)||(c=-b.detail/3):c=b.wheelDelta/120;return c},domReady:function(a){d(document).ready(a)}}})})(window, +window.jQuery,window.Code.Util); +(function(e,d,a){a.extend(a,{DOM:{setData:function(b,c,g){if(a.isLikeArray(b)){var f,d;f=0;for(d=b.length;f");a.attr(c);a.append(g);return a[0]},appendChild:function(a,c){d(c).append(a)},insertBefore:function(a,c){d(a).insertBefore(c)},appendText:function(a,c){d(c).text(a)},appendToBody:function(a){d("body").append(a)},removeChild:function(a){d(a).empty().remove()},removeChildren:function(a){d(a).empty()}, +hasAttribute:function(b,c){return!a.isNothing(d(b).attr(c))},getAttribute:function(b,c,g){b=d(b).attr(c);a.isNothing(b)&&!a.isNothing(g)&&(b=g);return b},setAttribute:function(b,c,g){if(a.isLikeArray(b)){var f,d;f=0;for(d=b.length;f=1&&d.DOM.setStyle(a,"opacity",0);d.Browser.isCSSTransformSupported?this._applyTransition(a,"opacity",f,b,c,g):d.isNothing(e.jQuery)||e.jQuery(a).fadeTo(b,f,c)},fadeTo:function(a,b,c,g,f){this.fadeIn(a, +c,g,f,b)},fadeOut:function(a,b,c,g){if(b<=0&&(d.DOM.setStyle(a,"opacity",0),!d.isNothing(c))){c(a);return}d.Browser.isCSSTransformSupported?this._applyTransition(a,"opacity",0,b,c,g):e.jQuery(a).fadeTo(b,0,c)},slideBy:function(a,b,c,g,f,i){var j={},b=d.coalesce(b,0),c=d.coalesce(c,0),i=d.coalesce(i,"ease-out");j[this._transitionPrefix+"Property"]="all";j[this._transitionPrefix+"Delay"]="0";g===0?(j[this._transitionPrefix+"Duration"]="",j[this._transitionPrefix+"TimingFunction"]=""):(j[this._transitionPrefix+ +"Duration"]=g+"ms",j[this._transitionPrefix+"TimingFunction"]=d.coalesce(i,"ease-out"),d.Events.add(a,this._transitionEndLabel,this._getTransitionEndHandler()));j[this._transformLabel]=d.Browser.is3dSupported?"translate3d("+b+"px, "+c+"px, 0px)":"translate("+b+"px, "+c+"px)";if(!d.isNothing(f))a.cclallcallback=f;d.DOM.setStyle(a,j);g===0&&e.setTimeout(function(){this._leaveTransforms(a)}.bind(this),this._applyTransitionDelay)},resetTranslate:function(a){var b={};b[this._transformLabel]=b[this._transformLabel]= +d.Browser.is3dSupported?"translate3d(0px, 0px, 0px)":"translate(0px, 0px)";d.DOM.setStyle(a,b)},_applyTransition:function(a,b,c,g,f,i){var j={},i=d.coalesce(i,"ease-in");j[this._transitionPrefix+"Property"]=b;j[this._transitionPrefix+"Duration"]=g+"ms";j[this._transitionPrefix+"TimingFunction"]=i;j[this._transitionPrefix+"Delay"]="0";d.Events.add(a,this._transitionEndLabel,this._getTransitionEndHandler());d.DOM.setStyle(a,j);d.isNothing(f)||(a["ccl"+b+"callback"]=f);e.setTimeout(function(){d.DOM.setStyle(a, +b,c)},this._applyTransitionDelay)},_onTransitionEnd:function(a){d.Events.remove(a.currentTarget,this._transitionEndLabel,this._getTransitionEndHandler());this._leaveTransforms(a.currentTarget)},_leaveTransforms:function(a){var b=a.style[this._transitionPrefix+"Property"],c=b!==""?"ccl"+b+"callback":"cclallcallback",g,b=d.coalesce(a.style.webkitTransform,a.style.MozTransform,a.style.transform),f,i=e.parseInt(d.DOM.getStyle(a,"left"),0),j=e.parseInt(d.DOM.getStyle(a,"top"),0),h,l,k={};b!==""&&(b=d.Browser.is3dSupported? +b.match(/translate3d\((.*?)\)/):b.match(/translate\((.*?)\)/),d.isNothing(b)||(f=b[1].split(", "),h=e.parseInt(f[0],0),l=e.parseInt(f[1],0)));k[this._transitionPrefix+"Property"]="";k[this._transitionPrefix+"Duration"]="";k[this._transitionPrefix+"TimingFunction"]="";k[this._transitionPrefix+"Delay"]="";d.DOM.setStyle(a,k);e.setTimeout(function(){if(!d.isNothing(f))k={},k[this._transformLabel]="",k.left=i+h+"px",k.top=j+l+"px",d.DOM.setStyle(a,k);d.isNothing(a[c])||(g=a[c],delete a[c],g(a))}.bind(this), +this._applyTransitionDelay)}}})})(window,window.Code.Util); +(function(e,d,a){a.registerNamespace("Code.Util.TouchElement");a.TouchElement.EventTypes={onTouch:"CodeUtilTouchElementOnTouch"};a.TouchElement.ActionTypes={touchStart:"touchStart",touchMove:"touchMove",touchEnd:"touchEnd",touchMoveEnd:"touchMoveEnd",tap:"tap",doubleTap:"doubleTap",swipeLeft:"swipeLeft",swipeRight:"swipeRight",swipeUp:"swipeUp",swipeDown:"swipeDown",gestureStart:"gestureStart",gestureChange:"gestureChange",gestureEnd:"gestureEnd"}})(window,window.klass,window.Code.Util); +(function(e,d,a){a.registerNamespace("Code.Util.TouchElement");a.TouchElement.TouchElementClass=d({el:null,captureSettings:null,touchStartPoint:null,touchEndPoint:null,touchStartTime:null,doubleTapTimeout:null,touchStartHandler:null,touchMoveHandler:null,touchEndHandler:null,mouseDownHandler:null,mouseMoveHandler:null,mouseUpHandler:null,mouseOutHandler:null,gestureStartHandler:null,gestureChangeHandler:null,gestureEndHandler:null,swipeThreshold:null,swipeTimeThreshold:null,doubleTapSpeed:null,dispose:function(){var b; +this.removeEventHandlers();for(b in this)a.objectHasProperty(this,b)&&(this[b]=null)},initialize:function(b,c){this.el=b;this.captureSettings={swipe:!1,move:!1,gesture:!1,doubleTap:!1,preventDefaultTouchEvents:!0};a.extend(this.captureSettings,c);this.swipeThreshold=50;this.doubleTapSpeed=this.swipeTimeThreshold=250;this.touchStartPoint={x:0,y:0};this.touchEndPoint={x:0,y:0}},addEventHandlers:function(){if(a.isNothing(this.touchStartHandler))this.touchStartHandler=this.onTouchStart.bind(this),this.touchMoveHandler= +this.onTouchMove.bind(this),this.touchEndHandler=this.onTouchEnd.bind(this),this.mouseDownHandler=this.onMouseDown.bind(this),this.mouseMoveHandler=this.onMouseMove.bind(this),this.mouseUpHandler=this.onMouseUp.bind(this),this.mouseOutHandler=this.onMouseOut.bind(this),this.gestureStartHandler=this.onGestureStart.bind(this),this.gestureChangeHandler=this.onGestureChange.bind(this),this.gestureEndHandler=this.onGestureEnd.bind(this);a.Events.add(this.el,"touchstart",this.touchStartHandler);this.captureSettings.move&& +a.Events.add(this.el,"touchmove",this.touchMoveHandler);a.Events.add(this.el,"touchend",this.touchEndHandler);a.Events.add(this.el,"mousedown",this.mouseDownHandler);a.Browser.isGestureSupported&&this.captureSettings.gesture&&(a.Events.add(this.el,"gesturestart",this.gestureStartHandler),a.Events.add(this.el,"gesturechange",this.gestureChangeHandler),a.Events.add(this.el,"gestureend",this.gestureEndHandler))},removeEventHandlers:function(){a.Events.remove(this.el,"touchstart",this.touchStartHandler); +this.captureSettings.move&&a.Events.remove(this.el,"touchmove",this.touchMoveHandler);a.Events.remove(this.el,"touchend",this.touchEndHandler);a.Events.remove(this.el,"mousedown",this.mouseDownHandler);a.Browser.isGestureSupported&&this.captureSettings.gesture&&(a.Events.remove(this.el,"gesturestart",this.gestureStartHandler),a.Events.remove(this.el,"gesturechange",this.gestureChangeHandler),a.Events.remove(this.el,"gestureend",this.gestureEndHandler))},getTouchPoint:function(a){return{x:a[0].pageX, +y:a[0].pageY}},fireTouchEvent:function(b){var c=0,g=0,f=0,d,c=this.touchEndPoint.x-this.touchStartPoint.x,g=this.touchEndPoint.y-this.touchStartPoint.y,f=Math.sqrt(c*c+g*g);if(this.captureSettings.swipe&&(d=new Date,d-=this.touchStartTime,d<=this.swipeTimeThreshold)){if(e.Math.abs(c)>=this.swipeThreshold){a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint,action:c<0?a.TouchElement.ActionTypes.swipeLeft:a.TouchElement.ActionTypes.swipeRight,targetEl:b.target, +currentTargetEl:b.currentTarget});return}if(e.Math.abs(g)>=this.swipeThreshold){a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint,action:g<0?a.TouchElement.ActionTypes.swipeUp:a.TouchElement.ActionTypes.swipeDown,targetEl:b.target,currentTargetEl:b.currentTarget});return}}f>1?a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchMoveEnd,point:this.touchEndPoint,targetEl:b.target,currentTargetEl:b.currentTarget}): +this.captureSettings.doubleTap?a.isNothing(this.doubleTapTimeout)?this.doubleTapTimeout=e.setTimeout(function(){this.doubleTapTimeout=null;a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint,action:a.TouchElement.ActionTypes.tap,targetEl:b.target,currentTargetEl:b.currentTarget})}.bind(this),this.doubleTapSpeed):(e.clearTimeout(this.doubleTapTimeout),this.doubleTapTimeout=null,a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint, +action:a.TouchElement.ActionTypes.doubleTap,targetEl:b.target,currentTargetEl:b.currentTarget})):a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,point:this.touchEndPoint,action:a.TouchElement.ActionTypes.tap,targetEl:b.target,currentTargetEl:b.currentTarget})},onTouchStart:function(b){this.captureSettings.preventDefaultTouchEvents&&b.preventDefault();a.Events.remove(this.el,"mousedown",this.mouseDownHandler);var c=a.Events.getTouchEvent(b).touches;c.length>1&&this.captureSettings.gesture? +this.isGesture=!0:(this.touchStartTime=new Date,this.isGesture=!1,this.touchStartPoint=this.getTouchPoint(c),a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchStart,point:this.touchStartPoint,targetEl:b.target,currentTargetEl:b.currentTarget}))},onTouchMove:function(b){this.captureSettings.preventDefaultTouchEvents&&b.preventDefault();if(!this.isGesture||!this.captureSettings.gesture){var c=a.Events.getTouchEvent(b).touches;a.Events.fire(this, +{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchMove,point:this.getTouchPoint(c),targetEl:b.target,currentTargetEl:b.currentTarget})}},onTouchEnd:function(b){if(!this.isGesture||!this.captureSettings.gesture){this.captureSettings.preventDefaultTouchEvents&&b.preventDefault();var c=a.Events.getTouchEvent(b);this.touchEndPoint=this.getTouchPoint(!a.isNothing(c.changedTouches)?c.changedTouches:c.touches);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch, +target:this,action:a.TouchElement.ActionTypes.touchEnd,point:this.touchEndPoint,targetEl:b.target,currentTargetEl:b.currentTarget});this.fireTouchEvent(b)}},onMouseDown:function(b){b.preventDefault();a.Events.remove(this.el,"touchstart",this.mouseDownHandler);a.Events.remove(this.el,"touchmove",this.touchMoveHandler);a.Events.remove(this.el,"touchend",this.touchEndHandler);this.captureSettings.move&&a.Events.add(this.el,"mousemove",this.mouseMoveHandler);a.Events.add(this.el,"mouseup",this.mouseUpHandler); +a.Events.add(this.el,"mouseout",this.mouseOutHandler);this.touchStartTime=new Date;this.isGesture=!1;this.touchStartPoint=a.Events.getMousePosition(b);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchStart,point:this.touchStartPoint,targetEl:b.target,currentTargetEl:b.currentTarget})},onMouseMove:function(b){b.preventDefault();a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchMove, +point:a.Events.getMousePosition(b),targetEl:b.target,currentTargetEl:b.currentTarget})},onMouseUp:function(b){b.preventDefault();this.captureSettings.move&&a.Events.remove(this.el,"mousemove",this.mouseMoveHandler);a.Events.remove(this.el,"mouseup",this.mouseUpHandler);a.Events.remove(this.el,"mouseout",this.mouseOutHandler);this.touchEndPoint=a.Events.getMousePosition(b);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.touchEnd,point:this.touchEndPoint, +targetEl:b.target,currentTargetEl:b.currentTarget});this.fireTouchEvent(b)},onMouseOut:function(b){var c=b.relatedTarget;if(!(this.el===c||a.DOM.isChildOf(c,this.el)))b.preventDefault(),this.captureSettings.move&&a.Events.remove(this.el,"mousemove",this.mouseMoveHandler),a.Events.remove(this.el,"mouseup",this.mouseUpHandler),a.Events.remove(this.el,"mouseout",this.mouseOutHandler),this.touchEndPoint=a.Events.getMousePosition(b),a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this, +action:a.TouchElement.ActionTypes.touchEnd,point:this.touchEndPoint,targetEl:b.target,currentTargetEl:b.currentTarget}),this.fireTouchEvent(b)},onGestureStart:function(b){b.preventDefault();var c=a.Events.getTouchEvent(b);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.gestureStart,scale:c.scale,rotation:c.rotation,targetEl:b.target,currentTargetEl:b.currentTarget})},onGestureChange:function(b){b.preventDefault();var c=a.Events.getTouchEvent(b); +a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.gestureChange,scale:c.scale,rotation:c.rotation,targetEl:b.target,currentTargetEl:b.currentTarget})},onGestureEnd:function(b){b.preventDefault();var c=a.Events.getTouchEvent(b);a.Events.fire(this,{type:a.TouchElement.EventTypes.onTouch,target:this,action:a.TouchElement.ActionTypes.gestureEnd,scale:c.scale,rotation:c.rotation,targetEl:b.target,currentTargetEl:b.currentTarget})}})})(window,window.klass, +window.Code.Util);(function(e,d,a){a.registerNamespace("Code.PhotoSwipe.Image");e.Code.PhotoSwipe.Image.EventTypes={onLoad:"onLoad",onError:"onError"}})(window,window.klass,window.Code.Util); +(function(e,d,a){a.registerNamespace("Code.PhotoSwipe.Image");var b=e.Code.PhotoSwipe;b.Image.ImageClass=d({refObj:null,imageEl:null,src:null,caption:null,metaData:null,imageLoadHandler:null,imageErrorHandler:null,dispose:function(){var c;this.shrinkImage();for(c in this)a.objectHasProperty(this,c)&&(this[c]=null)},initialize:function(a,b,f,d){this.refObj=a;this.src=this.originalSrc=b;this.caption=f;this.metaData=d;this.imageEl=new e.Image;this.imageLoadHandler=this.onImageLoad.bind(this);this.imageErrorHandler= +this.onImageError.bind(this)},load:function(){this.imageEl.originalSrc=a.coalesce(this.imageEl.originalSrc,"");this.imageEl.originalSrc===this.src?this.imageEl.isError?a.Events.fire(this,{type:b.Image.EventTypes.onError,target:this}):a.Events.fire(this,{type:b.Image.EventTypes.onLoad,target:this}):(this.imageEl.isError=!1,this.imageEl.isLoading=!0,this.imageEl.naturalWidth=null,this.imageEl.naturalHeight=null,this.imageEl.isLandscape=!1,this.imageEl.onload=this.imageLoadHandler,this.imageEl.onerror= +this.imageErrorHandler,this.imageEl.onabort=this.imageErrorHandler,this.imageEl.originalSrc=this.src,this.imageEl.src=this.src)},shrinkImage:function(){if(!a.isNothing(this.imageEl)&&this.imageEl.src.indexOf(this.src)>-1)this.imageEl.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",a.isNothing(this.imageEl.parentNode)||a.DOM.removeChild(this.imageEl,this.imageEl.parentNode)},onImageLoad:function(){this.imageEl.onload=null;this.imageEl.naturalWidth=a.coalesce(this.imageEl.naturalWidth, +this.imageEl.width);this.imageEl.naturalHeight=a.coalesce(this.imageEl.naturalHeight,this.imageEl.height);this.imageEl.isLandscape=this.imageEl.naturalWidth>this.imageEl.naturalHeight;this.imageEl.isLoading=!1;a.Events.fire(this,{type:b.Image.EventTypes.onLoad,target:this})},onImageError:function(){this.imageEl.onload=null;this.imageEl.onerror=null;this.imageEl.onabort=null;this.imageEl.isLoading=!1;this.imageEl.isError=!0;a.Events.fire(this,{type:b.Image.EventTypes.onError,target:this})}})})(window, +window.klass,window.Code.Util); +(function(e,d,a){a.registerNamespace("Code.PhotoSwipe.Cache");e=e.Code.PhotoSwipe;e.Cache.Mode={normal:"normal",aggressive:"aggressive"};e.Cache.Functions={getImageSource:function(a){return a.href},getImageCaption:function(b){if(b.nodeName==="IMG")return a.DOM.getAttribute(b,"alt");var c,g,f;c=0;for(g=b.childNodes.length;cb&& +(b=a.DOM.windowHeight())}else c=a.DOM.width(this.settings.target),b=a.DOM.height(this.settings.target),f="0px";a.DOM.setStyle(this.el,{width:c,height:b,top:f})},fadeIn:function(c,b){this.resetPosition();a.DOM.setStyle(this.el,"opacity",0);a.DOM.show(this.el);a.Animation.fadeIn(this.el,c,b)}})})(window,window.klass,window.Code.Util); +(function(e,d,a){a.registerNamespace("Code.PhotoSwipe.Carousel");e=e.Code.PhotoSwipe;e.Carousel.EventTypes={onSlideByEnd:"PhotoSwipeCarouselOnSlideByEnd",onSlideshowStart:"PhotoSwipeCarouselOnSlideshowStart",onSlideshowStop:"PhotoSwipeCarouselOnSlideshowStop"};e.Carousel.CssClasses={carousel:"ps-carousel",content:"ps-carousel-content",item:"ps-carousel-item",itemLoading:"ps-carousel-item-loading",itemError:"ps-carousel-item-error"};e.Carousel.SlideByAction={previous:"previous",current:"current",next:"next"}})(window, +window.klass,window.Code.Util); +(function(e,d,a){a.registerNamespace("Code.PhotoSwipe.Carousel");var b=e.Code.PhotoSwipe;b.Carousel.CarouselClass=d({el:null,contentEl:null,settings:null,cache:null,slideByEndHandler:null,currentCacheIndex:null,isSliding:null,isSlideshowActive:null,lastSlideByAction:null,touchStartPoint:null,touchStartPosition:null,imageLoadHandler:null,imageErrorHandler:null,slideshowTimeout:null,dispose:function(){var c,g,f;g=0;for(f=this.cache.images.length;g0&&a.DOM.setStyle(j,{marginRight:this.settings.margin+"px"}),a.DOM.appendChild(j,this.contentEl);this.settings.target===e?a.DOM.appendToBody(this.el):a.DOM.appendChild(this.el,this.settings.target)}, +resetPosition:function(){var c,g,f,d,j,h;this.settings.target===e?(c=a.DOM.windowWidth(),g=a.DOM.windowHeight(),f=a.DOM.windowScrollTop()+"px"):(c=a.DOM.width(this.settings.target),g=a.DOM.height(this.settings.target),f="0px");d=this.settings.margin>0?c+this.settings.margin:c;j=a.DOM.find("."+b.Carousel.CssClasses.item,this.contentEl);d*=j.length;a.DOM.setStyle(this.el,{top:f,width:c,height:g});a.DOM.setStyle(this.contentEl,{width:d,height:g});f=0;for(d=j.length;fe&&(b=e/f,f=Math.round(f*b),d=Math.round(d*b)),d>h&&(b=h/d,d=Math.round(d*b),f=Math.round(f*b))):(b=c.isLandscape?e/c.naturalWidth:h/c.naturalHeight,f=Math.round(c.naturalWidth* +b),d=Math.round(c.naturalHeight*b),this.settings.imageScaleMethod==="zoom"?(b=1,de?b=e/f:d>h&&(b=h/d),b!==1&&(f=Math.round(f*b),d=Math.round(d*b))));a.DOM.setStyle(c,{position:"absolute",width:f,height:d,top:Math.round((h-d)/2)+"px",left:Math.round((e-f)/2)+"px",display:"block"})}},setContentLeftPosition:function(){var c,b,d;c=this.settings.target===e?a.DOM.windowWidth():a.DOM.width(this.settings.target); +b=this.getItemEls();d=0;this.settings.loop?d=(c+this.settings.margin)*-1:this.currentCacheIndex===this.cache.images.length-1?d=(b.length-1)*(c+this.settings.margin)*-1:this.currentCacheIndex>0&&(d=(c+this.settings.margin)*-1);a.DOM.setStyle(this.contentEl,{left:d+"px"})},show:function(c){this.currentCacheIndex=c;this.resetPosition();this.setImages(!1);a.DOM.show(this.el);a.Animation.resetTranslate(this.contentEl);var c=this.getItemEls(),d,f;d=0;for(f=c.length;dthis.cache.images.length-1&&(b=0),e<0&&(e=this.cache.images.length-1),b=this.cache.getImages([e,this.currentCacheIndex,b]),a||this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[2],d[2]),this.addCacheImageToItemEl(b[0], +d[0])):d.length===1?a||(b=this.cache.getImages([this.currentCacheIndex]),this.addCacheImageToItemEl(b[0],d[0])):d.length===2?this.currentCacheIndex===0?(b=this.cache.getImages([this.currentCacheIndex,this.currentCacheIndex+1]),a||this.addCacheImageToItemEl(b[0],d[0]),this.addCacheImageToItemEl(b[1],d[1])):(b=this.cache.getImages([this.currentCacheIndex-1,this.currentCacheIndex]),a||this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[0],d[0])):this.currentCacheIndex===0?(b=this.cache.getImages([this.currentCacheIndex, +this.currentCacheIndex+1,this.currentCacheIndex+2]),a||this.addCacheImageToItemEl(b[0],d[0]),this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[2],d[2])):(this.currentCacheIndex===this.cache.images.length-1?(b=this.cache.getImages([this.currentCacheIndex-2,this.currentCacheIndex-1,this.currentCacheIndex]),a||this.addCacheImageToItemEl(b[2],d[2]),this.addCacheImageToItemEl(b[1],d[1])):(b=this.cache.getImages([this.currentCacheIndex-1,this.currentCacheIndex,this.currentCacheIndex+1]), +a||this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[2],d[2])),this.addCacheImageToItemEl(b[0],d[0]))},addCacheImageToItemEl:function(c,d){a.DOM.removeClass(d,b.Carousel.CssClasses.itemError);a.DOM.addClass(d,b.Carousel.CssClasses.itemLoading);a.DOM.removeChildren(d);a.DOM.setStyle(c.imageEl,{display:"none"});a.DOM.appendChild(c.imageEl,d);a.Animation.resetTranslate(c.imageEl);a.Events.add(c,b.Image.EventTypes.onLoad,this.imageLoadHandler);a.Events.add(c,b.Image.EventTypes.onError, +this.imageErrorHandler);c.load()},slideCarousel:function(c,d,f){if(!this.isSliding){var i,j;i=this.settings.target===e?a.DOM.windowWidth()+this.settings.margin:a.DOM.width(this.settings.target)+this.settings.margin;f=a.coalesce(f,this.settings.slideSpeed);if(!(e.Math.abs(j)<1)){switch(d){case a.TouchElement.ActionTypes.swipeLeft:c=i*-1;break;case a.TouchElement.ActionTypes.swipeRight:c=i;break;default:j=c.x-this.touchStartPoint.x,c=e.Math.abs(j)>i/2?j>0?i:i*-1:0}this.lastSlideByAction=c<0?b.Carousel.SlideByAction.next: +c>0?b.Carousel.SlideByAction.previous:b.Carousel.SlideByAction.current;if(!this.settings.loop&&(this.lastSlideByAction===b.Carousel.SlideByAction.previous&&this.currentCacheIndex===0||this.lastSlideByAction===b.Carousel.SlideByAction.next&&this.currentCacheIndex===this.cache.images.length-1))c=0,this.lastSlideByAction=b.Carousel.SlideByAction.current;this.isSliding=!0;this.doSlideCarousel(c,f)}}},moveCarousel:function(a){this.isSliding||this.settings.enableDrag&&this.doMoveCarousel(a.x-this.touchStartPoint.x)}, +getItemEls:function(){return a.DOM.find("."+b.Carousel.CssClasses.item,this.contentEl)},previous:function(){this.stopSlideshow();this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeRight,this.settings.nextPreviousSlideSpeed)},next:function(){this.stopSlideshow();this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeLeft,this.settings.nextPreviousSlideSpeed)},slideshowNext:function(){this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeLeft)},startSlideshow:function(){this.stopSlideshow(); +this.isSlideshowActive=!0;this.slideshowTimeout=e.setTimeout(this.slideshowNext.bind(this),this.settings.slideshowDelay);a.Events.fire(this,{type:b.Carousel.EventTypes.onSlideshowStart,target:this})},stopSlideshow:function(){if(!a.isNothing(this.slideshowTimeout))e.clearTimeout(this.slideshowTimeout),this.slideshowTimeout=null,this.isSlideshowActive=!1,a.Events.fire(this,{type:b.Carousel.EventTypes.onSlideshowStop,target:this})},onSlideByEnd:function(){if(!a.isNothing(this.isSliding)){var c=this.getItemEls(); +this.isSliding=!1;this.lastSlideByAction===b.Carousel.SlideByAction.next?this.currentCacheIndex+=1:this.lastSlideByAction===b.Carousel.SlideByAction.previous&&(this.currentCacheIndex-=1);if(this.settings.loop)if(this.lastSlideByAction===b.Carousel.SlideByAction.next?a.DOM.appendChild(c[0],this.contentEl):this.lastSlideByAction===b.Carousel.SlideByAction.previous&&a.DOM.insertBefore(c[c.length-1],c[0],this.contentEl),this.currentCacheIndex<0)this.currentCacheIndex=this.cache.images.length-1;else{if(this.currentCacheIndex=== +this.cache.images.length)this.currentCacheIndex=0}else this.cache.images.length>3&&(this.currentCacheIndex>1&&this.currentCacheIndex
'}})(window,window.klass,window.Code.Util); +(function(e,d,a){a.registerNamespace("Code.PhotoSwipe.Toolbar");var b=e.Code.PhotoSwipe;b.Toolbar.ToolbarClass=d({toolbarEl:null,closeEl:null,playEl:null,previousEl:null,nextEl:null,captionEl:null,captionContentEl:null,currentCaption:null,settings:null,cache:null,timeout:null,isVisible:null,fadeOutHandler:null,touchStartHandler:null,touchMoveHandler:null,clickHandler:null,dispose:function(){var b;this.clearTimeout();this.removeEventHandlers();a.Animation.stop(this.toolbarEl);a.Animation.stop(this.captionEl); +a.DOM.removeChild(this.toolbarEl,this.toolbarEl.parentNode);a.DOM.removeChild(this.captionEl,this.captionEl.parentNode);for(b in this)a.objectHasProperty(this,b)&&(this[b]=null)},initialize:function(c,d){var f;this.settings=d;this.cache=c;this.isVisible=!1;this.fadeOutHandler=this.onFadeOut.bind(this);this.touchStartHandler=this.onTouchStart.bind(this);this.touchMoveHandler=this.onTouchMove.bind(this);this.clickHandler=this.onClick.bind(this);f=b.Toolbar.CssClasses.toolbar;this.settings.captionAndToolbarFlipPosition&& +(f=f+" "+b.Toolbar.CssClasses.toolbarTop);this.toolbarEl=a.DOM.createElement("div",{"class":f},this.settings.getToolbar());a.DOM.setStyle(this.toolbarEl,{left:0,position:"absolute",overflow:"hidden",zIndex:this.settings.zIndex});this.settings.target===e?a.DOM.appendToBody(this.toolbarEl):a.DOM.appendChild(this.toolbarEl,this.settings.target);a.DOM.hide(this.toolbarEl);this.closeEl=a.DOM.find("."+b.Toolbar.CssClasses.close,this.toolbarEl)[0];this.settings.preventHide&&!a.isNothing(this.closeEl)&&a.DOM.hide(this.closeEl); +this.playEl=a.DOM.find("."+b.Toolbar.CssClasses.play,this.toolbarEl)[0];this.settings.preventSlideshow&&!a.isNothing(this.playEl)&&a.DOM.hide(this.playEl);this.nextEl=a.DOM.find("."+b.Toolbar.CssClasses.next,this.toolbarEl)[0];this.previousEl=a.DOM.find("."+b.Toolbar.CssClasses.previous,this.toolbarEl)[0];f=b.Toolbar.CssClasses.caption;this.settings.captionAndToolbarFlipPosition&&(f=f+" "+b.Toolbar.CssClasses.captionBottom);this.captionEl=a.DOM.createElement("div",{"class":f},"");a.DOM.setStyle(this.captionEl, +{left:0,position:"absolute",overflow:"hidden",zIndex:this.settings.zIndex});this.settings.target===e?a.DOM.appendToBody(this.captionEl):a.DOM.appendChild(this.captionEl,this.settings.target);a.DOM.hide(this.captionEl);this.captionContentEl=a.DOM.createElement("div",{"class":b.Toolbar.CssClasses.captionContent},"");a.DOM.appendChild(this.captionContentEl,this.captionEl);this.addEventHandlers()},resetPosition:function(){var b,d,f;this.settings.target===e?(this.settings.captionAndToolbarFlipPosition? +(d=a.DOM.windowScrollTop(),f=a.DOM.windowScrollTop()+a.DOM.windowHeight()-a.DOM.height(this.captionEl)):(d=a.DOM.windowScrollTop()+a.DOM.windowHeight()-a.DOM.height(this.toolbarEl),f=a.DOM.windowScrollTop()),b=a.DOM.windowWidth()):(this.settings.captionAndToolbarFlipPosition?(d="0",f=a.DOM.height(this.settings.target)-a.DOM.height(this.captionEl)):(d=a.DOM.height(this.settings.target)-a.DOM.height(this.toolbarEl),f=0),b=a.DOM.width(this.settings.target));a.DOM.setStyle(this.toolbarEl,{top:d+"px", +width:b});a.DOM.setStyle(this.captionEl,{top:f+"px",width:b})},toggleVisibility:function(a){this.isVisible?this.fadeOut():this.show(a)},show:function(c){a.Animation.stop(this.toolbarEl);a.Animation.stop(this.captionEl);this.resetPosition();this.setToolbarStatus(c);a.Events.fire(this,{type:b.Toolbar.EventTypes.onBeforeShow,target:this});this.showToolbar();this.setCaption(c);this.showCaption();this.isVisible=!0;this.setTimeout();a.Events.fire(this,{type:b.Toolbar.EventTypes.onShow,target:this})},setTimeout:function(){if(this.settings.captionAndToolbarAutoHideDelay> +0)this.clearTimeout(),this.timeout=e.setTimeout(this.fadeOut.bind(this),this.settings.captionAndToolbarAutoHideDelay)},clearTimeout:function(){if(!a.isNothing(this.timeout))e.clearTimeout(this.timeout),this.timeout=null},fadeOut:function(){this.clearTimeout();a.Events.fire(this,{type:b.Toolbar.EventTypes.onBeforeHide,target:this});a.Animation.fadeOut(this.toolbarEl,this.settings.fadeOutSpeed);a.Animation.fadeOut(this.captionEl,this.settings.fadeOutSpeed,this.fadeOutHandler);this.isVisible=!1},addEventHandlers:function(){a.Browser.isTouchSupported&& +(a.Browser.blackberry||a.Events.add(this.toolbarEl,"touchstart",this.touchStartHandler),a.Events.add(this.toolbarEl,"touchmove",this.touchMoveHandler),a.Events.add(this.captionEl,"touchmove",this.touchMoveHandler));a.Events.add(this.toolbarEl,"click",this.clickHandler)},removeEventHandlers:function(){a.Browser.isTouchSupported&&(a.Browser.blackberry||a.Events.remove(this.toolbarEl,"touchstart",this.touchStartHandler),a.Events.remove(this.toolbarEl,"touchmove",this.touchMoveHandler),a.Events.remove(this.captionEl, +"touchmove",this.touchMoveHandler));a.Events.remove(this.toolbarEl,"click",this.clickHandler)},handleTap:function(c){this.clearTimeout();var d;if(c.target===this.nextEl||a.DOM.isChildOf(c.target,this.nextEl))d=b.Toolbar.ToolbarAction.next;else if(c.target===this.previousEl||a.DOM.isChildOf(c.target,this.previousEl))d=b.Toolbar.ToolbarAction.previous;else if(c.target===this.closeEl||a.DOM.isChildOf(c.target,this.closeEl))d=b.Toolbar.ToolbarAction.close;else if(c.target===this.playEl||a.DOM.isChildOf(c.target, +this.playEl))d=b.Toolbar.ToolbarAction.play;this.setTimeout();if(a.isNothing(d))d=b.Toolbar.ToolbarAction.none;a.Events.fire(this,{type:b.Toolbar.EventTypes.onTap,target:this,action:d,tapTarget:c.target})},setCaption:function(b){a.DOM.removeChildren(this.captionContentEl);this.currentCaption=a.coalesce(this.cache.images[b].caption,"\u00a0");if(a.isObject(this.currentCaption))a.DOM.appendChild(this.currentCaption,this.captionContentEl);else{if(this.currentCaption==="")this.currentCaption="\u00a0"; +a.DOM.appendText(this.currentCaption,this.captionContentEl)}this.currentCaption=this.currentCaption==="\u00a0"?"":this.currentCaption;this.resetPosition()},showToolbar:function(){a.DOM.setStyle(this.toolbarEl,{opacity:this.settings.captionAndToolbarOpacity});a.DOM.show(this.toolbarEl)},showCaption:function(){(this.currentCaption===""||this.captionContentEl.childNodes.length<1)&&!this.settings.captionAndToolbarShowEmptyCaptions?a.DOM.hide(this.captionEl):(a.DOM.setStyle(this.captionEl,{opacity:this.settings.captionAndToolbarOpacity}), +a.DOM.show(this.captionEl))},setToolbarStatus:function(c){this.settings.loop||(a.DOM.removeClass(this.previousEl,b.Toolbar.CssClasses.previousDisabled),a.DOM.removeClass(this.nextEl,b.Toolbar.CssClasses.nextDisabled),c>0&&cthis.settings.maxUserZoom)a=this.settings.maxUserZoom;return a},setStartingScaleAndRotation:function(a,b){this.transformSettings.startingScale=this.getScale(a);this.transformSettings.startingRotation=(this.transformSettings.startingRotation+b)%360},zoomRotate:function(a,b){this.transformSettings.scale=this.getScale(a);this.transformSettings.rotation=this.transformSettings.startingRotation+b;this.applyTransform()},panStart:function(a){this.setStartingTranslateFromCurrentTransform();this.panStartingPoint= +{x:a.x,y:a.y}},pan:function(a){var b=(a.y-this.panStartingPoint.y)/this.transformSettings.scale;this.transformSettings.translateX=this.transformSettings.startingTranslateX+(a.x-this.panStartingPoint.x)/this.transformSettings.scale;this.transformSettings.translateY=this.transformSettings.startingTranslateY+b;this.applyTransform()},zoomAndPanToPoint:function(b,d){if(this.settings.target===e){this.panStart({x:a.DOM.windowWidth()/2,y:a.DOM.windowHeight()/2});var f=(d.y-this.panStartingPoint.y)/this.transformSettings.scale; +this.transformSettings.translateX=(this.transformSettings.startingTranslateX+(d.x-this.panStartingPoint.x)/this.transformSettings.scale)*-1;this.transformSettings.translateY=(this.transformSettings.startingTranslateY+f)*-1}this.setStartingScaleAndRotation(b,0);this.transformSettings.scale=this.transformSettings.startingScale;this.transformSettings.rotation=0;this.applyTransform()},applyTransform:function(){var c=this.transformSettings.rotation%360,d=e.parseInt(this.transformSettings.translateX,10), +f=e.parseInt(this.transformSettings.translateY,10),i="scale("+this.transformSettings.scale+") rotate("+c+"deg) translate("+d+"px, "+f+"px)";a.DOM.setStyle(this.transformEl,{webkitTransform:i,MozTransform:i,msTransform:i,transform:i});a.Events.fire(this,{target:this,type:b.ZoomPanRotate.EventTypes.onTransform,scale:this.transformSettings.scale,rotation:this.transformSettings.rotation,rotationDegs:c,translateX:d,translateY:f})}})})(window,window.klass,window.Code.Util); +(function(e,d){d.registerNamespace("Code.PhotoSwipe");var a=e.Code.PhotoSwipe;a.CssClasses={buildingBody:"ps-building",activeBody:"ps-active"};a.EventTypes={onBeforeShow:"PhotoSwipeOnBeforeShow",onShow:"PhotoSwipeOnShow",onBeforeHide:"PhotoSwipeOnBeforeHide",onHide:"PhotoSwipeOnHide",onDisplayImage:"PhotoSwipeOnDisplayImage",onResetPosition:"PhotoSwipeOnResetPosition",onSlideshowStart:"PhotoSwipeOnSlideshowStart",onSlideshowStop:"PhotoSwipeOnSlideshowStop",onTouch:"PhotoSwipeOnTouch",onBeforeCaptionAndToolbarShow:"PhotoSwipeOnBeforeCaptionAndToolbarShow", +onCaptionAndToolbarShow:"PhotoSwipeOnCaptionAndToolbarShow",onBeforeCaptionAndToolbarHide:"PhotoSwipeOnBeforeCaptionAndToolbarHide",onCaptionAndToolbarHide:"PhotoSwipeOnCaptionAndToolbarHide",onToolbarTap:"PhotoSwipeOnToolbarTap",onBeforeZoomPanRotateShow:"PhotoSwipeOnBeforeZoomPanRotateShow",onZoomPanRotateShow:"PhotoSwipeOnZoomPanRotateShow",onBeforeZoomPanRotateHide:"PhotoSwipeOnBeforeZoomPanRotateHide",onZoomPanRotateHide:"PhotoSwipeOnZoomPanRotateHide",onZoomPanRotateTransform:"PhotoSwipeOnZoomPanRotateTransform"}; +a.instances=[];a.activeInstances=[];a.setActivateInstance=function(b){if(d.arrayIndexOf(b.settings.target,a.activeInstances,"target")>-1)throw"Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target";a.activeInstances.push({target:b.settings.target,instance:b})};a.unsetActivateInstance=function(b){b=d.arrayIndexOf(b,a.activeInstances,"instance");a.activeInstances.splice(b,1)};a.attach=function(b,c,e){var f,i;f=a.createInstance(b,c,e);c=0;for(e= +b.length;c=2.1)this.isBackEventSupported=!0;if(!this.isBackEventSupported)this.isBackEventSupported=a.objectHasProperty(e,"onhashchange");this.settings={fadeInSpeed:250,fadeOutSpeed:250,preventHide:!1,preventSlideshow:!1,zIndex:1E3,backButtonHideEnabled:!0,enableKeyboard:!0,enableMouseWheel:!0, +mouseWheelSpeed:350,autoStartSlideshow:!1,jQueryMobile:!a.isNothing(e.jQuery)&&!a.isNothing(e.jQuery.mobile),jQueryMobileDialogHash:"&ui-state=dialog",enableUIWebViewRepositionTimeout:!1,uiWebViewResetPositionDelay:500,target:e,preventDefaultTouchEvents:!0,loop:!0,slideSpeed:250,nextPreviousSlideSpeed:0,enableDrag:!0,swipeThreshold:50,swipeTimeThreshold:250,slideTimingFunction:"ease-out",slideshowDelay:3E3,doubleTapSpeed:250,margin:20,imageScaleMethod:"fit",captionAndToolbarHide:!1,captionAndToolbarFlipPosition:!1, +captionAndToolbarAutoHideDelay:5E3,captionAndToolbarOpacity:0.8,captionAndToolbarShowEmptyCaptions:!0,getToolbar:h.Toolbar.getToolbar,allowUserZoom:!0,allowRotationOnUserZoom:!1,maxUserZoom:5,minUserZoom:0.5,doubleTapZoomLevel:2.5,getImageSource:h.Cache.Functions.getImageSource,getImageCaption:h.Cache.Functions.getImageCaption,getImageMetaData:h.Cache.Functions.getImageMetaData,cacheMode:h.Cache.Mode.normal};a.extend(this.settings,d);this.settings.target!==e&&(d=a.DOM.getStyle(this.settings.target, +"position"),(d!=="relative"||d!=="absolute")&&a.DOM.setStyle(this.settings.target,"position","relative"));if(this.settings.target!==e)this.isBackEventSupported=!1,this.settings.backButtonHideEnabled=!1;else if(this.settings.preventHide)this.settings.backButtonHideEnabled=!1;this.cache=new b.CacheClass(c,this.settings)},show:function(b){var c,d;this.backButtonClicked=this._isResettingPosition=!1;if(a.isNumber(b))this.currentIndex=b;else{this.currentIndex=-1;c=0;for(d=this.originalImages.length;cthis.originalImages.length-1)throw"Code.PhotoSwipe.PhotoSwipeClass.show: Starting index out of range";this.isAlreadyGettingPage=this.getWindowDimensions();h.setActivateInstance(this);this.windowDimensions=this.getWindowDimensions();this.settings.target===e?a.DOM.addClass(e.document.body,h.CssClasses.buildingBody):a.DOM.addClass(this.settings.target,h.CssClasses.buildingBody);this.createComponents();a.Events.fire(this,{type:h.EventTypes.onBeforeShow, +target:this});this.documentOverlay.fadeIn(this.settings.fadeInSpeed,this.onDocumentOverlayFadeIn.bind(this))},getWindowDimensions:function(){return{width:a.DOM.windowWidth(),height:a.DOM.windowHeight()}},createComponents:function(){this.documentOverlay=new c.DocumentOverlayClass(this.settings);this.carousel=new g.CarouselClass(this.cache,this.settings);this.uiLayer=new i.UILayerClass(this.settings);if(!this.settings.captionAndToolbarHide)this.toolbar=new f.ToolbarClass(this.cache,this.settings)}, +resetPosition:function(){if(!this._isResettingPosition){var b=this.getWindowDimensions();if(a.isNothing(this.windowDimensions)||!(b.width===this.windowDimensions.width&&b.height===this.windowDimensions.height))this._isResettingPosition=!0,this.windowDimensions=b,this.destroyZoomPanRotate(),this.documentOverlay.resetPosition(),this.carousel.resetPosition(),a.isNothing(this.toolbar)||this.toolbar.resetPosition(),this.uiLayer.resetPosition(),this._isResettingPosition=!1,a.Events.fire(this,{type:h.EventTypes.onResetPosition, +target:this})}},addEventHandler:function(b,c){a.Events.add(this,b,c)},addEventHandlers:function(){if(a.isNothing(this.windowOrientationChangeHandler))this.windowOrientationChangeHandler=this.onWindowOrientationChange.bind(this),this.windowScrollHandler=this.onWindowScroll.bind(this),this.keyDownHandler=this.onKeyDown.bind(this),this.windowHashChangeHandler=this.onWindowHashChange.bind(this),this.uiLayerTouchHandler=this.onUILayerTouch.bind(this),this.carouselSlideByEndHandler=this.onCarouselSlideByEnd.bind(this), +this.carouselSlideshowStartHandler=this.onCarouselSlideshowStart.bind(this),this.carouselSlideshowStopHandler=this.onCarouselSlideshowStop.bind(this),this.toolbarTapHandler=this.onToolbarTap.bind(this),this.toolbarBeforeShowHandler=this.onToolbarBeforeShow.bind(this),this.toolbarShowHandler=this.onToolbarShow.bind(this),this.toolbarBeforeHideHandler=this.onToolbarBeforeHide.bind(this),this.toolbarHideHandler=this.onToolbarHide.bind(this),this.mouseWheelHandler=this.onMouseWheel.bind(this),this.zoomPanRotateTransformHandler= +this.onZoomPanRotateTransform.bind(this);a.Browser.android?this.orientationEventName="resize":a.Browser.iOS&&!a.Browser.safari?a.Events.add(e.document.body,"orientationchange",this.windowOrientationChangeHandler):this.orientationEventName=!a.isNothing(e.onorientationchange)?"orientationchange":"resize";a.isNothing(this.orientationEventName)||a.Events.add(e,this.orientationEventName,this.windowOrientationChangeHandler);this.settings.target===e&&a.Events.add(e,"scroll",this.windowScrollHandler);this.settings.enableKeyboard&& +a.Events.add(e.document,"keydown",this.keyDownHandler);if(this.isBackEventSupported&&this.settings.backButtonHideEnabled)this.windowHashChangeHandler=this.onWindowHashChange.bind(this),this.settings.jQueryMobile?e.location.hash=this.settings.jQueryMobileDialogHash:(this.currentHistoryHashValue="PhotoSwipe"+(new Date).getTime().toString(),e.location.hash=this.currentHistoryHashValue),a.Events.add(e,"hashchange",this.windowHashChangeHandler);this.settings.enableMouseWheel&&a.Events.add(e,"mousewheel", +this.mouseWheelHandler);a.Events.add(this.uiLayer,a.TouchElement.EventTypes.onTouch,this.uiLayerTouchHandler);a.Events.add(this.carousel,g.EventTypes.onSlideByEnd,this.carouselSlideByEndHandler);a.Events.add(this.carousel,g.EventTypes.onSlideshowStart,this.carouselSlideshowStartHandler);a.Events.add(this.carousel,g.EventTypes.onSlideshowStop,this.carouselSlideshowStopHandler);a.isNothing(this.toolbar)||(a.Events.add(this.toolbar,f.EventTypes.onTap,this.toolbarTapHandler),a.Events.add(this.toolbar, +f.EventTypes.onBeforeShow,this.toolbarBeforeShowHandler),a.Events.add(this.toolbar,f.EventTypes.onShow,this.toolbarShowHandler),a.Events.add(this.toolbar,f.EventTypes.onBeforeHide,this.toolbarBeforeHideHandler),a.Events.add(this.toolbar,f.EventTypes.onHide,this.toolbarHideHandler))},removeEventHandlers:function(){a.Browser.iOS&&!a.Browser.safari&&a.Events.remove(e.document.body,"orientationchange",this.windowOrientationChangeHandler);a.isNothing(this.orientationEventName)||a.Events.remove(e,this.orientationEventName, +this.windowOrientationChangeHandler);a.Events.remove(e,"scroll",this.windowScrollHandler);this.settings.enableKeyboard&&a.Events.remove(e.document,"keydown",this.keyDownHandler);this.isBackEventSupported&&this.settings.backButtonHideEnabled&&a.Events.remove(e,"hashchange",this.windowHashChangeHandler);this.settings.enableMouseWheel&&a.Events.remove(e,"mousewheel",this.mouseWheelHandler);a.isNothing(this.uiLayer)||a.Events.remove(this.uiLayer,a.TouchElement.EventTypes.onTouch,this.uiLayerTouchHandler); +a.isNothing(this.toolbar)||(a.Events.remove(this.carousel,g.EventTypes.onSlideByEnd,this.carouselSlideByEndHandler),a.Events.remove(this.carousel,g.EventTypes.onSlideshowStart,this.carouselSlideshowStartHandler),a.Events.remove(this.carousel,g.EventTypes.onSlideshowStop,this.carouselSlideshowStopHandler));a.isNothing(this.toolbar)||(a.Events.remove(this.toolbar,f.EventTypes.onTap,this.toolbarTapHandler),a.Events.remove(this.toolbar,f.EventTypes.onBeforeShow,this.toolbarBeforeShowHandler),a.Events.remove(this.toolbar, +f.EventTypes.onShow,this.toolbarShowHandler),a.Events.remove(this.toolbar,f.EventTypes.onBeforeHide,this.toolbarBeforeHideHandler),a.Events.remove(this.toolbar,f.EventTypes.onHide,this.toolbarHideHandler))},hide:function(){if(!this.settings.preventHide){if(a.isNothing(this.documentOverlay))throw"Code.PhotoSwipe.PhotoSwipeClass.hide: PhotoSwipe instance is already hidden";if(a.isNothing(this.hiding)){this.clearUIWebViewResetPositionTimeout();this.destroyZoomPanRotate();this.removeEventHandlers();a.Events.fire(this, +{type:h.EventTypes.onBeforeHide,target:this});this.uiLayer.dispose();this.uiLayer=null;if(!a.isNothing(this.toolbar))this.toolbar.dispose(),this.toolbar=null;this.carousel.dispose();this.carousel=null;a.DOM.removeClass(e.document.body,h.CssClasses.activeBody);this.documentOverlay.dispose();this.documentOverlay=null;this._isResettingPosition=!1;h.unsetActivateInstance(this);a.Events.fire(this,{type:h.EventTypes.onHide,target:this});this.goBackInHistory()}}},goBackInHistory:function(){this.isBackEventSupported&& +this.settings.backButtonHideEnabled&&(this.backButtonClicked||e.history.back())},play:function(){!this.isZoomActive()&&!this.settings.preventSlideshow&&!a.isNothing(this.carousel)&&(!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.toolbar.fadeOut(),this.carousel.startSlideshow())},stop:function(){this.isZoomActive()||a.isNothing(this.carousel)||this.carousel.stopSlideshow()},previous:function(){this.isZoomActive()||a.isNothing(this.carousel)||this.carousel.previous()},next:function(){this.isZoomActive()|| +a.isNothing(this.carousel)||this.carousel.next()},toggleToolbar:function(){this.isZoomActive()||a.isNothing(this.toolbar)||this.toolbar.toggleVisibility(this.currentIndex)},fadeOutToolbarIfVisible:function(){!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.settings.captionAndToolbarAutoHideDelay>0&&this.toolbar.fadeOut()},createZoomPanRotate:function(){this.stop();if(this.canUserZoom()&&!this.isZoomActive())a.Events.fire(this,h.EventTypes.onBeforeZoomPanRotateShow),this.zoomPanRotate=new j.ZoomPanRotateClass(this.settings, +this.cache.images[this.currentIndex],this.uiLayer),this.uiLayer.captureSettings.preventDefaultTouchEvents=!0,a.Events.add(this.zoomPanRotate,h.ZoomPanRotate.EventTypes.onTransform,this.zoomPanRotateTransformHandler),a.Events.fire(this,h.EventTypes.onZoomPanRotateShow),!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.toolbar.fadeOut()},destroyZoomPanRotate:function(){if(!a.isNothing(this.zoomPanRotate))a.Events.fire(this,h.EventTypes.onBeforeZoomPanRotateHide),a.Events.remove(this.zoomPanRotate, +h.ZoomPanRotate.EventTypes.onTransform,this.zoomPanRotateTransformHandler),this.zoomPanRotate.dispose(),this.zoomPanRotate=null,this.uiLayer.captureSettings.preventDefaultTouchEvents=this.settings.preventDefaultTouchEvents,a.Events.fire(this,h.EventTypes.onZoomPanRotateHide)},canUserZoom:function(){var b;if(a.Browser.msie){if(b=document.createElement("div"),a.isNothing(b.style.msTransform))return!1}else if(!a.Browser.isCSSTransformSupported)return!1;if(!this.settings.allowUserZoom)return!1;if(this.carousel.isSliding)return!1; +b=this.cache.images[this.currentIndex];if(a.isNothing(b))return!1;if(b.isLoading)return!1;return!0},isZoomActive:function(){return!a.isNothing(this.zoomPanRotate)},getCurrentImage:function(){return this.cache.images[this.currentIndex]},onDocumentOverlayFadeIn:function(){e.setTimeout(function(){var b=this.settings.target===e?e.document.body:this.settings.target;a.DOM.removeClass(b,h.CssClasses.buildingBody);a.DOM.addClass(b,h.CssClasses.activeBody);this.addEventHandlers();this.carousel.show(this.currentIndex); +this.uiLayer.show();this.settings.autoStartSlideshow?this.play():a.isNothing(this.toolbar)||this.toolbar.show(this.currentIndex);a.Events.fire(this,{type:h.EventTypes.onShow,target:this});this.setUIWebViewResetPositionTimeout()}.bind(this),250)},setUIWebViewResetPositionTimeout:function(){if(this.settings.enableUIWebViewRepositionTimeout&&a.Browser.iOS&&!a.Browser.safari)a.isNothing(this._uiWebViewResetPositionTimeout)||e.clearTimeout(this._uiWebViewResetPositionTimeout),this._uiWebViewResetPositionTimeout= +e.setTimeout(function(){this.resetPosition();this.setUIWebViewResetPositionTimeout()}.bind(this),this.settings.uiWebViewResetPositionDelay)},clearUIWebViewResetPositionTimeout:function(){a.isNothing(this._uiWebViewResetPositionTimeout)||e.clearTimeout(this._uiWebViewResetPositionTimeout)},onWindowScroll:function(){this.resetPosition()},onWindowOrientationChange:function(){this.resetPosition()},onWindowHashChange:function(){if(e.location.hash!=="#"+(this.settings.jQueryMobile?this.settings.jQueryMobileDialogHash: +this.currentHistoryHashValue))this.backButtonClicked=!0,this.hide()},onKeyDown:function(a){a.keyCode===37?(a.preventDefault(),this.previous()):a.keyCode===39?(a.preventDefault(),this.next()):a.keyCode===38||a.keyCode===40?a.preventDefault():a.keyCode===27?(a.preventDefault(),this.hide()):a.keyCode===32?(this.settings.hideToolbar?this.hide():this.toggleToolbar(),a.preventDefault()):a.keyCode===13&&(a.preventDefault(),this.play())},onUILayerTouch:function(b){if(this.isZoomActive())switch(b.action){case a.TouchElement.ActionTypes.gestureChange:this.zoomPanRotate.zoomRotate(b.scale, +this.settings.allowRotationOnUserZoom?b.rotation:0);break;case a.TouchElement.ActionTypes.gestureEnd:this.zoomPanRotate.setStartingScaleAndRotation(b.scale,this.settings.allowRotationOnUserZoom?b.rotation:0);break;case a.TouchElement.ActionTypes.touchStart:this.zoomPanRotate.panStart(b.point);break;case a.TouchElement.ActionTypes.touchMove:this.zoomPanRotate.pan(b.point);break;case a.TouchElement.ActionTypes.doubleTap:this.destroyZoomPanRotate();this.toggleToolbar();break;case a.TouchElement.ActionTypes.swipeLeft:this.destroyZoomPanRotate(); +this.next();this.toggleToolbar();break;case a.TouchElement.ActionTypes.swipeRight:this.destroyZoomPanRotate(),this.previous(),this.toggleToolbar()}else switch(b.action){case a.TouchElement.ActionTypes.touchMove:case a.TouchElement.ActionTypes.swipeLeft:case a.TouchElement.ActionTypes.swipeRight:this.fadeOutToolbarIfVisible();this.carousel.onTouch(b.action,b.point);break;case a.TouchElement.ActionTypes.touchStart:case a.TouchElement.ActionTypes.touchMoveEnd:this.carousel.onTouch(b.action,b.point); +break;case a.TouchElement.ActionTypes.tap:this.toggleToolbar();break;case a.TouchElement.ActionTypes.doubleTap:this.settings.target===e&&(b.point.x-=a.DOM.windowScrollLeft(),b.point.y-=a.DOM.windowScrollTop());var c=this.cache.images[this.currentIndex].imageEl,d=e.parseInt(a.DOM.getStyle(c,"top"),10),f=e.parseInt(a.DOM.getStyle(c,"left"),10),g=f+a.DOM.width(c),c=d+a.DOM.height(c);if(b.point.xg)b.point.x=g;if(b.point.yc)b.point.y=c; +this.createZoomPanRotate();this.isZoomActive()&&this.zoomPanRotate.zoomAndPanToPoint(this.settings.doubleTapZoomLevel,b.point);break;case a.TouchElement.ActionTypes.gestureStart:this.createZoomPanRotate()}a.Events.fire(this,{type:h.EventTypes.onTouch,target:this,point:b.point,action:b.action})},onCarouselSlideByEnd:function(b){this.currentIndex=b.cacheIndex;a.isNothing(this.toolbar)||(this.toolbar.setCaption(this.currentIndex),this.toolbar.setToolbarStatus(this.currentIndex));a.Events.fire(this,{type:h.EventTypes.onDisplayImage, +target:this,action:b.action,index:b.cacheIndex})},onToolbarTap:function(b){switch(b.action){case f.ToolbarAction.next:this.next();break;case f.ToolbarAction.previous:this.previous();break;case f.ToolbarAction.close:this.hide();break;case f.ToolbarAction.play:this.play()}a.Events.fire(this,{type:h.EventTypes.onToolbarTap,target:this,toolbarAction:b.action,tapTarget:b.tapTarget})},onMouseWheel:function(b){var c=a.Events.getWheelDelta(b);if(!(b.timeStamp-(this.mouseWheelStartTime||0)0&&this.previous()},onCarouselSlideshowStart:function(){a.Events.fire(this,{type:h.EventTypes.onSlideshowStart,target:this})},onCarouselSlideshowStop:function(){a.Events.fire(this,{type:h.EventTypes.onSlideshowStop,target:this})},onToolbarBeforeShow:function(){a.Events.fire(this,{type:h.EventTypes.onBeforeCaptionAndToolbarShow,target:this})},onToolbarShow:function(){a.Events.fire(this,{type:h.EventTypes.onCaptionAndToolbarShow, +target:this})},onToolbarBeforeHide:function(){a.Events.fire(this,{type:h.EventTypes.onBeforeCaptionAndToolbarHide,target:this})},onToolbarHide:function(){a.Events.fire(this,{type:h.EventTypes.onCaptionAndToolbarHide,target:this})},onZoomPanRotateTransform:function(b){a.Events.fire(this,{target:this,type:h.EventTypes.onZoomPanRotateTransform,scale:b.scale,rotation:b.rotation,rotationDegs:b.rotationDegs,translateX:b.translateX,translateY:b.translateY})}})})(window,window.klass,window.Code.Util,window.Code.PhotoSwipe.Cache, +window.Code.PhotoSwipe.DocumentOverlay,window.Code.PhotoSwipe.Carousel,window.Code.PhotoSwipe.Toolbar,window.Code.PhotoSwipe.UILayer,window.Code.PhotoSwipe.ZoomPanRotate); diff --git a/photoswipe/code.photoswipe.jquery-3.0.5_bak.js b/photoswipe/code.photoswipe.jquery-3.0.5_bak.js new file mode 100755 index 0000000..f2380d1 --- /dev/null +++ b/photoswipe/code.photoswipe.jquery-3.0.5_bak.js @@ -0,0 +1,6425 @@ +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function (window) { + + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind + if (!Function.prototype.bind ) { + + Function.prototype.bind = function( obj ) { + var slice = [].slice, + args = slice.call(arguments, 1), + self = this, + nop = function () {}, + bound = function () { + return self.apply( this instanceof nop ? this : ( obj || {} ), + args.concat( slice.call(arguments) ) ); + }; + + nop.prototype = self.prototype; + + bound.prototype = new nop(); + + return bound; + }; + } + + + + if (typeof window.Code === "undefined") { + window.Code = {}; + } + + + + window.Code.Util = { + + + /* + * Function: registerNamespace + */ + registerNamespace: function () { + var + args = arguments, obj = null, i, j, ns, nsParts, root, argsLen, nsPartsLens; + for (i=0, argsLen=args.length; i Util.DOM.windowHeight()); + } + }; + + Util.Browser._detect(); + +} +( + window, + window.Code.Util +)) +; +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function (window, $, Util) { + + Util.extend(Util, { + + Events: { + + + /* + * Function: add + * Add an event handler + */ + add: function(obj, type, handler){ + + $(obj).bind(type, handler); + + }, + + + + /* + * Function: remove + * Removes a handler or all handlers associated with a type + */ + remove: function(obj, type, handler){ + + $(obj).unbind(type, handler); + + }, + + + /* + * Function: fire + * Fire an event + */ + fire: function(obj, type){ + + var + event, + args = Array.prototype.slice.call(arguments).splice(2); + + if (typeof type === "string"){ + event = { type: type }; + } + else{ + event = type; + } + + $(obj).trigger( $.Event(event.type, event), args); + + }, + + + /* + * Function: getMousePosition + */ + getMousePosition: function(event){ + + var retval = { + x: event.pageX, + y: event.pageY + }; + + return retval; + + }, + + + /* + * Function: getTouchEvent + */ + getTouchEvent: function(event){ + + return event.originalEvent; + + }, + + + + /* + * Function: getWheelDelta + */ + getWheelDelta: function(event){ + + var delta = 0; + + if (!Util.isNothing(event.wheelDelta)){ + delta = event.wheelDelta / 120; + } + else if (!Util.isNothing(event.detail)){ + delta = -event.detail / 3; + } + + return delta; + + }, + + + /* + * Function: domReady + */ + domReady: function(handler){ + + $(document).ready(handler); + + } + + + } + + + }); + + +} +( + window, + window.jQuery, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function (window, $, Util) { + + Util.extend(Util, { + + DOM: { + + + + /* + * Function: setData + */ + setData: function(el, key, value){ + + if (Util.isLikeArray(el)){ + var i, len; + for (i=0, len=el.length; i'); + retval.attr(attributes); + retval.append(content); + + return retval[0]; + + }, + + + + /* + * Function: appendChild + */ + appendChild: function(childEl, parentEl){ + + $(parentEl).append(childEl); + + }, + + + + /* + * Function: insertBefore + */ + insertBefore: function(newEl, refEl, parentEl){ + + $(newEl).insertBefore(refEl); + + }, + + + + /* + * Function: appendText + */ + appendText: function(text, parentEl){ + + $(parentEl).text(text); + + }, + + + + /* + * Function: appendToBody + */ + appendToBody: function(childEl){ + + $('body').append(childEl); + + }, + + + + /* + * Function: removeChild + */ + removeChild: function(childEl, parentEl){ + + $(childEl).empty().remove(); + + }, + + + + /* + * Function: removeChildren + */ + removeChildren: function(parentEl){ + + $(parentEl).empty(); + + }, + + + + /* + * Function: hasAttribute + */ + hasAttribute: function(el, attributeName){ + + return !Util.isNothing( $(el).attr(attributeName) ); + + }, + + + + /* + * Function: getAttribute + */ + getAttribute: function(el, attributeName, defaultValue){ + + var retval = $(el).attr(attributeName); + if (Util.isNothing(retval) && !Util.isNothing(defaultValue)){ + retval = defaultValue; + } + return retval; + + }, + + + + /* + * Function: el, attributeName + */ + setAttribute: function(el, attributeName, value){ + + if (Util.isLikeArray(el)){ + var i, len; + for (i=0, len=el.length; i= 1){ + Util.DOM.setStyle(el, 'opacity', 0); + } + + if (Util.Browser.isCSSTransformSupported){ + this._applyTransition(el, 'opacity', opacity, speed, callback, timingFunction); + } + else if (!Util.isNothing(window.jQuery)){ + window.jQuery(el).fadeTo(speed, opacity, callback); + } + + }, + + + + /* + * Function: fadeTo + */ + fadeTo: function(el, opacity, speed, callback, timingFunction){ + this.fadeIn(el, speed, callback, timingFunction, opacity); + }, + + + + /* + * Function: fadeOut + */ + fadeOut: function(el, speed, callback, timingFunction){ + + if (speed <= 0){ + Util.DOM.setStyle(el, 'opacity', 0); + if (!Util.isNothing(callback)){ + callback(el); + return; + } + } + + if (Util.Browser.isCSSTransformSupported){ + + this._applyTransition(el, 'opacity', 0, speed, callback, timingFunction); + + } + else{ + + window.jQuery(el).fadeTo(speed, 0, callback); + + } + + }, + + + + /* + * Function: slideBy + */ + slideBy: function(el, x, y, speed, callback, timingFunction){ + + var style = {}; + + x = Util.coalesce(x, 0); + y = Util.coalesce(y, 0); + timingFunction = Util.coalesce(timingFunction, 'ease-out'); + + style[this._transitionPrefix + 'Property'] = 'all'; + style[this._transitionPrefix + 'Delay'] = '0'; + + if (speed === 0){ + style[this._transitionPrefix + 'Duration'] = ''; + style[this._transitionPrefix + 'TimingFunction'] = ''; + } + else{ + style[this._transitionPrefix + 'Duration'] = speed + 'ms'; + style[this._transitionPrefix + 'TimingFunction'] = Util.coalesce(timingFunction, 'ease-out'); + + Util.Events.add(el, this._transitionEndLabel, this._getTransitionEndHandler()); + + } + + style[this._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(' + x + 'px, ' + y + 'px, 0px)' : 'translate(' + x + 'px, ' + y + 'px)'; + + if (!Util.isNothing(callback)){ + el.cclallcallback = callback; + } + + Util.DOM.setStyle(el, style); + + if (speed === 0){ + window.setTimeout(function(){ + this._leaveTransforms(el); + }.bind(this), this._applyTransitionDelay); + } + + }, + + + + /* + * Function: + */ + resetTranslate: function(el){ + + var style = {}; + style[this._transformLabel] = style[this._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(0px, 0px, 0px)' : 'translate(0px, 0px)'; + Util.DOM.setStyle(el, style); + + }, + + + + /* + * Function: _applyTransition + */ + _applyTransition: function(el, property, val, speed, callback, timingFunction){ + + var style = {}; + + timingFunction = Util.coalesce(timingFunction, 'ease-in'); + + style[this._transitionPrefix + 'Property'] = property; + style[this._transitionPrefix + 'Duration'] = speed + 'ms'; + style[this._transitionPrefix + 'TimingFunction'] = timingFunction; + style[this._transitionPrefix + 'Delay'] = '0'; + + Util.Events.add(el, this._transitionEndLabel, this._getTransitionEndHandler()); + + Util.DOM.setStyle(el, style); + + if (!Util.isNothing(callback)){ + el['ccl' + property + 'callback'] = callback; + } + + window.setTimeout(function(){ + Util.DOM.setStyle(el, property, val); + }, this._applyTransitionDelay); + + }, + + + + /* + * Function: _onTransitionEnd + */ + _onTransitionEnd: function(e){ + + Util.Events.remove(e.currentTarget, this._transitionEndLabel, this._getTransitionEndHandler()); + this._leaveTransforms(e.currentTarget); + + }, + + + + /* + * Function: _leaveTransforms + */ + _leaveTransforms: function(el){ + + var + property = el.style[this._transitionPrefix + 'Property'], + callbackLabel = (property !== '') ? 'ccl' + property + 'callback' : 'cclallcallback', + callback, + transform = Util.coalesce(el.style.webkitTransform, el.style.MozTransform, el.style.transform), + transformMatch, + transformExploded, + domX = window.parseInt(Util.DOM.getStyle(el, 'left'), 0), + domY = window.parseInt(Util.DOM.getStyle(el, 'top'), 0), + transformedX, + transformedY, + style = {}; + + if (transform !== ''){ + if (Util.Browser.is3dSupported){ + transformMatch = transform.match( /translate3d\((.*?)\)/ ); + } + else{ + transformMatch = transform.match( /translate\((.*?)\)/ ); + } + if (!Util.isNothing(transformMatch)){ + transformExploded = transformMatch[1].split(', '); + transformedX = window.parseInt(transformExploded[0], 0); + transformedY = window.parseInt(transformExploded[1], 0); + } + } + + style[this._transitionPrefix + 'Property'] = ''; + style[this._transitionPrefix + 'Duration'] = ''; + style[this._transitionPrefix + 'TimingFunction'] = ''; + style[this._transitionPrefix + 'Delay'] = ''; + + Util.DOM.setStyle(el, style); + + window.setTimeout(function(){ + + if(!Util.isNothing(transformExploded)){ + + style = {}; + style[this._transformLabel] = ''; + style.left = (domX + transformedX) + 'px'; + style.top = (domY + transformedY) + 'px'; + + Util.DOM.setStyle(el, style); + + } + + if (!Util.isNothing(el[callbackLabel])){ + callback = el[callbackLabel]; + delete el[callbackLabel]; + callback(el); + } + + }.bind(this), this._applyTransitionDelay); + + } + + + } + + + }); + + +} +( + window, + window.Code.Util +)); +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.Util.TouchElement'); + + + Util.TouchElement.EventTypes = { + + onTouch: 'CodeUtilTouchElementOnTouch' + + }; + + + Util.TouchElement.ActionTypes = { + + touchStart: 'touchStart', + touchMove: 'touchMove', + touchEnd: 'touchEnd', + touchMoveEnd: 'touchMoveEnd', + tap: 'tap', + doubleTap: 'doubleTap', + swipeLeft: 'swipeLeft', + swipeRight: 'swipeRight', + swipeUp: 'swipeUp', + swipeDown: 'swipeDown', + gestureStart: 'gestureStart', + gestureChange: 'gestureChange', + gestureEnd: 'gestureEnd' + + }; + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.Util.TouchElement'); + + + Util.TouchElement.TouchElementClass = klass({ + + el: null, + + captureSettings: null, + + touchStartPoint: null, + touchEndPoint: null, + touchStartTime: null, + doubleTapTimeout: null, + + touchStartHandler: null, + touchMoveHandler: null, + touchEndHandler: null, + + mouseDownHandler: null, + mouseMoveHandler: null, + mouseUpHandler: null, + mouseOutHandler: null, + + gestureStartHandler: null, + gestureChangeHandler: null, + gestureEndHandler: null, + + swipeThreshold: null, + swipeTimeThreshold: null, + doubleTapSpeed: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.removeEventHandlers(); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(el, captureSettings){ + + this.el = el; + + this.captureSettings = { + swipe: false, + move: false, + gesture: false, + doubleTap: false, + preventDefaultTouchEvents: true + }; + + Util.extend(this.captureSettings, captureSettings); + + this.swipeThreshold = 50; + this.swipeTimeThreshold = 250; + this.doubleTapSpeed = 250; + + this.touchStartPoint = { x: 0, y: 0 }; + this.touchEndPoint = { x: 0, y: 0 }; + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.isNothing(this.touchStartHandler)){ + this.touchStartHandler = this.onTouchStart.bind(this); + this.touchMoveHandler = this.onTouchMove.bind(this); + this.touchEndHandler = this.onTouchEnd.bind(this); + this.mouseDownHandler = this.onMouseDown.bind(this); + this.mouseMoveHandler = this.onMouseMove.bind(this); + this.mouseUpHandler = this.onMouseUp.bind(this); + this.mouseOutHandler = this.onMouseOut.bind(this); + this.gestureStartHandler = this.onGestureStart.bind(this); + this.gestureChangeHandler = this.onGestureChange.bind(this); + this.gestureEndHandler = this.onGestureEnd.bind(this); + } + + Util.Events.add(this.el, 'touchstart', this.touchStartHandler); + if (this.captureSettings.move){ + Util.Events.add(this.el, 'touchmove', this.touchMoveHandler); + } + Util.Events.add(this.el, 'touchend', this.touchEndHandler); + + Util.Events.add(this.el, 'mousedown', this.mouseDownHandler); + + if (Util.Browser.isGestureSupported && this.captureSettings.gesture){ + Util.Events.add(this.el, 'gesturestart', this.gestureStartHandler); + Util.Events.add(this.el, 'gesturechange', this.gestureChangeHandler); + Util.Events.add(this.el, 'gestureend', this.gestureEndHandler); + } + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + Util.Events.remove(this.el, 'touchstart', this.touchStartHandler); + if (this.captureSettings.move){ + Util.Events.remove(this.el, 'touchmove', this.touchMoveHandler); + } + Util.Events.remove(this.el, 'touchend', this.touchEndHandler); + Util.Events.remove(this.el, 'mousedown', this.mouseDownHandler); + + if (Util.Browser.isGestureSupported && this.captureSettings.gesture){ + Util.Events.remove(this.el, 'gesturestart', this.gestureStartHandler); + Util.Events.remove(this.el, 'gesturechange', this.gestureChangeHandler); + Util.Events.remove(this.el, 'gestureend', this.gestureEndHandler); + } + + }, + + + + /* + * Function: getTouchPoint + */ + getTouchPoint: function(touches){ + + return { + x: touches[0].pageX, + y: touches[0].pageY + }; + + }, + + + + /* + * Function: fireTouchEvent + */ + fireTouchEvent: function(e){ + + var + action, + distX = 0, + distY = 0, + dist = 0, + self, + endTime, + diffTime; + + distX = this.touchEndPoint.x - this.touchStartPoint.x; + distY = this.touchEndPoint.y - this.touchStartPoint.y; + dist = Math.sqrt( (distX * distX) + (distY * distY) ); + + if (this.captureSettings.swipe){ + endTime = new Date(); + diffTime = endTime - this.touchStartTime; + + // See if there was a swipe gesture + if (diffTime <= this.swipeTimeThreshold){ + + if (window.Math.abs(distX) >= this.swipeThreshold){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: (distX < 0) ? Util.TouchElement.ActionTypes.swipeLeft : Util.TouchElement.ActionTypes.swipeRight, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + + } + + + if (window.Math.abs(distY) >= this.swipeThreshold){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: (distY < 0) ? Util.TouchElement.ActionTypes.swipeUp : Util.TouchElement.ActionTypes.swipeDown, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + + } + + } + } + + + if (dist > 1){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchMoveEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + } + + + if (!this.captureSettings.doubleTap){ + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: Util.TouchElement.ActionTypes.tap, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + return; + + } + + if (Util.isNothing(this.doubleTapTimeout)){ + + this.doubleTapTimeout = window.setTimeout(function(){ + + this.doubleTapTimeout = null; + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: Util.TouchElement.ActionTypes.tap, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }.bind(this), this.doubleTapSpeed); + + return; + + } + else{ + + window.clearTimeout(this.doubleTapTimeout); + this.doubleTapTimeout = null; + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + point: this.touchEndPoint, + action: Util.TouchElement.ActionTypes.doubleTap, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + } + + }, + + + + /* + * Function: onTouchStart + */ + onTouchStart: function(e){ + + if (this.captureSettings.preventDefaultTouchEvents){ + e.preventDefault(); + } + + // No longer need mouse events + Util.Events.remove(this.el, 'mousedown', this.mouseDownHandler); + + var + touchEvent = Util.Events.getTouchEvent(e), + touches = touchEvent.touches; + + if (touches.length > 1 && this.captureSettings.gesture){ + this.isGesture = true; + return; + } + + this.touchStartTime = new Date(); + this.isGesture = false; + this.touchStartPoint = this.getTouchPoint(touches); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchStart, + point: this.touchStartPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + + }, + + + + /* + * Function: onTouchMove + */ + onTouchMove: function(e){ + + if (this.captureSettings.preventDefaultTouchEvents){ + e.preventDefault(); + } + + if (this.isGesture && this.captureSettings.gesture){ + return; + } + + var + touchEvent = Util.Events.getTouchEvent(e), + touches = touchEvent.touches; + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchMove, + point: this.getTouchPoint(touches), + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onTouchEnd + */ + onTouchEnd: function(e){ + + if (this.isGesture && this.captureSettings.gesture){ + return; + } + + if (this.captureSettings.preventDefaultTouchEvents){ + e.preventDefault(); + } + + // http://backtothecode.blogspot.com/2009/10/javascript-touch-and-gesture-events.html + // iOS removed the current touch from e.touches on "touchend" + // Need to look into e.changedTouches + + var + touchEvent = Util.Events.getTouchEvent(e), + touches = (!Util.isNothing(touchEvent.changedTouches)) ? touchEvent.changedTouches : touchEvent.touches; + + this.touchEndPoint = this.getTouchPoint(touches); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + this.fireTouchEvent(e); + + }, + + + + /* + * Function: onMouseDown + */ + onMouseDown: function(e){ + + e.preventDefault(); + + // No longer need touch events + Util.Events.remove(this.el, 'touchstart', this.mouseDownHandler); + Util.Events.remove(this.el, 'touchmove', this.touchMoveHandler); + Util.Events.remove(this.el, 'touchend', this.touchEndHandler); + + // Add move/up/out + if (this.captureSettings.move){ + Util.Events.add(this.el, 'mousemove', this.mouseMoveHandler); + } + Util.Events.add(this.el, 'mouseup', this.mouseUpHandler); + Util.Events.add(this.el, 'mouseout', this.mouseOutHandler); + + this.touchStartTime = new Date(); + this.isGesture = false; + this.touchStartPoint = Util.Events.getMousePosition(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchStart, + point: this.touchStartPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onMouseMove + */ + onMouseMove: function(e){ + + e.preventDefault(); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchMove, + point: Util.Events.getMousePosition(e), + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onMouseUp + */ + onMouseUp: function(e){ + + e.preventDefault(); + + if (this.captureSettings.move){ + Util.Events.remove(this.el, 'mousemove', this.mouseMoveHandler); + } + Util.Events.remove(this.el, 'mouseup', this.mouseUpHandler); + Util.Events.remove(this.el, 'mouseout', this.mouseOutHandler); + + this.touchEndPoint = Util.Events.getMousePosition(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + this.fireTouchEvent(e); + + }, + + + + /* + * Function: onMouseOut + */ + onMouseOut: function(e){ + + /* + * http://blog.stchur.com/2007/03/15/mouseenter-and-mouseleave-events-for-firefox-and-other-non-ie-browsers/ + */ + var relTarget = e.relatedTarget; + if (this.el === relTarget || Util.DOM.isChildOf(relTarget, this.el)){ + return; + } + + e.preventDefault(); + + if (this.captureSettings.move){ + Util.Events.remove(this.el, 'mousemove', this.mouseMoveHandler); + } + Util.Events.remove(this.el, 'mouseup', this.mouseUpHandler); + Util.Events.remove(this.el, 'mouseout', this.mouseOutHandler); + + this.touchEndPoint = Util.Events.getMousePosition(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.touchEnd, + point: this.touchEndPoint, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + this.fireTouchEvent(e); + + }, + + + + /* + * Function: onGestureStart + */ + onGestureStart: function(e){ + + e.preventDefault(); + + var touchEvent = Util.Events.getTouchEvent(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.gestureStart, + scale: touchEvent.scale, + rotation: touchEvent.rotation, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onGestureChange + */ + onGestureChange: function(e){ + + e.preventDefault(); + + var touchEvent = Util.Events.getTouchEvent(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.gestureChange, + scale: touchEvent.scale, + rotation: touchEvent.rotation, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + }, + + + + /* + * Function: onGestureEnd + */ + onGestureEnd: function(e){ + + e.preventDefault(); + + var touchEvent = Util.Events.getTouchEvent(e); + + Util.Events.fire(this, { + type: Util.TouchElement.EventTypes.onTouch, + target: this, + action: Util.TouchElement.ActionTypes.gestureEnd, + scale: touchEvent.scale, + rotation: touchEvent.rotation, + targetEl: e.target, + currentTargetEl: e.currentTarget + }); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.EventTypes = { + + onLoad: 'onLoad', + onError: 'onError' + + }; + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.ImageClass = klass({ + + + + refObj: null, + imageEl: null, + src: null, + caption: null, + metaData: null, + imageLoadHandler: null, + imageErrorHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i; + + this.shrinkImage(); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(refObj, src, caption, metaData){ + + this.refObj = refObj; + // This is needed. Webkit resolves the src + // value which means we can't compare against it in the load function + this.originalSrc = src; + this.src = src; + this.caption = caption; + this.metaData = metaData; + + this.imageEl = new window.Image(); + + this.imageLoadHandler = this.onImageLoad.bind(this); + this.imageErrorHandler = this.onImageError.bind(this); + + }, + + + + /* + * Function: load + */ + load: function(){ + + this.imageEl.originalSrc = Util.coalesce(this.imageEl.originalSrc, ''); + + if (this.imageEl.originalSrc === this.src){ + + if (this.imageEl.isError){ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + } + else{ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + } + return; + } + + this.imageEl.isError = false; + this.imageEl.isLoading = true; + this.imageEl.naturalWidth = null; + this.imageEl.naturalHeight = null; + this.imageEl.isLandscape = false; + this.imageEl.onload = this.imageLoadHandler; + this.imageEl.onerror = this.imageErrorHandler; + this.imageEl.onabort = this.imageErrorHandler; + this.imageEl.originalSrc = this.src; + this.imageEl.src = this.src; + + }, + + + + /* + * Function: shrinkImage + */ + shrinkImage: function(){ + + if (Util.isNothing(this.imageEl)){ + return; + } + + if (this.imageEl.src.indexOf(this.src) > -1){ + this.imageEl.src = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='; + if (!Util.isNothing(this.imageEl.parentNode)){ + Util.DOM.removeChild(this.imageEl, this.imageEl.parentNode); + } + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + this.imageEl.onload = null; + this.imageEl.naturalWidth = Util.coalesce(this.imageEl.naturalWidth, this.imageEl.width); + this.imageEl.naturalHeight = Util.coalesce(this.imageEl.naturalHeight, this.imageEl.height); + this.imageEl.isLandscape = (this.imageEl.naturalWidth > this.imageEl.naturalHeight); + this.imageEl.isLoading = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + this.imageEl.onload = null; + this.imageEl.onerror = null; + this.imageEl.onabort = null; + this.imageEl.isLoading = false; + this.imageEl.isError = true; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Cache'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Cache.Mode = { + + normal: 'normal', + aggressive: 'aggressive' + + }; + + + + PhotoSwipe.Cache.Functions = { + + /* + * Function: getImageSource + * Default method for returning an image's source + */ + getImageSource: function(el){ + return el.href; + }, + + + + /* + * Function: getImageCaption + * Default method for returning an image's caption + * Assumes the el is an anchor and the first child is the + * image. The returned value is the "alt" attribute of the + * image. + */ + getImageCaption: function(el){ + + if (el.nodeName === "IMG"){ + return Util.DOM.getAttribute(el, 'alt'); + } + var i, j, childEl; + for (i=0, j=el.childNodes.length; i height){ + height = Util.DOM.windowHeight(); + } + + } + else{ + + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + + } + + Util.DOM.setStyle(this.el, { + width: width, + height: height, + top: top + }); + + }, + + + + /* + * Function: fadeIn + */ + fadeIn: function(speed, callback){ + + this.resetPosition(); + + Util.DOM.setStyle(this.el, 'opacity', 0); + Util.DOM.show(this.el); + + Util.Animation.fadeIn(this.el, speed, callback); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Carousel.EventTypes = { + + onSlideByEnd: 'PhotoSwipeCarouselOnSlideByEnd', + onSlideshowStart: 'PhotoSwipeCarouselOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeCarouselOnSlideshowStop' + + }; + + + + PhotoSwipe.Carousel.CssClasses = { + carousel: 'ps-carousel', + content: 'ps-carousel-content', + item: 'ps-carousel-item', + itemLoading: 'ps-carousel-item-loading', + itemError: 'ps-carousel-item-error' + }; + + + + PhotoSwipe.Carousel.SlideByAction = { + previous: 'previous', + current: 'current', + next: 'next' + }; + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = klass({ + + + + el: null, + contentEl: null, + settings: null, + cache: null, + slideByEndHandler: null, + currentCacheIndex: null, + isSliding: null, + isSlideshowActive: null, + lastSlideByAction: null, + touchStartPoint: null, + touchStartPosition: null, + imageLoadHandler: null, + imageErrorHandler: null, + slideshowTimeout: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i, j; + + for (i=0, j=this.cache.images.length; i 0){ + Util.DOM.setStyle(itemEl, { + marginRight: this.settings.margin + 'px' + }); + } + + Util.DOM.appendChild(itemEl, this.contentEl); + + } + + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + }, + + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, height, top, itemWidth, itemEls, contentWidth, i, j, itemEl, imageEl; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + } + + itemWidth = (this.settings.margin > 0) ? width + this.settings.margin : width; + itemEls = Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + contentWidth = itemWidth * itemEls.length; + + + // Set the height and width to fill the document + Util.DOM.setStyle(this.el, { + top: top, + width: width, + height: height + }); + + + // Set the height and width of the content el + Util.DOM.setStyle(this.contentEl, { + width: contentWidth, + height: height + }); + + + // Set the height and width of item elements + for (i=0, j=itemEls.length; i maxWidth){ + scale = maxWidth / newWidth; + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + if (newHeight > maxHeight){ + scale = maxHeight / newHeight; + newHeight = Math.round(newHeight * scale); + newWidth = Math.round(newWidth * scale); + } + + } + else{ + + if (imageEl.isLandscape) { + // Ensure the width fits the screen + scale = maxWidth / imageEl.naturalWidth; + } + else { + // Ensure the height fits the screen + scale = maxHeight / imageEl.naturalHeight; + } + + newWidth = Math.round(imageEl.naturalWidth * scale); + newHeight = Math.round(imageEl.naturalHeight * scale); + + if (this.settings.imageScaleMethod === 'zoom'){ + + scale = 1; + if (newHeight < maxHeight){ + scale = maxHeight /newHeight; + } + else if (newWidth < maxWidth){ + scale = maxWidth /newWidth; + } + + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + } + else if (this.settings.imageScaleMethod === 'fit') { + // Rescale again to ensure full image fits into the viewport + scale = 1; + if (newWidth > maxWidth) { + scale = maxWidth / newWidth; + } + else if (newHeight > maxHeight) { + scale = maxHeight / newHeight; + } + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + } + + } + + newTop = Math.round( ((maxHeight - newHeight) / 2) ) + 'px'; + newLeft = Math.round( ((maxWidth - newWidth) / 2) ) + 'px'; + + Util.DOM.setStyle(imageEl, { + position: 'absolute', + width: newWidth, + height: newHeight, + top: newTop, + left: newLeft, + display: 'block' + }); + + }, + + + + /* + * Function: setContentLeftPosition + */ + setContentLeftPosition: function(){ + + var width, itemEls, left; + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + } + else{ + width = Util.DOM.width(this.settings.target); + } + + itemEls = this.getItemEls(); + left = 0; + + if (this.settings.loop){ + left = (width + this.settings.margin) * -1; + } + else{ + + if (this.currentCacheIndex === this.cache.images.length-1){ + left = ((itemEls.length-1) * (width + this.settings.margin)) * -1; + } + else if (this.currentCacheIndex > 0){ + left = (width + this.settings.margin) * -1; + } + + } + + Util.DOM.setStyle(this.contentEl, { + left: left + 'px' + }); + + }, + + + + /* + * Function: + */ + show: function(index){ + + this.currentCacheIndex = index; + this.resetPosition(); + this.setImages(false); + Util.DOM.show(this.el); + + Util.Animation.resetTranslate(this.contentEl); + var + itemEls = this.getItemEls(), + i, j; + for (i=0, j=itemEls.length; i this.cache.images.length-1){ + nextCacheIndex = 0; + } + if (previousCacheIndex < 0){ + previousCacheIndex = this.cache.images.length-1; + } + + cacheImages = this.cache.getImages([ + previousCacheIndex, + this.currentCacheIndex, + nextCacheIndex + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + + } + else{ + + if (itemEls.length === 1){ + if (!ignoreCurrent){ + // Current + cacheImages = this.cache.getImages([ + this.currentCacheIndex + ]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + } + else if (itemEls.length === 2){ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + else{ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1, + this.currentCacheIndex + 2 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + else if (this.currentCacheIndex === this.cache.images.length-1){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 2, + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + + } + + }, + + + + /* + * Function: addCacheImageToItemEl + */ + addCacheImageToItemEl: function(cacheImage, itemEl){ + + Util.DOM.removeClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemError); + Util.DOM.addClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemLoading); + + Util.DOM.removeChildren(itemEl); + + Util.DOM.setStyle(cacheImage.imageEl, { + display: 'none' + }); + Util.DOM.appendChild(cacheImage.imageEl, itemEl); + + Util.Animation.resetTranslate(cacheImage.imageEl); + + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + cacheImage.load(); + + }, + + + + /* + * Function: slideCarousel + */ + slideCarousel: function(point, action, speed){ + + if (this.isSliding){ + return; + } + + var width, diffX, slideBy; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth() + this.settings.margin; + } + else{ + width = Util.DOM.width(this.settings.target) + this.settings.margin; + } + + speed = Util.coalesce(speed, this.settings.slideSpeed); + + if (window.Math.abs(diffX) < 1){ + return; + } + + + switch (action){ + + case Util.TouchElement.ActionTypes.swipeLeft: + + slideBy = width * -1; + break; + + case Util.TouchElement.ActionTypes.swipeRight: + + slideBy = width; + break; + + default: + + diffX = point.x - this.touchStartPoint.x; + + if (window.Math.abs(diffX) > width / 2){ + slideBy = (diffX > 0) ? width : width * -1; + } + else{ + slideBy = 0; + } + break; + + } + + if (slideBy < 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.next; + } + else if (slideBy > 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.previous; + } + else{ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + + // Check for non-looping carousels + // If we are at the start or end, spring back to the current item element + if (!this.settings.loop){ + if ( (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous && this.currentCacheIndex === 0 ) || (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next && this.currentCacheIndex === this.cache.images.length-1) ){ + slideBy = 0; + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + } + + this.isSliding = true; + this.doSlideCarousel(slideBy, speed); + + }, + + + + /* + * Function: + */ + moveCarousel: function(point){ + + if (this.isSliding){ + return; + } + + if (!this.settings.enableDrag){ + return; + } + + this.doMoveCarousel(point.x - this.touchStartPoint.x); + + }, + + + + /* + * Function: getItemEls + */ + getItemEls: function(){ + + return Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeRight, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: next + */ + next: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: slideshowNext + */ + slideshowNext: function(){ + + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft); + + }, + + + + + /* + * Function: startSlideshow + */ + startSlideshow: function(){ + + this.stopSlideshow(); + + this.isSlideshowActive = true; + + this.slideshowTimeout = window.setTimeout(this.slideshowNext.bind(this), this.settings.slideshowDelay); + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: stopSlideshow + */ + stopSlideshow: function(){ + + if (!Util.isNothing(this.slideshowTimeout)){ + + window.clearTimeout(this.slideshowTimeout); + this.slideshowTimeout = null; + this.isSlideshowActive = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStop, + target: this + }); + + } + + }, + + + + /* + * Function: onSlideByEnd + */ + onSlideByEnd: function(e){ + + if (Util.isNothing(this.isSliding)){ + return; + } + + var itemEls = this.getItemEls(); + + this.isSliding = false; + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + this.currentCacheIndex = this.currentCacheIndex + 1; + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + this.currentCacheIndex = this.currentCacheIndex - 1; + } + + if (this.settings.loop){ + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + + if (this.currentCacheIndex < 0){ + this.currentCacheIndex = this.cache.images.length - 1; + } + else if (this.currentCacheIndex === this.cache.images.length){ + this.currentCacheIndex = 0; + } + + } + else{ + + if (this.cache.images.length > 3){ + + if (this.currentCacheIndex > 1 && this.currentCacheIndex < this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === 1){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + } + + } + + + } + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.setContentLeftPosition(); + this.setImages(true); + } + + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideByEnd, + target: this, + action: this.lastSlideByAction, + cacheIndex: this.currentCacheIndex + }); + + + if (this.isSlideshowActive){ + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.startSlideshow(); + } + else{ + this.stopSlideshow(); + } + + } + + + }, + + + + /* + * Function: onTouch + */ + onTouch: function(action, point){ + + this.stopSlideshow(); + + switch(action){ + + case Util.TouchElement.ActionTypes.touchStart: + this.touchStartPoint = point; + this.touchStartPosition = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.moveCarousel(point); + break; + + case Util.TouchElement.ActionTypes.touchMoveEnd: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + this.slideCarousel(point, action); + break; + + case Util.TouchElement.ActionTypes.tap: + break; + + case Util.TouchElement.ActionTypes.doubleTap: + break; + + + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + this.resetImagePosition(cacheImage.imageEl); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + Util.DOM.addClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemError); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util, TouchElement){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = PhotoSwipe.Carousel.CarouselClass.extend({ + + + /* + * Function: getStartingPos + */ + getStartingPos: function(){ + + var startingPos = this.touchStartPosition; + + if (Util.isNothing(startingPos)){ + startingPos = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + } + + return startingPos; + + }, + + + + /* + * Function: doMoveCarousel + */ + doMoveCarousel: function(xVal){ + + var style; + + if (Util.Browser.isCSSTransformSupported){ + + style = {}; + + style[Util.Animation._transitionPrefix + 'Property'] = 'all'; + style[Util.Animation._transitionPrefix + 'Duration'] = ''; + style[Util.Animation._transitionPrefix + 'TimingFunction'] = ''; + style[Util.Animation._transitionPrefix + 'Delay'] = '0'; + style[Util.Animation._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(' + xVal + 'px, 0px, 0px)' : 'translate(' + xVal + 'px, 0px)'; + + Util.DOM.setStyle(this.contentEl, style); + + } + else if (!Util.isNothing(window.jQuery)){ + + + window.jQuery(this.contentEl).stop().css('left', this.getStartingPos().x + xVal + 'px'); + + } + + }, + + + + /* + * Function: doSlideCarousel + */ + doSlideCarousel: function(xVal, speed){ + + var animateProps, transform; + + if (speed <= 0){ + + this.slideByEndHandler(); + return; + + } + + + if (Util.Browser.isCSSTransformSupported){ + + transform = Util.coalesce(this.contentEl.style.webkitTransform, this.contentEl.style.MozTransform, this.contentEl.style.transform, ''); + if (transform.indexOf('translate3d(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + else if (transform.indexOf('translate(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + + Util.Animation.slideBy(this.contentEl, xVal, 0, speed, this.slideByEndHandler, this.settings.slideTimingFunction); + + } + else if (!Util.isNothing(window.jQuery)){ + + animateProps = { + left: this.getStartingPos().x + xVal + 'px' + }; + + if (this.settings.animationTimingFunction === 'ease-out'){ + this.settings.animationTimingFunction = 'easeOutQuad'; + } + + if ( Util.isNothing(window.jQuery.easing[this.settings.animationTimingFunction]) ){ + this.settings.animationTimingFunction = 'linear'; + } + + window.jQuery(this.contentEl).animate( + animateProps, + this.settings.slideSpeed, + this.settings.animationTimingFunction, + this.slideByEndHandler + ); + + } + + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.TouchElement +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.CssClasses = { + toolbar: 'ps-toolbar', + toolbarContent: 'ps-toolbar-content', + toolbarTop: 'ps-toolbar-top', + caption: 'ps-caption', + captionBottom: 'ps-caption-bottom', + captionContent: 'ps-caption-content', + close: 'ps-toolbar-close', + play: 'ps-toolbar-play', + previous: 'ps-toolbar-previous', + previousDisabled: 'ps-toolbar-previous-disabled', + next: 'ps-toolbar-next', + nextDisabled: 'ps-toolbar-next-disabled' + }; + + + + PhotoSwipe.Toolbar.ToolbarAction = { + close: 'close', + play: 'play', + next: 'next', + previous: 'previous', + none: 'none' + }; + + + + PhotoSwipe.Toolbar.EventTypes = { + onTap: 'PhotoSwipeToolbarOnClick', + onBeforeShow: 'PhotoSwipeToolbarOnBeforeShow', + onShow: 'PhotoSwipeToolbarOnShow', + onBeforeHide: 'PhotoSwipeToolbarOnBeforeHide', + onHide: 'PhotoSwipeToolbarOnHide' + }; + + + + PhotoSwipe.Toolbar.getToolbar = function(){ + + return '
'; + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.ToolbarClass = klass({ + + + + toolbarEl: null, + closeEl: null, + playEl: null, + previousEl: null, + nextEl: null, + captionEl: null, + captionContentEl: null, + currentCaption: null, + settings: null, + cache: null, + timeout: null, + isVisible: null, + fadeOutHandler: null, + touchStartHandler: null, + touchMoveHandler: null, + clickHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.clearTimeout(); + + this.removeEventHandlers(); + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + Util.DOM.removeChild(this.toolbarEl, this.toolbarEl.parentNode); + Util.DOM.removeChild(this.captionEl, this.captionEl.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(cache, options){ + + var cssClass; + + this.settings = options; + this.cache = cache; + this.isVisible = false; + + this.fadeOutHandler = this.onFadeOut.bind(this); + this.touchStartHandler = this.onTouchStart.bind(this); + this.touchMoveHandler = this.onTouchMove.bind(this); + this.clickHandler = this.onClick.bind(this); + + + cssClass = PhotoSwipe.Toolbar.CssClasses.toolbar; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.toolbarTop; + } + + + // Toolbar + this.toolbarEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + this.settings.getToolbar() + ); + + + Util.DOM.setStyle(this.toolbarEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.toolbarEl); + } + else{ + Util.DOM.appendChild(this.toolbarEl, this.settings.target); + } + Util.DOM.hide(this.toolbarEl); + + this.closeEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.close, this.toolbarEl)[0]; + if (this.settings.preventHide && !Util.isNothing(this.closeEl)){ + Util.DOM.hide(this.closeEl); + } + + this.playEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.play, this.toolbarEl)[0]; + if (this.settings.preventSlideshow && !Util.isNothing(this.playEl)){ + Util.DOM.hide(this.playEl); + } + + this.nextEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.next, this.toolbarEl)[0]; + this.previousEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.previous, this.toolbarEl)[0]; + + + // Caption + cssClass = PhotoSwipe.Toolbar.CssClasses.caption; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.captionBottom; + } + + this.captionEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + '' + ); + Util.DOM.setStyle(this.captionEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.captionEl); + } + else{ + Util.DOM.appendChild(this.captionEl, this.settings.target); + } + Util.DOM.hide(this.captionEl); + + this.captionContentEl = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.Toolbar.CssClasses.captionContent + }, + '' + ); + Util.DOM.appendChild(this.captionContentEl, this.captionEl); + + this.addEventHandlers(); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, toolbarTop, captionTop; + + if (this.settings.target === window){ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = Util.DOM.windowScrollTop(); + captionTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.captionEl); + } + else { + toolbarTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.toolbarEl); + captionTop = Util.DOM.windowScrollTop(); + } + width = Util.DOM.windowWidth(); + } + else{ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = '0'; + captionTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.captionEl); + } + else{ + toolbarTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.toolbarEl); + captionTop = 0; + } + width = Util.DOM.width(this.settings.target); + } + + Util.DOM.setStyle(this.toolbarEl, { + top: toolbarTop + 'px', + width: width + }); + + Util.DOM.setStyle(this.captionEl, { + top: captionTop + 'px', + width: width + }); + }, + + + + /* + * Function: toggleVisibility + */ + toggleVisibility: function(index){ + + if (this.isVisible){ + this.fadeOut(); + } + else{ + this.show(index); + } + + }, + + + + /* + * Function: show + */ + show: function(index){ + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + this.resetPosition(); + this.setToolbarStatus(index); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeShow, + target: this + }); + + this.showToolbar(); + this.setCaption(index); + this.showCaption(); + + this.isVisible = true; + + this.setTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onShow, + target: this + }); + + }, + + + + /* + * Function: setTimeout + */ + setTimeout: function(){ + + if (this.settings.captionAndToolbarAutoHideDelay > 0){ + // Set a timeout to hide the toolbar + this.clearTimeout(); + this.timeout = window.setTimeout(this.fadeOut.bind(this), this.settings.captionAndToolbarAutoHideDelay); + } + + }, + + + + /* + * Function: clearTimeout + */ + clearTimeout: function(){ + + if (!Util.isNothing(this.timeout)){ + window.clearTimeout(this.timeout); + this.timeout = null; + } + + }, + + + + /* + * Function: fadeOut + */ + fadeOut: function(){ + + this.clearTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeHide, + target: this + }); + + Util.Animation.fadeOut(this.toolbarEl, this.settings.fadeOutSpeed); + Util.Animation.fadeOut(this.captionEl, this.settings.fadeOutSpeed, this.fadeOutHandler); + + this.isVisible = false; + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.add(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.add(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.add(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.add(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.remove(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.remove(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.remove(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: handleTap + */ + handleTap: function(e){ + + this.clearTimeout(); + + var action; + + if (e.target === this.nextEl || Util.DOM.isChildOf(e.target, this.nextEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.next; + } + else if (e.target === this.previousEl || Util.DOM.isChildOf(e.target, this.previousEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.previous; + } + else if (e.target === this.closeEl || Util.DOM.isChildOf(e.target, this.closeEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.close; + } + else if (e.target === this.playEl || Util.DOM.isChildOf(e.target, this.playEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.play; + } + + this.setTimeout(); + + if (Util.isNothing(action)){ + action = PhotoSwipe.Toolbar.ToolbarAction.none; + } + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onTap, + target: this, + action: action, + tapTarget: e.target + }); + + }, + + + + /* + * Function: setCaption + */ + setCaption: function(index){ + + Util.DOM.removeChildren(this.captionContentEl); + + this.currentCaption = Util.coalesce(this.cache.images[index].caption, '\u00A0'); + + if (Util.isObject(this.currentCaption)){ + Util.DOM.appendChild(this.currentCaption, this.captionContentEl); + } + else{ + if (this.currentCaption === ''){ + this.currentCaption = '\u00A0'; + } + Util.DOM.appendText(this.currentCaption, this.captionContentEl); + } + + this.currentCaption = (this.currentCaption === '\u00A0') ? '' : this.currentCaption; + this.resetPosition(); + + }, + + + + /* + * Function: showToolbar + */ + showToolbar: function(){ + + Util.DOM.setStyle(this.toolbarEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.toolbarEl); + + }, + + + + /* + * Function: showCaption + */ + showCaption: function(){ + + if (this.currentCaption === '' || this.captionContentEl.childNodes.length < 1){ + // Empty caption + if (!this.settings.captionAndToolbarShowEmptyCaptions){ + Util.DOM.hide(this.captionEl); + return; + } + } + Util.DOM.setStyle(this.captionEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.captionEl); + + }, + + + + /* + * Function: setToolbarStatus + */ + setToolbarStatus: function(index){ + + if (this.settings.loop){ + return; + } + + Util.DOM.removeClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + Util.DOM.removeClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + + if (index > 0 && index < this.cache.images.length-1){ + return; + } + + if (index === 0){ + if (!Util.isNothing(this.previousEl)){ + Util.DOM.addClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + } + } + + if (index === this.cache.images.length-1){ + if (!Util.isNothing(this.nextEl)){ + Util.DOM.addClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + } + } + + }, + + + + /* + * Function: onFadeOut + */ + onFadeOut: function(){ + + Util.DOM.hide(this.toolbarEl); + Util.DOM.hide(this.captionEl); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onHide, + target: this + }); + + }, + + + + /* + * Function: onTouchStart + */ + onTouchStart: function(e){ + + e.preventDefault(); + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + this.handleTap(e); + + }, + + + + /* + * Function: onTouchMove + */ + onTouchMove: function(e){ + + e.preventDefault(); + + }, + + + + /* + * Function: onClick + */ + onClick: function(e){ + + e.preventDefault(); + this.handleTap(e); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.UILayer.CssClasses = { + uiLayer: 'ps-uilayer' + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.UILayer.UILayerClass = Util.TouchElement.TouchElementClass.extend({ + + + + el: null, + settings: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.removeEventHandlers(); + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options){ + + this.settings = options; + + // Main container + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.UILayer.CssClasses.uiLayer + }, + '' + ); + Util.DOM.setStyle(this.el, { + display: 'block', + position: 'absolute', + left: 0, + top: 0, + overflow: 'hidden', + zIndex: this.settings.zIndex, + opacity: 0 + }); + Util.DOM.hide(this.el); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + this.supr(this.el, { + swipe: true, + move: true, + gesture: Util.Browser.iOS, + doubleTap: true, + preventDefaultTouchEvents: this.settings.preventDefaultTouchEvents + }); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + // Set the height and width to fill the document + if (this.settings.target === window){ + Util.DOM.setStyle(this.el, { + top: Util.DOM.windowScrollTop() + 'px', + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }); + } + else{ + Util.DOM.setStyle(this.el, { + top: '0px', + width: Util.DOM.width(this.settings.target), + height: Util.DOM.height(this.settings.target) + }); + } + + }, + + + + /* + * Function: show + */ + show: function(){ + + this.resetPosition(); + Util.DOM.show(this.el); + this.addEventHandlers(); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + this.supr(); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + this.supr(); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.ZoomPanRotate.CssClasses = { + zoomPanRotate: 'ps-zoom-pan-rotate' + }; + + + PhotoSwipe.ZoomPanRotate.EventTypes = { + + onTransform: 'PhotoSwipeZoomPanRotateOnTransform' + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.ZoomPanRotate.ZoomPanRotateClass = klass({ + + el: null, + settings: null, + containerEl: null, + imageEl: null, + transformSettings: null, + panStartingPoint: null, + transformEl: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options, cacheImage, uiLayer){ + + var parentEl, width, height, top; + + this.settings = options; + + if (this.settings.target === window){ + parentEl = document.body; + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + parentEl = this.settings.target; + width = Util.DOM.width(parentEl); + height = Util.DOM.height(parentEl); + top = '0px'; + } + + this.imageEl = cacheImage.imageEl.cloneNode(false); + Util.DOM.setStyle(this.imageEl, { + + zIndex: 1 + + }); + + this.transformSettings = { + + startingScale: 1.0, + scale: 1.0, + startingRotation: 0, + rotation: 0, + startingTranslateX: 0, + startingTranslateY: 0, + translateX: 0, + translateY: 0 + + }; + + + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.ZoomPanRotate.CssClasses.zoomPanRotate + }, + '' + ); + Util.DOM.setStyle(this.el, { + left: 0, + top: top, + position: 'absolute', + width: width, + height: height, + zIndex: this.settings.zIndex, + display: 'block' + }); + + Util.DOM.insertBefore(this.el, uiLayer.el, parentEl); + + if (Util.Browser.iOS){ + this.containerEl = Util.DOM.createElement('div','',''); + Util.DOM.setStyle(this.containerEl, { + left: 0, + top: 0, + width: width, + height: height, + position: 'absolute', + zIndex: 1 + }); + Util.DOM.appendChild(this.imageEl, this.containerEl); + Util.DOM.appendChild(this.containerEl, this.el); + Util.Animation.resetTranslate(this.containerEl); + Util.Animation.resetTranslate(this.imageEl); + this.transformEl = this.containerEl; + } + else{ + Util.DOM.appendChild(this.imageEl, this.el); + this.transformEl = this.imageEl; + } + + }, + + + + /* + * Function: setStartingTranslateFromCurrentTransform + */ + setStartingTranslateFromCurrentTransform: function(){ + + var + transformValue = Util.coalesce(this.transformEl.style.webkitTransform, this.transformEl.style.MozTransform, this.transformEl.style.transform), + transformExploded; + + if (!Util.isNothing(transformValue)){ + + transformExploded = transformValue.match( /translate\((.*?)\)/ ); + + if (!Util.isNothing(transformExploded)){ + + transformExploded = transformExploded[1].split(', '); + this.transformSettings.startingTranslateX = window.parseInt(transformExploded[0], 10); + this.transformSettings.startingTranslateY = window.parseInt(transformExploded[1], 10); + + } + + } + + }, + + + + /* + * Function: getScale + */ + getScale: function(scaleValue){ + + var scale = this.transformSettings.startingScale * scaleValue; + + if (this.settings.minUserZoom !== 0 && scale < this.settings.minUserZoom){ + scale = this.settings.minUserZoom; + } + else if (this.settings.maxUserZoom !== 0 && scale > this.settings.maxUserZoom){ + scale = this.settings.maxUserZoom; + } + + return scale; + + }, + + + + /* + * Function: setStartingScaleAndRotation + */ + setStartingScaleAndRotation: function(scaleValue, rotationValue){ + + this.transformSettings.startingScale = this.getScale(scaleValue); + + this.transformSettings.startingRotation = + (this.transformSettings.startingRotation + rotationValue) % 360; + + }, + + + + /* + * Function: zoomRotate + */ + zoomRotate: function(scaleValue, rotationValue){ + + this.transformSettings.scale = this.getScale(scaleValue); + + this.transformSettings.rotation = + this.transformSettings.startingRotation + rotationValue; + + this.applyTransform(); + + }, + + + + /* + * Function: panStart + */ + panStart: function(point){ + + this.setStartingTranslateFromCurrentTransform(); + + this.panStartingPoint = { + x: point.x, + y: point.y + }; + + }, + + + + /* + * Function: pan + */ + pan: function(point){ + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale , + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + this.transformSettings.startingTranslateX + dxScaleAdjust; + + this.transformSettings.translateY = + this.transformSettings.startingTranslateY + dyScaleAdjust; + + this.applyTransform(); + + }, + + + + /* + * Function: zoomAndPanToPoint + */ + zoomAndPanToPoint: function(scaleValue, point){ + + + if (this.settings.target === window){ + + this.panStart({ + x: Util.DOM.windowWidth() / 2, + y: Util.DOM.windowHeight() / 2 + }); + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale, + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + (this.transformSettings.startingTranslateX + dxScaleAdjust) * -1; + + this.transformSettings.translateY = + (this.transformSettings.startingTranslateY + dyScaleAdjust) * -1; + + } + + + this.setStartingScaleAndRotation(scaleValue, 0); + this.transformSettings.scale = this.transformSettings.startingScale; + + this.transformSettings.rotation = 0; + + this.applyTransform(); + + }, + + + + /* + * Function: applyTransform + */ + applyTransform: function(){ + + var + rotationDegs = this.transformSettings.rotation % 360, + translateX = window.parseInt(this.transformSettings.translateX, 10), + translateY = window.parseInt(this.transformSettings.translateY, 10), + transform = 'scale(' + this.transformSettings.scale + ') rotate(' + rotationDegs + 'deg) translate(' + translateX + 'px, ' + translateY + 'px)'; + + Util.DOM.setStyle(this.transformEl, { + webkitTransform: transform, + MozTransform: transform, + msTransform: transform, + transform: transform + }); + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, + scale: this.transformSettings.scale, + rotation: this.transformSettings.rotation, + rotationDegs: rotationDegs, + translateX: translateX, + translateY: translateY + }); + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, Util){ + + + Util.registerNamespace('Code.PhotoSwipe'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.CssClasses = { + buildingBody: 'ps-building', + activeBody: 'ps-active' + }; + + + + PhotoSwipe.EventTypes = { + + onBeforeShow: 'PhotoSwipeOnBeforeShow', + onShow: 'PhotoSwipeOnShow', + onBeforeHide: 'PhotoSwipeOnBeforeHide', + onHide: 'PhotoSwipeOnHide', + onDisplayImage: 'PhotoSwipeOnDisplayImage', + onResetPosition: 'PhotoSwipeOnResetPosition', + onSlideshowStart: 'PhotoSwipeOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeOnSlideshowStop', + onTouch: 'PhotoSwipeOnTouch', + onBeforeCaptionAndToolbarShow: 'PhotoSwipeOnBeforeCaptionAndToolbarShow', + onCaptionAndToolbarShow: 'PhotoSwipeOnCaptionAndToolbarShow', + onBeforeCaptionAndToolbarHide: 'PhotoSwipeOnBeforeCaptionAndToolbarHide', + onCaptionAndToolbarHide: 'PhotoSwipeOnCaptionAndToolbarHide', + onToolbarTap: 'PhotoSwipeOnToolbarTap', + onBeforeZoomPanRotateShow: 'PhotoSwipeOnBeforeZoomPanRotateShow', + onZoomPanRotateShow: 'PhotoSwipeOnZoomPanRotateShow', + onBeforeZoomPanRotateHide: 'PhotoSwipeOnBeforeZoomPanRotateHide', + onZoomPanRotateHide: 'PhotoSwipeOnZoomPanRotateHide', + onZoomPanRotateTransform: 'PhotoSwipeOnZoomPanRotateTransform' + + }; + + + + PhotoSwipe.instances = []; + PhotoSwipe.activeInstances = []; + + + + /* + * Function: Code.PhotoSwipe.setActivateInstance + */ + PhotoSwipe.setActivateInstance = function(instance){ + + // Can only have one instance per target (i.e. window or div) + var index = Util.arrayIndexOf(instance.settings.target, PhotoSwipe.activeInstances, 'target'); + if (index > -1){ + throw 'Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target'; + } + PhotoSwipe.activeInstances.push({ + target: instance.settings.target, + instance: instance + }); + + }; + + + + /* + * Function: Code.PhotoSwipe.unsetActivateInstance + */ + PhotoSwipe.unsetActivateInstance = function(instance){ + + var index = Util.arrayIndexOf(instance, PhotoSwipe.activeInstances, 'instance'); + PhotoSwipe.activeInstances.splice(index, 1); + + }; + + + + /* + * Function: Code.PhotoSwipe.attach + */ + PhotoSwipe.attach = function(images, options, id){ + + var i, j, instance, image; + + instance = PhotoSwipe.createInstance(images, options, id); + + // Add click event handlers if applicable + for (i=0, j=images.length; i= 2.1){ + this.isBackEventSupported = true; + } + } + + if (!this.isBackEventSupported){ + this.isBackEventSupported = Util.objectHasProperty(window, 'onhashchange'); + } + + this.settings = { + + // General + fadeInSpeed: 250, + fadeOutSpeed: 250, + preventHide: false, + preventSlideshow: false, + zIndex: 1000, + backButtonHideEnabled: true, + enableKeyboard: true, + enableMouseWheel: true, + mouseWheelSpeed: 350, + autoStartSlideshow: false, + jQueryMobile: ( !Util.isNothing(window.jQuery) && !Util.isNothing(window.jQuery.mobile) ), + jQueryMobileDialogHash: '&ui-state=dialog', + enableUIWebViewRepositionTimeout: false, + uiWebViewResetPositionDelay: 500, + target: window, + preventDefaultTouchEvents: true, + + + // Carousel + loop: true, + slideSpeed: 250, + nextPreviousSlideSpeed: 0, + enableDrag: true, + swipeThreshold: 50, + swipeTimeThreshold: 250, + slideTimingFunction: 'ease-out', + slideshowDelay: 3000, + doubleTapSpeed: 250, + margin: 20, + imageScaleMethod: 'fit', // Either "fit", "fitNoUpscale" or "zoom", + + + // Toolbar + captionAndToolbarHide: false, + captionAndToolbarFlipPosition: false, + captionAndToolbarAutoHideDelay: 5000, + captionAndToolbarOpacity: 0.8, + captionAndToolbarShowEmptyCaptions: true, + getToolbar: PhotoSwipe.Toolbar.getToolbar, + + + // ZoomPanRotate + allowUserZoom: true, + allowRotationOnUserZoom: false, + maxUserZoom: 5.0, + minUserZoom: 0.5, + doubleTapZoomLevel: 2.5, + + + // Cache + getImageSource: PhotoSwipe.Cache.Functions.getImageSource, + getImageCaption: PhotoSwipe.Cache.Functions.getImageCaption, + getImageMetaData: PhotoSwipe.Cache.Functions.getImageMetaData, + cacheMode: PhotoSwipe.Cache.Mode.normal + + }; + + Util.extend(this.settings, options); + + if (this.settings.target !== window){ + targetPosition = Util.DOM.getStyle(this.settings.target, 'position'); + if (targetPosition !== 'relative' || targetPosition !== 'absolute'){ + Util.DOM.setStyle(this.settings.target, 'position', 'relative'); + } + } + + if (this.settings.target !== window){ + this.isBackEventSupported = false; + this.settings.backButtonHideEnabled = false; + } + else{ + if (this.settings.preventHide){ + this.settings.backButtonHideEnabled = false; + } + } + + this.cache = new Cache.CacheClass(images, this.settings); + + }, + + + + /* + * Function: show + */ + show: function(obj){ + + var i, j; + + this._isResettingPosition = false; + this.backButtonClicked = false; + + // Work out what the starting index is + if (Util.isNumber(obj)){ + this.currentIndex = obj; + } + else{ + + this.currentIndex = -1; + for (i=0, j=this.originalImages.length; i this.originalImages.length-1){ + throw "Code.PhotoSwipe.PhotoSwipeClass.show: Starting index out of range"; + } + + // Store a reference to the current window dimensions + // Use this later to double check that a window has actually + // been resized. + this.isAlreadyGettingPage = this.getWindowDimensions(); + + // Set this instance to be the active instance + PhotoSwipe.setActivateInstance(this); + + this.windowDimensions = this.getWindowDimensions(); + + // Create components + if (this.settings.target === window){ + Util.DOM.addClass(window.document.body, PhotoSwipe.CssClasses.buildingBody); + } + else{ + Util.DOM.addClass(this.settings.target, PhotoSwipe.CssClasses.buildingBody); + } + this.createComponents(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeShow, + target: this + }); + + // Fade in the document overlay + this.documentOverlay.fadeIn(this.settings.fadeInSpeed, this.onDocumentOverlayFadeIn.bind(this)); + + }, + + + + /* + * Function: getWindowDimensions + */ + getWindowDimensions: function(){ + + return { + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }; + + }, + + + + /* + * Function: createComponents + */ + createComponents: function(){ + + this.documentOverlay = new DocumentOverlay.DocumentOverlayClass(this.settings); + this.carousel = new Carousel.CarouselClass(this.cache, this.settings); + this.uiLayer = new UILayer.UILayerClass(this.settings); + if (!this.settings.captionAndToolbarHide){ + this.toolbar = new Toolbar.ToolbarClass(this.cache, this.settings); + } + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + if (this._isResettingPosition){ + return; + } + + var newWindowDimensions = this.getWindowDimensions(); + if (!Util.isNothing(this.windowDimensions)){ + if (newWindowDimensions.width === this.windowDimensions.width && newWindowDimensions.height === this.windowDimensions.height){ + // This was added as a fudge for iOS + return; + } + } + + this._isResettingPosition = true; + + this.windowDimensions = newWindowDimensions; + + this.destroyZoomPanRotate(); + + this.documentOverlay.resetPosition(); + this.carousel.resetPosition(); + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.resetPosition(); + } + + this.uiLayer.resetPosition(); + + this._isResettingPosition = false; + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onResetPosition, + target: this + }); + + }, + + + + /* + * Function: addEventHandler + */ + addEventHandler: function(type, handler){ + + Util.Events.add(this, type, handler); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.isNothing(this.windowOrientationChangeHandler)){ + + this.windowOrientationChangeHandler = this.onWindowOrientationChange.bind(this); + this.windowScrollHandler = this.onWindowScroll.bind(this); + this.keyDownHandler = this.onKeyDown.bind(this); + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + this.uiLayerTouchHandler = this.onUILayerTouch.bind(this); + this.carouselSlideByEndHandler = this.onCarouselSlideByEnd.bind(this); + this.carouselSlideshowStartHandler = this.onCarouselSlideshowStart.bind(this); + this.carouselSlideshowStopHandler = this.onCarouselSlideshowStop.bind(this); + this.toolbarTapHandler = this.onToolbarTap.bind(this); + this.toolbarBeforeShowHandler = this.onToolbarBeforeShow.bind(this); + this.toolbarShowHandler = this.onToolbarShow.bind(this); + this.toolbarBeforeHideHandler = this.onToolbarBeforeHide.bind(this); + this.toolbarHideHandler = this.onToolbarHide.bind(this); + this.mouseWheelHandler = this.onMouseWheel.bind(this); + this.zoomPanRotateTransformHandler = this.onZoomPanRotateTransform.bind(this); + + } + + // Set window handlers + if (Util.Browser.android){ + // For some reason, resize was more stable than orientationchange in Android + this.orientationEventName = 'resize'; + } + else if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.add(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + else{ + var supportsOrientationChange = !Util.isNothing(window.onorientationchange); + this.orientationEventName = supportsOrientationChange ? 'orientationchange' : 'resize'; + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.add(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + if (this.settings.target === window){ + Util.Events.add(window, 'scroll', this.windowScrollHandler); + } + + if (this.settings.enableKeyboard){ + Util.Events.add(window.document, 'keydown', this.keyDownHandler); + } + + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + + if (this.settings.jQueryMobile){ + window.location.hash = this.settings.jQueryMobileDialogHash; + } + else{ + this.currentHistoryHashValue = 'PhotoSwipe' + new Date().getTime().toString(); + window.location.hash = this.currentHistoryHashValue; + } + + Util.Events.add(window, 'hashchange', this.windowHashChangeHandler); + + } + + if (this.settings.enableMouseWheel){ + Util.Events.add(window, 'mousewheel', this.mouseWheelHandler); + } + + Util.Events.add(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + + if (!Util.isNothing(this.toolbar)){ + Util.Events.add(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.remove(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.remove(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + + Util.Events.remove(window, 'scroll', this.windowScrollHandler); + + if (this.settings.enableKeyboard){ + Util.Events.remove(window.document, 'keydown', this.keyDownHandler); + } + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + Util.Events.remove(window, 'hashchange', this.windowHashChangeHandler); + } + + if (this.settings.enableMouseWheel){ + Util.Events.remove(window, 'mousewheel', this.mouseWheelHandler); + } + + if (!Util.isNothing(this.uiLayer)){ + Util.Events.remove(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + + /* + * Function: hide + */ + hide: function(){ + + if (this.settings.preventHide){ + return; + } + + if (Util.isNothing(this.documentOverlay)){ + throw "Code.PhotoSwipe.PhotoSwipeClass.hide: PhotoSwipe instance is already hidden"; + } + + if (!Util.isNothing(this.hiding)){ + return; + } + + this.clearUIWebViewResetPositionTimeout(); + + this.destroyZoomPanRotate(); + + this.removeEventHandlers(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeHide, + target: this + }); + + this.uiLayer.dispose(); + this.uiLayer = null; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.dispose(); + this.toolbar = null; + } + + this.carousel.dispose(); + this.carousel = null; + + Util.DOM.removeClass(window.document.body, PhotoSwipe.CssClasses.activeBody); + + this.documentOverlay.dispose(); + this.documentOverlay = null; + + this._isResettingPosition = false; + + // Deactive this instance + PhotoSwipe.unsetActivateInstance(this); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onHide, + target: this + }); + + this.goBackInHistory(); + + }, + + + + /* + * Function: goBackInHistory + */ + goBackInHistory: function(){ + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + if ( !this.backButtonClicked ){ + window.history.back(); + } + } + + }, + + + + /* + * Function: play + */ + play: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!this.settings.preventSlideshow){ + if (!Util.isNothing(this.carousel)){ + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + this.carousel.startSlideshow(); + } + } + + }, + + + + /* + * Function: stop + */ + stop: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.stopSlideshow(); + } + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.previous(); + } + + }, + + + + /* + * Function: next + */ + next: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.next(); + } + + }, + + + + /* + * Function: toggleToolbar + */ + toggleToolbar: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.toggleVisibility(this.currentIndex); + } + + }, + + + + /* + * Function: fadeOutToolbarIfVisible + */ + fadeOutToolbarIfVisible: function(){ + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible && this.settings.captionAndToolbarAutoHideDelay > 0){ + this.toolbar.fadeOut(); + } + + }, + + + + /* + * Function: createZoomPanRotate + */ + createZoomPanRotate: function(){ + + this.stop(); + + if (this.canUserZoom() && !this.isZoomActive()){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateShow); + + this.zoomPanRotate = new ZoomPanRotate.ZoomPanRotateClass( + this.settings, + this.cache.images[this.currentIndex], + this.uiLayer + ); + + // If we don't override this in the event of false + // you will be unable to pan around a zoomed image effectively + this.uiLayer.captureSettings.preventDefaultTouchEvents = true; + + Util.Events.add(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateShow); + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + + } + + }, + + + + /* + * Function: destroyZoomPanRotate + */ + destroyZoomPanRotate: function(){ + + if (!Util.isNothing(this.zoomPanRotate)){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateHide); + + Util.Events.remove(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + this.zoomPanRotate.dispose(); + this.zoomPanRotate = null; + + // Set the preventDefaultTouchEvents back to it was + this.uiLayer.captureSettings.preventDefaultTouchEvents = this.settings.preventDefaultTouchEvents; + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateHide); + + } + + }, + + + + /* + * Function: canUserZoom + */ + canUserZoom: function(){ + + var testEl, cacheImage; + + if (Util.Browser.msie){ + testEl = document.createElement('div'); + if (Util.isNothing(testEl.style.msTransform)){ + return false; + } + } + else if (!Util.Browser.isCSSTransformSupported){ + return false; + } + + if (!this.settings.allowUserZoom){ + return false; + } + + + if (this.carousel.isSliding){ + return false; + } + + cacheImage = this.cache.images[this.currentIndex]; + + if (Util.isNothing(cacheImage)){ + return false; + } + + if (cacheImage.isLoading){ + return false; + } + + return true; + + }, + + + + /* + * Function: isZoomActive + */ + isZoomActive: function(){ + + return (!Util.isNothing(this.zoomPanRotate)); + + }, + + + + /* + * Function: getCurrentImage + */ + getCurrentImage: function(){ + + return this.cache.images[this.currentIndex]; + + }, + + + + /* + * Function: onDocumentOverlayFadeIn + */ + onDocumentOverlayFadeIn: function(e){ + + window.setTimeout(function(){ + + var el = (this.settings.target === window) ? window.document.body : this.settings.target; + + Util.DOM.removeClass(el, PhotoSwipe.CssClasses.buildingBody); + Util.DOM.addClass(el, PhotoSwipe.CssClasses.activeBody); + + this.addEventHandlers(); + + this.carousel.show(this.currentIndex); + + this.uiLayer.show(); + + if (this.settings.autoStartSlideshow){ + this.play(); + } + else if (!Util.isNothing(this.toolbar)){ + this.toolbar.show(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onShow, + target: this + }); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), 250); + + + }, + + + + /* + * Function: setUIWebViewResetPositionTimeout + */ + setUIWebViewResetPositionTimeout: function(){ + + if (!this.settings.enableUIWebViewRepositionTimeout){ + return; + } + + if (!(Util.Browser.iOS && (!Util.Browser.safari))){ + return; + } + + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + this._uiWebViewResetPositionTimeout = window.setTimeout(function(){ + + this.resetPosition(); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), this.settings.uiWebViewResetPositionDelay); + + }, + + + + /* + * Function: clearUIWebViewResetPositionTimeout + */ + clearUIWebViewResetPositionTimeout: function(){ + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + }, + + + + /* + * Function: onWindowScroll + */ + onWindowScroll: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowOrientationChange + */ + onWindowOrientationChange: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowHashChange + */ + onWindowHashChange: function(e){ + + var compareHash = '#' + + ((this.settings.jQueryMobile) ? this.settings.jQueryMobileDialogHash : this.currentHistoryHashValue); + + if (window.location.hash !== compareHash){ + this.backButtonClicked = true; + this.hide(); + } + + }, + + + + /* + * Function: onKeyDown + */ + onKeyDown: function(e){ + + if (e.keyCode === 37) { // Left + e.preventDefault(); + this.previous(); + } + else if (e.keyCode === 39) { // Right + e.preventDefault(); + this.next(); + } + else if (e.keyCode === 38 || e.keyCode === 40) { // Up and down + e.preventDefault(); + } + else if (e.keyCode === 27) { // Escape + e.preventDefault(); + this.hide(); + } + else if (e.keyCode === 32) { // Spacebar + if (!this.settings.hideToolbar){ + this.toggleToolbar(); + } + else{ + this.hide(); + } + e.preventDefault(); + } + else if (e.keyCode === 13) { // Enter + e.preventDefault(); + this.play(); + } + + }, + + + + /* + * Function: onUILayerTouch + */ + onUILayerTouch: function(e){ + + if (this.isZoomActive()){ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.gestureChange: + this.zoomPanRotate.zoomRotate(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.gestureEnd: + this.zoomPanRotate.setStartingScaleAndRotation(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.touchStart: + this.zoomPanRotate.panStart(e.point); + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.zoomPanRotate.pan(e.point); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + this.destroyZoomPanRotate(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeLeft: + this.destroyZoomPanRotate(); + this.next(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeRight: + this.destroyZoomPanRotate(); + this.previous(); + this.toggleToolbar(); + break; + } + + } + else{ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.touchMove: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + + // Hide the toolbar if need be + this.fadeOutToolbarIfVisible(); + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.touchStart: + case Util.TouchElement.ActionTypes.touchMoveEnd: + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.tap: + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + + // Take into consideration the window scroll + if (this.settings.target === window){ + e.point.x -= Util.DOM.windowScrollLeft(); + e.point.y -= Util.DOM.windowScrollTop(); + } + + // Just make sure that if the user clicks out of the image + // that the image does not pan out of view! + var + cacheImageEl = this.cache.images[this.currentIndex].imageEl, + + imageTop = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'top'), 10), + imageLeft = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'left'), 10), + imageRight = imageLeft + Util.DOM.width(cacheImageEl), + imageBottom = imageTop + Util.DOM.height(cacheImageEl); + + if (e.point.x < imageLeft){ + e.point.x = imageLeft; + } + else if (e.point.x > imageRight){ + e.point.x = imageRight; + } + + if (e.point.y < imageTop){ + e.point.y = imageTop; + } + else if (e.point.y > imageBottom){ + e.point.y = imageBottom; + } + + this.createZoomPanRotate(); + if (this.isZoomActive()){ + this.zoomPanRotate.zoomAndPanToPoint(this.settings.doubleTapZoomLevel, e.point); + } + + break; + + case Util.TouchElement.ActionTypes.gestureStart: + this.createZoomPanRotate(); + break; + } + + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onTouch, + target: this, + point: e.point, + action: e.action + }); + + }, + + + + /* + * Function: onCarouselSlideByEnd + */ + onCarouselSlideByEnd: function(e){ + + this.currentIndex = e.cacheIndex; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.setCaption(this.currentIndex); + this.toolbar.setToolbarStatus(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onDisplayImage, + target: this, + action: e.action, + index: e.cacheIndex + }); + + }, + + + + /* + * Function: onToolbarTap + */ + onToolbarTap: function(e){ + + switch(e.action){ + + case Toolbar.ToolbarAction.next: + this.next(); + break; + + case Toolbar.ToolbarAction.previous: + this.previous(); + break; + + case Toolbar.ToolbarAction.close: + this.hide(); + break; + + case Toolbar.ToolbarAction.play: + this.play(); + break; + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onToolbarTap, + target: this, + toolbarAction: e.action, + tapTarget: e.tapTarget + }); + + }, + + + + /* + * Function: onMouseWheel + */ + onMouseWheel: function(e){ + + var + delta = Util.Events.getWheelDelta(e), + dt = e.timeStamp - (this.mouseWheelStartTime || 0); + + if (dt < this.settings.mouseWheelSpeed) { + return; + } + + this.mouseWheelStartTime = e.timeStamp; + + if (this.settings.invertMouseWheel){ + delta = delta * -1; + } + + if (delta < 0){ + this.next(); + } + else if (delta > 0){ + this.previous(); + } + + }, + + + + /* + * Function: onCarouselSlideshowStart + */ + onCarouselSlideshowStart: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: onCarouselSlideshowStop + */ + onCarouselSlideshowStop: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStop, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeShow + */ + onToolbarBeforeShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarShow + */ + onToolbarShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeHide + */ + onToolbarBeforeHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onToolbarHide + */ + onToolbarHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onZoomPanRotateTransform + */ + onZoomPanRotateTransform: function(e){ + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.EventTypes.onZoomPanRotateTransform, + scale: e.scale, + rotation: e.rotation, + rotationDegs: e.rotationDegs, + translateX: e.translateX, + translateY: e.translateY + }); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.Cache, + window.Code.PhotoSwipe.DocumentOverlay, + window.Code.PhotoSwipe.Carousel, + window.Code.PhotoSwipe.Toolbar, + window.Code.PhotoSwipe.UILayer, + window.Code.PhotoSwipe.ZoomPanRotate +)); diff --git a/photoswipe/error.gif b/photoswipe/error.gif new file mode 100755 index 0000000000000000000000000000000000000000..6a96f4d61b7b8f63458103f934473dc5bb9123e6 GIT binary patch literal 3431 zcmZ?wbhEHbRA5kG*v!D->+8E_%^FEb$(ov)&6_u0x^$_qu+Y%Zu&Jp@OG}H3i_6Z= zZvX!MXU?2qU|_g;^QPi|?g-xi1((EJTWZ)~7zXkle&WMycf00l~RTnaWtDQQ+gE^bikfIM5JjFOT9D}DX)@^Za$W4-*M zbbUihOG|wNBYh(yU7!lx;>x^|#0uTKVr7sK5Hnm-i<65o3raHc^Atd4CMM;Vme?vO z0p%57e#tF>8=hCJ2lkgJ3rU7i8p@`0v<(cc3=H6^ee+W?(<+Hp4UFFuVCo@8 zeM+)bT7FS(A~1*(3kq^FlM_K9uV0pz0u5KVhry14^Q@fnbMlLT?gF~s7){F4**Tyn zKP@u{C|4Zh?xf)9>TG6cX=bKtq-Ut44@xci(BuM4srvAw3Q7aC2cwpd6vm^$H5yzb zg#by4M^o2maFG-OBq<(ET|+ClxDbuq)I4Adw;b4%W&Ho|@1Nhle*XCW?dzA%pFVzg z|L*OZ*RNi_c>e6^lgE!9KDdAH?w#AWZr-?l?dp}wmo8p7f9~v=)2B|JIDYKtk;8`$ z9@xKc@1EVecJA1|ZR?iJn>KD(zi#cC)vH#nSiWrOlEsS_E|@=W?wr}PX3m&CZR(WC zlO|5+@9XX9?&|DlZ)=-aG z=zs`NpMrtq|AmvDccm1kOh3LV;RT1s=Q$a-6q-1++Gd_xwQ$EIfeU|Rwk%>|eknaqbN!V- z=CoXO22Y+^1{T7KP92v=z^a@NEjlvcvEDCF0rnGX#YU7l( zQwo=ETt3;Bcb@vDS?i*vZ=aRDg`-z%hw`Zd3|y;QSG1q%(qJ_|q@EzMXl7bQqw==f zv#(9!Vkz{Gt9)9RTCb5M{31TYmX-UZCQD5AHlGTU3&xHf2jtwHK63qV7Uqd?;kuzP aZL!NlQ5H?D9RdmRjSO-ue_A^j7_0$ekM4y4 literal 0 HcmV?d00001 diff --git a/photoswipe/icons.png b/photoswipe/icons.png new file mode 100755 index 0000000000000000000000000000000000000000..c4011d1d0cc4fe3338ed01ae89be440a4cce25cb GIT binary patch literal 3346 zcmZXXS5Omb6NWj`YXSsB5ClOJRC){jfCLcfARtwG?+5_`(n~0UAVqpplqyA{Ktw`} z^eSBfp(-`h08xIOb1u%zfAQ@;vwQW;?7r`8vZ1~fGXpmR1qB83J#7u+-?{Pkv!J8- z9UqiNy#1Z71i>tVOnhB}LhJ*aDb$>N9h~{^dE2`>8#~)Oh5Gk8D^XA|wcOKCGlkD? z*;sj5n{y~19FkZS0dt|CeYe?!Y}t{ULVB+?mcUhdDWt`UTherO4KlI zY5}2zr%1Dw=Q{4dJxcA7oDr0mkq(>5T=}O^AWqLA+-o?tbM>+G9PT7NOHpclD6X@z zu4n4F=<$@zNnz)(vI^KpG&fCs^o{l#Dh8QG^)ebW$VAtFD4yHm-`XFtND7J_YEQim zlYmLg^-PsiZM@p(o?3_K8xOPq@$7oF{+QFr@h;y|IM1(Enjw>`RnWhQAgogs-JI6j zTn8|$L2yqP84LQDFg@6PB8%iDJprd15TctA2C`*nHAG1nyqpig{x~n~T?`=>Bxl@W z0ut6aCTp9J@aB+6O`_8PVL_c}i~I@-WWfvZDMdD3+$S<}3F^=5_|v8uR(GEWkyJ)6 zow-2LV|RZ+nL9EG;~?|WRuR+Q)@D@RHDe|2EL6yK2H;c@ZJGe~OBWZwhzz-j-c7t> zjaF+!%z#wg1tL5NR`*%kkOW&~e}b7^hjd?8M`0WAWLVc2M;ex*-ajvfE+=*LztVV zoPNHO@Rhlgh3>CYNkLmUx0NOV#MGJeo(r;Vc}?m&Eksk8PZQZy84gJ|L?k;T5uSpE zm!#x~K!kX!5Oew1p~b!) zIgH97UB^OOLQZ#%+!uL97(kvc@Zb$@NZ&F{`CPiLFte#9$oR}ce2_>kUps3^!sHVFR-lqIluLAcw!4IWJ zog-+$s9ow!p2u9?H5<1`7<_c%lFEwAQ-%0heV{KUKF6>sfSYI;OKqD5p*v8atY3zj z#i1Pa1wIryP^Qluq{7#D64a2n;yOgWLyyo=&*_6y**ss>?zQ(`L-emcb6p0khL>wo2;7n+{emdU z`BXCX)4Ii4{;u(t3f%JH76vr6e9{Ni$_1lsNY-eal4;nZWc(E^z&qX#RWFu+hAY*_Q2as<7d>!+hUFj}dy ztv7D?$|JN~8QeC-)Zz2{hKtYdxzik3@Pqn*A~o;KPg4!ANT46p!v4xy6?xpnC)gRT!)tFKA-~bfsv>$jp%4!F9$bcU>)Sa_bL?Qp*-%<6AHWY$sa0A z-&gN4bTUPTJQ+Zwjc574m5ovm-rWdSxP`Y|Q{S^fH6&l!rc1yo6e>xkls)%Z$wOp* ztRxk$t0z)-@Q7&ieoya*7W?zvQcPTqRHE`fXg#=xe863Km2_4-5h#VlQ69EpvacLY zV<{p&a(wN29UUEA9f!+ov!-Q>;5TLB_kA@%gpvQkSlk%C1W@bpg#8fIx?$`>bYe%> zCuaQ0<01uY2Bj@p)sA^SL<7pB_tFGMMt(2-=u2Zd{Fk#yM}-@VWTQ%2YLieS`^12; za`nhm!mBm%XDH8%@z&il{?l2`Py4GUCxATCEAYG7Af3n?2(YGh_o1HPD(QW4s6rJC z@P@Ey=p3vz?G9X()BK42I2aYlbhIVT2yQXxMp+w@`%E~VsB8q1f)x;e@|SKo^xK8& z3!J69@@2crM0dET>29vM$x{%cCsJ#G`Wy&Y>DVz-@h z)jiDieyDXo+iV_W=61aBaTw}ri>6ttqY{-kurls_P8TY}X{!hy=xM+Cf-0rY^F8s6 z#Ey?fhX+#w-vQFSm?JDtOl;)aHHRd2y)RQgczSY=caNgy(851J?n|)V~rO*g|gih~!u0hP0|*lO>AiaK(!ikgi>bAv}c%sLj>R zn_-U@LSqkGxee|v$5i+ao@vVX0Rk2-Y5R!=a(>&!>p6di zFMyYQ#fdd8k>1l(`)h;62Tj4v@UMQN(=7bHx~A?k0mW9W;^+!DrUdL;e)Kjp(E!bR zzcK@}*PV))`_Vr7DtaovFOrQus5xf>sH;R1I9=q5y1p&*T$%4|u)Cws_iGZxg-;M@3YFxpdh@79*Pmeu5$u$x%x zotQs1a+FXDio5TYHuEKxUup&9QDd}K1$!_XE$uLWH{_00qI80PvCQ-MoPJ=)*!N4# z5Yv8wlB?1IGbNy?NPXB(KCHDI1wK}CRo>U@Ds0x@EVw)sNW+Y4ec1#Ka*7ydErEt8 zR$bDyj*+M&bwZAfhy2?s^eZyeK*W3{uY(wjGfRh!Uw;$NRIbF*oVE;d*SIkaYc#>J zsX@s~i~dNQi~WwuKeqG-V6ie0clY&ZNA;2>g!z6eB1b) z1@ef`@pkNPC8iDc{h`R^@Kl+FbOjH6YXhN(ir^(j2deVaHx}u#TRo`7U?ci#YDA}+ zvGHOmQ9@vrzF5=MoA1uC9I#!&j&F|osA*Di1DTI!HB9Q`OjtW4X8t^Eo|M0`ye~q% z;nr$HKWGlE^LC1;;Lf{!oJCrsLMBon`K%iK!~BxP{oATHPOnD{NpMM|*qMSxsCU&Z zjq1yd7Dz>o;xWUz3Ytr8X1*}M<>Ma<`@G5d4F$VCQIp&0Mp=70LJ^+%jBl?xxbUw~ zC1538h!kY1{o-JRw;i0+L$hLo%^;L<`BAbho)@~_jU(#4SZuQq#jmGb+*2+bvv!PW z!-ymoqpS_kt*MuEOMy)dwB|4Rpbc}_!%{z;vg#Dard~(_eEyVb64*=Oy@iowW5?fR z!H=;i!}@yU1ighc@Qt($qKHk2q9(wpMH_vwN-mH?a@X>riTH7}ZLY~%W@-GVSB-cY z58KIMk6D5KdwN0E?Q$8PJoM4*Ybi#@S`K#&wmK6Q`@K>SZne9edJKwgXwG3t3QhQA1*C@AOHXW literal 0 HcmV?d00001 diff --git a/photoswipe/icons@2x.png b/photoswipe/icons@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..87b63455d6822aa6c8771e9bb23f1cc77bbf034b GIT binary patch literal 5445 zcmb8zc{o(>-v@9KQnV0ZY^f~KVws_kvPPD^WZ##u?~!F@NVbw)p&|P&Ms{IFDfmC_xtgP! z7#Qu3+qI`yj<+%r4cO!03)D0ZH1>4~40Z?rGdytibp(s(cssa)jld4hq5gefWd??e zOF9}4o`g*Oe$SC0I3Co4$ZT|iboh5FhIo7VCS10+j$%}>$7;G~#}`)WK7Ke_c|q+$ zLFz-*wER+U-ICE^d7UdS$3)JUl3v>vjFI^D{B)!K^KXjw^SqF?3FnT1 zunxp7^*!5gwgQ-^WCqWMJUE&A`CI z{;%^nBh%mh|0X+!N0c~{{9_WEr_7z5aueAAPN1D>MW1=@!-S#1y5kcjpo|G~Hzy?W z?6hJjg4OHy$B*hjRt1>ZG;dZR$pLK@s^aF9NmNSm+QtNH6^)b^ws?A5yUz1-gV`NFjyN3`;~cE3XNYBz!U9&X85pV6QnN<<~cc^v@$KE7rFvE25p z+XWDJdoBd$G~aBpEdB8H8Y9p-Bt0A;T<7mJWSeX~bBO6SYkbS@OQb7-e0nQL(L}m0 z$X5Hu7qS`Upo!pnjZz)Y_{fav1Y$Weg(HKI4?};k1H7O!AHSuPYVLyp$)bo>T(=;| z<#b*hZf4(_*Y>+);0-d{|>6{*$SC{5^)^0q#2zSX}ry()+zYb32( za$?^(`s!xY(BP6CbxMuWsb-|@Fy(@kwvTh(@k0?VGbE;oIk^ZJzu%}t(f(YU{=P^O z?;33CZT8sFp{be~Vg0PmCz;xl88JH69w^ycG?HF0kHm#pL`^HwU)d2Jw51*3Rb-gV z3R9A+2}MrIL||jxI;)i0Z&i3FdjKh75tQ^igSqLdT zqnQL~uZf6K(uckqT-wwt+eh~^Rqi>DQ?|jKqhAE|Hd|u^^{6SY?9dX`ds>SrDdwra z-y4&?(MJ>V zSc)F~eFFhtbKZFf?_01u z`jpTJfq3Nmj(91cx%a!J0*>bb@YfrDofXgF%WAH zew8>3Krt!wFv-14x4|JP6lV|cl+tH4h-K_BUM_#Bi+Ftjfq0;ZRjU5_SU7+RrA#I( zLYMsRvq>jA>heEH***N+ZMVuSb=G41x6`%#j7K&;dLcB7G(5sI%a?_mZfl2)&@f^LH)bHvgALnc(E+2lRZiT|(pkcESX8X?S2>^D z4fQYw9ZSpgcb%LeaXYtZ0-Q!34qFlhg{)V4RB|4Jmz7+$&^f6y9X1?_=bRWpB8P_L z(q-VyudKzz&!U_T!^o_8H|B1ziMNeS2a{f~b1M~NYmt}q{wSTj1)x(WeIr}Ovr6C%@1qaF$Zg9AOph$<|9{>T;d}_eB_yyS$as`Kp|FU7=P`4d5rdIbIgf5EdU+zlfpB%F-EU8EPM#OY;0<+_43>?+7OBm33$>_{Tr zK5{yq0(0n4)f> zmjob+n7We=4JS9vauExo9eX|eS-yb3yocHaFd3wm73Z>5a%%&=K);Q>MnJ~QcAnayDF^Y|>N7@aQ6*!X8d9?N zFF)Gg2y~~@$Cl4!hlw`s_}~IRwhk`b;B#-EafuI2^EDa>Hr5aGS$oKT>$GUZ0LcEb z<-79bp0tMpdPJA`Qe3aPtg1u2pdzO}NwR9%RA#{gFH8?W%dJuJ)Hw624zB#YjFH^Q=Lot4l5gJic${=62$9vTnV4?pz<2UjE{ zLwmYW@C{Stfozm82py!iwSb^p6{@yd&81akkC z!X=LY?P@2!uSy>f(_;c|sU@yW#OvTZZraf$V%62v0owH{wZ1QR>zcYw)!kWv#1Pvw zto+VUwzCM8?Lv=XMU7%2F!eQEOnazAKOXGSU%e-lSf^q#guf2B&2axaMTGHRv+WND z|M1Sfli|P4KbrhA?!U?ZLZ1xA%kNowsHOnlk22V9JwQ6hV47Ny=np`UT>}XMfTd~0 z;cjKXQ?J2MtPH?+g11q|alSn93P>ykZGmS7(Mp$vCroxV!Z^KMnqJdQcreFbUSurm4MZN;SbXJr>?lvj&?sULY6(jU#6_- z9>yaPl}K@!xsZ&>7LAyp7Y*@wjhjvZ+tMzTHBn-AlR9aO+Mrylscd@%Ny%G!xPnwn zr02j{E@q<&N%zor-DN9ori_}6TW+ldr@|eblonsfJ@ov2x`#&{&a-(FfDl1gI65Ut zHsy%Z)*Jj8Lfg_%j!2~j>^~5u4AU+TBO5b-Z%IaKHK^t81o2#)NS?!}9<^%^-BP&R0tXTVx?iit+dVKe}Ui|It z8&CPCJkAlMtbZ(;>TCnM5*oFPom_j z=N2cL8$=0X_wkK<+voxQV?quNRv-o~@^TDlG|(KM$N9A#sq`|GCwx0gJkiP@+8nNp zq(}Qy%?c|}YG$sddpDSC#WceS*2E8#ANdzQ_7~@^i4^^IVqR}E+ZC40%!1Yn7Bg<5 z#HKIS8&S5sJB@C6DU9pYSQ@^oFH0;DESRazOH?eFh9|7xa)jNscB+syy^E*X6Azz^4lN!EHK+>P(5c$IcR119Q+rKj4HX` zDK^#{AVYUUsyz#=WAXS(2K?YR!qDnh!e1{G&6e1-#vbnCqH6{l1=9lk?b)Qk+?iAF z24CY`KGomXX~@uiznwUL{HsFrGw~G*Aw~AovT+z-K4gANsC^vl4}i-Ek5i}oj+u3OFSmy!E$!R z?qP;kW6=0_MWheYJ! zKYBV*r~lE1W!u*N;+02>r&A9hhQYA{&zVI|)MsPZ*RnqK3zXehyYHuU0WD z6aC&k1>#M)aBF{gII0|`bF)d7);89)xqtO`lmu%w|R6S-&Dm;<2n9t_PaOYF`#eNOf+kdW^V6nSlo$4|K@fX$pe=sK8tGgkcG$B7~yYjf%`giGo_fbrxRL0Mheuep_wR+9_*V4VGN*cmD&Wg}Ma~HVm zmfnu+RW&@?Z@NfO8jl7uW?6hnY)K7&S1RlC1)SUmYI7>hxU!|(B5w(u$tUr#oW|`& zud6ygdk3vg=PAGB9NIL!BD-~5Q2BWfTO#DmN3~7Wvvi%-GY@uaR3|2^>Q0a_d{%SI z*=Iv>KM(nrr7qQY9v_oSQps_jJOQ$Nk@B_`TB9L0o4p3SjbBzHe^`PcAO9s`!Ex&e z7a3?78-gR>i|fCAyktzc@!3~xK9&0lnA%bS6T4D+xJ(VQmh?J8J{KYBjh?pRxn#GO zh>Y*{l8q-vbWzWiXrCGmxTdCrfZH0SszKz^*9Efa&CbrXWuZ0!9M0EoPhIFAv|fHm*gE%FVn& zy7GSCS1Fs@pY^%^7*zFwQTySeU+=|^5*dBnsv;L)Toy@NoS2+9xxw!-nT@X%V?Ve8 zMQ;MpjTPiK+hQhm6*75hKkB#4C^m4ph;P4bEB9t?eGqLQ6bdwi;)yfq9)s zFG7Fgb>7fn(YDp@Hm6xqg4{1?2fxtq4n4`|w1Q2G_B@Oi7N~SQG(|tRN-eYQm8;{a zlo|GR7aS15l{Y=J!z`3&W(di!TEsl+zenCaqEk%Lw##VOF9BN(k51jF8>Ge8)B|ya zca%zHMhi(N>+S%@H1K50t>9dEfahVqKDTyN4$1^%&+t5d<-rLC26kQs2BzcE-@nYx n=f`S1?*DJI{PfYSP6jDGGYG-Z=kak}ltD++K%+*@{>A?Q9}A#= literal 0 HcmV?d00001 diff --git a/photoswipe/lib/klass.min.js b/photoswipe/lib/klass.min.js new file mode 100755 index 0000000..294fe70 --- /dev/null +++ b/photoswipe/lib/klass.min.js @@ -0,0 +1,8 @@ +/** + * Klass.js - copyright @dedfat + * version 1.0 + * https://github.com/ded/klass + * Follow our software http://twitter.com/dedfat :) + * MIT License + */ +!function(a,b){function j(a,b){function c(){}c[e]=this[e];var d=this,g=new c,h=f(a),j=h?a:this,k=h?{}:a,l=function(){this.initialize?this.initialize.apply(this,arguments):(b||h&&d.apply(this,arguments),j.apply(this,arguments))};l.methods=function(a){i(g,a,d),l[e]=g;return this},l.methods.call(l,k).prototype.constructor=l,l.extend=arguments.callee,l[e].implement=l.statics=function(a,b){a=typeof a=="string"?function(){var c={};c[a]=b;return c}():a,i(this,a,d);return this};return l}function i(a,b,d){for(var g in b)b.hasOwnProperty(g)&&(a[g]=f(b[g])&&f(d[e][g])&&c.test(b[g])?h(g,b[g],d):b[g])}function h(a,b,c){return function(){var d=this.supr;this.supr=c[e][a];var f=b.apply(this,arguments);this.supr=d;return f}}function g(a){return j.call(f(a)?a:d,a,1)}var c=/xyz/.test(function(){xyz})?/\bsupr\b/:/.*/,d=function(){},e="prototype",f=function(a){return typeof a===b};if(typeof module!="undefined"&&module.exports)module.exports=g;else{var k=a.klass;g.noConflict=function(){a.klass=k;return this},a.klass=g}}(this,"function") diff --git a/photoswipe/loader.gif b/photoswipe/loader.gif new file mode 100755 index 0000000000000000000000000000000000000000..c95d05a053b2272a04f2d337277705303a372501 GIT binary patch literal 3208 zcmc(iX;4$=9)}M(OO|u=>N&wC1Zq$MLM;Rp8a5RI1PI6?AP9)Ws35K^0zn`wApu!K zSOZD|i6L4MaRIFsK?-Vdur8>*dV#hsxYx1QdOOz(wsx5N_0IIZAI^s}?>lFn=l%VE zGe_X>%X3L!18m?mFtgsjf6wFbBoc|ApPyJP9v&Vx7!20d)@EjAUS3|~CEYwj{?xcdBgrm3A(9~ha#cOs>K&GZ3`oLs=|*iCF_>0owVaRIXGO}q1|mM zsk!himr0uEW;Mv=n>5>#{Ov4%^W!h^Ts?o62~=pg+$G%UOzbtDtznM5b>oHSCytBh zIs+N{0$F{6xhTdl63$C6^i*+Z?NKqmp2-UDtfjO=nd58A`Q>kF<1KG;mLy zOygAhrIzeZiFWtPv(G06OHS8O&nrb=6YI@HL%}{aw1y8lOlGrB&9FzePmLUk_I0AS z_*UJ}h9Lv0a1ldrCO~$!@9B|1V~cpg?4`9VdPgSfQH5#%Glkf(7@fYlfr(3}E|@m4 zDbO*-l!(+D~sT2_a)<4~u(?NnXN0dD;n)>ncP)hvTPq*&674<%kYuesQeEa}IS z%<3;uvMO4yT~6F5xtXXG+$)-l9MpE^KL(!lK8Z~v9>#Q5ya0yU6{T;iYd@=QU3cJ% z)4Xx!uqEjae9~&9_b(YEtbLM|c061I0O!_+*+NqJPOrMB( zEp_ahtzq&6Rk+u@JMD9ciSxTx+MKFw-%NR9rD$BF0O_&v#XgRFlbzCw74*VOxnnnh z0OryKe_!gEP)jkIwM1lWSYhJN3AuNlGB+I!U9fyPDVv**Bsqr51n|}j^Q;^WsNmRy zHMbC0s|JOs6|yo9jSz3{lXoxgxxHfZ z$mc=*?SG~pn$7;<`t1x;BQ~}^I&oZW6~WLCgoIH&DJoaXFaIS;Q5MuRi!y5FaGa%! z1no=2Rxyj@%C`YspZ57Cep!Wp2{Xn`7Qz?BL}a61yp4&g7g`;iGA!bq>1` zvcNhx%^OaLH&2DKEVg^w1T{1gXmiURYH8Z0h87*F(KhN)QLA=YQ zDd?H|c=Whi>Fr~Lv_b4%!wx1Dq(%MgzQ^XX`CfDXyncALg4Z(z5Y{nW0E+@R?3TJJ zx<>C4y53lI6#ou?5hzxc{`2$bqk7t##DcoyN1>X1(jwexA{{@Et%!c>PcJkvJ={uy z*31#DL*?bt^lG`2n)ducO2IGGBb+P|>ywomIHX+;DSIupyVwLOYY3#Sp6s@;Sng7P z5K%YRv?7hNHkHu@lyb_=VH5@TC%JTYBQ3ar&8LuiQSzcv-;Qs$ZQW!W_gfJM}cjs3F}|Kro=A9&gAff+fA#GY&+GOg1%?5KBHAX zTT=2IBZ8OR^QJb&r#SonBBE*9f4XteufB;#^{RKH9zU|khGJ}9|NY&xb4ro9RJfRL zBUF?SU|Bhwk+Vust^%u-!dkF0N#b1E>I!BS2q6T4^E~+m1NoqJj!Pc-C_+w?#9F{; zEOg3X^mbynWr8T$OTdP%(0uU{>=r=1f_4el;kPjSGK!Q2d5sgu6;R=S;xP{0RRnpw z!pT?KS*gU^$)0mO?*x-VSQ9|sxH?b({n3Qv+59j53VwlvF%7J!)ws zF|VOGJUCQ>UhN0&5#+&cA$avZ{s`|GRQ!lNefZtu!A$e3$dX}o$avG-C{t`HW%%)} zf_)B)K2{-Rwu6`dCkHZD3c1MBVS4sKehz~Lp?ZCBdMtr-Vn{cO1SaN)bb1u_?l*%# za3F4>2dp;`WE3?Z(-{~B^CNAqqs&_fPPM?biT4BHBeV*5gFpL9 zsF!Ke%c-aFAv<#}w`%RD;N`SGJCQnD!e257(?Nhytg5<1;zX;i$7)pNl?|l_`7&23 zI3of@;SVAZqj5$Axf>;)X8BBe=rAJA0A9DCS%B0N;yzO^v zokoB;Q%RRU5k@iec;VC5E~UM*R(#CB$|WI^n#4Q(baHw+ImN-59p!`+`n$y!o2Q|0 z@M0focCcElaET-%+P3BcE^UStEe9BorlYw_UGElI$9JHCptRSS!J?cUXvnoYhuaLm zrDj397WUw0&cf22SBFFkqxwNtJU8yMNV}08rawVUVf=XTwG<)ns(a09dtgd^P5dj6 gdv(vK{>OzxzB%r#C41f4k5ZhbC%|pyKj6dq4_Q#F=>Px# literal 0 HcmV?d00001 diff --git a/photoswipe/noutil/code.photoswipe.noutil-3.0.5.js b/photoswipe/noutil/code.photoswipe.noutil-3.0.5.js new file mode 100755 index 0000000..11055c6 --- /dev/null +++ b/photoswipe/noutil/code.photoswipe.noutil-3.0.5.js @@ -0,0 +1,4344 @@ +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.EventTypes = { + + onLoad: 'onLoad', + onError: 'onError' + + }; + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.ImageClass = klass({ + + + + refObj: null, + imageEl: null, + src: null, + caption: null, + metaData: null, + imageLoadHandler: null, + imageErrorHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i; + + this.shrinkImage(); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(refObj, src, caption, metaData){ + + this.refObj = refObj; + // This is needed. Webkit resolves the src + // value which means we can't compare against it in the load function + this.originalSrc = src; + this.src = src; + this.caption = caption; + this.metaData = metaData; + + this.imageEl = new window.Image(); + + this.imageLoadHandler = this.onImageLoad.bind(this); + this.imageErrorHandler = this.onImageError.bind(this); + + }, + + + + /* + * Function: load + */ + load: function(){ + + this.imageEl.originalSrc = Util.coalesce(this.imageEl.originalSrc, ''); + + if (this.imageEl.originalSrc === this.src){ + + if (this.imageEl.isError){ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + } + else{ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + } + return; + } + + this.imageEl.isError = false; + this.imageEl.isLoading = true; + this.imageEl.naturalWidth = null; + this.imageEl.naturalHeight = null; + this.imageEl.isLandscape = false; + this.imageEl.onload = this.imageLoadHandler; + this.imageEl.onerror = this.imageErrorHandler; + this.imageEl.onabort = this.imageErrorHandler; + this.imageEl.originalSrc = this.src; + this.imageEl.src = this.src; + + }, + + + + /* + * Function: shrinkImage + */ + shrinkImage: function(){ + + if (Util.isNothing(this.imageEl)){ + return; + } + + if (this.imageEl.src.indexOf(this.src) > -1){ + this.imageEl.src = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='; + if (!Util.isNothing(this.imageEl.parentNode)){ + Util.DOM.removeChild(this.imageEl, this.imageEl.parentNode); + } + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + this.imageEl.onload = null; + this.imageEl.naturalWidth = Util.coalesce(this.imageEl.naturalWidth, this.imageEl.width); + this.imageEl.naturalHeight = Util.coalesce(this.imageEl.naturalHeight, this.imageEl.height); + this.imageEl.isLandscape = (this.imageEl.naturalWidth > this.imageEl.naturalHeight); + this.imageEl.isLoading = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + this.imageEl.onload = null; + this.imageEl.onerror = null; + this.imageEl.onabort = null; + this.imageEl.isLoading = false; + this.imageEl.isError = true; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Cache'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Cache.Mode = { + + normal: 'normal', + aggressive: 'aggressive' + + }; + + + + PhotoSwipe.Cache.Functions = { + + /* + * Function: getImageSource + * Default method for returning an image's source + */ + getImageSource: function(el){ + return el.href; + }, + + + + /* + * Function: getImageCaption + * Default method for returning an image's caption + * Assumes the el is an anchor and the first child is the + * image. The returned value is the "alt" attribute of the + * image. + */ + getImageCaption: function(el){ + + if (el.nodeName === "IMG"){ + return Util.DOM.getAttribute(el, 'alt'); + } + var i, j, childEl; + for (i=0, j=el.childNodes.length; i height){ + height = Util.DOM.windowHeight(); + } + + } + else{ + + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + + } + + Util.DOM.setStyle(this.el, { + width: width, + height: height, + top: top + }); + + }, + + + + /* + * Function: fadeIn + */ + fadeIn: function(speed, callback){ + + this.resetPosition(); + + Util.DOM.setStyle(this.el, 'opacity', 0); + Util.DOM.show(this.el); + + Util.Animation.fadeIn(this.el, speed, callback); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Carousel.EventTypes = { + + onSlideByEnd: 'PhotoSwipeCarouselOnSlideByEnd', + onSlideshowStart: 'PhotoSwipeCarouselOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeCarouselOnSlideshowStop' + + }; + + + + PhotoSwipe.Carousel.CssClasses = { + carousel: 'ps-carousel', + content: 'ps-carousel-content', + item: 'ps-carousel-item', + itemLoading: 'ps-carousel-item-loading', + itemError: 'ps-carousel-item-error' + }; + + + + PhotoSwipe.Carousel.SlideByAction = { + previous: 'previous', + current: 'current', + next: 'next' + }; + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = klass({ + + + + el: null, + contentEl: null, + settings: null, + cache: null, + slideByEndHandler: null, + currentCacheIndex: null, + isSliding: null, + isSlideshowActive: null, + lastSlideByAction: null, + touchStartPoint: null, + touchStartPosition: null, + imageLoadHandler: null, + imageErrorHandler: null, + slideshowTimeout: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i, j; + + for (i=0, j=this.cache.images.length; i 0){ + Util.DOM.setStyle(itemEl, { + marginRight: this.settings.margin + 'px' + }); + } + + Util.DOM.appendChild(itemEl, this.contentEl); + + } + + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + }, + + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, height, top, itemWidth, itemEls, contentWidth, i, j, itemEl, imageEl; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + } + + itemWidth = (this.settings.margin > 0) ? width + this.settings.margin : width; + itemEls = Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + contentWidth = itemWidth * itemEls.length; + + + // Set the height and width to fill the document + Util.DOM.setStyle(this.el, { + top: top, + width: width, + height: height + }); + + + // Set the height and width of the content el + Util.DOM.setStyle(this.contentEl, { + width: contentWidth, + height: height + }); + + + // Set the height and width of item elements + for (i=0, j=itemEls.length; i maxWidth){ + scale = maxWidth / newWidth; + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + if (newHeight > maxHeight){ + scale = maxHeight / newHeight; + newHeight = Math.round(newHeight * scale); + newWidth = Math.round(newWidth * scale); + } + + } + else{ + + if (imageEl.isLandscape) { + // Ensure the width fits the screen + scale = maxWidth / imageEl.naturalWidth; + } + else { + // Ensure the height fits the screen + scale = maxHeight / imageEl.naturalHeight; + } + + newWidth = Math.round(imageEl.naturalWidth * scale); + newHeight = Math.round(imageEl.naturalHeight * scale); + + if (this.settings.imageScaleMethod === 'zoom'){ + + scale = 1; + if (newHeight < maxHeight){ + scale = maxHeight /newHeight; + } + else if (newWidth < maxWidth){ + scale = maxWidth /newWidth; + } + + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + } + else if (this.settings.imageScaleMethod === 'fit') { + // Rescale again to ensure full image fits into the viewport + scale = 1; + if (newWidth > maxWidth) { + scale = maxWidth / newWidth; + } + else if (newHeight > maxHeight) { + scale = maxHeight / newHeight; + } + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + } + + } + + newTop = Math.round( ((maxHeight - newHeight) / 2) ) + 'px'; + newLeft = Math.round( ((maxWidth - newWidth) / 2) ) + 'px'; + + Util.DOM.setStyle(imageEl, { + position: 'absolute', + width: newWidth, + height: newHeight, + top: newTop, + left: newLeft, + display: 'block' + }); + + }, + + + + /* + * Function: setContentLeftPosition + */ + setContentLeftPosition: function(){ + + var width, itemEls, left; + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + } + else{ + width = Util.DOM.width(this.settings.target); + } + + itemEls = this.getItemEls(); + left = 0; + + if (this.settings.loop){ + left = (width + this.settings.margin) * -1; + } + else{ + + if (this.currentCacheIndex === this.cache.images.length-1){ + left = ((itemEls.length-1) * (width + this.settings.margin)) * -1; + } + else if (this.currentCacheIndex > 0){ + left = (width + this.settings.margin) * -1; + } + + } + + Util.DOM.setStyle(this.contentEl, { + left: left + 'px' + }); + + }, + + + + /* + * Function: + */ + show: function(index){ + + this.currentCacheIndex = index; + this.resetPosition(); + this.setImages(false); + Util.DOM.show(this.el); + + Util.Animation.resetTranslate(this.contentEl); + var + itemEls = this.getItemEls(), + i, j; + for (i=0, j=itemEls.length; i this.cache.images.length-1){ + nextCacheIndex = 0; + } + if (previousCacheIndex < 0){ + previousCacheIndex = this.cache.images.length-1; + } + + cacheImages = this.cache.getImages([ + previousCacheIndex, + this.currentCacheIndex, + nextCacheIndex + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + + } + else{ + + if (itemEls.length === 1){ + if (!ignoreCurrent){ + // Current + cacheImages = this.cache.getImages([ + this.currentCacheIndex + ]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + } + else if (itemEls.length === 2){ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + else{ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1, + this.currentCacheIndex + 2 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + else if (this.currentCacheIndex === this.cache.images.length-1){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 2, + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + + } + + }, + + + + /* + * Function: addCacheImageToItemEl + */ + addCacheImageToItemEl: function(cacheImage, itemEl){ + + Util.DOM.removeClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemError); + Util.DOM.addClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemLoading); + + Util.DOM.removeChildren(itemEl); + + Util.DOM.setStyle(cacheImage.imageEl, { + display: 'none' + }); + Util.DOM.appendChild(cacheImage.imageEl, itemEl); + + Util.Animation.resetTranslate(cacheImage.imageEl); + + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + cacheImage.load(); + + }, + + + + /* + * Function: slideCarousel + */ + slideCarousel: function(point, action, speed){ + + if (this.isSliding){ + return; + } + + var width, diffX, slideBy; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth() + this.settings.margin; + } + else{ + width = Util.DOM.width(this.settings.target) + this.settings.margin; + } + + speed = Util.coalesce(speed, this.settings.slideSpeed); + + if (window.Math.abs(diffX) < 1){ + return; + } + + + switch (action){ + + case Util.TouchElement.ActionTypes.swipeLeft: + + slideBy = width * -1; + break; + + case Util.TouchElement.ActionTypes.swipeRight: + + slideBy = width; + break; + + default: + + diffX = point.x - this.touchStartPoint.x; + + if (window.Math.abs(diffX) > width / 2){ + slideBy = (diffX > 0) ? width : width * -1; + } + else{ + slideBy = 0; + } + break; + + } + + if (slideBy < 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.next; + } + else if (slideBy > 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.previous; + } + else{ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + + // Check for non-looping carousels + // If we are at the start or end, spring back to the current item element + if (!this.settings.loop){ + if ( (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous && this.currentCacheIndex === 0 ) || (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next && this.currentCacheIndex === this.cache.images.length-1) ){ + slideBy = 0; + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + } + + this.isSliding = true; + this.doSlideCarousel(slideBy, speed); + + }, + + + + /* + * Function: + */ + moveCarousel: function(point){ + + if (this.isSliding){ + return; + } + + if (!this.settings.enableDrag){ + return; + } + + this.doMoveCarousel(point.x - this.touchStartPoint.x); + + }, + + + + /* + * Function: getItemEls + */ + getItemEls: function(){ + + return Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeRight, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: next + */ + next: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: slideshowNext + */ + slideshowNext: function(){ + + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft); + + }, + + + + + /* + * Function: startSlideshow + */ + startSlideshow: function(){ + + this.stopSlideshow(); + + this.isSlideshowActive = true; + + this.slideshowTimeout = window.setTimeout(this.slideshowNext.bind(this), this.settings.slideshowDelay); + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: stopSlideshow + */ + stopSlideshow: function(){ + + if (!Util.isNothing(this.slideshowTimeout)){ + + window.clearTimeout(this.slideshowTimeout); + this.slideshowTimeout = null; + this.isSlideshowActive = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStop, + target: this + }); + + } + + }, + + + + /* + * Function: onSlideByEnd + */ + onSlideByEnd: function(e){ + + if (Util.isNothing(this.isSliding)){ + return; + } + + var itemEls = this.getItemEls(); + + this.isSliding = false; + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + this.currentCacheIndex = this.currentCacheIndex + 1; + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + this.currentCacheIndex = this.currentCacheIndex - 1; + } + + if (this.settings.loop){ + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + + if (this.currentCacheIndex < 0){ + this.currentCacheIndex = this.cache.images.length - 1; + } + else if (this.currentCacheIndex === this.cache.images.length){ + this.currentCacheIndex = 0; + } + + } + else{ + + if (this.cache.images.length > 3){ + + if (this.currentCacheIndex > 1 && this.currentCacheIndex < this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === 1){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + } + + } + + + } + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.setContentLeftPosition(); + this.setImages(true); + } + + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideByEnd, + target: this, + action: this.lastSlideByAction, + cacheIndex: this.currentCacheIndex + }); + + + if (this.isSlideshowActive){ + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.startSlideshow(); + } + else{ + this.stopSlideshow(); + } + + } + + + }, + + + + /* + * Function: onTouch + */ + onTouch: function(action, point){ + + this.stopSlideshow(); + + switch(action){ + + case Util.TouchElement.ActionTypes.touchStart: + this.touchStartPoint = point; + this.touchStartPosition = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.moveCarousel(point); + break; + + case Util.TouchElement.ActionTypes.touchMoveEnd: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + this.slideCarousel(point, action); + break; + + case Util.TouchElement.ActionTypes.tap: + break; + + case Util.TouchElement.ActionTypes.doubleTap: + break; + + + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + this.resetImagePosition(cacheImage.imageEl); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + Util.DOM.addClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemError); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util, TouchElement){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = PhotoSwipe.Carousel.CarouselClass.extend({ + + + /* + * Function: getStartingPos + */ + getStartingPos: function(){ + + var startingPos = this.touchStartPosition; + + if (Util.isNothing(startingPos)){ + startingPos = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + } + + return startingPos; + + }, + + + + /* + * Function: doMoveCarousel + */ + doMoveCarousel: function(xVal){ + + var style; + + if (Util.Browser.isCSSTransformSupported){ + + style = {}; + + style[Util.Animation._transitionPrefix + 'Property'] = 'all'; + style[Util.Animation._transitionPrefix + 'Duration'] = ''; + style[Util.Animation._transitionPrefix + 'TimingFunction'] = ''; + style[Util.Animation._transitionPrefix + 'Delay'] = '0'; + style[Util.Animation._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(' + xVal + 'px, 0px, 0px)' : 'translate(' + xVal + 'px, 0px)'; + + Util.DOM.setStyle(this.contentEl, style); + + } + else if (!Util.isNothing(window.jQuery)){ + + + window.jQuery(this.contentEl).stop().css('left', this.getStartingPos().x + xVal + 'px'); + + } + + }, + + + + /* + * Function: doSlideCarousel + */ + doSlideCarousel: function(xVal, speed){ + + var animateProps, transform; + + if (speed <= 0){ + + this.slideByEndHandler(); + return; + + } + + + if (Util.Browser.isCSSTransformSupported){ + + transform = Util.coalesce(this.contentEl.style.webkitTransform, this.contentEl.style.MozTransform, this.contentEl.style.transform, ''); + if (transform.indexOf('translate3d(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + else if (transform.indexOf('translate(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + + Util.Animation.slideBy(this.contentEl, xVal, 0, speed, this.slideByEndHandler, this.settings.slideTimingFunction); + + } + else if (!Util.isNothing(window.jQuery)){ + + animateProps = { + left: this.getStartingPos().x + xVal + 'px' + }; + + if (this.settings.animationTimingFunction === 'ease-out'){ + this.settings.animationTimingFunction = 'easeOutQuad'; + } + + if ( Util.isNothing(window.jQuery.easing[this.settings.animationTimingFunction]) ){ + this.settings.animationTimingFunction = 'linear'; + } + + window.jQuery(this.contentEl).animate( + animateProps, + this.settings.slideSpeed, + this.settings.animationTimingFunction, + this.slideByEndHandler + ); + + } + + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.TouchElement +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.CssClasses = { + toolbar: 'ps-toolbar', + toolbarContent: 'ps-toolbar-content', + toolbarTop: 'ps-toolbar-top', + caption: 'ps-caption', + captionBottom: 'ps-caption-bottom', + captionContent: 'ps-caption-content', + close: 'ps-toolbar-close', + play: 'ps-toolbar-play', + previous: 'ps-toolbar-previous', + previousDisabled: 'ps-toolbar-previous-disabled', + next: 'ps-toolbar-next', + nextDisabled: 'ps-toolbar-next-disabled' + }; + + + + PhotoSwipe.Toolbar.ToolbarAction = { + close: 'close', + play: 'play', + next: 'next', + previous: 'previous', + none: 'none' + }; + + + + PhotoSwipe.Toolbar.EventTypes = { + onTap: 'PhotoSwipeToolbarOnClick', + onBeforeShow: 'PhotoSwipeToolbarOnBeforeShow', + onShow: 'PhotoSwipeToolbarOnShow', + onBeforeHide: 'PhotoSwipeToolbarOnBeforeHide', + onHide: 'PhotoSwipeToolbarOnHide' + }; + + + + PhotoSwipe.Toolbar.getToolbar = function(){ + + return '
'; + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.ToolbarClass = klass({ + + + + toolbarEl: null, + closeEl: null, + playEl: null, + previousEl: null, + nextEl: null, + captionEl: null, + captionContentEl: null, + currentCaption: null, + settings: null, + cache: null, + timeout: null, + isVisible: null, + fadeOutHandler: null, + touchStartHandler: null, + touchMoveHandler: null, + clickHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.clearTimeout(); + + this.removeEventHandlers(); + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + Util.DOM.removeChild(this.toolbarEl, this.toolbarEl.parentNode); + Util.DOM.removeChild(this.captionEl, this.captionEl.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(cache, options){ + + var cssClass; + + this.settings = options; + this.cache = cache; + this.isVisible = false; + + this.fadeOutHandler = this.onFadeOut.bind(this); + this.touchStartHandler = this.onTouchStart.bind(this); + this.touchMoveHandler = this.onTouchMove.bind(this); + this.clickHandler = this.onClick.bind(this); + + + cssClass = PhotoSwipe.Toolbar.CssClasses.toolbar; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.toolbarTop; + } + + + // Toolbar + this.toolbarEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + this.settings.getToolbar() + ); + + + Util.DOM.setStyle(this.toolbarEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.toolbarEl); + } + else{ + Util.DOM.appendChild(this.toolbarEl, this.settings.target); + } + Util.DOM.hide(this.toolbarEl); + + this.closeEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.close, this.toolbarEl)[0]; + if (this.settings.preventHide && !Util.isNothing(this.closeEl)){ + Util.DOM.hide(this.closeEl); + } + + this.playEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.play, this.toolbarEl)[0]; + if (this.settings.preventSlideshow && !Util.isNothing(this.playEl)){ + Util.DOM.hide(this.playEl); + } + + this.nextEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.next, this.toolbarEl)[0]; + this.previousEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.previous, this.toolbarEl)[0]; + + + // Caption + cssClass = PhotoSwipe.Toolbar.CssClasses.caption; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.captionBottom; + } + + this.captionEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + '' + ); + Util.DOM.setStyle(this.captionEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.captionEl); + } + else{ + Util.DOM.appendChild(this.captionEl, this.settings.target); + } + Util.DOM.hide(this.captionEl); + + this.captionContentEl = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.Toolbar.CssClasses.captionContent + }, + '' + ); + Util.DOM.appendChild(this.captionContentEl, this.captionEl); + + this.addEventHandlers(); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, toolbarTop, captionTop; + + if (this.settings.target === window){ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = Util.DOM.windowScrollTop(); + captionTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.captionEl); + } + else { + toolbarTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.toolbarEl); + captionTop = Util.DOM.windowScrollTop(); + } + width = Util.DOM.windowWidth(); + } + else{ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = '0'; + captionTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.captionEl); + } + else{ + toolbarTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.toolbarEl); + captionTop = 0; + } + width = Util.DOM.width(this.settings.target); + } + + Util.DOM.setStyle(this.toolbarEl, { + top: toolbarTop + 'px', + width: width + }); + + Util.DOM.setStyle(this.captionEl, { + top: captionTop + 'px', + width: width + }); + }, + + + + /* + * Function: toggleVisibility + */ + toggleVisibility: function(index){ + + if (this.isVisible){ + this.fadeOut(); + } + else{ + this.show(index); + } + + }, + + + + /* + * Function: show + */ + show: function(index){ + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + this.resetPosition(); + this.setToolbarStatus(index); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeShow, + target: this + }); + + this.showToolbar(); + this.setCaption(index); + this.showCaption(); + + this.isVisible = true; + + this.setTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onShow, + target: this + }); + + }, + + + + /* + * Function: setTimeout + */ + setTimeout: function(){ + + if (this.settings.captionAndToolbarAutoHideDelay > 0){ + // Set a timeout to hide the toolbar + this.clearTimeout(); + this.timeout = window.setTimeout(this.fadeOut.bind(this), this.settings.captionAndToolbarAutoHideDelay); + } + + }, + + + + /* + * Function: clearTimeout + */ + clearTimeout: function(){ + + if (!Util.isNothing(this.timeout)){ + window.clearTimeout(this.timeout); + this.timeout = null; + } + + }, + + + + /* + * Function: fadeOut + */ + fadeOut: function(){ + + this.clearTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeHide, + target: this + }); + + Util.Animation.fadeOut(this.toolbarEl, this.settings.fadeOutSpeed); + Util.Animation.fadeOut(this.captionEl, this.settings.fadeOutSpeed, this.fadeOutHandler); + + this.isVisible = false; + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.add(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.add(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.add(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.add(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.remove(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.remove(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.remove(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: handleTap + */ + handleTap: function(e){ + + this.clearTimeout(); + + var action; + + if (e.target === this.nextEl || Util.DOM.isChildOf(e.target, this.nextEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.next; + } + else if (e.target === this.previousEl || Util.DOM.isChildOf(e.target, this.previousEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.previous; + } + else if (e.target === this.closeEl || Util.DOM.isChildOf(e.target, this.closeEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.close; + } + else if (e.target === this.playEl || Util.DOM.isChildOf(e.target, this.playEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.play; + } + + this.setTimeout(); + + if (Util.isNothing(action)){ + action = PhotoSwipe.Toolbar.ToolbarAction.none; + } + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onTap, + target: this, + action: action, + tapTarget: e.target + }); + + }, + + + + /* + * Function: setCaption + */ + setCaption: function(index){ + + Util.DOM.removeChildren(this.captionContentEl); + + this.currentCaption = Util.coalesce(this.cache.images[index].caption, '\u00A0'); + + if (Util.isObject(this.currentCaption)){ + Util.DOM.appendChild(this.currentCaption, this.captionContentEl); + } + else{ + if (this.currentCaption === ''){ + this.currentCaption = '\u00A0'; + } + Util.DOM.appendText(this.currentCaption, this.captionContentEl); + } + + this.currentCaption = (this.currentCaption === '\u00A0') ? '' : this.currentCaption; + this.resetPosition(); + + }, + + + + /* + * Function: showToolbar + */ + showToolbar: function(){ + + Util.DOM.setStyle(this.toolbarEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.toolbarEl); + + }, + + + + /* + * Function: showCaption + */ + showCaption: function(){ + + if (this.currentCaption === '' || this.captionContentEl.childNodes.length < 1){ + // Empty caption + if (!this.settings.captionAndToolbarShowEmptyCaptions){ + Util.DOM.hide(this.captionEl); + return; + } + } + Util.DOM.setStyle(this.captionEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.captionEl); + + }, + + + + /* + * Function: setToolbarStatus + */ + setToolbarStatus: function(index){ + + if (this.settings.loop){ + return; + } + + Util.DOM.removeClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + Util.DOM.removeClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + + if (index > 0 && index < this.cache.images.length-1){ + return; + } + + if (index === 0){ + if (!Util.isNothing(this.previousEl)){ + Util.DOM.addClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + } + } + + if (index === this.cache.images.length-1){ + if (!Util.isNothing(this.nextEl)){ + Util.DOM.addClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + } + } + + }, + + + + /* + * Function: onFadeOut + */ + onFadeOut: function(){ + + Util.DOM.hide(this.toolbarEl); + Util.DOM.hide(this.captionEl); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onHide, + target: this + }); + + }, + + + + /* + * Function: onTouchStart + */ + onTouchStart: function(e){ + + e.preventDefault(); + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + this.handleTap(e); + + }, + + + + /* + * Function: onTouchMove + */ + onTouchMove: function(e){ + + e.preventDefault(); + + }, + + + + /* + * Function: onClick + */ + onClick: function(e){ + + e.preventDefault(); + this.handleTap(e); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.UILayer.CssClasses = { + uiLayer: 'ps-uilayer' + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.UILayer.UILayerClass = Util.TouchElement.TouchElementClass.extend({ + + + + el: null, + settings: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.removeEventHandlers(); + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options){ + + this.settings = options; + + // Main container + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.UILayer.CssClasses.uiLayer + }, + '' + ); + Util.DOM.setStyle(this.el, { + display: 'block', + position: 'absolute', + left: 0, + top: 0, + overflow: 'hidden', + zIndex: this.settings.zIndex, + opacity: 0 + }); + Util.DOM.hide(this.el); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + this.supr(this.el, { + swipe: true, + move: true, + gesture: Util.Browser.iOS, + doubleTap: true, + preventDefaultTouchEvents: this.settings.preventDefaultTouchEvents + }); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + // Set the height and width to fill the document + if (this.settings.target === window){ + Util.DOM.setStyle(this.el, { + top: Util.DOM.windowScrollTop() + 'px', + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }); + } + else{ + Util.DOM.setStyle(this.el, { + top: '0px', + width: Util.DOM.width(this.settings.target), + height: Util.DOM.height(this.settings.target) + }); + } + + }, + + + + /* + * Function: show + */ + show: function(){ + + this.resetPosition(); + Util.DOM.show(this.el); + this.addEventHandlers(); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + this.supr(); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + this.supr(); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.ZoomPanRotate.CssClasses = { + zoomPanRotate: 'ps-zoom-pan-rotate' + }; + + + PhotoSwipe.ZoomPanRotate.EventTypes = { + + onTransform: 'PhotoSwipeZoomPanRotateOnTransform' + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.ZoomPanRotate.ZoomPanRotateClass = klass({ + + el: null, + settings: null, + containerEl: null, + imageEl: null, + transformSettings: null, + panStartingPoint: null, + transformEl: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options, cacheImage, uiLayer){ + + var parentEl, width, height, top; + + this.settings = options; + + if (this.settings.target === window){ + parentEl = document.body; + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + parentEl = this.settings.target; + width = Util.DOM.width(parentEl); + height = Util.DOM.height(parentEl); + top = '0px'; + } + + this.imageEl = cacheImage.imageEl.cloneNode(false); + Util.DOM.setStyle(this.imageEl, { + + zIndex: 1 + + }); + + this.transformSettings = { + + startingScale: 1.0, + scale: 1.0, + startingRotation: 0, + rotation: 0, + startingTranslateX: 0, + startingTranslateY: 0, + translateX: 0, + translateY: 0 + + }; + + + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.ZoomPanRotate.CssClasses.zoomPanRotate + }, + '' + ); + Util.DOM.setStyle(this.el, { + left: 0, + top: top, + position: 'absolute', + width: width, + height: height, + zIndex: this.settings.zIndex, + display: 'block' + }); + + Util.DOM.insertBefore(this.el, uiLayer.el, parentEl); + + if (Util.Browser.iOS){ + this.containerEl = Util.DOM.createElement('div','',''); + Util.DOM.setStyle(this.containerEl, { + left: 0, + top: 0, + width: width, + height: height, + position: 'absolute', + zIndex: 1 + }); + Util.DOM.appendChild(this.imageEl, this.containerEl); + Util.DOM.appendChild(this.containerEl, this.el); + Util.Animation.resetTranslate(this.containerEl); + Util.Animation.resetTranslate(this.imageEl); + this.transformEl = this.containerEl; + } + else{ + Util.DOM.appendChild(this.imageEl, this.el); + this.transformEl = this.imageEl; + } + + }, + + + + /* + * Function: setStartingTranslateFromCurrentTransform + */ + setStartingTranslateFromCurrentTransform: function(){ + + var + transformValue = Util.coalesce(this.transformEl.style.webkitTransform, this.transformEl.style.MozTransform, this.transformEl.style.transform), + transformExploded; + + if (!Util.isNothing(transformValue)){ + + transformExploded = transformValue.match( /translate\((.*?)\)/ ); + + if (!Util.isNothing(transformExploded)){ + + transformExploded = transformExploded[1].split(', '); + this.transformSettings.startingTranslateX = window.parseInt(transformExploded[0], 10); + this.transformSettings.startingTranslateY = window.parseInt(transformExploded[1], 10); + + } + + } + + }, + + + + /* + * Function: getScale + */ + getScale: function(scaleValue){ + + var scale = this.transformSettings.startingScale * scaleValue; + + if (this.settings.minUserZoom !== 0 && scale < this.settings.minUserZoom){ + scale = this.settings.minUserZoom; + } + else if (this.settings.maxUserZoom !== 0 && scale > this.settings.maxUserZoom){ + scale = this.settings.maxUserZoom; + } + + return scale; + + }, + + + + /* + * Function: setStartingScaleAndRotation + */ + setStartingScaleAndRotation: function(scaleValue, rotationValue){ + + this.transformSettings.startingScale = this.getScale(scaleValue); + + this.transformSettings.startingRotation = + (this.transformSettings.startingRotation + rotationValue) % 360; + + }, + + + + /* + * Function: zoomRotate + */ + zoomRotate: function(scaleValue, rotationValue){ + + this.transformSettings.scale = this.getScale(scaleValue); + + this.transformSettings.rotation = + this.transformSettings.startingRotation + rotationValue; + + this.applyTransform(); + + }, + + + + /* + * Function: panStart + */ + panStart: function(point){ + + this.setStartingTranslateFromCurrentTransform(); + + this.panStartingPoint = { + x: point.x, + y: point.y + }; + + }, + + + + /* + * Function: pan + */ + pan: function(point){ + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale , + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + this.transformSettings.startingTranslateX + dxScaleAdjust; + + this.transformSettings.translateY = + this.transformSettings.startingTranslateY + dyScaleAdjust; + + this.applyTransform(); + + }, + + + + /* + * Function: zoomAndPanToPoint + */ + zoomAndPanToPoint: function(scaleValue, point){ + + + if (this.settings.target === window){ + + this.panStart({ + x: Util.DOM.windowWidth() / 2, + y: Util.DOM.windowHeight() / 2 + }); + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale, + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + (this.transformSettings.startingTranslateX + dxScaleAdjust) * -1; + + this.transformSettings.translateY = + (this.transformSettings.startingTranslateY + dyScaleAdjust) * -1; + + } + + + this.setStartingScaleAndRotation(scaleValue, 0); + this.transformSettings.scale = this.transformSettings.startingScale; + + this.transformSettings.rotation = 0; + + this.applyTransform(); + + }, + + + + /* + * Function: applyTransform + */ + applyTransform: function(){ + + var + rotationDegs = this.transformSettings.rotation % 360, + translateX = window.parseInt(this.transformSettings.translateX, 10), + translateY = window.parseInt(this.transformSettings.translateY, 10), + transform = 'scale(' + this.transformSettings.scale + ') rotate(' + rotationDegs + 'deg) translate(' + translateX + 'px, ' + translateY + 'px)'; + + Util.DOM.setStyle(this.transformEl, { + webkitTransform: transform, + MozTransform: transform, + msTransform: transform, + transform: transform + }); + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, + scale: this.transformSettings.scale, + rotation: this.transformSettings.rotation, + rotationDegs: rotationDegs, + translateX: translateX, + translateY: translateY + }); + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, Util){ + + + Util.registerNamespace('Code.PhotoSwipe'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.CssClasses = { + buildingBody: 'ps-building', + activeBody: 'ps-active' + }; + + + + PhotoSwipe.EventTypes = { + + onBeforeShow: 'PhotoSwipeOnBeforeShow', + onShow: 'PhotoSwipeOnShow', + onBeforeHide: 'PhotoSwipeOnBeforeHide', + onHide: 'PhotoSwipeOnHide', + onDisplayImage: 'PhotoSwipeOnDisplayImage', + onResetPosition: 'PhotoSwipeOnResetPosition', + onSlideshowStart: 'PhotoSwipeOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeOnSlideshowStop', + onTouch: 'PhotoSwipeOnTouch', + onBeforeCaptionAndToolbarShow: 'PhotoSwipeOnBeforeCaptionAndToolbarShow', + onCaptionAndToolbarShow: 'PhotoSwipeOnCaptionAndToolbarShow', + onBeforeCaptionAndToolbarHide: 'PhotoSwipeOnBeforeCaptionAndToolbarHide', + onCaptionAndToolbarHide: 'PhotoSwipeOnCaptionAndToolbarHide', + onToolbarTap: 'PhotoSwipeOnToolbarTap', + onBeforeZoomPanRotateShow: 'PhotoSwipeOnBeforeZoomPanRotateShow', + onZoomPanRotateShow: 'PhotoSwipeOnZoomPanRotateShow', + onBeforeZoomPanRotateHide: 'PhotoSwipeOnBeforeZoomPanRotateHide', + onZoomPanRotateHide: 'PhotoSwipeOnZoomPanRotateHide', + onZoomPanRotateTransform: 'PhotoSwipeOnZoomPanRotateTransform' + + }; + + + + PhotoSwipe.instances = []; + PhotoSwipe.activeInstances = []; + + + + /* + * Function: Code.PhotoSwipe.setActivateInstance + */ + PhotoSwipe.setActivateInstance = function(instance){ + + // Can only have one instance per target (i.e. window or div) + var index = Util.arrayIndexOf(instance.settings.target, PhotoSwipe.activeInstances, 'target'); + if (index > -1){ + throw 'Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target'; + } + PhotoSwipe.activeInstances.push({ + target: instance.settings.target, + instance: instance + }); + + }; + + + + /* + * Function: Code.PhotoSwipe.unsetActivateInstance + */ + PhotoSwipe.unsetActivateInstance = function(instance){ + + var index = Util.arrayIndexOf(instance, PhotoSwipe.activeInstances, 'instance'); + PhotoSwipe.activeInstances.splice(index, 1); + + }; + + + + /* + * Function: Code.PhotoSwipe.attach + */ + PhotoSwipe.attach = function(images, options, id){ + + var i, j, instance, image; + + instance = PhotoSwipe.createInstance(images, options, id); + + // Add click event handlers if applicable + for (i=0, j=images.length; i= 2.1){ + this.isBackEventSupported = true; + } + } + + if (!this.isBackEventSupported){ + this.isBackEventSupported = Util.objectHasProperty(window, 'onhashchange'); + } + + this.settings = { + + // General + fadeInSpeed: 250, + fadeOutSpeed: 250, + preventHide: false, + preventSlideshow: false, + zIndex: 1000, + backButtonHideEnabled: true, + enableKeyboard: true, + enableMouseWheel: true, + mouseWheelSpeed: 350, + autoStartSlideshow: false, + jQueryMobile: ( !Util.isNothing(window.jQuery) && !Util.isNothing(window.jQuery.mobile) ), + jQueryMobileDialogHash: '&ui-state=dialog', + enableUIWebViewRepositionTimeout: false, + uiWebViewResetPositionDelay: 500, + target: window, + preventDefaultTouchEvents: true, + + + // Carousel + loop: true, + slideSpeed: 250, + nextPreviousSlideSpeed: 0, + enableDrag: true, + swipeThreshold: 50, + swipeTimeThreshold: 250, + slideTimingFunction: 'ease-out', + slideshowDelay: 3000, + doubleTapSpeed: 250, + margin: 20, + imageScaleMethod: 'fit', // Either "fit", "fitNoUpscale" or "zoom", + + + // Toolbar + captionAndToolbarHide: false, + captionAndToolbarFlipPosition: false, + captionAndToolbarAutoHideDelay: 5000, + captionAndToolbarOpacity: 0.8, + captionAndToolbarShowEmptyCaptions: true, + getToolbar: PhotoSwipe.Toolbar.getToolbar, + + + // ZoomPanRotate + allowUserZoom: true, + allowRotationOnUserZoom: false, + maxUserZoom: 5.0, + minUserZoom: 0.5, + doubleTapZoomLevel: 2.5, + + + // Cache + getImageSource: PhotoSwipe.Cache.Functions.getImageSource, + getImageCaption: PhotoSwipe.Cache.Functions.getImageCaption, + getImageMetaData: PhotoSwipe.Cache.Functions.getImageMetaData, + cacheMode: PhotoSwipe.Cache.Mode.normal + + }; + + Util.extend(this.settings, options); + + if (this.settings.target !== window){ + targetPosition = Util.DOM.getStyle(this.settings.target, 'position'); + if (targetPosition !== 'relative' || targetPosition !== 'absolute'){ + Util.DOM.setStyle(this.settings.target, 'position', 'relative'); + } + } + + if (this.settings.target !== window){ + this.isBackEventSupported = false; + this.settings.backButtonHideEnabled = false; + } + else{ + if (this.settings.preventHide){ + this.settings.backButtonHideEnabled = false; + } + } + + this.cache = new Cache.CacheClass(images, this.settings); + + }, + + + + /* + * Function: show + */ + show: function(obj){ + + var i, j; + + this._isResettingPosition = false; + this.backButtonClicked = false; + + // Work out what the starting index is + if (Util.isNumber(obj)){ + this.currentIndex = obj; + } + else{ + + this.currentIndex = -1; + for (i=0, j=this.originalImages.length; i this.originalImages.length-1){ + throw "Code.PhotoSwipe.PhotoSwipeClass.show: Starting index out of range"; + } + + // Store a reference to the current window dimensions + // Use this later to double check that a window has actually + // been resized. + this.isAlreadyGettingPage = this.getWindowDimensions(); + + // Set this instance to be the active instance + PhotoSwipe.setActivateInstance(this); + + this.windowDimensions = this.getWindowDimensions(); + + // Create components + if (this.settings.target === window){ + Util.DOM.addClass(window.document.body, PhotoSwipe.CssClasses.buildingBody); + } + else{ + Util.DOM.addClass(this.settings.target, PhotoSwipe.CssClasses.buildingBody); + } + this.createComponents(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeShow, + target: this + }); + + // Fade in the document overlay + this.documentOverlay.fadeIn(this.settings.fadeInSpeed, this.onDocumentOverlayFadeIn.bind(this)); + + }, + + + + /* + * Function: getWindowDimensions + */ + getWindowDimensions: function(){ + + return { + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }; + + }, + + + + /* + * Function: createComponents + */ + createComponents: function(){ + + this.documentOverlay = new DocumentOverlay.DocumentOverlayClass(this.settings); + this.carousel = new Carousel.CarouselClass(this.cache, this.settings); + this.uiLayer = new UILayer.UILayerClass(this.settings); + if (!this.settings.captionAndToolbarHide){ + this.toolbar = new Toolbar.ToolbarClass(this.cache, this.settings); + } + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + if (this._isResettingPosition){ + return; + } + + var newWindowDimensions = this.getWindowDimensions(); + if (!Util.isNothing(this.windowDimensions)){ + if (newWindowDimensions.width === this.windowDimensions.width && newWindowDimensions.height === this.windowDimensions.height){ + // This was added as a fudge for iOS + return; + } + } + + this._isResettingPosition = true; + + this.windowDimensions = newWindowDimensions; + + this.destroyZoomPanRotate(); + + this.documentOverlay.resetPosition(); + this.carousel.resetPosition(); + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.resetPosition(); + } + + this.uiLayer.resetPosition(); + + this._isResettingPosition = false; + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onResetPosition, + target: this + }); + + }, + + + + /* + * Function: addEventHandler + */ + addEventHandler: function(type, handler){ + + Util.Events.add(this, type, handler); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.isNothing(this.windowOrientationChangeHandler)){ + + this.windowOrientationChangeHandler = this.onWindowOrientationChange.bind(this); + this.windowScrollHandler = this.onWindowScroll.bind(this); + this.keyDownHandler = this.onKeyDown.bind(this); + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + this.uiLayerTouchHandler = this.onUILayerTouch.bind(this); + this.carouselSlideByEndHandler = this.onCarouselSlideByEnd.bind(this); + this.carouselSlideshowStartHandler = this.onCarouselSlideshowStart.bind(this); + this.carouselSlideshowStopHandler = this.onCarouselSlideshowStop.bind(this); + this.toolbarTapHandler = this.onToolbarTap.bind(this); + this.toolbarBeforeShowHandler = this.onToolbarBeforeShow.bind(this); + this.toolbarShowHandler = this.onToolbarShow.bind(this); + this.toolbarBeforeHideHandler = this.onToolbarBeforeHide.bind(this); + this.toolbarHideHandler = this.onToolbarHide.bind(this); + this.mouseWheelHandler = this.onMouseWheel.bind(this); + this.zoomPanRotateTransformHandler = this.onZoomPanRotateTransform.bind(this); + + } + + // Set window handlers + if (Util.Browser.android){ + // For some reason, resize was more stable than orientationchange in Android + this.orientationEventName = 'resize'; + } + else if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.add(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + else{ + var supportsOrientationChange = !Util.isNothing(window.onorientationchange); + this.orientationEventName = supportsOrientationChange ? 'orientationchange' : 'resize'; + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.add(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + if (this.settings.target === window){ + Util.Events.add(window, 'scroll', this.windowScrollHandler); + } + + if (this.settings.enableKeyboard){ + Util.Events.add(window.document, 'keydown', this.keyDownHandler); + } + + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + + if (this.settings.jQueryMobile){ + window.location.hash = this.settings.jQueryMobileDialogHash; + } + else{ + this.currentHistoryHashValue = 'PhotoSwipe' + new Date().getTime().toString(); + window.location.hash = this.currentHistoryHashValue; + } + + Util.Events.add(window, 'hashchange', this.windowHashChangeHandler); + + } + + if (this.settings.enableMouseWheel){ + Util.Events.add(window, 'mousewheel', this.mouseWheelHandler); + } + + Util.Events.add(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + + if (!Util.isNothing(this.toolbar)){ + Util.Events.add(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.remove(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.remove(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + + Util.Events.remove(window, 'scroll', this.windowScrollHandler); + + if (this.settings.enableKeyboard){ + Util.Events.remove(window.document, 'keydown', this.keyDownHandler); + } + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + Util.Events.remove(window, 'hashchange', this.windowHashChangeHandler); + } + + if (this.settings.enableMouseWheel){ + Util.Events.remove(window, 'mousewheel', this.mouseWheelHandler); + } + + if (!Util.isNothing(this.uiLayer)){ + Util.Events.remove(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + + /* + * Function: hide + */ + hide: function(){ + + if (this.settings.preventHide){ + return; + } + + if (Util.isNothing(this.documentOverlay)){ + throw "Code.PhotoSwipe.PhotoSwipeClass.hide: PhotoSwipe instance is already hidden"; + } + + if (!Util.isNothing(this.hiding)){ + return; + } + + this.clearUIWebViewResetPositionTimeout(); + + this.destroyZoomPanRotate(); + + this.removeEventHandlers(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeHide, + target: this + }); + + this.uiLayer.dispose(); + this.uiLayer = null; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.dispose(); + this.toolbar = null; + } + + this.carousel.dispose(); + this.carousel = null; + + Util.DOM.removeClass(window.document.body, PhotoSwipe.CssClasses.activeBody); + + this.documentOverlay.dispose(); + this.documentOverlay = null; + + this._isResettingPosition = false; + + // Deactive this instance + PhotoSwipe.unsetActivateInstance(this); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onHide, + target: this + }); + + this.goBackInHistory(); + + }, + + + + /* + * Function: goBackInHistory + */ + goBackInHistory: function(){ + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + if ( !this.backButtonClicked ){ + window.history.back(); + } + } + + }, + + + + /* + * Function: play + */ + play: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!this.settings.preventSlideshow){ + if (!Util.isNothing(this.carousel)){ + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + this.carousel.startSlideshow(); + } + } + + }, + + + + /* + * Function: stop + */ + stop: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.stopSlideshow(); + } + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.previous(); + } + + }, + + + + /* + * Function: next + */ + next: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.next(); + } + + }, + + + + /* + * Function: toggleToolbar + */ + toggleToolbar: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.toggleVisibility(this.currentIndex); + } + + }, + + + + /* + * Function: fadeOutToolbarIfVisible + */ + fadeOutToolbarIfVisible: function(){ + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible && this.settings.captionAndToolbarAutoHideDelay > 0){ + this.toolbar.fadeOut(); + } + + }, + + + + /* + * Function: createZoomPanRotate + */ + createZoomPanRotate: function(){ + + this.stop(); + + if (this.canUserZoom() && !this.isZoomActive()){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateShow); + + this.zoomPanRotate = new ZoomPanRotate.ZoomPanRotateClass( + this.settings, + this.cache.images[this.currentIndex], + this.uiLayer + ); + + // If we don't override this in the event of false + // you will be unable to pan around a zoomed image effectively + this.uiLayer.captureSettings.preventDefaultTouchEvents = true; + + Util.Events.add(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateShow); + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + + } + + }, + + + + /* + * Function: destroyZoomPanRotate + */ + destroyZoomPanRotate: function(){ + + if (!Util.isNothing(this.zoomPanRotate)){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateHide); + + Util.Events.remove(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + this.zoomPanRotate.dispose(); + this.zoomPanRotate = null; + + // Set the preventDefaultTouchEvents back to it was + this.uiLayer.captureSettings.preventDefaultTouchEvents = this.settings.preventDefaultTouchEvents; + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateHide); + + } + + }, + + + + /* + * Function: canUserZoom + */ + canUserZoom: function(){ + + var testEl, cacheImage; + + if (Util.Browser.msie){ + testEl = document.createElement('div'); + if (Util.isNothing(testEl.style.msTransform)){ + return false; + } + } + else if (!Util.Browser.isCSSTransformSupported){ + return false; + } + + if (!this.settings.allowUserZoom){ + return false; + } + + + if (this.carousel.isSliding){ + return false; + } + + cacheImage = this.cache.images[this.currentIndex]; + + if (Util.isNothing(cacheImage)){ + return false; + } + + if (cacheImage.isLoading){ + return false; + } + + return true; + + }, + + + + /* + * Function: isZoomActive + */ + isZoomActive: function(){ + + return (!Util.isNothing(this.zoomPanRotate)); + + }, + + + + /* + * Function: getCurrentImage + */ + getCurrentImage: function(){ + + return this.cache.images[this.currentIndex]; + + }, + + + + /* + * Function: onDocumentOverlayFadeIn + */ + onDocumentOverlayFadeIn: function(e){ + + window.setTimeout(function(){ + + var el = (this.settings.target === window) ? window.document.body : this.settings.target; + + Util.DOM.removeClass(el, PhotoSwipe.CssClasses.buildingBody); + Util.DOM.addClass(el, PhotoSwipe.CssClasses.activeBody); + + this.addEventHandlers(); + + this.carousel.show(this.currentIndex); + + this.uiLayer.show(); + + if (this.settings.autoStartSlideshow){ + this.play(); + } + else if (!Util.isNothing(this.toolbar)){ + this.toolbar.show(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onShow, + target: this + }); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), 250); + + + }, + + + + /* + * Function: setUIWebViewResetPositionTimeout + */ + setUIWebViewResetPositionTimeout: function(){ + + if (!this.settings.enableUIWebViewRepositionTimeout){ + return; + } + + if (!(Util.Browser.iOS && (!Util.Browser.safari))){ + return; + } + + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + this._uiWebViewResetPositionTimeout = window.setTimeout(function(){ + + this.resetPosition(); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), this.settings.uiWebViewResetPositionDelay); + + }, + + + + /* + * Function: clearUIWebViewResetPositionTimeout + */ + clearUIWebViewResetPositionTimeout: function(){ + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + }, + + + + /* + * Function: onWindowScroll + */ + onWindowScroll: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowOrientationChange + */ + onWindowOrientationChange: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowHashChange + */ + onWindowHashChange: function(e){ + + var compareHash = '#' + + ((this.settings.jQueryMobile) ? this.settings.jQueryMobileDialogHash : this.currentHistoryHashValue); + + if (window.location.hash !== compareHash){ + this.backButtonClicked = true; + this.hide(); + } + + }, + + + + /* + * Function: onKeyDown + */ + onKeyDown: function(e){ + + if (e.keyCode === 37) { // Left + e.preventDefault(); + this.previous(); + } + else if (e.keyCode === 39) { // Right + e.preventDefault(); + this.next(); + } + else if (e.keyCode === 38 || e.keyCode === 40) { // Up and down + e.preventDefault(); + } + else if (e.keyCode === 27) { // Escape + e.preventDefault(); + this.hide(); + } + else if (e.keyCode === 32) { // Spacebar + if (!this.settings.hideToolbar){ + this.toggleToolbar(); + } + else{ + this.hide(); + } + e.preventDefault(); + } + else if (e.keyCode === 13) { // Enter + e.preventDefault(); + this.play(); + } + + }, + + + + /* + * Function: onUILayerTouch + */ + onUILayerTouch: function(e){ + + if (this.isZoomActive()){ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.gestureChange: + this.zoomPanRotate.zoomRotate(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.gestureEnd: + this.zoomPanRotate.setStartingScaleAndRotation(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.touchStart: + this.zoomPanRotate.panStart(e.point); + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.zoomPanRotate.pan(e.point); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + this.destroyZoomPanRotate(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeLeft: + this.destroyZoomPanRotate(); + this.next(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeRight: + this.destroyZoomPanRotate(); + this.previous(); + this.toggleToolbar(); + break; + } + + } + else{ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.touchMove: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + + // Hide the toolbar if need be + this.fadeOutToolbarIfVisible(); + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.touchStart: + case Util.TouchElement.ActionTypes.touchMoveEnd: + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.tap: + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + + // Take into consideration the window scroll + if (this.settings.target === window){ + e.point.x -= Util.DOM.windowScrollLeft(); + e.point.y -= Util.DOM.windowScrollTop(); + } + + // Just make sure that if the user clicks out of the image + // that the image does not pan out of view! + var + cacheImageEl = this.cache.images[this.currentIndex].imageEl, + + imageTop = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'top'), 10), + imageLeft = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'left'), 10), + imageRight = imageLeft + Util.DOM.width(cacheImageEl), + imageBottom = imageTop + Util.DOM.height(cacheImageEl); + + if (e.point.x < imageLeft){ + e.point.x = imageLeft; + } + else if (e.point.x > imageRight){ + e.point.x = imageRight; + } + + if (e.point.y < imageTop){ + e.point.y = imageTop; + } + else if (e.point.y > imageBottom){ + e.point.y = imageBottom; + } + + this.createZoomPanRotate(); + if (this.isZoomActive()){ + this.zoomPanRotate.zoomAndPanToPoint(this.settings.doubleTapZoomLevel, e.point); + } + + break; + + case Util.TouchElement.ActionTypes.gestureStart: + this.createZoomPanRotate(); + break; + } + + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onTouch, + target: this, + point: e.point, + action: e.action + }); + + }, + + + + /* + * Function: onCarouselSlideByEnd + */ + onCarouselSlideByEnd: function(e){ + + this.currentIndex = e.cacheIndex; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.setCaption(this.currentIndex); + this.toolbar.setToolbarStatus(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onDisplayImage, + target: this, + action: e.action, + index: e.cacheIndex + }); + + }, + + + + /* + * Function: onToolbarTap + */ + onToolbarTap: function(e){ + + switch(e.action){ + + case Toolbar.ToolbarAction.next: + this.next(); + break; + + case Toolbar.ToolbarAction.previous: + this.previous(); + break; + + case Toolbar.ToolbarAction.close: + this.hide(); + break; + + case Toolbar.ToolbarAction.play: + this.play(); + break; + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onToolbarTap, + target: this, + toolbarAction: e.action, + tapTarget: e.tapTarget + }); + + }, + + + + /* + * Function: onMouseWheel + */ + onMouseWheel: function(e){ + + var + delta = Util.Events.getWheelDelta(e), + dt = e.timeStamp - (this.mouseWheelStartTime || 0); + + if (dt < this.settings.mouseWheelSpeed) { + return; + } + + this.mouseWheelStartTime = e.timeStamp; + + if (this.settings.invertMouseWheel){ + delta = delta * -1; + } + + if (delta < 0){ + this.next(); + } + else if (delta > 0){ + this.previous(); + } + + }, + + + + /* + * Function: onCarouselSlideshowStart + */ + onCarouselSlideshowStart: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: onCarouselSlideshowStop + */ + onCarouselSlideshowStop: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStop, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeShow + */ + onToolbarBeforeShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarShow + */ + onToolbarShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeHide + */ + onToolbarBeforeHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onToolbarHide + */ + onToolbarHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onZoomPanRotateTransform + */ + onZoomPanRotateTransform: function(e){ + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.EventTypes.onZoomPanRotateTransform, + scale: e.scale, + rotation: e.rotation, + rotationDegs: e.rotationDegs, + translateX: e.translateX, + translateY: e.translateY + }); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.Cache, + window.Code.PhotoSwipe.DocumentOverlay, + window.Code.PhotoSwipe.Carousel, + window.Code.PhotoSwipe.Toolbar, + window.Code.PhotoSwipe.UILayer, + window.Code.PhotoSwipe.ZoomPanRotate +)); diff --git a/photoswipe/noutil/code.photoswipe.noutil-3.0.5.min.js b/photoswipe/noutil/code.photoswipe.noutil-3.0.5.min.js new file mode 100755 index 0000000..27abd7a --- /dev/null +++ b/photoswipe/noutil/code.photoswipe.noutil-3.0.5.min.js @@ -0,0 +1,119 @@ +// PhotoSwipe - http://www.photoswipe.com/ +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Image");d.Code.PhotoSwipe.Image.EventTypes={onLoad:"onLoad",onError:"onError"}})(window,window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Image");var b=d.Code.PhotoSwipe;b.Image.ImageClass=j({refObj:null,imageEl:null,src:null,caption:null,metaData:null,imageLoadHandler:null,imageErrorHandler:null,dispose:function(){var c;this.shrinkImage();for(c in this)a.objectHasProperty(this,c)&&(this[c]=null)},initialize:function(a,f,b,i){this.refObj=a;this.src=this.originalSrc=f;this.caption=b;this.metaData=i;this.imageEl=new d.Image;this.imageLoadHandler=this.onImageLoad.bind(this);this.imageErrorHandler= +this.onImageError.bind(this)},load:function(){this.imageEl.originalSrc=a.coalesce(this.imageEl.originalSrc,"");this.imageEl.originalSrc===this.src?this.imageEl.isError?a.Events.fire(this,{type:b.Image.EventTypes.onError,target:this}):a.Events.fire(this,{type:b.Image.EventTypes.onLoad,target:this}):(this.imageEl.isError=!1,this.imageEl.isLoading=!0,this.imageEl.naturalWidth=null,this.imageEl.naturalHeight=null,this.imageEl.isLandscape=!1,this.imageEl.onload=this.imageLoadHandler,this.imageEl.onerror= +this.imageErrorHandler,this.imageEl.onabort=this.imageErrorHandler,this.imageEl.originalSrc=this.src,this.imageEl.src=this.src)},shrinkImage:function(){if(!a.isNothing(this.imageEl)&&this.imageEl.src.indexOf(this.src)>-1)this.imageEl.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",a.isNothing(this.imageEl.parentNode)||a.DOM.removeChild(this.imageEl,this.imageEl.parentNode)},onImageLoad:function(){this.imageEl.onload=null;this.imageEl.naturalWidth=a.coalesce(this.imageEl.naturalWidth, +this.imageEl.width);this.imageEl.naturalHeight=a.coalesce(this.imageEl.naturalHeight,this.imageEl.height);this.imageEl.isLandscape=this.imageEl.naturalWidth>this.imageEl.naturalHeight;this.imageEl.isLoading=!1;a.Events.fire(this,{type:b.Image.EventTypes.onLoad,target:this})},onImageError:function(){this.imageEl.onload=null;this.imageEl.onerror=null;this.imageEl.onabort=null;this.imageEl.isLoading=!1;this.imageEl.isError=!0;a.Events.fire(this,{type:b.Image.EventTypes.onError,target:this})}})})(window, +window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Cache");d=d.Code.PhotoSwipe;d.Cache.Mode={normal:"normal",aggressive:"aggressive"};d.Cache.Functions={getImageSource:function(a){return a.href},getImageCaption:function(b){if(b.nodeName==="IMG")return a.DOM.getAttribute(b,"alt");var c,f,e;c=0;for(f=b.childNodes.length;cf&& +(f=a.DOM.windowHeight())}else c=a.DOM.width(this.settings.target),f=a.DOM.height(this.settings.target),b="0px";a.DOM.setStyle(this.el,{width:c,height:f,top:b})},fadeIn:function(c,f){this.resetPosition();a.DOM.setStyle(this.el,"opacity",0);a.DOM.show(this.el);a.Animation.fadeIn(this.el,c,f)}})})(window,window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Carousel");d=d.Code.PhotoSwipe;d.Carousel.EventTypes={onSlideByEnd:"PhotoSwipeCarouselOnSlideByEnd",onSlideshowStart:"PhotoSwipeCarouselOnSlideshowStart",onSlideshowStop:"PhotoSwipeCarouselOnSlideshowStop"};d.Carousel.CssClasses={carousel:"ps-carousel",content:"ps-carousel-content",item:"ps-carousel-item",itemLoading:"ps-carousel-item-loading",itemError:"ps-carousel-item-error"};d.Carousel.SlideByAction={previous:"previous",current:"current",next:"next"}})(window, +window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Carousel");var b=d.Code.PhotoSwipe;b.Carousel.CarouselClass=j({el:null,contentEl:null,settings:null,cache:null,slideByEndHandler:null,currentCacheIndex:null,isSliding:null,isSlideshowActive:null,lastSlideByAction:null,touchStartPoint:null,touchStartPosition:null,imageLoadHandler:null,imageErrorHandler:null,slideshowTimeout:null,dispose:function(){var c,f,e;f=0;for(e=this.cache.images.length;f0&&a.DOM.setStyle(h,{marginRight:this.settings.margin+"px"}),a.DOM.appendChild(h,this.contentEl);this.settings.target===d?a.DOM.appendToBody(this.el):a.DOM.appendChild(this.el,this.settings.target)}, +resetPosition:function(){var c,f,e,i,h,g;this.settings.target===d?(c=a.DOM.windowWidth(),f=a.DOM.windowHeight(),e=a.DOM.windowScrollTop()+"px"):(c=a.DOM.width(this.settings.target),f=a.DOM.height(this.settings.target),e="0px");i=this.settings.margin>0?c+this.settings.margin:c;h=a.DOM.find("."+b.Carousel.CssClasses.item,this.contentEl);i*=h.length;a.DOM.setStyle(this.el,{top:e,width:c,height:f});a.DOM.setStyle(this.contentEl,{width:i,height:f});e=0;for(i=h.length;eh&&(f=h/b,b=Math.round(b*f),d=Math.round(d*f)),d>g&&(f=g/d,d=Math.round(d*f),b=Math.round(b*f))):(f=c.isLandscape?h/c.naturalWidth:g/c.naturalHeight,b=Math.round(c.naturalWidth* +f),d=Math.round(c.naturalHeight*f),this.settings.imageScaleMethod==="zoom"?(f=1,dh?f=h/b:d>g&&(f=g/d),f!==1&&(b=Math.round(b*f),d=Math.round(d*f))));a.DOM.setStyle(c,{position:"absolute",width:b,height:d,top:Math.round((g-d)/2)+"px",left:Math.round((h-b)/2)+"px",display:"block"})}},setContentLeftPosition:function(){var c,b,e;c=this.settings.target===d?a.DOM.windowWidth():a.DOM.width(this.settings.target); +b=this.getItemEls();e=0;this.settings.loop?e=(c+this.settings.margin)*-1:this.currentCacheIndex===this.cache.images.length-1?e=(b.length-1)*(c+this.settings.margin)*-1:this.currentCacheIndex>0&&(e=(c+this.settings.margin)*-1);a.DOM.setStyle(this.contentEl,{left:e+"px"})},show:function(c){this.currentCacheIndex=c;this.resetPosition();this.setImages(!1);a.DOM.show(this.el);a.Animation.resetTranslate(this.contentEl);var c=this.getItemEls(),f,d;f=0;for(d=c.length;fthis.cache.images.length-1&&(b=0),i<0&&(i=this.cache.images.length-1),b=this.cache.getImages([i,this.currentCacheIndex,b]),a||this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[2],d[2]),this.addCacheImageToItemEl(b[0], +d[0])):d.length===1?a||(b=this.cache.getImages([this.currentCacheIndex]),this.addCacheImageToItemEl(b[0],d[0])):d.length===2?this.currentCacheIndex===0?(b=this.cache.getImages([this.currentCacheIndex,this.currentCacheIndex+1]),a||this.addCacheImageToItemEl(b[0],d[0]),this.addCacheImageToItemEl(b[1],d[1])):(b=this.cache.getImages([this.currentCacheIndex-1,this.currentCacheIndex]),a||this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[0],d[0])):this.currentCacheIndex===0?(b=this.cache.getImages([this.currentCacheIndex, +this.currentCacheIndex+1,this.currentCacheIndex+2]),a||this.addCacheImageToItemEl(b[0],d[0]),this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[2],d[2])):(this.currentCacheIndex===this.cache.images.length-1?(b=this.cache.getImages([this.currentCacheIndex-2,this.currentCacheIndex-1,this.currentCacheIndex]),a||this.addCacheImageToItemEl(b[2],d[2]),this.addCacheImageToItemEl(b[1],d[1])):(b=this.cache.getImages([this.currentCacheIndex-1,this.currentCacheIndex,this.currentCacheIndex+1]), +a||this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[2],d[2])),this.addCacheImageToItemEl(b[0],d[0]))},addCacheImageToItemEl:function(c,d){a.DOM.removeClass(d,b.Carousel.CssClasses.itemError);a.DOM.addClass(d,b.Carousel.CssClasses.itemLoading);a.DOM.removeChildren(d);a.DOM.setStyle(c.imageEl,{display:"none"});a.DOM.appendChild(c.imageEl,d);a.Animation.resetTranslate(c.imageEl);a.Events.add(c,b.Image.EventTypes.onLoad,this.imageLoadHandler);a.Events.add(c,b.Image.EventTypes.onError, +this.imageErrorHandler);c.load()},slideCarousel:function(c,f,e){if(!this.isSliding){var i,h;i=this.settings.target===d?a.DOM.windowWidth()+this.settings.margin:a.DOM.width(this.settings.target)+this.settings.margin;e=a.coalesce(e,this.settings.slideSpeed);if(!(d.Math.abs(h)<1)){switch(f){case a.TouchElement.ActionTypes.swipeLeft:c=i*-1;break;case a.TouchElement.ActionTypes.swipeRight:c=i;break;default:h=c.x-this.touchStartPoint.x,c=d.Math.abs(h)>i/2?h>0?i:i*-1:0}this.lastSlideByAction=c<0?b.Carousel.SlideByAction.next: +c>0?b.Carousel.SlideByAction.previous:b.Carousel.SlideByAction.current;if(!this.settings.loop&&(this.lastSlideByAction===b.Carousel.SlideByAction.previous&&this.currentCacheIndex===0||this.lastSlideByAction===b.Carousel.SlideByAction.next&&this.currentCacheIndex===this.cache.images.length-1))c=0,this.lastSlideByAction=b.Carousel.SlideByAction.current;this.isSliding=!0;this.doSlideCarousel(c,e)}}},moveCarousel:function(a){this.isSliding||this.settings.enableDrag&&this.doMoveCarousel(a.x-this.touchStartPoint.x)}, +getItemEls:function(){return a.DOM.find("."+b.Carousel.CssClasses.item,this.contentEl)},previous:function(){this.stopSlideshow();this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeRight,this.settings.nextPreviousSlideSpeed)},next:function(){this.stopSlideshow();this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeLeft,this.settings.nextPreviousSlideSpeed)},slideshowNext:function(){this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeLeft)},startSlideshow:function(){this.stopSlideshow(); +this.isSlideshowActive=!0;this.slideshowTimeout=d.setTimeout(this.slideshowNext.bind(this),this.settings.slideshowDelay);a.Events.fire(this,{type:b.Carousel.EventTypes.onSlideshowStart,target:this})},stopSlideshow:function(){if(!a.isNothing(this.slideshowTimeout))d.clearTimeout(this.slideshowTimeout),this.slideshowTimeout=null,this.isSlideshowActive=!1,a.Events.fire(this,{type:b.Carousel.EventTypes.onSlideshowStop,target:this})},onSlideByEnd:function(){if(!a.isNothing(this.isSliding)){var c=this.getItemEls(); +this.isSliding=!1;this.lastSlideByAction===b.Carousel.SlideByAction.next?this.currentCacheIndex+=1:this.lastSlideByAction===b.Carousel.SlideByAction.previous&&(this.currentCacheIndex-=1);if(this.settings.loop)if(this.lastSlideByAction===b.Carousel.SlideByAction.next?a.DOM.appendChild(c[0],this.contentEl):this.lastSlideByAction===b.Carousel.SlideByAction.previous&&a.DOM.insertBefore(c[c.length-1],c[0],this.contentEl),this.currentCacheIndex<0)this.currentCacheIndex=this.cache.images.length-1;else{if(this.currentCacheIndex=== +this.cache.images.length)this.currentCacheIndex=0}else this.cache.images.length>3&&(this.currentCacheIndex>1&&this.currentCacheIndex
'}})(window,window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Toolbar");var b=d.Code.PhotoSwipe;b.Toolbar.ToolbarClass=j({toolbarEl:null,closeEl:null,playEl:null,previousEl:null,nextEl:null,captionEl:null,captionContentEl:null,currentCaption:null,settings:null,cache:null,timeout:null,isVisible:null,fadeOutHandler:null,touchStartHandler:null,touchMoveHandler:null,clickHandler:null,dispose:function(){var c;this.clearTimeout();this.removeEventHandlers();a.Animation.stop(this.toolbarEl);a.Animation.stop(this.captionEl); +a.DOM.removeChild(this.toolbarEl,this.toolbarEl.parentNode);a.DOM.removeChild(this.captionEl,this.captionEl.parentNode);for(c in this)a.objectHasProperty(this,c)&&(this[c]=null)},initialize:function(c,f){var e;this.settings=f;this.cache=c;this.isVisible=!1;this.fadeOutHandler=this.onFadeOut.bind(this);this.touchStartHandler=this.onTouchStart.bind(this);this.touchMoveHandler=this.onTouchMove.bind(this);this.clickHandler=this.onClick.bind(this);e=b.Toolbar.CssClasses.toolbar;this.settings.captionAndToolbarFlipPosition&& +(e=e+" "+b.Toolbar.CssClasses.toolbarTop);this.toolbarEl=a.DOM.createElement("div",{"class":e},this.settings.getToolbar());a.DOM.setStyle(this.toolbarEl,{left:0,position:"absolute",overflow:"hidden",zIndex:this.settings.zIndex});this.settings.target===d?a.DOM.appendToBody(this.toolbarEl):a.DOM.appendChild(this.toolbarEl,this.settings.target);a.DOM.hide(this.toolbarEl);this.closeEl=a.DOM.find("."+b.Toolbar.CssClasses.close,this.toolbarEl)[0];this.settings.preventHide&&!a.isNothing(this.closeEl)&&a.DOM.hide(this.closeEl); +this.playEl=a.DOM.find("."+b.Toolbar.CssClasses.play,this.toolbarEl)[0];this.settings.preventSlideshow&&!a.isNothing(this.playEl)&&a.DOM.hide(this.playEl);this.nextEl=a.DOM.find("."+b.Toolbar.CssClasses.next,this.toolbarEl)[0];this.previousEl=a.DOM.find("."+b.Toolbar.CssClasses.previous,this.toolbarEl)[0];e=b.Toolbar.CssClasses.caption;this.settings.captionAndToolbarFlipPosition&&(e=e+" "+b.Toolbar.CssClasses.captionBottom);this.captionEl=a.DOM.createElement("div",{"class":e},"");a.DOM.setStyle(this.captionEl, +{left:0,position:"absolute",overflow:"hidden",zIndex:this.settings.zIndex});this.settings.target===d?a.DOM.appendToBody(this.captionEl):a.DOM.appendChild(this.captionEl,this.settings.target);a.DOM.hide(this.captionEl);this.captionContentEl=a.DOM.createElement("div",{"class":b.Toolbar.CssClasses.captionContent},"");a.DOM.appendChild(this.captionContentEl,this.captionEl);this.addEventHandlers()},resetPosition:function(){var c,b,e;this.settings.target===d?(this.settings.captionAndToolbarFlipPosition? +(b=a.DOM.windowScrollTop(),e=a.DOM.windowScrollTop()+a.DOM.windowHeight()-a.DOM.height(this.captionEl)):(b=a.DOM.windowScrollTop()+a.DOM.windowHeight()-a.DOM.height(this.toolbarEl),e=a.DOM.windowScrollTop()),c=a.DOM.windowWidth()):(this.settings.captionAndToolbarFlipPosition?(b="0",e=a.DOM.height(this.settings.target)-a.DOM.height(this.captionEl)):(b=a.DOM.height(this.settings.target)-a.DOM.height(this.toolbarEl),e=0),c=a.DOM.width(this.settings.target));a.DOM.setStyle(this.toolbarEl,{top:b+"px", +width:c});a.DOM.setStyle(this.captionEl,{top:e+"px",width:c})},toggleVisibility:function(a){this.isVisible?this.fadeOut():this.show(a)},show:function(c){a.Animation.stop(this.toolbarEl);a.Animation.stop(this.captionEl);this.resetPosition();this.setToolbarStatus(c);a.Events.fire(this,{type:b.Toolbar.EventTypes.onBeforeShow,target:this});this.showToolbar();this.setCaption(c);this.showCaption();this.isVisible=!0;this.setTimeout();a.Events.fire(this,{type:b.Toolbar.EventTypes.onShow,target:this})},setTimeout:function(){if(this.settings.captionAndToolbarAutoHideDelay> +0)this.clearTimeout(),this.timeout=d.setTimeout(this.fadeOut.bind(this),this.settings.captionAndToolbarAutoHideDelay)},clearTimeout:function(){if(!a.isNothing(this.timeout))d.clearTimeout(this.timeout),this.timeout=null},fadeOut:function(){this.clearTimeout();a.Events.fire(this,{type:b.Toolbar.EventTypes.onBeforeHide,target:this});a.Animation.fadeOut(this.toolbarEl,this.settings.fadeOutSpeed);a.Animation.fadeOut(this.captionEl,this.settings.fadeOutSpeed,this.fadeOutHandler);this.isVisible=!1},addEventHandlers:function(){a.Browser.isTouchSupported&& +(a.Browser.blackberry||a.Events.add(this.toolbarEl,"touchstart",this.touchStartHandler),a.Events.add(this.toolbarEl,"touchmove",this.touchMoveHandler),a.Events.add(this.captionEl,"touchmove",this.touchMoveHandler));a.Events.add(this.toolbarEl,"click",this.clickHandler)},removeEventHandlers:function(){a.Browser.isTouchSupported&&(a.Browser.blackberry||a.Events.remove(this.toolbarEl,"touchstart",this.touchStartHandler),a.Events.remove(this.toolbarEl,"touchmove",this.touchMoveHandler),a.Events.remove(this.captionEl, +"touchmove",this.touchMoveHandler));a.Events.remove(this.toolbarEl,"click",this.clickHandler)},handleTap:function(c){this.clearTimeout();var d;if(c.target===this.nextEl||a.DOM.isChildOf(c.target,this.nextEl))d=b.Toolbar.ToolbarAction.next;else if(c.target===this.previousEl||a.DOM.isChildOf(c.target,this.previousEl))d=b.Toolbar.ToolbarAction.previous;else if(c.target===this.closeEl||a.DOM.isChildOf(c.target,this.closeEl))d=b.Toolbar.ToolbarAction.close;else if(c.target===this.playEl||a.DOM.isChildOf(c.target, +this.playEl))d=b.Toolbar.ToolbarAction.play;this.setTimeout();if(a.isNothing(d))d=b.Toolbar.ToolbarAction.none;a.Events.fire(this,{type:b.Toolbar.EventTypes.onTap,target:this,action:d,tapTarget:c.target})},setCaption:function(c){a.DOM.removeChildren(this.captionContentEl);this.currentCaption=a.coalesce(this.cache.images[c].caption,"\u00a0");if(a.isObject(this.currentCaption))a.DOM.appendChild(this.currentCaption,this.captionContentEl);else{if(this.currentCaption==="")this.currentCaption="\u00a0"; +a.DOM.appendText(this.currentCaption,this.captionContentEl)}this.currentCaption=this.currentCaption==="\u00a0"?"":this.currentCaption;this.resetPosition()},showToolbar:function(){a.DOM.setStyle(this.toolbarEl,{opacity:this.settings.captionAndToolbarOpacity});a.DOM.show(this.toolbarEl)},showCaption:function(){(this.currentCaption===""||this.captionContentEl.childNodes.length<1)&&!this.settings.captionAndToolbarShowEmptyCaptions?a.DOM.hide(this.captionEl):(a.DOM.setStyle(this.captionEl,{opacity:this.settings.captionAndToolbarOpacity}), +a.DOM.show(this.captionEl))},setToolbarStatus:function(c){this.settings.loop||(a.DOM.removeClass(this.previousEl,b.Toolbar.CssClasses.previousDisabled),a.DOM.removeClass(this.nextEl,b.Toolbar.CssClasses.nextDisabled),c>0&&cthis.settings.maxUserZoom)a=this.settings.maxUserZoom;return a},setStartingScaleAndRotation:function(a,b){this.transformSettings.startingScale=this.getScale(a);this.transformSettings.startingRotation=(this.transformSettings.startingRotation+b)%360},zoomRotate:function(a,b){this.transformSettings.scale=this.getScale(a);this.transformSettings.rotation=this.transformSettings.startingRotation+b;this.applyTransform()},panStart:function(a){this.setStartingTranslateFromCurrentTransform();this.panStartingPoint= +{x:a.x,y:a.y}},pan:function(a){var b=(a.y-this.panStartingPoint.y)/this.transformSettings.scale;this.transformSettings.translateX=this.transformSettings.startingTranslateX+(a.x-this.panStartingPoint.x)/this.transformSettings.scale;this.transformSettings.translateY=this.transformSettings.startingTranslateY+b;this.applyTransform()},zoomAndPanToPoint:function(b,f){if(this.settings.target===d){this.panStart({x:a.DOM.windowWidth()/2,y:a.DOM.windowHeight()/2});var e=(f.y-this.panStartingPoint.y)/this.transformSettings.scale; +this.transformSettings.translateX=(this.transformSettings.startingTranslateX+(f.x-this.panStartingPoint.x)/this.transformSettings.scale)*-1;this.transformSettings.translateY=(this.transformSettings.startingTranslateY+e)*-1}this.setStartingScaleAndRotation(b,0);this.transformSettings.scale=this.transformSettings.startingScale;this.transformSettings.rotation=0;this.applyTransform()},applyTransform:function(){var c=this.transformSettings.rotation%360,f=d.parseInt(this.transformSettings.translateX,10), +e=d.parseInt(this.transformSettings.translateY,10),i="scale("+this.transformSettings.scale+") rotate("+c+"deg) translate("+f+"px, "+e+"px)";a.DOM.setStyle(this.transformEl,{webkitTransform:i,MozTransform:i,msTransform:i,transform:i});a.Events.fire(this,{target:this,type:b.ZoomPanRotate.EventTypes.onTransform,scale:this.transformSettings.scale,rotation:this.transformSettings.rotation,rotationDegs:c,translateX:f,translateY:e})}})})(window,window.klass,window.Code.Util); +(function(d,j){j.registerNamespace("Code.PhotoSwipe");var a=d.Code.PhotoSwipe;a.CssClasses={buildingBody:"ps-building",activeBody:"ps-active"};a.EventTypes={onBeforeShow:"PhotoSwipeOnBeforeShow",onShow:"PhotoSwipeOnShow",onBeforeHide:"PhotoSwipeOnBeforeHide",onHide:"PhotoSwipeOnHide",onDisplayImage:"PhotoSwipeOnDisplayImage",onResetPosition:"PhotoSwipeOnResetPosition",onSlideshowStart:"PhotoSwipeOnSlideshowStart",onSlideshowStop:"PhotoSwipeOnSlideshowStop",onTouch:"PhotoSwipeOnTouch",onBeforeCaptionAndToolbarShow:"PhotoSwipeOnBeforeCaptionAndToolbarShow", +onCaptionAndToolbarShow:"PhotoSwipeOnCaptionAndToolbarShow",onBeforeCaptionAndToolbarHide:"PhotoSwipeOnBeforeCaptionAndToolbarHide",onCaptionAndToolbarHide:"PhotoSwipeOnCaptionAndToolbarHide",onToolbarTap:"PhotoSwipeOnToolbarTap",onBeforeZoomPanRotateShow:"PhotoSwipeOnBeforeZoomPanRotateShow",onZoomPanRotateShow:"PhotoSwipeOnZoomPanRotateShow",onBeforeZoomPanRotateHide:"PhotoSwipeOnBeforeZoomPanRotateHide",onZoomPanRotateHide:"PhotoSwipeOnZoomPanRotateHide",onZoomPanRotateTransform:"PhotoSwipeOnZoomPanRotateTransform"}; +a.instances=[];a.activeInstances=[];a.setActivateInstance=function(b){if(j.arrayIndexOf(b.settings.target,a.activeInstances,"target")>-1)throw"Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target";a.activeInstances.push({target:b.settings.target,instance:b})};a.unsetActivateInstance=function(b){b=j.arrayIndexOf(b,a.activeInstances,"instance");a.activeInstances.splice(b,1)};a.attach=function(b,c,d){var e,i;e=a.createInstance(b,c,d);c=0;for(d= +b.length;c=2.1)this.isBackEventSupported=!0;if(!this.isBackEventSupported)this.isBackEventSupported=a.objectHasProperty(d,"onhashchange");this.settings={fadeInSpeed:250,fadeOutSpeed:250,preventHide:!1,preventSlideshow:!1,zIndex:1E3,backButtonHideEnabled:!0,enableKeyboard:!0,enableMouseWheel:!0, +mouseWheelSpeed:350,autoStartSlideshow:!1,jQueryMobile:!a.isNothing(d.jQuery)&&!a.isNothing(d.jQuery.mobile),jQueryMobileDialogHash:"&ui-state=dialog",enableUIWebViewRepositionTimeout:!1,uiWebViewResetPositionDelay:500,target:d,preventDefaultTouchEvents:!0,loop:!0,slideSpeed:250,nextPreviousSlideSpeed:0,enableDrag:!0,swipeThreshold:50,swipeTimeThreshold:250,slideTimingFunction:"ease-out",slideshowDelay:3E3,doubleTapSpeed:250,margin:20,imageScaleMethod:"fit",captionAndToolbarHide:!1,captionAndToolbarFlipPosition:!1, +captionAndToolbarAutoHideDelay:5E3,captionAndToolbarOpacity:0.8,captionAndToolbarShowEmptyCaptions:!0,getToolbar:g.Toolbar.getToolbar,allowUserZoom:!0,allowRotationOnUserZoom:!1,maxUserZoom:5,minUserZoom:0.5,doubleTapZoomLevel:2.5,getImageSource:g.Cache.Functions.getImageSource,getImageCaption:g.Cache.Functions.getImageCaption,getImageMetaData:g.Cache.Functions.getImageMetaData,cacheMode:g.Cache.Mode.normal};a.extend(this.settings,e);this.settings.target!==d&&(e=a.DOM.getStyle(this.settings.target, +"position"),(e!=="relative"||e!=="absolute")&&a.DOM.setStyle(this.settings.target,"position","relative"));if(this.settings.target!==d)this.isBackEventSupported=!1,this.settings.backButtonHideEnabled=!1;else if(this.settings.preventHide)this.settings.backButtonHideEnabled=!1;this.cache=new b.CacheClass(c,this.settings)},show:function(b){var c,e;this.backButtonClicked=this._isResettingPosition=!1;if(a.isNumber(b))this.currentIndex=b;else{this.currentIndex=-1;c=0;for(e=this.originalImages.length;cthis.originalImages.length-1)throw"Code.PhotoSwipe.PhotoSwipeClass.show: Starting index out of range";this.isAlreadyGettingPage=this.getWindowDimensions();g.setActivateInstance(this);this.windowDimensions=this.getWindowDimensions();this.settings.target===d?a.DOM.addClass(d.document.body,g.CssClasses.buildingBody):a.DOM.addClass(this.settings.target,g.CssClasses.buildingBody);this.createComponents();a.Events.fire(this,{type:g.EventTypes.onBeforeShow, +target:this});this.documentOverlay.fadeIn(this.settings.fadeInSpeed,this.onDocumentOverlayFadeIn.bind(this))},getWindowDimensions:function(){return{width:a.DOM.windowWidth(),height:a.DOM.windowHeight()}},createComponents:function(){this.documentOverlay=new c.DocumentOverlayClass(this.settings);this.carousel=new f.CarouselClass(this.cache,this.settings);this.uiLayer=new i.UILayerClass(this.settings);if(!this.settings.captionAndToolbarHide)this.toolbar=new e.ToolbarClass(this.cache,this.settings)}, +resetPosition:function(){if(!this._isResettingPosition){var b=this.getWindowDimensions();if(a.isNothing(this.windowDimensions)||!(b.width===this.windowDimensions.width&&b.height===this.windowDimensions.height))this._isResettingPosition=!0,this.windowDimensions=b,this.destroyZoomPanRotate(),this.documentOverlay.resetPosition(),this.carousel.resetPosition(),a.isNothing(this.toolbar)||this.toolbar.resetPosition(),this.uiLayer.resetPosition(),this._isResettingPosition=!1,a.Events.fire(this,{type:g.EventTypes.onResetPosition, +target:this})}},addEventHandler:function(b,c){a.Events.add(this,b,c)},addEventHandlers:function(){if(a.isNothing(this.windowOrientationChangeHandler))this.windowOrientationChangeHandler=this.onWindowOrientationChange.bind(this),this.windowScrollHandler=this.onWindowScroll.bind(this),this.keyDownHandler=this.onKeyDown.bind(this),this.windowHashChangeHandler=this.onWindowHashChange.bind(this),this.uiLayerTouchHandler=this.onUILayerTouch.bind(this),this.carouselSlideByEndHandler=this.onCarouselSlideByEnd.bind(this), +this.carouselSlideshowStartHandler=this.onCarouselSlideshowStart.bind(this),this.carouselSlideshowStopHandler=this.onCarouselSlideshowStop.bind(this),this.toolbarTapHandler=this.onToolbarTap.bind(this),this.toolbarBeforeShowHandler=this.onToolbarBeforeShow.bind(this),this.toolbarShowHandler=this.onToolbarShow.bind(this),this.toolbarBeforeHideHandler=this.onToolbarBeforeHide.bind(this),this.toolbarHideHandler=this.onToolbarHide.bind(this),this.mouseWheelHandler=this.onMouseWheel.bind(this),this.zoomPanRotateTransformHandler= +this.onZoomPanRotateTransform.bind(this);a.Browser.android?this.orientationEventName="resize":a.Browser.iOS&&!a.Browser.safari?a.Events.add(d.document.body,"orientationchange",this.windowOrientationChangeHandler):this.orientationEventName=!a.isNothing(d.onorientationchange)?"orientationchange":"resize";a.isNothing(this.orientationEventName)||a.Events.add(d,this.orientationEventName,this.windowOrientationChangeHandler);this.settings.target===d&&a.Events.add(d,"scroll",this.windowScrollHandler);this.settings.enableKeyboard&& +a.Events.add(d.document,"keydown",this.keyDownHandler);if(this.isBackEventSupported&&this.settings.backButtonHideEnabled)this.windowHashChangeHandler=this.onWindowHashChange.bind(this),this.settings.jQueryMobile?d.location.hash=this.settings.jQueryMobileDialogHash:(this.currentHistoryHashValue="PhotoSwipe"+(new Date).getTime().toString(),d.location.hash=this.currentHistoryHashValue),a.Events.add(d,"hashchange",this.windowHashChangeHandler);this.settings.enableMouseWheel&&a.Events.add(d,"mousewheel", +this.mouseWheelHandler);a.Events.add(this.uiLayer,a.TouchElement.EventTypes.onTouch,this.uiLayerTouchHandler);a.Events.add(this.carousel,f.EventTypes.onSlideByEnd,this.carouselSlideByEndHandler);a.Events.add(this.carousel,f.EventTypes.onSlideshowStart,this.carouselSlideshowStartHandler);a.Events.add(this.carousel,f.EventTypes.onSlideshowStop,this.carouselSlideshowStopHandler);a.isNothing(this.toolbar)||(a.Events.add(this.toolbar,e.EventTypes.onTap,this.toolbarTapHandler),a.Events.add(this.toolbar, +e.EventTypes.onBeforeShow,this.toolbarBeforeShowHandler),a.Events.add(this.toolbar,e.EventTypes.onShow,this.toolbarShowHandler),a.Events.add(this.toolbar,e.EventTypes.onBeforeHide,this.toolbarBeforeHideHandler),a.Events.add(this.toolbar,e.EventTypes.onHide,this.toolbarHideHandler))},removeEventHandlers:function(){a.Browser.iOS&&!a.Browser.safari&&a.Events.remove(d.document.body,"orientationchange",this.windowOrientationChangeHandler);a.isNothing(this.orientationEventName)||a.Events.remove(d,this.orientationEventName, +this.windowOrientationChangeHandler);a.Events.remove(d,"scroll",this.windowScrollHandler);this.settings.enableKeyboard&&a.Events.remove(d.document,"keydown",this.keyDownHandler);this.isBackEventSupported&&this.settings.backButtonHideEnabled&&a.Events.remove(d,"hashchange",this.windowHashChangeHandler);this.settings.enableMouseWheel&&a.Events.remove(d,"mousewheel",this.mouseWheelHandler);a.isNothing(this.uiLayer)||a.Events.remove(this.uiLayer,a.TouchElement.EventTypes.onTouch,this.uiLayerTouchHandler); +a.isNothing(this.toolbar)||(a.Events.remove(this.carousel,f.EventTypes.onSlideByEnd,this.carouselSlideByEndHandler),a.Events.remove(this.carousel,f.EventTypes.onSlideshowStart,this.carouselSlideshowStartHandler),a.Events.remove(this.carousel,f.EventTypes.onSlideshowStop,this.carouselSlideshowStopHandler));a.isNothing(this.toolbar)||(a.Events.remove(this.toolbar,e.EventTypes.onTap,this.toolbarTapHandler),a.Events.remove(this.toolbar,e.EventTypes.onBeforeShow,this.toolbarBeforeShowHandler),a.Events.remove(this.toolbar, +e.EventTypes.onShow,this.toolbarShowHandler),a.Events.remove(this.toolbar,e.EventTypes.onBeforeHide,this.toolbarBeforeHideHandler),a.Events.remove(this.toolbar,e.EventTypes.onHide,this.toolbarHideHandler))},hide:function(){if(!this.settings.preventHide){if(a.isNothing(this.documentOverlay))throw"Code.PhotoSwipe.PhotoSwipeClass.hide: PhotoSwipe instance is already hidden";if(a.isNothing(this.hiding)){this.clearUIWebViewResetPositionTimeout();this.destroyZoomPanRotate();this.removeEventHandlers();a.Events.fire(this, +{type:g.EventTypes.onBeforeHide,target:this});this.uiLayer.dispose();this.uiLayer=null;if(!a.isNothing(this.toolbar))this.toolbar.dispose(),this.toolbar=null;this.carousel.dispose();this.carousel=null;a.DOM.removeClass(d.document.body,g.CssClasses.activeBody);this.documentOverlay.dispose();this.documentOverlay=null;this._isResettingPosition=!1;g.unsetActivateInstance(this);a.Events.fire(this,{type:g.EventTypes.onHide,target:this});this.goBackInHistory()}}},goBackInHistory:function(){this.isBackEventSupported&& +this.settings.backButtonHideEnabled&&(this.backButtonClicked||d.history.back())},play:function(){!this.isZoomActive()&&!this.settings.preventSlideshow&&!a.isNothing(this.carousel)&&(!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.toolbar.fadeOut(),this.carousel.startSlideshow())},stop:function(){this.isZoomActive()||a.isNothing(this.carousel)||this.carousel.stopSlideshow()},previous:function(){this.isZoomActive()||a.isNothing(this.carousel)||this.carousel.previous()},next:function(){this.isZoomActive()|| +a.isNothing(this.carousel)||this.carousel.next()},toggleToolbar:function(){this.isZoomActive()||a.isNothing(this.toolbar)||this.toolbar.toggleVisibility(this.currentIndex)},fadeOutToolbarIfVisible:function(){!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.settings.captionAndToolbarAutoHideDelay>0&&this.toolbar.fadeOut()},createZoomPanRotate:function(){this.stop();if(this.canUserZoom()&&!this.isZoomActive())a.Events.fire(this,g.EventTypes.onBeforeZoomPanRotateShow),this.zoomPanRotate=new h.ZoomPanRotateClass(this.settings, +this.cache.images[this.currentIndex],this.uiLayer),this.uiLayer.captureSettings.preventDefaultTouchEvents=!0,a.Events.add(this.zoomPanRotate,g.ZoomPanRotate.EventTypes.onTransform,this.zoomPanRotateTransformHandler),a.Events.fire(this,g.EventTypes.onZoomPanRotateShow),!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.toolbar.fadeOut()},destroyZoomPanRotate:function(){if(!a.isNothing(this.zoomPanRotate))a.Events.fire(this,g.EventTypes.onBeforeZoomPanRotateHide),a.Events.remove(this.zoomPanRotate, +g.ZoomPanRotate.EventTypes.onTransform,this.zoomPanRotateTransformHandler),this.zoomPanRotate.dispose(),this.zoomPanRotate=null,this.uiLayer.captureSettings.preventDefaultTouchEvents=this.settings.preventDefaultTouchEvents,a.Events.fire(this,g.EventTypes.onZoomPanRotateHide)},canUserZoom:function(){var b;if(a.Browser.msie){if(b=document.createElement("div"),a.isNothing(b.style.msTransform))return!1}else if(!a.Browser.isCSSTransformSupported)return!1;if(!this.settings.allowUserZoom)return!1;if(this.carousel.isSliding)return!1; +b=this.cache.images[this.currentIndex];if(a.isNothing(b))return!1;if(b.isLoading)return!1;return!0},isZoomActive:function(){return!a.isNothing(this.zoomPanRotate)},getCurrentImage:function(){return this.cache.images[this.currentIndex]},onDocumentOverlayFadeIn:function(){d.setTimeout(function(){var b=this.settings.target===d?d.document.body:this.settings.target;a.DOM.removeClass(b,g.CssClasses.buildingBody);a.DOM.addClass(b,g.CssClasses.activeBody);this.addEventHandlers();this.carousel.show(this.currentIndex); +this.uiLayer.show();this.settings.autoStartSlideshow?this.play():a.isNothing(this.toolbar)||this.toolbar.show(this.currentIndex);a.Events.fire(this,{type:g.EventTypes.onShow,target:this});this.setUIWebViewResetPositionTimeout()}.bind(this),250)},setUIWebViewResetPositionTimeout:function(){if(this.settings.enableUIWebViewRepositionTimeout&&a.Browser.iOS&&!a.Browser.safari)a.isNothing(this._uiWebViewResetPositionTimeout)||d.clearTimeout(this._uiWebViewResetPositionTimeout),this._uiWebViewResetPositionTimeout= +d.setTimeout(function(){this.resetPosition();this.setUIWebViewResetPositionTimeout()}.bind(this),this.settings.uiWebViewResetPositionDelay)},clearUIWebViewResetPositionTimeout:function(){a.isNothing(this._uiWebViewResetPositionTimeout)||d.clearTimeout(this._uiWebViewResetPositionTimeout)},onWindowScroll:function(){this.resetPosition()},onWindowOrientationChange:function(){this.resetPosition()},onWindowHashChange:function(){if(d.location.hash!=="#"+(this.settings.jQueryMobile?this.settings.jQueryMobileDialogHash: +this.currentHistoryHashValue))this.backButtonClicked=!0,this.hide()},onKeyDown:function(a){a.keyCode===37?(a.preventDefault(),this.previous()):a.keyCode===39?(a.preventDefault(),this.next()):a.keyCode===38||a.keyCode===40?a.preventDefault():a.keyCode===27?(a.preventDefault(),this.hide()):a.keyCode===32?(this.settings.hideToolbar?this.hide():this.toggleToolbar(),a.preventDefault()):a.keyCode===13&&(a.preventDefault(),this.play())},onUILayerTouch:function(b){if(this.isZoomActive())switch(b.action){case a.TouchElement.ActionTypes.gestureChange:this.zoomPanRotate.zoomRotate(b.scale, +this.settings.allowRotationOnUserZoom?b.rotation:0);break;case a.TouchElement.ActionTypes.gestureEnd:this.zoomPanRotate.setStartingScaleAndRotation(b.scale,this.settings.allowRotationOnUserZoom?b.rotation:0);break;case a.TouchElement.ActionTypes.touchStart:this.zoomPanRotate.panStart(b.point);break;case a.TouchElement.ActionTypes.touchMove:this.zoomPanRotate.pan(b.point);break;case a.TouchElement.ActionTypes.doubleTap:this.destroyZoomPanRotate();this.toggleToolbar();break;case a.TouchElement.ActionTypes.swipeLeft:this.destroyZoomPanRotate(); +this.next();this.toggleToolbar();break;case a.TouchElement.ActionTypes.swipeRight:this.destroyZoomPanRotate(),this.previous(),this.toggleToolbar()}else switch(b.action){case a.TouchElement.ActionTypes.touchMove:case a.TouchElement.ActionTypes.swipeLeft:case a.TouchElement.ActionTypes.swipeRight:this.fadeOutToolbarIfVisible();this.carousel.onTouch(b.action,b.point);break;case a.TouchElement.ActionTypes.touchStart:case a.TouchElement.ActionTypes.touchMoveEnd:this.carousel.onTouch(b.action,b.point); +break;case a.TouchElement.ActionTypes.tap:this.toggleToolbar();break;case a.TouchElement.ActionTypes.doubleTap:this.settings.target===d&&(b.point.x-=a.DOM.windowScrollLeft(),b.point.y-=a.DOM.windowScrollTop());var c=this.cache.images[this.currentIndex].imageEl,e=d.parseInt(a.DOM.getStyle(c,"top"),10),f=d.parseInt(a.DOM.getStyle(c,"left"),10),h=f+a.DOM.width(c),c=e+a.DOM.height(c);if(b.point.xh)b.point.x=h;if(b.point.yc)b.point.y=c; +this.createZoomPanRotate();this.isZoomActive()&&this.zoomPanRotate.zoomAndPanToPoint(this.settings.doubleTapZoomLevel,b.point);break;case a.TouchElement.ActionTypes.gestureStart:this.createZoomPanRotate()}a.Events.fire(this,{type:g.EventTypes.onTouch,target:this,point:b.point,action:b.action})},onCarouselSlideByEnd:function(b){this.currentIndex=b.cacheIndex;a.isNothing(this.toolbar)||(this.toolbar.setCaption(this.currentIndex),this.toolbar.setToolbarStatus(this.currentIndex));a.Events.fire(this,{type:g.EventTypes.onDisplayImage, +target:this,action:b.action,index:b.cacheIndex})},onToolbarTap:function(b){switch(b.action){case e.ToolbarAction.next:this.next();break;case e.ToolbarAction.previous:this.previous();break;case e.ToolbarAction.close:this.hide();break;case e.ToolbarAction.play:this.play()}a.Events.fire(this,{type:g.EventTypes.onToolbarTap,target:this,toolbarAction:b.action,tapTarget:b.tapTarget})},onMouseWheel:function(b){var c=a.Events.getWheelDelta(b);if(!(b.timeStamp-(this.mouseWheelStartTime||0)0&&this.previous()},onCarouselSlideshowStart:function(){a.Events.fire(this,{type:g.EventTypes.onSlideshowStart,target:this})},onCarouselSlideshowStop:function(){a.Events.fire(this,{type:g.EventTypes.onSlideshowStop,target:this})},onToolbarBeforeShow:function(){a.Events.fire(this,{type:g.EventTypes.onBeforeCaptionAndToolbarShow,target:this})},onToolbarShow:function(){a.Events.fire(this,{type:g.EventTypes.onCaptionAndToolbarShow, +target:this})},onToolbarBeforeHide:function(){a.Events.fire(this,{type:g.EventTypes.onBeforeCaptionAndToolbarHide,target:this})},onToolbarHide:function(){a.Events.fire(this,{type:g.EventTypes.onCaptionAndToolbarHide,target:this})},onZoomPanRotateTransform:function(b){a.Events.fire(this,{target:this,type:g.EventTypes.onZoomPanRotateTransform,scale:b.scale,rotation:b.rotation,rotationDegs:b.rotationDegs,translateX:b.translateX,translateY:b.translateY})}})})(window,window.klass,window.Code.Util,window.Code.PhotoSwipe.Cache, +window.Code.PhotoSwipe.DocumentOverlay,window.Code.PhotoSwipe.Carousel,window.Code.PhotoSwipe.Toolbar,window.Code.PhotoSwipe.UILayer,window.Code.PhotoSwipe.ZoomPanRotate); diff --git a/photoswipe/noutil/code.photoswipe.noutil.jquery-3.0.5.js b/photoswipe/noutil/code.photoswipe.noutil.jquery-3.0.5.js new file mode 100755 index 0000000..11055c6 --- /dev/null +++ b/photoswipe/noutil/code.photoswipe.noutil.jquery-3.0.5.js @@ -0,0 +1,4344 @@ +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.EventTypes = { + + onLoad: 'onLoad', + onError: 'onError' + + }; + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Image'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Image.ImageClass = klass({ + + + + refObj: null, + imageEl: null, + src: null, + caption: null, + metaData: null, + imageLoadHandler: null, + imageErrorHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i; + + this.shrinkImage(); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(refObj, src, caption, metaData){ + + this.refObj = refObj; + // This is needed. Webkit resolves the src + // value which means we can't compare against it in the load function + this.originalSrc = src; + this.src = src; + this.caption = caption; + this.metaData = metaData; + + this.imageEl = new window.Image(); + + this.imageLoadHandler = this.onImageLoad.bind(this); + this.imageErrorHandler = this.onImageError.bind(this); + + }, + + + + /* + * Function: load + */ + load: function(){ + + this.imageEl.originalSrc = Util.coalesce(this.imageEl.originalSrc, ''); + + if (this.imageEl.originalSrc === this.src){ + + if (this.imageEl.isError){ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + } + else{ + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + } + return; + } + + this.imageEl.isError = false; + this.imageEl.isLoading = true; + this.imageEl.naturalWidth = null; + this.imageEl.naturalHeight = null; + this.imageEl.isLandscape = false; + this.imageEl.onload = this.imageLoadHandler; + this.imageEl.onerror = this.imageErrorHandler; + this.imageEl.onabort = this.imageErrorHandler; + this.imageEl.originalSrc = this.src; + this.imageEl.src = this.src; + + }, + + + + /* + * Function: shrinkImage + */ + shrinkImage: function(){ + + if (Util.isNothing(this.imageEl)){ + return; + } + + if (this.imageEl.src.indexOf(this.src) > -1){ + this.imageEl.src = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='; + if (!Util.isNothing(this.imageEl.parentNode)){ + Util.DOM.removeChild(this.imageEl, this.imageEl.parentNode); + } + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + this.imageEl.onload = null; + this.imageEl.naturalWidth = Util.coalesce(this.imageEl.naturalWidth, this.imageEl.width); + this.imageEl.naturalHeight = Util.coalesce(this.imageEl.naturalHeight, this.imageEl.height); + this.imageEl.isLandscape = (this.imageEl.naturalWidth > this.imageEl.naturalHeight); + this.imageEl.isLoading = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onLoad, + target: this + }); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + this.imageEl.onload = null; + this.imageEl.onerror = null; + this.imageEl.onabort = null; + this.imageEl.isLoading = false; + this.imageEl.isError = true; + + Util.Events.fire(this, { + type: PhotoSwipe.Image.EventTypes.onError, + target: this + }); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Cache'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Cache.Mode = { + + normal: 'normal', + aggressive: 'aggressive' + + }; + + + + PhotoSwipe.Cache.Functions = { + + /* + * Function: getImageSource + * Default method for returning an image's source + */ + getImageSource: function(el){ + return el.href; + }, + + + + /* + * Function: getImageCaption + * Default method for returning an image's caption + * Assumes the el is an anchor and the first child is the + * image. The returned value is the "alt" attribute of the + * image. + */ + getImageCaption: function(el){ + + if (el.nodeName === "IMG"){ + return Util.DOM.getAttribute(el, 'alt'); + } + var i, j, childEl; + for (i=0, j=el.childNodes.length; i height){ + height = Util.DOM.windowHeight(); + } + + } + else{ + + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + + } + + Util.DOM.setStyle(this.el, { + width: width, + height: height, + top: top + }); + + }, + + + + /* + * Function: fadeIn + */ + fadeIn: function(speed, callback){ + + this.resetPosition(); + + Util.DOM.setStyle(this.el, 'opacity', 0); + Util.DOM.show(this.el); + + Util.Animation.fadeIn(this.el, speed, callback); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.Carousel.EventTypes = { + + onSlideByEnd: 'PhotoSwipeCarouselOnSlideByEnd', + onSlideshowStart: 'PhotoSwipeCarouselOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeCarouselOnSlideshowStop' + + }; + + + + PhotoSwipe.Carousel.CssClasses = { + carousel: 'ps-carousel', + content: 'ps-carousel-content', + item: 'ps-carousel-item', + itemLoading: 'ps-carousel-item-loading', + itemError: 'ps-carousel-item-error' + }; + + + + PhotoSwipe.Carousel.SlideByAction = { + previous: 'previous', + current: 'current', + next: 'next' + }; + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = klass({ + + + + el: null, + contentEl: null, + settings: null, + cache: null, + slideByEndHandler: null, + currentCacheIndex: null, + isSliding: null, + isSlideshowActive: null, + lastSlideByAction: null, + touchStartPoint: null, + touchStartPosition: null, + imageLoadHandler: null, + imageErrorHandler: null, + slideshowTimeout: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop, i, j; + + for (i=0, j=this.cache.images.length; i 0){ + Util.DOM.setStyle(itemEl, { + marginRight: this.settings.margin + 'px' + }); + } + + Util.DOM.appendChild(itemEl, this.contentEl); + + } + + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + }, + + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, height, top, itemWidth, itemEls, contentWidth, i, j, itemEl, imageEl; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + width = Util.DOM.width(this.settings.target); + height = Util.DOM.height(this.settings.target); + top = '0px'; + } + + itemWidth = (this.settings.margin > 0) ? width + this.settings.margin : width; + itemEls = Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + contentWidth = itemWidth * itemEls.length; + + + // Set the height and width to fill the document + Util.DOM.setStyle(this.el, { + top: top, + width: width, + height: height + }); + + + // Set the height and width of the content el + Util.DOM.setStyle(this.contentEl, { + width: contentWidth, + height: height + }); + + + // Set the height and width of item elements + for (i=0, j=itemEls.length; i maxWidth){ + scale = maxWidth / newWidth; + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + if (newHeight > maxHeight){ + scale = maxHeight / newHeight; + newHeight = Math.round(newHeight * scale); + newWidth = Math.round(newWidth * scale); + } + + } + else{ + + if (imageEl.isLandscape) { + // Ensure the width fits the screen + scale = maxWidth / imageEl.naturalWidth; + } + else { + // Ensure the height fits the screen + scale = maxHeight / imageEl.naturalHeight; + } + + newWidth = Math.round(imageEl.naturalWidth * scale); + newHeight = Math.round(imageEl.naturalHeight * scale); + + if (this.settings.imageScaleMethod === 'zoom'){ + + scale = 1; + if (newHeight < maxHeight){ + scale = maxHeight /newHeight; + } + else if (newWidth < maxWidth){ + scale = maxWidth /newWidth; + } + + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + + } + else if (this.settings.imageScaleMethod === 'fit') { + // Rescale again to ensure full image fits into the viewport + scale = 1; + if (newWidth > maxWidth) { + scale = maxWidth / newWidth; + } + else if (newHeight > maxHeight) { + scale = maxHeight / newHeight; + } + if (scale !== 1) { + newWidth = Math.round(newWidth * scale); + newHeight = Math.round(newHeight * scale); + } + } + + } + + newTop = Math.round( ((maxHeight - newHeight) / 2) ) + 'px'; + newLeft = Math.round( ((maxWidth - newWidth) / 2) ) + 'px'; + + Util.DOM.setStyle(imageEl, { + position: 'absolute', + width: newWidth, + height: newHeight, + top: newTop, + left: newLeft, + display: 'block' + }); + + }, + + + + /* + * Function: setContentLeftPosition + */ + setContentLeftPosition: function(){ + + var width, itemEls, left; + if (this.settings.target === window){ + width = Util.DOM.windowWidth(); + } + else{ + width = Util.DOM.width(this.settings.target); + } + + itemEls = this.getItemEls(); + left = 0; + + if (this.settings.loop){ + left = (width + this.settings.margin) * -1; + } + else{ + + if (this.currentCacheIndex === this.cache.images.length-1){ + left = ((itemEls.length-1) * (width + this.settings.margin)) * -1; + } + else if (this.currentCacheIndex > 0){ + left = (width + this.settings.margin) * -1; + } + + } + + Util.DOM.setStyle(this.contentEl, { + left: left + 'px' + }); + + }, + + + + /* + * Function: + */ + show: function(index){ + + this.currentCacheIndex = index; + this.resetPosition(); + this.setImages(false); + Util.DOM.show(this.el); + + Util.Animation.resetTranslate(this.contentEl); + var + itemEls = this.getItemEls(), + i, j; + for (i=0, j=itemEls.length; i this.cache.images.length-1){ + nextCacheIndex = 0; + } + if (previousCacheIndex < 0){ + previousCacheIndex = this.cache.images.length-1; + } + + cacheImages = this.cache.getImages([ + previousCacheIndex, + this.currentCacheIndex, + nextCacheIndex + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + + } + else{ + + if (itemEls.length === 1){ + if (!ignoreCurrent){ + // Current + cacheImages = this.cache.getImages([ + this.currentCacheIndex + ]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + } + else if (itemEls.length === 2){ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + else{ + + if (this.currentCacheIndex === 0){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex, + this.currentCacheIndex + 1, + this.currentCacheIndex + 2 + ]); + if (!ignoreCurrent){ + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + else if (this.currentCacheIndex === this.cache.images.length-1){ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 2, + this.currentCacheIndex - 1, + this.currentCacheIndex + ]); + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + } + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + else{ + cacheImages = this.cache.getImages([ + this.currentCacheIndex - 1, + this.currentCacheIndex, + this.currentCacheIndex + 1 + ]); + + if (!ignoreCurrent){ + // Current + this.addCacheImageToItemEl(cacheImages[1], itemEls[1]); + } + // Next + this.addCacheImageToItemEl(cacheImages[2], itemEls[2]); + // Previous + this.addCacheImageToItemEl(cacheImages[0], itemEls[0]); + } + + } + + } + + }, + + + + /* + * Function: addCacheImageToItemEl + */ + addCacheImageToItemEl: function(cacheImage, itemEl){ + + Util.DOM.removeClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemError); + Util.DOM.addClass(itemEl, PhotoSwipe.Carousel.CssClasses.itemLoading); + + Util.DOM.removeChildren(itemEl); + + Util.DOM.setStyle(cacheImage.imageEl, { + display: 'none' + }); + Util.DOM.appendChild(cacheImage.imageEl, itemEl); + + Util.Animation.resetTranslate(cacheImage.imageEl); + + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.add(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + cacheImage.load(); + + }, + + + + /* + * Function: slideCarousel + */ + slideCarousel: function(point, action, speed){ + + if (this.isSliding){ + return; + } + + var width, diffX, slideBy; + + if (this.settings.target === window){ + width = Util.DOM.windowWidth() + this.settings.margin; + } + else{ + width = Util.DOM.width(this.settings.target) + this.settings.margin; + } + + speed = Util.coalesce(speed, this.settings.slideSpeed); + + if (window.Math.abs(diffX) < 1){ + return; + } + + + switch (action){ + + case Util.TouchElement.ActionTypes.swipeLeft: + + slideBy = width * -1; + break; + + case Util.TouchElement.ActionTypes.swipeRight: + + slideBy = width; + break; + + default: + + diffX = point.x - this.touchStartPoint.x; + + if (window.Math.abs(diffX) > width / 2){ + slideBy = (diffX > 0) ? width : width * -1; + } + else{ + slideBy = 0; + } + break; + + } + + if (slideBy < 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.next; + } + else if (slideBy > 0){ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.previous; + } + else{ + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + + // Check for non-looping carousels + // If we are at the start or end, spring back to the current item element + if (!this.settings.loop){ + if ( (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous && this.currentCacheIndex === 0 ) || (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next && this.currentCacheIndex === this.cache.images.length-1) ){ + slideBy = 0; + this.lastSlideByAction = PhotoSwipe.Carousel.SlideByAction.current; + } + } + + this.isSliding = true; + this.doSlideCarousel(slideBy, speed); + + }, + + + + /* + * Function: + */ + moveCarousel: function(point){ + + if (this.isSliding){ + return; + } + + if (!this.settings.enableDrag){ + return; + } + + this.doMoveCarousel(point.x - this.touchStartPoint.x); + + }, + + + + /* + * Function: getItemEls + */ + getItemEls: function(){ + + return Util.DOM.find('.' + PhotoSwipe.Carousel.CssClasses.item, this.contentEl); + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeRight, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: next + */ + next: function(){ + + this.stopSlideshow(); + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft, this.settings.nextPreviousSlideSpeed); + + }, + + + + /* + * Function: slideshowNext + */ + slideshowNext: function(){ + + this.slideCarousel({x:0, y:0}, Util.TouchElement.ActionTypes.swipeLeft); + + }, + + + + + /* + * Function: startSlideshow + */ + startSlideshow: function(){ + + this.stopSlideshow(); + + this.isSlideshowActive = true; + + this.slideshowTimeout = window.setTimeout(this.slideshowNext.bind(this), this.settings.slideshowDelay); + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: stopSlideshow + */ + stopSlideshow: function(){ + + if (!Util.isNothing(this.slideshowTimeout)){ + + window.clearTimeout(this.slideshowTimeout); + this.slideshowTimeout = null; + this.isSlideshowActive = false; + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideshowStop, + target: this + }); + + } + + }, + + + + /* + * Function: onSlideByEnd + */ + onSlideByEnd: function(e){ + + if (Util.isNothing(this.isSliding)){ + return; + } + + var itemEls = this.getItemEls(); + + this.isSliding = false; + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + this.currentCacheIndex = this.currentCacheIndex + 1; + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + this.currentCacheIndex = this.currentCacheIndex - 1; + } + + if (this.settings.loop){ + + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + + if (this.currentCacheIndex < 0){ + this.currentCacheIndex = this.cache.images.length - 1; + } + else if (this.currentCacheIndex === this.cache.images.length){ + this.currentCacheIndex = 0; + } + + } + else{ + + if (this.cache.images.length > 3){ + + if (this.currentCacheIndex > 1 && this.currentCacheIndex < this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + else if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === 1){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.previous){ + // Move the last to the first + Util.DOM.insertBefore(itemEls[itemEls.length-1], itemEls[0], this.contentEl); + } + } + else if (this.currentCacheIndex === this.cache.images.length-2){ + if (this.lastSlideByAction === PhotoSwipe.Carousel.SlideByAction.next){ + // Move first to the last + Util.DOM.appendChild(itemEls[0], this.contentEl); + } + } + + } + + + } + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.setContentLeftPosition(); + this.setImages(true); + } + + + Util.Events.fire(this, { + type: PhotoSwipe.Carousel.EventTypes.onSlideByEnd, + target: this, + action: this.lastSlideByAction, + cacheIndex: this.currentCacheIndex + }); + + + if (this.isSlideshowActive){ + + if (this.lastSlideByAction !== PhotoSwipe.Carousel.SlideByAction.current){ + this.startSlideshow(); + } + else{ + this.stopSlideshow(); + } + + } + + + }, + + + + /* + * Function: onTouch + */ + onTouch: function(action, point){ + + this.stopSlideshow(); + + switch(action){ + + case Util.TouchElement.ActionTypes.touchStart: + this.touchStartPoint = point; + this.touchStartPosition = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.moveCarousel(point); + break; + + case Util.TouchElement.ActionTypes.touchMoveEnd: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + this.slideCarousel(point, action); + break; + + case Util.TouchElement.ActionTypes.tap: + break; + + case Util.TouchElement.ActionTypes.doubleTap: + break; + + + } + + }, + + + + /* + * Function: onImageLoad + */ + onImageLoad: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + this.resetImagePosition(cacheImage.imageEl); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + }, + + + + /* + * Function: onImageError + */ + onImageError: function(e){ + + var cacheImage = e.target; + + if (!Util.isNothing(cacheImage.imageEl.parentNode)){ + Util.DOM.removeClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemLoading); + Util.DOM.addClass(cacheImage.imageEl.parentNode, PhotoSwipe.Carousel.CssClasses.itemError); + } + + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onLoad, this.imageLoadHandler); + Util.Events.remove(cacheImage, PhotoSwipe.Image.EventTypes.onError, this.imageErrorHandler); + + } + + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util, TouchElement){ + + + Util.registerNamespace('Code.PhotoSwipe.Carousel'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Carousel.CarouselClass = PhotoSwipe.Carousel.CarouselClass.extend({ + + + /* + * Function: getStartingPos + */ + getStartingPos: function(){ + + var startingPos = this.touchStartPosition; + + if (Util.isNothing(startingPos)){ + startingPos = { + x: window.parseInt(Util.DOM.getStyle(this.contentEl, 'left'), 0), + y: window.parseInt(Util.DOM.getStyle(this.contentEl, 'top'), 0) + }; + } + + return startingPos; + + }, + + + + /* + * Function: doMoveCarousel + */ + doMoveCarousel: function(xVal){ + + var style; + + if (Util.Browser.isCSSTransformSupported){ + + style = {}; + + style[Util.Animation._transitionPrefix + 'Property'] = 'all'; + style[Util.Animation._transitionPrefix + 'Duration'] = ''; + style[Util.Animation._transitionPrefix + 'TimingFunction'] = ''; + style[Util.Animation._transitionPrefix + 'Delay'] = '0'; + style[Util.Animation._transformLabel] = (Util.Browser.is3dSupported) ? 'translate3d(' + xVal + 'px, 0px, 0px)' : 'translate(' + xVal + 'px, 0px)'; + + Util.DOM.setStyle(this.contentEl, style); + + } + else if (!Util.isNothing(window.jQuery)){ + + + window.jQuery(this.contentEl).stop().css('left', this.getStartingPos().x + xVal + 'px'); + + } + + }, + + + + /* + * Function: doSlideCarousel + */ + doSlideCarousel: function(xVal, speed){ + + var animateProps, transform; + + if (speed <= 0){ + + this.slideByEndHandler(); + return; + + } + + + if (Util.Browser.isCSSTransformSupported){ + + transform = Util.coalesce(this.contentEl.style.webkitTransform, this.contentEl.style.MozTransform, this.contentEl.style.transform, ''); + if (transform.indexOf('translate3d(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + else if (transform.indexOf('translate(' + xVal) === 0){ + this.slideByEndHandler(); + return; + } + + Util.Animation.slideBy(this.contentEl, xVal, 0, speed, this.slideByEndHandler, this.settings.slideTimingFunction); + + } + else if (!Util.isNothing(window.jQuery)){ + + animateProps = { + left: this.getStartingPos().x + xVal + 'px' + }; + + if (this.settings.animationTimingFunction === 'ease-out'){ + this.settings.animationTimingFunction = 'easeOutQuad'; + } + + if ( Util.isNothing(window.jQuery.easing[this.settings.animationTimingFunction]) ){ + this.settings.animationTimingFunction = 'linear'; + } + + window.jQuery(this.contentEl).animate( + animateProps, + this.settings.slideSpeed, + this.settings.animationTimingFunction, + this.slideByEndHandler + ); + + } + + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.TouchElement +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.CssClasses = { + toolbar: 'ps-toolbar', + toolbarContent: 'ps-toolbar-content', + toolbarTop: 'ps-toolbar-top', + caption: 'ps-caption', + captionBottom: 'ps-caption-bottom', + captionContent: 'ps-caption-content', + close: 'ps-toolbar-close', + play: 'ps-toolbar-play', + previous: 'ps-toolbar-previous', + previousDisabled: 'ps-toolbar-previous-disabled', + next: 'ps-toolbar-next', + nextDisabled: 'ps-toolbar-next-disabled' + }; + + + + PhotoSwipe.Toolbar.ToolbarAction = { + close: 'close', + play: 'play', + next: 'next', + previous: 'previous', + none: 'none' + }; + + + + PhotoSwipe.Toolbar.EventTypes = { + onTap: 'PhotoSwipeToolbarOnClick', + onBeforeShow: 'PhotoSwipeToolbarOnBeforeShow', + onShow: 'PhotoSwipeToolbarOnShow', + onBeforeHide: 'PhotoSwipeToolbarOnBeforeHide', + onHide: 'PhotoSwipeToolbarOnHide' + }; + + + + PhotoSwipe.Toolbar.getToolbar = function(){ + + return '
'; + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.Toolbar'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.Toolbar.ToolbarClass = klass({ + + + + toolbarEl: null, + closeEl: null, + playEl: null, + previousEl: null, + nextEl: null, + captionEl: null, + captionContentEl: null, + currentCaption: null, + settings: null, + cache: null, + timeout: null, + isVisible: null, + fadeOutHandler: null, + touchStartHandler: null, + touchMoveHandler: null, + clickHandler: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.clearTimeout(); + + this.removeEventHandlers(); + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + Util.DOM.removeChild(this.toolbarEl, this.toolbarEl.parentNode); + Util.DOM.removeChild(this.captionEl, this.captionEl.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(cache, options){ + + var cssClass; + + this.settings = options; + this.cache = cache; + this.isVisible = false; + + this.fadeOutHandler = this.onFadeOut.bind(this); + this.touchStartHandler = this.onTouchStart.bind(this); + this.touchMoveHandler = this.onTouchMove.bind(this); + this.clickHandler = this.onClick.bind(this); + + + cssClass = PhotoSwipe.Toolbar.CssClasses.toolbar; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.toolbarTop; + } + + + // Toolbar + this.toolbarEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + this.settings.getToolbar() + ); + + + Util.DOM.setStyle(this.toolbarEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.toolbarEl); + } + else{ + Util.DOM.appendChild(this.toolbarEl, this.settings.target); + } + Util.DOM.hide(this.toolbarEl); + + this.closeEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.close, this.toolbarEl)[0]; + if (this.settings.preventHide && !Util.isNothing(this.closeEl)){ + Util.DOM.hide(this.closeEl); + } + + this.playEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.play, this.toolbarEl)[0]; + if (this.settings.preventSlideshow && !Util.isNothing(this.playEl)){ + Util.DOM.hide(this.playEl); + } + + this.nextEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.next, this.toolbarEl)[0]; + this.previousEl = Util.DOM.find('.' + PhotoSwipe.Toolbar.CssClasses.previous, this.toolbarEl)[0]; + + + // Caption + cssClass = PhotoSwipe.Toolbar.CssClasses.caption; + if (this.settings.captionAndToolbarFlipPosition){ + cssClass = cssClass + ' ' + PhotoSwipe.Toolbar.CssClasses.captionBottom; + } + + this.captionEl = Util.DOM.createElement( + 'div', + { + 'class': cssClass + }, + '' + ); + Util.DOM.setStyle(this.captionEl, { + left: 0, + position: 'absolute', + overflow: 'hidden', + zIndex: this.settings.zIndex + }); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.captionEl); + } + else{ + Util.DOM.appendChild(this.captionEl, this.settings.target); + } + Util.DOM.hide(this.captionEl); + + this.captionContentEl = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.Toolbar.CssClasses.captionContent + }, + '' + ); + Util.DOM.appendChild(this.captionContentEl, this.captionEl); + + this.addEventHandlers(); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + var width, toolbarTop, captionTop; + + if (this.settings.target === window){ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = Util.DOM.windowScrollTop(); + captionTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.captionEl); + } + else { + toolbarTop = (Util.DOM.windowScrollTop() + Util.DOM.windowHeight()) - Util.DOM.height(this.toolbarEl); + captionTop = Util.DOM.windowScrollTop(); + } + width = Util.DOM.windowWidth(); + } + else{ + if (this.settings.captionAndToolbarFlipPosition){ + toolbarTop = '0'; + captionTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.captionEl); + } + else{ + toolbarTop = Util.DOM.height(this.settings.target) - Util.DOM.height(this.toolbarEl); + captionTop = 0; + } + width = Util.DOM.width(this.settings.target); + } + + Util.DOM.setStyle(this.toolbarEl, { + top: toolbarTop + 'px', + width: width + }); + + Util.DOM.setStyle(this.captionEl, { + top: captionTop + 'px', + width: width + }); + }, + + + + /* + * Function: toggleVisibility + */ + toggleVisibility: function(index){ + + if (this.isVisible){ + this.fadeOut(); + } + else{ + this.show(index); + } + + }, + + + + /* + * Function: show + */ + show: function(index){ + + Util.Animation.stop(this.toolbarEl); + Util.Animation.stop(this.captionEl); + + this.resetPosition(); + this.setToolbarStatus(index); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeShow, + target: this + }); + + this.showToolbar(); + this.setCaption(index); + this.showCaption(); + + this.isVisible = true; + + this.setTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onShow, + target: this + }); + + }, + + + + /* + * Function: setTimeout + */ + setTimeout: function(){ + + if (this.settings.captionAndToolbarAutoHideDelay > 0){ + // Set a timeout to hide the toolbar + this.clearTimeout(); + this.timeout = window.setTimeout(this.fadeOut.bind(this), this.settings.captionAndToolbarAutoHideDelay); + } + + }, + + + + /* + * Function: clearTimeout + */ + clearTimeout: function(){ + + if (!Util.isNothing(this.timeout)){ + window.clearTimeout(this.timeout); + this.timeout = null; + } + + }, + + + + /* + * Function: fadeOut + */ + fadeOut: function(){ + + this.clearTimeout(); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onBeforeHide, + target: this + }); + + Util.Animation.fadeOut(this.toolbarEl, this.settings.fadeOutSpeed); + Util.Animation.fadeOut(this.captionEl, this.settings.fadeOutSpeed, this.fadeOutHandler); + + this.isVisible = false; + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.add(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.add(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.add(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.add(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.isTouchSupported){ + if (!Util.Browser.blackberry){ + // Had an issue with touchstart, animation and Blackberry. BB will default to click + Util.Events.remove(this.toolbarEl, 'touchstart', this.touchStartHandler); + } + Util.Events.remove(this.toolbarEl, 'touchmove', this.touchMoveHandler); + Util.Events.remove(this.captionEl, 'touchmove', this.touchMoveHandler); + } + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + + }, + + + + /* + * Function: handleTap + */ + handleTap: function(e){ + + this.clearTimeout(); + + var action; + + if (e.target === this.nextEl || Util.DOM.isChildOf(e.target, this.nextEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.next; + } + else if (e.target === this.previousEl || Util.DOM.isChildOf(e.target, this.previousEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.previous; + } + else if (e.target === this.closeEl || Util.DOM.isChildOf(e.target, this.closeEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.close; + } + else if (e.target === this.playEl || Util.DOM.isChildOf(e.target, this.playEl)){ + action = PhotoSwipe.Toolbar.ToolbarAction.play; + } + + this.setTimeout(); + + if (Util.isNothing(action)){ + action = PhotoSwipe.Toolbar.ToolbarAction.none; + } + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onTap, + target: this, + action: action, + tapTarget: e.target + }); + + }, + + + + /* + * Function: setCaption + */ + setCaption: function(index){ + + Util.DOM.removeChildren(this.captionContentEl); + + this.currentCaption = Util.coalesce(this.cache.images[index].caption, '\u00A0'); + + if (Util.isObject(this.currentCaption)){ + Util.DOM.appendChild(this.currentCaption, this.captionContentEl); + } + else{ + if (this.currentCaption === ''){ + this.currentCaption = '\u00A0'; + } + Util.DOM.appendText(this.currentCaption, this.captionContentEl); + } + + this.currentCaption = (this.currentCaption === '\u00A0') ? '' : this.currentCaption; + this.resetPosition(); + + }, + + + + /* + * Function: showToolbar + */ + showToolbar: function(){ + + Util.DOM.setStyle(this.toolbarEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.toolbarEl); + + }, + + + + /* + * Function: showCaption + */ + showCaption: function(){ + + if (this.currentCaption === '' || this.captionContentEl.childNodes.length < 1){ + // Empty caption + if (!this.settings.captionAndToolbarShowEmptyCaptions){ + Util.DOM.hide(this.captionEl); + return; + } + } + Util.DOM.setStyle(this.captionEl, { + opacity: this.settings.captionAndToolbarOpacity + }); + Util.DOM.show(this.captionEl); + + }, + + + + /* + * Function: setToolbarStatus + */ + setToolbarStatus: function(index){ + + if (this.settings.loop){ + return; + } + + Util.DOM.removeClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + Util.DOM.removeClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + + if (index > 0 && index < this.cache.images.length-1){ + return; + } + + if (index === 0){ + if (!Util.isNothing(this.previousEl)){ + Util.DOM.addClass(this.previousEl, PhotoSwipe.Toolbar.CssClasses.previousDisabled); + } + } + + if (index === this.cache.images.length-1){ + if (!Util.isNothing(this.nextEl)){ + Util.DOM.addClass(this.nextEl, PhotoSwipe.Toolbar.CssClasses.nextDisabled); + } + } + + }, + + + + /* + * Function: onFadeOut + */ + onFadeOut: function(){ + + Util.DOM.hide(this.toolbarEl); + Util.DOM.hide(this.captionEl); + + Util.Events.fire(this, { + type: PhotoSwipe.Toolbar.EventTypes.onHide, + target: this + }); + + }, + + + + /* + * Function: onTouchStart + */ + onTouchStart: function(e){ + + e.preventDefault(); + Util.Events.remove(this.toolbarEl, 'click', this.clickHandler); + this.handleTap(e); + + }, + + + + /* + * Function: onTouchMove + */ + onTouchMove: function(e){ + + e.preventDefault(); + + }, + + + + /* + * Function: onClick + */ + onClick: function(e){ + + e.preventDefault(); + this.handleTap(e); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.UILayer.CssClasses = { + uiLayer: 'ps-uilayer' + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.UILayer'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.UILayer.UILayerClass = Util.TouchElement.TouchElementClass.extend({ + + + + el: null, + settings: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + this.removeEventHandlers(); + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options){ + + this.settings = options; + + // Main container + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.UILayer.CssClasses.uiLayer + }, + '' + ); + Util.DOM.setStyle(this.el, { + display: 'block', + position: 'absolute', + left: 0, + top: 0, + overflow: 'hidden', + zIndex: this.settings.zIndex, + opacity: 0 + }); + Util.DOM.hide(this.el); + + if (this.settings.target === window){ + Util.DOM.appendToBody(this.el); + } + else{ + Util.DOM.appendChild(this.el, this.settings.target); + } + + this.supr(this.el, { + swipe: true, + move: true, + gesture: Util.Browser.iOS, + doubleTap: true, + preventDefaultTouchEvents: this.settings.preventDefaultTouchEvents + }); + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + // Set the height and width to fill the document + if (this.settings.target === window){ + Util.DOM.setStyle(this.el, { + top: Util.DOM.windowScrollTop() + 'px', + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }); + } + else{ + Util.DOM.setStyle(this.el, { + top: '0px', + width: Util.DOM.width(this.settings.target), + height: Util.DOM.height(this.settings.target) + }); + } + + }, + + + + /* + * Function: show + */ + show: function(){ + + this.resetPosition(); + Util.DOM.show(this.el); + this.addEventHandlers(); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + this.supr(); + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + this.supr(); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + PhotoSwipe.ZoomPanRotate.CssClasses = { + zoomPanRotate: 'ps-zoom-pan-rotate' + }; + + + PhotoSwipe.ZoomPanRotate.EventTypes = { + + onTransform: 'PhotoSwipeZoomPanRotateOnTransform' + + }; + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, klass, Util){ + + + Util.registerNamespace('Code.PhotoSwipe.ZoomPanRotate'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + PhotoSwipe.ZoomPanRotate.ZoomPanRotateClass = klass({ + + el: null, + settings: null, + containerEl: null, + imageEl: null, + transformSettings: null, + panStartingPoint: null, + transformEl: null, + + + + /* + * Function: dispose + */ + dispose: function(){ + + var prop; + + Util.DOM.removeChild(this.el, this.el.parentNode); + + for (prop in this) { + if (Util.objectHasProperty(this, prop)) { + this[prop] = null; + } + } + + }, + + + + /* + * Function: initialize + */ + initialize: function(options, cacheImage, uiLayer){ + + var parentEl, width, height, top; + + this.settings = options; + + if (this.settings.target === window){ + parentEl = document.body; + width = Util.DOM.windowWidth(); + height = Util.DOM.windowHeight(); + top = Util.DOM.windowScrollTop() + 'px'; + } + else{ + parentEl = this.settings.target; + width = Util.DOM.width(parentEl); + height = Util.DOM.height(parentEl); + top = '0px'; + } + + this.imageEl = cacheImage.imageEl.cloneNode(false); + Util.DOM.setStyle(this.imageEl, { + + zIndex: 1 + + }); + + this.transformSettings = { + + startingScale: 1.0, + scale: 1.0, + startingRotation: 0, + rotation: 0, + startingTranslateX: 0, + startingTranslateY: 0, + translateX: 0, + translateY: 0 + + }; + + + this.el = Util.DOM.createElement( + 'div', + { + 'class': PhotoSwipe.ZoomPanRotate.CssClasses.zoomPanRotate + }, + '' + ); + Util.DOM.setStyle(this.el, { + left: 0, + top: top, + position: 'absolute', + width: width, + height: height, + zIndex: this.settings.zIndex, + display: 'block' + }); + + Util.DOM.insertBefore(this.el, uiLayer.el, parentEl); + + if (Util.Browser.iOS){ + this.containerEl = Util.DOM.createElement('div','',''); + Util.DOM.setStyle(this.containerEl, { + left: 0, + top: 0, + width: width, + height: height, + position: 'absolute', + zIndex: 1 + }); + Util.DOM.appendChild(this.imageEl, this.containerEl); + Util.DOM.appendChild(this.containerEl, this.el); + Util.Animation.resetTranslate(this.containerEl); + Util.Animation.resetTranslate(this.imageEl); + this.transformEl = this.containerEl; + } + else{ + Util.DOM.appendChild(this.imageEl, this.el); + this.transformEl = this.imageEl; + } + + }, + + + + /* + * Function: setStartingTranslateFromCurrentTransform + */ + setStartingTranslateFromCurrentTransform: function(){ + + var + transformValue = Util.coalesce(this.transformEl.style.webkitTransform, this.transformEl.style.MozTransform, this.transformEl.style.transform), + transformExploded; + + if (!Util.isNothing(transformValue)){ + + transformExploded = transformValue.match( /translate\((.*?)\)/ ); + + if (!Util.isNothing(transformExploded)){ + + transformExploded = transformExploded[1].split(', '); + this.transformSettings.startingTranslateX = window.parseInt(transformExploded[0], 10); + this.transformSettings.startingTranslateY = window.parseInt(transformExploded[1], 10); + + } + + } + + }, + + + + /* + * Function: getScale + */ + getScale: function(scaleValue){ + + var scale = this.transformSettings.startingScale * scaleValue; + + if (this.settings.minUserZoom !== 0 && scale < this.settings.minUserZoom){ + scale = this.settings.minUserZoom; + } + else if (this.settings.maxUserZoom !== 0 && scale > this.settings.maxUserZoom){ + scale = this.settings.maxUserZoom; + } + + return scale; + + }, + + + + /* + * Function: setStartingScaleAndRotation + */ + setStartingScaleAndRotation: function(scaleValue, rotationValue){ + + this.transformSettings.startingScale = this.getScale(scaleValue); + + this.transformSettings.startingRotation = + (this.transformSettings.startingRotation + rotationValue) % 360; + + }, + + + + /* + * Function: zoomRotate + */ + zoomRotate: function(scaleValue, rotationValue){ + + this.transformSettings.scale = this.getScale(scaleValue); + + this.transformSettings.rotation = + this.transformSettings.startingRotation + rotationValue; + + this.applyTransform(); + + }, + + + + /* + * Function: panStart + */ + panStart: function(point){ + + this.setStartingTranslateFromCurrentTransform(); + + this.panStartingPoint = { + x: point.x, + y: point.y + }; + + }, + + + + /* + * Function: pan + */ + pan: function(point){ + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale , + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + this.transformSettings.startingTranslateX + dxScaleAdjust; + + this.transformSettings.translateY = + this.transformSettings.startingTranslateY + dyScaleAdjust; + + this.applyTransform(); + + }, + + + + /* + * Function: zoomAndPanToPoint + */ + zoomAndPanToPoint: function(scaleValue, point){ + + + if (this.settings.target === window){ + + this.panStart({ + x: Util.DOM.windowWidth() / 2, + y: Util.DOM.windowHeight() / 2 + }); + + var + dx = point.x - this.panStartingPoint.x, + dy = point.y - this.panStartingPoint.y, + dxScaleAdjust = dx / this.transformSettings.scale, + dyScaleAdjust = dy / this.transformSettings.scale; + + this.transformSettings.translateX = + (this.transformSettings.startingTranslateX + dxScaleAdjust) * -1; + + this.transformSettings.translateY = + (this.transformSettings.startingTranslateY + dyScaleAdjust) * -1; + + } + + + this.setStartingScaleAndRotation(scaleValue, 0); + this.transformSettings.scale = this.transformSettings.startingScale; + + this.transformSettings.rotation = 0; + + this.applyTransform(); + + }, + + + + /* + * Function: applyTransform + */ + applyTransform: function(){ + + var + rotationDegs = this.transformSettings.rotation % 360, + translateX = window.parseInt(this.transformSettings.translateX, 10), + translateY = window.parseInt(this.transformSettings.translateY, 10), + transform = 'scale(' + this.transformSettings.scale + ') rotate(' + rotationDegs + 'deg) translate(' + translateX + 'px, ' + translateY + 'px)'; + + Util.DOM.setStyle(this.transformEl, { + webkitTransform: transform, + MozTransform: transform, + msTransform: transform, + transform: transform + }); + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, + scale: this.transformSettings.scale, + rotation: this.transformSettings.rotation, + rotationDegs: rotationDegs, + translateX: translateX, + translateY: translateY + }); + + } + + }); + + + +} +( + window, + window.klass, + window.Code.Util +));// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 + +(function(window, Util){ + + + Util.registerNamespace('Code.PhotoSwipe'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.CssClasses = { + buildingBody: 'ps-building', + activeBody: 'ps-active' + }; + + + + PhotoSwipe.EventTypes = { + + onBeforeShow: 'PhotoSwipeOnBeforeShow', + onShow: 'PhotoSwipeOnShow', + onBeforeHide: 'PhotoSwipeOnBeforeHide', + onHide: 'PhotoSwipeOnHide', + onDisplayImage: 'PhotoSwipeOnDisplayImage', + onResetPosition: 'PhotoSwipeOnResetPosition', + onSlideshowStart: 'PhotoSwipeOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeOnSlideshowStop', + onTouch: 'PhotoSwipeOnTouch', + onBeforeCaptionAndToolbarShow: 'PhotoSwipeOnBeforeCaptionAndToolbarShow', + onCaptionAndToolbarShow: 'PhotoSwipeOnCaptionAndToolbarShow', + onBeforeCaptionAndToolbarHide: 'PhotoSwipeOnBeforeCaptionAndToolbarHide', + onCaptionAndToolbarHide: 'PhotoSwipeOnCaptionAndToolbarHide', + onToolbarTap: 'PhotoSwipeOnToolbarTap', + onBeforeZoomPanRotateShow: 'PhotoSwipeOnBeforeZoomPanRotateShow', + onZoomPanRotateShow: 'PhotoSwipeOnZoomPanRotateShow', + onBeforeZoomPanRotateHide: 'PhotoSwipeOnBeforeZoomPanRotateHide', + onZoomPanRotateHide: 'PhotoSwipeOnZoomPanRotateHide', + onZoomPanRotateTransform: 'PhotoSwipeOnZoomPanRotateTransform' + + }; + + + + PhotoSwipe.instances = []; + PhotoSwipe.activeInstances = []; + + + + /* + * Function: Code.PhotoSwipe.setActivateInstance + */ + PhotoSwipe.setActivateInstance = function(instance){ + + // Can only have one instance per target (i.e. window or div) + var index = Util.arrayIndexOf(instance.settings.target, PhotoSwipe.activeInstances, 'target'); + if (index > -1){ + throw 'Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target'; + } + PhotoSwipe.activeInstances.push({ + target: instance.settings.target, + instance: instance + }); + + }; + + + + /* + * Function: Code.PhotoSwipe.unsetActivateInstance + */ + PhotoSwipe.unsetActivateInstance = function(instance){ + + var index = Util.arrayIndexOf(instance, PhotoSwipe.activeInstances, 'instance'); + PhotoSwipe.activeInstances.splice(index, 1); + + }; + + + + /* + * Function: Code.PhotoSwipe.attach + */ + PhotoSwipe.attach = function(images, options, id){ + + var i, j, instance, image; + + instance = PhotoSwipe.createInstance(images, options, id); + + // Add click event handlers if applicable + for (i=0, j=images.length; i= 2.1){ + this.isBackEventSupported = true; + } + } + + if (!this.isBackEventSupported){ + this.isBackEventSupported = Util.objectHasProperty(window, 'onhashchange'); + } + + this.settings = { + + // General + fadeInSpeed: 250, + fadeOutSpeed: 250, + preventHide: false, + preventSlideshow: false, + zIndex: 1000, + backButtonHideEnabled: true, + enableKeyboard: true, + enableMouseWheel: true, + mouseWheelSpeed: 350, + autoStartSlideshow: false, + jQueryMobile: ( !Util.isNothing(window.jQuery) && !Util.isNothing(window.jQuery.mobile) ), + jQueryMobileDialogHash: '&ui-state=dialog', + enableUIWebViewRepositionTimeout: false, + uiWebViewResetPositionDelay: 500, + target: window, + preventDefaultTouchEvents: true, + + + // Carousel + loop: true, + slideSpeed: 250, + nextPreviousSlideSpeed: 0, + enableDrag: true, + swipeThreshold: 50, + swipeTimeThreshold: 250, + slideTimingFunction: 'ease-out', + slideshowDelay: 3000, + doubleTapSpeed: 250, + margin: 20, + imageScaleMethod: 'fit', // Either "fit", "fitNoUpscale" or "zoom", + + + // Toolbar + captionAndToolbarHide: false, + captionAndToolbarFlipPosition: false, + captionAndToolbarAutoHideDelay: 5000, + captionAndToolbarOpacity: 0.8, + captionAndToolbarShowEmptyCaptions: true, + getToolbar: PhotoSwipe.Toolbar.getToolbar, + + + // ZoomPanRotate + allowUserZoom: true, + allowRotationOnUserZoom: false, + maxUserZoom: 5.0, + minUserZoom: 0.5, + doubleTapZoomLevel: 2.5, + + + // Cache + getImageSource: PhotoSwipe.Cache.Functions.getImageSource, + getImageCaption: PhotoSwipe.Cache.Functions.getImageCaption, + getImageMetaData: PhotoSwipe.Cache.Functions.getImageMetaData, + cacheMode: PhotoSwipe.Cache.Mode.normal + + }; + + Util.extend(this.settings, options); + + if (this.settings.target !== window){ + targetPosition = Util.DOM.getStyle(this.settings.target, 'position'); + if (targetPosition !== 'relative' || targetPosition !== 'absolute'){ + Util.DOM.setStyle(this.settings.target, 'position', 'relative'); + } + } + + if (this.settings.target !== window){ + this.isBackEventSupported = false; + this.settings.backButtonHideEnabled = false; + } + else{ + if (this.settings.preventHide){ + this.settings.backButtonHideEnabled = false; + } + } + + this.cache = new Cache.CacheClass(images, this.settings); + + }, + + + + /* + * Function: show + */ + show: function(obj){ + + var i, j; + + this._isResettingPosition = false; + this.backButtonClicked = false; + + // Work out what the starting index is + if (Util.isNumber(obj)){ + this.currentIndex = obj; + } + else{ + + this.currentIndex = -1; + for (i=0, j=this.originalImages.length; i this.originalImages.length-1){ + throw "Code.PhotoSwipe.PhotoSwipeClass.show: Starting index out of range"; + } + + // Store a reference to the current window dimensions + // Use this later to double check that a window has actually + // been resized. + this.isAlreadyGettingPage = this.getWindowDimensions(); + + // Set this instance to be the active instance + PhotoSwipe.setActivateInstance(this); + + this.windowDimensions = this.getWindowDimensions(); + + // Create components + if (this.settings.target === window){ + Util.DOM.addClass(window.document.body, PhotoSwipe.CssClasses.buildingBody); + } + else{ + Util.DOM.addClass(this.settings.target, PhotoSwipe.CssClasses.buildingBody); + } + this.createComponents(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeShow, + target: this + }); + + // Fade in the document overlay + this.documentOverlay.fadeIn(this.settings.fadeInSpeed, this.onDocumentOverlayFadeIn.bind(this)); + + }, + + + + /* + * Function: getWindowDimensions + */ + getWindowDimensions: function(){ + + return { + width: Util.DOM.windowWidth(), + height: Util.DOM.windowHeight() + }; + + }, + + + + /* + * Function: createComponents + */ + createComponents: function(){ + + this.documentOverlay = new DocumentOverlay.DocumentOverlayClass(this.settings); + this.carousel = new Carousel.CarouselClass(this.cache, this.settings); + this.uiLayer = new UILayer.UILayerClass(this.settings); + if (!this.settings.captionAndToolbarHide){ + this.toolbar = new Toolbar.ToolbarClass(this.cache, this.settings); + } + + }, + + + + /* + * Function: resetPosition + */ + resetPosition: function(){ + + if (this._isResettingPosition){ + return; + } + + var newWindowDimensions = this.getWindowDimensions(); + if (!Util.isNothing(this.windowDimensions)){ + if (newWindowDimensions.width === this.windowDimensions.width && newWindowDimensions.height === this.windowDimensions.height){ + // This was added as a fudge for iOS + return; + } + } + + this._isResettingPosition = true; + + this.windowDimensions = newWindowDimensions; + + this.destroyZoomPanRotate(); + + this.documentOverlay.resetPosition(); + this.carousel.resetPosition(); + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.resetPosition(); + } + + this.uiLayer.resetPosition(); + + this._isResettingPosition = false; + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onResetPosition, + target: this + }); + + }, + + + + /* + * Function: addEventHandler + */ + addEventHandler: function(type, handler){ + + Util.Events.add(this, type, handler); + + }, + + + + /* + * Function: addEventHandlers + */ + addEventHandlers: function(){ + + if (Util.isNothing(this.windowOrientationChangeHandler)){ + + this.windowOrientationChangeHandler = this.onWindowOrientationChange.bind(this); + this.windowScrollHandler = this.onWindowScroll.bind(this); + this.keyDownHandler = this.onKeyDown.bind(this); + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + this.uiLayerTouchHandler = this.onUILayerTouch.bind(this); + this.carouselSlideByEndHandler = this.onCarouselSlideByEnd.bind(this); + this.carouselSlideshowStartHandler = this.onCarouselSlideshowStart.bind(this); + this.carouselSlideshowStopHandler = this.onCarouselSlideshowStop.bind(this); + this.toolbarTapHandler = this.onToolbarTap.bind(this); + this.toolbarBeforeShowHandler = this.onToolbarBeforeShow.bind(this); + this.toolbarShowHandler = this.onToolbarShow.bind(this); + this.toolbarBeforeHideHandler = this.onToolbarBeforeHide.bind(this); + this.toolbarHideHandler = this.onToolbarHide.bind(this); + this.mouseWheelHandler = this.onMouseWheel.bind(this); + this.zoomPanRotateTransformHandler = this.onZoomPanRotateTransform.bind(this); + + } + + // Set window handlers + if (Util.Browser.android){ + // For some reason, resize was more stable than orientationchange in Android + this.orientationEventName = 'resize'; + } + else if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.add(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + else{ + var supportsOrientationChange = !Util.isNothing(window.onorientationchange); + this.orientationEventName = supportsOrientationChange ? 'orientationchange' : 'resize'; + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.add(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + if (this.settings.target === window){ + Util.Events.add(window, 'scroll', this.windowScrollHandler); + } + + if (this.settings.enableKeyboard){ + Util.Events.add(window.document, 'keydown', this.keyDownHandler); + } + + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + + this.windowHashChangeHandler = this.onWindowHashChange.bind(this); + + if (this.settings.jQueryMobile){ + window.location.hash = this.settings.jQueryMobileDialogHash; + } + else{ + this.currentHistoryHashValue = 'PhotoSwipe' + new Date().getTime().toString(); + window.location.hash = this.currentHistoryHashValue; + } + + Util.Events.add(window, 'hashchange', this.windowHashChangeHandler); + + } + + if (this.settings.enableMouseWheel){ + Util.Events.add(window, 'mousewheel', this.mouseWheelHandler); + } + + Util.Events.add(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.add(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + + if (!Util.isNothing(this.toolbar)){ + Util.Events.add(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.add(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + /* + * Function: removeEventHandlers + */ + removeEventHandlers: function(){ + + if (Util.Browser.iOS && (!Util.Browser.safari)){ + Util.Events.remove(window.document.body, 'orientationchange', this.windowOrientationChangeHandler); + } + + if (!Util.isNothing(this.orientationEventName)){ + Util.Events.remove(window, this.orientationEventName, this.windowOrientationChangeHandler); + } + + Util.Events.remove(window, 'scroll', this.windowScrollHandler); + + if (this.settings.enableKeyboard){ + Util.Events.remove(window.document, 'keydown', this.keyDownHandler); + } + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + Util.Events.remove(window, 'hashchange', this.windowHashChangeHandler); + } + + if (this.settings.enableMouseWheel){ + Util.Events.remove(window, 'mousewheel', this.mouseWheelHandler); + } + + if (!Util.isNothing(this.uiLayer)){ + Util.Events.remove(this.uiLayer, Util.TouchElement.EventTypes.onTouch, this.uiLayerTouchHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideByEnd, this.carouselSlideByEndHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStart, this.carouselSlideshowStartHandler); + Util.Events.remove(this.carousel, Carousel.EventTypes.onSlideshowStop, this.carouselSlideshowStopHandler); + } + + if (!Util.isNothing(this.toolbar)){ + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onTap, this.toolbarTapHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeShow, this.toolbarBeforeShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onShow, this.toolbarShowHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onBeforeHide, this.toolbarBeforeHideHandler); + Util.Events.remove(this.toolbar, Toolbar.EventTypes.onHide, this.toolbarHideHandler); + } + + }, + + + + + /* + * Function: hide + */ + hide: function(){ + + if (this.settings.preventHide){ + return; + } + + if (Util.isNothing(this.documentOverlay)){ + throw "Code.PhotoSwipe.PhotoSwipeClass.hide: PhotoSwipe instance is already hidden"; + } + + if (!Util.isNothing(this.hiding)){ + return; + } + + this.clearUIWebViewResetPositionTimeout(); + + this.destroyZoomPanRotate(); + + this.removeEventHandlers(); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeHide, + target: this + }); + + this.uiLayer.dispose(); + this.uiLayer = null; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.dispose(); + this.toolbar = null; + } + + this.carousel.dispose(); + this.carousel = null; + + Util.DOM.removeClass(window.document.body, PhotoSwipe.CssClasses.activeBody); + + this.documentOverlay.dispose(); + this.documentOverlay = null; + + this._isResettingPosition = false; + + // Deactive this instance + PhotoSwipe.unsetActivateInstance(this); + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onHide, + target: this + }); + + this.goBackInHistory(); + + }, + + + + /* + * Function: goBackInHistory + */ + goBackInHistory: function(){ + + if (this.isBackEventSupported && this.settings.backButtonHideEnabled){ + if ( !this.backButtonClicked ){ + window.history.back(); + } + } + + }, + + + + /* + * Function: play + */ + play: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!this.settings.preventSlideshow){ + if (!Util.isNothing(this.carousel)){ + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + this.carousel.startSlideshow(); + } + } + + }, + + + + /* + * Function: stop + */ + stop: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.stopSlideshow(); + } + + }, + + + + /* + * Function: previous + */ + previous: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.previous(); + } + + }, + + + + /* + * Function: next + */ + next: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.carousel)){ + this.carousel.next(); + } + + }, + + + + /* + * Function: toggleToolbar + */ + toggleToolbar: function(){ + + if (this.isZoomActive()){ + return; + } + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.toggleVisibility(this.currentIndex); + } + + }, + + + + /* + * Function: fadeOutToolbarIfVisible + */ + fadeOutToolbarIfVisible: function(){ + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible && this.settings.captionAndToolbarAutoHideDelay > 0){ + this.toolbar.fadeOut(); + } + + }, + + + + /* + * Function: createZoomPanRotate + */ + createZoomPanRotate: function(){ + + this.stop(); + + if (this.canUserZoom() && !this.isZoomActive()){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateShow); + + this.zoomPanRotate = new ZoomPanRotate.ZoomPanRotateClass( + this.settings, + this.cache.images[this.currentIndex], + this.uiLayer + ); + + // If we don't override this in the event of false + // you will be unable to pan around a zoomed image effectively + this.uiLayer.captureSettings.preventDefaultTouchEvents = true; + + Util.Events.add(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateShow); + + if (!Util.isNothing(this.toolbar) && this.toolbar.isVisible){ + this.toolbar.fadeOut(); + } + + } + + }, + + + + /* + * Function: destroyZoomPanRotate + */ + destroyZoomPanRotate: function(){ + + if (!Util.isNothing(this.zoomPanRotate)){ + + Util.Events.fire(this, PhotoSwipe.EventTypes.onBeforeZoomPanRotateHide); + + Util.Events.remove(this.zoomPanRotate, PhotoSwipe.ZoomPanRotate.EventTypes.onTransform, this.zoomPanRotateTransformHandler); + this.zoomPanRotate.dispose(); + this.zoomPanRotate = null; + + // Set the preventDefaultTouchEvents back to it was + this.uiLayer.captureSettings.preventDefaultTouchEvents = this.settings.preventDefaultTouchEvents; + + Util.Events.fire(this, PhotoSwipe.EventTypes.onZoomPanRotateHide); + + } + + }, + + + + /* + * Function: canUserZoom + */ + canUserZoom: function(){ + + var testEl, cacheImage; + + if (Util.Browser.msie){ + testEl = document.createElement('div'); + if (Util.isNothing(testEl.style.msTransform)){ + return false; + } + } + else if (!Util.Browser.isCSSTransformSupported){ + return false; + } + + if (!this.settings.allowUserZoom){ + return false; + } + + + if (this.carousel.isSliding){ + return false; + } + + cacheImage = this.cache.images[this.currentIndex]; + + if (Util.isNothing(cacheImage)){ + return false; + } + + if (cacheImage.isLoading){ + return false; + } + + return true; + + }, + + + + /* + * Function: isZoomActive + */ + isZoomActive: function(){ + + return (!Util.isNothing(this.zoomPanRotate)); + + }, + + + + /* + * Function: getCurrentImage + */ + getCurrentImage: function(){ + + return this.cache.images[this.currentIndex]; + + }, + + + + /* + * Function: onDocumentOverlayFadeIn + */ + onDocumentOverlayFadeIn: function(e){ + + window.setTimeout(function(){ + + var el = (this.settings.target === window) ? window.document.body : this.settings.target; + + Util.DOM.removeClass(el, PhotoSwipe.CssClasses.buildingBody); + Util.DOM.addClass(el, PhotoSwipe.CssClasses.activeBody); + + this.addEventHandlers(); + + this.carousel.show(this.currentIndex); + + this.uiLayer.show(); + + if (this.settings.autoStartSlideshow){ + this.play(); + } + else if (!Util.isNothing(this.toolbar)){ + this.toolbar.show(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onShow, + target: this + }); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), 250); + + + }, + + + + /* + * Function: setUIWebViewResetPositionTimeout + */ + setUIWebViewResetPositionTimeout: function(){ + + if (!this.settings.enableUIWebViewRepositionTimeout){ + return; + } + + if (!(Util.Browser.iOS && (!Util.Browser.safari))){ + return; + } + + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + this._uiWebViewResetPositionTimeout = window.setTimeout(function(){ + + this.resetPosition(); + + this.setUIWebViewResetPositionTimeout(); + + }.bind(this), this.settings.uiWebViewResetPositionDelay); + + }, + + + + /* + * Function: clearUIWebViewResetPositionTimeout + */ + clearUIWebViewResetPositionTimeout: function(){ + if (!Util.isNothing(this._uiWebViewResetPositionTimeout)){ + window.clearTimeout(this._uiWebViewResetPositionTimeout); + } + }, + + + + /* + * Function: onWindowScroll + */ + onWindowScroll: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowOrientationChange + */ + onWindowOrientationChange: function(e){ + + this.resetPosition(); + + }, + + + + /* + * Function: onWindowHashChange + */ + onWindowHashChange: function(e){ + + var compareHash = '#' + + ((this.settings.jQueryMobile) ? this.settings.jQueryMobileDialogHash : this.currentHistoryHashValue); + + if (window.location.hash !== compareHash){ + this.backButtonClicked = true; + this.hide(); + } + + }, + + + + /* + * Function: onKeyDown + */ + onKeyDown: function(e){ + + if (e.keyCode === 37) { // Left + e.preventDefault(); + this.previous(); + } + else if (e.keyCode === 39) { // Right + e.preventDefault(); + this.next(); + } + else if (e.keyCode === 38 || e.keyCode === 40) { // Up and down + e.preventDefault(); + } + else if (e.keyCode === 27) { // Escape + e.preventDefault(); + this.hide(); + } + else if (e.keyCode === 32) { // Spacebar + if (!this.settings.hideToolbar){ + this.toggleToolbar(); + } + else{ + this.hide(); + } + e.preventDefault(); + } + else if (e.keyCode === 13) { // Enter + e.preventDefault(); + this.play(); + } + + }, + + + + /* + * Function: onUILayerTouch + */ + onUILayerTouch: function(e){ + + if (this.isZoomActive()){ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.gestureChange: + this.zoomPanRotate.zoomRotate(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.gestureEnd: + this.zoomPanRotate.setStartingScaleAndRotation(e.scale, (this.settings.allowRotationOnUserZoom) ? e.rotation : 0); + break; + + case Util.TouchElement.ActionTypes.touchStart: + this.zoomPanRotate.panStart(e.point); + break; + + case Util.TouchElement.ActionTypes.touchMove: + this.zoomPanRotate.pan(e.point); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + this.destroyZoomPanRotate(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeLeft: + this.destroyZoomPanRotate(); + this.next(); + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.swipeRight: + this.destroyZoomPanRotate(); + this.previous(); + this.toggleToolbar(); + break; + } + + } + else{ + + switch (e.action){ + + case Util.TouchElement.ActionTypes.touchMove: + case Util.TouchElement.ActionTypes.swipeLeft: + case Util.TouchElement.ActionTypes.swipeRight: + + // Hide the toolbar if need be + this.fadeOutToolbarIfVisible(); + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.touchStart: + case Util.TouchElement.ActionTypes.touchMoveEnd: + + // Pass the touch onto the carousel + this.carousel.onTouch(e.action, e.point); + break; + + case Util.TouchElement.ActionTypes.tap: + this.toggleToolbar(); + break; + + case Util.TouchElement.ActionTypes.doubleTap: + + // Take into consideration the window scroll + if (this.settings.target === window){ + e.point.x -= Util.DOM.windowScrollLeft(); + e.point.y -= Util.DOM.windowScrollTop(); + } + + // Just make sure that if the user clicks out of the image + // that the image does not pan out of view! + var + cacheImageEl = this.cache.images[this.currentIndex].imageEl, + + imageTop = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'top'), 10), + imageLeft = window.parseInt(Util.DOM.getStyle(cacheImageEl, 'left'), 10), + imageRight = imageLeft + Util.DOM.width(cacheImageEl), + imageBottom = imageTop + Util.DOM.height(cacheImageEl); + + if (e.point.x < imageLeft){ + e.point.x = imageLeft; + } + else if (e.point.x > imageRight){ + e.point.x = imageRight; + } + + if (e.point.y < imageTop){ + e.point.y = imageTop; + } + else if (e.point.y > imageBottom){ + e.point.y = imageBottom; + } + + this.createZoomPanRotate(); + if (this.isZoomActive()){ + this.zoomPanRotate.zoomAndPanToPoint(this.settings.doubleTapZoomLevel, e.point); + } + + break; + + case Util.TouchElement.ActionTypes.gestureStart: + this.createZoomPanRotate(); + break; + } + + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onTouch, + target: this, + point: e.point, + action: e.action + }); + + }, + + + + /* + * Function: onCarouselSlideByEnd + */ + onCarouselSlideByEnd: function(e){ + + this.currentIndex = e.cacheIndex; + + if (!Util.isNothing(this.toolbar)){ + this.toolbar.setCaption(this.currentIndex); + this.toolbar.setToolbarStatus(this.currentIndex); + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onDisplayImage, + target: this, + action: e.action, + index: e.cacheIndex + }); + + }, + + + + /* + * Function: onToolbarTap + */ + onToolbarTap: function(e){ + + switch(e.action){ + + case Toolbar.ToolbarAction.next: + this.next(); + break; + + case Toolbar.ToolbarAction.previous: + this.previous(); + break; + + case Toolbar.ToolbarAction.close: + this.hide(); + break; + + case Toolbar.ToolbarAction.play: + this.play(); + break; + + } + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onToolbarTap, + target: this, + toolbarAction: e.action, + tapTarget: e.tapTarget + }); + + }, + + + + /* + * Function: onMouseWheel + */ + onMouseWheel: function(e){ + + var + delta = Util.Events.getWheelDelta(e), + dt = e.timeStamp - (this.mouseWheelStartTime || 0); + + if (dt < this.settings.mouseWheelSpeed) { + return; + } + + this.mouseWheelStartTime = e.timeStamp; + + if (this.settings.invertMouseWheel){ + delta = delta * -1; + } + + if (delta < 0){ + this.next(); + } + else if (delta > 0){ + this.previous(); + } + + }, + + + + /* + * Function: onCarouselSlideshowStart + */ + onCarouselSlideshowStart: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStart, + target: this + }); + + }, + + + + /* + * Function: onCarouselSlideshowStop + */ + onCarouselSlideshowStop: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onSlideshowStop, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeShow + */ + onToolbarBeforeShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarShow + */ + onToolbarShow: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarShow, + target: this + }); + + }, + + + + /* + * Function: onToolbarBeforeHide + */ + onToolbarBeforeHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onBeforeCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onToolbarHide + */ + onToolbarHide: function(e){ + + Util.Events.fire(this, { + type: PhotoSwipe.EventTypes.onCaptionAndToolbarHide, + target: this + }); + + }, + + + + /* + * Function: onZoomPanRotateTransform + */ + onZoomPanRotateTransform: function(e){ + + Util.Events.fire(this, { + target: this, + type: PhotoSwipe.EventTypes.onZoomPanRotateTransform, + scale: e.scale, + rotation: e.rotation, + rotationDegs: e.rotationDegs, + translateX: e.translateX, + translateY: e.translateY + }); + + } + + + }); + + + +} +( + window, + window.klass, + window.Code.Util, + window.Code.PhotoSwipe.Cache, + window.Code.PhotoSwipe.DocumentOverlay, + window.Code.PhotoSwipe.Carousel, + window.Code.PhotoSwipe.Toolbar, + window.Code.PhotoSwipe.UILayer, + window.Code.PhotoSwipe.ZoomPanRotate +)); diff --git a/photoswipe/noutil/code.photoswipe.noutil.jquery-3.0.5.min.js b/photoswipe/noutil/code.photoswipe.noutil.jquery-3.0.5.min.js new file mode 100755 index 0000000..27abd7a --- /dev/null +++ b/photoswipe/noutil/code.photoswipe.noutil.jquery-3.0.5.min.js @@ -0,0 +1,119 @@ +// PhotoSwipe - http://www.photoswipe.com/ +// Copyright (c) 2012 by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: 3.0.5 +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Image");d.Code.PhotoSwipe.Image.EventTypes={onLoad:"onLoad",onError:"onError"}})(window,window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Image");var b=d.Code.PhotoSwipe;b.Image.ImageClass=j({refObj:null,imageEl:null,src:null,caption:null,metaData:null,imageLoadHandler:null,imageErrorHandler:null,dispose:function(){var c;this.shrinkImage();for(c in this)a.objectHasProperty(this,c)&&(this[c]=null)},initialize:function(a,f,b,i){this.refObj=a;this.src=this.originalSrc=f;this.caption=b;this.metaData=i;this.imageEl=new d.Image;this.imageLoadHandler=this.onImageLoad.bind(this);this.imageErrorHandler= +this.onImageError.bind(this)},load:function(){this.imageEl.originalSrc=a.coalesce(this.imageEl.originalSrc,"");this.imageEl.originalSrc===this.src?this.imageEl.isError?a.Events.fire(this,{type:b.Image.EventTypes.onError,target:this}):a.Events.fire(this,{type:b.Image.EventTypes.onLoad,target:this}):(this.imageEl.isError=!1,this.imageEl.isLoading=!0,this.imageEl.naturalWidth=null,this.imageEl.naturalHeight=null,this.imageEl.isLandscape=!1,this.imageEl.onload=this.imageLoadHandler,this.imageEl.onerror= +this.imageErrorHandler,this.imageEl.onabort=this.imageErrorHandler,this.imageEl.originalSrc=this.src,this.imageEl.src=this.src)},shrinkImage:function(){if(!a.isNothing(this.imageEl)&&this.imageEl.src.indexOf(this.src)>-1)this.imageEl.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",a.isNothing(this.imageEl.parentNode)||a.DOM.removeChild(this.imageEl,this.imageEl.parentNode)},onImageLoad:function(){this.imageEl.onload=null;this.imageEl.naturalWidth=a.coalesce(this.imageEl.naturalWidth, +this.imageEl.width);this.imageEl.naturalHeight=a.coalesce(this.imageEl.naturalHeight,this.imageEl.height);this.imageEl.isLandscape=this.imageEl.naturalWidth>this.imageEl.naturalHeight;this.imageEl.isLoading=!1;a.Events.fire(this,{type:b.Image.EventTypes.onLoad,target:this})},onImageError:function(){this.imageEl.onload=null;this.imageEl.onerror=null;this.imageEl.onabort=null;this.imageEl.isLoading=!1;this.imageEl.isError=!0;a.Events.fire(this,{type:b.Image.EventTypes.onError,target:this})}})})(window, +window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Cache");d=d.Code.PhotoSwipe;d.Cache.Mode={normal:"normal",aggressive:"aggressive"};d.Cache.Functions={getImageSource:function(a){return a.href},getImageCaption:function(b){if(b.nodeName==="IMG")return a.DOM.getAttribute(b,"alt");var c,f,e;c=0;for(f=b.childNodes.length;cf&& +(f=a.DOM.windowHeight())}else c=a.DOM.width(this.settings.target),f=a.DOM.height(this.settings.target),b="0px";a.DOM.setStyle(this.el,{width:c,height:f,top:b})},fadeIn:function(c,f){this.resetPosition();a.DOM.setStyle(this.el,"opacity",0);a.DOM.show(this.el);a.Animation.fadeIn(this.el,c,f)}})})(window,window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Carousel");d=d.Code.PhotoSwipe;d.Carousel.EventTypes={onSlideByEnd:"PhotoSwipeCarouselOnSlideByEnd",onSlideshowStart:"PhotoSwipeCarouselOnSlideshowStart",onSlideshowStop:"PhotoSwipeCarouselOnSlideshowStop"};d.Carousel.CssClasses={carousel:"ps-carousel",content:"ps-carousel-content",item:"ps-carousel-item",itemLoading:"ps-carousel-item-loading",itemError:"ps-carousel-item-error"};d.Carousel.SlideByAction={previous:"previous",current:"current",next:"next"}})(window, +window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Carousel");var b=d.Code.PhotoSwipe;b.Carousel.CarouselClass=j({el:null,contentEl:null,settings:null,cache:null,slideByEndHandler:null,currentCacheIndex:null,isSliding:null,isSlideshowActive:null,lastSlideByAction:null,touchStartPoint:null,touchStartPosition:null,imageLoadHandler:null,imageErrorHandler:null,slideshowTimeout:null,dispose:function(){var c,f,e;f=0;for(e=this.cache.images.length;f0&&a.DOM.setStyle(h,{marginRight:this.settings.margin+"px"}),a.DOM.appendChild(h,this.contentEl);this.settings.target===d?a.DOM.appendToBody(this.el):a.DOM.appendChild(this.el,this.settings.target)}, +resetPosition:function(){var c,f,e,i,h,g;this.settings.target===d?(c=a.DOM.windowWidth(),f=a.DOM.windowHeight(),e=a.DOM.windowScrollTop()+"px"):(c=a.DOM.width(this.settings.target),f=a.DOM.height(this.settings.target),e="0px");i=this.settings.margin>0?c+this.settings.margin:c;h=a.DOM.find("."+b.Carousel.CssClasses.item,this.contentEl);i*=h.length;a.DOM.setStyle(this.el,{top:e,width:c,height:f});a.DOM.setStyle(this.contentEl,{width:i,height:f});e=0;for(i=h.length;eh&&(f=h/b,b=Math.round(b*f),d=Math.round(d*f)),d>g&&(f=g/d,d=Math.round(d*f),b=Math.round(b*f))):(f=c.isLandscape?h/c.naturalWidth:g/c.naturalHeight,b=Math.round(c.naturalWidth* +f),d=Math.round(c.naturalHeight*f),this.settings.imageScaleMethod==="zoom"?(f=1,dh?f=h/b:d>g&&(f=g/d),f!==1&&(b=Math.round(b*f),d=Math.round(d*f))));a.DOM.setStyle(c,{position:"absolute",width:b,height:d,top:Math.round((g-d)/2)+"px",left:Math.round((h-b)/2)+"px",display:"block"})}},setContentLeftPosition:function(){var c,b,e;c=this.settings.target===d?a.DOM.windowWidth():a.DOM.width(this.settings.target); +b=this.getItemEls();e=0;this.settings.loop?e=(c+this.settings.margin)*-1:this.currentCacheIndex===this.cache.images.length-1?e=(b.length-1)*(c+this.settings.margin)*-1:this.currentCacheIndex>0&&(e=(c+this.settings.margin)*-1);a.DOM.setStyle(this.contentEl,{left:e+"px"})},show:function(c){this.currentCacheIndex=c;this.resetPosition();this.setImages(!1);a.DOM.show(this.el);a.Animation.resetTranslate(this.contentEl);var c=this.getItemEls(),f,d;f=0;for(d=c.length;fthis.cache.images.length-1&&(b=0),i<0&&(i=this.cache.images.length-1),b=this.cache.getImages([i,this.currentCacheIndex,b]),a||this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[2],d[2]),this.addCacheImageToItemEl(b[0], +d[0])):d.length===1?a||(b=this.cache.getImages([this.currentCacheIndex]),this.addCacheImageToItemEl(b[0],d[0])):d.length===2?this.currentCacheIndex===0?(b=this.cache.getImages([this.currentCacheIndex,this.currentCacheIndex+1]),a||this.addCacheImageToItemEl(b[0],d[0]),this.addCacheImageToItemEl(b[1],d[1])):(b=this.cache.getImages([this.currentCacheIndex-1,this.currentCacheIndex]),a||this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[0],d[0])):this.currentCacheIndex===0?(b=this.cache.getImages([this.currentCacheIndex, +this.currentCacheIndex+1,this.currentCacheIndex+2]),a||this.addCacheImageToItemEl(b[0],d[0]),this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[2],d[2])):(this.currentCacheIndex===this.cache.images.length-1?(b=this.cache.getImages([this.currentCacheIndex-2,this.currentCacheIndex-1,this.currentCacheIndex]),a||this.addCacheImageToItemEl(b[2],d[2]),this.addCacheImageToItemEl(b[1],d[1])):(b=this.cache.getImages([this.currentCacheIndex-1,this.currentCacheIndex,this.currentCacheIndex+1]), +a||this.addCacheImageToItemEl(b[1],d[1]),this.addCacheImageToItemEl(b[2],d[2])),this.addCacheImageToItemEl(b[0],d[0]))},addCacheImageToItemEl:function(c,d){a.DOM.removeClass(d,b.Carousel.CssClasses.itemError);a.DOM.addClass(d,b.Carousel.CssClasses.itemLoading);a.DOM.removeChildren(d);a.DOM.setStyle(c.imageEl,{display:"none"});a.DOM.appendChild(c.imageEl,d);a.Animation.resetTranslate(c.imageEl);a.Events.add(c,b.Image.EventTypes.onLoad,this.imageLoadHandler);a.Events.add(c,b.Image.EventTypes.onError, +this.imageErrorHandler);c.load()},slideCarousel:function(c,f,e){if(!this.isSliding){var i,h;i=this.settings.target===d?a.DOM.windowWidth()+this.settings.margin:a.DOM.width(this.settings.target)+this.settings.margin;e=a.coalesce(e,this.settings.slideSpeed);if(!(d.Math.abs(h)<1)){switch(f){case a.TouchElement.ActionTypes.swipeLeft:c=i*-1;break;case a.TouchElement.ActionTypes.swipeRight:c=i;break;default:h=c.x-this.touchStartPoint.x,c=d.Math.abs(h)>i/2?h>0?i:i*-1:0}this.lastSlideByAction=c<0?b.Carousel.SlideByAction.next: +c>0?b.Carousel.SlideByAction.previous:b.Carousel.SlideByAction.current;if(!this.settings.loop&&(this.lastSlideByAction===b.Carousel.SlideByAction.previous&&this.currentCacheIndex===0||this.lastSlideByAction===b.Carousel.SlideByAction.next&&this.currentCacheIndex===this.cache.images.length-1))c=0,this.lastSlideByAction=b.Carousel.SlideByAction.current;this.isSliding=!0;this.doSlideCarousel(c,e)}}},moveCarousel:function(a){this.isSliding||this.settings.enableDrag&&this.doMoveCarousel(a.x-this.touchStartPoint.x)}, +getItemEls:function(){return a.DOM.find("."+b.Carousel.CssClasses.item,this.contentEl)},previous:function(){this.stopSlideshow();this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeRight,this.settings.nextPreviousSlideSpeed)},next:function(){this.stopSlideshow();this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeLeft,this.settings.nextPreviousSlideSpeed)},slideshowNext:function(){this.slideCarousel({x:0,y:0},a.TouchElement.ActionTypes.swipeLeft)},startSlideshow:function(){this.stopSlideshow(); +this.isSlideshowActive=!0;this.slideshowTimeout=d.setTimeout(this.slideshowNext.bind(this),this.settings.slideshowDelay);a.Events.fire(this,{type:b.Carousel.EventTypes.onSlideshowStart,target:this})},stopSlideshow:function(){if(!a.isNothing(this.slideshowTimeout))d.clearTimeout(this.slideshowTimeout),this.slideshowTimeout=null,this.isSlideshowActive=!1,a.Events.fire(this,{type:b.Carousel.EventTypes.onSlideshowStop,target:this})},onSlideByEnd:function(){if(!a.isNothing(this.isSliding)){var c=this.getItemEls(); +this.isSliding=!1;this.lastSlideByAction===b.Carousel.SlideByAction.next?this.currentCacheIndex+=1:this.lastSlideByAction===b.Carousel.SlideByAction.previous&&(this.currentCacheIndex-=1);if(this.settings.loop)if(this.lastSlideByAction===b.Carousel.SlideByAction.next?a.DOM.appendChild(c[0],this.contentEl):this.lastSlideByAction===b.Carousel.SlideByAction.previous&&a.DOM.insertBefore(c[c.length-1],c[0],this.contentEl),this.currentCacheIndex<0)this.currentCacheIndex=this.cache.images.length-1;else{if(this.currentCacheIndex=== +this.cache.images.length)this.currentCacheIndex=0}else this.cache.images.length>3&&(this.currentCacheIndex>1&&this.currentCacheIndex
'}})(window,window.klass,window.Code.Util); +(function(d,j,a){a.registerNamespace("Code.PhotoSwipe.Toolbar");var b=d.Code.PhotoSwipe;b.Toolbar.ToolbarClass=j({toolbarEl:null,closeEl:null,playEl:null,previousEl:null,nextEl:null,captionEl:null,captionContentEl:null,currentCaption:null,settings:null,cache:null,timeout:null,isVisible:null,fadeOutHandler:null,touchStartHandler:null,touchMoveHandler:null,clickHandler:null,dispose:function(){var c;this.clearTimeout();this.removeEventHandlers();a.Animation.stop(this.toolbarEl);a.Animation.stop(this.captionEl); +a.DOM.removeChild(this.toolbarEl,this.toolbarEl.parentNode);a.DOM.removeChild(this.captionEl,this.captionEl.parentNode);for(c in this)a.objectHasProperty(this,c)&&(this[c]=null)},initialize:function(c,f){var e;this.settings=f;this.cache=c;this.isVisible=!1;this.fadeOutHandler=this.onFadeOut.bind(this);this.touchStartHandler=this.onTouchStart.bind(this);this.touchMoveHandler=this.onTouchMove.bind(this);this.clickHandler=this.onClick.bind(this);e=b.Toolbar.CssClasses.toolbar;this.settings.captionAndToolbarFlipPosition&& +(e=e+" "+b.Toolbar.CssClasses.toolbarTop);this.toolbarEl=a.DOM.createElement("div",{"class":e},this.settings.getToolbar());a.DOM.setStyle(this.toolbarEl,{left:0,position:"absolute",overflow:"hidden",zIndex:this.settings.zIndex});this.settings.target===d?a.DOM.appendToBody(this.toolbarEl):a.DOM.appendChild(this.toolbarEl,this.settings.target);a.DOM.hide(this.toolbarEl);this.closeEl=a.DOM.find("."+b.Toolbar.CssClasses.close,this.toolbarEl)[0];this.settings.preventHide&&!a.isNothing(this.closeEl)&&a.DOM.hide(this.closeEl); +this.playEl=a.DOM.find("."+b.Toolbar.CssClasses.play,this.toolbarEl)[0];this.settings.preventSlideshow&&!a.isNothing(this.playEl)&&a.DOM.hide(this.playEl);this.nextEl=a.DOM.find("."+b.Toolbar.CssClasses.next,this.toolbarEl)[0];this.previousEl=a.DOM.find("."+b.Toolbar.CssClasses.previous,this.toolbarEl)[0];e=b.Toolbar.CssClasses.caption;this.settings.captionAndToolbarFlipPosition&&(e=e+" "+b.Toolbar.CssClasses.captionBottom);this.captionEl=a.DOM.createElement("div",{"class":e},"");a.DOM.setStyle(this.captionEl, +{left:0,position:"absolute",overflow:"hidden",zIndex:this.settings.zIndex});this.settings.target===d?a.DOM.appendToBody(this.captionEl):a.DOM.appendChild(this.captionEl,this.settings.target);a.DOM.hide(this.captionEl);this.captionContentEl=a.DOM.createElement("div",{"class":b.Toolbar.CssClasses.captionContent},"");a.DOM.appendChild(this.captionContentEl,this.captionEl);this.addEventHandlers()},resetPosition:function(){var c,b,e;this.settings.target===d?(this.settings.captionAndToolbarFlipPosition? +(b=a.DOM.windowScrollTop(),e=a.DOM.windowScrollTop()+a.DOM.windowHeight()-a.DOM.height(this.captionEl)):(b=a.DOM.windowScrollTop()+a.DOM.windowHeight()-a.DOM.height(this.toolbarEl),e=a.DOM.windowScrollTop()),c=a.DOM.windowWidth()):(this.settings.captionAndToolbarFlipPosition?(b="0",e=a.DOM.height(this.settings.target)-a.DOM.height(this.captionEl)):(b=a.DOM.height(this.settings.target)-a.DOM.height(this.toolbarEl),e=0),c=a.DOM.width(this.settings.target));a.DOM.setStyle(this.toolbarEl,{top:b+"px", +width:c});a.DOM.setStyle(this.captionEl,{top:e+"px",width:c})},toggleVisibility:function(a){this.isVisible?this.fadeOut():this.show(a)},show:function(c){a.Animation.stop(this.toolbarEl);a.Animation.stop(this.captionEl);this.resetPosition();this.setToolbarStatus(c);a.Events.fire(this,{type:b.Toolbar.EventTypes.onBeforeShow,target:this});this.showToolbar();this.setCaption(c);this.showCaption();this.isVisible=!0;this.setTimeout();a.Events.fire(this,{type:b.Toolbar.EventTypes.onShow,target:this})},setTimeout:function(){if(this.settings.captionAndToolbarAutoHideDelay> +0)this.clearTimeout(),this.timeout=d.setTimeout(this.fadeOut.bind(this),this.settings.captionAndToolbarAutoHideDelay)},clearTimeout:function(){if(!a.isNothing(this.timeout))d.clearTimeout(this.timeout),this.timeout=null},fadeOut:function(){this.clearTimeout();a.Events.fire(this,{type:b.Toolbar.EventTypes.onBeforeHide,target:this});a.Animation.fadeOut(this.toolbarEl,this.settings.fadeOutSpeed);a.Animation.fadeOut(this.captionEl,this.settings.fadeOutSpeed,this.fadeOutHandler);this.isVisible=!1},addEventHandlers:function(){a.Browser.isTouchSupported&& +(a.Browser.blackberry||a.Events.add(this.toolbarEl,"touchstart",this.touchStartHandler),a.Events.add(this.toolbarEl,"touchmove",this.touchMoveHandler),a.Events.add(this.captionEl,"touchmove",this.touchMoveHandler));a.Events.add(this.toolbarEl,"click",this.clickHandler)},removeEventHandlers:function(){a.Browser.isTouchSupported&&(a.Browser.blackberry||a.Events.remove(this.toolbarEl,"touchstart",this.touchStartHandler),a.Events.remove(this.toolbarEl,"touchmove",this.touchMoveHandler),a.Events.remove(this.captionEl, +"touchmove",this.touchMoveHandler));a.Events.remove(this.toolbarEl,"click",this.clickHandler)},handleTap:function(c){this.clearTimeout();var d;if(c.target===this.nextEl||a.DOM.isChildOf(c.target,this.nextEl))d=b.Toolbar.ToolbarAction.next;else if(c.target===this.previousEl||a.DOM.isChildOf(c.target,this.previousEl))d=b.Toolbar.ToolbarAction.previous;else if(c.target===this.closeEl||a.DOM.isChildOf(c.target,this.closeEl))d=b.Toolbar.ToolbarAction.close;else if(c.target===this.playEl||a.DOM.isChildOf(c.target, +this.playEl))d=b.Toolbar.ToolbarAction.play;this.setTimeout();if(a.isNothing(d))d=b.Toolbar.ToolbarAction.none;a.Events.fire(this,{type:b.Toolbar.EventTypes.onTap,target:this,action:d,tapTarget:c.target})},setCaption:function(c){a.DOM.removeChildren(this.captionContentEl);this.currentCaption=a.coalesce(this.cache.images[c].caption,"\u00a0");if(a.isObject(this.currentCaption))a.DOM.appendChild(this.currentCaption,this.captionContentEl);else{if(this.currentCaption==="")this.currentCaption="\u00a0"; +a.DOM.appendText(this.currentCaption,this.captionContentEl)}this.currentCaption=this.currentCaption==="\u00a0"?"":this.currentCaption;this.resetPosition()},showToolbar:function(){a.DOM.setStyle(this.toolbarEl,{opacity:this.settings.captionAndToolbarOpacity});a.DOM.show(this.toolbarEl)},showCaption:function(){(this.currentCaption===""||this.captionContentEl.childNodes.length<1)&&!this.settings.captionAndToolbarShowEmptyCaptions?a.DOM.hide(this.captionEl):(a.DOM.setStyle(this.captionEl,{opacity:this.settings.captionAndToolbarOpacity}), +a.DOM.show(this.captionEl))},setToolbarStatus:function(c){this.settings.loop||(a.DOM.removeClass(this.previousEl,b.Toolbar.CssClasses.previousDisabled),a.DOM.removeClass(this.nextEl,b.Toolbar.CssClasses.nextDisabled),c>0&&cthis.settings.maxUserZoom)a=this.settings.maxUserZoom;return a},setStartingScaleAndRotation:function(a,b){this.transformSettings.startingScale=this.getScale(a);this.transformSettings.startingRotation=(this.transformSettings.startingRotation+b)%360},zoomRotate:function(a,b){this.transformSettings.scale=this.getScale(a);this.transformSettings.rotation=this.transformSettings.startingRotation+b;this.applyTransform()},panStart:function(a){this.setStartingTranslateFromCurrentTransform();this.panStartingPoint= +{x:a.x,y:a.y}},pan:function(a){var b=(a.y-this.panStartingPoint.y)/this.transformSettings.scale;this.transformSettings.translateX=this.transformSettings.startingTranslateX+(a.x-this.panStartingPoint.x)/this.transformSettings.scale;this.transformSettings.translateY=this.transformSettings.startingTranslateY+b;this.applyTransform()},zoomAndPanToPoint:function(b,f){if(this.settings.target===d){this.panStart({x:a.DOM.windowWidth()/2,y:a.DOM.windowHeight()/2});var e=(f.y-this.panStartingPoint.y)/this.transformSettings.scale; +this.transformSettings.translateX=(this.transformSettings.startingTranslateX+(f.x-this.panStartingPoint.x)/this.transformSettings.scale)*-1;this.transformSettings.translateY=(this.transformSettings.startingTranslateY+e)*-1}this.setStartingScaleAndRotation(b,0);this.transformSettings.scale=this.transformSettings.startingScale;this.transformSettings.rotation=0;this.applyTransform()},applyTransform:function(){var c=this.transformSettings.rotation%360,f=d.parseInt(this.transformSettings.translateX,10), +e=d.parseInt(this.transformSettings.translateY,10),i="scale("+this.transformSettings.scale+") rotate("+c+"deg) translate("+f+"px, "+e+"px)";a.DOM.setStyle(this.transformEl,{webkitTransform:i,MozTransform:i,msTransform:i,transform:i});a.Events.fire(this,{target:this,type:b.ZoomPanRotate.EventTypes.onTransform,scale:this.transformSettings.scale,rotation:this.transformSettings.rotation,rotationDegs:c,translateX:f,translateY:e})}})})(window,window.klass,window.Code.Util); +(function(d,j){j.registerNamespace("Code.PhotoSwipe");var a=d.Code.PhotoSwipe;a.CssClasses={buildingBody:"ps-building",activeBody:"ps-active"};a.EventTypes={onBeforeShow:"PhotoSwipeOnBeforeShow",onShow:"PhotoSwipeOnShow",onBeforeHide:"PhotoSwipeOnBeforeHide",onHide:"PhotoSwipeOnHide",onDisplayImage:"PhotoSwipeOnDisplayImage",onResetPosition:"PhotoSwipeOnResetPosition",onSlideshowStart:"PhotoSwipeOnSlideshowStart",onSlideshowStop:"PhotoSwipeOnSlideshowStop",onTouch:"PhotoSwipeOnTouch",onBeforeCaptionAndToolbarShow:"PhotoSwipeOnBeforeCaptionAndToolbarShow", +onCaptionAndToolbarShow:"PhotoSwipeOnCaptionAndToolbarShow",onBeforeCaptionAndToolbarHide:"PhotoSwipeOnBeforeCaptionAndToolbarHide",onCaptionAndToolbarHide:"PhotoSwipeOnCaptionAndToolbarHide",onToolbarTap:"PhotoSwipeOnToolbarTap",onBeforeZoomPanRotateShow:"PhotoSwipeOnBeforeZoomPanRotateShow",onZoomPanRotateShow:"PhotoSwipeOnZoomPanRotateShow",onBeforeZoomPanRotateHide:"PhotoSwipeOnBeforeZoomPanRotateHide",onZoomPanRotateHide:"PhotoSwipeOnZoomPanRotateHide",onZoomPanRotateTransform:"PhotoSwipeOnZoomPanRotateTransform"}; +a.instances=[];a.activeInstances=[];a.setActivateInstance=function(b){if(j.arrayIndexOf(b.settings.target,a.activeInstances,"target")>-1)throw"Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target";a.activeInstances.push({target:b.settings.target,instance:b})};a.unsetActivateInstance=function(b){b=j.arrayIndexOf(b,a.activeInstances,"instance");a.activeInstances.splice(b,1)};a.attach=function(b,c,d){var e,i;e=a.createInstance(b,c,d);c=0;for(d= +b.length;c=2.1)this.isBackEventSupported=!0;if(!this.isBackEventSupported)this.isBackEventSupported=a.objectHasProperty(d,"onhashchange");this.settings={fadeInSpeed:250,fadeOutSpeed:250,preventHide:!1,preventSlideshow:!1,zIndex:1E3,backButtonHideEnabled:!0,enableKeyboard:!0,enableMouseWheel:!0, +mouseWheelSpeed:350,autoStartSlideshow:!1,jQueryMobile:!a.isNothing(d.jQuery)&&!a.isNothing(d.jQuery.mobile),jQueryMobileDialogHash:"&ui-state=dialog",enableUIWebViewRepositionTimeout:!1,uiWebViewResetPositionDelay:500,target:d,preventDefaultTouchEvents:!0,loop:!0,slideSpeed:250,nextPreviousSlideSpeed:0,enableDrag:!0,swipeThreshold:50,swipeTimeThreshold:250,slideTimingFunction:"ease-out",slideshowDelay:3E3,doubleTapSpeed:250,margin:20,imageScaleMethod:"fit",captionAndToolbarHide:!1,captionAndToolbarFlipPosition:!1, +captionAndToolbarAutoHideDelay:5E3,captionAndToolbarOpacity:0.8,captionAndToolbarShowEmptyCaptions:!0,getToolbar:g.Toolbar.getToolbar,allowUserZoom:!0,allowRotationOnUserZoom:!1,maxUserZoom:5,minUserZoom:0.5,doubleTapZoomLevel:2.5,getImageSource:g.Cache.Functions.getImageSource,getImageCaption:g.Cache.Functions.getImageCaption,getImageMetaData:g.Cache.Functions.getImageMetaData,cacheMode:g.Cache.Mode.normal};a.extend(this.settings,e);this.settings.target!==d&&(e=a.DOM.getStyle(this.settings.target, +"position"),(e!=="relative"||e!=="absolute")&&a.DOM.setStyle(this.settings.target,"position","relative"));if(this.settings.target!==d)this.isBackEventSupported=!1,this.settings.backButtonHideEnabled=!1;else if(this.settings.preventHide)this.settings.backButtonHideEnabled=!1;this.cache=new b.CacheClass(c,this.settings)},show:function(b){var c,e;this.backButtonClicked=this._isResettingPosition=!1;if(a.isNumber(b))this.currentIndex=b;else{this.currentIndex=-1;c=0;for(e=this.originalImages.length;cthis.originalImages.length-1)throw"Code.PhotoSwipe.PhotoSwipeClass.show: Starting index out of range";this.isAlreadyGettingPage=this.getWindowDimensions();g.setActivateInstance(this);this.windowDimensions=this.getWindowDimensions();this.settings.target===d?a.DOM.addClass(d.document.body,g.CssClasses.buildingBody):a.DOM.addClass(this.settings.target,g.CssClasses.buildingBody);this.createComponents();a.Events.fire(this,{type:g.EventTypes.onBeforeShow, +target:this});this.documentOverlay.fadeIn(this.settings.fadeInSpeed,this.onDocumentOverlayFadeIn.bind(this))},getWindowDimensions:function(){return{width:a.DOM.windowWidth(),height:a.DOM.windowHeight()}},createComponents:function(){this.documentOverlay=new c.DocumentOverlayClass(this.settings);this.carousel=new f.CarouselClass(this.cache,this.settings);this.uiLayer=new i.UILayerClass(this.settings);if(!this.settings.captionAndToolbarHide)this.toolbar=new e.ToolbarClass(this.cache,this.settings)}, +resetPosition:function(){if(!this._isResettingPosition){var b=this.getWindowDimensions();if(a.isNothing(this.windowDimensions)||!(b.width===this.windowDimensions.width&&b.height===this.windowDimensions.height))this._isResettingPosition=!0,this.windowDimensions=b,this.destroyZoomPanRotate(),this.documentOverlay.resetPosition(),this.carousel.resetPosition(),a.isNothing(this.toolbar)||this.toolbar.resetPosition(),this.uiLayer.resetPosition(),this._isResettingPosition=!1,a.Events.fire(this,{type:g.EventTypes.onResetPosition, +target:this})}},addEventHandler:function(b,c){a.Events.add(this,b,c)},addEventHandlers:function(){if(a.isNothing(this.windowOrientationChangeHandler))this.windowOrientationChangeHandler=this.onWindowOrientationChange.bind(this),this.windowScrollHandler=this.onWindowScroll.bind(this),this.keyDownHandler=this.onKeyDown.bind(this),this.windowHashChangeHandler=this.onWindowHashChange.bind(this),this.uiLayerTouchHandler=this.onUILayerTouch.bind(this),this.carouselSlideByEndHandler=this.onCarouselSlideByEnd.bind(this), +this.carouselSlideshowStartHandler=this.onCarouselSlideshowStart.bind(this),this.carouselSlideshowStopHandler=this.onCarouselSlideshowStop.bind(this),this.toolbarTapHandler=this.onToolbarTap.bind(this),this.toolbarBeforeShowHandler=this.onToolbarBeforeShow.bind(this),this.toolbarShowHandler=this.onToolbarShow.bind(this),this.toolbarBeforeHideHandler=this.onToolbarBeforeHide.bind(this),this.toolbarHideHandler=this.onToolbarHide.bind(this),this.mouseWheelHandler=this.onMouseWheel.bind(this),this.zoomPanRotateTransformHandler= +this.onZoomPanRotateTransform.bind(this);a.Browser.android?this.orientationEventName="resize":a.Browser.iOS&&!a.Browser.safari?a.Events.add(d.document.body,"orientationchange",this.windowOrientationChangeHandler):this.orientationEventName=!a.isNothing(d.onorientationchange)?"orientationchange":"resize";a.isNothing(this.orientationEventName)||a.Events.add(d,this.orientationEventName,this.windowOrientationChangeHandler);this.settings.target===d&&a.Events.add(d,"scroll",this.windowScrollHandler);this.settings.enableKeyboard&& +a.Events.add(d.document,"keydown",this.keyDownHandler);if(this.isBackEventSupported&&this.settings.backButtonHideEnabled)this.windowHashChangeHandler=this.onWindowHashChange.bind(this),this.settings.jQueryMobile?d.location.hash=this.settings.jQueryMobileDialogHash:(this.currentHistoryHashValue="PhotoSwipe"+(new Date).getTime().toString(),d.location.hash=this.currentHistoryHashValue),a.Events.add(d,"hashchange",this.windowHashChangeHandler);this.settings.enableMouseWheel&&a.Events.add(d,"mousewheel", +this.mouseWheelHandler);a.Events.add(this.uiLayer,a.TouchElement.EventTypes.onTouch,this.uiLayerTouchHandler);a.Events.add(this.carousel,f.EventTypes.onSlideByEnd,this.carouselSlideByEndHandler);a.Events.add(this.carousel,f.EventTypes.onSlideshowStart,this.carouselSlideshowStartHandler);a.Events.add(this.carousel,f.EventTypes.onSlideshowStop,this.carouselSlideshowStopHandler);a.isNothing(this.toolbar)||(a.Events.add(this.toolbar,e.EventTypes.onTap,this.toolbarTapHandler),a.Events.add(this.toolbar, +e.EventTypes.onBeforeShow,this.toolbarBeforeShowHandler),a.Events.add(this.toolbar,e.EventTypes.onShow,this.toolbarShowHandler),a.Events.add(this.toolbar,e.EventTypes.onBeforeHide,this.toolbarBeforeHideHandler),a.Events.add(this.toolbar,e.EventTypes.onHide,this.toolbarHideHandler))},removeEventHandlers:function(){a.Browser.iOS&&!a.Browser.safari&&a.Events.remove(d.document.body,"orientationchange",this.windowOrientationChangeHandler);a.isNothing(this.orientationEventName)||a.Events.remove(d,this.orientationEventName, +this.windowOrientationChangeHandler);a.Events.remove(d,"scroll",this.windowScrollHandler);this.settings.enableKeyboard&&a.Events.remove(d.document,"keydown",this.keyDownHandler);this.isBackEventSupported&&this.settings.backButtonHideEnabled&&a.Events.remove(d,"hashchange",this.windowHashChangeHandler);this.settings.enableMouseWheel&&a.Events.remove(d,"mousewheel",this.mouseWheelHandler);a.isNothing(this.uiLayer)||a.Events.remove(this.uiLayer,a.TouchElement.EventTypes.onTouch,this.uiLayerTouchHandler); +a.isNothing(this.toolbar)||(a.Events.remove(this.carousel,f.EventTypes.onSlideByEnd,this.carouselSlideByEndHandler),a.Events.remove(this.carousel,f.EventTypes.onSlideshowStart,this.carouselSlideshowStartHandler),a.Events.remove(this.carousel,f.EventTypes.onSlideshowStop,this.carouselSlideshowStopHandler));a.isNothing(this.toolbar)||(a.Events.remove(this.toolbar,e.EventTypes.onTap,this.toolbarTapHandler),a.Events.remove(this.toolbar,e.EventTypes.onBeforeShow,this.toolbarBeforeShowHandler),a.Events.remove(this.toolbar, +e.EventTypes.onShow,this.toolbarShowHandler),a.Events.remove(this.toolbar,e.EventTypes.onBeforeHide,this.toolbarBeforeHideHandler),a.Events.remove(this.toolbar,e.EventTypes.onHide,this.toolbarHideHandler))},hide:function(){if(!this.settings.preventHide){if(a.isNothing(this.documentOverlay))throw"Code.PhotoSwipe.PhotoSwipeClass.hide: PhotoSwipe instance is already hidden";if(a.isNothing(this.hiding)){this.clearUIWebViewResetPositionTimeout();this.destroyZoomPanRotate();this.removeEventHandlers();a.Events.fire(this, +{type:g.EventTypes.onBeforeHide,target:this});this.uiLayer.dispose();this.uiLayer=null;if(!a.isNothing(this.toolbar))this.toolbar.dispose(),this.toolbar=null;this.carousel.dispose();this.carousel=null;a.DOM.removeClass(d.document.body,g.CssClasses.activeBody);this.documentOverlay.dispose();this.documentOverlay=null;this._isResettingPosition=!1;g.unsetActivateInstance(this);a.Events.fire(this,{type:g.EventTypes.onHide,target:this});this.goBackInHistory()}}},goBackInHistory:function(){this.isBackEventSupported&& +this.settings.backButtonHideEnabled&&(this.backButtonClicked||d.history.back())},play:function(){!this.isZoomActive()&&!this.settings.preventSlideshow&&!a.isNothing(this.carousel)&&(!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.toolbar.fadeOut(),this.carousel.startSlideshow())},stop:function(){this.isZoomActive()||a.isNothing(this.carousel)||this.carousel.stopSlideshow()},previous:function(){this.isZoomActive()||a.isNothing(this.carousel)||this.carousel.previous()},next:function(){this.isZoomActive()|| +a.isNothing(this.carousel)||this.carousel.next()},toggleToolbar:function(){this.isZoomActive()||a.isNothing(this.toolbar)||this.toolbar.toggleVisibility(this.currentIndex)},fadeOutToolbarIfVisible:function(){!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.settings.captionAndToolbarAutoHideDelay>0&&this.toolbar.fadeOut()},createZoomPanRotate:function(){this.stop();if(this.canUserZoom()&&!this.isZoomActive())a.Events.fire(this,g.EventTypes.onBeforeZoomPanRotateShow),this.zoomPanRotate=new h.ZoomPanRotateClass(this.settings, +this.cache.images[this.currentIndex],this.uiLayer),this.uiLayer.captureSettings.preventDefaultTouchEvents=!0,a.Events.add(this.zoomPanRotate,g.ZoomPanRotate.EventTypes.onTransform,this.zoomPanRotateTransformHandler),a.Events.fire(this,g.EventTypes.onZoomPanRotateShow),!a.isNothing(this.toolbar)&&this.toolbar.isVisible&&this.toolbar.fadeOut()},destroyZoomPanRotate:function(){if(!a.isNothing(this.zoomPanRotate))a.Events.fire(this,g.EventTypes.onBeforeZoomPanRotateHide),a.Events.remove(this.zoomPanRotate, +g.ZoomPanRotate.EventTypes.onTransform,this.zoomPanRotateTransformHandler),this.zoomPanRotate.dispose(),this.zoomPanRotate=null,this.uiLayer.captureSettings.preventDefaultTouchEvents=this.settings.preventDefaultTouchEvents,a.Events.fire(this,g.EventTypes.onZoomPanRotateHide)},canUserZoom:function(){var b;if(a.Browser.msie){if(b=document.createElement("div"),a.isNothing(b.style.msTransform))return!1}else if(!a.Browser.isCSSTransformSupported)return!1;if(!this.settings.allowUserZoom)return!1;if(this.carousel.isSliding)return!1; +b=this.cache.images[this.currentIndex];if(a.isNothing(b))return!1;if(b.isLoading)return!1;return!0},isZoomActive:function(){return!a.isNothing(this.zoomPanRotate)},getCurrentImage:function(){return this.cache.images[this.currentIndex]},onDocumentOverlayFadeIn:function(){d.setTimeout(function(){var b=this.settings.target===d?d.document.body:this.settings.target;a.DOM.removeClass(b,g.CssClasses.buildingBody);a.DOM.addClass(b,g.CssClasses.activeBody);this.addEventHandlers();this.carousel.show(this.currentIndex); +this.uiLayer.show();this.settings.autoStartSlideshow?this.play():a.isNothing(this.toolbar)||this.toolbar.show(this.currentIndex);a.Events.fire(this,{type:g.EventTypes.onShow,target:this});this.setUIWebViewResetPositionTimeout()}.bind(this),250)},setUIWebViewResetPositionTimeout:function(){if(this.settings.enableUIWebViewRepositionTimeout&&a.Browser.iOS&&!a.Browser.safari)a.isNothing(this._uiWebViewResetPositionTimeout)||d.clearTimeout(this._uiWebViewResetPositionTimeout),this._uiWebViewResetPositionTimeout= +d.setTimeout(function(){this.resetPosition();this.setUIWebViewResetPositionTimeout()}.bind(this),this.settings.uiWebViewResetPositionDelay)},clearUIWebViewResetPositionTimeout:function(){a.isNothing(this._uiWebViewResetPositionTimeout)||d.clearTimeout(this._uiWebViewResetPositionTimeout)},onWindowScroll:function(){this.resetPosition()},onWindowOrientationChange:function(){this.resetPosition()},onWindowHashChange:function(){if(d.location.hash!=="#"+(this.settings.jQueryMobile?this.settings.jQueryMobileDialogHash: +this.currentHistoryHashValue))this.backButtonClicked=!0,this.hide()},onKeyDown:function(a){a.keyCode===37?(a.preventDefault(),this.previous()):a.keyCode===39?(a.preventDefault(),this.next()):a.keyCode===38||a.keyCode===40?a.preventDefault():a.keyCode===27?(a.preventDefault(),this.hide()):a.keyCode===32?(this.settings.hideToolbar?this.hide():this.toggleToolbar(),a.preventDefault()):a.keyCode===13&&(a.preventDefault(),this.play())},onUILayerTouch:function(b){if(this.isZoomActive())switch(b.action){case a.TouchElement.ActionTypes.gestureChange:this.zoomPanRotate.zoomRotate(b.scale, +this.settings.allowRotationOnUserZoom?b.rotation:0);break;case a.TouchElement.ActionTypes.gestureEnd:this.zoomPanRotate.setStartingScaleAndRotation(b.scale,this.settings.allowRotationOnUserZoom?b.rotation:0);break;case a.TouchElement.ActionTypes.touchStart:this.zoomPanRotate.panStart(b.point);break;case a.TouchElement.ActionTypes.touchMove:this.zoomPanRotate.pan(b.point);break;case a.TouchElement.ActionTypes.doubleTap:this.destroyZoomPanRotate();this.toggleToolbar();break;case a.TouchElement.ActionTypes.swipeLeft:this.destroyZoomPanRotate(); +this.next();this.toggleToolbar();break;case a.TouchElement.ActionTypes.swipeRight:this.destroyZoomPanRotate(),this.previous(),this.toggleToolbar()}else switch(b.action){case a.TouchElement.ActionTypes.touchMove:case a.TouchElement.ActionTypes.swipeLeft:case a.TouchElement.ActionTypes.swipeRight:this.fadeOutToolbarIfVisible();this.carousel.onTouch(b.action,b.point);break;case a.TouchElement.ActionTypes.touchStart:case a.TouchElement.ActionTypes.touchMoveEnd:this.carousel.onTouch(b.action,b.point); +break;case a.TouchElement.ActionTypes.tap:this.toggleToolbar();break;case a.TouchElement.ActionTypes.doubleTap:this.settings.target===d&&(b.point.x-=a.DOM.windowScrollLeft(),b.point.y-=a.DOM.windowScrollTop());var c=this.cache.images[this.currentIndex].imageEl,e=d.parseInt(a.DOM.getStyle(c,"top"),10),f=d.parseInt(a.DOM.getStyle(c,"left"),10),h=f+a.DOM.width(c),c=e+a.DOM.height(c);if(b.point.xh)b.point.x=h;if(b.point.yc)b.point.y=c; +this.createZoomPanRotate();this.isZoomActive()&&this.zoomPanRotate.zoomAndPanToPoint(this.settings.doubleTapZoomLevel,b.point);break;case a.TouchElement.ActionTypes.gestureStart:this.createZoomPanRotate()}a.Events.fire(this,{type:g.EventTypes.onTouch,target:this,point:b.point,action:b.action})},onCarouselSlideByEnd:function(b){this.currentIndex=b.cacheIndex;a.isNothing(this.toolbar)||(this.toolbar.setCaption(this.currentIndex),this.toolbar.setToolbarStatus(this.currentIndex));a.Events.fire(this,{type:g.EventTypes.onDisplayImage, +target:this,action:b.action,index:b.cacheIndex})},onToolbarTap:function(b){switch(b.action){case e.ToolbarAction.next:this.next();break;case e.ToolbarAction.previous:this.previous();break;case e.ToolbarAction.close:this.hide();break;case e.ToolbarAction.play:this.play()}a.Events.fire(this,{type:g.EventTypes.onToolbarTap,target:this,toolbarAction:b.action,tapTarget:b.tapTarget})},onMouseWheel:function(b){var c=a.Events.getWheelDelta(b);if(!(b.timeStamp-(this.mouseWheelStartTime||0)0&&this.previous()},onCarouselSlideshowStart:function(){a.Events.fire(this,{type:g.EventTypes.onSlideshowStart,target:this})},onCarouselSlideshowStop:function(){a.Events.fire(this,{type:g.EventTypes.onSlideshowStop,target:this})},onToolbarBeforeShow:function(){a.Events.fire(this,{type:g.EventTypes.onBeforeCaptionAndToolbarShow,target:this})},onToolbarShow:function(){a.Events.fire(this,{type:g.EventTypes.onCaptionAndToolbarShow, +target:this})},onToolbarBeforeHide:function(){a.Events.fire(this,{type:g.EventTypes.onBeforeCaptionAndToolbarHide,target:this})},onToolbarHide:function(){a.Events.fire(this,{type:g.EventTypes.onCaptionAndToolbarHide,target:this})},onZoomPanRotateTransform:function(b){a.Events.fire(this,{target:this,type:g.EventTypes.onZoomPanRotateTransform,scale:b.scale,rotation:b.rotation,rotationDegs:b.rotationDegs,translateX:b.translateX,translateY:b.translateY})}})})(window,window.klass,window.Code.Util,window.Code.PhotoSwipe.Cache, +window.Code.PhotoSwipe.DocumentOverlay,window.Code.PhotoSwipe.Carousel,window.Code.PhotoSwipe.Toolbar,window.Code.PhotoSwipe.UILayer,window.Code.PhotoSwipe.ZoomPanRotate); diff --git a/photoswipe/photoswipe.css b/photoswipe/photoswipe.css new file mode 100755 index 0000000..8a9771a --- /dev/null +++ b/photoswipe/photoswipe.css @@ -0,0 +1,172 @@ +/* + * photoswipe.css + * Copyright (c) %%year%% by Code Computerlove (http://www.codecomputerlove.com) + * Licensed under the MIT license + * + * Default styles for PhotoSwipe + * Avoid any position or dimension based styles + * where possible, unless specified already here. + * The gallery automatically works out gallery item + * positions etc. + */ + + +body.ps-active, body.ps-building, div.ps-active, div.ps-building +{ + background: #000; + overflow: hidden; +} +body.ps-active *, div.ps-active * +{ + -webkit-tap-highlight-color: rgba(255, 255, 255, 0); + display: none; +} +body.ps-active *:focus, div.ps-active *:focus +{ + outline: 0; +} + + +/* Document overlay */ +div.ps-document-overlay +{ + background: #000; +} + + +/* UILayer */ +div.ps-uilayer { + + background: #000; + cursor: pointer; + +} + + +/* Zoom/pan/rotate layer */ +div.ps-zoom-pan-rotate{ + background: #000; +} +div.ps-zoom-pan-rotate * { display: block; } + + +/* Carousel */ +div.ps-carousel-item-loading +{ + background: url(loader.gif) no-repeat center center; +} + +div.ps-carousel-item-error +{ + background: url(error.gif) no-repeat center center; +} + + +/* Caption */ +div.ps-caption +{ + background: #000000; + background: -moz-linear-gradient(top, #303130 0%, #000101 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#303130), color-stop(100%,#000101)); + border-bottom: 1px solid #42403f; + color: #ffffff; + width: 100%; +} +div.ps-caption * { display: block; float: left; clear: left; padding: 5px; } + +div.ps-caption-bottom +{ + border-top: 1px solid #42403f; + border-bottom: none; + /*min-height: 44px;*/ +} + +div.ps-caption-content +{ + /*padding: 13px;*/ + display: block; +} +/* Toolbar */ +div.ps-toolbar +{ + background: #000000; + background: -moz-linear-gradient(top, #303130 0%, #000101 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#303130), color-stop(100%,#000101)); + border-top: 1px solid #42403f; + color: #ffffff; + font-size: 13px; + font-family: "Lucida Grande", Helvetica, Arial,Verdana, sans-serif; + text-align: center; + height: 44px; + display: table; + table-layout: fixed; +} +div.ps-toolbar * { + display: block; +} + +div.ps-toolbar-top +{ + border-bottom: 1px solid #42403f; + border-top: none; +} + +div.ps-toolbar-close, div.ps-toolbar-previous, div.ps-toolbar-next, div.ps-toolbar-play +{ + cursor: pointer; + display: table-cell; +} + +div.ps-toolbar div div.ps-toolbar-content +{ + width: 44px; + height: 44px; + margin: 0 auto 0; + background-image: url(icons.png); + background-repeat: no-repeat; +} + +div.ps-toolbar-close div.ps-toolbar-content +{ + background-position: 0 0; +} + +div.ps-toolbar-previous div.ps-toolbar-content +{ + background-position: -44px 0; +} + +div.ps-toolbar-previous-disabled div.ps-toolbar-content +{ + background-position: -44px -44px; +} + +div.ps-toolbar-next div.ps-toolbar-content +{ + background-position: -132px 0; +} + +div.ps-toolbar-next-disabled div.ps-toolbar-content +{ + background-position: -132px -44px; +} + +div.ps-toolbar-play div.ps-toolbar-content +{ + background-position: -88px 0; +} + +/* Hi-res display */ +@media only screen and (-webkit-min-device-pixel-ratio: 1.5), + only screen and (-moz-min-device-pixel-ratio: 1.5), + only screen and (min-resolution: 240dpi) +{ + div.ps-toolbar div div.ps-toolbar-content + { + -moz-background-size: 176px 88px; + -o-background-size: 176px 88px; + -webkit-background-size: 176px 88px; + background-size: 176px 88px; + background-image: url(icons@2x.png); + } +} diff --git a/photoswipe/photoswipe.js b/photoswipe/photoswipe.js new file mode 100755 index 0000000..7da521c --- /dev/null +++ b/photoswipe/photoswipe.js @@ -0,0 +1,273 @@ +// Copyright (c) %%year%% by Code Computerlove (http://www.codecomputerlove.com) +// Licensed under the MIT license +// version: %%version%% + +(function(window, Util){ + + + Util.registerNamespace('Code.PhotoSwipe'); + var PhotoSwipe = window.Code.PhotoSwipe; + + + + PhotoSwipe.CssClasses = { + buildingBody: 'ps-building', + activeBody: 'ps-active' + }; + + + + PhotoSwipe.EventTypes = { + + onBeforeShow: 'PhotoSwipeOnBeforeShow', + onShow: 'PhotoSwipeOnShow', + onBeforeHide: 'PhotoSwipeOnBeforeHide', + onHide: 'PhotoSwipeOnHide', + onDisplayImage: 'PhotoSwipeOnDisplayImage', + onResetPosition: 'PhotoSwipeOnResetPosition', + onSlideshowStart: 'PhotoSwipeOnSlideshowStart', + onSlideshowStop: 'PhotoSwipeOnSlideshowStop', + onTouch: 'PhotoSwipeOnTouch', + onBeforeCaptionAndToolbarShow: 'PhotoSwipeOnBeforeCaptionAndToolbarShow', + onCaptionAndToolbarShow: 'PhotoSwipeOnCaptionAndToolbarShow', + onBeforeCaptionAndToolbarHide: 'PhotoSwipeOnBeforeCaptionAndToolbarHide', + onCaptionAndToolbarHide: 'PhotoSwipeOnCaptionAndToolbarHide', + onToolbarTap: 'PhotoSwipeOnToolbarTap', + onBeforeZoomPanRotateShow: 'PhotoSwipeOnBeforeZoomPanRotateShow', + onZoomPanRotateShow: 'PhotoSwipeOnZoomPanRotateShow', + onBeforeZoomPanRotateHide: 'PhotoSwipeOnBeforeZoomPanRotateHide', + onZoomPanRotateHide: 'PhotoSwipeOnZoomPanRotateHide', + onZoomPanRotateTransform: 'PhotoSwipeOnZoomPanRotateTransform' + + }; + + + + PhotoSwipe.instances = []; + PhotoSwipe.activeInstances = []; + + + + /* + * Function: Code.PhotoSwipe.setActivateInstance + */ + PhotoSwipe.setActivateInstance = function(instance){ + + // Can only have one instance per target (i.e. window or div) + var index = Util.arrayIndexOf(instance.settings.target, PhotoSwipe.activeInstances, 'target'); + if (index > -1){ + throw 'Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active for this target'; + } + PhotoSwipe.activeInstances.push({ + target: instance.settings.target, + instance: instance + }); + + }; + + + + /* + * Function: Code.PhotoSwipe.unsetActivateInstance + */ + PhotoSwipe.unsetActivateInstance = function(instance){ + + var index = Util.arrayIndexOf(instance, PhotoSwipe.activeInstances, 'instance'); + PhotoSwipe.activeInstances.splice(index, 1); + + }; + + + + /* + * Function: Code.PhotoSwipe.attach + */ + PhotoSwipe.attach = function(images, options, id){ + + var i, j, instance, image; + + instance = PhotoSwipe.createInstance(images, options, id); + + // Add click event handlers if applicable + for (i=0, j=images.length; i