Skip to content

Instantly share code, notes, and snippets.

View shaneharter's full-sized avatar

Shane Harter shaneharter

View GitHub Profile
@shaneharter
shaneharter / backbone_pushstate_router.js
Last active August 29, 2015 14:06 — forked from wololodev/backbone_pushstate_router.js
Play nice with Backbone.history.root when attaching pushstate click handler
// Only need this for pushState enabled browsers
if (Backbone.history && Backbone.history._hasPushState) {
var $document = $(window.document);
var openLinkInTab = false;
// Links like <a href="some/thing/here"> are relative to the page.
// We want to run these links thru the router
var is_relative_to_page = function(href) {
return href.match(/^\/|(http:|https:|ftp:|mailto:|javascript:)/) === null;
};
@shaneharter
shaneharter / tap.js
Created December 18, 2012 18:43 — forked from evilbuck/tap.js
Object.defineProperty(Object.prototype, 'tap', {
value: function(fun){
fun.call( this );
return this;
},
enumerable: false
});
// Usage:
// a = [];