var isPublic = location.pathname.indexOf('/LEAP') == -1;
// page init
$(document).ready(function(){
if(isPublic){jcf.customForms.replaceAll();}
initInputs();
FontResize.init();
//functions only applicable on large screens
if($(window).width() > 980) {
initTouchNav();
initDropDown();
}
if($(window).width() > 615) {
initSameHeight();
}
$('.menuToggle').click(function(){
if($(this).hasClass('active')) {
$('#nav').removeClass('active');
$(this).removeClass('active');
} else {
$('#nav').addClass('active');
$(this).addClass('active');
}
});
//main gallery mobile adjustments
$('.mainGallery').parents('.LEAP3_PictureGallery').addClass('galleryPage');
$('.image.thumb').parents('tr').addClass('thumbRow');
});
//newsleter Subscribe function;
function submitContactForm(token) {
var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var email = jQuery('#contact_email').val();
var name = jQuery('#contact_name').val();
if(!filter.test(email)){
alert('Please enter your email address.');
} else if(!name.length) {
alert('Please tell us your name.');
} else {
var eparts = name.split(' ');
var fname = eparts.shift();
jQuery('#sidebar_contact_form input[name="reqFieldFirstName"]').val(fname);
if(eparts.length){
jQuery('#sidebar_contact_form input[name="reqFieldLastName"]').val(eparts.join(' '));
} else {
jQuery('#sidebar_contact_form input[name="reqFieldLastName"]').val(fname);
}
document.getElementById("sidebar_contact_form").submit();
}
return false;
}
// scroll gallery init
function initCarousel() {
jQuery('.carousel').scrollGallery({
mask: '.mask',
slider: '.slideset',
slides: '.slide',
btnPrev: 'a.btn-prev',
btnNext: 'a.btn-next',
pagerLinks: '.pagination li',
stretchSlideToMask: true,
maskAutoSize: true,
autoRotation: true,
switchTime: 5000,
animSpeed: 500,
step: 1
});
}
// clear inputs on focus
function initInputs() {
PlaceholderInput.replaceByOptions({
// filter options
clearInputs: isPublic,
clearTextareas: isPublic,
clearPasswords: isPublic,
skipClass: 'default',
// input options
wrapWithElement: false,
showUntilTyping: false,
getParentByClass: false,
placeholderAttr: 'value'
});
}
// align blocks height
function initSameHeight() {
jQuery('.blocks').sameHeight({
elements: '.block-article, .block-gallery, .contact-block',
multiLine: true
});
}
// animated navigation init
function initDropDown() {
var isWinPhoneDevice = navigator.msPointerEnabled && /MSIE 10.*Touch/.test(navigator.userAgent);
jQuery('#nav').animDropdown({
dropClass: 'active',
items: 'li',
drop: '>ul',
animSpeed: !jQuery.support.opacity ? 0 : 400,
effect: 'fade'
});
}
// handle dropdowns on mobile devices
function initTouchNav() {
lib.each(lib.queryElementsBySelector('#nav'), function(){
new TouchNav({
navBlock: this
});
});
}
/*
* jQuery Dropdown plugin
*/
;(function($){
$.fn.animDropdown = function(o){
// default options
var options = $.extend({
hoverClass:'hover',
dropClass:'drop-active',
items: 'li',
drop: '>ul',
delay: 100,
animSpeed: 300,
effect: 'fade'
},o);
return this.each(function(){
// options
var nav = $(this),
items = nav.find(options.items);
items.addClass(options.hoverClass).each(function(){
var item = $(this), delayTimer;
var drop = item.find(options.drop);
item.data('drop', drop);
if(drop.length) {
dropdownEffects[options.effect].prepare({item:item,drop:drop});
}
item.bind(window.TouchNav && TouchNav.isActiveOn(this) ? 'itemhover' : 'mouseenter', function(){
hideAllDropdowns(item);
item.addClass(options.hoverClass);
clearTimeout(delayTimer);
delayTimer = setTimeout(function(){
if(drop.length && item.hasClass(options.hoverClass)) {
item.addClass(options.dropClass);
dropdownEffects[options.effect].animate({drop:drop, state:true, speed:options.animSpeed, complete:function(){
// callback
}});
}
}, options.delay);
item.data('timer', delayTimer);
}).bind(window.TouchNav && TouchNav.isActiveOn(this) ? 'itemleave' : 'mouseleave', function(){
if(!item.hasClass(options.dropClass)) {
item.removeClass(options.hoverClass);
}
clearTimeout(delayTimer);
delayTimer = setTimeout(function(){
if(drop.length && item.hasClass(options.dropClass)) {
dropdownEffects[options.effect].animate({drop:drop, state:false, speed:options.animSpeed, complete:function(){
// callback
item.removeClass(options.hoverClass);
item.removeClass(options.dropClass);
}});
}
}, options.delay);
item.data('timer', delayTimer);
});
});
// hide dropdowns
items.removeClass(options.hoverClass);
if(dropdownEffects[options.effect].postProcess) {
items.each(function(){
dropdownEffects[options.effect].postProcess({item: $(this)});
});
}
// hide current level dropdowns
function hideAllDropdowns(except) {
var siblings = except.siblings();
siblings.removeClass(options.hoverClass).each(function(){
var item = $(this);
clearTimeout(item.data('timer'));
});
siblings.filter('.' + options.dropClass).each(function(){
var item = jQuery(this).removeClass(options.dropClass);
if(item.data('drop').length) {
dropdownEffects[options.effect].animate({drop:item.data('drop'), state:false, speed:options.animSpeed});
}
});
}
});
};
// dropdown effects
var dropdownEffects = {
fade: {
prepare: function(o) {
o.drop.css({opacity:0,display:'none'});
},
animate: function(o) {
o.drop.stop().show().animate({opacity: o.state ? 1 : 0},{duration: o.speed || 0, complete: function(){
if(o.state) {
o.drop.css({opacity:''});
} else {
o.drop.css({opacity:0,display:'none'});
}
if(typeof o.complete === 'function') {
o.complete.call(o.drop);
}
}});
}
},
slide: {
prepare: function(o) {
var elementWrap = o.drop.wrap('
').show().parent();
var elementHeight = o.drop.outerHeight(true);
var elementWidth = o.drop.outerWidth(true);
var elementPos = o.drop.position();
elementWrap.css({
height:elementHeight,
width: elementWidth,
position:'absolute',
overflow:'hidden',
top: elementPos.top,
left:elementPos.left
});
o.drop.css({
position:'static',
display:'block',
top: 'auto',
left: 'auto'
});
o.drop.data('height', elementHeight).data('wrap', elementWrap).css({marginTop: -elementHeight});
},
animate: function(o) {
o.drop.data('wrap').show().css({overflow:'hidden'});
o.drop.stop().animate({marginTop: o.state ? 0 : -o.drop.data('height')},{duration: o.speed || 0, complete: function(){
if(o.state) {
o.drop.css({marginTop:''});
o.drop.data('wrap').css({overflow:''});
} else {
o.drop.data('wrap').css({display:'none'});
}
if(typeof o.complete === 'function') {
o.complete.call(o.drop);
}
}});
},
postProcess: function(o) {
if(o.item.data('drop').length) {
o.item.data('drop').data('wrap').css({display:'none'});
}
}
}
};
}(jQuery));
// navigation accesibility module
function TouchNav(opt) {
this.options = {
hoverClass: 'hover',
menuItems: 'li',
menuOpener: 'a',
menuDrop: 'ul',
navBlock: null
};
for(var p in opt) {
if(opt.hasOwnProperty(p)) {
this.options[p] = opt[p];
}
}
this.init();
}
TouchNav.isActiveOn = function(elem) {
return elem && elem.touchNavActive;
};
TouchNav.prototype = {
init: function() {
if(typeof this.options.navBlock === 'string') {
this.menu = document.getElementById(this.options.navBlock);
} else if(typeof this.options.navBlock === 'object') {
this.menu = this.options.navBlock;
}
if(this.menu) {
this.addEvents();
}
},
addEvents: function() {
// attach event handlers
var self = this;
this.menuItems = lib.queryElementsBySelector(this.options.menuItems, this.menu);
for(var i = 0; i < this.menuItems.length; i++) {
(function(i){
var item = self.menuItems[i],
currentDrop = lib.queryElementsBySelector(self.options.menuDrop, item)[0],
currentOpener = lib.queryElementsBySelector(self.options.menuOpener, item)[0];
// only for touch input devices
if( (self.isTouchDevice || navigator.msPointerEnabled) && currentDrop && currentOpener) {
lib.event.add(currentOpener, 'click', lib.bind(self.clickHandler, self));
lib.event.add(currentOpener, navigator.msPointerEnabled ? 'MSPointerDown' : 'touchstart', function(e){
if(navigator.msPointerEnabled && e.pointerType !== e.MSPOINTER_TYPE_TOUCH) {
self.preventCurrentClick = false;
return;
}
self.touchFlag = true;
self.currentItem = item;
self.currentLink = currentOpener;
self.pressHandler.apply(self, arguments);
});
}
// for desktop computers and touch devices
lib.event.add(item, 'mouseover', function(){
if(!self.touchFlag) {
self.currentItem = item;
self.mouseoverHandler();
}
});
lib.event.add(item, 'mouseout', function(){
if(!self.touchFlag) {
self.currentItem = item;
self.mouseoutHandler();
}
});
item.touchNavActive = true;
})(i);
}
// hide dropdowns when clicking outside navigation
if(this.isTouchDevice || navigator.msPointerEnabled) {
lib.event.add(document, navigator.msPointerEnabled ? 'MSPointerDown' : 'touchstart', lib.bind(this.clickOutsideHandler, this));
}
},
mouseoverHandler: function() {
lib.addClass(this.currentItem, this.options.hoverClass);
jQuery(this.currentItem).trigger('itemhover');
},
mouseoutHandler: function() {
lib.removeClass(this.currentItem, this.options.hoverClass);
jQuery(this.currentItem).trigger('itemleave');
},
hideActiveDropdown: function() {
for(var i = 0; i < this.menuItems.length; i++) {
if(lib.hasClass(this.menuItems[i], this.options.hoverClass)) {
lib.removeClass(this.menuItems[i], this.options.hoverClass);
jQuery(this.menuItems[i]).trigger('itemleave');
}
}
this.activeParent = null;
},
pressHandler: function(e) {
// hide previous drop (if active)
if(this.currentItem !== this.activeParent) {
if(this.activeParent && this.currentItem.parentNode === this.activeParent.parentNode) {
lib.removeClass(this.activeParent, this.options.hoverClass);
} else if(!this.isParent(this.activeParent, this.currentLink)) {
this.hideActiveDropdown();
}
}
// handle current drop
this.activeParent = this.currentItem;
if(lib.hasClass(this.currentItem, this.options.hoverClass)) {
this.preventCurrentClick = false;
} else {
e.preventDefault();
this.preventCurrentClick = true;
lib.addClass(this.currentItem, this.options.hoverClass);
jQuery(this.currentItem).trigger('itemhover');
}
},
clickHandler: function(e) {
// prevent first click on link
if(this.preventCurrentClick || typeof this.preventCurrentClick === 'undefined') {
e.preventDefault();
}
},
clickOutsideHandler: function(event) {
if(navigator.msPointerEnabled && event.pointerType !== event.MSPOINTER_TYPE_TOUCH) return;
var e = event.changedTouches ? event.changedTouches[0] : event;
if(this.activeParent && !this.isParent(this.menu, e.target)) {
this.hideActiveDropdown();
this.touchFlag = false;
}
},
isParent: function(parent, child) {
while(child.parentNode) {
if(child.parentNode == parent) {
return true;
}
child = child.parentNode;
}
return false;
},
isTouchDevice: (function() {
try {
return (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) || navigator.userAgent.indexOf('IEMobile') != -1;
} catch (e) {
return false;
}
}())
};
/*
* jQuery Carousel plugin
*/
;(function($){
function ScrollGallery(options) {
this.options = $.extend({
mask: 'div.mask',
slider: '>*',
slides: '>*',
activeClass:'active',
disabledClass:'disabled',
btnPrev: 'a.btn-prev',
btnNext: 'a.btn-next',
generatePagination: false,
pagerList: '
',
pagerListItem: ' ',
pagerListItemText: 'a',
pagerLinks: '.pagination li',
currentNumber: 'span.current-num',
totalNumber: 'span.total-num',
btnPlay: '.btn-play',
btnPause: '.btn-pause',
btnPlayPause: '.btn-play-pause',
galleryReadyClass: 'gallery-js-ready',
autorotationActiveClass: 'autorotation-active',
autorotationDisabledClass: 'autorotation-disabled',
stretchSlideToMask: false,
circularRotation: true,
disableWhileAnimating: false,
autoRotation: false,
pauseOnHover: isTouchDevice ? false : true,
maskAutoSize: false,
switchTime: 4000,
animSpeed: 600,
event:'click',
swipeGap: false,
swipeThreshold: 15,
handleTouch: true,
vertical: false,
useTranslate3D: false,
step: false
}, options);
this.init();
}
ScrollGallery.prototype = {
init: function() {
if(this.options.holder) {
this.findElements();
this.attachEvents();
this.refreshPosition();
this.refreshState(true);
this.resumeRotation();
this.makeCallback('onInit', this);
}
},
findElements: function() {
// define dimensions proporties
this.fullSizeFunction = this.options.vertical ? 'outerHeight' : 'outerWidth';
this.innerSizeFunction = this.options.vertical ? 'height' : 'width';
this.slideSizeFunction = 'outerHeight';
this.maskSizeProperty = 'height';
this.animProperty = this.options.vertical ? 'marginTop' : 'marginLeft';
this.swipeProperties = this.options.vertical ? ['up', 'down'] : ['left', 'right'];
// control elements
this.gallery = $(this.options.holder).addClass(this.options.galleryReadyClass);
this.mask = this.gallery.find(this.options.mask);
this.slider = this.mask.find(this.options.slider);
this.slides = this.slider.find(this.options.slides);
this.btnPrev = this.gallery.find(this.options.btnPrev);
this.btnNext = this.gallery.find(this.options.btnNext);
this.currentStep = 0; this.stepsCount = 0;
// get start index
if(this.options.step === false) {
var activeSlide = this.slides.filter('.'+this.options.activeClass);
if(activeSlide.length) {
this.currentStep = this.slides.index(activeSlide);
}
}
// calculate offsets
this.calculateOffsets();
// create gallery pagination
if(typeof this.options.generatePagination === 'string') {
this.pagerLinks = $();
this.buildPagination();
} else {
this.pagerLinks = this.gallery.find(this.options.pagerLinks);
this.attachPaginationEvents();
}
// autorotation control buttons
this.btnPlay = this.gallery.find(this.options.btnPlay);
this.btnPause = this.gallery.find(this.options.btnPause);
this.btnPlayPause = this.gallery.find(this.options.btnPlayPause);
// misc elements
this.curNum = this.gallery.find(this.options.currentNumber);
this.allNum = this.gallery.find(this.options.totalNumber);
},
attachEvents: function() {
// bind handlers scope
var self = this;
this.bindHandlers(['onWindowResize']);
$(window).bind('load resize orientationchange', this.onWindowResize);
// previous and next button handlers
if(this.btnPrev.length) {
this.prevSlideHandler = function(e) {
e.preventDefault();
self.prevSlide();
};
this.btnPrev.bind(this.options.event, this.prevSlideHandler);
}
if(this.btnNext.length) {
this.nextSlideHandler = function(e) {
e.preventDefault();
self.nextSlide();
};
this.btnNext.bind(this.options.event, this.nextSlideHandler);
}
// pause on hover handling
if(this.options.pauseOnHover && !isTouchDevice) {
this.hoverHandler = function() {
if(self.options.autoRotation) {
self.galleryHover = true;
self.pauseRotation();
}
};
this.leaveHandler = function() {
if(self.options.autoRotation) {
self.galleryHover = false;
self.resumeRotation();
}
};
this.gallery.bind({mouseenter: this.hoverHandler, mouseleave: this.leaveHandler});
}
// autorotation buttons handler
if(this.btnPlay.length) {
this.btnPlayHandler = function(e) {
e.preventDefault();
self.startRotation();
};
this.btnPlay.bind(this.options.event, this.btnPlayHandler);
}
if(this.btnPause.length) {
this.btnPauseHandler = function(e) {
e.preventDefault();
self.stopRotation();
};
this.btnPause.bind(this.options.event, this.btnPauseHandler);
}
if(this.btnPlayPause.length) {
this.btnPlayPauseHandler = function(e) {
e.preventDefault();
if(!self.gallery.hasClass(self.options.autorotationActiveClass)) {
self.startRotation();
} else {
self.stopRotation();
}
};
this.btnPlayPause.bind(this.options.event, this.btnPlayPauseHandler);
}
// swipe event handling
if(isTouchDevice) {
// enable hardware acceleration
if(this.options.useTranslate3D) {
this.slider.css({'-webkit-transform': 'translate3d(0px, 0px, 0px)'});
}
// swipe gestures
if(this.options.handleTouch && jQuery.fn.hammer) {
this.mask.hammer({
drag_block_horizontal: this.options.vertical ? false : true,
drag_block_vertical: this.options.vertical ? true : false,
drag_min_distance: 1
}).on(this.options.vertical ? 'touch release dragup dragdown swipeup swipedown' : 'touch release dragleft dragright swipeleft swiperight', function(ev){
switch(ev.type) {
case 'touch':
if(!self.galleryAnimating){
self.originalOffset = parseInt(self.slider.stop(true, false).css(self.animProperty), 10);
}
break;
case (self.options.vertical? 'dragup' : 'dragright'):
case (self.options.vertical? 'dragdown' : 'dragleft'):
if(!self.galleryAnimating){
if(ev.gesture.direction === self.swipeProperties[0] || ev.gesture.direction === self.swipeProperties[1]){
var tmpOffset = self.originalOffset + ev.gesture[self.options.vertical ? 'deltaY' : 'deltaX'];
tmpOffset = Math.max(Math.min(0, tmpOffset), self.maxOffset)
self.tmpProps = {};
self.tmpProps[self.animProperty] = tmpOffset;
self.slider.css(self.tmpProps);
ev.gesture.preventDefault();
};
};
break;
case (self.options.vertical ? 'swipeup' : 'swipeleft'):
if(!self.galleryAnimating){
if(ev.gesture.direction === self.swipeProperties[0]) self.nextSlide();
}
ev.gesture.stopDetect();
break;
case (self.options.vertical ? 'swipedown' : 'swiperight'):
if(!self.galleryAnimating){
if(ev.gesture.direction === self.swipeProperties[1]) self.prevSlide();
}
ev.gesture.stopDetect();
break;
case 'release':
if(!self.galleryAnimating){
if(Math.abs(ev.gesture[self.options.vertical ? 'deltaY' : 'deltaX']) > self.options.swipeThreshold) {
if(self.options.vertical){
if(ev.gesture.direction == 'down') self.prevSlide(); else if(ev.gesture.direction == 'up') self.nextSlide();
}
else {
if(ev.gesture.direction == 'right') self.prevSlide(); else if(ev.gesture.direction == 'left') self.nextSlide();
}
}
else {
self.switchSlide();
}
}
break;
}
});
}
}
},
onWindowResize: function() {
if(!this.galleryAnimating) {
this.calculateOffsets();
this.refreshPosition();
this.buildPagination();
this.refreshState();
this.resizeQueue = false;
} else {
this.resizeQueue = true;
}
},
refreshPosition: function() {
this.currentStep = Math.min(this.currentStep, this.stepsCount - 1);
this.tmpProps = {};
this.tmpProps[this.animProperty] = this.getStepOffset();
this.slider.stop().css(this.tmpProps);
},
calculateOffsets: function() {
var self = this, tmpOffset, tmpStep;
if(this.options.stretchSlideToMask) {
var tmpObj = {};
tmpObj[this.innerSizeFunction] = this.mask[this.innerSizeFunction]();
this.slides.css(tmpObj);
}
this.maskSize = this.mask[this.innerSizeFunction]();
this.sumSize = this.getSumSize();
this.maxOffset = this.maskSize - this.sumSize;
// vertical gallery with single size step custom behavior
if(this.options.vertical && this.options.maskAutoSize) {
this.options.step = 1;
this.stepsCount = this.slides.length;
this.stepOffsets = [0];
tmpOffset = 0;
for(var i = 0; i < this.slides.length; i++) {
tmpOffset -= $(this.slides[i])[this.fullSizeFunction](true);
this.stepOffsets.push(tmpOffset);
}
this.maxOffset = tmpOffset;
return;
}
// scroll by slide size
if(typeof this.options.step === 'number' && this.options.step > 0) {
this.slideDimensions = [];
this.slides.each($.proxy(function(ind, obj){
self.slideDimensions.push( $(obj)[self.fullSizeFunction](true) );
},this));
// calculate steps count
this.stepOffsets = [0];
this.stepsCount = 1;
tmpOffset = tmpStep = 0;
while(tmpOffset > this.maxOffset) {
tmpOffset -= this.getSlideSize(tmpStep, tmpStep + this.options.step);
tmpStep += this.options.step;
this.stepOffsets.push(Math.max(tmpOffset, this.maxOffset));
this.stepsCount++;
}
}
// scroll by mask size
else {
// define step size
this.stepSize = this.maskSize;
// calculate steps count
this.stepsCount = 1;
tmpOffset = 0;
while(tmpOffset > this.maxOffset) {
tmpOffset -= this.stepSize;
this.stepsCount++;
}
}
},
getSumSize: function() {
var sum = 0;
this.slides.each($.proxy(function(ind, obj){
sum += $(obj)[this.fullSizeFunction](true);
},this));
this.slider.css(this.innerSizeFunction, sum);
return sum;
},
getStepOffset: function(step) {
step = step || this.currentStep;
if(typeof this.options.step === 'number') {
return this.stepOffsets[this.currentStep];
} else {
return Math.max(-this.currentStep * this.stepSize, this.maxOffset);
}
},
getSlideSize: function(i1, i2) {
var sum = 0;
for(var i = i1; i < Math.min(i2, this.slideDimensions.length); i++) {
sum += this.slideDimensions[i];
}
return sum;
},
buildPagination: function() {
if(typeof this.options.generatePagination === 'string') {
if(!this.pagerHolder) {
this.pagerHolder = this.gallery.find(this.options.generatePagination);
}
if(this.pagerHolder.length && this.oldStepsCount != this.stepsCount) {
this.oldStepsCount = this.stepsCount;
this.pagerHolder.empty();
this.pagerList = $(this.options.pagerList).appendTo(this.pagerHolder);
for(var i = 0; i < this.stepsCount; i++) {
$(this.options.pagerListItem).appendTo(this.pagerList).find(this.options.pagerListItemText).text(i+1);
}
this.pagerLinks = this.pagerList.children();
this.attachPaginationEvents();
}
}
},
attachPaginationEvents: function() {
var self = this;
this.pagerLinksHandler = function(e) {
e.preventDefault();
self.numSlide(self.pagerLinks.index(e.currentTarget));
};
this.pagerLinks.bind(this.options.event, this.pagerLinksHandler);
},
prevSlide: function() {
if(!(this.options.disableWhileAnimating && this.galleryAnimating)) {
if(this.currentStep > 0) {
this.currentStep--;
this.switchSlide();
} else if(this.options.circularRotation) {
this.currentStep = this.stepsCount - 1;
this.switchSlide();
}
}
},
nextSlide: function(fromAutoRotation) {
if(!(this.options.disableWhileAnimating && this.galleryAnimating)) {
if(this.currentStep < this.stepsCount - 1) {
this.currentStep++;
this.switchSlide();
} else if(this.options.circularRotation || fromAutoRotation === true) {
this.currentStep = 0;
this.switchSlide();
}
}
},
numSlide: function(c) {
if(this.currentStep != c) {
this.currentStep = c;
this.switchSlide();
}
},
switchSlide: function() {
var self = this;
this.galleryAnimating = true;
this.tmpProps = {};
this.tmpProps[this.animProperty] = this.getStepOffset();
this.slider.stop().animate(this.tmpProps, {duration: this.options.animSpeed, complete: function(){
// animation complete
self.galleryAnimating = false;
if(self.resizeQueue) {
self.onWindowResize();
}
// onchange callback
self.makeCallback('onChange', self);
self.autoRotate();
}});
this.refreshState();
// onchange callback
this.makeCallback('onBeforeChange', this);
},
refreshState: function(initial) {
if(this.options.step === 1 || this.stepsCount === this.slides.length) {
this.slides.removeClass(this.options.activeClass).eq(this.currentStep).addClass(this.options.activeClass);
}
this.pagerLinks.removeClass(this.options.activeClass).eq(this.currentStep).addClass(this.options.activeClass);
this.curNum.html(this.currentStep+1);
this.allNum.html(this.stepsCount);
// initial refresh
if(this.options.maskAutoSize && typeof this.options.step === 'number') {
this.tmpProps = {};
this.tmpProps[this.maskSizeProperty] = this.slides.eq(Math.min(this.currentStep,this.slides.length-1))[this.slideSizeFunction](true);
this.mask.stop()[initial ? 'css' : 'animate'](this.tmpProps);
}
// disabled state
if(!this.options.circularRotation) {
this.btnPrev.add(this.btnNext).removeClass(this.options.disabledClass);
if(this.currentStep === 0) this.btnPrev.addClass(this.options.disabledClass);
if(this.currentStep === this.stepsCount - 1) this.btnNext.addClass(this.options.disabledClass);
}
},
startRotation: function() {
this.options.autoRotation = true;
this.galleryHover = false;
this.autoRotationStopped = false;
this.resumeRotation();
},
stopRotation: function() {
this.galleryHover = true;
this.autoRotationStopped = true;
this.pauseRotation();
},
pauseRotation: function() {
this.gallery.addClass(this.options.autorotationDisabledClass);
this.gallery.removeClass(this.options.autorotationActiveClass);
clearTimeout(this.timer);
},
resumeRotation: function() {
if(!this.autoRotationStopped) {
this.gallery.addClass(this.options.autorotationActiveClass);
this.gallery.removeClass(this.options.autorotationDisabledClass);
this.autoRotate();
}
},
autoRotate: function() {
var self = this;
clearTimeout(this.timer);
if(this.options.autoRotation && !this.galleryHover && !this.autoRotationStopped) {
this.timer = setTimeout(function(){
self.nextSlide(true);
}, this.options.switchTime);
} else {
this.pauseRotation();
}
},
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);
}
},
destroy: function() {
// destroy handler
$(window).unbind('load resize orientationchange', this.onWindowResize);
this.btnPrev.unbind(this.options.event, this.prevSlideHandler);
this.btnNext.unbind(this.options.event, this.nextSlideHandler);
this.pagerLinks.unbind(this.options.event, this.pagerLinksHandler);
this.gallery.unbind({mouseenter: this.hoverHandler, mouseleave: this.leaveHandler});
// autorotation buttons handlers
this.stopRotation();
this.btnPlay.unbind(this.options.event, this.btnPlayHandler);
this.btnPause.unbind(this.options.event, this.btnPauseHandler);
this.btnPlayPause.unbind(this.options.event, this.btnPlayPauseHandler);
// destroy swipe handler
if(this.options.handleTouch && $.fn.hammer) {
this.mask.hammer().off('touch release dragup dragdown dragleft dragright swipeup swipedown swipeleft swiperight');
}
// remove inline styles, classes and pagination
var unneededClasses = [this.options.galleryReadyClass, this.options.autorotationActiveClass, this.options.autorotationDisabledClass];
this.gallery.removeClass(unneededClasses.join(' '));
this.slider.add(this.slides).removeAttr('style');
if(typeof this.options.generatePagination === 'string') {
this.pagerHolder.empty();
}
}
};
// detect device type
var isTouchDevice = /MSIE 10.*Touch/.test(navigator.userAgent) || ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;
// jquery plugin
$.fn.scrollGallery = function(opt){
return this.each(function(){
$(this).data('ScrollGallery', new ScrollGallery($.extend(opt,{holder:this})));
});
};
}(jQuery));
/*
* jQuery SameHeight plugin
*/
;(function($){
$.fn.sameHeight = function(opt) {
var options = $.extend({
skipClass: 'same-height-ignore',
leftEdgeClass: 'same-height-left',
rightEdgeClass: 'same-height-right',
elements: '>*',
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';
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 = $('