This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="toggle" class=""> | |
<div class="one"></div> | |
<div class="two"></div> | |
<div class="three"></div> | |
</div> | |
<!-- just toggle the "on" class with js :) --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://youmightnotneedjquery.com/ | |
// Returns first element that matches CSS selector {expr}. | |
// Querying can optionally be restricted to {container}’s descendants | |
function $(expr, container) { | |
return typeof expr === "string"? (container || document).querySelector(expr) : expr || null; | |
} | |
// Returns all elements that match CSS selector {expr} as an array. | |
// Querying can optionally be restricted to {container}’s descendants | |
function $$(expr, container) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.time("foo"); | |
// do stufff | |
console.timeEnd("foo"); | |
// http://codepen.io/KK4OXJ/pen/eNyRYr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
By Osvaldas Valutis, www.osvaldas.info | |
Available for use under the MIT License | |
@example : | |
var item = document.querySelector( '.item' ); | |
item.classList.add( 'disappear' ); | |
item.onCSSAnimationEnd( function() | |
{ | |
item.parentNode.removeChild( item ); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function excerpt($limit) { | |
$excerpt = explode(' ', get_the_excerpt(), $limit); | |
if (count($excerpt)>=$limit) { | |
array_pop($excerpt); | |
$excerpt = implode(" ",$excerpt).'...'; | |
} else { | |
$excerpt = implode(" ",$excerpt); | |
} | |
$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt); | |
return $excerpt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( get_post_gallery() ) : ?> | |
<div class="gallery-wrapper"> | |
<?php // build slider structure ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadImages(container){ | |
var $ctn = container, | |
els = $ctn.find('.tile-background'), | |
options = {}; | |
options.src = 'data-src'; | |
options.errorClass = 'lazyload--error'; | |
options.successClass = 'lazyload--success'; | |
els.each(function(index){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// to drop in functions.php | |
// changes occur at line 120 | |
add_action( 'wpcf7_init', 'wpcf7_add_shortcode_checkbox_alt' ); | |
function wpcf7_add_shortcode_checkbox_alt() { | |
wpcf7_add_shortcode( array( 'checkbox', 'checkbox*', 'radio' ), | |
'my_checkbox', true ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from http://corlan.org/2012/02/15/quick-hack-to-deal-with-touch-and-mouse-events/ | |
// not tested | |
function init() { | |
var el = document.getElementById('myDiv'); | |
el.addEventListener('mousemove', onMouseMove); | |
el.addEventListener('touchmove', onTouchMove); | |
} | |
function onMouseMove(e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://medium.com/@primozcigler/neat-trick-for-css-object-fit-fallback-on-edge-and-other-browsers-afbc53bbb2c3 | |
if ( ! Modernizr.objectfit ) { | |
$('.post__image-container').each(function () { | |
var $container = $(this), | |
imgUrl = $container.find('img').prop('src'); | |
if (imgUrl) { | |
$container | |
.css('backgroundImage', 'url(' + imgUrl + ')') | |
.addClass('compat-object-fit'); |
OlderNewer