1var EH = {}; 2var $document = $(document); 3var $document_body = $(document.body); 4var $window = $(window); 5var $html = $('html'); 6var $body = $('body'); 7var $notification = $('.js-notification'); 8var $preloader = $('#preloader'); 9 10(function ($) { 11 'use strict'; 12 13 EH.initialize = { 14 init: function() { 15 EH.initialize.setupAjaxHeader(); 16 EH.initialize.activateTooltipPopover(); 17 EH.initialize.goToTop(); 18 EH.initialize.floatMenu(); 19 EH.initialize.acceptCookie(); 20 21 //Remove old cookie 22 Cookies.remove('cookies_status'); 23 }, 24 setupAjaxHeader: function() { 25 $.ajaxSetup({ 26 headers: { 27 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 28 }, 29 dataType: 'json', 30 type: 'POST', 31 timeout: 60000, 32 error: function (xhr,status,error) { 33 let message = xhr.responseJSON.message; 34 if (error == 'timeout') 35 message = 'Looks like the server is taking to long to respond, please try again in sometime'; 36 EH.notification.showWarning(message); 37 if (xhr.status == 419) 38 location.reload(true); 39 }, 40 complete: function() { 41 EH.initialize.hideFullscreenLoading(); 42 EH.loading.hideCenter(); 43 }, 44 }); 45 }, 46 activateTooltipPopover: function() { 47 $('[data-toggle="tooltip"]').tooltip(); 48 $('[data-toggle="popover"]').popover(); 49 $('.popover-dismiss').popover({ 50 trigger: 'focus' 51 }) 52 }, 53 goToTop: function() { 54 var $top = $('.js-go-to'); 55 56 $top.on("click", function(e) { 57 e.preventDefault(); 58 $("html, body").animate({scrollTop: 0}, 600); 59 }); 60 $window.scroll(function() { 61 if ($window.scrollTop() > 400) { 62 $top.addClass("show"); 63 } else { 64 $top.removeClass("show"); 65 } 66 }) 67 }, 68 floatMenu: function() { 69 var $sidebar = $('#sidebar');
70 var $overlay = $('.overlay'); 71 if ($sidebar.length) { 72 /* 73 $sidebar.mCustomScrollbar({ 74 theme: 'minimal' 75 }); 76 */ 77 $overlay.on('click', function () { 78 $sidebar.removeClass('active'); 79 $overlay.removeClass('active'); 80 }); 81 $('.js-sidebar-collapse').on('click', function () { 82 $sidebar.addClass('active'); 83 $overlay.addClass('active'); 84 }); 85 } 86 }, 87 showPreloader: function() { 88 let t = setTimeout(function() { 89 if( $preloader.length > 0 ) { 90 $preloader.delay(200).fadeOut('slow'); 91 //EH.initialize.showCookieConsent(); 92 } 93 }, 100); 94 95 }, 96 showCookieConsent: function() { 97 window.cookieconsent.initialise({ 98 "palette": { 99 "popup": { 100 "background": "#000" 101 }, 102 "button": { 103 "background": "#f1d600" 104 } 105 }, 106 "showLink": false, 107 "theme": "classic", 108 "position": "bottom-left", 109 "content": { 110 "message": "This website uses cookies to ensure you get the best experience on your website" 111 } 112 }); 113 }, 114 showFullscreenLoading: function(message) { 115 $preloader.find('#spinner').append(`<div class="text-primary font-weight-bold js-message mt-2">${message}</div>`); 116 $preloader.css('background', 'rgba(255, 255, 255, 0.7)').fadeIn(); 117 }, 118 hideFullscreenLoading: function() { 119 $preloader.find('.js-message').remove(); 120 $preloader.fadeOut('fast'); 121 }, 122 showButtonLoading: function($button, message) { 123 $button.prop('disabled', true).addClass('js-btn-upload-loading'); 124 $button.html(`<span class="spinner-border spinner-border-sm mr-1" role="status" aria-hidden="true"></span>${message}`); 125 }, 126 removeButtonLoading: function($button, message) { 127 $button.prop('disabled', false).removeClass('js-btn-upload-loading'); 128 $button.html(message); 129 }, 130 randomId: function() { 131 var text = ""; 132 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; 133 for (var i = 0; i < 5; i++) 134 text += possible.charAt(Math.floor(Math.random() * possible.length)); 135 return text; 136 }, 137 acceptCookie: function() { 138 $('.js-btn-accept-cookie').on("click", function(e) { 139 let data_cookie = $(this).data('cookie'); 140 if (data_cookie == '' && !$('#statistics_cookies').is(':checked')) 141 data_cookie = 'necessary'; 142 else 143 data_cookie = 'all'; 144 145 $('.js-cookies').fadeOut(); 146 Cookies.set('cookieconsent_status', data_cookie, { SameSite: 'None', secure: true }); 147 if (typeof ga_id !== 'undefined' && data_cookie == 'all') { 148 window[`ga-disable-${ga_id}`] = false; 149 if(typeof gtag === 'function') { 150 gtag('config', `${ga_id}`); 151 } 152 153 if(typeof ga === 'function') { 154 ga('send', 'pageview'); 155 } 156 } 157 }); 158 159 $('.js-cookies-toggle').on('click', function(e) { 160 $('.js-cookies').toggleClass('hide'); 161 }); 162
163 $('.js-close-cookies').on('click', function(e) { 164 e.preventDefault(); 165 $('.js-cookies').fadeOut(); 166 }); 167 168 $('.js-cookies').on('click', '.custom-checkbox:first', function(e) { 169 alert('Mandatory - can not be deselected. Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.'); 170 }) 171 }, 172 initTelephoneInput: function(national_mode) { 173 $('.js-telephone-input').intlTelInput({ 174 hiddenInput: 'full_phone', 175 initialCountry: "auto", 176 geoIpLookup: function(callback) { 177 $.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) { 178 var countryCode = (resp && resp.country) ? resp.country : ""; 179 callback(countryCode); 180 }); 181 }, 182 nationalMode: national_mode, 183 utilsScript: base_url + "/vendor/intl-tel-input/js/utils.js" 184 }); 185 }, 186 hasRequireFieldsEmpty: function(message) { 187 const class_name_not_check = "not-check-required-field"; 188 $('.js-required-field').each((i, el) => { $(el).removeClass(class_name_not_check); }); 189 $(".hidden .js-required-field").each((i, el) => { $(el).addClass(class_name_not_check); }); 190 $(".js-editable-table-field").each((i, el) => { $(el).addClass(class_name_not_check); }); 191 let require_fields = $(`.js-required-field:not(.${class_name_not_check})`); 192 193 message = message || (message = "Please complete all required fields."); 194 const fields_empty = require_fields.filter(function(i, el) { 195 const value = $(el).text().toString().toLowerCase().trim(); 196 if( value === "empty" || value.indexOf("*") >= 0) { 197 return true; 198 } 199 }); 200 201 if(fields_empty.length > 0) { 202 const first_element = fields_empty[0]; 203 first_element.scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"}); 204 EH.notification.showWarning(message); 205 return true; 206 } 207 return false; 208 } 209 }; 210 211 EH.notification = { 212 alert : $notification.find('.alert'), 213 show: function(message, type) { 214 EH.notification.setType(type); 215 EH.notification.setMessage(message); 216 $notification.fadeIn().delay(3000).fadeOut(); 217 }, 218 showSuccess: function(message) { 219 EH.notification.show(`<i class="fas fa-check-circle mr-2"></i> ${message}`, 'success'); 220 return true; 221 }, 222 showWarning: function(message) { 223 EH.notification.show(`<i class="fas fa-exclamation-triangle mr-2"></i> ${message}`, 'warning'); 224 return false; 225 }, 226 setMessage: function(message) { 227 EH.notification.alert.find('.js-nofication-message').html(message); 228 }, 229 setType: function(type) { 230 EH.notification.alert.removeClass('alert-warning alert-success').addClass(`alert-${type}`); 231 } 232 } 233 234 EH.map = { 235 componentForm: { 236 locality: 'long_name', 237 administrative_area_level_1: 'long_name', 238 country: 'long_name', 239 postal_code: 'short_name' 240 }, 241 location: {}, 242 locationItems: [], 243 delayKeypress: null, 244 requestCurrent: null, 245 initLocation: function() { 246 const $location_value = $location_input.val(); 247 let $latitude_value = ''; 248 let $longitude_value = ''; 249 EH.map.location = { 250 city: '', 251 state: '', 252 location_name: $location_value, 253 country: '', 254 post_code: '', 255 country_code: '', 256 latitude: $latitude_value, 257 longitude: $longitude_value 258 } 259 }, 260 init: function() { 261 EH.map.autocomplete(); 262 EH.map.initLocation(); 263 if($location_input.val()) { 264 EH.map.location.latitude = ($('#inp-latitude') !== undefined) ? $('#inp-latitude').val() : ''; 265 EH.map.location.longitude = ($('#inp-longitude') !== undefined) ? $('#inp-longitude').val() : ''; 266 } 267 }, 268 autocomplete: function() { 269 $location_input.autocomplete({ 270 source: function(request, response) { 271 clearTimeout(EH.map.delayKeypress); 272 let $btnSearch = null; 273 let $defaultButtonLabel = ""; 274 if(EH.map.requestCurrent !== null) { 275 EH.map.requestCurrent.abort(); 276 } 277 if(typeof $job_search_form !== 'undefined') { 278 $btnSearch = $job_search_form.find('.js-search-button'); 279 $defaultButtonLabel = $($btnSearch).html(); 280 } else if(typeof $("form#applyForm") !== 'undefined') { 281 $btnSearch = $("form#applyForm").find('button[type=submit]'); 282 $defaultButtonLabel = $($btnSearch).text(); 283 } 284 if($btnSearch){ 285 EH.initialize.showButtonLoading($btnSearch, ''); 286 } 287 EH.map.delayKeypress = setTimeout(function () { 288 EH.map.requestCurrent = $.ajax({ 289 url: geocoding_url, 290 data: {term: request.term}, 291 success: function(data){ 292 if(Array.isArray(data) && data.length > 0) { 293 response(data); 294 } 295 if($btnSearch){ 296 EH.initialize.removeButtonLoading( 297 $btnSearch, $defaultButtonLabel 298 ); 299 } 300 }, 301 error: function() { 302 if($btnSearch){ 303 EH.initialize.removeButtonLoading( 304 $btnSearch, $defaultButtonLabel 305 ); 306 } 307 } 308 }); 309 }, 200); 310 }, 311 change: function( event, ui ) { 312 // if (!ui.item) { 313 // EH.map.updateLocationInfo(''); 314 // } 315 if (!event.currentTarget.value) { 316 EH.map.locationItems = []; 317 } 318 }, 319 response: function( event, ui ) { 320 EH.map.updateLocationInfo(ui.content[0].value); 321 EH.map.locationItems = ui.content; 322 }, 323 focus: function( event, ui ) { 324 EH.map.updateLocationInfo( ui.item.value ); 325 return false;
326 }, 327 select: function( event, ui ) { 328 $location_input.val(ui.item.value.formatted_address); 329 EH.map.updateLocationInfo( ui.item.value ); 330 return false; 331 } 332 }); 333 }, 334 updateLocationInfo: function(place) { 335 EH.map.initLocation(); 336 if (place) { 337 let formatted_address = place.formatted_address; 338 const latitude = place.geometry.location.lat; 339 const longitude = place.geometry.location.lng; 340 $('#inp-latitude').val(latitude); 341 $('#inp-longitude').val(longitude); 342 EH.map.location.location_name = formatted_address; 343 EH.map.location.address = formatted_address; 344 345 EH.map.location.latitude = latitude; 346 EH.map.location.longitude = longitude; 347 348 for (let i = 0; i < place.address_components.length; i++) { 349 let address_type = place.address_components[i].types[0]; 350 let long_name = place.address_components[i]['long_name']; 351 let short_name = place.address_components[i]['short_name']; 352 353 switch(address_type) 354 { 355 case 'country': 356 EH.map.location.country_code = short_name; 357 EH.map.location.country = long_name; 358 break; 359 360 case 'locality': 361 EH.map.location.city = long_name; 362 break; 363 364 case 'administrative_area_level_1': 365 EH.map.location.state = long_name; 366 break; 367 368 case 'postal_code': 369 EH.map.location.post_code = short_name; 370 break; 371 } 372 } 373 } 374 } 375 } 376 377 EH.validation = { 378 setDefaults: function() { 379 if ($.validator !== undefined) { 380 $.validator.setDefaults({ 381 messages: validation_messages, 382 errorElement: 'div', 383 errorPlacement: function ( error, element ) { 384 error.addClass( 'invalid-feedback' ); 385 element.addClass('is-invalid'); 386 387 if ( element.prop( 'type' ) === 'checkbox' || element.prop( 'type' ) === 'radio' || element.hasClass('js-telephone-input') ) { 388 element.closest('.form-group').append(error); 389 } else { 390 error.insertAfter( element ); 391 } 392 }, 393 highlight: function ( element, errorClass, validClass ) { 394 $(element).addClass('is-invalid'); 395 }, 396 unhighlight: function (element, errorClass, validClass) { 397 $(element).removeClass('is-invalid'); 398 }, 399 submitHandler: function(form) { 400 if (EH.page.validatePassword()) { 401 EH.initialize.showButtonLoading($(form).find('[type="submit"]'), 'Processing ...'); 402 EH.executeCaptcha(form); 403 } 404 405 }, 406 normalizer: function(value) { 407 return $.trim(value); 408 }, 409 }); 410 $.validator.messages.required = validation_messages.required; 411 EH.validation.passwordRules(); 412 } 413 }, 414 passwordRules: function() { 415 416 $.validator.addMethod("passwordHasNumbers", function(password, element) { 417 let num = password.match(/[0-9]/g); 418 return num ? (num.length > 1) : false; 419 }, validation_messages.password.hasNumbers); 420 421 $.validator.addMethod("passwordHasUppercase", function(password, element) { 422 let num = password.match(/[A-Z]/g); 423 return num ? (num.length > 0) : false;
424 }, validation_messages.password.hasUppercase); 425 $.validator.addMethod("validEmail", function(email, element) { 426 return EH.validation.email(email); 427 }, validation_messages.email.valid); 428 429 $.validator.addMethod("passwordInstructionValidation", function(password, element) { 430 let countPassedValidation = 0; 431 432 if (password < 10) { 433 return false; 434 } 435 436 if (commonPasswords.includes(password.toLowerCase())) { 437 return false; 438 } 439 440 if (password.match(/[a-z]/g)) { 441 countPassedValidation++; 442 } 443 444 if (password.match(/[A-Z]/g)) { 445 countPassedValidation++; 446 } 447 448 if (password.match(/[0-9]/g)) { 449 countPassedValidation++; 450 } 451 452 if (/[`!@#$%^&*()_\-+=\[\]{};':"\\|,.<>\/?~ ]/.test(password)) { 453 countPassedValidation++; 454 } 455 456 if (password.length >= 20) { 457 countPassedValidation++; 458 } 459 460 return countPassedValidation >= 4; 461 }, "Password does not meet the requirements."); 462 }, 463 email: function(email) { 464 var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 465 return re.test(String(email).toLowerCase()); 466 } 467 } 468 469 EH.file = { 470 validate: function(file, valid_extensions) { 471 let file_size = file.size; 472 let extension = file.name.substr(file.name.lastIndexOf('.') + 1).toLowerCase(); 473 if ($.inArray(extension, valid_extensions) == -1){ 474 return EH.notification.showWarning(validation_messages.file.invalidFileType); 475 } else if (file_size > 5242880) { 476 return EH.notification.showWarning(validation_messages.file.invalidFileSize); 477 } 478 return true; 479 }, 480 validateImage: function(file) { 481 return EH.file.validate(file, ['png', 'bmp', 'jpg', 'jpeg', 'ico', 'gif']) 482 }, 483 validateDocument: function(file) { 484 return EH.file.validate(file, ['pdf', 'doc', 'docx', 'rtf', 'png', 'jpeg', 'jpg', 'bmp', 'jng', 'ppt', 'pptx', 'csv', 'gif']); 485 }, 486 validateByType: function(file, type) { 487 if (type == 'document') 488 return EH.file.validateDocument(file); 489 return EH.file.validateImage(file); 490 }, 491 reset: function($el){ 492 $el.wrap('<form>').closest('form').get(0).reset(); 493 $el.unwrap(); 494 } 495 } 496 497 EH.loading = { 498 showCenter: function($selector) { 499 let html = $('#spinner').html(); 500 let $center_loading = $(`<div class="center-loading js-center-loading">${html}</div>`); 501 $selector.css('position', 'relative').append($center_loading); 502 }, 503 hideCenter: function() { 504 $('.js-center-loading').remove(); 505 }, 506 hideAll: function() { 507 508 } 509 } 510 511 EH.includeCaptchaActions = new Set(['submit_cv', 'submit_vacancy', 'apply', 'register']); 512 513 EH.executeCaptcha = function(form, callback) { 514 var submitAction = function() { 515 if (callback !== undefined) { 516 callback(); 517 } 518 else { 519 form.submit(); 520 } 521 } 522 if (!isUser) { 523 var action = form.action.indexOf('/apply/') >= 0 ? 'apply' : form.action.split('/').pop().replace('-', '_'); 524 525 //Sometimes, a tracking url is appended to the actual path 526 //Truncate this to get the actual action value 527 if (action.indexOf('?')) { 528 action = action.split('?')[0]; 529 } else if (action.indexOf('#')) { 530 action = action.split('#')[0]; 531 } 532 533 if (EH.includeCaptchaActions.has(action)) { 534 grecaptcha.execute(captchaKey, {action: action}) 535 .then(function(token) { 536 var $gcaptcha = $('.gcaptcha-token', form); 537 if (!$gcaptcha.length) { 538 $gcaptcha = $('<input type="hidden" name="gcaptcha_token">').appendTo(form); 539 } 540 $gcaptcha.val(token); 541 submitAction(); 542 }) 543 .catch(submitAction); 544 } 545 else { 546 submitAction(); 547 } 548 } 549 else { 550 submitAction(); 551 } 552 } 553 554 window.addEventListener('load', function () { 555 EH.initialize.showPreloader();
556 EH.initialize.init(); 557 }); 558 559})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.