1
|
|
|
// ============================================================================= |
2
|
|
|
|
3
|
|
|
// Utilities JavaScript (jQuery) |
4
|
|
|
|
5
|
|
|
// ============================================================================= |
6
|
|
|
|
7
|
|
|
(function($) { |
8
|
|
|
|
9
|
|
|
// Add isValid() |
10
|
|
|
|
11
|
|
|
$.fn.isValid = function(){ |
12
|
|
|
return this[0].checkValidity() |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
$(document).ready(function() { |
16
|
|
|
|
17
|
|
|
// Accordion Handlers ================================================== |
18
|
|
|
|
19
|
|
|
function accordionTrigger(trigger) { |
20
|
|
|
if ($(trigger).parent(".accordion").hasClass("active")) { |
21
|
|
|
$(trigger).attr("aria-expanded", "false"); |
22
|
|
|
$(trigger).parent(".accordion").removeClass("active"); |
23
|
|
|
$(trigger).parent(".accordion").find(".accordion-content").attr("aria-hidden", "true"); |
24
|
|
|
} |
25
|
|
|
else { |
26
|
|
|
$(trigger).attr("aria-expanded", "true"); |
27
|
|
|
$(trigger).parent(".accordion").addClass("active"); |
28
|
|
|
$(trigger).parent(".accordion").find(".accordion-content").attr("aria-hidden", "false"); |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
$(document).on("click", ".accordion-trigger", function(e){ |
|
|
|
|
33
|
|
|
|
34
|
|
|
accordionTrigger(this); |
35
|
|
|
|
36
|
|
|
}); |
37
|
|
|
|
38
|
|
|
$(document).on("keyup", ".accordion-trigger", function(e){ |
39
|
|
|
|
40
|
|
|
if(e.which == 13) { |
41
|
|
|
accordionTrigger(this); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
}); |
45
|
|
|
|
46
|
|
|
// Form Handlers ======================================================= |
47
|
|
|
|
48
|
|
|
// Required Fields |
49
|
|
|
|
50
|
|
|
function requiredFields() { |
51
|
|
|
$("input:required, textarea:required").each(function(e) { |
|
|
|
|
52
|
|
|
$(this).parent().addClass("required"); |
53
|
|
|
$(this).parent().find("label").append("<span class='form__required'><i class='fa fa-asterisk' aria-label='Asterisk'></i></span>"); |
54
|
|
|
}); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
requiredFields(); |
58
|
|
|
|
59
|
|
|
// Label Handers =================================================== |
60
|
|
|
|
61
|
|
|
function labelHandlers() { |
62
|
|
|
|
63
|
|
|
$("[class*='form__input-wrapper'] input, [class*='form__input-wrapper'] textarea").focusin(function(e) { |
|
|
|
|
64
|
|
|
$(this).parent().addClass("active"); |
65
|
|
|
}); |
66
|
|
|
|
67
|
|
|
$("[class*='form__input-wrapper'] input, [class*='form__input-wrapper'] textarea").focusout(function(e) { |
|
|
|
|
68
|
|
|
|
69
|
|
|
// Check for existing value. |
70
|
|
|
|
71
|
|
|
if ($(this).val() == "") { |
72
|
|
|
$(this).parent().removeClass("active"); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
// Check Validity |
76
|
|
|
|
77
|
|
|
if ($(this).isValid() == true) { |
|
|
|
|
78
|
|
|
|
79
|
|
|
if ($(this).val() == "" || $(this).attr("type") == "password") { |
80
|
|
|
$(this).parent().removeClass("valid"); |
81
|
|
|
$(this).parent().removeClass("invalid"); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
else { |
84
|
|
|
$(this).parent().addClass("valid"); |
85
|
|
|
$(this).parent().removeClass("invalid"); |
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
} |
89
|
|
|
else { |
90
|
|
|
|
91
|
|
|
if ($(this).attr("type") == "password") { |
92
|
|
|
return false; |
93
|
|
|
} |
94
|
|
|
else { |
|
|
|
|
95
|
|
|
$(this).parent().addClass("invalid"); |
96
|
|
|
$(this).parent().removeClass("valid"); |
|
|
|
|
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
}); |
102
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
labelHandlers(); |
106
|
|
|
|
107
|
|
|
// Experience Handlers ================================================= |
108
|
|
|
|
109
|
|
|
// Degrees |
110
|
|
|
|
111
|
|
|
function addDegree(trigger) { |
|
|
|
|
112
|
|
|
|
113
|
|
|
// Get Wrapper |
114
|
|
|
var wrapper = $(".application-post__experience-wrapper"); |
115
|
|
|
|
116
|
|
|
// Get Template |
117
|
|
|
var template = $(".application-post__accordion--degree.template").clone(); |
118
|
|
|
|
119
|
|
|
// Get New ID |
120
|
|
|
var newID = parseInt(wrapper.find("[class*='application-post__accordion--']").last().attr("data-experience-id")) + 1; |
121
|
|
|
|
122
|
|
|
// Remove Template Class |
123
|
|
|
template.removeClass("template"); |
124
|
|
|
|
125
|
|
|
// Assign the New ID |
126
|
|
|
template.attr("data-experience-id", newID); |
127
|
|
|
|
128
|
|
|
// Edit Form IDs |
129
|
|
|
|
130
|
|
|
// Degree Type |
131
|
|
|
template.find("[data-form-id*='experience-degree']").find("label").attr("for", "degree" + newID); |
132
|
|
|
template.find("[data-form-id*='experience-degree']").find("select").attr("id", "degree" + newID); |
133
|
|
|
|
134
|
|
|
// Area of Study |
135
|
|
|
template.find("[data-form-id*='experience-aos']").find("label").attr("for", "areaOfStudy" + newID); |
136
|
|
|
template.find("[data-form-id*='experience-aos']").find("input").attr("id", "areaOfStudy" + newID); |
137
|
|
|
|
138
|
|
|
// Institution |
139
|
|
|
template.find("[data-form-id*='experience-institution']").find("label").attr("for", "institution" + newID); |
140
|
|
|
template.find("[data-form-id*='experience-institution']").find("input").attr("id", "institution" + newID); |
141
|
|
|
|
142
|
|
|
// Start Date |
143
|
|
|
template.find("[data-form-id*='experience-start-date']").find("label").attr("for", "startDate" + newID); |
144
|
|
|
template.find("[data-form-id*='experience-start-date']").find("input").attr("id", "startDate" + newID); |
145
|
|
|
|
146
|
|
|
// End Date |
147
|
|
|
template.find("[data-form-id*='experience-end-date']").find("label").attr("for", "endDate" + newID); |
148
|
|
|
template.find("[data-form-id*='experience-end-date']").find("input").attr("id", "endDate" + newID); |
149
|
|
|
|
150
|
|
|
// Append Clone to the Wrapper |
151
|
|
|
wrapper.append(template); |
152
|
|
|
|
153
|
|
|
requiredFields(); |
154
|
|
|
labelHandlers(); |
155
|
|
|
|
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
$("#addDegreeButton").on("click", function(e) { |
159
|
|
|
|
160
|
|
|
e.preventDefault(); |
161
|
|
|
|
162
|
|
|
addDegree(this); |
163
|
|
|
|
164
|
|
|
}); |
165
|
|
|
|
166
|
|
|
$("#addDegreeButton").on("keyup", function(e) { |
167
|
|
|
|
168
|
|
|
if(e.which == 13) { |
169
|
|
|
e.preventDefault(); |
170
|
|
|
addDegree(this); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
}); |
174
|
|
|
|
175
|
|
|
// Courses |
176
|
|
|
|
177
|
|
|
function addCourse(trigger) { |
|
|
|
|
178
|
|
|
|
179
|
|
|
// Get Wrapper |
180
|
|
|
var wrapper = $(".application-post__experience-wrapper"); |
181
|
|
|
|
182
|
|
|
// Get Template |
183
|
|
|
var template = $(".application-post__accordion--course.template").clone(); |
184
|
|
|
|
185
|
|
|
// Get New ID |
186
|
|
|
var newID = parseInt(wrapper.find("[class*='application-post__accordion--']").last().attr("data-experience-id")) + 1; |
187
|
|
|
|
188
|
|
|
// Remove Template Class |
189
|
|
|
template.removeClass("template"); |
190
|
|
|
|
191
|
|
|
// Assign the New ID |
192
|
|
|
template.attr("data-experience-id", newID); |
193
|
|
|
|
194
|
|
|
// Edit Form IDs |
195
|
|
|
|
196
|
|
|
// Course Name |
197
|
|
|
template.find("[data-form-id*='experience-course-name']").find("label").attr("for", "courseName" + newID); |
198
|
|
|
template.find("[data-form-id*='experience-course-name']").find("input").attr("id", "courseName" + newID); |
199
|
|
|
|
200
|
|
|
// Institution |
201
|
|
|
template.find("[data-form-id*='experience-institution']").find("label").attr("for", "institution" + newID); |
202
|
|
|
template.find("[data-form-id*='experience-institution']").find("input").attr("id", "institution" + newID); |
203
|
|
|
|
204
|
|
|
// Start Date |
205
|
|
|
template.find("[data-form-id*='experience-start-date']").find("label").attr("for", "startDate" + newID); |
206
|
|
|
template.find("[data-form-id*='experience-start-date']").find("input").attr("id", "startDate" + newID); |
207
|
|
|
|
208
|
|
|
// End Date |
209
|
|
|
template.find("[data-form-id*='experience-end-date']").find("label").attr("for", "endDate" + newID); |
210
|
|
|
template.find("[data-form-id*='experience-end-date']").find("input").attr("id", "endDate" + newID); |
211
|
|
|
|
212
|
|
|
// Append Clone to the Wrapper |
213
|
|
|
wrapper.append(template); |
214
|
|
|
|
215
|
|
|
requiredFields(); |
216
|
|
|
labelHandlers(); |
217
|
|
|
|
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
$("#addCourseButton").on("click", function(e) { |
221
|
|
|
|
222
|
|
|
e.preventDefault(); |
223
|
|
|
|
224
|
|
|
addCourse(this); |
225
|
|
|
|
226
|
|
|
}); |
227
|
|
|
|
228
|
|
|
$("#addCourseButton").on("keyup", function(e) { |
229
|
|
|
|
230
|
|
|
if(e.which == 13) { |
231
|
|
|
e.preventDefault(); |
232
|
|
|
addCourse(this); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
}); |
236
|
|
|
|
237
|
|
|
// Work |
238
|
|
|
|
239
|
|
|
function addWork(trigger) { |
|
|
|
|
240
|
|
|
|
241
|
|
|
// Get Wrapper |
242
|
|
|
var wrapper = $(".application-post__experience-wrapper"); |
243
|
|
|
|
244
|
|
|
// Get Template |
245
|
|
|
var template = $(".application-post__accordion--work.template").clone(); |
246
|
|
|
|
247
|
|
|
// Get New ID |
248
|
|
|
var newID = parseInt(wrapper.find("[class*='application-post__accordion--']").last().attr("data-experience-id")) + 1; |
249
|
|
|
|
250
|
|
|
// Remove Template Class |
251
|
|
|
template.removeClass("template"); |
252
|
|
|
|
253
|
|
|
// Assign the New ID |
254
|
|
|
template.attr("data-experience-id", newID); |
255
|
|
|
|
256
|
|
|
// Edit Form IDs |
257
|
|
|
|
258
|
|
|
// Role |
259
|
|
|
template.find("[data-form-id*='experience-course-name']").find("label").attr("for", "role" + newID); |
260
|
|
|
template.find("[data-form-id*='experience-course-name']").find("input").attr("id", "role" + newID); |
261
|
|
|
|
262
|
|
|
// Group / Company |
263
|
|
|
template.find("[data-form-id*='experience-institution']").find("label").attr("for", "group" + newID); |
264
|
|
|
template.find("[data-form-id*='experience-institution']").find("input").attr("id", "group" + newID); |
265
|
|
|
|
266
|
|
|
// Description |
267
|
|
|
template.find("[data-form-id*='experience-description']").find("label").attr("for", "description" + newID); |
268
|
|
|
template.find("[data-form-id*='experience-description']").find("input").attr("id", "description" + newID); |
269
|
|
|
|
270
|
|
|
// Start Date |
271
|
|
|
template.find("[data-form-id*='experience-start-date']").find("label").attr("for", "startDate" + newID); |
272
|
|
|
template.find("[data-form-id*='experience-start-date']").find("input").attr("id", "startDate" + newID); |
273
|
|
|
|
274
|
|
|
// End Date |
275
|
|
|
template.find("[data-form-id*='experience-end-date']").find("label").attr("for", "endDate" + newID); |
276
|
|
|
template.find("[data-form-id*='experience-end-date']").find("input").attr("id", "endDate" + newID); |
277
|
|
|
|
278
|
|
|
// Append Clone to the Wrapper |
279
|
|
|
wrapper.append(template); |
280
|
|
|
|
281
|
|
|
requiredFields(); |
282
|
|
|
labelHandlers(); |
283
|
|
|
|
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
$("#addWorkButton").on("click", function(e) { |
287
|
|
|
|
288
|
|
|
e.preventDefault(); |
289
|
|
|
|
290
|
|
|
addWork(this); |
291
|
|
|
|
292
|
|
|
}); |
293
|
|
|
|
294
|
|
|
$("#addWorkButton").on("keyup", function(e) { |
295
|
|
|
|
296
|
|
|
if(e.which == 13) { |
297
|
|
|
e.preventDefault(); |
298
|
|
|
addWork(this); |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
}); |
302
|
|
|
|
303
|
|
|
// Create Job Handlers ================================================= |
304
|
|
|
|
305
|
|
|
// Tasks |
306
|
|
|
|
307
|
|
|
function addTask(trigger) { |
|
|
|
|
308
|
|
|
|
309
|
|
|
// Get Wrapper |
310
|
|
|
var wrapper = $(".manager-jobs__create-task-wrapper"); |
311
|
|
|
|
312
|
|
|
// Get Template |
313
|
|
|
var template = $(".manager-jobs__create-task.template").clone(); |
314
|
|
|
|
315
|
|
|
console.log(wrapper.find(".manager-jobs__create-task")); |
|
|
|
|
316
|
|
|
|
317
|
|
|
// Get New ID |
318
|
|
|
if (wrapper.find(".manager-jobs__create-task").length == 0) { |
|
|
|
|
319
|
|
|
var newID = parseInt(template.attr("data-task-id")) + 1; |
320
|
|
|
} |
321
|
|
|
else { |
322
|
|
|
var newID = parseInt(wrapper.find("[class*='manager-jobs__create-task']").last().attr("data-task-id")) + 1; |
|
|
|
|
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
// Remove Template Class |
326
|
|
|
template.removeClass("template"); |
327
|
|
|
|
328
|
|
|
// Assign the New ID |
329
|
|
|
template.attr("data-task-id", newID); |
330
|
|
|
|
331
|
|
|
// Add newID as suffix to all "id" and "for" attributes |
332
|
|
|
template.find("*[id]").each(function() { $(this).attr("id", this.id + newID)}); |
333
|
|
|
template.find("*[for]").each(function() { $(this).attr("for", $(this).attr("for") + newID)}); |
334
|
|
|
|
335
|
|
|
// Replace :id with newID in all form names |
336
|
|
|
template.find("*[name]").each(function() { $(this).attr('name', $(this).attr("name").replace(":id", newID))}); |
337
|
|
|
|
338
|
|
|
// Task (English) |
339
|
|
|
//template.find("[data-form-id*='task-english']").find("label").attr("for", "taskEN" + newID); |
340
|
|
|
//template.find("[data-form-id*='task-english']").find("input").attr("id", "taskEN" + newID); |
341
|
|
|
|
342
|
|
|
// Task (French) |
343
|
|
|
//template.find("[data-form-id*='task-french']").find("label").attr("for", "taskFR" + newID); |
344
|
|
|
//template.find("[data-form-id*='task-french']").find("input").attr("id", "taskFR" + newID); |
345
|
|
|
|
346
|
|
|
// Append Clone to the Wrapper |
347
|
|
|
wrapper.append(template); |
348
|
|
|
|
349
|
|
|
requiredFields(); |
350
|
|
|
labelHandlers(); |
351
|
|
|
deleteTaskTrigger(); |
352
|
|
|
|
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
$("#addTaskButton").on("click", function(e) { |
356
|
|
|
|
357
|
|
|
e.preventDefault(); |
358
|
|
|
|
359
|
|
|
addTask(this); |
360
|
|
|
|
361
|
|
|
}); |
362
|
|
|
|
363
|
|
|
$("#addTaskButton").on("keyup", function(e) { |
364
|
|
|
|
365
|
|
|
if(e.which == 13) { |
366
|
|
|
e.preventDefault(); |
367
|
|
|
addTask(this); |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
}); |
371
|
|
|
|
372
|
|
|
// Task Deletion |
373
|
|
|
|
374
|
|
|
function deleteTask(trigger) { |
375
|
|
|
|
376
|
|
|
$(trigger).parents(".manager-jobs__create-task").remove(); |
377
|
|
|
|
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
function deleteTaskTrigger() { |
381
|
|
|
|
382
|
|
|
$(".manager-jobs__delete-task-button").on("click", function(e) { |
383
|
|
|
|
384
|
|
|
e.preventDefault(); |
385
|
|
|
|
386
|
|
|
deleteTask(this); |
387
|
|
|
|
388
|
|
|
}); |
389
|
|
|
|
390
|
|
|
$(".manager-jobs__delete-task-button").on("keyup", function(e) { |
391
|
|
|
|
392
|
|
|
if(e.which == 13) { |
393
|
|
|
e.preventDefault(); |
394
|
|
|
deleteTask(this); |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
}); |
398
|
|
|
|
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
deleteTaskTrigger(); |
402
|
|
|
|
403
|
|
|
// Skills |
404
|
|
|
|
405
|
|
|
// Questions |
406
|
|
|
|
407
|
|
|
function addQuestion(trigger) { |
|
|
|
|
408
|
|
|
|
409
|
|
|
// Get Wrapper |
410
|
|
|
var wrapper = $(".manager-jobs__create-question-wrapper"); |
411
|
|
|
|
412
|
|
|
// Get Template |
413
|
|
|
var template = $(".manager-jobs__create-question.template").clone(); |
414
|
|
|
|
415
|
|
|
console.log(wrapper.find(".manager-jobs__create-question")); |
|
|
|
|
416
|
|
|
|
417
|
|
|
// Get New ID |
418
|
|
|
if (wrapper.find(".manager-jobs__create-question").length == 0) { |
|
|
|
|
419
|
|
|
var newID = parseInt(template.attr("data-question-id")) + 1; |
420
|
|
|
} |
421
|
|
|
else { |
422
|
|
|
var newID = parseInt(wrapper.find("[class*='manager-jobs__create-question']").last().attr("data-question-id")) + 1; |
|
|
|
|
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
// Remove Template Class |
426
|
|
|
template.removeClass("template"); |
427
|
|
|
|
428
|
|
|
// Assign the New ID |
429
|
|
|
template.attr("data-question-id", newID); |
430
|
|
|
|
431
|
|
|
// Add newID as suffix to all "id" and "for" attributes |
432
|
|
|
template.find("*[id]").each(function() { $(this).attr("id", this.id + newID)}); |
433
|
|
|
template.find("*[for]").each(function() { $(this).attr("for", $(this).attr("for") + newID)}); |
434
|
|
|
|
435
|
|
|
// Replace :id with newID in all form names |
436
|
|
|
template.find("*[name]").each(function() { $(this).attr('name', $(this).attr("name").replace(":id", newID))}); |
437
|
|
|
|
438
|
|
|
// Edit Form IDs |
439
|
|
|
// |
440
|
|
|
// // Queestion (English) |
441
|
|
|
// template.find("[data-form-id*='question-english']").find("label").attr("for", "questionEN" + newID); |
442
|
|
|
// template.find("[data-form-id*='question-english']").find("input").attr("id", "questionEN" + newID); |
443
|
|
|
// |
444
|
|
|
// // Queestion (French) |
445
|
|
|
// template.find("[data-form-id*='question-french']").find("label").attr("for", "questionFR" + newID); |
446
|
|
|
// template.find("[data-form-id*='question-french']").find("input").attr("id", "questionFR" + newID); |
447
|
|
|
|
448
|
|
|
// Append Clone to the Wrapper |
449
|
|
|
wrapper.append(template); |
450
|
|
|
|
451
|
|
|
requiredFields(); |
452
|
|
|
labelHandlers(); |
453
|
|
|
deleteQuestionTrigger(); |
454
|
|
|
|
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
$("#addQuestionButton").on("click", function(e) { |
458
|
|
|
|
459
|
|
|
e.preventDefault(); |
460
|
|
|
|
461
|
|
|
addQuestion(this); |
462
|
|
|
|
463
|
|
|
}); |
464
|
|
|
|
465
|
|
|
$("#addQuestionButton").on("keyup", function(e) { |
466
|
|
|
|
467
|
|
|
if(e.which == 13) { |
468
|
|
|
e.preventDefault(); |
469
|
|
|
addQuestion(this); |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
}); |
473
|
|
|
|
474
|
|
|
// Task Deletion |
475
|
|
|
|
476
|
|
|
function deleteQuestion(trigger) { |
477
|
|
|
|
478
|
|
|
$(trigger).parents(".manager-jobs__create-question").remove(); |
479
|
|
|
|
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
function deleteQuestionTrigger() { |
483
|
|
|
|
484
|
|
|
$(".manager-jobs__delete-question-button").on("click", function(e) { |
485
|
|
|
|
486
|
|
|
e.preventDefault(); |
487
|
|
|
|
488
|
|
|
deleteQuestion(this); |
489
|
|
|
|
490
|
|
|
}); |
491
|
|
|
|
492
|
|
|
$(".manager-jobs__delete-question-button").on("keyup", function(e) { |
493
|
|
|
|
494
|
|
|
if(e.which == 13) { |
495
|
|
|
e.preventDefault(); |
496
|
|
|
deleteQuestion(this); |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
}); |
500
|
|
|
|
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
deleteQuestionTrigger(); |
504
|
|
|
|
505
|
|
|
}); |
506
|
|
|
|
507
|
|
|
})(jQuery); |
508
|
|
|
|
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.