// page init
jQuery(function(){
initStickyBlock();
initAnchors();
initCycleCarousel();
initMobileNav();
initSameHeight();
});
// init sticky header
function initStickyBlock() {
jQuery('#wrapper').StickyBlock({
fixedClass : 'fixed-position',
heightRatio: 1
});
}
// initialize smooth anchor links
function initAnchors() {
new SmoothScroll({
anchorLinks: 'a[href^="#"]:not([href="#"])',
extraOffset: function() {
var totalHeight = 0;
jQuery('header').each(function(){
totalHeight += jQuery(this).outerHeight();
});
return totalHeight;
},
activeClasses: 'parent',
anchorActiveClass: 'active'
});
}
// cycle scroll gallery init
function initCycleCarousel() {
jQuery('.gallery').scrollAbsoluteGallery({
mask: '.mask',
slider: '.slideset',
slides: '.slide',
btnPrev: 'a.btn-prev',
btnNext: 'a.btn-next',
generatePagination: '.pagination',
stretchSlideToMask: true,
maskAutoSize: true,
autoRotation: false,
switchTime: 3000,
animSpeed: 500
});
}
// mobile menu init
function initMobileNav() {
jQuery('body').mobileNav({
hideOnClickOutside: true,
menuActiveClass: 'navigation-active',
menuOpener: '.opener-navigation',
menuDrop: '.drop-navigation'
});
}
// align blocks height
function initSameHeight() {
jQuery('.schedule-list').sameHeight({
elements: '.schedule-row',
useMinHeight: true,
flexible: true,
multiLine: true,
biggestHeight: true
});
}
/*
* sticky block plugin
*/
;(function($) {
function StickyBlock(options) {
this.options = $.extend({
holder: null,
fixedClass : 'fixed',
compareBlock: 'div',
blockHeight: false,
blockTop: false,
heightRatio: false
}, options);
this.init();
}
StickyBlock.prototype = {
init: function() {
if(this.options.holder) {
this.findElements();
this.attachEvents();
}
},
findElements: function() {
this.holder = jQuery(this.options.holder);
this.compareBlock = jQuery(this.options.compareBlock);
this.win = jQuery(window);
if (this.options.blockHeight){
this.scrollHeight = this.compareBlock.innerHeight();
}
if (this.options.blockTop){
this.scrollHeight = this.compareBlock.offset().top;
}
if (this.options.heightRatio){
this.scrollHeight = this.options.heightRatio;
}
},
attachEvents: function() {
// bind handlers scope
var self = this;
this.bindHandlers(['onScroll']);
$(window).bind('scroll resize load', this.onScroll);
},
onScroll: function() {
var self = this;
self.scrollTop = self.win.scrollTop();
if (self.scrollTop > self.scrollHeight){
self.holder.addClass(self.options.fixedClass);
} else {
self.holder.removeClass(self.options.fixedClass);
}
},
bindHandlers: function(handlersList) {
var self = this;
$.each(handlersList, function(index, handler) {
var origHandler = self[handler];
self[handler] = function() {
return origHandler.apply(self, arguments);
};
});
},
makeCallback: function(name) {
if(typeof this.options[name] === 'function') {
var args = Array.prototype.slice.call(arguments);
args.shift();
this.options[name].apply(this, args);
}
}
};
// jQuery plugin interface
$.fn.StickyBlock = function(opt) {
return this.each(function() {
new StickyBlock($.extend(opt, {holder: this}));
});
};
}(jQuery));
/*!
* SmoothScroll module
*/
;(function($, exports) {
// private variables
var page,
win = $(window),
activeBlock, activeWheelHandler,
wheelEvents = ('onwheel' in document || document.documentMode >= 9 ? 'wheel' : 'mousewheel DOMMouseScroll');
// animation handlers
function scrollTo(offset, options, callback) {
// initialize variables
var scrollBlock;
if (document.body) {
if (typeof options === 'number') {
options = { duration: options };
} else {
options = options || {};
}
page = page || $('html, body');
scrollBlock = options.container || page;
} else {
return;
}
// treat single number as scrollTop
if (typeof offset === 'number') {
offset = { top: offset };
}
// handle mousewheel/trackpad while animation is active
if (activeBlock && activeWheelHandler) {
activeBlock.off(wheelEvents, activeWheelHandler);
}
if (options.wheelBehavior && options.wheelBehavior !== 'none') {
activeWheelHandler = function(e) {
if (options.wheelBehavior === 'stop') {
scrollBlock.off(wheelEvents, activeWheelHandler);
scrollBlock.stop();
} else if (options.wheelBehavior === 'ignore') {
e.preventDefault();
}
};
activeBlock = scrollBlock.on(wheelEvents, activeWheelHandler);
}
// start scrolling animation
scrollBlock.stop().animate({
scrollLeft: offset.left,
scrollTop: offset.top
}, options.duration, function() {
if (activeWheelHandler) {
scrollBlock.off(wheelEvents, activeWheelHandler);
}
if ($.isFunction(callback)) {
callback();
}
});
}
// smooth scroll contstructor
function SmoothScroll(options) {
this.options = $.extend({
anchorLinks: 'a[href^="#"]', // selector or jQuery object
container: null, // specify container for scrolling (default - whole page)
extraOffset: null, // function or fixed number
activeClasses: null, // null, "link", "parent"
easing: 'swing', // easing of scrolling
animMode: 'duration', // or "speed" mode
animDuration: 800, // total duration for scroll (any distance)
animSpeed: 1500, // pixels per second
anchorActiveClass: 'anchor-active',
sectionActiveClass: 'section-active',
wheelBehavior: 'stop', // "stop", "ignore" or "none"
useNativeAnchorScrolling: false // do not handle click in devices with native smooth scrolling
}, options);
this.init();
}
SmoothScroll.prototype = {
init: function() {
this.initStructure();
this.attachEvents();
},
initStructure: function() {
var self = this;
this.container = this.options.container ? $(this.options.container) : $('html,body');
this.scrollContainer = this.options.container ? this.container : win;
this.anchorLinks = jQuery(this.options.anchorLinks).filter(function() {
return document.getElementById(this.getAttribute('href').slice(1));
});
},
getAnchorTarget: function(link) {
// get target block from link href
var targetId = $(link).attr('href');
return $(targetId.length > 1 ? targetId : 'html');
},
getTargetOffset: function(block) {
// get target offset
var blockOffset = block.offset().top;
if (this.options.container) {
blockOffset -= this.container.offset().top - this.container.prop('scrollTop');
}
// handle extra offset
if (typeof this.options.extraOffset === 'number') {
blockOffset -= this.options.extraOffset;
} else if (typeof this.options.extraOffset === 'function') {
blockOffset -= this.options.extraOffset(block);
}
return { top: blockOffset };
},
attachEvents: function() {
var self = this;
// handle active classes
if (this.options.activeClasses && this.anchorLinks.length) {
// cache structure
this.anchorData = [];
for (var i = 0; i < this.anchorLinks.length; i++) {
var link = jQuery(this.anchorLinks[i]),
targetBlock = self.getAnchorTarget(link),
anchorDataItem;
$.each(self.anchorData, function(index, item) {
if (item.block[0] === targetBlock[0]) {
anchorDataItem = item;
}
});
if (anchorDataItem) {
anchorDataItem.link = anchorDataItem.link.add(link);
} else {
self.anchorData.push({
link: link,
block: targetBlock
});
}
};
// add additional event handlers
this.resizeHandler = function() {
self.recalculateOffsets();
};
this.scrollHandler = function() {
self.refreshActiveClass();
};
this.recalculateOffsets();
this.scrollContainer.on('scroll', this.scrollHandler);
win.on('resize', this.resizeHandler);
}
// handle click event
this.clickHandler = function(e) {
self.onClick(e);
};
if (!this.options.useNativeAnchorScrolling) {
this.anchorLinks.on('click', this.clickHandler);
}
},
recalculateOffsets: function() {
var self = this;
$.each(this.anchorData, function(index, data) {
data.offset = self.getTargetOffset(data.block);
data.height = data.block.outerHeight();
});
this.refreshActiveClass();
},
refreshActiveClass: function() {
var self = this,
foundFlag = false,
containerHeight = this.container.prop('scrollHeight'),
viewPortHeight = this.scrollContainer.height(),
scrollTop = this.options.container ? this.container.prop('scrollTop') : win.scrollTop();
// user function instead of default handler
if (this.options.customScrollHandler) {
this.options.customScrollHandler.call(this, scrollTop, this.anchorData);
return;
}
// sort anchor data by offsets
this.anchorData.sort(function(a, b) {
return a.offset.top - b.offset.top;
});
function toggleActiveClass(anchor, block, state) {
anchor.toggleClass(self.options.anchorActiveClass, state);
block.toggleClass(self.options.sectionActiveClass, state);
}
// default active class handler
$.each(this.anchorData, function(index) {
var reverseIndex = self.anchorData.length - index - 1,
data = self.anchorData[reverseIndex],
anchorElement = (self.options.activeClasses === 'parent' ? data.link.parent() : data.link);
if (scrollTop >= containerHeight - viewPortHeight) {
// handle last section
if (reverseIndex === self.anchorData.length - 1) {
toggleActiveClass(anchorElement, data.block, true);
} else {
toggleActiveClass(anchorElement, data.block, false);
}
} else {
// handle other sections
if (!foundFlag && (scrollTop >= data.offset.top - 1 || reverseIndex === 0)) {
foundFlag = true;
toggleActiveClass(anchorElement, data.block, true);
} else {
toggleActiveClass(anchorElement, data.block, false);
}
}
});
},
calculateScrollDuration: function(offset) {
var distance;
if (this.options.animMode === 'speed') {
distance = Math.abs(this.scrollContainer.scrollTop() - offset.top);
return (distance / this.options.animSpeed) * 1000;
} else {
return this.options.animDuration;
}
},
onClick: function(e) {
var targetBlock = this.getAnchorTarget(e.currentTarget),
targetOffset = this.getTargetOffset(targetBlock);
e.preventDefault();
scrollTo(targetOffset, {
container: this.container,
wheelBehavior: this.options.wheelBehavior,
duration: this.calculateScrollDuration(targetOffset)
});
},
destroy: function() {
if (this.options.activeClasses) {
win.off('resize', this.resizeHandler);
this.scrollContainer.off('scroll', this.scrollHandler);
}
this.anchorLinks.off('click', this.clickHandler);
}
};
// public API
$.extend(SmoothScroll, {
scrollTo: function(blockOrOffset, durationOrOptions, callback) {
scrollTo(blockOrOffset, durationOrOptions, callback);
}
});
// export module
exports.SmoothScroll = SmoothScroll;
}(jQuery, this));
/*
* jQuery Cycle Carousel plugin
*/
;(function($){
function ScrollAbsoluteGallery(options) {
this.options = $.extend({
activeClass: 'active',
mask: 'div.slides-mask',
slider: '>ul',
slides: '>li',
btnPrev: '.btn-prev',
btnNext: '.btn-next',
pagerLinks: 'ul.pager > li',
generatePagination: false,
pagerList: '
',
pagerListItem: ' ',
pagerListItemText: 'a',
galleryReadyClass: 'gallery-js-ready',
currentNumber: 'span.current-num',
totalNumber: 'span.total-num',
maskAutoSize: false,
autoRotation: false,
pauseOnHover: false,
stretchSlideToMask: false,
switchTime: 3000,
animSpeed: 500,
handleTouch: true,
swipeThreshold: 15,
vertical: false
}, options);
this.init();
}
ScrollAbsoluteGallery.prototype = {
init: function() {
if(this.options.holder) {
this.findElements();
this.attachEvents();
this.makeCallback('onInit', this);
}
},
findElements: function() {
// find structure elements
this.holder = $(this.options.holder).addClass(this.options.galleryReadyClass);
this.mask = this.holder.find(this.options.mask);
this.slider = this.mask.find(this.options.slider);
this.slides = this.slider.find(this.options.slides);
this.btnPrev = this.holder.find(this.options.btnPrev);
this.btnNext = this.holder.find(this.options.btnNext);
// slide count display
this.currentNumber = this.holder.find(this.options.currentNumber);
this.totalNumber = this.holder.find(this.options.totalNumber);
// create gallery pagination
if(typeof this.options.generatePagination === 'string') {
this.pagerLinks = this.buildPagination();
} else {
this.pagerLinks = this.holder.find(this.options.pagerLinks);
}
// define index variables
this.sizeProperty = this.options.vertical ? 'height' : 'width';
this.positionProperty = this.options.vertical ? 'top' : 'left';
this.animProperty = this.options.vertical ? 'marginTop' : 'marginLeft';
this.slideSize = this.slides[this.sizeProperty]();
this.currentIndex = 0;
this.prevIndex = 0;
// reposition elements
this.options.maskAutoSize = this.options.vertical ? false : this.options.maskAutoSize;
if(this.options.vertical) {
this.mask.css({
height: this.slides.innerHeight()
});
}
if(this.options.maskAutoSize){
this.mask.css({
height: this.slider.height()
});
}
this.slider.css({
position: 'relative',
height: this.options.vertical ? this.slideSize * this.slides.length : '100%'
});
this.slides.css({
position: 'absolute'
}).css(this.positionProperty, -9999).eq(this.currentIndex).css(this.positionProperty, 0);
this.refreshState();
},
buildPagination: function() {
var pagerLinks = $();
if(!this.pagerHolder) {
this.pagerHolder = this.holder.find(this.options.generatePagination);
}
if(this.pagerHolder.length) {
this.pagerHolder.empty();
this.pagerList = $(this.options.pagerList).appendTo(this.pagerHolder);
for(var i = 0; i < this.slides.length; i++) {
$(this.options.pagerListItem).appendTo(this.pagerList).find(this.options.pagerListItemText).text(i+1);
}
pagerLinks = this.pagerList.children();
}
return pagerLinks;
},
attachEvents: function() {
// attach handlers
var self = this;
if(this.btnPrev.length) {
this.btnPrevHandler = function(e) {
e.preventDefault();
self.prevSlide();
};
this.btnPrev.click(this.btnPrevHandler);
}
if(this.btnNext.length) {
this.btnNextHandler = function(e) {
e.preventDefault();
self.nextSlide();
};
this.btnNext.click(this.btnNextHandler);
}
if(this.pagerLinks.length) {
this.pagerLinksHandler = function(e) {
e.preventDefault();
self.numSlide(self.pagerLinks.index(e.currentTarget));
};
this.pagerLinks.click(this.pagerLinksHandler);
}
// handle autorotation pause on hover
if(this.options.pauseOnHover) {
this.hoverHandler = function() {
clearTimeout(self.timer);
};
this.leaveHandler = function() {
self.autoRotate();
};
this.holder.bind({mouseenter: this.hoverHandler, mouseleave: this.leaveHandler});
}
// handle holder and slides dimensions
this.resizeHandler = function() {
if(!self.animating) {
if(self.options.stretchSlideToMask) {
self.resizeSlides();
}
self.resizeHolder();
self.setSlidesPosition(self.currentIndex);
}
};
$(window).bind('load resize orientationchange', this.resizeHandler);
if(self.options.stretchSlideToMask) {
self.resizeSlides();
}
// handle swipe on mobile devices
if(this.options.handleTouch && window.Hammer && this.mask.length && this.slides.length > 1 && isTouchDevice) {
this.swipeHandler = new Hammer.Manager(this.mask[0]);
this.swipeHandler.add(new Hammer.Pan({
direction: self.options.vertical ? Hammer.DIRECTION_VERTICAL : Hammer.DIRECTION_HORIZONTAL,
threshold: self.options.swipeThreshold
}));
this.swipeHandler.on('panstart', function() {
if(self.animating) {
self.swipeHandler.stop();
} else {
clearTimeout(self.timer);
}
}).on('panmove', function(e) {
self.swipeOffset = -self.slideSize + e[self.options.vertical ? 'deltaY' : 'deltaX'];
self.slider.css(self.animProperty, self.swipeOffset);
clearTimeout(self.timer);
}).on('panend', function(e) {
if(e.distance > self.options.swipeThreshold) {
if(e.offsetDirection === Hammer.DIRECTION_RIGHT || e.offsetDirection === Hammer.DIRECTION_DOWN) {
self.nextSlide();
} else {
self.prevSlide();
}
} else {
var tmpObj = {};
tmpObj[self.animProperty] = -self.slideSize;
self.slider.animate(tmpObj, {duration: self.options.animSpeed});
self.autoRotate();
}
self.swipeOffset = 0;
});
}
// start autorotation
this.autoRotate();
this.resizeHolder();
this.setSlidesPosition(this.currentIndex);
},
resizeSlides: function() {
this.slideSize = this.mask[this.options.vertical ? 'height' : 'width']();
this.slides.css(this.sizeProperty, this.slideSize);
},
resizeHolder: function() {
if(this.options.maskAutoSize) {
this.mask.css({
height: this.slides.eq(this.currentIndex).outerHeight(true)
});
}
},
prevSlide: function() {
if(!this.animating && this.slides.length > 1) {
this.direction = -1;
this.prevIndex = this.currentIndex;
if(this.currentIndex > 0) this.currentIndex--;
else this.currentIndex = this.slides.length - 1;
this.switchSlide();
}
},
nextSlide: function(fromAutoRotation) {
if(!this.animating && this.slides.length > 1) {
this.direction = 1;
this.prevIndex = this.currentIndex;
if(this.currentIndex < this.slides.length - 1) this.currentIndex++;
else this.currentIndex = 0;
this.switchSlide();
}
},
numSlide: function(c) {
if(!this.animating && this.currentIndex !== c && this.slides.length > 1) {
this.direction = c > this.currentIndex ? 1 : -1;
this.prevIndex = this.currentIndex;
this.currentIndex = c;
this.switchSlide();
}
},
preparePosition: function() {
// prepare slides position before animation
this.setSlidesPosition(this.prevIndex, this.direction < 0 ? this.currentIndex : null, this.direction > 0 ? this.currentIndex : null, this.direction);
},
setSlidesPosition: function(index, slideLeft, slideRight, direction) {
// reposition holder and nearest slides
if(this.slides.length > 1) {
var prevIndex = (typeof slideLeft === 'number' ? slideLeft : index > 0 ? index - 1 : this.slides.length - 1);
var nextIndex = (typeof slideRight === 'number' ? slideRight : index < this.slides.length - 1 ? index + 1 : 0);
this.slider.css(this.animProperty, this.swipeOffset ? this.swipeOffset : -this.slideSize);
this.slides.css(this.positionProperty, -9999).eq(index).css(this.positionProperty, this.slideSize);
if(prevIndex === nextIndex && typeof direction === 'number') {
var calcOffset = direction > 0 ? this.slideSize*2 : 0;
this.slides.eq(nextIndex).css(this.positionProperty, calcOffset);
} else {
this.slides.eq(prevIndex).css(this.positionProperty, 0);
this.slides.eq(nextIndex).css(this.positionProperty, this.slideSize*2);
}
}
},
switchSlide: function() {
// prepare positions and calculate offset
var self = this;
var oldSlide = this.slides.eq(this.prevIndex);
var newSlide = this.slides.eq(this.currentIndex);
this.animating = true;
// resize mask to fit slide
if(this.options.maskAutoSize) {
this.mask.animate({
height: newSlide.outerHeight(true)
}, {
duration: this.options.animSpeed
});
}
// start animation
var animProps = {};
animProps[this.animProperty] = this.direction > 0 ? -this.slideSize*2 : 0;
this.preparePosition();
this.slider.animate(animProps,{duration:this.options.animSpeed, complete:function() {
self.setSlidesPosition(self.currentIndex);
// start autorotation
self.animating = false;
self.autoRotate();
// onchange callback
self.makeCallback('onChange', self);
}});
// refresh classes
this.refreshState();
// onchange callback
this.makeCallback('onBeforeChange', this);
},
refreshState: function(initial) {
// slide change function
this.slides.removeClass(this.options.activeClass).eq(this.currentIndex).addClass(this.options.activeClass);
this.pagerLinks.removeClass(this.options.activeClass).eq(this.currentIndex).addClass(this.options.activeClass);
// display current slide number
this.currentNumber.html(this.currentIndex + 1);
this.totalNumber.html(this.slides.length);
// add class if not enough slides
this.holder.toggleClass('not-enough-slides', this.slides.length === 1);
},
autoRotate: function() {
var self = this;
clearTimeout(this.timer);
if(this.options.autoRotation) {
this.timer = setTimeout(function() {
self.nextSlide();
}, this.options.switchTime);
}
},
makeCallback: function(name) {
if(typeof this.options[name] === 'function') {
var args = Array.prototype.slice.call(arguments);
args.shift();
this.options[name].apply(this, args);
}
},
destroy: function() {
// destroy handler
this.btnPrev.unbind('click', this.btnPrevHandler);
this.btnNext.unbind('click', this.btnNextHandler);
this.pagerLinks.unbind('click', this.pagerLinksHandler);
this.holder.unbind('mouseenter', this.hoverHandler);
this.holder.unbind('mouseleave', this.leaveHandler);
$(window).unbind('load resize orientationchange', this.resizeHandler);
clearTimeout(this.timer);
// destroy swipe handler
if(this.swipeHandler) {
this.swipeHandler.destroy();
}
// remove inline styles, classes and pagination
this.holder.removeClass(this.options.galleryReadyClass);
this.slider.add(this.slides).removeAttr('style');
if(typeof this.options.generatePagination === 'string') {
this.pagerHolder.empty();
}
}
};
// detect device type
var isTouchDevice = /Windows Phone/.test(navigator.userAgent) || ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;
// jquery plugin
$.fn.scrollAbsoluteGallery = function(opt){
return this.each(function(){
$(this).data('ScrollAbsoluteGallery', new ScrollAbsoluteGallery($.extend(opt,{holder:this})));
});
};
}(jQuery));
/*! Hammer.JS - v2.0.4 - 2014-09-28
* http://hammerjs.github.io/
*
* Copyright (c) 2014 Jorik Tangelder;
* Licensed under the MIT license */
if(Object.create){!function(a,b,c,d){"use strict";function e(a,b,c){return setTimeout(k(a,c),b)}function f(a,b,c){return Array.isArray(a)?(g(a,c[b],c),!0):!1}function g(a,b,c){var e;if(a)if(a.forEach)a.forEach(b,c);else if(a.length!==d)for(e=0;e-1}function r(a){return a.trim().split(/\s+/g)}function s(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0;dc[b]}):d.sort()),d}function v(a,b){for(var c,e,f=b[0].toUpperCase()+b.slice(1),g=0;g1&&!c.firstMultiple?c.firstMultiple=E(b):1===e&&(c.firstMultiple=!1);var f=c.firstInput,g=c.firstMultiple,h=g?g.center:f.center,i=b.center=F(d);b.timeStamp=nb(),b.deltaTime=b.timeStamp-f.timeStamp,b.angle=J(h,i),b.distance=I(h,i),C(c,b),b.offsetDirection=H(b.deltaX,b.deltaY),b.scale=g?L(g.pointers,d):1,b.rotation=g?K(g.pointers,d):0,D(c,b);var j=a.element;p(b.srcEvent.target,j)&&(j=b.srcEvent.target),b.target=j}function C(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(b.eventType===yb||f.eventType===Ab)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function D(a,b){var c,e,f,g,h=a.lastInterval||b,i=b.timeStamp-h.timeStamp;if(b.eventType!=Bb&&(i>xb||h.velocity===d)){var j=h.deltaX-b.deltaX,k=h.deltaY-b.deltaY,l=G(i,j,k);e=l.x,f=l.y,c=mb(l.x)>mb(l.y)?l.x:l.y,g=H(j,k),a.lastInterval=b}else c=h.velocity,e=h.velocityX,f=h.velocityY,g=h.direction;b.velocity=c,b.velocityX=e,b.velocityY=f,b.direction=g}function E(a){for(var b=[],c=0;ce;)c+=a[e].clientX,d+=a[e].clientY,e++;return{x:lb(c/b),y:lb(d/b)}}function G(a,b,c){return{x:b/a||0,y:c/a||0}}function H(a,b){return a===b?Cb:mb(a)>=mb(b)?a>0?Db:Eb:b>0?Fb:Gb}function I(a,b,c){c||(c=Kb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function J(a,b,c){c||(c=Kb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function K(a,b){return J(b[1],b[0],Lb)-J(a[1],a[0],Lb)}function L(a,b){return I(b[0],b[1],Lb)/I(a[0],a[1],Lb)}function M(){this.evEl=Nb,this.evWin=Ob,this.allow=!0,this.pressed=!1,y.apply(this,arguments)}function N(){this.evEl=Rb,this.evWin=Sb,y.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function O(){this.evTarget=Ub,this.evWin=Vb,this.started=!1,y.apply(this,arguments)}function P(a,b){var c=t(a.touches),d=t(a.changedTouches);return b&(Ab|Bb)&&(c=u(c.concat(d),"identifier",!0)),[c,d]}function Q(){this.evTarget=Xb,this.targetIds={},y.apply(this,arguments)}function R(a,b){var c=t(a.touches),d=this.targetIds;if(b&(yb|zb)&&1===c.length)return d[c[0].identifier]=!0,[c,c];var e,f,g=t(a.changedTouches),h=[],i=this.target;if(f=c.filter(function(a){return p(a.target,i)}),b===yb)for(e=0;eh&&(b.push(a),h=b.length-1):e&(Ab|Bb)&&(c=!0),0>h||(b[h]=a,this.callback(this.manager,e,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),c&&b.splice(h,1))}});var Tb={touchstart:yb,touchmove:zb,touchend:Ab,touchcancel:Bb},Ub="touchstart",Vb="touchstart touchmove touchend touchcancel";j(O,y,{handler:function(a){var b=Tb[a.type];if(b===yb&&(this.started=!0),this.started){var c=P.call(this,a,b);b&(Ab|Bb)&&c[0].length-c[1].length===0&&(this.started=!1),this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:tb,srcEvent:a})}}});var Wb={touchstart:yb,touchmove:zb,touchend:Ab,touchcancel:Bb},Xb="touchstart touchmove touchend touchcancel";j(Q,y,{handler:function(a){var b=Wb[a.type],c=R.call(this,a,b);c&&this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:tb,srcEvent:a})}}),j(S,y,{handler:function(a,b,c){var d=c.pointerType==tb,e=c.pointerType==vb;if(d)this.mouse.allow=!1;else if(e&&!this.mouse.allow)return;b&(Ab|Bb)&&(this.mouse.allow=!0),this.callback(a,b,c)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Yb=v(jb.style,"touchAction"),Zb=Yb!==d,$b="compute",_b="auto",ac="manipulation",bc="none",cc="pan-x",dc="pan-y";T.prototype={set:function(a){a==$b&&(a=this.compute()),Zb&&(this.manager.element.style[Yb]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return g(this.manager.recognizers,function(b){l(b.options.enable,[b])&&(a=a.concat(b.getTouchAction()))}),U(a.join(" "))},preventDefaults:function(a){if(!Zb){var b=a.srcEvent,c=a.offsetDirection;if(this.manager.session.prevented)return void b.preventDefault();var d=this.actions,e=q(d,bc),f=q(d,dc),g=q(d,cc);return e||f&&c&Hb||g&&c&Ib?this.preventSrc(b):void 0}},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};var ec=1,fc=2,gc=4,hc=8,ic=hc,jc=16,kc=32;V.prototype={defaults:{},set:function(a){return h(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){if(f(a,"recognizeWith",this))return this;var b=this.simultaneous;return a=Y(a,this),b[a.id]||(b[a.id]=a,a.recognizeWith(this)),this},dropRecognizeWith:function(a){return f(a,"dropRecognizeWith",this)?this:(a=Y(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){if(f(a,"requireFailure",this))return this;var b=this.requireFail;return a=Y(a,this),-1===s(b,a)&&(b.push(a),a.requireFailure(this)),this},dropRequireFailure:function(a){if(f(a,"dropRequireFailure",this))return this;a=Y(a,this);var b=s(this.requireFail,a);return b>-1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){function b(b){c.manager.emit(c.options.event+(b?W(d):""),a)}var c=this,d=this.state;hc>d&&b(!0),b(),d>=hc&&b(!0)},tryEmit:function(a){return this.canEmit()?this.emit(a):void(this.state=kc)},canEmit:function(){for(var a=0;af?Db:Eb,c=f!=this.pX,d=Math.abs(a.deltaX)):(e=0===g?Cb:0>g?Fb:Gb,c=g!=this.pY,d=Math.abs(a.deltaY))),a.direction=e,c&&d>b.threshold&&e&b.direction},attrTest:function(a){return Z.prototype.attrTest.call(this,a)&&(this.state&fc||!(this.state&fc)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=X(a.direction);b&&this.manager.emit(this.options.event+b,a),this._super.emit.call(this,a)}}),j(_,Z,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[bc]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&fc)},emit:function(a){if(this._super.emit.call(this,a),1!==a.scale){var b=a.scale<1?"in":"out";this.manager.emit(this.options.event+b,a)}}}),j(ab,V,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[_b]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,!d||!c||a.eventType&(Ab|Bb)&&!f)this.reset();else if(a.eventType&yb)this.reset(),this._timer=e(function(){this.state=ic,this.tryEmit()},b.time,this);else if(a.eventType&Ab)return ic;return kc},reset:function(){clearTimeout(this._timer)},emit:function(a){this.state===ic&&(a&&a.eventType&Ab?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=nb(),this.manager.emit(this.options.event,this._input)))}}),j(bb,Z,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[bc]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&fc)}}),j(cb,Z,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:Hb|Ib,pointers:1},getTouchAction:function(){return $.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return c&(Hb|Ib)?b=a.velocity:c&Hb?b=a.velocityX:c&Ib&&(b=a.velocityY),this._super.attrTest.call(this,a)&&c&a.direction&&a.distance>this.options.threshold&&mb(b)>this.options.velocity&&a.eventType&Ab},emit:function(a){var b=X(a.direction);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),j(db,V,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[ac]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance*',
flexible: false,
multiLine: false,
useMinHeight: false,
biggestHeight: false
},opt);
return this.each(function(){
var holder = $(this), postResizeTimer, ignoreResize;
var elements = holder.find(options.elements).not('.' + options.skipClass);
if(!elements.length) return;
// resize handler
function doResize() {
elements.css(options.useMinHeight && supportMinHeight ? 'minHeight' : 'height', '');
if(options.multiLine) {
// resize elements row by row
resizeElementsByRows(elements, options);
} else {
// resize elements by holder
resizeElements(elements, holder, options);
}
}
doResize();
// handle flexible layout / font resize
var delayedResizeHandler = function() {
if(!ignoreResize) {
ignoreResize = true;
doResize();
clearTimeout(postResizeTimer);
postResizeTimer = setTimeout(function() {
doResize();
setTimeout(function(){
ignoreResize = false;
}, 10);
}, 100);
}
};
// handle flexible/responsive layout
if(options.flexible) {
$(window).bind('resize orientationchange fontresize', delayedResizeHandler);
}
// handle complete page load including images and fonts
$(window).bind('load', delayedResizeHandler);
});
};
// detect css min-height support
var supportMinHeight = typeof document.documentElement.style.maxHeight !== 'undefined';
// get elements by rows
function resizeElementsByRows(boxes, options) {
var currentRow = $(), maxHeight, maxCalcHeight = 0, firstOffset = boxes.eq(0).offset().top;
boxes.each(function(ind){
var curItem = $(this);
if(curItem.offset().top === firstOffset) {
currentRow = currentRow.add(this);
} else {
maxHeight = getMaxHeight(currentRow);
maxCalcHeight = Math.max(maxCalcHeight, resizeElements(currentRow, maxHeight, options));
currentRow = curItem;
firstOffset = curItem.offset().top;
}
});
if(currentRow.length) {
maxHeight = getMaxHeight(currentRow);
maxCalcHeight = Math.max(maxCalcHeight, resizeElements(currentRow, maxHeight, options));
}
if(options.biggestHeight) {
boxes.css(options.useMinHeight && supportMinHeight ? 'minHeight' : 'height', maxCalcHeight);
}
}
// calculate max element height
function getMaxHeight(boxes) {
var maxHeight = 0;
boxes.each(function(){
maxHeight = Math.max(maxHeight, $(this).outerHeight());
});
return maxHeight;
}
// resize helper function
function resizeElements(boxes, parent, options) {
var calcHeight;
var parentHeight = typeof parent === 'number' ? parent : parent.height();
boxes.removeClass(options.leftEdgeClass).removeClass(options.rightEdgeClass).each(function(i){
var element = $(this);
var depthDiffHeight = 0;
var isBorderBox = element.css('boxSizing') === 'border-box' || element.css('-moz-box-sizing') === 'border-box' || element.css('-webkit-box-sizing') === 'border-box';
if(typeof parent !== 'number') {
element.parents().each(function(){
var tmpParent = $(this);
if(parent.is(this)) {
return false;
} else {
depthDiffHeight += tmpParent.outerHeight() - tmpParent.height();
}
});
}
calcHeight = parentHeight - depthDiffHeight;
calcHeight -= isBorderBox ? 0 : element.outerHeight() - element.height();
if(calcHeight > 0) {
element.css(options.useMinHeight && supportMinHeight ? 'minHeight' : 'height', calcHeight);
}
});
boxes.filter(':first').addClass(options.leftEdgeClass);
boxes.filter(':last').addClass(options.rightEdgeClass);
return calcHeight;
}
}(jQuery));
/*
* jQuery FontResize Event
*/
jQuery.onFontResize = (function($) {
$(function() {
var randomID = 'font-resize-frame-' + Math.floor(Math.random() * 1000);
var resizeFrame = $('