Skip to content

Instantly share code, notes, and snippets.

@trhaynes
Created May 8, 2012 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trhaynes/2631808 to your computer and use it in GitHub Desktop.
Save trhaynes/2631808 to your computer and use it in GitHub Desktop.
I didn't write this code
AboutContent = {
defaultSection: "branching-and-merging",
init: function() {
if ($("body#about").length === 0) return;
AboutContent.observeNav(),
AboutContent.observePopState(),
AboutContent.showSection(AboutContent.getSection())
},
observePopState: function() {
if (window.history && window.history.pushState) return $(window).bind("popstate",
function(a) {
var b;
initialPop = !popped && location.href === initialURL,
popped = !0;
if (initialPop) return;
return b = AboutContent.getSection(),
AboutContent.showSection(b)
})
},
getSection: function(a) {
var b;
b = location.href.substring(location.href.lastIndexOf("/") + 1);
if (b.length === 0 || b == "about") b = AboutContent.defaultSection;
return b
},
showSection: function(a) {
a == "about" && (a = AboutContent.defaultSection),
$("ol#about-nav a").removeClass("current"),
$("ol#about-nav a#nav-" + a).addClass("current"),
$("section").hide(0,
function() {
$("section#" + a).show()
})
},
observeNav: function() {
$("ol#about-nav a, .bottom-nav a").click(function(a) {
a.preventDefault();
var b = $(this).attr("data-section-id");
window.history && window.history.pushState && history.pushState(null, $(this).html(), "/about/" + b),
AboutContent.showSection(b)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment