2019-11-24 14:31:28 +00:00
|
|
|
{{ $jquery := resources.Get "js/jquery.min.js" | resources.Fingerprint }}
|
|
|
|
<script defer src="{{ $jquery.RelPermalink }}"></script>
|
|
|
|
{{ $masonry := resources.Get "js/masonry.pkgd.min.js" | resources.Fingerprint }}
|
|
|
|
<script defer src="{{ $masonry.RelPermalink }}"></script>
|
|
|
|
{{ $imagesloaded := resources.Get "js/imagesloaded.pkgd.min.js" | resources.Fingerprint }}
|
|
|
|
<script defer src="{{ $imagesloaded.RelPermalink }}"></script>
|
|
|
|
{{ $enquire := resources.Get "js/enquire.min.js" | resources.Fingerprint }}
|
|
|
|
<script defer src="{{ $enquire.RelPermalink }}"></script>
|
|
|
|
{{ $zzo := resources.Get "js/zzo.js" | resources.Minify | resources.Fingerprint }}
|
|
|
|
<script defer src="{{ $zzo.RelPermalink }}"></script>
|
2019-11-25 04:36:50 +00:00
|
|
|
{{ $photoSwipe := resources.Get "js/photoswipe.min.js" | resources.Fingerprint }}
|
|
|
|
<script defer src="{{ $photoSwipe.RelPermalink }}"></script>
|
|
|
|
{{ $photoSwipeUi := resources.Get "js/photoswipe-ui-default.min.js" | resources.Fingerprint }}
|
|
|
|
<script defer src="{{ $photoSwipeUi.RelPermalink }}"></script>
|
|
|
|
{{ $photoSwipeStyle := resources.Get "css/photoswipe/photoswipe.css" | resources.Minify }}
|
|
|
|
<link rel="stylesheet" href="{{ $photoSwipeStyle.RelPermalink }}">
|
|
|
|
{{ $photoSwipeSkin := resources.Get "css/photoswipe/custom-skin.css" | resources.Minify }}
|
|
|
|
<link rel="stylesheet" href="{{ $photoSwipeSkin.RelPermalink }}">
|
2019-11-04 13:09:44 +00:00
|
|
|
|
2019-11-24 14:31:28 +00:00
|
|
|
<script>
|
|
|
|
window.onload = function() {
|
|
|
|
// masonry
|
|
|
|
var $grid = $('.grid').masonry({
|
|
|
|
itemSelector: '.grid-item',
|
|
|
|
columnWidth: '.grid-sizer',
|
|
|
|
percentPosition: true,
|
|
|
|
});
|
|
|
|
$grid.imagesLoaded().progress(function () {
|
|
|
|
$grid.masonry();
|
|
|
|
});
|
2019-11-04 13:09:44 +00:00
|
|
|
|
2019-11-24 14:31:28 +00:00
|
|
|
$('.grid-item').mouseenter(function () {
|
|
|
|
$(this).children('.grid-item__desc').show();
|
|
|
|
});
|
2019-11-14 08:18:50 +00:00
|
|
|
|
2019-11-24 14:31:28 +00:00
|
|
|
$('.grid-item').mouseleave(function () {
|
|
|
|
$(this).children('.grid-item__desc').hide();
|
|
|
|
});
|
2019-11-04 13:09:44 +00:00
|
|
|
|
2019-11-24 14:31:28 +00:00
|
|
|
enquire.register("screen and (max-width:500px)", {
|
|
|
|
match: function () {
|
|
|
|
$('.grid-item').addClass('full');
|
|
|
|
$('.grid-sizer').addClass('full');
|
|
|
|
$('.grid-item').removeClass('half');
|
|
|
|
$('.grid-sizer').removeClass('half');
|
|
|
|
},
|
|
|
|
unmatch: function () {
|
|
|
|
$('.grid-item').addClass('half');
|
|
|
|
$('.grid-sizer').addClass('half');
|
|
|
|
$('.grid-item').removeClass('full');
|
|
|
|
$('.grid-sizer').removeClass('full');
|
|
|
|
},
|
|
|
|
}).register("screen and (max-width:700px)", {
|
|
|
|
match: function () {
|
|
|
|
$('.grid-item').addClass('half');
|
|
|
|
$('.grid-sizer').addClass('half');
|
|
|
|
$('.grid-item').removeClass('third');
|
|
|
|
$('.grid-sizer').removeClass('third');
|
|
|
|
},
|
|
|
|
unmatch: function () {
|
|
|
|
$('.grid-item').addClass('third');
|
|
|
|
$('.grid-sizer').addClass('third');
|
|
|
|
$('.grid-item').removeClass('half');
|
|
|
|
$('.grid-sizer').removeClass('half');
|
|
|
|
},
|
|
|
|
}).register("screen and (max-width:900px)", {
|
|
|
|
match: function () {
|
|
|
|
$('.grid-item').addClass('third');
|
|
|
|
$('.grid-sizer').addClass('third');
|
|
|
|
$('.grid-item').removeClass('quarter');
|
|
|
|
$('.grid-sizer').removeClass('quarter');
|
|
|
|
},
|
|
|
|
unmatch: function () {
|
|
|
|
$('.grid-item').addClass('quarter');
|
|
|
|
$('.grid-sizer').addClass('quarter');
|
|
|
|
$('.grid-item').removeClass('third');
|
|
|
|
$('.grid-sizer').removeClass('third');
|
|
|
|
},
|
|
|
|
}).register("screen and (max-width:1200px)", {
|
|
|
|
match: function () {
|
|
|
|
$('.grid-item').addClass('quarter');
|
|
|
|
$('.grid-sizer').addClass('quarter');
|
|
|
|
$('.grid-item').removeClass('fifth');
|
|
|
|
$('.grid-sizer').removeClass('fifth');
|
|
|
|
},
|
|
|
|
unmatch: function () {
|
|
|
|
$('.grid-item').addClass('fifth');
|
|
|
|
$('.grid-sizer').addClass('fifth');
|
|
|
|
$('.grid-item').removeClass('quarter');
|
|
|
|
$('.grid-sizer').removeClass('quarter');
|
|
|
|
},
|
|
|
|
});
|
2019-11-14 08:18:50 +00:00
|
|
|
|
2019-11-25 04:36:50 +00:00
|
|
|
// gallery
|
|
|
|
var pswpElement = $('.pswp')[0];
|
|
|
|
var imgElements = $('.single__contents').find('img');
|
|
|
|
var items = [];
|
|
|
|
|
|
|
|
{{ $mode:= .Params.Mode }}
|
|
|
|
var mode = JSON.parse({{ $mode | jsonify }});
|
2019-11-14 08:18:50 +00:00
|
|
|
|
2019-11-24 14:31:28 +00:00
|
|
|
imgElements.each(function (i, v) {
|
2019-11-25 04:36:50 +00:00
|
|
|
$(this).siblings().click(function (e) {
|
|
|
|
initGallery(i);
|
|
|
|
});
|
2019-11-24 14:31:28 +00:00
|
|
|
$(this).css('cursor', 'pointer');
|
2019-11-25 04:36:50 +00:00
|
|
|
|
|
|
|
var caption = null;
|
|
|
|
if (mode && mode.toLowerCase().includes('one')) {
|
|
|
|
caption = $(this).attr('alt');
|
|
|
|
} else {
|
|
|
|
caption = filename(v['src']);
|
|
|
|
}
|
|
|
|
|
|
|
|
items.push({
|
|
|
|
src: v['src'],
|
|
|
|
w: 0,
|
|
|
|
h: 0,
|
|
|
|
title: caption,
|
|
|
|
});
|
2019-11-24 14:31:28 +00:00
|
|
|
});
|
2019-11-25 04:36:50 +00:00
|
|
|
|
|
|
|
function filename(str) {
|
|
|
|
var s = str.replace(/\\/g, '/');
|
|
|
|
s = s.substring(s.lastIndexOf('/') + 1);
|
|
|
|
return str ? s.replace(/[?#].+$/, '') : s.split('.')[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
function initGallery(index) {
|
|
|
|
var options = { index: index };
|
|
|
|
var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
|
|
|
|
gallery.listen('imageLoadComplete', function (index, item) {
|
|
|
|
if (item.h < 1 || item.w < 1) {
|
|
|
|
let img = new Image();
|
|
|
|
img.onload = () => {
|
|
|
|
item.w = img.width;
|
|
|
|
item.h = img.height;
|
|
|
|
gallery.invalidateCurrItems();
|
|
|
|
gallery.updateSize(true);
|
|
|
|
}
|
|
|
|
img.src = item.src;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
gallery.init();
|
|
|
|
}
|
2019-11-24 14:31:28 +00:00
|
|
|
|
|
|
|
// search
|
2019-11-14 08:18:50 +00:00
|
|
|
{{ $searchLanguages := .Site.Params.searchLanguages }}
|
|
|
|
var searchLanguages = JSON.parse({{ $searchLanguages | jsonify }});
|
2019-11-24 16:30:46 +00:00
|
|
|
{{ if .Site.IsMultiLingual }}
|
|
|
|
var baseurl = "{{.Site.BaseURL}}{{.Site.LanguagePrefix}}";
|
|
|
|
{{ else }}
|
|
|
|
var baseurl = "{{.Site.BaseURL}}";
|
|
|
|
{{ end }}
|
2019-11-24 14:31:28 +00:00
|
|
|
|
2019-11-14 08:18:50 +00:00
|
|
|
if (!searchLanguages) {
|
|
|
|
searchLanguages = ['en'];
|
|
|
|
}
|
2019-11-24 14:31:28 +00:00
|
|
|
|
2019-11-05 09:22:06 +00:00
|
|
|
var lunrIndex = null;
|
|
|
|
var pagesIndex = null;
|
|
|
|
var searchResults = null;
|
|
|
|
var searchMenu = null;
|
|
|
|
|
|
|
|
function endsWith(str, suffix) {
|
|
|
|
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
|
|
|
}
|
2019-11-05 08:11:56 +00:00
|
|
|
|
2019-11-05 09:22:06 +00:00
|
|
|
function initLunr() {
|
|
|
|
if (!endsWith(baseurl, "/")) {
|
|
|
|
baseurl = baseurl + '/';
|
|
|
|
};
|
2019-11-20 17:45:46 +00:00
|
|
|
|
2019-11-05 09:22:06 +00:00
|
|
|
$.getJSON(baseurl + "index.json")
|
|
|
|
.done(function (index) {
|
|
|
|
pagesIndex = index;
|
|
|
|
lunrIndex = lunr(function () {
|
2019-11-14 08:18:50 +00:00
|
|
|
this.use(lunr.multiLanguage(...searchLanguages));
|
2019-11-05 09:22:06 +00:00
|
|
|
this.ref('uri');
|
|
|
|
this.field('title');
|
|
|
|
this.field('description');
|
2019-11-14 08:18:50 +00:00
|
|
|
this.field('content');
|
2019-11-05 09:22:06 +00:00
|
|
|
//this.field('tags');
|
|
|
|
//this.field('series');
|
|
|
|
//this.field('categories');
|
|
|
|
|
|
|
|
var that = this;
|
|
|
|
index.forEach(function (page) {
|
|
|
|
that.add(page);
|
|
|
|
});
|
2019-11-04 13:09:44 +00:00
|
|
|
});
|
2019-11-05 09:22:06 +00:00
|
|
|
})
|
|
|
|
.fail(function (jqxhr, textStatus, error) {
|
|
|
|
var err = textStatus + ", " + error;
|
|
|
|
console.error("Error getting Hugo index file:", err);
|
2019-11-04 13:09:44 +00:00
|
|
|
});
|
2019-11-05 09:22:06 +00:00
|
|
|
}
|
2019-11-05 08:11:56 +00:00
|
|
|
|
2019-11-05 09:22:06 +00:00
|
|
|
function search(query) {
|
|
|
|
return lunrIndex.search(query).map(function (result) {
|
|
|
|
return pagesIndex.filter(function (page) {
|
|
|
|
return page.uri === result.ref;
|
|
|
|
})[0];
|
|
|
|
});
|
|
|
|
}
|
2019-11-05 08:11:56 +00:00
|
|
|
|
2019-11-05 09:22:06 +00:00
|
|
|
function renderSearchResults(results) {
|
|
|
|
searchResults = document.getElementById('search-results');
|
|
|
|
searchMenu = document.getElementById('search-menu');
|
|
|
|
searchResults.setAttribute('class', 'dropdown is-active');
|
|
|
|
|
|
|
|
var content = document.createElement('div');
|
|
|
|
content.setAttribute('class', 'dropdown-content search-content');
|
|
|
|
|
|
|
|
if (results.length > 0) {
|
|
|
|
results.forEach(function (result) {
|
|
|
|
var item = document.createElement('a');
|
|
|
|
item.setAttribute('href', result.uri);
|
|
|
|
item.setAttribute('class', 'dropdown-item');
|
|
|
|
item.innerHTML = `<div class="menu-item"><div class="menu-item__title">» ${result.title}</div><div class="menu-item__desc">${result.description ? result.description : result.content}</div></div>`;
|
|
|
|
content.appendChild(item);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
var item = document.createElement('span');
|
2019-11-04 13:09:44 +00:00
|
|
|
item.setAttribute('class', 'dropdown-item');
|
2019-11-05 09:22:06 +00:00
|
|
|
item.innerText = 'No results found';
|
2019-11-04 13:09:44 +00:00
|
|
|
content.appendChild(item);
|
2019-11-05 09:22:06 +00:00
|
|
|
}
|
2019-11-04 13:09:44 +00:00
|
|
|
|
2019-11-05 09:22:06 +00:00
|
|
|
while (searchMenu.hasChildNodes()) {
|
|
|
|
searchMenu.removeChild(
|
|
|
|
searchMenu.lastChild
|
|
|
|
);
|
|
|
|
}
|
|
|
|
searchMenu.appendChild(content);
|
2019-11-05 08:11:56 +00:00
|
|
|
}
|
2019-11-04 13:09:44 +00:00
|
|
|
|
2019-11-20 06:55:05 +00:00
|
|
|
function renderSearchResultsMobile(results) {
|
|
|
|
searchResults = document.getElementById('search-mobile-results');
|
|
|
|
|
|
|
|
var content = document.createElement('div');
|
|
|
|
content.setAttribute('class', 'mobile-search__content');
|
|
|
|
|
|
|
|
if (results.length > 0) {
|
|
|
|
results.forEach(function (result) {
|
|
|
|
var item = document.createElement('a');
|
|
|
|
item.setAttribute('href', result.uri);
|
|
|
|
item.innerHTML = `<div class="mobile-search__item"><div class="mobile-search__item--title">» ${result.title}</div><div class="mobile-search__item--desc">${result.description ? result.description : result.content}</div></div>`;
|
|
|
|
content.appendChild(item);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
var item = document.createElement('span');
|
|
|
|
content.appendChild(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#search-mobile-results').empty();
|
|
|
|
searchResults.appendChild(content);
|
|
|
|
}
|
|
|
|
|
2019-11-05 09:22:06 +00:00
|
|
|
initLunr();
|
2019-11-04 13:09:44 +00:00
|
|
|
|
2019-11-05 09:22:06 +00:00
|
|
|
$("#search").on('input', function (e) {
|
|
|
|
if (!e.target.value) {
|
|
|
|
$('#search-results').attr('class', 'dropdown');
|
|
|
|
return null;
|
2019-11-04 13:09:44 +00:00
|
|
|
}
|
2019-11-20 06:55:05 +00:00
|
|
|
|
|
|
|
if ($(window).width() < 770) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-11-05 09:22:06 +00:00
|
|
|
var results = search(e.target.value);
|
|
|
|
renderSearchResults(results);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#search').on('blur', function () {
|
2019-11-20 06:55:05 +00:00
|
|
|
if ($(window).width() < 770) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-11-05 09:22:06 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
$('#search-results').attr('class', 'dropdown');
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#search').on('click', function (e) {
|
2019-11-20 06:55:05 +00:00
|
|
|
if ($(window).width() < 770) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-11-05 09:22:06 +00:00
|
|
|
if (!e.target.value) {
|
|
|
|
$('#search-results').attr('class', 'dropdown');
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
var results = search(e.target.value);
|
|
|
|
renderSearchResults(results);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#search').on('keydown', function (e) {
|
2019-11-20 06:55:05 +00:00
|
|
|
if ($(window).width() < 770) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-11-05 09:22:06 +00:00
|
|
|
var items = $('#search-menu .dropdown-item');
|
|
|
|
var activeIndex = $('#search-menu .dropdown-item.is-active').index();
|
|
|
|
|
|
|
|
items.removeClass('is-active');
|
|
|
|
if (e.key === 'ArrowDown') {
|
|
|
|
items.eq(activeIndex + 1).addClass('is-active');
|
|
|
|
} else if (e.key === 'ArrowUp') {
|
|
|
|
items.eq(activeIndex - 1).addClass('is-active');
|
|
|
|
} else if (e.key === 'Enter') {
|
|
|
|
var currentItemLink = items.eq(activeIndex).attr('href');
|
|
|
|
if (currentItemLink) {
|
|
|
|
location.href = currentItemLink;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-11-20 06:55:05 +00:00
|
|
|
|
|
|
|
$("#search-mobile").on('input', function(e) {
|
|
|
|
if (!e.target.value) {
|
|
|
|
$('#search-mobile-results').empty();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var results = search(e.target.value);
|
|
|
|
renderSearchResultsMobile(results);
|
|
|
|
});
|
2019-11-24 14:31:28 +00:00
|
|
|
}
|
|
|
|
</script>
|