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