Skip to content

Instantly share code, notes, and snippets.

@jakemcgraw
Created November 1, 2010 20:13
Show Gist options
  • Save jakemcgraw/658786 to your computer and use it in GitHub Desktop.
Save jakemcgraw/658786 to your computer and use it in GitHub Desktop.
Do like Facebook/Twitter
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