Skip to content

Instantly share code, notes, and snippets.

@dbushell
dbushell / gist:2567294
Created May 1, 2012 10:55
HTML Entities with jQuery and the Browser
View gist:2567294
var div = $('<div/>');
function encodeEntities(str) {
return div.text(str).html();
}
function decodeEntities(str) {
return div.html(str).text();
}
@dbushell
dbushell / gist:2773801
Created May 23, 2012 08:06
Touchscreen swipe events for image rotator
View gist:2773801
if (Modernizr.touch) {
var hero = $('#hero');
var touchCancel = function()
{
hero[0].removeEventListener('touchmove', touchMove, false);
hero[0].data('touch', false);
};
@dbushell
dbushell / dabblet.css
Created July 12, 2012 17:04
Diagonal Stripe Background with CSS and SVG
View dabblet.css
/**
* Diagonal Stripe Background with CSS and SVG
*/
body {
padding: 0;
margin: 0;
}
#content {
@dbushell
dbushell / gist:4131104
Created November 22, 2012 13:10
Animate scrolling to an element or offset
View gist:4131104
/*!
* requires jQuery
* usage:
* Scroller.to({ offset: 100 });
* Scroller.to({ target: $('#main') });
*
* advanced usage (with additional easing function not provided here)
* Scroller.to({ target: $('#main'), delay: 500, multiplier: 1.5, easing: 'easeOutQuad' });
*/
var Scroller = (function()
@dbushell
dbushell / gist:4247060
Created December 9, 2012 21:19
Add SVG upload support to a WordPress theme
View gist:4247060
// add to functions.php in your WordPress theme
add_filter('upload_mimes', 'my_upload_mimes');
function my_upload_mimes($mimes = array())
{
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
View gist:5038289
$('input[type="date"]').each(function()
{
var picker = new Pikaday({ field: this });
$(this).data('pikaday', picker);
});
@dbushell
dbushell / gist:5186122
Last active December 15, 2015 02:19
Grunt task to build HTML templates with includes (work in progress!)
View gist:5186122
/*!
*
* Copyright (c) David Bushell | @dbushell | http://dbushell.com/
*
*/
var fs = require("fs"),
path = require("path");
module.exports = function(grunt)
@dbushell
dbushell / htmlizr.js
Last active December 15, 2015 20:19
Grunt task to build HTML templates with includes (original version: https://gist.github.com/dbushell/5186122)
View htmlizr.js
/*!
*
* Copyright (c) David Bushell | @dbushell | http://dbushell.com/
*
*/
var fs = require("fs"),
path = require("path");
module.exports = function(grunt)
View gist:6369330
// http://jasonwyatt.tumblr.com/post/10481498815/how-to-correctly-debounce-a-javascript-function
function debounce(fn, debounceDuration)
{
debounceDuration = debounceDuration || 100;
return function(){
if(!fn.debouncing){
var args = Array.prototype.slice.apply(arguments);
fn.lastReturnVal = fn.apply(window, args);
fn.debouncing = true;
View gist:9afdcb229f15a3bbb0a4
<?php
add_action('ninja_forms_display_js', 'dbushell__ninja_forms_display_js');
add_action('ninja_forms_display_css', 'dbushell__ninja_forms_display_css');
function dbushell__ninja_forms_display_js()
{
if (is_admin()) {
return;
}