Difference between revisions of "Template:SEU/Notebook/JS"

(Created page with "$(function(){ var pageNum = 0; for (var i = 0; i < $('.runPage').length; i++) { $('.runPage').eq(i).css('z-index',7-2*i); $('.runPage').eq(i).children('div').css('z-ind...")
 
Line 3: Line 3:
  
 
for (var i = 0; i < $('.runPage').length; i++) {
 
for (var i = 0; i < $('.runPage').length; i++) {
$('.runPage').eq(i).css('z-index',7-2*i);
+
$('.runPage').eq(i).css('z-index',9-2*i);
$('.runPage').eq(i).children('div').css('z-index',7-2*i);
+
$('.runPage').eq(i).children('div').css('z-index',9-2*i);
$('.runPage').eq(i).children('img').css('z-index',6-2*i);
+
$('.runPage').eq(i).children('img').css('z-index',9-2*i);
 
};
 
};
  
 
$('.nextBtn').bind('click',function(){
 
$('.nextBtn').bind('click',function(){
if ( pageNum <= 2 ) {
+
if ( pageNum <= 3 ) {
 
runNext(pageNum);
 
runNext(pageNum);
 
pageNum++;
 
pageNum++;
 
};
 
};
console.log(pageNum);
+
console.log(pageNum);
 
});
 
});
  
Line 24: Line 24:
 
if ( index >= 1 ) {
 
if ( index >= 1 ) {
 
element.css('z-index',3+2*index);
 
element.css('z-index',3+2*index);
};
+
};
 
setTimeout(function(){
 
setTimeout(function(){
 
if (index==0) {
 
if (index==0) {
Line 30: Line 30:
 
};
 
};
 
element.children('div').css('z-index',2+2*index);
 
element.children('div').css('z-index',2+2*index);
element.children('img').css('z-index',3+2*index);
+
element.children('img').css('z-index',3+2*index);
 
},1000);
 
},1000);
 
}
 
}
  
 
$('.lastBtn').bind('click',function(){
 
$('.lastBtn').bind('click',function(){
if ( pageNum >= 1 ) {
+
if ( pageNum >= 1 ) {
 
pageNum--;
 
pageNum--;
 
runLast(pageNum);
 
runLast(pageNum);
 
};
 
};
console.log(pageNum);
+
console.log(pageNum);
 
});
 
});
  
Line 49: Line 49:
 
function zIndexLast(index,element){
 
function zIndexLast(index,element){
 
if (index == 0) {
 
if (index == 0) {
element.css('z-index',7-2*index);
+
element.css('z-index',9-2*index);
 
};
 
};
 
setTimeout(function(){
 
setTimeout(function(){
element.css('z-index',7-2*index);
+
element.css('z-index',9-2*index);
element.children('div').css('z-index',7-2*index);
+
element.children('div').css('z-index',9-2*index);
element.children('img').css('z-index',6-2*index);
+
element.children('img').css('z-index',8-2*index);
 
},1000);
 
},1000);
 
}
 
}
 
});
 
});

Revision as of 14:41, 20 September 2019

$(function(){ var pageNum = 0;

for (var i = 0; i < $('.runPage').length; i++) { $('.runPage').eq(i).css('z-index',9-2*i); $('.runPage').eq(i).children('div').css('z-index',9-2*i); $('.runPage').eq(i).children('img').css('z-index',9-2*i); };

$('.nextBtn').bind('click',function(){ if ( pageNum <= 3 ) { runNext(pageNum); pageNum++; }; console.log(pageNum); });

function runNext(index){ $('.runPage').eq(index).addClass('runClass'); zIndexNext(index,$('.runPage').eq(index)); }

function zIndexNext(index,element){ if ( index >= 1 ) { element.css('z-index',3+2*index); }; setTimeout(function(){ if (index==0) { element.css('z-index',3+2*index); }; element.children('div').css('z-index',2+2*index); element.children('img').css('z-index',3+2*index); },1000); }

$('.lastBtn').bind('click',function(){ if ( pageNum >= 1 ) { pageNum--; runLast(pageNum); }; console.log(pageNum); });

function runLast(index){ $('.runPage').eq(index).removeClass('runClass'); zIndexLast(index,$('.runPage').eq(index)); }

function zIndexLast(index,element){ if (index == 0) { element.css('z-index',9-2*index); }; setTimeout(function(){ element.css('z-index',9-2*index); element.children('div').css('z-index',9-2*index); element.children('img').css('z-index',8-2*index); },1000); } });