Skip to content

Instantly share code, notes, and snippets.

View jhned's full-sized avatar

Josh Nederveld jhned

View GitHub Profile
@jhned
jhned / createGeoJSONCircle.js
Created June 12, 2017 14:31
Add a circle overlay polygon in Mapbox
var createGeoJSONCircle = function(center, radiusInKm, points) {
if(!points) points = 64;
var coords = {
latitude: center[1],
longitude: center[0]
};
var km = radiusInKm;
@jhned
jhned / sticky-test.html
Created July 20, 2017 01:39
Sticky Test
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Sticky Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
@jhned
jhned / lender-snapshot-modified.html
Created October 16, 2018 20:00
Lender Snapshot Updates
<div class="lender-snapshot">
<div class="lender-snapshot__sidebar">
<h2 class="lender-snapshot__title">Advantage Student Loan Refinancing</h2>
<div class="lender-snapshot__logo">
<img width="300" height="70" src="https://i2.wp.com/www.credible.com/blog/wp-content/uploads/2017/11/ael_logo-1-1.png?fit=300%2C70&amp;ssl=1" class="attachment-large size-large wp-post-image" alt="Advantage Educational Loan" sizes="(max-width: 543px) 100vw, (max-width: 991px) 30vw, 300px" style="max-width: 250px;max-height: 60px;"
srcset="https://i2.wp.com/www.credible.com/blog/wp-content/uploads/2017/11/ael_logo-1-1.png?w=300&amp;ssl=1 300w, https://i2.wp.com/www.credible.com/blog/wp-content/uploads/2017/11/ael_logo-1-1.png?resize=150%2C35&amp;ssl=1 150w">
</div>
<a href="/refi/prequal/" class="lender-snapshot__cta">Compare Rates</a>
<div class="lender-snapshot__boxes">
<div class="lender-snapshot__box">
@jhned
jhned / no-label-for-HTML-fields.html
Created April 4, 2019 18:57
Ninja Forms If Statement
<script id="tmpl-nf-field-label" type="text/template">
<# if (data.type != 'html') { #>
<div class="nf-field-label"><label for="nf-field-{{{ data.id }}}"
id="nf-label-field-{{{ data.id }}}"
class="{{{ data.renderLabelClasses() }}}">{{{ data.label }}} {{{ ( 'undefined' != typeof data.required && 1 == data.required ) ? '<span class="ninja-forms-req-symbol">*</span>' : '' }}}</label></div>
<# } #>
</script>
@jhned
jhned / fluid-property.scss
Created April 11, 2019 17:29
Fluid Property
@mixin fluid_property($properties, $sizes, $include-default: true) {
$counter: 1;
$has-default: false;
$breakpoints-keys: map-keys($breakpoints);
@each $current-size in $sizes {
$continue: false;
$next-size: n;
@jhned
jhned / after-mail-sent.html
Created May 17, 2019 17:56
After mail sent
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
(function($) {
$('.beforeSuccess').css('display','none');
$('.afterSuccess').css('display','block');
}(jQuery));
}, false );
</script>
@jhned
jhned / home-specific-enqueues.php
Created March 24, 2020 15:25
Home Specific CSS
add_action( 'wp_enqueue_scripts', 'enqueue_scripts', 1 );
function enqueue_scripts() {
if ( is_front_page() ) {
// On the home page, enqueue the home CSS, and don't defer it.
// Include the full stylesheet as well, for UX CSS (e.g., :hover), but DO defer it with a filter on style_loader_tag.
wp_enqueue_style( 'site-screen-home-no-defer', get_template_directory_uri() . '/css/style.home.css', null, false, 'screen' );
wp_enqueue_style( 'site-screen', get_template_directory_uri() . '/css/style.css', null, false, 'screen' );
} else {
wp_enqueue_style( 'site-screen-no-defer', get_template_directory_uri() . '/css/style.css', null, false, 'screen' );
@jhned
jhned / stylesheet-prefetch-fallback.js
Last active April 20, 2020 18:27
A fallback for stylesheets loaded with prefetch
var DOMTokenListSupports = function (tokenList, token) {
if (!tokenList || !tokenList.supports) {
return;
}
try {
return tokenList.supports(token);
} catch (e) {
if (e instanceof TypeError) {
console.log("The DOMTokenList doesn't have a supported tokens list");
} else {
@jhned
jhned / stylesheet-prefetch-fallback-2.js
Created April 20, 2020 17:47
Use setTimeout and querySelectorAll for IE11-compatible prefetch fallback
function loadStylesheets() {
// Give it a few seconds so that the browsers that support prefetch + onload have a chance to load the styles.
// After a few seconds though, we should double-check to make sure the styles loaded.
setTimeout(function () {
var prefetchLinks = document.querySelectorAll('link[rel=prefetch]');
// The onload attribute should be switching out the rel value from prefetch to stylesheet.
// If that hasn't happened, then we'll need to manually intervene.
if (0 === prefetchLinks.length) {
@jhned
jhned / wordpress-prefetch-enqueues-class.php
Last active April 20, 2020 19:24
WordPress Enqueues Class using prefetch
<?php
/**
* Class Enqueues
*/
class Enqueues {
/**
* Used for version-ing of enqueued assets
*