PageSourceSearch

https://www.europa-uomo.org/wp-content/themes/europa-uomo/js/main.js?v=1791054464&ver=1

js europa-uomo.org collected 2026-10-03 19:08:42 UTC 6,632 bytes, 297 lines download raw bytes

1var ajaxState;
2var playVideoEventCalled = false;
3
4(function($){
5
6 
7  $(document).ready( function() {
8
9
10
11
12setInterval( function() {
13
14  var img = $('.carousel-images-wrap .image-wrap:last-child');
15
16  img.fadeOut(1000, function() {
17
18    img.prependTo(img.parent());
19    img.show();
20
21  });
22
23}, 3000);
24
25
26
27
28
29    $('#nav-wrap .menu-toggle').click( function() {
30
31      $('body').toggleClass('with-nav');
32
33    });
34
35
36    $('#chatbot-trigger').click( function() {
37      $('#chatbot').fadeIn();
38    });
39
40
41    $('#chatbot .close').click( function() {
42      $('#chatbot').fadeOut();
43    });
44
45
46    $('.user-form').submit( function() {
47
48        var btn = $(this).find('button[type=submit]'); 
49
50        btn.prop('disabled', true).addClass('processing');
51
52
53        var fm = $(this);
54	var success = validateForm( $(this) );
55
56        if ( !success ) {
57          scrollTo($(this), 0);
58          btn.prop('disabled', false).removeClass('processing');
59          return false;
60        }
61
62	if ( typeof ga !== 'undefined' )
63          ga('send', 'event', 'form', 'submit', fm.attr('id'));
64
65	if ( !fm.hasClass('is-ajax') )
66          return true;          
67
68        scrollTo(fm, 0);
69
70        var formData = new FormData(this);
71        formData.append('isAjax', 'true');
72
73        $.ajax({
74          type: 'POST',
75          url: '/',
76          data: formData,
77          cache: false,
78          contentType: false,
79          processData: false,
80          success: function( data ) { 
81
82	    if ( !fm.hasClass('do-not-reset') )
83	      fm.get(0).reset();
84
85            btn.prop('disabled', false).removeClass('processing');
86           
87            fm.find('.form-message-wrap').hide();
88
89            if ( data == 'true' ) {
90              fm.find('.form-message-wrap.form-message-success').slideDown();
91              fm.find('.field-wrap').addClass('disabled');
92	    }
93            else {
94              fm.find('.form-message-wrap.form-message-error').slideDown();
95            }
96          },
97        });
98
99       
100
101       return false;
102    });
103
104
105
106  });
107
108
109
110
111  $.fn.isInViewport = function() {
112    var elementTop = $(this).offset().top;
113    var elementBottom = elementTop + $(this).outerHeight();
114    var viewportTop = $(window).scrollTop();
115    var viewportBottom = viewportTop + $(window).height();
116    return elementBottom > viewportTop && elementTop < viewportBottom;
117  };
118
119
120  window.screenToSVG = function(svg, screenX, screenY) {
121   var p = svg.createSVGPoint()
122    p.x = screenX
123    p.y = screenY
124    return p.matrixTransform(svg.getScreenCTM().inverse());
125  }
126
127  window.SVGToScreen = function(svg, svgX, svgY) {
128   var p = svg.createSVGPoint()
129    p.x = svgX
130    p.y = svgY
131    return p.matrixTransform(svg.getScreenCTM());
132  }
133
134
135  window.showPopup = function(postcode) {
136    $('html,body').addClass('no-scroll');
137    $(key).show(); 
138  }
139
140  window.hidePopup = function( el ) {
141    $(el).parent().hide(); 
142    $('html,body').removeClass('no-scroll');
143  }
144
145  window.validateEmail = function(email) {
146    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,}))$/;
147    return re.test(email);
148  }
149
150
151  window.validateMobile = function(mobile) {
152    var re = /^(\+44[\s-]?7\d{3}|\(?07\d{3}\)?)[\s-]?\d{3}[\s-]?\d{3}$/i;
153    mobile = mobile.replace(/\s+/ig, '');
154    rtn = re.test(mobile);
155    return rtn;
156  }
157
158
159  window.validatePostcode = function(postcode) {
160    var re = /^[A-Z]{1,2}[0-9A-Z]{1,2} ?[0-9][A-Z]{2}$/i;
161    rtn = re.test(postcode);
162    if ( rtn ) {
163    $.ajax({
164      type: 'POST',
165      url: $('body').data('ajax-url') + '?action=is_valid_postcode&postcode=' + postcode,
166      processData: false,
167      contentType: false,
168	  async: false,
169      success: function( data ) {
170      if ( typeof data.status === 'undefined' || data.status == 'true' )
171        rtn = true;
172      else
173        rtn = false;
174      }
175
176    });
177    }
178    return rtn;
179  }
180
181  window.getRandomNumber = function(min, max) {
182    return (Math.random() * (max - min + 1)) + min;
183  }
184  
185  window.scrollTo = function( el, offset ) {
186
187    if ( el.size() == 0 )
188    return;
189
190    if ( $('body').width() < 600 )
191    offset += 75;
192
193
194
195    $(window).trigger('scroll');
196
197      $('html, body').animate({
198        scrollTop: el.offset().top - offset
199      }, 1000, function() {
200
201    });
202
203  }
204
205
206  window.validateForm = function( fm ) {
207
208    var proceed = true;
209
210    fm.find('.form-message-wrap').hide();
211
212
213    fm.find('.with-error').removeClass('with-error');
214    fm.find('.form-message-wrap').slideUp();
215    
216
217    fm.find('input,select,textarea').each( function() {
218      var result = validateField(this);
219      if ( !result )
220        $(this).parents('.field-wrap').addClass('with-error');
221    });
222
223
224    proceed = fm.find('.field-wrap.with-error:visible').size() == 0;
225
226    if ( !proceed ) {
227      fm.find('.form-message-wrap.form-message-error').slideDown();
228    }
229
230    return proceed;
231  
232  }
233
234
235
236  window.validateField = function( field ) {
237
238
239      if( typeof $(field).attr('type') !== 'undefined' && ($(field).attr('type').toLowerCase() == 'radio' || $(field).attr('type').toLowerCase() == 'checkbox') ) {
240        var val = $( $(field).parents('form') ).find('input[name="' + $(field).attr('name') + '"]:checked').map(function(_, el) { return $(el).val(); }).get().join(',');
241      }
242      else {
243        var val = $.trim($(field).val());
244      }
245
246
247      if ( $(field).hasClass('validate-not-empty') && val == '' ) { 
248        return false;
249      }
250
251      if ( $(field).hasClass('validate-email') && val != '' && !validateEmail(val) ) { 
252        return false;
253      }
254
255      if ( $(field).hasClass('validate-mobile') && val != '' && !validateMobile(val) ) { 
256        return false;
257      }
258
259      if ( $(field).hasClass('validate-postcode') && val != '' && !validatePostcode(val) ) { 
260        return false;
261      }
262
263    if ( $(field).hasClass('validate-url') && val != '' ) {     
264
265      if ( val.substr(0, 3) === 'www' )
266      {
267        val = 'http://' + val;
268      }
269
270      if ( !validateUrl(val) )
271        return false;
272
273    }
274
275    return true;
276
277  }
278
279
280
281
282})(jQuery);
283
284
285
286function googleTranslateElementInit() {
287  new google.translate.TranslateElement({
288  	pageLanguage: 'en',
289  	layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
290  	autoDisplay: false
291  },'google_translate_element');
292}
293
294
295
296
297

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.