-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
106 lines (93 loc) · 2.71 KB
/
script.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
$(document).ready( function() {
var enableDownloadDropdowns = function() {
$( '.expand-body' ).hide();
$( '.download-button' ).hover( function() {
$( this ).addClass( 'hover' );
}, function() {
$( this ).removeClass( 'hover' );
} );
$( '.expand-link' ).click( function() {
var link = $( this );
var body = link.closest( '.expand-head' ).next( '.expand-body' );
var relatedItem = body.children( '.expand-item' ).eq( link.index() );
if( body.is( ':visible' ) && relatedItem.is( ':visible' ) ) {
body.slideUp( function() {
link.removeClass( 'selected' );
} );
} else {
relatedItem.show().siblings().hide();
link.addClass( 'selected' ).siblings().removeClass( 'selected' );
body.slideDown();
}
} );
};
var enableInfoBox = function() {
var infoBox = $( '#info-box' );
infoBox.mouseenter( function() {
infoBox.stop();
infoBox.animate( {
"width" : "200px"
} );
} );
infoBox.mouseleave( function() {
infoBox.stop();
infoBox.animate( {
"width" : "45px"
} );
} );
};
function enablePopup() {
var body = $( "body" );
var overlay = $( '<div class="overlay"></div>' );
var popup = $( '<div id="popup"></div>' );
body.append( overlay );
overlay.click( function() {
hideOverlayAndPopup();
} );
$( ".popup-activate" ).click( function() {
showOverlay();
showPopup( this );
return false;
} );
function showPopup( featureElem ) {
var featureId = $( featureElem ).parents( ".feature" ).attr( "id" );
popup.append( $( ".popup-content[data-for=" + featureId + "]" ).html() );
var closeBtn = $( '<span id="popup-close">X</span>' );
var backLink = $( '<a style="cursor:pointer">back</a>' );
closeBtn.click( hideOverlayAndPopup );
backLink.click( hideOverlayAndPopup );
popup.append( closeBtn );
popup.append( backLink );
body.append( popup );
popup.fadeIn( 100 );
};
function hideOverlayAndPopup() {
hideOverlay();
hidePopup();
}
function hidePopup() {
popup.fadeOut( 100, function() {
popup.empty();
body.remove( popup );
} );
}
function showOverlay() {
overlay.css( "display", "block" );
overlay.css( "filter", "alpha(opacity=0)" );
overlay.animate( {
"opacity" : "0.5"
} );
};
function hideOverlay() {
overlay.animate( {
"opacity" : "0"
},
function() {
overlay.css( "display", "none" );
} );
};
}
enableDownloadDropdowns();
enableInfoBox();
enablePopup();
} );