2017-06-08 12:36:32 +00:00
|
|
|
/**
|
|
|
|
* Main JS file for Casper behaviours
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* globals jQuery, document */
|
|
|
|
(function ($, undefined) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var $document = $(document);
|
|
|
|
|
|
|
|
$document.ready(function () {
|
|
|
|
|
|
|
|
var $postContent = $(".post-content");
|
|
|
|
$postContent.fitVids();
|
|
|
|
|
2017-07-13 13:22:43 +00:00
|
|
|
$(".scroll-up").arctic_scroll();
|
|
|
|
|
|
|
|
var scrollTarget = (window.innerHeight * 0.30);
|
|
|
|
// Don't hide this earlier (in CSS) for SEO reasons
|
|
|
|
$('.hidden-content').hide();
|
|
|
|
|
|
|
|
// On scroll, check if the height is passed, and if so, trigger.
|
|
|
|
$(document).scroll(function(e){
|
2017-07-13 16:04:03 +00:00
|
|
|
if ($document.width() > 767) {
|
|
|
|
if (window.scrollY >= scrollTarget) {
|
|
|
|
$('#scroll-arrow').hide(200);
|
|
|
|
$('.hidden-content').fadeIn(100);
|
|
|
|
} else if (window.scrollY < scrollTarget) {
|
|
|
|
$('.hidden-content').fadeOut(200);
|
|
|
|
$('#scroll-arrow').show(200);
|
|
|
|
}
|
2017-07-13 13:22:43 +00:00
|
|
|
}
|
2017-06-08 12:36:32 +00:00
|
|
|
});
|
2017-07-13 16:04:03 +00:00
|
|
|
|
2017-07-14 11:39:45 +00:00
|
|
|
$(window).resize(function() {resizeHeader();});
|
2017-07-13 16:04:03 +00:00
|
|
|
resizeHeader();
|
|
|
|
|
|
|
|
function resizeHeader() {
|
2017-07-14 11:39:45 +00:00
|
|
|
var hide = true;
|
|
|
|
|
|
|
|
if ($('#scroll-arrow').is(':visible')) {
|
|
|
|
hide = false;
|
|
|
|
} else if ($(window).width() > 767) {
|
|
|
|
$('#scroll-arrow').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
var overhang = $(window).height() - $('.top-content').outerHeight();
|
|
|
|
var height = $('.hidden-content').height();
|
|
|
|
|
|
|
|
var calculated = 200;
|
|
|
|
|
2017-07-13 16:04:03 +00:00
|
|
|
if ($(window).width() > 767) {
|
2017-07-14 11:39:45 +00:00
|
|
|
calculated = (height - overhang + ($(window).height() * 0.2));
|
|
|
|
} else if ($('.hidden-content').is(":visible")) {
|
|
|
|
calculated = (height - overhang + ($(window).height() * 0.5));
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.below-header').height(calculated);
|
|
|
|
|
|
|
|
if (hide) {
|
|
|
|
$('#scroll-arrow').hide();
|
2017-07-13 16:04:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.mobile-button').click(function() {
|
|
|
|
$('.hidden-content').fadeIn(100);
|
|
|
|
resizeHeader();
|
|
|
|
})
|
2017-06-08 12:36:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Arctic Scroll by Paul Adam Davis
|
|
|
|
// https://github.com/PaulAdamDavis/Arctic-Scroll
|
|
|
|
$.fn.arctic_scroll = function (options) {
|
|
|
|
|
|
|
|
var defaults = {
|
|
|
|
elem: $(this),
|
|
|
|
speed: 500
|
|
|
|
},
|
|
|
|
|
|
|
|
allOptions = $.extend(defaults, options);
|
|
|
|
|
|
|
|
allOptions.elem.click(function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
var $this = $(this),
|
|
|
|
$htmlBody = $('html, body'),
|
|
|
|
offset = ($this.attr('data-offset')) ? $this.attr('data-offset') : false,
|
|
|
|
position = ($this.attr('data-position')) ? $this.attr('data-position') : false,
|
|
|
|
toMove;
|
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
toMove = parseInt(offset);
|
|
|
|
$htmlBody.stop(true, false).animate({scrollTop: ($(this.hash).offset().top + toMove) }, allOptions.speed);
|
|
|
|
} else if (position) {
|
|
|
|
toMove = parseInt(position);
|
|
|
|
$htmlBody.stop(true, false).animate({scrollTop: toMove }, allOptions.speed);
|
|
|
|
} else {
|
|
|
|
$htmlBody.stop(true, false).animate({scrollTop: ($(this.hash).offset().top) }, allOptions.speed);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
})(jQuery);
|