From: ec2-user Date: Sun, 13 Nov 2011 06:38:41 +0000 (+0000) Subject: most pages under pseudo-nav behavior X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=467402f6acb4e5ae0eadf6c29e053a86bc044ff7;p=oweals%2Ffinalsclub.git most pages under pseudo-nav behavior --- diff --git a/public/javascripts/main.js b/public/javascripts/main.js index a002d07..63ee1fb 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -198,7 +198,7 @@ var pageVectors = [ /* Do and show the appropriate thing, based on the pages current URL */ -function showPage() { +function showPage(y) { var path = document.location.pathname @@ -211,7 +211,13 @@ function showPage() { vector.func(matches, function(pageId) { $("#pg_"+pageId).fadeIn(100); - $('html, body').animate({ scrollTop: 0 }, 100); + + //alert(backTop) + //if(!backFlag) + //$('html, body').animate({ scrollTop: backTop }, 100); + //if(y !== undefined) + window.scroll(0, y) + //backFlag = false }) break @@ -239,45 +245,28 @@ function showPage() { Based on what path looks like, an appropriate DIV is shown, and action taken */ function goPage(path) { - history.pushState({prev:path}, path, path); - showPage(); + var y = 0 + window.pageYOffset + var o = {py:(path+"|"+y)} + history.pushState(o, path, path); + showPage(0); } -/* Simulates a "back" browser navigation. -*/ +/* Simulates a "back" browser navigation. */ +var backTop = 0 function goBack(event) { - var state = event.state; //alert("pop: "+o2j(state)); - - showPage() - - /*hideAllPages(); - - if(!state) { - - history.replaceState(null, "", "/index.html"); - showPage("home"); - - } - else { - //alert("location: " + document.location + ", state: " + JSON.stringify(event.state)); - //history.replaceState(null, "", state.prev); - showPage(state.prev); - // showPage(state.prev); - //alert("location: " + document.location + ", state: " + JSON.stringify(event.state)); - } - */ + // alert("pop: "+o2j(event.state)); + //backTop = window.pageYOffset; //$("html, body").offset().top + showPage( event.state ? event.state.y : 0 ) } $(document).ready(function() { - // This executes after the page has been fully loaded + // This code executes after the page has been fully loaded window.onpopstate = goBack - //showPage("home"); - })