View tap.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(Object.prototype, 'tap', { | |
value: function(fun){ | |
fun.call( this ); | |
return this; | |
}, | |
enumerable: false | |
}); | |
// Usage: | |
// a = []; |
View backbone_pushstate_router.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
}; |