-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheaderAndFooter.js
More file actions
65 lines (58 loc) · 1.49 KB
/
headerAndFooter.js
File metadata and controls
65 lines (58 loc) · 1.49 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class HeaderAndFooter {
constructor(caption) {
this.caption = caption;
this.renderLink = [
{content:'Contacts', icon: 'search'},
{content:'Keypad', icon: 'th'},
{content:'Edit contact', icon: 'pencil'},
{content:'User', icon: 'user'},
{content:'Add user', icon: 'plus'}
];
};
createHeader() {
let header = `
<header class="header">
<div class="container top-radius">
<h2>${this.caption}</h2>
</div>
</header>
`;
return header;
};
createFooter() {
let done = `
<footer class="footer">
<div class="container bottom-radius">
<nav class="main-nav">
`;
let testIndexHtml = function(str) {
if(str === 'Contacts') {
return 'index';
} else {
return str;
};
};
let contentNav = this.renderLink.reduce((start, elem) => {
start += `
<a href="${testIndexHtml(elem.content)}.html" class="tab ${elem.content}">
<span class="glyphicon glyphicon-${elem.icon}" aria-hidden="true"></span>
<span class = "tab-text">${elem.content}</span>
</a>
`;
return start;
}, done);
let footer = contentNav + '</nav>\n </div>\n </footer>';
return footer;
};
createMain() {
return `
<main class="main">
<div class="container">
</div>
</main>
`;
};
renderTemplate() {
document.body.innerHTML = this.createHeader() + this.createMain() + this.createFooter();
};
};