add lesson life cycle stage indicator
[rnaseq-cwl-training.git] / assets / js / lesson.js
1 // Make all tables striped by default.
2 $("table").addClass("table table-striped");
3
4
5 // Handle foldable challenges and solutions (on click and at start).
6 $(".solution").click(function(event) {
7     var trigger = $(event.target).has(".fold-unfold").size() > 0
8                || $(event.target).filter(".fold-unfold").size() > 0;
9     if (trigger) {
10         $(">*:not(h2)", this).toggle(400);
11         $(">h2>span.fold-unfold", this).toggleClass("glyphicon-collapse-down glyphicon-collapse-up");
12         event.stopPropagation();
13     }
14 });
15 $(".solution").each(function() {
16     $(">*:not(h2)", this).toggle();
17     var h2 = $("h2:first", this);
18     h2.append("<span class='fold-unfold glyphicon glyphicon-collapse-down'></span>");
19 });
20
21
22 // Handle searches.
23 // Relies on document having 'meta' element with name 'search-domain'.
24 function google_search() {
25   var query = document.getElementById("google-search").value;
26   var domain = $("meta[name=search-domain]").attr("value");
27   window.open("https://www.google.com/search?q=" + query + "+site:" + domain);
28 }
29
30 // function to shrink the life cycle bar when scrolling
31 $(function(){
32     $('#life-cycle').data('size','big');
33 });
34
35 $(window).scroll(function(){
36     if($(document).scrollTop() > 0)
37     {
38         if($('#life-cycle').data('size') == 'big')
39         {
40             $('#life-cycle').data('size','small');
41             $('#life-cycle').stop().animate({
42                 padding: '5px'
43             },100);
44         }
45     }
46     else
47     {
48         if($('#life-cycle').data('size') == 'small')
49         {
50             $('#life-cycle').data('size','big');
51             $('#life-cycle').stop().animate({
52                 padding: '15px'
53             },100);
54         }
55     }
56 });