/* JavaScript Document piccoli script caricati in defer quando si usa il jquery $(document).ready() si usa il defer */ /* INIZIO CHECK FORM */ var $jQCheckForm = jQuery.noConflict(); $jQCheckForm(document).ready(function () { InizializzazioneCheckForm(); }); function InizializzazioneCheckForm() { $jQCheckForm("form.checkJq").submit(function() { var modulo=$jQCheckForm(this).attr("id"); if(!checkModulo("#"+modulo)) { console.log("errori"); return false; } }); } function checkModulo(modulo) { var erroriTOT=0; $jQCheckForm(modulo+" .obbligatorio, "+modulo+" input[class*='formato_']").each(function() { var errori=0; if($jQCheckForm(this).is(":disabled")==false) { var valore=$jQCheckForm.trim($jQCheckForm(this).val()); var identificatore=$jQCheckForm(this).attr("id"); var classe=$jQCheckForm.trim($jQCheckForm(this).attr("class")); var arrayClasse=classe.split(" "); $jQCheckForm.each(arrayClasse, function(kClass, vClass) { if(vClass=="obbligatorio") { if(valore=="") { errori++; } } if(vClass=="formato_cap") { if(valore!="") { var dtRegex = new RegExp(/^[0-9]{5}$/); if(!dtRegex.test(valore)) { errori++; } } } if(vClass=="formato_piva") { if(valore!="") { var dtRegex = new RegExp(/^[0-9]{11}$/); if(!dtRegex.test(valore)) { errori++; } } } if(vClass=="formato_cf") { if(valore!="") { var dtRegex = new RegExp(/^[0-9]{11}$/); var dtRegex2 = new RegExp(/^[a-zA-Z]{6}[0-9]{2}[a-zA-Z]{1}[0-9]{2}[a-zA-Z]{1}[0-9]{3}[a-zA-Z]{1}$/); if(!dtRegex.test(valore) && !dtRegex2.test(valore)) { errori++; } } } if(vClass=="formato_int") { if(valore!="") { var dtRegex = new RegExp(/^\d*$/); if(!dtRegex.test(valore)) { errori++; } } } if(vClass=="formato_telefono") { if(valore!="") { var dtRegex = new RegExp(/^[+./0123 456789-]+$/); if(!dtRegex.test(valore)) { errori++; } } } if(vClass=="formato_email") { if(valore!="") { var dtRegex = new RegExp(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,6})?$/); if(!dtRegex.test(valore)) { errori++; } } } if(vClass=="formato_email") { if(valore!="") { var dtRegex = new RegExp(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,6})?$/); if(!dtRegex.test(valore)) { errori++; } } } if(vClass.indexOf("formato_obb_se_not_")>=0) { if(valore=="") { var altroCampo=vClass.replace("formato_obb_se_not_",""); var valoreAltroCampo=$jQCheckForm.trim($jQCheckForm(modulo+" #"+altroCampo).val()); if(valoreAltroCampo=="") { errori++; } } } if(errori>0) { $jQCheckForm(modulo+" #"+identificatore).addClass("field-errore"); if($jQCheckForm(modulo+" label[for='"+identificatore+"']").length>0) { $jQCheckForm(modulo+" label[for='"+identificatore+"']").addClass("label-errore"); } } else { $jQCheckForm(modulo+" #"+identificatore).removeClass("field-errore"); if($jQCheckForm(modulo+" label[for='"+identificatore+"']").length>0) { $jQCheckForm(modulo+" label[for='"+identificatore+"']").removeClass("label-errore"); } } }); } erroriTOT=parseInt(erroriTOT)+parseInt(errori); }); if(erroriTOT==0) { return true; } else { return false; } } /* FINE CHECK FORM */ /* INIZIO SCROLL CON ANCORA */ var $jQScrollOnElement = jQuery.noConflict(); $jQScrollOnElement(document).ready(function () { /*se nell'url c'è un acora mi sposto sull'elemento */ if (location.href.indexOf("#") != -1) { var hash=location.hash.replace("#",""); /*se è un form devo cercare l'elemento form perché l'ancora è nascosta e con gli elementi nascosti non funziona perché non li jquery ovviamente non li vede */ var elemento="a[name='"+hash+"']"; if(hash.indexOf("Formrichiesteinfo") != -1) { elemento="#modulo"+hash; } if($jQScrollOnElement(elemento).length>0) { ScrollOnElement(elemento, 150) } } }); function ScrollOnElement(element, riduci=0) { var top=($jQScrollOnElement(element).offset().top)-riduci; if($jQScrollOnElement(".box-barra-alta").length) { top= top - $jQScrollOnElement(".box-barra-alta").outerHeight(true); } $jQScrollOnElement(".menu-orizzontale-con-blocco").each(function(){ top= top - ($jQOrizzontaleMenu(this).outerHeight(true)*2) }); $jQScrollOnElement("html,body").animate({scrollTop:top}, 2000); } /* FINE SCROLL CON ANCORA */ /* INIZIO SORTBY PER LE PAGINE DI ELENCO */ var $JQsortBy= jQuery.noConflict(); $JQsortBy(document).ready(function (){ let phpSelfDoveSono=$JQMenuTastiAttivi("input[id='phpSelfDoveSono']").val(); let phpSelfDoveSono2=$JQMenuTastiAttivi("input[id='phpSelfDoveSono2']").val(); if(phpSelfDoveSono=="categorie.php" || phpSelfDoveSono2=="categorie.php") { if($JQsortBy("#sortBy").length ) { $JQsortBy("#sortBy").change(function() { $JQsortBy("form[id='paginazione'] #ordinaPer").val($JQsortBy( "#sortBy option:selected" ).val()); $JQsortBy("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */ $JQsortBy("form[id='paginazione']").submit(); }); } } }); /* FINE SORTBY PER LE PAGINE DI ELENCO */ /* INIZIO FILTRI PER LE PAGINE DI ELENCO */ var $JQfiltri= jQuery.noConflict(); $JQfiltri(document).ready(function (){ let phpSelfDoveSono=$JQMenuTastiAttivi("input[id='phpSelfDoveSono']").val(); let phpSelfDoveSono2=$JQMenuTastiAttivi("input[id='phpSelfDoveSono2']").val(); if(phpSelfDoveSono=="categorie.php" || phpSelfDoveSono2=="categorie.php") { $JQfiltri("a[name='area-filtri']").click(function(e, first){ e.preventDefault(); var display=$JQfiltri("+ div.area-filtri", $JQfiltri(this)).css("display"); $JQfiltri("+ div.area-filtri", $JQfiltri(this)).slideToggle(first ? 0 : 400); return false; }); if($JQfiltri("div[id^='filtroElenco']").length ) { $JQfiltri("div[id^='filtroElenco']").click(function() { var arrayFiltri=new Array(); if($JQfiltri("form[id='paginazione'] #filtri").val()!="") { arrayFiltri=$JQfiltri("form[id='paginazione'] #filtri").val().split(","); } var nArray=count(arrayFiltri); var arrayIdentificatoreFiltro=$JQfiltri(this).attr("id").split("filtroElenco"); if($JQfiltri.inArray(arrayIdentificatoreFiltro[1], arrayFiltri)<0) { arrayFiltri[nArray]=arrayIdentificatoreFiltro[1]; } $JQfiltri("form[id='paginazione'] #filtri").val(implode(",",arrayFiltri)); $JQfiltri("form[id='paginazione'] #azione").val("cercaspec"); $JQfiltri("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */ $JQfiltri("form[id='paginazione']").submit(); }); } if($JQfiltri("select[id^='filtroSelect']").length ) { $JQfiltri("select[id^='filtroSelect']").change(function() { var arrayFiltri=new Array(); $JQfiltri("select[id^='filtroSelect']").each(function() { var valore=$JQfiltri(this).val(); if(valore!="") { var nArray=count(arrayFiltri); if($JQfiltri.inArray(valore, arrayFiltri)<0) { arrayFiltri[nArray]=valore; } } }); $JQfiltri("form[id='paginazione'] #filtri").val(implode(",",arrayFiltri)); $JQfiltri("form[id='paginazione'] #azione").val("cercaspec"); $JQfiltri("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */ $JQfiltri("form[id='paginazione']").submit(); }); } if( $JQfiltri("div[id^='filtroElenco']").length || $JQfiltri("select[id^='filtroSelect']").length || $JQfiltri("img[id^='filtroElimina']").length ) { $JQfiltri("#filtroEliminaTutti").click(function() { $JQfiltri("form[id='paginazione'] #filtri").val(""); $JQfiltri("form[id='paginazione'] #azione").val("cercaspec"); $JQfiltri("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */ $JQfiltri("form[id='paginazione']").submit(); }); $JQfiltri("img[id^='filtroElimina'], #filtroEliminaTutti").click(function() { var arrayFiltri=new Array(); if($JQfiltri("form[id='paginazione'] #filtri").val()!="") { arrayFiltri=$JQfiltri("form[id='paginazione'] #filtri").val().split(","); } var nArray=count(arrayFiltri); var arrayIdentificatoreFiltro=$JQfiltri(this).attr("id").split("filtroElimina"); arrayFiltri.splice($JQfiltri.inArray(arrayIdentificatoreFiltro[1], arrayFiltri),1); $JQfiltri("form[id='paginazione'] #filtri").val(implode(",",arrayFiltri)); $JQfiltri("form[id='paginazione'] #azione").val("cercaspec"); $JQfiltri("form[id='paginazione'] #pagina").val(""); /*annullo la pagina altrimenti non funziona più il lazy loading */ $JQfiltri("form[id='paginazione']").submit(); }); } } }); /* FINE FILTRI PER LE PAGINE DI ELENCO */ /* INZIO CAMBIO VALUTA */ var $jQValuta = jQuery.noConflict(); $jQValuta(document).ready(function (){ if($jQValuta("#idvalutaopzionale").length ) { $jQValuta("#idvalutaopzionale").change(function() { CambiaValuta($jQValuta(this).val()); }); } }); function CambiaValuta(value) { $jQValuta.ajax({ url: 'box/box_cambiavaluta.php', type: 'POST', data: 'azione=cambiavaluta&valutascelta=' + value, success: function() { location.reload(); } }); } /* FINE CAMBIO VALUTA */ /* INIZIO TORNA IN CIMA ALLE PAGINE */ var $JQscrolltop = jQuery.noConflict(); function tornaSu() { $JQscrolltop('html,body').animate({scrollTop:0}, 'slow'); } $JQscrolltop(document).ready(function (){ $JQscrolltop("#tornasu").click(function(){ tornaSu(); }); }); $JQscrolltop(window).scroll(function(e){ var mioscroll = $JQscrolltop(window).scrollTop(); if(mioscroll >= 300) { $JQscrolltop("#tornasu").fadeIn(); } else { $JQscrolltop("#tornasu").fadeOut(); } }); /* FINE TORNA IN CIMA ALLE PAGINE */ /* INIZIO RESIZE FORM */ var $jQresizeFormBox = jQuery.noConflict(); $jQresizeFormBox(document).ready(function () { resizeFormBox(); }); function resizeFormBox() { if($jQresizeFormBox(window).width() > 1000) { $jQresizeFormBox(".boxcerca form, .box-generico form[id^='moduloFormrichiesteinfo']").each(function (e){ var w=$jQresizeFormBox(this).outerWidth(); if(w<260) { $jQresizeFormBox(this).find(".formcontattiriga").each(function (e1){ $jQresizeFormBox(this).css({"display": "block"}); }); $jQresizeFormBox(this).find(".formcontattirigacampo").each(function (e2){ $jQresizeFormBox(this).css({"width": "100%", "padding-right": "0"}); }); } }); } } /* FINE RESIZE FORM */ /* INIZIO ADATTAMENTO SWF ALLA LARGHEZZA DEL CONTENITORE */ var $jQEmbed = jQuery.noConflict(); $jQEmbed(document).ready(function (){ $jQEmbed(".embedcontainer").each(function(){ var w=$jQEmbed(this).find("input[name='larghezzaswf']").val(); var h=$jQEmbed(this).find("input[name='altezzaswf']").val(); var wContainer=$jQEmbed(this).width(); var from_w=w; var from_h=h; var to_w = wContainer; if(from_w0 || $jQGenerico("#box-barra-alta-mobile").length>0 || $jQGenerico("#banner-avviso-modello").length>0) { var height=0; if($jQGenerico(".box-barra-alta").length>0) { height=$jQGenerico(".box-barra-alta").height(); } if($jQGenerico("#box-barra-alta-mobile").length>0) { height=$jQGenerico("#box-barra-alta-mobile").height(); } if($jQGenerico("#banner-avviso-modello").length>0) { var height2=$jQGenerico("#banner-avviso-modello").outerHeight(true); height=parseFloat(height)+parseFloat(height2); $jQGenerico(".box-barra-alta").css({"top":height2+"px"}); if($jQGenerico("#box-barra-alta-mobile").length) { $jQGenerico("#box-barra-alta-mobile").css({"top":height2+"px"}); $jQGenerico("#menu-burger-nav-mobile").css({"top":height2+"px"}); } } $jQGenerico("#sfondo-sito-home, #sfondo-sito").css({"padding-top":height+"px", "-webkit-transition":"padding-top .5s linear", "-moz-transition":"padding-top .5s linear", "-ms-transition":"padding-top .5s linear", "-o-transition":"padding-top .5s linear", "transition":"padding-top .5s linear"}); } // fine spostamento contenuto sito e altro secondo altezza barra alta // inizio lingua browser per successivo popup siti collegati const getLanguage = () => navigator.userLanguage || (navigator.languages && navigator.languages.length && navigator.languages[0]) || navigator.language || navigator.browserLanguage || navigator.systemLanguage || "it"; var linguaBrowser=getLanguage(); linguaBrowser1=linguaBrowser.toLowerCase(); linguaBrowser2=linguaBrowser1.split("-"); linguaBrowser2=linguaBrowser2[0]; array_lingue = new Array(); $jQGenerico("#linguabrowser").html("lingua browser: "+linguaBrowser+" | lingua browser 1: "+linguaBrowser1+" | lingua browser 2: "+linguaBrowser2); $jQGenerico("#linguasitoweb").html("it"); if($jQGenerico(".windows_SitiWebLingua").length>0) { if(linguaBrowser1!="it") { if( linguaBrowser2!="it" || ( linguaBrowser2=="it" && in_array (linguaBrowser1, array_lingue) ) ) { // mostro popup siti in lingua $jQGenerico(".windows_SitiWebLingua_sfondo").show(); $jQGenerico(".windows_SitiWebLingua").css({"display":"flex"}); } } $jQGenerico(".windows_SitiWebLingua .winsitiweblingua-boxscelta").click(function (e) { var url=$jQGenerico(this).attr("data-url"); window.location = url; }); $jQGenerico(".windows_SitiWebLingua .winsitiweblingua-boxattuale").click(function (e) { $jQGenerico(".windows_SitiWebLingua .windows_small_chiudi").trigger("click"); }); $jQGenerico(".windows_SitiWebLingua .windows_small_chiudi").click(function (e) { $jQGenerico.post("https://www.basketcostaweb.com/piede.php", {"azione": "setwinlinguasitoweb"}); }); } // fine lingua browser per successivo popup siti collegati $jQGenerico(".windows_small_chiudi").click(function (e) { $jQGenerico(".windowsSfondo").fadeOut(1000); $jQGenerico(".windows").fadeOut(1000); }); $jQGenerico(".calDateEvento div[data-navlink]").click(function() { var url=$jQGenerico(this).attr("data-urllink"); var opzioni=$jQGenerico(this).attr("data-navlink"); var obj = jQuery.parseJSON(opzioni); var querystring = $jQGenerico.param(obj); var redirect=window.location.protocol+"//"+window.location.hostname+"/"+url+"?"+querystring; $jQGenerico(location).attr("href",redirect); }); }); function doneResizing() { if(typeof PiedeFisso == "function") { PiedeFisso(); } if(typeof resizeFormBox == "function") { resizeFormBox(); } if(typeof resizeScreen == "function") { resizeScreen(); } } function resizeScreen() { var risoluzionedimensione_prima=$jQGenerico("#risoluzioneschermo #risoluzionedimensione").html().split(" × "); var detectmobile_prima=$jQGenerico("#risoluzioneschermo #detectmobile").html(); $jQGenerico.post("https://www.basketcostaweb.com/intestazione_css.php", { azione: "resizescreen", windowwidth: $jQGenerico(window).width(), windowheight: $jQGenerico(window).height() }, function(response) { $jQGenerico("#risoluzioneschermo #risoluzionedimensione").html($jQGenerico(window).width()+" × "+$jQGenerico(window).height()); $jQGenerico("#risoluzioneschermo #detectmobile").html(response); var risoluzionedimensione_dopo=$jQGenerico("#risoluzioneschermo #risoluzionedimensione").html().split(" × "); var detectmobile_dopo=$jQGenerico("#risoluzioneschermo #detectmobile").html(); if(detectmobile_prima!="" && detectmobile_prima!=detectmobile_dopo) { location.reload(); } }); } function ShowWindow(win) { $jQGenerico(win+"_sfondo").fadeIn(1000); $jQGenerico(win).fadeIn(1000); } function HideWindow(win) { $jQGenerico(win+"_sfondo").fadeOut(1000); $jQGenerico(win).fadeOut(1000); } function shareFacebook(url,titolo) { window.open("http://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(url),"sharer","toolbar=0,status=0,width=626,height=436"); } function shareTwitter(url,titolo) { window.open("https://twitter.com/intent/tweet?url="+encodeURIComponent(url),"sharer","toolbar=0,status=0,width=626,height=436"); } function shareWhatsapp(url,titolo) { window.open("https://api.whatsapp.com/send?phone=&text="+encodeURIComponent(url)+"%0A%0A"+titolo,"sharer","toolbar=0,status=0,width=650,height=660"); } function shareMessenger(url) { window.open("https://www.facebook.com/dialog/send?app_id=767547120467610&link="+encodeURIComponent(url)+"&redirect_uri="+encodeURIComponent(url)+"&display=popup","sharer","toolbar=0,status=0,width=626,height=436"); } function shareTelegram(url,titolo) { window.open("https://t.me/share?url="+encodeURIComponent(url)+"&text="+titolo,"sharer","toolbar=0,status=0,width=626,height=436"); } function copyUrl(url,questo) { var sampleTextarea = document.createElement("textarea"); document.body.appendChild(sampleTextarea); sampleTextarea.value = url; //save main text in it sampleTextarea.select(); //select textarea contenrs document.execCommand("copy"); document.body.removeChild(sampleTextarea); questo.after("
Link copiato negli appunti
"); setTimeout(function(){ $jQGenerico(".confermacopyurl").remove(); },3000); } /* FINE JQUERY GENERICO */