Preparing for June 2016 release
[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 $(".challenge,.discussion,.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 $(".challenge,.discussion,.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 }