Slides
Slides
_____ _ _ _ _____
/ ___/| (*) | | | |/ ___/ v 4.1
| (___ | |_ __| | ___ ____ | | (___
\___ \| | |/ _` |/ _ / __/ _ | |\___ \
____) | | | (_| | __\__ \ | |__| |____) |
/_____/|_|_|\__,_|\___/___/ \____//_____/
This file contains scripts required for the proper functionality and
display
of your Slides Project. It also requires plugins.js and jquery-3.3.1 to
run this script properly.
https://designmodo.com/slides/
*/
window.inAction = 1;
window.allowSlide = 1;
window.blockScroll = 1;
window.effectOffset = 500;
window.effectSpeed = 1000;
window.slideSpeed = 1000;
window.cleanupDelay = 1400;
window.horizontalMode = 0;
window.sidebarShown = 0;
window.loadingProgress = 0;
window.smoothScroll = 0;
window.scrollSpeed = 0.5;
window.preload = 1;
window.setHashLink = 1;
window.hideSidebarOnBodyClick = 1;
window.collectScrolls = 0;
window.sliderStatus = 0;
window.minScrollToSlide = 500;
window.minSwipeToSlide = 4;
window.enableMobileZoom = 0;
window.hideOnScrollSensitivity = 100;
window.allowParallaxOnMobile = 1;
window.hidePopupOnBodyClick = 1;
//Detect mode
window.isScroll = $body.hasClass('scroll');
window.isSimplifiedMobile = $body.hasClass('simplifiedMobile');
if (window.isScroll || window.isSimplifiedMobile && window.isMobile) {
$html.addClass('scrollable'); }
$html.addClass('page-ready');
//Set speed
if ($body.hasClass('fast')){
//fast
window.slideSpeed = 700;
window.cleanupDelay = 1200;
window.effectSpeed = 800;
window.scrollSpeed = 0.35;
window.effectOffset = 400;
} else if ($body.hasClass('slow')){
//slow
window.slideSpeed = 1400;
window.cleanupDelay = 2000;
window.effectSpeed = 1400;
window.effectOffset = 400;
window.scrollSpeed = .8;
window.effectOffset = 600;
}
//Horizonal Mode
if ($body.hasClass('horizontal')){
window.horizontalMode = 1;
}
//Preload
if ($body.hasClass('noPreload')){
window.preload = 0;
}
//Is it animated?
if ($body.hasClass('animated')){
window.isAnimated = "auto";
} else if ($body.hasClass('animateOnEvent')) {
window.isAnimated = "animateOnEvent";
if (window.isMobile) {
window.isAnimated = "auto";
$body.removeClass('animateOnEvent').addClass('animated');
}
}
if (!window.isAnimated) {
window.cleanupDelay = 0;
}
$('html,body').stop().clearQueue().animate({scrollTop:requestedElement.po
sition().top},window.effectSpeed);
} else {
$(window).on('load', function(){
$('html,body').stop().clearQueue().animate({scrollTop:requestedElement.po
sition().top},window.effectSpeed);
});
}
}
} else {
//slide mode
window.stage = $('.slide').index(requestedElement) + 1;
showSlide(window.stage);
}
}
}
}
updateHash();
window.images = imgs.length;
window.progressBar = $('.progress-bar');
//show progress
function updateProgressBar(){
//loading
var progress = window.loadingProgress/window.images;
// animate
window.progressBar.css('width',progress * 100 + "%");
if (window.loadingProgress == window.images) {
window.progressBar.addClass('loaded');
}
}
updateProgressBar();
}
//Initiate slide
showSlide(window.stage);
$('.grid.masonry').masonry({
itemSelector: 'li',
transitionDuration: '0.1s'
});
$('.grid.masonry').imagesLoaded().progress( function() {
$('.grid.masonry').masonry('layout');
});
if (!window.loaded) {
$(window).on('load', function(){
runTheCode();
});
}
function runTheCode(){
$html.addClass('page-loaded');
window.inAction = 0;
window.blockScroll = 0;
window.loaded = 1;
setTimeout(function(){
if (window.isScroll){
updateScroll();
updateNavigation();
} if (window.isMobile && window.isSimplifiedMobile){
$('.slide').addClass('selected animate active');
updateScroll();
updateNavigation();
} else {
showSlide(window.stage);
}
},500);
}
/***
* _____ _ _ _ _____ _
* / ____| (_) | | / ____| |
* | (___ | |_ __| | ___ | | | |__ __ _ _ __ __ _ ___
* \___ \| | |/ _` |/ _ \ | | | '_ \ / _` | '_ \ / _` |/ _ \
* ____) | | | (_| | __/ | |____| | | | (_| | | | | (_| | __/
* |_____/|_|_|\__,_|\___| \_____|_| |_|\__,_|_| |_|\__, |\___|
* __/ |
* Slide Appearance Manager |___/
*/
function showSlide(requested){
requested = parseInt(requested);
updateNavigation();
//cleanup
hideDropdown();
unzoomImage();
hideSidebar();
window.allowSlide = 1;
//reset
$body.removeClass('sidebarShown lastSlide firstSlide hidePanel-top
hidePanel-bottom');
$body.removeClassByPrefix("stage-").addClass('stage-
'+window.stage);
}
//white slide?
if ( newSlide.hasClass('whiteSlide') ){
$body.addClass('whiteSlide');
} else {
$body.removeClass('whiteSlide');
}
//set order
newSlide.prevAll('.slide').addClass('before').removeClass('after');
newSlide.nextAll('.slide').addClass('after').removeClass('before');
//set a trigger
$(window).trigger("slideChange", [parseInt(requested), newSlide]);
}
//set hash
if (window.setHashLink){
if (newSlide.attr('data-name') || newSlide.attr('id')) {
window.location.hash = (newSlide.attr('data-name')) ?
newSlide.attr('data-name') : newSlide.attr('id');
} else if
((window.location.toString().indexOf('#')>0)&&(location.protocol !==
"file:")&&(location.href.split('#')[0])){
if (history.pushState) {
window.history.pushState("", "", location.href.split('#')[0]);
} else {
window.location.hash = "";
}
}
}
if (window.loaded){
//wait for animation
window.blockScroll = 1;
setTimeout(function(){
if (currenSlideIndex !== requested){
currenSlide.removeClass('active animate');
}
setTimeout(function(){
newSlide.addClass('animate');
},window.slideSpeed - window.effectOffset);
clearTimeout(window.clearElementAnimation);
window.clearElementAnimation = setTimeout(function(){
$(".slide.selected [class*='ae-']").addClass('done');
}, window.slideSpeed + window.effectSpeed + window.cleanupDelay);
}
//end showSlide();
}
//Change slide
window.changeSlide = function(n){
if (n === "increase"){
if ((window.stage + 1) >= window.stages){
n = window.stages;
} else {
n = window.stage + 1;
}
} else if (n === "decrease"){
if ((window.stage - 1) < 1){
n = 1;
} else {
n = window.stage - 1;
}
}
$('html,body').stop().clearQueue().animate({scrollTop:finalPosition},1000
);
} else {
if ((n !== window.stage)&&( n <= window.stages)){
if (window.inAction !== 1){
window.inAction = 1;
window.stage = n;
var delay = 0;
if ($('.zoom-overlay-open').length > 0) {
unzoomImage();
delay = 550;
}
setTimeout(function(){
showSlide(window.stage);
setTimeout(function(){ window.inAction = 0; },
window.slideSpeed);
}, delay);
}
}
}
};
$('.nextSlide').on('click', function(){
window.changeSlide('increase');
});
$('.prevSlide').on('click', function(){
window.changeSlide('decrease');
});
$('.toFirstSlide').on('click', function(){
window.changeSlide(1);
if (history.pushState) {
window.history.pushState("", "", location.href.split('#')[0]);
} else {
window.location.hash = "";
}
hideSidebar();
});
$('.toLastSlide').on('click', function(){
window.changeSlide(window.stages);
if (history.pushState) {
window.history.pushState("", "", location.href.split('#')[0]);
} else {
window.location.hash = "";
}
hideSidebar();
});
$('[class*="toSlide-"]').on('click', function(){
var num = parseInt($(this).attr('class').split('toSlide-')[1].split('
')[0]);
window.changeSlide(num);
hideSidebar();
});
if (type) {
$('.zoom-img-wrap, .zoom-overlay').remove();
}
}
}
//set
$(window).on('resize load ready',function(){
//cleanup after image zoom
$('[data-action="zoom"]').removeAttr('style');
if ($('.zoom-overlay').length > 0){
unzoomImage('fast');
}
//common stuff
window.windowHeight = $(window).height();
window.windowWidth = $(window).width();
window.documentHeight = $(document).height();
});
/*** *
* | | |
* |
* _____ * _ _
* / ____| | | | |
* | (___ ___ _ __ ___ | | |
* \___ \ / __| '__/ _ \| | |
* ____) | (__| | | (_) | | |
* |_____/ \___|_| \___/|_|_|
*
* Scrolling
*/
var eventCount = 0,
eventCountStart;
//scroll mode
if (window.isScroll &&
((!window.sidebarShown)&&(!window.popupShown)&&(!window.blockScroll))) {
//smooth scroll
if (window.smoothScroll && !window.isMobile){
TweenLite.to(scrollObject, window.scrollSpeed, {
scrollTo : { y: finalScroll, autoKill:false },
ease: Power4.easeOut,
overwrite: "all"
});
} else {
if (!window.isWindows){
$currentSection.scrollTop(curSecScrolltop - energy);
}
}
}
//slide mode
if ( !window.isScroll && !(window.isMobile &&
window.isSimplifiedMobile)){
$body.addClass('hidePanel-bottom');
if
((!window.sidebarShown)&&(!window.popupShown)&&(!window.blockScroll)) {
if (window.smoothScroll){
//lock default scroll
event.preventDefault();
//smooth scroll
if (energy > 1500) { energy = 1500; }
if (energy < -1000) { energy = -1500; }
TweenLite.to($currentSection, 0.5, {
scrollTo : { y: curSecScrolltop - energy, autoKill:false },
ease: Power4.easeOut,
overwrite: 5
});
} else {
curSecScrolltop = (scrollDirection === "up") ?
curSecScrolltop - scrollsize : curSecScrolltop + scrollsize;
$currentSection.scrollTop(curSecScrolltop);
}
}
//end scroll oversized content
}
window.collectScrolls = 0;
//should we even..
if ((scrollDirection === "down" && window.stage !==
window.stages)||(scrollDirection === "up" && window.stage !== 1)){
//ok let's go
if (window.inAction !== 1){
if (scrollDirection === "down"){
window.changeSlide('increase');
} else {
window.changeSlide('decrease');
}
}
}
}
}
//end on mousewheel event
});
function updateScroll(){
//Hide dropdown
hideDropdownOnScrollDelay++;
if (hideDropdownOnScrollDelay >= 2){
hideDropdown();
hideDropdownOnScrollDelay = 0;
}
$('.slide').each(function(index, element) {
if (window.setStageClasses != 0) {
if (halfOnScreen && allowToSelect) {
//set order
$element.prevAll('.slide').addClass('before').removeClass('after');
$element.nextAll('.slide').addClass('after').removeClass('before');
$element.addClass('selected animate active').removeClass('after
before');
//set a trigger
$(window).trigger("slideChange", [window.stage, $element]);
if (window.isAnimated == "auto") {
//clearTimeout(window.clearElementAnimation);
window.clearElementAnimation = setTimeout(function(){
$element.find("[class*='ae-']").addClass('done');
}, window.effectSpeed + window.cleanupDelay);
}
updateNavigation();
}
if (!window.firstTimeTrigger){
window.firstTimeTrigger = 1;
$(window).trigger("slideChange", [window.stage, $element]);
}
} else {
$element.removeClass('selected');
}
}
//Parallax background
if ((scale > -1 && scale < 1) && !(window.allowParallaxOnMobile &&
window.isMobile)) {
if ($element.hasClass('parallax') || $element.find('.parallax-
element')){
$element.find('.parallax-element').each(function() {
var $el = $(this),
velocity = parseInt($el.data('parallax-velocity')) ?
parseInt($el.data('parallax-velocity')) : 50,
precentage = scale * velocity;
if (!window.preload) {
$("[class*='ae-']").each(function(i, element) {
var $ae = $(element);
if (isElementInView($ae)) {
$ae.addClass("do").one('webkitAnimationEnd oanimationend
msAnimationEnd animationend', function(){
$(this).removeClassByPrefix('ae-
').removeClass("do").addClass("done");
});
}
});
} else if (window.loaded){
$("[class*='ae-']").each(function(i, element) {
var $ae = $(element);
if (isElementInView($ae)) {
$ae.addClass("do").one('webkitAnimationEnd oanimationend
msAnimationEnd animationend', function(){
$(this).removeClassByPrefix('ae-
').removeClass("do").addClass("done");
});
}
});
}
}
}
function isElementInView(element) {
var pageTop = $(window).scrollTop(),
$element = $(element),
elementHeight = $element.height(),
pageBottom = pageTop + window.windowHeight,
elementTop = $element.offset().top,
elementBottom = elementTop + elementHeight;
/***
* _____
* / ____| (*)
* | (_____ ___ _ __ ___
* \___ \ \ /\ / / | '_ \ / _ \
* ____) \ V V /| | |_) | __/
* |_____/ \_/\_/ |_| .__/ \___|
* | |
* |_|
*
* Swipes for mobile devices
*/
$('.mobile .slides:not(.scroll):not(.simplifiedMobile),
.slides.desktopSwipe').swipe({
swipeStatus:function(event, phase, direction, distance){
window.allowSwipeUp = 1;
window.allowSwipeDown = 1;
if (window.sidebarShown){
$currentSection = $('.sidebar .content');
}
if (window.popupShown){
$currentSection = $('.popup .content');
}
//horizontal mode
if (window.horizontalMode){
next = "left";
prev = "right";
}
//lock slide
if ( !window.horizontalMode && ( currentSectionHeight >
windowHeight) ){
if (window.scrollTop + windowHeight < currentSectionHeight){
window.allowSwipeUp = 0;
}
if (window.scrollTop > 0) {
window.allowSwipeDown = 0;
}
}
$('.slides.desktopSwipe *').on('click',function(){
$(this).addClass('selectable');
});
/***
* _____ _
* | __ \ | |
* | |__) |_ _ _ __ ___| |___
* | ___/ _` | '_ \ / _ \ / __|
* | | | (_| | | | | __/ \__ \
* |_| \__,_|_| |_|\___|_|___/
*
* Responsive Panels
*/
$(desktop).addClass('hidden');
$(compact).removeClass('hidden');
} else {
$(desktop).removeClass('hidden');
$(compact).addClass('hidden');
var totalWidth = 0;
desktop.children().each(function(){
if ( $(this).outerWidth() > $(this).children().outerWidth()
){
totalWidth += Math.round($(this).outerWidth());
} else {
totalWidth += Math.round($(this).children().outerWidth());
}
});
});
});
}
if (window.isScroll || window.isSimplifiedMobile){
var lastScrollTop,
i = 0,
sensitivity = window.hideOnScrollSensitivity ?
window.hideOnScrollSensitivity : 100,
panelToHide = $('.panel.hideOnScroll');
/***
* _ __
* | |/ /
* | ' / ___ _ _ ___
* | < / _ \ | | / __|
* | . \ __/ |_| \__ \
* |_|\_\___|\__, |___/
* __/ |
* |___/
*
* Listen the Keys
*/
$(document).on("keydown",function(e){
var delta = 2.5,
scrollTime = 0.3,
scrollDistance = 50,
$currentSection = $('.slide.selected .content'),
scrollTop = $currentSection.scrollTop(),
finalScroll = scrollTop + parseInt(delta * scrollDistance);
if (window.window.disableKeyNavigation ||
e.target.nodeName.toLowerCase() == 'input' ||
e.target.nodeName.toLowerCase() == 'textarea') {
return;
}
/* [ ‚Üê ] */
if (e.keyCode === 37){
e.preventDefault();
if (window.horizontalMode){ window.changeSlide('decrease'); }
}
/* [ ‚Üë ] */
if (e.keyCode === 38){
if (!window.horizontalMode){
e.preventDefault();
window.changeSlide('decrease');
} else {
e.preventDefault();
TweenLite.to($currentSection, window.scrollSpeed, {
scrollTo : { y: finalScroll, autoKill:true },
ease: Power4.easeOut,
overwrite: 5
});
}
}
/* [ ‚Üí ] */
if (e.keyCode === 39){
if (window.horizontalMode){
e.preventDefault();
window.changeSlide('increase');
}
}
/* [ ‚Üì ] */
if (e.keyCode === 40){
if (!window.horizontalMode) {
e.preventDefault();
window.changeSlide('increase');
} else {
e.preventDefault();
TweenLite.to($currentSection, window.scrollSpeed, {
scrollTo : { y: finalScroll, autoKill:true },
ease: Power4.easeOut,
overwrite: 5
});
}
}
/* [ esc ] */
if (e.keyCode === 27){
hideSidebar();
hideDropdown();
hidePopup();
unzoomImage();
}
});
/***
* _ _ _
* | \ | | (*) | | (*) *
* | \| | __ ___ ___ __ _ __ _| |_ _ ___ _ __ *
* | . ` |/ _` \ \ / | |/ _` |/ _` | __| |/ _ \| '_ \ (*) [Tooltip]
* | |\ | (_| |\ V /| | (_| | (_| | |_| | (_) | | | | *
* |_| \_|\__,_| \_/ |_|\__, |\__,_|\__|_|\___/|_| |_| *
* __/ |
* /___/
*
* Generate Navigation Dots and Tootlips
*/
if ($(navigation).length > 0) {
if ($(navigation).is(':empty')) {
$(navigation).each(function(index, element) {
for (var i = 1; i <= slidesNumber; i++){
// Add Tooltips
var title = $('.slide:not(.exclude):eq('+(i -
1)+')').data('title');
if (title === undefined) {
$(element).append('<li></li>');
} else {
$(element).append('<li data-title="'+title+'"></li>');
}
}
});
}
//Navigation clicks
$('.navigation li').on("click touchend", function(){
var thisIndes = $(this).index(),
realIndex =
$('.slide:not(.exclude):eq('+thisIndes+')').index('.slide');
$(this).blur();
window.changeSlide(realIndex + 1);
});
if (!$('.side').hasClass('compact')){
//Collapse sidemenu to compact
$(window).on('load resize ready',function(){
var containerHeight = window.windowHeight - 140,
container = $('.side').removeClass('compact').find('ul'),
totalWidth = 0;
$(container).children().each(function(){
totalWidth += Math.round($(this).outerHeight(true));
});
e.preventDefault();
$('html,body').stop().clearQueue().animate({scrollTop:target.position().t
op},1000);
}
if (window.setHashLink){
window.location.hash = hashLink;
}
} else {
window.stage = $('.slide').index(requestedElement) + 1;
showSlide(window.stage);
}
hideSidebar();
}
});
//Update Navigation
function updateNavigation(){
setTimeout(function(){
if ( $(navigation).length > 0 ){
$(navigation).each(function(index, element) {
$(element).find('li.selected').removeClass('selected');
$('.sidebarTrigger[data-sidebar-id]').on('click', function(){
});
window.showSidebar = function(id){
var sidebarID = id,
element = $('.sidebar[data-sidebar-id="' + sidebarID + '"]'),
isAnimated = $(element).hasClass('animated');
if (!window.sidebarShown){
if (element.length > 0) {
window.sidebarShown = 1;
window.allowSlide = 0;
$(element).removeClass('animate active').addClass('visible');
$html.addClass('sidebarShown sidebar_' + sidebarID);
$(element).find('.content').scrollTop(0);
if (isAnimated){
clearTimeout(window.removeAnimationTimeout);
setTimeout(function(){
$(element).addClass('animate active');
},100);
}
}
} else {
hideSidebar();
}
//clean up
hideDropdown();
function hideSidebar(){
if (window.sidebarShown){
$html.removeClass('sidebarShown').removeClassByPrefix('sidebar_');
var $sidebar = $('.sidebar.visible');
$sidebar.removeClass('visible');
window.removeAnimationTimeout = setTimeout(function(){
$sidebar.removeClass('animate
active').find('.done').removeClass('done');
},500);
window.sidebarShown = 0;
window.allowSlide = 1;
}
}
/***
* _____ __
* | __ \ _ _ _ __ | |_
* | |__) ___ _ __ | | | | '_ \ |__| |
* | ___/ _ \| '_ \| | | | |_) | |__|
* | | | (_) | |_) \__,_| .__/
* |_| \___/| .__/ | |
* | | |_|
* PopUp |_|
*/
$('.popupTrigger[data-popup-id]').on('click', function(){
var popupID = $(this).data('popup-id');
window.showPopup(popupID);
});
window.showPopup = function(id){
var popupID = id,
element = $('.popup[data-popup-id="' + popupID + '"]'),
isAnimated = element.hasClass('animated');
if (element.length > 0) {
hideSidebar();
$(element).addClass('visible');
//set a trigger
$(window).trigger('popupShown');
if (isAnimated){
setTimeout(function(){
$(element).addClass('animate active');
clearTimeout(window.clearPopupElementAnimation);
window.clearPopupElementAnimation = setTimeout(function(){
$(element).find("[class*='ae-']").addClass('done');
}, window.effectSpeed + window.cleanupDelay);
},100);
}
//Autoplay Iframe
if ($(element).hasClass('autoplay')){
var $element = $(element),
iframe = $element.find('iframe'),
HTML5video = $element.find('video');
if ( iframe.length > 0 ) {
var iframeSrc = $(iframe).attr('src'),
symbol = (iframeSrc.indexOf('?') > -1) ? "&" : "?";
//clean up
hideDropdown();
}
function hidePopup(popupID) {
popupID = typeof popupID !== 'undefined' ? popupID : false;
if ( $.isArray(window.popupShown) ){
$(element).attr('src',
$(element).attr('src').replace(symbol+'autoplay=1',''));
});
}
//stop videos
if (video.length > 0) {
$(video).each(function(n, element){
$(element)[0].pause();
$(element)[0].currentTime = 0;
});
}
setTimeout(function(){
window.allowSlide = 1;
if (window.popupShown.length <= 0) {
$html.removeClass('popupShown');
window.popupShown = false;
}
}, 500);
}
}
$(window).on('popupHidden', function(){
if (history.pushState) {
window.history.pushState("", "", location.href.split('#')[0]);
} else {
window.location.hash = "";
}
});
}
}
/***
* _____ ______ ______ ______
* / ____| | ____| ____| ____|
* | | __ __ _| |__ | |__ | |__
* | | |_ |/ _` | __| | __| | __|
* | |__| | (_| | | | |____| |____
* \_____|\__,_|_| |______|______|
*
* Grid and Flex Element Equalizer
*/
setTimeout(function(){
equalizeElements();
}, 1);
});
function equalizeElements(){
$(el).css('height','auto');
});
//apply
$(element).find('.equalElement').each(function(index, el) {
$(el).css('height', height + "px");
});
} else {
$(equalElement).css("height", "auto");
}
});
}
}
//Detect Resize
$(window).on('resize',function(){
$html.addClass('resizing');
}).on('resizeEnd',function(){
$html.removeClass('resizing');
});
/***
* _____ _ _ _
* / ____| (_) | |
* | (___ | |_ __| | ___ _ __
* \___ \| | |/ _` |/ _ \ '__|
* ____) | | | (_| | __/ |
* |_____/|_|_|\__,_|\___|_|
*
* Slider * *(*)* *
*/
if ($(sliderEl).length > 0) {
$(sliderEl).each(function(index, element) {
//check status
var $el = $(element),
sliderID = $el.data('slider-id'),
nextIndex = $el.find('.selected').index();
//set status
if (window.sliderStatus) {
$html.removeClassByPrefix("slider_" +
sliderID).addClass("slider_" + sliderID + "_" + nextIndex);
}
//autoplay
if ($el.hasClass('autoplay')) {
//clickable
if ($el.hasClass('clickable') || $el.hasClass('autoplay')){
$el.on('click next', function(event){
//uselect old
$selected.removeClass('selected').addClass('hide').one('webkitTransitionE
nd otransitionend oTransitionEnd msTransitionEnd transitionend',
function() {
$(this).removeClass('hide');
});
//select next
$nextElement.removeClass('hide').addClass('selected');
//set status
if (window.sliderStatus) {
$html.removeClassByPrefix("slider_" +
sliderID).addClass("slider_" + sliderID + "_" + nextIndex);
}
//animated
if (isAnimated) {
$el.addClass('animateOnEvent');
$el.find('li').removeClassByPrefix('ae-').removeClass('do');
$el.find('.selected').each(function(index){
$(this).removeClassByPrefix('ae-
').removeClass('do').addClass('ae-' + (index + 1)).addClass('do');
});
$(window).scroll();
}
$controller.children('li:eq('+nextIndex+')').addClass('selected');
}
});
}
});
}
// controller
var $controller = $('.controller');
if ($controller.length > 0) {
if (!$controllerElement.hasClass('selected')){
$selectedElement.removeClass('selected');
$controllerElement.addClass('selected');
$slider.children('.selected').removeClass('selected').addClass('hide').on
e('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd
transitionend', function() {
$(this).removeClass('hide');
});
$slider.children('li').eq(nextIndex).removeClass('hide').addClass('select
ed');
//set status
if (window.sliderStatus) {
$html.removeClassByPrefix("slider_" +
sliderID).addClass("slider_" + sliderID + "_" + nextIndex);
}
}
//is animated
if (isAnimated) {
$slider.addClass('animateOnEvent');
$slider.find('>li').removeClassByPrefix('ae-').removeClass('do');
$slider.find('.selected').each(function(index){
$(this).removeClassByPrefix('ae-
').removeClass('do').addClass('ae-' + (index + 1)).addClass('do');
});
$(window).scroll();
}
});
}
if ($(this).data('slider-id')){
var $this = $(this),
$desiredElement, nextIndex,
sliderID = $this.data('slider-id'),
action = $this.data('slider-action'),
$slider = $('.slider[data-slider-id="' + sliderID + '"]'),
$controller = $('.controller[data-slider-id="'+sliderID+'"]'),
controllerSelector = $controller.data('controller-selector') ?
$controller.data('controller-selector') : "li",
$selected = $slider.find('.selected'),
isAnimated = $slider.hasClass('animated');
//detect direction
if (action === "next"){
$desiredElement = $selected.nextOrFirst("li");
} else if (action === "prev") {
$desiredElement = $selected.prevOrLast("li");
} else if (parseInt(action) || action === 0 ) {
nextIndex = parseInt(action);
$desiredElement =$slider.find('>li:eq(' + nextIndex + ")");
}
//select element
nextIndex = $desiredElement.index();
$selected.removeClass('selected');
$desiredElement.removeClass('hide').addClass('selected');
//set status
if (window.sliderStatus) {
$html.removeClassByPrefix("slider_" +
sliderID).addClass("slider_" + sliderID + "_" + nextIndex);
}
//is animated
if (isAnimated) {
$slider.addClass('animateOnEvent');
$slider.find('li').removeClassByPrefix('ae-').removeClass('do');
$slider.find('.selected').each(function(index){
$(this).removeClassByPrefix('ae-
').removeClass('do').addClass('ae-' + (index + 1)).addClass('do');
});
$(window).scroll();
}
//change controller
if ((sliderID) && ($controller.length > 0) ){
$controller.find('.selected').removeClass('selected').addClass('hide').on
e('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd
transitionend', function() {
$this.removeClass('hide');
});
$controller.find(controllerSelector).eq(nextIndex).addClass('selected');
}
}
});
//Auto Height
$('[data-slider-id].autoHeight').each(function(index, element) {
$(window).on('click resize load ready next',function(){
var totalHeight = 0,
el = $(element).find('.selected');
$(element).find('.selected').children().each(function(){
totalHeight += Math.round($(this).outerHeight(true));
});
$(element).height(totalHeight + "px");
});
});
$(".slider.clickable[data-slider-id], .controller[data-slider-
id]").on('click', function(event){
if($(event.target).data('slider-event') != "cancel")
$(window).resize();
});
/***
* _____ _
* | __ \ | |
* | | | |_ __ ___ _ __ __| | _____ ___ __
* | | | | '__/ _ \| '_ \ / _` |/ _ \ \ /\ / / '_ \
* | |__| | | | (_) | |_) | (_| | (_) \ V V /| | | |
* |_____/|_| \___/| .__/ \__,_|\___/ \_/\_/ |_| |_|
* | |
* |_|
*
* Dropdown Window and Share
*/
window.dropdownShown = false;
//click
$('.dropdownTrigger').on('click', function(){
showDropdown($(this));
});
//hover
$('.dropdownTrigger.hover').hover(function(){
showDropdown($(this), "hover");
});
//show
var offset = $this.offset(),
position = $this.position(),
offsetY = window.popupShown ? Math.ceil(position.top) :
Math.ceil(offset.top),
offsetX = Math.ceil(offset.left),
dropdownID = $this.data('dropdown-id'),
$element = $('.dropdown[data-dropdown-id="' + dropdownID + '"]'),
elementPosition = $this.data('dropdown-position') ?
$this.data('dropdown-position') : $element.attr('class'),
elementPosition = elementPosition.split(' ');
//hide
if (!$isHover) {
hideDropdown();
}
//vertical position
if ( elementPosition.indexOf('bottom') != -1 ) {
offsetY = offsetY - $element.outerHeight();
$element.removeClass('top').addClass('bottom');
} else {
offsetY = offsetY + $this.outerHeight();
$element.removeClass('bottom').addClass('top');
}
//horizontal position
if ( elementPosition.indexOf('right') != -1 ) {
offsetX = offsetX - $element.outerWidth() + $this.outerWidth();
$element.removeClass('left center').addClass('right');
} else if ( elementPosition.indexOf('left') != -1 ) {
$element.removeClass('right center').addClass('left');
} else if ( elementPosition.indexOf('center') != -1 ) {
offsetX = offsetX - ($element.outerWidth()/2) +
($this.outerWidth()/2);
$element.removeClass('right left').addClass('center');
}
$element.addClass('show').css('top',offsetY).css('left',offsetX);
$html.addClass('dropdownShown dropdown_' + dropdownID);
window.dropdownShown = true;
}
function hideDropdown(){
//hide
if (window.dropdownShown){
$html.removeClass('dropdownShown').removeClassByPrefix('dropdown_');
window.dropdownShown = false;
hideDropdownOnScrollDelay = 0;
$('.dropdown.show').addClass('hide').one('webkitTransitionEnd
otransitionend msTransitionEnd transitionend', function(){
$(this).removeClass('show hide')
$html.removeClass('dropdownShown').removeClassByPrefix('dropdown_');;
});
$(window).trigger('dropdownHidden');
}
}
//remove on resize
$(window).on('resize',function(){
hideDropdown();
});
$('.share').sharrre({
enableHover: false,
url: window.shareUrl,
text: window.shareText,
enableCounter: false,
share: {
twitter: true,
facebook: true,
pinterest: true,
googlePlus: true,
stumbleupon: true,
linkedin: true
},
buttons: {
pinterest: {
media: $('.dropdown').data('pinterest-image'),
description: $('.dropdown').data('text') + " " +
$('.dropdown').data('url')
}
},
template: $('.share').html(),
render: function(api) {
//open email
window.location.href ="mailto:?subject=" + encodeURIComponent(
subject ) + "&body=" + encodeURIComponent( body ) + "%20" + url;
});
}
});
/***
* _____ _ _
* | __ \(_) | |
* | | | |_ __ _| | ___ __ _
* | | | | |/ _` | |/ _ \ / _` |
* | |__| | | (_| | | (_) | (_| |
* |_____/|_|\__,_|_|\___/ \__, |
* __/ |
* |___/
* Dialog Windows
*/
window.showDialog(dialogID)
});
if (!$element.is(':visible')){
$element.addClass('reveal').slideDown(500,function(){
$(this).removeClass('reveal').removeClass('hidden');
});
}
}
$element.addClass('hide').slideUp(500,function(){
$(this).removeClass('hide');
if ($.cookie(cookieName)){
$(element).hide();
}
});
//links
$('.dialog [data-href]').on('click', function(){
if ($(this).data('target')){
window.open($(this).data('href'), '_blank');
} else {
window.location = $(this).data('href');
}
});
if (!isNaN(timeoutDelay)) {
setTimeout(function(){
$element.addClass('reveal').slideDown(500,function(){
$(this).removeClass('reveal').removeClass('hidden');
});
}, timeoutDelay);
}
});
//delay reveal for dialog window
$('.dialog[data-dialog-hide-delay]').each(function(){
var timeoutDelay = parseFloat($(this).attr('data-dialog-hide-
delay')),
$element = $(this);
if (!isNaN(timeoutDelay)) {
setTimeout(function(){
$element.addClass('hide').slideUp(500,function(){
$(this).removeClass('hide');
});
}, timeoutDelay);
}
});
//submit form
$('.dialog [data-type="submit"]').click(function(){
$(this).parents('form').submit();
});
/***
* _____ _ _ ______
* / ____| | | | | | ____|
* | | ___ _ __ | |_ __ _ ___| |_ | |__ ___ _ __ _ __ ___
* | | / _ \| '_ \| __/ _` |/ __| __| | __/ _ \| '__| '_ ` _ \
* | |___| (_) | | | | || (_| | (__| |_ | | | (_) | | | | | | | |
* \_____\___/|_| |_|\__\__,_|\___|\__| |_| \___/|_| |_| |_| |_|
*
* Ajax Contact Form
*/
if (ajaxFormButtonIsInput) {
$ajaxFormButton.val(successText);
} else {
$ajaxFormButton.text(successText)
}
$ajaxFormButton.addClass(successClass);
setTimeout(function(){
if (ajaxFormButtonIsInput) {
$ajaxFormButton.val(defaultText);
} else {
$ajaxFormButton.html(defaultText);
}
$ajaxFormButton.attr('class', defaultClasses);
$ajaxForm[0].reset();
},4000);
});
});
/***
* _____ _
* / ____| | |
* | (___ ___ _ _ _ __ __| |
* \___ \ / _ \| | | | '_ \ / _` |
* ____) | (_) | |_| | | | | (_| |
* |_____/ \___/ \__,_|_| |_|\__,_|
*
* Music and Sound
*/
$('audio[data-sound-id]').each(function(event, element){
var $element = $(element),
musicID = $element.data('sound-id'),
audio = $element[0],
$soundButton = $('.soundTrigger[data-sound-id="'+musicID+'"]');
if (audio.autoplay){
$soundButton.addClass('playing');
} else {
$soundButton.removeClass('playing');
}
});
$('.soundTrigger').click(function(){
var musicID = $(this).data('sound-id'),
$audio = $('audio[data-sound-id="'+musicID+'"]'),
action = $audio.data('sound-action') ? $audio.data('sound-
action') : "toggle",
fade = (parseInt($audio.data('sound-fade')) >= 0 ||
$audio.data('sound-fade')) ? parseInt($audio.data('sound-fade')) : 500;
$(this).removeClass('playing');
}
});
// end on dom ready
});
/***
* _
* /\ | |
* / \ _ __ __ _| |_ _ _______
* / /\ \ | '_ \ / _` | | | | |_ / _ \
* / ____ \| | | | (_| | | |_| |/ / __/
* /_/ \_\_| |_|\__,_|_|\__, /___\___|
* __/ |
* |___/
*
* Analyze Devices and Browsers
*/
window.isMobile = false;
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera
Mini/i.test(navigator.userAgent)) { window.isMobile = true; }
//Detect Mobile
if(window.isMobile){$html.addClass('mobile');}else{$html.addClass('deskto
p');}
//Detect Browser
window.isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') >
-1;
window.isSafari = /^((?!chrome).)*safari/i.test(navigator.userAgent);
window.isChrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
window.isChromeiOS = navigator.userAgent.match('CriOS');
window.isMSIE = navigator.userAgent.match('MSIE');
window.isEdge = navigator.userAgent.match('Edge');
window.isAndroid = navigator.userAgent.toLowerCase().indexOf("android") >
-1;
window.isiPad = navigator.userAgent.match(/iPad/i) !== null;
//Detect OS
window.isWindows = navigator.platform.toUpperCase().indexOf('WIN')!==-1;
window.isOSX = navigator.platform.toUpperCase().indexOf('MAC')!==-1;
window.isLinux = navigator.platform.toUpperCase().indexOf('LINUX')!==-1;
//Retina
window.isRetina = ((window.matchMedia && (window.matchMedia('only screen
and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx),
only screen and (min-resolution: 48.8dpcm)').matches ||
window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3),
only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min-
-moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio:
1.3)').matches)) || (window.devicePixelRatio && window.devicePixelRatio >
1.3));
if (window.isRetina){$html.addClass('retina');};