sample of organized js
/**
*
* Lausanne Collegiate School - default_16
* @link http://lausanne.finalsite.com
* Built By: Lindsey Noble
* Project Manager: Mike Hartzler
* Designer: Julianne Hamilton
*
*/
/*!
* global_vars is a file particular to your site
* it contains base functions that are likely but not always used
**/
jQuery(function($) {
// 'use strict';
var FOOTER = FOOTER || {},
HOME = HOME || {},
INIT = INIT || {},
MEGANAV = MEGANAV || {},
OFFCANVAS = OFFCANVAS || {},
SUBNAV = SUBNAV || {},
SEARCH = SEARCH || {},
UTIL = UTIL || {},
//Enhancement Pages
BPT_ATHLETICS = BPT_ATHLETICS || {},
BPT_DIGITAL_SIGN = BPT_DIGITAL_SIGN || {},
//reusable enhancement functions
CONTAINER_TOP_SLIDESHOW = CONTAINER_TOP_SLIDESHOW || {},
FIXED_BG_SLIDESHOW = FIXED_BG_SLIDESHOW || {},
FOOTER_EXPLORE = FOOTER_EXPLORE || {},
GRAD_CAPS = GRAD_CAPS || {},
GLOBAL_MAP_SLIDESHOW = GLOBAL_MAP_SLIDESHOW || {},
INTERIOR_ANIMATIONS = INTERIOR_ANIMATIONS || {},
IMAGE_VIDEO_LIGHTBOX = IMAGE_VIDEO_LIGHTBOX || {},
LANDING_PAGE_TOP_SLIDESHOW = LANDING_PAGE_TOP_SLIDESHOW || {},
REUSABLE_CUSTOM_SLIDESHOW = REUSABLE_CUSTOM_SLIDESHOW || {},
TESTIMONIAL_SLIDESHOW = TESTIMONIAL_SLIDESHOW ||{}
;
var $body = $('body'),
$navMain = $('.nav-main'),
$navSub = $('.nav-sub'),
$navTier = $('.nav-tier'),
$navMain_level1 = $('#fsHeader').find('.nav-main .fsNavLevel1'),
sectionTitle = $navMain_level1.find('> li[class*="fsNavCurrentPage"] > a').text(),
$navSub_title = $navSub.find('> header > .fsElementTitle'),
bpMobile = 600,
bpTablet = 800,
isHome = $('.home').length,
notHome = $('body:not(.home)').length,
notComposeMode = !$('.fsComposeMode').length, // if (isHome && notComposeMode)....
//enhancement vars
$bpt_athletics3 = $('.bpt-athletics3'),
$footer_explore_element = $('.footer-explore'),
$fixed_bg_slideshow_wrapper = $('.fixed-bg-slideshow'),
$global_slideshow_element = $('.global-slideshow'),
$grad_cap_element = $('.grad-slideshow'),
$hero_slideshow_container = $('.container-slideshow-top'),
$landing_slideshow_element = $('.landing-slideshow-top'),
$offset_text_container = $('.offset-text-container.static-image'),
$reusable_slideshow_element = $('.custom-reusable-slideshow'),
$testimonial_slideshow_element = $('.testimonial-slideshow')
;
//check if browser supports placeholders for placeholder()
$.support.placeholder = (function() {
var i = document.createElement('input');
return 'placeholder' in i;
})();
// ================================
// Initiation of all Functions
// ================================
INIT = {
init: function() {
SUBNAV.init();
MEGANAV.init();
OFFCANVAS.init();
SEARCH.init();
FOOTER.init();
UTIL.respondSliders();
UTIL.customCal();
if (isHome && notComposeMode) {
HOME.init();
GLOBAL_MAP_SLIDESHOW.init();
}
if ($('.featured-news').length) {
UTIL.featuredNews();
}
if (notHome && notComposeMode) {
//BPT
$('.nav-breadcrumb').find('a').parents('.nav-breadcrumb').addClass('has-links');
if ($bpt_athletics3.length) {
BPT_ATHLETICS.init();
}
if ($('.ds-image-rotation').length) {
BPT_DIGITAL_SIGN.init();
}
//reusable treatments
if ($hero_slideshow_container.length) {
CONTAINER_TOP_SLIDESHOW.init();
}
if ($fixed_bg_slideshow_wrapper.length) {
FIXED_BG_SLIDESHOW.init();
}
if ($footer_explore_element.length) {
FOOTER_EXPLORE.init();
INTERIOR_ANIMATIONS.animateFooterExplore();
}
if ($grad_cap_element.length) {
GRAD_CAPS.init();
}
if ($global_slideshow_element.length) {
GLOBAL_MAP_SLIDESHOW.init();
}
if ($landing_slideshow_element.length) {
LANDING_PAGE_TOP_SLIDESHOW.init();
}
if ($offset_text_container.length) {
INTERIOR_ANIMATIONS.animateOffsetText();
}
if ($reusable_slideshow_element.length) {
REUSABLE_CUSTOM_SLIDESHOW.init();
}
if ($testimonial_slideshow_element.length) {
TESTIMONIAL_SLIDESHOW.init();
INTERIOR_ANIMATIONS.animateTestimonialSlideshow();
}
if ($('.nav-language').length) {
$body.addClass('has-language-nav');
$('.nav-language').prependTo('#fsPageContent');
}
//check for custom image linked to video lightbox
if ($('.fs_style_29').length) {
IMAGE_VIDEO_LIGHTBOX.init();
}
//animations
if ($('.infographic-container').length) {
INTERIOR_ANIMATIONS.animateInfographicContent();
}
}//end not compose mode functions
//misc
},
};
// ================================
// Mega Nav
// ================================
MEGANAV = {
init: function() {
this.columns();
backgroundImage('.nav-main .fsNavPageThumbnail');
},
// split list into columns
columns: function() {
var num_cols = 2,
container = $navMain.find('.fsNavPageInfo > .fsNavLevel2'),
listItem = 'li',
listClass = 'sub-list'
;
container.each(function() {
var items_per_col = [],
items = $(this).find(listItem),
min_items_per_col = Math.floor(items.length / num_cols),
difference = items.length - (min_items_per_col * num_cols);
for (var i = 0; i < num_cols; i++) {
if (i < difference) {
items_per_col[i] = min_items_per_col + 1;
} else {
items_per_col[i] = min_items_per_col;
}
$(this).append($('<span ></span>').addClass(listClass));
for (var j = 0; j < items_per_col[i]; j++) {
var pointer = 0;
for (var k = 0; k < i; k++) {
pointer += items_per_col[k];
}
$(this).find('.' + listClass).last().append(items[j + pointer]);
}
}
});
}
};
// ================================
// Search Functionality
// ================================
SEARCH = {
init: function() {
placeholder($(".site-search"), "What are you looking for?");
this.toggleSearch();
},
toggleSearch: function() {
// Toggle attribute of the body
$('.util-nav .fsNavLevel1 > li:nth-of-type(3)').click(function() {
$body.toggleClass('search-is-active');
});
// Remove attribute on the bottom if anything other than
// what is mentioned is clicked on
$(document).on('click', function(event) {
if (!$(event.target).closest('.site-search, .util-nav .fsNavLevel1 > li:nth-of-type(3)').length) {
$body.removeClass('search-is-active');
}
});
$('.site-search > footer .fsElementFooterContent').on('click', function() {
$body.removeClass('search-is-active');
});
}
};
// ================================
// Sub Navigation
// ================================
SUBNAV = {
init: function() {
this.title();
this.mobileNav();
},
// Create a section title based on the current page
title: function() {
// if (sectionTitle.length !== 0) {
// $navSub_title.html(sectionTitle);
// }
if ($navSub.find('nav .fsNavLevel1').length !== 0) {
$navSub.removeClass('nav-sub-empty');
} else {
$navSub.addClass('nav-sub-empty');
}
if ($navTier.find('nav .fsNavLevel1').length !== 0) {
$navTier.removeClass('nav-tier-empty');
} else {
$navTier.addClass('nav-tier-empty');
}
},
mobileNav: function() {
// nav-sub - mobile toggle
$navSub_title.click(function() {
$(this).closest($navSub).toggleClass('active-nav');
});
// // nav-sub remove click elsewhere
// $(document).on('click', function(event) {
// if (!$(event.target).closest($navSub).length) {
// $navSub.removeClass('active-nav');
// }
// });
}
};
// ================================
// Off Canvas Menu
// ================================
OFFCANVAS = {
init: function() {
this.clickHandler();
},
clickHandler: function() {
// Toggle attribute of the body
$('.drawer-trigger').click(function() {
$body.toggleClass('drawer-is-active');
});
// Remove attribute on the bottom if anything other than
// what is mentioned is clicked on
$(document).on('click', function(event) {
if (!$(event.target).closest('#fsMenu, .drawer-trigger').length) {
$body.removeClass('drawer-is-active');
}
});
}
};
// ================================
// Footer
// ================================
FOOTER = {
init: function() {
this.quickColumns();
},
// split list into columns
quickColumns: function() {
var num_cols = 2,
container = $('.footer-quicklinks .fsNavLevel1'),
listItem = 'li',
listClass = 'sub-list'
;
container.each(function() {
var items_per_col = [],
items = $(this).find(listItem),
min_items_per_col = Math.floor(items.length / num_cols),
difference = items.length - (min_items_per_col * num_cols);
for (var i = 0; i < num_cols; i++) {
if (i < difference) {
items_per_col[i] = min_items_per_col + 1;
} else {
items_per_col[i] = min_items_per_col;
}
$(this).append($('<span ></span>').addClass(listClass));
for (var j = 0; j < items_per_col[i]; j++) {
var pointer = 0;
for (var k = 0; k < i; k++) {
pointer += items_per_col[k];
}
$(this).find('.' + listClass).last().append(items[j + pointer]);
}
}
});
}
};
// ================================
// Home
// ================================
HOME = {
init: function() {
this.mixedSlideshow();
this.multimediaSlideshow();
this.hpAlert();
this.videoOffset();
this.animateContent();
this.gradCapHome();
},
hpAlert: function() {
$('.hp-alert > footer > .fsElementFooterContent').click(function() {
$('.hp-alert').toggleClass('off');
});
},
multimediaSlideshow: function() {
// setTimeout(function(){
$('.fsContainer.hp-multimedia-slideshow').fsMultimediaSlideshow();
// $body.addClass('show');
// }, 2000);
},
mixedSlideshow: function() {
$('.mixed-slideshow-container > .fsElementContent').prepend('<div class="mixed-controls"><div class="mix-prev mix-arrow"/><div class="mix-next mix-arrow"/></div>');
$('.mixed-slideshow.part-1').attr('dir', 'rtl');
$('.mixed-slideshow.part-2').attr('dir', 'rtl');
//small image slideshow part 1
$('.mixed-slideshow.part-1').each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="universal-slide" style="background-image: url({imgSrc});">',
'<img src="{imgSrc}" class="universal-img" />',
'</article>'
], // html markup
callback: function() {
self.find('.fsMediaCustomPlayer').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
initialSlide: 1,
arrows: false,
swipe: false,
touchMove: false,
rtl: true,
});
}
});
});
// main slideshow part 2
$('.mixed-slideshow.part-2').each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="universal-slide" style="background-image: url({imgSrc});">',
'<img src="{imgSrc}" class="image-desktop" />',
'<div class="image-slide" style="background-image: url({imgSrc});">',
'<img src="{imgSrc}" class="universal-img" />',
'</div>',
'<div class="caption-wrapper">',
'<div class="caption-title">{captionTitle}</div>',
'<div class="caption-desc">{captionDesc}</div>',
'</div>',
'</article>'
], // html markup
callback: function() {
self.find('.fsMediaCustomPlayer').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
arrows: false,
swipe: false,
touchMove: false,
rtl: true,
adaptiveHeight: true,
// asNavFor: '.mixed-slideshow.part-1',
});
}
});
});
//slideshow content part 3
$('.mixed-slideshow.part-3').each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="universal-slide">',
'<div class="caption-wrapper">',
'<div class="caption-title">{captionTitle}</div>',
'<div class="caption-desc">{captionDesc}</div>',
'</div>',
'</article>'
], // html markup
callback: function() {
//write all functions to be run after media data has been pulled in here
// ie (slick, randomize, etc...)
self.find('.fsMediaCustomPlayer').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
arrows: false,
swipe: false,
touchMove: false,
fade: true,
// asNavFor: '.mixed-slideshow.part-2',
});
}
});
});
$('.mixed-slideshow.part-4 > .fsElementContent').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
arrows: false,
swipe: false,
touchMove: false,
// fade: true,
});
$(".mix-next").on("click",function(e) {
$(".mixed-slideshow").find(".fsMediaCustomPlayer").slick("slickNext");
$('.mixed-slideshow.part-4 > .fsElementContent').slick("slickNext");
});
$(".mix-prev").on("click",function(e) {
$(".mixed-slideshow").find(".fsMediaCustomPlayer").slick("slickPrev");
$('.mixed-slideshow.part-4 > .fsElementContent').slick("slickPrev");
});
},
animateContent: function() {
$('.mixed-slideshow-container')
.waypoint(function(direction) {
if (direction === 'down') {
$(this.element).addClass('animate-content');
}
else {
$(this.element).removeClass('animate-content');
}
}, {
offset: '50%'
});
$('.hp-panel-2')
.waypoint(function(direction) {
if (direction === 'down') {
$(this.element).addClass('animate-content');
}
else {
$(this.element).removeClass('animate-content');
}
}, {
offset: '50%'
});
$('.hp-panel-3')
.waypoint(function(direction) {
if (direction === 'down') {
$(this.element).addClass('animate-content');
}
else {
$(this.element).removeClass('animate-content');
}
}, {
offset: '50%'
});
$('.hp-panel-4')
.waypoint(function(direction) {
if (direction === 'down') {
$(this.element).addClass('animate-content');
}
else {
$(this.element).removeClass('animate-content');
}
}, {
offset: '70%'
});
},
videoOffset: function() {
var iframe = document.querySelector('iframe');
var player = new Vimeo.Player(iframe);
player.on('play', function() {
console.log('played the video!');
$('.no-touch .video-placeholder').addClass('video-active');
});
player.on('pause', function() {
console.log('paused the video!');
$('.no-touch .video-placeholder').removeClass('video-active');
});
},
gradCapHome: function() {
$grad_cap_element.each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="grad-item">',
'<img src="{imgSrc}" class="grad-img" />',
'<div class="grad-desc-wrapper">',
'<div class="grad-quote">{captionDesc}</div>',
'<div class="grad-cite">{captionTitle}</div>',
'</div>',
'</article>'
], // html markup
callback: function() {
//write all functions to be run after media data has been pulled in here
// ie (slick, randomize, etc...)
self.randomize('article');
}
});
});
}
};
// ================================
// Enhancements Pages
// ================================
BPT_ATHLETICS = {
init: function() {
this.BPTathletics3();
},
BPTathletics3: function() {
var $notComposeMode = $('body:not(.fsComposeMode)'),
$noTouch = $('.no-touch'),
$circleButton = $('.circle-button')
;
// function athBPTv3() {
var $athMainSlideshow = $('.ath-landing-slideshow'),
$athSchedule = $('.ath-event-slideshow.schedules'),
$athScores = $('.ath-event-slideshow.scores')
;
//landing slideshow
$athMainSlideshow.find('.fsElementHeaderContent > a').on('click', function(event) {
event.preventDefault();
$athMainSlideshow.addClass('start-show');
$athMainSlideshow.mediaSlider({
mediaTemplate:[
'<article class="universal-slide" style="background-image: url({imgSrc});">',
'<img src="{imgSrc}" class="universal-img" />',
'<div class="caption-wrapper">',
'<div class="caption-title">{captionTitle}</div>',
'<div class="caption-desc">{captionDesc}</div>',
'</div>',
'</article>'
], // html markup
callback: function() {
//write all functions to be run after media data has been pulled in here
// ie (slick, randomize, etc...)
$athMainSlideshow.find('.fsMediaCustomPlayer').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
});
$athMainSlideshow.find('.fsMediaCustomPlayer').addClass('show');
}
});
});
//toggling slideshow schedules/scores
$athSchedule.addClass('on');
$athSchedule.click(function() {
$(this).addClass('on');
$athScores.removeClass('on');
});
$athScores.click(function() {
$(this).addClass('on');
$athSchedule.removeClass('on');
});
$('.ath-event-slideshow .fsListItems').slick({
arrows: true,
infinite: true,
speed: 300,
variableWidth: true,
responsive: [
{
breakpoint: 600,
settings: {
arrows: true,
infinite: true,
speed: 300,
slidesToShow: 1,
slidesToScroll: 1,
variableWidth: false,
adaptiveHeight: true
}
}
]
});
//Title Bar
$('.title-bar').find('> header .fsElementTitle').wrapInner('<div class="title-inner">');
//Featured News
backgroundImage('.bpt-featured-news .fsThumbnail');
// }//end ath treatment function
//circle button
if ($circleButton.length) {
// if($notComposeMode.length) {
$circleButton.wrapInner('<a href="" class="circle-button-link" /> ');
$circleButton.each(function() {
var $circleFront = $(this).find('header').clone().addClass('front');
$(this).find('.circle-button-link').prepend($circleFront);
$(this).find('.fsElementContent').remove();
});
$circleButton.find('header').wrapInner('<div class="circle-button-inner" />');
$circleButton.find('.fsElementHeaderContent a').each(function(){
var imgurl = $(this).attr('href');
$(this).parents('.circle-button-link').attr('href', imgurl);
});
$circleButton.doubleTapToGo();
// }
}
},
};
BPT_DIGITAL_SIGN = {
init: function() {
this.BPTDigitalSign1();
},
BPTDigitalSign1: function() {
var $bgMedia = $('.ds-image-rotation'),
$calSchedulePull = $('.cal-schedule-pull > .fsElementContent'),
$calResultsPull = $('.cal-results-pull > .fsElementContent'),
$dateContainer = $('.ds-date-time > .fsElementContent'),
$pullPage = '/digital-signage-2/newscal-pull-content-ds1',
// functions
imageRotate,
initSign,
pullContent,
signageDate,
weatherPlugin
;
imageRotate = function imageRotate(){
$bgMedia.mediaSlider({
mediaTemplate:[
'<article class="ds-bg-slide" style="background-image: url({imgSrc});">',
'</article>'
], // html markup
callback: function() {
$bgMedia.find('.fsMediaCustomPlayer').slick({
infinite: true,
initialSlide: 0,
vertical: true,
arrows: false,
centerMode: true,
autoplay: true,
autoplaySpeed: 10000,
pauseOnHover: false,
});
}
});
};
initSign = function initSign(){
signageDate();
setInterval(signageDate, 1000);
imageRotate();
setInterval(imageRotate, 60*60000);
pullContent();
setInterval(pullContent, 60*60000);
};
pullContent = function pullContent() {
$calSchedulePull.html('Loading...');
$calSchedulePull.load($pullPage + " .athletic-schedule", function() {
$('.fsAthleticsAdvantage').text('Home').each(function() {
$(this).parent('article').addClass('home');
});
$('.athletic-schedule .fsListItems').slick({
vertical: true,
arrows: false,
centerMode: true,
autoplay: true,
autoplaySpeed: 10000,
pauseOnHover: false,
});
});
$calResultsPull.html('Loading...');
$calResultsPull.load($pullPage + " .athletic-results", function() {
$('.fsResultWin .fsAthleticsResult').text('Win').each(function() {
$(this).text('W');
});
$('.fsResultLoss .fsAthleticsResult').text('Win').each(function() {
$(this).text('L');
});
$('.athletic-results .fsListItems').slick({
vertical: true,
arrows: false,
centerMode: true,
autoplay: true,
autoplaySpeed: 10000,
pauseOnHover: false,
});
});
//set reload cal/news
setTimeout(function(){
pullContent();
},30*60000); //30 mintues
};
signageDate = function signageDate(){
// function pad(n){
// return n<10 ? '0'+n : n;
// };
var container = $dateContainer;
var mydate = new Date();
var year = mydate.getYear();
var day = mydate.getDay();
var month = mydate.getMonth();
var daym = mydate.getDate();
var hours = mydate.getHours();
var hour,ampm;
var seconds = mydate.getSeconds();
var fulltime = hour+""+minutes+""+seconds+""+ampm;
hour = hours % 12 || 12;
ampm = hours < 12 ? "am" : "pm";
var minutes = mydate.getMinutes() < 10 ? '0'+ mydate.getMinutes() : mydate.getMinutes();
if (year < 1000) { year += 1900; }
if (daym<10) { daym = '0' + daym; }
var dayarray = new Array('Sun','Mon','Tues','Wed','Thurs','Fri','Sat');
var montharray = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var today = '<div class="ds_fullDateTime"><div class="ds_date"><span class="ds_day">' + dayarray[day] +',</span><span class="ds_month"> ' + montharray[month] +' ' + daym + ' </span></div><div class="ds_time">' + hour + ':' + minutes + ' ' + ampm + '</div></div>';
container.html(today);
// // If time is 1am
// if(fulltime === "1000am" || fulltime === "2300pm") {
// document.location.reload(true);
// }
//check time and do full refresh of page
//hours is based on 24 hour time here
if(hours === 6 && minutes === 15) {
//save current timestamp
var ts = Date.now();
//get saved timestamp (if available)
var sts = parseInt(readCookie('timestamp'));
//console.log(sts);
//only reload if it's been at least 10 minutes since last check
if( sts < ts - 600000){
//save timestamp to check later
createCookie('timestamp',ts);
document.location.reload(true);
}
}
};
},
};
// ================================
// Reusable Treatments
// ================================
CONTAINER_TOP_SLIDESHOW = {
init: function() {
this.containerSlideshowTop();
},
containerSlideshowTop: function() {
$hero_slideshow_container.insertBefore('.nav-breadcrumb');
$hero_slideshow_container.find('> .fsElementContent').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
arrows: true,
// centerMode: true,
variableWidth: true,
infinite:false,
responsive: [
{
breakpoint: 700,
settings: {
variableWidth: false,
}
}
]
});
},
};
FIXED_BG_SLIDESHOW = {
init: function() {
this.fixedBgSlideshow();
},
fixedBgSlideshow: function() {
$fixed_bg_slideshow_wrapper.find('.fsMediaCustomPlayer').prepend('<div class="fixed-controls"><div class="slick-prev slick-arrow"/><div class="slick-next slick-arrow"/></div>');
$fixed_bg_slideshow_wrapper.each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="fixed-bg-slide" style="background-image: url({imgSrc});">',
'<div class="caption-wrapper">',
'<div class="caption-inner">',
'<div class="caption-title">{captionTitle}</div>',
'<div class="caption-desc">{captionDesc}</div>',
'</div>',
'</div>',
'<img src="{imgSrc}" class="fixed-bg-img" />',
'</article>'
], // html markup
callback: function() {
$('.fixed-bg-slide:first-of-type').addClass('first on');
$('.fixed-bg-slide:last-of-type').addClass('last');
$('.fixed-controls > .slick-next').on('click', function() {
$('.fixed-bg-slide.on').each(function() {
if ($(this).hasClass('last')) {
$(this).removeClass('on');
$('.fixed-bg-slide.first').addClass('on');
} else {
$(this).removeClass('on');
}
$(this).next('.fixed-bg-slide').addClass('on');
});
});
$('.fixed-controls > .slick-prev').on('click', function() {
$('.fixed-bg-slide.on').each(function() {
if ($(this).hasClass('first')) {
$(this).removeClass('on');
$('.fixed-bg-slide.last').addClass('on');
} else {
$(this).removeClass('on');
}
$(this).prev('.fixed-bg-slide').addClass('on');
});
});
}
});
});
},
};
FOOTER_EXPLORE = {
init: function() {
this.exploreFooter();
},
exploreFooter: function() {
backgroundImage('.explore-content > .fsElementContent');
$footer_explore_element.insertBefore('#fsFooter');
$footer_explore_element.find('> header > .fsElementHeaderContent').on('click', function() {
$.smoothScroll();
});
},
};
GRAD_CAPS = {
init: function() {
this.gradRandomize();
},
gradRandomize: function() {
$grad_cap_element.each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="grad-item">',
'<img src="{imgSrc}" class="grad-img" />',
'<div class="grad-desc-wrapper">',
'<div class="grad-quote">{captionDesc}</div>',
'<div class="grad-cite">{captionTitle}</div>',
'</div>',
'</article>'
], // html markup
callback: function() {
//write all functions to be run after media data has been pulled in here
// ie (slick, randomize, etc...)
self.randomize('article');
}
});
});
$('body:not(.home) .hp-panel-4')
.waypoint(function(direction) {
if (direction === 'down') {
$(this.element).addClass('animate-content');
}
else {
$(this.element).removeClass('animate-content');
}
}, {
offset: '70%'
});
},
};
GLOBAL_MAP_SLIDESHOW = {
init: function() {
this.globalSlideshow();
},
globalSlideshow: function() {
$('.hp-map-image > .fsElementContent').prepend('<div class="hp-dots" />');
$global_slideshow_element.each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="global-item">',
'<div class="global-img-wrapper" style="background-image: url({imgSrc});">',
'<img src="{imgSrc}" class="global-img" />',
'</div>',
'<div class="global-desc-wrapper">',
'<div class="global-title">{captionTitle}</div>',
'<div class="global-desc">{captionDesc}</div>',
'</div>',
'</article>'
], // html markup
callback: function() {
self.find('.fsMediaCustomPlayer').on('init', function(event, slick){
self.find('.slick-slide:not(.slick-cloned)').each(function(i) {
var $famTitle = $(this).find('.global-title').clone();
var famClass = $(this).find('.global-title').html();
$('.hp-dots .slick-dots li').eq(i).prepend($famTitle);
$('.hp-dots .slick-dots li').eq(i).addClass(famClass);
});
});
self.find('.fsMediaCustomPlayer').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
arrows: false,
dots: true,
appendDots: $('.hp-dots'),
fade: true,
adaptiveHeight: true,
responsive: [
{
breakpoint: 700,
settings: {
dots: false,
arrows: true,
}
}
]
});
}
});
});
},
};
INTERIOR_ANIMATIONS = {
animateFooterExplore: function() {
$footer_explore_element
.waypoint(function(direction) {
if (direction === 'down') {
$(this.element).addClass('animate-content');
}
else {
$(this.element).removeClass('animate-content');
}
}, {
offset: '30%'
});
},
animateInfographicContent: function() {
$('.infographic-container')
.waypoint(function(direction) {
if (direction === 'down') {
$(this.element).addClass('animate-content');
}
else {
$(this.element).removeClass('animate-content');
}
}, {
offset: '65%'
});
},
animateOffsetText: function() {
$offset_text_container
.waypoint(function(direction) {
if (direction === 'down') {
$(this.element).addClass('animate-content');
}
else {
$(this.element).removeClass('animate-content');
}
}, {
offset: '55%'
});
},
animateTestimonialSlideshow: function() {
$testimonial_slideshow_element
.waypoint(function(direction) {
if (direction === 'down') {
$(this.element).addClass('animate-content');
}
else {
$(this.element).removeClass('animate-content');
}
}, {
offset: '65%'
});
},
};
IMAGE_VIDEO_LIGHTBOX = {
init: function() {
this.videoLightboxLink();
},
videoLightboxLink: function() {
$('.fsPageLayout .fs_style_29 > img[style*="float: left;"]').parent('').addClass('float-left');
$('.fsPageLayout .fs_style_29 > img[style*="float: right;"]').parent('').addClass('float-right');
$('.float-left, .float-right').parent('p').addClass('clear-me');
// $('.fsPageLayout .fs_style_29').on('click', function(e) {
// e.preventDefault();
// // $('.infographic-lightbox > .infographic-video').remove();
// // $('.infographic-lightbox > header').remove();
// $(this).linkedImageLightbox({
// lightboxVideoTemplate:[
// // '<article class="infographic-video full-vid" style="background-image: url({videoBG});">',
// '<article class="image-video-lightbox full-vid">',
// '<video src="{videoSrc}" muted autoplay />',
// '</article>'
// ], // html markup
// callback: function() {
// var $lightboxVideo = $('.full-vid').find('video');
// $lightboxVideo.attr('controls', 'controls');
// $lightboxVideo.removeAttr('muted');
// $body.addClass('video-active');
// $('.full-vid').appendTo('.inner-vid-lightbox');
// $('.infographic-lightbox.show .full-vid').addClass('show');
// $lightboxVideo[0].play();
// $('.vid-lightbox .close').on('click', function() {
// $('body').removeClass('video-active');
// $('.vid-lightbox').find('video').remove();
// });
// }
// });//end landing video
// });
},
};
LANDING_PAGE_TOP_SLIDESHOW = {
init: function() {
this.landingPageSlideshowTop();
},
landingPageSlideshowTop: function() {
$body.prepend('<div class="vid-lightbox"><button class="close"/><div class="inner-vid-lightbox" /></div>');
$landing_slideshow_element.insertBefore('.nav-breadcrumb');
$landing_slideshow_element.each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="landing-top-slide">',
'<div class="landing-top-img-wrapper" style="background-image: url({imgSrc});">',
'<img src="{imgSrc}" class="landing-top-img" />',
'</div>',
'<div class="caption-wrapper">',
'<div class="caption-title">{captionTitle}</div>',
'<div class="caption-desc">{captionDesc}</div>',
'</div>',
'</article>'
], // html markup
callback: function() {
var $captionTop = $landing_slideshow_element.clone().addClass('text-top-slideshow');
$captionTop.insertBefore('.nav-breadcrumb');
$('<div class="landing-top-controls"><div class="slick-prev slick-arrow"/><div class="slick-next slick-arrow"/></div>').insertBefore('.landing-slideshow-top:not(.text-top-slideshow)');
//write all functions to be run after media data has been pulled in here
// ie (slick, randomize, etc...)
$('.fs_style_29').parents('article').addClass('has-video');
$('.landing-slideshow-top:not(.text-top-slideshow)').find('.fsMediaCustomPlayer').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
arrows: false,
// centerMode: true,
variableWidth: true,
infinite:false,
responsive: [
{
breakpoint: 700,
settings: {
variableWidth: false,
}
}
]
});
$('.landing-slideshow-top.text-top-slideshow').find('.fsMediaCustomPlayer').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
arrows: false,
infinite:false,
fade: true,
responsive: [
{
breakpoint: 980,
settings: {
adaptiveHeight: true,
}
}
]
});
$(".landing-top-controls .slick-next").on("click",function(e) {
$(".landing-slideshow-top").find(".fsMediaCustomPlayer").slick("slickNext");
});
$(".landing-top-controls .slick-prev").on("click",function(e) {
$(".landing-slideshow-top").find(".fsMediaCustomPlayer").slick("slickPrev");
});
$('.landing-slideshow-top:not(.text-top-slideshow) .has-video').each(function(){
var bannerMediaLink = $(this).find('.fs_style_29').attr('href');
var bannerMediaID = bannerMediaLink.split('g=')[1].split('"')[0];
$(this).on('click', function() {
$body.addClass('video-active');
loadBannerMedia(bannerMediaID);
});
});
$('.vid-lightbox .close').on('click', function() {
$('body').removeClass('video-active');
$('.vid-lightbox').find('video').remove();
});
}
});
});
},
};
REUSABLE_CUSTOM_SLIDESHOW = {
init: function() {
this.resusableSlideshow();
},
resusableSlideshow: function() {
$reusable_slideshow_element.each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="reusable-slide" style="background-image: url({imgSrc});">',
'<img src="{imgSrc}" class="reusable-img" />',
'<div class="caption-wrapper">',
// '<div class="caption-title">{captionTitle}</div>',
'<div class="caption-desc">{captionDesc}</div>',
'</div>',
'</article>'
], // html markup
callback: function() {
self.find('.reusable-slide:nth-of-type(3)').addClass('active');
$('.reusable-slide:last-child').addClass('last');
$('.reusable-slide').click(function() {
$('.reusable-slide').removeClass('active');
$(this).addClass('active');
if ($(this).hasClass('last')) {
$('.reusable-slide:nth-child(4)').addClass('move');
} else {
$('.reusable-slide:nth-child(4)').removeClass('move');
}
});
}
});
});
},
};
TESTIMONIAL_SLIDESHOW = {
init: function() {
this.testimonialSlideshow();
},
testimonialSlideshow: function() {
$testimonial_slideshow_element.each(function() {
var self = $(this);
self.mediaSlider({
mediaTemplate:[
'<article class="testimonial-slide">',
'<div class="image-title-wrapper">',
'<img src="{imgSrc}" class="testimonial-img" />',
'<div class="caption-title">{captionTitle}</div>',
'</div>',
'<div class="testimonial-content">',
'<blockquote class="caption-desc">{captionDesc}</blockquote>',
'</div>',
'</article>'
], // html markup
callback: function() {
self.find('.fsMediaCustomPlayer').slick({
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
infinite:true,
adaptiveHeight: true,
});
}
});
});
},
};
// ================================
// Utility & milliseconds Functions
// ================================
UTIL = {
respondSliders: function() {
// ================================
// Responsive Built-in sliders
// ================================
// the following takes care of the news/calendar slideshow option
// and makes them responsive
var targets = [
'.fsNews.fsSlideshow',
'.fsCalendar.fsSlideshow'
];
var bp = [{
breakpoint: bpTablet,
settings: {
slidesToShow: 2,
slidesToScroll: 1,
infinite: true,
dots: true
}
}, {
breakpoint: bpMobile,
settings: {
slidesToShow: 1,
dots: false
}
}];
for (var i = 0; i < targets.length; i++) {
$(targets[i] + ' .fsElementSlideshow')
.slick('slickSetOption', 'responsive', bp, true);
}
},
customCal: function() {
var $hpCal = $('.hp-cal');
$hpCal.find('.fsDayContainer > article').unwrap();
$hpCal.find('.fsListItems').slick({
slidesToShow: 2,
slidesToScroll: 1,
responsive: [
{
breakpoint: 800,
settings: {
slidesToShow: 1,
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
}
},
{
breakpoint: 500,
settings: {
slidesToShow: 1,
}
}
]
});
},
featuredNews: function() {
backgroundImage('.featured-news .fsThumbnail');
$('.featured-news article').each(function() {
$(this).prepend('<div class="featured-desc" />');
var $featuredLink = $(this).find('.fsReadMoreLink'),
$featuredDesc = $(this).find('.featured-desc'),
$featuredNotes = $(this).find('.fsSummary'),
$featuredThumb = $(this).find('.fsThumbnail')
;
$featuredDesc.append($featuredNotes, $featuredLink);
$featuredThumb.parent().addClass('has-img');
});
}
};
INIT.init();
}); //jQuery