jefklakscodex/static/js/codex.js

94 lines
2.6 KiB
JavaScript
Raw Normal View History

2018-05-15 20:55:14 +02:00
$(function() {
2018-05-17 20:30:00 +02:00
var disableResponsiveImagesForInlineLis = function() {
$('li img.img-responsive').each(function() {
$(this).removeClass('img-responsive');
$(this).css('border', 'none');
});
};
2018-05-15 20:55:14 +02:00
var enableLightboxOnClickImgInContent = function() {
$('.content-column-content img').click(function(e) {
var me = $(this);
e.preventDefault();
me.data('remote', me.attr('src'));
me.ekkoLightbox();
});
};
var enableScrollToTopOnInternalLinks = function() {
$('#totop').click(function() {
$.scrollTo($('#top'), 1000);
});
$('a.internal').click(function() {
$.scrollTo($($(this).data('to')), 1000);
});
};
var addRandomImageToSideBarMenus = function() {
var rand = Math.floor(Math.random() * 10) + 1;
$('.sidebar-menu li').mouseenter(function() {
$(this).css('background', '#f1f4dd url(/img/random/' + rand + '.gif) no-repeat right');
}).mouseleave(function() {
$(this).css('background', 'none');
}).click(function() {
location.href = $(this).find('a').attr('href');
});
};
var setSideBarPlatformHeight = function() {
$('.sidebar-game-platform').height($('.sidebar-content .img-inactive').height());
};
var animateActiveGameImagesIfFound = function() {
var animate = function() {
var active = $(this).find('.img-active');
if(active.length > 0) {
active.css('display', 'block');
$(this).find('.img-inactive').css('display', 'none');
}
};
var inanimate = function() {
var active = $(this).find('.img-active');
if(active.length > 0) {
active.css('display', 'none');
$(this).find('.img-inactive').css('display', 'block');
}
};
$('.box-masonry').mouseenter(animate).mouseleave(inanimate);
$('.sidebar-game-info').mouseenter(animate).mouseleave(inanimate);
};
2020-04-13 15:52:21 +02:00
var resizeSidebar = function() {
const height = document.querySelector('.content-column').clientHeight;
$('.sidebar-content').css('height', (height + 50) + 'px');
};
2020-04-13 17:23:08 +02:00
var hijackAppendChildToExecuteAfter = function(afterFn, elId) {
2020-04-13 17:12:32 +02:00
const _appendChild = Node.prototype.appendChild;
2020-04-13 17:16:30 +02:00
Node.prototype.appendChild = function(el) {
const result = _appendChild.apply(this, arguments);
2020-04-13 17:23:08 +02:00
if(el.id === elId) {
setTimeout(afterFn, 100);
}
return result;
2020-04-13 17:12:32 +02:00
}
}
2018-05-15 20:55:14 +02:00
animateActiveGameImagesIfFound();
setSideBarPlatformHeight();
addRandomImageToSideBarMenus();
enableScrollToTopOnInternalLinks();
enableLightboxOnClickImgInContent();
2018-05-17 20:30:00 +02:00
disableResponsiveImagesForInlineLis();
2020-04-13 15:52:21 +02:00
resizeSidebar();
2018-05-15 20:55:14 +02:00
2020-04-13 17:12:32 +02:00
// needed for Commento, no 'official' callback when done provided.
2020-04-13 17:23:08 +02:00
hijackAppendChildToExecuteAfter(resizeSidebar, 'commento-footer');
2020-04-13 15:46:20 +02:00
2018-05-15 20:55:14 +02:00
});