Created
November 1, 2010 20:13
-
-
Save jakemcgraw/658786 to your computer and use it in GitHub Desktop.
Do like Facebook/Twitter
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
TRUPH = jQuery.extend(true, TRUPH||{}, { | |
domain: "http://tru.ph", | |
basePath: "/photo", | |
getBaseUrl: function(){ | |
return TRUPH.domain+TRUPH.basePath; | |
}, | |
shebang: "#!" | |
}); | |
jQuery(function($){ | |
$("a").removeAttr("onclick") // no more onclick | |
// replace href with AJAXified ver | |
.attr("href", function(){ | |
return this.href.replace(TRUPH.getBaseUrl(), TRUPH.shebang); | |
}); | |
// use onhashchange if available | |
if ("onhashchange" in window) { | |
window.onhashchange = function(){ | |
// todo update menu | |
// update display | |
$("#display").load(TRUPH.basePath+location.hash.replace(TRUPH.shebang, "")); | |
}; | |
} | |
// use onclick | |
else { | |
$("a").live("click", function(e){ | |
// todo update menu | |
// update display | |
$("#display").load(TRUPH.basePath+this.href.replace(TRUPH.shebang), ""); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment