Created
November 15, 2011 18:52
-
-
Save mikevalstar/1367956 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function loadPage(hash, fn){ | |
| if(!hash || hash == ''){ | |
| if(typeof _gaq !== 'undefined') | |
| _gaq.push(['_trackPageview']); | |
| return; // nothing to do | |
| } | |
| var url = (hash[0] == '#') ? hash.substring(2): hash; | |
| $('#C').html('Loading Content...'); // replace with loading screen code | |
| var callback = function(responseText, textStatus, XMLHttpRequest){ | |
| $(document).attr('title', $(responseText).filter('title').text()); | |
| if(fn) fn(); | |
| // track the page view | |
| if(typeof _gaq !== 'undefined') | |
| _gaq.push(['_trackPageview', url]); | |
| } | |
| $('#C').load(url + ' #C', callback); | |
| } | |
| $("a").live("click", function(event){ | |
| var href = $(this).attr("href"); | |
| if(href[0] == "/" | |
| && href.substring(href.length - 4) != '.png' | |
| && href.substring(href.length - 4) != '.jpg' | |
| && href.substring(href.length - 5) != '.jpeg' | |
| && href.substring(href.length - 4) != '.gif' ){ | |
| event.preventDefault(); | |
| window.location.hash = "#!" + href; | |
| } | |
| }); | |
| $(window).bind('hashchange', function(){ | |
| loadPage( location.hash ); | |
| }); | |
| loadPage( location.hash, false ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment