Skip to content

Instantly share code, notes, and snippets.

@rhysburnie
rhysburnie / jquery.externallinks.js
Last active August 29, 2015 13:59
Return filtered collection of external links
@rhysburnie
rhysburnie / rAF.js
Last active August 29, 2015 14:01 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Moller. fixes from Paul Irish and Tino Zijdel
// sorry Erik the umlaut in your name was causing errors in most compilers so replaced it with "o"
// MIT license
(function() {
var lastTime = 0;
(function() {
var lastScrollY = 0;
var ticking = false;
var update = function() {
// do your stuff
ticking = false;
};
var requestTick = function() {
// selectorSupported lovingly lifted from the mad italian genius, diego perini
// http://javascript.nwbox.com/CSSSupport/
function selectorSupported(selector){
var support, link, sheet, doc = document,
root = doc.documentElement,
head = root.getElementsByTagName('head')[0],
impl = doc.implementation || {
hasFeature: function() {
@rhysburnie
rhysburnie / faClassNames
Last active August 29, 2015 14:06
Get a list of available fontawesome classnames
/**
* @requires jQuery (which is on the fontawesome page already)
*
* I wrote this when we needed to create an array of available
* fontawesome classnames for a 'select icon' interface but
* didn't want to do it manually.
*
* What it does:
*
* Gets a comma seperated list of fontawesome classname strings
/*!
* quantize.js Copyright 2008 Nick Rabinowitz.
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
// fill out a couple protovis dependencies
/*!
* Block below copied from Protovis: http://mbostock.github.com/protovis/
* Copyright 2010 Stanford Visualization Group
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
@rhysburnie
rhysburnie / foreach-notnative.js
Last active August 29, 2015 14:21
forEach function for looping results from `querySelectorAll`
/**
* Primarily for looping `querySelectorAll` results (`NodeList`)
*
* Avoid array hacks like: `[].forEach.call(NodeList)`
* see: http://toddmotto.com/ditch-the-array-foreach-call-nodelist-hack/
*/
+function(exports){
// exposed on this global object
var exposed = 'notnative';
+function(exports){
// exposed on this global object
var exposed = 'notnative';
/**!
* @author Rhys Burnie
* @description native js coordinates tool for scripts consumption.
* @licence MIT
* Copyright Rhys Burnie
*/
@rhysburnie
rhysburnie / element-matches-polyfill.js
Last active October 21, 2015 04:15
Polyfill Element.matches
if(typeof window!=="undefined"){
window.Element && function(proto) {
if(!proto.matches) {
proto.matches = proto.matchesSelector ||
proto.mozMatchesSelector ||
proto.msMatchesSelector ||
proto.oMatchesSelector ||
proto.webkitMatchesSelector ||
function (selector) {
var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1;
@rhysburnie
rhysburnie / myns.makeShapeComposite.js
Last active December 16, 2015 01:19
makeShapeComposite function for Kineticjs
/**
* makeShapeComposite function on a gloabl namespace - see var namespace
*
* ns.kineticSupport.makeShapeComposite(shape, operation);
* @param Kinetic.Shape (family)
* @param Sting - valid globalCompositeOperation name
* @return the supplied shape after globalCompositeOperation set
*/
(function(){
var namespace = 'myns',