templates/front/offer/offer_preview/offer_preview.twig line 1

Open in your IDE?
  1. {% if offer is defined %}
  2.     {% set description = offer.workDescription|default %}
  3.     {% if app.request.locale == 'pl' %}
  4.         {% set title = offer.header.offerNamePL != '' ? offer.header.offerNamePL|default : offer.header.offerNameEN|default %}
  5.     {% else %}
  6.         {% set title = offer.header.offerNameEN != '' ? offer.header.offerNameEN|default : offer.header.offerNamePL|default %}
  7.     {% endif %}
  8. {% endif %}
  9. {% extends "front/layouts/default.twig" %}
  10. {% block content %}
  11.     {% if offer.offer|default(null) is null %}
  12.         {% set offer = offer %}
  13.     {% else %}
  14.         {% set offer = offer.offer %}
  15.     {% endif %}
  16.     {% include 'front/offer/offer_preview/includes/header/back_to_list_menu_top.twig' %}
  17.     {% include 'front/offer/offer_preview/includes/offer_preview.twig'
  18.         with
  19.         {
  20.             bottom_menu: true,
  21.             offer: offer,
  22.         }
  23.     %}
  24. {% endblock %}
  25. {% set currentPath = app.request.schemeAndHttpHost ~ app.request.requestUri %}
  26. {# Recaptch #}
  27. {% block script %}
  28. <input type="text" class="page_url" value="{{ currentPath }}" style="display: none;"> 
  29. <script src="https://www.google.com/recaptcha/api.js?render=6LfE3zUqAAAAAJ-V6PWpV7aWU_sbzShJho_MKIJn" async defer></script>
  30. <script>
  31. let pageUrl = {{ currentPath|json_encode|raw  }};
  32. const ARROW_DOWN = () => {
  33.     return `
  34.     <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-fill" viewBox="0 0 16 16">
  35.         <path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/>
  36.     </svg>`;
  37. };
  38. const ARROW_UP = () => {
  39.     return `
  40.     <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-up-fill" viewBox="0 0 16 16">
  41.         <path d="m7.247 4.86-4.796 5.481c-.566.647-.106 1.659.753 1.659h9.592a1 1 0 0 0 .753-1.659l-4.796-5.48a1 1 0 0 0-1.506 0z"/>
  42.     </svg>`;
  43. };
  44. let langguage = `{{app.request.locale}}`;
  45. let messageSize = {
  46.     pl:'Plik ma za duży rozmiar (dozwolony rozmiar max 5 MB).',
  47.     en:'The file is too large (allowed size max 5 MB).'
  48. };
  49. let messageApplication = {
  50.     pl:'Zgłoszenie nie zostało wysłane, spróbuj ponownie.',
  51.     en:'The application was not sent, please try again.'
  52. };
  53. let messageType = {
  54.     pl: 'Nieprawidłowe rozszerzenie.',
  55.     en: 'Invalid extension.'
  56. }
  57. function validRequiredCheckBox(textbox){
  58.     let messageValidCheckbox = `{{ 'USER_ZONE.APPLICATION_MODAL.CHECKBOX_MESSAGE_VALID'|trans }}`;
  59.     if(!textbox.checked){
  60.         textbox.setCustomValidity(messageValidCheckbox);
  61.     }else{
  62.         textbox.setCustomValidity('');
  63.     }
  64.     return true;
  65. }
  66. function onSubmit(token) {
  67.     $.ajax({
  68.         method:'POST',
  69.         url:'/recaptch/send/data',
  70.         data:{response:token},
  71.         success: (rep)=>
  72.         {
  73.             if(rep.success == true){
  74.                 grecaptcha.ready(function() {
  75.                     grecaptcha.execute('6LfE3zUqAAAAAJ-V6PWpV7aWU_sbzShJho_MKIJn', {action: 'submit'}).then(function(token2) {
  76.                         $('#from-aplication').append('<input type="hidden" name="response" value="'+token2+'">');
  77.                     });
  78.                 });
  79.                 $('#from-aplication').trigger('submit');
  80.             }else{
  81.                 $('.alert-application').show();
  82.                 langguage == 'pl' ? $('.alert-message').text(messageApplication.pl):$('.alert-message').text(messageApplication.en);
  83.                 $('.button-to-send-cv').attr('disabled',false);
  84.             }
  85.         }
  86.     });
  87. }
  88. $(document).on('click', '.copy_url', function(){
  89.     $('.page_url').show();
  90.     $('.page_url').select();
  91.     document.execCommand("copy");
  92.     $('.page_url').blur();
  93.     $('.page_url').hide();
  94. });
  95. $('#from-aplication').submit(function(e) {
  96.     let valid = $('.file_is_valid').length;
  97.     let checkboxObject = $('.form_checkbox_valid_required');
  98.     let checkbox = checkboxObject.toArray();
  99.     let inputRequiredObject = $('.form_input_valid_required');
  100.     let inputRequired = inputRequiredObject.toArray();
  101.     let error = false;
  102.     e.preventDefault();
  103.     if (inputRequiredObject.length) {
  104.         inputRequired.forEach((element) => {
  105.             if (!$(element).val()) {
  106.                 $(element).css('border','1px solid red');
  107.                 error = true;
  108.                 return;
  109.             }
  110.             $(element).removeAttr('style');
  111.         });
  112.     }
  113.     if (checkboxObject.length) {
  114.         checkbox.forEach((element) => {
  115.             if (!$(element).prop('checked')) {
  116.                 $(element).css('border','1px solid red');
  117.                 error = true;
  118.                 return;
  119.             }
  120.             $(element).removeAttr('style');
  121.         });
  122.     }
  123.     if (!valid) {
  124.         $('.box-upload').css('border','1px solid red');
  125.         error = true;
  126.     }
  127.     if (!error) {
  128.         $('#from-aplication').unbind('submit');
  129.         $('.alert-application').show();
  130.         $('.button-to-send-cv').attr('disabled', true);
  131.         $('.alert-message').text(`{{ 'USER_ZONE.APPLICATION_MODAL.THANKS'|trans }}`);
  132.         $('.box-upload').removeAttr('style');
  133.         setTimeout(()=>{
  134.              e.currentTarget.submit()
  135.         }, 2000);
  136.     }
  137. });
  138. $(document).on('click', '.text-checkbox2-label', function(){
  139.     if($(this).hasClass('drop-down-list-checkbox')){
  140.         $(this).removeClass('drop-down-list-checkbox');
  141.         $('.arrow-label-checkbox').html(ARROW_DOWN);
  142.         $('.box-text-checlbox2-label').hide();
  143.     }else{
  144.         $(this).addClass('drop-down-list-checkbox');
  145.         $('.arrow-label-checkbox').html(ARROW_UP);
  146.         $('.box-text-checlbox2-label').show();
  147.     }
  148. });
  149.  
  150. $(document).ready(function(){
  151.     const acceptFileType = `{{ constant('App\\Entity\\File::ACCEPTED_FILE_TYPE')|json_encode }}`;
  152.     $('.upload-button').change(function(e){
  153.         var name = e.target.files[0].name;
  154.         var type = e.target.files[0].type;
  155.         var size = Math.round(((e.target.files[0].size/1024)/1024).toFixed(4));
  156.         if(acceptFileType.includes(type))
  157.         {
  158.             if(size >= 5){
  159.                 $('.upload-button').removeClass('file_is_valid');
  160.                 $('.box-upload').css('border','1px solid red');
  161.                 langguage == 'pl' ? $('.text-message-upload').text(messageSize.pl):$('.text-message-upload').text(messageSize.en) ;
  162.             }else{
  163.                 $('.upload-button').addClass('file_is_valid');
  164.                 $('.text-message-upload').text(name);
  165.                 $('.box-upload').removeAttr('style')
  166.             }
  167.         }else{
  168.             $('.box-upload').css('border','1px solid red');
  169.             $('.upload-button').removeClass('file_is_valid');
  170.             langguage == 'pl' ? $('.text-message-upload').text(messageType.pl):$('.text-message-upload').text(messageType.en) ;
  171.         }
  172.     });
  173. });  
  174. function slug(text)
  175. {
  176.     text = text.toString().toLowerCase().trim();
  177.     const sets = [
  178.         {to: 'a', from: '[ÀÁÂÃÄÅÆĀĂĄẠẢẤẦẨẪẬẮẰẲẴẶἀ]'},
  179.         {to: 'c', from: '[ÇĆĈČ]'},
  180.         {to: 'd', from: '[ÐĎĐÞ]'},
  181.         {to: 'e', from: '[ÈÉÊËĒĔĖĘĚẸẺẼẾỀỂỄỆ]'},
  182.         {to: 'g', from: '[ĜĞĢǴ]'},
  183.         {to: 'h', from: '[ĤḦ]'},
  184.         {to: 'i', from: '[ÌÍÎÏĨĪĮİỈỊ]'},
  185.         {to: 'j', from: '[Ĵ]'},
  186.         {to: 'ij', from: '[IJ]'},
  187.         {to: 'k', from: '[Ķ]'},
  188.         {to: 'l', from: '[ĹĻĽŁ]'},
  189.         {to: 'm', from: '[Ḿ]'},
  190.         {to: 'n', from: '[ÑŃŅŇ]'},
  191.         {to: 'o', from: '[ÒÓÔÕÖØŌŎŐỌỎỐỒỔỖỘỚỜỞỠỢǪǬƠ]'},
  192.         {to: 'oe', from: '[Œ]'},
  193.         {to: 'p', from: '[ṕ]'},
  194.         {to: 'r', from: '[ŔŖŘ]'},
  195.         {to: 's', from: '[ߌŜŞŠȘ]'},
  196.         {to: 't', from: '[ŢŤ]'},
  197.         {to: 'u', from: '[ÙÚÛÜŨŪŬŮŰŲỤỦỨỪỬỮỰƯ]'},
  198.         {to: 'w', from: '[ẂŴẀẄ]'},
  199.         {to: 'x', from: '[ẍ]'},
  200.         {to: 'y', from: '[ÝŶŸỲỴỶỸ]'},
  201.         {to: 'z', from: '[ŹŻŽ]'},
  202.         {to: '-', from: '[·/_,:;\']'}
  203.     ];
  204.     sets.forEach(set => {
  205.         text = text.replace(new RegExp(set.from, 'gi'), set.to);
  206.     });
  207.     return text
  208.         .replace(/\s+/g, '-')
  209.         .replace(/[^0-9a-zа-я\u0370-\u03ff\u1f00-\u1fff-]+/g, '')
  210.         .replace(/--+/g, '-')
  211.         .replace(/^-+/, '')
  212.         .replace(/-+$/, '');
  213. }
  214. function createFiltersString(){
  215.   filtersString = '';
  216.     $('.click-filter').each(function() {
  217.         if (filtersString === '') {
  218.             filtersString += '?';
  219.             filtersString += $(this).data('filter-key') + '=' + slug($(this).data('filter'));
  220.         } else {
  221.             filtersString += '&';
  222.             filtersString += $(this).data('filter-key') + '=' +  slug($(this).data('filter'));
  223.           
  224.         }
  225.         if($(this).data('filter-key') == "filters[search][]"){
  226.             filtersString += '&';
  227.             filtersString += "filters[phrase]["+slug($(this).data('filter'))+"]" + '=' + $(this).data('filter');
  228.         }
  229.         // filtersString += '&page=1'
  230.     });
  231. }
  232. function buildUrl() {
  233.   let newUrl = window.location.protocol + "//" + window.location.host + filtersString;
  234.   return newUrl;
  235. }
  236. $(document).on('click', '.search-button-list', function (e) {
  237.   $('.click-filter').removeClass('.click-filter');
  238.   $(this).addClass('click-filter');
  239.   createFiltersString();
  240.   let url = `{{ path('front-page', {url: get_page_url(app.request.locale, constant('App\\Config\\Pages::OFFERS_INDUSTRY'))})}}`;
  241.   window.location.href = url+filtersString + '&filters[page][]=1';
  242.   return false;
  243. });
  244. </script>
  245. {% endblock %}