-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddUser.js
More file actions
100 lines (85 loc) · 2.97 KB
/
Copy pathaddUser.js
File metadata and controls
100 lines (85 loc) · 2.97 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
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
//add-user при клике:
//index.html/contacts.html - в поле search при вводе буквы,
//добавить поиск по имени если имя включает хотя бы одну эту букву.
//после ввода каждого символа, фильтровать отображаемых пользователей.
//При удалении всех символов отобразить снова весь список
class AddUser {
constructor(globalState){
this.state = globalState; //стал равен this.state-у со страницы App.js
}
buttonsHandler(){
let buttonsParent = document.querySelector('main');
buttonsParent.addEventListener('click', this.clickHandler.bind(this));
}
clickHandler(e) {
let target = e && e.target;
if (!target) return;
let active = e && e.target && (e.target.closest('button') || e.target.classList.contains('add-btn'));
if (active == false) return;
let input = active.querySelector('input');
input.style.backgroundColor = 'lightgreen';
input.addEventListener('blur', () => {
input.removeAttribute('style');
})
}
renderInfo(value) {
return `<div class="edit-field">
<button href="#" class="add-btn"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
<input type="text" placeholder="${value}"></input>
</button>
</div>`;
}
renderLink(options) {
let {href, glyphicon, text, active} = options;
let activeClass = active ? 'active' : '';
return `<a href="${href}.html" class="tab ${activeClass}">
<span class="glyphicon glyphicon-${glyphicon}" aria-hidden="true"></span>
<span class = "tab-text">${text}</span>
</a> `
}
setEvents(){
this.buttonsHandler();
}
render() {
return `<header class="header">
<div class="container top-radius">
<nav class="user-top-line">
<a href="user.html">Cansel</a>
<button class="done-btn">Done</button>
</nav>
</div>
</header>
<main class="main">
<div class="container">
<div class="edit-main-info">
<div class="edit-foto">
<button class="add-foto-btn">
<span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
<span>add foto</span>
</button>
</div>
<div class="main-info-holder">
${this.renderInfo('First Name')}
${this.renderInfo('Last Name')}
${this.renderInfo('Company')}
</div>
</div>
<div class="scroll-holder">
<div class="edit-info">
${this.renderInfo('add mobile phone')}
${this.renderInfo('add home phone')}
${this.renderInfo('add email')}
${this.renderInfo('add address')}
${this.renderInfo('add birthday')}
${this.renderInfo('add social profile')}
${this.renderInfo('add field')}
<div class="edit-field">
<button href="#" class="delete-contact">delete contact</button>
</div>
</div>
</div>
</div>
</main>`
/*this.setEvents();*/
}
}