;(function(window, undefined){
"use strict";
var $=window.jQuery||window.Zepto,
lazyInstanceId=0,
windowLoaded=false;
$.fn.Lazy=$.fn.lazy=function(settings){
return new LazyPlugin(this, settings);
};
$.Lazy=$.lazy=function(names, elements, loader){
if($.isFunction(elements)){
loader=elements;
elements=[];
}
if(!$.isFunction(loader)){
return;
}
names=$.isArray(names) ? names:[names];
elements=$.isArray(elements) ? elements:[elements];
var config=LazyPlugin.prototype.config,
forced=config._f||(config._f={});
for(var i=0, l=names.length; i < l; i++){
if(config[names[i]]===undefined||$.isFunction(config[names[i]])){
config[names[i]]=loader;
}}
for(var c=0, a=elements.length; c < a; c++){
forced[elements[c]]=names[0];
}};
function _executeLazy(instance, config, items, events, namespace){
var _awaitingAfterLoad=0,
_actualWidth=-1,
_actualHeight=-1,
_isRetinaDisplay=false,
_afterLoad="afterLoad",
_load="load",
_error="error",
_img="img",
_src="src",
_srcset="srcset",
_sizes="sizes",
_backgroundImage="background-image";
function _initialize(){
_isRetinaDisplay=window.devicePixelRatio > 1;
items=_prepareItems(items);
if(config.delay >=0){
setTimeout(function(){
_lazyLoadItems(true);
}, config.delay);
}
if(config.delay < 0||config.combined){
events.e=_throttle(config.throttle, function(event){
if(event.type==="resize"){
_actualWidth=_actualHeight=-1;
}
_lazyLoadItems(event.all);
});
events.a=function(additionalItems){
additionalItems=_prepareItems(additionalItems);
items.push.apply(items, additionalItems);
};
events.g=function(){
return (items=$(items).filter(function(){
return !$(this).data(config.loadedName);
}));
};
events.f=function(forcedItems){
for(var i=0; i < forcedItems.length; i++){
var item=items.filter(function(){
return this===forcedItems[i];
});
if(item.length){
_lazyLoadItems(false, item);
}}
};
_lazyLoadItems();
$(config.appendScroll).on("scroll." + namespace + " resize." + namespace, events.e);
}}
function _prepareItems(items){
var defaultImage=config.defaultImage,
placeholder=config.placeholder,
imageBase=config.imageBase,
srcsetAttribute=config.srcsetAttribute,
loaderAttribute=config.loaderAttribute,
forcedTags=config._f||{};
items=$(items).filter(function(){
var element=$(this),
tag=_getElementTagName(this);
return !element.data(config.handledName) &&
(element.attr(config.attribute)||element.attr(srcsetAttribute)||element.attr(loaderAttribute)||forcedTags[tag]!==undefined);
})
.data("plugin_" + config.name, instance);
for(var i=0, l=items.length; i < l; i++){
var element=$(items[i]),
tag=_getElementTagName(items[i]),
elementImageBase=element.attr(config.imageBaseAttribute)||imageBase;
if(tag===_img&&elementImageBase&&element.attr(srcsetAttribute)){
element.attr(srcsetAttribute, _getCorrectedSrcSet(element.attr(srcsetAttribute), elementImageBase));
}
if(forcedTags[tag]!==undefined&&!element.attr(loaderAttribute)){
element.attr(loaderAttribute, forcedTags[tag]);
}
if(tag===_img&&defaultImage&&!element.attr(_src)){
element.attr(_src, defaultImage);
}
else if(tag!==_img&&placeholder&&(!element.css(_backgroundImage)||element.css(_backgroundImage)==="none")){
element.css(_backgroundImage, "url('" + placeholder + "')");
}}
return items;
}
function _lazyLoadItems(allItems, forced){
if(!items.length){
if(config.autoDestroy){
instance.destroy();
}
return;
}
var elements=forced||items,
loadTriggered=false,
imageBase=config.imageBase||"",
srcsetAttribute=config.srcsetAttribute,
handledName=config.handledName;
for(var i=0; i < elements.length; i++){
if(allItems||forced||_isInLoadableArea(elements[i])){
var element=$(elements[i]),
tag=_getElementTagName(elements[i]),
attribute=element.attr(config.attribute),
elementImageBase=element.attr(config.imageBaseAttribute)||imageBase,
customLoader=element.attr(config.loaderAttribute);
if(!element.data(handledName) &&
(!config.visibleOnly||element.is(":visible"))&&(
(attribute||element.attr(srcsetAttribute))&&(
(tag===_img&&(elementImageBase + attribute!==element.attr(_src)||element.attr(srcsetAttribute)!==element.attr(_srcset))) ||
(tag!==_img&&elementImageBase + attribute!==element.css(_backgroundImage))
) ||
customLoader)){
loadTriggered=true;
element.data(handledName, true);
_handleItem(element, tag, elementImageBase, customLoader);
}}
}
if(loadTriggered){
items=$(items).filter(function(){
return !$(this).data(handledName);
});
}}
function _handleItem(element, tag, imageBase, customLoader){
++_awaitingAfterLoad;
var errorCallback=function(){
_triggerCallback("onError", element);
_reduceAwaiting();
errorCallback=$.noop;
};
_triggerCallback("beforeLoad", element);
var srcAttribute=config.attribute,
srcsetAttribute=config.srcsetAttribute,
sizesAttribute=config.sizesAttribute,
retinaAttribute=config.retinaAttribute,
removeAttribute=config.removeAttribute,
loadedName=config.loadedName,
elementRetina=element.attr(retinaAttribute);
if(customLoader){
var loadCallback=function(){
if(removeAttribute){
element.removeAttr(config.loaderAttribute);
}
element.data(loadedName, true);
_triggerCallback(_afterLoad, element);
setTimeout(_reduceAwaiting, 1);
loadCallback=$.noop;
};
element.off(_error).one(_error, errorCallback)
.one(_load, loadCallback);
if(!_triggerCallback(customLoader, element, function(response){
if(response){
element.off(_load);
loadCallback();
}else{
element.off(_error);
errorCallback();
}})) element.trigger(_error);
}else{
var imageObj=$(new Image());
imageObj.one(_error, errorCallback)
.one(_load, function(){
element.hide();
if(tag===_img){
element.attr(_sizes, imageObj.attr(_sizes))
.attr(_srcset, imageObj.attr(_srcset))
.attr(_src, imageObj.attr(_src));
}else{
element.css(_backgroundImage, "url('" + imageObj.attr(_src) + "')");
}
element[config.effect](config.effectTime);
if(removeAttribute){
element.removeAttr(srcAttribute + " " + srcsetAttribute + " " + retinaAttribute + " " + config.imageBaseAttribute);
if(sizesAttribute!==_sizes){
element.removeAttr(sizesAttribute);
}}
element.data(loadedName, true);
_triggerCallback(_afterLoad, element);
imageObj.remove();
_reduceAwaiting();
});
var imageSrc=(_isRetinaDisplay&&elementRetina ? elementRetina:element.attr(srcAttribute))||"";
imageObj.attr(_sizes, element.attr(sizesAttribute))
.attr(_srcset, element.attr(srcsetAttribute))
.attr(_src, imageSrc ? imageBase + imageSrc:null);
imageObj.complete&&imageObj.trigger(_load);
}}
function _isInLoadableArea(element){
var elementBound=element.getBoundingClientRect(),
direction=config.scrollDirection,
threshold=config.threshold,
vertical     =
((_getActualHeight() + threshold) > elementBound.top) &&
(-threshold < elementBound.bottom),
horizontal   =
((_getActualWidth() + threshold) > elementBound.left) &&
(-threshold < elementBound.right);
if(direction==="vertical"){
return vertical;
}
else if(direction==="horizontal"){
return horizontal;
}
return vertical&&horizontal;
}
function _getActualWidth(){
return _actualWidth >=0 ? _actualWidth:(_actualWidth=$(window).width());
}
function _getActualHeight(){
return _actualHeight >=0 ? _actualHeight:(_actualHeight=$(window).height());
}
function _getElementTagName(element){
return element.tagName.toLowerCase();
}
function _getCorrectedSrcSet(srcset, imageBase){
if(imageBase){
var entries=srcset.split(",");
srcset="";
for(var i=0, l=entries.length; i < l; i++){
srcset +=imageBase + entries[i].trim() + (i!==l - 1 ? ",":"");
}}
return srcset;
}
function _throttle(delay, callback){
var timeout,
lastExecute=0;
return function(event, ignoreThrottle){
var elapsed=+new Date() - lastExecute;
function run(){
lastExecute=+new Date();
callback.call(instance, event);
}
timeout&&clearTimeout(timeout);
if(elapsed > delay||!config.enableThrottle||ignoreThrottle){
run();
}else{
timeout=setTimeout(run, delay - elapsed);
}};}
function _reduceAwaiting(){
--_awaitingAfterLoad;
if(!items.length&&!_awaitingAfterLoad){
_triggerCallback("onFinishedAll");
}}
function _triggerCallback(callback, element, args){
if((callback=config[callback])){
callback.apply(instance, [].slice.call(arguments, 1));
return true;
}
return false;
}
if(config.bind==="event"||windowLoaded){
_initialize();
}else{
$(window).on(_load + "." + namespace, _initialize);
}}
function LazyPlugin(elements, settings){
var _instance=this,
_config=$.extend({}, _instance.config, settings),
_events={},
_namespace=_config.name + "-" + (++lazyInstanceId);
_instance.config=function(entryName, value){
if(value===undefined){
return _config[entryName];
}
_config[entryName]=value;
return _instance;
};
_instance.addItems=function(items){
_events.a&&_events.a($.type(items)==="string" ? $(items):items);
return _instance;
};
_instance.getItems=function(){
return _events.g ? _events.g():{};};
_instance.update=function(useThrottle){
_events.e&&_events.e({}, !useThrottle);
return _instance;
};
_instance.force=function(items){
_events.f&&_events.f($.type(items)==="string" ? $(items):items);
return _instance;
};
_instance.loadAll=function(){
_events.e&&_events.e({all: true}, true);
return _instance;
};
_instance.destroy=function(){
$(_config.appendScroll).off("." + _namespace, _events.e);
$(window).off("." + _namespace);
_events={};
return undefined;
};
_executeLazy(_instance, _config, elements, _events, _namespace);
return _config.chainable ? elements:_instance;
}
LazyPlugin.prototype.config={
name:"lazy",
chainable:true,
autoDestroy:true,
bind:"load",
threshold:500,
visibleOnly:false,
appendScroll:window,
scrollDirection:"both",
imageBase:null,
defaultImage:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",
placeholder:null,
delay:-1,
combined:false,
attribute:"data-src",
srcsetAttribute:"data-srcset",
sizesAttribute:"data-sizes",
retinaAttribute:"data-retina",
loaderAttribute:"data-loader",
imageBaseAttribute:"data-imagebase",
removeAttribute:true,
handledName:"handled",
loadedName:"loaded",
effect:"show",
effectTime:0,
enableThrottle:true,
throttle:250,
beforeLoad:undefined,
afterLoad:undefined,
onError:undefined,
onFinishedAll:undefined
};
$(window).on("load", function(){
windowLoaded=true;
});
})(window);
(function(){
var win=window,
lastTime=0;
win.requestAnimationFrame=win.requestAnimationFrame||win.webkitRequestAnimationFrame;
if(!win.requestAnimationFrame){
win.requestAnimationFrame=function(callback){
var currTime=new Date().getTime(),
timeToCall=Math.max(0, 16 -(currTime - lastTime) ),
id=setTimeout(callback, timeToCall);
lastTime=currTime + timeToCall;
return id;
};}
if(!win.cancelAnimationFrame){
win.cancelAnimationFrame=function(id){
clearTimeout(id);
};}}());
(function(root, factory){
if(typeof define==='function'&&define.amd){
define(
'themeone-utils/utils',
factory
);
}else if(typeof module==='object'&&module.exports){
module.exports=factory();
}else{
root.ThemeoneUtils=factory();
}}(this, function(){
"use strict";
var utils={};
var Console=window.console;
utils.error=function(message){
if(typeof Console!=='undefined'){
Console.error(message);
}};
utils.extend=function(options, defaults){
if(options){
if(typeof options!=='object'){
this.error('Custom options must be an object');
}else{
for(var prop in defaults){
if(defaults.hasOwnProperty(prop)&&options.hasOwnProperty(prop) ){
defaults[prop]=options[prop];
}}
}}
return defaults;
};
utils.prop=function(prop){
var el=this.createEl(),
prefixes=['', 'Webkit', 'Moz', 'ms', 'O'];
for(var p=0, pl=prefixes.length; p < pl; p++){
var prefixedProp=prefixes[p] ? prefixes[p] + prop.charAt(0).toUpperCase() + prop.slice(1):prop;
if(el.style[prefixedProp]!==undefined){
return prefixedProp;
}}
return '';
};
utils.cloneObject=function(obj){
var copy={};
for(var attr in obj){
if(obj.hasOwnProperty(attr) ){
copy[attr]=obj[attr];
}}
return copy;
};
utils.createEl=function(tag, classes){
var el=document.createElement(tag||'div');
if(classes){
el.className=classes;
}
return el;
};
utils.camelize=function(string){
return string.replace(/-([a-z])/g, function(g){
return g[1].toUpperCase();
});
};
utils.handleEvents=function(_this, el, event, fn, isBind){
if(typeof this.event_handlers!=='object'){
this.event_handlers={};}
if(!this.event_handlers[fn]){
this.event_handlers[fn]=_this[fn].bind(_this);
}
isBind=isBind===undefined ? true:!!isBind;
var bindMethod=isBind ? 'addEventListener':'removeEventListener';
event.forEach(function(ev){
el[bindMethod](ev, this.event_handlers[fn], false);
}.bind(this) );
};
utils.dispatchEvent=function(_this, namespace, type, event, args){
type +=namespace ? '.' + namespace:'';
var emitArgs=event ? [event].concat(args):[args];
_this.emitEvent(type, emitArgs);
};
utils.throttle=function(func, delay){
var timestamp=null,
limit=delay;
return function(){
var self=this,
args=arguments,
now=Date.now();
if(!timestamp||now - timestamp >=limit){
timestamp=now;
func.apply(self, args);
}};};
utils.modulo=function(length, index){
return(length +(index % length) ) % length;
};
utils.classReg=function(className){
return new RegExp('(^|\\s+)' + className + '(\\s+|$)');
};
utils.hasClass=function(el, className){
return !!el.className.match(this.classReg(className) );
};
utils.addClass=function(el, className){
if(!this.hasClass(el, className) ){
el.className +=(el.className ? ' ':'')  + className;
}};
utils.removeClass=function(el, className){
if(this.hasClass(el, className) ){
el.className=el.className.replace(this.classReg(className), ' ').replace(/\s+$/, '');
}};
utils.translate=function(el, x, y, s){
var scale=s ? ' scale(' + s + ',' + s + ')':'';
el.style[this.browser.trans]=(this.browser.gpu) ?
'translate3d(' +(x||0) + 'px, ' +(y||0) + 'px, 0)' + scale :
'translate(' +(x||0) + 'px, ' +(y||0) + 'px)' + scale;
};
utils.browser={
trans:utils.prop('transform'),
gpu:utils.prop('perspective') ? true:false
};
return utils;
}));
(function(root, factory){
if(typeof define==='function'&&define.amd){
define(
'themeone-event/event',
factory
);
}else if(typeof module==='object'&&module.exports){
module.exports=factory();
}else{
root.ThemeoneEvent=factory();
}}(typeof window!=='undefined' ? window:this, function(){
"use strict";
var EvEmitter=function(){},
proto=EvEmitter.prototype;
proto.on=function(eventName, listener){
if(!eventName||!listener){
return null;
}
var events=this._events=this._events||{};
var listeners=events[eventName]=events[eventName]||[];
if(listeners.indexOf(listener)===-1){
listeners.push(listener);
}
return this;
};
proto.off=function(eventName, listener){
var listeners=this._events&&this._events[eventName];
if(!listeners||!listeners.length){
return null;
}
var index=listeners.indexOf(listener);
if(index!==-1){
listeners.splice(index, 1);
}
return this;
};
proto.emitEvent=function(eventName, args){
var listeners=this._events&&this._events[eventName];
if(!listeners||!listeners.length){
return null;
}
var i=0,
listener=listeners[i];
args=args||[];
var onceListeners=this._onceEvents&&this._onceEvents[eventName];
while(listener){
var isOnce=onceListeners&&onceListeners[listener];
if(isOnce){
this.off(eventName, listener);
delete onceListeners[listener];
}
listener.apply(this, args);
i +=isOnce ? 0:1;
listener=listeners[i];
}
return this;
};
return EvEmitter;
}));
(function(root, factory){
if(typeof define==='function'&&define.amd){
define(
'themeone-animate/animate',
['themeone-utils/utils',
'themeone-event/event'],
factory
);
}else if(typeof module==='object'&&module.exports){
module.exports=factory(
require('themeone-utils'),
require('themeone-event')
);
}else{
root.ThemeoneAnimate=factory(
root.ThemeoneUtils,
root.ThemeoneEvent
);
}}(this, function(utils, EvEmitter){
'use strict';
var Animate=function(element, positions, friction, attraction){
this.element=element;
this.defaults=positions;
this.forces={
friction:friction||0.28,
attraction:attraction||0.028
};
this.resetAnimate();
};
var proto=Animate.prototype=Object.create(EvEmitter.prototype);
proto.updateDrag=function(obj){
this.move=true;
this.drag=obj;
};
proto.releaseDrag=function(){
this.move=false;
};
proto.animateTo=function(obj){
this.attraction=obj;
};
proto.startAnimate=function(){
this.move=true;
this.settle=false;
this.restingFrames=0;
if(!this.RAF){
this.animate();
}};
proto.stopAnimate=function(){
this.move=false;
this.restingFrames=0;
if(this.RAF){
cancelAnimationFrame(this.RAF);
this.RAF=false;
}
this.start=utils.cloneObject(this.position);
this.velocity={
x:0,
y:0,
s:0
};};
proto.resetAnimate=function(){
this.stopAnimate();
this.settle=true;
this.drag=utils.cloneObject(this.defaults);
this.start=utils.cloneObject(this.defaults);
this.resting=utils.cloneObject(this.defaults);
this.position=utils.cloneObject(this.defaults);
this.attraction=utils.cloneObject(this.defaults);
};
proto.animate=function(){
var loop=(function(){
if(typeof this.position!=='undefined'){
var previous=utils.cloneObject(this.position);
this.applyDragForce();
this.applyAttractionForce();
utils.dispatchEvent(this, 'toanimate', 'render', this);
this.integratePhysics();
this.getRestingPosition();
this.render(100);
this.RAF=requestAnimationFrame(loop);
this.checkSettle(previous);
}}).bind(this);
this.RAF=requestAnimationFrame(loop);
};
proto.integratePhysics=function(){
for(var k in this.position){
if(typeof this.position[k]!=='undefined'){
this.position[k] +=this.velocity[k];
this.position[k]=(k==='s') ? Math.max(0.1, this.position[k]):this.position[k];
this.velocity[k] *=this.getFrictionFactor();
}}
};
proto.applyDragForce=function(){
if(this.move){
for(var k in this.drag){
if(typeof this.drag[k]!=='undefined'){
var dragVelocity=this.drag[k] - this.position[k];
var dragForce=dragVelocity - this.velocity[k];
this.applyForce(k, dragForce);
}}
}};
proto.applyAttractionForce=function(){
if(!this.move){
for(var k in this.attraction){
if(typeof this.attraction[k]!=='undefined'){
var distance=this.attraction[k] - this.position[k];
var force=distance * this.forces.attraction;
this.applyForce(k, force);
}}
}};
proto.getRestingPosition=function(){
for(var k in this.position){
if(typeof this.position[k]!=='undefined'){
this.resting[k]=this.position[k] + this.velocity[k] /(1 - this.getFrictionFactor());
}}
};
proto.applyForce=function(direction, force){
this.velocity[direction] +=force;
};
proto.getFrictionFactor=function(){
return 1 - this.forces.friction;
};
proto.roundValues=function(values, round){
for(var k in values){
if(typeof values[k]!=='undefined'){
round=k==='s' ? round * 100:round;
values[k]=Math.round(values[k] * round) / round;
}}
};
proto.checkSettle=function(previous){
if(!this.move){
var count=0;
for(var k in this.position){
if(typeof this.position[k]!=='undefined'){
var round=k==='s' ? 10000:100;
if(Math.round(this.position[k] * round)===Math.round(previous[k] * round) ){
count++;
if(count===Object.keys(this.position).length){
this.restingFrames++;
}}
}}
}
if(this.restingFrames > 2){
this.stopAnimate();
this.render(this.position.s > 1 ? 10:1);
this.settle=true;
if(JSON.stringify(this.start)!==JSON.stringify(this.position) ){
utils.dispatchEvent(this, 'toanimate', 'settle', this);
}}
};
proto.render=function(round){
this.roundValues(this.position, round);
utils.translate(this.element,
this.position.x,
this.position.y,
this.position.s
);
};
return Animate;
}));
(function(root, factory){
if(typeof define==='function'&&define.amd){
define(
['themeone-utils/utils',
'themeone-event/event',
'themeone-animate/animate'],
factory
);
}else if(typeof exports==='object'&&module.exports){
module.exports=factory(
require('themeone-utils'),
require('themeone-event'),
require('themeone-animate')
);
}else{
root.ModuloBox=factory(
root.ThemeoneUtils,
root.ThemeoneEvent,
root.ThemeoneAnimate
);
}}(this, function(utils, EvEmitter, Animate){
'use strict';
var version='1.3.0';
var GUID=0;
var instances={};
var expando='mobx' +(version + Math.random()).replace(/\D/g, '');
var cache={ uid:0 };
var defaults={
mediaSelector:'.mobx',
threshold:5,
attraction:{
slider:0.055,
slide:0.018,
thumbs:0.016 
},
friction:{
slider:0.62,
slide:0.18,
thumbs:0.22 
},
rightToLeft:false,
loop:3,
preload:1,
unload:false,
timeToIdle:4000,
history:false,
mouseWheel:true,
contextMenu:true,
scrollBar:true,
fadeIfSettle:false,
controls:['close'], // 'zoom', 'play', 'fullScreen', 'download', 'share', 'close'
prevNext:true,
prevNextTouch:false,
counterMessage:'[index] / [total]',
caption:true,
autoCaption:false,
captionSmallDevice:true,
thumbnails:true,
thumbnailsNav:'basic',
thumbnailSizes:{
1920:{
width:110,
height:80,
gutter:10 
},
1280:{
width:90,
height:65,
gutter:10
},
680:{
width:70,
height:50,
gutter:8
},
480:{
width:60,
height:44,
gutter:5
}},
spacing:0.1,
smartResize:true,
overflow:false,
loadError:'Sorry, an error occured while loading the content...',
noContent:'Sorry, no content was found!',
prevNextKey:true,
scrollToNav:false,
scrollSensitivity:15,
zoomTo:'auto',
minZoom:1.2,
maxZoom:4,
doubleTapToZoom:true,
scrollToZoom:false,
pinchToZoom:true,
escapeToClose:true,
scrollToClose:false,
pinchToClose:true,
dragToClose:true,
tapToClose:true,
shareButtons:['facebook', 'googleplus', 'twitter', 'pinterest', 'linkedin', 'reddit'], // 'facebook', 'googleplus', 'twitter', 'pinterest', 'linkedin', 'reddit', 'stumbleupon', 'tumblr', 'blogger', 'buffer', 'digg', 'evernote'
shareText:'Share on',
sharedUrl:'deeplink',
slideShowInterval:4000,
slideShowAutoPlay:false,
slideShowAutoStop:false,
countTimer:true,
countTimerBg:'rgba(255,255,255,0.25)',
countTimerColor:'rgba(255,255,255,0.75)',
mediaelement:false,
videoRatio:16 / 9,
videoMaxWidth:1180,
videoAutoPlay:false,
videoThumbnail:false
};
var ModuloBox=function(options){
this.options=utils.extend(options, defaults);
this.setVar();
};
var proto=ModuloBox.prototype=Object.create(EvEmitter.prototype);
proto.init=function(){
if(this.GUID){
return instances[this.GUID];
}
this.GUID=++GUID;
instances[this.GUID]=this;
this.createDOM();
this.setAnimation();
this.getGalleries();
this.openFromQuery();
};
proto.setVar=function(){
var win=window,
doc=document,
nav=navigator;
this.pre='mobx';
this.gesture={};
this.buttons={};
this.slider={};
this.slides={};
this.cells={};
this.states={};
this.pointers=[];
this.expando=expando;
this.cache=cache;
this.dragEvents=this.detectPointerEvents();
this.browser={
touchDevice:('ontouchstart' in win)||(nav.maxTouchPoints > 0)||(nav.msMaxTouchPoints > 0),
pushState:'history' in win&&'pushState' in history,
fullScreen:this.detectFullScreen(),
mouseWheel:'onwheel' in doc.createElement('div') ?
'wheel':doc.onmousewheel!==undefined ?
'mousewheel':'DOMMouseScroll'
};
this.iframeVideo=this.iframeVideo();
this.socialMedia=this.socialMedia();
};
proto.detectPointerEvents=function(){
var nav=navigator;
if(nav.pointerEnabled){
return {
start:['pointerdown'],
move:['pointermove'],
end:['pointerup', 'pointercancel']
};}
if(nav.msPointerEnabled){
return {
start:['MSPointerDown'],
move:['MSPointerMove'],
end:['MSPointerUp', 'MSPointerCancel']
};}
return {
start:['mousedown', 'touchstart'],
move:['mousemove', 'touchmove'],
end:['mouseup', 'mouseleave', 'touchend', 'touchcancel']
};};
proto.detectFullScreen=function(){
var fullScreen=['fullscreenEnabled', 'webkitFullscreenEnabled', 'mozFullScreenEnabled', 'msFullscreenEnabled'];
for(var i=0, l=fullScreen.length; i < l; i++){
if(document[fullScreen[i]]){
return {
element:['fullscreenElement', 'webkitFullscreenElement', 'mozFullScreenElement', 'msFullscreenElement'][i],
request:['requestFullscreen', 'webkitRequestFullscreen', 'mozRequestFullScreen', 'msRequestFullscreen'][i],
change:['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'][i],
exit:['exitFullscreen', 'webkitExitFullscreen', 'mozCancelFullScreen', 'msExitFullscreen'][i]
};}}
var controls=this.options.controls,
index=controls.indexOf('fullScreen');
if(index > -1){
controls.splice(index, 1);
}
return null;
};
proto.iframeVideo=function(){
return {
youtube:{
reg:/(?:www\.)?youtu\.?be(?:\.com)?\/?.*?(?:watch|embed)?(?:.*v=|v\/|watch%3Fv%3D|\/)([\w\-_]+)&?/i,
url:'https://www.youtube.com/embed/[ID]?enablejsapi=1&rel=0&autoplay=1',
share:'https://www.youtube.com/watch?v=[ID]',
poster:'https://img.youtube.com/vi/[ID]/maxresdefault.jpg',
thumb:'https://img.youtube.com/vi/[ID]/default.jpg',
play:{ event:'command', func:'playVideo' },
pause:{ event:'command', func:'pauseVideo' }},
vimeo:{
reg:/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/)?(\d+)(?:[a-zA-Z0-9_\-]+)?/i,
url:'https://player.vimeo.com/video/[ID]?autoplay=1&api=1',
share:'https://vimeo.com/[ID]',
poster:'https://vimeo.com/api/v2/video/[ID].json',
play:{ event:'command', method:'play' },
pause:{ event:'command', method:'pause' }},
dailymotion:{
reg:/(?:www\.)?(?:dailymotion\.com(?:\/embed)(?:\/video|\/hub)|dai\.ly)\/([0-9a-z]+)(?:[\-_0-9a-zA-Z]+#video=(?:[a-zA-Z0-9_\-]+))?/i,
url:'https://dailymotion.com/embed/video/[ID]?autoplay=1&api=postMessage',
share:'https://www.dailymotion.com/video/[ID]',
poster:'https://www.dailymotion.com/thumbnail/video/[ID]',
thumb:'https://www.dailymotion.com/thumbnail/video/[ID]',
play:'play',
pause:'pause'
},
wistia:{
reg:/(?:www\.)?(?:wistia\.(?:com|net)|wi\.st)\/(?:(?:m|medias|projects)|embed\/(?:iframe|playlists))\/([a-zA-Z0-9_\-]+)/i,
url:'https://fast.wistia.net/embed/iframe/[ID]?version=3&enablejsapi=1&html5=1&autoplay=1',
share:'https://fast.wistia.net/embed/iframe/[ID]',
poster:'https://fast.wistia.com/oembed?url=https://home.wistia.com/medias/[ID].json',
play:{ event:'cmd', method:'play' },
pause:{ event:'cmd', method:'pause' }}
};};
proto.socialMedia=function(){
return {
facebook:'https://www.facebook.com/sharer/sharer.php?u=[url]',
googleplus:'https://plus.google.com/share?url=[url]',
twitter:'https://twitter.com/intent/tweet?text=[text]&url=[url]',
pinterest:'https://www.pinterest.com/pin/create/button/?url=[url]&media=[image]&description=[text]',
linkedin:'https://www.linkedin.com/shareArticle?url=[url]&mini=true&title=[text]',
reddit:'https://www.reddit.com/submit?url=[url]&title=[text]',
stumbleupon:'https://www.stumbleupon.com/badge?url=[url]&title=[text]',
tumblr:'https://www.tumblr.com/share?v=3&u=[url]&t=[text]',
blogger:'https://www.blogger.com/blog_this.pyra?t&u=[url]&n=[text]',
buffer:'https://bufferapp.com/add?url=[url]title=[text]',
digg:'https://digg.com/submit?url=[url]&title=[text]',
evernote:'https://www.evernote.com/clip.action?url=[url]&title=[text]'
};};
proto.createDOM=function(){
this.DOM={};
var elements=[
'holder',
'overlay',
'slider',
'item',
'item-inner',
'ui',
'top-bar',
'bottom-bar',
'share-tooltip',
'counter',
'caption',
'caption-inner',
'thumbs-holder',
'thumbs-inner'
];
for(var i=0; i < elements.length; i++){
this.DOM[utils.camelize(elements[i])]=utils.createEl('div', this.pre + '-' + elements[i]);
}
this.appendDOM(this.DOM);
};
proto.appendDOM=function(dom){
var opt=this.options;
dom.holder.appendChild(dom.overlay);
dom.holder.appendChild(dom.slider);
dom.holder.appendChild(dom.ui);
for(var i=0; i < 5; i++){
var slide=dom.item.cloneNode(true);
slide.appendChild(dom.itemInner.cloneNode(true) );
dom.slider.appendChild(slide);
this.slides[i]=slide;
}
this.slides.length=dom.slider.children.length;
this.createUI(dom, opt);
dom.holder.setAttribute('tabindex', -1);
dom.holder.setAttribute('aria-hidden', true);
this.DOM.comment=document.createComment(' ModuloBox (v' + version + ') by Themeone ');
document.body.appendChild(this.DOM.comment);
utils.dispatchEvent(this, 'modulobox', 'beforeAppendDOM', dom);
document.body.appendChild(dom.holder);
dom.topBar.height=dom.topBar.clientHeight;
};
proto.createUI=function(dom, opt){
var shareIndex=opt.controls.indexOf('share');
if(shareIndex > -1){
var buttons=opt.shareButtons,
i=buttons.length;
while(i--){
if(!this.socialMedia.hasOwnProperty(buttons[i]) ){
buttons.splice(i, 1);
}}
if(buttons.length){
dom.ui.appendChild(dom.shareTooltip);
if(opt.shareText){
dom.shareTooltip.appendChild(utils.createEl('span') ).textContent=opt.shareText;
}
this.createButtons(buttons, dom.shareTooltip, 'shareOn');
}else{
opt.controls.splice(shareIndex, 1);
}}
if(opt.controls.length||opt.counterMessage){
var slideShow=opt.controls.indexOf('play');
dom.ui.appendChild(dom.topBar);
if(opt.counterMessage){
dom.topBar.appendChild(dom.counter);
}
if(opt.slideShowInterval < 1&&slideShow > -1){
opt.controls.splice(slideShow, 1);
}
if(opt.countTimer&&slideShow > -1){
var timer=this.DOM.timer=utils.createEl('canvas', this.pre + '-timer');
timer.setAttribute('width', 48);
timer.setAttribute('height', 48);
dom.topBar.appendChild(timer);
}
if(opt.controls.length){
var controls=opt.controls.slice();
this.createButtons(controls.reverse(), dom.topBar);
}}
if(opt.caption||opt.thumbnails){
dom.ui.appendChild(dom.bottomBar);
if(opt.caption){
dom.bottomBar.appendChild(dom.caption)
.appendChild(dom.captionInner);
}
if(opt.thumbnails){
dom.bottomBar.appendChild(dom.thumbsHolder)
.appendChild(dom.thumbsInner);
}}
if(opt.prevNext){
this.createButtons(['prev', 'next'], dom.ui);
}};
proto.createButtons=function(buttons, dom, event){
var length=buttons.length;
for(var i=0; i < length; i++){
var type=buttons[i];
this.buttons[type]=utils.createEl('BUTTON', this.pre + '-' + type.toLowerCase());
dom.appendChild(this.buttons[type]);
if(( type&&typeof this[type]==='function')||event){
this.buttons[type].event=event ? event:type;
this.buttons[type].action=type;
if(event==='shareOn'){
this.buttons[type].setAttribute('title', type.charAt(0).toUpperCase() + type.slice(1) );
}}
}};
proto.getGalleries=function(){
this.galleries={};
var selectors=this.options.mediaSelector,
sources='';
if(!selectors){
return false;
}
try {
sources=document.querySelectorAll(selectors);
} catch (error){
utils.error('Your current mediaSelector is not a valid selector: "' + selectors + '"');
}
for(var i=0, l=sources.length; i < l; i++){
var source=sources[i],
media={};
media.src=source.tagName==='A'   ? source.getAttribute('href'):null;
media.src=source.tagName==='IMG' ? source.currentSrc||source.src:media.src;
media.src=source.getAttribute('data-src')||media.src;
if(media.src){
this.getMediaAtts(source, media);
this.setMediaType(media);
if(media.type){
this.getMediaThumb(source, media);
this.getVideoThumb(media);
this.getMediaCaption(source, media);
this.setMediaCaption(media);
var gallery=this.setGalleryName(source);
this.setGalleryFeatures(gallery, media);
media.index=gallery.length;
gallery.push(media);
this.setMediaEvent(source, gallery.name, media.index);
}}
}
utils.dispatchEvent(this, 'modulobox', 'updateGalleries', this.galleries);
};
proto.addMedia=function(name, media){
if(!media||typeof media!=='object'){
utils.error('No media was found to addMedia() in a gallery');
return false;
}
name=name==='' ? 1:name;
var gallery=this.galleries[name];
gallery = !gallery ?(this.galleries[name]=[]):gallery;
gallery.name=name;
var length=media.length;
for(var i=0; i < length; i++){
var item=utils.cloneObject(media[i]);
if(item.src){
this.setMediaType(item);
this.getVideoThumb(item);
this.setMediaCaption(item);
this.setGalleryFeatures(gallery, item);
item.index=gallery.length;
gallery.push(item);
}}
};
proto.setMediaType=function(media){
if(['image', 'video', 'iframe', 'HTML'].indexOf(media.type) > -1){
return;
}
media.type=null;
var source=media.src ? media.src:null;
var extension=(source.split(/[?#]/)[0]||source).substr(( ~-source.lastIndexOf('.') >>> 0) + 2);
if(/(jpg|jpeg|png|bmp|gif|tif|tiff|jfi|jfif|exif|svg)/i.test(extension)||['external.xx.fbcdn', 'drscdn.500px.org'].indexOf(source) > -1){
media.type='image';
media.src=this.getSrc(source);
}else if(/(mp4|webm|ogv)/i.test(extension) ){
media.type='video';
media.format='html5';
}else{
var stream=this.iframeVideo;
for(var type in stream){
if(stream.hasOwnProperty(type) ){
var regs=source.match(stream[type].reg);
if(regs&&regs[1]){
var object=stream[type];
media.type='video';
media.format=type;
media.share=object.share.replace('[ID]', regs[1]);
media.src=object.url.replace('[ID]', regs[1]);
media.pause=object.pause;
media.play=object.play;
if(this.options.videoThumbnail){
media.poster = !media.poster&&object.poster ? object.poster.replace('[ID]', regs[1]):media.poster;
media.thumb  = !media.thumb&&object.poster ? object.poster.replace('[ID]', regs[1]):media.thumb;
}
break;
}}
}}
};
proto.getSrc=function(source){
var srcset=(source||'').split(/,/),
length=srcset.length,
width=0;
if(length <=1){
return source;
}
for(var i=0; i < length; i++){
var parts=srcset[i].replace(/\s+/g, ' ').trim().split(/ /),
value=parseFloat(parts[1])||0,
unit=parts[1] ? parts[1].slice(-1):null;
if(( unit==='w'&&screen.width >=value&&value > width)||!value||i===0){
width=value;
source=parts[0];
}}
return source;
};
proto.getMediaAtts=function(source, media){
var auto=this.options.autoCaption,
data=this.getAttr(source),
img=source.firstElementChild;
img=source.tagName!=='IMG'&&img&&img.tagName==='IMG' ? img:source;
media.type   = !media.type ? data.type||source.getAttribute('data-type'):media.type;
media.title=data.title||source.getAttribute('data-title')||(auto ? img.title:null);
media.desc=data.desc||source.getAttribute('data-desc')||(auto ? img.alt:null);
media.thumb=data.thumb||source.getAttribute('data-thumb');
media.poster=this.getSrc(data.poster||source.getAttribute('data-poster') );
media.width=data.width||source.getAttribute('data-width');
media.height=data.height||source.getAttribute('data-height');
if(media.title===media.desc){
media.desc=null;
}};
proto.getMediaThumb=function(source, media){
var thumbnail=source.getElementsByTagName('img');
if(!media.thumb&&thumbnail[0]){
media.thumb=thumbnail[0].src;
}};
proto.getVideoThumb=function(media){
if(!this.options.videoThumbnail||media.type!=='video'||media.format==='html5'){
return;
}
var hasPoster=media.poster&&media.poster.indexOf('.json') > -1,
hasThumb=media.thumb&&media.thumb.indexOf('.json') > -1;
if(hasPoster||hasThumb){
var uri=hasPoster ? media.poster:media.thumb,
xhr=new XMLHttpRequest();
xhr.onload=function(event){
var response=event.target.responseText;
response=JSON.parse(response);
response=response.hasOwnProperty(0) ? response[0]:response;
if(response){
media.poster=response.thumbnail_large||response.thumbnail_url;
if(media.dom){
media.dom.style.backgroundImage='url("' + media.poster + '")';
}
if(hasThumb){
var thumb=response.thumbnail_small||response.thumbnail_url;
if(typeof media.thumb==='object'){
media.thumb.style.backgroundImage='url("' + thumb + '")';
}else{
media.thumb=thumb;
}}
}}.bind(this);
xhr.open('GET', encodeURI(uri), true);
setTimeout(function(){
xhr.send();
}, 0);
}};
proto.getMediaCaption=function(source, media){
var next=source.nextElementSibling;
if(next&&next.tagName==='FIGCAPTION'){
var caption=next.innerHTML;
if(! media.title){
media.title=caption;
}else if(! media.desc){
media.desc=caption;
}}
};
proto.setMediaCaption=function(media){
media.title=media.title ? '<div class="' + this.pre + '-title">' + media.title.trim() + '</div>':'';
media.desc=media.desc ? '<div class="' + this.pre + '-desc">' + media.desc.trim() + '</div>':'';
media.caption=media.title + media.desc;
};
proto.getGalleryName=function(source){
var parent=source,
node=0;
while(parent&&node < 2){
parent=parent.parentNode;
if(parent&&parent.tagName==='FIGURE'&&parent.parentNode){
return parent.parentNode.getAttribute('id');
}
node++;
}};
proto.setGalleryName=function(source){
var data=this.getAttr(source);
var name=data.rel||source.getAttribute('data-rel');
name = !name ? this.getGalleryName(source):name;
name = !name ? Object.keys(this.galleries).length + 1:name;
var gallery=this.galleries[name];
gallery = !gallery ?(this.galleries[name]=[]):gallery;
gallery.name=name;
return gallery;
};
proto.setGalleryFeatures=function(gallery, media){
if(!gallery.zoom&&media.type==='image'){
gallery.zoom=true;
}
if(!gallery.download&&(media.type==='image'||media.format==='html5') ){
gallery.download=true;
}};
proto.setMediaEvent=function(source, name, index){
if(source.mobxListener){
source.removeEventListener('click', source.mobxListener, false);
}
source.mobxListener=this.open.bind(this, name, index);
source.addEventListener('click', source.mobxListener, false);
};
proto.open=function(name, index, event){
if(event){
event.preventDefault();
event.stopPropagation();
}
if(!this.GUID){
return false;
}
if(!this.galleries.hasOwnProperty(name) ){
utils.error('This gallery name:"' + name + '", does not exist!');
return false;
}
if(!this.galleries[name].length){
utils.error('Sorry, no media was found for the current gallery.');
return false;
}
if(!this.galleries[name][index]){
utils.error('Sorry, no media was found for the current media index: ' + index);
return false;
}
utils.dispatchEvent(this, 'modulobox', 'beforeOpen', name, index);
this.slides.index=index;
this.gallery=this.galleries[name];
this.gallery.name=name;
this.gallery.index=index;
this.gallery.loaded=false;
this.removeContent();
this.wrapAround();
this.hideScrollBar();
this.setSlider();
this.setThumbs();
this.setCaption();
this.setMedia(this.options.preload);
this.updateMediaInfo();
this.replaceState();
this.setControls();
this.bindEvents(true);
this.show();
if(this.options.videoAutoPlay){
this.appendVideo();
}
if(this.options.slideShowAutoPlay&&this.options.controls.indexOf('play') > -1 &&
(! this.options.videoAutoPlay||this.galleries[name][index].type!=='video') ){
this.startSlideShow();
}
this.states.zoom=false;
this.states.open=true;
};
proto.openFromQuery=function(){
var query=this.getQueryString(window.location.search);
if(query.hasOwnProperty('guid')&&query.hasOwnProperty('mid') ){
var open=this.open(decodeURIComponent(query.guid),
decodeURIComponent(query.mid) - 1
);
if(open===false){
this.replaceState(true);
}}
};
proto.show=function(){
var holder=this.DOM.holder,
method=this.options.rightToLeft ? 'add':'remove';
holder.setAttribute('aria-hidden', false);
utils.removeClass(holder, this.pre + '-idle');
utils.removeClass(holder, this.pre + '-panzoom');
utils.removeClass(holder, this.pre + '-will-close');
utils[method + 'Class'](holder, this.pre + '-rtl');
utils.addClass(holder, this.pre + '-open');
};
proto.close=function(event){
if(event){
event.preventDefault();
}
var holder=this.DOM.holder,
gallery=this.gallery,
index=gallery ? gallery.index:'undefined',
name=gallery ? gallery.name:'undefined';
utils.dispatchEvent(this, 'modulobox', 'beforeClose', name, index);
if(this.states.fullScreen){
this.exitFullScreen();
utils.removeClass(holder, this.pre + '-fullscreen');
}
this.share();
this.stopSlideShow();
this.pauseVideo();
this.bindEvents(false);
this.replaceState(true);
this.hideScrollBar();
holder.setAttribute('aria-hidden', true);
utils.removeClass(holder, this.pre + '-open');
this.states.open=false;
};
proto.setControls=function(){
var gallery=this.gallery,
options=this.options,
buttons=this.buttons;
if(this.DOM.counter){
this.DOM.counter.style.display=(gallery.initialLength > 1) ? '':'none';
}
if(options.controls.indexOf('play') > -1){
buttons.play.style.display=(gallery.initialLength > 1) ? '':'none';
}
if(options.controls.indexOf('zoom') > -1){
buttons.zoom.style.display = !gallery.zoom ? 'none':'';
}
if(options.controls.indexOf('download') > -1){
buttons.download.style.display = !gallery.download ? 'none':'';
}
this.setPrevNextButtons();
};
proto.setPrevNextButtons=function(){
if(this.options.prevNext){
var hide=this.slider.width < 680&&this.browser.touchDevice&&!this.options.prevNextTouch;
this.buttons.prev.style.display =
this.buttons.next.style.display=(this.gallery.length > 1&&!hide) ? '':'none';
}};
proto.setCaption=function(){
this.states.caption = !(!this.options.captionSmallDevice&&(this.slider.width <=480||this.slider.height <=480) );
this.DOM.caption.style.display=this.states.caption ? '':'none';
};
proto.hideScrollBar=function(){
if(!this.options.scrollBar){
var open=this.states.open,
scrollBar=open==='undefined'||!open ? true:false;
document.body.style.overflow =
document.documentElement.style.overflow=scrollBar ? 'hidden':'';
}};
proto.bindEvents=function(bind){
var win=window,
doc=document,
opt=this.options,
holder=this.DOM.holder,
buttons=this.buttons,
scrollMethod;
for(var type in buttons){
if(buttons.hasOwnProperty(type) ){
var DOM=(type!=='share') ? buttons[type]:win;
utils.handleEvents(this, DOM, ['click', 'touchend'], buttons[type].event, bind);
}}
utils.handleEvents(this, holder, this.dragEvents.start, 'touchStart', bind);
utils.handleEvents(this, win, ['keydown'], 'keyDown', bind);
utils.handleEvents(this, win, ['resize', 'orientationchange'], 'resize', bind);
utils.handleEvents(this, holder, ['transitionend', 'webkitTransitionEnd', 'oTransitionEnd', 'otransitionend', 'MSTransitionEnd'], 'opened');
utils.handleEvents(this, holder, ['touchend'], 'disableZoom', bind);
if(this.browser.fullScreen){
utils.handleEvents(this, doc, [this.browser.fullScreen.change], 'toggleFullScreen', bind);
}
if(opt.history){
utils.handleEvents(this, win, ['mouseout'], 'mouseOut', bind);
}
if(opt.timeToIdle > 0){
utils.handleEvents(this, holder, ['mousemove'], 'mouseMove', bind);
}
if(!opt.contextMenu){
utils.handleEvents(this, holder, ['contextmenu'], 'contextMenu', bind);
}
if(!opt.mouseWheel){
this.disableScroll(bind);
}
if(opt.scrollToZoom){
scrollMethod='scrollToZoom';
}
else if(opt.scrollToNav){
scrollMethod='scrollToNav';
}
else if(opt.scrollToClose){
scrollMethod='scrollToClose';
}
if(scrollMethod){
utils.handleEvents(this, holder, [this.browser.mouseWheel], scrollMethod, bind);
}};
proto.opened=function(event){
if(event.propertyName==='visibility'&&event.target===this.DOM.holder){
var name=this.gallery.name,
index=this.gallery.index;
if(!this.states.open){
this.removeContent();
utils.dispatchEvent(this, 'modulobox', 'afterClose', name, index);
}else{
utils.dispatchEvent(this, 'modulobox', 'afterOpen', name, index);
}}
};
proto.mouseOut=function(event){
var e=event ? event:window.event,
from=e.relatedTarget||e.toElement;
if(!from||from.nodeName==='HTML'){
this.replaceState();
}};
proto.mouseMove=function(){
var holder=this.DOM.holder,
idleClass=this.pre + '-idle';
clearTimeout(this.states.idle);
this.states.idle=setTimeout(function(){
if(!utils.hasClass(holder, this.pre + '-open-tooltip') ){
utils.addClass(holder, idleClass);
}}.bind(this), this.options.timeToIdle);
utils.removeClass(holder, idleClass);
};
proto.contextMenu=function(event){
var target=event.target,
tagName=target.tagName,
className=target.className;
if(tagName==='IMG'||tagName==='VIDEO' ||
className.indexOf(this.pre + '-video') > -1 ||
className.indexOf(this.pre + '-thumb-bg') > -1 ||
className===this.pre + '-thumb'){
event.preventDefault();
}};
proto.disableScroll=function(bind){
var doc=document,
win=window;
var prevent=function(e){
if(!this.isEl(e) ){
return;
}
e=e||win.event;
if(e.preventDefault){
e.preventDefault();
e.returnValue=false;
return false;
}};
win.onwheel      =
win.ontouchmove  =
win.onmousewheel =
doc.onmousewheel =
doc.onmousewheel=bind ? prevent.bind(this):null;
};
proto.scrollToZoom=function(event){
if(!this.isEl(event) ){
return;
}
var data=this.normalizeWheel(event);
if(data&&data.deltaY){
var cell=this.getCell(),
scale=cell.attraction.s||cell.position.s;
scale=Math.min(this.options.maxZoom, Math.max(1, scale - Math.abs(data.deltaY) / data.deltaY) );
this.stopSlideShow();
this.zoomTo(event.clientX, event.clientY, Math.round(scale * 10) / 10);
}};
proto.scrollToNav=function(event){
if(!this.isEl(event) ){
return;
}
var data=this.normalizeWheel(event);
if(data&&data.delta){
this[data.delta * this.isRTL() < 0 ? 'prev':'next']();
}};
proto.scrollToClose=function(event){
if(!this.isEl(event) ){
return;
}
event.preventDefault();
this.close();
};
proto.disableZoom=function(event){
var node=event.target;
while(node){
if(['VIDEO', 'INPUT', 'A'].indexOf(node.tagName) > -1){
return;
}
node=node.parentElement;
}
event.preventDefault();
};
proto.resize=function(event){
this.DOM.topBar.height=this.DOM.topBar.clientHeight;
this.share();
this.setSlider();
this.setThumbsPosition();
this.setCaption();
this.resizeMedia();
this.updateMediaInfo();
this.setPrevNextButtons();
this.states.zoom=false;
utils.removeClass(this.DOM.holder, this.pre + '-panzoom');
utils.dispatchEvent(this, 'modulobox', 'resize', event);
};
proto.resizeMedia=function(){
var slides=this.slides;
for(var i=0; i < slides.length; i++){
if(!this.gallery){
break;
}
var media=this.gallery[slides[i].media];
if(media&&(( media.dom&&media.dom.loaded)||(media.dom&&['video', 'iframe', 'HTML'].indexOf(media.type) > -1) )){
this.setMediaSize(media, slides[i]);
}}
};
proto.isEl=function(event){
var name=event.target.className;
name=typeof name==='string' ? name:name.baseVal;
return name.indexOf(this.pre) > -1;
};
proto.isZoomable=function(){
var media=this.getMedia(),
zoom=false;
if(media.type==='image'&&media.dom&&media.dom.size&&media.dom.size.scale > 1){
zoom=true;
}
this.DOM.holder.setAttribute('data-zoom', zoom);
return zoom;
};
proto.isDownloadable=function(){
var media=this.getMedia(),
download=true;
if(media.type!=='image'&&media.format!=='html5'){
download=false;
}
this.DOM.holder.setAttribute('data-download', download);
return download;
};
proto.isRTL=function(){
return this.options.rightToLeft ? - 1:1;
};
proto.addAttr=function(el, attrs){
var cacheID;
if(typeof el[this.expando]==='undefined'){
cacheID=this.cache.uid++;
el[this.expando]=cacheID;
this.cache[cacheID]={};}else{
cacheID=el[this.expando];
}
for(var attr in attrs){
if(attrs.hasOwnProperty(attr) ){
this.cache[cacheID][attr]=attrs[attr];
}}
};
proto.getAttr=function(el){
return this.cache[el[this.expando]]||{};};
proto.getThumbHeight=function(){
var thumb=this.thumbs;
return thumb.height > 0&&thumb.width > 0 ? thumb.height + Math.min(10, thumb.gutter) * 2:0;
};
proto.getMedia=function(){
var gallery=this.gallery;
return gallery ? gallery[gallery.index]:null;
};
proto.getCell=function(){
var slides=this.slides,
index=utils.modulo(slides.length, slides.index);
return this.cells[index];
};
proto.removeContent=function(){
for(var i=0; i < this.slides.length; i++){
var slide=this.slides[i];
this.unloadMedia(slide);
this.removeMedia(slide);
slide.index =
slide.media=null;
}
this.removeMedia(this.DOM.thumbsHolder);
};
proto.getQueryString=function(search){
var params={};
search.substr(1).split('&').forEach(function(param){
param=param.split('=');
params[decodeURIComponent(param[0])]=param.length > 1 ? decodeURIComponent(param[1]):'';
});
return params;
};
proto.setQueryString=function(key){
var search=window.location.search,
query=this.getQueryString(search);
search=decodeURI(search);
for(var prop in key){
if(key.hasOwnProperty(prop) ){
var replace=encodeURIComponent(key[prop]);
if(query.hasOwnProperty(prop) ){
var value=query[prop];
if(!replace){
search=search.replace('&' + prop + '=' + value, '');
search=search.replace(prop + '=' + value, '');
}else{
search=search.replace(prop + '=' + value, prop + '=' + replace);
}}else{
if(replace){
search=search +(!search ? '?':'&') + prop + '=' + replace;
}else{
search=search.replace(prop + '=', '');
}}
}}
var base=[location.protocol, '//', location.host, location.pathname].join('');
search = !search.substr(1) ? search.substr(1):search;
return encodeURI(base + search);
};
proto.replaceState=function(remove){
if(( this.options.history||remove)&&this.browser.pushState&&!this.states.push){
var prevData=window.history.state,
data={
guid:!remove ? this.gallery.name:'',
mid:!remove ? utils.modulo(this.gallery.initialLength, this.gallery.index) + 1:''
};
if(!prevData||prevData.mid!==data.mid){
var search=this.setQueryString(data);
try {
window.history.replaceState(data, '', search);
} catch (error){
this.options.history=false;
utils.error('SecurityError: A history state object with origin \'null\' cannot be created. Please run the script on a server.');
}}
}
this.states.push=false;
};
proto.normalizeWheel=function(event){
var ev=event||window.event,
data=null,
deltaX,
deltaY,
delta;
event.preventDefault();
if('detail' in ev){
deltaY=ev.detail * -1;
}
if('wheelDelta' in ev){
deltaY=ev.wheelDelta * -1;
}
if('wheelDeltaY' in ev){
deltaY=ev.wheelDeltaY * -1;
}
if('wheelDeltaX' in ev){
deltaX=ev.wheelDeltaX * -1;
}
if('deltaY' in ev){
deltaY=ev.deltaY;
}
if('deltaX' in ev){
deltaX=ev.deltaX * -1;
}
if(ev.deltaMode===1){
deltaX *=40;
deltaY *=40;
}else if(ev.deltaMode===2){
deltaX *=100;
deltaY *=100;
}
delta=Math.abs(deltaX) > Math.abs(deltaY) ? deltaX:deltaY;
delta=Math.min(100, Math.max(-100, delta) );
if(Math.abs(delta) < this.options.scrollSensitivity){
this.states.prevDelta=delta;
return data;
}
var time=+new Date();
if(Math.abs(delta) > Math.abs(this.states.prevDelta)||time - this.states.prevScroll > 60){
data={
'deltaX':deltaX,
'deltaY':deltaY,
'delta':delta
};}
this.states.prevDelta=delta;
this.states.prevScroll=time;
return data;
};
proto.share=function(event){
if(event&&event.target.tagName==='VIDEO'){
return;
}
var holder=this.DOM.holder,
className=this.pre + '-open-tooltip',
element=event ? event.target.className:null,
method=utils.hasClass(holder, className) ? 'remove':'add';
if(( method==='remove'&&(element!==this.pre + '-share'||!event) )||element===this.pre + '-share'){
if(method==='add'){
this.setShareTooltip();
}
utils[method + 'Class'](holder, className);
}};
proto.shareOn=function(event){
var type=event.target.action,
gallery=this.gallery,
media=this.getMedia(),
image=media.type==='image' ? media.src:media.poster,
url=this.socialMedia[type],
uri;
if(url){
if(this.options.sharedUrl==='page'){
uri=[location.protocol, '//', location.host, location.pathname].join('');
}else if(this.options.sharedUrl==='deeplink'||['iframe', 'HTML'].indexOf(media.type) > -1){
uri=this.setQueryString({
guid:gallery.name,
mid:gallery.index + 1
});
}else{
uri=media.src.replace(/\s/g, '').split(',')[0];
if(media.type==='video'&&media.format!=='html5'){
uri=media.share;
}}
var link=utils.createEl('a');
link.href=image;
image=link.href;
link.href=uri;
uri=link.href;
var tmp=utils.createEl('div');
tmp.innerHTML=media.caption;
var text=(tmp.textContent||tmp.innerText).replace(/\s+/g, ' ').trim()||'';
url=url.replace('[url]', encodeURIComponent(uri) )
.replace('[image]', encodeURIComponent(image) )
.replace('[text]', encodeURIComponent(text||document.title) );
if(url){
var left=Math.round(window.screenX +(window.outerWidth - 626) / 2),
top=Math.round(window.screenY +(window.outerHeight - 436) / 2);
window.open(url, this.pre + '_share', 'status=0,resizable=1,location=1,toolbar=0,width=626,height=436,top=' + top + ',left=' + left);
}}else{
utils.error('This social share media does not exist');
}
return false;
};
proto.setShareTooltip=function(){
if(this.options.controls.indexOf('share') > -1){
var attribute='right',
tooltip=this.DOM.shareTooltip,
width=tooltip.clientWidth,
button=this.buttons.share.getBoundingClientRect(),
position=button.left - width + button.width / 2 + 20;
if(position < 0){
attribute='left';
position=button.left + button.width / 2 - 20;
}
tooltip.setAttribute('data-position', attribute);
tooltip.style.top=this.DOM.topBar.height + 6 + 'px';
tooltip.style.left=position + 'px';
}};
proto.download=function(){
if(!this.isDownloadable()){
return false;
}
var media=this.getMedia(),
url=media.src.replace(/\s/g, '').split(',')[0],
link=document.createElement('a');
link.href=url;
link.download=new Date().getTime();
link.setAttribute('target', '_blank');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
proto.fullScreen=function(){
var fullScreenElement=this.browser.fullScreen.element;
if(!document[fullScreenElement]){
this.requestFullScreen();
}else{
this.exitFullScreen();
}};
proto.toggleFullScreen=function(){
var holder=this.DOM.holder,
fullScreenElement=document[this.browser.fullScreen.element];
if(!fullScreenElement){
this.share();
this.states.fullScreen=false;
utils.removeClass(holder, this.pre + '-fullscreen');
}else if(fullScreenElement===holder){
this.setShareTooltip();
this.states.fullScreen=true;
utils.addClass(holder, this.pre + '-fullscreen');
}
this.videoFullScreen();
};
proto.requestFullScreen=function(){
var request=this.browser.fullScreen.request;
if(document.documentElement[request]){
this.DOM.holder[request]();
}};
proto.exitFullScreen=function(){
var exit=this.browser.fullScreen.exit;
if(document[exit]){
document[exit]();
}};
proto.play=function(){
if(this.states.play){
this.stopSlideShow();
}else{
this.startSlideShow();
}};
proto.startSlideShow=function(){
var start=0,
gallery=this.gallery,
options=this.options,
loop=this.states.loop,
autoStop=options.slideShowAutoStop,
cycle=Math.max(120, options.slideShowInterval),
count=options.countTimer,
canvas=count&&this.DOM.timer ? this.DOM.timer.getContext('2d'):null;
var countDown=(function(now){
now = !now ? +new Date():now;
start = !start ? now:start;
if(!loop||autoStop){
if(gallery.index===gallery.initialLength - 1){
this.stopSlideShow();
return;
}}
if(count&&canvas){
var percent=Math.min(1,(now - start + cycle) / cycle - 1),
radians=percent * 360 *(Math.PI / 180);
canvas.clearRect(0, 0, 48, 48);
this.timerProgress(canvas, options.countTimerBg, 100);
this.timerProgress(canvas, options.countTimerColor, radians);
}
if(now >=start + cycle){
start=now;
this.slideTo(this.slides.index + 1, true);
}
this.timer=requestAnimationFrame(countDown);
}).bind(this);
utils.addClass(this.DOM.holder, this.pre + '-autoplay');
this.states.play=true;
this.timer=requestAnimationFrame(countDown);
};
proto.stopSlideShow=function(){
cancelAnimationFrame(this.timer);
utils.removeClass(this.DOM.holder, this.pre + '-autoplay');
this.states.play=false;
};
proto.timerProgress=function(canvas, color, end){
var start=1.5 * Math.PI;
canvas.strokeStyle=color;
canvas.lineWidth=5;
canvas.beginPath();
canvas.arc(24, 24, 18, start, start + end, false);
canvas.stroke();
};
proto.appendVideo=function(){
var media=this.getMedia();
if(media.type!=='video'){
return;
}
utils.addClass(media.dom, this.pre + '-loading');
utils.removeClass(media.dom, this.pre + '-playing');
if(!media.video){
if(media.format==='html5'){
media.video=utils.createEl('video');
media.video.setAttribute('controls', '');
media.video.setAttribute('autoplay', '');
var urls=media.src.replace(/\s/g, '').split(',');
for(var i=0; i < urls.length; i++){
var frag=document.createDocumentFragment(),
source=utils.createEl('source'),
type=(/^.+\.([^.]+)$/).exec(urls[i]);
if(type&&['mp4', 'webm', 'ogv'].indexOf(type[1]) > -1){
source.src=urls[i];
source.setAttribute('type', 'video/' +(type[1]==='ogv' ? 'ogg':type[1]) );
frag.appendChild(source);
}
media.video.appendChild(frag);
}}
else if(media.format){
media.video=utils.createEl('iframe');
media.video.src=media.src;
media.video.setAttribute('frameborder', 0);
media.video.setAttribute('allowfullscreen', '');
}
media.video.setAttribute('width', '100%');
media.video.setAttribute('height', '100%');
}
if(!media.dom.firstChild){
media.dom.appendChild(media.video);
if(media.format!=='html5'){
media.video.loaded=false;
}}
this.playVideo(media);
};
proto.onVideoLoaded=function(media){
media.video.loaded=true;
utils.removeClass(media.dom, this.pre + '-loading');
utils.addClass(media.dom, this.pre + '-playing');
this.cloneVideo(media);
};
proto.cloneVideo=function(media){
if(this.states.loop&&media.format==='html5'){
var gallery=this.gallery,
length=gallery.length,
initial=gallery.initialLength,
current=utils.modulo(initial, media.index);
for(var i=0; i < length; i++){
var index=utils.modulo(initial, gallery[i].index);
if(index===current&&gallery[i].index!==media.index){
gallery[i].video=media.video;
}}
}};
proto.videoFullScreen=function(){
var media=this.getMedia(),
fullScreen=this.states.fullScreen;
if(media.type==='video'&&media.format!=='html5'&&media.video){
media.video[fullScreen ? 'removeAttribute':'setAttribute']('allowfullscreen', '');
}};
proto.playVideo=function(media){
if(media.video.loaded){
media.video.getClientRects();
utils.removeClass(media.dom, this.pre + '-loading');
utils.addClass(media.dom, this.pre + '-playing');
if(media.format!=='html5'){
if(media.play){
var message=typeof media.play==='object' ? JSON.stringify(media.play):String(media.play);
media.video.contentWindow.postMessage(message, '*');
}}else if(!media.video.error){
if(typeof MediaElementPlayer==='function'&&typeof jQuery!=='undefined'&&this.options.mediaelement){
var mejs=(media.video.tagName==='VIDEO') ? media.video:media.video.getElementsByTagName('video')[0];
if(mejs.player){
mejs.player.setControlsSize();
}
mejs.play();
}else{
media.video.play();
}}
}else{
var _this=this;
if(typeof jQuery!=='undefined'&&typeof MediaElementPlayer==='function'&&!media.play&&this.options.mediaelement&&!media.video.player){
MediaElementPlayer(media.video, {
features:['playpause', 'stop', 'current', 'progress', 'duration', 'volume', 'fullscreen'],
videoVolume:'horizontal',
startVolume:0.8,
keyActions:false,
enableKeyboard:false,
iPadUseNativeControls:true,
iPhoneUseNativeControls:true,
AndroidUseNativeControls:true,
success:function(mejs){
mejs.addEventListener('loadeddata', function(){
media.video=media.dom.lastChild;
if(media.video){
var offScreen=media.video.previousSibling;
if(offScreen&&offScreen.parentNode){
offScreen.parentNode.removeChild(offScreen);
}
_this.onVideoLoaded(media);
}}, media, false);
},
error:function(){
_this.onVideoLoaded(media);
}});
}else if(!media.video.onload){
media.video.onload  =
media.video.onerror =
media.video.onloadedmetadata=function(){
if(media.dom.firstChild){
_this.onVideoLoaded(media);
_this.videoFullScreen();
}};
media.video.src=media.src.replace(/\s/g, '').split(',')[0];
}}
};
proto.pauseVideo=function(){
var media=this.getMedia();
if(media&&media.type==='video'&&media.video){
utils.removeClass(media.dom, this.pre + '-playing');
if(!media.video.loaded){
media.dom.innerHTML='';
utils.removeClass(media.dom, this.pre + '-loading');
return;
}
if(media.format==='html5'){
if(typeof MediaElementPlayer==='function'&&typeof jQuery!=='undefined'&&this.options.mediaelement){
var mejs=(media.video.tagName==='VIDEO') ? media.video:media.video.getElementsByTagName('video')[0];
mejs.pause();
}else{
media.video.pause();
}}else{
if(media.pause&&media.format!=='dailymotion'){
var message=typeof media.pause==='object' ? JSON.stringify(media.pause):String(media.pause);
media.video.contentWindow.postMessage(message, '*');
}else{
media.dom.innerHTML='';
media.video=null;
}}
}};
proto.insertMedia=function(media_index, slide_index){
var media=this.gallery[media_index];
if(!media){
return;
}
if(typeof media.index==='undefined'){
media.index=this.gallery.indexOf(media);
}
this.buildMedia(media);
this.appendMedia(media, slide_index);
this.loadMedia(media, slide_index);
};
proto.buildMedia=function(media){
if(typeof media.dom==='undefined'){
switch(media.type){
case 'image':
media.dom=utils.createEl('img', this.pre + '-img');
media.dom.src=media.src;
break;
case 'video':
media.dom=utils.createEl('div', this.pre + '-video');
if(media.poster){
media.dom.style.backgroundImage='url("' + media.poster + '")';
}else{
media.dom.loaded=true;
}
break;
case 'iframe':
media.dom=utils.createEl('iframe', this.pre + '-iframe');
media.dom.setAttribute('allowfullscreen', '');
media.dom.setAttribute('frameborder', 0);
media.dom.src=media.src;
break;
case 'HTML':
var element=media.src;
var content=document.querySelector(element);
media.dom=utils.createEl('div', this.pre + '-html');
media.dom.appendChild(utils.createEl('div', this.pre + '-html-inner') );
media.dom.firstChild.innerHTML=content ? content.innerHTML:null;
media.src=content ? content:'';
media.dom.loaded=true;
break;
}
if(!media.type||!media.src){
media.dom=utils.createEl('div', this.pre + '-error');
media.dom.textContent=this.options.noContent;
media.dom.loaded=true;
media.dom.error=true;
utils.dispatchEvent(this, 'modulobox', 'noContent', this.gallery.name, parseInt(media.index, 10) );
}}
};
proto.appendMedia=function(media, slide_index){
var slide=this.slides[slide_index],
holder=slide.firstChild,
loader;
if(!holder.childElementCount){
var fragment=document.createDocumentFragment();
loader=utils.createEl('div', this.pre + '-loader');
fragment.appendChild(loader);
fragment.appendChild(media.dom);
holder.appendChild(fragment);
}else{
var oldMedia=holder.lastChild;
loader=holder.firstChild;
loader.style.visibility='';
if(media.dom!==oldMedia){
var method=holder.childElementCount===1 ? 'appendChild':'replaceChild';
holder[method](media.dom, oldMedia);
}}
slide.media=media.index;
};
proto.loadMedia=function(media, slide_index){
if(media.dom.loaded){
this.showMedia(media, slide_index);
return;
}
var _this=this,
dom=media.type==='iframe' ? media.dom:media.dom.img=new Image();
var onComplete=function(){
if(!media.dom.error){
utils.dispatchEvent(_this, 'modulobox', 'loadComplete', _this.gallery.name, parseInt(media.index, 10) );
}
media.dom.loaded=media.type!=='iframe' ? true:false;
_this.showMedia(media, slide_index);
};
dom.onload=onComplete;
dom.onerror=function(e){
if(media.type!=='video'){
media.dom=utils.createEl('p', _this.pre + '-error');
media.dom.textContent=_this.options.loadError;
media.dom.error=true;
_this.appendMedia(media, slide_index);
}
utils.dispatchEvent(_this, 'modulobox', 'loadError', _this.gallery.name, parseInt(media.index, 10) );
onComplete();
};
dom.src=(media.type==='video') ? media.poster:media.src;
};
proto.unloadMedia=function(slide){
if(!this.gallery){
return;
}
var index=slide.media,
media=this.gallery[index];
if(!media||!media.dom){
return;
}
if(this.options.unload&&media.type==='image'&&!media.dom.loaded&&!media.dom.complete&&!media.dom.naturalWidth){
media.dom.onload=null;
media.dom.onerror=null;
media.dom.src='';
if(media.dom.img){
media.dom.img.onload=null;
media.dom.img.onerror=null;
media.dom.img.src='';
delete media.dom.img;
}
delete media.dom;
}
else if(media.type==='video'&&media.format!=='html5'&&media.dom.firstChild){
media.video=null;
media.dom.removeChild(media.dom.firstChild);
}};
proto.removeMedia=function(holder){
var content=holder.firstChild;
if(!content){
return;
}
while(content.firstChild){
content.removeChild(content.firstChild);
}};
proto.showMedia=function(media, slide_index){
var slider=this.slider;
if(this.options.fadeIfSettle&&!slider.settle&&!media.dom.revealed){
return;
}
var slide=this.slides[slide_index],
gallery=this.gallery,
holder=slide.firstChild,
loader=holder.firstChild,
preload=this.options.preload;
this.setMediaSize(media, slide);
if(media.index===gallery.index){
this.isZoomable();
}
utils.addClass(media.dom, this.pre + '-media-loaded');
media.dom.revealed=true;
if(slide.media===media.index){
loader.style.visibility='hidden';
gallery.loaded +=1;
if(gallery.loaded===preload&&preload < 4){
this.setMedia(preload + 2);
}}
if(media.type==='iframe'){
media.dom.loaded=false;
}};
proto.setMediaSize=function(media, slide){
var object=media.dom,
slider=this.slider,
viewport=object.viewport,
thumbs=this.getThumbHeight();
if(object.error){
return;
}
if(!viewport ||
viewport.width!==slider.width ||
viewport.height!==slider.height - thumbs){
this.getCaptionHeight(media, slide);
this.getMediaSize(media, slide);
this.fitMediaSize(media, slide);
this.setMediaOffset(media, slide);
}
var style=object.style;
style.width=object.size.width + 'px';
style.height=object.size.height + 'px';
style.left=object.offset.left + 'px';
style.top=object.offset.top + 'px';
};
proto.getCaptionHeight=function(media, slide){
var caption=this.DOM.captionInner,
topBar=this.DOM.topBar.height,
content=caption.innerHTML,
thumbs=this.getThumbHeight();
if(this.options.caption&&this.states.caption&&media.caption){
caption.innerHTML=media.caption;
caption.height=Math.max(topBar, parseInt(caption.clientHeight, 10) )||topBar;
caption.innerHTML=content;
}else{
caption.height=thumbs ? 0:topBar;
}
slide.width=this.slider.width;
slide.height=this.slider.height - topBar - caption.height - thumbs;
};
proto.getMediaSize=function(media, slide){
var size=media.dom.size={};
switch(media.type){
case 'image':
size.width=media.dom.naturalWidth;
size.height=media.dom.naturalHeight;
break;
case 'video':
size.width=this.options.videoMaxWidth;
size.height=size.width / this.options.videoRatio;
break;
case 'iframe':
size.width=media.width ? media.width:slide.width > 680 ? slide.width * 0.8:slide.width;
size.height=media.height ? media.height:slide.height;
break;
case 'HTML':
size.width=media.width ? media.width:slide.width;
size.height=media.height ? media.height:slide.height;
break;
}};
proto.fitMediaSize=function(media, slide){
var slider=this.slider,
options=this.options,
zoom=options.zoomTo,
size=media.dom.size,
ratio=size.width / size.height,
thumbs=this.getThumbHeight(),
smallDevice=slider.width <=480||slider.height <=680,
canOverflow=['video', 'iframe', 'HTML'].indexOf(media.type) < 0,
smartResize=options.smartResize&&smallDevice,
width, height;
var viewports=[slide.height];
if(( smartResize||options.overflow)&&canOverflow){
viewports.unshift(slider.height - thumbs);
}
viewports.forEach(function(viewport){
if(!height||height < slider.height - thumbs){
width=Math.min(size.width, ratio * viewport);
width=width > slide.width ? slide.width:Math.round(width);
height=Math.ceil(1 / ratio * width);
height=height % viewport < 2 ? viewport:height;
}});
var scale=Number(( size.width / width).toFixed(3) );
zoom=zoom==='auto' ? scale:zoom;
media.dom.size={
width:width,
height:height,
scale:scale >=options.minZoom ? Math.min(options.maxZoom, zoom):1
};};
proto.setMediaOffset=function(media, slide){
var size=media.dom.size,
slider=this.slider,
topBar=this.DOM.topBar.height,
thumbs=this.getThumbHeight(),
fromTop=0;
if(size.height <=slide.height){
fromTop=topBar +(slide.height - size.height) * 0.5;
}
media.dom.offset={
top:fromTop < 0 ? 0:Math.round(fromTop),
left:Math.round(( slide.width - size.width) * 0.5)
};
media.dom.viewport={
width:slider.width,
height:slider.height - thumbs
};};
proto.mediaViewport=function(scale){
var media=this.getMedia();
if(!media.dom||!media.dom.size){
return {
top:0,
bottom:0,
left:0,
right:0
};}
var size=media.dom.size,
offset=media.dom.offset,
height=this.slider.height,
width=this.slider.width,
hGap=(height - size.height) * 0.5,
vGap=offset.top * 2 - hGap,
cGap=(hGap - vGap) * 0.5,
sGap=cGap * scale - cGap * 2 - vGap,
left=size.width / 2 *(scale - 1) - offset.left,
top=size.height * scale <=height ? cGap * scale:-size.height / 2 *(scale - 1) + height - size.height + sGap,
bottom=size.height * scale <=height ? cGap * scale:size.height / 2 *(scale - 1) + sGap;
return {
top:scale <=1 ? 0:Math.round(top),
bottom:scale <=1 ? 0:Math.round(bottom),
left:size.width * scale < width ? 0:Math.round(left),
right:size.width * scale < width ? 0:Math.round(-left)
};};
proto.setMedia=function(number){
var gallery=this.gallery,
slides=this.slides,
loop=this.states.loop,
RTL=this.isRTL(),
index=Math.round(- RTL * this.slider.position.x / slides.width),
length=gallery.initialLength - 1,
adjust=0,
toLoad=[],
i;
if(!number&&!gallery.loaded){
number=0;
for(i=0; i < slides.length; i++){
if(slides[i].firstChild.childElementCount){
number++;
}}
number +=2;
gallery.loaded=this.options.preload;
}
switch(number){
case 0:
case 1:
toLoad=[0];
break;
case 2:
case 3:
toLoad=[-1, 0, 1];
break;
default:
number=5;
toLoad=[-2, -1, 0, 1, 2];
}
if(!loop){
var maxMedia=index + toLoad[number - 1],
minMedia=index + toLoad[0];
adjust=(minMedia < 0) ? -minMedia:0;
adjust=(maxMedia > length) ? length - maxMedia:adjust;
}
toLoad=toLoad.map(function(i){
return utils.modulo(gallery.length, i + adjust + index);
});
for(i=0; i < slides.length; i++){
var slide=slides[i],
media_index=utils.modulo(gallery.length, slide.index);
if(!loop&&slide.index > media_index){
continue;
}
if(toLoad.indexOf(media_index) > -1&&slide.media!==media_index){
this.unloadMedia(slide);
this.insertMedia(media_index, i);
}}
};
proto.updateMediaInfo=function(){
var slides=this.slides,
gallery=this.gallery;
gallery.index=utils.modulo(gallery.length, slides.index);
this.isZoomable();
this.isDownloadable();
this.updateCounter();
this.updateCaption();
this.updateThumbs();
utils.dispatchEvent(this, 'modulobox', 'updateMedia', this.getMedia());
};
proto.setThumbs=function(){
var gallery=this.gallery,
thumbs=this.thumbs,
length=gallery.initialLength,
thumbnails=this.options.thumbnails,
thumbsHolder=this.DOM.thumbsHolder;
if(!thumbnails||length < 2){
this.DOM.caption.style.bottom=0;
thumbsHolder.style.visibility='hidden';
thumbsHolder.style.height=0;
thumbs.height =
thumbs.gutter=0;
return;
}
var sizes=this.options.thumbnailSizes,
screenW=Math.max(window.innerWidth, Math.max(screen.width, screen.height) ),
thumbNb=0,
i;
var widths=Object.keys(sizes).sort(function(a, b){
return a - b;
});
for(i=0; i < widths.length; i++){
var size=widths[i],
width=i===widths.length - 1 ? screenW:Math.min(screenW, size),
number=Math.ceil(width /(sizes[size].width + sizes[size].gutter) * 2);
if(isFinite(number)&&number > thumbNb){
thumbNb=number;
}
if(size >=screenW){
break;
}}
var fragment=document.createDocumentFragment();
length=length > 50 ? Math.min(thumbNb, length):length;
for(i=0; i < length; i++){
var thumb=utils.createEl('div', this.pre + '-thumb');
fragment.appendChild(thumb);
}
this.DOM.thumbsInner.appendChild(fragment);
this.setThumbsPosition();
};
proto.thumbClick=function(event){
var target=event.target;
if(!utils.hasClass(target, this.pre + '-thumb') ){
target=target.parentNode;
}
if(parseInt(target.index, 10) >=0){
this.slideTo(target.index);
}};
proto.loadThumb=function(thumb, index){
var media=this.gallery[index],
src;
if(!media.thumb||typeof media.thumb!=='object'){
src=media.thumb;
media.thumb=utils.createEl('div', this.pre + '-thumb-bg');
media.thumb.style.backgroundImage=src&&src.indexOf('.json') < 0 ? 'url(' + src + ')':null;
if(media.type==='video'){
utils.addClass(media.thumb, this.pre + '-thumb-video');
utils.addClass(media.thumb, this.pre + '-thumb-loaded');
}}
var method=thumb.firstChild ? 'replaceChild':'appendChild';
thumb[method](media.thumb, thumb.firstChild);
thumb.media=index;
if(src){
var dom=new Image();
dom.onload=function(){
utils.addClass(media.thumb, this.pre + '-thumb-loaded');
}.bind(this);
dom.src=src;
}};
proto.updateThumbs=function(){
var gallery=this.gallery;
if(!this.options.thumbnails||gallery.initialLength < 2){
return;
}
var thumbs=this.thumbs,
position=this.getThumbPosition(thumbs);
thumbs.stopAnimate();
if(position===thumbs.position.x){
this.shiftThumbs(thumbs);
return;
}
if(Math.abs(position - thumbs.position.x) > 50 * thumbs.size){
this.DOM.thumbsHolder.style.visibility='hidden';
thumbs.position.x=position;
utils.translate(this.DOM.thumbsInner, position, 0);
this.renderThumbs(thumbs);
this.DOM.thumbsHolder.style.visibility='';
}else{
thumbs.startAnimate();
thumbs.releaseDrag();
thumbs.animateTo({
x:position
});
}};
proto.updateCaption=function(){
if(this.options.caption){
var media=this.getMedia(),
content=media.caption ? media.caption:'',
caption=this.DOM.captionInner;
if(caption.innerHTML!==content){
caption.innerHTML=content;
}}
};
proto.updateCounter=function(){
if(this.options.counterMessage){
var gallery=this.gallery,
length=gallery.initialLength,
index=utils.modulo(length, gallery.index),
message=this.options.counterMessage,
content=message.replace('[index]', index + 1).replace('[total]', length),
counter=this.DOM.counter;
if(counter.textContent!==content){
counter.textContent=content;
}}
};
proto.wrapAround=function(){
var loop=this.options.loop,
gallery=this.gallery,
length=gallery.length;
if(!gallery.initialLength){
gallery.initialLength=length;
}
this.states.loop=loop&&loop <=length ? true:false;
if(this.states.loop&&length < this.slides.length){
var add=Math.ceil(this.slides.length / length) * length - length;
for(var i=0; i < add; i++){
var index=length + i;
gallery[index]=utils.cloneObject(gallery[utils.modulo(length, i)]);
gallery[index].index=index;
}}
};
proto.setSlider=function(){
var slider=this.slider,
slides=this.slides;
this.setSizes(slider, slides);
this.setSliderPosition(slider, slides);
this.setSlidesPositions(slides);
this.DOM.overlay.style.opacity=1;
};
proto.setSizes=function(slider, slides){
slider.width=document.body.clientWidth;
slider.height=window.innerHeight;
slides.width=slider.width + Math.round(slider.width * this.options.spacing);
};
proto.setSlidesPositions=function(slides){
for(var i=0; i < slides.length; i++){
slides[i].position=null;
this.setCellPosition(i);
}
this.shiftSlides();
};
proto.setThumbsPosition=function(){
if(!this.options.thumbnails||this.gallery.initialLength < 2){
return;
}
var thumbs=this.thumbs,
slider=this.slider,
holder=this.DOM.thumbsHolder,
inner=this.DOM.thumbsInner,
sizes=this.options.thumbnailSizes,
RTL=this.options.rightToLeft,
widths=Object.keys(sizes).sort(function(a, b){ return b - a; }),
width=Math.max.apply(null, widths),
browser=window.innerWidth,
size;
for(var i=0; i < widths.length; i++){
size=Number(widths[i]);
if(browser <=size){
width=size;
}}
thumbs.width=Number(sizes[width].width);
thumbs.gutter=Number(sizes[width].gutter);
thumbs.height=Number(sizes[width].height);
thumbs.size=thumbs.width + thumbs.gutter;
thumbs.length=this.gallery.initialLength;
var totalWidth=thumbs.length * thumbs.size;
thumbs.bound={
left: 0,
right: totalWidth > slider.width ? slider.width - totalWidth:0
};
if(RTL){
thumbs.bound.right=totalWidth > slider.width ? slider.width - thumbs.size:totalWidth - thumbs.size;
thumbs.bound.left=totalWidth - thumbs.size;
}
if(this.options.thumbnailsNav==='centered'){
thumbs.bound={
left:totalWidth > slider.width ? Math.floor(slider.width * 0.5 - thumbs.size * 0.5):Math.floor(totalWidth * 0.5 - thumbs.size * 0.5),
right:totalWidth > slider.width ? Math.ceil(slider.width * 0.5 - totalWidth + thumbs.size * 0.5):-Math.ceil(totalWidth * 0.5 - thumbs.size * 0.5)
};
if(RTL){
thumbs.bound.right=thumbs.bound.left;
thumbs.bound.left=thumbs.bound.left + totalWidth - thumbs.size;
}}
thumbs.resetAnimate();
var position=this.getThumbPosition(thumbs);
thumbs.position.x=position;
utils.translate(inner, position, 0);
var hasHeight=this.getThumbHeight();
holder.style.visibility=hasHeight ? '':'hidden';
holder.style.height=hasHeight ? hasHeight + 'px':'';
inner.style.height=hasHeight ? thumbs.height + Math.min(10, thumbs.gutter) + 'px':'';
inner.style.width=thumbs.length * thumbs.size + 'px';
inner.style.right=totalWidth > slider.width&&RTL ? 'auto':'';
};
proto.getThumbPosition=function(thumbs){
var slider=this.slider,
gallery=this.gallery,
thumbNav=this.options.thumbnailsNav,
RTL=this.isRTL(),
left=RTL < 0 ? 'right':'left',
index=utils.modulo(gallery.initialLength, gallery.index),
centered=slider.width * 0.5 - thumbs.size * 0.5,
position=thumbs.bound[left] - index * thumbs.size * RTL;
position = !thumbs.bound[left] ? position + centered:position + (RTL < 0&&thumbNav!=='centered' ? - centered:0);
return Math.max(thumbs.bound.right, Math.min(thumbs.bound.left, position) );
};
proto.setCellPosition=function(index){
var cell=this.cells[index];
cell.resetAnimate();
utils.translate(this.slides[index].children[0], 0, 0, 1);
};
proto.setSliderPosition=function(slider, slides){
var RTL=this.options.rightToLeft,
posX=- slides.index * slides.width;
posX=RTL ? - posX:posX;
slider.resetAnimate();
slider.position.x =
slider.attraction.x=posX;
slider.bound={
left:0,
right:-(this.gallery.length - 1) * slides.width
};
if(RTL){
slider.bound.left=- slider.bound.right;
slider.bound.right=0;
}
utils.translate(this.DOM.slider, posX, 0);
};
proto.setAnimation=function(){
var slider=this.DOM.slider,
friction=this.options.friction,
attraction=this.options.attraction;
this.slider=new Animate(
slider,
{ x:0, y:0 },
Math.min(Math.max(friction.slider, 0), 1),
Math.min(Math.max(attraction.slider, 0), 1)
);
this.slider.on('settle.toanimate', this.settleSider.bind(this) );
this.slider.on('render.toanimate', this.renderSlider.bind(this) );
var slides=slider.children,
length=slides.length;
for(var i=0; i < length; i++){
this.cells[i]=new Animate(
slides[i].children[0],
{ x:0, y:0, s:1 },
Math.min(Math.max(friction.slide, 0), 1),
Math.min(Math.max(attraction.slide, 0), 1)
);
this.cells[i].on('settle.toanimate', this.settleCell.bind(this) );
this.cells[i].on('render.toanimate', this.renderCell.bind(this) );
}
this.thumbs=new Animate(
this.DOM.thumbsInner,
{ x:0 },
Math.min(Math.max(friction.thumbs, 0), 1),
Math.min(Math.max(attraction.thumbs, 0), 1)
);
this.thumbs.on('settle.toanimate', this.settleThumbs.bind(this) );
this.thumbs.on('render.toanimate', this.renderThumbs.bind(this) );
};
proto.settleSider=function(slider){
var media;
utils.dispatchEvent(this, 'modulobox', 'sliderSettled', slider.position);
if(this.states.open){
this.setMedia();
this.replaceState();
}
if(this.options.fadeIfSettle){
var slides=this.slides;
for(var i=0; i < slides.length; i++){
var index=slides[i].media;
media=this.gallery[index];
if(media.dom.loaded){
this.showMedia(media, i);
}}
}};
proto.settleCell=function(cell){
var gesture=this.gesture;
if(gesture.closeBy){
utils.dispatchEvent(this, 'modulobox', 'panYSettled', null, cell.position);
}
if(( gesture.closeBy&&gesture.canClose===false)||!gesture.closeBy){
utils.dispatchEvent(this, 'modulobox', 'panZoomSettled', null, cell.position);
}};
proto.settleThumbs=function(thumbs){
utils.dispatchEvent(this, 'modulobox', 'thumbsSettled', null, thumbs.position);
};
proto.renderSlider=function(slider){
this.shiftSlides();
var RTL=this.isRTL(),
length=this.gallery.initialLength,
indexPos=- RTL * slider.position.x / this.slides.width,
moduloPos=utils.modulo(length, indexPos),
progress=(moduloPos > length - 0.5 ? 0:moduloPos) /(length - 1);
utils.dispatchEvent(this, 'modulobox', 'sliderProgress', null, Math.min(1, Math.max(0, progress) ));
};
proto.renderCell=function(cell){
this.willClose(cell);
var progress;
if(this.gesture.type==='panY'||this.gesture.closeBy||(this.gesture.type==='dragSlider'&&cell.position.y!==0) ){
progress=1 - Math.abs(cell.position.y) /(this.slider.height * 0.5);
utils.dispatchEvent(this, 'modulobox', 'panYProgress', null, progress);
}
if(this.gesture.type!=='panY'&&cell.position.s!==1){
progress=cell.position.s;
utils.dispatchEvent(this, 'modulobox', 'panZoomProgress', null, progress);
}};
proto.renderThumbs=function(thumbs){
this.shiftThumbs(thumbs);
var progress=thumbs.bound.left!==thumbs.bound.right ?(thumbs.bound.left - thumbs.position.x) /(thumbs.bound.left - thumbs.bound.right):0;
utils.dispatchEvent(this, 'modulobox', 'thumbsProgress', null, progress);
};
proto.touchStart=function(event){
var element=event.target,
tagName=element.tagName,
className=element.className;
if(event.which!==3&&element!==this.buttons.play){
this.stopSlideShow();
}
if(event.which===3||!this.isEl(event)||['BUTTON', 'VIDEO', 'INPUT', 'A'].indexOf(tagName) > -1){
return;
}
if(tagName==='IMG'&&this.gallery.length > 1){
utils.addClass(this.DOM.holder, this.pre + '-dragging');
}
event.preventDefault();
if(utils.hasClass(this.DOM.holder, this.pre + '-open-tooltip') ){
return;
}
if(!this.pointers.length){
this.gesture.canClose=undefined;
utils.handleEvents(this, window, this.dragEvents.move, 'touchMove');
utils.handleEvents(this, window, this.dragEvents.end, 'touchEnd');
}
this.addPointer(event);
if(className.indexOf('-thumb') < 0){
this.slider.stopAnimate();
var cell=this.getCell();
if(Math.round(cell.position.s * 100) / 100!==1||this.pointers.length===2||this.gesture.closeBy){
cell.stopAnimate();
}}else{
this.thumbs.stopAnimate();
}
this.gestures('start');
};
proto.touchMove=function(event){
this.updatePointer(event);
var gesture=this.gesture;
var pointerNb=this.pointers.length;
var isSettle=this.isSliderSettle();
this.switchPointers();
this.gestures('move');
if(gesture.type){
this[gesture.type](event);
utils.dispatchEvent(this, 'modulobox', gesture.type + 'Move', event, gesture);
gesture.move=true;
}
else if(( pointerNb===2&&isSettle) ||
Math.abs(gesture.dx) > this.options.threshold ||
Math.abs(gesture.dy) > this.options.threshold){
gesture.sx +=gesture.dx;
gesture.sy +=gesture.dy;
gesture.canZoom=this.isZoomable();
gesture.closeBy=false;
gesture.type=Math.abs(gesture.dx) < Math.abs(gesture.dy) / 2 ? false:'dragSlider';
gesture.type=this.options.dragToClose&&!gesture.type&&isSettle ? 'panY':gesture.type;
gesture.type=(this.options.pinchToZoom||this.states.zoom)&&gesture.canZoom&&isSettle&&(pointerNb===2||this.states.zoom) ? 'panZoom':gesture.type;
gesture.type=this.options.pinchToClose&&gesture.scale < 1&&isSettle&&pointerNb===2 ? 'panZoom':gesture.type;
gesture.type=event.target.className.indexOf('-thumb') > -1 ? 'dragThumbs':gesture.type;
if(gesture.type==='dragSlider'){
this.setMedia();
}
if(['dragSlider', 'dragThumbs'].indexOf(gesture.type) > -1){
var cell=this.getCell();
cell.startAnimate();
cell.releaseDrag();
cell.animateTo({
x:0,
y:0,
s:1
});
}
if(gesture.type!=='dragSlider'){
var slider=this.slider,
slides=this.slides;
var RTL=this.isRTL();
if(- RTL * slider.position.x!==slides.index * slides.width){
slider.startAnimate();
slider.releaseDrag();
}}
if(gesture.type){
this.pauseVideo();
utils.dispatchEvent(this, 'modulobox', gesture.type + 'Start', event, gesture);
if(this.gallery.length > 1||gesture.type!=='dragSlider'){
utils.addClass(this.DOM.holder, this.pre + '-dragging');
}}
}};
proto.touchEnd=function(event){
this.deletePointer(event);
if(!this.pointers.length){
utils.removeClass(this.DOM.holder, this.pre + '-dragging');
utils.handleEvents(this, window, this.dragEvents.move, 'touchMove', false);
utils.handleEvents(this, window, this.dragEvents.end, 'touchEnd', false);
if(this.isSliderSettle()){
var className=event.target.className;
if(utils.hasClass(event.target, this.pre + '-video') ){
this.appendVideo();
}else if(this.options.tapToClose&&!this.states.zoom&&(className===this.pre + '-item-inner'||className===this.pre + '-top-bar')&&Math.abs(this.gesture.dx) < this.options.threshold){
this.close();
return;
}
if(event.target.tagName==='IMG'){
this.doubleTap(event);
}}
if(this.options.thumbnails&&!this.gesture.move){
this.thumbClick(event);
}
var gestureEnd=this.gesture.type + 'End';
if(this.gesture.type&&typeof this[gestureEnd]==='function'){
this[gestureEnd](event);
utils.dispatchEvent(this, 'modulobox', gestureEnd, event, this.gesture);
}
this.gesture.type =
this.gesture.move=false;
if(!this.states.open){
return;
}
var cell=this.getCell();
if(!cell.settle){
cell.startAnimate();
cell.releaseDrag();
}
var slider=this.slider;
if(!slider.settle){
slider.startAnimate();
slider.releaseDrag();
}}
};
proto.switchPointers=function(){
if(this.gesture.type==='panZoom'&&this.pointers.length===1&&this.gesture.distance!==0){
var moving=this.getCell();
moving.stopAnimate();
moving.startAnimate();
this.gesture.move=false;
this.gestures('start');
this.gestures('move');
}};
proto.doubleTap=function(event){
event.preventDefault();
var touches=this.mapPointer(event),
clientX=touches[0].clientX,
clientY=touches[0].clientY;
if(typeof this.tap!=='undefined' &&
+new Date() - this.tap.delay < 350 &&
Math.abs(this.tap.deltaX - clientX) < 30 &&
Math.abs(this.tap.deltaY - clientY) < 30 
){
if(this.states.tapIdle){
clearTimeout(this.states.tapIdle);
}
if(this.options.doubleTapToZoom){
this.zoomTo(clientX, clientY);
}
this.tap=undefined;
}else{
if(this.browser.touchDevice&&this.options.timeToIdle&&!this.states.idle){
this.states.tapIdle=setTimeout(function(){
var method = !utils.hasClass(this.DOM.holder, this.pre + '-idle') ? 'add':'remove';
utils[method + 'Class'](this.DOM.holder, this.pre + '-idle');
}.bind(this), 350);
}
this.tap={
delay:+new Date(),
deltaX:touches[0].clientX,
deltaY:touches[0].clientY
};}};
proto.isSliderSettle=function(){
if(this.gesture.type){
return false;
}
var RTL=this.isRTL(),
slides=this.slides,
width=slides.width,
toSettle=Math.abs(RTL * this.slider.position.x + slides.index * width) / width * 100;
return toSettle <=3 ? true:false;
};
proto.mapPointer=function(event){
return event.touches ? event.changedTouches:[event];
};
proto.addPointer=function(event){
var pointers=this.mapPointer(event);
for(var i=0; i < pointers.length; i++){
if(this.pointers.length < 2&&['dragSlider', 'panY', 'dragThumbs'].indexOf(this.gesture.type)===-1){
var ev=pointers[i],
id=ev.pointerId!==undefined ? ev.pointerId:ev.identifier;
if(!this.getPointer(id) ){
this.pointers[this.pointers.length]={
id:id,
x:Math.round(ev.clientX),
y:Math.round(ev.clientY)
};}}
}};
proto.updatePointer=function(event){
var pointers=this.mapPointer(event);
for(var i=0; i < pointers.length; i++){
var ev=pointers[i],
id=ev.pointerId!==undefined ? ev.pointerId:ev.identifier,
pt=this.getPointer(id);
if(pt){
pt.x=Math.round(ev.clientX);
pt.y=Math.round(ev.clientY);
}}
};
proto.deletePointer=function(event){
var pointers=this.mapPointer(event);
for(var i=0; i < pointers.length; i++){
var ev=pointers[i],
id=ev.pointerId!==undefined ? ev.pointerId:ev.identifier;
for(var p=0; p < this.pointers.length; p++){
if(this.pointers[p].id===id){
this.pointers.splice(p, 1);
}}
}};
proto.getPointer=function(id){
for(var k in this.pointers){
if(this.pointers[k].id===id){
return this.pointers[k];
}}
return null;
};
proto.gestures=function(type){
var g=this.gesture,
pointers=this.pointers,
distance;
if(!pointers.length){
return;
}
g.direction=g.x ? pointers[0].x > g.x ? 1:-1:0;
g.x=pointers[0].x;
g.y=pointers[0].y;
if(pointers.length===2){
var x2=pointers[1].x,
y2=pointers[1].y;
distance=this.getDistance([g.x, g.y], [x2, y2]);
g.x=g.x -(g.x - x2) / 2;
g.y=g.y -(g.y - y2) / 2;
}
if(type==='start'){
g.dx=0;
g.dy=0;
g.sx=g.x;
g.sy=g.y;
g.distance=distance ? distance:0;
}else{
g.dx=g.x - g.sx;
g.dy=g.y - g.sy;
g.scale=distance&&g.distance ? distance / g.distance:1;
}};
proto.getDistance=function(p1, p2){
var x=p2[0] - p1[0],
y=p2[1] - p1[1];
return Math.sqrt(( x * x) +(y * y) );
};
proto.panY=function(){
var moving=this.getCell();
moving.startAnimate();
moving.updateDrag({
x:moving.position.x,
y:moving.start.y + this.gesture.dy,
s:moving.position.s
});
};
proto.panYEnd=function(){
var posY=0,
moving=this.getCell(),
height=this.slider.height,
resting=moving.resting.y;
if(1 - Math.abs(resting) /(height * 0.5) < 0.8){
posY=Math.abs(resting) < height * 0.5 ? Math.abs(resting) / resting * height * 0.5:resting;
this.close();
moving.animateTo({
x:0,
y:posY,
s:posY ? moving.resting.s:1
});
moving.startAnimate();
moving.releaseDrag();
}};
proto.panZoom=function(){
var moving=this.getCell(),
gesture=this.gesture,
bound=this.mediaViewport(moving.position.s),
minZoom=this.options.pinchToClose&&gesture.canClose ? 0.1:0.6,
scale=Math.min(this.options.maxZoom * 1.5, Math.max(minZoom, moving.start.s * gesture.scale) ),
posX=moving.start.x + gesture.dx,
posY=moving.start.y + gesture.dy,
centerX=gesture.sx - this.slider.width * 0.5,
centerY=gesture.sy - this.slider.height * 0.5;
if(!gesture.canZoom||(!this.options.pinchToZoom&&!this.states.zoom) ){
scale=Math.min(1, scale);
}
if(!this.options.pinchToZoom&&this.states.zoom){
scale=moving.position.s;
}
if(!gesture.move&&this.pointers.length===1){
moving.start.x +=posX > bound.left ? posX - bound.left:posX < bound.right ? posX - bound.right:0;
moving.start.y +=posY > bound.bottom ? posY - bound.bottom:posY < bound.top ? posY - bound.top:0;
}
posX=gesture.dx + centerX +(moving.start.x - centerX) *(scale / moving.start.s);
posY=gesture.dy + centerY +(moving.start.y - centerY) *(scale / moving.start.s);
if(this.pointers.length===1){
posX=posX > bound.left ?(posX + bound.left) * 0.5:posX < bound.right ?(posX + bound.right) * 0.5:posX;
posY=posY > bound.bottom ?(posY + bound.bottom) * 0.5:posY < bound.top ?(posY + bound.top) * 0.5:posY;
}
moving.startAnimate();
moving.updateDrag({
x:posX,
y:posY,
s:scale
});
this.updateZoom(scale);
};
proto.panZoomEnd=function(){
var moving=this.getCell(),
gesture=this.gesture,
scale=moving.resting.s > this.options.maxZoom ? this.options.maxZoom:moving.resting.s < 1 ? 1:moving.resting.s,
bound=this.mediaViewport(scale),
posX, posY;
if(Math.round(moving.resting.s * 10) / 10 > this.options.maxZoom){
var centerX=gesture.distance ? gesture.sx - this.slider.width * 0.5:0;
var centerY=gesture.distance ? gesture.sy - this.slider.height * 0.5:0;
posX=gesture.dx + centerX +(moving.start.x - centerX) *(scale / moving.start.s);
posY=gesture.dy + centerY +(moving.start.y - centerY) *(scale / moving.start.s);
posX=posX > bound.left ? bound.left:posX < bound.right ? bound.right:posX;
posY=posY > bound.bottom ? bound.bottom:posY < bound.top ? bound.top:posY;
}else{
posX=moving.resting.x > bound.left ? bound.left:moving.resting.x < bound.right ? bound.right:undefined;
posY=moving.resting.y > bound.bottom ? bound.bottom:moving.resting.y < bound.top ? bound.top:undefined;
}
if(this.options.pinchToClose&&moving.resting.s < 0.8&&gesture.canClose){
scale=moving.resting.s < 0.3 ? moving.resting.s:0.15;
posX=moving.resting.x;
posY=moving.resting.y;
this.close();
}
moving.animateTo({
x:posX,
y:posY,
s:scale!==moving.resting.s ? scale:undefined
});
moving.startAnimate();
moving.releaseDrag();
this.updateZoom(moving.resting.s);
};
proto.dragThumbs=function(){
var moving=this.thumbs,
bound=moving.bound,
posX=moving.start.x + this.gesture.dx;
if(!this.gesture.move){
moving.start.x +=posX > bound.left ? posX - bound.left:posX < bound.right ? posX - bound.right:0;
posX=moving.start.x + this.gesture.dx;
}
posX=posX > bound.left ?(posX + bound.left) * 0.5:posX < bound.right ?(posX + bound.right) * 0.5:posX;
moving.startAnimate();
moving.attraction.x=undefined;
moving.updateDrag({
x:posX
});
};
proto.dragThumbsEnd=function(){
var moving=this.thumbs,
bound=moving.bound,
posX=moving.resting.x;
posX=posX > bound.left ? bound.left:posX < bound.right ? bound.right:posX;
if(posX!==moving.resting.x){
moving.animateTo({
x: posX
});
}
moving.startAnimate();
moving.releaseDrag();
};
proto.dragSlider=function(){
if(this.gallery.length===1){
return;
}
var moving=this.slider,
posX=moving.start.x + this.gesture.dx;
if(!this.states.loop){
var bound=moving.bound;
if(!this.gesture.move){
moving.start.x +=posX > bound.left ? posX - bound.left:posX < bound.right ? posX - bound.right:0;
posX=moving.start.x + this.gesture.dx;
}
posX=posX > bound.left ?(posX + bound.left) * 0.5:posX < bound.right ?(posX + bound.right) * 0.5:posX;
}
moving.startAnimate();
moving.updateDrag({
x:posX
});
};
proto.dragSliderEnd=function(){
if(this.gallery.length===1){
return;
}
var moving=this.slider,
slides=this.slides,
oldIndex=slides.index,
RTL=this.isRTL(),
restingX=moving.resting.x,
positionX=moving.position.x;
this.getRestingIndex(positionX, restingX);
if(oldIndex!==slides.index){
this.updateMediaInfo();
}
this.slider.animateTo({
x:- RTL * slides.index * slides.width,
y:undefined,
s:undefined
});
moving.startAnimate();
moving.releaseDrag();
};
proto.getRestingIndex=function(positionX, restingX){
var direction=this.gesture.direction,
gallery=this.gallery,
slides=this.slides,
deltaX=this.gesture.dx,
RTL=this.isRTL(),
index=Math.round(- RTL * positionX / slides.width),
moved=Math.abs(restingX - positionX);
if(Math.abs(deltaX) < slides.width * 0.5&&moved){
if(deltaX > 0&&direction > 0){
index -=1 * RTL;
}else if(deltaX < 0&&direction < 0){
index +=1 * RTL;
}}
var gap=Math.max(-1, Math.min(1, index - slides.index) );
if(!this.states.loop &&
(( gallery.index + gap < 0) ||
(gallery.index + gap > gallery.length - 1) )){
return;
}
slides.index +=gap;
};
proto.shiftSlides=function(){
var slides=this.slides,
gallery=this.gallery,
loop=this.states.loop,
RTL=this.isRTL(),
from=RTL * Math.round(- this.slider.position.x / slides.width) - 2,
to=from + 5;
if(!loop&&to > gallery.initialLength - 1){
from=gallery.initialLength - 5;
to=from + 5;
}
if(!loop&&from < 0){
from=0;
to=5;
}
for(var i=from; i < to; i++){
var position=RTL * i * slides.width,
slide_index=utils.modulo(slides.length, i),
slide=slides[slide_index];
if(slide.index!==i||slide.position!==position){
slide.index=i;
slide.position=position;
slide.style.left=position + 'px';
}}
if(this.states.open){
this.setMedia(3);
}};
proto.shiftThumbs=function(thumbs){
var child=this.DOM.thumbsInner.children,
slider=this.slider,
gallery=this.gallery,
RTL=this.isRTL(),
length=child.length,
index=utils.modulo(gallery.initialLength, gallery.index),
width=thumbs.size *(length) * 0.5,
center=Math.round(( - RTL * thumbs.position.x + RTL * width * 0.5) / thumbs.size),
from=Math.max(0, center - Math.floor(length / 2) ),
to=from + length;
var tolerance=slider.width * 0.5,
boundLeft=thumbs.position.x + tolerance,
boundRight=thumbs.position.x - slider.width - tolerance;
if(to > gallery.initialLength){
to=gallery.initialLength;
from=to - length;
}
if(to===gallery.initialLength - 1&&from - to < length){
from=gallery.initialLength - length;
}
for(var i=from; i < to; i++){
var thumb=child[utils.modulo(length, i)],
position=RTL * i * thumbs.size + thumbs.gutter * 0.5,
className=this.pre + '-active-thumb',
isActive=utils.hasClass(thumb, className);
if(thumb.index!==i||thumb.position!==position){
thumb.index=i;
thumb.position=position;
thumb.style.left=position + 'px';
}
this.setThumbSize(thumb, thumbs);
if(- thumb.position <=boundLeft&&- thumb.position >=boundRight&&thumb.media!==i){
this.loadThumb(thumb, i);
}
if(isActive&&index!==i){
utils.removeClass(thumb, className);
}else if(!isActive&&index===i){
utils.addClass(thumb, className);
}}
};
proto.setThumbSize=function(thumb, thumbs){
if(thumb.width!==thumbs.width ||
thumb.height!==thumbs.height ||
thumb.gutter!==thumbs.gutter){
thumb.width=thumbs.width;
thumb.height=thumbs.height;
thumb.gutter=thumbs.gutter;
thumb.style.width=thumbs.width + 'px';
thumb.style.height=thumbs.height + 'px';
}};
proto.willClose=function(cell){
var opacity=this.DOM.overlay.style.opacity,
canClose=this.gesture.canClose,
gestureType=this.gesture.type,
gestureClose=this.gesture.closeBy,
pinchToClose=gestureType==='panZoom'||gestureClose==='panZoom',
dragYToClose=gestureType==='panY'||gestureClose==='panY';
if(cell.position.s > 1.1&&typeof canClose==='undefined'){
this.gesture.canClose=false;
}else if(cell.position.s < 1&&typeof canClose==='undefined'){
this.gesture.canClose=true;
}
if(this.options.pinchToClose&&pinchToClose&&this.gesture.canClose){
opacity=cell.position.s;
this.gesture.closeBy='panZoom';
}else if(dragYToClose){
opacity=1 - Math.abs(cell.position.y) /(this.slider.height * 0.5);
this.gesture.closeBy='panY';
}else if(opacity&&opacity < 1){
opacity=1;
this.gesture.closeBy=false;
}
opacity = !opacity ? 1:Math.max(0, Math.min(1, opacity) );
var method=opacity <=0.8||!opacity ? 'add':'remove';
utils[method + 'Class'](this.DOM.holder, this.pre + '-will-close');
this.DOM.overlay.style.opacity=opacity;
};
proto.prev=utils.throttle(function(){
if(!this.gesture.move){
this.slideTo(this.slides.index - 1 * this.isRTL());
}}, 120);
proto.next=utils.throttle(function(){
if(!this.gesture.move){
this.slideTo(this.slides.index + 1 * this.isRTL());
}}, 120);
proto.slideTo=function(to, slideShow){
var slides=this.slides,
gallery=this.gallery,
holder=this.DOM.slider,
RTL=this.isRTL(),
length=gallery.initialLength,
moduloTo=utils.modulo(length, to),
moduloFrom=utils.modulo(length, gallery.index),
slideBy=moduloTo - moduloFrom,
fromEnds=length - Math.abs(slideBy);
if(!this.states.loop&&(to < 0||to > this.gallery.initialLength - 1) ){
return;
}
if(this.states.loop&&fromEnds < 3&&fromEnds * 2 < length){
slideBy=slideBy < 0 ? fromEnds:-fromEnds;
}
if(moduloTo===to){
to=slides.index + slideBy;
}
slideBy=to - slides.index;
if(!slideBy){
return;
}
if(this.states.zoom){
this.zoom();
}
this.pauseVideo();
this.share();
if(!slideShow){
this.stopSlideShow();
}
slides.index=to;
var slider=this.slider;
if(Math.abs(slideBy) > 2){
utils.addClass(holder, this.pre + '-hide');
this.setSliderPosition(slider, slides);
this.setSlidesPositions(slides);
var moveBy=RTL * slides.width * Math.min(2, Math.abs(slideBy) ) * Math.abs(slideBy) / slideBy;
slider.position.x   =
slider.attraction.x=slider.position.x + moveBy;
utils.translate(holder, slider.position.x, 0);
holder.getClientRects();
}
this.updateMediaInfo();
utils.removeClass(holder, this.pre + '-hide');
slider.startAnimate();
slider.releaseDrag();
slider.animateTo({
x:- RTL * to * slides.width,
y:0,
s:undefined
});
};
proto.keyDown=function(event){
var key=event.keyCode,
opt=this.options;
if(opt.prevNextKey){
if(key===37){
this.prev(event);
}else if(key===39){
this.next(event);
}}
if(key===27&&opt.escapeToClose){
this.close();
}
if(!opt.mouseWheel&&[32, 33, 34, 35, 36, 38, 40].indexOf(key) > -1){
event.preventDefault();
return false;
}};
proto.zoom=function(){
this.zoomTo();
};
proto.zoomTo=function(x, y, scale){
if(!this.isSliderSettle()||(!this.isZoomable()&&scale > 1) ){
return;
}
this.gesture.closeBy=false;
var media=this.getMedia();
scale=scale ? scale:this.states.zoom ? 1:media.dom.size.scale;
var cell=this.getCell(),
bound=this.mediaViewport(scale),
centX=x ? x - this.slider.width * 0.5:0,
centY=y ? y - this.slider.height * 0.5:0,
PosX=scale > 1 ? Math.ceil(centX +(cell.position.x - centX) *(scale / cell.position.s) ):0,
PosY=scale > 1 ? Math.ceil(centY +(cell.position.y - centY) *(scale / cell.position.s) ):0;
cell.startAnimate();
cell.releaseDrag();
cell.animateTo({
x:PosX > bound.left ? bound.left:PosX < bound.right ? bound.right:PosX,
y:PosY > bound.bottom ? bound.bottom:PosY < bound.top ? bound.top:PosY,
s:scale
});
this.updateZoom(scale);
};
proto.updateZoom=function(scale){
this.states.zoom=scale > 1 ? true:false;
utils[this.states.zoom ? 'addClass':'removeClass'](this.DOM.holder, this.pre + '-panzoom');
};
proto.destroy=function(){
if(!this.GUID){
return;
}
if(this.states.open){
this.close();
}
var selectors=this.options.mediaSelector,
sources='';
try {
sources=document.querySelectorAll(selectors);
} catch (error){}
for(var i=0, l=sources.length; i < l; i++){
var source=sources[i];
if(source.mobxListener){
source.removeEventListener('click', source.mobxListener, false);
}}
this.bindEvents(false);
this.slider.resetAnimate();
for(i=0; i < this.slides.length; i++){
this.cells[i].resetAnimate();
}
if(this.thumbs){
this.thumbs.resetAnimate();
}
this.DOM.holder.parentNode.removeChild(this.DOM.holder);
this.DOM.comment.parentNode.removeChild(this.DOM.comment);
delete instances[this.GUID];
delete this.GUID;
};
if(typeof jQuery!=='undefined'){
(function($){
$.ModuloBox=function(options){
return new ModuloBox(options);
};})(jQuery);
}
return ModuloBox;
}));
jQuery(function(){
ParallaxScroll.init();
});
var ParallaxScroll={
showLogs: false,
round: 1000,
init: function(){
this._log("init");
if(this._inited){
this._log("Already Inited");
this._inited=true;
return;
}
this._requestAnimationFrame=(function(){
return  window.requestAnimationFrame       ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame    ||
window.oRequestAnimationFrame      ||
window.msRequestAnimationFrame     ||
function( callback,  element){
window.setTimeout(callback, 1000 / 60);
};})();
this._onScroll(true);
},
_inited: false,
_properties: ['x', 'y', 'z', 'rotateX', 'rotateY', 'rotateZ', 'scaleX', 'scaleY', 'scaleZ', 'scale'],
_requestAnimationFrame:null,
_log: function(message){
if(this.showLogs) console.log("Parallax Scroll / " + message);
},
_onScroll: function(noSmooth){
var scroll=jQuery(document).scrollTop();
var windowHeight=jQuery(window).height();
this._log("onScroll " + scroll);
jQuery("[data-parallax]").each(jQuery.proxy(function(index, el){
var $el=jQuery(el);
var properties=[];
var applyProperties=false;
var style=$el.data("style");
if(style==undefined){
style=$el.attr("style")||"";
$el.data("style", style);
}
var datas=[$el.data("parallax")];
var iData;
for(iData=2; ; iData++){
if($el.data("parallax"+iData)){
datas.push($el.data("parallax-"+iData));
}else{
break;
}}
var datasLength=datas.length;
for(iData=0; iData < datasLength; iData ++){
var data=datas[iData];
var scrollFrom=data["from-scroll"];
if(scrollFrom==undefined) scrollFrom=Math.max(0, jQuery(el).offset().top - windowHeight);
scrollFrom=scrollFrom | 0;
var scrollDistance=data["distance"];
var scrollTo=data["to-scroll"];
if(scrollDistance==undefined&&scrollTo==undefined) scrollDistance=windowHeight;
scrollDistance=Math.max(scrollDistance | 0, 1);
var easing=data["easing"];
var easingReturn=data["easing-return"];
if(easing==undefined||!jQuery.easing||!jQuery.easing[easing]) easing=null;
if(easingReturn==undefined||!jQuery.easing||!jQuery.easing[easingReturn]) easingReturn=easing;
if(easing){
var totalTime=data["duration"];
if(totalTime==undefined) totalTime=scrollDistance;
totalTime=Math.max(totalTime | 0, 1);
var totalTimeReturn=data["duration-return"];
if(totalTimeReturn==undefined) totalTimeReturn=totalTime;
scrollDistance=1;
var currentTime=$el.data("current-time");
if(currentTime==undefined) currentTime=0;
}
if(scrollTo==undefined) scrollTo=scrollFrom + scrollDistance;
scrollTo=scrollTo | 0;
var smoothness=data["smoothness"];
if(smoothness==undefined) smoothness=30;
smoothness=smoothness | 0;
if(noSmooth||smoothness==0) smoothness=1;
smoothness=smoothness | 0;
var scrollCurrent=scroll;
scrollCurrent=Math.max(scrollCurrent, scrollFrom);
scrollCurrent=Math.min(scrollCurrent, scrollTo);
if(easing){
if($el.data("sens")==undefined) $el.data("sens", "back");
if(scrollCurrent>scrollFrom){
if($el.data("sens")=="back"){
currentTime=1;
$el.data("sens", "go");
}else{
currentTime++;
}}
if(scrollCurrent<scrollTo){
if($el.data("sens")=="go"){
currentTime=1;
$el.data("sens", "back");
}else{
currentTime++;
}}
if(noSmooth) currentTime=totalTime;
$el.data("current-time", currentTime);
}
this._properties.map(jQuery.proxy(function(prop){
var defaultProp=0;
var to=data[prop];
if(to==undefined) return;
if(prop=="scale"||prop=="scaleX"||prop=="scaleY"||prop=="scaleZ"){
defaultProp=1;
}else{
to=to | 0;
}
var prev=$el.data("_" + prop);
if(prev==undefined) prev=defaultProp;
var next=((to-defaultProp) * ((scrollCurrent - scrollFrom) / (scrollTo - scrollFrom))) + defaultProp;
var val=prev + (next - prev) / smoothness;
if(easing&&currentTime>0&&currentTime<=totalTime){
var from=defaultProp;
if($el.data("sens")=="back"){
from=to;
to=-to;
easing=easingReturn;
totalTime=totalTimeReturn;
}
val=jQuery.easing[easing](null, currentTime, from, to, totalTime);
}
val=Math.ceil(val * this.round) / this.round;
if(val==prev&&next==to) val=to;
if(!properties[prop]) properties[prop]=0;
properties[prop] +=val;
if(prev!=properties[prop]){
$el.data("_" + prop, properties[prop]);
applyProperties=true;
}}, this));
}
if(applyProperties){
if(properties["z"]!=undefined){
var perspective=data["perspective"];
if(perspective==undefined) perspective=800;
var $parent=$el.parent();
if(!$parent.data("style")) $parent.data("style", $parent.attr("style")||"");
$parent.attr("style", "perspective:" + perspective + "px; -webkit-perspective:" + perspective + "px; "+ $parent.data("style"));
}
if(properties["scaleX"]==undefined) properties["scaleX"]=1;
if(properties["scaleY"]==undefined) properties["scaleY"]=1;
if(properties["scaleZ"]==undefined) properties["scaleZ"]=1;
if(properties["scale"]!=undefined){
properties["scaleX"] *=properties["scale"];
properties["scaleY"] *=properties["scale"];
properties["scaleZ"] *=properties["scale"];
}
var translate3d="translate3d(" + (properties["x"] ? properties["x"]:0) + "px, " + (properties["y"] ? properties["y"]:0) + "px, " + (properties["z"] ? properties["z"]:0) + "px)";
var rotate3d="rotateX(" + (properties["rotateX"] ? properties["rotateX"]:0) + "deg) rotateY(" + (properties["rotateY"] ? properties["rotateY"]:0) + "deg) rotateZ(" + (properties["rotateZ"] ? properties["rotateZ"]:0) + "deg)";
var scale3d="scaleX(" + properties["scaleX"] + ") scaleY(" + properties["scaleY"] + ") scaleZ(" + properties["scaleZ"] + ")";
var cssTransform=translate3d + " " + rotate3d + " " + scale3d + ";";
this._log(cssTransform);
$el.attr("style", "transform:" + cssTransform + " -webkit-transform:" + cssTransform + " " + style);
}}, this));
if(window.requestAnimationFrame){
window.requestAnimationFrame(jQuery.proxy(this._onScroll, this, false));
}else{
this._requestAnimationFrame(jQuery.proxy(this._onScroll, this, false));
}}
};
(function($, window, document){
function crossBrowser(property, value, prefix){
function ucase(string){
return string.charAt(0).toUpperCase() + string.slice(1);
}
var vendor=['webkit', 'moz', 'ms', 'o'],
properties={};
for (var i=0; i < vendor.length; i++){
if(prefix){
value=value.replace(prefix, '-' + vendor[i] + '-' + prefix);
}
properties[ucase(vendor[i]) + ucase(property)]=value;
}
properties[property]=value;
return properties;
}
function smooveIt(direction){
var height=$(window).height(),
width=$(window).width();
for (var i=0; i < $.fn.smoove.items.length; i++){
var $item=$.fn.smoove.items[i],
params=$item.params;
if(!$item.hasClass('smooved')){
var offset=(!direction||direction==='down'&&$item.css('opacity')==='1') ? 0:params.offset,
itemtop=$(window).scrollTop() + height - $item.offset().top;
if(typeof offset==='string'&&offset.indexOf('%')){
offset=parseInt(offset) / 100 * height;
}
if(itemtop < offset||direction=='first'){
if(!isNaN(params.opacity)){
$item.css({
opacity: params.opacity
});
}
var transforms=[],
properties=['move', 'move3D', 'moveX', 'moveY', 'moveZ', 'rotate', 'rotate3d', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scale3d', 'scaleX', 'scaleY', 'skew', 'skewX', 'skewY'];
for (var p=0; p < properties.length; p++){
if(typeof params[properties[p]]!=="undefined"){
transforms[properties[p]]=params[properties[p]];
}}
var transform='';
for (var t in transforms){
transform +=t.replace('move', 'translate') + '(' + transforms[t] + ') ';
}
if(transform){
$item.css(crossBrowser('transform', transform));
$item.parent().css(crossBrowser('perspective', params.perspective));
if(params.transformOrigin){
$item.css(crossBrowser('transformOrigin', params.transformOrigin));
}}
if(typeof params.delay!=="undefined"&&params.delay > 0){
$item.css('transition-delay', parseInt(params.delay)+'ms');
}
$item.addClass('first_smooved');
}else{
if(!$item.hasClass('first_smooved')===true){
$item.css('opacity', 1).css(crossBrowser('transform', 'translate(0px, 0px)')).css('transform', '');
$item.addClass('smooved');
$item.parent().addClass('smooved');
}else{
jQuery('body').addClass('has-smoove');
if(itemtop < offset||jQuery(window).height() >=jQuery(document).height()){
$item.queue(function (next){
jQuery(this).css('opacity', 1).css(crossBrowser('transform', 'translate(0px, 0px)')).css('transform', '');
$item.addClass('smooved');
$item.parent().addClass('smooved');
$item.removeClass('first_smooved');
next();
});
}else{
$item.delay(1000).queue(function (next){
window.scrollTo(window.scrollX, window.scrollY+1);
});
$item.removeClass('first_smooved');
}}
}}
}}
function throttle(fn, threshhold, scope){
threshhold=threshhold||250;
var last, deferTimer;
return function(){
var context=scope||this,
now=+new Date(),
args=arguments;
if(last&&now < last + threshhold){
clearTimeout(deferTimer);
deferTimer=setTimeout(function(){
last=now;
fn.apply(context, args);
}, threshhold);
}else{
last=now;
fn.apply(context, args);
}};}
$.fn.smoove=function(options){
$.fn.smoove.init(this, $.extend({}, $.fn.smoove.defaults, options));
return this;
};
$.fn.smoove.items=[];
$.fn.smoove.loaded=false;
$.fn.smoove.defaults={
offset: '50%',
opacity: 0,
delay: '0ms',
duration: '500ms',
transition: "",
transformStyle: 'preserve-3d',
transformOrigin: false,
perspective: 1000,
min_width: 768,
min_height: false
};
$.fn.smoove.init=function(items, settings){
items.each(function(){
var $item=$(this),
params=$item.params=$.extend({}, settings, $item.data());
$item.data('top', $item.offset().top);
params.transition=crossBrowser('transition', params.transition, 'transform');
$item.css(params.transition);
$.fn.smoove.items.push($item);
});
if(!$.fn.smoove.loaded){
$.fn.smoove.loaded=true;
var oldScroll=0,
oldHeight=$(window).height(),
oldWidth=$(window).width(),
oldDocHeight=$(document).height(),
resizing;
if($('body').width()===$(window).width()){
$('body').addClass('smoove-overflow');
}
/*$(window).on("orientationchange resize", function(){
clearTimeout(resizing);
resizing=setTimeout(function(){
var height=$(window).height(),
width=$(window).width(),
direction=(oldHeight > height) ? direction='up':'down',
items=$.fn.smoove.items;
oldHeight=height;
if(oldWidth!==width){
for (var i=0; i < items.length; i++){
items[i].css(crossBrowser('transform', '')).css(crossBrowser('transition', ''));
}
var stillResizing=setInterval(function(){
var docHeight=$(document).height();
if(docHeight===oldDocHeight){
window.clearInterval(stillResizing);
for (var i=0; i < items.length; i++){
items[i].data('top', items[i].offset().top);
items[i].css(items[i].params.transition);
}
smooveIt(direction);
}
oldDocHeight=docHeight;
}, 500);
}else{
}
oldWidth=width;
}, 500);
});*/
if($('body').hasClass('elementor-editor-active')){
$('iframe#elementor-preview-iframe').ready(function(){
smooveIt('first');
$(window).on('scroll', throttle(function(){
var scrolltop=$(window).scrollTop(),
direction=(scrolltop < oldScroll) ? direction='up':'down';
oldScroll=scrolltop;
smooveIt(direction);
}, 250));
window.scrollTo(window.scrollX, window.scrollY+1);
});
}else{
jQuery(document).ready(function(){
smooveIt('down');
$(window).on('scroll', throttle(function(){
var scrolltop=$(window).scrollTop(),
direction=(scrolltop < oldScroll) ? direction='up':'down';
oldScroll=scrolltop;
smooveIt(direction);
}, 250));
if(jQuery(window).height() >=jQuery(document).height()){
smooveIt('down');
}
var isFirefox=navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
if(isFirefox){
window.scrollTo(window.scrollX, window.scrollY+1);
}
var isTouch=('ontouchstart' in document.documentElement);
if(isTouch){
window.scrollTo(window.scrollX, window.scrollY+1);
}});
}}
};}(jQuery, window, document));
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Parallax=f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
var getOwnPropertySymbols=Object.getOwnPropertySymbols;
var hasOwnProperty=Object.prototype.hasOwnProperty;
var propIsEnumerable=Object.prototype.propertyIsEnumerable;
function toObject(val){
if(val===null||val===undefined){
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative(){
try {
if(!Object.assign){
return false;
}
var test1=new String('abc');
test1[5]='de';
if(Object.getOwnPropertyNames(test1)[0]==='5'){
return false;
}
var test2={};
for (var i=0; i < 10; i++){
test2['_' + String.fromCharCode(i)]=i;
}
var order2=Object.getOwnPropertyNames(test2).map(function (n){
return test2[n];
});
if(order2.join('')!=='0123456789'){
return false;
}
var test3={};
'abcdefghijklmnopqrst'.split('').forEach(function (letter){
test3[letter]=letter;
});
if(Object.keys(Object.assign({}, test3)).join('')!=='abcdefghijklmnopqrst'){
return false;
}
return true;
} catch (err){
return false;
}}
module.exports=shouldUseNative() ? Object.assign:function (target, source){
var from;
var to=toObject(target);
var symbols;
for (var s=1; s < arguments.length; s++){
from=Object(arguments[s]);
for (var key in from){
if(hasOwnProperty.call(from, key)){
to[key]=from[key];
}}
if(getOwnPropertySymbols){
symbols=getOwnPropertySymbols(from);
for (var i=0; i < symbols.length; i++){
if(propIsEnumerable.call(from, symbols[i])){
to[symbols[i]]=from[symbols[i]];
}}
}}
return to;
};},{}],2:[function(require,module,exports){
(function (process){
(function(){
var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;
if((typeof performance!=="undefined"&&performance!==null)&&performance.now){
module.exports=function(){
return performance.now();
};}else if((typeof process!=="undefined"&&process!==null)&&process.hrtime){
module.exports=function(){
return (getNanoSeconds() - nodeLoadTime) / 1e6;
};
hrtime=process.hrtime;
getNanoSeconds=function(){
var hr;
hr=hrtime();
return hr[0] * 1e9 + hr[1];
};
moduleLoadTime=getNanoSeconds();
upTime=process.uptime() * 1e9;
nodeLoadTime=moduleLoadTime - upTime;
}else if(Date.now){
module.exports=function(){
return Date.now() - loadTime;
};
loadTime=Date.now();
}else{
module.exports=function(){
return new Date().getTime() - loadTime;
};
loadTime=new Date().getTime();
}}).call(this);
}).call(this,require('_process'))
},{"_process":3}],3:[function(require,module,exports){
var process=module.exports={};
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout(){
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout (){
throw new Error('clearTimeout has not been defined');
}
(function (){
try {
if(typeof setTimeout==='function'){
cachedSetTimeout=setTimeout;
}else{
cachedSetTimeout=defaultSetTimout;
}} catch (e){
cachedSetTimeout=defaultSetTimout;
}
try {
if(typeof clearTimeout==='function'){
cachedClearTimeout=clearTimeout;
}else{
cachedClearTimeout=defaultClearTimeout;
}} catch (e){
cachedClearTimeout=defaultClearTimeout;
}} ())
function runTimeout(fun){
if(cachedSetTimeout===setTimeout){
return setTimeout(fun, 0);
}
if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout){
cachedSetTimeout=setTimeout;
return setTimeout(fun, 0);
}
try {
return cachedSetTimeout(fun, 0);
} catch(e){
try {
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
return cachedSetTimeout.call(this, fun, 0);
}}
}
function runClearTimeout(marker){
if(cachedClearTimeout===clearTimeout){
return clearTimeout(marker);
}
if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout){
cachedClearTimeout=clearTimeout;
return clearTimeout(marker);
}
try {
return cachedClearTimeout(marker);
} catch (e){
try {
return cachedClearTimeout.call(null, marker);
} catch (e){
return cachedClearTimeout.call(this, marker);
}}
}
var queue=[];
var draining=false;
var currentQueue;
var queueIndex=-1;
function cleanUpNextTick(){
if(!draining||!currentQueue){
return;
}
draining=false;
if(currentQueue.length){
queue=currentQueue.concat(queue);
}else{
queueIndex=-1;
}
if(queue.length){
drainQueue();
}}
function drainQueue(){
if(draining){
return;
}
var timeout=runTimeout(cleanUpNextTick);
draining=true;
var len=queue.length;
while(len){
currentQueue=queue;
queue=[];
while (++queueIndex < len){
if(currentQueue){
currentQueue[queueIndex].run();
}}
queueIndex=-1;
len=queue.length;
}
currentQueue=null;
draining=false;
runClearTimeout(timeout);
}
process.nextTick=function (fun){
var args=new Array(arguments.length - 1);
if(arguments.length > 1){
for (var i=1; i < arguments.length; i++){
args[i - 1]=arguments[i];
}}
queue.push(new Item(fun, args));
if(queue.length===1&&!draining){
runTimeout(drainQueue);
}};
function Item(fun, array){
this.fun=fun;
this.array=array;
}
Item.prototype.run=function (){
this.fun.apply(null, this.array);
};
process.title='browser';
process.browser=true;
process.env={};
process.argv=[];
process.version='';
process.versions={};
function noop(){}
process.on=noop;
process.addListener=noop;
process.once=noop;
process.off=noop;
process.removeListener=noop;
process.removeAllListeners=noop;
process.emit=noop;
process.prependListener=noop;
process.prependOnceListener=noop;
process.listeners=function (name){ return [] }
process.binding=function (name){
throw new Error('process.binding is not supported');
};
process.cwd=function (){ return '/' };
process.chdir=function (dir){
throw new Error('process.chdir is not supported');
};
process.umask=function(){ return 0; };},{}],4:[function(require,module,exports){
(function (global){
var now=require('performance-now')
, root=typeof window==='undefined' ? global:window
, vendors=['moz', 'webkit']
, suffix='AnimationFrame'
, raf=root['request' + suffix]
, caf=root['cancel' + suffix]||root['cancelRequest' + suffix]
for(var i=0; !raf&&i < vendors.length; i++){
raf=root[vendors[i] + 'Request' + suffix]
caf=root[vendors[i] + 'Cancel' + suffix]
|| root[vendors[i] + 'CancelRequest' + suffix]
}
if(!raf||!caf){
var last=0
, id=0
, queue=[]
, frameDuration=1000 / 60
raf=function(callback){
if(queue.length===0){
var _now=now()
, next=Math.max(0, frameDuration - (_now - last))
last=next + _now
setTimeout(function(){
var cp=queue.slice(0)
queue.length=0
for(var i=0; i < cp.length; i++){
if(!cp[i].cancelled){
try{
cp[i].callback(last)
} catch(e){
setTimeout(function(){ throw e }, 0)
}}
}}, Math.round(next))
}
queue.push({
handle: ++id,
callback: callback,
cancelled: false
})
return id
}
caf=function(handle){
for(var i=0; i < queue.length; i++){
if(queue[i].handle===handle){
queue[i].cancelled=true
}}
}}
module.exports=function(fn){
return raf.call(root, fn)
}
module.exports.cancel=function(){
caf.apply(root, arguments)
}
module.exports.polyfill=function(){
root.requestAnimationFrame=raf
root.cancelAnimationFrame=caf
}}).call(this,typeof global!=="undefined" ? global:typeof self!=="undefined" ? self:typeof window!=="undefined" ? window:{})
},{"performance-now":2}],5:[function(require,module,exports){
'use strict';
var _createClass=function (){ function defineProperties(target, props){ for (var i=0; i < props.length; i++){ var descriptor=props[i]; descriptor.enumerable=descriptor.enumerable||false; descriptor.configurable=true; if("value" in descriptor) descriptor.writable=true; Object.defineProperty(target, descriptor.key, descriptor); }} return function (Constructor, protoProps, staticProps){ if(protoProps) defineProperties(Constructor.prototype, protoProps); if(staticProps) defineProperties(Constructor, staticProps); return Constructor; };}();
function _classCallCheck(instance, Constructor){ if(!(instance instanceof Constructor)){ throw new TypeError("Cannot call a class as a function"); }}
var rqAnFr=require('raf');
var objectAssign=require('object-assign');
var helpers={
propertyCache: {},
vendors: [null, ['-webkit-', 'webkit'], ['-moz-', 'Moz'], ['-o-', 'O'], ['-ms-', 'ms']],
clamp: function clamp(value, min, max){
return min < max ? value < min ? min:value > max ? max:value:value < max ? max:value > min ? min:value;
},
data: function data(element, name){
return helpers.deserialize(element.getAttribute('data-' + name));
},
deserialize: function deserialize(value){
if(value==='true'){
return true;
}else if(value==='false'){
return false;
}else if(value==='null'){
return null;
}else if(!isNaN(parseFloat(value))&&isFinite(value)){
return parseFloat(value);
}else{
return value;
}},
camelCase: function camelCase(value){
return value.replace(/-+(.)?/g, function (match, character){
return character ? character.toUpperCase():'';
});
},
accelerate: function accelerate(element){
helpers.css(element, 'transform', 'translate3d(0,0,0) rotate(0.0001deg)');
helpers.css(element, 'transform-style', 'preserve-3d');
helpers.css(element, 'backface-visibility', 'hidden');
},
transformSupport: function transformSupport(value){
var element=document.createElement('div'),
propertySupport=false,
propertyValue=null,
featureSupport=false,
cssProperty=null,
jsProperty=null;
for (var i=0, l=helpers.vendors.length; i < l; i++){
if(helpers.vendors[i]!==null){
cssProperty=helpers.vendors[i][0] + 'transform';
jsProperty=helpers.vendors[i][1] + 'Transform';
}else{
cssProperty='transform';
jsProperty='transform';
}
if(element.style[jsProperty]!==undefined){
propertySupport=true;
break;
}}
switch (value){
case '2D':
featureSupport=propertySupport;
break;
case '3D':
if(propertySupport){
var body=document.body||document.createElement('body'),
documentElement=document.documentElement,
documentOverflow=documentElement.style.overflow,
isCreatedBody=false;
if(!document.body){
isCreatedBody=true;
documentElement.style.overflow='hidden';
documentElement.appendChild(body);
body.style.overflow='hidden';
body.style.background='';
}
body.appendChild(element);
element.style[jsProperty]='translate3d(1px,1px,1px)';
propertyValue=window.getComputedStyle(element).getPropertyValue(cssProperty);
featureSupport=propertyValue!==undefined&&propertyValue.length > 0&&propertyValue!=='none';
documentElement.style.overflow=documentOverflow;
body.removeChild(element);
if(isCreatedBody){
body.removeAttribute('style');
body.parentNode.removeChild(body);
}}
break;
}
return featureSupport;
},
css: function css(element, property, value){
var jsProperty=helpers.propertyCache[property];
if(!jsProperty){
for (var i=0, l=helpers.vendors.length; i < l; i++){
if(helpers.vendors[i]!==null){
jsProperty=helpers.camelCase(helpers.vendors[i][1] + '-' + property);
}else{
jsProperty=property;
}
if(element.style[jsProperty]!==undefined){
helpers.propertyCache[property]=jsProperty;
break;
}}
}
element.style[jsProperty]=value;
}};
var MAGIC_NUMBER=30,
DEFAULTS={
relativeInput: false,
clipRelativeInput: false,
inputElement: null,
hoverOnly: false,
calibrationThreshold: 100,
calibrationDelay: 500,
supportDelay: 500,
calibrateX: false,
calibrateY: true,
invertX: true,
invertY: true,
limitX: false,
limitY: false,
scalarX: 10.0,
scalarY: 10.0,
frictionX: 0.1,
frictionY: 0.1,
originX: 0.5,
originY: 0.5,
pointerEvents: false,
precision: 1,
onReady: null,
selector: null
};
var Parallax=function (){
function Parallax(element, options){
_classCallCheck(this, Parallax);
this.element=element;
var data={
calibrateX: helpers.data(this.element, 'calibrate-x'),
calibrateY: helpers.data(this.element, 'calibrate-y'),
invertX: helpers.data(this.element, 'invert-x'),
invertY: helpers.data(this.element, 'invert-y'),
limitX: helpers.data(this.element, 'limit-x'),
limitY: helpers.data(this.element, 'limit-y'),
scalarX: helpers.data(this.element, 'scalar-x'),
scalarY: helpers.data(this.element, 'scalar-y'),
frictionX: helpers.data(this.element, 'friction-x'),
frictionY: helpers.data(this.element, 'friction-y'),
originX: helpers.data(this.element, 'origin-x'),
originY: helpers.data(this.element, 'origin-y'),
pointerEvents: helpers.data(this.element, 'pointer-events'),
precision: helpers.data(this.element, 'precision'),
relativeInput: helpers.data(this.element, 'relative-input'),
clipRelativeInput: helpers.data(this.element, 'clip-relative-input'),
hoverOnly: helpers.data(this.element, 'hover-only'),
inputElement: document.querySelector(helpers.data(this.element, 'input-element')),
selector: helpers.data(this.element, 'selector')
};
for (var key in data){
if(data[key]===null){
delete data[key];
}}
objectAssign(this, DEFAULTS, data, options);
if(!this.inputElement){
this.inputElement=this.element;
}
this.calibrationTimer=null;
this.calibrationFlag=true;
this.enabled=false;
this.depthsX=[];
this.depthsY=[];
this.raf=null;
this.bounds=null;
this.elementPositionX=0;
this.elementPositionY=0;
this.elementWidth=0;
this.elementHeight=0;
this.elementCenterX=0;
this.elementCenterY=0;
this.elementRangeX=0;
this.elementRangeY=0;
this.calibrationX=0;
this.calibrationY=0;
this.inputX=0;
this.inputY=0;
this.motionX=0;
this.motionY=0;
this.velocityX=0;
this.velocityY=0;
this.onMouseMove=this.onMouseMove.bind(this);
this.onDeviceOrientation=this.onDeviceOrientation.bind(this);
this.onDeviceMotion=this.onDeviceMotion.bind(this);
this.onOrientationTimer=this.onOrientationTimer.bind(this);
this.onMotionTimer=this.onMotionTimer.bind(this);
this.onCalibrationTimer=this.onCalibrationTimer.bind(this);
this.onAnimationFrame=this.onAnimationFrame.bind(this);
this.onWindowResize=this.onWindowResize.bind(this);
this.windowWidth=null;
this.windowHeight=null;
this.windowCenterX=null;
this.windowCenterY=null;
this.windowRadiusX=null;
this.windowRadiusY=null;
this.portrait=false;
this.desktop = !navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|mobi|tablet|opera mini|nexus 7)/i);
this.motionSupport = !!window.DeviceMotionEvent&&!this.desktop;
this.orientationSupport = !!window.DeviceOrientationEvent&&!this.desktop;
this.orientationStatus=0;
this.motionStatus=0;
this.initialise();
}
_createClass(Parallax, [{
key: 'initialise',
value: function initialise(){
if(this.transform2DSupport===undefined){
this.transform2DSupport=helpers.transformSupport('2D');
this.transform3DSupport=helpers.transformSupport('3D');
}
if(this.transform3DSupport){
helpers.accelerate(this.element);
}
var style=window.getComputedStyle(this.element);
if(style.getPropertyValue('position')==='static'){
this.element.style.position='relative';
}
if(!this.pointerEvents){
this.element.style.pointerEvents='none';
}
this.updateLayers();
this.updateDimensions();
this.enable();
this.queueCalibration(this.calibrationDelay);
}}, {
key: 'doReadyCallback',
value: function doReadyCallback(){
if(this.onReady){
this.onReady();
}}
}, {
key: 'updateLayers',
value: function updateLayers(){
if(this.selector){
this.layers=this.element.querySelectorAll(this.selector);
}else{
this.layers=this.element.children;
}
if(!this.layers.length){
console.warn('ParallaxJS: Your scene does not have any layers.');
}
this.depthsX=[];
this.depthsY=[];
for (var index=0; index < this.layers.length; index++){
var layer=this.layers[index];
if(this.transform3DSupport){
helpers.accelerate(layer);
}
layer.style.position=index ? 'absolute':'relative';
layer.style.display='block';
layer.style.left=0;
layer.style.top=0;
var depth=helpers.data(layer, 'depth')||0;
this.depthsX.push(helpers.data(layer, 'depth-x')||depth);
this.depthsY.push(helpers.data(layer, 'depth-y')||depth);
}}
}, {
key: 'updateDimensions',
value: function updateDimensions(){
this.windowWidth=window.innerWidth;
this.windowHeight=window.innerHeight;
this.windowCenterX=this.windowWidth * this.originX;
this.windowCenterY=this.windowHeight * this.originY;
this.windowRadiusX=Math.max(this.windowCenterX, this.windowWidth - this.windowCenterX);
this.windowRadiusY=Math.max(this.windowCenterY, this.windowHeight - this.windowCenterY);
}}, {
key: 'updateBounds',
value: function updateBounds(){
this.bounds=this.inputElement.getBoundingClientRect();
this.elementPositionX=this.bounds.left;
this.elementPositionY=this.bounds.top;
this.elementWidth=this.bounds.width;
this.elementHeight=this.bounds.height;
this.elementCenterX=this.elementWidth * this.originX;
this.elementCenterY=this.elementHeight * this.originY;
this.elementRangeX=Math.max(this.elementCenterX, this.elementWidth - this.elementCenterX);
this.elementRangeY=Math.max(this.elementCenterY, this.elementHeight - this.elementCenterY);
}}, {
key: 'queueCalibration',
value: function queueCalibration(delay){
clearTimeout(this.calibrationTimer);
this.calibrationTimer=setTimeout(this.onCalibrationTimer, delay);
}}, {
key: 'enable',
value: function enable(){
if(this.enabled){
return;
}
this.enabled=true;
if(this.orientationSupport){
this.portrait=false;
window.addEventListener('deviceorientation', this.onDeviceOrientation);
this.detectionTimer=setTimeout(this.onOrientationTimer, this.supportDelay);
}else if(this.motionSupport){
this.portrait=false;
window.addEventListener('devicemotion', this.onDeviceMotion);
this.detectionTimer=setTimeout(this.onMotionTimer, this.supportDelay);
}else{
this.calibrationX=0;
this.calibrationY=0;
this.portrait=false;
window.addEventListener('mousemove', this.onMouseMove);
this.doReadyCallback();
}
window.addEventListener('resize', this.onWindowResize);
this.raf=rqAnFr(this.onAnimationFrame);
}}, {
key: 'disable',
value: function disable(){
if(!this.enabled){
return;
}
this.enabled=false;
if(this.orientationSupport){
window.removeEventListener('deviceorientation', this.onDeviceOrientation);
}else if(this.motionSupport){
window.removeEventListener('devicemotion', this.onDeviceMotion);
}else{
window.removeEventListener('mousemove', this.onMouseMove);
}
window.removeEventListener('resize', this.onWindowResize);
rqAnFr.cancel(this.raf);
}}, {
key: 'calibrate',
value: function calibrate(x, y){
this.calibrateX=x===undefined ? this.calibrateX:x;
this.calibrateY=y===undefined ? this.calibrateY:y;
}}, {
key: 'invert',
value: function invert(x, y){
this.invertX=x===undefined ? this.invertX:x;
this.invertY=y===undefined ? this.invertY:y;
}}, {
key: 'friction',
value: function friction(x, y){
this.frictionX=x===undefined ? this.frictionX:x;
this.frictionY=y===undefined ? this.frictionY:y;
}}, {
key: 'scalar',
value: function scalar(x, y){
this.scalarX=x===undefined ? this.scalarX:x;
this.scalarY=y===undefined ? this.scalarY:y;
}}, {
key: 'limit',
value: function limit(x, y){
this.limitX=x===undefined ? this.limitX:x;
this.limitY=y===undefined ? this.limitY:y;
}}, {
key: 'origin',
value: function origin(x, y){
this.originX=x===undefined ? this.originX:x;
this.originY=y===undefined ? this.originY:y;
}}, {
key: 'setInputElement',
value: function setInputElement(element){
this.inputElement=element;
this.updateDimensions();
}}, {
key: 'setPosition',
value: function setPosition(element, x, y){
x=x.toFixed(this.precision) + 'px';
y=y.toFixed(this.precision) + 'px';
if(this.transform3DSupport){
helpers.css(element, 'transform', 'translate3d(' + x + ',' + y + ',0)');
}else if(this.transform2DSupport){
helpers.css(element, 'transform', 'translate(' + x + ',' + y + ')');
}else{
element.style.left=x;
element.style.top=y;
}}
}, {
key: 'onOrientationTimer',
value: function onOrientationTimer(){
if(this.orientationSupport&&this.orientationStatus===0){
this.disable();
this.orientationSupport=false;
this.enable();
}else{
this.doReadyCallback();
}}
}, {
key: 'onMotionTimer',
value: function onMotionTimer(){
if(this.motionSupport&&this.motionStatus===0){
this.disable();
this.motionSupport=false;
this.enable();
}else{
this.doReadyCallback();
}}
}, {
key: 'onCalibrationTimer',
value: function onCalibrationTimer(){
this.calibrationFlag=true;
}}, {
key: 'onWindowResize',
value: function onWindowResize(){
this.updateDimensions();
}}, {
key: 'onAnimationFrame',
value: function onAnimationFrame(){
this.updateBounds();
var calibratedInputX=this.inputX - this.calibrationX,
calibratedInputY=this.inputY - this.calibrationY;
if(Math.abs(calibratedInputX) > this.calibrationThreshold||Math.abs(calibratedInputY) > this.calibrationThreshold){
this.queueCalibration(0);
}
if(this.portrait){
this.motionX=this.calibrateX ? calibratedInputY:this.inputY;
this.motionY=this.calibrateY ? calibratedInputX:this.inputX;
}else{
this.motionX=this.calibrateX ? calibratedInputX:this.inputX;
this.motionY=this.calibrateY ? calibratedInputY:this.inputY;
}
this.motionX *=this.elementWidth * (this.scalarX / 100);
this.motionY *=this.elementHeight * (this.scalarY / 100);
if(!isNaN(parseFloat(this.limitX))){
this.motionX=helpers.clamp(this.motionX, -this.limitX, this.limitX);
}
if(!isNaN(parseFloat(this.limitY))){
this.motionY=helpers.clamp(this.motionY, -this.limitY, this.limitY);
}
this.velocityX +=(this.motionX - this.velocityX) * this.frictionX;
this.velocityY +=(this.motionY - this.velocityY) * this.frictionY;
for (var index=0; index < this.layers.length; index++){
var layer=this.layers[index],
depthX=this.depthsX[index],
depthY=this.depthsY[index],
xOffset=this.velocityX * (depthX * (this.invertX ? -1:1)),
yOffset=this.velocityY * (depthY * (this.invertY ? -1:1));
this.setPosition(layer, xOffset, yOffset);
}
this.raf=rqAnFr(this.onAnimationFrame);
}}, {
key: 'rotate',
value: function rotate(beta, gamma){
var x=(beta||0) / MAGIC_NUMBER,
y=(gamma||0) / MAGIC_NUMBER;
var portrait=this.windowHeight > this.windowWidth;
if(this.portrait!==portrait){
this.portrait=portrait;
this.calibrationFlag=true;
}
if(this.calibrationFlag){
this.calibrationFlag=false;
this.calibrationX=x;
this.calibrationY=y;
}
this.inputX=x;
this.inputY=y;
}}, {
key: 'onDeviceOrientation',
value: function onDeviceOrientation(event){
var beta=event.beta;
var gamma=event.gamma;
if(beta!==null&&gamma!==null){
this.orientationStatus=1;
this.rotate(beta, gamma);
}}
}, {
key: 'onDeviceMotion',
value: function onDeviceMotion(event){
var beta=event.rotationRate.beta;
var gamma=event.rotationRate.gamma;
if(beta!==null&&gamma!==null){
this.motionStatus=1;
this.rotate(beta, gamma);
}}
}, {
key: 'onMouseMove',
value: function onMouseMove(event){
var clientX=event.clientX,
clientY=event.clientY;
if(this.hoverOnly&&(clientX < this.elementPositionX||clientX > this.elementPositionX + this.elementWidth||clientY < this.elementPositionY||clientY > this.elementPositionY + this.elementHeight)){
this.inputX=0;
this.inputY=0;
return;
}
if(this.relativeInput){
if(this.clipRelativeInput){
clientX=Math.max(clientX, this.elementPositionX);
clientX=Math.min(clientX, this.elementPositionX + this.elementWidth);
clientY=Math.max(clientY, this.elementPositionY);
clientY=Math.min(clientY, this.elementPositionY + this.elementHeight);
}
if(this.elementRangeX&&this.elementRangeY){
this.inputX=(clientX - this.elementPositionX - this.elementCenterX) / this.elementRangeX;
this.inputY=(clientY - this.elementPositionY - this.elementCenterY) / this.elementRangeY;
}}else{
if(this.windowRadiusX&&this.windowRadiusY){
this.inputX=(clientX - this.windowCenterX) / this.windowRadiusX;
this.inputY=(clientY - this.windowCenterY) / this.windowRadiusY;
}}
}}, {
key: 'destroy',
value: function destroy(){
this.disable();
clearTimeout(this.calibrationTimer);
clearTimeout(this.detectionTimer);
this.element.removeAttribute('style');
for (var index=0; index < this.layers.length; index++){
this.layers[index].removeAttribute('style');
}
delete this.element;
delete this.layers;
}}, {
key: 'version',
value: function version(){
return '3.1.0';
}}]);
return Parallax;
}();
module.exports=Parallax;
},{"object-assign":1,"raf":4}]},{},[5])(5)
});
;(function ($, window, document, undefined){
var IE=(function (){
if(document.documentMode){
return document.documentMode;
}else{
for (var i=7; i > 0; i--){
var div=document.createElement("div");
div.innerHTML="<!--[if IE " + i + "]><span></span><![endif]-->";
if(div.getElementsByTagName("span").length){
div=null;
return i;
}
div=null;
}}
return undefined;
})();
var console=window.console||{ log: function (){}, time: function (){}};
var NAME="blast",
characterRanges={
latinPunctuation: "–—′’'“″„\"(«.…¡¿′’'”″“\")».…!?",
latinLetters: "\\u0041-\\u005A\\u0061-\\u007A\\u00C0-\\u017F\\u0100-\\u01FF\\u0180-\\u027F"
},
Reg={
abbreviations: new RegExp("[^" + characterRanges.latinLetters + "](e\\.g\\.)|(i\\.e\\.)|(mr\\.)|(mrs\\.)|(ms\\.)|(dr\\.)|(prof\\.)|(esq\\.)|(sr\\.)|(jr\\.)[^" + characterRanges.latinLetters + "]", "ig"),
innerWordPeriod: new RegExp("[" + characterRanges.latinLetters + "]\.[" + characterRanges.latinLetters + "]", "ig"),
onlyContainsPunctuation: new RegExp("[^" + characterRanges.latinPunctuation + "]"),
adjoinedPunctuation: new RegExp("^[" + characterRanges.latinPunctuation + "]+|[" + characterRanges.latinPunctuation + "]+$", "g"),
skippedElements: /(script|style|select|textarea)/i,
hasPluginClass: new RegExp("(^|)" + NAME + "(|$)", "gi")
};
$.fn[NAME]=function (options){
function encodePunctuation (text){
return text
.replace(Reg.abbreviations, function(match){
return match.replace(/\./g, "{{46}}");
})
.replace(Reg.innerWordPeriod, function(match){
return match.replace(/\./g, "{{46}}");
});
}
function decodePunctuation (text){
return text.replace(/{{(\d{1,3})}}/g, function(fullMatch, subMatch){
return String.fromCharCode(subMatch);
});
}
function wrapNode (node, opts){
var wrapper=document.createElement(opts.tag);
wrapper.className=NAME;
if(opts.customClass){
wrapper.className +=" " + opts.customClass;
if(opts.generateIndexID){
wrapper.id=opts.customClass + "-" + Element.blastedIndex;
}}
if(opts.delimiter==="all"&&/\s/.test(node.data)){
wrapper.style.whiteSpace="pre-line";
}
if(opts.generateValueClass===true&&!opts.search&&(opts.delimiter==="character"||opts.delimiter==="word")){
var valueClass,
text=node.data;
if(opts.delimiter==="word"&&Reg.onlyContainsPunctuation.test(text)){
text=text.replace(Reg.adjoinedPunctuation, "");
}
valueClass=NAME + "-" + opts.delimiter.toLowerCase() + "-" + text.toLowerCase();
wrapper.className +=" " + valueClass;
}
if(opts.aria){
wrapper.setAttribute("aria-hidden", "true");
}
wrapper.appendChild(node.cloneNode(false));
return wrapper;
}
function traverseDOM (node, opts){
var matchPosition=-1,
skipNodeBit=0;
if(node.nodeType===3&&node.data.length){
if(Element.nodeBeginning){
node.data=(!opts.search&&opts.delimiter==="sentence") ? encodePunctuation(node.data):decodePunctuation(node.data);
Element.nodeBeginning=false;
}
matchPosition=node.data.search(delimiterRegex);
if(matchPosition!==-1){
var match=node.data.match(delimiterRegex),
matchText=match[0],
subMatchText=match[1]||false;
if(matchText===""){
matchPosition++;
}else if(subMatchText&&subMatchText!==matchText){
matchPosition +=matchText.indexOf(subMatchText);
matchText=subMatchText;
}
var middleBit=node.splitText(matchPosition);
middleBit.splitText(matchText.length);
skipNodeBit=1;
if(!opts.search&&opts.delimiter==="sentence"){
middleBit.data=decodePunctuation(middleBit.data);
}
var wrappedNode=wrapNode(middleBit, opts, Element.blastedIndex);
middleBit.parentNode.replaceChild(wrappedNode, middleBit);
Element.wrappers.push(wrappedNode);
Element.blastedIndex++;
}
}else if(node.nodeType===1&&node.hasChildNodes()&&!Reg.skippedElements.test(node.tagName)&&!Reg.hasPluginClass.test(node.className)){
for (var i=0; i < node.childNodes.length; i++){
Element.nodeBeginning=true;
i +=traverseDOM(node.childNodes[i], opts);
}}
return skipNodeBit;
}
var opts=$.extend({}, $.fn[NAME].defaults, options),
delimiterRegex,
Element={};
if(opts.search.length&&(typeof opts.search==="string"||/^\d/.test(parseFloat(opts.search)))){
opts.delimiter=opts.search.toString().replace(/[-[\]{,}(.)*+?|^$\\\/]/g, "\\$&");
delimiterRegex=new RegExp("(?:^|[^-" + characterRanges.latinLetters + "])(" + opts.delimiter + "('s)?)(?![-" + characterRanges.latinLetters + "])", "i");
}else{
if(typeof opts.delimiter==="string"){
opts.delimiter=opts.delimiter.toLowerCase();
}
switch (opts.delimiter){
case "all":
delimiterRegex=/(.)/;
break;
case "letter":
case "char":
case "character":
delimiterRegex=/(\S)/;
break;
case "word":
delimiterRegex=/\s*(\S+)\s*/;
break;
case "sentence":
delimiterRegex=/(?=\S)(([.]{2,})?[^!?]+?([.…!?]+|(?=\s+$)|$)(\s*[′’'”″“")»]+)*)/;
break;
case "element":
delimiterRegex=/(?=\S)([\S\s]*\S)/;
break;
default:
if(opts.delimiter instanceof RegExp){
delimiterRegex=opts.delimiter;
}else{
console.log(NAME + ": Unrecognized delimiter, empty search string, or invalid custom Regex. Aborting.");
return true;
}}
}
this.each(function(){
var $this=$(this),
text=$this.text();
if(options!==false){
Element={
blastedIndex: 0,
nodeBeginning: false,
wrappers: Element.wrappers||[]
};
if($this.data(NAME)!==undefined&&($this.data(NAME)!=="search"||opts.search===false)){
reverse($this, opts);
if(opts.debug) console.log(NAME + ": Removed element's existing Blast call.");
}
$this.data(NAME, opts.search!==false ? "search":opts.delimiter);
if(opts.aria){
$this.attr("aria-label", text);
}
if(opts.stripHTMLTags){
$this.html(text);
}
try {
document.createElement(opts.tag);
} catch (error){
opts.tag="span";
if(opts.debug) console.log(NAME + ": Invalid tag supplied. Defaulting to span.");
}
$this.addClass(NAME + "-root");
if(opts.debug) console.time(NAME);
traverseDOM(this, opts);
if(opts.debug) console.timeEnd(NAME);
}else if(options===false&&$this.data(NAME)!==undefined){
reverse($this, opts);
}
if(opts.debug){
$.each(Element.wrappers, function(index, element){
console.log(NAME + " [" + opts.delimiter + "] " + this.outerHTML);
this.style.backgroundColor=index % 2 ? "#f12185":"#075d9a";
});
}});
function reverse ($this, opts){
if(opts.debug) console.time("blast reversal");
var skippedDescendantRoot=false;
$this
.removeClass(NAME + "-root")
.removeAttr("aria-label")
.find("." + NAME)
.each(function (){
var $this=$(this);
if(!$this.closest("." + NAME + "-root").length){
var thisParentNode=this.parentNode;
if(IE <=7) (thisParentNode.firstChild.nodeName);
thisParentNode.replaceChild(this.firstChild, this);
thisParentNode.normalize();
}else{
skippedDescendantRoot=true;
}});
if(window.Zepto){
$this.data(NAME, undefined);
}else{
$this.removeData(NAME);
}
if(opts.debug){
console.log(NAME + ": Reversed Blast" + ($this.attr("id") ? " on #" + $this.attr("id") + ".":".") + (skippedDescendantRoot ? " Skipped reversal on the children of one or more descendant root elements.":""));
console.timeEnd("blast reversal");
}}
if(options!==false&&opts.returnGenerated===true){
var newStack=$().add(Element.wrappers);
newStack.prevObject=this;
newStack.context=this.context;
return newStack;
}else{
return this;
}};
$.fn.blast.defaults={
returnGenerated: true,
delimiter: "word",
tag: "span",
search: false,
customClass: "",
generateIndexID: false,
generateValueClass: false,
stripHTMLTags: false,
aria: true,
debug: false
};})(window.jQuery||window.Zepto, window, document);
(function(modules){
var installedModules={};
function __webpack_require__(moduleId){
if(installedModules[moduleId]){
return installedModules[moduleId].exports;
}
var module=installedModules[moduleId]={
i: moduleId,
l: false,
exports: {}
};
modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
module.l=true;
return module.exports;
}
__webpack_require__.m=modules;
__webpack_require__.c=installedModules;
__webpack_require__.d=function(exports, name, getter){
if(!__webpack_require__.o(exports, name)){
Object.defineProperty(exports, name, { enumerable: true, get: getter });
}
};
__webpack_require__.r=function(exports){
if(typeof Symbol!=='undefined'&&Symbol.toStringTag){
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
__webpack_require__.t=function(value, mode){
if(mode & 1) value=__webpack_require__(value);
if(mode & 8) return value;
if((mode & 4)&&typeof value==='object'&&value&&value.__esModule) return value;
var ns=Object.create(null);
__webpack_require__.r(ns);
Object.defineProperty(ns, 'default', { enumerable: true, value: value });
if(mode & 2&&typeof value!='string') for(var key in value) __webpack_require__.d(ns, key, function(key){ return value[key]; }.bind(null, key));
return ns;
};
__webpack_require__.n=function(module){
var getter=module&&module.__esModule ?
function getDefault(){ return module['default']; } :
function getModuleExports(){ return module; };
__webpack_require__.d(getter, 'a', getter);
return getter;
};
__webpack_require__.o=function(object, property){ return Object.prototype.hasOwnProperty.call(object, property); };
__webpack_require__.p="";
return __webpack_require__(__webpack_require__.s=10);
})
([
,
,
(function(module, exports){
module.exports=function (callback){
if(document.readyState==='complete'||document.readyState==='interactive'){
callback.call();
}else if(document.attachEvent){
document.attachEvent('onreadystatechange', function (){
if(document.readyState==='interactive') callback.call();
});
}else if(document.addEventListener){
document.addEventListener('DOMContentLoaded', callback);
}};
}),
(function(module, exports, __webpack_require__){
(function(global){var win;
if(typeof window!=="undefined"){
win=window;
}else if(typeof global!=="undefined"){
win=global;
}else if(typeof self!=="undefined"){
win=self;
}else{
win={};}
module.exports=win;
}.call(this, __webpack_require__(4)))
}),
(function(module, exports){
function _typeof(obj){ "@babel/helpers - typeof"; if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){ _typeof=function _typeof(obj){ return typeof obj; };}else{ _typeof=function _typeof(obj){ return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype ? "symbol":typeof obj; };} return _typeof(obj); }
var g;
g=function (){
return this;
}();
try {
g=g||new Function("return this")();
} catch (e){
if((typeof window==="undefined" ? "undefined":_typeof(window))==="object") g=window;
}
module.exports=g;
}),
,
,
,
,
,
(function(module, exports, __webpack_require__){
module.exports=__webpack_require__(11);
}),
(function(module, __webpack_exports__, __webpack_require__){
"use strict";
__webpack_require__.r(__webpack_exports__);
var lite_ready__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(2);
var lite_ready__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(lite_ready__WEBPACK_IMPORTED_MODULE_0__);
var global__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(3);
var global__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(global__WEBPACK_IMPORTED_MODULE_1__);
var _jarallax_esm__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(12);
function _typeof(obj){ "@babel/helpers - typeof"; if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){ _typeof=function _typeof(obj){ return typeof obj; };}else{ _typeof=function _typeof(obj){ return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype ? "symbol":typeof obj; };} return _typeof(obj); }
var oldPlugin=global__WEBPACK_IMPORTED_MODULE_1__["window"].jarallax;
global__WEBPACK_IMPORTED_MODULE_1__["window"].jarallax=_jarallax_esm__WEBPACK_IMPORTED_MODULE_2__["default"];
global__WEBPACK_IMPORTED_MODULE_1__["window"].jarallax.noConflict=function (){
global__WEBPACK_IMPORTED_MODULE_1__["window"].jarallax=oldPlugin;
return this;
};
if('undefined'!==typeof global__WEBPACK_IMPORTED_MODULE_1__["jQuery"]){
var jQueryPlugin=function jQueryPlugin(){
for (var _len=arguments.length, args=new Array(_len), _key=0; _key < _len; _key++){
args[_key]=arguments[_key];
}
Array.prototype.unshift.call(args, this);
var res=_jarallax_esm__WEBPACK_IMPORTED_MODULE_2__["default"].apply(global__WEBPACK_IMPORTED_MODULE_1__["window"], args);
return 'object'!==_typeof(res) ? res:this;
};
jQueryPlugin.constructor=_jarallax_esm__WEBPACK_IMPORTED_MODULE_2__["default"].constructor;
var oldJqPlugin=global__WEBPACK_IMPORTED_MODULE_1__["jQuery"].fn.jarallax;
global__WEBPACK_IMPORTED_MODULE_1__["jQuery"].fn.jarallax=jQueryPlugin;
global__WEBPACK_IMPORTED_MODULE_1__["jQuery"].fn.jarallax.noConflict=function (){
global__WEBPACK_IMPORTED_MODULE_1__["jQuery"].fn.jarallax=oldJqPlugin;
return this;
};}
lite_ready__WEBPACK_IMPORTED_MODULE_0___default()(function (){
Object(_jarallax_esm__WEBPACK_IMPORTED_MODULE_2__["default"])(document.querySelectorAll('[data-jarallax]'));
});
}),
(function(module, __webpack_exports__, __webpack_require__){
"use strict";
__webpack_require__.r(__webpack_exports__);
var lite_ready__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(2);
var lite_ready__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(lite_ready__WEBPACK_IMPORTED_MODULE_0__);
var global__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(3);
var global__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(global__WEBPACK_IMPORTED_MODULE_1__);
function _slicedToArray(arr, i){ return _arrayWithHoles(arr)||_iterableToArrayLimit(arr, i)||_unsupportedIterableToArray(arr, i)||_nonIterableRest(); }
function _nonIterableRest(){ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen){ if(!o) return; if(typeof o==="string") return _arrayLikeToArray(o, minLen); var n=Object.prototype.toString.call(o).slice(8, -1); if(n==="Object"&&o.constructor) n=o.constructor.name; if(n==="Map"||n==="Set") return Array.from(o); if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len){ if(len==null||len > arr.length) len=arr.length; for (var i=0, arr2=new Array(len); i < len; i++){ arr2[i]=arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i){ if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(arr))) return; var _arr=[]; var _n=true; var _d=false; var _e=undefined; try { for (var _i=arr[Symbol.iterator](), _s; !(_n=(_s=_i.next()).done); _n=true){ _arr.push(_s.value); if(i&&_arr.length===i) break; }} catch (err){ _d=true; _e=err; } finally { try { if(!_n&&_i["return"]!=null) _i["return"](); } finally { if(_d) throw _e; }} return _arr; }
function _arrayWithHoles(arr){ if(Array.isArray(arr)) return arr; }
function _typeof(obj){ "@babel/helpers - typeof"; if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){ _typeof=function _typeof(obj){ return typeof obj; };}else{ _typeof=function _typeof(obj){ return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype ? "symbol":typeof obj; };} return _typeof(obj); }
function _classCallCheck(instance, Constructor){ if(!(instance instanceof Constructor)){ throw new TypeError("Cannot call a class as a function"); }}
function _defineProperties(target, props){ for (var i=0; i < props.length; i++){ var descriptor=props[i]; descriptor.enumerable=descriptor.enumerable||false; descriptor.configurable=true; if("value" in descriptor) descriptor.writable=true; Object.defineProperty(target, descriptor.key, descriptor); }}
function _createClass(Constructor, protoProps, staticProps){ if(protoProps) _defineProperties(Constructor.prototype, protoProps); if(staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var navigator=global__WEBPACK_IMPORTED_MODULE_1__["window"].navigator;
var isIE=-1 < navigator.userAgent.indexOf('MSIE ')||-1 < navigator.userAgent.indexOf('Trident/')||-1 < navigator.userAgent.indexOf('Edge/');
var isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
var supportTransform=function (){
var prefixes='transform WebkitTransform MozTransform'.split(' ');
var div=document.createElement('div');
for (var i=0; i < prefixes.length; i +=1){
if(div&&div.style[prefixes[i]]!==undefined){
return prefixes[i];
}}
return false;
}();
var $deviceHelper;
function getDeviceHeight(){
if(!$deviceHelper&&document.body){
$deviceHelper=document.createElement('div');
$deviceHelper.style.cssText='position: fixed; top: -9999px; left: 0; height: 100vh; width: 0;';
document.body.appendChild($deviceHelper);
}
return ($deviceHelper ? $deviceHelper.clientHeight:0)||global__WEBPACK_IMPORTED_MODULE_1__["window"].innerHeight||document.documentElement.clientHeight;
}
var wndH;
function updateWndVars(){
if(isMobile){
wndH=getDeviceHeight();
}else{
wndH=global__WEBPACK_IMPORTED_MODULE_1__["window"].innerHeight||document.documentElement.clientHeight;
}}
updateWndVars();
global__WEBPACK_IMPORTED_MODULE_1__["window"].addEventListener('resize', updateWndVars);
global__WEBPACK_IMPORTED_MODULE_1__["window"].addEventListener('orientationchange', updateWndVars);
global__WEBPACK_IMPORTED_MODULE_1__["window"].addEventListener('load', updateWndVars);
lite_ready__WEBPACK_IMPORTED_MODULE_0___default()(function (){
updateWndVars({
type: 'dom-loaded'
});
});
var jarallaxList=[];
function getParents(elem){
var parents=[];
while (null!==elem.parentElement){
elem=elem.parentElement;
if(1===elem.nodeType){
parents.push(elem);
}}
return parents;
}
function updateParallax(){
if(!jarallaxList.length){
return;
}
jarallaxList.forEach(function (data, k){
var instance=data.instance,
oldData=data.oldData;
var clientRect=instance.$item.getBoundingClientRect();
var newData={
width: clientRect.width,
height: clientRect.height,
top: clientRect.top,
bottom: clientRect.bottom,
wndW: global__WEBPACK_IMPORTED_MODULE_1__["window"].innerWidth,
wndH: wndH
};
var isResized = !oldData||oldData.wndW!==newData.wndW||oldData.wndH!==newData.wndH||oldData.width!==newData.width||oldData.height!==newData.height;
var isScrolled=isResized||!oldData||oldData.top!==newData.top||oldData.bottom!==newData.bottom;
jarallaxList[k].oldData=newData;
if(isResized){
instance.onResize();
}
if(isScrolled){
instance.onScroll();
}});
global__WEBPACK_IMPORTED_MODULE_1__["window"].requestAnimationFrame(updateParallax);
}
var instanceID=0;
var Jarallax=function (){
function Jarallax(item, userOptions){
_classCallCheck(this, Jarallax);
var self=this;
self.instanceID=instanceID;
instanceID +=1;
self.$item=item;
self.defaults={
type: 'scroll',
speed: 0.5,
imgSrc: null,
imgElement: '.jarallax-img',
imgSize: 'cover',
imgPosition: '50% 50%',
imgRepeat: 'no-repeat',
keepImg: false,
elementInViewport: null,
zIndex: -100,
disableParallax: false,
disableVideo: false,
videoSrc: null,
videoStartTime: 0,
videoEndTime: 0,
videoVolume: 0,
videoLoop: true,
videoPlayOnlyVisible: true,
videoLazyLoading: true,
onScroll: null,
onInit: null,
onDestroy: null,
onCoverImage: null
};
var dataOptions=self.$item.dataset||{};
var pureDataOptions={};
Object.keys(dataOptions).forEach(function (key){
var loweCaseOption=key.substr(0, 1).toLowerCase() + key.substr(1);
if(loweCaseOption&&'undefined'!==typeof self.defaults[loweCaseOption]){
pureDataOptions[loweCaseOption]=dataOptions[key];
}});
self.options=self.extend({}, self.defaults, pureDataOptions, userOptions);
self.pureOptions=self.extend({}, self.options);
Object.keys(self.options).forEach(function (key){
if('true'===self.options[key]){
self.options[key]=true;
}else if('false'===self.options[key]){
self.options[key]=false;
}});
self.options.speed=Math.min(2, Math.max(-1, parseFloat(self.options.speed)));
if('string'===typeof self.options.disableParallax){
self.options.disableParallax=new RegExp(self.options.disableParallax);
}
if(self.options.disableParallax instanceof RegExp){
var disableParallaxRegexp=self.options.disableParallax;
self.options.disableParallax=function (){
return disableParallaxRegexp.test(navigator.userAgent);
};}
if('function'!==typeof self.options.disableParallax){
self.options.disableParallax=function (){
return false;
};}
if('string'===typeof self.options.disableVideo){
self.options.disableVideo=new RegExp(self.options.disableVideo);
}
if(self.options.disableVideo instanceof RegExp){
var disableVideoRegexp=self.options.disableVideo;
self.options.disableVideo=function (){
return disableVideoRegexp.test(navigator.userAgent);
};}
if('function'!==typeof self.options.disableVideo){
self.options.disableVideo=function (){
return false;
};}
var elementInVP=self.options.elementInViewport;
if(elementInVP&&'object'===_typeof(elementInVP)&&'undefined'!==typeof elementInVP.length){
var _elementInVP=elementInVP;
var _elementInVP2=_slicedToArray(_elementInVP, 1);
elementInVP=_elementInVP2[0];
}
if(!(elementInVP instanceof Element)){
elementInVP=null;
}
self.options.elementInViewport=elementInVP;
self.image={
src: self.options.imgSrc||null,
$container: null,
useImgTag: false,
position: /iPad|iPhone|iPod|Android/.test(navigator.userAgent) ? 'absolute':'fixed'
};
if(self.initImg()&&self.canInitParallax()){
self.init();
}}
_createClass(Jarallax, [{
key: "css",
value: function css(el, styles){
if('string'===typeof styles){
return global__WEBPACK_IMPORTED_MODULE_1__["window"].getComputedStyle(el).getPropertyValue(styles);
}
if(styles.transform&&supportTransform){
styles[supportTransform]=styles.transform;
}
Object.keys(styles).forEach(function (key){
el.style[key]=styles[key];
});
return el;
}}, {
key: "extend",
value: function extend(out){
for (var _len=arguments.length, args=new Array(_len > 1 ? _len - 1:0), _key=1; _key < _len; _key++){
args[_key - 1]=arguments[_key];
}
out=out||{};
Object.keys(args).forEach(function (i){
if(!args[i]){
return;
}
Object.keys(args[i]).forEach(function (key){
out[key]=args[i][key];
});
});
return out;
}}, {
key: "getWindowData",
value: function getWindowData(){
return {
width: global__WEBPACK_IMPORTED_MODULE_1__["window"].innerWidth||document.documentElement.clientWidth,
height: wndH,
y: document.documentElement.scrollTop
};}}, {
key: "initImg",
value: function initImg(){
var self=this;
var $imgElement=self.options.imgElement;
if($imgElement&&'string'===typeof $imgElement){
$imgElement=self.$item.querySelector($imgElement);
}
if(!($imgElement instanceof Element)){
if(self.options.imgSrc){
$imgElement=new Image();
$imgElement.src=self.options.imgSrc;
}else{
$imgElement=null;
}}
if($imgElement){
if(self.options.keepImg){
self.image.$item=$imgElement.cloneNode(true);
}else{
self.image.$item=$imgElement;
self.image.$itemParent=$imgElement.parentNode;
}
self.image.useImgTag=true;
}
if(self.image.$item){
return true;
}
if(null===self.image.src){
self.image.src='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
self.image.bgImage=self.css(self.$item, 'background-image');
}
return !(!self.image.bgImage||'none'===self.image.bgImage);
}}, {
key: "canInitParallax",
value: function canInitParallax(){
return supportTransform&&!this.options.disableParallax();
}}, {
key: "init",
value: function init(){
var self=this;
var containerStyles={
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
overflow: 'hidden'
};
var imageStyles={
pointerEvents: 'none',
transformStyle: 'preserve-3d',
backfaceVisibility: 'hidden',
willChange: 'transform,opacity'
};
if(!self.options.keepImg){
var curStyle=self.$item.getAttribute('style');
if(curStyle){
self.$item.setAttribute('data-jarallax-original-styles', curStyle);
}
if(self.image.useImgTag){
var curImgStyle=self.image.$item.getAttribute('style');
if(curImgStyle){
self.image.$item.setAttribute('data-jarallax-original-styles', curImgStyle);
}}
}
if('static'===self.css(self.$item, 'position')){
self.css(self.$item, {
position: 'relative'
});
}
if('auto'===self.css(self.$item, 'z-index')){
self.css(self.$item, {
zIndex: 0
});
}
self.image.$container=document.createElement('div');
self.css(self.image.$container, containerStyles);
self.css(self.image.$container, {
'z-index': self.options.zIndex
});// fix for IE https://github.com/nk-o/jarallax/issues/110
if(isIE){
self.css(self.image.$container, {
opacity: 0.9999
});
}
self.image.$container.setAttribute('id', "jarallax-container-".concat(self.instanceID));
self.$item.appendChild(self.image.$container);
if(self.image.useImgTag){
imageStyles=self.extend({
'object-fit': self.options.imgSize,
'object-position': self.options.imgPosition,
'font-family': "object-fit: ".concat(self.options.imgSize, "; object-position: ").concat(self.options.imgPosition, ";"),
'max-width': 'none'
}, containerStyles, imageStyles);
}else{
self.image.$item=document.createElement('div');
if(self.image.src){
imageStyles=self.extend({
'background-position': self.options.imgPosition,
'background-size': self.options.imgSize,
'background-repeat': self.options.imgRepeat,
'background-image': self.image.bgImage||"url(\"".concat(self.image.src, "\")")
}, containerStyles, imageStyles);
}}
if('opacity'===self.options.type||'scale'===self.options.type||'scale-opacity'===self.options.type||1===self.options.speed){
self.image.position='absolute';
}
if('fixed'===self.image.position){
var $parents=getParents(self.$item).filter(function (el){
var styles=global__WEBPACK_IMPORTED_MODULE_1__["window"].getComputedStyle(el);
var parentTransform=styles['-webkit-transform']||styles['-moz-transform']||styles.transform;
var overflowRegex=/(auto|scroll)/;
return parentTransform&&'none'!==parentTransform||overflowRegex.test(styles.overflow + styles['overflow-y'] + styles['overflow-x']);
});
self.image.position=$parents.length ? 'absolute':'fixed';
}
imageStyles.position=self.image.position;
self.css(self.image.$item, imageStyles);
self.image.$container.appendChild(self.image.$item);
self.onResize();
self.onScroll(true);
if(self.options.onInit){
self.options.onInit.call(self);
}
if('none'!==self.css(self.$item, 'background-image')){
self.css(self.$item, {
'background-image': 'none'
});
}
self.addToParallaxList();
}}, {
key: "addToParallaxList",
value: function addToParallaxList(){
jarallaxList.push({
instance: this
});
if(1===jarallaxList.length){
global__WEBPACK_IMPORTED_MODULE_1__["window"].requestAnimationFrame(updateParallax);
}}
}, {
key: "removeFromParallaxList",
value: function removeFromParallaxList(){
var self=this;
jarallaxList.forEach(function (data, key){
if(data.instance.instanceID===self.instanceID){
jarallaxList.splice(key, 1);
}});
}}, {
key: "destroy",
value: function destroy(){
var self=this;
self.removeFromParallaxList();
var originalStylesTag=self.$item.getAttribute('data-jarallax-original-styles');
self.$item.removeAttribute('data-jarallax-original-styles');
if(!originalStylesTag){
self.$item.removeAttribute('style');
}else{
self.$item.setAttribute('style', originalStylesTag);
}
if(self.image.useImgTag){
var originalStylesImgTag=self.image.$item.getAttribute('data-jarallax-original-styles');
self.image.$item.removeAttribute('data-jarallax-original-styles');
if(!originalStylesImgTag){
self.image.$item.removeAttribute('style');
}else{
self.image.$item.setAttribute('style', originalStylesTag);
}
if(self.image.$itemParent){
self.image.$itemParent.appendChild(self.image.$item);
}}
if(self.$clipStyles){
self.$clipStyles.parentNode.removeChild(self.$clipStyles);
}
if(self.image.$container){
self.image.$container.parentNode.removeChild(self.image.$container);
}
if(self.options.onDestroy){
self.options.onDestroy.call(self);
}
delete self.$item.jarallax;
}}, {
key: "clipContainer",
value: function clipContainer(){
if('fixed'!==this.image.position){
return;
}
var self=this;
var rect=self.image.$container.getBoundingClientRect();
var width=rect.width,
height=rect.height;
if(!self.$clipStyles){
self.$clipStyles=document.createElement('style');
self.$clipStyles.setAttribute('type', 'text/css');
self.$clipStyles.setAttribute('id', "jarallax-clip-".concat(self.instanceID));
var head=document.head||document.getElementsByTagName('head')[0];
head.appendChild(self.$clipStyles);
}
var styles="#jarallax-container-".concat(self.instanceID, " {\n            clip: rect(0 ").concat(width, "px ").concat(height, "px 0);\n            clip: rect(0, ").concat(width, "px, ").concat(height, "px, 0);\n            -webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);\n            clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);\n        }");
if(self.$clipStyles.styleSheet){
self.$clipStyles.styleSheet.cssText=styles;
}else{
self.$clipStyles.innerHTML=styles;
}}
}, {
key: "coverImage",
value: function coverImage(){
var self=this;
var rect=self.image.$container.getBoundingClientRect();
var contH=rect.height;
var speed=self.options.speed;
var isScroll='scroll'===self.options.type||'scroll-opacity'===self.options.type;
var scrollDist=0;
var resultH=contH;
var resultMT=0;
if(isScroll){
if(0 > speed){
scrollDist=speed * Math.max(contH, wndH);
if(wndH < contH){
scrollDist -=speed * (contH - wndH);
}}else{
scrollDist=speed * (contH + wndH);
}
if(1 < speed){
resultH=Math.abs(scrollDist - wndH);
}else if(0 > speed){
resultH=scrollDist / speed + Math.abs(scrollDist);
}else{
resultH +=(wndH - contH) * (1 - speed);
}
scrollDist /=2;
}
self.parallaxScrollDistance=scrollDist;
if(isScroll){
resultMT=(wndH - resultH) / 2;
}else{
resultMT=(contH - resultH) / 2;
}
self.css(self.image.$item, {
height: "".concat(resultH, "px"),
marginTop: "".concat(resultMT, "px"),
left: 'fixed'===self.image.position ? "".concat(rect.left, "px"):'0',
width: "".concat(rect.width, "px")
});
if(self.options.onCoverImage){
self.options.onCoverImage.call(self);
}
return {
image: {
height: resultH,
marginTop: resultMT
},
container: rect
};}}, {
key: "isVisible",
value: function isVisible(){
return this.isElementInViewport||false;
}}, {
key: "onScroll",
value: function onScroll(force){
var self=this;
var rect=self.$item.getBoundingClientRect();
var contT=rect.top;
var contH=rect.height;
var styles={};
var viewportRect=rect;
if(self.options.elementInViewport){
viewportRect=self.options.elementInViewport.getBoundingClientRect();
}
self.isElementInViewport=0 <=viewportRect.bottom&&0 <=viewportRect.right&&viewportRect.top <=wndH&&viewportRect.left <=global__WEBPACK_IMPORTED_MODULE_1__["window"].innerWidth;
if(force ? false:!self.isElementInViewport){
return;
}
var beforeTop=Math.max(0, contT);
var beforeTopEnd=Math.max(0, contH + contT);
var afterTop=Math.max(0, -contT);
var beforeBottom=Math.max(0, contT + contH - wndH);
var beforeBottomEnd=Math.max(0, contH - (contT + contH - wndH));
var afterBottom=Math.max(0, -contT + wndH - contH);
var fromViewportCenter=1 - 2 * ((wndH - contT) / (wndH + contH));
var visiblePercent=1;
if(contH < wndH){
visiblePercent=1 - (afterTop||beforeBottom) / contH;
}else if(beforeTopEnd <=wndH){
visiblePercent=beforeTopEnd / wndH;
}else if(beforeBottomEnd <=wndH){
visiblePercent=beforeBottomEnd / wndH;
}
if('opacity'===self.options.type||'scale-opacity'===self.options.type||'scroll-opacity'===self.options.type){
styles.transform='translate3d(0,0,0)';
styles.opacity=visiblePercent;
}
if('scale'===self.options.type||'scale-opacity'===self.options.type){
var scale=1;
if(0 > self.options.speed){
scale -=self.options.speed * visiblePercent;
}else{
scale +=self.options.speed * (1 - visiblePercent);
}
styles.transform="scale(".concat(scale, ") translate3d(0,0,0)");
}
if('scroll'===self.options.type||'scroll-opacity'===self.options.type){
var positionY=self.parallaxScrollDistance * fromViewportCenter;
if('absolute'===self.image.position){
positionY -=contT;
}
styles.transform="translate3d(0,".concat(positionY, "px,0)");
}
self.css(self.image.$item, styles);
if(self.options.onScroll){
self.options.onScroll.call(self, {
section: rect,
beforeTop: beforeTop,
beforeTopEnd: beforeTopEnd,
afterTop: afterTop,
beforeBottom: beforeBottom,
beforeBottomEnd: beforeBottomEnd,
afterBottom: afterBottom,
visiblePercent: visiblePercent,
fromViewportCenter: fromViewportCenter
});
}}
}, {
key: "onResize",
value: function onResize(){
this.coverImage();
this.clipContainer();
}}]);
return Jarallax;
}();
var plugin=function plugin(items, options){
if('object'===(typeof HTMLElement==="undefined" ? "undefined":_typeof(HTMLElement)) ? items instanceof HTMLElement:items&&'object'===_typeof(items)&&null!==items&&1===items.nodeType&&'string'===typeof items.nodeName){
items=[items];
}
var len=items.length;
var k=0;
var ret;
for (var _len2=arguments.length, args=new Array(_len2 > 2 ? _len2 - 2:0), _key2=2; _key2 < _len2; _key2++){
args[_key2 - 2]=arguments[_key2];
}
for (k; k < len; k +=1){
if('object'===_typeof(options)||'undefined'===typeof options){
if(!items[k].jarallax){
items[k].jarallax=new Jarallax(items[k], options);
}}else if(items[k].jarallax){
ret=items[k].jarallax[options].apply(items[k].jarallax, args);
}
if('undefined'!==typeof ret){
return ret;
}}
return items;
};
plugin.constructor=Jarallax;
__webpack_exports__["default"]=(plugin);
})
]);
(function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k));
if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("<div />"))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q,
u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0),height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),e<F&&(m=!1,c=q,null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),
h.detach()),b={position:"",width:"",top:""},a.css(b).removeClass(t).trigger("sticky_kit:unstick")),B&&(b=f.height(),u+q>b&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"relative"}),
a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize",
y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n<K;n++)d=this[n],J(b(d));return this}}).call(this);