Skip to content

Instantly share code, notes, and snippets.

@KaiserEMP
KaiserEMP / js
Created December 6, 2018 11:34
js
$('.eda-module-type-slider .slides').imagesLoaded(function () {
//console.log('all images loaded');
$('.eda-module-type-slider .slides').addClass('images-loaded');
$('.eda-module-type-slider').each(function (index, value) {
var slides = $(this).find('.slide');
if (slides.length > 1) {
jFadeBanner($(this));
}
});
@KaiserEMP
KaiserEMP / js
Created December 3, 2018 14:56
asd
* Get Viewport Dimensions
* returns object with viewport dimensions to match css in width and height properties
* ( source: http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript )
*/
function updateViewportDimensions() {
var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;
return { width:x,height:y };
}
// setting the viewport width
var viewport = updateViewportDimensions();
@KaiserEMP
KaiserEMP / js
Created December 3, 2018 14:52
JOM
$('.current-post-ancestor').each(function(i, e) {
$(this).closest('.menu-item-has-children').addClass('current-post-ancestor');
});
@KaiserEMP
KaiserEMP / js
Created November 28, 2018 16:00
js
/* If is visible in viewport */
$.fn.isInViewport = function() {
var element = this;
var elementHeight = element.outerHeight();
var scrollTop = $(window).scrollTop();
var viewportHeight = $( window ).height();
var elementOffset = element.offset();
var inViewportHeight = elementHeight + viewportHeight;
if ((scrollTop + viewportHeight) > elementOffset.top && scrollTop < (elementOffset.top + elementHeight) ) {
return (((scrollTop + viewportHeight - elementOffset.top) / inViewportHeight) * 100).toFixed(3);
@KaiserEMP
KaiserEMP / js
Created October 28, 2018 12:32
js
/* Toggle submenus */
$('.megamenu-container .expander').click(function(){
$(this).parent().toggleClass('current-menu-item');
});
/* Toggle desktop submenus */
$('.megamenu-container .sub-menu-container .expander').click(function(){
$(this).parent().toggleClass('current-menu-drop');
});
function applePie() {
return ( navigator.userAgent.match(/(iPhone|iPod|iPad)/i) );
}
$('.fancy-overlay').fancybox({
your: 'settings',
afterShow: function() {
if ( applePie() ) { $('body').css({'position': 'fixed'}); }
},
afterClose: function() {
@KaiserEMP
KaiserEMP / js
Created October 9, 2018 21:28
sdf
function reserveHeaderSpace() {
if (!$('body').hasClass('not-top')) {
var headerHeight = $('header.header').outerHeight();
if (!$('body').hasClass("mobile-menu-visible")) {
if (!$('body').hasClass("search-visible")) {
$('.content-wrap').css('padding-top', headerHeight);
}
}
} else {
$('.content-wrap').css('padding-top', '');
@KaiserEMP
KaiserEMP / js
Last active September 18, 2018 07:40
assd
function outMenu() {
var openHeader = $('header.header > .container').outerHeight();
var headerBlock = $('.eda-module-type-slider .outer');
//console.log(openHeader);
var scrollDistance = $(window).scrollTop();
//console.log('scroll ' + scrollDistance);
var windowHeight = $(window).outerHeight();
//console.log('window ' + windowHeight);
var sliderHeight = $('.eda-module-type-slider').outerHeight();
@KaiserEMP
KaiserEMP / js
Last active September 18, 2018 07:37
Various short scripts
// Make jQuery work
var script = document.createElement('script');
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(script);
// Create a div
$0.appendChild(document.createElement('div'));
// Disable CSS
$('style,link[rel="stylesheet"]').remove();
@KaiserEMP
KaiserEMP / css
Created September 14, 2018 08:03
Use OTF,
@font-face {
font-family: 'bariol_boldbold';
src: url('Bariol_Bold.otf') format('opentype');
font-weight: normal;
font-style: normal;
}