Skip to content

Instantly share code, notes, and snippets.

View maxxcrawford's full-sized avatar

Maxx Crawford maxxcrawford

View GitHub Profile
@maxxcrawford
maxxcrawford / dateShow.js
Last active December 17, 2015 16:09
Show/Hide Date Expiration
var dateExpire = function(){
var today = new Date(); //Get Raw Current Date
var dd = today.getDate(); // Formate Date
var mm = today.getMonth()+1; // Format Month
var yyyy = today.getFullYear();
if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} today = mm+'/'+dd+'/'+yyyy; // Assemble mm/dd/yy date
$('.boo').each(function(){
if ($(this).attr('data-expire') < today){
$(this).hide();
} else {
@maxxcrawford
maxxcrawford / colorboxResizer.js
Last active December 21, 2015 21:48
Colorbox Responsive Resizer
/* Colorbox resize function */
var resizeTimer;
function resizeColorBox()
{
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
if (jQuery('#cboxOverlay').is(':visible')) {
jQuery.colorbox.load(true);
}
}, 300)
@maxxcrawford
maxxcrawford / addEventListenerIE8.js
Last active December 21, 2015 23:09
addEventListener / IE8 Fix
if (!window.addEventListener) {
// DO NOTHING
//window.attachEvent("orientationchange", resizeColorBox);
}
else {
window.addEventListener("orientationchange", resizeColorBox, false);
}
@maxxcrawford
maxxcrawford / smoothScroll.js
Created November 14, 2013 23:25
Smooth animate/scroll to snippet
$(".scroll").click(function(event){
event.preventDefault();
//calculate destination place
var dest=0;
if($(this.hash).offset().top > $(document).height()-$(window).height()){
dest=$(document).height()-$(window).height();
}else{
dest=$(this.hash).offset().top;
}
//go to destination
@maxxcrawford
maxxcrawford / ajaxCall.js
Created November 19, 2013 21:24
AJAX Call
var cache = {};
function getData( val ){
// Return a promise from the cache (if available)
// or create a new one (a jqXHR object) and store it in the cache.
var promise = cache[val];
if (!promise) {
promise = $.ajax('/foo/', {
data: { value: val },
@maxxcrawford
maxxcrawford / unknownCentering-IE.css
Created January 17, 2014 17:25
An update to a method found on css-tricks.com to center items within each other without using table positioning. Source: http://css-tricks.com/centering-in-the-unknown/
.block:before {
border: none;
width: 0;
}
@maxxcrawford
maxxcrawford / newYear.js
Last active January 3, 2016 14:39
A simple JS snippet to automatically display the current year. This is primarily used for the copyright located in the footer.
document.write(new Date().getFullYear());
@maxxcrawford
maxxcrawford / sphere-scale.html
Created February 12, 2014 20:44
CSS Transform/Animation Scale Example ( http://jsfiddle.net/aNX9h )
<!doctype html>
<html>
<head>
<title>CSS animations: Example 1</title>
<style type="text/css">
body {
padding: 20px;
}
@maxxcrawford
maxxcrawford / placeholder-shim.js
Created April 14, 2014 21:37
Placeholder Shim (Modernizr Test)
/* global Modernizr */
(function (app, $, window, document, undefined) {
/* SHIM: <input> placeholder shim
--------------------------------------------------------------------------- */
if(!Modernizr.input.placeholder){
$(document).on('focus', 'input[placeholder], textarea[placeholder]', function() {
var input = $(this);
if (input.val() === input.attr('placeholder')) {
input.val('').removeClass('placeholder');
}
// ImageMagick - Convert SVG to PNG w/ transparency
//
// - open terminal
//
// - confirm you have imagemagick installed
// --- type: convert -v
//
// - cd to folder
//
// - single file