Mercurial > hg > extraction-interface
diff search/search.js @ 0:b12c99b7c3f0
commit for previous development
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 19 Jan 2015 17:13:49 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/search/search.js Mon Jan 19 17:13:49 2015 +0100 @@ -0,0 +1,31 @@ +$(document).ready(function(){ + initSection(); +}); +function initSection(){ //Hide sections if there are more than 5 + $("td div.section").hide(); + for(var i=1; i<=5; i++){ + $("td div.section:nth-child("+i+")").show(); + } + $("td:has(div)").each(function(){ + console.log($(this).children().length); + if($(this).children().length<=5){ + return; + } + var last=$(this).children(".section").last(); + $("<div/>").addClass("visibilityControl").html("+").insertAfter(last); + }); + $("td div.visibilityControl").click(function(){ + if($(this).html()=="+"){ + $(this).parent().children(".section").show(); + $(this).html("-"); + return; + } + if($(this).html()=="-"){ + $(this).parent().children(".section").hide(); + for(var i=1; i<=5; i++){ + $(this).parent().children(".section:nth-child("+i+")").show(); + } + $(this).html("+"); + } + }); +}