-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
137 lines (122 loc) · 5.49 KB
/
app.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
(function(document) {
'use strict';
var app = document.querySelector('#app');
window.addEventListener('WebComponentsReady', function() {
console.log("loaded");
app.DisplayEnums = {
NONE: 'none',
CONTACT: 'contact',
REFERENCES: 'references',
WORK_HISTORY: 'work-history',
EDUCATION: 'education'
}
var mainCollapse = document.getElementById('collapse');
var currentDisplay = app.DisplayEnums.NONE;
var animationDelay = 400;
/*--------------Contact Details Collapseable--------------*/
var contactDetailsDiv = document.getElementById('contactDetails');
/*--------------Reference Details Collapseable--------------*/
var referencesDetailsDiv = document.getElementById('referencesDetails');
/*--------------Work History Collapseable--------------*/
var workHistoryDetailsDiv = document.getElementById('workHistoryDetails');
/*--------------Work History Collapseable--------------*/
var educationDetailsDiv = document.getElementById('educationDetails');
app.displayContactDetails = function(){
var contactDetails = contactDetailsDiv.innerHTML;
mainCollapse.innerHTML = contactDetails;
currentDisplay = app.DisplayEnums.CONTACT;
}
app.displayWorkHistoryDetails = function(){
var workHistoryDetails = workHistoryDetailsDiv.innerHTML;
mainCollapse.innerHTML = workHistoryDetails;
currentDisplay = app.DisplayEnums.WORK_HISTORY;
}
app.displayReferenceDetails = function(){
var referencesDetails = referencesDetailsDiv.innerHTML;
mainCollapse.innerHTML = referencesDetails;
currentDisplay = app.DisplayEnums.REFERENCES;
}
app.displayEducationDetails = function(){
var educationDetails = educationDetailsDiv.innerHTML;
mainCollapse.innerHTML = educationDetails;
currentDisplay = app.DisplayEnums.EDUCATION;
}
//Button Listeners
document.getElementById('contact-button').addEventListener('click', function(){
//If the collapse is open but displaying the details clicked, just close it.
if(mainCollapse.opened && currentDisplay == app.DisplayEnums.CONTACT){
mainCollapse.toggle();
//Else if the collapse is opened but displaying other details than that that was
//clicked. Close it, pause for the animation using a setTimeout function, change
//the details and reopen it.
}else if(mainCollapse.opened && currentDisplay != app.DisplayEnums.CONTACT){
mainCollapse.toggle();
setTimeout(function(){
app.displayContactDetails();
mainCollapse.toggle();
}, animationDelay);
//If the collapse is not opened we can just
}else if(!mainCollapse.opened){
app.displayContactDetails();
mainCollapse.toggle();
}
});
document.getElementById('work-history-button').addEventListener('click', function(){
//If the collapse is open but displaying the details clicked, just close it.
if(mainCollapse.opened && currentDisplay == app.DisplayEnums.WORK_HISTORY){
mainCollapse.toggle();
//Else if the collapse is opened but displaying other details than that that was
//clicked. Close it, pause for the animation using a setTimeout function, change
//the details and reopen it.
}else if(mainCollapse.opened && currentDisplay != app.DisplayEnums.WORK_HISTORY){
mainCollapse.toggle();
setTimeout(function(){
app.displayWorkHistoryDetails();
mainCollapse.toggle();
}, animationDelay);
//If the collapse is not opened we can just
}else if(!mainCollapse.opened){
app.displayWorkHistoryDetails();
mainCollapse.toggle();
}
});
document.getElementById('reference-button').addEventListener('click', function(){
//If the collapse is open but displaying the details clicked, just close it.
if(mainCollapse.opened && currentDisplay == app.DisplayEnums.REFERENCES){
mainCollapse.toggle();
//Else if the collapse is opened but displaying other details than that that was
//clicked. Close it, pause for the animation using a setTimeout function, change
//the details and reopen it.
}else if(mainCollapse.opened && currentDisplay != app.DisplayEnums.REFERENCES){
mainCollapse.toggle();
setTimeout(function(){
app.displayReferenceDetails();
mainCollapse.toggle();
}, animationDelay);
//If the collapse is not opened we can just
}else if(!mainCollapse.opened){
app.displayReferenceDetails();
mainCollapse.toggle();
}
});
document.getElementById('education-button').addEventListener('click', function(){
//If the collapse is open but displaying the details clicked, just close it.
if(mainCollapse.opened && currentDisplay == app.DisplayEnums.EDUCATION){
mainCollapse.toggle();
//Else if the collapse is opened but displaying other details than that that was
//clicked. Close it, pause for the animation using a setTimeout function, change
//the details and reopen it.
}else if(mainCollapse.opened && currentDisplay != app.DisplayEnums.EDUCATION){
mainCollapse.toggle();
setTimeout(function(){
app.displayEducationDetails();
mainCollapse.toggle();
}, animationDelay);
//If the collapse is not opened we can just
}else if(!mainCollapse.opened){
app.displayEducationDetails();
mainCollapse.toggle();
}
});
});
})(document);