-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathnav-bar.js
179 lines (151 loc) · 4.49 KB
/
nav-bar.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import classic from 'ember-classic-decorator';
import { action, computed } from '@ember/object';
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
@classic
export default class NavBar extends Component {
@service router;
@service globalData;
@service('event') eventService;
loaded = false
@tracked
showSpeakers = null;
@tracked
showExhibitors = null;
@tracked
showSessions = null;
didUpdateAttrs() {
if (!this.loaded && this.get('needShowEventMenu')) {
this.loaded = true;
this.checkSpeakers();
this.checkSessions();
this.checkExhibitors();
} else if (!this.get('needShowEventMenu')) {
this.loaded = false;
}
}
@computed('session.currentRouteName')
get isGroupRoute() {
return (String(this.session.currentRouteName).includes('group'));
}
@computed('session.currentRouteName')
get isNotEventPageRoute() {
if (this.isGroupRoute) {
return true;
}
return !(String(this.session.currentRouteName).includes('public'));
}
@computed('session.currentRouteName')
get isNotWizardPageRoute() {
if (this.isGroupRoute) {
return true;
}
return !String(this.session.currentRouteName) !== 'create';
}
@computed('session.currentRouteName')
get isNotExplorePageRoute() {
if (this.isGroupRoute) {
return true;
}
return !(String(this.session.currentRouteName).includes('explore'));
}
@computed('session.currentRouteName')
get isNotPublicPageRoute() {
if (this.isGroupRoute) {
return true;
}
return !(String(this.session.currentRouteName).includes('public'));
}
@computed('session.currentRouteName')
get isNotOrderPageRoute() {
if (this.isGroupRoute) {
return true;
}
return !(String(this.session.currentRouteName).includes('order'));
}
@computed('session.currentRouteName')
get isNotEventDetailPageRoute() {
if (this.isGroupRoute || this.routing.currentRouteName === 'events.list') {
return true;
}
return !(String(this.session.currentRouteName).includes('events.view'));
}
@computed('isNotPublicPageRoute')
get checkShowClassCssPublic() {
if (this.session.isAuthenticated) {
if (this.isNotPublicPageRoute) {
return 'au-home-page';
} else {
return 'au-public-page';
}
} else {
if (this.isNotPublicPageRoute) {
return 'un-home-page';
} else {
return 'un-public-page';
}
}
}
@action
handleKeyPress() {
if (event.keyCode === 13 || event.which === 13) {
this.search();
document.querySelector('#mobile-bar').classList.remove('show-bar');
document.getElementById('mobileSearchBar').blur();
}
}
@action
searchOnClick() {
this.sendAction('search');
document.querySelector('#mobile-bar').classList.remove('show-bar');
}
@action
toggleSearchBar() {
document.querySelector('#mobile-bar').classList.toggle('show-bar');
}
@action
toggleMobileSearchBar() {
const mobileBar = document.getElementById('mobile-bar');
const mobileSearchBar = document.getElementById('mobileSearchBar');
mobileBar.classList.add('show-bar');
mobileSearchBar.focus();
document.querySelector('.pusher').addEventListener('click', function(e) {
if (e.target === mobileSearchBar) {
return;
}
mobileBar.classList.remove('show-bar');
});
}
@action
handleClick() {
this.router.replaceWith('public.index', this.globalData.idEvent);
}
@action
redirectToPage(event) {
const optionValue = event;
if (optionValue === 'speakers') {
this.router.replaceWith('public.speakers', this.globalData.idEvent);
} else if (optionValue === 'exhibition') {
this.router.replaceWith('public.exhibition', this.globalData.idEvent);
} else if (optionValue === 'schedule') {
this.router.replaceWith('public.sessions.index', this.globalData.idEvent);
} else {
this.router.replaceWith('public.index', this.globalData.idEvent);
}
}
async checkSpeakers() {
this.showSpeakers = await this.eventService.hasSpeakers(this.globalData.idEvent);
}
async checkExhibitors() {
this.showExhibitors = await this.eventService.hasExhibitors(this.globalData.idEvent);
}
async checkSessions() {
this.showSessions = await this.eventService.hasSessions(this.globalData.idEvent);
}
@action
logout() {
this.authManager.logout();
this.routing.transitionTo('index');
}
}