-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeline.js
86 lines (83 loc) · 2.7 KB
/
timeline.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var scaling = {
'precambrian' : { 'width':'115%', 'left': 0 },
'phanerozoic' : { 'width':'600%', 'left':'-500%' },
'paleozoic' : { 'width' : '1350%', 'left': '-1167%'},
'mesozoic' : { 'width':'1650%', 'left':'-1540%' },
'cenozoic' : { 'width' : '4000%', 'left' : '-3900%' }
}
$(document).ready( function() {
// set the descriptions for each list item (i.e. a dd element) to (hidden?)
$('.shown').hide();
hideOLs = function() {
// in the list #eons, hide any child lists
$('#eons').find('ol').hide();
$('.era').removeClass('open-arrow');
$(this).addClass('greyed');
$('#showall').removeClass('greyed')
};
hideOLs();
$('#hideall').click( hideOLs );
$('#showall').click( function() {
$('#eons').find('ol').show();
// change arrows to open
$('.era').addClass('open-arrow');
// grey out link text
$(this).addClass('greyed');
$('#hideall').removeClass('greyed');
});
showAbout = function(){
$(this).next().show();
return false;
};
hideAbout = function() {
$(this).next().hide();
return false;
};
zoomTimeline = function(eraName) {
console.log("Zooming to "+eraName);
$('#r-'+eraName.slice(0,3)).toggleClass('overline');
if ( scaling[eraName] ) {
$('#horizontal-ribbon').animate( scaling[eraName], "slow" );
} else {
console.log("not a key in scaling object");
return false;
}
}
// toggle visibility of description (<dd>) when the title (<dt>) is moused over
/**** this was not unbinding properly
/ $('dt').hover(
showAbout, //mouseover
hideAbout //mouseout
); */
$('dt').bind( 'mouseover', showAbout).bind( 'mouseout', hideAbout);
$("#make-plain").click( function() {
$('.shown').show();
$('dd').removeClass('shown');
$('ol').show();
// remove hover show/hide functionality
//$('dt').hover( function() {return false}, function() {return false});
//hideAbout = function() { console.log("new hideAbout function"); return false };
//showAbout = function() { return false }
$('dt').unbind( 'mouseover', showAbout ).unbind( 'mouseout', hideAbout );
});
//expand eras when clicked, and show child list
$('.era').click( function() {
if ( $(this).find('ol:first').css('display') == 'none' ) {
$(this).addClass('open-arrow');
$('#hideall').removeClass('greyed');
$(this).children('ol').show();
dd1 = $(this).find('dd:first')[0]
$(dd1).toggleClass('child-shown');
// zoom timeline ribbon to the era in question
zoomTimeline( $(this.firstChild).attr('class') );
} else {
$(this).removeClass('open-arrow');
$('#showall').removeClass('greyed');
$(this).children('ol').hide();
}
return false;
});
$('.period').click( function() {
return false; /**prevent the click event from going to parent and hiding this element**/
});
});