-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
50 lines (46 loc) · 1.16 KB
/
script.js
File metadata and controls
50 lines (46 loc) · 1.16 KB
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
// wait for the dom to load
$(document).ready(function() {
/**
* toggles the button color between primary and accent colors
* @param {element} btn - the button to toggle
*/
function toggleBtnColor(btn){
if(btn.classList.contains('mdl-button--accent')){
btn.classList.replace('mdl-button--accent','mdl-button--primary');
} else {
btn.classList.replace('mdl-button--primary','mdl-button--accent');
}
}
/**
* load content into our page
*/
function load_()
{
var content = this.getAttribute('value');
$('.content').load(content + '.html', function() {
if (console) {
console.log(content + ' loaded successfully');
}
});
}
/**
* remove content from our page
*/
function unload_()
{
$('.content').empty();
}
/**
* adds event handlers for all click events
*/
function clickHandlers(){
// click events for navigation
var navLinks = document.querySelectorAll('.mdl-navigation__link');
for (var i = 0; i < navLinks.length; i++){
navLinks[i].addEventListener('click', load_);
}
}
clickHandlers();
// initialize page with portfolio page temporarily
document.querySelector('.nav-resume').click();
});