-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathats.js
More file actions
212 lines (194 loc) · 6.6 KB
/
Copy pathats.js
File metadata and controls
212 lines (194 loc) · 6.6 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/**
* @fileoverview ATS (Applicant Tracking System) page functionality
* @description Handles all interactive elements on the ATS page including proposal toggles,
* tab navigation, popups, and mobile menu functionality.
* @module ATSPage
*/
/**
* @class ATSPage
* @description Main class for handling ATS page functionality
*/
class ATSPage {
/**
* @constructor
* @description Initializes the ATS page functionality and binds event handlers
*/
constructor() {
// Bind methods to maintain 'this' context
this.toggleProposal = this.toggleProposal.bind(this);
this.handleTabClick = this.handleTabClick.bind(this);
this.toggleMobileMenu = this.toggleMobileMenu.bind(this);
this.init();
}
/**
* @method init
* @description Initializes all page functionalities
* @private
*/
init() {
try {
this.initializeProposalToggles();
this.initializeTabsNavigation();
this.initializePopups();
this.initializeMobileMenu();
console.log('ATS Page initialized successfully');
} catch (error) {
console.error('Error initializing ATS Page:', error);
}
}
/**
* @method initializeProposalToggles
* @description Sets up event listeners for proposal text expansion/collapse
* @private
*/
initializeProposalToggles() {
try {
const proposalButtons = document.querySelectorAll('[data-proposal-toggle]');
proposalButtons.forEach(button => {
button.addEventListener('click', () => this.toggleProposal(button));
});
} catch (error) {
console.error('Error initializing proposal toggles:', error);
}
}
/**
* @method toggleProposal
* @description Toggles the visibility of full/collapsed proposal text
* @param {HTMLElement} button - The button element that triggered the toggle
* @private
*/
toggleProposal(button) {
try {
const proposalText = button.closest('.mt-4').querySelector('.proposal-text');
const collapsed = proposalText.querySelector('.collapsed');
const expanded = proposalText.querySelector('.expanded');
if (!collapsed || !expanded) return;
collapsed.classList.toggle('ats-hidden');
expanded.classList.toggle('ats-hidden');
button.textContent = collapsed.classList.contains('hidden') ? 'See Less' : 'See More';
} catch (error) {
console.error('Error toggling proposal:', error);
}
}
/**
* @method initializeTabsNavigation
* @description Sets up event listeners for tab navigation
* @private
*/
initializeTabsNavigation() {
try {
const tabs = document.querySelectorAll('.cursor-pointer');
tabs.forEach(tab => {
tab.addEventListener('click', () => this.handleTabClick(tab));
});
} catch (error) {
console.error('Error initializing tabs:', error);
}
}
/**
* @method handleTabClick
* @description Handles the tab selection and updates active state
* @param {HTMLElement} selectedTab - The tab element that was clicked
* @private
*/
handleTabClick(selectedTab) {
try {
const allTabs = selectedTab.parentElement.querySelectorAll('.cursor-pointer');
allTabs.forEach(tab => {
tab.classList.remove('tab-active');
});
selectedTab.classList.add('tab-active');
} catch (error) {
console.error('Error handling tab click:', error);
}
}
/**
* @method initializePopups
* @description Sets up event listeners for popup triggers and outside clicks
* @private
*/
initializePopups() {
try {
document.querySelectorAll('[data-popup]').forEach(trigger => {
trigger.addEventListener('click', (e) => {
e.stopPropagation();
this.togglePopup(trigger.dataset.popup);
});
});
document.addEventListener('click', (event) => {
if (!event.target.closest('.popup-content') && !event.target.closest('#notifications-icon')) {
document.querySelectorAll('[data-popup]').forEach(popup => popup.classList.add('hidden'));
const notifications = document.getElementById('popup-notifications');
notifications.classList.add('hidden');
}
});
} catch (error) {
console.error('Error initializing popups:', error);
}
}
/**
* @method togglePopup
* @description Toggles the visibility of a specific popup
* @param {string} popupId - The ID of the popup to toggle
* @private
*/
togglePopup(popupId) {
try {
const popup = document.getElementById(`popup-${popupId}`);
if (popup) {
popup.classList.toggle('hidden');
}
} catch (error) {
console.error('Error toggling popup:', error);
}
}
/**
* @method closeAllPopups
* @description Closes all open popups
* @private
*/
closeAllPopups() {
try {
document.querySelectorAll('[id^="popup-"]').forEach(popup => {
popup.classList.add('hidden');
});
} catch (error) {
console.error('Error closing popups:', error);
}
}
/**
* @method initializeMobileMenu
* @description Sets up event listener for mobile menu toggle
* @private
*/
initializeMobileMenu() {
try {
const menuButton = document.querySelector('[data-mobile-menu]');
if (menuButton) {
menuButton.addEventListener('click', this.toggleMobileMenu);
}
} catch (error) {
console.error('Error initializing mobile menu:', error);
}
}
/**
* @method toggleMobileMenu
* @description Toggles the visibility of the mobile menu
* @private
*/
toggleMobileMenu() {
try {
const mobileMenu = document.getElementById('mobile-menu-ats');
if (mobileMenu) {
mobileMenu.classList.toggle('hidden');
}
} catch (error) {
console.error('Error toggling mobile menu:', error);
}
}
}
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
new ATSPage();
});
export default ATSPage;