PageSourceSearch

https://blunavytraghetti.com/wp-content/themes/cosmo/assets/js/form.js?ver=1775745451

js blunavytraghetti.com collected 2026-09-24 12:35:41 UTC 7,782 bytes, 234 lines download raw bytes

1jQuery(document).ready(function ($) {
2
3  if($('.form-ajax-posizioni-aperte').length > 0){
4
5    function aggiungiCampoSocial () {
6      let container = document.querySelector("#socialContainer .social-input-group");
7      let input = document.createElement("div");
8
9      input.classList.add("social-input");
10      input.innerHTML = `
11          <input type="url" name="social[]">
12          <button class="btn btn-primary btn-remove-social-profile" type="button">-</button>
13      `;
14
15      container.appendChild(input);
16    }
17
18    function rimuoviCampoSocial (button) {
19      let container = document.getElementById("socialContainer");
20      if (container.children.length > 1) {
21          container.removeChild(button.parentElement);
22      } else {
23          alert("Devi inserire almeno un profilo social!");
24      }
25    }
26
27    $(document).on("click", "#socialContainer .btn-add-social-profile", function () {
28      aggiungiCampoSocial();
29    });
30
31    $(document).on("click", "#socialContainer .btn-remove-social-profile", function () {
32      rimuoviCampoSocial(this);
33    });
34
35
36    $(document).on('submit', '.form-ajax-posizioni-aperte', function(e){
37      e.preventDefault();
38
39      let vecchiaPosizione = $('#current-step').val() * 1;
40      let nuovaPosizione = vecchiaPosizione + 1;
41
42      let currentTab = $('.form-scheda[data-scheda="' + vecchiaPosizione + '"]');
43  
44
45      if(currentTab.attr('data-target')){
46
47        // Eseguo l'ajax di bn_ajax_load_application_step per caricare la versione corretta del form
48        var thisForm = $(this);
49        var thisSubmit = thisForm.find('.real-submit');
50        var thisMessageDetails = thisForm.find('[data-message-details]');
51        thisSubmit.val(WPURLS.string.caricamento);
52
53        var siteurl = WPURLS.siteurl;
54        var ajaxurl = siteurl + '/wp-admin/admin-ajax.php?action=bn_ajax_load_application_step';
55        var formData = new FormData(this);
56
57        formData.append('target', currentTab.attr('data-target'));
58
59        $.ajax({
60          type: 'POST',
61          dataType: 'json',
62          url: ajaxurl,
63          data: formData,
64          contentType: false,
65          processData: false,
66          cache: false,
67          success: function(data){
68
69            let scheda = $('.form-scheda[data-scheda="' + nuovaPosizione + '"]');
70            scheda.replaceWith(data.data.html);
71
72            $([document.documentElement, document.body]).animate({
73              scrollTop: $("#form-candidatura").offset().top
74            }, 300);
75    
76            $('.form-steps li').removeClass('bold')
77            $('.form-steps li[data-step=' + nuovaPosizione + ']').addClass('bold');
78    
79            $('#current-step').val(nuovaPosizione);
80
81            $('.form-scheda').each(function(){
82              if($(this).data("scheda") == nuovaPosizione){
83                $(this).removeClass("d-none")
84                $(this).find('.isDisabled').prop("disabled", false)
85              } else {
86                $(this).addClass("d-none")
87              }
88            });
89
90          }
91        });
92        
93
94      } else {
95        $('.isDisabled').prop("disabled", false);
96
97        if($('.form-ajax-posizioni-aperte').hasClass('disabled')){
98          return
99        }
100
101        var thisForm = $('.form-ajax-posizioni-aperte');
102        $('.form-ajax-posizioni-aperte').addClass('disabled');
103
104        var thisSubmit = thisForm.find('.real-submit');
105        var thisMessageDetails = thisForm.find('[data-message-details]');
106
107        thisSubmit.val(WPURLS.string.invio);
108    
109        var siteurl = WPURLS.siteurl;
110        var ajaxurl = siteurl + '/wp-admin/admin-ajax.php?action=bn_ajax_application';
111        var formData = new FormData(this);
112
113        $.ajax({
114          type: 'POST',
115          dataType: 'json',
116          url: ajaxurl,
117    
118          data: formData,
119          contentType: false,
120          processData: false,
121          cache: false,
122          
123          success: function(data){
124            thisSubmit.val(WPURLS.string.success);
125            thisSubmit.addClass('success');
126
127            // $('.form-scheda-thank').removeClass("d-none")
128            
129            $('.nav-candidatura').addClass("d-none")
130            $( ".form-scheda" ).animate({height:0},500, function(){$('.form-scheda').addClass("d-none")});
131            
132            setTimeout(function(){
133              $( ".form-scheda-thank" ).animate({height:100},500);
134            }, 600);
135
136            if(data.messageDetails){
137              thisMessageDetails.find('p').html(WPURLS.string.success);
138              thisMessageDetails.slideDown();
139            }
140
141            // Ora faccio il redirect
142            if (data.redirect) {
143              setTimeout(function () {
144                window.location.href = data.redirect
145              }, 1000)
146            }
147
148            setTimeout(function(){
149              thisSubmit.val(WPURLS.string.invia_candidatura);
150              thisSubmit.removeClass('success');
151            }, 20000);
152
153
154          },
155          error: function(){
156            thisSubmit.addClass('error');
157            thisSubmit.val(WPURLS.string.errore);
158            setTimeout(function(){
159              thisSubmit.val(WPURLS.string.invia_candidatura);
160              thisSubmit.removeClass('error');
161            }, 20000);
162          }
163        });
164      }
165    })
166
167    $('.form-ajax-posizioni-aperte .form-scheda .indietro').each(function(){
168      $(this).on('click', function(){      
169        if($('#current-step').val() > 1){
170          let vecchiaPosizione = $('#current-step').val() * 1
171          let nuovaPosizione = vecchiaPosizione - 1
172
173          $('.form-steps li').removeClass('bold')
174          $('.form-steps li[data-step=' + nuovaPosizione + ']').addClass('bold')
175
176          $('#current-step').val(nuovaPosizione)
177          $('.form-scheda').each(function(){
178            if($(this).data("scheda") == nuovaPosizione){
179              $(this).removeClass("d-none")
180              $(this).find('.isDisabled:not(.isDisabled-radio-posiztion)').prop("disabled", false)
181            } else {
182              $(this).addClass("d-none")
183              $(this).find('.isDisabled:not(.isDisabled-radio-posiztion)').prop("disabled", true)
184            }
185          })
186        }
187      })
188    })
189
190    $('.posizione-aperta').on('click', function(){
191
192      $('.sub-category-posizioni').addClass('d-none').find('.isDisabled').prop("disabled", true).prop( "checked", false );
193      $('.category-posizioni').find('.isDisabled').prop("disabled", true).prop( "checked", false );
194      $('.all-positions').addClass('d-none')
195
196      let nomePosizione = $(this).data('posizione')
197      $("#posizione").val(nomePosizione);
198      $('.form-scheda-uno input[type="submit"]').click()
199    })
200
201    $('#posizione').on('change', function(){
202      if($(this).val() == "spontanea"){
203        $('.all-positions').removeClass('d-none')
204        $('.form-scheda').each(function(){
205          if($(this).data("scheda") == 1){
206            $(this).find('.isDisabled').prop("disabled", false)
207          }
208        })
209      } else {
210        $('.all-positions').addClass('d-none')
211        $('.form-scheda').each(function(){
212          if($(this).data("scheda") == 1){
213            $(this).find('.isDisabled').prop("disabled", true)
214          }
215        })
216      }
217    })
218
219    $('.radio-position').each(function(){
220      $(this).on('change', function(){
221        let subCategoryClass = $(this).val()
222        $('.sub-category-posizioni').addClass('d-none').find('.isDisabled').prop("disabled", true).prop( "checked", false );
223        $('.sub-category-posizioni.' + subCategoryClass).removeClass('d-none').find('.isDisabled').prop("disabled", false)
224      })
225    })
226    
227    if($('#posizioni').length > 0){
228      setTimeout(function(){
229        $('.accordion-item').removeClass('d-none');
230      }, 10)
231    }
232  }
233
234})

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.