2019-05-04 19:02:00 +03:00
|
|
|
var body = $('body');
|
|
|
|
|
2019-05-08 19:38:28 +03:00
|
|
|
window.lazySizesConfig = window.lazySizesConfig || {};
|
|
|
|
window.lazySizesConfig.loadHidden = false;
|
|
|
|
|
2019-04-29 19:46:11 +03:00
|
|
|
$(function () {
|
|
|
|
'use strict';
|
|
|
|
social();
|
2019-04-30 18:00:55 +03:00
|
|
|
author();
|
2019-05-04 08:01:50 +03:00
|
|
|
stickySidebar();
|
|
|
|
pagination();
|
2019-05-09 14:14:57 +03:00
|
|
|
loadInstagram();
|
2019-05-14 18:48:55 +03:00
|
|
|
gallery();
|
|
|
|
copyright();
|
2019-05-04 19:02:00 +03:00
|
|
|
offCanvas();
|
2019-04-29 19:46:11 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
function social() {
|
|
|
|
'use strict';
|
|
|
|
var data = {
|
|
|
|
facebook: {name: 'Facebook', icon: 'facebook'},
|
|
|
|
twitter: {name: 'Twitter', icon: 'twitter'},
|
|
|
|
instagram: {name: 'Instagram', icon: 'instagram'},
|
|
|
|
dribbble: {name: 'Dribbble', icon: 'dribbble'},
|
|
|
|
behance: {name: 'Behance', icon: 'behance'},
|
|
|
|
github: {name: 'GitHub', icon: 'github-circle'},
|
|
|
|
linkedin: {name: 'LinkedIn', icon: 'linkedin'},
|
|
|
|
vk: {name: 'VK', icon: 'vk'},
|
|
|
|
rss: {name: 'RSS', icon: 'rss'},
|
|
|
|
};
|
|
|
|
var links = themeOptions.social_links;
|
|
|
|
var output = '';
|
|
|
|
|
|
|
|
for (var key in links) {
|
|
|
|
if (links[key] != '') {
|
|
|
|
output += '<a class="social-item" href="' + links[key] + '" target="_blank"><i class="icon icon-' + data[key]['icon'] + '"></i></a>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.social').html(output);
|
2019-04-30 18:00:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function author() {
|
|
|
|
'use strict';
|
|
|
|
$('.author-name').on('click', function () {
|
|
|
|
$(this).next('.author-social').toggleClass('enabled');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function stickySidebar() {
|
|
|
|
'use strict';
|
|
|
|
var marginTop = 30;
|
|
|
|
|
2019-05-04 19:02:00 +03:00
|
|
|
jQuery('.sidebar-column, .related-column').theiaStickySidebar({
|
2019-04-30 18:00:55 +03:00
|
|
|
additionalMarginTop: marginTop,
|
|
|
|
additionalMarginBottom: 30,
|
|
|
|
});
|
2019-05-04 08:01:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function pagination() {
|
|
|
|
'use strict';
|
|
|
|
var wrapper = $('.post-feed .row');
|
2019-05-09 14:14:57 +03:00
|
|
|
var button = $('.infinite-scroll-button');
|
2019-05-04 08:01:50 +03:00
|
|
|
|
2019-05-04 19:02:00 +03:00
|
|
|
if (body.hasClass('paged-next')) {
|
2019-05-09 14:14:57 +03:00
|
|
|
wrapper.on('request.infiniteScroll', function (event, path) {
|
|
|
|
button.hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
wrapper.on('load.infiniteScroll', function (event, response, path) {
|
|
|
|
if ($(response).find('body').hasClass('paged-next')) {
|
|
|
|
button.show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-04 08:01:50 +03:00
|
|
|
wrapper.infiniteScroll({
|
|
|
|
append: '.post-column',
|
|
|
|
button: '.infinite-scroll-button',
|
|
|
|
debug: false,
|
|
|
|
hideNav: '.pagination',
|
|
|
|
history: false,
|
|
|
|
path: '.pagination .older-posts',
|
|
|
|
scrollThreshold: false,
|
|
|
|
status: '.infinite-scroll-status',
|
|
|
|
});
|
|
|
|
}
|
2019-05-04 19:02:00 +03:00
|
|
|
}
|
|
|
|
|
2019-05-09 14:14:57 +03:00
|
|
|
function loadInstagram() {
|
|
|
|
'use strict';
|
|
|
|
var photos;
|
|
|
|
var feed = $('.instagram-feed');
|
|
|
|
|
|
|
|
if (themeOptions.instagram_token != '') {
|
|
|
|
if ( localStorage.getItem('instagram') !== null && (Math.floor(Date.now() / 1000) - JSON.parse(localStorage.getItem('instagram')).timestamp) < 300) {
|
|
|
|
photos = JSON.parse(localStorage.getItem('instagram')).photos;
|
|
|
|
outputInstagram(photos, feed);
|
|
|
|
} else {
|
|
|
|
$.ajax({
|
|
|
|
url: 'https://api.instagram.com/v1/users/self/media/recent/',
|
|
|
|
dataType: 'jsonp',
|
|
|
|
type: 'GET',
|
2019-05-27 10:32:25 +03:00
|
|
|
data: {access_token: themeOptions.instagram_token, count: 6},
|
2019-05-09 14:14:57 +03:00
|
|
|
success: function (result) {
|
|
|
|
photos = result.data;
|
|
|
|
var cache = {
|
|
|
|
photos: photos,
|
|
|
|
timestamp: Math.floor(Date.now() / 1000)
|
|
|
|
};
|
|
|
|
localStorage.setItem('instagram', JSON.stringify(cache));
|
|
|
|
outputInstagram(photos, feed);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
feed.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function outputInstagram(photos, feed) {
|
|
|
|
'use strict';
|
|
|
|
var photo;
|
|
|
|
var output = '';
|
|
|
|
|
|
|
|
for (var index in photos) {
|
|
|
|
photo = photos[index];
|
2019-05-27 10:32:25 +03:00
|
|
|
output += '<a class="instagram-feed-item" href="' + photo.link + '" target="_blank">' +
|
|
|
|
'<img class="u-object-fit" src="' + photo.images.thumbnail.url + '">' +
|
|
|
|
'<i class="instagram-feed-item-icon icon icon-instagram"></i>' +
|
|
|
|
'</a>';
|
2019-05-09 14:14:57 +03:00
|
|
|
}
|
|
|
|
|
2019-05-27 10:32:25 +03:00
|
|
|
feed.each(function(i, v) {
|
|
|
|
$(v).html(output);
|
|
|
|
$(v).css('height', Math.round($(v).height()) + 'px');
|
|
|
|
});
|
2019-05-09 14:14:57 +03:00
|
|
|
}
|
|
|
|
|
2019-05-14 18:48:55 +03:00
|
|
|
function gallery() {
|
|
|
|
'use strict';
|
|
|
|
var images = document.querySelectorAll('.kg-gallery-image img');
|
|
|
|
images.forEach(function (image) {
|
|
|
|
var container = image.closest('.kg-gallery-image');
|
|
|
|
var width = image.attributes.width.value;
|
|
|
|
var height = image.attributes.height.value;
|
|
|
|
var ratio = width / height;
|
|
|
|
container.style.flex = ratio + ' 1 0%';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyright() {
|
|
|
|
'use strict';
|
|
|
|
if (themeOptions.copyright != '') {
|
|
|
|
$('.copyright').html(themeOptions.copyright);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-04 19:02:00 +03:00
|
|
|
function offCanvas() {
|
|
|
|
'use strict';
|
2019-05-08 19:38:28 +03:00
|
|
|
$('.burger:not(.burger.close)').on('click', function () {
|
|
|
|
body.addClass('canvas-visible canvas-opened');
|
|
|
|
dimmer('open', 'medium');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.burger-close').on('click', function () {
|
|
|
|
if (body.hasClass('canvas-opened')) {
|
|
|
|
body.removeClass('canvas-opened');
|
|
|
|
dimmer('close', 'medium');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.dimmer').on('click', function () {
|
|
|
|
if (body.hasClass('canvas-opened')) {
|
|
|
|
body.removeClass('canvas-opened');
|
|
|
|
dimmer('close', 'medium');
|
|
|
|
}
|
2019-05-04 19:02:00 +03:00
|
|
|
});
|
2019-05-08 19:38:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function dimmer(action, speed) {
|
|
|
|
'use strict';
|
|
|
|
var dimmer = $('.dimmer');
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case 'open':
|
|
|
|
dimmer.fadeIn(speed);
|
|
|
|
break;
|
|
|
|
case 'close':
|
|
|
|
dimmer.fadeOut(speed);
|
|
|
|
break;
|
|
|
|
}
|
2019-04-29 19:46:11 +03:00
|
|
|
}
|