Skip to content

Instantly share code, notes, and snippets.

View andrewlaskey's full-sized avatar

Andrew Laskey andrewlaskey

View GitHub Profile
@andrewlaskey
andrewlaskey / _base.scss
Created February 20, 2013 17:11
Adding ACF Location Field Edit to Front-end
//In my base scss file I copied and pasted the css from the location field plugin
.location_dl {margin-left:10px;}
.location_dl::after
{
content:"";
display:table;
clear:both;
}
.location_dt-address,
@andrewlaskey
andrewlaskey / setAllToMaxHeight.js
Created April 4, 2013 16:40
Set All To Max Height Function
//Paul Irish - http://www.broken-links.com/2009/01/20/very-quick-equal-height-columns-in-jquery/
$.fn.setAllToMaxHeight = function(){
return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
}
@andrewlaskey
andrewlaskey / stickyTitles.js
Last active October 9, 2018 20:03
Sticky Instagram-like Headers
//http://stackoverflow.com/questions/13279725/getting-a-sticky-header-to-push-up-like-in-instagrams-iphone-app-using-css-a
function stickyTitles(stickies) {
this.load = function() {
stickies.each(function(){
var thisSticky = jQuery(this).wrap('<div class="followWrap" />');
thisSticky.parent().height(thisSticky.outerHeight());
@andrewlaskey
andrewlaskey / example.php
Created April 4, 2013 16:56
Modified Backstretch.js to keep image aspect ratio constant when container dimensions change
<?php $imgdata = wp_get_attachment_image_src( get_post_thumbnail_id(), "full");
$imgurl = $imgdata[0]; // the url of the thumbnail picture
$imgwidth = $imgdata[1]; // thumbnail's width
$imgheight = $imgdata[2]; // thumbnail's height
if ($imgheight > 0) {
$ratio = $imgwidth / $imgheight;
} else {
$ratio = 1;
}
?>
@andrewlaskey
andrewlaskey / checkIfExists.js
Created April 4, 2013 17:08
Simple check if element exists function
var checkIfExists = function(id) {
if (document.getElementById(id)) {
return true;
}
return false;
};
@andrewlaskey
andrewlaskey / reveal_slider.html
Last active December 15, 2015 19:49
A responsive image with a slider to reveal hidden text.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Idiom Test - Slider</title>
<style type="text/css">
.wrapper {
position: relative;
width: 100%;
height: 500px;
@andrewlaskey
andrewlaskey / vertical-rhythm.scss
Last active April 28, 2019 20:11
Vertical Rhythm Template for SASS projects
//Taken from: http://csswizardry.com/2012/02/pragmatic-practical-font-sizing-in-css/
/* Housekeeping */
*{ margin:0; padding:0; }
/* Define your base font-size here; most elements will inherit this. */
html{
font-size:1em; /* Assuming 16px... */
line-height:1.5; /* 24px (This is now our magic number; all subsequent margin-bottoms and line-heights want to be a multiple of this number in order to maintain vertical rhythm.) */
}
@andrewlaskey
andrewlaskey / numbers_with_commas.js
Created August 9, 2013 22:00
Print a number in javascript with commas as thousands separators
//http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
@andrewlaskey
andrewlaskey / functions.php
Last active December 23, 2015 22:49
Wordpress useful common url shortcodes
<?php
//[imagedir]
function image_directory() {
return get_stylesheet_directory_uri() . '/images/';
}
add_shortcode('imagedir', 'image_directory');
//[homeurl]
function home_url_shortcode() {
@andrewlaskey
andrewlaskey / stretch.html
Created September 30, 2013 18:14
Dynamically set a background image to a div that will keep its aspect ratio when the div resizes.
<div class="Item" data-stretch="images/some_image.png">