Difference between revisions of "Team:ZJU-China/Template/label.js"
(15 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | 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'; | ||
+ | var toLoad1= hash+'.html #popView2'; | ||
+ | jQuery('#page-content-wrapper').load(toLoad); | ||
+ | jQuery('#popView2').load(toLoad1); | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | jQuery('#nav li a').click(function(){ | ||
+ | |||
+ | var iWidth = document.documentElement.clientWidth; | ||
+ | var iHeight = document.documentElement.clientHeight*5; | ||
+ | var bgObj = document.createElement("div"); | ||
+ | bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:998;"; | ||
+ | document.body.appendChild(bgObj); | ||
+ | scroll(0,0) | ||
+ | var toLoad = jQuery(this).attr('href')+' #page-content-wrapper'; | ||
+ | var toLoad1 = jQuery(this).attr('href')+' #popView2'; | ||
+ | jQuery('#popView2').css("right","30px"); | ||
+ | jQuery('#page-content-wrapper').hide('fast',loadContent); | ||
+ | jQuery('#popView2').hide('fast',loadContent); | ||
+ | jQuery('#load').remove(); | ||
+ | jQuery('#wrapper').append('<span id="load">LOADING...</span>'); | ||
+ | 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()); | ||
+ | jQuery('#popView2').load(toLoad1,'',showNewContent()); | ||
+ | } | ||
+ | |||
+ | function showNewContent() { | ||
+ | jQuery('#page-content-wrapper').show('normal',hideLoader()); | ||
+ | jQuery('#popView2').show('normal',hideLoader()); | ||
+ | |||
+ | } | ||
+ | function hideLoader() { | ||
+ | setTimeout(function() { jQuery('#load').fadeOut('normal'); document.body.removeChild(bgObj); }, 1000); | ||
+ | |||
+ | } | ||
+ | return false; | ||
+ | |||
+ | }); | ||
+ | |||
+ | }); | ||
+ | |||
+ | |||
+ | |||
jQuery(document).ready(function(){ | jQuery(document).ready(function(){ | ||
var isHiden1 = true; /*控制切换菜单*/ | var isHiden1 = true; /*控制切换菜单*/ | ||
Line 4: | Line 60: | ||
jQuery('#popView1').click(function(){ | jQuery('#popView1').click(function(){ | ||
if(isHiden1){ | if(isHiden1){ | ||
− | + | jQuery('#popView1').animate({left:'+=150px'});//菜单块向右移动 | |
jQuery('#popView2').css('display','inline'); | jQuery('#popView2').css('display','inline'); | ||
− | jQuery('#popView2').animate({right:'+= | + | jQuery('#popView2').animate({right:'-200px'}); |
+ | jQuery('#popView2').animate({right:'+=170px'});//菜单块向左移动 | ||
}else{ | }else{ | ||
jQuery('#popView1').animate({left:'-=150px'}); //菜单块向左移动 | jQuery('#popView1').animate({left:'-=150px'}); //菜单块向左移动 | ||
− | + | ||
− | + | jQuery('#popView2').animate({right:'-=170px'});//菜单块向右移动 | |
+ | jQuery('#popView2').fadeOut('normal'); | ||
} | } | ||
isHiden1 = !isHiden1; | isHiden1 = !isHiden1; | ||
}); | }); | ||
− | + | jQuery(document).scroll(function() { | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
if(jQuery(document).scrollTop()>=100) | if(jQuery(document).scrollTop()>=100) | ||
{ | { | ||
jQuery('aside').css('position','fixed').css('top','50px'); | jQuery('aside').css('position','fixed').css('top','50px'); | ||
− | jQuery('asider').css('position','fixed').css('top','50px'); | + | jQuery('asider').css('position','fixed').css('top','50px').css('z-index','50'); |
jQuery('aside').fadeIn('normal'); | jQuery('aside').fadeIn('normal'); | ||
+ | if(isHiden1>0){ | ||
+ | jQuery('asider').fadeIn('normal'); | ||
+ | } | ||
} | } | ||
Line 34: | Line 90: | ||
jQuery('asider').css('position','static').css('float','left').css('position','absolute').css('top','150px'); | jQuery('asider').css('position','static').css('float','left').css('position','absolute').css('top','150px'); | ||
jQuery('aside').fadeOut('normal'); | jQuery('aside').fadeOut('normal'); | ||
− | + | jQuery('asider').css('display','none'); | |
− | jQuery('asider'). | + | |
} | } | ||
}); | }); | ||
+ | |||
+ | |||
}); | }); | ||
+ | |||
+ | |||
/* slide */ | /* slide */ | ||
jQuery(document).ready(function(){ | jQuery(document).ready(function(){ |
Latest revision as of 04:15, 8 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'; var toLoad1= hash+'.html #popView2'; jQuery('#page-content-wrapper').load(toLoad); jQuery('#popView2').load(toLoad1); } });
jQuery('#nav li a').click(function(){
var iWidth = document.documentElement.clientWidth; var iHeight = document.documentElement.clientHeight*5; var bgObj = document.createElement("div"); bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:998;"; document.body.appendChild(bgObj);
scroll(0,0) var toLoad = jQuery(this).attr('href')+' #page-content-wrapper'; var toLoad1 = jQuery(this).attr('href')+' #popView2';
jQuery('#popView2').css("right","30px");
jQuery('#page-content-wrapper').hide('fast',loadContent); jQuery('#popView2').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()); jQuery('#popView2').load(toLoad1,,showNewContent()); }
function showNewContent() { jQuery('#page-content-wrapper').show('normal',hideLoader()); jQuery('#popView2').show('normal',hideLoader());
} function hideLoader() {
setTimeout(function() { jQuery('#load').fadeOut('normal'); document.body.removeChild(bgObj); }, 1000);
} return false;
});
});
jQuery(document).ready(function(){
var isHiden1 = true; /*控制切换菜单*/ var isHiden2 = true; /*控制切换菜单*/ jQuery('#popView1').click(function(){ if(isHiden1){ jQuery('#popView1').animate({left:'+=150px'});//菜单块向右移动
jQuery('#popView2').css('display','inline');
jQuery('#popView2').animate({right:'-200px'});
jQuery('#popView2').animate({right:'+=170px'});//菜单块向左移动
}else{ jQuery('#popView1').animate({left:'-=150px'}); //菜单块向左移动
jQuery('#popView2').animate({right:'-=170px'});//菜单块向右移动 jQuery('#popView2').fadeOut('normal'); } isHiden1 = !isHiden1; });
jQuery(document).scroll(function() {
if(jQuery(document).scrollTop()>=100) { jQuery('aside').css('position','fixed').css('top','50px'); jQuery('asider').css('position','fixed').css('top','50px').css('z-index','50'); jQuery('aside').fadeIn('normal'); if(isHiden1>0){ jQuery('asider').fadeIn('normal'); }
} else { jQuery('aside').css('position','static').css('float','left').css('position','absolute').css('top','150px'); jQuery('asider').css('position','static').css('float','left').css('position','absolute').css('top','150px'); jQuery('aside').fadeOut('normal'); jQuery('asider').css('display','none'); }
});
});
/* slide */
jQuery(document).ready(function(){
jQuery('a[href^="#"]').on('click',function (e) { e.preventDefault();
var target = this.hash, $target = jQuery(target);
jQuery('html, body').stop().animate({ 'scrollTop': $target.offset().top }, 900, 'swing', function () { window.location.hash = target; }); });
});