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