2013-11-23 21:53:52 +01:00
|
|
|
|
|
|
|
$(ASAP = function(){
|
|
|
|
|
2013-11-29 21:36:09 +01:00
|
|
|
photoGrid.init();
|
2013-11-30 17:13:19 +01:00
|
|
|
siteNavigation.init();
|
2013-11-23 21:53:52 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$(window).load( AfterLoad = function() {
|
|
|
|
|
|
|
|
infiniteScroll.init();
|
2013-12-07 16:00:56 +01:00
|
|
|
siteEffects.init();
|
2013-11-23 21:53:52 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-11-30 17:13:19 +01:00
|
|
|
var siteNavigation = {
|
|
|
|
|
|
|
|
siteSearch: function() {
|
2013-12-01 00:47:47 +01:00
|
|
|
|
|
|
|
var $searchlink = $('.search-btn'),
|
2013-12-04 20:54:40 +01:00
|
|
|
$searcharea = $('.search-area'),
|
2013-12-01 00:47:47 +01:00
|
|
|
$searchfield = $('.search-field'),
|
|
|
|
$searchresults = $('.search-results'),
|
2013-12-04 20:54:40 +01:00
|
|
|
$searchpop = $('.popover');
|
2013-12-01 00:47:47 +01:00
|
|
|
|
|
|
|
// init jekyll search
|
|
|
|
$searchfield.simpleJekyllSearch({
|
2013-11-30 17:13:19 +01:00
|
|
|
searchResults : '.search-results',
|
|
|
|
searchResultsTitle : '',
|
|
|
|
template : '<a class="nav-link" href="{url}" title="{title}">{title}</a>',
|
|
|
|
});
|
2013-12-01 00:47:47 +01:00
|
|
|
|
|
|
|
$searchlink.click(function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
// show search
|
2013-12-04 20:54:40 +01:00
|
|
|
$searcharea.addClass('ready');
|
2013-12-01 00:47:47 +01:00
|
|
|
$searchfield.focus();
|
2013-12-04 20:54:40 +01:00
|
|
|
if ( $searchfield.val().length ) {
|
|
|
|
$searchpop.removeClass('hide');
|
|
|
|
}
|
2013-12-01 00:47:47 +01:00
|
|
|
|
|
|
|
// hide menu too just in case
|
2013-12-03 23:39:48 +01:00
|
|
|
if ( $('body').hasClass('menu-open') ) {
|
|
|
|
$('body').removeClass('menu-open');
|
2013-12-01 00:47:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind the hide controls
|
|
|
|
$(document).bind('click.hidethepop', function() {
|
2013-12-04 20:54:40 +01:00
|
|
|
$searcharea.removeClass('ready');
|
|
|
|
$searchpop.addClass('hide');
|
2013-12-01 00:47:47 +01:00
|
|
|
|
|
|
|
// unbind the hide controls
|
|
|
|
$(document).unbind('click.hidethepop');
|
|
|
|
});
|
|
|
|
|
2013-12-04 20:57:34 +01:00
|
|
|
// dont close thepop when click on thepop
|
2013-12-01 00:47:47 +01:00
|
|
|
$searchpop.click(function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2013-12-04 20:57:34 +01:00
|
|
|
// dont close thepop when click on search field
|
|
|
|
$searchfield.click(function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2013-12-01 00:47:47 +01:00
|
|
|
|
|
|
|
// and dont close thepop now
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
|
2013-12-04 20:54:40 +01:00
|
|
|
// finally show popup upon first keypress
|
|
|
|
$searchfield.on('keyup', function() {
|
|
|
|
$searchpop.removeClass('hide');
|
|
|
|
});
|
|
|
|
|
|
|
|
// close button
|
2013-12-01 00:47:47 +01:00
|
|
|
$('.search-close').click(function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
// hide search area
|
2013-12-04 20:54:40 +01:00
|
|
|
$searcharea.removeClass('ready');
|
|
|
|
$searchpop.addClass('hide');
|
2013-12-01 00:47:47 +01:00
|
|
|
|
|
|
|
// empty search field
|
|
|
|
$searchfield.val('').blur();
|
|
|
|
});
|
2013-11-30 17:13:19 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
siteMenu: function() {
|
2013-12-01 00:47:47 +01:00
|
|
|
var $thelink = $('.menu-btn'),
|
|
|
|
$thepop = $('.nav-main .nav-popover');
|
|
|
|
|
|
|
|
$thelink.click(function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
|
2013-12-01 16:00:12 +01:00
|
|
|
// toggle menu
|
2013-12-03 23:39:48 +01:00
|
|
|
$('body').toggleClass('menu-open');
|
2013-12-01 00:47:47 +01:00
|
|
|
|
|
|
|
// bind the hide controls
|
2013-12-03 23:39:48 +01:00
|
|
|
$(document).bind('click.hidethepop', function() {
|
|
|
|
$('body').removeClass('menu-open');
|
2013-12-01 00:47:47 +01:00
|
|
|
// unbind the hide controls
|
2013-12-03 23:39:48 +01:00
|
|
|
$(document).unbind('click.hidethepop');
|
2013-12-01 00:47:47 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// dont close thepop when you click on thepop
|
|
|
|
$thepop.click(function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
|
|
|
|
// and dont close thepop now
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2013-11-30 17:13:19 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
init: function(){
|
|
|
|
this.siteSearch();
|
|
|
|
this.siteMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-29 21:36:09 +01:00
|
|
|
var photoGrid = {
|
|
|
|
|
|
|
|
masonryLayout: function() {
|
|
|
|
var $container = $('#main .masonry');
|
|
|
|
|
|
|
|
$container.imagesLoaded( function(){
|
|
|
|
$container.masonry({
|
|
|
|
itemSelector : 'article',
|
|
|
|
columnWidth : '.grid-sizer'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
init: function(){
|
|
|
|
// only fire when photo page present and screen bigger than 480px
|
|
|
|
if ( $('.page-photos').length > 0 ) {
|
|
|
|
this.masonryLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-11-23 21:53:52 +01:00
|
|
|
|
|
|
|
var siteEffects = {
|
2013-11-30 17:13:19 +01:00
|
|
|
|
2013-12-07 16:00:56 +01:00
|
|
|
socialiteButtons: function() {
|
|
|
|
|
|
|
|
$('.comments').one('mouseenter', function() {
|
|
|
|
Socialite.load($(this)[0]);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2013-11-23 21:53:52 +01:00
|
|
|
init: function(){
|
2013-12-07 16:00:56 +01:00
|
|
|
this.socialiteButtons();
|
2013-11-23 21:53:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var infiniteScroll = {
|
|
|
|
|
|
|
|
infiniteScrollSetup: function() {
|
|
|
|
|
2013-12-02 22:49:21 +01:00
|
|
|
if ( $('.page-photos').length > 0 ) {
|
2013-11-23 21:53:52 +01:00
|
|
|
var items = '#main .masonry';
|
|
|
|
} else {
|
|
|
|
var items = '#main article.hentry';
|
|
|
|
}
|
|
|
|
var $scrollContent = $('#main');
|
|
|
|
|
|
|
|
$scrollContent.infinitescroll({
|
|
|
|
itemSelector : items,
|
|
|
|
nextSelector : '.next a',
|
2013-12-03 21:11:38 +01:00
|
|
|
navSelector : '.paginator',
|
2013-11-23 21:53:52 +01:00
|
|
|
binder : $scrollContent,
|
|
|
|
behavior : 'krlc3',
|
|
|
|
}, function($scrollContent) {
|
|
|
|
// run picturefill over retrieved items
|
|
|
|
picturefill();
|
|
|
|
// run the photogrid over retrieved items
|
2013-12-02 22:49:21 +01:00
|
|
|
photoGrid.init();
|
2013-11-23 21:53:52 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
init: function(){
|
|
|
|
this.infiniteScrollSetup();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
--------------------------------
|
|
|
|
Infinite Scroll Behavior
|
|
|
|
Manual mode with minimal loader
|
|
|
|
|
|
|
|
Usage: behavior: 'krlc3'
|
|
|
|
--------------------------------
|
|
|
|
*/
|
|
|
|
$.extend($.infinitescroll.prototype,{
|
|
|
|
|
|
|
|
_setup_krlc3: function infscr_setup_krlc3 () {
|
|
|
|
var opts = this.options,
|
|
|
|
instance = this,
|
|
|
|
loader = $('<span class="loading"> ...</span>');
|
|
|
|
|
|
|
|
$(opts.nextSelector).parent().parent().addClass('infiniteLoader');
|
|
|
|
|
|
|
|
// Bind nextSelector link to retrieve
|
|
|
|
$(opts.nextSelector).click(function(e) {
|
|
|
|
if (e.which == 1 && !e.metaKey && !e.shiftKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
instance.retrieve();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// custom start
|
|
|
|
instance.options.loading.start = function (opts) {
|
|
|
|
loader
|
|
|
|
.appendTo(opts.nextSelector)
|
|
|
|
.show(opts.loading.speed, function () {
|
|
|
|
instance.beginAjax(opts);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// custom finish
|
|
|
|
instance.options.loading.finished = function(opts) {
|
|
|
|
loader.detach();
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|