Mercurial > hg > LGSearch
comparison search.js @ 0:c9363a90b8b5
first commit to development server
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 24 Mar 2015 15:12:34 +0100 |
parents | |
children | 4b9ae7d500f9 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c9363a90b8b5 |
---|---|
1 $(document).ready(function(){ | |
2 initSection(); | |
3 }); | |
4 function initSection(){ //Hide sections if there are more than 5 | |
5 $("td div.section").hide(); | |
6 for(var i=1; i<=5; i++){ | |
7 $("td div.section:nth-child("+i+")").show(); | |
8 } | |
9 $("td:has(div)").each(function(){ | |
10 console.log($(this).children().length); | |
11 if($(this).children().length<=5){ | |
12 return; | |
13 } | |
14 var last=$(this).children(".section").last(); | |
15 $("<div/>").addClass("visibilityControl").html("+").insertAfter(last); | |
16 }); | |
17 $("td div.visibilityControl").click(function(){ | |
18 if($(this).html()=="+"){ | |
19 $(this).parent().children(".section").show(); | |
20 $(this).html("-"); | |
21 return; | |
22 } | |
23 if($(this).html()=="-"){ | |
24 $(this).parent().children(".section").hide(); | |
25 for(var i=1; i<=5; i++){ | |
26 $(this).parent().children(".section:nth-child("+i+")").show(); | |
27 } | |
28 $(this).html("+"); | |
29 } | |
30 }); | |
31 } |