Difference between revisions of "Team:ZJU-China/js/globe/ZJU-ajax.js"
Line 5: | Line 5: | ||
var href = $(this).attr('href'); | var href = $(this).attr('href'); | ||
if(hash==href.substr(0,href.length-5)){ | if(hash==href.substr(0,href.length-5)){ | ||
− | var toLoad = hash+'.html #content'; | + | var toLoad = hash+'.html #page-content-wrapper'; |
− | $('#content').load(toLoad) | + | $('#page-content-wrapper').load(toLoad) |
} | } | ||
}); | }); | ||
Line 12: | Line 12: | ||
$('#nav li a').click(function(){ | $('#nav li a').click(function(){ | ||
− | var toLoad = $(this).attr('href')+' #content'; | + | var toLoad = $(this).attr('href')+' #page-content-wrapper'; |
− | $('#content').hide('fast',loadContent); | + | $('#page-content-wrapper').hide('fast',loadContent); |
$('#load').remove(); | $('#load').remove(); | ||
$('#wrapper').append('<span id="load">LOADING...</span>'); | $('#wrapper').append('<span id="load">LOADING...</span>'); | ||
Line 19: | Line 19: | ||
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); | window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); | ||
function loadContent() { | function loadContent() { | ||
− | $('#content').load(toLoad,'',showNewContent()) | + | $('#page-content-wrapper').load(toLoad,'',showNewContent()) |
} | } | ||
function showNewContent() { | function showNewContent() { | ||
− | $('#content').show('normal',hideLoader()); | + | $('#page-content-wrapper').show('normal',hideLoader()); |
} | } | ||
function hideLoader() { | function hideLoader() { |
Revision as of 03:07, 5 September 2015
$(document).ready(function() {
var hash = window.location.hash.substr(1); var href = $('#nav li a').each(function(){ var href = $(this).attr('href'); if(hash==href.substr(0,href.length-5)){ var toLoad = hash+'.html #page-content-wrapper'; $('#page-content-wrapper').load(toLoad) } });
$('#nav li a').click(function(){
var toLoad = $(this).attr('href')+' #page-content-wrapper'; $('#page-content-wrapper').hide('fast',loadContent); $('#load').remove(); $('#wrapper').append('LOADING...'); $('#load').fadeIn('normal'); window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); function loadContent() { $('#page-content-wrapper').load(toLoad,,showNewContent()) } function showNewContent() { $('#page-content-wrapper').show('normal',hideLoader()); } function hideLoader() { $('#load').fadeOut('normal'); } return false;
});
});