2017-03-10 22:59:27 -08:00
|
|
|
// Smooth Scroll Init - Register click handler for ID anchors
|
2017-04-07 01:40:29 -07:00
|
|
|
$('a[href*="#"]:not(a[modal])').click(function () {
|
2017-03-04 20:02:56 -08:00
|
|
|
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
|
|
|
|
var target = $(this.hash);
|
|
|
|
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
|
|
|
|
if (target.length) {
|
2017-03-11 20:11:20 -08:00
|
|
|
var targetOffset = target.offset().top - $(".nav-bar__header").outerHeight(true);
|
|
|
|
// console.log(targetOffset, target.offset().top, $(".nav-bar__header").outerHeight())
|
2017-03-04 20:02:56 -08:00
|
|
|
$('html, body').animate({
|
2017-03-11 20:11:20 -08:00
|
|
|
scrollTop: targetOffset
|
2017-03-04 20:02:56 -08:00
|
|
|
}, 1000);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-03-12 11:05:18 -07:00
|
|
|
// navbar mobile toggle - preload
|
2017-03-10 22:59:27 -08:00
|
|
|
(function navbarInit() {
|
2017-03-04 20:02:56 -08:00
|
|
|
|
|
|
|
function toggleMobileMenu() {
|
2017-03-11 20:11:20 -08:00
|
|
|
$('.nav-bar__menu')[0].style.transition = "max-height 0.5s";
|
|
|
|
$('.nav-bar__menu')[0].classList.toggle("hide-menu");
|
2017-03-04 20:02:56 -08:00
|
|
|
}
|
2017-03-11 20:11:20 -08:00
|
|
|
$('.nav-bar__menu-button, .nav-bar__menu-item > a').click(toggleMobileMenu)
|
2017-03-04 20:02:56 -08:00
|
|
|
|
|
|
|
}());
|
2017-03-10 22:59:27 -08:00
|
|
|
|
2017-03-29 19:58:42 -07:00
|
|
|
// using an image for phone and toggle hide it
|
|
|
|
$('#cell').click(function () { $('#cell-number').toggleClass("hide"); });
|
|
|
|
// $('#phone').click(function () { alert('phone clicked'); return false; });
|
|
|
|
|
2017-04-05 00:24:28 -07:00
|
|
|
function navbarSpacer() {
|
2017-04-07 01:40:29 -07:00
|
|
|
$('.nav-bar-spacer').css({
|
2017-04-05 00:24:28 -07:00
|
|
|
height: $(".nav-bar__header").outerHeight(true),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-03-21 08:32:26 -07:00
|
|
|
// hero resizer
|
2017-04-08 14:24:15 -07:00
|
|
|
function heroResize(bfr = 30) {
|
2017-04-05 00:24:28 -07:00
|
|
|
var h = $(window).height() - $(".nav-bar__header").outerHeight(true),
|
2017-03-22 20:19:31 -07:00
|
|
|
w = $(window).width(),
|
|
|
|
fr = bfr * h / w
|
|
|
|
// console.log('w,h,fr', w, h, fr)
|
|
|
|
// minimum base font ratio
|
|
|
|
fr = (fr > bfr) ? bfr : fr
|
|
|
|
// adjust for short viewport height
|
2017-04-08 14:24:15 -07:00
|
|
|
fr = (w / h > 1 && h < 700) ? 30 * w / h : fr
|
2017-03-22 20:19:31 -07:00
|
|
|
//console.log('fr after', fr)
|
|
|
|
|
2017-03-21 08:32:26 -07:00
|
|
|
$('#hero').css({
|
2017-04-10 15:15:14 -07:00
|
|
|
width: w + 15,
|
2017-03-22 20:19:31 -07:00
|
|
|
height: h / w > 1.5 ? w * 1.5 : h,
|
2017-03-21 08:32:26 -07:00
|
|
|
});
|
2017-03-22 20:19:31 -07:00
|
|
|
|
2017-04-08 14:24:15 -07:00
|
|
|
var mf = w / h > 1 ? 0 : 12
|
|
|
|
|
2017-03-21 08:32:26 -07:00
|
|
|
$('#hero').flowtype({
|
2017-04-08 14:24:15 -07:00
|
|
|
maxFont: 30,
|
|
|
|
minFont: mf,
|
2017-03-22 20:19:31 -07:00
|
|
|
fontRatio: fr
|
2017-03-21 08:32:26 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-04-08 14:24:15 -07:00
|
|
|
function typeResize(fr = 20) {
|
|
|
|
$('main:not(#hero)').flowtype({
|
2017-03-21 08:32:26 -07:00
|
|
|
// maximum: 1000,
|
|
|
|
minFont: 12,
|
|
|
|
maxFont: 25,
|
2017-04-08 14:24:15 -07:00
|
|
|
fontRatio: fr
|
2017-03-12 11:05:18 -07:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-03-21 08:32:26 -07:00
|
|
|
// Lightbox for Gallery
|
|
|
|
|
2017-04-01 19:59:26 -07:00
|
|
|
function lightgallery(id) {
|
2017-03-21 08:32:26 -07:00
|
|
|
// Intialize all the media i.e. photos with "media" id
|
|
|
|
// TODO use Hugo params to initialize multiple galleries/albums
|
|
|
|
var lg = $(id).lightGallery({
|
|
|
|
thumbnail: true,
|
|
|
|
thumbWidth: 80,
|
|
|
|
controls: true,
|
|
|
|
loop: false,
|
|
|
|
download: false,
|
|
|
|
counter: true,
|
|
|
|
// videojs: true
|
|
|
|
});
|
|
|
|
|
|
|
|
lg.on('onBeforeOpen.lg', function (event) {
|
|
|
|
$('.nav-bar').css("display", "none")
|
|
|
|
});
|
|
|
|
|
|
|
|
lg.on('onCloseAfter.lg', function (event) {
|
|
|
|
$('.nav-bar').css("display", "flex")
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2017-04-07 01:40:29 -07:00
|
|
|
|
2017-04-08 14:24:15 -07:00
|
|
|
// Modal tool. Must use modal template for content
|
|
|
|
(function ($) {
|
|
|
|
|
|
|
|
// extend jquery so remove handlers can be added and removed at the right time in a group
|
|
|
|
$.fn.modalHandlers = function (state = 'on') {
|
|
|
|
|
|
|
|
if (state === 'on') {
|
|
|
|
$(document).on('click', modalClickOutside);
|
|
|
|
$(document).keypress(modalEsc);
|
|
|
|
this.find('a[modal-close]').on('click', modalClickCloser);
|
|
|
|
return this
|
|
|
|
}
|
2017-04-07 01:40:29 -07:00
|
|
|
|
2017-04-08 14:24:15 -07:00
|
|
|
if (state === 'off') {
|
|
|
|
$(document).off('click', modalClickOutside);
|
|
|
|
$(document).off('keypress', modalEsc);
|
|
|
|
this.find('a[modal-close]').off('click', modalClickCloser);
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// modal event handlers - add more if you want - add them to extension above
|
|
|
|
function modalEsc(event) {
|
|
|
|
if (event.key === "Escape") { modalHide() }
|
2017-04-07 01:40:29 -07:00
|
|
|
}
|
|
|
|
|
2017-04-08 14:24:15 -07:00
|
|
|
function modalClickOutside(event) {
|
|
|
|
var container = $(".section__container--modal");
|
|
|
|
if (!container.is(event.target) && // If the target of the click isn't the container...
|
|
|
|
container.has(event.target).length === 0) // ... nor a descendant of the container
|
|
|
|
{ modalHide(); }
|
|
|
|
}
|
2017-04-07 01:40:29 -07:00
|
|
|
|
2017-04-08 14:24:15 -07:00
|
|
|
function modalClickCloser(event) {
|
|
|
|
modalHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
// modal show and hide
|
|
|
|
function modalShow(modal_hash) {
|
2017-04-07 01:40:29 -07:00
|
|
|
var closer = "<a modal-close class='fa-stack fa-2x' ><i class='fa fa-circle-thin fa-stack-2x'></i><i class='fa fa-close fa-stack-1x'></i></a>"
|
2017-04-08 14:24:15 -07:00
|
|
|
$(modal_hash).find('.section__headline').append(closer).end().modalHandlers().addClass("current").css('display', 'flex');
|
2017-04-07 01:40:29 -07:00
|
|
|
}
|
2017-04-08 14:24:15 -07:00
|
|
|
|
|
|
|
function modalHide() {
|
|
|
|
$('.section--modal.current').hide().modalHandlers("off").removeClass("current").find('a[modal-close]').remove;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Register click event for all modal links on page
|
|
|
|
$("a[modal]").click(function () {
|
|
|
|
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
|
|
|
|
var target = this.hash;
|
|
|
|
modalShow(target);
|
|
|
|
} else {
|
|
|
|
alert(`modal display of off page content not supported`);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
}(jQuery));
|
|
|
|
|
2017-04-07 01:40:29 -07:00
|
|
|
// end modal
|