1var is_chrome = navigator.userAgent.indexOf('Chrome') > -1; 2var is_explorer = navigator.userAgent.indexOf('MSIE') > -1 || navigator.userAgent.indexOf('Trident') > -1; 3var is_firefox = navigator.userAgent.indexOf('Firefox') > -1; 4var is_safari = navigator.userAgent.indexOf("Safari") > -1; 5var is_opera = navigator.userAgent.toLowerCase().indexOf("op") > -1; 6if ((is_chrome) && (is_safari)) { is_safari = false; } 7if ((is_chrome) && (is_opera)) { is_chrome = false; } 8 9jQuery(document).ready(function () { 10 $('.nodesktop').remove(); 11 12 13 if (is_safari) $('body').addClass('safari'); 14 15 initNav(); 16 IEPlaceholderFix(); 17 initBootstrapLightbox(); 18 initFooter(); 19 initOpenerOrganigramma(); 20 ApriChiudi(); 21 initPageSearch(); 22 initIrfaq(); 23 initListTransformation(); 24 initVivereInTicino(); 25 // initHeadingLinks(); 26 initSaiperche(); 27 initClearField(); 28 initCarouselLinks(); 29 // initTichSlider(); 30 if($('body:not(.agenda-culturale)').length == 1) initTichSlider(); 31 32 if($('#contact-form').length) initModuloContattatoPage(); 33 else initModuloContattato(); 34 35 if ($('.scuola-parallax').length) initParallaxPage(); 36 else if (document.getElementById('mappa-traffico')) initMap(); 37 else if (document.getElementById('mappa-radar')) initMap2(); 38 else if (document.getElementById('dt-mappa-ticino')) initDTMappaTicino(); 39 else if (document.getElementById('aste')) initAste(); 40 else if ($('.map').length && $('map').length) initMap3(); 41 else if ($('body.gc-home').length) initGCHome(); 42 else if (document.getElementById('ticino2020')) initTicino2020(); 43 else if (document.getElementById('pca')) initPCA(); 44 else if ($('.user-cpa-pi1').length) initCPA(); 45 else if ($('.cpa_page').length) initCPANew(); 46 else if (document.getElementById('ricercaSalaStampa')) initSelectSalaStampa(); 47 else if (document.getElementById('ODG')) initODG(); 48 else if (document.getElementById('dfe-inner-form')) initDFEInnerForm(); 49 else if ($('.home-menu').length) { 50 initHomeMenu(); 51 initTematicaBox(); 52 initGC(); 53 //initSondaggio(); 54 } 55 else if ($('body.pagina-depressione').length) initDepressione(); 56 else if ($('.sviluppo-economico').length) initSviluppoEconomico(); 57 else if ($('#uefmap').length) initUEFMap(); 58 else if ($('#dispop').length) initSPOPMap(); 59 else if (document.getElementById('di_svg_schema')) initDISVGSchema();// Schema della procedura - DI 60 else if ($('#pinacoteca').length) initPinacoteca(); 61 else if ($('#RtiD').length) initLegislazione(); 62 else if ($('#altrePubb').length) initLegislazione(); 63 else if ($('#deputatiHome').length) initDTCF(); 64 else if ($('#listaArticoli').length) initDTCF(); 65 else if(document.getElementById('antibiotici_quiz2')) initAntibioticiQuiz2(); 66 else if ($('#tich_pubblicazioni').length) initTichPubblicazioni(); 67 else if ($('.boxWebcams').length) initWebcamPage(); 68 else if(document.getElementById('formulario_use')) initFormularioUSE(); 69 else if(document.getElementById('formulario_use2')) initFormularioUSE2(); 70 else if(document.getElementById('formulario_use_uac')) initFormularioUSEUAC(); 71 else if(document.getElementById('formulario_rimborso_polizia')) initFormularioRimborsoPolizia(); 72 else if(document.getElementById('formulario_uosp_workshop')) initFormularioUOSPWorkshop(); 73 else if(document.getElementById('contatore_uosp_workshop')) initContatoreUOSPWorkshop(); 74 else if(document.getElementById('formulario_ias')) initFormularioIAS(); 75 else if(document.getElementById('formulario_ias2')) initFormularioIAS2(); 76 else if(document.getElementById('formulario_ias_adeguamento_1')) initFormularioIASAdeguamento1(); 77 else if(document.getElementById('formulario_ias_adeguamento_2')) initFormularioIASAdeguamento2(); 78 else if(document.getElementById('formulario_ias_adeguamento_3')) initFormularioIASAdeguamento3(); 79 else if(document.getElementById('formulario_ias_up_comunicazioni')) initFormularioIasUpComunicazioni(); 80 else if(document.getElementById('formulario_ias_up_procura')) initFormularioIasU
80pProcura(); 81 else if($('.ias-parallax').length) initIAS(); 82 else if($('.rassegna-stampa').length) initRassegnaStampa(); 83 else if ($('.impiantiSportivi-parallax').length) initImpiantiSportivi(); 84 else if($('.tx-tich-areamedia').length || $('.tx-tich-attualita').length) initAreaMedia(); 85 else if(document.getElementById('formulario_tlet')) initFormularioTLET(); 86 else if(document.getElementById('formulario_sel')) initFormularioSEL(); 87 else if(document.getElementById('formulario_di_simposio')) initFormularioSEL2(); 88 else if(document.getElementById('formulario_di_simposio_dfe')) initFormularioSELDFE(); 89 else if($('.schedario_utpg').length) initSchedarioUTPG(); 90 else if($('.agenda-culturale').length) initAgendaCulturale(); 91 else if($('.laboratorio-cantonale').length) initLaboratorioCantonale(); 92 else if($('.portaleComuni').length) initComuni(); 93 else if($('.tx-tich-dssfrancointasca').length) initFrancoInTasca(); 94 else if(document.getElementById('dt_caccia_search')) initDTCaccia() 95 else if($('.calcolatore-salario-minimo').length) initCalcolatoreSalarioMinimo() 96 else if($('.entrata-sviluppo-economico-home').length) initSviluppoEconomicoHome(); 97 else if($('.monitoraggio-ceneri #mappa_dati').length ) initMappaDatiMonitoraggioCeneri(); 98 else if($('.monitoraggio-ceneri #mappa_collegamenti').length ) initMappaCollegamentiMonitoraggioCeneri(); 99 100 if(document.getElementById('chart_dt_caccia')) initCacciaChart(); 101 if(document.getElementById('canicola_map')) initCanicolaMap(); 102 103 if($('.menu-spatola').length) initMenuSpatola(); 104 if($('.layoutPaginaTemi').length) initLayoutPaginaTemi(); 105 106 if($('.video_lightbox').length) initVideoLightboxes(); 107 108 if(document.getElementById('assegni_parentali')) 109 { 110 initIASAssegniParentali(); 111 } 112 113 //if(location.href == 'https://www4.ti.ch/dss/dsp/covid19/home/') initSondaggio(); 114 115 if (typeof tiporicerca !== 'undefined' && tiporicerca != '') { 116 initRicerca(); 117 } 118 119 // Fix menu sinistra 120 $('.noitem span:contains(\'Menu\')').each(function () { 121 $(this).parent().addClass('no-text'); 122 }); 123 $('.noitem:contains(\'Menu\')').each(function () { 124 $(this).text('').css('padding', '0').css('border-bottom', '0'); 125 }); 126 127 // Fix user contatti address 128 $('#contenitore .col-xs-4 .user-contatti-pi1 address > p').filter(function () { return $.trim(this.innerHTML) == "" }).remove(); 129 $('#contenitore .col-xs-6 .user-contatti-pi1 address > p').filter(function () { return $.trim(this.innerHTML) == "" }).remove(); 130 131 // Fix 132 jQuery(document.body).on('click', '.dropdown-menu li', function (event) { 133 var jQuerytarget = jQuery(event.currentTarget); 134 135 jQuerytarget.closest('.btn-group') 136 .find('[data-bind="label"]').text(jQuerytarget.text()) 137 .end() 138 .children('.dropdown-toggle').dropdown('toggle'); 139 return false; 140 }); 141 142 // Timeline 143 if($('.timeline-container2').length) initSpecialTimeline(); 144 else if($('.timeline-uapcd-container').length) initSpecialTimelineUAPCD(); 145 146 // Popover 147 if ($('[data-toggle="popover"]').length) $('[data-toggle="popover"]').popover(); 148 149 // Torna in cima 150 initBackToTop(); 151 152 // Se la pagina ha il cambio lingua, lo script mette in bold la lingua attuale 153 154 // Read more 155 if ($('.readmore').length) { 156 $('.readmore').readmore({ 157 speed: 75, 158 moreLink: '<a href="#">...<i class="fa fa-angle-down"></i></a>', 159 lessLink: '<a href="#"><i class="fa fa-angle-up"></i></a>' 160 }); 161 } 162 163 // Datepicker 164 if ($('.datepicker').length) initDatepicker(); 165 166 // Selectpicker 167 if ($('select:not(.default)').length){ 168 169 if($('.tx-powermail').length) $('.tx-powermail select').addClass('default') 170 171 jQuery('select:not(.default)').selectpicker({ 172 'selectedText': 'cat', 173 noneSelectedText: 'Selezionare', 174 noneResultsText: 'Nessun risultato', 175 countSelectedText: '{0} di {1} selezionato' 176 }); 177 178 // GC parlamento 179 if($('.user-gcparlamento-pi9').length){ 180 $('button.selectpicker').attr('aria-describedby', 'testo-nascosto').after('<span id="testo-nascosto" class="hidden">Selezionare anno. Attenzione, la ricerca inizia quando un valore è selezionato</span>'); 181 182 $('button.selectpicker').attr('aria-expanded', false) 183 $('html').click(function (e){ 184 setTimeout(function (){ 185 $('button.selectpicker').attr('aria-expanded', $('button.selectpicker').parent().hasClass('open')); 186 }, 50); 187 }).keyup(function (e){ 188 setTimeout(function (){ 189 $('button.selectpicker').attr('aria-expanded', $('button.selectpicker').parent().hasClass('open')); 190 }, 50); 191 }); 192 } 193 } 194 195 setTimeout(function (){ 196 $('.bootstrap-select').show(); 197 },1); 198 199 //Lightbox for Bootstrap 200 $(document).on('click', '[data-toggle="lightbox"]', function (event) { 201 event.preventDefault(); 202 $(this).ekkoLightbox({ 203 alwaysShowClose: true 204 }); 205 }); 206 207 208 $('#skiplink1, #skiplink2').focus(function (){ 209 $('body').css('padding-top', '38px'); 210 }).blur(function (){ 211 $('body').css('padding-top', '0'); 212 }); 213 214 215 // Bootstrap collapse fix 216 $('.panel-group').on('hidden.bs.collapse', function (e) { 217 $(this).find('[data-toggle=collapse]').attr('aria-expanded', 'false'); 218 }).on('shown.bs.collapse', function (e) { 219 $(this).find('[data-toggle=collapse]').attr('aria-expanded', 'true'); 220 }); 221 222 // modifica richiesta da SM, per accessibilità - 16.10.2025 223 $('.panel-group').on('hidden.bs.collapse', function (e) { 224 $(this).find('[data-toggle=collapse]').attr('aria-expanded', 'false'); 225 }) 226 .on('shown.bs.collapse', function (e) { 227 var panelId = $(e.target).attr('id'); 228 229 $('[data-toggle="collapse"]').attr('aria-expanded', 'false'); 230 $('#'+panelId).parent().find('.panel-heading a').attr('aria-expanded', 'true'); 231 }); 232 233 234 if($('.foldable-list').length){ 235 $('.fold').click(function (e){ 236 e.preventDefault(); 237 if($(this).next().hasClass('hidden')) $(this).children('i').removeClass('fa-plus-circle').addClass('fa-minus-circle'); 238 else $(this).children('i').removeClass('fa-minus-circle').addClass('fa-plus-circle'); 239 $(this).next().toggleClass('hidden'); 240 }); 241 } 242 243 if(typeof gmaps != 'undefined' && gmaps.length) showGMaps() 244 245 // Coronavirus 246 if($('.corona-more-info-opener').length){ 247 $('.corona-more-info-opener').append('<i class="fa fa-chevron-down"></i>') 248 $('.corona-more-info-opener').click(function (){ 249 var o = $('.corona-more-info') 250 if(o.hasClass('show')){ 251 o.removeClass('show') 252 $('.corona-more-info-opener i').attr('class', 'fa fa-chevron-down') 253 } 254 else{ 255 o.addClass('show') 256 $('.corona-more-info-opener i').attr('class', 'fa fa-chevron-up') 257 } 258 }) 259 } 260 261 if($('.steppers').length) initSteppers() 262 263 var h = location.hash.substring(1) 264 if(h == 'come-calcolo-la-cifra-d-affari'){ 265 $('.tab-content.faq-cat-content:first > div > div > div:eq(2) > .panel-heading a').trigger('click') 266 $('.tab-content.faq-cat-content:first > div > div > div:eq(2) .panel:eq(1) .panel-heading a').trigger('click') 267 $('body, html').animate({ scrollTop: $('.tab-content.faq-cat-content:first').offset().top-20}, 200) 268 } 269 else if(h == 'quale-documentazione-devo-prepare'){ 270 $('.tab-content.faq-cat-content:first > div > div > div:eq(3) > .panel-heading a').trigger('click') 271 // $('.tab-content.faq-cat-content:first > div > div > div:eq(2) .panel:eq(1) .panel-heading a').trigger('click') 272 $('body, html').animate({ scrollTop: $('.tab-content.faq-cat-content:first').offset().top-20}, 200) 273 } 274 275 if($('#corona_registration').length){ 276 $('#corona_registration input').click(function (){ 277 if($('#corona_registration input:checked').length == 1) $('#corona_registration .btn').removeClass('disabled') 278 else $('#corona_registration .btn').addClass('disabled') 279 }) 280 } 281 282 var h = location.hash 283 if(h && h.indexOf('apri-') > - 1){ 284 var n = parseInt(h.replace('#apri-', '')) - 1 285 if(n >= 0 && $('.faq-cat-content .panel-group .collapsed:eq('+n+')').length){ 286 $('.faq-cat-content .panel-group .collapsed:eq('+n+')').trigger('click') 287 } 288 } 289 290 if($('.numeri-incrementali').length){ 291 $('.numeri-incrementali div').each(function (){ 292 293 var n = $(this).attr('data-number') 294 if(n.indexOf('.') > -1) n = parseFloat(n) 295 else n = parseInt(n) 296 297 animateValue($(this), parseInt($(this).text()), n, parseInt($(this).attr('data-speed')), ($(this).is('[data-format]') ? true : false), ($(this).is('[data-symbol]') ? $(this).attr('data-symbol') : false)); 298 }) 299 } 300 301 302 var cookie_path = document.getElementById('ustat') ? '/DFE/DR/USTAT/' : '/typo3conf/ext/theme/Resources/Public/scripts/' 303 $.get(cookie_path+'cookies.php?check', function (r) { 304 if(r == 'no'){ 305 $('body').prepend('<div class="cookies-bar"><div class="cookies-content"><div class="text">Navigando su questo sito accetti l\'utilizzo statistico dei cookies al fine del suo miglioramento. <a href="https://www4.ti.ch/index.php?id=121569">Più informazioni</a></div><button class="btn btn-default">Accetta</button></div></div>') 306 $('.cookies-bar button').click(function (){ 307 $.get(cookie_path+'cookies.php?set') 308 $('.cookies-bar').remove() 309 }) 310 } 311 }) 312 313 if($('.breadcrumb .titolo_pagina').length){ 314 tmp = document.title.split(' - ') 315 $('.breadcrumb .titolo_pagina').text(tmp[0]) 316 } 317 318 319 // console.log(onVisibleElements) 320 if(onVisibleElements){ 321 $(window).scroll(visibleElementsCheck) 322 visibleElementsCheck() 323 } 324 function visibleElementsCheck(e){ 325 var vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0
325) 326 // var v = $(window).scrollTop() + vh 327 for(x in onVisibleElements){ 328 // if(onVisibleElements[x] >= $(window).scrollTop() && onVisibleElements[x] >= $(window).scrollTop()) 329 if(!onVisibleElements[x].visible && onVisibleElements[x].top <= ($(window).scrollTop() + vh - 200) && onVisibleElements[x].bottom >= $(window).scrollTop() + 50){ 330 onVisibleElements[x].visible = true 331 onVisibleElements[x].callback() 332 } 333 } 334 } 335 336 337 // Powermail captcha focus 338 $('.powermail_securimage_outer a.captcha_play_button, .powermail_securimage_outer > a').click(function (){ 339 $('#captcha_code').focus() 340 }) 341 342 // Avvisi 343 initAvvisi() 344 345 if($('.spreco-box').length) initPenuriaEnergetica() 346 else if($('.dt_penuriaenergetica .favorites').length) initPenuriaEnergeticaPreferiti() 347}) 348 349function initCalcolatoreSalarioMinimo(){ 350 var noga = { 351 2: 19.50, 352 3: 19.50, 353 5: 19.50, 354 6: 19.50, 355 7: 19.50, 356 8: 19.50, 357 9: 19.50, 358 10: 19.00, 359 11: 19.04, 360 12: 19.50, 361 13: 19.00, 362 14: 19.00, 363 15: 19.00, 364 16: 19.18, 365 17: 19.00, 366 18: 19.49, 367 19: 19.50, 368 20: 19.50, 369 21: 19.50, 370 22: 19.00, 371 23: 19.50, 372 24: 19.43, 373 25: 19.32, 374 26: 19.50, 375 27: 19.50, 376 28: 19.50, 377 29: 19.29, 378 30: 19.50, 379 31: 19.05, 380 32: 19.50, 381 33: 19.50, 382 35: 19.50, 383 36: 19.50, 384 37: 19.50, 385 38: 19.03, 386 39: 19.03, 387 41: 19.50, 388 42: 19.50, 389 43: 19.39, 390 45: 19.00, 391 46: 19.50, 392 47: 19.00, 393 49: 19.50, 394 50: 19.50, 395 51: 19.50, 396 52: 19.38, 397 53: 19.00, 398 55: 19.00, 399 56: 19.00, 400 58: 19.50, 401 59: 19.00, 402 60: 19.50, 403 61: 19.50, 404 62: 19.50, 405 63: 19.50, 406 64: 19.50, 407 65: 19.50, 408 66: 19.50, 409 68: 19.50, 410 69: 19.50, 411 70: 19.50, 412 71: 19.50, 413 72: 19.50, 414 73: 19.50, 415 74: 19.50, 416 75: 19.12, 417 77: 19.50, 418 78: 19.00, 419 79: 19.00, 420 80: 19.00, 421 81: 19.00, 422 82: 19.01, 423 84: 19.50, 424 85: 19.50, 425 86: 19.50, 426 87: 19.00, 427 88: 19.50, 428 90: 19.50, 429 91: 19.50, 430 92: 19.00, 431 93: 19.50, 432 94: 19.50, 433 95: 19.00, 434 96: 19.00, 435 97: 19.00, 436 98: 19.00, 437 99: 19.00 438 } 439 var settimane_mensili = 4.33333333333333333333333333 440 function init() { 441 442 noga = {} 443 $('#noga option[data-value]').each(function (){ 444 noga[$(this).val()] = parseFloat($(this).attr('data-value')) 445 }) 446 447 $('.calcolatore-salario-minimo input[type=radio], .calcolatore-salario-minimo select').change(calc) 448 $('.calcolatore-salario-minimo input[type=number]').keyup(calc) 449 } 450 function calc(){ 451 var data = { 452 noga: $('.calcolatore-salario-minimo select[name=noga]').val(), 453 hours: $('.calcolatore-salario-minimo input[name=hours]').val(), 454 thirteen: $('.calcolatore-salario-minimo input[name=thirteen]:checked').val() 455 } 456 if(data.noga && data.hours > 0 && data.thirteen){ 457 var salario_annuale = 0 458 var salario_mensile = data.noga * data.hours * settimane_mensili 459 460 if(data.thirteen == 'si'){ 461 salario_mensile = salario_mensile / 13 * 12; 462 salario_annuale = salario_mensile * 13 463 } 464 else salario_annuale = salario_mensile * 12 465 466 // salario_mensile = salario_mensile.toFixed(2) 467 salario_mensile = truncate(salario_mensile) 468 if(salario_mensile.length > 6){ 469 var tmp = salario_mensile.split('.') 470 salario_mensile = tmp[0].substring(0, (tmp[0].length - 3))+"'"+tmp[0].substring((tmp[0].length - 3))+'.'+tmp[1] 471 } 472 473 474 // console.log(truncate(salario_annuale)) 475 // salario_annuale = salario_annuale.toFixed(2) 476 salario_annuale = truncate(salario_annuale) 477 // console.log(salario_annuale) 478 479 480 if(salario_annuale.length > 6){ 481 var tmp = salario_annuale.split('.') 482 salario_annuale = tmp[0].substring(0, (tmp[0].length - 3))+"'"+tmp[0].substring((tmp[0].length - 3))+'.'+tmp[1] 483 } 484 485 //$('.calcolatore-salario-minimo .hourly').text(noga[data.noga].toFixed(2)) 486 487 488 489 $('.calcolatore-salario-minimo .monthly').text(salario_mensile) 490 $('.calcolatore-salario-minimo .yearly').text(salario_annuale) 491 } 492 } 493 function truncate(num){ 494 n = num.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0] 495 return parseFloat(n) 496 } 497 init() 498} 499 500 501function animateValue(obj, start, end, duration, format, symbol) { 502 startTimestamp = null; 503 var t = setTimeout(step, 50); 504 var float = (end+'').indexOf('.') > -1 ? true : false 505 506 symbol = (symbol) ? ' '+symbol : '' 507 508 function step(){ 509 if (!startTimestamp) startTimestamp = Date.now(); 510 progress = Math.min((Date.now() - startTimestamp) / duration, 1); 511 512 if(float){
513 obj.text((end / 100 * (progress * 100)).toFixed(1)+symbol); 514 } 515 else if(format){ 516 var v = Math.round(end / 100 * (progress * 100))+'' 517 if(v > 999) v = v.substring(0, v.length - 3)+"'"+v.substring(v.length - 3) 518 obj.text(v+symbol); 519 } 520 else obj.text(Math.round(end / 100 * (progress * 100))+symbol); 521 522 if (progress < 1) { 523 setTimeout(step, 50); 524 } 525 } 526} 527 528// function animateValue(obj, start, end, duration, format) { 529// startTimestamp = null; 530// var t = setTimeout(step, 50); 531 532// function step(){ 533// if (!startTimestamp) startTimestamp = Date.now(); 534// progress = Math.min((Date.now() - startTimestamp) / duration, 1); 535 536// if(format){ 537// var v = Math.floor(end / 100 * (progress * 100))+'' 538// if(v > 999) v = v.substring(0, v.length - 3)+"'"+v.substring(v.length - 3) 539// obj.text(v); 540// } 541// else obj.text(Math.floor(end / 100 * (progress * 100))); 542// // obj.text(Math.floor(end / 100 * (progress * 100))); 543 544// if (progress < 1) { 545// setTimeout(step, 50); 546// } 547// } 548// } 549 550// function animateValue(obj, start, end, duration, format) { 551// startTimestamp = null; 552// step = function(timestamp){ 553// if (!startTimestamp) startTimestamp = timestamp; 554// progress = Math.min((timestamp - startTimestamp) / duration, 1); 555// if(format){ 556// var v = Math.floor(end / 100 * (progress * 100))+'' 557// if(v > 999) v = v.substring(0, v.length - 3)+"'"+v.substring(v.length - 3) 558// obj.text(v); 559// } 560// else obj.text(Math.floor(end / 100 * (progress * 100))); 561// if (progress < 1) { 562// window.requestAnimationFrame(step); 563// } 564// }; 565// window.requestAnimationFrame(step); 566// } 567 568function initFormularioUSE(){ 569 var uploadFile = {}; 570 var url = '/fileadmin/DFE/DE-USE/formulario-sussidio/'; 571 function init(){ 572 $('#legge').change(changeFields); 573 $('#formulario_use button').click(send); 574 initMultiUpload(); 575 } 576 function changeFields(){ 577 var v = $(this).val(); 578 579 $('.variante').addClass('hidden') 580 if(v == 'a' || v == 'b'){ 581 $('#variante_'+v).removeClass('hidden'); 582 $('#legge').siblings('.error-messages').addClass('hidden'); 583 } 584 } 585 function send(e){ 586 e.preventDefault(); 587 588 var error = false; 589 590 if($('#ragione_sociale').val() == ''){ 591 $('#ragione_sociale').siblings('.error-messages').removeClass('hidden'); 592 error = true; 593 } 594 else $('#ragione_sociale').siblings('.error-messages').addClass('hidden'); 595 596 if($('#numero_idi').val() == ''){ 597 $('#numero_idi').siblings('.error-messages').removeClass('hidden'); 598 error = true; 599 } 600 else $('#numero_idi').siblings('.error-messages').addClass('hidden'); 601 602 if($('#numero_iva').val() == ''){ 603 $('#numero_iva').siblings('.error-messages').removeClass('hidden'); 604 error = true; 605 } 606 else $('#numero_iva').siblings('.error-messages').addClass('hidden'); 607 608 if($('#numero_noga').val() == ''){ 609 $('#numero_noga').siblings('.error-messages').removeClass('hidden'); 610 error = true; 611 } 612 else $('#numero_noga').siblings('.error-messages').addClass('hidden'); 613 614 if($('#legge').val() == ''){ 615 $('#legge').siblings('.error-messages').removeClass('hidden'); 616 error = true; 617 } 618 else $('#legge').siblings('.error-messages').addClass('hidden'); 619 620 621 if($('#legge').val() == 'a'){ 622 623 if($('[name=misura_richiesta]:checked').length == 0){ 624 $('[name=misura_richiesta]:first').parent().parent().siblings('.error-messages').removeClass('hidden'); 625 error = true; 626 } 627 else $('[name=misura_richiesta]:first').parent().parent().siblings('.error-messages').addClass('hidden'); 628 } 629 else if($('#legge').val() == 'b'){ 630 631 if($('[name=misura_richiesta2]:checked').length == 0){ 632 $('[name=misura_richiesta2]:first').parent().parent().siblings('.error-messages').removeClass('hidden'); 633 error = true; 634 } 635 else $('[name=misura_richiesta2]:first').parent().parent().siblings('.error-messages').addClass('hidden'); 636 637 638 if($('[name=otr]:checked').length == 0){ 639 $('[name=otr]:first').parent().parent().siblings('.error-messages').removeClass('hidden'); 640 error = true; 641 } 642 else $('[name=otr]:first').parent().parent().siblings('.error-messages').addClass('hidden'); 643 } 644 645 if(!error){ 646 var data = { 647 ragione_sociale: $('#ragione_sociale').val(), 648 numero_idi: $('#numero_idi').val(), 649 numero_iva: $('#numero_iva').val(),
650 numero_noga: $('#numero_noga').val(), 651 dimensione: $('#dimensione').val(), 652 progetto: $('#progetto').val(), 653 comune: $('#comune').val(), 654 legge: $('#legge').val() 655 }; 656 657 if(data.legge == 'a'){ 658 data.data_richiesta = $('#data_richiesta').val(); 659 data.numero_etp = $('#numero_etp').val(); 660 data.assoggettamento_lavoro = $('#assoggettamento_lavoro').val(); 661 data.stato_richiesta = $('#stato_richiesta').val(); 662 data.misura_richiesta = $('[name=misura_richiesta]:checked').val(); 663 664 if($('.allegati .allegato:not(.hidden)').length){ 665 data.files = []; 666 $('.allegati .allegato:not(.hidden) input').each(function (){ 667 data.files.push($(this).attr('data-file')) 668 }); 669 } 670 } 671 else{ 672 data.otr = $('[name=otr]:checked').val(); 673 data.misura_richiesta = $('[name=misura_richiesta2]:checked').val(); 674 } 675 676 $.post(url+'save.php', data, function (r){ 677 // console.log(r) 678 }); 679 } 680 } 681 function initMultiUpload(){ 682 var attachments_n = 1; 683 var max_weight = 10; 684 var used_weight = 0; 685 var working = false; 686 var uploadButtonContent = ''; 687 function init(){ 688 uploadButtonContent = $('#formulario_use .allegati .add').html(); 689 690 $('#formulario_use').on('click', '.allegati .add', addAttachemnt); 691 $('#formulario_use').on('click', '.allegati .remove', clearAttachemnt); 692 693 $('#formulario_use').on('change', '.inputfile', change); 694 } 695 function addAttachemnt(e){ 696 e.preventDefault(); 697 698 if(!working){ 699 $(this).siblings('.allegato.hidden.new').remove(); 700 701 if($('#attachments-error').length) $('#attachments-error').remove(); 702 703 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 704 $('#formulario_use .allegato.new label').attr('for', 'file'+attachments_n); 705 $('#formulario_use .allegato.new input').attr('id', 'file'+attachments_n).attr('name', 'file'+attachments_n); 706 707 $('#formulario_use .allegato.new input:last').trigger('click'); 708 709 attachments_n++; 710 } 711 } 712 function clearAttachemnt(e){ 713 e.preventDefault(); 714 715 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 716 uploadFile[id] = false; 717 718 var p = $(this).parents('.allegato'); 719 used_weight -= parseInt(p.find('input').attr('data-weight')); 720 // updateWeights(); 721 722 p.find('input[type=file]').val(''); 723 p.find('input[type=file]').next().children('span').text('Allega un file'); 724 p.remove(); 725 } 726 function change(event){ 727 var id = $(this).attr('id'); 728 729 tmp = $(this).val().split("\\"); 730 var v = tmp[tmp.length - 1]; 731 732 if(v){ 733 tmp2 = v.split('.'); 734 var ext = tmp2[(tmp2.length - 1)]; 735 736 if(ext == 'exe' || ext == 'bat' || ext == 'com'){ 737 if($('#attachments-error').length) $('#attachments-error').remove(); 738 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><p style="color:#c33;position: relative; top: -10px;">Formato non consentito.</p></div>'); 739 740 $('label[for='+id+'] span').text('Allega un file (10Mb massimo)'); 741 } 742 else{ 743 $('label[for='+id+'] span').text(v); 744 745 if($('#attachments-error').length) $('#attachments-error').remove(); 746 747 748 uploadFile[id] = event.target.files; 749 750 upload(id, event.target.files); 751 } 752 } 753 } 754 function upload(x, value){ 755 var data = new FormData(); 756 757 // if(value.length > 1){ 758 // var upd = {}; 759 // n = 1; 760 // console.log(value[0]);
761 // for(y in value){ 762 // upd[n] = value[y]; 763 // n++; 764 // } 765 // } 766 // else{ 767 var upd = { 768 x: value 769 }; 770 // } 771 772 // console.log(upd); 773 // console.log(value) 774 // console.log(x) 775 776 $('body').append('<div id="sending-form" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;"></div>'); 777 $('#formulario_use .allegati .add').html('<i class="fa fa-spinner fa-spin"></i>'); 778 working = true; 779 780 for(x in upd){ 781 if(upd[x]){ 782 n = 1; 783 $.each(upd[x], function(key, value){ 784 data.append('file'+n, value); 785 n++; 786 }); 787 } 788 } 789 790 791 $.ajax({ 792 // url: url+'upload.php?max='+(max_weight - used_weight), // point to server-side PHP script 793 url: url+'upload.php', // point to server-side PHP script 794 dataType: 'text', // what to expect back from the PHP script, if anything 795 cache: false, 796 contentType: false, 797 processData: false, 798 data: data, 799 type: 'post', 800 success: function(php_script_response){ 801 802 if(php_script_response == 'filesize'){ 803 if($('#attachments-error').length) $('#attachments-error').remove(); 804 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>L\'allegato supera il limite consentito di 10MB.</li></ul></div>'); 805 } 806 else if(php_script_response == 'error'){ 807 if($('#attachments-error').length) $('#attachments-error').remove(); 808 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>Errore durante il caricamento degli allegati.</li></ul></div>'); 809 } 810 else{ 811 if(php_script_response.indexOf(';') > -1){ 812 var tmp = php_script_response.split(';'); 813 } 814 else var tmp = [php_script_response]; 815 // var tmp = php_script_response.split('|'); 816 // used_weight += parseInt(tmp[1]); 817 818 $('.allegato.new.hidden input').attr('data-file', php_script_response); 819 // $('.allegato.new.hidden input').attr('data-weight', tmp[1]); 820 821 // updateWeights() 822 $('.allegato.new.hidden').removeClass('new hidden'); 823 } 824 825 $('#formulario_use .allegati .add').html(uploadButtonContent); 826 $('#sending-form').remove(); 827 // $('.allegati .add').removeClass('disabled'); 828 working = false; 829 } 830 }); 831 } 832 function updateWeights(){ 833 if(contactData.lang == 'en') $('.allegati h4').html('Attachments '+(used_weight)+' MB(maximum size allowed 10 MB)'); 834 else $('.allegati h4').html('Allegati '+(used_weight)+' MB(dimensione massima consentita 10 MB)'); 835 836 if(used_weight == max_weight) $('.allegati .add').hide(); 837 else $('.allegati .add').show(); 838 } 839 init(); 840 } 841 init(); 842} 843function initVideoLightboxes(){ 844 // <link rel="stylesheet" type="text/css" href="typo3conf/ext/tich_wowza/css/StyleSheet.css" media="screen" /> 845 $('head').append('<script type="text/javascript" src="//player.wowza.com/player/latest/wowzaplayer.min.js"></script>'); 846 847 var myWowzaPlayer;x 848 $('.video_lightbox').click(function (e){ 849 e.preventDefault(); 850 851 var r = 'playerElement' + Math.floor((Math.random() * 100) + 1); 852 853 $('body').prepend('<div id="lightbox_video"><div id="'+r+'" style="width:100%; height:0; padding:0 0 56.25% 0"></div><a href="#" id="close_lightbox_video" style="position: absolute; top: 0; right: 0; padding: 0 10px; font-size: 30px; color: #FFF"><i class="fa fa-times"></i></a></div>'); 854 855 myWowzaPlayer = WowzaPlayer.create(r, 856 { 857 "license":"PLAY1-mWhxJ-Gh3GN-vcn6m-JWJhQ-G9PXe", 858 "title":"", 859 "description":"", 860 "posterFrameURL": $(this).attr('data-cover') ? $(this).attr('data-cover') : '', 861 "sourceURL": $(this).attr('href'), 862 "autoPlay":false, 863 "volume":"75", 864 "mute":false, 865 "loop":false, 866 "audioOnly":false, 867 "uiShowQuickRewind":true, 868 "uiQuickRewindSeconds":"30" 869 } 870 ); 871 872 $('#close_lightbox_video').click(function (e){ 873 e.preventDefault(); 874 if(myWowzaPlayer != null) myWowzaPlayer.destroy(); 875 $('#lightbox_video').remove(); 876 }); 877 }); 878} 879function initSondaggio(){
880 function init(){ 881 $('body').append('<div id="sondaggio"><a href="#" class="close"><i class="fa fa-times"></i></a><h1>COVID-19: sondaggio sulla comunicazione</h1><p>Come pensi sia stata gestita la comunicazione ufficiale delle autorità cantonali durante la crisi sanitaria? Vogliamo sapere la tua opinione!<a href="https://www.wssphinx.ti.ch/SurveyServer/s/fust043/TI_Covid19/questionnaire.htm" class="btn btn-primary" role="button" aria-pressed="true">Partecipa al sondaggio</a></p></div>'); 882 883 setTimeout(function (){ 884 $('#sondaggio').addClass('show'); 885 }, 500); 886 887 $('#sondaggio .close').click(close); 888 } 889 function close(e){ 890 e.preventDefault(); 891 $('#sondaggio').removeClass('show'); 892 } 893 init(); 894} 895 896function showGMaps(){ 897 $.getScript('https://maps.googleapis.com/maps/api/js?key=AIzaSyCRMOl4GMPjzzCWJwjeysPeMum9uskXM5A', function (){ 898 showGMap(0) 899 }) 900} 901function showGMap(n){ 902 if(gmaps[n]){ 903 var data = gmaps[n] 904 var map = new google.maps.Map(document.getElementById(data.id), { 905 zoom: data.zoom, 906 panControl: false, 907 mapTypeControl: false, 908 scaleControl: false, 909 streetViewControl: false, 910 overviewMapControl: false, 911 mapTypeId: google.maps.MapTypeId[data.map_type], 912 disableDefaultUI: true 913 }); 914 915 var infowindow = new google.maps.InfoWindow({ 916 content: data.description 917 }); 918 919 geocoder = new google.maps.Geocoder(); 920 geocoder.geocode( { 'address': data.address}, function(results, status) { 921 if (status == google.maps.GeocoderStatus.OK){ 922 map.setCenter(results[0].geometry.location); 923 924 var marker = new google.maps.Marker({ 925 map: map, 926 position: results[0].geometry.location 927 }); 928 929 google.maps.event.addListener(marker, 'click', function() { 930 infowindow.open(map,marker); 931 }); 932 } 933 n++ 934 setTimeout(function (){ 935 showGMap(n) 936 }, 350) 937 }) 938 } 939} 940 941/* Aste */ 942function initAste(){ 943 var url = '/typo3conf/ext/user_diasteonline/'; 944 var pagination_n = 9; 945 var items_n = 0; 946 var selectedCategory = 'all'; 947 var link = ''; 948 var fadeTimeout = 150; 949 function init(){ 950 $('.nav button').click(changeCategory); 951 952 if($('#aste .list a:eq(0)').length) link = $('#aste .list a:eq(0)').attr('href').split('?')[0]; 953 954 // init list 955 $('#aste .list').after('<div class="hidden list_all"></div>') 956 $('#aste .list_all').html($('#aste .list').html()); 957 pagination2(); 958 959 960 } 961 function changeCategory(e) { 962 e.preventDefault(); 963 964 if(!$(this).hasClass('btn-primary')){ 965 $('.nav .btn-primary').addClass('btn-default').removeClass('btn-primary'); 966 $(this).addClass('btn-primary').removeClass('btn-default'); 967 968 var data = { 969 type: $(this).attr('data-type'), 970 link: link 971 }; 972 973 if(data.type != selectedCategory){ 974 selectedCategory = data.type; 975 976 $('#aste .divSpagina').hide(); 977 if(data.type == 'all'){ 978 $('#aste .list').html($('#aste .list_all').html()); 979 pagination2(); 980 } 981 else{ 982 $.getJSON(url+'request.php', data, function (r){ 983 984 if(r.length){ 985 var n = 1; 986 var nn = 1; 987 var html = ''; 988 for(x in r){ 989 if(nn == 1) html += '<div class="page">'; 990 if(n == 1) html += '<div class="row">'; 991 992 html += r[x]; 993 994 if(n == 3){ 995 html += '</div>'; 996 n = 1; 997 } 998 else n++; 999 1000 if(nn == pagination_n){ 1001 html += '</div>'; 1002 nn = 1; 1003 } 1004 else nn++; 1005 } 1006 1007 if(n < 3 && n > 1) html += '</div>'; 1008 if(nn < pagination_n && nn > 1) html += '</div>'; 1009 1010 $('#aste .list').html(html); 1011 1012 if(r.length > pagination_n){ 1013 pagination(r); 1014 } 1015 else{ 1016 $('#aste .page:eq(0)').show(); 1017 setTimeout(function (){ 1018 $('#aste .page:eq(0)').addClass('show'); 1019 }, fadeTimeout); 1020 } 1021 } 1022 else{ 1023 $('#aste .list').html('<p class="bodytext">Nessun asta in questa categoria</p>') 1024 } 1025 }); 1026 } 1027 } 1028 } 1029 } 1030 var lastPage; 1031 function pagination(items){ 1032 1033 lastPage = 0; 1034 1035 $('.divSpagina').remove(); 1036 1037 items_n = items.length; 1038 1039 html = '<div class="divSpagina"><span>Risultati 1 - '+pagination_n+' di '+items_n+'</span><ul class="pagination"><li class=""><a href="#" class="first">«</a></li><li class=""><a href="#" class="prev">â¹</a></li>'; 1040 1041 var n = 0; 1042 var nn = 1; 1043 for(x=0;x<items.length;x++){ 1044 n++; 1045 if(n == pagination_n) { 1046 html += '<li><a href="#" data-n="'+nn+'">'+nn+'</a></li>'; 1047 nn++; 1048 n = 0; 1049 } 1050 } 1051 if(n > 0){ 1052 n++; 1053 html += '<li><a href="#" data-n="'+nn+'">'+nn+'</a></li>'; 1054 } 1055 1056 1057 html += '<li><a href="#" class="next">âº</a></li><li><a href="#" class="last">»</a></li></ul></div>'; 1058 $('#aste .list').after(html); 1059 1060 $('.pagination [data-n=1]').parent().addClass('active'); 1061 $('#aste .page:eq(0)').show(); 1062 setTimeout(function (){ 1063 $('#aste .page:eq(0)').addClass('show'); 1064 }, fadeTimeout); 1065 1066 1067 updatePagination(); 1068 1069 $('.pagination a').click(function (e){ 1070 e.preventDefault(); 1071 1072 if(!$(this).parent().hasClass('disabled')){ 1073 $('.pagination .active').removeClass('active'); 1074 if($(this).is('[data-n]')){ 1075 1076 $(this).parent().addClass('active'); 1077 1078 var n = $(this).attr('data-n') - 1; 1079 1080 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1081 setTimeout(function (){ 1082 $('#aste .page:eq('+lastPage+')').hide(); 1083 $('#aste .page:eq('+n+')').show(); 1084 setTimeout(function (){ 1085 $('#aste .page:eq('+n+')').addClass('show');lastPage = n; 1086 updatePagination(); 1087 }, fadeTimeout); 1088 1089 }, 700); 1090 } 1091 else if($(this).hasClass('first')){ 1092 n = 0 1093 $('.pagination li a[data-n='+(n+1)+']').parent().addClass('active'); 1094 1095 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1096 setTimeout(function (){ 1097 $('#aste .page:eq('+lastPage+')').hide(); 1098 $('#aste .page:eq('+n+')').show(); 1099 setTimeout(function (){ 1100 $('#aste .page:eq('+n+')').addClass('show');lastPage = 0; 1101 updatePagination(); 1102 }, fadeTimeout); 1103 1104 }, 700); 1105 } 1106 else if($(this).hasClass('prev')){ 1107 n = lastPage - 1; 1108 $('.pagination li a[data-n='+(n+1)+']').parent().addClass('active'); 1109 1110 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1111 setTimeout(function (){ 1112 $('#aste .page:eq('+lastPage+')').hide(); 1113 $('#aste .page:eq('+n+')').show(); 1114 setTimeout(function (){ 1115 $('#aste .page:eq('+n+')').addClass('show');lastPage = n; 1116 updatePagination(); 1117 }, fadeTimeout); 1118 1119 }, 700); 1120 } 1121 else if($(this).hasClass('last')){ 1122 // n = $('.pagination li').length - 4; 1123 1124 // $('.pagination li a[data-n='+(n)+']').parent().addClass('active'); 1125 1126 // $('#aste .page:eq('+lastPage+')').removeClass('show'); 1127 // setTimeout(function (){ 1128 // $('#aste .page:eq('+lastPage+')').hide(); 1129 // $('#aste .page:eq('+n+')').show(); 1130 // setTimeout(function (){ 1131 // $('#aste .page:eq('+n+')').addClass('show'); 1132 // }, fadeTimeout); 1133 // lastPage = n - 1; 1134 // updatePagination(); 1135 // }, 700); 1136 1137 1138 n = $('.pagination li').length - 4; 1139 1140 $('.pagination li a[data-n='+(n)+']').parent().addClass('active'); 1141 1142 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1143 setTimeout(function (){ 1144 $('#aste .page:eq('+lastPage+')').hide(); 1145 $('#aste .page:eq('+(n-1)+')').show(); 1146 setTimeout(function (){ 1147 $('#aste .page:eq('+(n-1)+')').addClass('show');lastPage = n-1; 1148 updatePagination(); 1149 }, fadeTimeout); 1150 1151 }, 700); 1152 } 1153 else if($(this).hasClass('next')){ 1154 n = lastPage + 1; 1155 $('.pagination li a[data-n='+(n+1)+']').parent().addClass('active'); 1156 1157 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1158 setTimeout(function (){ 1159 $('#aste .page:eq('+lastPage+')').hide(); 1160 $('#aste .page:eq('+n+')').show(); 1161 setTimeout(function (){ 1162 $('#aste .page:eq('+n+')').addClass('show');lastPage = n; 1163 updatePagination(); 1164 }, fadeTimeout); 1165 1166 }, 700); 1167 } 1168 1169 $('body').animate({ scrollTop: 0 }, 600); 1170 } 1171 }) 1172 } 1173 function pagination2(){ 1174 1175 lastPage = 0; 1176 1177 $('.divSpagina').remove(); 1178 1179 items_n = $('#aste .list_all .page .col-xs-4').length; 1180 1181 html = '<div class="divSpagina"><span>Risultati 1 - '+pagination_n+' di '+items_n+'</span><ul class="pagination"><li class=""><a href="#" class="first">«</a></li><li class=""><a href="#" class="prev">â¹</a></li>'; 1182 1183 var n = 0; 1184 var nn = 1; 1185 for(x=0;x<$('#aste .list_all .page').length;x++){ 1186 // n++; 1187 // if(n == pagination_n) { 1188 html += '<li><a href="#" data-n="'+(x+1)+'">'+(x+1)+'</a></li>'; 1189 // nn++; 1190 // n = 0; 1191 // } 1192 } 1193 1194 html += '<li><a href="#" class="next">âº</a></li><li><a href="#" class="last">»</a></li></ul></div>'; 1195 $('#aste .list').after(html); 1196 1197 $('.pagination [data-n=1]').parent().addClass('active'); 1198 // $('#aste .page:eq(0)').show(); 1199 // setTimeout(function (){ 1200 // $('#aste .page:eq(0)').addClass('show'); 1201 // }, fadeTimeout); 1202 1203 1204 updatePagination(); 1205 1206 $('.pagination a').click(function (e){ 1207 e.preventDefault(); 1208 1209 if(!$(this).parent().hasClass('disabled')){ 1210 $('.pagination .active').removeClass('active'); 1211 if($(this).is('[data-n]')){ 1212 1213 $(this).parent().addClass('active'); 1214 1215 var n = $(this).attr('data-n') - 1; 1216 1217 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1218 setTimeout(function (){ 1219 $('#aste .page:eq('+lastPage+')').hide(); 1220 $('#aste .page:eq('+n+')').show(); 1221 setTimeout(function (){ 1222 $('#aste .page:eq('+n+')').addClass('show');lastPage = n; 1223 updatePagination(); 1224 }, fadeTimeout); 1225 1226 }, 700); 1227 } 1228 else if($(this).hasClass('first')){ 1229 n = 0 1230 $('.pagination li a[data-n='+(n+1)+']').parent().addClass('active'); 1231 1232 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1233 setTimeout(function (){ 1234 $('#aste .page:eq('+lastPage+')').hide(); 1235 $('#aste .page:eq('+n+')').show(); 1236 setTimeout(function (){ 1237 $('#aste .page:eq('+n+')').addClass('show');lastPage = 0; 1238 updatePagination(); 1239 }, fadeTimeout); 1240 1241 }, 700); 1242 } 1243 else if($(this).hasClass('prev')){ 1244 n = lastPage - 1; 1245 $('.pagination li a[data-n='+(n+1)+']').parent().addClass('active'); 1246 1247 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1248 setTimeout(function (){ 1249 $('#aste .page:eq('+lastPage+')').hide(); 1250 $('#aste .page:eq('+n+')').show(); 1251 setTimeout(function (){ 1252 $('#aste .page:eq('+n+')').addClass('show');lastPage = n; 1253 updatePagination(); 1254 }, fadeTimeout); 1255 1256 }, 700); 1257 } 1258 else if($(this).hasClass('last')){ 1259 n = $('.pagination li').length - 4; 1260 1261 $('.pagination li a[data-n='+(n)+']').parent().addClass('active'); 1262 1263 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1264 setTimeout(function (){ 1265 $('#aste .page:eq('+lastPage+')').hide(); 1266 $('#aste .page:eq('+(n-1)+')').show(); 1267 setTimeout(function (){ 1268 $('#aste .page:eq('+(n-1)+')').addClass('show');lastPage = n-1; 1269 updatePagination(); 1270 }, fadeTimeout); 1271 1272 }, 700); 1273 } 1274 else if($(this).hasClass('next')){ 1275 n = lastPage + 1; 1276 $('.pagination li a[data-n='+(n+1)+']').parent().addClass('active'); 1277 1278 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1279 setTimeout(function (){ 1280 $('#aste .page:eq('+lastPage+')').hide(); 1281 $('#aste .page:eq('+n+')').show(); 1282 setTimeout(function (){ 1283 $('#aste .page:eq('+n+')').addClass('show');lastPage = n; 1284 updatePagination(); 1285 }, fadeTimeout); 1286 1287 }, 700); 1288 } 1289 1290 $('body').animate({ scrollTop: 0 }, 600); 1291 } 1292 }) 1293 } 1294 function showPage(){ 1295 $('#aste .page:eq('+lastPage+')').removeClass('show'); 1296 setTimeout(function (){ 1297 $('#aste .page:eq('+lastPage+')').hide(); 1298 $('#aste .page:eq('+n+')').show(); 1299 setTimeout(function (){ 1300 $('#aste .page:eq('+n+')').addClass('show'); 1301 }, fadeTimeout); 1302 }, 700); 1303 } 1304 function updatePagination(){ 1305 1306 var i = $('.pagination .active').index(); 1307 var n = $('.pagination li').length; 1308 1309 if(i == 2){ 1310 $('.pagination li:eq(0)').addClass('disabled'); 1311 $('.pagination li:eq(1)').addClass('
1311disabled'); 1312 } 1313 else if(i == 3){ 1314 $('.pagination li:eq(0)').addClass('disabled'); 1315 $('.pagination li:eq(1)').removeClass('disabled'); 1316 } 1317 else{ 1318 $('.pagination li:eq(0)').removeClass('disabled'); 1319 $('.pagination li:eq(1)').removeClass('disabled'); 1320 } 1321 1322 1323 if(i == n - 2 - 1){ 1324 $('.pagination li:eq('+(n - 2 - 1 + 1)+')').addClass('disabled'); 1325 $('.pagination li:eq('+(n - 2 - 1 + 2)+')').addClass('disabled'); 1326 } 1327 else if(i == n - 3 - 1){ 1328 $('.pagination li:eq('+(n - 2 - 1 + 2)+')').addClass('disabled'); 1329 $('.pagination li:eq('+(n - 2 - 1 + 1)+')').removeClass('disabled'); 1330 } 1331 else{ 1332 $('.pagination li:eq('+(n - 2 - 1 + 1)+')').removeClass('disabled'); 1333 $('.pagination li:eq('+(n - 2 - 1 + 2)+')').removeClass('disabled'); 1334 } 1335 1336 var nnnn = ((i - 1) * pagination_n); 1337 1338 1339 if(nnnn > items_n) nnnn = items_n; 1340// 1341 // console.log(nnnn) 1342 // console.log(parseInt($('.page.show:visible .col-xs-4').length)) 1343 // console.log(nnnn - parseInt($('.page.show:visible .col-xs-4').length) + 1) 1344 1345 $('.divSpagina > span').html('Risultati '+(nnnn - parseInt($('.page.show:visible .col-xs-4').length) + 1)+' - '+nnnn+' di '+items_n) 1346 } 1347 init(); 1348} 1349 1350function initAvvisi(){ 1351 if($('.tich-avvisi').length){ 1352 $('.tich-avvisi.alert').removeClass('hidden') 1353 1354 if($('.tich-avvisi.info, .tich-avvisi.success, .tich-avvisi.alert').length){ 1355 var tss = $(this) 1356 $.getJSON('typo3conf/ext/theme/Resources/Public/scripts/avvisi.php', function (l){ 1357 if(l){ 1358 $('.tich-avvisi').each(function (){ 1359 if(l.hidden.indexOf($(this).parents('.frame').attr('id')) == -1) $(this).removeClass('hidden') 1360 }) 1361 } 1362 else $('.tich-avvisi.info, .tich-avvisi.success').removeClass('hidden') 1363 1364 1365 $('.tich-avvisi').each(function (){ 1366 $(this).attr('data-height', $(this).outerHeight()) 1367 }) 1368 1369 if(l){ 1370 $('.tich-avvisi').each(function (){ 1371 if(l.closed.indexOf($(this).parents('.frame').attr('id')) > -1) $(this).addClass('short').css('height', '82px') 1372 }) 1373 } 1374 1375 if($('.tich-avvisi.alert:not(.hidden)').length) $('body').addClass('tich-avvisi-border avviso-alert') 1376 else if($('.tich-avvisi.success:not(.hidden)').length) $('body').addClass('tich-avvisi-border avviso-success') 1377 1378 if($('body .avvisi .tich-avvisi.alert, body .avvisi .tich-avvisi:not(.hidden').length){ 1379 $(window).scroll(function (e){ 1380 if($(window).scrollTop() > 0){ 1381 $('body .avvisi .tich-avvisi.alert, body .avvisi').addClass('sticky')//.css('height', '82px') 1382 $('body .avvisi .tich-avvisi.alert, body .avvisi .tich-avvisi:not(.hidden)').addClass('short').css('height', '82px') 1383 1384 1385 $('body').css('padding-top', ($('body .avvisi .tich-avvisi.alert, body .avvisi .tich-avvisi:not(.hidden)').length * 82)+'px') 1386 } 1387 else{ 1388 $('body .avvisi .tich-avvisi.alert, body .avvisi').removeClass('sticky')//.css('height', $('body .avvisi .tich-avvisi.alert, body .avvisi').attr('data-height')+'px') 1389 $('body .avvisi .tich-avvisi.alert, body .avvisi .tich-avvisi:not(.hidden)').removeClass('short').css('height', $('body .avvisi .tich-avvisi.alert, body .avvisi').attr('data-height')+'px') 1390 1391 $('body .avvisi .tich-avvisi.alert, body .avvisi .tich-avvisi:not(.hidden)').each(function (){ 1392 $(this).removeClass('short').css('height', $(this).attr('data-height')+'px') 1393 }) 1394 1395 $('body').css('padding-top', '0px') 1396 } 1397 }) 1398 } 1399 }) 1400 } 1401 } 1402 1403 $('.tich-avvisi .close-avviso').click(function (e){ 1404 e.preventDefault() 1405 1406 if($(this).parents('.tich-avvisi').hasClass('success')) $('body').removeClass('tich-avvisi-border avviso-success') 1407 1408 $.post('typo3conf/ext/theme/Resources/Public/scripts/avvisi.php', {i: $(this).parents('.frame').attr('id'), t: 'h'}) 1409 1410 1411 $(this).parents('.tich-avvisi').remove() 1412 }) 1413 $('.tich-avvisi .toggle-avviso').click(function (e){ 1414 e.preventDefault() 1415 1416 var p = $(this).parents('.tich-avvisi') 1417 1418 // if(p.hasClass('short')) p.css('height', p.attr('data-height')+'px') 1419 // else p.css('height', '82px') 1420 1421 if(p.hasClass('short')){ 1422 p.css('height', p.attr('data-height')+'px') 1423 $.post('typo3conf/ext/theme/Resources/Public/scripts/avvisi.php', {i: $(this).parents('.frame').attr('id'), t: 'o'}) 1424 } 1425 else { 1426 p.css('height', '82px') 1427 $.post('typo3conf/ext/theme/Resources/Public/scripts/avvisi.php', {i: $(this).parents('.frame').attr('id'), t: 'c'}) 1428 } 1429 1430 p.toggleClass('short') 1431 }) 1432} 1433 1434function initPenuriaEnergetica(){ 1435 var difficulties = { 1436 1: 'bassa', 1437 2: 'media', 1438 3: 'alta', 1439 4: '-', 1440 } 1441 var times = { 1442 1: 'immediato', 1443 2: 'medio termine', 1444 3: 'lungo termine', 1445 4: '-', 1446 } 1447 var favorites_n = 0
1448 function init(){ 1449 loadData() 1450 $('.tx-tich-dtpenuriaenergetica > .btn').click(function (){ 1451 // $(this).attr('data-id') 1452 $(this).toggleClass('active') 1453 loadData() 1454 }) 1455 $('.btn-group.sort button').click(function (){ 1456 if(!$(this).hasClass('active')){ 1457 $('.btn-group.sort .active').removeClass('active') 1458 $(this).addClass('active') 1459 loadData() 1460 } 1461 }) 1462 1463 $('body').on('click', '.add-favorite', changeFavorite) 1464 1465 } 1466 function loadData(){ 1467 // $('.grid .col').html('') 1468 $('.grid > h2').remove() 1469 $('.grid').addClass('loading') 1470 1471 var d = { 1472 o: $('.btn-group.sort .active').attr('data-value') 1473 } 1474 1475 if($('.tx-tich-dtpenuriaenergetica > .btn.active').length){ 1476 var tmp = [] 1477 $('.tx-tich-dtpenuriaenergetica > .btn.active').each(function (){ 1478 tmp.push($(this).attr('data-id')) 1479 }) 1480 d.c = tmp.join(',') 1481 } 1482 1483 $.getJSON('/typo3conf/ext/tich_dtpenuriaenergetica/Resources/Public/PHP/consigliJson.php', d, function (data){ 1484 var items = [] 1485 1486 if(data.state){ 1487 var f = 0 1488 for(x in data.items){ 1489 var c = $('.spreco-box.placeholder.hidden').clone() 1490 1491 c.attr('data-id', data.items[x].id) 1492 var html = '' 1493 for (var i = 1; i <= 5; i++) { 1494 if(data.items[x].rating < i) html += '<i class="fa fa-star-o"></i>' 1495 else html += '<i class="fa fa-star"></i>' 1496 } 1497 c.find('.rating').html(html) 1498 1499 c.find('h3').text(data.items[x].title) 1500 c.find('.difficulty').text(difficulties[data.items[x].difficulty]) 1501 c.find('.time').text(times[data.items[x].time]) 1502 c.find('.back p').replaceWith(data.items[x].text) 1503 c.find('.category').html('<img src="'+data.items[x].icona_categoria+'">') 1504 1505 if(data.items[x].link) c.find('.back > .in > a').attr('href', data.items[x].link) 1506 else c.find('.back > .in > a').remove() 1507 1508 if(data.items[x].long) c.addClass('long') 1509 if(data.items[x].favorite){ 1510 c.addClass('favorite') 1511 c.find('.fa-bookmark-o').removeClass('fa-bookmark-o').addClass('fa-bookmark') 1512 f++ 1513 } 1514 1515 c.removeClass('placeholder hidden') 1516 items.push(c) 1517 } 1518 1519 // items = items.reverse() 1520 1521 $('.grid .col').html('') 1522 1523 var cols = [0, 0, 0] 1524 col = 0 1525 for(x in items){ 1526 var c = 0 1527 var v = 10000 1528 for(y in cols){ 1529 if(cols[y] < v){ 1530 v = cols[y] 1531 c = y 1532 } 1533 } 1534 $('.grid .col:eq('+c+')').append(items[x]) 1535 cols[c] += items[x].hasClass('long') ? 2 : 1 1536 1537 1538 1539 // if(items[x].hasClass('long')) console.log('long') 1540 // $('.grid .col:eq('+col+')').prepend(items[x]) 1541 // col++ 1542 // if(col == 3) col = 0 1543 } 1544 1545 // favorites_n = data.favorites - $('.grid .spreco-box.favorite').length 1546 favorites_n = data.favorites 1547 updateFavoritesButton() 1548 } 1549 else{ 1550 $('.grid .col').html('') 1551 $('.grid').prepend('<h2 style="flex: 1 0 100%;text-align: center;">Nessun consiglio trovato</h2>') 1552 } 1553 $('.grid').removeClass('loading') 1554 }) 1555 } 1556 function changeFavorite(){ 1557 var p = $(this).parents('.spreco-box') 1558 var id = p.attr('data-id') 1559 var action = $(this).children('i').hasClass('fa-bookmark-o') ? 1 : 2 1560 var url = '/typo3conf/ext/tich_dtpenuriaenergetica/Resources/Public/PHP/consigliJson.php?a='+action+'&id='+id 1561 1562 if(action == 1){ 1563 $(this).children('i').removeClass('fa-bookmark-o').addClass('fa-bookmark') 1564 p.addClass('favorite') 1565 favorites_n++ 1566 } 1567 else{ 1568 $(this).children('i').removeClass('fa-bookmark').addClass('fa-bookmark-o') 1569 p.removeClass('favorite') 1570 favorites_n-- 1571 } 1572 1573 updateFavoritesButton(); 1574 1575 $.get(url) 1576 } 1577 function updateFavoritesButton(){ 1578 // var f = $('.grid .spreco-box.favorite').length + favorites_n 1579 var f = favorites_n 1580 if(f) $('.favorite-button').addClass('on') 1581 else $('.favorite-button').removeClass('on') 1582 $('.favorite-button span').text(f) 1583 } 1584 init() 1585} 1586 1587function initPenuriaEnergeticaPreferiti(){ 1588 var difficulties = { 1589 1: 'bassa', 1590 2: 'media', 1591 3: 'alta', 1592 4: '-', 1593 } 1594 var times = { 1595 1: 'immediato', 1596 2: 'medio termine', 1597 3: 'lungo termine', 1598 4: '-', 1599 }
1600 function init(){ 1601 loadData() 1602 // $('.tx-tich-dtpenuriaenergetica > .btn').click(function (){ 1603 // // $(this).attr('data-id') 1604 // $(this).toggleClass('active') 1605 // loadData() 1606 // }) 1607 // $('.btn-group.sort button').click(function (){ 1608 // if(!$(this).hasClass('active')){ 1609 // $('.btn-group.sort .active').removeClass('active') 1610 // $(this).addClass('active') 1611 // loadData() 1612 // } 1613 // }) 1614 1615 // $('body').on('click', '.add-favorite', changeFavorite) 1616 1617 } 1618 function loadData(){ 1619 // $('.grid .col').html('') 1620 $('.favorites > h2').remove() 1621 $('.favorites').addClass('loading') 1622 1623 var d = { 1624 o: 1 1625 } 1626 1627 $.getJSON('/typo3conf/ext/tich_dtpenuriaenergetica/Resources/Public/PHP/consigliJson.php', d, function (data){ 1628 var items = [] 1629 1630 if(data.state){ 1631 var f = [] 1632 var stars = 0 1633 for(x in data.items){ 1634 if(data.items[x].favorite){ 1635 var c = $('.item.placeholder.hidden').clone() 1636 1637 f.push(data.items[x].id) 1638 1639 c.attr('data-id', data.items[x].id) 1640 var html = '' 1641 for (var i = 1; i <= 5; i++) { 1642 if(data.items[x].rating < i) html += '<i class="fa fa-star-o"></i>' 1643 else { 1644 html += '<i class="fa fa-star"></i>' 1645 stars++ 1646 } 1647 } 1648 c.find('.rating').html(html) 1649 1650 c.find('h2').text(data.items[x].title) 1651 c.find('.difficulty span').text(difficulties[data.items[x].difficulty]) 1652 c.find('.timing span').text(times[data.items[x].time]) 1653 c.find('p').replaceWith(data.items[x].text) 1654 c.find('.category').html('<img src="'+data.items[x].icona_categoria.replace('.
1654svg', '_b.svg')+'">') 1655 c.find('.category').attr('href', '/index.php?id=137205&c='+data.items[x].id_category) 1656 1657 if(data.items[x].link) c.find('.more-info').attr('href', data.items[x].link) 1658 else c.find('.more-info').remove() 1659 1660 // if(data.items[x].long) c.addClass('long') 1661 // if(data.items[x].favorite){ 1662 // c.addClass('favorite') 1663 // c.find('.fa-bookmark-o').removeClass('fa-bookmark-o').addClass('fa-bookmark') 1664 // f++ 1665 // } 1666 1667 c.removeClass('placeholder hidden') 1668 $('.favorites').append(c) 1669 } 1670 } 1671 $('.print-favorites').attr('href', '/typo3conf/ext/tich_dtpenuriaenergetica/Resources/Public/PHP/preferitiPDF.php?p='+f.join(',')) 1672 $('span.stars').text(stars) 1673 } 1674 else{ 1675 $('.grid .col').html('') 1676 $('.grid').prepend('<h2 style="flex: 1 0 100%;text-align: center;">Nessun consiglio trovato</h2>') 1677 } 1678 $('.grid').removeClass('loading') 1679 }) 1680 } 1681 function changeFavorite(){ 1682 var p = $(this).parents('.spreco-box') 1683 var id = p.attr('data-id') 1684 var action = $(this).children('i').hasClass('fa-bookmark-o') ? 1 : 2 1685 var url = '/typo3conf/ext/tich_dtpenuriaenergetica/Resources/Public/PHP/consigliJson.php?a='+action+'&id='+id 1686 1687 if(action == 1){ 1688 $(this).children('i').removeClass('fa-bookmark-o').addClass('fa-bookmark') 1689 p.addClass('favorite') 1690 } 1691 else{ 1692 $(this).children('i').removeClass('fa-bookmark').addClass('fa-bookmark-o') 1693 p.removeClass('favorite') 1694 } 1695 1696 updateFavoritesButton(); 1697 1698 $.get(url) 1699 } 1700 function updateFavoritesButton(){ 1701 var f = $('.grid .spreco-box.favorite').length 1702 if(f) $('.favorite-button').addClass('on') 1703 else $('.favorite-button').removeClass('on') 1704 $('.favorite-button span').text(f) 1705 } 1706 init() 1707} 1708 1709/* Carousel links */ 1710function initCarouselLinks() { 1711 var e = $('.carousel a[href=\'\']'); 1712 if (e.length) { 1713 e.css({ cursor: 'default' }).click(function (e) { e.preventDefault(); }).children('.carousel-caption').css({ cursor: 'default' }); 1714 } 1715} 1716/* Footer */ 1717function initFooter() { 1718 var pathname = window.location.href.split('#')[0]; 1719 jQuery('a[href^="#"]').each(function () { 1720 jQuery(this).attr('href', pathname + jQuery(this).attr('href')); 1721 }); 1722 1723 //attiva i menù se ho il javascript 1724 jQuery("#navPrimoLivello1 a, #navPrimoLivello2 a").attr("href", "#"); 1725 jQuery("#navPrimoLivello1 a, #navPrimoLivello2 a").attr("onclick", "javascript:return false;"); 1726 1727 setTimeout(function () { 1728 1729 1730 var o = $('.footer .bar').offset(); 1731 $('.sliding-content').each(function () { 1732 var h = $(this).outerHeight(); 1733 $(this).css({ top: (o.top - h) + 'px' }).hide(); 1734 }); 1735 1736 }, 1000); 1737 1738 1739 var footer_hover = { 'apps': false, 'social': false }; 1740 var footer_opened = false; 1741 $('.footer .bar li a:not(.info-legali)').click(function (e) { 1742 e.preventDefault(); 1743 1744 var h = $(this).attr('href'); 1745 footer_opened = true; 1746 $('.footer .bar .selected').removeClass('selected'); 1747 $(this).addClass('selected'); 1748 if (h.indexOf('#') && (h.indexOf('#') + 1) < h.length) { 1749 tmp = h.split('#'); 1750 if (tmp[1] && $('.sliding-content.' + tmp[1]).length) { 1751 // footer_hover[tmp[1]] = true; 1752 1753 $('.sliding-content.visible').removeClass('visible').hide(); 1754 1755 1756 $('.sliding-content.' + tmp[1]).show() 1757 $('.sliding-content.' + tmp[1]).addClass('visible'); 1758 // setTimeout(function (){ 1759 // $('.sliding-content.'+tmp[1]).addClass('visible'); 1760 // }, 200); 1761 } 1762 } 1763 }); 1764 1765 $('html, body').click(function (e) { 1766 if (footer_opened) { 1767 if (!$(e.target).parents('.footer').length && !$(e.target).parents('.sliding-content').length) { 1768 $('.sliding-content.visible').removeClass('visible').hide(); 1769 $('.footer .bar .selected').removeClass('selected'); 1770 } 1771 } 1772 }) 1773 1774 1775 1776 $('.sliding-content').each(function () { 1777 $(this).append('<i class="fa fa-times"></i>'); 1778 }); 1779 1780 $('.fa.fa-times').click(function () { 1781 $('.sliding-content.visible').removeClass('visible').hide(); 1782 $('.footer .bar .selected').removeClass('selected'); 1783 }) 1784 1785 1786 $('.sliding-content a.social-link').click(function (e) { 1787 e.preventDefault(); 1788 $('html, body').animate({ scrollTop: 0 }, 500); 1789 // apriContatti2(); 1790 }) 1791} 1792/* Functions */ 1793function windowHeight() { 1794 return window.innerHeight 1795 || document.documentElement.clientHeight 1796 || document.body.clientHeight; 1797} 1798function initClearField() {
1799 function init() { 1800 if(!is_explorer){ 1801 $('input.clear-field').wrap('<span class="clear-field"></span>'); 1802 $('input.clear-field').after('<a href="#" class="hidden"><i class="fa fa-times" aria-label="Cancella contenuto"></i></a>'); 1803 $('input.clear-field').keyup(keyup); 1804 $('span.clear-field a').click(click); 1805 1806 if ($('input.clear-field').val()) { 1807 $('input.clear-field').next().removeClass('hidden'); 1808 } 1809 } 1810 } 1811 function keyup(e) { 1812 if ($(this).val()) { 1813 $(this).next().removeClass('hidden'); 1814 } 1815 else if (!$(this).next().hasClass('hidden')) $(this).next().addClass('hidden'); 1816 } 1817 function click(e) { 1818 e.preventDefault(); 1819 $(this).prev().val(''); 1820 $(this).addClass('hidden'); 1821 } 1822 init(); 1823} 1824function initDatepicker() { 1825 $.fn.datepicker.dates['it'] = { 1826 days: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"], 1827 daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"], 1828 daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"], 1829 months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], 1830 monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"], 1831 today: "Oggi", 1832 clear: "Svuota" 1833 }; 1834 1835 $('.datepicker').datepicker({ 1836 format: "dd.mm.yyyy", 1837 todayHighlight: true, 1838 language: 'it', 1839 }); 1840} 1841function IEPlaceholderFix() { 1842 var ua = window.navigator.userAgent; 1843 var msie = ua.indexOf("MSIE "); 1844 if (msie > 0 && parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))) < 10) { 1845 jQuery('[placeholder]').focus(function () { 1846 var input = jQuery(this); 1847 if (input.val() == input.attr('placeholder')) { 1848 input.val(''); 1849 input.removeClass('placeholder'); 1850 } 1851 }).blur(function () { 1852 var input = jQuery(this); 1853 if (input.val() == '' || input.val() == input.attr('placeholder')) { 1854 input.addClass('placeholder'); 1855 input.val(input.attr('placeholder')); 1856 } 1857 }).blur(); 1858 } 1859} 1860function createWindowWithRemotingUrl() { 1861 jQuery.window({ 1862 title: "Prova", 1863 url: "https://www.ti.ch" 1864 }); 1865} 1866function initBackToTop(){ 1867 $('body').append('<a href="#" id="backtotop" tabindex="-1" aria-label="Torna in cima alla pagina"><i class="fa fa-angle-up" aria-hidden="true"></i></a>'); 1868 $('#backtotop').click(function (e){ 1869 e.preventDefault(); 1870 $('html, body').animate({'scrollTop': 0}, 500); 1871 }); 1872 $(window).scroll(function (e){ 1873 if($(this).scrollTop() > 100) $('#backtotop').addClass('shown'); 1874 else $('#backtotop').removeClass('shown'); 1875 }); 1876} 1877function initHeadingLinks() { 1878 // $('h3 > a').append(' <i class="fa fa-angle-right"></i>'); 1879 1880 $('h3 > a').each(function () { 1881 if ($(this).parents('.lista-comunicati').length == 0 && $(this).parents('#numeroComuni').length == 0 && $(this).parents('.rss-title').length == 0) $(this).append(' <i class="fa fa-angle-right"></i>'); 1882 }); 1883} 1884function Popup(sURL) { 1885 var w = window.open(sURL, '', 'width=800,height=600'); 1886} 1887function PopupPrimoPiano(sURL) { 1888 var w = window.open(sURL, '', 'width=800,height=600,resizable=1'); 1889} 1890function nuovafinestra(str, w, h) { 1891 1892 var efficientString = 'scrollbars=yes,resizable=yes,width='; 1893 efficientString += w; 1894 efficientString += ',height='; 1895 efficientString += h; 1896 efficientString += ',status=no,location=no,toolbar=no'; 1897 1898 searchWin = window.open(str, 'nuovafinestra', efficientString); 1899 // searchWin.refer = self; 1900} 1901function TargetBlank() { 1902 if (document.getElementsByTagName) { 1903 var msg = ' (Collegamento in nuova finestra)'; 1904 var links = document.getElementsByTagName('a'); 1905 for (i = 0; i < links.length; i++) { 1906 var link = links[i]; 1907 if (link.className.indexOf('targetblank') != -1) { 1908 link.title += msg; 1909 var fn = function () { 1910 window.open(this.href); 1911 return false;
1912 } 1913 link.onclick = link.onkeypress = fn; 1914 } 1915 } 1916 } 1917} 1918function setPointer(theRow, thePointerColor) { 1919 if (thePointerColor == '' || typeof (theRow.style) == 'undefined') { 1920 return false; 1921 } 1922 if (typeof (document.getElementsByTagName) != 'undefined') { 1923 var theCells = theRow.getElementsByTagName('td'); 1924 } else if (typeof (theRow.cells) != 'undefined') { 1925 var theCells = theRow.cells; 1926 } else { 1927 return false; 1928 } 1929 var rowCellsCnt = theCells.length; 1930 for (var c = 0; c < rowCellsCnt; c++) { 1931 theCells[c].style.backgroundColor = thePointerColor; 1932 } 1933 return true; 1934} 1935function URLEncode(strToEnc, sep) { 1936 arrOfStr = strToEnc.split(sep); 1937 strToEnc = arrOfStr[0]; 1938 for (i = 1; i < arrOfStr.length; i++) { 1939 strToEnc += '%20' + arrOfStr[i]; 1940 } 1941 return strToEnc; 1942} 1943function getParameterByName(name) { 1944 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); 1945 var regexS = "[\\?&]" + name + "=([^&#]*)"; 1946 var regex = new RegExp(regexS); 1947 var results = regex.exec(window.location.href); 1948 if (results == null) 1949 return ""; 1950 else 1951 return decodeURIComponent(results[1].replace(/\+/g, " ")); 1952} 1953var myWin; 1954function openWin(pagina, nome, parametri) { 1955 // Apre una pagina in una nuova finestra in base ai parametri passati 1956 // PARAMETRI 1957 // pagina : URI della pagina da caricare 1958 // nome : nome della nuova finestra (da non confondere con il titolo) 1959 // parametri : parametri di visualizzazione della nuova finestra 1960 if (!myWin || myWin.closed) { 1961 myWin = window.open(URLEncode(pagina), nome, parametri); 1962 } else { 1963 // myWin.close(); 1964 myWin = window.open(URLEncode(pagina), nome, parametri); 1965 myWin.focus(); 1966 } 1967} 1968function openURL(url) { 1969 location.href = url; 1970} 1971function mouseTrap(first, last){ 1972 first.keydown(function (e){ 1973 if(e.keyCode == 9 && e.shiftKey){ 1974 e.preventDefault(); 1975 last.focus(); 1976 } 1977 }); 1978 last.keydown(function (e){ 1979 if(e.keyCode == 9 && !e.shiftKey){ 1980 e.preventDefault(); 1981 first.focus(); 1982 } 1983 }); 1984} 1985 1986function initPhraseSlider(t){ 1987 1988 var sp_index = 1; 1989 var sp_count; 1990 1991 sp_count = t.children().length 1992 1993 t.children(':eq('+(sp_index - 1)+')').css({left: 0}); 1994 1995 var next = (sp_index + 1 > sp_count) ? 1 : sp_index + 1; 1996 t.children(':eq('+(next)+')').css({left: -1000}); 1997 1998 1999 2000 // t.children(':first').css({left: 0}); 2001 setInterval(function (){ 2002 t.children(':eq('+(sp_index - 1)+')').css({left: 1000}); 2003 2004 sp_index = ((sp_index + 1) > sp_count) ? 1 : sp_index + 1; 2005 2006 t.children(':eq('+(sp_index - 1)+')').css({left: 0}); 2007 2008 var next = (sp_index + 1 > sp_count) ? 1 : sp_index + 1; 2009 t.children(':eq('+(next-1)+')').addClass('flip').css({left: -1000}); 2010 setTimeout(function (){ 2011 t.children(':eq('+(next-1)+')').removeClass('flip'); 2012 }, 1500) 2013 2014 // t.children(':eq('+(sp_index - 1)+')').css({left: 1000}); 2015 2016 // console.log(sp_count) 2017 // console.log(sp_index) 2018 // index = ((sp_index + 1) > sp_count) ? 1 : sp_index + 1; 2019 // console.log(sp_index) 2020 2021 // t.children(':eq('+(sp_index - 1)+')').css({left: 0}); 2022 2023 // var next = (sp_index + 1 > sp_count) ? 1 : sp_index + 1; 2024 // t.children(':eq('+(next)+')').css({left: -1000}); 2025 2026 }, 8000) 2027} 2028 2029function capitalizeFirstLetter(string) { 2030 return string.charAt(0).toUpperCase() + string.slice(1); 2031} 2032 2033$.urlParam = function(name){ 2034 var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); 2035 return results[1] || 0; 2036} 2037/* Home */ 2038function initHomeMenu() { 2039 2040 $('.home-tab a').click(function (e) { 2041 // e.preventDefault(); 2042 var i = $(this).parent().index(); 2043 $('.home-tab a.selected').removeClass('selected'); 2044 $(this).addClass('selected') 2045 if (i == 0) { 2046 2047 } 2048 else { 2049 $('.home-icon-menu .items').hide(); 2050 // $('.home-icon-menu .sub-page').hide(); 2051 $('.home-icon-menu .sub-page').css('height', 0).html(''); 2052 $('.home-icon-menu, .home-icon-menu .items:eq(' + (i - 1) + ')').show(); 2053 openOverlayMenu(); 2054 } 2055 // $('.home-tab a') 2056 }); 2057 2058 // aria-expanded 2059 $('.home-menu .menu > li > a').each(function (){ 2060 $(this).attr('aria-expanded', false); 2061 }); 2062 2063 // fix tab navigation 2064 $('.sub-items').each(function (i){ 2065 if(i > 0) $(this).attr('data-n', i - 1); 2066 }) 2067 2068 var str = new Array(); 2069 for(x=0;x<$('.home-menu .menu li').length;x++) str.push('.home-menu .sub-items:eq('+x+') ul a:first');
2070 $(str.join(',')).keydown(function (e){ 2071 if(e.keyCode == 9 && e.shiftKey){ 2072 e.preventDefault(); 2073 $('.home-menu .menu li:eq('+$(this).parents('.sub-items').attr('data-n')+') a').focus(); 2074 } 2075 }); 2076 2077 var str = new Array(); 2078 for(x=0;x<$('.home-menu .menu li').length;x++) str.push('.home-menu .sub-items:eq('+x+') ul a:last'); 2079 $(str.join(',')).keydown(function (e){ 2080 if(e.keyCode == 9 && !e.shiftKey){ 2081 e.preventDefault(); 2082 $('.home-menu .menu li:eq('+$(this).parents('.sub-items').attr('data-n')+') a').focus(); 2083 } 2084 }); 2085 2086 $('.home-menu .menu > li:last a').keydown(function (e){ 2087 if(e.keyCode == 9 && !e.shiftKey){ 2088 e.preventDefault(); 2089 $('.tx-user-slider a').focus() 2090 // console.log($('.tx-user-slider a:first')) 2091 // $('.lista-icons.small-incons a:first').focus(); 2092 // $('.home-menu .menu li:eq('+$(this).parents('.sub-items').attr('data-n')+') a').focus(); 2093 } 2094 }); 2095 2096 2097 $('.home-menu ul.menu a').click(function (e) { 2098 e.preventDefault(); 2099 var i = $(this).parent().index() + 1; 2100 $('.home-menu .sub-items').hide(); 2101 $('.home-menu a.selected').removeClass('selected'); 2102 2103 $('.home-menu .sub-items:eq(' + i + ')').show(); 2104 $(this).addClass('selected') 2105 2106 $('.home-menu .sub-items:eq(' + i + ') ul a:first').focus(); 2107 2108 $('.home-menu .menu > li > a').attr('aria-expanded', false); 2109 $(this).attr('aria-expanded', true); 2110 }); 2111 2112 $('#overlay').click(function () { 2113 if (location.href.indexOf('#') > -1) { 2114 var tmp = location.href.split('#'); 2115 location.href = tmp[0] + '#'; 2116 } 2117 else { 2118 location.href = location.href + '#'; 2119 } 2120 }); 2121 2122 $('.home-icon-menu .item a').click(function (e) { 2123 // e.preventDefault(); 2124 var o = $(this).parent().parent().next('.sub-page'); 2125 2126 if ($(this).attr('href') == '#tematiche/circolazione-trasporti') { 2127 $.get('templates/pages/sala-stampa.html', function (r) { 2128 // o.html(r).show().css('height','auto'); 2129 o.html(r); 2130 o.css('height', o.children().outerHeight()); 2131 // $('#overlay').hide(); 2132 $('#overlay').removeClass('shown'); 2133 }); 2134 } 2135 else { 2136 $.get('templates/pages/vivere-ticino.html', function (r) { 2137 o.html(r); 2138 setTimeout(function () { 2139 o.css('height', o.children().outerHeight()); 2140 }, 500) 2141 // o.css('height', o.children().outerHeight()); 2142 $('#overlay').removeClass('shown'); 2143 }); 2144 } 2145 }); 2146 2147 // serve per gestire la scomparsa dell'overlay quando é stata cambiata pagina 2148 if ($('#overlay.shown.autohide').length) setTimeout(function () { $('#overlay').removeClass('shown'); }, 100); 2149 2150 2151 2152 $('.consigliere img').hover(function () { 2153 $(this).next('a').addClass('shown'); 2154 }, function () { 2155 $(this).next('a').removeClass('shown'); 2156 }); 2157} 2158/* Liste icone */ 2159var icone = { 2160 'elencoFILE': 'file-text-o', 2161 'elencoPDF': 'file-pdf-o', 2162 'elencoDOC': 'file-word-o', 2163 'elencoDOCX': 'file-word-o', 2164 'elencoXLS': 'file-excel-o', 2165 'elencoXLSX': 'file-excel-o', 2166 'elencoPPT': 'file-powerpoint-o', 2167 'elencoIMG': 'file-image-o', 2168 'elencoLinkInterno': 'angle-right', 2169 'elencoLinkEsterno': 'external-link', 2170 'elencoAudio': 'file-audio-o', 2171 'elencoRSS': 'rss-square', 2172 'elencoGoogleEarth': 'globe', 2173 'elencoDataPicker': 'calendar', 2174 'elencoHTML': 'code', 2175 'elencoZIP': 'file-archive-o', 2176 // 'elencozip': 'file-archive-o', 2177 'elencoDXF': 'pencil-square-o', 2178 'elencoDWG': 'pencil-square', 2179 'elencoGeoRSS': 'rss', 2180 'elencoSWF': 'star', 2181 'elencoVideo': 'file-video-o', 2182 'elencoQuadrato': 'square', 2183 'elencoCartella': 'folder-open', 2184 'elencoMappa': 'map-o', 2185 'elencoEService': 'list-alt', 2186 'elencoForm': 'pencil-square-o', 2187 'elencoFacebook': 'facebook', 2188 'elencoTelegram': 'telegram', 2189 'elencoLinkedin': 'linkedin-square', 2190 'elencoTwitter': 'twitter', 2191 'elencoInstagram': 'instagram', 2192 'elencoYoutube': 'youtube-play', 2193 'elencoWhatsapp': 'whatsapp', 2194 'elencoThreema': 'threema', 2195 'elencoTag': 'tag' 2196} 2197function initListTransformation() { 2198 2199 for(x=0;x<4;x++){ 2200 if($('li[class*=elenco] dfn').length){ 2201 $('li[class*=elenco] dfn').each(function (){ 2202 $(this).replaceWith('<span>'+$(this).html()+'</span>'); 2203 }); 2204 } 2205 else break; 2206 } 2207 2208 $('li[class*=elenco]').each(function () { 2209 var c = $(this).attr('class'); 2210 if (icone[c]) { 2211 if ( 2212 !$(this).parents('.big-icon').length 2213 // !$(this).parents('.risultatiTutti').length 2214 ) { 2215 2216 // var text = $(this).clone() //clone the element 2217 // .children() //select all the children 2218 // .remove() //remove all the children 2219 // .end() //again go back to selected element 2220 // .text(); 2221 // if(text){ 2222 // var tmp = $(this).children('a').append('<span>'+text+'</span>').clone(); 2223 // $(this).html(tmp); 2224 // } 2225 2226 2227 // var html = $(this).html(); 2228 // var end = (html.indexOf('</a>') + 4); 2229 // if(end < html.length){ 2230 2231 // var str = html.substring(end); 2232 // if(str.indexOf('<br>') == 0) str = str.substring(4); 2233 // else if(str.indexOf('<br/>') == 0) str = str.substring(5); 2234 // else if(str.indexOf('<br />') == 0) str = str.substring(6); 2235 2236 // var a = $(this).children('a').clone().append('<span>'+str+'</span>')//.prepend('|'); 2237 // $(this).html(a); 2238 // } 2239 2240 // small 2241 if ($(this).children().is('a')) { 2242 $(this).children('a').addClass('small-icon-link').prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2243 $(this).parent('ul').addClass('lista-icone'); 2244 // $(this).parents('ul').addClass('lista-icone'); 2245 } 2246 else { 2247 $(this).prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2248 } 2249 $(this).parent('ul').addClass('lista-icons small-incons'); 2250 2251 //console.log('here') 2252 } 2253 // else if($(this).parents('.box-default').length || (!$(this).parents('.box-default').length && $(this).parents('.big-icon').length)){ 2254 else { 2255 // big 2256 if ($(this).children().is('a')) { 2257 // var text = $(this).children('a').text(); 2258 // $(this).children('a').text(''); 2259 // $(this).children('a').append('<span>'+text+'</span>'); 2260 2261 // console.log('asdf') 2262 2263 var text = $(this).children('a') 2264 .clone() //clone the element 2265 .children() //select all the children 2266 .remove() //remove all the children 2267 .end() //again go back to selected element 2268 .text(); 2269 if ($(this).children('a').children('span').length) { 2270 text += '<span class="text">' + $(this).children('a').children('span').text() + '</span>'; 2271 } 2272 2273 var width = $(this).outerWidth() - 70; 2274 if (width < 0) { 2275 width = $(this).parents('.box-default').outerWidth() - 70 - 30; 2276 // width = $(this).parents('.frame-box-default').outerWidth() - 70 - 30; 2277 } 2278 var icon_type = ($(this).hasClass('elencoLinkEsterno') || $(this).hasClass('elencoLinkInterno')) ? 'link' : 'file'; 2279 2280 $(this).children('a').addClass('big-icon-link').html('<span class="i"><i class="fontac-' + icon_type + '"></i><i class="fa fa-' + icone[c] + ' appendice"></i></span><span class="t" style="width: ' + width + 'px">
2280' + text + '</span><span class="c"></span>'); 2281 2282 $(this).parents('ul').addClass('lista-icone big-list') 2283 } 2284 else { 2285 var icon_type = ($(this).hasClass('elencoLinkEsterno') || $(this).hasClass('elencoLinkInterno')) ? 'link' : 'file'; 2286 // $(this).prepend('<i class="'+c+'-big"></i>'); 2287 $(this).prepend('<span class="big-icon-link"><i class="fontac-' + icon_type + '"></i><i class="fa fa-' + icone[c] + ' appendice"></i></span>'); 2288 } 2289 $(this).parent('ul').attr('class', '').addClass('lista-icons big-incons'); 2290 } 2291 $(this).attr('class', ''); 2292 } 2293 $(this).addClass('no-list'); 2294 2295 }); 2296 2297 $('ul[class*=elenco][class!=elenco_scheda][class!=elencoQuadratoNero][class!=elencoGlossario][class!=\'elenco 1x\']').each(function () { 2298 var c = $(this).attr('class'); 2299 if (icone[c]) { 2300 if ( 2301 !$(this).parents('.big-icon').length 2302 ) { 2303 2304 2305 // var text = $(this).children('a') 2306 // .clone() //clone the element 2307 // .children() //select all the children 2308 // .remove() //remove all the children 2309 // .end() //again go back to selected element 2310 // .text(); 2311 // if($(this).children('a').children('span').length){ 2312 // text += '<span class="text">'+$(this).children('a').children('span').text()+'</span>'; 2313 // } 2314 2315 $(this).children('li').each(function () { 2316 var html = $(this).html(); 2317 var end = (html.indexOf('</a>') + 4); 2318 if (end < html.length) { 2319 2320 var str = html.substring(end); 2321 if (str.indexOf('<br>') == 0) str = str.substring(4); 2322 else if (str.indexOf('<br/>') == 0) str = str.substring(5); 2323 else if (str.indexOf('<br />') == 0) str = str.substring(6); 2324 2325 var a = $(this).children('a').clone().append('<span>' + str + '</span>'); 2326 $(this).html(a); 2327 } 2328 }); 2329 2330 // small 2331 if ($(this).children('li:eq(0)').children().is('a')) { 2332 $(this).children('li').each(function () { 2333 $(this).children('a').addClass('small-icon-link').prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2334 2335 if ($(this).find('ul').length) { 2336 $(this).find('ul').children('li').each(function () { 2337 if ($(this).children().is('a')) { 2338 $(this).children('a').addClass('small-icon-link').prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2339 } 2340 else { 2341 $(this).prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2342 } 2343 $(this).addClass('no-list'); 2344 }) 2345 } 2346 2347 }); 2348 $(this).addClass('lista-icone'); 2349 } 2350 else { 2351 $(this).children('li').each(function () { 2352 $(this).prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2353 2354 2355 if ($(this).find('ul').length) { 2356 $(this).find('ul').children('li').each(function () { 2357 if ($(this).children().is('a')) { 2358 $(this).children('a').addClass('small-icon-link').prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2359 } 2360 else { 2361 $(this).prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2362 } 2363 $(this).addClass('no-list'); 2364 }) 2365 } 2366 }); 2367 } 2368 $(this).attr('class', '').addClass('lista-icons small-incons'); 2369 } 2370 // else if($(this).parents('.box-default').length || (!$(this).parents('.box-default').length && $(this).parents('.big-icon').length)){ 2371 else { 2372 // big 2373 2374 if ($(this).children('li:eq(0)').children().is('a')) { 2375 var icon_type = ($(this).hasClass('elencoLinkEsterno') || $(this).hasClass('elencoLinkInterno')) ? 'link' : 'file'; 2376 $(this).children('li').each(function () { 2377 2378 var text = $(this).children('a') 2379 .clone() //clone the element 2380 .children() //select all the children 2381 .remove() //remove all the children 2382 .end() //again go back to selected element 2383 .text(); 2384 if ($(this).children('a').children('span').length) { 2385 text += '<span class="text">' + $(this).children('a').children('span').text() + '</span>'; 2386 } 2387 2388 $(this).children('a').addClass('big-icon-link').prepend('<i class="fontac-' + icon_type + '"></i><i class="fa fa-' + icone[c] + ' appendice"></i>'); 2389 2390 var i1 = $(this).children('a').children('.fontac-' + icon_type + ''); 2391 var i2 = $(this).children('a').children('.appendice'); 2392 2393 2394 2395 2396 2397 var width = $(this).outerWidth() - 70; 2398 if (width < 0) { 2399 width = $(this).parents('.box-default').outerWidth() - 70 - 30; 2400 // width = $(this).parents('.frame-box-default').outerWidth() - 70 - 30; 2401 } 2402 $(this).children('a').text(''); 2403 $(this).children('a').append('<span class="i"></span>'); 2404 $(this).children('a').children('span').append(i1).append(i2); 2405 $(this).children('a').append('<span class="t" style="width: ' + width + 'px">
2405' + text + '</span><span class="c"></span>'); 2406 2407 2408 }); 2409 $(this).addClass('lista-icone big-list') 2410 } 2411 else { 2412 // $(this).prepend('<i class="'+c+'-big"></i>'); 2413 var icon_type = ($(this).hasClass('elencoLinkEsterno') || $(this).hasClass('elencoLinkInterno')) ? 'link' : 'file'; 2414 $(this).children('li').each(function () { 2415 $(this).prepend('<span class="big-icon-link"><i class="fontac-' + icon_type + '"></i><i class="fa fa-' + icone[c] + ' appendice"></i></span>'); 2416 }); 2417 } 2418 $(this).attr('class', '').addClass('lista-icons big-incons'); 2419 } 2420 // $(this).attr('class', ''); 2421 } 2422 $(this).children('li').each(function () { 2423 $(this).addClass('no-list'); 2424 2425 if ($(this).children('a').hasClass('internal-link')) { 2426 $(this).children('a').removeClass('internal-link'); 2427 } 2428 }); 2429 }); 2430 2431 $('ul[class*=elenco][class!=elenco_scheda][class!=elencoQuadratoNero][class!=elencoGlossario][class!=\'elenco 1x\']').each(function () { 2432 var c = $(this).attr('class'); 2433 if (icone[c]) { 2434 if ( 2435 !$(this).parents('.big-icon').length 2436 ) { 2437 2438 2439 // var text = $(this).children('a') 2440 // .clone() //clone the element 2441 // .children() //select all the children 2442 // .remove() //remove all the children 2443 // .end() //again go back to selected element 2444 // .text(); 2445 // if($(this).children('a').children('span').length){ 2446 // text += '<span class="text">'+$(this).children('a').children('span').text()+'</span>'; 2447 // } 2448 2449 $(this).children('li').each(function () { 2450 var html = $(this).html(); 2451 var end = (html.indexOf('</a>') + 4); 2452 if (end < html.length) { 2453 2454 var str = html.substring(end); 2455 if (str.indexOf('<br>') == 0) str = str.substring(4); 2456 else if (str.indexOf('<br/>') == 0) str = str.substring(5); 2457 else if (str.indexOf('<br />') == 0) str = str.substring(6); 2458 2459 var a = $(this).children('a').clone().append('<span>' + str + '</span>'); 2460 $(this).html(a); 2461 } 2462 }); 2463 2464 // console.log($(this)) 2465 2466 // small 2467 if ($(this).children('li:eq(0)').children().is('a')) { 2468 $(this).children('li').each(function () { 2469 $(this).children('a').addClass('small-icon-link').prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2470 2471 }); 2472 $(this).addClass('lista-icone'); 2473 } 2474 else { 2475 $(this).children('li').each(function () { 2476 $(this).prepend('<i class="fa fa-' + icone[c] + '"></i>'); 2477 }); 2478 } 2479 $(this).attr('class', '').addClass('lista-icons small-incons'); 2480 2481 2482 2483 } 2484 // else if($(this).parents('.box-default').length || (!$(this).parents('.box-default').length && $(this).parents('.big-icon').length)){ 2485 else { 2486 // big 2487 2488 if ($(this).children('li:eq(0)').children().is('a')) { 2489 var icon_type = ($(this).hasClass('elencoLinkEsterno') || $(this).hasClass('elencoLinkInterno')) ? 'link' : 'file'; 2490 $(this).children('li').each(function () { 2491 2492 var text = $(this).children('a') 2493 .clone() //clone the element 2494 .children() //select all the children 2495 .remove() //remove all the children 2496 .end() //again go back to selected element 2497 .text(); 2498 if ($(this).children('a').children('span').length) { 2499 text += '<span class="text">' + $(this).children('a').children('span').text() + '</span>'; 2500 } 2501 2502 $(this).children('a').addClass('big-icon-link').prepend('<i class="fontac-' + icon_type + '"></i><i class="fa fa-' + icone[c] + ' appendice"></i>'); 2503 2504 var i1 = $(this).children('a').children('.fontac-' + icon_type + ''); 2505 var i2 = $(this).children('a').children('.appendice'); 2506 2507 2508 2509 2510 2511 var width = $(this).outerWidth() - 70; 2512 if (width < 0) { 2513 width = $(this).parents('.box-default').outerWidth() - 70 - 30; 2514 // width = $(this).parents('.frame-box-default').outerWidth() - 70 - 30; 2515 } 2516 $(this).children('a').text(''); 2517 $(this).children('a').append('<span class="i"></span>'); 2518 $(this).children('a').children('span').append(i1).append(i2); 2519 $(this).children('a').append('<span class="t" style="width: ' + width + 'px">
2519' + text + '</span><span class="c"></span>'); 2520 2521 2522 }); 2523 $(this).addClass('lista-icone big-list') 2524 } 2525 else { 2526 // $(this).prepend('<i class="'+c+'-big"></i>'); 2527 var icon_type = ($(this).hasClass('elencoLinkEsterno') || $(this).hasClass('elencoLinkInterno')) ? 'link' : 'file'; 2528 $(this).children('li').each(function () { 2529 $(this).prepend('<span class="big-icon-link"><i class="fontac-' + icon_type + '"></i><i class="fa fa-' + icone[c] + ' appendice"></i></span>'); 2530 }); 2531 } 2532 $(this).attr('class', '').addClass('lista-icons big-incons'); 2533 } 2534 // $(this).attr('class', ''); 2535 } 2536 $(this).children('li').each(function () { 2537 $(this).addClass('no-list'); 2538 2539 if ($(this).children('a').hasClass('internal-link')) { 2540 $(this).children('a').removeClass('internal-link'); 2541 } 2542 }); 2543 }); 2544} 2545 2546/* Irfaq */ 2547function initIrfaq() { 2548 function irfaqOpen(e) { 2549 e.preventDefault(); 2550 2551 if ($(this).parent().parent().is('[class*=irfaq]')) { 2552 $(this).parent().parent().find('.panel-heading > a.collapsed').trigger('click').removeClass('collapsed'); 2553 } 2554 else { 2555 $('.panel-heading > a.collapsed').trigger('click').removeClass('collapsed'); 2556 } 2557 } 2558 function irfaqClose(e) { 2559 e.preventDefault(); 2560 2561 if ($(this).parent().parent().is('[class*=irfaq]')) { 2562 $(this).parent().parent().find('.panel-heading > a[class=""]').trigger('click'); 2563 } 2564 else { 2565 $('.panel-heading > a[class=""]').trigger('click'); 2566 } 2567 2568 } 2569 $('.irfaq-open').click(irfaqOpen); 2570 $('.irfa-close').click(irfaqClose); 2571} 2572/* Lightbox */ 2573function initBootstrapLightbox(){ 2574 function init(){ 2575 2576 var html = ''; 2577 var n = 1; 2578 $('a.cboxElement').each(function (){ 2579 var id = 'myModal'+n; 2580 $(this).attr('data-toggle', 'modal').attr('data-target', '#'+id); 2581 2582 // if($(this).hasClass('iframe')){ 2583 var href = $(this).attr('href'); 2584 $(this).attr('href', '#').attr('data-src', href); 2585 content = ''; 2586 title = $(this).text(); 2587 // } 2588 2589 html += generateModal(id, title, content); 2590 $(this).click(open); 2591 n++; 2592 }); 2593 $('body').append(html); 2594 } 2595 function generateModal(id, title, content){ 2596 var html = '<div class="modal fade" id="'+id+'" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">'; 2597 html += '<div class="modal-dialog modal-lg" role="document">'; 2598 html += '<div class="modal-content">'; 2599 html += '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button><h4 class="modal-title" id="myModalLabel">'+title+'</h4></div>'; 2600 html += '<div class="modal-body">'+content+'</div>'; 2601 html += '</div></div></div>'; 2602 return html; 2603 } 2604 function open(e){ 2605 // e.preventDefault(); 2606 2607 var href = $(this).attr('href'); 2608 if($(this).hasClass('iframe')){ 2609 href = $(this).attr('data-src');
2610 $(''+$(this).attr('data-target')+' .modal-body').html('<iframe src="'+href+'" style="display: 1none; width: 100%; height: 480px; border: 0"></iframe>'); 2611 } 2612 } 2613 init(); 2614} 2615/* Maps */ 2616function initMap() { 2617 $('map area').hover(function () { 2618 var p = $(this).attr('coords').split(','); 2619 var base_p = $('#mappa-traffico').position(); 2620 $('.map-tooltip').css({ top: base_p.top + parseInt(p[1]) + 'px', left: base_p.left + parseInt(p[0]) + 20 + 'px' }).show(); 2621 $('.map-tooltip .' + $(this).attr('id')).show(); 2622 2623 }, function () { 2624 $('.map-tooltip, .map-tooltip .inner').hide(); 2625 }); 2626} 2627function initMap2() { 2628 2629 var hover_color = '#C33'; 2630 var positions = {}; 2631 2632 function init() { 2633 $('#mappa-radar').css('position', 'relative'); 2634 initCantieri(); 2635 initRadar(); 2636 //initFancybox(); 2637 } 2638 2639 function initCantieri() { 2640 function mouseover() { 2641 d3.select(this).select('.st19').transition().attr('r', 12).style('fill', hover_color); 2642 d3.select(this).select('.st20').transition().attr('r', 12).style('stroke', hover_color); 2643 2644 d3.select(this).select('.cls-16').transition().attr('r', 12).style('fill', hover_color); 2645 d3.select(this).select('.cls-17').transition().attr('r', 12).style('stroke', hover_color); 2646 2647 showTooltip($(this)); 2648 } 2649 function mouseout() { 2650 d3.select(this).select('.st19').transition().attr('r', 11).style('fill', '#2F4699'); 2651 d3.select(this).select('.st20').transition().attr('r', 11).style('stroke', '#2F4699'); 2652 2653 d3.select(this).select('.cls-16').transition().attr('r', 11).style('fill', '#2F4699'); 2654 d3.select(this).select('.cls-17').transition().attr('r', 11).style('stroke', '#2F4699'); 2655 2656 hideTooltip(); 2657 } 2658 function click() { 2659 var id = $(this).attr('id').substring(1); 2660 var link = $('.map-tooltip2 .e' + id + '').attr('data-link'); 2661 window.open(link); 2662 } 2663 2664 d3.select('svg').selectAll('#Cantieri > g').on('mouseover', mouseover); 2665 d3.select('svg').selectAll('#Cantieri > g').on('mouseout', mouseout); 2666 d3.select('svg').selectAll('#Cantieri > g').on('click', click); 2667 } 2668 2669 function initRadar() { 2670 function mouseover() { 2671 d3.select(this).select('circle').transition().attr('r', 10).style('fill', hover_color); 2672 d3.select(this).select('text').transition().style('fill', hover_color); 2673 2674 showTooltip($(this)); 2675 } 2676 function mouseout() { 2677 d3.select(this).select('circle').transition().attr('r', 6.9).style('fill', '#2F4699'); 2678 d3.select(this).select('text').transition().style('fill', '#2F4699'); 2679 2680 hideTooltip(); 2681 } 2682 function click() { 2683 var id = $(this).attr('id').substring(1); 2684 $('.map-tooltip2 .e' + id + ' a').trigger('click'); 2685 } 2686 2687 d3.select('svg').selectAll('#Radar > g').on('mouseover', mouseover); 2688 d3.select('svg').selectAll('#Radar > g').on('mouseout', mouseout); 2689 d3.select('svg').selectAll('#Radar > g').on('click', click); 2690 } 2691 2692 function showTooltip(o) { 2693 var d = o.attr('data-p'); 2694 var id = o.attr('id').substring(1); 2695 2696 // if(!positions[id]){ 2697 // var p = o.children('circle').position(); 2698 // positions[id] = { 2699 // top: p.top + 20, 2700 // left: ((d == 'r') ? (p.left + 20) : (p.left - 250)) 2701 // }; 2702 // } 2703 2704 // if (!positions[id]) { 2705 var p = o.children('circle').offset(); 2706 var mp = $('#mappa-radar').offset(); 2707 positions[id] = { 2708 top: p.top + 20 - mp.top, 2709 left: ((d == 'r') ? (p.left + 20 - mp.left) : (p.left - 250 - mp.left)) 2710 }; 2711 // } 2712 2713 2714 var pp = o.children('circle').offset(); 2715 2716 // console.log(positions[id]); 2717 // console.log(pp) 2718 // console.log($('#mappa-radar').position()) 2719 // console.log($('#mappa-radar').offset()) 2720 2721 $('.map-tooltip').css({ top: p.top + 40, left: p.left + 10 }).show(); 2722 $('.map-tooltip2').css({ top: positions[id].top, left: positions[id].left }).show(); 2723 $('.map-tooltip2 .e' + id).show(); 2724 } 2725 2726 function hideTooltip() { 2727 $('.map-tooltip2, .map-tooltip2 > div').hide(); 2728 } 2729 2730 function initFancybox() { 2731 $('.fancybox').fancybox({ 2732 helpers: { 2733 title: { 2734 type: 'inside' 2735 }, 2736 overlay: { 2737 speedOut: 0 2738 } 2739 } 2740 }); 2741 } 2742 2743 init(); 2744} 2745function initMap3() { 2746 $.getScript('https://www3.ti.ch/DT/dc/uca/temi/corsi_acqua/jquery.maphilight.js', function () { 2747 $('.map').maphilight(); 2748 }); 2749} 2750function initMenuSpatola() { 2751 var breadcrumb_separator = '<span><i class="fa fa-angle-right"></i></span>';
2752 function init() { 2753 $(window).on('hashchange', hashChanged); 2754 hashChanged(true); 2755 } 2756 function hashChanged(first) { 2757 var h = location.hash.substring(1); 2758 if (h) { 2759 if (h.indexOf('/') == -1) { 2760 var a = $('.menu-spatola a[href$="#' + h + '"]'); 2761 selectLv1(a, h); 2762 } 2763 else { 2764 var a = $('.menu-spatola a[href$="#' + h + '"]'); 2765 if (first) { 2766 2767 var tmp = h.split('/'); 2768 2769 if(tmp.length > 0){ 2770 b = $('.menu-spatola a[href$="#' + tmp[0] + '"]'); 2771 selectLv1(b, tmp[0]); 2772 } 2773 if(tmp.length > 1){ 2774 b = $('.menu-spatola a[href$="#' + tmp[0] + '/' + tmp[1] + '"]'); 2775 selectLv2(b, tmp[0] + '/' + tmp[1]); 2776 } 2777 if(tmp.length > 2){ 2778 b = $('.menu-spatola a[href$="#' + tmp[0] + '/' + tmp[1] + '/' + tmp[2] + '"]'); 2779 selectLv3(b, h); 2780 } 2781 } 2782 else{ 2783 var tmp = h.split('/'); 2784 2785 if(tmp.length > 2){ 2786 b = $('.menu-spatola a[href$="#' + tmp[0] + '/' + tmp[1] + '/' + tmp[2] + '"]'); 2787 selectLv3(b, h); 2788 } 2789 else if(tmp.length > 1){ 2790 b = $('.menu-spatola a[href$="#' + tmp[0] + '/' + tmp[1] + '"]'); 2791 selectLv2(b, tmp[0] + '/' + tmp[1]); 2792 } 2793 else if(tmp.length > 0){ 2794 b = $('.menu-spatola a[href$="#' + tmp[0] + '"]'); 2795 selectLv1(b, tmp[0]); 2796 } 2797 } 2798 } 2799 } 2800 else { 2801 $('.menu-spatola .active').removeClass('active'); 2802 $('.menu-spatola').attr('class', 'menu-spatola clearfix'); 2803 2804 /* Breadcrumbs */ 2805 $('.breadcrumb .lv2-b').prev().remove(); 2806 $('.breadcrumb .lv3-b').prev().remove(); 2807 $('.breadcrumb .lv2-b, .breadcrumb .lv3-b').remove(); 2808 } 2809 2810 if(typeof(first) == 'undefined' || h){ 2811 // var top = (($('main h1:first').length) ? $('main h1:first').offset().top : $('.tx-tich-menu-spatola').offset().top) - 10 2812 var top = $('.tx-tich-menu-spatola .breadcrumb').next().offset().top - 10 2813 /*if($(window).scrollTop() > top)*/ $('html').animate({scrollTop: top}, 200) 2814 } 2815 } 2816 function selectLv1(a, h) { 2817 $('.menu-spatola').attr('class', 'menu-spatola clearfix lv2-opened'); 2818 if ($('.lv2 a.active').length) $('.lv2 a.active').removeClass('active'); 2819 if ($('.lv3 a.active').length) $('.lv3 a.active').removeClass('active'); 2820 2821 /* Breadcrumbs */ 2822 if ($('.breadcrumb .lv3-b').length) { 2823 $('.breadcrumb .lv3-b').prev().remove(); 2824 $('.breadcrumb .lv3-b').remove(); 2825 } 2826 if ($('.breadcrumb .lv4-b').length) { 2827 $('.breadcrumb .lv4-b').prev().remove(); 2828 $('.breadcrumb .lv4-b').remove(); 2829 } 2830 $('.breadcrumb .root').removeClass('disabled'); 2831 2832 if (!a.hasClass('active')) { 2833 2834 if ($('.lv2 .submenu.active').length) $('.lv2 .submenu.active').removeClass('active'); 2835 $('.lv2 .submenu[data-id=' + h + ']').addClass('active'); 2836 2837 if ($('.lv1 a.active').length) $('.lv1 a.active').removeClass('active'); 2838 a.addClass('active'); 2839 2840 /* Breadcrumbs */ 2841 // Lv2 2842 $('.breadcrumb .disabled').removeClass('disabled') 2843 var link = '<a href="'+$('a[href$="#' + h.split('/')[0] + '"]').attr('href')+'" class="lv2-b disabled">'+a.children('span').text()+'</a>'; 2844 if ($('.breadcrumb .lv2-b').length) $('.breadcrumb .lv2-b').replaceWith(link); 2845 else $('.breadcrumb').append(breadcrumb_separator + link); 2846 } 2847 else $('.breadcrumb .lv2-b').addClass('disabled') 2848 } 2849 function selectLv2(a, h) { 2850 if (!a.hasClass('active')) { 2851 $('.menu-spatola').attr('class', 'menu-spatola clearfix lv3-opened'); 2852 $('.lv3 .submenu.active').removeClass('active'); 2853 $('.lv3 .submenu[data-id="' + h + '"]').addClass('active'); 2854 2855 if ($('.lv2 a.active').length) $('.lv2 a.active').removeClass('active'); 2856 if ($('.lv3 a.active').length) $('.lv3 a.active').removeClass('active'); 2857 a.addClass('active'); 2858 2859 /* Breadcrumbs */ 2860 $('.breadcrumb .disabled').removeClass('disabled') 2861 var link = '<a href="'+a.attr('href')+'" class="lv3-b disabled">' +a.children('span').text()+ '</a>'; 2862 if ($('.breadcrumb .lv3-b').length) $('.breadcrumb .lv3-b').replaceWith(link); 2863 if ($('.breadcrumb .lv4-b').length){ 2864 $('.breadcrumb .lv4-b').prev().remove(); 2865 $('.breadcrumb .lv4-b').remove(); 2866 } 2867 else $('.breadcrumb').append(breadcrumb_separator + link); 2868 } 2869 else $('.breadcrumb .lv3-b').addClass('disabled') 2870 } 2871 function selectLv3(a, h) { 2872 if (!a.hasClass('active')) { 2873 $('.menu-spatola').attr('class', 'menu-spatola clearfix lv4-opened'); 2874 $('.lv4 .submenu.active').removeClass('active'); 2875 $('.lv4 .submenu[data-id="' + h + '"]').addClass('active'); 2876 2877 if ($('.lv3 a.active').length) $('.lv3 a.active').removeClass('active'); 2878 a.addClass('active'); 2879 2880 /* Breadcrumbs */ 2881 $('.breadcrumb .disabled').removeClass('disabled') 2882 var link = '<a href="'+a.attr('href')+'" class="lv4-b disabled">' +a.children('span').text()+ '</a>'; 2883 if ($('.breadcrumb .lv4-b').length) $('.breadcrumb .lv4-b').replaceWith(link); 2884 else $('.breadcrumb').append(breadcrumb_separator + link); 2885 } 2886 else $('.breadcrumb .lv4-b').addClass('disabled') 2887 } 2888 init(); 2889} 2890/* Nav */ 2891function initNav() { 2892 var timeoutId1; 2893 var timeoutId2; 2894 /*var timeoutId3;*/ 2895 jQuery("#navPrimoLivello1").hover(function () { 2896 jQuery("#navPrimoLivello1").css('background-color', '#ffffff'); 2897 2898 if (jQuery('#visualizza1').css("display") == 'none') { 2899 if (!timeoutId1) { 2900 2901 timeoutId1 = window.setTimeout(function () { 2902 if (timeoutId1 > 0) { 2903 timeoutId1 = null; // EDIT: added this line 2904 //jQuery("#visualizza1").slideDown('fast'); 2905 jQuery('#visualizza1').css("display", "block"); 2906 } 2907 }, 500); 2908 } 2909 } 2910 }, function () { 2911 timeoutId1 = 0; 2912 2913 jQuery('#visualizza1').css("display", "none"); 2914 jQuery("#navPrimoLivello1").css('background-color', '#eeeeee'); 2915 2916 }); 2917 2918 2919 jQuery("#navPrimoLivello2").hover(function () { 2920 jQuery("#navPrimoLivello2").css('background-color', '#ffffff'); 2921 if (!timeoutId2) { 2922 2923 timeoutId2 = window.setTimeout(function () { 2924 if (timeoutId2 > 0) { 2925 timeoutId2 = null; // EDIT: added this line 2926 //jQuery("#visualizza2").slideDown('fast'); 2927 jQuery('#visualizza2').css("display", "block"); 2928 } 2929 }, 500); 2930 2931 } 2932 }, function () { 2933 timeoutId2 = 0; 2934 2935 jQuery('#visualizza2').css("display", "none"); 2936 jQuery("#navPrimoLivello2").css('background-color', '#eeeeee'); 2937 2938 }); 2939} 2940/* Overlay */ 2941function showOverlay(o) { 2942 $('body').append('<div class="overlay-close"><div class="inner"><a href="#" title="Chiudi" aria-label="Chiudi"><i class="fa fa-times" aria-hidden="true"></i></a></div></div><div class="overlay"></div>'); 2943 $('.overlay-close').click(function (e) { 2944 e.preventDefault(); 2945 hideOverlay(); 2946 }); 2947 $(window).on('keydown', function (e){ 2948 if(e.keyCode == 27){ 2949 $('.overlay-close a').trigger('click'); 2950 } 2951 }) 2952} 2953function hideOverlay() { 2954 $('.overlay-close, .overlay, #organigramma, .overlay-content').remove(); 2955 $('header .right a.opened').removeClass('opened'); 2956 if(overlayOpener){
2957 overlayOpener.focus(); 2958 overlayOpener = false; 2959 } 2960 2961 if($('.tx-tichwowza-pi2 object').length){ 2962 $('.tx-tichwowza-pi2 object').css('visibility', 'visible'); 2963 } 2964} 2965function resizeOverlay() { 2966 if($(".background").outerHeight() > 50) var h = $(".background").outerHeight() + $(".footer").outerHeight(); 2967 else var h = $("#maincontent").outerHeight() + $(".footer").outerHeight() + 136; 2968 2969 if ($('body.parallax-template').length) { 2970 h += $('body > .co-n1, body > .box-default, body > .frame-box-default').outerHeight(); 2971 } 2972 else if(windowHeight() - $('header.new').outerHeight() > h){ 2973 h = windowHeight() - $('header.new').outerHeight(); 2974 } 2975 2976 $('.overlay').css({ height: h }).show(); 2977} 2978/* Parallax */ 2979function initParallaxPage() { 2980 2981 var items = []; 2982 var h = 0; 2983 function init() { 2984 h = windowHeight(); 2985 2986 setTimeout(function () { 2987 items.push({ 2988 from: 0, 2989 to: $('.box-default .scuola-parallax .box-1, .frame-box-default .scuola-parallax .box-1').outerHeight() 2990 }); 2991 items.push({ 2992 from: $('.box-4').offset().top - h, 2993 to: $('.box-4').offset().top + $('.box-4').outerHeight() - h 2994 }); 2995 2996 items.push({ 2997 // from: $('.box-3').offset().top - h, 2998 from: 0, 2999 to: $('.box-3').offset().top + $('.box-3').outerHeight() - h 3000 }); 3001 3002 3003 3004 $(window).scroll(scroll); 3005 3006 }, 200); 3007 3008 initSlider(); 3009 3010 setTimeout(function () { $('.box-1 .img1').addClass('shown'); }, 300); 3011 setTimeout(function () { $('.box-1 .triangle').addClass('opened'); }, 500); 3012 setTimeout(function () { $('.box-1 .bar').addClass('opened'); }, 1000); 3013 } 3014 function scroll(e) { 3015 var v = $(window).scrollTop(); 3016 3017 if (v >= 0 && v <= 500) { 3018 $('.box-default .scuola-parallax .box-1 .img1').css({ 'background-position': '0px ' + (items[0].from - (v / 4)) + 'px' }) 3019 $('.frame-box-default .scuola-parallax .box-1 .img1').css({ 'background-position': '0px ' + (items[0].from - (v / 4)) + 'px' }) 3020 } 3021 else if (v >= items[1].from) { 3022 var val = (items[1].from - v) / 8; 3023 $('.box-default .scuola-parallax .box-4').css({ 'background-position': '0px ' + val + 'px' }) 3024 $('.frame-box-default .scuola-parallax .box-4').css({ 'background-position': '0px ' + val + 'px' }) 3025 } 3026 3027 3028 if (v >= items[2].from <= items[2].to) { 3029 var val = (items[2].from - v) / 14; 3030 $('.box-default .scuola-parallax .box-3 .circle').css({ 'background-position': 'center ' + val + 'px' }) 3031 $('.frame-box-default .scuola-parallax .box-3 .circle').css({ 'background-position': 'center ' + val + 'px' }) 3032 } 3033 } 3034 function initSlider() { 3035 var owl = $("#owl-demo") 3036 3037 owl.owlCarousel({ 3038 navigation: false, 3039 mouseDrag: false, 3040 touchDrag: false, 3041 responsiveClass: true, 3042 responsive: { 3043 0: { 3044 items: 1, 3045 // nav:true 3046 }, 3047 600: { 3048 items: 4, 3049 // nav:false 3050 }, 3051 1400: { 3052 items: 5, 3053 // nav:true, 3054 // loop:false 3055 } 3056 } 3057 }); 3058 3059 $(".box-2 .next").click(function (e) { 3060 e.preventDefault(); 3061 owl.trigger('next.owl.carousel'); 3062 }); 3063 3064 $(".box-2 .prev").click(function (e) { 3065 e.preventDefault(); 3066 owl.trigger('prev.owl.carousel'); 3067 }); 3068 3069 // $("#owl-demo a.fancybox").fancybox(); 3070 } 3071 init(); 3072} 3073function initSpecialTimeline() { 3074 $('.timeline-container > .frame-box-default > .row > .col-xs-12 > a').remove(); 3075 var html = ''; 3076 var first = true; 3077 $('.timeline-container > .frame-box-default > .row > .col-xs-12 .frame-box-default').each(function () { 3078 if (first) { 3079 html += $(this).html(); 3080 html = html.replace('</ul>', ''); 3081 first = false;
3082 } 3083 else html += $(this).html(); 3084 }); 3085 $('.timeline-container > .frame-box-default > .row > .col-xs-12').html(html); 3086 $('.timeline-container').addClass('shown'); 3087 3088 3089 /* V2 */ 3090 3091 var start = '<ul class="timeline-new"><li class="timeline-title">::title::</li>'; 3092 var entryA = '<li><div class="timeline-badge primary"><a><img src="/typo3conf/ext/user_archivio_votazioni/images/circle.png" alt=""></a></div><div class="timeline-panel"><div class="timeline-body"><h3 class="bar">::title::</h3>::text::</div></div></li>'; 3093 var entryB = '<li class="timeline-inverted"><div class="timeline-badge primary"><a><img src="/typo3conf/ext/user_archivio_votazioni/images/circle.png" alt=""></a></div><div class="timeline-panel"><div class="timeline-body"><h3 class="bar">::title::</h3>::text::</div></div></li>'; 3094 var end = '<li class="clearfix" style="float: none;"></li></ul>'; 3095 3096 3097 // $('.timeline-container2') 3098 $('.timeline-container2 a:not([href])').remove(); 3099 $('.timeline-container2 > .frame-box-default > .csc-header').remove(); 3100 3101 $('.timeline-container2').each(function () { 3102 var first = true; 3103 var html = ''; 3104 var n = 0; 3105 $(this).find('> .frame-box-default > .row > .col-xs-12 > .frame-box-default').each(function () { 3106 if (first) { 3107 html += start.replace('::title::', $(this).text()); 3108 first = false; 3109 } 3110 else { 3111 var entry = (n % 2 == 0) ? entryA : entryB; 3112 var t = $(this).find('h3').text() ? $(this).find('h3').text() : ' '; 3113 entry = entry.replace('::title::', t); 3114 entry = entry.replace('::text::', $(this).find('.ce-bodytext').html()); 3115 3116 html += entry; 3117 n++; 3118 } 3119 }); 3120 html += end; 3121 $(this).find('> .frame-box-default > .row > .col-xs-12').html(html); 3122 }); 3123 3124 3125 // var first = true; 3126 // var html = ''; 3127 // var n = 0; 3128 3129 // $('.timeline-container2 > .frame-box-default > .row > .col-xs-12 > .frame-box-default').each(function (){ 3130 // if(first){ 3131 // html += start.replace('::title::', $(this).text()); 3132 // first = false; 3133 // } 3134 // else{ 3135 // // console.log($(this).find('.csc-header').text()); 3136 // // console.log($(this).find('.rte').html()); 3137 3138 // var entry = (n % 2 == 0) ? entryA : entryB; 3139 // entry = entry.replace('::title::', $(this).find('.csc-header').text()); 3140 // entry = entry.replace('::text::', $(this).find('.rte').html()); 3141 3142 // html += entry; 3143 // n++; 3144 // } 3145 // }); 3146 3147 // html += end; 3148 // $('.timeline-container2 > .frame-box-default > .row > .col-xs-12').html(html); 3149} 3150function initSpecialTimelineUAPCD() { 3151 var start = '<ul class="timeline-v2">'; 3152 var timeline_title = '<li class="timeline-title">::title::</li>'; 3153 var entryA = '<li><div class="timeline-badge primary"><a><img src="/typo3conf/ext/tich_gen_votazioni/Resources/Public/Images/circle.png" alt=""></a></div><div class="timeline-panel"><div class="timeline-body"><h3>::title::</h3>::image::<div class="text">::text::</div></div></div></li>'; 3154 3155 3156 var entryB = '<li class="timeline-inverted"><div class="timeline-badge primary"><a><img src="/typo3conf/ext/tich_gen_votazioni/Resources/Public/Images/circle.png" alt=""></a></div><div class="timeline-panel"><div class="timeline-body"><h3>::title::</h3>::image::<div class="text">::text::</div></div></li>'; 3157 var end = '<li class="clearfix" style="float: none;"></li></ul>'; 3158 3159 var table_row = '<div class="timeline-row"><div class="timeline-title-cell">::title::</div><div class="timeline-text-cell">::text::</div></div>' 3160 3161 $('.timeline-uapcd-container a:not([href])').remove(); 3162 // $('.timeline-uapcd-container > .frame-box-default > .csc-header').remove(); 3163 3164 $('.timeline-uapcd-container').each(function () { 3165 var first = true; 3166 var html = ''; 3167 var n = 0; 3168 $(this).find('> .frame-box-default > .row > .col-xs-12 > .frame-box-default').each(function () { 3169 if(first){ 3170 html += start 3171 var t = $(this).html() 3172 if(RegExp(/<h[0-9]/).test(t)){ 3173 t = t.replace(/\n/gi, '') 3174 var tmp = t.match(/<h[0-9].*?>(.*?)<\/h[0-9]>/) 3175 if(tmp) html += timeline_title.replace('::title::', tmp[1].trim()); 3176 } 3177 first = false 3178 } 3179 else{ 3180 var entry = (n % 2 == 0) ? entryA : entryB; 3181 3182 // Image 3183 if($(this).find('figure.image img').length){ 3184 var image = $(this).find('figure.image img').attr('src') 3185 entry = entry.replace('::image::', '<div class="image"><img src="'+image+'"></div>'); 3186 } 3187 else entry = entry.replace('::image::', ''); 3188 3189 // Title 3190 var t = $(this).find('h2').text() ? ($(this).find('h2').text()).trim() : ' '; 3191 entry = entry.replace('::title::', t); 3192 3193 // Content 3194 var contents = $(this).find('.ce-bodytext').html().split('<hr>') 3195 var table = '' 3196 for(x in contents){ 3197 var p = contents[x].indexOf('</h3>') 3198 var title = contents[x].substring(4, p) 3199 var text = contents[x].substring(p+5) 3200 table += table_row.replace('::title::', title).replace('::text::', text) 3201 } 3202 entry = entry.replace('::text::', table); 3203 3204 html += entry; 3205 n++; 3206 } 3207 }); 3208 html += end; 3209 $(this).find('> .frame-box-default > .row > .col-xs-12').html(html); 3210 }); 3211} 3212function initDFEInnerForm(){ 3213 var formData = {}; 3214 var events_dates = { 3215 'chiasso': new Date(2017, 8, 22, 0, 0, 0, 0), 3216 'bellinzona': new Date(2017, 9, 13, 0, 0, 0, 0), 3217 'lugano': new Date(2018, 1, 22, 0, 0, 0, 0), 3218 'locarno': new Date(2018, 3, 19, 0, 0, 0, 0) 3219 } 3220
3221 function init(){ 3222 3223 $.getJSON('/fileadmin/DFE/DE-EVENTI/check_max.php', {}, function (r){ 3224 if(r){ 3225 formData = r; 3226 for(x in r){ 3227 $('#dfe-inner-form .row.titles .col-xs-3[data-id='+x+']').show(); 3228 } 3229 3230 $('#dfe-inner-form .row.titles .col-xs-3:not(:visible)').addClass('disabled').show(); 3231 3232 var n = 0; 3233 $('#dfe-inner-form .row.titles .col-xs-3:visible').each(function (){ 3234 $(this).attr('data-n', n); 3235 n++; 3236 }); 3237 3238 var t = new Date(); 3239 for(x in events_dates){ 3240 if(events_dates[x] <= t) { 3241 $('#dfe-inner-form .row.titles .col-xs-3[data-id='+x+']').addClass('disabled').children('p').html('Evento concluso.'); 3242 } 3243 } 3244 } 3245 }); 3246 3247 $('#dfe-inner-form .titles > div > a').click(selectDate); 3248 $('#dfe-inner-form button').click(submit); 3249 $('#dfe-inner-form .captcha a').click(refreshCaptcha); 3250 3251 $('#dfe-inner-form .inner i.closeform').click(function (){ 3252 $('#dfe-inner-form .titles a i').removeClass('hidden'); 3253 $('#dfe-inner-form .inner').css("display","none"); 3254 }); 3255 3256 // $('#dfe-inner-form button').contextmenu(function (){ 3257 // $(this).parent().addClass('hidden'); 3258 // $(this).parent().prev().removeClass('hidden'); 3259 // }); 3260 } 3261 function selectDate(e){ 3262 e.preventDefault(); 3263 3264 if(!$(this).parent().hasClass('disabled')){ 3265 var index = $(this).parent().attr('data-n'); 3266 var city = $(this).children('b').text().toLowerCase(); 3267 3268 3269 $('#dfe-inner-form .inner').attr('class', 'inner i'+index).show(); 3270 $('#dfe-inner-form .inner h3 span').text(capitalizeFirstLetter(city)); 3271 $('#dfe-inner-form input[name=luogo]').val(city); 3272 3273 3274 $('#dfe-inner-form .form').removeClass('hidden'); 3275 $('#dfe-inner-form .thankyou').addClass('hidden'); 3276 3277 $('#dfe-inner-form .titles a i').removeClass('hidden'); 3278 $(e.currentTarget).find('i').addClass("hidden"); 3279 3280 if(formData[city] == 1){ 3281 $('#dfe-inner-form .form .person2').addClass('hidden'); 3282 $('#dfe-inner-form .form .person2 input').val(''); 3283 $('#dfe-inner-form .form h5 span').text('(ultimo posto disponibile)'); 3284 } 3285 else{ 3286 $('#dfe-inner-form .form .person2').removeClass('hidden'); 3287 3288 $('#dfe-inner-form .form h5 span').text('(massimo 2 per azienda)'); 3289 } 3290 } 3291 } 3292 3293 3294 function submit(){ 3295 var error = false; 3296 3297 if(!checkField('azienda')) error = true; 3298 if(!checkField('nap_luogo')) error = true; 3299 if(!checkField('telefono')) error = true; 3300 3301 3302 if(!checkField('p1_nome')) error = true; 3303 if(!checkField('p1_cognome')) error = true; 3304 if(!checkField('p1_email')) error = true; 3305 3306 var p2 = false; 3307 if($('#dfe-inner-form input[name=p2_nome]').val() || $('#dfe-inner-form input[name=p2_cognome]').val() || $('#dfe-inner-form input[name=p2_email]').val()){ 3308 if(!checkField('p2_nome')) error = true; 3309 if(!checkField('p2_cognome')) error = true; 3310 if(!checkField('p2_email')) error = true; 3311 p2 = true; 3312 } 3313 else{ 3314 $('#dfe-inner-form input[name=p2_nome], #dfe-inner-form input[name=p2_cognome], #dfe-inner-form input[name=p2_email]').removeClass('form-error'); 3315 } 3316 3317 // Captcha! 3318 if(!checkField('captcha')) error = true; 3319 // else{ 3320 3321 // } 3322 3323 if(!error){ 3324 var data = { 3325 luogo: $('#dfe-inner-form input[name=luogo]').val(), 3326 azienda: $('#dfe-inner-form input[name=azienda]').val(), 3327 nap_luogo: $('#dfe-inner-form input[name=nap_luogo]').val(), 3328 telefono: $('#dfe-inner-form input[name=telefono]').val(), 3329 p1_nome: $('#dfe-inner-form input[name=p1_nome]').val(), 3330 p1_cognome: $('#dfe-inner-form input[name=p1_cognome]').val(), 3331 p1_email: $('#dfe-inner-form input[name=p1_email]').val(), 3332 captcha: $('#dfe-inner-form input[name=captcha]').val() 3333 } 3334 if(p2){ 3335 data.p2_nome = $('#dfe-inner-form input[name=p2_nome]').val(); 3336 data.p2_cognome = $('#dfe-inner-form input[name=p2_cognome]').val(); 3337 data.p2_email = $('#dfe-inner-form input[name=p2_email]').val(); 3338 } 3339 3340 3341 $.post('/fileadmin/DFE/DE-EVENTI/send.php', data, function (r){ 3342 if(r == 'ok'){ 3343 $('#dfe-inner-form input[name=luogo]').val('').removeClass('form-error'); 3344 $('#dfe-inner-form input[name=azienda]').val('').removeClass('form-error'); 3345 $('#dfe-inner-form input[name=nap_luogo]').val('').removeClass('form-error'); 3346 $('#dfe-inner-form input[name=telefono]').val('').removeClass('form-error'); 3347 $('#dfe-inner-form input[name=p1_nome]').val('').removeClass('form-error'); 3348 $('#dfe-inner-form input[name=p1_cognome]').val('').removeClass('form-error'); 3349 $('#dfe-inner-form input[name=p1_email]').val('').removeClass('form-error'); 3350 $('#dfe-inner-form input[name=captcha]').val('').removeClass('form-error'); 3351 $('#dfe-inner-form input[name=p2_nome]').val('').removeClass('form-error'); 3352 $('#dfe-inner-form input[name=p2_cognome]').val('').removeClass('form-error'); 3353 $('#dfe-inner-form input[name=p2_email]').val('').removeClass('form-error'); 3354 3355 $('#dfe-inner-form .form').addClass('hidden'); 3356 $('#dfe-inner-form .thankyou').removeClass('hidden'); 3357 } 3358 else if(r == 'captcha'){ 3359 $('#dfe-inner-form input[name=captcha]').addClass('error-form').val(''); 3360 3361 var src = $('#dfe-inner-form .captcha img').attr('src'); 3362 if(src.indexOf('?') > -1){ 3363 var tmp = src.split('?'); 3364 src = tmp[0]+'?'; 3365 } 3366 else src += '?'; 3367 src += Math.floor((Math.random() * 10000) + 1); 3368 $('#dfe-inner-form .captcha img').attr('src', src); 3369 } 3370 else{ 3371 3372 } 3373 }); 3374 } 3375 3376 } 3377 function checkField(field){ 3378 if(!$('#dfe-inner-form input[name='+field+']').val()){ 3379 $('#dfe-inner-form input[name='+field+']').addClass('form-error'); 3380 return false;
3381 } 3382 else $('#dfe-inner-form input[name='+field+']').removeClass('form-error'); 3383 return true; 3384 } 3385 function refreshCaptcha(e){ 3386 e.preventDefault(); 3387 3388 var src = $('.captcha img').attr('src'); 3389 if(src.indexOf('?') > -1){ 3390 tmp = src.split('?'); 3391 src = tmp[0]; 3392 } 3393 src += '?'+Math.floor((Math.random() * 10000) + 1); 3394 3395 $('.captcha img').attr('src', src); 3396 3397 } 3398 init(); 3399} 3400function initDISVGSchema(){ 3401 for(x in link_procedure_di){ 3402 $('#'+x).attr('class', $('#'+x).attr('class') + ' link').attr('data-link', link_procedure_di[x]); 3403 // $('#'+x).next().attr('class', $('#'+x).next().attr('class') + ' link').attr('data-link', link_procedure_di[x]); 3404 } 3405 // console.log('test') 3406 function procedura_click(){ 3407 if($(this).attr('data-link')){ 3408 // window.open($(this).attr('data-link')); 3409 location.href = $(this).attr('data-link'); 3410 } 3411 } 3412 function mouseover(){ 3413 if($(this).attr('data-link')){ 3414 $(this).children('rect').css('fill', '#333'); 3415 } 3416 // if($(this).attr('data-link')){ 3417 // window.open($(this).attr('data-link')); 3418 // } 3419 } 3420 function mouseout(){ 3421 if($(this).attr('data-link')){ 3422 $(this).children('rect').removeAttr('style'); 3423 } 3424 // if($(this).attr('data-link')){ 3425 // window.open($(this).attr('data-link')); 3426 // } 3427 } 3428 d3.select('svg').selectAll('g').on('click', procedura_click) 3429 d3.select('svg').selectAll('g').on('mouseover', mouseover).on('mouseout', mouseout); 3430} 3431/* DT Mappa Ticino */ 3432function initDTMappaTicino() { 3433 function init() { 3434 d3.select('svg').selectAll('#Limiti_pubbl_x_sito_web > g') 3435 .on('mouseover', mouseover) 3436 .on('mouseout', mouseout) 3437 .on('click', click); 3438 } 3439 function mouseover() { 3440 $(this).attr('class', 'hover'); 3441 } 3442 function mouseout() { 3443 $(this).attr('class', ''); 3444 } 3445 function click() { 3446 var id = $(this).attr('id'); 3447 var href = $('a:contains(' + id + ')').attr('href'); 3448 if(href) window.open(href); 3449 } 3450 init(); 3451} 3452function initAgendaCulturale(){ 3453 function init(){ 3454 if($('.big_dropdown').length) initDaterange() 3455 else if($('#formulario_osservatorio').length) initFormularioAgenda() 3456 3457 if($('.loop').length) initHomeCarousel() 3458 } 3459 function initHomeCarousel(){ 3460 3461 $('.loop').owlCarousel({ 3462 center: true, 3463 autoWidth: true, 3464 loop: true, 3465 margin: 0 3466 }).on('changed.owl.carousel', function(event) { 3467 setTimeout(function (){ 3468 $('.owl-item .inner-caption:not(.hidden)').addClass('hidden') 3469 $('.owl-item.active .inner-caption').removeClass('hidden') 3470 }, 100) 3471 }) 3472 $('.owl-item:not(.center) .inner-caption').addClass('hidden') 3473 3474 $('.owl-carousel .owl-stage-outer').append('<a href="#" class="prev"><i class="fa fa-angle-left"></i></a><a href="#" class="next"><i class="fa fa-angle-right"></i></a>') 3475 3476 3477 $('.owl-carousel .prev').click(function(e){ 3478 e.preventDefault(); 3479 $('.loop').trigger('prev.owl.carousel'); 3480 }); 3481 $('.owl-carousel .next').click(function(e){ 3482 e.preventDefault(); 3483 $('.loop').trigger('next.owl.carousel'); 3484 }); 3485 3486 3487 } 3488 function initDaterange(){ 3489 var startDate = false; 3490 var endDate = false; 3491 3492 if($('.big_dropdown').text().indexOf('Oggi') == -1){ 3493 var text = $('#periodo').text(); 3494 var tmp = text.split('-'); 3495 startDate = tmp[0]; 3496 endDate = tmp[1]; 3497 } 3498 3499 $('.big_dropdown').daterangepicker({ 3500 autoUpdateInput: false, 3501 startDate: startDate, 3502 endDate: endDate, 3503 showDropdowns: true, 3504 minDate: '01.01.1992', 3505 locale: { 3506 format: 'DD.MM.YYYY', 3507 firstDay: 1, 3508 cancelLabel: 'Cancella', 3509 applyLabel: 'Applica', 3510 customRangeLabel: "Custom", 3511 daysOfWeek: ["Do","Lu","Ma","Me","Gi","Ve", "Sa"], 3512 monthNames: ["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"] 3513 } 3514 }, 3515 function(start, end) { 3516 var startDate = start; 3517 var endDate = end; 3518 3519 var val=startDate.format('DD.MM.YYYY') + '-' + endDate.format('DD.MM.YYYY'); 3520 $("#periodo").val(val); 3521 $('#formRicerca').submit(); 3522 } 3523 ); 3524 } 3525 init(); 3526 3527 $('.big_dropdown').on('apply.daterangepicker', function(ev, picker) { 3528 $(this).html('<i class="fa fa-calendar"></i> '+picker.startDate.format('DD.MM.YYYY') + ' - ' + picker.endDate.format('DD.MM.YYYY')+' <i class="fa fa-caret-down"></i>'); 3529 }); 3530 3531 $('.big_dropdown').on('cancel.daterangepicker', function(ev, picker) { 3532 $(this).html('<i class="fa fa-calendar"></i> Oggi <i class="fa fa-caret-down"></i>'); 3533 $("#periodo").val(''); 3534 }); 3535 3536 $('.agenda-culturale #formRicerca select').change(function (){ 3537 $('#formRicerca').submit(); 3538 3539 }); 3540 3541 $('#ricercaButton').click(function (){ 3542 $('#formRicerca').submit(); 3543 }); 3544 3545 //filtro tipologie 3546 $('.dropdown-tipologia .dropdown-menu input').change(function() { 3547 3548 var valoreTipologie = []; 3549 3550 $('#opzioniTipologia input').each(function () { 3551 if ($(this).is(":checked")) { 3552 valoreTipologie.push(this.value); 3553 } 3554 }); 3555 3556 $('#valoreTipologia').val(valoreTipologie); 3557 $('#formRicerca').submit(); 3558 }); 3559 3560} 3561 3562function initFormularioAgenda(){ 3563 var uploadFile = {}; 3564 var url = '/fileadmin/DECS/DCSU/AC/OSSERVATORIO/segnaliazioni/'; 3565 var loading = false;
3566 var prestazioniUpload = false; 3567 var date_n = 1 3568 var max_date_n = 4 3569 function init(){ 3570 3571 3572 $('.add-date').click(addDate) 3573 $('#formulario_osservatorio').on('click', '.remove-date', removeDate) 3574 3575 $('.send-form').click(send); 3576 3577 $.fn.datepicker.dates['it'] = { 3578 days: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"], 3579 daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"], 3580 daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"], 3581 months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], 3582 monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"], 3583 today: "Oggi", 3584 clear: "Svuota" 3585 }; 3586 3587 $('#inizio, #fine').datepicker({ 3588 format: "dd.mm.yyyy", 3589 language: 'it', 3590 }); 3591 3592 initMultiUpload1(); 3593 initMultiUpload2(); 3594 } 3595 3596 function addDate(e){ 3597 e.preventDefault() 3598 3599 var c = $(this).prev().clone() 3600 c.attr('class', 'new-date') 3601 3602 $(this).prev().before(c) 3603 3604 $('.new-date:eq('+(date_n-1)+') input[name*=inizio], .new-date:eq('+(date_n-1)+') input[name*=fine]').datepicker({ 3605 format: "dd.mm.yyyy", 3606 language: 'it', 3607 }); 3608 3609 date_n++ 3610 if(date_n == max_date_n){ 3611 $('.add-date').addClass('hidden') 3612 } 3613 } 3614 function removeDate(e){ 3615 e.preventDefault() 3616 3617 $(this).parents('.new-date').remove() 3618 date_n-- 3619 $('.add-date').removeClass('hidden') 3620 } 3621 function send(e){ 3622 e.preventDefault(); 3623 3624 if(!loading){ 3625 loading = true; 3626 3627 var error = false; 3628 3629 if(!checkField('#titolo')) error = true; 3630 if(!checkField('#descrizione','descrizione')) error = true; 3631 if(!checkField('#nomeLuogo')) error = true; 3632 if(!checkField('#citta')) error = true; 3633 if(!checkField('#inizio')) error = true; 3634 3635 3636 if($('#fine').val()){ 3637 var from = moment($('#inizio').val(), 'DD.MM.YYYY') 3638 var to = moment($('#fine').val(), 'DD.MM.YYYY') 3639 if(!to.isAfter(from) && !to.isSame(from)){ 3640 $('#fine').siblings('.error-messages').removeClass('hidden') 3641 error = true 3642 } 3643 else $('#fine').siblings('.error-messages').addClass('hidden') 3644 } 3645 else $('#fine').siblings('.error-messages').addClass('hidden') 3646 3647 if($('.new-date').length){ 3648 for(x=0;x<$('.new-date').length;x++){ 3649 var o = $('.new-date:eq('+x+')') 3650 var inizio = o.find('input[name*=inizio]') 3651 if(!inizio.val()){ 3652 inizio.siblings('.error-messages').removeClass('hidden') 3653 error = true 3654 } 3655 else{ 3656 inizio.siblings('.error-messages').addClass('hidden') 3657 var fine = o.find('input[name*=fine]') 3658 if(fine.val()){ 3659 var from = moment(inizio.val(), 'DD.MM.YYYY') 3660 var to = moment(fine.val(), 'DD.MM.YYYY') 3661 if(!to.isAfter(from) && !to.isSame(from)){ 3662 fine.siblings('.error-messages').removeClass('hidden') 3663 error = true 3664 } 3665 else fine.siblings('.error-messages').addClass('hidden') 3666 } 3667 else fine.siblings('.error-messages').addClass('hidden') 3668 } 3669 } 3670 } 3671 3672 if($('#organizzatore').val() == '' && $('#nomeOrganizzatore').val() == ''){ 3673 checkField('#organizzatore') 3674 checkField('#nomeOrganizzatore') 3675 error = true 3676 } 3677 else { 3678 $('#organizzatore').siblings('.error-messages').addClass('hidden') 3679 $('#nomeOrganizzatore').siblings('.error-messages').addClass('hidden') 3680 } 3681 3682 if(!checkField('#email', 'email')) error = true; 3683 3684 if(!checkField('#copertina', 'copertina')) error = true; 3685 if(!checkField('#locandina', 'locandina')) error = true; 3686 3687 if(!error){ 3688 if(!checkCaptchaField()) error = true; 3689 } 3690 3691 if(!error){ 3692 3693 $('form').submit() 3694 3695 } 3696 else{ 3697 $('html, body').animate({scrollTop: $('.error-messages:first').offset().top - 70}, 500) 3698 loading = false;
3699 } 3700 } 3701 } 3702 function checkField(s, type){ 3703 if(typeof type == 'undefined'){ 3704 if($(s).val().trim() == ''){ 3705 $(s).siblings('.error-messages').removeClass('hidden'); 3706 return false; 3707 } 3708 else{ 3709 $(s).siblings('.error-messages').addClass('hidden'); 3710 return true; 3711 } 3712 } 3713 else if(type == 'radio' || type == 'checkbox'){ 3714 if($(s+':checked').length == 0){ 3715 $(s+':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 3716 return false; 3717 } 3718 else{ 3719 $(s+':first').parent().parent().siblings('.error-messages').addClass('hidden'); 3720 return true; 3721 } 3722 } 3723 else if(type == 'email'){ 3724 if($(s).val() == '' || !checkEmail($(s).val())){ 3725 $(s).siblings('.error-messages').removeClass('hidden'); 3726 return false; 3727 } 3728 else{ 3729 $(s).siblings('.error-messages').addClass('hidden'); 3730 return true; 3731 } 3732 } 3733 else if(type == 'copertina'){ 3734 tmp = $(s).val().split("\\"); 3735 var v = tmp[tmp.length - 1]; 3736 3737 if(v){ 3738 tmp2 = v.split('.'); 3739 var ext = tmp2[(tmp2.length - 1)]; 3740 3741 if(ext != 'jpg' && ext != 'jpeg' && ext != 'png' && ext != 'PNG' && ext != 'JPG'){ 3742 $(s).siblings('.error-messages-type').removeClass('hidden'); 3743 return false; 3744 } 3745 else{ 3746 $(s).siblings('.error-messages-type').addClass('hidden'); 3747 return true; 3748 } 3749 } 3750 else{ 3751 return true; 3752 } 3753 } 3754 else if(type == 'locandina'){ 3755 tmp = $(s).val().split("\\"); 3756 var v = tmp[tmp.length - 1]; 3757 3758 if(v){ 3759 tmp2 = v.split('.'); 3760 var ext = tmp2[(tmp2.length - 1)]; 3761 3762 if(ext != 'pdf'){ 3763 $(s).siblings('.error-messages-type').removeClass('hidden'); 3764 return false; 3765 } 3766 else{ 3767 $(s).siblings('.error-messages-type').addClass('hidden'); 3768 return true; 3769 } 3770 } 3771 else{ 3772 return true; 3773 } 3774 } 3775 else if(type == 'date'){ 3776 if($(s).val() == '' || !checkDate($(s).val())){ 3777 $(s).siblings('.error-messages').removeClass('hidden'); 3778 return false; 3779 } 3780 else{ 3781 $(s).siblings('.error-messages').addClass('hidden'); 3782 return true; 3783 } 3784 } 3785 else if(type == 'descrizione'){ 3786 if($(s).val().trim() == ''){ 3787 $(s).siblings('.error-messages').removeClass('hidden'); 3788 $(s).siblings('.error-lenght').addClass('hidden'); 3789 return false; 3790 } 3791 else if($(s).val().trim().length < 150){ 3792 $(s).siblings('.error-messages').addClass('hidden'); 3793 $(s).siblings('.error-lenght').removeClass('hidden'); 3794 return false; 3795 } 3796 else{ 3797 $(s).siblings('.error-messages').addClass('hidden'); 3798 $(s).siblings('.error-lenght').addClass('hidden'); 3799 return true; 3800 } 3801 } 3802 } 3803 function checkEmail(email) { 3804 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,}))$/; 3805 return re.test(String(email).toLowerCase()); 3806 } 3807 function checkDate(value){ 3808 if(new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 3809 else return false; 3810 } 3811 function checkCaptchaField(){ 3812 var error = false; 3813 3814 if(typeof grecaptcha !== 'undefined' && grecaptcha.getResponse().length){ 3815 $('.captcha .error-messages').addClass('hidden'); 3816 } 3817 else{ 3818 $('.captcha .error-messages').removeClass('hidden'); 3819 error = true; 3820 } 3821 3822 if(!error) return true; 3823 return false;
3824 } 3825 function initMultiUpload1(){ 3826 var attachments_n = 1; 3827 var max_uploads = 1; 3828 var max_weight = 4; 3829 var working = false; 3830 var uploadButtonContent = ''; 3831 function init(){ 3832 3833 $('#formulario_osservatorio').on('click', '.allegati1 button', addAttachemnt); 3834 $('#formulario_osservatorio').on('change', '.allegati1 input', change); 3835 } 3836 function addAttachemnt(e){ 3837 e.preventDefault(); 3838 3839 if(!working){ 3840 3841 $('#formulario_osservatorio .allegati1 input').trigger('click'); 3842 } 3843 } 3844 3845 function change(event){ 3846 var id = $(this).attr('id'); 3847 3848 tmp = $(this).val().split("\\"); 3849 var v = tmp[tmp.length - 1]; 3850 3851 if(v){ 3852 tmp2 = v.split('.'); 3853 var ext = tmp2[(tmp2.length - 1)]; 3854 3855 3856 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size').addClass('hidden'); 3857 3858 if(ext != 'jpg' && ext != 'jpeg' && ext != 'png' && ext != 'PNG' && ext != 'JPG'){ 3859 // Type error 3860 $('.allegati1 .error-messages-type').removeClass('hidden'); 3861 3862 } 3863 else{ 3864 if(Math.round(event.target.files[0].size / 1048576) > max_weight){ 3865 // Size error 3866 $('.allegati1 .error-messages-size').removeClass('hidden'); 3867 3868 $('.allegati1 .filename').text(''); 3869 3870 } 3871 else{ 3872 $('.allegati1 .filename').text(v); 3873 3874 uploadFile[id] = event.target.files; 3875 3876 } 3877 } 3878 } 3879 } 3880 init(); 3881 } 3882 function initMultiUpload2(){ 3883 var attachments_n = 1; 3884 var max_uploads = 1; 3885 var max_weight = 4; 3886 var working = false; 3887 var uploadButtonContent = ''; 3888 function init(){ 3889 3890 $('#formulario_osservatorio').on('click', '.allegati2 button', addAttachemnt); 3891 $('#formulario_osservatorio').on('change', '.allegati2 input', change); 3892 } 3893 function addAttachemnt(e){ 3894 e.preventDefault(); 3895 3896 if(!working){ 3897 $('#formulario_osservatorio .allegati2 input').trigger('click'); 3898 } 3899 } 3900 3901 function change(event){ 3902 var id = $(this).attr('id'); 3903 3904 tmp = $(this).val().split("\\"); 3905 var v = tmp[tmp.length - 1]; 3906 3907 if(v){ 3908 tmp2 = v.split('.'); 3909 var ext = tmp2[(tmp2.length - 1)]; 3910 3911 3912 $('.allegati2 .error-messages, .allegati2 .error-messages-type, .allegati2 .error-messages-size').addClass('hidden'); 3913 3914 if(ext != 'pdf'){ 3915 // Type error 3916 $('.allegati2 .error-messages-type').removeClass('hidden'); 3917 3918 } 3919 else{ 3920 if(Math.round(event.target.files[0].size / 1048576) > max_weight){ 3921 $('.allegati2 .error-messages-size').removeClass('hidden'); 3922 3923 // Svuota il campo .filename 3924 $('.allegati2 .filename').text(''); 3925 3926 } 3927 else{ 3928 $('.allegati2 .filename').text(v); 3929 3930 uploadFile[id] = event.target.files; 3931 3932 } 3933 } 3934 } 3935 } 3936 init(); 3937 } 3938 init(); 3939} 3940 3941/* ApriChiudi */ 3942function ApriChiudi() { 3943 try { 3944 jQuery(".msg_body").hide(); 3945 jQuery(".msg_body.aperto").slideToggle(500); 3946 // jQuery(".msg_head").toggleClass("SimboloMeno"); 3947 3948 jQuery(".msg_head").click(function () { 3949 jQuery(this).next(".msg_body").slideToggle(500); 3950 jQuery(this).toggleClass("SimboloMeno"); 3951 }); 3952 } catch (e) { } 3953} 3954 3955/* ApriChiudiSingolo */ 3956function ApriChiudiSingolo() { 3957 try { 3958 jQuery(".msg_body").hide(500); 3959 jQuery(".msg_body.aperto").slideToggle(500); 3960 jQuery(".msg_head.SimboloMeno").toggleClass("nosimbolo"); // test 3961 3962 jQuery(".msg_head").click(function () { 3963 // jQuery(".msg_body").hide(); 3964 jQuery(".msg_body").hide(500); 3965 jQuery(".msg_head").toggleClass("SimboloMeno", false); 3966 jQuery(".msg_head").toggleClass("nosimbolo", false); // test 3967 jQuery(this).next(".msg_body").slideToggle(500); 3968 jQuery(this).toggleClass("SimboloMeno"); 3969 jQuery(this).toggleClass("nosimbolo"); // test 3970 }); 3971 } catch (e) { } 3972} 3973function initAreaMedia(){ 3974 3975 $('head').append('<link href="https://fonts.googleapis.com/css?family=IBM+Plex+Serif:400,700" rel="stylesheet">'); 3976 3977 3978 3979 $("#areaMediaPrint").click(function() { 3980 $("#showComunicato").show(); 3981 window.print(); 3982 3983 }); 3984 3985 3986 $('.downloadAreaMedia').click(function(e) { 3987 3988 3989 $.ajaxTransport("+binary", function(options, originalOptions, jqXHR){
3990 // check for conditions and support for blob / arraybuffer response type 3991 if (window.FormData && ((options.dataType && (options.dataType == 'binary')) || (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) || (window.Blob && options.data instanceof Blob))))) 3992 { 3993 return { 3994 // create new XMLHttpRequest 3995 send: function(_, callback){ 3996 // setup all variables 3997 var xhr = new XMLHttpRequest(), 3998 url = options.url, 3999 type = options.type, 4000 // blob or arraybuffer. Default is blob 4001 dataType = options.responseType || "blob", 4002 data = options.data || null; 4003 4004 xhr.addEventListener('load', function(){ 4005 var data = {}; 4006 data[options.dataType] = xhr.response; 4007 // make callback and send data 4008 callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders()); 4009 }); 4010 4011 xhr.open(type, url, true); 4012 xhr.responseType = dataType; 4013 xhr.send(data); 4014 }, 4015 abort: function(){ 4016 jqXHR.abort(); 4017 } 4018 }; 4019 } 4020 }); 4021 4022 4023 var splitterA = $(this).attr('id').split(','); 4024 var urlMio = splitterA[0]; 4025 console.log(urlMio); 4026 $.ajax({ 4027 url: urlMio, 4028 type: "GET", 4029 dataType: 'binary', 4030 success: function(result) { 4031 var url = URL.createObjectURL(result); 4032 var $a = $('<a />', { 4033 'href': url, 4034 'download': splitterA[1], 4035 'text': "click" 4036 }).hide().appendTo("body")[0].click(); 4037 setTimeout(function() { 4038 URL.revokeObjectURL(url); 4039 }, 10000); 4040 } 4041 }); 4042 4043 4044 4045 }); 4046 4047 4048 if($('.daterange').length){ 4049 var startDate = false; 4050 var endDate = false; 4051 4052 if($('.btn.btn-default.daterange .filter-option').text().indexOf('Periodo') == -1){ 4053 var text = $('.btn.btn-default.daterange .filter-option').text(); 4054 // $("#periodo").val(text); 4055 var tmp = text.split('-'); 4056 startDate = tmp[0]; 4057 endDate = tmp[1]; 4058 } 4059 4060 $('.daterange').daterangepicker({ 4061 autoUpdateInput: false, 4062 startDate: startDate, 4063 endDate: endDate, 4064 showDropdowns: true, 4065 locale: { 4066 format: 'DD.MM.YYYY', 4067 firstDay: 1, 4068 cancelLabel: 'Cancella', 4069 applyLabel: 'Applica', 4070 customRangeLabel: "Custom", 4071 daysOfWeek: ["Do","Lu","Ma","Me","Gi","Ve", "Sa"], 4072 monthNames: ["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"] 4073 } 4074 }, 4075 function(start, end) { 4076 var startDate = start; 4077 var endDate = end; 4078 4079 var val=startDate.format('D.MM.YYYY') + '-' + endDate.format('D.MM.YYYY'); 4080 $("#periodo").val(val); 4081 $('#ricerca').submit(); 4082 } 4083 ); 4084 4085 $('.daterange').on('apply.daterangepicker', function(ev, picker) { 4086 $(this).html('<span class="filter-option pull-left">'+picker.startDate.format('DD.MM.YYYY') + ' - ' + picker.endDate.format('DD.MM.YYYY')+'</span> <span class="calendar"></span>'); 4087 }); 4088 4089 $('.daterange').on('cancel.daterangepicker', function(ev, picker) { 4090 $(this).html('<span class="filter-option pull-left">Periodo</span> <span class="calendar"></span>'); 4091 }); 4092 } 4093 4094 4095} 4096 4097/* Box Tematiche */ 4098function initTematicaBox() { 4099 $('.box-tematica .box').click(function (e) { 4100 e.preventDefault(); 4101 if ($(this).hasClass('opened')) { 4102 $(this).removeClass('opened'); 4103 } 4104 else { 4105 $('.box-tematica .box.opened').removeClass('opened'); 4106 $(this).addClass('opened') 4107 } 4108 }) 4109} 4110(function () { 4111 'use strict'; 4112 4113 // ========================================================================== 4114 // Costanti e helper 4115 // ========================================================================== 4116 4117 // Catturato subito, in modo sincrono, all'esecuzione dello script: dopo 4118 // qualunque deferral (es. DOMContentLoaded) document.currentScript torna 4119 // sempre null, quindi va salvato qui e non dentro le funzioni che lo usano 4120 // più avanti. Serve a risolvere help.json/preset.json relativamente alla 4121 // posizione dello script stesso, non a quella della pagina â necessario 4122 // perché nell'ambiente TYPO3 questo script finisce concatenato in 4123 // jsGenerale.js, servito da un URL completamente diverso dalla pagina che 4124 // lo include (vedi CLAUDE.md "Deploy in produzione (TYPO3)"). 4125 var SCRIPT_URL = document.currentScript ? document.currentScript.src : null; 4126 4127 function dataUrl(filename) { 4128 var relative = 'calcolatoredasf-data/' + filename; 4129 return SCRIPT_URL ? new URL(relative, SCRIPT_URL).href : relative; 4130 } 4131 4132 var ROUND = function (n) { return Math.round(n); }; 4133 // Arrotonda la divisione prima di troncare, per evitare che l'imprecisione 4134 // dei float (es. 132.1 / 0.1 = 1320.9999999999998) faccia scendere il 4135 // risultato di uno step (vedi CLAUDE.md "Arrotondamento"). 4136 var FLOOR_TO_STEP = function (n, step) { 4137 var scaled = Math.round((n / step) * 1e8) / 1e8;
4138 return Math.floor(scaled) * step; 4139 }; 4140 4141 var PERCENT_OPTIONS = (function () { 4142 var out = []; 4143 for (var p = 1; p <= 100; p++) out.push({ value: p, label: p + '%' }); 4144 return out; 4145 })(); 4146 4147 // Anno corrente all'anno corrente - 10, in ordine decrescente. 4148 var ANNO_TASSAZIONE_OPTIONS = (function () { 4149 var currentYear = new Date().getFullYear(); 4150 var out = []; 4151 for (var y = currentYear; y >= currentYear - 10; y--) out.push({ value: y, label: String(y) }); 4152 return out; 4153 })(); 4154 4155 // Testi di aiuto caricati da help.json (vedi loadHelpTexts()). Restano un 4156 // oggetto vuoto se il fetch fallisce (es. pagina aperta con file:// invece 4157 // che da un server) â in quel caso i pallini "i" semplicemente non 4158 // compaiono, il resto dell'applicativo continua a funzionare normalmente. 4159 var HELP_TEXTS = {}; 4160 4161 function escapeHtml(value) { 4162 return String(value) 4163 .replace(/&/g, '&') 4164 .replace(/</g, '<') 4165 .replace(/>/g, '>') 4166 .replace(/"/g, '"') 4167 .replace(/'/g, '''); 4168 } 4169 4170 function resolveLabel(label, ctx) { 4171 return typeof label === 'function' ? label(ctx) : label; 4172 } 4173 4174 // ========================================================================== 4175 // FIELD_DEFS â fonte di verità unica, trascritta 1:1 dalla tabella di 4176 // riferimento in CLAUDE.md ("Tabella di riferimento campi â celle Excel â 4177 // id tecnico"). Ogni correzione a una formula qui deve essere specchiata in 4178 // CLAUDE.md (vedi sezione "Manutenzione di questo documento"). 4179 // ========================================================================== 4180 4181 var FIELD_DEFS = [ 4182 { 4183 num: 1, id: 'stato_civile', cell: null, kind: 'input', controlType: 'select', 4184 valueType: 'string', label: 'Stato civile', required: true, 4185 options: [ 4186 { value: 'single', label: 'Single' }, 4187 { value: 'coniugato', label: 'Coniugato' } 4188 ], 4189 default: 'single' 4190 }, 4191 { 4192 num: 2, id: 'anno_tassazione', cell: null, kind: 'input', controlType: 'select', 4193 label: 'Anno ultima decisione tassazione cresciuta in giudicato', required: true, 4194 options: ANNO_TASSAZIONE_OPTIONS, default: new Date().getFullYear(), structural: true 4195 }, 4196 { 4197 num: 3, id: 'reddito_imponibile_complessivo', cell: 'C5', kind: 'input', controlType: 'number', 4198 label: function (ctx) { return '[28] Reddito imponibile complessivo ' + ctx.anno; }, 4199 default: 0, required: true, min: 0 4200 }, 4201 { 4202 num: 4, id: 'spese_disabilita', cell: 'C6', kind: 'input', controlType: 'number', 4203 label: function (ctx) { return '[15.1] Spese per disabilità ' + ctx.anno; }, 4204 default: 0, required: true, min: 0 4205 }, 4206 { 4207 // Ripristinato su richiesta del committente: solo il campo dell'anno 4208 // corrente serve ancora a "1/10 Sostanza mobiliare" (vedi sotto); gli 4209 // altri 4 anni storici (che alimentavano "Totale variazione") restano 4210 // eliminati. Vedi CLAUDE.md "Punti da verificare". 4211 num: 5, id: 'titoli_capitali', cell: 'C8', kind: 'input', controlType: 'number', 4212 label: function (ctx) { return '[29.1] Titoli e capitali ' + ctx.anno; }, 4213 default: 0, required: true, min: 0 4214 }, 4215 { 4216 num: 6, id: 'franchigia_sostanza_mobiliare', cell: 'C9', kind: 'derived', 4217 label: 'Franchigia (sostanza mobiliare)', 4218 formulaText: "15'000 (fisso)", 4219 compute: function () { return 15000; } 4220 }, 4221 { 4222 num: 7, id: 'sostanza_mobiliare', cell: 'C10', kind: 'derived', 4223 label: '1/10 Sostanza mobiliare', 4224 formulaText: 'MAX(0, (titoli_capitali â franchigia_sostanza_mobiliare) / 10)', 4225 // Corretto dall'utente: la trascrizione iniziale della formula Excel 4226 // sommava la franchigia invece di sottrarla. 4227 compute: function (values) { 4228 return Math.max(0, (values.titoli_capitali - values.franchigia_sostanza_mobiliare) / 10); 4229 } 4230 }, 4231 { 4232 num: 8, id: 'sostanza_immobiliare', cell: 'C24', kind: 'input', controlType: 'number', 4233 label: '[30] Sostanza Immobiliare', default: 0, required: true, min: 0 4234 }, 4235 { 4236 num: 9, id: 'debiti_privati', cell: 'C25', kind: 'input', controlType: 'number', 4237 label: '[33.1] Debiti Privati', default: 0, required: true, min: 0 4238 }, 4239 { 4240 num: 10, id: 'franchigia_sostanza_immobiliare', cell: 'C26', kind: 'derived', 4241 label: 'Franchigia (sostanza immobiliare)', 4242 formulaText: "300'000 (fisso)", 4243 compute: function () { return 300000; } 4244 }, 4245 { 4246 num: 11, id: 'sostanza_immobiliare_decimo', cell: 'C27', kind: 'derived', 4247 label: '1/10 Sostanza immobiliare', 4248 formulaText: 'MAX(0, (sostanza_immobiliare - debiti_privati - franchigia_sostanza_immobiliare) / 10)', 4249 // Corretto dall'utente: sia la franchigia sia i debiti privati vanno 4250 // sottratti, non sommati (la trascrizione iniziale della formula Excel 4251 // era sbagliata) â vedi CLAUDE.md. 4252 // NOTE: non risulta usato in nessuna formula successiva â vedi CLAUDE.md "Punti da verificare". 4253 compute: function (values) { 4254 return Math.max(0, (values.sostanza_immobiliare - values.debiti_privati - values.franchigia_sostanza_immobiliare) / 10); 4255 } 4256 }, 4257 { 4258 // Rimossi i termini donazione_mobiliare_decimo e 4259 // donazione_immobiliare_decimo su richiesta del committente (vedi 4260 // CLAUDE.md "Punti da verificare": eliminati definitivamente 4261 // donazione_mobiliare/donazione_immobiliare e i rispettivi campi 4262 // "Franchigia"/"1/10" dal form e dal calcolo). Aggiunto invece
4263 // sostanza_immobiliare_decimo, corretto dall'utente (in precedenza non 4264 // entrava in questa somma). 4265 // Corretto dall'utente: il totale non può risultare negativo â se la 4266 // somma scende sotto 0, va riportato a 0 per permettere al calcolo di 4267 // proseguire regolarmente sui campi successivi. 4268 num: 12, id: 'reddito_lordo_determinante', cell: 'C33', kind: 'derived', 4269 label: 'Reddito lordo determinante', 4270 formulaText: 'MAX(0, reddito_imponibile_complessivo + spese_disabilita + sostanza_mobiliare + sostanza_immobiliare_decimo)', 4271 compute: function (values) { 4272 return Math.max(0, values.reddito_imponibile_complessivo + values.spese_disabilita + 4273 values.sostanza_mobiliare + values.sostanza_immobiliare_decimo); 4274 } 4275 }, 4276 { 4277 num: 13, id: 'spillatico_10', cell: 'C34/C35', kind: 'derived', 4278 label: 'Spillatico (10%)', 4279 formulaText: 'raw = (reddito_lordo_determinante à 10 / 100) > 3999 ? raw : 0; risultato = clamp(raw, 4000, 7200)', 4280 compute: function (values) { 4281 var raw = (values.reddito_lordo_determinante * 10) / 100; 4282 raw = raw > 3999 ? raw : 0; 4283 var clamped = raw > 7200 ? 7200 : (raw < 4000 ? 4000 : raw); 4284 return { value: clamped, steps: [{ id: 'spillatico_raw', label: 'Spillatico raw (pre-clamp)', value: ROUND(raw) }] }; 4285 } 4286 }, 4287 { 4288 num: 14, id: 'imposta_cantonale', cell: 'C37', kind: 'input', controlType: 'number', 4289 label: function (ctx) { return 'Imposta cantonale (IC) ' + ctx.anno; }, default: 0, required: true, min: 0 4290 }, 4291 { 4292 num: 15, id: 'imposta_comunale_moltiplicatore', cell: 'C38', kind: 'input', controlType: 'select', 4293 label: function (ctx) { return 'Imposta comunale ' + ctx.anno; }, 4294 options: PERCENT_OPTIONS, default: 100, required: true 4295 }, 4296 { 4297 num: 16, id: 'imposta_comunale_risultato', cell: 'C38', kind: 'derived', 4298 label: function (ctx) { return 'Imposta comunale ' + ctx.anno + ' (risultato)'; }, 4299 formulaText: 'imposta_cantonale à imposta_comunale_moltiplicatore / 100', 4300 compute: function (values) { return (values.imposta_cantonale * values.imposta_comunale_moltiplicatore) / 100; } 4301 }, 4302 { 4303 num: 17, id: 'idf', cell: 'C39', kind: 'input', controlType: 'number', 4304 label: function (ctx) { return 'Imposta federale diretta (IFD) ' + ctx.anno; }, default: 0, required: true, min: 0 4305 }, 4306 { 4307 num: 18, id: 'imposta_personale', cell: 'C40', kind: 'derived', 4308 label: 'Imposta personale', 4309 formulaText: "stato_civile === 'coniugato' ? 80 : 40", 4310 compute: function (values) { return values.stato_civile === 'coniugato' ? 80 : 40; } 4311 }, 4312 { 4313 num: 19, id: 'contributi_mantenimento_domicilio', cell: 'C41', kind: 'input', controlType: 'number', 4314 label: function (ctx) { return '[6.3] Contributi di sostegno al mant. a domicilio (' + statoCivileLabel(ctx.statoCivile) + ')'; }, 4315 default: 0, required: true, min: 0 4316 }, 4317 { 4318 num: 20, id: 'totale', cell: 'C42', kind: 'derived', 4319 label: 'Totale', 4320 formulaText: 'spillatico_10 + imposta_cantonale + imposta_comunale_risultato + idf + imposta_personale + contributi_mantenimento_domicilio', 4321 compute: function (values) { 4322 return values.spillatico_10 + values.imposta_cantonale + values.imposta_comunale_risultato + 4323 values.idf + values.imposta_personale + values.contributi_mantenimento_domicilio; 4324 } 4325 }, 4326 { 4327 num: 21, id: 'reddito_netto_determinante', cell: 'C44', kind: 'derived', 4328 label: 'Reddito netto determinante', 4329 formulaText: 'reddito_lordo_determinante â totale', 4330 compute: function (values) { return values.reddito_lordo_determinante - values.totale; } 4331 }, 4332 { 4333 num: 22, id: 'importo_giornaliero', cell: 'C46', kind: 'derived', 4334 label: function (ctx) { return "Calcolo dell'importo giornaliero (" + statoCivileLabel(ctx.statoCivile) + ')'; }, 4335 formulaText: 'reddito_netto_determinante / 365', 4336 visibleWhen: function (values) { return values.stato_civile !== 'coniugato'; }, 4337 compute: function (values) { return values.reddito_netto_determinante / 365; } 4338 }, 4339 { 4340 // Su richiesta del committente (corretto rispetto a una versione 4341 // precedente che arrotondava a step di 0.5): unico campo con 2 4342 // decimali, sempre multiplo di 0.10 (.00, .10, .20 ... .90) â mai 4343 // arrotondato al franco intero â arrotondato per difetto, non al più 4344 // vicino. Vedi CLAUDE.md "Arrotondamento". 4345 num: 23, id: 'importo_giornaliero_coniugato', cell: null, kind: 'derived', 4346 label: 'Se coniugato', 4347 formulaText: 'FLOOR_TO_STEP(importo_giornaliero / 2, 0.1)', 4348 decimals: 2, roundStep: 0.1, 4349 visibleWhen: function (values) { return values.stato_civile === 'coniugato'; }, 4350 compute: function (values) { return values.importo_giornaliero / 2; } 4351 } 4352 ]; 4353 4354 // ========================================================================== 4355 // Preset di dati per i test (vedi CLAUDE.md "Preset di dati per i test"). 4356 // Dati esternalizzati in preset.json (vedi loadTestPresets()) â questo 4357 // array resta vuoto finché il fetch non risolve; se fallisce (es. pagina 4358 // aperta via file://) resta vuoto e il menu preset non mostra opzioni, 4359 // stessa logica di HELP_TEXTS/help.json. 4360 // ========================================================================== 4361 4362 var TEST_PRESETS = []; 4363 4364 // ========================================================================== 4365 // Stato applicativo 4366 // ========================================================================== 4367 4368 var state = { 4369 values: {}, 4370 debug: false, 4371 debugLog: [] 4372 }; 4373 4374 // ========================================================================== 4375 // Espansione campi dinamici / contesto di calcolo 4376 // ========================================================================== 4377 4378 function statoCivileLabel(value) { 4379 return value === 'coniugato' ? 'Coniugato' : 'Single'; 4380 } 4381 4382 function buildContext(values) { 4383 return { 4384 anno: values.anno_tassazione, 4385 statoCivile: values.stato_civile 4386 }; 4387 } 4388 4389 function getExpandedFields(values) { 4390 var out = []; 4391 FIELD_DEFS.forEach(function (def) { 4392 if (def.kind === 'dynamic-group') {
4393 def.years(values).forEach(function (year) { 4394 out.push({ 4395 num: def.num, id: def.idFor(year), cell: null, kind: 'input', 4396 controlType: def.controlType, label: def.labelFor(year), default: def.default, 4397 required: def.requiredWhen ? def.requiredWhen(year, values) : def.required, 4398 groupId: def.id 4399 }); 4400 }); 4401 } else { 4402 out.push(def); 4403 } 4404 }); 4405 return out; 4406 } 4407 4408 function ensureDynamicDefaults() { 4409 var expanded = getExpandedFields(state.values); 4410 expanded.forEach(function (f) { 4411 if (f.kind === 'input' && typeof state.values[f.id] === 'undefined') { 4412 state.values[f.id] = typeof f.default !== 'undefined' ? f.default : 0; 4413 } 4414 }); 4415 } 4416 4417 // ========================================================================== 4418 // Motore di calcolo â itera i campi nell'ordine di FIELD_DEFS (già un 4419 // ordine topologico valido: ogni campo calcolato dipende solo da campi 4420 // precedenti, vedi CLAUDE.md). L'arrotondamento al franco intero è 4421 // applicato qui, centralmente, subito dopo ogni compute(). 4422 // ========================================================================== 4423 4424 function recompute() { 4425 ensureDynamicDefaults(); 4426 var ctx = buildContext(state.values); 4427 var expanded = getExpandedFields(state.values); 4428 var debugLog = []; 4429 4430 expanded.forEach(function (f) { 4431 var label = resolveLabel(f.label, ctx); 4432 if (f.kind === 'input') { 4433 debugLog.push({ num: f.num, id: f.id, label: label, value: state.values[f.id], formula: null }); 4434 return; 4435 } 4436 if (f.kind === 'derived') { 4437 // NOTA: compute() gira SEMPRE, indipendentemente da visibleWhen â il 4438 // campo 29 dipende dal valore del campo 28 anche quando quest'ultimo 4439 // non è mostrato in form (coniugato). 4440 var raw = f.compute(state.values, ctx); 4441 var value, steps; 4442 if (raw !== null && typeof raw === 'object' && 'value' in raw) { 4443 value = raw.value; 4444 steps = raw.steps; 4445 } else { 4446 value = raw; 4447 } 4448 if (f.roundStep) { 4449 value = FLOOR_TO_STEP(value, f.roundStep); 4450 // Ripulisce il residuo di imprecisione dei float (es. 132.70000000000002) 4451 // così il valore stampato in debug coincide con quello mostrato nel campo. 4452 if (typeof f.decimals === 'number') value = Number(value.toFixed(f.decimals)); 4453 } else { 4454 value = ROUND(value); 4455 } 4456 state.values[f.id] = value; 4457 debugLog.push({ num: f.num, id: f.id, label: label, value: value, formula: f.formulaText }); 4458 if (steps) { 4459 steps.forEach(function (s) { 4460 debugLog.push({ num: f.num, id: s.id, label: s.label, value: s.value, formula: null, isStep: true }); 4461 }); 4462 } 4463 } 4464 }); 4465 4466 state.debugLog = debugLog; 4467 } 4468 4469 // ========================================================================== 4470 // Rendering 4471 // ========================================================================== 4472 4473 // Tutto il codice sotto dipende dal DOM del form (incollato a mano nel 4474 // box HTML di TYPO3): se questo script viene eseguito prima che il 4475 // markup sia stato parsato (es. bundle JS caricato altrove nella pagina 4476 // rispetto al <script> di fondo pagina usato in index.html), 4477 // document.getElementById(...) restituirebbe null e le successive 4478 // addEventListener() lancerebbero un errore, interrompendo l'intero 4479 // script prima ancora di arrivare a init() â da qui il rinvio a 4480 // DOMContentLoaded (vedi CLAUDE.md "Deploy in produzione (TYPO3)"). 4481 function main() { 4482 var fieldsContainer = document.getElementById('fields-container'); 4483 var debugToggle = document.getElementById('debug-toggle'); 4484 var debugToggleWrapper = document.getElementById('debug-toggle-wrapper'); 4485 var debugPanelWrapper = document.getElementById('debug-panel-wrapper'); 4486 var debugOutputEl = document.getElementById('debug-output'); 4487 var testPresetWrapper = document.getElementById('test-preset-wrapper'); 4488 var presetSelect = document.getElementById('preset-select'); 4489 var loadPresetBtn = document.getElementById('load-preset-btn'); 4490 var copyDebugBtn = document.getElementById('copy-debug-btn'); 4491 4492 function renderFieldHTML(f, ctx) { 4493 if (f.hidden) return ''; 4494 if (f.visibleWhen && !f.visibleWhen(state.values)) return ''; 4495 4496 var label = escapeHtml(resolveLabel(f.label, ctx)); 4497 var value = state.values[f.id]; 4498 if (f.kind === 'derived' && typeof f.decimals === 'number' && typeof value === 'number') { 4499 value = value.toFixed(f.decimals); 4500 } 4501 var badge = state.debug ? ' <span class="field-id-badge">' + escapeHtml(f.id) + '</span>' : ''; 4502 var elId = 'field-' + f.id; 4503 var requiredAttr = f.required ? ' required' : ''; 4504 var requiredMarker = f.required ? ' <span class="required-marker">*</span>' : ''; 4505 var maxAttr = (typeof f.max !== 'undefined') ? ' max="' + escapeHtml(f.max) + '"' : ''; 4506 var minAttr = (typeof f.min !== 'undefined') ? ' min="' + escapeHtml(f.min) + '"' : ''; 4507 4508 var helpText = HELP_TEXTS[f.id] || (f.groupId && HELP_TEXTS[f.groupId]) || ''; 4509 var helpHtml = ''; 4510 if (helpText) { 4511 helpHtml = 4512 ' <button type="button" class="help-icon" data-help-for="' + f.id + '" aria-label="Aiuto">' + 4513 '<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></button>' + 4514 '<div class="popover help-popover bottom" data-help-popover-for="' + f.id + '" role="tooltip">' + 4515 '<div class="arrow"></div><div class="popover-content">' + escapeHtml(helpText) + '</div></div>'; 4516 } 4517 4518 var errorHtml = '<div class="help-block field-error" data-error-for="' + f.id + '" style="display:none;"></div>'; 4519 4520 if (f.kind === 'input') { 4521 if (f.controlType === 'select') { 4522 var options = typeof f.options === 'function' ? f.options(ctx) : (f.options || []); 4523 var optionsHtml = options.map(function (o) { 4524 var selected = String(o.value) === String(value) ? ' selected' : ''; 4525 return '<option value="' + escapeHtml(o.value) + '"' + selected + '>
4525' + escapeHtml(o.label) + '</option>'; 4526 }).join(''); 4527 return '<div class="form-group help-field-group"><label for="' + elId + '">' + label + requiredMarker + helpHtml + badge + '</label>' + 4528 '<select id="' + elId + '" class="form-control" data-field-id="' + f.id + '"' + requiredAttr + '>' + optionsHtml + '</select>' + 4529 errorHtml + '</div>'; 4530 } 4531 return '<div class="form-group help-field-group"><label for="' + elId + '">' + label + requiredMarker + helpHtml + badge + '</label>' + 4532 '<input type="number" id="' + elId + '" class="form-control" data-field-id="' + f.id + '" value="' + escapeHtml(value) + '"' + requiredAttr + maxAttr + minAttr + '>' + 4533 errorHtml + '</div>'; 4534 } 4535 4536 // derived â non modificabile 4537 return '<div class="form-group help-field-group"><label for="' + elId + '">' + label + helpHtml + badge + '</label>' + 4538 '<input type="text" id="' + elId + '" class="form-control field-derived" data-field-id="' + f.id + '" value="' + escapeHtml(value) + '" readonly></div>'; 4539 } 4540 4541 function renderForm() { 4542 var ctx = buildContext(state.values); 4543 var expanded = getExpandedFields(state.values); 4544 fieldsContainer.innerHTML = expanded.map(function (f) { return renderFieldHTML(f, ctx); }).join(''); 4545 } 4546 4547 function renderValues() { 4548 var ctx = buildContext(state.values); 4549 getExpandedFields(state.values).forEach(function (f) { 4550 if (f.kind !== 'derived' || f.hidden) return; 4551 if (f.visibleWhen && !f.visibleWhen(state.values)) return; 4552 var el = fieldsContainer.querySelector('[data-field-id="' + f.id + '"]'); 4553 if (!el) return; 4554 var value = state.values[f.id]; 4555 el.value = (typeof f.decimals === 'number') ? value.toFixed(f.decimals) : value; 4556 }); 4557 } 4558 4559 // ========================================================================== 4560 // Debug 4561 // ========================================================================== 4562 4563 function formatDebugText(debugLog) { 4564 return debugLog.map(function (row) { 4565 var numPart = row.isStep ? ' step' : '[' + row.num + ']'; 4566 var formulaPart = row.formula ? '\n ' + row.formula : ''; 4567 return numPart + ' ' + row.id + ' = ' + row.value + formulaPart; 4568 }).join('\n'); 4569 } 4570 4571 function renderDebug() { 4572 if (window.console && console.group) { 4573 console.group('Calcolo â ' + new Date().toLocaleTimeString()); 4574 if (console.table) console.table(state.debugLog); 4575 console.groupEnd(); 4576 } 4577 debugOutputEl.value = formatDebugText(state.debugLog); 4578 } 4579 4580 function applyDebugVisibility() { 4581 // Il checkbox stesso resta nascosto finché la modalità debug non è già 4582 // attiva (via ?debug=1 o localStorage â vedi loadDebugPreference()): 4583 // un utente normale in produzione non deve poterla scoprire/attivare 4584 // dall'interfaccia. Una volta attiva, il checkbox compare per poterla 4585 // disattivare. Vedi CLAUDE.md "Modalità debug". 4586 debugToggleWrapper.style.display = state.debug ? '' : 'none'; 4587 debugPanelWrapper.style.display = state.debug ? '' : 'none'; 4588 // Nascosto anche in debug mode se preset.json non si è ancora caricato o 4589 // non è disponibile (vedi loadTestPresets()) â niente menu vuoto. 4590 testPresetWrapper.style.display = (state.debug && TEST_PRESETS.length > 0) ? '' : 'none'; 4591 } 4592 4593 function loadDebugPreference() { 4594 var params = new URLSearchParams(window.location.search); 4595 if (params.get('debug') === '1') { 4596 state.debug = true; 4597 } else { 4598 state.debug = window.localStorage && localStorage.getItem('calc_debug') === '1'; 4599 } 4600 debugToggle.checked = state.debug; 4601 } 4602 4603 debugToggle.addEventListener('change', function () { 4604 state.debug = debugToggle.checked; 4605 if (window.localStorage) localStorage.setItem('calc_debug', state.debug ? '1' : '0'); 4606 applyDebugVisibility(); 4607 var presetApplied = state.debug && applyDefaultDebugPreset(); 4608 if (!presetApplied) { 4609 renderForm(); 4610 if (state.debug) renderDebug(); 4611 } 4612 }); 4613 4614 copyDebugBtn.addEventListener('click', function () { 4615 debugOutputEl.select(); 4616 if (navigator.clipboard && navigator.clipboard.writeText) {
4617 navigator.clipboard.writeText(debugOutputEl.value).catch(function () { 4618 document.execCommand('copy'); 4619 }); 4620 } else { 4621 document.execCommand('copy'); 4622 } 4623 }); 4624 4625 // ========================================================================== 4626 // Preset di test 4627 // ========================================================================== 4628 4629 // Il tema TYPO3 usa bootstrap-select (jQuery): al primo scan della 4630 // pagina clona le <option> di ogni <select class="form-control"> nel suo 4631 // widget custom. #preset-select esiste già nel markup statico (vedi 4632 // index.html) ma le sue <option> arrivano solo dopo il fetch asincrono 4633 // di preset.json â il widget resta quindi vuoto finché non gli si dice 4634 // esplicitamente di rileggerle. Nessun effetto in ambienti senza 4635 // jQuery/bootstrap-select (es. index.html standalone in ddev). 4636 function refreshSelectWidget(selectEl) { 4637 if (window.jQuery && window.jQuery.fn && window.jQuery.fn.selectpicker) { 4638 window.jQuery(selectEl).selectpicker('refresh'); 4639 } 4640 } 4641 4642 function populatePresetSelect() { 4643 presetSelect.innerHTML = TEST_PRESETS.map(function (preset, index) { 4644 return '<option value="' + index + '">' + escapeHtml(preset.name) + '</option>'; 4645 }).join(''); 4646 refreshSelectWidget(presetSelect); 4647 } 4648 4649 function applyPreset(preset) { 4650 Object.keys(preset.values).forEach(function (id) { 4651 state.values[id] = preset.values[id]; 4652 }); 4653 recompute(); 4654 renderForm(); 4655 if (state.debug) renderDebug(); 4656 } 4657 4658 // In modalità debug si parte sempre dal preset "Single" (se disponibile in 4659 // preset.json), per non dover ricompilare il form a mano ad ogni test. 4660 function applyDefaultDebugPreset() { 4661 var index = -1; 4662 for (var i = 0; i < TEST_PRESETS.length; i++) { 4663 if (TEST_PRESETS[i].name === 'Single') { index = i; break; } 4664 } 4665 if (index === -1) return false; 4666 presetSelect.value = String(index); 4667 refreshSelectWidget(presetSelect); 4668 applyPreset(TEST_PRESETS[index]); 4669 return true; 4670 } 4671 4672 loadPresetBtn.addEventListener('click', function () { 4673 var preset = TEST_PRESETS[Number(presetSelect.value)]; 4674 if (preset) applyPreset(preset); 4675 }); 4676 4677 // ========================================================================== 4678 // Wiring eventi form 4679 // ========================================================================== 4680 4681 // Valida il formato inserito appoggiandosi alla validity API nativa 4682 // dell'input (niente parsing/regex custom): "badInput" scatta quando il 4683 // testo digitato/incollato non è un numero valido, "valueMissing" quando 4684 // un campo obbligatorio è vuoto. 4685 function validateField(target, fieldId) { 4686 var group = target.closest('.form-group'); 4687 if (!group) return; 4688 var errorEl = group.querySelector('[data-error-for="' + fieldId + '"]'); 4689 var message = ''; 4690 if (target.validity) { 4691 if (target.validity.badInput) { 4692 message = 'Devi inserire un valore numerico, non del testo.'; 4693 } else if (target.validity.valueMissing) { 4694 message = 'Questo campo è obbligatorio.'; 4695 } else if (target.validity.rangeOverflow) { 4696 message = 'Il valore massimo consentito è ' + target.max + '.'; 4697 } else if (target.validity.rangeUnderflow) { 4698 message = 'Il valore minimo consentito è ' + target.min + '.'; 4699 } 4700 } 4701 group.classList.toggle('has-error', !!message); 4702 if (errorEl) { 4703 errorEl.textContent = message; 4704 errorEl.style.display = message ? '' : 'none'; 4705 } 4706 } 4707 4708 function handleFieldEvent(e) { 4709 var fieldId = e.target.getAttribute('data-field-id'); 4710 if (!fieldId) return; 4711 4712 validateField(e.target, fieldId); 4713 4714 var structural = fieldId === 'anno_tassazione' || fieldId === 'stato_civile'; 4715 // I campi strutturali (che forzano un renderForm() completo, quindi 4716 // ricreano gli elementi del DOM) reagiscono solo a 'change', non a 4717 // 'input' â altrimenti digitare nel campo anno ricostruirebbe il form 4718 // ad ogni tasto premuto, perdendo il focus a metà digitazione. 4719 if (structural && e.type === 'input') return; 4720 4721 var def = getFieldDefById(fieldId); 4722 var value = (def && def.valueType === 'string') ? e.target.value : (parseFloat(e.target.value) || 0); 4723 state.values[fieldId] = value; 4724 4725 recompute(); 4726 if (structural) { 4727 renderForm(); 4728 } else { 4729 renderValues(); 4730 } 4731 if (state.debug) renderDebug(); 4732 } 4733 4734 function getFieldDefById(id) { 4735 for (var i = 0; i < FIELD_DEFS.length; i++) { 4736 if (FIELD_DEFS[i].id === id) return FIELD_DEFS[i]; 4737 } 4738 return null; 4739 } 4740 4741 fieldsContainer.addEventListener('input', handleFieldEvent); 4742 fieldsContainer.addEventListener('change', handleFieldEvent); 4743 4744 // ========================================================================== 4745 // Popover di aiuto (icona "i") â solo JS/CSS, nessun plugin Bootstrap. 4746 // Riusa le classi CSS .popover/.popover.in già presenti in Bootstrap 3 4747 // (che gestiscono già display:none/block), qui gestite manualmente al click. 4748 // ========================================================================== 4749 4750 function closeAllPopovers() { 4751 fieldsContainer.querySelectorAll('.help-popover.in').forEach(function (el) { 4752 el.classList.remove('in'); 4753 }); 4754 } 4755 4756 fieldsContainer.addEventListener('click', function (e) { 4757 var btn = e.target.closest('.help-icon'); 4758 if (btn) { 4759 e.preventDefault(); 4760 var fieldId = btn.getAttribute('data-help-for'); 4761 var popover = fieldsContainer.querySelector('[data-help-popover-for="' + fieldId + '"]'); 4762 var wasOpen = popover && popover.classList.contains('in'); 4763 closeAllPopovers(); 4764 if (popover && !wasOpen) popover.classList.add('in'); 4765 return; 4766 } 4767 if (!e.target.closest('.help-popover')) closeAllPopovers(); 4768 }); 4769 4770 document.addEventListener('click', function (e) { 4771 if (!e.target.closest('.help-icon') && !e.target.closest('.help-popover')) closeAllPopovers(); 4772 }); 4773 4774 // ========================================================================== 4775 // Caricamento testi di aiuto da help.json (asincrono). Se il fetch fallisce 4776 // (es. pagina aperta con doppio click via file:// invece che da un server), 4777 // i pallini "i" non vengono mostrati ma il resto dell'app funziona 4778 // normalmente â vedi CLAUDE.md. 4779 // ========================================================================== 4780 4781 function loadHelpTexts() { 4782 fetch(dataUrl('help.json')) 4783 .then(function (response) { 4784 if (!response.ok) throw new Error('HTTP ' + response.status); 4785 return response.json(); 4786 }) 4787 .then(function (data) { 4788 HELP_TEXTS = data || {}; 4789 renderForm(); 4790 }) 4791 .catch(function (err) { 4792 console.warn('help.json non caricato â i pallini di aiuto non saranno mostrati.', err); 4793 }); 4794 } 4795 4796 // ========================================================================== 4797 // Caricamento preset di test da preset.json (asincrono). Stesso pattern e 4798 // stessa degradazione controllata di loadHelpTexts(): se il fetch fallisce, 4799 // TEST_PRESETS resta vuoto e il menu preset non compare (vedi 4800 // applyDebugVisibility()), il resto dell'app funziona normalmente. 4801 // ========================================================================== 4802 4803 function loadTestPresets() { 4804 fetch(dataUrl('preset.json')) 4805 .then(function (response) { 4806 if (!response.ok) throw new Error('HTTP ' + response.status); 4807 return response.json(); 4808 }) 4809 .then(function (data) { 4810 TEST_PRESETS = data || []; 4811 populatePresetSelect(); 4812 applyDebugVisibility(); 4813 // Se la modalità debug era già attiva al caricamento (URL/localStorage), 4814 // i preset non erano ancora disponibili quando init() l'ha impostata: 4815 // applica ora il preset di default. 4816 if (state.debug) applyDefaultDebugPreset(); 4817 }) 4818 .catch(function (err) { 4819 console.warn('preset.json non caricato â il menu preset di test non sarà disponibile.', err); 4820 }); 4821 } 4822 4823 // ========================================================================== 4824 // Init 4825 // ========================================================================== 4826
4827 function init() { 4828 FIELD_DEFS.forEach(function (def) { 4829 if (def.kind === 'input' && typeof def.default !== 'undefined') { 4830 state.values[def.id] = def.default; 4831 } 4832 }); 4833 4834 loadDebugPreference(); 4835 populatePresetSelect(); 4836 applyDebugVisibility(); 4837 4838 recompute(); 4839 renderForm(); 4840 if (state.debug) renderDebug(); 4841 4842 loadHelpTexts(); 4843 loadTestPresets(); 4844 } 4845 4846 init(); 4847 } 4848 4849 if (document.readyState === 'loading') { 4850 document.addEventListener('DOMContentLoaded', main); 4851 } else { 4852 main(); 4853 } 4854})(); 4855 4856function initCanicolaMap(){ 4857 var data 4858 var mouseTimer 4859 function init(){ 4860 $.getJSON('/fileadmin/DSS/DSP/canicola/map-data.php', function (r){ 4861 if(r && r[301]){ 4862 data = r 4863 for(x in r){ 4864 $('#canicola_map_container [data-id='+x+']').attr('class', 'lv'+r[x].level) 4865 } 4866 $('#canicola_map_container').removeClass('hidden') 4867 $('#canicola_map #regioni g').hover(mIn, mOut) 4868 } 4869 }) 4870 } 4871 function mIn(){ 4872 4873 if(mouseTimer) clearTimeout(mouseTimer) 4874 4875 var d = data[$(this).data('id')] 4876 var html = '' 4877 html += '<b>Regione</b><br><span>'+d.title+'</span><br>' 4878 html += '<b>Grado</b><br><span>'+d.level+'</span><br>' 4879 if(d.level != 0) html += '<b>Evento</b><br><span>'+d.event+'</span><br>' 4880 // html += '<b>Probabilità </b><br><span>'+d.certainty+'</span><br>' 4881 4882 $('#canicola_map_legend').html(html) 4883 } 4884 function mOut(){ 4885 mouseTimer = setTimeout(function (){ 4886 $('#canicola_map_legend').html('Seleziona una regione per vedere i dettagli sulla canicola') 4887 }, 200) 4888 } 4889 init() 4890} 4891function initComuni(){ 4892 $("#sliderComuni").carousel(); 4893} 4894/* Contatto */ 4895/*function initModuloContattato(){ 4896 var htmlOverlay = '<div class="overlay" tabindex="-1" style="text-align:center; opacity:1;background-color: rgba(0,0,0,0.9)"></div><div class="overlay-close"><div class="inner"><a href="#" title="Chiudi" aria-label="Chiudi"><i class="fa fa-times" aria-hidden="true"></i></a></div></div>'; 4897 var url = '/typo3conf/ext/user_contatti/requests/'; 4898 var contactData = {}; 4899 function init(){ 4900 $('.modulo_contatto').click(openModal); 4901 4902 } 4903 function openModal(e){ 4904 e.preventDefault(); 4905 4906 overlayOpener = $(this); 4907 4908 var data = { 4909 idua: $(this).attr('data-idua'), 4910 dip: $(this).attr('data-dip'), 4911 url: location.href, 4912 title: $(this).attr('data-title') ? $(this).attr('data-title') : $(this).attr('data-titolo'), 4913 lang: $(this).attr('data-lang') ? $(this).attr('data-lang') : 'it' 4914 }; 4915 contactData = data; 4916 4917 $.post(url+'load.php', data, function (r){ 4918 4919 // FIX a problema su IE e FF - se cé un video wowza viene mostrato sopra il form 4920 if($('.tx-tichwowza-pi2 object').length){ 4921 $('.tx-tichwowza-pi2 object').css('visibility', 'hidden'); 4922 } 4923 4924 $('body').append(htmlOverlay); 4925 $('.overlay-close').click(function (e){ 4926 e.preventDefault(); 4927 hideOverlay(); 4928 }); 4929 $('.overlay').html(r); 4930 4931 setTimeout(function (){ 4932 var h = $(".background").outerHeight() + $(".footer").outerHeight(); 4933 var wh = (window.innerHeight|| document.documentElement.clientHeight || document.body.clientHeight) - 50; 4934 var fh = $('#contact-form').height() + 50; 4935 if(h < wh) h = wh; 4936 if(h < fh) h = fh; 4937 if($('#ti-map-form').length) h += 350 4938 $('.overlay').css({'height': h}); 4939 4940 $('html, body').animate({ scrollTop: 0 }, 500); 4941 4942 initForm(); 4943 4944 setTimeout(function (){ $('#contact-form').addClass('shown'); }, 300); 4945 4946 $(window).on('keydown', function (e){ 4947 if(e.keyCode == 27){ 4948 $('.overlay-close a').trigger('click'); 4949 } 4950 }) 4951 }, 400) 4952 4953 }); 4954 } 4955 4956 var errorMessages = { 4957 'it': { 4958 'empty': 'Campo obbligatorio', 4959 'radio-empty': 'Campo obbligatorio', 4960 'email': 'L\'e-mail inserita non è corretta', 4961 'phone': 'Il campo non può contenere caratteri', 4962 'shareThankyou': 'Il messaggio è stato correttamente inviato', 4963 'thankyou': 'Grazie del suo messaggio', 4964 'sent': 'Il messaggio è stato correttamente inviato allâunità amministrativa competente', 4965 'errorTitle': 'Errore di invio', 4966 'errorText': 'Il messaggio non è stato correttamente inviato, la preghiamo di riprovare.</br>Qualora il problema persista contattare [email protected].<br>Grazie della comprensione', 4967 'fillCorrectly': 'Compilare il campo correttamente', 4968 'notEmpty': 'Il campo non può essere vuoto', 4969 'maxFilesize': 'L\'allegato supera il limite consentito di 10MB', 4970 'uploadError': 'Errore durante il caricamento degli allegati', 4971 'wrongFormat': 'Il formato del file selezionato non é permesso' 4972 }, 4973 'en': { 4974 'empty': 'Required field', 4975 'radio-empty': 'Required field', 4976 'email': 'The inserted email is incorrect', 4977 'phone': 'The field can not contain characters', 4978 'shareThankyou': 'The message was successfully sent', 4979 'thankyou': 'Thank you for your message', 4980 'sent': 'The message was successfully sent', 4981 'errorTitle': 'Sending error', 4982 'errorText': 'The message has not been successfully submitted, please try again. <br> If the problem persists contact [email protected]. <br> Thank you for your understanding', 4983 'fillCorrectly': 'Fill in the field correctly', 4984 'notEmpty': 'The field can not be empty', 4985 'maxFilesize': 'The attachment exceeds the allowed limit of 10MB', 4986 'uploadError': 'Error loading attachments', 4987 'wrongFormat': 'The format of the selected file is not allowed' 4988 } 4989 }; 4990 var loadJs = true; 4991 var sendButtonContent = ''; 4992 var uploadButtonContent = ''; 4993 var recaptchaChecked = false;
4994 function initForm(){ 4995 $('#contact-form .send-form').width($('#contact-form .send-form').width()); 4996 sendButtonContent = $('#contact-form .send-form').html(); 4997 4998 $('#contact-form .allegati .add').width($('#contact-form .allegati .add').width()); 4999 uploadButtonContent = $('#contact-form .allegati .add').html(); 5000 5001 $('#contact-form .send-form').click(sendForm); 5002 $('.refresh-button').trigger('click') 5003 $('#contact-form .form-group').each(function (){ 5004 if($(this).children('div.row').length){ 5005 $(this).children('div.row').children().each(function (){ 5006 $(this).append('<div class="error-messages hidden"></div>'); 5007 }) 5008 } 5009 else $(this).append('<div class="error-messages hidden"></div>'); 5010 }); 5011 5012 $('a.info-button').click(function (e){ e.preventDefault(); }); 5013 5014 initMultiUpload(); 5015 5016 $('.overlay .col-xs-4 h4').click(function (){ 5017 $('.overlay .col-xs-8 input[data-check], .overlay .col-xs-8 textarea[data-check]').each(function (){ 5018 var name = ($(this).attr('name') == 'email') ? '[email protected]' : $(this).attr('name'); 5019 $(this).val(name); 5020 }); 5021 }); 5022 5023 if($('.info-button').length){ 5024 $('.info-button').popover(); 5025 $('a.info-button').click(function (e){ e.preventDefault(); }); 5026 } 5027 5028 jQuery("#contact-form").highlighter({ 5029 "selector" : ".holder", 5030 "minWords" : 1 5031 }); 5032 5033 $('#contact-form input[type=text]:first').focus(); 5034 5035 5036 5037 // Tab navigation 5038 mouseTrap($('.overlay input:first'), $('.overlay-close a')); 5039 5040 5041 5042 $('input[type=radio][name=ente]').click(function (){ 5043 if($(this).attr('id') == 'altro_ente'){ 5044 $('#nome_altro_ente').removeClass('hidden'); 5045 $('#nome_comune').addClass('hidden'); 5046 } 5047 else if($(this).attr('id') == 'comune'){ 5048 $('#nome_altro_ente').addClass('hidden'); 5049 $('#nome_comune').removeClass('hidden'); 5050 } 5051 else { 5052 $('#nome_altro_ente').addClass('hidden'); 5053 $('#nome_comune').addClass('hidden'); 5054 } 5055 }); 5056 $('input[type=radio][name=ruolo]').click(function (){ 5057 if($(this).attr('id') == 'altro_ruolo') $('#nome_altro_ruolo').removeClass('hidden'); 5058 else $('#nome_altro_ruolo').addClass('hidden'); 5059 }); 5060 5061 } 5062 function updateCaptcha(e){ 5063 e.preventDefault(); 5064 5065 var src = $(this).siblings('img').attr('src'); 5066 if(src.indexOf('?') > -1){ 5067 tmp = src.split('?'); 5068 src = tmp[0]; 5069 } 5070 src += '?' + Math.random(); 5071 $('.captcha img').attr('src', src); 5072 } 5073 function sendForm(e){ 5074 e.preventDefault(); 5075 5076 var error = false; 5077 $('body').append('<div id="sending-form" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;"></div>'); 5078 $('#contact-form .send-form').html('<i class="fa fa-spinner fa-spin"></i>'); 5079 5080 $('#contact-form [data-check]').each(function (){ 5081 if(!checkField($(this))) error = true; 5082 }); 5083 5084 if($('#ti-map-form').length){ 5085 if($('#coordX').val() == '' || $('#coordY').val() == ''){ 5086 error = true; 5087 $('#ti-map-form').siblings('.error-messages').removeClass('hidden') 5088 $('#tti-map-form > div').css('border-color', '#ebccd1'); 5089 } 5090 else{ 5091 $('#ti-map-form').siblings('.error-messages').addClass('hidden') 5092 $('#ti-map-form > div').css('border-color', '#eee'); 5093 } 5094 } 5095 else { 5096 $('#ti-map-form').siblings('.error-messages').addClass('hidden') 5097 $('#ti-map-form > div').css('border-color', '#eee'); 5098 } 5099 5100 if(!checkCaptchaField()){ 5101 error = true; 5102 } 5103 5104 if(!error){ 5105 sendData(false); 5106 $('#sending-form').remove(); 5107 $('#contact-form .send-form').html(sendButtonContent); 5108 } 5109 else { 5110 $('#sending-form').remove(); 5111 $('#contact-form .send-form').html(sendButtonContent); 5112 $('.form-control.error:first').focus(); 5113 $('.refresh-button').trigger('click'); 5114 } 5115 } 5116 function sendData(attachments){ 5117 var data = contactData; 5118 5119 $('#contact-form [data-check]').each(function (){ 5120 if($(this).attr('data-check') == 'radio-empty'){
5121 var i = $(this).find('input:checked'); 5122 data[i.attr('name')] = i.val(); 5123 } 5124 else if($(this).attr('data-check') == 'checkboxes-empty'){ 5125 var text = []; 5126 $(this).find('input:checked').each(function (){ 5127 text.push($(this).val()); 5128 }); 5129 data[$(this).find('input:first:checked').attr('name')] = text.join(', '); 5130 } 5131 else if($(this).attr('type') == 'checkbox'){ 5132 data[$(this).attr('name')] = ($(this).is(':checked')) ? 'si' : 'no'; 5133 } 5134 else data[$(this).attr('name')] = $(this).val(); 5135 }); 5136 5137 $('#contact-form select:not([data-check])').each(function (){ 5138 data[$(this).attr('name')] = $(this).val(); 5139 }); 5140 5141 $('#contact-form .checkbox').each(function (){ 5142 if($(this).find('> fieldset > div:not([data-check],[class])').length){ 5143 var v = []; 5144 $(this).find('input').each(function (){ 5145 if($(this).is(':checked')) v.push($(this).val()) 5146 }) 5147 if(v.length) data[$(this).find('input:first').attr('name')] = v.join(', '); 5148 } 5149 }) 5150 5151 if($('.allegato:not(.hidden)').length){ 5152 var v = new Array(); 5153 $('.allegato:not(.hidden) input').each(function (){ 5154 v.push($(this).attr('data-file')); 5155 }); 5156 data['allegati'] = v.join(';'); 5157 } 5158 5159 if($('#ti-map-form').length){ 5160 data['coordx'] = $('#coordX').val(); 5161 data['coordy'] = $('#coordY').val(); 5162 } 5163 5164 $.post(url+'send.php', data, function (r){ 5165 $('html, body').animate({ scrollTop: 0 }, 500); 5166 $('#contact-form h2').remove(); 5167 if(r == 'ok'){ 5168 if($('.overlay h1').text() == 'Condividi') var text = '<h2 style="margin: 0 0 10px 0">'+errorMessages[contactData.lang].shareThankyou+'.</h2>'; 5169 else var text = '<h2 style="margin: 0 0 10px 0">'+errorMessages[contactData.lang].thankyou+'</h2><p>'+errorMessages[contactData.lang].sent+'.</p>'; 5170 } 5171 else{ 5172 var text = '<h2 style="margin: 0 0 10px 0">'+errorMessages[contactData.lang].errorTitle+'</h2><p>'+errorMessages[contactData.lang].errorText+'.</p>'; 5173 } 5174 5175 $('#contact-form > .row:eq(1)').html('<div class="col-xs-12 conferma" role="alert">'+text+'</div>'); 5176 $('#contact-form > .row:eq(1) h2').focus(); 5177 5178 }); 5179 } 5180 function checkField(field){ 5181 var error = false; 5182 var checks = field.attr('data-check'); 5183 var messages = new Array(); 5184 var v = field.val(); 5185 if(checks.indexOf(',') > -1) checks = checks.split(','); 5186 else checks = new Array(checks); 5187 5188 if(checks[0] == 'radio-empty'){ 5189 var found = false; 5190 field.find('input').each(function (){ 5191 if($(this).is(':checked')) found = true; 5192 }); 5193 if(!found){ 5194 messages.push('radio-empty'); 5195 error = true; 5196 } 5197 } 5198 else if(checks[0] == 'checkboxes-empty'){ 5199 var found = false; 5200 field.find('input').each(function (){ 5201 if($(this).is(':checked')) found = true; 5202 }); 5203 if(!found){ 5204 messages.push('radio-empty'); 5205 error = true; 5206 } 5207 } 5208 else{ 5209 for(x in checks){ 5210 if(checks[x] == 'empty'){ 5211 if(v == '' || ((v == '-' || v == '0') && field.is('select'))){ 5212 error = true; 5213 messages.push('empty'); 5214 } 5215 } 5216 else if(checks[x] == 'email' && v){ 5217 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,}))$/; 5218 if(!re.test(v)){ 5219 error = true; 5220 messages.push('email'); 5221 } 5222 } 5223 } 5224 } 5225 5226 if(error){ 5227 field.addClass('error'); 5228 field.next().removeClass('hidden').html(getErrorMessage(messages)); 5229 return false;
5230 } 5231 else{ 5232 field.removeClass('error'); 5233 field.next().addClass('hidden'); 5234 return true; 5235 } 5236 } 5237 function checkCaptchaField(){ 5238 var field = $('#contact-form [name=captcha]'); 5239 var error = false; 5240 5241 if(field.val()){ 5242 var r = checkCaptcha(field.val()); 5243 if(r.responseText == 'ok'){ 5244 field.removeClass('error'); 5245 if($('#contact-form .captcha .error-messages').length) $('#contact-form .captcha .error-messages').remove(); 5246 } 5247 else{ 5248 field.addClass('error').val(''); 5249 $('#contact-form .captcha a').trigger('click'); 5250 if($('#contact-form .captcha .error-messages').length) $('#contact-form .captcha .error-messages').remove(); 5251 $('#contact-form .captcha').append('<div class="error-messages"><ul><li>'+errorMessages[contactData.lang].fillCorrectly+'</li></ul></div>') 5252 error = true; 5253 } 5254 } 5255 else{ 5256 field.addClass('error'); 5257 $('#contact-form .captcha a').trigger('click'); 5258 5259 if($('#contact-form .captcha .error-messages').length) $('#contact-form .captcha .error-messages').remove(); 5260 $('#contact-form .captcha').append('<div class="error-messages"><ul><li>'+errorMessages[contactData.lang].notEmpty+'</li></ul></div>') 5261 error = true; 5262 } 5263 5264 if(!error) return true; 5265 return false; 5266 } 5267 function checkCaptcha(value){ 5268 var rand = Math.floor((Math.random() * 100000) + 1); 5269 return $.ajax({ 5270 url: $('base').attr('href')+'typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r='+rand, 5271 data: { 5272 value: value 5273 }, 5274 async: false, 5275 method: 'post' 5276 }); 5277 } 5278 function getErrorMessage(messages){ 5279 var html = '<ul>'; 5280 for(x in messages){ 5281 html += '<li role="alert">'+errorMessages[contactData.lang][messages[x]]+'</li>'; 5282 } 5283 html += '</ul>'; 5284 return html; 5285 } 5286 5287 function hasAttachments(){ 5288 for(x in uploadFile){ 5289 if(uploadFile[x]){ 5290 return true; 5291 } 5292 } 5293 return false; 5294 } 5295 function uploadFiles(event){ 5296 var data = new FormData(); 5297 5298 for(x in uploadFile){ 5299 if(uploadFile[x]){ 5300 $.each(uploadFile[x], function(key, value){ 5301 data.append('file'+x, value); 5302 }); 5303 } 5304 } 5305 5306 $.ajax({ 5307 url: url+'upload.php', // point to server-side PHP script 5308 dataType: 'text', // what to expect back from the PHP script, if anything 5309 cache: false, 5310 contentType: false, 5311 processData: false, 5312 data: data, 5313 type: 'post', 5314 success: function(php_script_response){ 5315 if(php_script_response == 'filesize'){ 5316 if($('#attachments-error').length) $('#attachments-error').remove(); 5317 $('.allegato.hidden').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>'+errorMessages[contactData.lang].maxFilesize+'.</li></ul></div>'); 5318 } 5319 else if(php_script_response == 'error'){ 5320 if($('#attachments-error').length) $('#attachments-error').remove(); 5321 $('.allegato.hidden').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>'+errorMessages[contactData.lang].uploadError+'.</li></ul></div>'); 5322 } 5323 else sendData(php_script_response); 5324 5325 $('#sending-form').remove(); 5326 $('#contact-form .send-form').html(sendButtonContent); 5327 } 5328 }); 5329 } 5330 var uploadFile = {}; 5331 function initMultiUpload(){ 5332 var attachments_n = 1; 5333 var max_weight = 10; 5334 var used_weight = 0; 5335 var working = false; 5336 function init(){ 5337 $('#contact-form').on('click', '.allegati .add', addAttachemnt); 5338 $('#contact-form').on('click', '.allegati .remove', clearAttachemnt); 5339 5340 $('#contact-form').on('change', '.inputfile', change); 5341 } 5342 function addAttachemnt(e){ 5343 e.preventDefault(); 5344 5345 if(!working){ 5346 $(this).siblings('.allegato.hidden.new').remove(); 5347 5348 if($('#attachments-error').length) $('#attachments-error').remove(); 5349 5350 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 5351 $('#contact-form .allegato.new label').attr('for', 'file'+attachments_n); 5352 $('#contact-form .allegato.new input').attr('id', 'file'+attachments_n).attr('name', 'file'+attachments_n); 5353 5354 $('#contact-form .allegato.new input:last').trigger('click'); 5355 5356 attachments_n++; 5357 } 5358 } 5359 function clearAttachemnt(e){ 5360 e.preventDefault(); 5361 5362 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 5363 uploadFile[id] = false;
5364 5365 var p = $(this).parents('.allegato'); 5366 used_weight -= parseInt(p.find('input').attr('data-weight')); 5367 updateWeights(); 5368 5369 p.find('input[type=file]').val(''); 5370 p.find('input[type=file]').next().children('span').text('Allega un file'); 5371 p.remove(); 5372 } 5373 function change(event){ 5374 var id = $(this).attr('id'); 5375 5376 tmp = $(this).val().split("\\"); 5377 var v = tmp[tmp.length - 1]; 5378 5379 if(v){ 5380 tmp2 = v.split('.'); 5381 var ext = tmp2[(tmp2.length - 1)]; 5382 5383 if(ext == 'doc' || ext == 'docx' || ext == 'pdf' || ext == 'jpg' || ext == 'jpeg' || ext == 'png'){ 5384 $('label[for='+id+'] span').text(v); 5385 5386 if($('#attachments-error').length) $('#attachments-error').remove(); 5387 5388 uploadFile[id] = event.target.files; 5389 5390 upload(id, event.target.files); 5391 } 5392 else{ 5393 if($('#attachments-error').length) $('#attachments-error').remove(); 5394 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><p style="color:#c33;position: relative; top: -10px;">'+errorMessages[contactData.lang].wrongFormat+'.</p></div>'); 5395 5396 $('label[for='+id+'] span').text('Allega un file (10Mb massimo)'); 5397 } 5398 } 5399 } 5400 function upload(x, value){ 5401 var data = new FormData(); 5402 var upd = { 5403 x: value 5404 }; 5405 5406 $('body').append('<div id="sending-form" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;"></div>'); 5407 $('#contact-form .allegati .add').html('<i class="fa fa-spinner fa-spin"></i>'); 5408 working = true; 5409 5410 for(x in upd){ 5411 if(upd[x]){ 5412 $.each(upd[x], function(key, value){ 5413 data.append('file'+x, value); 5414 }); 5415 } 5416 } 5417 5418 $.ajax({ 5419 url: url+'upload.php?max='+(max_weight - used_weight), // point to server-side PHP script 5420 dataType: 'text', // what to expect back from the PHP script, if anything 5421 cache: false, 5422 contentType: false, 5423 processData: false, 5424 data: data, 5425 type: 'post', 5426 success: function(php_script_response){ 5427 5428 if(php_script_response == 'filesize'){ 5429 if($('#attachments-error').length) $('#attachments-error').remove(); 5430 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>L'+errorMessages[contactData.lang].maxFilesize+'.</li></ul></div>'); 5431 } 5432 else if(php_script_response == 'error'){ 5433 if($('#attachments-error').length) $('#attachments-error').remove(); 5434 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>'+errorMessages[contactData.lang].uploadError+'.</li></ul></div>'); 5435 } 5436 else{ 5437 var tmp = php_script_response.split('|'); 5438 used_weight += parseInt(tmp[1]); 5439 5440 $('.allegato.new.hidden input').attr('data-file', tmp[0]); 5441 $('.allegato.new.hidden input').attr('data-weight', tmp[1]); 5442 5443 updateWeights() 5444 $('.allegato.new.hidden').removeClass('new hidden'); 5445 } 5446 5447 $('#contact-form .allegati .add').html(uploadButtonContent); 5448 $('#sending-form').remove(); 5449 // $('.allegati .add').removeClass('disabled'); 5450 working = false; 5451 } 5452 }); 5453 } 5454 function updateWeights(){ 5455 if(contactData.lang == 'en') $('.allegati h4').html('Attachments '+(used_weight)+' MB(maximum size allowed 10 MB)'); 5456 else $('.allegati h4').html('Allegati '+(used_weight)+' MB(dimensione massima consentita 10 MB)'); 5457 5458 if(used_weight == max_weight) $('.allegati .add').hide(); 5459 else $('.allegati .add').show(); 5460 } 5461 init(); 5462 } 5463 init(); 5464} 5465*/ 5466function initModuloContattato(){ 5467 5468 var htmlOverlay = '<div class="overlay" tabindex="-1" style="text-align:center; opacity:1;background-color: rgba(0,0,0,0.9)"></div><div class="overlay-close"><div class="inner"><a href="#" title="Chiudi" aria-label="Chiudi"><i class="fa fa-times" aria-hidden="true"></i></a></div></div>'; 5469 var url = '/typo3conf/ext/user_contatti/requests/'; 5470 var contactData = {}; 5471
5472 function init(){ 5473 $('.modulo_contatto').click(openModal); 5474 } 5475 5476 function openModal(e){ 5477 e.preventDefault(); 5478 5479 overlayOpener = $(this); 5480 5481 var data = { 5482 idua: $(this).attr('data-idua'), 5483 dip: $(this).attr('data-dip'), 5484 url: location.href, 5485 title: $(this).attr('data-title') ? $(this).attr('data-title') : $(this).attr('data-titolo'), 5486 lang: $(this).attr('data-lang') ? $(this).attr('data-lang') : 'it' 5487 }; 5488 5489 contactData = data; 5490 5491 $.post(url+'load.php', data, function (r){ 5492 5493 // FIX a problema su IE e FF - se cé un video wowza viene mostrato sopra il form 5494 if($('.tx-tichwowza-pi2 object').length){ 5495 $('.tx-tichwowza-pi2 object').css('visibility', 'hidden'); 5496 } 5497 5498 $('body').append(htmlOverlay); 5499 5500 $('.overlay-close').click(function (e){ 5501 e.preventDefault(); 5502 hideOverlay(); 5503 }); 5504 5505 $('.overlay').html(r); 5506 5507 setTimeout(function (){ 5508 5509 var h = $(".background").outerHeight() + $(".footer").outerHeight(); 5510 var wh = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) - 50; 5511 var fh = $('#contact-form').height() + 50; 5512 5513 if(h < wh) h = wh; 5514 if(h < fh) h = fh; 5515 if($('#ti-map-form').length) h += 350; 5516 5517 $('.overlay').css({'height': h}); 5518 5519 $('html, body').animate({ scrollTop: 0 }, 500); 5520 5521 initForm(); 5522 5523 setTimeout(function (){ 5524 $('#contact-form').addClass('shown'); 5525 }, 300); 5526 5527 $(window).on('keydown', function (e){ 5528 if(e.keyCode == 27){ 5529 $('.overlay-close a').trigger('click'); 5530 } 5531 }); 5532 5533 }, 400); 5534 5535 }); 5536 } 5537 5538 5539 /* Form */ 5540 5541 var errorMessages = { 5542 5543 'it': { 5544 'empty': 'Campo obbligatorio', 5545 'radio-empty': 'Campo obbligatorio', 5546 'email': 'L\'e-mail inserita non è corretta', 5547 'phone': 'Il campo non può contenere caratteri', 5548 'shareThankyou': 'Il messaggio è stato correttamente inviato', 5549 'thankyou': 'Grazie del suo messaggio', 5550 'sent': 'Il messaggio è stato correttamente inviato allâunità amministrativa competente', 5551 'errorTitle': 'Errore di invio', 5552 'errorText': 'Il messaggio non è stato correttamente inviato, la preghiamo di riprovare.</br>Qualora il problema persista contattare [email protected].<br>Grazie della comprensione', 5553 'fillCorrectly': 'Compilare il campo correttamente', 5554 'notEmpty': 'Il campo non può essere vuoto', 5555 'maxFilesize': 'L\'allegato supera il limite consentito di 10MB', 5556 'uploadError': 'Errore durante il caricamento degli allegati', 5557 'wrongFormat': 'Il formato del file selezionato non é permesso' 5558 }, 5559 5560 'en': { 5561 'empty': 'Required field', 5562 'radio-empty': 'Required field', 5563 'email': 'The inserted email is incorrect', 5564 'phone': 'The field can not contain characters', 5565 'shareThankyou': 'The message was successfully sent', 5566 'thankyou': 'Thank you for your message', 5567 'sent': 'The message was successfully sent', 5568 'errorTitle': 'Sending error', 5569 'errorText': 'The message has not been successfully submitted, please try again. <br> If the problem persists contact [email protected]. <br> Thank you for your understanding', 5570 'fillCorrectly': 'Fill in the field correctly', 5571 'notEmpty': 'The field can not be empty', 5572 'maxFilesize': 'The attachment exceeds the allowed limit of 10MB', 5573 'uploadError': 'Error loading attachments', 5574 'wrongFormat': 'The format of the selected file is not allowed' 5575 } 5576 5577 }; 5578 5579 5580 var loadJs = true; 5581 var sendButtonContent = ''; 5582 var uploadButtonContent = ''; 5583 5584 5585 function initForm(){ 5586 5587 $('#contact-form .send-form').width( 5588 $('#contact-form .send-form').width() 5589 ); 5590 5591 sendButtonContent = $('#contact-form .send-form').html(); 5592 5593 5594 $('#contact-form .allegati .add').width( 5595 $('#contact-form .allegati .add').width() 5596 ); 5597 5598 uploadButtonContent = $('#contact-form .allegati .add').html(); 5599 5600 5601 $('#contact-form .send-form').click(sendForm); 5602 5603 5604 $('#contact-form .form-group').each(function (){ 5605 5606 if($(this).children('div.row').length){ 5607 5608 $(this).children('div.row').children().each(function (){ 5609 5610 $(this).append( 5611 '<div class="error-messages hidden"></div>' 5612 ); 5613 5614 }); 5615 5616 } 5617 else{ 5618 5619 $(this).append( 5620 '<div class="error-messages hidden"></div>' 5621 ); 5622 5623 } 5624 5625 }); 5626 5627 5628 $('a.info-button').click(function (e){ 5629 e.preventDefault(); 5630 }); 5631 5632 5633 initMultiUpload(); 5634 5635
5636 $('.overlay .col-xs-4 h4').click(function (){ 5637 5638 $('.overlay .col-xs-8 input[data-check], .overlay .col-xs-8 textarea[data-check]').each(function (){ 5639 5640 var name = ($(this).attr('name') == 'email') 5641 ? '[email protected]' 5642 : $(this).attr('name'); 5643 5644 $(this).val(name); 5645 5646 }); 5647 5648 }); 5649 5650 5651 if($('.info-button').length){ 5652 5653 $('.info-button').popover(); 5654 5655 $('a.info-button').click(function (e){ 5656 e.preventDefault(); 5657 }); 5658 5659 } 5660 5661 5662 jQuery("#contact-form").highlighter({ 5663 "selector" : ".holder", 5664 "minWords" : 1 5665 }); 5666 5667 5668 $('#contact-form input[type=text]:first').focus(); 5669 5670 5671 // Tab navigation 5672 mouseTrap( 5673 $('.overlay input:first'), 5674 $('.overlay-close a') 5675 ); 5676 5677 5678 $('input[type=radio][name=ente]').click(function (){ 5679 5680 if($(this).attr('id') == 'altro_ente'){ 5681 5682 $('#nome_altro_ente').removeClass('hidden'); 5683 $('#nome_comune').addClass('hidden'); 5684 5685 } 5686 else if($(this).attr('id') == 'comune'){ 5687 5688 $('#nome_altro_ente').addClass('hidden'); 5689 $('#nome_comune').removeClass('hidden'); 5690 5691 } 5692 else{ 5693 5694 $('#nome_altro_ente').addClass('hidden'); 5695 $('#nome_comune').addClass('hidden'); 5696 5697 } 5698 5699 }); 5700 5701 5702 $('input[type=radio][name=ruolo]').click(function (){ 5703 5704 if($(this).attr('id') == 'altro_ruolo'){ 5705 5706 $('#nome_altro_ruolo').removeClass('hidden'); 5707 5708 } 5709 else{ 5710 5711 $('#nome_altro_ruolo').addClass('hidden'); 5712 5713 } 5714 5715 }); 5716 5717 } 5718 5719 5720 /** 5721 * GOOGLE RECAPTCHA 5722 * 5723 * Restituisce true solamente se 5724 * "Non sono un robot" è stato selezionato. 5725 */ 5726 function checkCaptchaField(){ 5727 5728 var response = ''; 5729 5730 5731 if(typeof grecaptcha !== 'undefined'){ 5732 5733 response = grecaptcha.getResponse(); 5734 5735 } 5736 5737 5738 if(!response){ 5739 5740 if($('#contact-form .captcha .error-messages').length){ 5741 5742 $('#contact-form .captcha .error-messages').remove(); 5743 5744 } 5745 5746 5747 $('#contact-form .captcha').append( 5748 '<div class="error-messages">' + 5749 '<ul>' + 5750 '<li role="alert">' + 5751 errorMessages[contactData.lang].notEmpty + 5752 '</li>' + 5753 '</ul>' + 5754 '</div>' 5755 ); 5756 5757 5758 return false; 5759 5760 } 5761 5762 5763 $('#contact-form .captcha .error-messages').remove(); 5764 5765 5766 return true; 5767 } 5768 5769 5770 function sendForm(e){ 5771 5772 e.preventDefault(); 5773 5774 5775 var error = false; 5776 5777 5778 $('body').append( 5779 '<div id="sending-form" ' + 5780 'style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;">' + 5781 '</div>' 5782 ); 5783 5784 5785 $('#contact-form .send-form').html( 5786 '<i class="fa fa-spinner fa-spin"></i>' 5787 ); 5788 5789 5790 /** 5791 * Controllo campi normali 5792 */ 5793 $('#contact-form [data-check]').each(function (){ 5794 5795 if(!checkField($(this))){ 5796 5797 error = true; 5798 5799 } 5800 5801 }); 5802 5803 5804 /** 5805 * Controllo mappa 5806 */ 5807 if($('#ti-map-form').length){ 5808 5809 if( 5810 $('#coordX').val() == '' 5811 || 5812 $('#coordY').val() == '' 5813 ){ 5814 5815 error = true; 5816 5817 5818 $('#ti-map-form') 5819 .siblings('.error-messages') 5820 .removeClass('hidden'); 5821 5822 5823 $('#ti-map-form > div') 5824 .css( 5825 'border-color', 5826 '#ebccd1' 5827 ); 5828 5829 } 5830 else{ 5831 5832 $('#ti-map-form') 5833 .siblings('.error-messages') 5834 .addClass('hidden'); 5835 5836
5837 $('#ti-map-form > div') 5838 .css( 5839 'border-color', 5840 '#eee' 5841 ); 5842 5843 } 5844 5845 } 5846 else{ 5847 5848 $('#ti-map-form') 5849 .siblings('.error-messages') 5850 .addClass('hidden'); 5851 5852 } 5853 5854 5855 /** 5856 * GOOGLE RECAPTCHA 5857 */ 5858 if(!checkCaptchaField()){ 5859 5860 error = true; 5861 5862 } 5863 5864 5865 /** 5866 * Invio 5867 */ 5868 if(!error){ 5869 5870 sendData(false); 5871 5872 5873 $('#sending-form').remove(); 5874 5875 5876 $('#contact-form .send-form').html( 5877 sendButtonContent 5878 ); 5879 5880 } 5881 else{ 5882 5883 $('#sending-form').remove(); 5884 5885 5886 $('#contact-form .send-form').html( 5887 sendButtonContent 5888 ); 5889 5890 5891 $('.form-control.error:first').focus(); 5892 5893 } 5894 5895 } 5896 5897 5898 function sendData(attachments){ 5899 5900 var data = contactData; 5901 5902 5903 /** 5904 * Campi con validazione 5905 */ 5906 $('#contact-form [data-check]').each(function (){ 5907 5908 if( 5909 $(this).attr('data-check') 5910 == 5911 'radio-empty' 5912 ){ 5913 5914 var i = $(this).find( 5915 'input:checked' 5916 ); 5917 5918 5919 if(i.length){ 5920 5921 data[i.attr('name')] = i.val(); 5922 5923 } 5924 5925 } 5926 else if( 5927 $(this).attr('data-check') 5928 == 5929 'checkboxes-empty' 5930 ){ 5931 5932 var text = []; 5933 5934 5935 $(this) 5936 .find('input:checked') 5937 .each(function (){ 5938 5939 text.push( 5940 $(this).val() 5941 ); 5942 5943 }); 5944 5945 5946 var checkboxName = 5947 $(this) 5948 .find('input:first') 5949 .attr('name'); 5950 5951 5952 if(checkboxName){ 5953 5954 data[checkboxName] = 5955 text.join(', '); 5956 5957 } 5958 5959 } 5960 else if( 5961 $(this).attr('type') 5962 == 5963 'checkbox' 5964 ){ 5965 5966 data[$(this).attr('name')] = 5967 ($(this).is(':checked')) 5968 ? 'si' 5969 : 'no'; 5970 5971 } 5972 else{ 5973 5974 data[$(this).attr('name')] = 5975 $(this).val(); 5976 5977 } 5978 5979 }); 5980 5981 5982 /** 5983 * Select senza data-check 5984 */ 5985 $('#contact-form select:not([data-check])').each(function (){ 5986 5987 data[$(this).attr('name')] = 5988 $(this).val(); 5989 5990 }); 5991 5992 5993 /** 5994 * Checkbox multiple 5995 */ 5996 $('#contact-form .checkbox').each(function (){ 5997 5998 if( 5999 $(this) 6000 .find('> fieldset > div:not([data-check],[class])') 6001 .length 6002 ){ 6003 6004 var v = []; 6005 6006 6007 $(this).find('input').each(function (){ 6008 6009 if($(this).is(':checked')){ 6010 6011 v.push( 6012 $(this).val() 6013 ); 6014 6015 } 6016 6017 }); 6018 6019 6020 if(v.length){ 6021 6022 var checkboxName = 6023 $(this) 6024 .find('input:first') 6025 .attr('name'); 6026 6027 6028 if(checkboxName){ 6029 6030 data[checkboxName] = 6031 v.join(', '); 6032 6033 } 6034 6035 } 6036 6037 } 6038 6039 }); 6040 6041 6042 /** 6043 * Allegati 6044 */ 6045 if($('.allegato:not(.hidden)').length){ 6046 6047 var allegati = new Array(); 6048 6049 6050 $('.allegato:not(.hidden) input').each(function (){ 6051 6052 allegati.push( 6053 $(this).attr('data-file') 6054 ); 6055 6056 }); 6057 6058 6059 data['allegati'] = 6060 allegati.join(';'); 6061 6062 } 6063 6064 6065 /** 6066 * Coordinate 6067 */ 6068 if($('#ti-map-form').length){ 6069
6070 data['coordx'] = 6071 $('#coordX').val(); 6072 6073 data['coordy'] = 6074 $('#coordY').val(); 6075 6076 } 6077 6078 6079 /** 6080 * GOOGLE RECAPTCHA 6081 * 6082 * Il PHP riceve: 6083 * 6084 * $_POST['g-recaptcha-response'] 6085 */ 6086 if(typeof grecaptcha !== 'undefined'){ 6087 6088 data['g-recaptcha-response'] = 6089 grecaptcha.getResponse(); 6090 6091 } 6092 else{ 6093 6094 data['g-recaptcha-response'] = ''; 6095 6096 } 6097 6098 6099 /** 6100 * Invio AJAX 6101 */ 6102 $.post( 6103 url+'send.php', 6104 data, 6105 function (r){ 6106 6107 $('html, body').animate( 6108 { 6109 scrollTop: 0 6110 }, 6111 500 6112 ); 6113 6114 6115 $('#contact-form h2').remove(); 6116 6117 6118 if(r == 'ok'){ 6119 6120 if( 6121 $('.overlay h1').text() 6122 == 6123 'Condividi' 6124 ){ 6125 6126 var text = 6127 '<h2 style="margin: 0 0 10px 0">' + 6128 errorMessages[contactData.lang].shareThankyou + 6129 '.</h2>'; 6130 6131 } 6132 else{ 6133 6134 var text = 6135 '<h2 style="margin: 0 0 10px 0">' + 6136 errorMessages[contactData.lang].thankyou + 6137 '</h2>' + 6138 '<p>' + 6139 errorMessages[contactData.lang].sent + 6140 '.</p>'; 6141 6142 } 6143 6144 } 6145 else{ 6146 6147 var text = 6148 '<h2 style="margin: 0 0 10px 0">' + 6149 errorMessages[contactData.lang].errorTitle + 6150 '</h2>' + 6151 '<p>' + 6152 errorMessages[contactData.lang].errorText + 6153 '.</p>'; 6154 6155 6156 /** 6157 * Il token Google è utilizzabile una sola volta. 6158 * Se l'invio fallisce lo resettiamo. 6159 */ 6160 if(typeof grecaptcha !== 'undefined'){ 6161 6162 grecaptcha.reset(); 6163 6164 } 6165 6166 } 6167 6168 6169 $('#contact-form > .row:eq(1)').html( 6170 '<div class="col-xs-12 conferma" role="alert">' + 6171 text + 6172 '</div>' 6173 ); 6174 6175 6176 $('#contact-form > .row:eq(1) h2').focus(); 6177 6178 } 6179 ); 6180 6181 } 6182 6183 6184 function checkField(field){ 6185 6186 var error = false; 6187 6188 var checks = 6189 field.attr('data-check'); 6190 6191 var messages = 6192 new Array(); 6193 6194 var v = 6195 field.val(); 6196 6197 6198 if(checks.indexOf(',') > -1){ 6199 6200 checks = 6201 checks.split(','); 6202 6203 } 6204 else{ 6205 6206 checks = 6207 new Array(checks); 6208 6209 } 6210 6211 6212 if(checks[0] == 'radio-empty'){ 6213 6214 var found = false; 6215 6216 6217 field.find('input').each(function (){ 6218 6219 if($(this).is(':checked')){ 6220 6221 found = true; 6222 6223 } 6224 6225 }); 6226 6227 6228 if(!found){ 6229 6230 messages.push( 6231 'radio-empty' 6232 ); 6233 6234 error = true; 6235 6236 } 6237 6238 } 6239 else if( 6240 checks[0] 6241 == 6242 'checkboxes-empty' 6243 ){ 6244 6245 var found = false; 6246 6247 6248 field.find('input').each(function (){ 6249 6250 if($(this).is(':checked')){ 6251 6252 found = true; 6253 6254 } 6255 6256 }); 6257 6258 6259 if(!found){ 6260 6261 messages.push( 6262 'radio-empty' 6263 ); 6264 6265 error = true; 6266 6267 } 6268 6269 } 6270 else{ 6271 6272 for(x in checks){ 6273 6274 if(checks[x] == 'empty'){ 6275 6276 if( 6277 v == '' 6278 || 6279 ( 6280 (v == '-' || v == '0') 6281 && 6282 field.is('select') 6283 ) 6284 ){ 6285 6286 error = true; 6287 6288 messages.push( 6289 'empty' 6290 ); 6291 6292 } 6293 6294 } 6295 else if( 6296 checks[x] == 'email' 6297 && 6298 v 6299 ){ 6300 6301 var re = 6302 /^(([^<>()\[\]\\.,;:\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,}))$/; 6303 6304 6305 if(!re.test(v)){ 6306 6307 error = true; 6308 6309 messages.push( 6310 'email' 6311 ); 6312 6313 } 6314 6315 } 6316 6317 } 6318 6319 } 6320 6321 6322 if(error){ 6323 6324 field.addClass('error'); 6325 6326 6327 field 6328 .next() 6329 .removeClass('hidden') 6330 .html( 6331 getErrorMessage(messages) 6332 ); 6333 6334 6335 return false;
6336 6337 } 6338 else{ 6339 6340 field.removeClass('error'); 6341 6342 6343 field 6344 .next() 6345 .addClass('hidden'); 6346 6347 6348 return true; 6349 6350 } 6351 6352 } 6353 6354 6355 function getErrorMessage(messages){ 6356 6357 var html = '<ul>'; 6358 6359 6360 for(x in messages){ 6361 6362 html += 6363 '<li role="alert">' + 6364 errorMessages[contactData.lang][messages[x]] + 6365 '</li>'; 6366 6367 } 6368 6369 6370 html += '</ul>'; 6371 6372 6373 return html; 6374 6375 } 6376 6377 6378 /* Allegati */ 6379 6380 function hasAttachments(){ 6381 6382 for(x in uploadFile){ 6383 6384 if(uploadFile[x]){ 6385 6386 return true; 6387 6388 } 6389 6390 } 6391 6392 6393 return false; 6394 6395 } 6396 6397 6398 function uploadFiles(event){ 6399 6400 var data = 6401 new FormData(); 6402 6403 6404 for(x in uploadFile){ 6405 6406 if(uploadFile[x]){ 6407 6408 $.each( 6409 uploadFile[x], 6410 function(key, value){ 6411 6412 data.append( 6413 'file'+x, 6414 value 6415 ); 6416 6417 } 6418 ); 6419 6420 } 6421 6422 } 6423 6424 6425 $.ajax({ 6426 6427 url: 6428 url+'upload.php', 6429 6430 dataType: 6431 'text', 6432 6433 cache: 6434 false, 6435 6436 contentType: 6437 false, 6438 6439 processData: 6440 false, 6441 6442 data: 6443 data, 6444 6445 type: 6446 'post', 6447 6448 success: 6449 function(php_script_response){ 6450 6451 if( 6452 php_script_response 6453 == 6454 'filesize' 6455 ){ 6456 6457 if( 6458 $('#attachments-error').length 6459 ){ 6460 6461 $('#attachments-error').remove(); 6462 6463 } 6464 6465 6466 $('.allegato.hidden').after( 6467 '<div id="attachments-error">' + 6468 '<ul style="color:#c33;position: relative; top: -10px;">' + 6469 '<li>' + 6470 errorMessages[contactData.lang].maxFilesize + 6471 '.</li>' + 6472 '</ul>' + 6473 '</div>' 6474 ); 6475 6476 } 6477 else if( 6478 php_script_response 6479 == 6480 'error' 6481 ){ 6482 6483 if( 6484 $('#attachments-error').length 6485 ){ 6486 6487 $('#attachments-error').remove(); 6488 6489 } 6490 6491 6492 $('.allegato.hidden').after( 6493 '<div id="attachments-error">' + 6494 '<ul style="color:#c33;position: relative; top: -10px;">' + 6495 '<li>' + 6496 errorMessages[contactData.lang].uploadError + 6497 '.</li>' + 6498 '</ul>' + 6499 '</div>' 6500 ); 6501 6502 } 6503 else{ 6504 6505 sendData( 6506 php_script_response 6507 ); 6508 6509 } 6510 6511 6512 $('#sending-form').remove(); 6513 6514 6515 $('#contact-form .send-form').html( 6516 sendButtonContent 6517 ); 6518 6519 } 6520 6521 }); 6522 6523 } 6524 6525 6526 var uploadFile = {}; 6527 6528 6529 function initMultiUpload(){ 6530 6531 var attachments_n = 1; 6532 6533 var max_weight = 10; 6534 6535 var used_weight = 0; 6536 6537 var working = false; 6538 6539 6540 function init(){ 6541 6542 $('#contact-form').on( 6543 'click', 6544 '.allegati .add', 6545 addAttachemnt 6546 ); 6547 6548 6549 $('#contact-form').on( 6550 'click', 6551 '.allegati .remove', 6552 clearAttachemnt 6553 ); 6554 6555 6556 $('#contact-form').on( 6557 'change', 6558 '.inputfile', 6559 change 6560 ); 6561 6562 } 6563 6564 6565 function addAttachemnt(e){ 6566 6567 e.preventDefault(); 6568 6569 6570 if(!working){ 6571 6572 $(this) 6573 .siblings('.allegato.hidden.new') 6574 .remove(); 6575 6576 6577 if( 6578 $('#attachments-error').length 6579 ){ 6580 6581 $('#attachments-error').remove(); 6582 6583 } 6584 6585 6586 $(this) 6587 .prev() 6588 .before( 6589 $(this) 6590 .siblings('.allegato.hidden') 6591 .clone() 6592 .addClass('new') 6593 ); 6594 6595 6596 $('#contact-form .allegato.new label') 6597 .attr( 6598 'for', 6599 'file'+attachments_n 6600 ); 6601 6602 6603 $('#contact-form .allegato.new input') 6604 .attr( 6605 'id', 6606 'file'+attachments_n 6607 ) 6608 .attr( 6609 'name', 6610 'file'+attachments_n 6611 ); 6612 6613 6614 $('#contact-form .allegato.new input:last') 6615 .trigger('click'); 6616 6617 6618 attachments_n++; 6619 6620 } 6621 6622 } 6623 6624 6625 function clearAttachemnt(e){ 6626 6627 e.preventDefault(); 6628 6629 6630 var id = 6631 $(this) 6632 .parents('.allegato') 6633 .find('input[type=file]') 6634 .attr('id'); 6635 6636 6637 uploadFile[id] = false;
6638 6639 6640 var p = 6641 $(this).parents('.allegato'); 6642 6643 6644 used_weight -= 6645 parseInt( 6646 p.find('input') 6647 .attr('data-weight') 6648 ); 6649 6650 6651 updateWeights(); 6652 6653 6654 p.find('input[type=file]') 6655 .val(''); 6656 6657 6658 p.find('input[type=file]') 6659 .next() 6660 .children('span') 6661 .text('Allega un file'); 6662 6663 6664 p.remove(); 6665 6666 } 6667 6668 6669 function change(event){ 6670 6671 var id = 6672 $(this).attr('id'); 6673 6674 6675 tmp = 6676 $(this) 6677 .val() 6678 .split("\\"); 6679 6680 6681 var v = 6682 tmp[tmp.length - 1]; 6683 6684 6685 if(v){ 6686 6687 tmp2 = 6688 v.split('.'); 6689 6690 6691 var ext = 6692 tmp2[tmp2.length - 1]; 6693 6694 6695 if( 6696 ext == 'doc' 6697 || 6698 ext == 'docx' 6699 || 6700 ext == 'pdf' 6701 || 6702 ext == 'jpg' 6703 || 6704 ext == 'jpeg' 6705 || 6706 ext == 'png' 6707 ){ 6708 6709 $('label[for='+id+'] span') 6710 .text(v); 6711 6712 6713 if( 6714 $('#attachments-error').length 6715 ){ 6716 6717 $('#attachments-error').remove(); 6718 6719 } 6720 6721 6722 uploadFile[id] = 6723 event.target.files; 6724 6725 6726 upload( 6727 id, 6728 event.target.files 6729 ); 6730 6731 } 6732 else{ 6733 6734 if( 6735 $('#attachments-error').length 6736 ){ 6737 6738 $('#attachments-error').remove(); 6739 6740 } 6741 6742 6743 $('.allegato.hidden:not(.new)').after( 6744 '<div id="attachments-error">' + 6745 '<p style="color:#c33;position: relative; top: -10px;">' + 6746 errorMessages[contactData.lang].wrongFormat + 6747 '.</p>' + 6748 '</div>' 6749 ); 6750 6751 6752 $('label[for='+id+'] span') 6753 .text( 6754 'Allega un file (10Mb massimo)' 6755 ); 6756 6757 } 6758 6759 } 6760 6761 } 6762 6763 6764 function upload(x, value){ 6765 6766 var data = 6767 new FormData(); 6768 6769 6770 var upd = { 6771 x: value 6772 }; 6773 6774 6775 $('body').append( 6776 '<div id="sending-form" ' + 6777 'style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;">' + 6778 '</div>' 6779 ); 6780 6781 6782 $('#contact-form .allegati .add').html( 6783 '<i class="fa fa-spinner fa-spin"></i>' 6784 ); 6785 6786 6787 working = true; 6788 6789 6790 for(x in upd){ 6791 6792 if(upd[x]){ 6793 6794 $.each( 6795 upd[x], 6796 function(key, value){ 6797 6798 data.append( 6799 'file'+x, 6800 value 6801 ); 6802 6803 } 6804 ); 6805 6806 } 6807 6808 } 6809 6810 6811 $.ajax({ 6812 6813 url: 6814 url + 6815 'upload.php?max=' + 6816 (max_weight - used_weight), 6817 6818 dataType: 6819 'text', 6820 6821 cache: 6822 false, 6823 6824 contentType: 6825 false, 6826 6827 processData: 6828 false, 6829 6830 data: 6831 data, 6832 6833 type: 6834 'post', 6835 6836 success: 6837 function(php_script_response){ 6838 6839 if( 6840 php_script_response 6841 == 6842 'filesize' 6843 ){ 6844 6845 if( 6846 $('#attachments-error').length 6847 ){ 6848 6849 $('#attachments-error').remove(); 6850 6851 } 6852 6853 6854 $('.allegato.hidden:not(.new)').after( 6855 '<div id="attachments-error">' + 6856 '<ul style="color:#c33;position: relative; top: -10px;">' + 6857 '<li>' + 6858 errorMessages[contactData.lang].maxFilesize + 6859 '.</li>' + 6860 '</ul>' + 6861 '</div>' 6862 ); 6863 6864 } 6865 else if( 6866 php_script_response 6867 == 6868 'error' 6869 ){ 6870 6871 if( 6872 $('#attachments-error').length 6873 ){ 6874 6875 $('#attachments-error').remove(); 6876 6877 } 6878 6879 6880 $('.allegato.hidden:not(.new)').after( 6881 '<div id="attachments-error">' + 6882 '<ul style="color:#c33;position: relative; top: -10px;">' + 6883 '<li>' + 6884 errorMessages[contactData.lang].uploadError + 6885 '.</li>' + 6886 '</ul>' + 6887 '</div>' 6888 ); 6889 6890 } 6891 else{ 6892 6893 var tmp = 6894 php_script_response.split('|'); 6895 6896 6897 used_weight += 6898 parseInt( 6899 tmp[1] 6900 ); 6901 6902 6903 $('.allegato.new.hidden input') 6904 .attr( 6905 'data-file', 6906 tmp[0] 6907 ); 6908 6909 6910 $('.allegato.new.hidden input') 6911 .attr( 6912 'data-weight', 6913 tmp[1] 6914 ); 6915 6916 6917 updateWeights(); 6918 6919 6920 $('.allegato.new.hidden') 6921 .removeClass( 6922 'new hidden' 6923 ); 6924 6925 } 6926 6927 6928 $('#contact-form .allegati .add').html( 6929 uploadButtonContent 6930 ); 6931 6932 6933 $('#sending-form').remove(); 6934 6935 6936 working = false;
6937 6938 } 6939 6940 }); 6941 6942 } 6943 6944 6945 function updateWeights(){ 6946 6947 if(contactData.lang == 'en'){ 6948 6949 $('.allegati h4').html( 6950 'Attachments ' + 6951 used_weight + 6952 ' MB(maximum size allowed 10 MB)' 6953 ); 6954 6955 } 6956 else{ 6957 6958 $('.allegati h4').html( 6959 'Allegati ' + 6960 used_weight + 6961 ' MB(dimensione massima consentita 10 MB)' 6962 ); 6963 6964 } 6965 6966 6967 if(used_weight == max_weight){ 6968 6969 $('.allegati .add').hide(); 6970 6971 } 6972 else{ 6973 6974 $('.allegati .add').show(); 6975 6976 } 6977 6978 } 6979 6980 6981 init(); 6982 6983 } 6984 6985 6986 init(); 6987 6988} 6989 6990/*function initModuloContattatoPage(){ 6991 6992 var url = '/typo3conf/ext/user_contatti/requests/'; 6993 var contactData = { 6994 lang: $.urlParam('lang') 6995 }; 6996 function init(){ 6997 initForm(); 6998 $('#contact-form').addClass('shown'); 6999 } 7000 7001 7002 var errorMessages = { 7003 'it': { 7004 'empty': 'Campo obbligatorio', 7005 'radio-empty': 'Campo obbligatorio', 7006 'email': 'L\'e-mail inserita non è corretta', 7007 'phone': 'Il campo non può contenere caratteri', 7008 'shareThankyou': 'Il messaggio è stato correttamente inviato', 7009 'thankyou': 'Grazie del suo messaggio', 7010 'sent': 'Il messaggio è stato correttamente inviato allâunità amministrativa competente', 7011 'errorTitle': 'Errore di invio', 7012 'errorText': 'Il messaggio non è stato correttamente inviato, la preghiamo di riprovare.</br>Qualora il problema persista contattare [email protected].<br>Grazie della comprensione', 7013 'fillCorrectly': 'Compilare il campo correttamente', 7014 'notEmpty': 'Il campo non può essere vuoto', 7015 'maxFilesize': 'L\'allegato supera il limite consentito di 10MB', 7016 'uploadError': 'Errore durante il caricamento degli allegati', 7017 'wrongFormat': 'Il formato del file selezionato non é permesso' 7018 }, 7019 'en': { 7020 'empty': 'Required field', 7021 'radio-empty': 'Required field', 7022 'email': 'The inserted email is incorrect', 7023 'phone': 'The field can not contain characters', 7024 'shareThankyou': 'The message was successfully sent', 7025 'thankyou': 'Thank you for your message', 7026 'sent': 'The message was successfully sent', 7027 'errorTitle': 'Sending error', 7028 'errorText': 'The message has not been successfully submitted, please try again. <br> If the problem persists contact [email protected]. <br> Thank you for your understanding', 7029 'fillCorrectly': 'Fill in the field correctly', 7030 'notEmpty': 'The field can not be empty', 7031 'maxFilesize': 'The attachment exceeds the allowed limit of 10MB', 7032 'uploadError': 'Error loading attachments', 7033 'wrongFormat': 'The format of the selected file is not allowed' 7034 } 7035 }; 7036 var loadJs = true; 7037 var sendButtonContent = ''; 7038 var uploadButtonContent = ''; 7039 var recaptchaChecked = false; 7040 function initForm(){ 7041 $('#contact-form .send-form').width($('#contact-form .send-form').width()); 7042 sendButtonContent = $('#contact-form .send-form').html(); 7043 7044 $('#contact-form .allegati .add').width($('#contact-form .allegati .add').width()); 7045 uploadButtonContent = $('#contact-form .allegati .add').html(); 7046 7047 $('#contact-form .send-form').click(sendForm); 7048 $('#contact-form .form-group').each(function (){ 7049 if($(this).children('div.row').length){ 7050 $(this).children('div.row').children().each(function (){ 7051 $(this).append('<div class="error-messages hidden"></div>'); 7052 }) 7053 } 7054 else $(this).append('<div class="error-messages hidden"></div>'); 7055 }); 7056 7057 $('a.info-button').click(function (e){ e.preventDefault(); }); 7058 7059 initMultiUpload(); 7060 7061 if($('.info-button').length){ 7062 $('.info-button').popover(); 7063 $('a.info-button').click(function (e){ e.preventDefault(); }); 7064 } 7065 setTimeout(function (){ 7066 $('#contact-form input[type=text]:first').focus(); 7067 }, 1000) 7068 7069 } 7070 function updateCaptcha(e){ 7071 e.preventDefault(); 7072 7073 var src = $('#captcha_image').attr('src'); 7074 if(src.indexOf('?') > -1){ 7075 tmp = src.split('?'); 7076 src = tmp[0]; 7077 } 7078 src += '?' + Math.random(); 7079 $('.captcha img').attr('src', src); 7080 } 7081 function sendForm(e){ 7082 e.preventDefault(); 7083 7084 var error = false;
7085 $('body').append('<div id="sending-form" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;"></div>'); 7086 $('#contact-form .send-form').html('<i class="fa fa-spinner fa-spin"></i>'); 7087 7088 $('#contact-form [data-check]').each(function (){ 7089 if(!checkField($(this))) error = true; 7090 }); 7091 7092 if(!checkCaptchaField()){ 7093 error = true; 7094 } 7095 7096 if(!error){ 7097 sendData(false); 7098 $('#sending-form').remove(); 7099 $('#contact-form .send-form').html(sendButtonContent); 7100 } 7101 else { 7102 $('#sending-form').remove(); 7103 $('#contact-form .send-form').html(sendButtonContent); 7104 $('.form-control.error:first').focus(); 7105 } 7106 } 7107 function sendData(attachments){ 7108 var data = contactData; 7109 $('#contact-form [data-check]').each(function (){ 7110 if($(this).attr('data-check') == 'radio-empty'){ 7111 var i = $(this).find('input:checked'); 7112 data[i.attr('name')] = i.val(); 7113 } 7114 else if($(this).attr('type') == 'checkbox'){ 7115 data[$(this).attr('name')] = ($(this).is(':checked')) ? 'si' : 'no'; 7116 } 7117 else data[$(this).attr('name')] = $(this).val(); 7118 }); 7119 7120 $('#contact-form select:not([data-check])').each(function (){ 7121 data[$(this).attr('name')] = $(this).val(); 7122 }); 7123 7124 7125 data['idua'] = $.urlParam('idua'); 7126 data['dip'] = $.urlParam('dip'); 7127 data['lang'] = $.urlParam('lang'); 7128 7129 if($('.allegato:not(.hidden)').length){ 7130 var v = new Array(); 7131 $('.allegato:not(.hidden) input').each(function (){ 7132 v.push($(this).attr('data-file')); 7133 }); 7134 data['allegati'] = v.join(';'); 7135 } 7136 7137 $.post(url+'send.php', data, function (r){ 7138 $('html, body').animate({ scrollTop: 0 }, 500); 7139 $('#contact-form h2').remove(); 7140 7141 if(r == 'ok'){ 7142 if($('.overlay h1').text() == 'Condividi') var text = '<h2>'+errorMessages[contactData.lang].shareThankyou+'.</h2>'; 7143 else var text = '<h2>'+errorMessages[contactData.lang].thankyou+'</h2><p>'+errorMessages[contactData.lang].sent+'.</p>'; 7144 } 7145 else{ 7146 var text = '<h2>'+errorMessages[contactData.lang].errorTitle+'</h2><p>'+errorMessages[contactData.lang].errorText+'.</p>'; 7147 } 7148 7149 // if(contactData.lang == 'en') msg = '<h2>Grazie del suo messaggio.</h2><p>Il messaggio è stato correttamente inviato allâunità amministrativa competente.</p>'; 7150 // else msg = '<h2>Thank you for your message.</h2><p>The message has been successfully sent to the appropriate administrative department.</p>'; 7151 $('#contact-form > .row:eq(1)').html('<div class="thankyou">'+text+'</div>'); 7152 }); 7153 } 7154 function checkField(field){ 7155 var error = false; 7156 var checks = field.attr('data-check'); 7157 var messages = new Array(); 7158 var v = field.val(); 7159 if(checks.indexOf(',') > -1) checks = checks.split(','); 7160 else checks = new Array(checks); 7161 7162 if(checks[0] == 'radio-empty'){ 7163 var found = false; 7164 field.find('input').each(function (){ 7165 if($(this).is(':checked')) found = true; 7166 }); 7167 if(!found){ 7168 messages.push('radio-empty'); 7169 error = true; 7170 } 7171 } 7172 else{ 7173 for(x in checks){ 7174 if(checks[x] == 'empty'){ 7175 if(v == '' || ((v == '-' || v == '0') && field.is('select'))){ 7176 error = true; 7177 messages.push('empty'); 7178 } 7179 } 7180 else if(checks[x] == 'email' && v){ 7181 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,}))$/; 7182 if(!re.test(v)){ 7183 error = true; 7184 messages.push('email'); 7185 } 7186 } 7187 } 7188 } 7189 7190 if(error){ 7191 field.addClass('error'); 7192 field.next().removeClass('hidden').html(getErrorMessage(messages)); 7193 return false;
7194 } 7195 else{ 7196 field.removeClass('error'); 7197 field.next().addClass('hidden'); 7198 return true; 7199 } 7200 } 7201 function checkCaptchaField(){ 7202 var field = $('#contact-form [name=captcha]'); 7203 var error = false; 7204 7205 if(field.val()){ 7206 var r = checkCaptcha(field.val()); 7207 if(r.responseText == 'ok'){ 7208 field.removeClass('error'); 7209 if($('#contact-form .captcha .error-messages').length) $('#contact-form .captcha .error-messages').remove(); 7210 } 7211 else{ 7212 field.addClass('error').val(''); 7213 $('#contact-form .captcha a').trigger('click'); 7214 7215 if(!$('#contact-form .captcha .error-messages').length) $('#contact-form .captcha').append('<div class="error-messages"><ul><li>'+errorMessages[contactData.lang].fillCorrectly+'</li></ul></div>') 7216 error = true; 7217 } 7218 } 7219 else{ 7220 field.addClass('error'); 7221 $('#contact-form .captcha a').trigger('click'); 7222 7223 if(!$('#contact-form .captcha .error-messages').length) $('#contact-form .captcha').append('<div class="error-messages"><ul><li>'+errorMessages[contactData.lang].notEmpty+'</li></ul></div>') 7224 error = true; 7225 } 7226 7227 if(!error) return true; 7228 return false; 7229 } 7230 function checkCaptcha(value){ 7231 return $.ajax({ 7232 url: $('base').attr('href')+'typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php', 7233 data: { 7234 value: value 7235 }, 7236 async: false, 7237 method: 'post' 7238 }); 7239 } 7240 function getErrorMessage(messages){ 7241 var html = '<ul>'; 7242 for(x in messages){ 7243 html += '<li>'+errorMessages[contactData.lang][messages[x]]+'</li>'; 7244 } 7245 html += '</ul>'; 7246 return html; 7247 } 7248 7249 function hasAttachments(){ 7250 for(x in uploadFile){ 7251 if(uploadFile[x]){ 7252 return true; 7253 } 7254 } 7255 return false; 7256 } 7257 function uploadFiles(event){ 7258 var data = new FormData(); 7259 7260 for(x in uploadFile){ 7261 if(uploadFile[x]){ 7262 $.each(uploadFile[x], function(key, value){ 7263 data.append('file'+x, value); 7264 }); 7265 } 7266 } 7267 7268 $.ajax({ 7269 url: url+'upload.php', // point to server-side PHP script 7270 dataType: 'text', // what to expect back from the PHP script, if anything 7271 cache: false, 7272 contentType: false, 7273 processData: false, 7274 data: data, 7275 type: 'post', 7276 success: function(php_script_response){ 7277 if(php_script_response == 'filesize'){ 7278 if($('#attachments-error').length) $('#attachments-error').remove(); 7279 $('.allegato.hidden').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>'+errorMessages[contactData.lang].maxFilesize+'.</li></ul></div>'); 7280 } 7281 else if(php_script_response == 'error'){ 7282 if($('#attachments-error').length) $('#attachments-error').remove(); 7283 $('.allegato.hidden').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>'+errorMessages[contactData.lang].uploadError+'.</li></ul></div>'); 7284 } 7285 else sendData(php_script_response); 7286 7287 $('#sending-form').remove(); 7288 $('#contact-form .send-form').html(sendButtonContent); 7289 } 7290 }); 7291 } 7292 var uploadFile = {}; 7293 function initMultiUpload(){ 7294 var attachments_n = 1; 7295 var max_weight = 10; 7296 var used_weight = 0; 7297 var working = false; 7298 function init(){ 7299 $('#contact-form').on('click', '.allegati .add', addAttachemnt); 7300 $('#contact-form').on('click', '.allegati .remove', clearAttachemnt); 7301 $('#contact-form').on('change', '.inputfile', change); 7302 } 7303 function addAttachemnt(e){ 7304 e.preventDefault(); 7305 7306 if(!working){ 7307 $(this).siblings('.allegato.hidden.new').remove(); 7308 7309 if($('#attachments-error').length) $('#attachments-error').remove(); 7310 7311 // var n = $('#contact-form .allegato').length - 1; 7312 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 7313 $('#contact-form .allegato.new label').attr('for', 'file'+attachments_n); 7314 $('#contact-form .allegato.new input').attr('id', 'file'+attachments_n).attr('name', 'file'+attachments_n); 7315 7316 $('#contact-form .allegato.new input:last').trigger('click'); 7317 7318 attachments_n++; 7319 } 7320 } 7321 function clearAttachemnt(e){ 7322 e.preventDefault(); 7323 7324 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 7325 uploadFile[id] = false;
7326 7327 var p = $(this).parents('.allegato'); 7328 used_weight -= parseInt(p.find('input').attr('data-weight')); 7329 updateWeights(); 7330 7331 p.find('input[type=file]').val(''); 7332 p.find('input[type=file]').next().children('span').text('Allega un file'); 7333 p.remove(); 7334 } 7335 function change(event){ 7336 var id = $(this).attr('id'); 7337 7338 tmp = $(this).val().split("\\"); 7339 var v = tmp[tmp.length - 1]; 7340 7341 if(v){ 7342 tmp2 = v.split('.'); 7343 var ext = tmp2[(tmp2.length - 1)]; 7344 7345 if(ext == 'exe' || ext == 'bat' || ext == 'com'){ 7346 if($('#attachments-error').length) $('#attachments-error').remove(); 7347 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><p style="color:#c33;position: relative; top: -10px;">'+errorMessages[contactData.lang].wrongFormat+'.</p></div>'); 7348 7349 $('label[for='+id+'] span').text('Allega un file (10Mb massimo)'); 7350 } 7351 else{ 7352 $('label[for='+id+'] span').text(v); 7353 7354 if($('#attachments-error').length) $('#attachments-error').remove(); 7355 7356 uploadFile[id] = event.target.files; 7357 7358 upload(id, event.target.files); 7359 } 7360 } 7361 } 7362 function upload(x, value){ 7363 var data = new FormData(); 7364 var upd = { 7365 x: value 7366 }; 7367 7368 $('body').append('<div id="sending-form" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;"></div>'); 7369 $('#contact-form .allegati .add').html('<i class="fa fa-spinner fa-spin"></i>'); 7370 // $('.allegati .add').addClass('disabled'); 7371 working = true; 7372 7373 for(x in upd){ 7374 if(upd[x]){ 7375 $.each(upd[x], function(key, value){ 7376 data.append('file'+x, value); 7377 }); 7378 } 7379 } 7380 7381 $.ajax({ 7382 url: url+'upload.php?max='+(max_weight - used_weight), // point to server-side PHP script 7383 dataType: 'text', // what to expect back from the PHP script, if anything 7384 cache: false, 7385 contentType: false, 7386 processData: false, 7387 data: data, 7388 type: 'post', 7389 success: function(php_script_response){ 7390 7391 if(php_script_response == 'filesize'){ 7392 if($('#attachments-error').length) $('#attachments-error').remove(); 7393 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>'+errorMessages[contactData.lang].maxFilesize+'.</li></ul></div>'); 7394 } 7395 else if(php_script_response == 'error'){ 7396 if($('#attachments-error').length) $('#attachments-error').remove(); 7397 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>'+errorMessages[contactData.lang].uploadError+'.</li></ul></div>'); 7398 } 7399 else{ 7400 var tmp = php_script_response.split('|'); 7401 used_weight += parseInt(tmp[1]); 7402 7403 $('.allegato.new.hidden input').attr('data-file', tmp[0]); 7404 $('.allegato.new.hidden input').attr('data-weight', tmp[1]); 7405 7406 updateWeights() 7407 $('.allegato.new.hidden').removeClass('new hidden'); 7408 } 7409 7410 $('#contact-form .allegati .add').html(uploadButtonContent); 7411 $('#sending-form').remove(); 7412 // $('.allegati .add').removeClass('disabled'); 7413 working = false; 7414 7415 // else sendData(php_script_response); 7416 // $('#sending-form').remove(); 7417 // $('#contact-form .send-form').html(sendButtonContent); 7418 } 7419 }); 7420 } 7421 function updateWeights(){ 7422 if(contactData.lang == 'en') $('.allegati h4').html('Attachments '+(used_weight)+' MB(maximum size allowed 10 MB)'); 7423 else $('.allegati h4').html('Allegati '+(used_weight)+' MB(dimensione massima consentita 10 MB)'); 7424 7425 if(used_weight == max_weight) $('.allegati .add').hide(); 7426 else $('.allegati .add').show(); 7427 } 7428 init(); 7429 } 7430 init(); 7431}*/ 7432 7433function initModuloContattatoPage(){ 7434 7435 var url = 7436 '/typo3conf/ext/user_contatti/requests/'; 7437 7438 7439 var contactData = { 7440 7441 lang: 7442 $.urlParam('lang') 7443 ? $.urlParam('lang') 7444 : 'it' 7445 7446 }; 7447 7448
7449 function init(){ 7450 7451 initForm(); 7452 7453 7454 $('#contact-form') 7455 .addClass('shown'); 7456 7457 } 7458 7459 7460 var errorMessages = { 7461 7462 'it': { 7463 7464 'empty': 7465 'Campo obbligatorio', 7466 7467 'radio-empty': 7468 'Campo obbligatorio', 7469 7470 'email': 7471 'L\'e-mail inserita non è corretta', 7472 7473 'phone': 7474 'Il campo non può contenere caratteri', 7475 7476 'shareThankyou': 7477 'Il messaggio è stato correttamente inviato', 7478 7479 'thankyou': 7480 'Grazie del suo messaggio', 7481 7482 'sent': 7483 'Il messaggio è stato correttamente inviato allâunità amministrativa competente', 7484 7485 'errorTitle': 7486 'Errore di invio', 7487 7488 'errorText': 7489 'Il messaggio non è stato correttamente inviato, la preghiamo di riprovare.</br>Qualora il problema persista contattare [email protected].<br>Grazie della comprensione', 7490 7491 'fillCorrectly': 7492 'Compilare il campo correttamente', 7493 7494 'notEmpty': 7495 'Il campo non può essere vuoto', 7496 7497 'maxFilesize': 7498 'L\'allegato supera il limite consentito di 10MB', 7499 7500 'uploadError': 7501 'Errore durante il caricamento degli allegati', 7502 7503 'wrongFormat': 7504 'Il formato del file selezionato non é permesso' 7505 7506 }, 7507 7508 7509 'en': { 7510 7511 'empty': 7512 'Required field', 7513 7514 'radio-empty': 7515 'Required field', 7516 7517 'email': 7518 'The inserted email is incorrect', 7519 7520 'phone': 7521 'The field can not contain characters', 7522 7523 'shareThankyou': 7524 'The message was successfully sent', 7525 7526 'thankyou': 7527 'Thank you for your message', 7528 7529 'sent': 7530 'The message was successfully sent', 7531 7532 'errorTitle': 7533 'Sending error', 7534 7535 'errorText': 7536 'The message has not been successfully submitted, please try again. <br> If the problem persists contact [email protected]. <br> Thank you for your understanding', 7537 7538 'fillCorrectly': 7539 'Fill in the field correctly', 7540 7541 'notEmpty': 7542 'The field can not be empty', 7543 7544 'maxFilesize': 7545 'The attachment exceeds the allowed limit of 10MB', 7546 7547 'uploadError': 7548 'Error loading attachments', 7549 7550 'wrongFormat': 7551 'The format of the selected file is not allowed' 7552 7553 } 7554 7555 }; 7556 7557 7558 var loadJs = true; 7559 7560 var sendButtonContent = ''; 7561 7562 var uploadButtonContent = ''; 7563 7564 7565 function initForm(){ 7566 7567 $('#contact-form .send-form').width( 7568 $('#contact-form .send-form').width() 7569 ); 7570 7571 7572 sendButtonContent = 7573 $('#contact-form .send-form').html(); 7574 7575 7576 $('#contact-form .allegati .add').width( 7577 $('#contact-form .allegati .add').width() 7578 ); 7579 7580 7581 uploadButtonContent = 7582 $('#contact-form .allegati .add').html(); 7583 7584 7585 $('#contact-form .send-form').click( 7586 sendForm 7587 ); 7588 7589 7590 $('#contact-form .form-group').each(function (){ 7591 7592 if( 7593 $(this) 7594 .children('div.row') 7595 .length 7596 ){ 7597 7598 $(this) 7599 .children('div.row') 7600 .children() 7601 .each(function (){ 7602 7603 $(this).append( 7604 '<div class="error-messages hidden"></div>' 7605 ); 7606 7607 }); 7608 7609 } 7610 else{ 7611 7612 $(this).append( 7613 '<div class="error-messages hidden"></div>' 7614 ); 7615 7616 } 7617 7618 }); 7619 7620 7621 $('a.info-button').click(function (e){ 7622 7623 e.preventDefault(); 7624 7625 }); 7626 7627 7628 initMultiUpload(); 7629 7630 7631 if($('.info-button').length){ 7632 7633 $('.info-button').popover(); 7634 7635 7636 $('a.info-button').click(function (e){ 7637 7638 e.preventDefault(); 7639 7640 }); 7641 7642 } 7643 7644 7645 setTimeout(function (){ 7646 7647 $('#contact-form input[type=text]:first') 7648 .focus(); 7649 7650 }, 1000); 7651 7652 } 7653 7654 //GOOGLE RECAPTCHA 7655 7656 function checkCaptchaField(){ 7657 7658 var response = ''; 7659 7660 7661 if( 7662 typeof grecaptcha 7663 !== 7664 'undefined' 7665 ){ 7666 7667 response = 7668 grecaptcha.getResponse(); 7669 7670 } 7671 7672 7673 if(!response){ 7674 7675 if( 7676 $('#contact-form .captcha .error-messages') 7677 .length 7678 ){ 7679 7680 $('#contact-form .captcha .error-messages') 7681 .remove(); 7682 7683 } 7684 7685 7686 $('#contact-form .captcha').append( 7687 '<div class="error-messages">' + 7688 '<ul>' + 7689 '<li role="alert">
7689' + 7690 errorMessages[contactData.lang].notEmpty + 7691 '</li>' + 7692 '</ul>' + 7693 '</div>' 7694 ); 7695 7696 7697 return false; 7698 7699 } 7700 7701 7702 $('#contact-form .captcha .error-messages') 7703 .remove(); 7704 7705 7706 return true; 7707 7708 } 7709 7710 7711 function sendForm(e){ 7712 7713 e.preventDefault(); 7714 7715 7716 var error = false; 7717 7718 7719 $('body').append( 7720 '<div id="sending-form" ' + 7721 'style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;">' + 7722 '</div>' 7723 ); 7724 7725 7726 $('#contact-form .send-form').html( 7727 '<i class="fa fa-spinner fa-spin"></i>' 7728 ); 7729 7730 7731 7732 //Controllo campi 7733 7734 $('#contact-form [data-check]').each(function (){ 7735 7736 if(!checkField($(this))){ 7737 7738 error = true; 7739 7740 } 7741 7742 }); 7743 7744 7745 7746 //GOOGLE RECAPTCHA 7747 7748 if(!checkCaptchaField()){ 7749 7750 error = true; 7751 7752 } 7753 7754 7755 if(!error){ 7756 7757 sendData(false); 7758 7759 7760 $('#sending-form').remove(); 7761 7762 7763 $('#contact-form .send-form').html( 7764 sendButtonContent 7765 ); 7766 7767 } 7768 else{ 7769 7770 $('#sending-form').remove(); 7771 7772 7773 $('#contact-form .send-form').html( 7774 sendButtonContent 7775 ); 7776 7777 7778 $('.form-control.error:first').focus(); 7779 7780 } 7781 7782 } 7783 7784 7785 function sendData(attachments){ 7786 7787 var data = contactData; 7788 7789 7790 7791 //Campi 7792 7793 $('#contact-form [data-check]').each(function (){ 7794 7795 if( 7796 $(this).attr('data-check') 7797 == 7798 'radio-empty' 7799 ){ 7800 7801 var i = 7802 $(this).find( 7803 'input:checked' 7804 ); 7805 7806 7807 if(i.length){ 7808 7809 data[i.attr('name')] = 7810 i.val(); 7811 7812 } 7813 7814 } 7815 else if( 7816 $(this).attr('type') 7817 == 7818 'checkbox' 7819 ){ 7820 7821 data[$(this).attr('name')] = 7822 ($(this).is(':checked')) 7823 ? 'si' 7824 : 'no'; 7825 7826 } 7827 else{ 7828 7829 data[$(this).attr('name')] = 7830 $(this).val(); 7831 7832 } 7833 7834 }); 7835 7836 7837 7838 // Select 7839 7840 $('#contact-form select:not([data-check])').each(function (){ 7841 7842 data[$(this).attr('name')] = 7843 $(this).val(); 7844 7845 }); 7846 7847 7848 7849 // Parametri pagina 7850 7851 data['idua'] = 7852 $.urlParam('idua'); 7853 7854 7855 data['dip'] = 7856 $.urlParam('dip'); 7857 7858 7859 data['lang'] = 7860 $.urlParam('lang') 7861 ? $.urlParam('lang') 7862 : 'it'; 7863 7864 7865 7866 //GOOGLE RECAPTCHA 7867 7868 if(typeof grecaptcha !== 'undefined'){ 7869 7870 data['g-recaptcha-response'] = 7871 grecaptcha.getResponse(); 7872 7873 } 7874 else{ 7875 7876 data['g-recaptcha-response'] = ''; 7877 7878 } 7879 7880 7881 //allegati 7882 if($('.allegato:not(.hidden)').length){ 7883 7884 var allegati = 7885 new Array(); 7886 7887 7888 $('.allegato:not(.hidden) input').each(function (){ 7889 7890 allegati.push( 7891 $(this).attr('data-file') 7892 ); 7893 7894 }); 7895 7896 7897 data['allegati'] = 7898 allegati.join(';'); 7899 7900 } 7901 7902 7903 //INVIO 7904 $.post( 7905 url+'send.php', 7906 data, 7907 function (r){ 7908 7909 $('html, body').animate( 7910 { 7911 scrollTop: 0 7912 }, 7913 500 7914 ); 7915 7916 7917 $('#contact-form h2').remove(); 7918 7919 7920 if(r == 'ok'){ 7921 7922 if( 7923 $('.overlay h1').text() 7924 == 7925 'Condividi' 7926 ){ 7927 7928 var text = 7929 '<h2>' + 7930 errorMessages[contactData.lang].shareThankyou + 7931 '.</h2>'; 7932 7933 } 7934 else{ 7935 7936 var text = 7937 '<h2>' + 7938 errorMessages[contactData.lang].thankyou + 7939 '</h2>' + 7940 '<p>' + 7941 errorMessages[contactData.lang].sent + 7942 '.</p>'; 7943 7944 } 7945 7946 } 7947 else{ 7948 7949 var text = 7950 '<h2>' + 7951 errorMessages[contactData.lang].errorTitle + 7952 '</h2>' + 7953 '<p>' + 7954 errorMessages[contactData.lang].errorText + 7955 '.</p>'; 7956 7957 7958 if(typeof grecaptcha !== 'undefined'){ 7959 7960 grecaptcha.reset(); 7961 7962 } 7963 7964 } 7965 7966 7967 $('#contact-form > .row:eq(1)').html( 7968 '<div class="thankyou">' + 7969 text + 7970 '</div>' 7971 ); 7972 7973 } 7974 ); 7975 7976 } 7977 7978 7979 function checkField(field){ 7980 7981 var error = false;
7982 7983 var checks = 7984 field.attr('data-check'); 7985 7986 var messages = 7987 new Array(); 7988 7989 var v = 7990 field.val(); 7991 7992 7993 if(checks.indexOf(',') > -1){ 7994 7995 checks = 7996 checks.split(','); 7997 7998 } 7999 else{ 8000 8001 checks = 8002 new Array(checks); 8003 8004 } 8005 8006 8007 if( 8008 checks[0] 8009 == 8010 'radio-empty' 8011 ){ 8012 8013 var found = false; 8014 8015 8016 field.find('input').each(function (){ 8017 8018 if($(this).is(':checked')){ 8019 8020 found = true; 8021 8022 } 8023 8024 }); 8025 8026 8027 if(!found){ 8028 8029 messages.push( 8030 'radio-empty' 8031 ); 8032 8033 error = true; 8034 8035 } 8036 8037 } 8038 else{ 8039 8040 for(x in checks){ 8041 8042 if( 8043 checks[x] 8044 == 8045 'empty' 8046 ){ 8047 8048 if( 8049 v == '' 8050 || 8051 ( 8052 (v == '-' || v == '0') 8053 && 8054 field.is('select') 8055 ) 8056 ){ 8057 8058 error = true; 8059 8060 messages.push( 8061 'empty' 8062 ); 8063 8064 } 8065 8066 } 8067 else if( 8068 checks[x] 8069 == 8070 'email' 8071 && 8072 v 8073 ){ 8074 8075 var re = 8076 /^(([^<>()\[\]\\.,;:\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,}))$/; 8077 8078 8079 if(!re.test(v)){ 8080 8081 error = true; 8082 8083 messages.push( 8084 'email' 8085 ); 8086 8087 } 8088 8089 } 8090 8091 } 8092 8093 } 8094 8095 8096 if(error){ 8097 8098 field.addClass( 8099 'error' 8100 ); 8101 8102 8103 field 8104 .next() 8105 .removeClass('hidden') 8106 .html( 8107 getErrorMessage(messages) 8108 ); 8109 8110 8111 return false; 8112 8113 } 8114 else{ 8115 8116 field.removeClass( 8117 'error' 8118 ); 8119 8120 8121 field 8122 .next() 8123 .addClass( 8124 'hidden' 8125 ); 8126 8127 8128 return true; 8129 8130 } 8131 8132 } 8133 8134 8135 function getErrorMessage(messages){ 8136 8137 var html = 8138 '<ul>'; 8139 8140 8141 for(x in messages){ 8142 8143 html += 8144 '<li>' + 8145 errorMessages[contactData.lang][messages[x]] + 8146 '</li>'; 8147 8148 } 8149 8150 8151 html += 8152 '</ul>'; 8153 8154 8155 return html; 8156 8157 } 8158 8159 8160 8161 8162 function hasAttachments(){ 8163 8164 for(x in uploadFile){ 8165 8166 if(uploadFile[x]){ 8167 8168 return true; 8169 8170 } 8171 8172 } 8173 8174 8175 return false; 8176 8177 } 8178 8179 8180 function uploadFiles(event){ 8181 8182 var data = 8183 new FormData(); 8184 8185 8186 for(x in uploadFile){ 8187 8188 if(uploadFile[x]){ 8189 8190 $.each( 8191 uploadFile[x], 8192 function(key, value){ 8193 8194 data.append( 8195 'file'+x, 8196 value 8197 ); 8198 8199 } 8200 ); 8201 8202 } 8203 8204 } 8205 8206 8207 $.ajax({ 8208 8209 url: 8210 url+'upload.php', 8211 8212 dataType: 8213 'text', 8214 8215 cache: 8216 false, 8217 8218 contentType: 8219 false, 8220 8221 processData: 8222 false, 8223 8224 data: 8225 data, 8226 8227 type: 8228 'post', 8229 8230 success: 8231 function(php_script_response){ 8232 8233 if( 8234 php_script_response 8235 == 8236 'filesize' 8237 ){ 8238 8239 if( 8240 $('#attachments-error').length 8241 ){ 8242 8243 $('#attachments-error').remove(); 8244 8245 } 8246 8247 8248 $('.allegato.hidden').after( 8249 '<div id="attachments-error">' + 8250 '<ul style="color:#c33;position: relative; top: -10px;">' + 8251 '<li>' + 8252 errorMessages[contactData.lang].maxFilesize + 8253 '.</li>' + 8254 '</ul>' + 8255 '</div>' 8256 ); 8257 8258 } 8259 else if( 8260 php_script_response 8261 == 8262 'error' 8263 ){ 8264 8265 if( 8266 $('#attachments-error').length 8267 ){ 8268 8269 $('#attachments-error').remove(); 8270 8271 } 8272 8273 8274 $('.allegato.hidden').after( 8275 '<div id="attachments-error">' + 8276 '<ul style="color:#c33;position: relative; top: -10px;">' + 8277 '<li>' + 8278 errorMessages[contactData.lang].uploadError + 8279 '.</li>' + 8280 '</ul>' + 8281 '</div>' 8282 ); 8283 8284 } 8285 else{ 8286 8287 sendData( 8288 php_script_response 8289 ); 8290 8291 } 8292 8293 8294 $('#sending-form').remove(); 8295 8296 8297 $('#contact-form .send-form').html( 8298 sendButtonContent 8299 ); 8300 8301 } 8302 8303 }); 8304 8305 } 8306 8307 8308 var uploadFile = {}; 8309 8310 8311 function initMultiUpload(){ 8312 8313 var attachments_n = 1; 8314 8315 var max_weight = 10; 8316 8317 var used_weight = 0; 8318 8319 var working = false;
8320 8321 8322 function init(){ 8323 8324 $('#contact-form').on( 8325 'click', 8326 '.allegati .add', 8327 addAttachemnt 8328 ); 8329 8330 8331 $('#contact-form').on( 8332 'click', 8333 '.allegati .remove', 8334 clearAttachemnt 8335 ); 8336 8337 8338 $('#contact-form').on( 8339 'change', 8340 '.inputfile', 8341 change 8342 ); 8343 8344 } 8345 8346 8347 function addAttachemnt(e){ 8348 8349 e.preventDefault(); 8350 8351 8352 if(!working){ 8353 8354 $(this) 8355 .siblings( 8356 '.allegato.hidden.new' 8357 ) 8358 .remove(); 8359 8360 8361 if( 8362 $('#attachments-error').length 8363 ){ 8364 8365 $('#attachments-error') 8366 .remove(); 8367 8368 } 8369 8370 8371 $(this) 8372 .prev() 8373 .before( 8374 $(this) 8375 .siblings('.allegato.hidden') 8376 .clone() 8377 .addClass('new') 8378 ); 8379 8380 8381 $('#contact-form .allegato.new label') 8382 .attr( 8383 'for', 8384 'file'+attachments_n 8385 ); 8386 8387 8388 $('#contact-form .allegato.new input') 8389 .attr( 8390 'id', 8391 'file'+attachments_n 8392 ) 8393 .attr( 8394 'name', 8395 'file'+attachments_n 8396 ); 8397 8398 8399 $('#contact-form .allegato.new input:last') 8400 .trigger( 8401 'click' 8402 ); 8403 8404 8405 attachments_n++; 8406 8407 } 8408 8409 } 8410 8411 8412 function clearAttachemnt(e){ 8413 8414 e.preventDefault(); 8415 8416 8417 var id = 8418 $(this) 8419 .parents('.allegato') 8420 .find('input[type=file]') 8421 .attr('id'); 8422 8423 8424 uploadFile[id] = 8425 false; 8426 8427 8428 var p = 8429 $(this) 8430 .parents('.allegato'); 8431 8432 8433 used_weight -= 8434 parseInt( 8435 p.find('input') 8436 .attr('data-weight') 8437 ); 8438 8439 8440 updateWeights(); 8441 8442 8443 p.find('input[type=file]') 8444 .val(''); 8445 8446 8447 p.find('input[type=file]') 8448 .next() 8449 .children('span') 8450 .text( 8451 'Allega un file' 8452 ); 8453 8454 8455 p.remove(); 8456 8457 } 8458 8459 8460 function change(event){ 8461 8462 var id = 8463 $(this).attr('id'); 8464 8465 8466 tmp = 8467 $(this) 8468 .val() 8469 .split("\\"); 8470 8471 8472 var v = 8473 tmp[ 8474 tmp.length - 1 8475 ]; 8476 8477 8478 if(v){ 8479 8480 tmp2 = 8481 v.split('.'); 8482 8483 8484 var ext = 8485 tmp2[ 8486 tmp2.length - 1 8487 ]; 8488 8489 8490 if( 8491 ext == 'exe' 8492 || 8493 ext == 'bat' 8494 || 8495 ext == 'com' 8496 ){ 8497 8498 if( 8499 $('#attachments-error').length 8500 ){ 8501 8502 $('#attachments-error').remove(); 8503 8504 } 8505 8506 8507 $('.allegato.hidden:not(.new)').after( 8508 '<div id="attachments-error">' + 8509 '<p style="color:#c33;position: relative; top: -10px;">' + 8510 errorMessages[contactData.lang].wrongFormat + 8511 '.</p>' + 8512 '</div>' 8513 ); 8514 8515 8516 $('label[for='+id+'] span') 8517 .text( 8518 'Allega un file (10Mb massimo)' 8519 ); 8520 8521 } 8522 else{ 8523 8524 $('label[for='+id+'] span') 8525 .text(v); 8526 8527 8528 if( 8529 $('#attachments-error').length 8530 ){ 8531 8532 $('#attachments-error') 8533 .remove(); 8534 8535 } 8536 8537 8538 uploadFile[id] = 8539 event.target.files; 8540 8541 8542 upload( 8543 id, 8544 event.target.files 8545 ); 8546 8547 } 8548 8549 } 8550 8551 } 8552 8553 8554 function upload(x, value){ 8555 8556 var data = 8557 new FormData(); 8558 8559 8560 var upd = { 8561 x: value 8562 }; 8563 8564 8565 $('body').append( 8566 '<div id="sending-form" ' + 8567 'style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;">' + 8568 '</div>' 8569 ); 8570 8571 8572 $('#contact-form .allegati .add') 8573 .html( 8574 '<i class="fa fa-spinner fa-spin"></i>' 8575 ); 8576 8577 8578 working = true; 8579 8580 8581 for(x in upd){ 8582 8583 if(upd[x]){ 8584 8585 $.each( 8586 upd[x], 8587 function(key, value){ 8588 8589 data.append( 8590 'file'+x, 8591 value 8592 ); 8593 8594 } 8595 ); 8596 8597 } 8598 8599 } 8600 8601 8602 $.ajax({ 8603 8604 url: 8605 url + 8606 'upload.php?max=' + 8607 (max_weight - used_weight),
8608 8609 dataType: 8610 'text', 8611 8612 cache: 8613 false, 8614 8615 contentType: 8616 false, 8617 8618 processData: 8619 false, 8620 8621 data: 8622 data, 8623 8624 type: 8625 'post', 8626 8627 success: 8628 function(php_script_response){ 8629 8630 if( 8631 php_script_response 8632 == 8633 'filesize' 8634 ){ 8635 8636 if( 8637 $('#attachments-error').length 8638 ){ 8639 8640 $('#attachments-error') 8641 .remove(); 8642 8643 } 8644 8645 8646 $('.allegato.hidden:not(.new)').after( 8647 '<div id="attachments-error">' + 8648 '<ul style="color:#c33;position: relative; top: -10px;">' + 8649 '<li>' + 8650 errorMessages[contactData.lang].maxFilesize + 8651 '.</li>' + 8652 '</ul>' + 8653 '</div>' 8654 ); 8655 8656 } 8657 else if( 8658 php_script_response 8659 == 8660 'error' 8661 ){ 8662 8663 if( 8664 $('#attachments-error').length 8665 ){ 8666 8667 $('#attachments-error') 8668 .remove(); 8669 8670 } 8671 8672 8673 $('.allegato.hidden:not(.new)').after( 8674 '<div id="attachments-error">' + 8675 '<ul style="color:#c33;position: relative; top: -10px;">' + 8676 '<li>' + 8677 errorMessages[contactData.lang].uploadError + 8678 '.</li>' + 8679 '</ul>' + 8680 '</div>' 8681 ); 8682 8683 } 8684 else{ 8685 8686 var tmp = 8687 php_script_response 8688 .split('|'); 8689 8690 8691 used_weight += 8692 parseInt( 8693 tmp[1] 8694 ); 8695 8696 8697 $('.allegato.new.hidden input') 8698 .attr( 8699 'data-file', 8700 tmp[0] 8701 ); 8702 8703 8704 $('.allegato.new.hidden input') 8705 .attr( 8706 'data-weight', 8707 tmp[1] 8708 ); 8709 8710 8711 updateWeights(); 8712 8713 8714 $('.allegato.new.hidden') 8715 .removeClass( 8716 'new hidden' 8717 ); 8718 8719 } 8720 8721 8722 $('#contact-form .allegati .add') 8723 .html( 8724 uploadButtonContent 8725 ); 8726 8727 8728 $('#sending-form') 8729 .remove(); 8730 8731 8732 working = 8733 false; 8734 8735 } 8736 8737 }); 8738 8739 } 8740 8741 8742 function updateWeights(){ 8743 8744 if( 8745 contactData.lang 8746 == 8747 'en' 8748 ){ 8749 8750 $('.allegati h4').html( 8751 'Attachments ' + 8752 used_weight + 8753 ' MB(maximum size allowed 10 MB)' 8754 ); 8755 8756 } 8757 else{ 8758 8759 $('.allegati h4').html( 8760 'Allegati ' + 8761 used_weight + 8762 ' MB(dimensione massima consentita 10 MB)' 8763 ); 8764 8765 } 8766 8767 8768 if( 8769 used_weight 8770 == 8771 max_weight 8772 ){ 8773 8774 $('.allegati .add') 8775 .hide(); 8776 8777 } 8778 else{ 8779 8780 $('.allegati .add') 8781 .show(); 8782 8783 } 8784 8785 } 8786 8787 8788 init(); 8789 8790 } 8791 8792 8793 init(); 8794 8795} 8796 8797/* CPA */ 8798function initCPA() { 8799 $('#contenitore').addClass('cpa-container'); 8800} 8801 8802function initCPANew(){ 8803 $('.flipster').flipster({ 8804 style: 'carousel', 8805 buttons: true, 8806 loop: true 8807 }); 8808 $('.flipster .next').click(function (e){ 8809 e.preventDefault() 8810 $('.flip-item.flip-next').trigger('click') 8811 }) 8812 $('.flipster .prev').click(function (e){ 8813 e.preventDefault() 8814 $('.flip-item.flip-prev').trigger('click') 8815 }) 8816 8817 $('.cpa_results td a.opener').click(function (){ 8818 var i = $(this).children('i') 8819 if(i.hasClass('fa-angle-down')){ 8820 i.removeClass('fa-angle-down').addClass('fa-angle-up') 8821 $(this).parents('tr').next().removeClass('hidden') 8822 } 8823 else{ 8824 i.removeClass('fa-angle-up').addClass('fa-angle-down') 8825 $(this).parents('tr').next().addClass('hidden') 8826 } 8827 }) 8828 8829 $('.dropdown-menu[aria-labelledby=dropdownMenu1] a').click(function (){ 8830 location.href = $(this).attr('href') 8831 }) 8832 8833 $('.dropdown.range .dropdown-menu input, .dropdown.range .dropdown-menu label').click(function (e){ 8834 e.stopPropagation() 8835 8836 }); 8837 8838 $('.col-xs-2:eq(5) .dropdown-menu').click(function (e){ 8839 e.stopPropagation() 8840 }) 8841 8842 8843 $(".js-range-slider").ionRangeSlider({ 8844 type: "double", 8845 min: $(".js-range-slider").data('inizio'), 8846 max: $(".js-range-slider").data('fine'), 8847 from: $(".js-range-slider").data('da'), 8848 to: $(".js-range-slider").data('a'), 8849 grid: true 8850 }); 8851 8852} 8853function initDepressione() {
8854 function init() { 8855 initSlider(); 8856 initParallax(); 8857 initMenu(); 8858 initOpener(); 8859 } 8860 8861 function initOpener() { 8862 var h = new Array(); 8863 var n = 0; 8864 $('.inner .text').each(function() { 8865 h.push($(this).height()); 8866 $(this).prev().attr('data-id', n); 8867 n++; 8868 $(this).height(0); 8869 }); 8870 8871 $('.inner a').click(function(e) { 8872 e.preventDefault(); 8873 if ($(this).hasClass('opened')) { 8874 $(this).removeClass('opened'); 8875 // $(this).next().height(0); 8876 $(this).next().animate({ height: 0}, 1000); 8877 } else { 8878 $(this).addClass('opened'); 8879 // $(this).next().height(h[$(this).attr('data-id')]); 8880 $(this).next().animate({height: h[$(this).attr('data-id')]}, 1000); 8881 } 8882 8883 }) 8884 } 8885 8886 function initMenu() { 8887 var menuTrigger; 8888 var menu; 8889 var tornaSu = $('.dp-torna-su'); 8890 var triggers = new Array(); 8891 var scrolling = false; 8892 8893 function init() { 8894 menu = $('.dp-floating-menu'); 8895 menuTrigger = ($('.main-section').length) ? $('.main-section').offset().top - 8 : 10000000; 8896 8897 setTimeout(calcTriggers, 560); 8898 8899 $('.dp-menu a').click(menuClick); 8900 8901 $(window).scroll(onScroll).trigger('scroll'); 8902 $(window).resize(calcTriggers); 8903 8904 tornaSu.click(moveUp); 8905 $('.dp-menu.dp-floating-menu h5').css({ 8906 cursor: 'pointer' 8907 }).click(moveUp); 8908 8909 if ($('.nav.no-click').length) $('.nav.no-click a').click(menuClick); 8910 } 8911 8912 function onScroll(e) { 8913 var v = $(window).scrollTop(); 8914 if (v >= menuTrigger) { 8915 tornaSu.addClass('out'); 8916 menu.removeClass('closed'); 8917 } else { 8918 tornaSu.removeClass('out'); 8919 menu.addClass('closed'); 8920 } 8921 8922 for (x in triggers) { 8923 8924 if (v >= triggers[x].from - 5 && v < triggers[x].to - 5) { 8925 $('.dp-floating-menu .hover').removeClass('hover'); 8926 $('.dp-floating-menu a[href*="#' + triggers[x].id + '"]').addClass('hover'); 8927 break; 8928 } 8929 } 8930 8931 } 8932 8933 function calcTriggers() { 8934 $('.full-page-layout.depressione .section').each(function() { 8935 var top = $(this).offset().top - 200; 8936 // if($(this).attr('id') == 'chi-siamo'){ 8937 // top -= 15; 8938 // } 8939 triggers.push({ 8940 id: $(this).attr('id'), 8941 from: top, 8942 to: top + $(this).outerHeight() 8943 }); 8944 }); 8945 } 8946 8947 function menuClick(e) { 8948 if (!$(this).hasClass('bb')) { 8949 e.preventDefault(); 8950 8951 var tmp = $(this).attr('href').split('#'); 8952 var top = $('.section#' + tmp[1]).offset().top - 56; 8953 $('html, body').animate({ 8954 scrollTop: top + 'px' 8955 }, 700); 8956 } 8957 } 8958 8959 function moveUp(e) { 8960 e.preventDefault(); 8961 $('html, body').animate({ 8962 scrollTop: 0 8963 }, 700); 8964 } 8965 init(); 8966 } 8967 8968 function initParallax() { 8969 var items = []; 8970 var h = 0; 8971 8972 function init() { 8973 h = windowHeight(); 8974 setTimeout(function() { 8975 $('.full-page.image').each(function() { 8976 items.push({ 8977 from: $(this).offset().top - 800, 8978 to: $(this).offset().top + $(this).outerHeight() + 800 8979 }); 8980 }); 8981 $(window).scroll(scroll); 8982 8983 }, 200); 8984 } 8985 8986 function scroll(e) { 8987 var v = $(window).scrollTop(); 8988 8989 for (x in items) { 8990 if (v >= items[x].from <= items[x].to) { 8991 n = (v - items[x].from) / 8; 8992 if (n < 0) n = 0; 8993 $('.full-page.image:eq(' + x + ')').css('background-position', 'center -' + n + 'px'); 8994 } 8995 } 8996 } 8997 init(); 8998 } 8999 9000 function initSlider() { 9001 var owl = $("#owl-demo") 9002 9003 owl.owlCarousel({ 9004 navigation: false, 9005 mouseDrag: false, 9006 touchDrag: false, 9007 responsiveClass: true, 9008 responsive: { 9009 0: { 9010 items: 1, 9011 // nav:true 9012 }, 9013 600: { 9014 items: 3, 9015 // nav:false 9016 }, 9017 1400: { 9018 items: 5, 9019 // nav:true, 9020 // loop:false 9021 } 9022 } 9023 }); 9024 9025 $("#owl-demo2").owlCarousel({ 9026 navigation: false, 9027 mouseDrag: false, 9028 touchDrag: false, 9029 responsiveClass: true, 9030 responsive: { 9031 0: { 9032 items: 1, 9033 // nav:true 9034 }, 9035 600: { 9036 items: 3, 9037 // nav:false 9038 } 9039 } 9040 }); 9041 9042 $("#owl-demo3").owlCarousel({ 9043 navigation: false, 9044 mouseDrag: false, 9045 touchDrag: false, 9046 responsiveClass: true, 9047 responsive: { 9048 0: { 9049 items: 1, 9050 // nav:true 9051 }, 9052 600: { 9053 items: 3, 9054 // nav:false 9055 }, 9056 1400: { 9057 items: 5, 9058 // nav:true, 9059 // loop:false 9060 } 9061 } 9062 }); 9063 9064 $(".images-slider .next").click(function(e) { 9065 e.preventDefault(); 9066 owl.trigger('next.owl.carousel'); 9067 }); 9068 9069 $(".images-slider .prev").click(function(e) { 9070 e.preventDefault(); 9071 owl.trigger('prev.owl.carousel'); 9072 }); 9073 9074 // $("#owl-demo a.fancybox").fancybox(); 9075 } 9076 init(); 9077} 9078function initDTCaccia(){ 9079 $('.birthdate').datepicker({ 9080 format: "dd.mm.yyyy", 9081 startView: 2 9082 }) 9083 9084 $.fn.datepicker.dates['it'] = { 9085 days: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"], 9086 daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"], 9087 daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"], 9088 months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], 9089 monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"], 9090 today: "Oggi", 9091 clear: "Svuota" 9092 }; 9093} 9094function initDTCF(){ 9095 9096 if ($('#deputatiHome').length) 9097 { 9098 $(function() { 9099 $("#deputatiHome .deputato").mouseover(function() { 9100 $(this).find('.testoHover').show(); 9101 $(this).find('.testo').hide(); 9102 9103 }).mouseout(function(){ 9104 $(this).find('.testoHover').hide(); 9105 $(this).find('.testo').show(); 9106 }); 9107 }); 9108 } 9109 else if ($('#listaArticoli').length) 9110 { 9111 $(function() { 9112 9113 $('input[name="daterange"]').daterangepicker({ 9114 autoUpdateInput: false, 9115 locale: { 9116 format: 'DD.MM.YYYY', 9117 firstDay: 1, 9118 cancelLabel: 'Cancella', 9119 applyLabel: 'Applica', 9120 customRangeLabel: "Custom", 9121 daysOfWeek: ["Do","Lu","Ma","Me","Gi","Ve", "Sa"], 9122 monthNames: ["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"] 9123 } 9124 }); 9125 9126 $('input[name="daterange"]').on('apply.daterangepicker', function(ev, picker) { 9127 $(this).val(picker.startDate.format('DD.MM.YYYY') + ' - ' + picker.endDate.format('DD.MM.YYYY')); 9128 $('.myForm').submit(); 9129 }); 9130 9131 $('input[name="daterange"]').on('cancel.daterangepicker', function(ev, picker) { 9132 $(this).val(''); 9133 $('.myForm').submit(); 9134 }); 9135 }); 9136 9137 } 9138 9139} 9140function initFormularioIAS() { 9141 var uploadFile = {}; 9142 var url = '/fileadmin/DSS/IAS/formulario_modifica_indirizzo/'; 9143 var loading = false;
9144 var prestazioniUpload = false; 9145 function init() { 9146 $('select#tipo').change(changeForm); 9147 $('input[name=prestazioni]').change(checkPrestazioni); 9148 $('.send-form').click(send); 9149 9150 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 9151 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 9152 }); 9153 9154 $.fn.datepicker.dates['it'] = { 9155 days: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"], 9156 daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"], 9157 daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"], 9158 months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], 9159 monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"], 9160 today: "Oggi", 9161 clear: "Svuota" 9162 }; 9163 9164 $('.birthdate').datepicker({ 9165 format: "dd.mm.yyyy", 9166 language: 'it', 9167 startView: 'year' 9168 }); 9169 9170 initMultiUpload1(); 9171 initMultiUpload2(); 9172 } 9173 function changeForm() { 9174 if ($(this).val() == '') { 9175 $('.all-fields').addClass('hidden'); 9176 } 9177 else { 9178 $('.prestazioni, .prestazioni_single, .allegati-box1, .allegati-box2').addClass('hidden'); 9179 $('.g3').addClass('hidden') 9180 9181 if ($(this).val() == 1) { 9182 $('.prestazioni, .presso').removeClass('hidden'); 9183 $('.ragione_sociale, .supplemento_indirizzo').addClass('hidden'); 9184 } 9185 else if ($(this).val() == 2) { 9186 $('.prestazioni_single, .ragione_sociale, .supplemento_indirizzo').removeClass('hidden'); 9187 $('.presso').addClass('hidden'); 9188 } 9189 else if ($(this).val() == 3) { 9190 $('.prestazioni, .allegati-box1, .ragione_sociale, .presso').removeClass('hidden'); 9191 $('.g3').removeClass('hidden'); 9192 $('.supplemento_indirizzo').addClass('hidden'); 9193 } 9194 $('.all-fields').removeClass('hidden'); 9195 } 9196 } 9197 function checkPrestazioni() { 9198 if ($('input[name=prestazioni]:checked').length) { 9199 var show = false; 9200 $('input[name=prestazioni]:checked').each(function () { 9201 if ($(this).val() == 'assegno_integrativo' || $(this).val() == 'pc') show = true; 9202 }); 9203 9204 if (show) { 9205 $('.allegati-box2').removeClass('hidden'); 9206 prestazioniUpload = true; 9207 } 9208 else { 9209 $('.allegati-box2').addClass('hidden'); 9210 prestazioniUpload = false; 9211 } 9212 } 9213 else { 9214 $('.allegati-box2').addClass('hidden'); 9215 prestazioniUpload = false; 9216 } 9217 } 9218 function send(e) { 9219 e.preventDefault(); 9220 9221 if (!loading) { 9222 loading = true; 9223 9224 var error = false; 9225 9226 9227 if ($('#nome').val() != '' || $('#cognome').val() != '') { 9228 if (!checkField('#nome')) error = true; 9229 if (!checkField('#cognome')) error = true; 9230 $('#ragione_sociale').siblings('.error-messages').addClass('hidden'); 9231 } 9232 else if ($('#ragione_sociale').val() != '') { 9233 $('#nome, #cognome').siblings('.error-messages').addClass('hidden'); 9234 } 9235 else if ($('#ragione_sociale').val() == '') { 9236 if (!checkField('#nome')) error = true; 9237 if (!checkField('#cognome')) error = true; 9238 if (!checkField('#ragione_sociale')) error = true; 9239 } 9240 9241 9242 if (!checkField('#avs')) error = true; 9243 9244 if (!checkField('#telefono')) error = true; 9245 if (!checkField('#email', 'email')) error = true; 9246 if (!checkField('#via')) error = true; 9247 if (!checkField('#localita')) error = true; 9248 if (!checkField('#data_indirizzo', 'date')) error = true; 9249 9250 //if (($('select#tipo').val() == 1 || $('select#tipo').val() == 3)) { 9251 //if (!checkField('#presso')) error = true; 9252 //} 9253 //else { 9254 //if (!checkField('#supplemento_indirizzo')) error = true; 9255 //} 9256 9257 if (!checkField('#nascita')) error = true; 9258 9259 // Prestazioni 9260 if ($('select#tipo').val() == 1 || $('select#tipo').val() == 3) { 9261 if (!$('input[name=prestazioni]:checked').length && !$('input[name=assoggettamento]:checked').length) { 9262 $('label[for=assoggettamento1]').siblings('.error-messages').removeClass('hidden'); 9263 error = true; 9264 } 9265 else $('label[for=assoggettamento1]').siblings('.error-messages').addClass('hidden'); 9266 } 9267 else { 9268 if (!$('input[name=prestazioni_single]:checked').length && !$('input[name=assoggettamento]:checked').length) { 9269 $('label[for=assoggettamento1]').siblings('.error-messages').removeClass('hidden'); 9270 error = true; 9271 } 9272 else $('label[for=assoggettamento1]').siblings('.error-messages').addClass('hidden'); 9273 } 9274 9275 // Allegati 1 9276 if ($('select#tipo').val() == 3) { 9277 if (!$('.allegati1 .allegato:not(.hidden)').length) { 9278 error = true; 9279 $('.allegati1 .error-messages').removeClass('hidden'); 9280 } 9281 else $('.allegati1 .error-messages').addClass('hidden'); 9282 } 9283 9284 // Allegati 2 9285 if (prestazioniUpload) { 9286 if (!$('.allegati2 .allegato:not(.hidden)').length) { 9287 error = true; 9288 $('.allegati2 .error-messages').removeClass('hidden'); 9289 } 9290 else $('.allegati2 .error-messages').addClass('hidden'); 9291 } 9292 9293 if (!error) { 9294 // Captcha 9295 if (!checkCaptchaField()) error = true; 9296 } 9297 9298 9299 if (!error) { 9300 var data = new FormData(); 9301 9302 data.append('tipo', $('#tipo').val()); 9303 data.append('nome', $('#nome').val()); 9304 data.append('cognome', $('#cognome').val()); 9305 data.append('ragione_sociale', $('#ragione_sociale').val()); 9306 data.append('avs', $('#avs').val()); 9307 data.append('nascita', $('#nascita').val()); 9308 data.append('telefono', $('#telefono').val()); 9309 data.append('email', $('#email').val()); 9310 data.append('via', $('#via').val()); 9311 data.append('localita', $('#localita').val()); 9312 data.append('data_indirizzo', $('#data_indirizzo').val()); 9313 9314 if (($('select#tipo').val() == 1 || $('select#tipo').val() == 3)) data.append('presso', $('#presso').val()); 9315 else data.append('supplemento_indirizzo', $('#supplemento_indirizzo').val()); 9316 9317 for (x in uploadFile) { 9318 data.append(x, document.getElementById(x).files[0]); 9319 } 9320 9321 // Prestazioni 9322 if (($('select#tipo').val() == 1 || $('select#tipo').val() == 3) && $('input[name=prestazioni]:checked').length) { 9323 var prestazioni = []; 9324 $('input[name=prestazioni]:checked').each(function () { 9325 prestazioni.push($(this).val()); 9326 }); 9327 data.append('prestazioni', prestazioni.join('+')); 9328 } 9329 //else if ($('select#tipo').val() == 2 && $('input[name=prestazioni_single]:checked').length) { 9330 // data.append('prestazioni_single', $('input[name=prestazioni_single]:checked').val()); 9331 //} 9332 9333 // Prestazioni Single 9334 if ($('select#tipo').val() == 2 && $('input[name=prestazioni_single]:checked').length) { 9335 var prestazioni_single = []; 9336 $('input[name=prestazioni_single]:checked').each(function () { 9337 prestazioni_single.push($(this).val()); 9338 }); 9339 data.append('prestazioni_single', prestazioni_single.join('+')); 9340 } 9341 9342 9343 9344 // Assoggettamento 9345 if ($('input[name=assoggettamento]:checked').length) { 9346 var assoggettamento = []; 9347 $('input[name=assoggettamento]:checked').each(function () { 9348 assoggettamento.push($(this).val()); 9349 }); 9350 data.append('assoggettamento', assoggettamento.join('+')); 9351 } 9352 9353 var button_text = $('button.send-form').text(); 9354 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 9355 $.ajax({ 9356 url: url + 'save.php', // point to server-side PHP script 9357 dataType: 'text', // what to expect back from the PHP script, if anything 9358 cache: false, 9359 contentType: false, 9360 processData: false, 9361 data: data, 9362 type: 'post', 9363 success: function (php_script_response) { 9364 if (php_script_response == 'ok') { 9365 $('form, .intro p').remove(); 9366 $('.success').removeClass('hidden'); 9367 } 9368 else { 9369 $('button.send-form').html(button_text).removeClass('disabled'); 9370 loading = false;
9371 9372 } 9373 } 9374 }); 9375 } 9376 else loading = false; 9377 } 9378 } 9379 function checkField(s, type) { 9380 if (typeof type == 'undefined') { 9381 if ($(s).val() == '') { 9382 $(s).siblings('.error-messages').removeClass('hidden'); 9383 return false; 9384 } 9385 else { 9386 $(s).siblings('.error-messages').addClass('hidden'); 9387 return true; 9388 } 9389 } 9390 else if (type == 'radio' || type == 'checkbox') { 9391 if ($(s + ':checked').length == 0) { 9392 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 9393 return false; 9394 } 9395 else { 9396 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 9397 return true; 9398 } 9399 } 9400 else if (type == 'email') { 9401 if ($(s).val() == '' || !checkEmail($(s).val())) { 9402 $(s).siblings('.error-messages').removeClass('hidden'); 9403 return false; 9404 } 9405 else { 9406 $(s).siblings('.error-messages').addClass('hidden'); 9407 return true; 9408 } 9409 } 9410 else if (type == 'date') { 9411 if ($(s).val() == '' || !checkDate($(s).val())) { 9412 $(s).siblings('.error-messages').removeClass('hidden'); 9413 return false; 9414 } 9415 else { 9416 $(s).siblings('.error-messages').addClass('hidden'); 9417 return true; 9418 } 9419 } 9420 } 9421 function checkEmail(email) { 9422 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,}))$/; 9423 return re.test(String(email).toLowerCase()); 9424 } 9425 function checkDate(value) { 9426 if (new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 9427 else return false; 9428 } 9429 function checkCaptchaField() { 9430 var field = $('input[name=captcha]'); 9431 var error = false; 9432 9433 if (field.val()) { 9434 var r = checkCaptcha(field.val()); 9435 if (r.responseText == 'ok') { 9436 field.removeClass('error'); 9437 $('.captcha .error-messages').addClass('hidden'); 9438 } 9439 else { 9440 field.addClass('error').val(''); 9441 $('.refresh-button').trigger('click'); 9442 $('.captcha .error-messages').removeClass('hidden'); 9443 error = true; 9444 } 9445 } 9446 else { 9447 field.addClass('error'); 9448 $('.refresh-button').trigger('click'); 9449 $('.captcha .error-messages').removeClass('hidden'); 9450 error = true; 9451 } 9452 9453 if (!error) return true; 9454 return false; 9455 } 9456 function checkCaptcha(value) { 9457 var rand = Math.floor((Math.random() * 100000) + 1); 9458 return $.ajax({ 9459 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 9460 data: { 9461 value: value 9462 }, 9463 async: false, 9464 method: 'post' 9465 }); 9466 } 9467 function initMultiUpload1() { 9468 var attachments_n = 1; 9469 var max_uploads = 1; 9470 var max_weight = 10; 9471 var working = false; 9472 var uploadButtonContent = ''; 9473 function init() { 9474 uploadButtonContent = $('#formulario_ias .allegati1 .add').html(); 9475 9476 $('#formulario_ias').on('click', '.allegati1 .add', addAttachemnt); 9477 $('#formulario_ias').on('click', '.allegati1 .remove', clearAttachemnt); 9478 9479 $('#formulario_ias').on('change', '.allegati1 .inputfile', change); 9480 } 9481 function addAttachemnt(e) { 9482 e.preventDefault(); 9483 9484 if (!working) { 9485 $(this).siblings('.allegato.hidden.new').remove(); 9486 9487 if ($('#attachments-error').length) $('#attachments-error').remove(); 9488 9489 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 9490 $('#formulario_ias .allegati1 .allegato.new label').attr('for', 'file' + attachments_n); 9491 $('#formulario_ias .allegati1 .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 9492 9493 $('#formulario_ias .allegati1 .allegato.new input:last').trigger('click'); 9494 } 9495 } 9496 function clearAttachemnt(e) { 9497 e.preventDefault(); 9498 9499 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 9500 uploadFile[id] = false;
9501 9502 var p = $(this).parents('.allegato'); 9503 9504 p.find('input[type=file]').val(''); 9505 p.find('input[type=file]').next().children('span').text('Allega un file'); 9506 p.remove(); 9507 9508 attachments_n--; 9509 9510 $('#formulario_ias .allegati1 .add').removeClass('hidden'); 9511 } 9512 function change(event) { 9513 var id = $(this).attr('id'); 9514 9515 tmp = $(this).val().split("\\"); 9516 var v = tmp[tmp.length - 1]; 9517 9518 if (v) { 9519 tmp2 = v.split('.'); 9520 var ext = tmp2[(tmp2.length - 1)]; 9521 9522 9523 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size').addClass('hidden'); 9524 9525 if (ext.toLowerCase() != 'jpg' && ext.toLowerCase() != 'pdf' && ext.toLowerCase() != 'png') { 9526 // Type error 9527 $('.allegati1 .error-messages-type').removeClass('hidden'); 9528 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 9529 } 9530 else { 9531 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 9532 // Size error 9533 $('.allegati1 .error-messages-size').removeClass('hidden'); 9534 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 9535 } 9536 else { 9537 $('label[for=' + id + '] span').text(v); 9538 9539 if ($('#attachments-error').length) $('#attachments-error').remove(); 9540 9541 uploadFile[id] = event.target.files; 9542 9543 $('.allegati1 .allegato.new.hidden').removeClass('new hidden'); 9544 $('#formulario_ias .allegati1 .add').html(uploadButtonContent); 9545 9546 9547 attachments_n++; 9548 if (max_uploads < attachments_n) $('#formulario_ias .allegati1 .add').addClass('hidden'); 9549 } 9550 } 9551 } 9552 } 9553 init(); 9554 } 9555 function initMultiUpload2() { 9556 var attachments_n = 2; 9557 var max_uploads = 1; 9558 var max_weight = 10; 9559 var working = false; 9560 var uploadButtonContent = ''; 9561 function init() { 9562 uploadButtonContent = $('#formulario_ias .allegati2 .add').html(); 9563 9564 $('#formulario_ias').on('click', '.allegati2 .add', addAttachemnt); 9565 $('#formulario_ias').on('click', '.allegati2 .remove', clearAttachemnt); 9566 9567 $('#formulario_ias').on('change', '.allegati2 .inputfile', change); 9568 } 9569 function addAttachemnt(e) { 9570 e.preventDefault(); 9571 9572 if (!working) { 9573 $(this).siblings('.allegato.hidden.new').remove(); 9574 9575 if ($('#attachments-error').length) $('#attachments-error').remove(); 9576 9577 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 9578 $('#formulario_ias .allegati2 .allegato.new label').attr('for', 'file' + attachments_n); 9579 $('#formulario_ias .allegati2 .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 9580 9581 $('#formulario_ias .allegati2 .allegato.new input:last').trigger('click'); 9582 } 9583 } 9584 function clearAttachemnt(e) { 9585 e.preventDefault(); 9586 9587 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 9588 uploadFile[id] = false; 9589 9590 var p = $(this).parents('.allegato'); 9591 9592 p.find('input[type=file]').val(''); 9593 p.find('input[type=file]').next().children('span').text('Allega un file'); 9594 p.remove(); 9595 9596 attachments_n--; 9597 9598 $('#formulario_ias .allegati2 .add').removeClass('hidden'); 9599 } 9600 function change(event) { 9601 var id = $(this).attr('id'); 9602 9603 tmp = $(this).val().split("\\"); 9604 var v = tmp[tmp.length - 1]; 9605 9606 if (v) { 9607 tmp2 = v.split('.'); 9608 var ext = tmp2[(tmp2.length - 1)]; 9609 9610 9611 $('.allegati2 .error-messages, .allegati2 .error-messages-type, .allegati2 .error-messages-size').addClass('hidden'); 9612 9613 if (ext.toLowerCase() != 'jpg' && ext.toLowerCase() != 'pdf' && ext.toLowerCase() != 'png') { 9614 // Type error 9615 $('.allegati2 .error-messages-type').removeClass('hidden'); 9616 $('.allegati2 .allegato.new.hidden .remove').trigger('click'); 9617 } 9618 else { 9619 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 9620 // Size error 9621 $('.allegati2 .error-messages-size').removeClass('hidden'); 9622 $('.allegati2 .allegato.new.hidden .remove').trigger('click'); 9623 } 9624 else { 9625 $('label[for=' + id + '] span').text(v); 9626 9627 if ($('#attachments-error').length) $('#attachments-error').remove(); 9628 9629 uploadFile[id] = event.target.files; 9630 9631 $('.allegati2 .allegato.new.hidden').removeClass('new hidden'); 9632 $('#formulario_ias .allegati2 .add').html(uploadButtonContent); 9633 9634 9635 attachments_n++; 9636 if (max_uploads < attachments_n) $('#formulario_ias .allegati2 .add').addClass('hidden'); 9637 } 9638 } 9639 } 9640 } 9641 init(); 9642 } 9643 init(); 9644} 9645 9646function initFormularioIAS2() { 9647 var uploadFile = {}; 9648 var url = '/fileadmin/DSS/IAS/formulario_corrispondenza/'; 9649 var loading = false;
9650 var prestazioniUpload = false; 9651 function init() { 9652 $('.add-element').click(addElement) 9653 $('.lamal-table').on('click', '.remove-element', removeElement) 9654 9655 $('.send-form').click(send); 9656 9657 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 9658 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 9659 }); 9660 9661 $.fn.datepicker.dates['it'] = { 9662 days: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"], 9663 daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"], 9664 daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"], 9665 months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], 9666 monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"], 9667 today: "Oggi", 9668 clear: "Svuota" 9669 }; 9670 9671 initMultiUpload1(); 9672 9673 } 9674 function addElement(e) { 9675 e.preventDefault() 9676 var e = $('.lamal-table tr.placeholder').clone() 9677 e.removeClass('placeholder hidden'); 9678 9679 $('.lamal-table tr.placeholder').before(e) 9680 if ($('.lamal-table tr').length == 10) $('.add-element').addClass('hidden') 9681 } 9682 function removeElement(e) { 9683 e.preventDefault() 9684 $(this).parents('tr').remove() 9685 if ($('.lamal-table tr').length < 10) $('.add-element').removeClass('hidden') 9686 } 9687 function send(e) { 9688 e.preventDefault(); 9689 9690 if (!loading) { 9691 loading = true; 9692 9693 var error = false; 9694 9695 9696 if (!checkField('#nome')) error = true; 9697 if (!checkField('#cognome')) error = true; 9698 if (!checkField('#avs')) error = true; 9699 if (!checkField('#nascita')) error = true; 9700 if (!checkField('#telefono')) error = true; 9701 if (!checkField('#email', 'email')) error = true; 9702 9703 if (!$('#complementari1').is(':checked') && !$('#complementari2').is(':checked')) { 9704 error = true 9705 $('#complementari2').parent().siblings('.error-messages').removeClass('hidden') 9706 } 9707 else $('#complementari2').parent().siblings('.error-messages').addClass('hidden') 9708 9709 var n = 0; 9710 $('.lamal-table tbody tr').each(function () { 9711 if (!$(this).hasClass('placeholder')) { 9712 9713 $(this).find('input[name=cognome]').attr('id', 'cognome' + n); 9714 if (!checkField('#cognome' + n)) error = true; 9715 9716 $(this).find('input[name=nome]').attr('id', 'nome' + n); 9717 if (!checkField('#nome' + n)) error = true; 9718 9719 $(this).find('input[name=data]').attr('id', 'data' + n); 9720 if (!checkField('#data' + n)) error = true; 9721 9722 $(this).find('input[name=assicurazione]').attr('id', 'assicurazione' + n); 9723 if (!checkField('#assicurazione' + n)) error = true; 9724 9725 n++; 9726 } 9727 }) 9728 9729 // Allegati 1 9730 if (!$('.allegati1 .allegato:not(.hidden)').length) { 9731 error = true; 9732 $('.allegati1 .error-messages').removeClass('hidden'); 9733 } 9734 else $('.allegati1 .error-messages').addClass('hidden'); 9735 9736 9737 9738 if (!error) { 9739 // Captcha 9740 if (!checkCaptchaField()) error = true; 9741 } 9742 9743 9744 if (!error) { 9745 var data = new FormData(); 9746 9747 data.append('nome', $('#nome').val()); 9748 data.append('cognome', $('#cognome').val()); 9749 data.append('avs', $('#avs').val()); 9750 data.append('nascita', $('#nascita').val()); 9751 data.append('telefono', $('#telefono').val()); 9752 data.append('email', $('#email').val()); 9753 data.append('complementari', $('input[name=complementari]:checked').val()); 9754 9755 var n = 0; 9756 $('.lamal-table tbody tr').each(function () { 9757 if (!$(this).hasClass('placeholder')) { 9758 data.append('cognome' + n, $(this).find('input[name=cognome]').val()); 9759 data.append('nome' + n, $(this).find('input[name=nome]').val()); 9760 data.append('data' + n, $(this).find('input[name=data]').val()); 9761 data.append('assicurazione' + n, $(this).find('input[name=assicurazione]').val()); 9762 n++; 9763 } 9764 }) 9765 data.append('element_n', n); 9766 9767 for (x in uploadFile) { 9768 data.append(x, document.getElementById(x).files[0]); 9769 } 9770 9771 var button_text = $('button.send-form').text(); 9772 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 9773 $.ajax({ 9774 url: url + 'save.php', // point to server-side PHP script 9775 dataType: 'text', // what to expect back from the PHP script, if anything 9776 cache: false, 9777 contentType: false, 9778 processData: false, 9779 data: data, 9780 type: 'post', 9781 success: function (php_script_response) { 9782 if (php_script_response == 'ok') { 9783 $('form, .intro p').remove(); 9784 $('.success').removeClass('hidden'); 9785 } 9786 else { 9787 $('button.send-form').html(button_text).removeClass('disabled'); 9788 loading = false;
9789 9790 } 9791 } 9792 }); 9793 } 9794 else loading = false; 9795 } 9796 } 9797 function checkField(s, type) { 9798 if (typeof type == 'undefined') { 9799 if ($(s).val() == '') { 9800 $(s).siblings('.error-messages').removeClass('hidden'); 9801 return false; 9802 } 9803 else { 9804 $(s).siblings('.error-messages').addClass('hidden'); 9805 return true; 9806 } 9807 } 9808 else if (type == 'radio' || type == 'checkbox') { 9809 if ($(s + ':checked').length == 0) { 9810 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 9811 return false; 9812 } 9813 else { 9814 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 9815 return true; 9816 } 9817 } 9818 else if (type == 'email') { 9819 if ($(s).val() == '' || !checkEmail($(s).val())) { 9820 $(s).siblings('.error-messages').removeClass('hidden'); 9821 return false; 9822 } 9823 else { 9824 $(s).siblings('.error-messages').addClass('hidden'); 9825 return true; 9826 } 9827 } 9828 else if (type == 'date') { 9829 if ($(s).val() == '' || !checkDate($(s).val())) { 9830 $(s).siblings('.error-messages').removeClass('hidden'); 9831 return false; 9832 } 9833 else { 9834 $(s).siblings('.error-messages').addClass('hidden'); 9835 return true; 9836 } 9837 } 9838 } 9839 function checkEmail(email) { 9840 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,}))$/; 9841 return re.test(String(email).toLowerCase()); 9842 } 9843 function checkDate(value) { 9844 if (new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 9845 else return false; 9846 } 9847 function checkCaptchaField() { 9848 var field = $('input[name=captcha]'); 9849 var error = false; 9850 9851 if (field.val()) { 9852 var r = checkCaptcha(field.val()); 9853 if (r.responseText == 'ok') { 9854 field.removeClass('error'); 9855 $('.captcha .error-messages').addClass('hidden'); 9856 } 9857 else { 9858 field.addClass('error').val(''); 9859 $('.refresh-button').trigger('click'); 9860 $('.captcha .error-messages').removeClass('hidden'); 9861 error = true; 9862 } 9863 } 9864 else { 9865 field.addClass('error'); 9866 $('.refresh-button').trigger('click'); 9867 $('.captcha .error-messages').removeClass('hidden'); 9868 error = true; 9869 } 9870 9871 if (!error) return true; 9872 return false; 9873 } 9874 function checkCaptcha(value) { 9875 var rand = Math.floor((Math.random() * 100000) + 1); 9876 return $.ajax({ 9877 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 9878 data: { 9879 value: value 9880 }, 9881 async: false, 9882 method: 'post' 9883 }); 9884 } 9885 function initMultiUpload1() { 9886 var attachments_n = 1; 9887 var max_uploads = 8; 9888 var max_weight = 10; 9889 var working = false; 9890 var uploadButtonContent = ''; 9891 function init() { 9892 uploadButtonContent = $('#formulario_ias2 .allegati1 .add').html(); 9893 9894 $('#formulario_ias2').on('click', '.allegati1 .add', addAttachemnt); 9895 $('#formulario_ias2').on('click', '.allegati1 .remove', clearAttachemnt); 9896 9897 $('#formulario_ias2').on('change', '.allegati1 .inputfile', change); 9898 } 9899 function addAttachemnt(e) { 9900 e.preventDefault(); 9901 9902 if (!working) { 9903 $(this).siblings('.allegato.hidden.new').remove(); 9904 9905 if ($('#attachments-error').length) $('#attachments-error').remove(); 9906 9907 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 9908 $('#formulario_ias2 .allegati1 .allegato.new label').attr('for', 'file' + attachments_n); 9909 $('#formulario_ias2 .allegati1 .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 9910 9911 $('#formulario_ias2 .allegati1 .allegato.new input:last').trigger('click'); 9912 } 9913 } 9914 function clearAttachemnt(e) { 9915 e.preventDefault(); 9916 9917 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 9918 uploadFile[id] = false;
9919 9920 var p = $(this).parents('.allegato'); 9921 9922 p.find('input[type=file]').val(''); 9923 p.find('input[type=file]').next().children('span').text('Allega un file'); 9924 p.remove(); 9925 9926 attachments_n--; 9927 9928 $('#formulario_ias2 .allegati1 .add').removeClass('hidden'); 9929 } 9930 function change(event) { 9931 var id = $(this).attr('id'); 9932 9933 tmp = $(this).val().split("\\"); 9934 var v = tmp[tmp.length - 1]; 9935 9936 if (v) { 9937 tmp2 = v.split('.'); 9938 var ext = tmp2[(tmp2.length - 1)]; 9939 9940 9941 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size').addClass('hidden'); 9942 9943 if (ext.toLowerCase() != 'pdf' && ext.toLowerCase() != 'doc' && ext.toLowerCase() != 'docx') { 9944 // Type error 9945 $('.allegati1 .error-messages-type').removeClass('hidden'); 9946 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 9947 } 9948 else { 9949 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 9950 // Size error 9951 $('.allegati1 .error-messages-size').removeClass('hidden'); 9952 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 9953 } 9954 else { 9955 $('label[for=' + id + '] span').text(v); 9956 9957 if ($('#attachments-error').length) $('#attachments-error').remove(); 9958 9959 uploadFile[id] = event.target.files; 9960 9961 $('.allegati1 .allegato.new.hidden').removeClass('new hidden'); 9962 $('#formulario_ias2 .allegati1 .add').html(uploadButtonContent); 9963 9964 9965 attachments_n++; 9966 if (max_uploads < attachments_n) $('#formulario_ias2 .allegati1 .add').addClass('hidden'); 9967 } 9968 } 9969 } 9970 } 9971 init(); 9972 } 9973 function initMultiUpload2() { 9974 var attachments_n = 2; 9975 var max_uploads = 1; 9976 var max_weight = 10; 9977 var working = false; 9978 var uploadButtonContent = ''; 9979 function init() { 9980 uploadButtonContent = $('#formulario_ias .allegati2 .add').html(); 9981 9982 $('#formulario_ias').on('click', '.allegati2 .add', addAttachemnt); 9983 $('#formulario_ias').on('click', '.allegati2 .remove', clearAttachemnt); 9984 9985 $('#formulario_ias').on('change', '.allegati2 .inputfile', change); 9986 } 9987 function addAttachemnt(e) { 9988 e.preventDefault(); 9989 9990 if (!working) { 9991 $(this).siblings('.allegato.hidden.new').remove(); 9992 9993 if ($('#attachments-error').length) $('#attachments-error').remove(); 9994 9995 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 9996 $('#formulario_ias .allegati2 .allegato.new label').attr('for', 'file' + attachments_n); 9997 $('#formulario_ias .allegati2 .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 9998 9999 $('#formulario_ias .allegati2 .allegato.new input:last').trigger('click'); 10000 } 10001 } 10002 function clearAttachemnt(e) { 10003 e.preventDefault(); 10004 10005 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 10006 uploadFile[id] = false; 10007 10008 var p = $(this).parents('.allegato'); 10009 10010 p.find('input[type=file]').val(''); 10011 p.find('input[type=file]').next().children('span').text('Allega un file'); 10012 p.remove(); 10013 10014 attachments_n--; 10015 10016 $('#formulario_ias .allegati2 .add').removeClass('hidden'); 10017 } 10018 function change(event) { 10019 var id = $(this).attr('id'); 10020 10021 tmp = $(this).val().split("\\"); 10022 var v = tmp[tmp.length - 1]; 10023 10024 if (v) { 10025 tmp2 = v.split('.'); 10026 var ext = tmp2[(tmp2.length - 1)]; 10027 10028 10029 $('.allegati2 .error-messages, .allegati2 .error-messages-type, .allegati2 .error-messages-size').addClass('hidden'); 10030 10031 if (ext.toLowerCase() != 'jpg' && ext.toLowerCase() != 'pdf' && ext.toLowerCase() != 'png') { 10032 // Type error 10033 $('.allegati2 .error-messages-type').removeClass('hidden'); 10034 $('.allegati2 .allegato.new.hidden .remove').trigger('click'); 10035 } 10036 else { 10037 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 10038 // Size error 10039 $('.allegati2 .error-messages-size').removeClass('hidden'); 10040 $('.allegati2 .allegato.new.hidden .remove').trigger('click'); 10041 } 10042 else { 10043 $('label[for=' + id + '] span').text(v); 10044 10045 if ($('#attachments-error').length) $('#attachments-error').remove(); 10046 10047 uploadFile[id] = event.target.files; 10048 10049 $('.allegati2 .allegato.new.hidden').removeClass('new hidden'); 10050 $('#formulario_ias .allegati2 .add').html(uploadButtonContent); 10051 10052 10053 attachments_n++; 10054 if (max_uploads < attachments_n) $('#formulario_ias .allegati2 .add').addClass('hidden'); 10055 } 10056 } 10057 } 10058 } 10059 init(); 10060 } 10061 init(); 10062} 10063 10064function initFormularioIASAdeguamento1() { 10065 var uploadFile = {}; 10066 var url = '/fileadmin/DSS/IAS/formulario_ias_adeguamento_1/'; 10067 var loading = false;
10068 var utile_presumibile = false; 10069 function init() { 10070 $('.intro .start').click(startForm) 10071 $('input[name=adeguare]').change(checkAdeguare) 10072 $('input[name=adeguare_retroattivi]').change(checkAdeguamentiRetroattivi) 10073 $('.send-form').click(send); 10074 10075 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 10076 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 10077 }); 10078 10079 initMultiUpload1(); 10080 } 10081 function startForm() { 10082 $('.intro').addClass('hidden') 10083 $('form.hidden').removeClass('hidden') 10084 } 10085 function checkAdeguare() { 10086 if ($('#adeguare1').is(':checked')) { 10087 $('.utile_presumibile').removeClass('hidden'); 10088 utile_presumibile = true; 10089 } 10090 else { 10091 $('.utile_presumibile').addClass('hidden'); 10092 utile_presumibile = false; 10093 } 10094 } 10095 function checkAdeguamentiRetroattivi() { 10096 if ($(this).is(':checked')) $(this).parent().next().removeClass('hidden') 10097 else { 10098 $(this).parent().next().addClass('hidden') 10099 $(this).parents('.checkbox').next().addClass('hidden') 10100 } 10101 } 10102 function send(e) { 10103 e.preventDefault(); 10104 10105 if (!loading) { 10106 loading = true; 10107 10108 var error = false; 10109 10110 10111 if (!checkField('#numero_affiliato')) error = true; 10112 if (!checkField('#nome')) error = true; 10113 if (!checkField('#cognome')) error = true; 10114 if (!checkField('#ragione_sociale')) error = true; 10115 if (!checkField('#indirizzo')) error = true; 10116 if (!checkField('#cap')) error = true; 10117 if (!checkField('#localita')) error = true; 10118 if (!checkField('#nazione')) error = true; 10119 if (!checkField('#telefono')) error = true; 10120 if (!checkField('#email', 'email')) error = true; 10121 if (!checkField('input[name=adeguare]', 'radio')) error = true; 10122 10123 if (utile_presumibile) { 10124 if (!checkField('#utile_presumibile')) error = true; 10125 } 10126 10127 if ($('input[name=adeguare_retroattivi]:checked').length) { 10128 $('input[name=adeguare_retroattivi]:checked').each(function () { 10129 var f = $('input[name=' + $(this).attr('id') + '_v]') 10130 if (f.val()) $(this).parents('.checkbox').next().addClass('hidden') 10131 else { 10132 $(this).parents('.checkbox').next().removeClass('hidden') 10133 error = true 10134 } 10135 }) 10136 } 10137 10138 if (!error) { 10139 if (!checkCaptchaField()) error = true; 10140 } 10141 10142 10143 if (!error) { 10144 var data = new FormData(); 10145 10146 data.append('numero_affiliato', $('#numero_affiliato').val()); 10147 data.append('nome', $('#nome').val()); 10148 data.append('cognome', $('#cognome').val()); 10149 data.append('ragione_sociale', $('#ragione_sociale').val()); 10150 data.append('indirizzo', $('#indirizzo').val()); 10151 data.append('cap', $('#cap').val()); 10152 data.append('localita', $('#localita').val()); 10153 data.append('nazione', $('#nazione').val()); 10154 data.append('telefono', $('#telefono').val()); 10155 data.append('email', $('#email').val()); 10156 data.append('adeguare', $('input[name=adeguare]:checked').val()); 10157 data.append('utile_presumibile', $('#utile_presumibile').val()); 10158 10159 if ($('input[name=adeguare_retroattivi]:checked').length) { 10160 var d = {} 10161 $('input[name=adeguare_retroattivi]:checked').each(function () { 10162 d[$(this).val()] = $('input[name=' + $(this).attr('id') + '_v]').val() 10163 }) 10164 data.append('adeguare_retroattivi', JSON.stringify(d)) 10165 } 10166 10167 for (x in uploadFile) { 10168 data.append(x, document.getElementById(x).files[0]); 10169 } 10170 10171 var button_text = $('button.send-form').text(); 10172 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 10173 $.ajax({ 10174 url: url + 'save.php', // point to server-side PHP script 10175 dataType: 'text', // what to expect back from the PHP script, if anything 10176 cache: false, 10177 contentType: false, 10178 processData: false, 10179 data: data, 10180 type: 'post', 10181 success: function (php_script_response) { 10182 if (php_script_response == 'ok') { 10183 $('form, .intro').remove(); 10184 $('.success').removeClass('hidden'); 10185 } 10186 else { 10187 $('button.send-form').html(button_text).removeClass('disabled'); 10188 loading = false;
10189 } 10190 } 10191 }); 10192 } 10193 else { 10194 loading = false; 10195 $('html, body').animate({ 'scrollTop': $('.error-messages:not(.hidden):first').offset().top - 50 }, 50) 10196 } 10197 } 10198 } 10199 function checkField(s, type) { 10200 if (typeof type == 'undefined') { 10201 if ($(s).val() == '') { 10202 $(s).siblings('.error-messages').removeClass('hidden'); 10203 return false; 10204 } 10205 else { 10206 $(s).siblings('.error-messages').addClass('hidden'); 10207 return true; 10208 } 10209 } 10210 else if (type == 'radio' || type == 'checkbox') { 10211 if ($(s + ':checked').length == 0) { 10212 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 10213 return false; 10214 } 10215 else { 10216 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 10217 return true; 10218 } 10219 } 10220 else if (type == 'email') { 10221 if ($(s).val() == '' || !checkEmail($(s).val())) { 10222 $(s).siblings('.error-messages').removeClass('hidden'); 10223 return false; 10224 } 10225 else { 10226 $(s).siblings('.error-messages').addClass('hidden'); 10227 return true; 10228 } 10229 } 10230 else if (type == 'date') { 10231 if ($(s).val() == '' || !checkDate($(s).val())) { 10232 $(s).siblings('.error-messages').removeClass('hidden'); 10233 return false; 10234 } 10235 else { 10236 $(s).siblings('.error-messages').addClass('hidden'); 10237 return true; 10238 } 10239 } 10240 } 10241 function checkEmail(email) { 10242 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,}))$/; 10243 return re.test(String(email).toLowerCase()); 10244 } 10245 function checkDate(value) { 10246 if (new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 10247 else return false; 10248 } 10249 function checkCaptchaField() { 10250 var field = $('input[name=captcha]'); 10251 var error = false; 10252 10253 if (field.val()) { 10254 var r = checkCaptcha(field.val()); 10255 if (r.responseText == 'ok') { 10256 field.removeClass('error'); 10257 $('.captcha .error-messages').addClass('hidden'); 10258 } 10259 else { 10260 field.addClass('error').val(''); 10261 $('.refresh-button').trigger('click'); 10262 $('.captcha .error-messages').removeClass('hidden'); 10263 error = true; 10264 } 10265 } 10266 else { 10267 field.addClass('error'); 10268 $('.refresh-button').trigger('click'); 10269 $('.captcha .error-messages').removeClass('hidden'); 10270 error = true; 10271 } 10272 10273 if (!error) return true; 10274 return false; 10275 } 10276 function checkCaptcha(value) { 10277 var rand = Math.floor((Math.random() * 100000) + 1); 10278 return $.ajax({ 10279 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 10280 data: { 10281 value: value 10282 }, 10283 async: false, 10284 method: 'post' 10285 }); 10286 } 10287 function initMultiUpload1() { 10288 var id_form = '#formulario_ias_adeguamento_1'; 10289 var attachments_n = 1; 10290 var max_uploads = 5; 10291 var max_weight = 10; 10292 var working = false; 10293 var uploadButtonContent = ''; 10294 function init() { 10295 uploadButtonContent = $(id_form + ' .allegati1 .add').html(); 10296 10297 $(id_form).on('click', '.allegati1 .add', addAttachemnt); 10298 $(id_form).on('click', '.allegati1 .remove', clearAttachemnt); 10299 10300 $(id_form).on('change', '.allegati1 .inputfile', change); 10301 } 10302 function addAttachemnt(e) { 10303 e.preventDefault(); 10304 10305 if (!working) { 10306 $(this).siblings('.allegato.hidden.new').remove(); 10307 10308 if ($('#attachments-error').length) $('#attachments-error').remove(); 10309 10310 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 10311 $(id_form + ' .allegati1 .allegato.new label').attr('for', 'file' + attachments_n); 10312 $(id_form + ' .allegati1 .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 10313 10314 $(id_form + ' .allegati1 .allegato.new input:last').trigger('click'); 10315 } 10316 } 10317 function clearAttachemnt(e) { 10318 e.preventDefault(); 10319 10320 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 10321 uploadFile[id] = false;
10322 10323 var p = $(this).parents('.allegato'); 10324 10325 p.find('input[type=file]').val(''); 10326 p.find('input[type=file]').next().children('span').text('Allega un file'); 10327 p.remove(); 10328 10329 attachments_n--; 10330 if (attachments_n < 1) attachments_n = 1 10331 10332 $(id_form + ' .allegati1 .add').removeClass('hidden'); 10333 10334 // Reset ids 10335 if ($(id_form + ' .allegati1 .allegato:not(.hidden)').length) { 10336 var n = 1 10337 $(id_form + ' .allegati1 .allegato:not(.hidden)').each(function () { 10338 $(this).find('input').attr('name', 'file' + n).attr('id', 'file' + n) 10339 $(this).find('label').attr('for', 'file' + n) 10340 n++ 10341 }) 10342 } 10343 } 10344 function change(event) { 10345 var id = $(this).attr('id'); 10346 10347 tmp = $(this).val().split("\\"); 10348 var v = tmp[tmp.length - 1]; 10349 10350 if (v) { 10351 tmp2 = v.split('.'); 10352 var ext = tmp2[(tmp2.length - 1)].toLowerCase(); 10353 10354 10355 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size').addClass('hidden'); 10356 10357 if (ext != 'jpg' && ext != 'jpeg' && ext != 'pdf' && ext != 'png' && ext != 'doc' && ext != 'docx' && ext != 'xls' && ext != 'xlsx') { 10358 // Type error 10359 $('.allegati1 .error-messages-type').removeClass('hidden'); 10360 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 10361 } 10362 else { 10363 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 10364 // Size error 10365 $('.allegati1 .error-messages-size').removeClass('hidden'); 10366 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 10367 } 10368 else { 10369 $('label[for=' + id + '] span').text(v); 10370 10371 if ($('#attachments-error').length) $('#attachments-error').remove(); 10372 10373 uploadFile[id] = event.target.files; 10374 10375 $('.allegati1 .allegato.new.hidden').removeClass('new hidden'); 10376 $(id_form + ' .allegati1 .add').html(uploadButtonContent); 10377 10378 10379 attachments_n++; 10380 if (max_uploads < attachments_n) $(id_form + ' .allegati1 .add').addClass('hidden'); 10381 } 10382 } 10383 } 10384 } 10385 init(); 10386 } 10387 init(); 10388} 10389 10390function initFormularioIASAdeguamento2() { 10391 var uploadFile = {}; 10392 var url = '/fileadmin/DSS/IAS/formulario_ias_adeguamento_2/'; 10393 var loading = false; 10394 var anno_contributivo = false; 10395 function init() { 10396 $('.intro .start').click(startForm) 10397 $('input[name=adeguare]').change(checkAdeguare) 10398 $('input[name=adeguare_anni]').change(checkAdeguamentiRetroattivi) 10399 $('input[name=redditi]').change(checkRedditi) 10400 $('.send-form').click(send); 10401 10402 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 10403 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 10404 }); 10405 10406 initMultiUpload1(); 10407 10408 $('input[name*=da]').attr('placeholder', 'xx.xx.xxxx') 10409 10410 } 10411 function startForm() { 10412 $('.intro').addClass('hidden') 10413 $('form.hidden').removeClass('hidden') 10414 } 10415 function checkAdeguare() { 10416 if ($('#adeguare1').is(':checked')) { 10417 $('.anno_contributivo').removeClass('hidden'); 10418 $('.redditi, .sostanza_netta').addClass('hidden'); 10419 anno_contributivo = true; 10420 } 10421 else { 10422 $('.anno_contributivo').addClass('hidden'); 10423 $('.redditi, .sostanza_netta').removeClass('hidden'); 10424 anno_contributivo = false; 10425 } 10426 } 10427 function checkAdeguamentiRetroattivi() { 10428 if ($(this).is(':checked')) $(this).parent().next().removeClass('hidden') 10429 else { 10430 $(this).parent().next().addClass('hidden') 10431 $(this).parents('.checkbox').next().addClass('hidden') 10432 } 10433 } 10434 function checkRedditi() { 10435 var p = $(this).parents('tr') 10436 if ($(this).is(':checked')) { 10437 p.find('input[type=text]').removeAttr('disabled') 10438 } 10439 else { 10440 p.find('input[type=text]').prop('disabled', true) 10441 p.find('.error-messages').addClass('hidden') 10442 } 10443 } 10444 function send(e) { 10445 e.preventDefault(); 10446 10447 if (!loading) { 10448 loading = true; 10449 10450 var error = false;
10451 10452 10453 if (!checkField('#numero_affiliato')) error = true; 10454 if (!checkField('#nome')) error = true; 10455 if (!checkField('#cognome')) error = true; 10456 if (!checkField('#indirizzo')) error = true; 10457 if (!checkField('#cap')) error = true; 10458 if (!checkField('#localita')) error = true; 10459 if (!checkField('#nazione')) error = true; 10460 if (!checkField('#telefono')) error = true; 10461 if (!checkField('#email', 'email')) error = true; 10462 if (!checkField('input[name=adeguare]', 'radio')) error = true; 10463 10464 if (anno_contributivo) { 10465 if (!checkField('#anno_contributivo')) error = true; 10466 10467 if ($('input[name=adeguare_anni]:checked').length) { 10468 $('input[name=adeguare_anni]:checked').each(function () { 10469 var f = $('input[name=' + $(this).attr('id') + '_v]') 10470 if (f.val()) $(this).parents('.checkbox').next().addClass('hidden') 10471 else { 10472 $(this).parents('.checkbox').next().removeClass('hidden') 10473 error = true 10474 } 10475 }) 10476 } 10477 } 10478 10479 10480 10481 if ($('input[name=redditi]:checked').length) { 10482 $('input[name=redditi]:checked').each(function () { 10483 if (!checkField('input[name=' + $(this).attr('id') + '_chf]')) error = true; 10484 if (!checkField('input[name=' + $(this).attr('id') + '_da]')) error = true; 10485 }) 10486 } 10487 10488 10489 if (!error) { 10490 if (!checkCaptchaField()) error = true; 10491 } 10492 10493 10494 if (!error) { 10495 var data = new FormData(); 10496 10497 data.append('numero_affiliato', $('#numero_affiliato').val()); 10498 data.append('nome', $('#nome').val()); 10499 data.append('cognome', $('#cognome').val()); 10500 data.append('indirizzo', $('#indirizzo').val()); 10501 data.append('cap', $('#cap').val()); 10502 data.append('localita', $('#localita').val()); 10503 data.append('nazione', $('#nazione').val()); 10504 data.append('telefono', $('#telefono').val()); 10505 data.append('email', $('#email').val()); 10506 data.append('adeguare', $('input[name=adeguare]:checked').val()); 10507 data.append('anno_contributivo', $('#anno_contributivo').val()); 10508 10509 if ($('input[name=adeguare_anni]:checked').length) { 10510 var d = {} 10511 $('input[name=adeguare_anni]:checked').each(function () { 10512 d[$(this).val()] = $('input[name=' + $(this).attr('id') + '_v]').val() 10513 }) 10514 data.append('adeguare_anni', JSON.stringify(d)) 10515 } 10516 10517 if ($('input[name=redditi]:checked').length) { 10518 var d = {} 10519 $('input[name=redditi]:checked').each(function () { 10520 d[$(this).val()] = { 10521 'chf': $('input[name=' + $(this).attr('id') + '_chf]').val(), 10522 'date': $('input[name=' + $(this).attr('id') + '_da]').val() 10523 } 10524 }) 10525 data.append('redditi', JSON.stringify(d)) 10526 } 10527 10528 for (x in uploadFile) { 10529 data.append(x, document.getElementById(x).files[0]); 10530 } 10531 10532 var button_text = $('button.send-form').text(); 10533 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 10534 $.ajax({ 10535 url: url + 'save.php', // point to server-side PHP script 10536 dataType: 'text', // what to expect back from the PHP script, if anything 10537 cache: false, 10538 contentType: false, 10539 processData: false, 10540 data: data, 10541 type: 'post', 10542 success: function (php_script_response) { 10543 if (php_script_response == 'ok') { 10544 $('form, .intro').remove(); 10545 $('.success').removeClass('hidden'); 10546 } 10547 else { 10548 $('button.send-form').html(button_text).removeClass('disabled'); 10549 loading = false;
10550 } 10551 } 10552 }); 10553 } 10554 else { 10555 loading = false; 10556 $('html, body').animate({ 'scrollTop': $('.error-messages:not(.hidden):first').offset().top - 50 }, 50) 10557 } 10558 } 10559 } 10560 function checkField(s, type) { 10561 if (typeof type == 'undefined') { 10562 if ($(s).val() == '') { 10563 $(s).siblings('.error-messages').removeClass('hidden'); 10564 return false; 10565 } 10566 else { 10567 $(s).siblings('.error-messages').addClass('hidden'); 10568 return true; 10569 } 10570 } 10571 else if (type == 'radio' || type == 'checkbox') { 10572 if ($(s + ':checked').length == 0) { 10573 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 10574 return false; 10575 } 10576 else { 10577 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 10578 return true; 10579 } 10580 } 10581 else if (type == 'email') { 10582 if ($(s).val() == '' || !checkEmail($(s).val())) { 10583 $(s).siblings('.error-messages').removeClass('hidden'); 10584 return false; 10585 } 10586 else { 10587 $(s).siblings('.error-messages').addClass('hidden'); 10588 return true; 10589 } 10590 } 10591 else if (type == 'date') { 10592 if ($(s).val() == '' || !checkDate($(s).val())) { 10593 $(s).siblings('.error-messages').removeClass('hidden'); 10594 return false; 10595 } 10596 else { 10597 $(s).siblings('.error-messages').addClass('hidden'); 10598 return true; 10599 } 10600 } 10601 } 10602 function checkEmail(email) { 10603 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,}))$/; 10604 return re.test(String(email).toLowerCase()); 10605 } 10606 function checkDate(value) { 10607 if (new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 10608 else return false; 10609 } 10610 function checkCaptchaField() { 10611 var field = $('input[name=captcha]'); 10612 var error = false; 10613 10614 if (field.val()) { 10615 var r = checkCaptcha(field.val()); 10616 if (r.responseText == 'ok') { 10617 field.removeClass('error'); 10618 $('.captcha .error-messages').addClass('hidden'); 10619 } 10620 else { 10621 field.addClass('error').val(''); 10622 $('.refresh-button').trigger('click'); 10623 $('.captcha .error-messages').removeClass('hidden'); 10624 error = true; 10625 } 10626 } 10627 else { 10628 field.addClass('error'); 10629 $('.refresh-button').trigger('click'); 10630 $('.captcha .error-messages').removeClass('hidden'); 10631 error = true; 10632 } 10633 10634 if (!error) return true; 10635 return false; 10636 } 10637 function checkCaptcha(value) { 10638 var rand = Math.floor((Math.random() * 100000) + 1); 10639 return $.ajax({ 10640 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 10641 data: { 10642 value: value 10643 }, 10644 async: false, 10645 method: 'post' 10646 }); 10647 } 10648 function initMultiUpload1() { 10649 var id_form = '#formulario_ias_adeguamento_2'; 10650 var attachments_n = 1; 10651 var max_uploads = 5; 10652 var max_weight = 10; 10653 var working = false; 10654 var uploadButtonContent = ''; 10655 function init() { 10656 uploadButtonContent = $(id_form + ' .allegati1 .add').html(); 10657 10658 $(id_form).on('click', '.allegati1 .add', addAttachemnt); 10659 $(id_form).on('click', '.allegati1 .remove', clearAttachemnt); 10660 10661 $(id_form).on('change', '.allegati1 .inputfile', change); 10662 } 10663 function addAttachemnt(e) { 10664 e.preventDefault(); 10665 10666 if (!working) { 10667 $(this).siblings('.allegato.hidden.new').remove(); 10668 10669 if ($('#attachments-error').length) $('#attachments-error').remove(); 10670 10671 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 10672 $(id_form + ' .allegati1 .allegato.new label').attr('for', 'file' + attachments_n); 10673 $(id_form + ' .allegati1 .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 10674 10675 $(id_form + ' .allegati1 .allegato.new input:last').trigger('click'); 10676 } 10677 } 10678 function clearAttachemnt(e) { 10679 e.preventDefault(); 10680 10681 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 10682 uploadFile[id] = false;
10683 10684 var p = $(this).parents('.allegato'); 10685 10686 p.find('input[type=file]').val(''); 10687 p.find('input[type=file]').next().children('span').text('Allega un file'); 10688 p.remove(); 10689 10690 attachments_n--; 10691 if (attachments_n < 1) attachments_n = 1 10692 10693 $(id_form + ' .allegati1 .add').removeClass('hidden'); 10694 10695 // Reset ids 10696 if ($(id_form + ' .allegati1 .allegato:not(.hidden)').length) { 10697 var n = 1 10698 $(id_form + ' .allegati1 .allegato:not(.hidden)').each(function () { 10699 $(this).find('input').attr('name', 'file' + n).attr('id', 'file' + n) 10700 $(this).find('label').attr('for', 'file' + n) 10701 n++ 10702 }) 10703 } 10704 } 10705 function change(event) { 10706 var id = $(this).attr('id'); 10707 10708 tmp = $(this).val().split("\\"); 10709 var v = tmp[tmp.length - 1]; 10710 10711 if (v) { 10712 tmp2 = v.split('.'); 10713 var ext = tmp2[(tmp2.length - 1)].toLowerCase(); 10714 10715 10716 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size').addClass('hidden'); 10717 10718 if (ext != 'jpg' && ext != 'pdf' && ext != 'png' && ext != 'doc' && ext != 'docx' && ext != 'xls' && ext != 'xlsx') { 10719 // Type error 10720 $('.allegati1 .error-messages-type').removeClass('hidden'); 10721 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 10722 } 10723 else { 10724 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 10725 // Size error 10726 $('.allegati1 .error-messages-size').removeClass('hidden'); 10727 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 10728 } 10729 else { 10730 $('label[for=' + id + '] span').text(v); 10731 10732 if ($('#attachments-error').length) $('#attachments-error').remove(); 10733 10734 uploadFile[id] = event.target.files; 10735 10736 $('.allegati1 .allegato.new.hidden').removeClass('new hidden'); 10737 $(id_form + ' .allegati1 .add').html(uploadButtonContent); 10738 10739 10740 attachments_n++; 10741 if (max_uploads < attachments_n) $(id_form + ' .allegati1 .add').addClass('hidden'); 10742 } 10743 } 10744 } 10745 } 10746 init(); 10747 } 10748 init(); 10749} 10750 10751function initFormularioIASAdeguamento3() { 10752 var uploadFile = {}; 10753 var url = '/fileadmin/DSS/IAS/formulario_ias_adeguamento_3/'; 10754 var loading = false; 10755 var reddito_professionale = false; 10756 function init() { 10757 $('.intro .start').click(startForm) 10758 $('input[name=adeguare]').change(checkAdeguare) 10759 $('input[name=adeguare_anni]').change(checkAdeguamentiRetroattivi) 10760 $('.send-form').click(send); 10761 10762 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 10763 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 10764 }); 10765 10766 initMultiUpload1(); 10767 } 10768 function startForm() { 10769 $('.intro').addClass('hidden') 10770 $('form.hidden').removeClass('hidden') 10771 } 10772 function checkAdeguare() { 10773 if ($('#adeguare1').is(':checked')) { 10774 $('.reddito_professionale').removeClass('hidden'); 10775 $('.redditi').addClass('hidden'); 10776 reddito_professionale = true; 10777 } 10778 else { 10779 $('.reddito_professionale').addClass('hidden'); 10780 $('.redditi').removeClass('hidden'); 10781 reddito_professionale = false; 10782 } 10783 } 10784 function checkAdeguamentiRetroattivi() { 10785 if ($(this).is(':checked')) $(this).parent().next().removeClass('hidden') 10786 else { 10787 $(this).parent().next().addClass('hidden') 10788 $(this).parents('.checkbox').next().addClass('hidden') 10789 } 10790 } 10791 function send(e) { 10792 e.preventDefault(); 10793 10794 if (!loading) { 10795 loading = true; 10796 10797 var error = false;
10798 10799 10800 if (!checkField('#numero_affiliato')) error = true; 10801 if (!checkField('#nome')) error = true; 10802 if (!checkField('#cognome')) error = true; 10803 if (!checkField('#ragione_sociale')) error = true; 10804 if (!checkField('#indirizzo')) error = true; 10805 if (!checkField('#cap')) error = true; 10806 if (!checkField('#localita')) error = true; 10807 if (!checkField('#nazione')) error = true; 10808 if (!checkField('#telefono')) error = true; 10809 if (!checkField('#email', 'email')) error = true; 10810 if (!checkField('input[name=adeguare]', 'radio')) error = true; 10811 10812 if (reddito_professionale) { 10813 if (!checkField('#reddito_professionale')) error = true; 10814 } 10815 10816 if ($('input[name=adeguare_anni]:checked').length) { 10817 $('input[name=adeguare_anni]:checked').each(function () { 10818 var f = $('input[name=' + $(this).attr('id') + '_v]') 10819 if (f.val()) $(this).parents('.checkbox').next().addClass('hidden') 10820 else { 10821 $(this).parents('.checkbox').next().removeClass('hidden') 10822 error = true 10823 } 10824 }) 10825 } 10826 10827 if (!error) { 10828 if (!checkCaptchaField()) error = true; 10829 } 10830 10831 if (!error) { 10832 var data = new FormData(); 10833 10834 data.append('numero_affiliato', $('#numero_affiliato').val()); 10835 data.append('nome', $('#nome').val()); 10836 data.append('cognome', $('#cognome').val()); 10837 data.append('ragione_sociale', $('#ragione_sociale').val()); 10838 data.append('indirizzo', $('#indirizzo').val()); 10839 data.append('cap', $('#cap').val()); 10840 data.append('localita', $('#localita').val()); 10841 data.append('nazione', $('#nazione').val()); 10842 data.append('telefono', $('#telefono').val()); 10843 data.append('email', $('#email').val()); 10844 data.append('adeguare', $('input[name=adeguare]:checked').val()); 10845 data.append('reddito_professionale', $('#reddito_professionale').val()); 10846 10847 if ($('input[name=adeguare_anni]:checked').length) { 10848 var d = {} 10849 $('input[name=adeguare_anni]:checked').each(function () { 10850 d[$(this).val()] = $('input[name=' + $(this).attr('id') + '_v]').val() 10851 }) 10852 data.append('adeguare_anni', JSON.stringify(d)) 10853 } 10854 10855 for (x in uploadFile) { 10856 data.append(x, document.getElementById(x).files[0]); 10857 } 10858 10859 var button_text = $('button.send-form').text(); 10860 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 10861 $.ajax({ 10862 url: url + 'save.php', // point to server-side PHP script 10863 dataType: 'text', // what to expect back from the PHP script, if anything 10864 cache: false, 10865 contentType: false, 10866 processData: false, 10867 data: data, 10868 type: 'post', 10869 success: function (php_script_response) { 10870 if (php_script_response == 'ok') { 10871 $('form, .intro').remove(); 10872 $('.success').removeClass('hidden'); 10873 } 10874 else { 10875 $('button.send-form').html(button_text).removeClass('disabled'); 10876 loading = false; 10877 10878 } 10879 } 10880 }); 10881 } 10882 else { 10883 loading = false; 10884 $('html, body').animate({ 'scrollTop': $('.error-messages:not(.hidden):first').offset().top - 50 }, 50) 10885 } 10886 } 10887 } 10888 function checkField(s, type) { 10889 if (typeof type == 'undefined') { 10890 if ($(s).val() == '') { 10891 $(s).siblings('.error-messages').removeClass('hidden'); 10892 return false;
10893 } 10894 else { 10895 $(s).siblings('.error-messages').addClass('hidden'); 10896 return true; 10897 } 10898 } 10899 else if (type == 'radio' || type == 'checkbox') { 10900 if ($(s + ':checked').length == 0) { 10901 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 10902 return false; 10903 } 10904 else { 10905 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 10906 return true; 10907 } 10908 } 10909 else if (type == 'email') { 10910 if ($(s).val() == '' || !checkEmail($(s).val())) { 10911 $(s).siblings('.error-messages').removeClass('hidden'); 10912 return false; 10913 } 10914 else { 10915 $(s).siblings('.error-messages').addClass('hidden'); 10916 return true; 10917 } 10918 } 10919 else if (type == 'date') { 10920 if ($(s).val() == '' || !checkDate($(s).val())) { 10921 $(s).siblings('.error-messages').removeClass('hidden'); 10922 return false; 10923 } 10924 else { 10925 $(s).siblings('.error-messages').addClass('hidden'); 10926 return true; 10927 } 10928 } 10929 } 10930 function checkEmail(email) { 10931 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,}))$/; 10932 return re.test(String(email).toLowerCase()); 10933 } 10934 function checkDate(value) { 10935 if (new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 10936 else return false; 10937 } 10938 function checkCaptchaField() { 10939 var field = $('input[name=captcha]'); 10940 var error = false; 10941 10942 if (field.val()) { 10943 var r = checkCaptcha(field.val()); 10944 if (r.responseText == 'ok') { 10945 field.removeClass('error'); 10946 $('.captcha .error-messages').addClass('hidden'); 10947 } 10948 else { 10949 field.addClass('error').val(''); 10950 $('.refresh-button').trigger('click'); 10951 $('.captcha .error-messages').removeClass('hidden'); 10952 error = true; 10953 } 10954 } 10955 else { 10956 field.addClass('error'); 10957 $('.refresh-button').trigger('click'); 10958 $('.captcha .error-messages').removeClass('hidden'); 10959 error = true; 10960 } 10961 10962 if (!error) return true; 10963 return false; 10964 } 10965 function checkCaptcha(value) { 10966 var rand = Math.floor((Math.random() * 100000) + 1); 10967 return $.ajax({ 10968 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 10969 data: { 10970 value: value 10971 }, 10972 async: false, 10973 method: 'post' 10974 }); 10975 } 10976 function initMultiUpload1() { 10977 var id_form = '#formulario_ias_adeguamento_3'; 10978 var attachments_n = 1; 10979 var max_uploads = 5; 10980 var max_weight = 10; 10981 var working = false; 10982 var uploadButtonContent = ''; 10983 function init() { 10984 uploadButtonContent = $(id_form + ' .allegati1 .add').html(); 10985 10986 $(id_form).on('click', '.allegati1 .add', addAttachemnt); 10987 $(id_form).on('click', '.allegati1 .remove', clearAttachemnt); 10988 10989 $(id_form).on('change', '.allegati1 .inputfile', change); 10990 } 10991 function addAttachemnt(e) { 10992 e.preventDefault(); 10993 10994 if (!working) { 10995 $(this).siblings('.allegato.hidden.new').remove(); 10996 10997 if ($('#attachments-error').length) $('#attachments-error').remove(); 10998 10999 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 11000 $(id_form + ' .allegati1 .allegato.new label').attr('for', 'file' + attachments_n); 11001 $(id_form + ' .allegati1 .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 11002 11003 $(id_form + ' .allegati1 .allegato.new input:last').trigger('click'); 11004 } 11005 } 11006 function clearAttachemnt(e) { 11007 e.preventDefault(); 11008 11009 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 11010 uploadFile[id] = false;
11011 11012 var p = $(this).parents('.allegato'); 11013 11014 p.find('input[type=file]').val(''); 11015 p.find('input[type=file]').next().children('span').text('Allega un file'); 11016 p.remove(); 11017 11018 attachments_n--; 11019 if (attachments_n < 1) attachments_n = 1 11020 11021 $(id_form + ' .allegati1 .add').removeClass('hidden'); 11022 11023 // Reset ids 11024 if ($(id_form + ' .allegati1 .allegato:not(.hidden)').length) { 11025 var n = 1 11026 $(id_form + ' .allegati1 .allegato:not(.hidden)').each(function () { 11027 $(this).find('input').attr('name', 'file' + n).attr('id', 'file' + n) 11028 $(this).find('label').attr('for', 'file' + n) 11029 n++ 11030 }) 11031 } 11032 } 11033 function change(event) { 11034 var id = $(this).attr('id'); 11035 11036 tmp = $(this).val().split("\\"); 11037 var v = tmp[tmp.length - 1]; 11038 11039 if (v) { 11040 tmp2 = v.split('.'); 11041 var ext = tmp2[(tmp2.length - 1)].toLowerCase(); 11042 11043 11044 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size').addClass('hidden'); 11045 11046 if (ext != 'jpg' && ext != 'pdf' && ext != 'png' && ext != 'doc' && ext != 'docx' && ext != 'xls' && ext != 'xlsx') { 11047 // Type error 11048 $('.allegati1 .error-messages-type').removeClass('hidden'); 11049 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 11050 } 11051 else { 11052 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 11053 // Size error 11054 $('.allegati1 .error-messages-size').removeClass('hidden'); 11055 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 11056 } 11057 else { 11058 $('label[for=' + id + '] span').text(v); 11059 11060 if ($('#attachments-error').length) $('#attachments-error').remove(); 11061 11062 uploadFile[id] = event.target.files; 11063 11064 $('.allegati1 .allegato.new.hidden').removeClass('new hidden'); 11065 $(id_form + ' .allegati1 .add').html(uploadButtonContent); 11066 11067 11068 attachments_n++; 11069 if (max_uploads < attachments_n) $(id_form + ' .allegati1 .add').addClass('hidden'); 11070 } 11071 } 11072 } 11073 } 11074 init(); 11075 } 11076 init(); 11077} 11078 11079function initFormularioIasUpComunicazioni() { 11080 var uploadFile = {}; 11081 var url = '/fileadmin/DSS/IAS/formulario_ias_up_comunicazioni/'; 11082 var loading = false; 11083 var reddito_professionale = false; 11084 function init() { 11085 11086 $('.send-form').click(send); 11087 11088 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 11089 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 11090 }); 11091 11092 $('input[name=infos]').click(changeInfos) 11093 11094 initMultiUpload1(); 11095 } 11096 function changeInfos() { 11097 if ($(this).val() == 1) { 11098 $('textarea[name=info_extra]').prop('disabled', true) 11099 $('textarea[name=info_extra]').next().addClass('hidden') 11100 } 11101 else $('textarea[name=info_extra]').prop('disabled', false) 11102 } 11103 11104 function send(e) { 11105 e.preventDefault(); 11106 11107 if (!loading) { 11108 loading = true; 11109 11110 var error = false; 11111 11112 11113 if (!checkField('#prestazione')) error = true; 11114 11115 if (!checkField('#avs')) error = true; 11116 if (!checkField('#nome')) error = true; 11117 if (!checkField('#cognome')) error = true; 11118 11119 if (!checkField('#nome_autorizzo')) error = true; 11120 if (!checkField('#cognome_autorizzo')) error = true; 11121 if (!checkField('#nascita_autorizzo')) error = true; 11122 if (!checkField('#via_autorizzo')) error = true; 11123 if (!checkField('#localita_autorizzo')) error = true; 11124 11125 11126 if ($('input[name=infos]:checked').length) { 11127 $('.info-text').removeClass('error') 11128 if ($('input[name=infos]:checked').val() == 2 && $('textarea[name=info_extra]').val() == '') { 11129 $('textarea[name=info_extra]').next().removeClass('hidden') 11130 error = true 11131 } 11132 else $('textarea[name=info_extra]').next().addClass('hidden') 11133 } 11134 else { 11135 error = true 11136 // add error class 11137 $('.info-text').addClass('error') 11138 } 11139 11140 11141 if (!error) { 11142 if (!checkCaptchaField()) error = true; 11143 } 11144 11145 11146 if (!error) { 11147 var data = new FormData(); 11148 11149 data.append('prestazione', $('#prestazione').val()); 11150 data.append('avs', $('#avs').val()); 11151 data.append('nome', $('#nome').val()); 11152 data.append('cognome', $('#cognome').val()); 11153 data.append('nome_autorizzo', $('#nome_autorizzo').val()); 11154 data.append('cognome_autorizzo', $('#cognome_autorizzo').val()); 11155 data.append('nascita_autorizzo', $('#nascita_autorizzo').val()); 11156 data.append('via_autorizzo', $('#via_autorizzo').val()); 11157 data.append('localita_autorizzo', $('#localita_autorizzo').val()); 11158 11159 data.append('infos', $('input[name=infos]:checked').val()); 11160 data.append('infos_text', $('textarea[name=info_extra]').val()); 11161 11162 11163 var button_text = $('button.send-form').text(); 11164 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 11165 $.ajax({ 11166 url: url + 'save.php', // point to server-side PHP script 11167 dataType: 'text', // what to expect back from the PHP script, if anything 11168 cache: false, 11169 contentType: false, 11170 processData: false, 11171 data: data, 11172 type: 'post', 11173 success: function (php_script_response) { 11174 $('form, .intro').remove(); 11175 $('.success').removeClass('hidden'); 11176 $('.pdf-link').attr('href', url + php_script_response) 11177 } 11178 }); 11179 } 11180 else { 11181 loading = false;
11182 $('html, body').animate({ 'scrollTop': $('.error-messages:not(.hidden):first').offset().top - 50 }, 50) 11183 } 11184 } 11185 } 11186 function checkField(s, type) { 11187 if (typeof type == 'undefined') { 11188 if ($(s).val() == '') { 11189 $(s).siblings('.error-messages').removeClass('hidden'); 11190 return false; 11191 } 11192 else { 11193 $(s).siblings('.error-messages').addClass('hidden'); 11194 return true; 11195 } 11196 } 11197 else if (type == 'radio' || type == 'checkbox') { 11198 if ($(s + ':checked').length == 0) { 11199 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 11200 return false; 11201 } 11202 else { 11203 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 11204 return true; 11205 } 11206 } 11207 else if (type == 'email') { 11208 if ($(s).val() == '' || !checkEmail($(s).val())) { 11209 $(s).siblings('.error-messages').removeClass('hidden'); 11210 return false; 11211 } 11212 else { 11213 $(s).siblings('.error-messages').addClass('hidden'); 11214 return true; 11215 } 11216 } 11217 else if (type == 'date') { 11218 if ($(s).val() == '' || !checkDate($(s).val())) { 11219 $(s).siblings('.error-messages').removeClass('hidden'); 11220 return false; 11221 } 11222 else { 11223 $(s).siblings('.error-messages').addClass('hidden'); 11224 return true; 11225 } 11226 } 11227 } 11228 function checkEmail(email) { 11229 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,}))$/; 11230 return re.test(String(email).toLowerCase()); 11231 } 11232 function checkDate(value) { 11233 if (new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 11234 else return false; 11235 } 11236 function checkCaptchaField() { 11237 var field = $('input[name=captcha]'); 11238 var error = false; 11239 11240 if (field.val()) { 11241 var r = checkCaptcha(field.val()); 11242 if (r.responseText == 'ok') { 11243 field.removeClass('error'); 11244 $('.captcha .error-messages').addClass('hidden'); 11245 } 11246 else { 11247 field.addClass('error').val(''); 11248 $('.refresh-button').trigger('click'); 11249 $('.captcha .error-messages').removeClass('hidden'); 11250 error = true; 11251 } 11252 } 11253 else { 11254 field.addClass('error'); 11255 $('.refresh-button').trigger('click'); 11256 $('.captcha .error-messages').removeClass('hidden'); 11257 error = true; 11258 } 11259 11260 if (!error) return true; 11261 return false; 11262 } 11263 function checkCaptcha(value) { 11264 var rand = Math.floor((Math.random() * 100000) + 1); 11265 return $.ajax({ 11266 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 11267 data: { 11268 value: value 11269 }, 11270 async: false, 11271 method: 'post' 11272 }); 11273 } 11274 function initMultiUpload1() { 11275 var id_form = '#formulario_ias_adeguamento_3'; 11276 var attachments_n = 1; 11277 var max_uploads = 5; 11278 var max_weight = 10; 11279 var working = false; 11280 var uploadButtonContent = ''; 11281 function init() { 11282 uploadButtonContent = $(id_form + ' .allegati1 .add').html(); 11283 11284 $(id_form).on('click', '.allegati1 .add', addAttachemnt); 11285 $(id_form).on('click', '.allegati1 .remove', clearAttachemnt); 11286 11287 $(id_form).on('change', '.allegati1 .inputfile', change); 11288 } 11289 function addAttachemnt(e) { 11290 e.preventDefault(); 11291 11292 if (!working) { 11293 $(this).siblings('.allegato.hidden.new').remove(); 11294 11295 if ($('#attachments-error').length) $('#attachments-error').remove(); 11296 11297 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 11298 $(id_form + ' .allegati1 .allegato.new label').attr('for', 'file' + attachments_n); 11299 $(id_form + ' .allegati1 .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 11300 11301 $(id_form + ' .allegati1 .allegato.new input:last').trigger('click'); 11302 } 11303 } 11304 function clearAttachemnt(e) { 11305 e.preventDefault(); 11306 11307 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 11308 uploadFile[id] = false;
11309 11310 var p = $(this).parents('.allegato'); 11311 11312 p.find('input[type=file]').val(''); 11313 p.find('input[type=file]').next().children('span').text('Allega un file'); 11314 p.remove(); 11315 11316 attachments_n--; 11317 if (attachments_n < 1) attachments_n = 1 11318 11319 $(id_form + ' .allegati1 .add').removeClass('hidden'); 11320 11321 // Reset ids 11322 if ($(id_form + ' .allegati1 .allegato:not(.hidden)').length) { 11323 var n = 1 11324 $(id_form + ' .allegati1 .allegato:not(.hidden)').each(function () { 11325 $(this).find('input').attr('name', 'file' + n).attr('id', 'file' + n) 11326 $(this).find('label').attr('for', 'file' + n) 11327 n++ 11328 }) 11329 } 11330 } 11331 function change(event) { 11332 var id = $(this).attr('id'); 11333 11334 tmp = $(this).val().split("\\"); 11335 var v = tmp[tmp.length - 1]; 11336 11337 if (v) { 11338 tmp2 = v.split('.'); 11339 var ext = tmp2[(tmp2.length - 1)].toLowerCase(); 11340 11341 11342 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size').addClass('hidden'); 11343 11344 if (ext != 'jpg' && ext != 'pdf' && ext != 'png' && ext != 'doc' && ext != 'docx' && ext != 'xls' && ext != 'xlsx') { 11345 // Type error 11346 $('.allegati1 .error-messages-type').removeClass('hidden'); 11347 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 11348 } 11349 else { 11350 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 11351 // Size error 11352 $('.allegati1 .error-messages-size').removeClass('hidden'); 11353 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 11354 } 11355 else { 11356 $('label[for=' + id + '] span').text(v); 11357 11358 if ($('#attachments-error').length) $('#attachments-error').remove(); 11359 11360 uploadFile[id] = event.target.files; 11361 11362 $('.allegati1 .allegato.new.hidden').removeClass('new hidden'); 11363 $(id_form + ' .allegati1 .add').html(uploadButtonContent); 11364 11365 11366 attachments_n++; 11367 if (max_uploads < attachments_n) $(id_form + ' .allegati1 .add').addClass('hidden'); 11368 } 11369 } 11370 } 11371 } 11372 init(); 11373 } 11374 init(); 11375} 11376 11377function initFormularioIasUpProcura() { 11378 var uploadFile = {}; 11379 var url = '/fileadmin/DSS/IAS/formulario_ias_up_procura/'; 11380 var loading = false; 11381 var reddito_professionale = false; 11382 function init() { 11383 $('.send-form').click(send); 11384 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 11385 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 11386 }); 11387 } 11388 function send(e) { 11389 e.preventDefault(); 11390 11391 if (!loading) { 11392 loading = true; 11393 11394 var error = false; 11395 11396 11397 if (!checkField('#prestazione')) error = true; 11398 11399 if (!checkField('#avs')) error = true; 11400 if (!checkField('#nome')) error = true; 11401 if (!checkField('#cognome')) error = true; 11402 11403 if (!checkField('#nome_autorizzo')) error = true; 11404 if (!checkField('#cognome_autorizzo')) error = true; 11405 if (!checkField('#nascita_autorizzo')) error = true; 11406 if (!checkField('#via_autorizzo')) error = true; 11407 if (!checkField('#localita_autorizzo')) error = true; 11408 11409 if (!error) { 11410 if (!checkCaptchaField()) error = true; 11411 } 11412 11413 if (!error) { 11414 var data = new FormData(); 11415 11416 data.append('prestazione', $('#prestazione').val()); 11417 data.append('avs', $('#avs').val()); 11418 data.append('nome', $('#nome').val()); 11419 data.append('cognome', $('#cognome').val()); 11420 data.append('nome_autorizzo', $('#nome_autorizzo').val()); 11421 data.append('cognome_autorizzo', $('#cognome_autorizzo').val()); 11422 data.append('nascita_autorizzo', $('#nascita_autorizzo').val()); 11423 data.append('via_autorizzo', $('#via_autorizzo').val()); 11424 data.append('localita_autorizzo', $('#localita_autorizzo').val()); 11425 11426 var button_text = $('button.send-form').text(); 11427 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 11428 $.ajax({ 11429 url: url + 'save.php', // point to server-side PHP script 11430 dataType: 'text', // what to expect back from the PHP script, if anything 11431 cache: false, 11432 contentType: false, 11433 processData: false, 11434 data: data, 11435 type: 'post', 11436 success: function (php_script_response) { 11437 $('form, .intro').remove(); 11438 $('.success').removeClass('hidden'); 11439 $('.pdf-link').attr('href', url + php_script_response) 11440 11441 } 11442 }); 11443 } 11444 else { 11445 loading = false;
11446 $('html, body').animate({ 'scrollTop': $('.error-messages:not(.hidden):first').offset().top - 50 }, 50) 11447 } 11448 } 11449 } 11450 function checkField(s, type) { 11451 if (typeof type == 'undefined') { 11452 if ($(s).val() == '') { 11453 $(s).siblings('.error-messages').removeClass('hidden'); 11454 return false; 11455 } 11456 else { 11457 $(s).siblings('.error-messages').addClass('hidden'); 11458 return true; 11459 } 11460 } 11461 else if (type == 'radio' || type == 'checkbox') { 11462 if ($(s + ':checked').length == 0) { 11463 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 11464 return false; 11465 } 11466 else { 11467 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 11468 return true; 11469 } 11470 } 11471 else if (type == 'email') { 11472 if ($(s).val() == '' || !checkEmail($(s).val())) { 11473 $(s).siblings('.error-messages').removeClass('hidden'); 11474 return false; 11475 } 11476 else { 11477 $(s).siblings('.error-messages').addClass('hidden'); 11478 return true; 11479 } 11480 } 11481 else if (type == 'date') { 11482 if ($(s).val() == '' || !checkDate($(s).val())) { 11483 $(s).siblings('.error-messages').removeClass('hidden'); 11484 return false; 11485 } 11486 else { 11487 $(s).siblings('.error-messages').addClass('hidden'); 11488 return true; 11489 } 11490 } 11491 } 11492 function checkEmail(email) { 11493 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,}))$/; 11494 return re.test(String(email).toLowerCase()); 11495 } 11496 function checkDate(value) { 11497 if (new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 11498 else return false; 11499 } 11500 function checkCaptchaField() { 11501 var field = $('input[name=captcha]'); 11502 var error = false; 11503 11504 if (field.val()) { 11505 var r = checkCaptcha(field.val()); 11506 if (r.responseText == 'ok') { 11507 field.removeClass('error'); 11508 $('.captcha .error-messages').addClass('hidden'); 11509 } 11510 else { 11511 field.addClass('error').val(''); 11512 $('.refresh-button').trigger('click'); 11513 $('.captcha .error-messages').removeClass('hidden'); 11514 error = true; 11515 } 11516 } 11517 else { 11518 field.addClass('error'); 11519 $('.refresh-button').trigger('click'); 11520 $('.captcha .error-messages').removeClass('hidden'); 11521 error = true; 11522 } 11523 11524 if (!error) return true; 11525 return false; 11526 } 11527 function checkCaptcha(value) { 11528 var rand = Math.floor((Math.random() * 100000) + 1); 11529 return $.ajax({ 11530 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 11531 data: { 11532 value: value 11533 }, 11534 async: false, 11535 method: 'post' 11536 }); 11537 } 11538 function initMultiUpload1() { 11539 var id_form = '#formulario_ias_adeguamento_3'; 11540 var attachments_n = 1; 11541 var max_uploads = 5; 11542 var max_weight = 10; 11543 var working = false; 11544 var uploadButtonContent = ''; 11545 function init() { 11546 uploadButtonContent = $(id_form + ' .allegati1 .add').html(); 11547 11548 $(id_form).on('click', '.allegati1 .add', addAttachemnt); 11549 $(id_form).on('click', '.allegati1 .remove', clearAttachemnt); 11550 11551 $(id_form).on('change', '.allegati1 .inputfile', change); 11552 } 11553 function addAttachemnt(e) { 11554 e.preventDefault(); 11555 11556 if (!working) { 11557 $(this).siblings('.allegato.hidden.new').remove(); 11558 11559 if ($('#attachments-error').length) $('#attachments-error').remove(); 11560 11561 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 11562 $(id_form + ' .allegati1 .allegato.new label').attr('for', 'file' + attachments_n); 11563 $(id_form + ' .allegati1 .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 11564 11565 $(id_form + ' .allegati1 .allegato.new input:last').trigger('click'); 11566 } 11567 } 11568 function clearAttachemnt(e) { 11569 e.preventDefault(); 11570 11571 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 11572 uploadFile[id] = false;
11573 11574 var p = $(this).parents('.allegato'); 11575 11576 p.find('input[type=file]').val(''); 11577 p.find('input[type=file]').next().children('span').text('Allega un file'); 11578 p.remove(); 11579 11580 attachments_n--; 11581 if (attachments_n < 1) attachments_n = 1 11582 11583 $(id_form + ' .allegati1 .add').removeClass('hidden'); 11584 11585 // Reset ids 11586 if ($(id_form + ' .allegati1 .allegato:not(.hidden)').length) { 11587 var n = 1 11588 $(id_form + ' .allegati1 .allegato:not(.hidden)').each(function () { 11589 $(this).find('input').attr('name', 'file' + n).attr('id', 'file' + n) 11590 $(this).find('label').attr('for', 'file' + n) 11591 n++ 11592 }) 11593 } 11594 } 11595 function change(event) { 11596 var id = $(this).attr('id'); 11597 11598 tmp = $(this).val().split("\\"); 11599 var v = tmp[tmp.length - 1]; 11600 11601 if (v) { 11602 tmp2 = v.split('.'); 11603 var ext = tmp2[(tmp2.length - 1)].toLowerCase(); 11604 11605 11606 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size').addClass('hidden'); 11607 11608 if (ext != 'jpg' && ext != 'pdf' && ext != 'png' && ext != 'doc' && ext != 'docx' && ext != 'xls' && ext != 'xlsx') { 11609 // Type error 11610 $('.allegati1 .error-messages-type').removeClass('hidden'); 11611 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 11612 } 11613 else { 11614 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 11615 // Size error 11616 $('.allegati1 .error-messages-size').removeClass('hidden'); 11617 $('.allegati1 .allegato.new.hidden .remove').trigger('click'); 11618 } 11619 else { 11620 $('label[for=' + id + '] span').text(v); 11621 11622 if ($('#attachments-error').length) $('#attachments-error').remove(); 11623 11624 uploadFile[id] = event.target.files; 11625 11626 $('.allegati1 .allegato.new.hidden').removeClass('new hidden'); 11627 $(id_form + ' .allegati1 .add').html(uploadButtonContent); 11628 11629 11630 attachments_n++; 11631 if (max_uploads < attachments_n) $(id_form + ' .allegati1 .add').addClass('hidden'); 11632 } 11633 } 11634 } 11635 } 11636 init(); 11637 } 11638 init(); 11639} 11640var captcha_image_audioObj; 11641function initFormularioRimborsoPolizia(){ 11642 var url = '/fileadmin/DI/POLIZIA/formulario_rimborsi/'; 11643 var intestatario = false; 11644 var loading = false; 11645 var uploadFile = {}; 11646 function init(){ 11647 $('#formulario_rimborso_polizia input[name=intestato]').click(changeIntestatario); 11648 $('#formulario_rimborso_polizia button.send-form').click(send); 11649 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function (){ 11650 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 11651 }); 11652 initMultiUpload(); 11653 11654 $('#giustificativi').change(function (){ 11655 if($(this).is(':checked')) $('.giustificato').removeClass('hidden') 11656 else $('.giustificato').addClass('hidden') 11657 }) 11658 } 11659 function send(e){ 11660 e.preventDefault(); 11661 11662 if(!loading){ 11663 loading = true; 11664 11665 var error = false; 11666 11667 if(!checkField('#numero_riferimento')) error = true; 11668 // if(!checkField('#data_contravvenzione')) error = true; 11669 if(!checkField('#numero_targa')) error = true; 11670 if(!checkField('#nome')) error = true; 11671 // if(!checkField('#nome')) error = true; 11672 if(!checkField('#via')) error = true; 11673 if(!checkField('#nap')) error = true; 11674 if(!checkField('#localita')) error = true; 11675 if(!checkField('#paese')) error = true; 11676 if(!checkField('#telefono')) error = true; 11677 if(!checkField('#email', 'email')) error = true; 11678 if(!checkField('#istituto_nome')) error = true; 11679 if(!checkField('#istituto_via')) error = true; 11680 if(!checkField('#istituto_nap')) error = true; 11681 if(!checkField('#istituto_localita')) error = true; 11682 if(!checkField('#istituto_paese')) error = true; 11683 if(!checkField('#iban', 'iban')) error = true; 11684 else if(!checkIBAN($('#iban').val())){ 11685 error = true; 11686 $('#iban').siblings('.error-messages').removeClass('hidden'); 11687 } 11688 // else $('#iban').siblings('.error-messages').addClass('hidden'); 11689 if(!checkField('#swift')) error = true; 11690 11691 11692 if(!checkField('input[name=intestato]', 'radio')) error = true; 11693 else if(!intestatario){ 11694 if(!checkField('#intestatario_cognome')) error = true; 11695 if(!checkField('#intestatario_nome')) error = true; 11696 if(!checkField('#intestatario_via')) error = true; 11697 if(!checkField('#intestatario_nap')) error = true; 11698 if(!checkField('#intestatario_localita')) error = true; 11699 if(!checkField('#intestatario_paese')) error = true; 11700 } 11701 11702 if(!$('.allegati .allegato:not(.hidden)').length){ 11703 error = true; 11704 $('.allegati .error-messages').removeClass('hidden'); 11705 } 11706 else $('.allegati .error-messages').addClass('hidden'); 11707 11708 if(!error){ 11709 if(!checkCaptchaField()) error = true; 11710 } 11711 11712 if(!error){ 11713 var data = new FormData(); 11714 11715 data.append('lang', $('input[name=lang]').val()); 11716 11717 data.append('numero_riferimento', $('#numero_riferimento').val()); 11718 data.append('data_contravvenzione', $('#data_contravvenzione').val()); 11719 data.append('numero_targa', $('#numero_targa').val()); 11720 data.append('nome', $('#nome').val()); 11721 data.append('persona_contatto', $('#persona_contatto').val()); 11722 data.append('via', $('#via').val()); 11723 data.append('nap', $('#nap').val()); 11724 data.append('localita', $('#localita').val()); 11725 data.append('paese', $('#paese').val()); 11726 data.append('telefono', $('#telefono').val()); 11727 data.append('email', $('#email').val()); 11728 data.append('istituto_nome', $('#istituto_nome').val()); 11729 data.append('istituto_via', $('#istituto_via').val()); 11730 data.append('istituto_nap', $('#istituto_nap').val()); 11731 data.append('istituto_localita', $('#istituto_localita').val()); 11732 data.append('istituto_paese', $('#istituto_paese').val()); 11733 data.append('iban', $('#iban').val()); 11734 data.append('swift', $('#swift').val()); 11735 data.append('intestatario', $('input[name=intestato]:checked').val()); 11736 11737 if(!intestatario){ 11738 data.append('intestatario_cognome', $('#intestatario_cognome').val()); 11739 data.append('intestatario_nome', $('#intestatario_nome').val()); 11740 data.append('intestatario_via', $('#intestatario_via').val()); 11741 data.append('intestatario_nap', $('#intestatario_nap').val()); 11742 data.append('intestatario_localita', $('#intestatario_localita').val()); 11743 data.append('intestatario_paese', $('#intestatario_paese').val()); 11744 } 11745 11746 for(x in uploadFile){ 11747 data.append(x, document.getElementById(x).files[0]); 11748 } 11749 11750 var button_text = $('button.send-form').text(); 11751 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 11752 $.ajax({ 11753 url: url+'save.php', // point to server-side PHP script 11754 dataType: 'text', // what to expect back from the PHP script, if anything 11755 cache: false, 11756 contentType: false, 11757 processData: false, 11758 data: data, 11759 type: 'post', 11760 success: function(php_script_response){ 11761 if(php_script_response == 'ok'){ 11762 $('form, .intro p').remove(); 11763 $('#giustificativi').next().remove() 11764 $('#giustificativi').remove() 11765 $('.success').removeClass('hidden'); 11766 } 11767 else{ 11768 $('button.send-form').html(button_text).removeClass('disabled'); 11769 loading = false;
11770 11771 if(php_script_response == 'no_file'){ 11772 $('.allegati .error-messages').removeClass('hidden'); 11773 } 11774 else if(php_script_response == 'filesize'){ 11775 $('.allegati .error-messages-size').removeClass('hidden'); 11776 } 11777 } 11778 } 11779 }); 11780 } 11781 else loading = false; 11782 } 11783 } 11784 function changeIntestatario(){ 11785 if($(this).val() == 'si'){ 11786 intestatario = true; 11787 $('.intestatario').addClass('hidden'); 11788 } 11789 else{ 11790 intestatario = false; 11791 $('.intestatario').removeClass('hidden'); 11792 } 11793 } 11794 function checkField(s, type){ 11795 if(typeof type == 'undefined'){ 11796 if($(s).val() == ''){ 11797 $(s).siblings('.error-messages').removeClass('hidden'); 11798 return false; 11799 } 11800 else{ 11801 $(s).siblings('.error-messages').addClass('hidden'); 11802 return true; 11803 } 11804 } 11805 else if(type == 'radio'){ 11806 if($(s+':checked').length == 0){ 11807 $(s+':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 11808 return false; 11809 } 11810 else{ 11811 $(s+':first').parent().parent().siblings('.error-messages').addClass('hidden'); 11812 return true; 11813 } 11814 } 11815 else if(type == 'email'){ 11816 if($(s).val() == '' || !checkEmail($(s).val())){ 11817 $(s).siblings('.error-messages').removeClass('hidden'); 11818 return false; 11819 } 11820 else{ 11821 $(s).siblings('.error-messages').addClass('hidden'); 11822 return true; 11823 } 11824 } 11825 else if(type == 'iban'){ 11826 if($(s).val() == ''){ 11827 $(s).siblings('.error-messages').removeClass('hidden'); 11828 return false; 11829 } 11830 else{ 11831 $(s).siblings('.error-messages').addClass('hidden'); 11832 return true; 11833 } 11834 } 11835 } 11836 function checkEmail(email) { 11837 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,}))$/; 11838 return re.test(String(email).toLowerCase()); 11839 } 11840 function checkCaptchaField(){ 11841 var field = $('input[name=captcha]'); 11842 var error = false; 11843 11844 if(field.val()){ 11845 var r = checkCaptcha(field.val()); 11846 if(r.responseText == 'ok'){ 11847 field.removeClass('error'); 11848 $('.captcha .error-messages').addClass('hidden'); 11849 } 11850 else{ 11851 field.addClass('error').val(''); 11852 $('.refresh-button').trigger('click'); 11853 $('.captcha .error-messages').removeClass('hidden'); 11854 error = true; 11855 } 11856 } 11857 else{ 11858 field.addClass('error'); 11859 $('.refresh-button').trigger('click'); 11860 $('.captcha .error-messages').removeClass('hidden'); 11861 error = true; 11862 } 11863 11864 if(!error) return true; 11865 return false; 11866 } 11867 function checkIBAN(value){ 11868 // Remove spaces and to upper case 11869 var iban = value.replace( / /g, "" ).toUpperCase(), 11870 ibancheckdigits = "", 11871 leadingZeroes = true, 11872 cRest = "", 11873 cOperator = "", 11874 countrycode, ibancheck, charAt, cChar, bbanpattern, bbancountrypatterns, ibanregexp, i, p; 11875 11876 // Check for IBAN code length. 11877 // It contains: 11878 // country code ISO 3166-1 - two letters, 11879 // two check digits, 11880 // Basic Bank Account Number (BBAN) - up to 30 chars 11881 var minimalIBANlength = 5; 11882 if ( iban.length < minimalIBANlength ) { 11883 return false; 11884 } 11885 11886 // Check the country code and find the country specific format 11887 countrycode = iban.substring( 0, 2 ); 11888 bbancountrypatterns = { 11889 "AL": "\\d{8}[\\dA-Z]{16}", 11890 "AD": "\\d{8}[\\dA-Z]{12}", 11891 "AT": "\\d{16}", 11892 "AZ": "[\\dA-Z]{4}\\d{20}", 11893 "BE": "\\d{12}", 11894 "BH": "[A-Z]{4}[\\dA-Z]{14}", 11895 "BA": "\\d{16}", 11896 "BR": "\\d{23}[A-Z][\\dA-Z]", 11897 "BG": "[A-Z]{4}\\d{6}[\\dA-Z]{8}", 11898 "CR": "\\d{17}", 11899 "HR": "\\d{17}", 11900 "CY": "\\d{8}[\\dA-Z]{16}", 11901 "CZ": "\\d{20}", 11902 "DK": "\\d{14}", 11903 "DO": "[A-Z]{4}\\d{20}", 11904 "EE": "\\d{16}", 11905 "FO": "\\d{14}", 11906 "FI": "\\d{14}", 11907 "FR": "\\d{10}[\\dA-Z]{11}\\d{2}", 11908 "GE": "[\\dA-Z]{2}\\d{16}", 11909 "DE": "\\d{18}", 11910 "GI": "[A-Z]{4}[\\dA-Z]{15}", 11911 "GR": "\\d{7}[\\dA-Z]{16}", 11912 "GL": "\\d{14}", 11913 "GT": "[\\dA-Z]{4}[\\dA-Z]{20}", 11914 "HU": "\\d{24}", 11915 "IS": "\\d{22}", 11916 "IE": "[\\dA-Z]{4}\\d{14}", 11917 "IL": "\\d{19}", 11918 "IT": "[A-Z]\\d{10}[\\dA-Z]{12}", 11919 "KZ": "\\d{3}[\\dA-Z]{13}", 11920 "KW": "[A-Z]{4}[\\dA-Z]{22}", 11921 "LV": "[A-Z]{4}[\\dA-Z]{13}", 11922 "LB": "\\d{4}[\\dA-Z]{20}", 11923 "LI": "\\d{5}[\\dA-Z]{12}", 11924 "LT": "\\d{16}", 11925 "LU": "\\d{3}[\\dA-Z]{13}", 11926 "MK": "\\d{3}[\\dA-Z]{10}\\d{2}", 11927 "MT": "[A-Z]{4}\\d{5}[\\dA-Z]{18}", 11928 "MR": "\\d{23}", 11929 "MU": "[A-Z]{4}\\d{19}[A-Z]{3}", 11930 "MC": "\\d{10}[\\dA-Z]{11}\\d{2}", 11931 "MD": "[\\dA-Z]{2}\\d{18}", 11932 "ME": "\\d{18}", 11933 "NL": "[A-Z]{4}\\d{10}", 11934 "NO": "\\d{11}", 11935 "PK": "[\\dA-Z]{4}\\d{16}", 11936 "PS": "[\\dA-Z]{4}\\d{21}", 11937 "PL": "\\d{24}", 11938 "PT": "\\d{21}", 11939 "RO": "[A-Z]{4}[\\dA-Z]{16}", 11940 "SM": "[A-Z]\\d{10}[\\dA-Z]{12}", 11941 "SA": "\\d{2}[\\dA-Z]{18}", 11942 "RS": "\\d{18}", 11943 "SK": "\\d{20}", 11944 "SI": "\\d{15}", 11945 "ES": "\\d{20}", 11946 "SE": "\\d{20}", 11947 "CH": "\\d{5}[\\dA-Z]{12}", 11948 "TN": "\\d{20}", 11949 "TR": "\\d{5}[\\dA-Z]{17}", 11950 "AE": "\\d{3}\\d{16}", 11951 "GB": "[A-Z]{4}\\d{14}", 11952 "VG": "[\\dA-Z]{4}\\d{16}" 11953 }; 11954 11955 bbanpattern = bbancountrypatterns[ countrycode ]; 11956 11957 // As new countries will start using IBAN in the 11958 // future, we only check if the countrycode is known. 11959 // This prevents false negatives, while almost all 11960 // false positives introduced by this, will be caught
11961 // by the checksum validation below anyway. 11962 // Strict checking should return FALSE for unknown 11963 // countries. 11964 if ( typeof bbanpattern !== "undefined" ) { 11965 ibanregexp = new RegExp( "^[A-Z]{2}\\d{2}" + bbanpattern + "$", "" ); 11966 if ( !( ibanregexp.test( iban ) ) ) { 11967 return false; // Invalid country specific format 11968 } 11969 } 11970 11971 // Now check the checksum, first convert to digits 11972 ibancheck = iban.substring( 4, iban.length ) + iban.substring( 0, 4 ); 11973 for ( i = 0; i < ibancheck.length; i++ ) { 11974 charAt = ibancheck.charAt( i ); 11975 if ( charAt !== "0" ) { 11976 leadingZeroes = false; 11977 } 11978 if ( !leadingZeroes ) { 11979 ibancheckdigits += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf( charAt ); 11980 } 11981 } 11982 11983 // Calculate the result of: ibancheckdigits % 97 11984 for ( p = 0; p < ibancheckdigits.length; p++ ) { 11985 cChar = ibancheckdigits.charAt( p ); 11986 cOperator = "" + cRest + "" + cChar; 11987 cRest = cOperator % 97; 11988 } 11989 return cRest === 1; 11990 } 11991 function checkCaptcha(value){ 11992 var rand = Math.floor((Math.random() * 100000) + 1); 11993 return $.ajax({ 11994 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r='+rand, 11995 data: { 11996 value: value 11997 }, 11998 async: false, 11999 method: 'post' 12000 }); 12001 } 12002 function initMultiUpload(){ 12003 var attachments_n = 1; 12004 var max_weight = 5; 12005 var working = false; 12006 var uploadButtonContent = ''; 12007 function init(){ 12008 uploadButtonContent = $('#formulario_rimborso_polizia .allegati .add').html(); 12009 12010 $('#formulario_rimborso_polizia').on('click', '.allegati .add', addAttachemnt); 12011 $('#formulario_rimborso_polizia').on('click', '.allegati .remove', clearAttachemnt); 12012 12013 $('#formulario_rimborso_polizia').on('change', '.inputfile', change); 12014 } 12015 function addAttachemnt(e){ 12016 e.preventDefault(); 12017 12018 if(!working){ 12019 $(this).siblings('.allegato.hidden.new').remove(); 12020 12021 if($('#attachments-error').length) $('#attachments-error').remove(); 12022 12023 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 12024 $('#formulario_rimborso_polizia .allegato.new label').attr('for', 'file'+attachments_n); 12025 $('#formulario_rimborso_polizia .allegato.new input').attr('id', 'file'+attachments_n).attr('name', 'file'+attachments_n); 12026 12027 $('#formulario_rimborso_polizia .allegato.new input:last').trigger('click'); 12028 12029 attachments_n++; 12030 } 12031 } 12032 function clearAttachemnt(e){ 12033 e.preventDefault(); 12034 12035 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 12036 uploadFile[id] = false; 12037 12038 var p = $(this).parents('.allegato'); 12039 12040 p.find('input[type=file]').val(''); 12041 p.find('input[type=file]').next().children('span').text('Allega un file'); 12042 p.remove(); 12043 12044 attachments_n--; 12045 } 12046 function change(event){ 12047 var id = $(this).attr('id'); 12048 12049 tmp = $(this).val().split("\\"); 12050 var v = tmp[tmp.length - 1]; 12051 12052 if(v){ 12053 tmp2 = v.split('.'); 12054 var ext = tmp2[(tmp2.length - 1)]; 12055 12056 12057 $('.allegati .error-messages, .allegati .error-messages-type, .allegati .error-messages-size').addClass('hidden'); 12058 12059 if(ext == 'exe' || ext == 'bat' || ext == 'com'){ 12060 // Type error 12061 $('.allegati .error-messages-type').removeClass('hidden'); 12062 $('.allegato.new.hidden .remove').trigger('click'); 12063 } 12064 else{ 12065 if(Math.round(event.target.files[0].size / 1048576) > max_weight){ 12066 // Size error 12067 $('.allegati .error-messages-size').removeClass('hidden'); 12068 $('.allegato.new.hidden .remove').trigger('click'); 12069 } 12070 else{ 12071 $('label[for='+id+'] span').text(v); 12072 12073 if($('#attachments-error').length) $('#attachments-error').remove(); 12074 12075 uploadFile[id] = event.target.files; 12076 12077 $('.allegato.new.hidden').removeClass('new hidden'); 12078 $('#formulario_rimborso_polizia .allegati .add').html(uploadButtonContent); 12079 } 12080 } 12081 } 12082 } 12083 init(); 12084 } 12085 init(); 12086} 12087function initFormularioSEL2(){ 12088 var uploadFile = {}; 12089 var url = '/fileadmin/DI/SEL/formulario_sel/'; 12090 var loading = false;
12091 var scelte = false 12092 function init(){ 12093 // var f = $('#formulario_di_simposio').clone() 12094 // $('#formulario_di_simposio').remove() 12095 // $('main .container:eq(2)').append(f) 12096 12097 $.get(url+'check.php', function (r){ 12098 if(r != 'ok'){ 12099 $('#iscrizione1').parents('.radio').css('opacity', 0.5) 12100 $('#iscrizione1').prop('disabled', true) 12101 $('#iscrizione1').parent().css('cursor', 'default') 12102 } 12103 }) 12104 12105 $('.iscriviti').click(startForm) 12106 $('input[name=iscrizione]').click(checkIscrizione) 12107 $('.send-form').click(send); 12108 12109 $('#ente').change(enteEvent) 12110 12111 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function (){ 12112 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 12113 }); 12114 } 12115 function enteEvent(){ 12116 var v = $(this).val() 12117 $('#ruolo option:first').prop('selected', true) 12118 $('#ruolo').trigger('change') 12119 12120 if(!v){ 12121 $('.ruolo').addClass('hidden') 12122 } 12123 else{ 12124 $('.ruolo').removeClass('hidden') 12125 // if(v == 'cantone'){ 12126 $('#ruolo option').each(function (n){ 12127 if(n == 0){ 12128 $(this).show() 12129 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12130 } 12131 else if(v == 'cantone' && ($(this).val() == 1 || $(this).val() == 9)){ 12132 $(this).show() 12133 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12134 } 12135 else if(v == 'comune' && ($(this).val() >= 2 && $(this).val() <= 8)){ 12136 $(this).show() 12137 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12138 } 12139 else if(v == 'aziende' && ($(this).val() >= 10 && $(this).val() <= 14)){ 12140 $(this).show() 12141 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12142 } 12143 else if(v == 'altro' && $(this).val() == 15){ 12144 $(this).show() 12145 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12146 } 12147 else { 12148 $(this).hide() 12149 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').hide() 12150 } 12151 }) 12152 12153 12154 // } 12155 } 12156 } 12157 function startForm(e){ 12158 e.preventDefault() 12159 $('#formulario_di_simposio').removeClass('hidden') 12160 $('html, body').animate({scrollTop: $('#formulario_di_simposio').offset().top - 50}, 500) 12161 12162 $('.btn.iscriviti').remove() 12163 } 12164 function checkIscrizione(){ 12165 if($(this).val() == 'partecipare'){ 12166 $('.parte').removeClass('hidden') 12167 scelte = true 12168 } 12169 else{ 12170 $('.parte').addClass('hidden') 12171 scelte = false 12172 } 12173 } 12174 function send(e){ 12175 e.preventDefault(); 12176 12177 if(!loading){ 12178 loading = true; 12179 12180 var error = false; 12181 12182 if(!checkField('#nome')) error = true; 12183 if(!checkField('#cognome')) error = true; 12184 if(!checkField('#indirizzo')) error = true; 12185 if(!checkField('#npa')) error = true; 12186 if(!checkField('#luogo')) error = true; 12187 if(!checkField('#telefono')) error = true; 12188 if(!checkField('#email', 'email')) error = true; 12189 12190 if(!checkField('#ente')) error = true; 12191 if(!checkField('#ruolo')) error = true; 12192 // if(!checkField('input[name=ente]', 'radio')) error = true; 12193 // if(!checkField('input[name=ruolo]', 'radio')) error = true; 12194 if(!checkField('input[name=iscrizione]', 'radio')) error = true; 12195 // if($('#iscrizione1').is(':checked')) if(!checkField('input[name=date]', 'radio')) error = true; 12196 12197 // // Iscrizioni 12198 // if(scelte){ 12199 // if(!checkField('#scelta1')) error = true; 12200 // if(!checkField('#scelta2')) error = true; 12201 // } 12202 12203 if(!error){ 12204 // Captcha 12205 if(!checkCaptchaField()) error = true; 12206 } 12207 12208 12209 if(!error){ 12210 var data = new FormData() 12211 12212 data.append('nome', $('#nome').val()); 12213 data.append('cognome', $('#cognome').val()); 12214 data.append('indirizzo', $('#indirizzo').val()); 12215 data.append('npa', $('#npa').val()); 12216 data.append('luogo', $('#luogo').val()); 12217 data.append('telefono', $('#telefono').val()); 12218 data.append('email', $('#email').val()); 12219 data.append('ente', $('#ente').val()); 12220 data.append('ruolo', $('#ruolo').val()); 12221 data.append('iscrizione', $('input[name=iscrizione]:checked').val()); 12222 // if(scelte) data.append('date', $('input[name=date]:checked').val()); 12223 12224 12225 var button_text = $('button.send-form').text(); 12226 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 12227 $.ajax({ 12228 url: url+'save.php', // point to server-side PHP script 12229 dataType: 'text', // what to expect back from the PHP script, if anything 12230 cache: false, 12231 contentType: false, 12232 processData: false, 12233 data: data, 12234 type: 'post', 12235 success: function(php_script_response){ 12236 if(php_script_response == 'ok'){ 12237 var top = $('#formulario_di_simposio').offset().top - 200 12238 $('form').remove(); 12239 $('.success').css('padding', '0 10px 60px 10px').removeClass('hidden'); 12240 // $('#subscription_intro').remove() 12241 $('#subscription_intro').css('padding-top', '50px').html('') 12242 $('html, body').animate({scrollTop: top}, 500) 12243 $('.btn.iscriviti').remove() 12244 } 12245 else{ 12246 $('button.send-form').html(button_text).removeClass('disabled'); 12247 loading = false;
12248 } 12249 } 12250 }); 12251 } 12252 else{ 12253 loading = false; 12254 $('html, body').animate({scrollTop: $('.error-messages:first').offset().top - 70}, 500) 12255 } 12256 } 12257 } 12258 function checkField(s, type){ 12259 if(typeof type == 'undefined'){ 12260 if($(s).val() == ''){ 12261 $(s).siblings('.error-messages').removeClass('hidden'); 12262 return false; 12263 } 12264 else{ 12265 $(s).siblings('.error-messages').addClass('hidden'); 12266 return true; 12267 } 12268 } 12269 else if(type == 'radio' || type == 'checkbox'){ 12270 if($(s+':checked').length == 0){ 12271 $(s+':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 12272 return false; 12273 } 12274 else{ 12275 $(s+':first').parent().parent().siblings('.error-messages').addClass('hidden'); 12276 return true; 12277 } 12278 } 12279 else if(type == 'email'){ 12280 if($(s).val() == '' || !checkEmail($(s).val())){ 12281 12282 if($(s).val() == '') $(s).siblings('.error-messages').text('Compila il campo') 12283 else $(s).siblings('.error-messages').text('Email non valida') 12284 12285 $(s).siblings('.error-messages').removeClass('hidden'); 12286 return false; 12287 } 12288 else{ 12289 $(s).siblings('.error-messages').addClass('hidden'); 12290 return true; 12291 } 12292 } 12293 else if(type == 'date'){ 12294 if($(s).val() == '' || !checkDate($(s).val())){ 12295 $(s).siblings('.error-messages').removeClass('hidden'); 12296 return false; 12297 } 12298 else{ 12299 $(s).siblings('.error-messages').addClass('hidden'); 12300 return true; 12301 } 12302 } 12303 } 12304 function checkEmail(email) { 12305 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,}))$/; 12306 return re.test(String(email).toLowerCase()); 12307 } 12308 function checkDate(value){ 12309 if(new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 12310 else return false; 12311 } 12312 function checkCaptchaField(){ 12313 var field = $('input[name=captcha]'); 12314 var error = false; 12315 12316 if(field.val()){ 12317 var r = checkCaptcha(field.val()); 12318 if(r.responseText == 'ok'){ 12319 field.removeClass('error'); 12320 $('.captcha .error-messages').addClass('hidden'); 12321 } 12322 else{ 12323 field.addClass('error').val(''); 12324 $('.refresh-button').trigger('click'); 12325 $('.captcha .error-messages').removeClass('hidden'); 12326 error = true; 12327 } 12328 } 12329 else{ 12330 field.addClass('error'); 12331 $('.refresh-button').trigger('click'); 12332 $('.captcha .error-messages').removeClass('hidden'); 12333 error = true; 12334 } 12335 12336 if(!error) return true; 12337 return false; 12338 } 12339 function checkCaptcha(value){ 12340 var rand = Math.floor((Math.random() * 100000) + 1); 12341 return $.ajax({ 12342 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r='+rand, 12343 data: { 12344 value: value 12345 }, 12346 async: false, 12347 method: 'post' 12348 }); 12349 } 12350 init(); 12351} 12352 12353function initFormularioSELDFE(){ 12354 var uploadFile = {}; 12355 var url = '/fileadmin/DI/SEL/formulario_sel_dfe/'; 12356 var loading = false; 12357 var scelte = false 12358 function init(){ 12359 // var f = $('#formulario_di_simposio').clone() 12360 // $('#formulario_di_simposio').remove() 12361 // $('main .container:eq(2)').append(f) 12362 12363 $.get(url+'check.php', function (r){ 12364 if(r != 'ok'){ 12365 $('#iscrizione1').parents('.radio').css('opacity', 0.5) 12366 $('#iscrizione1').prop('disabled', true) 12367 $('#iscrizione1').parent().css('cursor', 'default') 12368 } 12369 }) 12370 12371 $('.iscriviti').click(startForm) 12372 $('input[name=iscrizione]').click(checkIscrizione) 12373 $('.send-form').click(send); 12374 12375 $('#ente').change(enteEvent) 12376 12377 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function (){ 12378 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 12379 }); 12380 } 12381 function enteEvent(){ 12382 var v = $(this).val() 12383 $('#ruolo option:first').prop('selected', true) 12384 $('#ruolo').trigger('change') 12385 12386 if(!v){ 12387 $('.ruolo').addClass('hidden') 12388 } 12389 else{ 12390 $('.ruolo').removeClass('hidden') 12391 // if(v == 'cantone'){ 12392 $('#ruolo option').each(function (n){ 12393 if(n == 0){ 12394 $(this).show() 12395 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12396 } 12397 else if(v == 'cantone' && ($(this).val() == 1 || $(this).val() == 9)){ 12398 $(this).show() 12399 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12400 } 12401 else if(v == 'comune' && ($(this).val() >= 2 && $(this).val() <= 8)){ 12402 $(this).show() 12403 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12404 } 12405 else if(v == 'aziende' && ($(this).val() >= 10 && $(this).val() <= 14)){ 12406 $(this).show() 12407 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12408 } 12409 else if(v == 'altro' && $(this).val() == 15){ 12410 $(this).show() 12411 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').show() 12412 } 12413 else { 12414 $(this).hide() 12415 $('#ruolo').next().find('.dropdown-menu.selectpicker li[rel='+n+']').hide() 12416 } 12417 }) 12418 12419 12420 // } 12421 } 12422 } 12423 function startForm(e){ 12424 e.preventDefault() 12425 $('#formulario_di_simposio_dfe').removeClass('hidden') 12426 $('html, body').animate({scrollTop: $('#formulario_di_simposio_dfe').offset().top - 50}, 500) 12427 12428 $('.btn.iscriviti').remove() 12429 } 12430 function checkIscrizione(){ 12431 if($(this).val() == 'partecipare'){ 12432 $('.parte').removeClass('hidden') 12433 scelte = true 12434 } 12435 else{ 12436 $('.parte').addClass('hidden') 12437 scelte = false 12438 } 12439 } 12440 function send(e){ 12441 e.preventDefault(); 12442 12443 if(!loading){ 12444 loading = true; 12445 12446 var error = false;
12447 12448 if(!checkField('#nome')) error = true; 12449 if(!checkField('#cognome')) error = true; 12450 //if(!checkField('#indirizzo')) error = true; 12451 //if(!checkField('#npa')) error = true; 12452 //if(!checkField('#luogo')) error = true; 12453 if(!checkField('#telefono')) error = true; 12454 if(!checkField('#email', 'email')) error = true; 12455 12456 if(!checkField('#ente')) error = true; 12457 if(!checkField('#ruolo')) error = true; 12458 // if(!checkField('input[name=ente]', 'radio')) error = true; 12459 // if(!checkField('input[name=ruolo]', 'radio')) error = true; 12460 if(!checkField('input[name=iscrizione]', 'radio')) error = true; 12461 // if($('#iscrizione1').is(':checked')) if(!checkField('input[name=date]', 'radio')) error = true; 12462 12463 // // Iscrizioni 12464 // if(scelte){ 12465 // if(!checkField('#scelta1')) error = true; 12466 // if(!checkField('#scelta2')) error = true; 12467 // } 12468 12469 if(!error){ 12470 // Captcha 12471 if(!checkCaptchaField()) error = true; 12472 } 12473 12474 12475 if(!error){ 12476 var data = new FormData() 12477 12478 data.append('nome', $('#nome').val()); 12479 data.append('cognome', $('#cognome').val()); 12480 //data.append('indirizzo', $('#indirizzo').val()); 12481 //data.append('npa', $('#npa').val()); 12482 //data.append('luogo', $('#luogo').val()); 12483 data.append('telefono', $('#telefono').val()); 12484 data.append('email', $('#email').val()); 12485 data.append('ente', $('#ente').val()); 12486 data.append('ruolo', $('#ruolo').val()); 12487 data.append('iscrizione', $('input[name=iscrizione]:checked').val()); 12488 if(scelte) data.append('date', $('input[name=date]:checked').val()); 12489 12490 12491 var button_text = $('button.send-form').text(); 12492 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 12493 $.ajax({ 12494 url: url+'save.php', // point to server-side PHP script 12495 dataType: 'text', // what to expect back from the PHP script, if anything 12496 cache: false, 12497 contentType: false, 12498 processData: false, 12499 data: data, 12500 type: 'post', 12501 success: function(php_script_response){ 12502 if(php_script_response == 'ok'){ 12503 var top = $('#formulario_di_simposio_dfe').offset().top - 200 12504 $('form').remove(); 12505 $('.success').css('padding', '0 10px 60px 10px').removeClass('hidden'); 12506 // $('#subscription_intro').remove() 12507 $('#subscription_intro').css('padding-top', '50px').html('') 12508 $('html, body').animate({scrollTop: top}, 500) 12509 $('.btn.iscriviti').remove() 12510 } 12511 else{ 12512 $('button.send-form').html(button_text).removeClass('disabled'); 12513 loading = false; 12514 } 12515 } 12516 }); 12517 } 12518 else{ 12519 loading = false; 12520 $('html, body').animate({scrollTop: $('.error-messages:first').offset().top - 70}, 500) 12521 } 12522 } 12523 } 12524 function checkField(s, type){ 12525 if(typeof type == 'undefined'){ 12526 if($(s).val() == ''){ 12527 $(s).siblings('.error-messages').removeClass('hidden'); 12528 return false; 12529 } 12530 else{ 12531 $(s).siblings('.error-messages').addClass('hidden'); 12532 return true; 12533 } 12534 } 12535 else if(type == 'radio' || type == 'checkbox'){ 12536 if($(s+':checked').length == 0){ 12537 $(s+':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 12538 return false;
12539 } 12540 else{ 12541 $(s+':first').parent().parent().siblings('.error-messages').addClass('hidden'); 12542 return true; 12543 } 12544 } 12545 else if(type == 'email'){ 12546 if($(s).val() == '' || !checkEmail($(s).val())){ 12547 12548 if($(s).val() == '') $(s).siblings('.error-messages').text('Compila il campo') 12549 else $(s).siblings('.error-messages').text('Email non valida') 12550 12551 $(s).siblings('.error-messages').removeClass('hidden'); 12552 return false; 12553 } 12554 else{ 12555 $(s).siblings('.error-messages').addClass('hidden'); 12556 return true; 12557 } 12558 } 12559 else if(type == 'date'){ 12560 if($(s).val() == '' || !checkDate($(s).val())){ 12561 $(s).siblings('.error-messages').removeClass('hidden'); 12562 return false; 12563 } 12564 else{ 12565 $(s).siblings('.error-messages').addClass('hidden'); 12566 return true; 12567 } 12568 } 12569 } 12570 function checkEmail(email) { 12571 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,}))$/; 12572 return re.test(String(email).toLowerCase()); 12573 } 12574 function checkDate(value){ 12575 if(new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 12576 else return false; 12577 } 12578 function checkCaptchaField(){ 12579 var field = $('input[name=captcha]'); 12580 var error = false; 12581 12582 if(field.val()){ 12583 var r = checkCaptcha(field.val()); 12584 if(r.responseText == 'ok'){ 12585 field.removeClass('error'); 12586 $('.captcha .error-messages').addClass('hidden'); 12587 } 12588 else{ 12589 field.addClass('error').val(''); 12590 $('.refresh-button').trigger('click'); 12591 $('.captcha .error-messages').removeClass('hidden'); 12592 error = true; 12593 } 12594 } 12595 else{ 12596 field.addClass('error'); 12597 $('.refresh-button').trigger('click'); 12598 $('.captcha .error-messages').removeClass('hidden'); 12599 error = true; 12600 } 12601 12602 if(!error) return true; 12603 return false; 12604 } 12605 function checkCaptcha(value){ 12606 var rand = Math.floor((Math.random() * 100000) + 1); 12607 return $.ajax({ 12608 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r='+rand, 12609 data: { 12610 value: value 12611 }, 12612 async: false, 12613 method: 'post' 12614 }); 12615 } 12616 init(); 12617} 12618 12619function initFormularioSEL(){ 12620 var uploadFile = {}; 12621 var url = '/fileadmin/DI/SEL/formulario_sel/'; 12622 var loading = false; 12623 var scelte = false 12624 function init(){ 12625 var f = $('#formulario_sel').clone() 12626 $('#formulario_sel').remove() 12627 $('main .container:eq(2)').append(f) 12628 12629 $('.iscrizione').click(startForm) 12630 $('input[name=iscrizione]').change(checkIscrizione) 12631 $('.send-form').click(send); 12632 12633 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function (){ 12634 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 12635 }); 12636 } 12637 function startForm(e){ 12638 e.preventDefault() 12639 $('#formulario_sel').removeClass('hidden') 12640 $('html, body').animate({scrollTop: $('#formulario_sel').offset().top - 50}, 500) 12641 } 12642 function checkIscrizione(){ 12643 if($(this).val() == 1 || $(this).val() == 3){ 12644 $('.scelte').removeClass('hidden') 12645 scelte = true 12646 } 12647 else{ 12648 $('.scelte').addClass('hidden') 12649 scelte = false 12650 } 12651 } 12652 function send(e){ 12653 e.preventDefault(); 12654 12655 if(!loading){ 12656 loading = true; 12657 12658 var error = false; 12659 12660 if(!checkField('#nome')) error = true; 12661 if(!checkField('#cognome')) error = true; 12662 if(!checkField('#indirizzo')) error = true; 12663 if(!checkField('#nap')) error = true; 12664 if(!checkField('#luogo')) error = true; 12665 if(!checkField('#telefono')) error = true; 12666 if(!checkField('#email', 'email')) error = true; 12667 if(!checkField('input[name=ente]', 'radio')) error = true; 12668 if(!checkField('input[name=ruolo]', 'radio')) error = true; 12669 if(!checkField('input[name=iscrizione]', 'radio')) error = true; 12670 12671 // Iscrizioni 12672 if(scelte){ 12673 if(!checkField('#scelta1')) error = true; 12674 if(!checkField('#scelta2')) error = true; 12675 } 12676 12677 if(!error){ 12678 // Captcha 12679 if(!checkCaptchaField()) error = true; 12680 } 12681 12682 12683 if(!error){ 12684 var data = new FormData() 12685 12686 data.append('nome', $('#nome').val()); 12687 data.append('cognome', $('#cognome').val()); 12688 data.append('indirizzo', $('#indirizzo').val()); 12689 data.append('nap', $('#nap').val()); 12690 data.append('luogo', $('#luogo').val()); 12691 data.append('telefono', $('#telefono').val()); 12692 data.append('email', $('#email').val()); 12693 data.append('ente', $('input[name=ente]:checked').val()); 12694 data.append('ruolo', $('input[name=ruolo]:checked').val()); 12695 data.append('iscrizione', $('input[name=iscrizione]:checked').val()); 12696 12697 // Iscrizioni 12698 if(scelte){ 12699 data.append('scelta1', $('#scelta1').val()); 12700 data.append('scelta2', $('#scelta2').val()); 12701 } 12702 12703 12704 var button_text = $('button.send-form').text(); 12705 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 12706 $.ajax({ 12707 url: url+'save.php', // point to server-side PHP script 12708 dataType: 'text', // what to expect back from the PHP script, if anything 12709 cache: false, 12710 contentType: false, 12711 processData: false, 12712 data: data, 12713 type: 'post', 12714 success: function(php_script_response){ 12715 if(php_script_response == 'ok'){ 12716 $('form').remove(); 12717 $('.success').removeClass('hidden'); 12718 $('html, body').animate({scrollTop: $('#formulario_sel').offset().top}, 500) 12719 } 12720 else{ 12721 $('button.send-form').html(button_text).removeClass('disabled'); 12722 loading = false;
12723 } 12724 } 12725 }); 12726 } 12727 else{ 12728 loading = false; 12729 $('html, body').animate({scrollTop: $('.error-messages:first').offset().top - 70}, 500) 12730 } 12731 } 12732 } 12733 function checkField(s, type){ 12734 if(typeof type == 'undefined'){ 12735 if($(s).val() == ''){ 12736 $(s).siblings('.error-messages').removeClass('hidden'); 12737 return false; 12738 } 12739 else{ 12740 $(s).siblings('.error-messages').addClass('hidden'); 12741 return true; 12742 } 12743 } 12744 else if(type == 'radio' || type == 'checkbox'){ 12745 if($(s+':checked').length == 0){ 12746 $(s+':first').parent().siblings('.error-messages').removeClass('hidden'); 12747 return false; 12748 } 12749 else{ 12750 $(s+':first').parent().siblings('.error-messages').addClass('hidden'); 12751 return true; 12752 } 12753 } 12754 else if(type == 'email'){ 12755 if($(s).val() == '' || !checkEmail($(s).val())){ 12756 $(s).siblings('.error-messages').removeClass('hidden'); 12757 return false; 12758 } 12759 else{ 12760 $(s).siblings('.error-messages').addClass('hidden'); 12761 return true; 12762 } 12763 } 12764 else if(type == 'date'){ 12765 if($(s).val() == '' || !checkDate($(s).val())){ 12766 $(s).siblings('.error-messages').removeClass('hidden'); 12767 return false; 12768 } 12769 else{ 12770 $(s).siblings('.error-messages').addClass('hidden'); 12771 return true; 12772 } 12773 } 12774 } 12775 function checkEmail(email) { 12776 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,}))$/; 12777 return re.test(String(email).toLowerCase()); 12778 } 12779 function checkDate(value){ 12780 if(new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 12781 else return false; 12782 } 12783 function checkCaptchaField(){ 12784 var field = $('input[name=captcha]'); 12785 var error = false; 12786 12787 if(field.val()){ 12788 var r = checkCaptcha(field.val()); 12789 if(r.responseText == 'ok'){ 12790 field.removeClass('error'); 12791 $('.captcha .error-messages').addClass('hidden'); 12792 } 12793 else{ 12794 field.addClass('error').val(''); 12795 $('.refresh-button').trigger('click'); 12796 $('.captcha .error-messages').removeClass('hidden'); 12797 error = true; 12798 } 12799 } 12800 else{ 12801 field.addClass('error'); 12802 $('.refresh-button').trigger('click'); 12803 $('.captcha .error-messages').removeClass('hidden'); 12804 error = true; 12805 } 12806 12807 if(!error) return true; 12808 return false; 12809 } 12810 function checkCaptcha(value){ 12811 var rand = Math.floor((Math.random() * 100000) + 1); 12812 return $.ajax({ 12813 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r='+rand, 12814 data: { 12815 value: value 12816 }, 12817 async: false, 12818 method: 'post' 12819 }); 12820 } 12821 init(); 12822} 12823function initFormularioTLET(){ 12824 var uploadFile = {}; 12825 var url = '/fileadmin/DFE/DE/formulario_tlet/'; 12826 var loading = false; 12827 var prestazioniUpload = false; 12828 var pranzo = false 12829 function init(){ 12830 $('.modulo_tlet').click(startForm) 12831 $('input[name=pranzo]').click(checkPranzo) 12832 $('.send-form').click(send); 12833 12834 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function (){ 12835 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 12836 }); 12837 12838 // $.getScript('https://raw.githack.com/SortableJS/Sortable/master/Sortable.js', function (){ 12839 // $.getScript('https://cdn.jsdelivr.net/npm/jquery-sortablejs@latest/jquery-sortable.js', function (){ 12840 // $('.order').sortable() 12841 // }); 12842 // }); 12843 } 12844 function startForm(e){ 12845 e.preventDefault() 12846 $('.boxFisso').removeClass('hidden') 12847 location.hash = 'formulario_tlet' 12848 $('#nome').trigger('focus') 12849 } 12850 function checkPranzo(){ 12851 pranzo = ($('#pranzo1').is(':checked')) ? true : false 12852 if(pranzo) $('.menu').removeClass('hidden') 12853 else $('.menu').addClass('hidden') 12854 } 12855 function send(e){ 12856 e.preventDefault(); 12857 12858 if(!loading){ 12859 loading = true; 12860 12861 var error = false;
12862 12863 if(!checkField('#nome')) error = true; 12864 if(!checkField('#cognome')) error = true; 12865 // if(!checkField('#azienda')) error = true; 12866 // if(!checkField('#indirizzo')) error = true; 12867 if(!checkField('#email', 'email')) error = true; 12868 // if(!checkField('#telefono')) error = true; 12869 if(!checkField('input[name=partecipo]', 'radio')) error = true; 12870 if(!checkField('input[name=pranzo]', 'radio')) error = true; 12871 12872 if(pranzo){ 12873 if(!checkField('input[name=menu]', 'radio')) error = true; 12874 } 12875 12876 if(!error){ 12877 // Captcha 12878 if(!checkCaptchaField()) error = true; 12879 } 12880 12881 12882 if(!error){ 12883 var data = new FormData() 12884 12885 data.append('nome', $('#nome').val()); 12886 data.append('cognome', $('#cognome').val()); 12887 data.append('azienda', $('#azienda').val()); 12888 data.append('indirizzo', $('#indirizzo').val()); 12889 data.append('email', $('#email').val()); 12890 data.append('telefono', $('#telefono').val()); 12891 data.append('partecipo', $('input[name=partecipo]:checked').val()); 12892 data.append('pranzo', $('input[name=pranzo]:checked').val()); 12893 12894 if(pranzo) data.append('menu', $('input[name=menu]:checked').val()); 12895 // else data.append('menu', 0); 12896 12897 // Cibo 12898 /* var cibo = 0 12899 if($('input[name=cibo]:checked').length){ 12900 var n = [] 12901 $('input[name=cibo]:checked').each(function (){ 12902 n.push($(this).val()) 12903 }) 12904 cibo = n.join(',') 12905 } 12906 data.append('cibo', cibo);*/ 12907 12908 // Ordine 12909 var n = [] 12910 $('.order li').each(function (){ 12911 n.push($(this).data('n')+':'+$(this).children('select').val()) 12912 }) 12913 data.append('ordine', n.join(',')); 12914 12915 // Navetta 12916 var n = [] 12917 $('input[name=navetta]:checked').each(function (){ 12918 n.push($(this).val()) 12919 }) 12920 data.append('navetta', n.join(',')); 12921 12922 12923 var button_text = $('button.send-form').text(); 12924 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 12925 $.ajax({ 12926 url: url+'save.php', // point to server-side PHP script 12927 dataType: 'text', // what to expect back from the PHP script, if anything 12928 cache: false, 12929 contentType: false, 12930 processData: false, 12931 data: data, 12932 type: 'post', 12933 success: function(php_script_response){ 12934 if(php_script_response == 'ok'){ 12935 $('form').remove(); 12936 $('.success').removeClass('hidden'); 12937 } 12938 else{ 12939 $('button.send-form').html(button_text).removeClass('disabled'); 12940 loading = false; 12941 } 12942 } 12943 }); 12944 } 12945 else loading = false; 12946 } 12947 } 12948 function checkField(s, type){ 12949 if(typeof type == 'undefined'){ 12950 if($(s).val() == ''){ 12951 $(s).siblings('.error-messages').removeClass('hidden'); 12952 return false; 12953 } 12954 else{ 12955 $(s).siblings('.error-messages').addClass('hidden'); 12956 return true; 12957 } 12958 } 12959 else if(type == 'radio' || type == 'checkbox'){ 12960 if($(s+':checked').length == 0){ 12961 $(s+':first').parent().siblings('.error-messages').removeClass('hidden'); 12962 return false; 12963 } 12964 else{ 12965 $(s+':first').parent().siblings('.error-messages').addClass('hidden'); 12966 return true; 12967 } 12968 } 12969 else if(type == 'email'){ 12970 if($(s).val() == '' || !checkEmail($(s).val())){ 12971 $(s).siblings('.error-messages').removeClass('hidden'); 12972 return false;
12973 } 12974 else{ 12975 $(s).siblings('.error-messages').addClass('hidden'); 12976 return true; 12977 } 12978 } 12979 else if(type == 'date'){ 12980 if($(s).val() == '' || !checkDate($(s).val())){ 12981 $(s).siblings('.error-messages').removeClass('hidden'); 12982 return false; 12983 } 12984 else{ 12985 $(s).siblings('.error-messages').addClass('hidden'); 12986 return true; 12987 } 12988 } 12989 } 12990 function checkEmail(email) { 12991 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,}))$/; 12992 return re.test(String(email).toLowerCase()); 12993 } 12994 function checkDate(value){ 12995 if(new RegExp("[0-9]{2}\.[0-9]{2}\.[0-9]{4}").test(value)) return true; 12996 else return false; 12997 } 12998 function checkCaptchaField(){ 12999 var field = $('input[name=captcha]'); 13000 var error = false; 13001 13002 if(field.val()){ 13003 var r = checkCaptcha(field.val()); 13004 if(r.responseText == 'ok'){ 13005 field.removeClass('error'); 13006 $('.captcha .error-messages').addClass('hidden'); 13007 } 13008 else{ 13009 field.addClass('error').val(''); 13010 $('.refresh-button').trigger('click'); 13011 $('.captcha .error-messages').removeClass('hidden'); 13012 error = true; 13013 } 13014 } 13015 else{ 13016 field.addClass('error'); 13017 $('.refresh-button').trigger('click'); 13018 $('.captcha .error-messages').removeClass('hidden'); 13019 error = true; 13020 } 13021 13022 if(!error) return true; 13023 return false; 13024 } 13025 function checkCaptcha(value){ 13026 var rand = Math.floor((Math.random() * 100000) + 1); 13027 return $.ajax({ 13028 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r='+rand, 13029 data: { 13030 value: value 13031 }, 13032 async: false, 13033 method: 'post' 13034 }); 13035 } 13036 init(); 13037} 13038function initFormularioUOSPWorkshop(){ 13039 var url = '/fileadmin/DECS/DS/UOSP/formulario_workshop/'; 13040 var iscritti_max = 30; 13041 var workshop1_options = {}; 13042 var workshop2_options = {}; 13043 function init(){ 13044 $.getJSON(url+'iscrizioni.json?_='+Math.round(Math.random()*1000000000), function (data){ 13045 if(data.state == 3){ 13046 $('.closed').removeClass('hidden'); 13047 } 13048 else{ 13049 if(data.state != 1){ 13050 var n = 1; 13051 for(x in data[1]){ 13052 if(data[1][x] < iscritti_max){ 13053 $('select[name=workshop1]').append('<option value="'+n+'">'+x+'</option>'); 13054 workshop1_options[n] = x; 13055 } 13056 n++; 13057 } 13058 $('.workshop1').removeClass('disabled'); 13059 $('select[name=workshop1]').selectpicker('refresh'); 13060 13061 $('select[name=workshop1]').change(changeSelect1); 13062 } 13063 13064 if(data.state != 2){ 13065 var n = 1; 13066 for(x in data[2]){ 13067 if(data[2][x] < iscritti_max){ 13068 $('select[name=workshop2]').append('<option value="'+n+'">'+x+'</option>'); 13069 workshop2_options[n] = x; 13070 } 13071 n++; 13072 } 13073 $('.workshop2').removeClass('disabled'); 13074 $('select[name=workshop2]').selectpicker('refresh'); 13075 13076 $('select[name=workshop2]').change(changeSelect2); 13077 } 13078 13079 $('form').show(); 13080 } 13081 }) 13082 $('#formulario_uosp_workshop button').click(send); 13083 } 13084 function changeSelect1(){ 13085 $('select[name=workshop2] option').show(); 13086 13087 if($(this).val()){ 13088 $('select[name=workshop2] option[value='+$(this).val()+']').hide(); 13089 $('.workshop2').removeClass('disabled'); 13090 } 13091 // else $('.workshop2').addClass('disabled'); 13092 13093 $('select[name=workshop2]').selectpicker('refresh'); 13094 } 13095 function changeSelect2(){ 13096 $('select[name=workshop1] option').show(); 13097 13098 if($(this).val()){ 13099 $('select[name=workshop1] option[value='+$(this).val()+']').hide(); 13100 // $('.workshop2').removeClass('disabled'); 13101 } 13102 13103 $('select[name=workshop1]').selectpicker('refresh'); 13104 } 13105 13106 function send(e){ 13107 e.preventDefault(); 13108 13109 var error = false;
13110 13111 if($('#nome').val() == ''){ 13112 $('#nome').siblings('.error-messages').removeClass('hidden'); 13113 error = true; 13114 } 13115 else $('#nome').siblings('.error-messages').addClass('hidden'); 13116 13117 if($('#cognome').val() == ''){ 13118 $('#cognome').siblings('.error-messages').removeClass('hidden'); 13119 error = true; 13120 } 13121 else $('#cognome').siblings('.error-messages').addClass('hidden'); 13122 13123 if($('#email').val() == ''){ 13124 $('#email').siblings('.error-messages').removeClass('hidden'); 13125 error = true; 13126 } 13127 else $('#email').siblings('.error-messages').addClass('hidden'); 13128 13129 if($('#telefono').val() == ''){ 13130 $('#telefono').siblings('.error-messages').removeClass('hidden'); 13131 error = true; 13132 } 13133 else $('#telefono').siblings('.error-messages').addClass('hidden'); 13134 13135 if($('#istituzione').val() == ''){ 13136 $('#istituzione').siblings('.error-messages').removeClass('hidden'); 13137 error = true; 13138 } 13139 else $('#istituzione').siblings('.error-messages').addClass('hidden'); 13140 13141 13142 if($('#workshop1').val() == ''){ 13143 $('#workshop1').siblings('.error-messages').removeClass('hidden'); 13144 error = true; 13145 } 13146 else $('#workshop1').siblings('.error-messages').addClass('hidden'); 13147 13148 if($('#workshop2').val() == ''){ 13149 $('#workshop2').siblings('.error-messages').removeClass('hidden'); 13150 error = true; 13151 } 13152 else $('#workshop2').siblings('.error-messages').addClass('hidden'); 13153 13154 13155 if(!error){ 13156 var data = { 13157 nome: $('#nome').val(), 13158 cognome: $('#cognome').val(), 13159 email: $('#email').val(), 13160 telefono: $('#telefono').val(), 13161 istituzione: $('#istituzione').val(), 13162 workshop1: $('select[name=workshop1] option:selected').text(), 13163 workshop2: $('select[name=workshop2] option:selected').text(), 13164 ricevere_atti: $('input[name=ricevere_atti]').is(':checked') ? 1 : 0 13165 }; 13166 13167 $.post(url+'save.php', data, function (r){ 13168 if(r == 'ok'){ 13169 $('#formulario_uosp_workshop').remove(); 13170 $('h1').next().remove(); 13171 $('.thankyou').removeClass('hidden'); 13172 } 13173 else $('.form-error').removeClass('hidden'); 13174 }); 13175 } 13176 } 13177 init(); 13178} 13179 13180function initContatoreUOSPWorkshop(){ 13181 var url = '/fileadmin/DECS/DS/UOSP/formulario_workshop/'; 13182 var iscritti_max = 30; 13183 function init(){ 13184 $.getJSON(url+'iscrizioni.json?_='+Math.round(Math.random()*1000000000), function (data){ 13185 if(data.state == 3){ 13186 $('#contatore_uosp_workshop').prepend('<p>Formulario chiuso, tutti i workshop sono completi.</p>'); 13187 } 13188 for(i=1;i<=2;i++){ 13189 var html = '<ul>'; 13190 for(x in data[i]){ 13191 // html += '<li><b>'+x+':</b> '+data[i][x]+'</li>'; 13192 html += '<li>'+x+': <b>'+data[i][x]+'</b></li>'; 13193 } 13194 html += '</ul>'; 13195 $('.workshop'+i).html(html); 13196 } 13197 }); 13198 } 13199 init(); 13200} 13201var captcha_image_audioObj; 13202function initFormularioUSE() { 13203 13204 var uploadFile = {}; 13205 var url = '/fileadmin/DFE/DE-USE/formulario-sussidio/'; 13206 var legge; 13207 var loading = false; 13208 function init() { 13209 13210 $('#legge').change(changeFields); 13211 $('select[name=misura_richiesta]').change(checkFiere); 13212 $('#formulario_use input[name=has_iva]').click(checkIVA); 13213 $('#formulario_use button.send-form').click(send); 13214 13215 $('input[name=numero_etp_residenti], input[name=numero_etp_non_residenti]').keyup(calcDipendenti) 13216 $('input[name=totale_investimento], input[name=totale_investimento_ltur], input[name=totale_investimento_lalpr], input[name=totale_investimento_dlc]') 13217 $('input[name=numero_iban], input[name=numero_iban_ltur], input[name=numero_iban_lalpr], input[name=numero_iban_dlc]') 13218 $('input[name=nome_banca], input[name=nome_banca_ltur], input[name=nome_banca_lalpr], input[name=nome_banca_dlc]') 13219 $('input[name=nome_intestatario], input[name=nome_intestatario_ltur], input[name=nome_bintestatario_lalpr], input[name=nomeintestatario_dlc]') 13220 initMultiUpload(); 13221 13222 var h = location.hash.substring(1) 13223 if (h) { 13224 if ($('#legge option[value=' + h + ']').length) { 13225 $('#legge option[value=' + h + ']').prop('selected', true).trigger('change') 13226 } 13227 } 13228 13229 $('head').append('<link rel="stylesheet" type="text/css" href="/typo3conf/ext/theme/Resources/Public/css/daterangepicker.css">'); 13230 $.getScript('/typo3conf/ext/theme/Resources/Public/js/moment.js', function () { 13231 $.getScript('/typo3conf/ext/theme/Resources/Public/js/daterangepicker.js', function () { 13232 13233 var d = new Date(); 13234 dd = d.getDate() < 10 ? '0' + d.getDate() : d.getDate(); 13235 dm = d.getMonth() + 1 < 10 ? '0' + (d.getMonth() + 1) : d.getMonth() + 1; 13236 13237 $('#date_fiera').daterangepicker({ 13238 autoUpdateInput: false, 13239 locale: { 13240 format: 'DD.MM.YYYY', 13241 firstDay: 1, 13242 cancelLabel: 'Cancella', 13243 applyLabel: 'Applica', 13244 customRangeLabel: "Custom", 13245 daysOfWeek: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"], 13246 monthNames: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], 13247 }, 13248 minDate: dd + '/' + dm + '/' + d.getFullYear() 13249 }); 13250 13251 $('#date_fiera').on('apply.daterangepicker', function (ev, picker) { 13252 $(this).val(picker.startDate.format('DD.MM.YYYY') + ' - ' + picker.endDate.format('DD.MM.YYYY')); 13253 }); 13254 13255 $('#date_fiera').on('cancel.daterangepicker', function (ev, picker) { 13256 $(this).val(''); 13257 }); 13258 }); 13259 }); 13260 13261 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 13262 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 13263 }); 13264 13265 // Data richiesta 13266 var d = new Date(); 13267 dd = d.getDate() < 10 ? '0' + d.getDate() : d.getDate(); 13268 dm = d.getMonth() + 1 < 10 ? '0' + (d.getMonth() + 1) : d.getMonth() + 1;
13269 $('#data_richiesta').val(dd + '.' + dm + '.' + d.getFullYear()); 13270 } 13271 function calcDipendenti() { 13272 var v1 = $('input[name=numero_etp_residenti]').val().replace(',', '.') 13273 var v2 = $('input[name=numero_etp_non_residenti]').val().replace(',', '.') 13274 13275 v1 = parseFloat(v1) 13276 v2 = parseFloat(v2) 13277 13278 if (v1 >= 0 && v2 >= 0) { 13279 $('input[name=numero_etp_totale]').val(v1 + v2) 13280 } 13281 } 13282 13283 // Controllo IBAN (esegue una verifica sulla validità dell'IBAN inserito) 13284 function checkIBAN(iban) { 13285 13286 var newIban = iban.toString().toUpperCase().replace(/ /g, ''), 13287 13288 modulo = function (divident, divisor) { 13289 var cDivident = ''; 13290 var cRest = ''; 13291 13292 for (var i in divident) { 13293 var cChar = divident[i]; 13294 var cOperator = cRest + '' + cDivident + '' + cChar; 13295 13296 if (cOperator < parseInt(divisor)) { 13297 cDivident += '' + cChar; 13298 } else { 13299 cRest = cOperator % divisor; 13300 if (cRest == 0) { 13301 cRest = ''; 13302 } 13303 cDivident = ''; 13304 } 13305 13306 } 13307 cRest += '' + cDivident; 13308 if (cRest == '') { 13309 cRest = 0; 13310 } 13311 return cRest; 13312 }; 13313 13314 //Questo codice permette di validare anche formati esteri IT, LI.. 13315 /*if (newIban.search(/^[A-Z]{2}/gi) < 0) { 13316 return false; 13317 }*/ 13318 13319 // Verifica se l'IBAN é Svizzero altrimenti ritorna false. 13320 if (newIban.search(/^CH/gi) < 0) { 13321 return false; 13322 } 13323 13324 newIban = newIban.substring(4) + newIban.substring(0, 4); 13325 13326 newIban = newIban.replace(/[A-Z]/g, function (match) { 13327 return match.charCodeAt(0) - 55; 13328 }); 13329 13330 return parseInt(modulo(newIban, 97), 10) === 1; 13331 } 13332 13333 function formatValue() { 13334 var v = $(this).val() 13335 var i = false 13336 var d = false 13337 var s = false 13338 13339 if (v.indexOf('.') > -1) { 13340 tmp = v.split('.') 13341 i = tmp[0] 13342 d = tmp[1] 13343 s = '.' 13344 } 13345 else if (v.indexOf(',') > -1) { 13346 tmp = v.split(',') 13347 i = tmp[0] 13348 d = tmp[1] 13349 s = ',' 13350 } 13351 else i = v 13352 13353 if (i.length > 3) { 13354 13355 var n = [] 13356 for (x = 0; x < Math.ceil(i.length / 3); x++) { 13357 start = (i.length - (3 * (x + 1))) 13358 if (start < 0) start = 0 13359 n.push(i.slice(start, (i.length - (3 * x)))) 13360 } 13361 n.reverse() 13362 i = n.join("'") 13363 } 13364 13365 if (d) { 13366 i += s + d 13367 } 13368 13369 $(this).val(i) 13370 } 13371 function unformatValue() { 13372 var v = $(this).val() 13373 13374 if (v.indexOf("'") > -1) { 13375 v = v.replace(/'/g, '') 13376 $(this).val(v) 13377 } 13378 } 13379 function send(e) { 13380 e.preventDefault(); 13381 13382 if (!loading) { 13383 loading = true; 13384 13385 var error = false; 13386 13387 if (!checkField('#legge')) error = true; 13388 if (!error) { 13389 if (!checkField('#ragione_sociale')) error = true; 13390 if (!checkField('#email', 'email')) error = true; 13391 if (!checkField('#numero_idi')) error = true; 13392 13393 // Numero IVA 13394 if (!checkField('input[name=has_iva]', 'radio')) error = true; 13395 else if ($('input[name=has_iva]:checked').val() == 'si') { 13396 if (!checkField('#numero_iva', 'iva')) error = true; 13397 } 13398 13399 if (!checkField('input[name=dimensione_azienda]', 'radio')) error = true; 13400 if (!checkField('#comune_sede')) error = true; 13401 13402 if (!checkField('#distretto')) error = true; 13403 if (!checkField('#progetto')) error = true; 13404 if (!checkField('#data_richiesta')) error = true; 13405 13406 if (legge == 'linn') { 13407 if (!checkField('#numero_etp_residenti')) error = true; 13408 if (!checkField('#numero_etp_non_residenti')) error = true; 13409 if (!checkField('#numero_etp_totale')) error = true; 13410 if (!checkField('input[name=assoggettazione]', 'radio')) error = true; 13411 13412 $('#misura_richiesta').change(function () { 13413 let selectedValue = $(this).val(); 13414 13415 // Controlla se il valore selezionato della select list misura_richiesta per linn è vuoto 13416 if (selectedValue === '') { 13417 // Mostra il messaggio di errore 13418 $('#misura_richiesta').siblings('.error-messages').removeClass('hidden'); 13419 error = true; 13420 } else { 13421 // Nasconde il messaggio di errore 13422 $('#misura_richiesta').siblings('.error-messages').addClass('hidden'); 13423 error = false;
13424 } 13425 }); 13426 13427 $('#tipologia_azienda').change(function () { 13428 let selectedValue = $(this).val(); 13429 13430 // Controlla se il valore selezionato della select list tipologia_azienda per linn è vuoto 13431 if (selectedValue === '') { 13432 // Mostra il messaggio di errore 13433 $('#tipologia_azienda').siblings('.error-messages').removeClass('hidden'); 13434 error = true; 13435 } else { 13436 // Nasconde il messaggio di errore 13437 $('#tipologia_azienda').siblings('.error-messages').addClass('hidden'); 13438 error = false; 13439 } 13440 }); 13441 13442 // Controlla lo stato delle select nel caso dovesse cambiare 13443 $('#misura_richiesta').change(); 13444 $('#tipologia_azienda').change(); 13445 13446 function validateNumeroEtpTotale() { 13447 let numeroEtpTotale = $('#numero_etp_totale'); 13448 let minEtp = 0; 13449 let errorMessage = "Compila il campo"; // Messaggio di errore di default 13450 13451 let misuraRichiesta = $('#misura_richiesta').val(); 13452 let tipologiaAzienda = $('#tipologia_azienda').val(); 13453 13454 if (misuraRichiesta === 'Agevolazioni fiscali') { 13455 minEtp = 0; 13456 } else if (tipologiaAzienda === 'Startup') { 13457 minEtp = 1; 13458 errorMessage = "Il numero di ETP è inferiore al numero minimo richiesto per questa misura (1)"; 13459 } else if ((misuraRichiesta === 'Investimenti di natura materiale' || misuraRichiesta === 'Investimenti di natura immateriale') && tipologiaAzienda !== 'Startup') { 13460 minEtp = 5; 13461 errorMessage = "Il numero di ETP è inferiore al numero minimo richiesto per questa misura (5)"; 13462 } else { 13463 minEtp = 3; 13464 errorMessage = "Il numero di ETP è inferiore al numero minimo richiesto per questa misura (3)"; 13465 } 13466 13467 // Imposta dinamicamente l'attributo min basandoti sulle selezioni 13468 numeroEtpTotale.attr('min', minEtp); 13469 13470 let errorElement = numeroEtpTotale.siblings('.error-messages'); 13471 if (parseInt(numeroEtpTotale.val()) < minEtp) { 13472 errorElement.text(errorMessage).removeClass('hidden'); 13473 return false; // Fallimento della validazione 13474 } else { 13475 errorElement.addClass('hidden'); 13476 return true; // Successo della validazione 13477 } 13478 } 13479 13480 13481 13482 // Ascolta i cambiamenti nei campi select e nel campo di input 13483 $('#misura_richiesta, #tipologia_azienda, #numero_etp_totale').change(validateNumeroEtpTotale); 13484 13485 13486 // Esegui la validazione una volta all'inizio per lo stato iniziale 13487 validateNumeroEtpTotale(); 13488 if (!validateNumeroEtpTotale()) error = true; 13489 if (!checkField('#totale_investimento')) error = true; 13490 if (!checkField('#numero_iban')) error = true; 13491 if (!checkField('#nome_banca')) error = true; 13492 if (!checkField('#nome_intestatario')) error = true; 13493 else if (!checkIBAN($('#numero_iban').val())) { 13494 error = true; 13495 $('#numero_iban').siblings('.error-messages').removeClass('hidden'); 13496 } 13497 13498 if ($('select[name=misura_richiesta]').val() == 'Partecipazione a fiere specialistiche') { 13499 if (!checkField('#nazione_fiera')) error = true; 13500 if (!checkField('#citta_fiera')) error = true; 13501 if (!checkField('#date_fiera', 'daterange')) error = true; 13502 } 13503 13504 if (!$('#terms:checked').length) { 13505 error = true; 13506 $('#special_linn .error-messages').removeClass('hidden'); 13507 } 13508 else $('#special_linn .error-messages').addClass('hidden'); 13509 13510 //dichiaro controllo 13511 if (!$('#termsdichiaro:checked').length) { 13512 error = true; 13513 $('#special_dichiaro .error-messages').removeClass('hidden'); 13514 } 13515 else $('#special_dichiaro .error-messages').addClass('hidden'); 13516 13517 13518 } 13519 else if (legge == 'ltur') { 13520 13521 13522 if (!checkField('input[name=otr]', 'radio')) error = true; 13523 if (!checkField('#totale_investimento_ltur')) error = true; 13524 if (!checkField('#nome_banca_ltur')) error = true; 13525 if (!checkField('#nome_intestatario_ltur')) error = true; 13526 if (!checkField('#numero_iban_ltur')) error = true; 13527 else if (!checkIBAN($('#numero_iban_ltur').val())) { 13528 error = true; 13529 $('#numero_iban_ltur').siblings('.error-messages').removeClass('hidden'); 13530 } 13531 if (!checkField('input[name=misura_richiesta2]', 'radio')) error = true; 13532 13533 //dichiaro controllo 13534 if (!$('#termsdichiaro:checked').length) { 13535 error = true; 13536 $('#special_dichiaro .error-messages').removeClass('hidden'); 13537 } 13538 else $('#special_dichiaro .error-messages').addClass('hidden'); 13539 } 13540 else if (legge == 'lalpr') { 13541 if (!checkField('input[name=ers]', 'radio')) error = true; 13542 if (!checkField('#totale_investimento_lalpr')) error = true; 13543 if (!checkField('#nome_banca_lalpr')) error = true; 13544 if (!checkField('#nome_intestatario_lalpr')) error = true; 13545 if (!checkField('#numero_iban_lalpr')) error = true; 13546 else if (!checkIBAN($('#numero_iban_lalpr').val())) { 13547 error = true; 13548 $('#numero_iban_lalpr').siblings('.error-messages').removeClass('hidden'); 13549 }
13550 if (!checkField('input[name=ambito]', 'radio')) error = true; 13551 13552 //dichiaro controllo 13553 if (!$('#termsdichiaro:checked').length) { 13554 error = true; 13555 $('#special_dichiaro .error-messages').removeClass('hidden'); 13556 } 13557 else $('#special_dichiaro .error-messages').addClass('hidden'); 13558 } 13559 else if (legge == 'dlc') { 13560 if (!checkField('input[name=ers2]', 'radio')) error = true; 13561 if (!checkField('#totale_investimento_dlc')) error = true; 13562 if (!checkField('#nome_banca_dlc')) error = true; 13563 if (!checkField('#nome_intestatario_dlc')) error = true; 13564 if (!checkField('#numero_iban_dlc')) error = true; 13565 else if (!checkIBAN($('#numero_iban_dlc').val())) { 13566 error = true; 13567 $('#numero_iban_dlc').siblings('.error-messages').removeClass('hidden'); 13568 } 13569 } 13570 13571 if (!error) { 13572 if (!checkCaptchaField()) error = true; 13573 } 13574 13575 if (!error) { 13576 var data = { 13577 legge: $('#legge').val(), 13578 ragione_sociale: $('#ragione_sociale').val(), 13579 email: $('#email').val(), 13580 numero_idi: $('#numero_idi').val(), 13581 numero_iva: $('#numero_iva').val(), 13582 dimensione_azienda: $('input[name=dimensione_azienda]:checked').val(), 13583 comune_sede: $('#comune_sede').val(), 13584 comune_esecuzione: $('#comune_esecuzione').val(), 13585 distretto: $('#distretto').val(), 13586 progetto: $('#progetto').val(), 13587 data_richiesta: $('#data_richiesta').val(), 13588 }; 13589 13590 if (legge == 'linn') { 13591 data.numero_etp_residenti = $('#numero_etp_residenti').val(); 13592 data.numero_etp_non_residenti = $('#numero_etp_non_residenti').val(); 13593 data.numero_etp_totale = $('#numero_etp_totale').val(); 13594 data.assoggettazione = $('input[name=assoggettazione]:checked').val(); 13595 data.misura_richiesta = $('#misura_richiesta').find(":selected").val(); 13596 data.tipologia_azienda = $('#tipologia_azienda').find(":selected").val(); 13597 data.totale_investimento = $('#totale_investimento').val(); 13598 data.nome_banca = $('#nome_banca').val(); 13599 data.nome_intestatario = $('#nome_intestatario').val(); 13600 data.numero_iban = $('#numero_iban').val(); 13601 if (data.misura_richiesta == 'Partecipazione a fiere specialistiche') { 13602 data.nazione_fiera = $('#nazione_fiera').val(); 13603 data.citta_fiera = $('#citta_fiera').val(); 13604 data.date_fiera = $('#date_fiera').val(); 13605 } 13606 } 13607 13608 else if (legge == 'ltur') { 13609 data.proprietario_fondo = $('#proprietario_fondo').val() == '' ? '-' : $('#proprietario_fondo').val(); 13610 data.numero_mappale = $('#numero_mappale').val() == '' ? '-' : $('#numero_mappale').val(); 13611 13612 data.otr = $('input[name=otr]:checked').val(); 13613 data.totale_investimento = $('#totale_investimento_ltur').val(); 13614 data.nome_banca_ltur = $('#nome_banca_ltur').val(); 13615 data.nome_intestatario_ltur = $('#nome_intestatario_ltur').val(); 13616 data.numero_iban_ltur = $('#numero_iban_ltur').val(); 13617 data.misura_richiesta = $('input[name=misura_richiesta2]:checked').val(); 13618 } 13619 else if (legge == 'lalpr') { 13620 data.ers = $('input[name=ers]:checked').val(); 13621 data.totale_investimento = $('#totale_investimento_lalpr').val(); 13622 data.nome_banca_lalpr = $('#nome_banca_lalpr').val(); 13623 data.nome_intestatario_lalpr = $('#nome_intestatario_lalpr').val(); 13624 data.numero_iban_lalpr = $('#numero_iban_lalpr').val();
13625 data.ambito = $('input[name=ambito]:checked').val(); 13626 } 13627 else if (legge == 'dlc') { 13628 data.ers = $('input[name=ers2]:checked').val(); 13629 data.totale_investimento = $('#totale_investimento_dlc').val(); 13630 data.nome_banca_dlc = $('#nome_banca_dlc').val(); 13631 data.nome_intestatario_dlc = $('#nome_intestatario_dlc').val(); 13632 data.numero_iban_dlc = $('#numero_iban_dlc').val(); 13633 } 13634 13635 data.files = []; 13636 $('input[type=file][id]').each(function () { 13637 data.files.push($(this).attr('data-file')); 13638 }); 13639 13640 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 13641 $.post(url + 'save.php', data, function (r) { 13642 $('form, .intro').remove(); 13643 $('.success').removeClass('hidden'); 13644 13645 }).fail(function () { 13646 $('button.send-form').html('Invia').removeClass('disabled'); 13647 }); 13648 } 13649 else { 13650 $('.error-messages:not(.hidden):first').siblings('input').focus() 13651 loading = false; 13652 } 13653 } 13654 } 13655 } 13656 function initMultiUpload() { 13657 var attachments_n = 1; 13658 var max_weight = 10; 13659 var used_weight = 0; 13660 var working = false; 13661 var uploadButtonContent = ''; 13662 function init() { 13663 uploadButtonContent = $('#formulario_use .allegati .add').html(); 13664 13665 $('#formulario_use').on('click', '.allegati .add', addAttachemnt); 13666 $('#formulario_use').on('click', '.allegati .remove', clearAttachemnt); 13667 13668 $('#formulario_use').on('change', '.inputfile', change); 13669 } 13670 13671 function addAttachemnt(e) { 13672 e.preventDefault(); 13673 13674 if (!working) { 13675 $(this).siblings('.allegato.hidden.new').remove(); 13676 13677 if ($('#attachments-error').length) $('#attachments-error').remove(); 13678 13679 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 13680 $('#formulario_use .allegato.new label').attr('for', 'file' + attachments_n); 13681 $('#formulario_use .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 13682 13683 $('#formulario_use .allegato.new input:last').trigger('click'); 13684 13685 attachments_n++; 13686 } 13687 } 13688 function clearAttachemnt(e) { 13689 e.preventDefault(); 13690 13691 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 13692 uploadFile[id] = false; 13693 13694 var p = $(this).parents('.allegato'); 13695 used_weight -= parseInt(p.find('input').attr('data-weight')); 13696 13697 p.find('input[type=file]').val(''); 13698 p.find('input[type=file]').next().children('span').text('Allega un file'); 13699 p.remove(); 13700 } 13701 function change(event) { 13702 var id = $(this).attr('id'); 13703 13704 tmp = $(this).val().split("\\"); 13705 var v = tmp[tmp.length - 1]; 13706 13707 if (v) { 13708 tmp2 = v.split('.'); 13709 var ext = tmp2[(tmp2.length - 1)]; 13710 13711 if (ext == 'exe' || ext == 'bat' || ext == 'com') { 13712 if ($('#attachments-error').length) $('#attachments-error').remove(); 13713 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><p style="color:#c33;position: relative; top: -10px;">Formato non consentito.</p></div>'); 13714 13715 $('label[for=' + id + '] span').text('Allega un file (10Mb massimo)'); 13716 } 13717 else { 13718 $('label[for=' + id + '] span').text(v); 13719 13720 if ($('#attachments-error').length) $('#attachments-error').remove(); 13721 13722 13723 uploadFile[id] = event.target.files; 13724 13725 upload(id, event.target.files); 13726 } 13727 } 13728 } 13729 function upload(x, value) { 13730 var data = new FormData(); 13731 var upd = { 13732 x: value 13733 }; 13734 13735 $('body').append('<div id="sending-form" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;"></div>'); 13736 $('#formulario_use .allegati .add').html('<i class="fa fa-spinner fa-spin"></i>'); 13737 working = true; 13738 13739 for (x in upd) { 13740 if (upd[x]) { 13741 n = 1; 13742 $.each(upd[x], function (key, value) { 13743 data.append('file' + n, value); 13744 n++; 13745 }); 13746 } 13747 } 13748 $.ajax({ 13749 13750 url: url + 'upload.php', // point to server-side PHP script 13751 dataType: 'text', // what to expect back from the PHP script, if anything 13752 cache: false, 13753 contentType: false, 13754 processData: false, 13755 data: data, 13756 type: 'post', 13757 success: function (php_script_response) { 13758 13759 if (php_script_response == 'filesize') { 13760 if ($('#attachments-error').length) $('#attachments-error').remove(); 13761 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>L\'allegato supera il limite consentito di 10MB.</li></ul></div>'); 13762 } 13763 else if (php_script_response == 'error') { 13764 if ($('#attachments-error').length) $('#attachments-error').remove(); 13765 $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>Errore durante il caricamento degli allegati.</li></ul></div>'); 13766 } 13767 else { 13768 if (php_script_response.indexOf(';') > -1) { 13769 var tmp = php_script_response.split(';'); 13770 } 13771 else var tmp = [php_script_response]; 13772 $('.allegato.new.hidden input').attr('data-file', php_script_response); 13773 $('.allegato.new.hidden').removeClass('new hidden'); 13774 } 13775 13776 $('#formulario_use .allegati .add').html(uploadButtonContent); 13777 $('#sending-form').remove(); 13778 13779 working = false;
13780 } 13781 }); 13782 } 13783 function updateWeights() { 13784 if (contactData.lang == 'en') $('.allegati h4').html('Attachments ' + (used_weight) + ' MB(maximum size allowed 10 MB)'); 13785 else $('.allegati h4').html('Allegati ' + (used_weight) + ' MB(dimensione massima consentita 10 MB)'); 13786 13787 if (used_weight == max_weight) $('.allegati .add').hide(); 13788 else $('.allegati .add').show(); 13789 } 13790 init(); 13791 } 13792 function changeFields() { 13793 legge = $(this).val(); 13794 13795 $('.buttons, .general, .variante').addClass('hidden') 13796 if (legge) { 13797 $('#variante_' + legge).removeClass('hidden'); 13798 $('.buttons, .general').removeClass('hidden'); 13799 13800 if (legge == 'ltur') $('#special_ltur').removeClass('hidden'); 13801 else $('#special_ltur').addClass('hidden'); 13802 13803 if (legge == 'linn') $('#special_linn').removeClass('hidden'); 13804 else $('#special_linn').addClass('hidden'); 13805 13806 if (legge == 'linn') $('#special_linn2').removeClass('hidden'); 13807 else $('#special_linn2').addClass('hidden'); 13808 13809 //dichiaro 13810 if (legge == 'linn') { 13811 $('#special_dichiaro').removeClass('hidden'); 13812 } 13813 else if (legge == 'lalpr') { 13814 $('#special_dichiaro').removeClass('hidden'); 13815 } 13816 else if (legge == 'ltur') { 13817 $('#special_dichiaro').removeClass('hidden'); 13818 } 13819 else $('#special_dichiaro').addClass('hidden'); 13820 } 13821 } 13822 function checkFiere() { 13823 v = $(this).val(); 13824 if (v == 'Partecipazione a fiere specialistiche') $('.fiere').removeClass('hidden'); 13825 else $('.fiere').addClass('hidden'); 13826 } 13827 function checkIVA() { 13828 if ($(this).attr('id') == 'has_iva1') $('#inserire_iva').removeClass('hidden'); 13829 else $('#inserire_iva').addClass('hidden'); 13830 } 13831 function checkField(s, type) { 13832 if (typeof type == 'undefined') { 13833 if ($(s).val() == '') { 13834 $(s).siblings('.error-messages').removeClass('hidden'); 13835 return false; 13836 } 13837 else { 13838 $(s).siblings('.error-messages').addClass('hidden'); 13839 return true; 13840 } 13841 } 13842 else if (type == 'email') { 13843 if ($(s).val() == '' || !checkEmail($(s).val())) { 13844 $(s).siblings('.error-messages').removeClass('hidden'); 13845 return false; 13846 } 13847 else { 13848 $(s).siblings('.error-messages').addClass('hidden'); 13849 return true; 13850 } 13851 } 13852 else if (type == 'radio') { 13853 if ($(s + ':checked').length == 0) { 13854 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 13855 return false; 13856 } 13857 else { 13858 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 13859 return true; 13860 } 13861 } 13862 else if (type == 'iva') { 13863 if ($(s).val() == '' || !/^(CHE-[0-9]{3}.[0-9]{3}.[0-9]{3} IVA)$/.test($(s).val())) { 13864 $(s).siblings('.error-messages').removeClass('hidden'); 13865 return false; 13866 } 13867 else { 13868 $(s).siblings('.error-messages').addClass('hidden'); 13869 return true; 13870 } 13871 } 13872 else if (type == 'daterange') { 13873 if ($(s).val() == '' || !/^[0-9]{2}\.[0-9]{2}\.[0-9]{4} - [0-9]{2}\.[0-9]{2}\.[0-9]{4}$/.test($(s).val())) { 13874 $(s).siblings('.error-messages').removeClass('hidden'); 13875 return false; 13876 } 13877 else { 13878 $(s).siblings('.error-messages').addClass('hidden'); 13879 return true; 13880 } 13881 } else if (type == 'select') { 13882 if ($(s).find('option:selected').length == 0 || $(s).find('option:selected').val() == '') { 13883 $(s).siblings('.error-messages').removeClass('hidden'); 13884 return false;
13885 } else { 13886 $(s).siblings('.error-messages').addClass('hidden'); 13887 return true; 13888 } 13889 } 13890 } 13891 function checkEmail(email) { 13892 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,}))$/; 13893 return re.test(String(email).toLowerCase()); 13894 } 13895 function checkCaptchaField() { 13896 var field = $('input[name=captcha]'); 13897 var error = false; 13898 13899 if (field.val()) { 13900 var r = checkCaptcha(field.val()); 13901 if (r.responseText == 'ok') { 13902 field.removeClass('error'); 13903 $('.captcha .error-messages').addClass('hidden'); 13904 } 13905 else { 13906 field.addClass('error').val(''); 13907 $('.refresh-button').trigger('click'); 13908 $('.captcha .error-messages').removeClass('hidden'); 13909 error = true; 13910 } 13911 } 13912 else { 13913 field.addClass('error'); 13914 $('.refresh-button').trigger('click'); 13915 $('.captcha .error-messages').removeClass('hidden'); 13916 error = true; 13917 } 13918 13919 if (!error) return true; 13920 return false; 13921 } 13922 function checkCaptcha(value) { 13923 var rand = Math.floor((Math.random() * 100000) + 1); 13924 return $.ajax({ 13925 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 13926 data: { 13927 value: value 13928 }, 13929 async: false, 13930 method: 'post' 13931 }); 13932 } 13933 init(); 13934} 13935 13936function initFormularioUSEUAC() { 13937 var uploadFile = {}; 13938 var url = '/fileadmin/DFE/DE-UAC/formulario/'; 13939 var legge; 13940 var loading = false; 13941 function init() { 13942 13943 var h = location.hash 13944 if (h && h != '#') { 13945 h = h.substring(1) 13946 if ($('#legge option[value=' + h + ']').length) { 13947 $('#legge option[value=' + h + ']').prop('selected', true) 13948 setTimeout(function () { $('#legge').trigger('change') }, 500) 13949 } 13950 } 13951 13952 $('#legge').change(changeFields); 13953 $('#formulario_use_uac button.send-form').click(send); 13954 initMultiUpload1(); 13955 initMultiUpload2(); 13956 13957 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 13958 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 13959 }); 13960 } 13961 function send(e) { 13962 e.preventDefault(); 13963 13964 if (!loading) { 13965 loading = true; 13966 13967 var error = false; 13968 13969 if (!checkField('#legge')) error = true; 13970 13971 if (!error) { 13972 if ($('#legge').val() == 'linn') { 13973 if (!checkDossier2()) error = true; 13974 } 13975 else { 13976 if (!checkDossier()) error = true; 13977 } 13978 13979 if (!checkField('#ragione_sociale')) error = true; 13980 13981 $('#pin').siblings('.error-messages-n').addClass('hidden') 13982 if (!checkField('#pin')) error = true; 13983 else { 13984 if ($('#pin').val().length != 4) { 13985 $('#pin').siblings('.error-messages-n').removeClass('hidden') 13986 error = true 13987 } 13988 } 13989 13990 if (!error) { 13991 if (!checkCaptchaField()) error = true; 13992 } 13993 13994 if (!error) { 13995 var data = { 13996 legge: $('#legge').val(), 13997 ragione_sociale: $('#ragione_sociale').val(), 13998 pin: $('#pin').val() 13999 }; 14000 14001 if ($('#legge').val() == 'linn') data.n_dossier = $('#n_dossier').val() 14002 else data.n_dossier = $('#n_dossier1').val() + '.' + $('#n_dossier2').val() + '.' + $('#n_dossier3').val() 14003 14004 data.files = []; 14005 $('input[type=file][id]').each(function () { 14006 data.files.push($(this).attr('data-file')); 14007 }); 14008 14009 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 14010 $.post(url + 'save.php', data, function (r) { 14011 $('form, .intro').remove(); 14012 $('.success').removeClass('hidden'); 14013 }).fail(function () { 14014 $('button.send-form').html('Invia').removeClass('disabled'); 14015 }); 14016 } 14017 else { 14018 $('.error-messages:not(.hidden):first').siblings('input').focus() 14019 loading = false;
14020 } 14021 } 14022 } 14023 } 14024 function initMultiUpload1() { 14025 var attachments_n = 1; 14026 var max_weight = 10; 14027 var max_uploads = 2; 14028 var used_weight = 0; 14029 var working = false; 14030 var uploadButtonContent = ''; 14031 function init() { 14032 uploadButtonContent = $('#formulario_use_uac .allegati1 .add').html(); 14033 14034 $('#formulario_use_uac').on('click', '.allegati1 .add', addAttachemnt); 14035 $('#formulario_use_uac').on('click', '.allegati1 .remove', clearAttachemnt); 14036 14037 $('#formulario_use_uac').on('change', '.allegati1 .inputfile', change); 14038 } 14039 function addAttachemnt(e) { 14040 e.preventDefault(); 14041 14042 if (!working) { 14043 $(this).siblings('.allegati1 .allegato.hidden.new').remove(); 14044 14045 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size, .allegati1 .error-messages-upload').addClass('hidden') 14046 14047 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 14048 $('#formulario_use_uac .allegati1 .allegato.new label').attr('for', 'file1_' + attachments_n); 14049 $('#formulario_use_uac .allegati1 .allegato.new input').attr('id', 'file1_' + attachments_n).attr('name', 'file1_' + attachments_n); 14050 14051 $('#formulario_use_uac .allegati1 .allegato.new input:last').trigger('click'); 14052 14053 14054 } 14055 } 14056 function clearAttachemnt(e) { 14057 e.preventDefault(); 14058 14059 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 14060 uploadFile[id] = false; 14061 14062 var p = $(this).parents('.allegato'); 14063 used_weight -= parseInt(p.find('input').attr('data-weight')); 14064 14065 14066 p.find('input[type=file]').val(''); 14067 p.find('input[type=file]').next().children('span').text('Allega un file'); 14068 p.remove(); 14069 14070 attachments_n--; 14071 if (max_uploads >= attachments_n) $('#formulario_use_uac .allegati1 .add').removeClass('hidden'); 14072 14073 if ($('.allegati1 .allegato:not(.hidden)').length == 0) $('.allegati1 .add').css('margin-top', '0') 14074 } 14075 function change(event) { 14076 var id = $(this).attr('id'); 14077 14078 tmp = $(this).val().split("\\"); 14079 var v = tmp[tmp.length - 1]; 14080 14081 if (v) { 14082 tmp2 = v.split('.'); 14083 var ext = tmp2[(tmp2.length - 1)]; 14084 14085 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size, .allegati1 .error-messages-upload').addClass('hidden') 14086 14087 if (ext.toLowerCase() != 'xls' && ext.toLowerCase() != 'xlsx') { 14088 $('.allegati1 .error-messages-type').removeClass('hidden') 14089 14090 } 14091 else { 14092 $('label[for=' + id + '] span').text(v); 14093 14094 uploadFile[id] = event.target.files; 14095 14096 upload(id, event.target.files); 14097 14098 } 14099 } 14100 14101 } 14102 function upload(x, value) { 14103 var data = new FormData(); 14104 var upd = { 14105 x: value 14106 }; 14107 14108 working = true; 14109 14110 for (x in upd) { 14111 if (upd[x]) { 14112 n = 1; 14113 $.each(upd[x], function (key, value) { 14114 data.append('file' + n, value); 14115 n++; 14116 }); 14117 } 14118 } 14119 $.ajax({ 14120 url: url + 'upload.php', // point to server-side PHP script 14121 dataType: 'text', // what to expect back from the PHP script, if anything 14122 cache: false, 14123 contentType: false, 14124 processData: false, 14125 data: data, 14126 type: 'post', 14127 success: function (php_script_response) { 14128 14129 $('.allegati1 .error-messages, .allegati1 .error-messages-type, .allegati1 .error-messages-size, .allegati1 .error-messages-upload').addClass('hidden') 14130 14131 if (php_script_response == 'filesize') { 14132 $('.allegati1 .error-messages-size').removeClass('hidden') 14133 } 14134 else if (php_script_response == 'error') { 14135 $('.allegati1 .error-messages-upload').removeClass('hidden') 14136 } 14137 else { 14138 if (php_script_response.indexOf(';') > -1) { 14139 var tmp = php_script_response.split(';'); 14140 } 14141 else var tmp = [php_script_response]; 14142 14143 $('.allegati1 .allegato.new.hidden input').attr('data-file', php_script_response); 14144 $('.allegati1 .allegato.new.hidden').removeClass('new hidden'); 14145 14146 attachments_n++; 14147 } 14148 14149 $('#formulario_use_uac .allegati1 .add').html(uploadButtonContent); 14150 if (attachments_n > max_uploads) $('#formulario_use_uac .allegati1 .add').addClass('hidden'); 14151 14152 working = false;
14153 14154 if ($('.allegati1 .allegato:not(.hidden)').length) $('.allegati1 .add').css('margin-top', '20px') 14155 } 14156 }); 14157 } 14158 function updateWeights() { 14159 if (contactData.lang == 'en') $('.allegati1 h4').html('Attachments ' + (used_weight) + ' MB(maximum size allowed 10 MB)'); 14160 else $('.allegati1 h4').html('Allegati ' + (used_weight) + ' MB(dimensione massima consentita 10 MB)'); 14161 14162 if (used_weight == max_weight) $('.allegati1 .add').hide(); 14163 else $('.allegati1 .add').show(); 14164 } 14165 init(); 14166 } 14167 14168 function initMultiUpload2() { 14169 var attachments_n = 1; 14170 var max_weight = 10; 14171 var max_uploads = 2; 14172 var used_weight = 0; 14173 var working = false; 14174 var uploadButtonContent = ''; 14175 function init() { 14176 uploadButtonContent = $('#formulario_use_uac .allegati2 .add').html(); 14177 14178 $('#formulario_use_uac').on('click', '.allegati2 .add', addAttachemnt); 14179 $('#formulario_use_uac').on('click', '.allegati2 .remove', clearAttachemnt); 14180 $('#formulario_use_uac').on('change', '.allegati2 .inputfile', change); 14181 } 14182 function addAttachemnt(e) { 14183 e.preventDefault(); 14184 14185 if (!working) { 14186 $(this).siblings('.allegati2 .allegato.hidden.new').remove(); 14187 14188 $('.allegati2 .error-messages, .allegati2 .error-messages-type, .allegati2 .error-messages-size, .allegati2 .error-messages-upload').addClass('hidden') 14189 14190 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 14191 $('#formulario_use_uac .allegati2 .allegato.new label').attr('for', 'file2_' + attachments_n); 14192 $('#formulario_use_uac .allegati2 .allegato.new input').attr('id', 'file2_' + attachments_n).attr('name', 'file2_' + attachments_n); 14193 $('#formulario_use_uac .allegati2 .allegato.new input:last').trigger('click'); 14194 } 14195 } 14196 function clearAttachemnt(e) { 14197 e.preventDefault(); 14198 14199 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 14200 uploadFile[id] = false; 14201 14202 var p = $(this).parents('.allegato'); 14203 used_weight -= parseInt(p.find('input').attr('data-weight')); 14204 14205 14206 p.find('input[type=file]').val(''); 14207 p.find('input[type=file]').next().children('span').text('Allega un file'); 14208 p.remove(); 14209 14210 attachments_n--; 14211 if (max_uploads >= attachments_n) $('#formulario_use_uac .allegati2 .add').removeClass('hidden'); 14212 14213 if ($('.allegati2 .allegato:not(.hidden)').length == 0) $('.allegati2 .add').css('margin-top', '0') 14214 } 14215 14216 function change(event) { 14217 var id = $(this).attr('id'); 14218 14219 tmp = $(this).val().split("\\"); 14220 var v = tmp[tmp.length - 1]; 14221 14222 if (v) { 14223 tmp2 = v.split('.'); 14224 var ext = tmp2[(tmp2.length - 1)]; 14225 14226 $('.allegati2 .error-messages, .allegati2 .error-messages-type, .allegati2 .error-messages-size, .allegati2 .error-messages-upload').addClass('hidden') 14227 14228 if (ext.toLowerCase() != 'pdf') { 14229 $('.allegati2 .error-messages-type').removeClass('hidden') 14230 14231 } 14232 else { 14233 $('label[for=' + id + '] span').text(v); 14234 14235 uploadFile[id] = event.target.files; 14236 14237 upload(id, event.target.files); 14238 } 14239 } 14240 } 14241 14242 function upload(x, value) { 14243 var data = new FormData(); 14244 var upd = { 14245 x: value 14246 }; 14247 14248 working = true; 14249 14250 for (x in upd) { 14251 if (upd[x]) { 14252 n = 1; 14253 $.each(upd[x], function (key, value) { 14254 data.append('file' + n, value); 14255 n++; 14256 }); 14257 } 14258 } 14259 14260 $.ajax({ 14261 14262 url: url + 'upload.php', // point to server-side PHP script 14263 dataType: 'text', // what to expect back from the PHP script, if anything 14264 cache: false, 14265 contentType: false, 14266 processData: false, 14267 data: data, 14268 type: 'post', 14269 success: function (php_script_response) { 14270 14271 $('.allegati2 .error-messages, .allegati2 .error-messages-type, .allegati2 .error-messages-size, .allegati2 .error-messages-upload').addClass('hidden') 14272 14273 if (php_script_response == 'filesize') { 14274 14275 $('.allegati2 .error-messages-size').removeClass('hidden') 14276 } 14277 else if (php_script_response == 'error') { 14278 $('.allegati2 .error-messages-upload').removeClass('hidden') 14279 } 14280 else { 14281 if (php_script_response.indexOf(';') > -1) { 14282 var tmp = php_script_response.split(';'); 14283 } 14284 else var tmp = [php_script_response]; 14285 14286 14287 $('.allegati2 .allegato.new.hidden input').attr('data-file', php_script_response); 14288 14289 $('.allegati2 .allegato.new.hidden').removeClass('new hidden'); 14290 14291 attachments_n++; 14292 } 14293 14294 $('#formulario_use_uac .allegati2 .add').html(uploadButtonContent); 14295 if (attachments_n > max_uploads) $('#formulario_use_uac .allegati2 .add').addClass('hidden'); 14296 14297 if ($('.allegati2 .allegato:not(.hidden)').length) $('.allegati2 .add').css('margin-top', '20px') 14298 14299 14300 working = false;
14301 } 14302 }); 14303 } 14304 14305 function updateWeights() { 14306 if (contactData.lang == 'en') $('.allegati2 h4').html('Attachments ' + (used_weight) + ' MB(maximum size allowed 10 MB)'); 14307 else $('.allegati2 h4').html('Allegati ' + (used_weight) + ' MB(dimensione massima consentita 10 MB)'); 14308 14309 if (used_weight == max_weight) $('.allegati2 .add').hide(); 14310 else $('.allegati2 .add').show(); 14311 } 14312 init(); 14313 } 14314 14315 function changeFields() { 14316 legge = $(this).val(); 14317 14318 if (legge) $('.fields').removeClass('hidden') 14319 else $('.fields').addClass('hidden') 14320 14321 $('#n_dossier1').val('') 14322 14323 if (legge == 'linn') { 14324 $('.n_dossier1').removeClass('hidden') 14325 $('.n_dossier2').addClass('hidden') 14326 } 14327 else { 14328 $('.n_dossier2').removeClass('hidden') 14329 $('.n_dossier1').addClass('hidden') 14330 } 14331 } 14332 14333 function checkDossier() { 14334 var error = false; 14335 var dossier = [ 14336 $('#n_dossier1').val(), 14337 $('#n_dossier2').val(), 14338 $('#n_dossier3').val() 14339 ] 14340 var error_message = $('#n_dossier1').siblings('.error-messages'); 14341 14342 if (dossier[0] == "" || dossier[1] == "" || dossier[2] == "") { 14343 error = true; 14344 error_message.text('Compila i campi') 14345 } 14346 else { 14347 if (legge == 'ltur') { 14348 if (!/T[0-9]/.test(dossier[0])) error = true 14349 } 14350 else if (legge == 'linn') { 14351 if (dossier[0] != 'F' && dossier[0] != 'i') error = true 14352 } 14353 else if (legge == 'lalpr') { 14354 if (dossier[0] != 'PR') error = true 14355 } 14356 14357 if (!/[0-9]{2}/.test(dossier[1]) || !/[0-9]{3}/.test(dossier[2])) error = true 14358 14359 error_message.text('Compila correttamente i campi') 14360 } 14361 14362 if (error) { 14363 error_message.removeClass('hidden') 14364 return false; 14365 } 14366 else { 14367 error_message.addClass('hidden') 14368 return true 14369 } 14370 } 14371 function checkDossier2() { 14372 var error = false; 14373 var dossier = $('#n_dossier').val() 14374 var error_message = $('#n_dossier').siblings('.error-messages'); 14375 14376 if (dossier == "") { 14377 error = true; 14378 error_message.text('Compila il campo') 14379 } 14380 else { 14381 if (dossier.indexOf('.') == -1) error = true 14382 else { 14383 tmp = dossier.split('.') 14384 if (tmp.length == 3 || tmp.length == 4) { 14385 if (tmp[0] != 'F' && dossier[0] != 'i') error = true 14386 else if (!/^[0-9]{2}$/.test(tmp[1]) || !/^[0-9]{3}$/.test(tmp[2])) error = true 14387 14388 if (tmp.length == 4) { 14389 if (!/^[a-zA-Z]{3}$/.test(tmp[3])) error = true 14390 } 14391 } 14392 else error = true 14393 } 14394 error_message.text('Compila correttamente i campi') 14395 } 14396 14397 if (error) { 14398 error_message.removeClass('hidden') 14399 return false; 14400 } 14401 else { 14402 error_message.addClass('hidden') 14403 return true 14404 } 14405 } 14406 14407 14408 function checkField(s, type) { 14409 if (typeof type == 'undefined') { 14410 if ($(s).val() == '') { 14411 $(s).siblings('.error-messages').removeClass('hidden'); 14412 return false; 14413 } else { 14414 $(s).siblings('.error-messages').addClass('hidden'); 14415 return true; 14416 } 14417 } else if (type == 'radio') { 14418 if ($(s + ':checked').length == 0) { 14419 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 14420 return false; 14421 } else { 14422 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 14423 return true; 14424 } 14425 } else if (type == 'select') { 14426 if ($(s).find('option:selected').length == 0 || $(s).find('option:selected').val() == '') { 14427 $(s).siblings('.error-messages').removeClass('hidden'); 14428 return false;
14429 } else { 14430 $(s).siblings('.error-messages').addClass('hidden'); 14431 return true; 14432 } 14433 } 14434 } 14435 14436 14437 function checkCaptchaField() { 14438 var field = $('input[name=captcha]'); 14439 var error = false; 14440 14441 if (field.val()) { 14442 var r = checkCaptcha(field.val()); 14443 if (r.responseText == 'ok') { 14444 field.removeClass('error'); 14445 $('.captcha .error-messages').addClass('hidden'); 14446 } 14447 else { 14448 field.addClass('error').val(''); 14449 $('.refresh-button').trigger('click'); 14450 $('.captcha .error-messages').removeClass('hidden'); 14451 error = true; 14452 } 14453 } 14454 else { 14455 field.addClass('error'); 14456 $('.refresh-button').trigger('click'); 14457 $('.captcha .error-messages').removeClass('hidden'); 14458 error = true; 14459 } 14460 14461 if (!error) return true; 14462 return false; 14463 } 14464 14465 function checkCaptcha(value) { 14466 var rand = Math.floor((Math.random() * 100000) + 1); 14467 return $.ajax({ 14468 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 14469 data: { 14470 value: value 14471 }, 14472 async: false, 14473 method: 'post' 14474 }); 14475 } 14476 init(); 14477} 14478var captcha_image_audioObj; 14479function initFormularioUSE2() { 14480 var uploadFile = {}; 14481 var url = '/fileadmin/DFE/DE-USE/formulario-business-plan/'; 14482 var legge; 14483 var loading = false; 14484 function init() { 14485 // $('#legge').change(changeFields); 14486 // $('input[name=misura_richiesta]').click(checkFiere); 14487 // $('#formulario_use2 input[name=has_iva]').click(checkIVA); 14488 $('#formulario_use2 button.send-form').click(send); 14489 initMultiUpload(); 14490 14491 // $('head').append('<link rel="stylesheet" type="text/css" href="/typo3conf/ext/theme/Resources/Public/css/daterangepicker.css">'); 14492 // $.getScript('/typo3conf/ext/theme/Resources/Public/js/moment.js', function (){ 14493 // $.getScript('/typo3conf/ext/theme/Resources/Public/js/daterangepicker.js', function (){ 14494 14495 // var d = new Date(); 14496 // dd = d.getDate() < 10 ? '0'+d.getDate() : d.getDate(); 14497 // dm = d.getMonth() + 1 < 10 ? '0'+(d.getMonth() + 1) : d.getMonth() + 1; 14498 14499 // $('#date_fiera').daterangepicker({ 14500 // autoUpdateInput: false, 14501 // locale: { 14502 // format: 'DD.MM.YYYY', 14503 // firstDay: 1, 14504 // cancelLabel: 'Cancella', 14505 // applyLabel: 'Applica', 14506 // customRangeLabel: "Custom", 14507 // daysOfWeek: ["Do","Lu","Ma","Me","Gi","Ve", "Sa"], 14508 // monthNames: ["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"], 14509 // }, 14510 // minDate: dd+'/'+dm+'/'+d.getFullYear() 14511 // }); 14512 14513 // $('#date_fiera').on('apply.daterangepicker', function(ev, picker) { 14514 // $(this).val(picker.startDate.format('DD.MM.YYYY') + ' - ' + picker.endDate.format('DD.MM.YYYY')); 14515 // // $('.myForm').submit(); 14516 // }); 14517 14518 // $('#date_fiera').on('cancel.daterangepicker', function(ev, picker) { 14519 // $(this).val(''); 14520 // // $('.myForm').submit(); 14521 // }); 14522 // }); 14523 // }); 14524 14525 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function () { 14526 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 14527 }); 14528 14529 // // Data richiesta 14530 // var d = new Date(); 14531 // dd = d.getDate() < 10 ? '0'+d.getDate() : d.getDate(); 14532 // dm = d.getMonth() + 1 < 10 ? '0'+(d.getMonth() + 1) : d.getMonth() + 1;
14533 // $('#data_richiesta').val(dd+'.'+dm+'.'+d.getFullYear()); 14534 } 14535 function send(e) { 14536 e.preventDefault(); 14537 14538 if (!loading) { 14539 loading = true; 14540 14541 var error = false; 14542 14543 if (!checkField('#legge')) error = true; 14544 if (!error) { 14545 if (!checkField('#n_incarto')) error = true; 14546 if (!checkField('#ragione_sociale')) error = true; 14547 if (!checkField('#nome_progetto')) error = true; 14548 14549 $('#pin').siblings('.error-messages-n').addClass('hidden') 14550 if (!checkField('#pin')) error = true; 14551 else { 14552 if ($('#pin').val().length != 4) { 14553 $('#pin').siblings('.error-messages-n').removeClass('hidden') 14554 error = true 14555 } 14556 } 14557 14558 14559 if (!error) { 14560 if (!checkCaptchaField()) error = true; 14561 } 14562 14563 if (!error) { 14564 var data = new FormData(); 14565 14566 data.append('n_incarto', $('#n_incarto').val()); 14567 data.append('ragione_sociale', $('#ragione_sociale').val()); 14568 data.append('nome_progetto', $('#nome_progetto').val()); 14569 data.append('pin', $('#pin').val()); 14570 14571 for (x in uploadFile) { 14572 data.append(x, document.getElementById(x).files[0]); 14573 } 14574 14575 $('button.send-form').html('<i class="fa fa-spinner fa-spin"></i>').addClass('disabled'); 14576 $.ajax({ 14577 url: url + 'save.php', // point to server-side PHP script 14578 dataType: 'text', // what to expect back from the PHP script, if anything 14579 cache: false, 14580 contentType: false, 14581 processData: false, 14582 data: data, 14583 type: 'post', 14584 success: function (php_script_response) { 14585 if (php_script_response.split('-')[0] == 'ok') { 14586 $('form, .intro p').remove(); 14587 $('.success').removeClass('hidden'); 14588 } 14589 else { 14590 $('button.send-form').html('Invia').removeClass('disabled'); 14591 loading = false; 14592 } 14593 } 14594 }); 14595 } 14596 else { 14597 $('.error-messages:not(.hidden):first').siblings('input').focus() 14598 loading = false; 14599 } 14600 } 14601 } 14602 } 14603 // function initMultiUpload(){ 14604 // var attachments_n = 1; 14605 // var max_weight = 10; 14606 // var used_weight = 0; 14607 // var working = false; 14608 // var uploadButtonContent = ''; 14609 // function init(){ 14610 // uploadButtonContent = $('#@p .allegati .add').html(); 14611 14612 // $('#formulario_use2').on('click', '.allegati .add', addAttachemnt); 14613 // $('#formulario_use2').on('click', '.allegati .remove', clearAttachemnt); 14614 14615 // $('#formulario_use2').on('change', '.inputfile', change); 14616 // } 14617 // function addAttachemnt(e){ 14618 // e.preventDefault(); 14619 14620 // if(!working){ 14621 // $(this).siblings('.allegato.hidden.new').remove(); 14622 14623 // if($('#attachments-error').length) $('#attachments-error').remove(); 14624 14625 // $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 14626 // $('#formulario_use2 .allegato.new label').attr('for', 'file'+attachments_n); 14627 // $('#formulario_use2 .allegato.new input').attr('id', 'file'+attachments_n).attr('name', 'file'+attachments_n); 14628 14629 // $('#formulario_use2 .allegato.new input:last').trigger('click'); 14630 14631 // attachments_n++; 14632 // } 14633 // } 14634 // function clearAttachemnt(e){ 14635 // e.preventDefault(); 14636 14637 // var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 14638 // uploadFile[id] = false;
14639 14640 // var p = $(this).parents('.allegato'); 14641 // used_weight -= parseInt(p.find('input').attr('data-weight')); 14642 // // updateWeights(); 14643 14644 // p.find('input[type=file]').val(''); 14645 // p.find('input[type=file]').next().children('span').text('Allega un file'); 14646 // p.remove(); 14647 // } 14648 // function change(event){ 14649 // var id = $(this).attr('id'); 14650 14651 // tmp = $(this).val().split("\\"); 14652 // var v = tmp[tmp.length - 1]; 14653 14654 // if(v){ 14655 // tmp2 = v.split('.'); 14656 // var ext = tmp2[(tmp2.length - 1)]; 14657 14658 // if(ext == 'exe' || ext == 'bat' || ext == 'com'){ 14659 // if($('#attachments-error').length) $('#attachments-error').remove(); 14660 // $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><p style="color:#c33;position: relative; top: -10px;">Formato non consentito.</p></div>'); 14661 14662 // $('label[for='+id+'] span').text('Allega un file (10Mb massimo)'); 14663 // } 14664 // else{ 14665 // $('label[for='+id+'] span').text(v); 14666 14667 // if($('#attachments-error').length) $('#attachments-error').remove(); 14668 14669 14670 // uploadFile[id] = event.target.files; 14671 14672 // // upload(id, event.target.files); 14673 // } 14674 // } 14675 // } 14676 // function upload(x, value){ 14677 // var data = new FormData(); 14678 14679 // // if(value.length > 1){ 14680 // // var upd = {}; 14681 // // n = 1; 14682 // // console.log(value[0]);
14683 // // for(y in value){ 14684 // // upd[n] = value[y]; 14685 // // n++; 14686 // // } 14687 // // } 14688 // // else{ 14689 // var upd = { 14690 // x: value 14691 // }; 14692 // // } 14693 14694 // // console.log(upd); 14695 // // console.log(value) 14696 // // console.log(x) 14697 14698 // $('body').append('<div id="sending-form" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10002;"></div>'); 14699 // $('#formulario_use2 .allegati .add').html('<i class="fa fa-spinner fa-spin"></i>'); 14700 // working = true; 14701 14702 // for(x in upd){ 14703 // if(upd[x]){ 14704 // n = 1; 14705 // $.each(upd[x], function(key, value){ 14706 // data.append('file'+n, value); 14707 // n++; 14708 // }); 14709 // } 14710 // } 14711 14712 14713 // $.ajax({ 14714 // // url: url+'upload.php?max='+(max_weight - used_weight), // point to server-side PHP script 14715 // url: url+'upload.php', // point to server-side PHP script 14716 // dataType: 'text', // what to expect back from the PHP script, if anything 14717 // cache: false, 14718 // contentType: false, 14719 // processData: false, 14720 // data: data, 14721 // type: 'post', 14722 // success: function(php_script_response){ 14723 14724 // if(php_script_response == 'filesize'){ 14725 // if($('#attachments-error').length) $('#attachments-error').remove(); 14726 // $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>L\'allegato supera il limite consentito di 10MB.</li></ul></div>'); 14727 // } 14728 // else if(php_script_response == 'error'){ 14729 // if($('#attachments-error').length) $('#attachments-error').remove(); 14730 // $('.allegato.hidden:not(.new)').after('<div id="attachments-error"><ul style="color:#c33;position: relative; top: -10px;"><ul>Errore durante il caricamento degli allegati.</li></ul></div>'); 14731 // } 14732 // else{ 14733 // if(php_script_response.indexOf(';') > -1){ 14734 // var tmp = php_script_response.split(';'); 14735 // } 14736 // else var tmp = [php_script_response]; 14737 // // var tmp = php_script_response.split('|'); 14738 // // used_weight += parseInt(tmp[1]); 14739 14740 // $('.allegato.new.hidden input').attr('data-file', php_script_response); 14741 // // $('.allegato.new.hidden input').attr('data-weight', tmp[1]); 14742 14743 // // updateWeights() 14744 // $('.allegato.new.hidden').removeClass('new hidden'); 14745 // } 14746 14747 // $('#formulario_use2 .allegati .add').html(uploadButtonContent); 14748 // $('#sending-form').remove(); 14749 // // $('.allegati .add').removeClass('disabled'); 14750 // working = false; 14751 // } 14752 // }); 14753 // } 14754 // function updateWeights(){ 14755 // if(contactData.lang == 'en') $('.allegati h4').html('Attachments '+(used_weight)+' MB(maximum size allowed 10 MB)'); 14756 // else $('.allegati h4').html('Allegati '+(used_weight)+' MB(dimensione massima consentita 10 MB)'); 14757 14758 // if(used_weight == max_weight) $('.allegati .add').hide(); 14759 // else $('.allegati .add').show(); 14760 // } 14761 // init(); 14762 // } 14763 function initMultiUpload() { 14764 var attachments_n = 1; 14765 var max_uploads = 5; 14766 var max_weight = 10; 14767 var working = false; 14768 var uploadButtonContent = ''; 14769 function init() { 14770 uploadButtonContent = $('#formulario_use2 .allegati .add').html(); 14771 14772 $('#formulario_use2').on('click', '.allegati .add', addAttachemnt); 14773 $('#formulario_use2').on('click', '.allegati .remove', clearAttachemnt); 14774 14775 $('#formulario_use2').on('change', '.allegati .inputfile', change); 14776 } 14777 function addAttachemnt(e) { 14778 e.preventDefault(); 14779 14780 if (!working) { 14781 $(this).siblings('.allegato.hidden.new').remove(); 14782 14783 if ($('#attachments-error').length) $('#attachments-error').remove(); 14784 14785 $(this).prev().before($(this).siblings('.allegato.hidden').clone().addClass('new')); 14786 $('#formulario_use2 .allegati .allegato.new label').attr('for', 'file' + attachments_n); 14787 $('#formulario_use2 .allegati .allegato.new input').attr('id', 'file' + attachments_n).attr('name', 'file' + attachments_n); 14788 14789 $('#formulario_use2 .allegati .allegato.new input:last').trigger('click'); 14790 } 14791 } 14792 function clearAttachemnt(e) { 14793 e.preventDefault(); 14794 14795 var id = $(this).parents('.allegato').find('input[type=file]').attr('id'); 14796 uploadFile[id] = false;
14797 14798 var p = $(this).parents('.allegato'); 14799 14800 p.find('input[type=file]').val(''); 14801 p.find('input[type=file]').next().children('span').text('Allega un file'); 14802 p.remove(); 14803 14804 attachments_n--; 14805 14806 $('#formulario_use2 .allegati .add').removeClass('hidden'); 14807 } 14808 function change(event) { 14809 var id = $(this).attr('id'); 14810 14811 tmp = $(this).val().split("\\"); 14812 var v = tmp[tmp.length - 1]; 14813 14814 if (v) { 14815 tmp2 = v.split('.'); 14816 var ext = tmp2[(tmp2.length - 1)]; 14817 14818 14819 $('.allegati .error-messages, .allegati .error-messages-type, .allegati .error-messages-size').addClass('hidden'); 14820 14821 if (ext.toLowerCase() != 'pdf') { 14822 // Type error 14823 $('.allegati .error-messages-type').removeClass('hidden'); 14824 $('.allegati .allegato.new.hidden .remove').trigger('click'); 14825 } 14826 else { 14827 if (Math.round(event.target.files[0].size / 1048576) > max_weight) { 14828 // Size error 14829 $('.allegati .error-messages-size').removeClass('hidden'); 14830 $('.allegati .allegato.new.hidden .remove').trigger('click'); 14831 } 14832 else { 14833 $('label[for=' + id + '] span').text(v); 14834 14835 if ($('#attachments-error').length) $('#attachments-error').remove(); 14836 14837 uploadFile[id] = event.target.files; 14838 14839 $('.allegati .allegato.new.hidden').removeClass('new hidden'); 14840 $('#formulario_use2 .allegati .add').html(uploadButtonContent); 14841 14842 14843 attachments_n++; 14844 if (max_uploads < attachments_n) $('#formulario_use2 .allegati .add').addClass('hidden'); 14845 } 14846 } 14847 } 14848 } 14849 init(); 14850 } 14851 function changeFields() { 14852 legge = $(this).val(); 14853 14854 $('.buttons, .general, .variante').addClass('hidden') 14855 if (legge) { 14856 $('#variante_' + legge).removeClass('hidden'); 14857 $('.buttons, .general').removeClass('hidden'); 14858 // $('#legge').siblings('.error-messages').addClass('hidden'); 14859 if (legge == 'ltur') $('#special_ltur').removeClass('hidden'); 14860 else $('#special_ltur').addClass('hidden'); 14861 14862 if (legge == 'linn') $('#special_linn').removeClass('hidden'); 14863 else $('#special_linn').addClass('hidden'); 14864 14865 //dichiaro 14866 if (legge == 'linn') $('#special_dichiaro').removeClass('hidden'); 14867 else $('#special_dichiaro').addClass('hidden'); 14868 if (legge == 'lalpr') $('#special_dichiaro').removeClass('hidden'); 14869 else $('#special_dichiaro').addClass('hidden'); 14870 if (legge == 'ltur') $('#special_dichiaro').removeClass('hidden'); 14871 else $('#special_dichiaro').addClass('hidden'); 14872 14873 // if(legge == 'dlc') 14874 } 14875 } 14876 function checkFiere() { 14877 v = $(this).val(); 14878 if (v == 'Partecipazione a fiere specialistiche') $('.fiere').removeClass('hidden'); 14879 else $('.fiere').addClass('hidden'); 14880 } 14881 function checkIVA() { 14882 if ($(this).attr('id') == 'has_iva1') $('#inserire_iva').removeClass('hidden'); 14883 else $('#inserire_iva').addClass('hidden'); 14884 } 14885 function checkField(s, type) { 14886 if (typeof type == 'undefined') { 14887 if ($(s).val() == '') { 14888 $(s).siblings('.error-messages').removeClass('hidden'); 14889 return false; 14890 } 14891 else { 14892 $(s).siblings('.error-messages').addClass('hidden'); 14893 return true; 14894 } 14895 } 14896 else if (type == 'radio') { 14897 if ($(s + ':checked').length == 0) { 14898 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 14899 return false; 14900 } 14901 else { 14902 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 14903 return true; 14904 } 14905 } 14906 } 14907 function checkCaptchaField() { 14908 var field = $('input[name=captcha]'); 14909 var error = false;
14910 14911 if (field.val()) { 14912 var r = checkCaptcha(field.val()); 14913 if (r.responseText == 'ok') { 14914 field.removeClass('error'); 14915 $('.captcha .error-messages').addClass('hidden'); 14916 } 14917 else { 14918 field.addClass('error').val(''); 14919 $('.refresh-button').trigger('click'); 14920 $('.captcha .error-messages').removeClass('hidden'); 14921 error = true; 14922 } 14923 } 14924 else { 14925 field.addClass('error'); 14926 $('.refresh-button').trigger('click'); 14927 $('.captcha .error-messages').removeClass('hidden'); 14928 error = true; 14929 } 14930 14931 if (!error) return true; 14932 return false; 14933 } 14934 function checkCaptcha(value) { 14935 var rand = Math.floor((Math.random() * 100000) + 1); 14936 return $.ajax({ 14937 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?r=' + rand, 14938 data: { 14939 value: value 14940 }, 14941 async: false, 14942 method: 'post' 14943 }); 14944 } 14945 init(); 14946} 14947function initFrancoInTasca(){ 14948 14949 $("a.suggerimento").click(function() { 14950 val=$(this).attr('data-termine'); 14951 $("#q").val(val); 14952 $('#ricerca').submit(); 14953 }); 14954 14955 initAutocompleteFIT(); 14956 14957 function initAutocompleteFIT(){ 14958 function init(){ 14959 $('head').append('<link rel="stylesheet" type="text/css" href="https://www4.ti.ch/typo3conf/ext/theme/Resources/Public/css/jquery-ui.css">'); 14960 14961 if(typeof $.ui === "undefined") 14962 $.getScript('https://www4.ti.ch/typo3conf/ext/theme/Resources/Public/js/jquery-ui.js', suggest); 14963 else 14964 suggest(); 14965 14966 } 14967 function suggest() { 14968 $("#q").autocomplete({ 14969 source : function(request, response) { 14970 $.ajax({ 14971 url: "https://ricerca.ti.ch/suggest?client=francointasca&site=francointasca&max=5&format=rich", 14972 dataType: "jsonp", 14973 data : { 14974 q : request.term 14975 }, 14976 success : function(data) { 14977 response( $.map( data.results, function( item ) { 14978 return { 14979 label: item.name, 14980 value: item.name 14981 } 14982 })); 14983 } 14984 }); 14985 }, 14986 }); 14987 } 14988 init(); 14989 } 14990} 14991/* GC */ 14992function initGC() { 14993 14994 var isOut = true; 14995 var overs = {}; 14996 var url = 'https://www4.ti.ch/poteri/gc/parlamento/composizione-del-parlamento/composizione-nelle-ultime-legislature/dettaglio-deputati/?user_gcparlamento_pi3[canID]='; 14997 14998 function mouseover() { 14999 15000 var n = parseInt($(this).attr('id').substring(1)); 15001 15002 overs[n] = true; 15003 15004 if ($('.deputato.d' + n + ' img[data-src]').length) { 15005 $('.deputato.d' + n + ' img').attr('src', $('.deputato.d' + n + ' img').attr('data-src')); 15006 } 15007 15008 setTimeout(function () { 15009 if (overs[n]) { 15010 $('.deputato').removeClass('shown'); 15011 $('.deputato.d' + n).addClass('shown'); 15012 } 15013 }, 500); 15014 } 15015 function mouseout() { 15016 var n = parseInt($(this).attr('id').substring(1)); 15017 15018 setTimeout(function () { 15019 if (!overs[n]) { 15020 $('.deputato.d' + n).removeClass('shown'); 15021 } 15022 }, 1000); 15023 15024 overs[n] = false; 15025 } 15026 function click() { 15027 var n = parseInt($(this).attr('id').substring(1)); 15028 if (!isNaN($('.deputato.d' + n).attr('data-id'))) 15029 location.href = url + $('.deputato.d' + n).attr('data-id'); 15030 } 15031 15032 d3.select('svg').selectAll('circle, path, ellipse').on('mouseover', mouseover); 15033 d3.select('svg').selectAll('circle, path, ellipse').on('mouseout', mouseout); 15034 d3.select('svg').selectAll('circle, path, ellipse').on('click', click); 15035} 15036function initGCHome(){ 15037 var colors = { 15038 'lega': '#3B7947', 15039 'ps-giso-fa': '#C43A39', 15040 'plr': '#087093', 15041 'verdi': '#4AD038', 15042 'il-centro': '#EA711F', 15043 'mps': '#DDC156', 15044 'pc-pop': '#AD7832', 15045 'udc': '#A83688', 15046 'piu-donne': '#85E6E7', 15047 'avanti':'#FFCE00', 15048 'pvl-e-gvl':'#FF9FEB', 15049 'helvethica':'#2900b9' 15050 }; 15051 var url = 'https://www4.ti.ch/poteri/gc/parlamento/composizione-del-parlamento/composizione-nelle-ultime-legislature/dettaglio-deputati/?user_gcparlamento_pi3[canID]='; 15052 var isOut = true; 15053 var overs = {}; 15054 var searching = false;
15055 function init(){ 15056 initMap(); 15057 15058 $('.partiti input').click(filterMap); 15059 15060 d3.select('svg').selectAll('circle, path, ellipse').on('click', click); 15061 d3.select('svg').selectAll('circle, path, ellipse').on('mouseover', mouseover); 15062 d3.select('svg').selectAll('circle, path, ellipse').on('mouseout', mouseout); 15063 15064 $.ui.autocomplete.filter = function (array, term) { 15065 // var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(term), "i"); 15066 var matcher = new RegExp("(?:^| )"+$.ui.autocomplete.escapeRegex(term), "gi"); 15067 15068 15069 return $.grep(array, function (value) { 15070 return matcher.test(value); 15071 // return matcher.test(value.label || value.value || value); 15072 }); 15073 }; 15074 15075 $('.ricerca input[type=text]').autocomplete({ 15076 source: deputati, 15077 select: searchDeputato, 15078 position: { my: "left bottom", at: "left top", collision: "flip" } 15079 // change: searchDeputato 15080 }).keydown(function (e){ 15081 if((e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 27){ 15082 var v = $(this).val(); 15083 $('svg circle, svg path, svg ellipse').css('opacity', 1); 15084 $('.deputato.shown').removeClass('shown'); 15085 if(v != ''){ 15086 var o = $('.deputato[data-name="'+v.toLowerCase()+'"]'); 15087 if(o.length){ 15088 var posto = o.attr('data-posto'); 15089 if(posto){ 15090 $('svg circle[id!='+posto+'], svg path[id!='+posto+'], svg ellipse[id!='+posto+']').css('opacity', 0.3); 15091 15092 if ($('.deputato[data-posto=' + posto + '] img[data-src]').length) { 15093 $('.deputato[data-posto=' + posto + '] img').attr('src', $('.deputato[data-posto=' + posto + '] img').attr('data-src')); 15094 } 15095 $('.deputato.shown').removeClass('shown'); 15096 $('.deputato[data-posto=' + posto + ']').addClass('shown'); 15097 } 15098 } 15099 } 15100 } 15101 }).focus(function (){ 15102 $('.user-gcdeputazione-pi1 input[type=checkbox]').prop('disabled', true); 15103 searching = true; 15104 }).blur(function (){ 15105 if($(this).val() == ''){ 15106 15107 15108 $('.user-gcdeputazione-pi1 input[type=checkbox]').prop('disabled', false); 15109 if($('.user-gcdeputazione-pi1 input[type=checkbox]:checked').length){ 15110 $('svg circle, svg path, svg ellipse').css('opacity', 0.3); 15111 15112 $('.partiti input:checked').each(function (){ 15113 $('svg .'+$(this).val()).css('opacity', 1) 15114 }); 15115 } 15116 else{ 15117 $('svg circle, svg path, svg ellipse').css('opacity', 1); 15118 } 15119 15120 15121 // $('.user-gcdeputazione-pi1 input[type=checkbox]').prop('disabled', false); 15122 // $('svg circle, svg path, svg ellipse').css('opacity', 1); 15123 15124 // $('.partiti input:not(:checked)').each(function (){ 15125 // $('svg .'+$(this).val()).css('opacity', 0.3) 15126 // }); 15127 15128 $('.deputato.shown').removeClass('shown'); 15129 15130 searching = false; 15131 } 15132 }); 15133 15134 $('.ricerca').on('click', '.clear-field a', function (){ 15135 $('.deputato.shown').removeClass('shown'); 15136 15137 $('.user-gcdeputazione-pi1 input[type=checkbox]').prop('disabled', false); 15138 15139 if($('.user-gcdeputazione-pi1 input[type=checkbox]:checked').length){ 15140 $('svg circle, svg path, svg ellipse').css('opacity', 0.3); 15141 15142 $('.partiti input:checked').each(function (){ 15143 $('svg .'+$(this).val()).css('opacity', 1) 15144 }); 15145 } 15146 else{ 15147 $('svg circle, svg path, svg ellipse').css('opacity', 1); 15148 } 15149 15150 // $('.partiti input:not(:checked)').each(function (){ 15151 // $('svg .'+$(this).val()).css('opacity', 0.3) 15152 // }); 15153 searching = false;
15154 }) 15155 } 15156 function searchDeputato( event, ui ) { 15157 var v = (ui.item.label) ? ui.item.label : $(this).val(); 15158 $('svg circle, svg path, svg ellipse').css('opacity', 1); 15159 if(v != ''){ 15160 var o = $('.deputato[data-name="'+v.toLowerCase()+'"]'); 15161 if(o.length){ 15162 var posto = o.attr('data-posto'); 15163 if(posto){ 15164 $('svg circle[id!='+posto+'], svg path[id!='+posto+'], svg ellipse[id!='+posto+']').css('opacity', 0.3); 15165 15166 if ($('.deputato[data-posto=' + posto + '] img[data-src]').length) { 15167 $('.deputato[data-posto=' + posto + '] img').attr('src', $('.deputato[data-posto=' + posto + '] img').attr('data-src')); 15168 } 15169 $('.deputato').removeClass('shown'); 15170 $('.deputato[data-posto=' + posto + ']').addClass('shown'); 15171 } 15172 } 15173 } 15174 } 15175 function initMap(){ 15176 for(x in disposizione_deputati){ 15177 $('svg #p'+x).attr('class', disposizione_deputati[x].replace('ù','u')); 15178 } 15179 } 15180 function filterMap(){ 15181 15182 var v = $(this).val(); 15183 var active = $(this).is(':checked'); 15184 15185 if(active){ 15186 if($('.partiti input:checked').length == 1){ 15187 $('svg circle[class], svg path[class], svg ellipse[class]').css('opacity', 0.3) 15188 } 15189 $('svg .'+$(this).val()).css('opacity', 1); 15190 } 15191 else{ 15192 if($('.partiti input:checked').length == 0){ 15193 $('svg circle[class], svg path[class], svg ellipse[class]').css('opacity', 1) 15194 } 15195 else $('svg .'+$(this).val()).css('opacity', 0.3); 15196 } 15197 15198 15199 15200 // var v = $(this).val(); 15201 // var active = $(this).is(':checked'); 15202 15203 // if(active){ 15204 // $('svg .'+v).css('opacity', 1) 15205 // } 15206 // else $('svg .'+v).css('opacity', 0.3) 15207 } 15208 function click(){ 15209 var o = $('.deputato[data-posto='+$(this).attr('id')+']'); 15210 if(o.length){ 15211 if(o.attr('data-id') != '2366') 15212 location.href = url + o.attr('data-id'); 15213 } 15214 15215 } 15216 function mouseover() { 15217 if(!searching){ 15218 var id = $(this).attr('id'); 15219 15220 overs[id] = true; 15221 15222 if ($('.deputato[data-posto=' + id + '] img[data-src]').length) { 15223 $('.deputato[data-posto=' + id + '] img').attr('src', $('.deputato[data-posto=' + id + '] img').attr('data-src')); 15224 } 15225 15226 setTimeout(function () { 15227 if (overs[id]) { 15228 $('.deputato').removeClass('shown'); 15229 $('.deputato[data-posto=' + id + ']').addClass('shown'); 15230 } 15231 }, 500); 15232 } 15233 } 15234 function mouseout() { 15235 if(!searching){ 15236 var id = $(this).attr('id'); 15237 15238 setTimeout(function () { 15239 if (!overs[id]) { 15240 $('.deputato[data-posto=' + id + ']').removeClass('shown'); 15241 } 15242 }, 1000); 15243 15244 overs[id] = false; 15245 } 15246 } 15247 init(); 15248} 15249function initCacciaChart() { 15250 15251 var data = [ 15252 { "name": "Caccia alta", "start": "2024-08-31", "end": "2024-09-14", "time": "06:00 â 20:30", "color": "rgba(169, 68, 66, 0.9)" }, 15253 { "name": "Caccia alta", "start": "2024-09-20", "end": "2024-09-24", "time": "06:30 â 20:00", "color": "rgba(169, 68, 66, 0.9)" }, 15254 { "name": "Caccia estiva al cinghiale", "start": "2024-06-01", "end": "2024-06-30", "time": "04:40 â 08:00 / 19:00 â 22:30", "color": "rgba(217, 83, 79, 0.9)" }, 15255 { "name": "Caccia estiva al cinghiale", "start": "2024-07-02", "end": "2024-07-31", "time": "20:00 â 06:00", "color": "rgba(217, 83, 79, 0.9)" }, 15256 { "name": "Caccia bassa", "start": "2024-10-16", "end": "2024-10-26", "time": "08:00 â 18:30", "color": "rgba(51, 122, 183, 0.9)" }, 15257 { "name": "Caccia bassa", "start": "2024-10-27", "end": "2024-11-30", "time": "07:30 â 16:30", "color": "rgba(51, 122, 183, 0.9)" }, 15258 // Periodo unificato per la caccia invernale al cinghiale e alla volpe 15259 { 15260 "name": "Caccia invernale al cinghiale e volpe", 15261 "start": "2024-11-16", 15262 "end": "2024-12-22", 15263 "time": "07:00 â 14:00", 15264 "color": "rgba(92, 184, 92, 0.9)" 15265 }, 15266 { 15267 "name": "Caccia invernale al cinghiale e volpe", 15268 "start": "2025-01-04", 15269 "end": "2025-01-22", 15270 "time": "07:00 â 16:30", 15271 "color": "rgba(92, 184, 92, 0.9)" 15272 }, 15273 { "name": "Caccia acquatica", "start": "2024-12-15", "end": "2025-01-31", "time": "07:00 â 11:00 / 15:30 â 17:30", "color": "rgba(240, 173, 78, 0.9)" }, 15274 { "name": "Caccia tardo autunnale", "start": "2024-11-16", "end": "2024-12-22", "time": "07:00 â 14:00", "color": "rgba(91, 192, 222, 0.9)" }, 15275 { "name": "Caccia speciale allo stambecco", "start": "2024-10-01", "end": "2024-10-15", "time": "07:30 â 18:00", "color": "rgba(138, 109, 59, 0.9)" } 15276 ]; 15277 15278 var localeIT = d3.timeFormatLocale({ 15279 "dateTime": "%A, %e %B %Y %X", 15280 "date": "%d/%m/%Y", 15281 "time": "%H:%M:%S", 15282 "periods": ["AM", "PM"], 15283 "days": ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"], 15284 "shortDays": ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"], 15285 "months": ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], 15286 "shortMonths": ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"] 15287 }); 15288 15289 // Raggruppa i dati per nome 15290 var groupedData = d3.group(data, d => d.name); 15291 15292 var formatDate = localeIT.format("%d %B"); 15293 15294 var width = 900; 15295 var height = 300; 15296 var margin = { top: 60, right: 20, bottom: 20, left: 250 }; 15297 15298 var svg = d3.select("#chart_dt_caccia").append("svg") 15299 .attr("width", width + margin.left + margin.right) 15300 .attr("height", height + margin.top + margin.bottom) 15301 .attr("id", "svgRoot") 15302 .append("g") 15303 .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); 15304 15305 var minDate = new Date(2024, 5, 1); 15306 var maxDate = new Date(2025, 1, 15); 15307 15308 var x = d3.scaleTime() 15309 .domain([minDate, maxDate]) 15310 .range([0, width]); 15311 15312 var y = d3.scaleBand() 15313 .domain([...new Set(data.map(d => d.name))]) 15314 .range([0, height]) 15315 .padding(0.3); 15316 15317 var xAxis = svg.append("g") 15318 .attr("class", "x-axis") 15319 .attr("transform", "translate(0,-20)"); 15320 15321 var yAxis = svg.append("g") 15322 .attr("class", "y-axis") 15323 .call(d3.axisLeft(y).tickSize(0)) 15324 .selectAll("text") 15325 .style("font-size", "13px") 15326 .style("font-weight", "bold") 15327 .attr("x", -20) 15328 .style("text-anchor", "end") 15329 .each(function (d) { 15330 var text = d3.select(this); 15331 var periods = groupedData.get(d); 15332 15333 text.text(null) 15334 .append("tspan") 15335 .text(d) 15336 .attr("y", "0em") 15337 .attr("x", -22); 15338 15339 text.append("tspan") 15340 .attr("class", "fa") 15341 .attr("y", "0.4em") 15342 .attr("x", "-5") 15343 .attr("font-size", "13px") 15344 .attr("fill", "rgb(0, 102, 204)") 15345 .attr("font-weight", "bold") 15346 .style("cursor", "pointer") 15347 .html("") 15348 .on("mouseover", function (event) { 15349 var tooltipContent = `<strong>${d}</strong>`; 15350 periods.forEach(function (p) { 15351 var timeInfo = ""; 15352 if (d === "Caccia alta") { 15353 if (p.start === "2024-08-31" && p.end === "2024-09-14") { 15354 timeInfo = " (sopra i 400 mslm 06:00 â 20:30 / sotto i 400 mslm 06:00 â 10:00 e 16:30 â 20:30)"; 15355 } else if (p.start === "2024-09-20" && p.end === "2024-09-24") { 15356 timeInfo = " (sopra i 400 mslm 06:30 â 20:00 / sotto i 400 mslm 06:30 â 10:00 e 16:30 â 20:00)"; 15357 } 15358 } else if (d === "Caccia bassa") { 15359 if (p.start === "2024-10-16" && p.end === "2024-10-26") { 15360 timeInfo = " (08:00 â 18:30), nei giorni di martedì, mercoledì, giovedì, sabato e domenica"; 15361 } else if (p.start === "2024-10-27" && p.end === "2024-11-30") { 15362 timeInfo = " (07:30 â 16:30), nei giorni di martedì, mercoledì, giovedì, sabato e domenica"; 15363 } 15364 } else if (d === "Caccia invernale al cinghiale e volpe") { 15365 // Raggruppa le date per anni nel tooltip 15366 if (p.start.includes("2024")) { 15367 timeInfo = ` (07:00 â 14:00) nei giorni di mercoledì, sabato e domenica`; 15368 } else if (p.start.includes("2025")) { 15369 timeInfo = ` (07:00 â 16:30) nei giorni di mercoledì, sabato e domenica`; 15370 } 15371 } else if (d === "Caccia acquatica") { 15372 timeInfo = " (07:00 â 11:00 / 15:30 â 17:30), ad eccezione del lunedì, mercoledì, 25.12 e 26.12, 01.01.2025 e 06.01.2025"; 15373 } else if (d === "Caccia tardo autunnale") { 15374 timeInfo = " (07:00 â 14:00), nei giorni di sabato, domenica e mercoledì"; 15375 } else if (d === "Caccia speciale allo stambecco") { 15376 timeInfo = " (07:30 â 18:00)"; 15377 } else if (d === "Caccia estiva al cinghiale") { 15378 if (p.start === "2024-06-01" && p.end === "2024-06-30") { 15379 timeInfo = " (04:40 â 08:00 / 19:00 â 22:30), nei giorni di mercoledì, venerdì, sabato e domenica"; 15380 } else if (p.start === "2024-07-02" && p.end === "2024-07-31") { 15381 timeInfo = " (20:00 â 06:00), tutti i giorni "; 15382 } 15383 } 15384 15385 tooltipContent += `<br>${formatDate(new Date(p.start))} - ${formatDate(new Date(p.end))} ${timeInfo}`; 15386 }); 15387 15388 tooltip.style("display", "block") 15389 .html(tooltipContent) 15390 .style("top", (event.pageY + 10) + "px") 15391 .style("left", (event.pageX + 10) + "px"); 15392 }) 15393 .on("mouseout", function () { 15394 tooltip.style("display", "none"); 15395 }); 15396 }); 15397 15398 var tooltip = d3.select("body").append("div") 15399 .attr("id", "tooltip") 15400 .style("position", "absolute") 15401 .style("background", "white") 15402 .style("border", "1px solid rgba(0, 0, 0, 0.1)") 15403 .style("border-radius", "8px") 15404 .style("padding", "10px") 15405 .style("box-shadow", "0 4px 8px rgba(0, 0, 0, 0.1)") 15406 .style("display", "none") 15407 .style("pointer-events", "none"); 15408 15409 yAxis.select(function () { return this.parentNode; }) 15410 .selectAll("g.tick") 15411 .append("text") 15412 .attr("x", -10) 15413 .attr("y", y.bandwidth() / 2) 15414 .attr("dy", ".35em") 15415 .attr("font-size", "13px") 15416 .attr("fill", "blue") 15417 .style("cursor", "pointer") 15418 .text("X") 15419 .on("mouseover", function (event, d) { 15420 var datum = data.find(item => item.name === d); 15421 tooltip.style("display", "block") 15422 .html(`<strong>${datum.name}</strong><br>Inizio: ${formatDate(new Date(datum.start))}<br>Fine: ${formatDate(new Date(datum.end))}`) 15423 .style("top", (event.pageY + 10) + "px") 15424 .style("left", (event.pageX + 10) + "px"); 15425 }) 15426 .on("mouseout", function () { 15427 tooltip.style("display", "none"); 15428 }); 15429 15430 svg.append("g") 15431 .attr("class", "grid") 15432 .call(d3.axisLeft(y) 15433 .tickSize(-width) 15434 .tickFormat('') 15435 ) 15436 .selectAll("line") 15437 .style("stroke", "#ddd") 15438 .style("stroke-dasharray", "2,2"); 15439 15440 var bars = svg.selectAll(".bar") 15441 .data(data) 15442 .enter().append("rect") 15443 .attr("class", "bar") 15444 .attr("x", d => x(new Date(d.start))) 15445 .attr("y", d => y(d.name) + (y.bandwidth() / 2) - (y.bandwidth() * 0.3 / 2) - 3) 15446 .attr("width", d => x(new Date(d.end)) - x(new Date(d.start))) 15447 .attr("height", y.bandwidth() * 0.2 - 3) 15448 .attr("fill", d => d.color); 15449 15450 var today = new Date(); 15451 var todayDateFormatted = formatDate(today); 15452 15453 var verticalLine = svg.append("line") 15454 .attr("x1", x(today)) 15455 .attr("x2", x(today)) 15456 .attr("y1", 0) 15457 .attr("y2", height) 15458 .attr("stroke", "black") 15459 .attr("stroke-width", 1) 15460 .style("visibility", "hidden"); 15461 15462 var dateTooltip = svg.append("text") 15463 .attr("x", x(today) + 5) 15464 .attr("y", -5) 15465 .attr("class", "tooltip-date") 15466 .text(todayDateFormatted) 15467 .style("font-weight", "bold") 15468 .style("font-size", "12px") 15469 .attr("fill", "black") 15470 .style("visibility", "hidden"); 15471 15472 svg.append("rect") 15473 .attr("class", "overlay") 15474 .attr("x", 0) 15475 .attr("y", 0) 15476 .attr("width", width) 15477 .attr("height", height) 15478 .attr("fill", "none") 15479 .attr("pointer-events", "all") 15480 .on("mousemove", function (event) { 15481 var mouseX = d3.pointer(event)[0]; 15482 var dateAtMouseX = x.invert(mouseX); 15483 var dateFormatted = formatDate(dateAtMouseX); 15484 15485 verticalLine 15486 .attr("x1", mouseX) 15487 .attr("x2", mouseX) 15488 .style("visibility", "visible"); 15489 15490 dateTooltip 15491 .attr("x", mouseX + 5) 15492 .style("visibility", "visible") 15493 .text(dateFormatted); 15494 }) 15495 .on("mouseout", function () { 15496 verticalLine.style("visibility", "hidden"); 15497 dateTooltip.style("visibility", "hidden"); 15498 }); 15499 15500 function updateChart(sliderValue) { 15501 var zoomFactor = sliderValue; 15502 15503 var newDomainStart = new Date(minDate.getTime() - zoomFactor * 24 * 60 * 60 * 1000); 15504 var newDomainEnd = new Date(maxDate.getTime() + zoomFactor * 24 * 60 * 60 * 1000); 15505 15506 newDomainStart = newDomainStart < minDate ? minDate : newDomainStart; 15507 15508 x.domain([newDomainStart, newDomainEnd]); 15509 15510 var numTicks = Math.floor((newDomainEnd - newDomainStart) / (1000 * 60 * 60 * 24 * 30)); 15511
15512 xAxis.call(d3.axisTop(x).ticks(numTicks).tickFormat(function (d) { 15513 if ((newDomainEnd - newDomainStart) <= (1000 * 60 * 60 * 24 * 30)) { 15514 return localeIT.format("%d %b %Y")(d); 15515 } else { 15516 return localeIT.format("%b %Y")(d); 15517 } 15518 })) 15519 .selectAll("text") 15520 .style("font-size", "12px") 15521 .style("font-weight", "bold"); 15522 15523 bars.attr("x", d => x(new Date(d.start))) 15524 .attr("width", d => x(new Date(d.end)) - x(new Date(d.start))); 15525 verticalLine.attr("x1", x(today)).attr("x2", x(today)); 15526 dateTooltip.attr("x", x(today) + 15).attr("y", -5).text(todayDateFormatted).style("font-weight", "bold"); 15527 } 15528 15529 d3.select("#slider").on("input", function () { 15530 var sliderValue = +this.value; 15531 updateChart(sliderValue); 15532 }); 15533 15534 updateChart(0); 15535 15536 function wrap(text, width) { 15537 text.each(function () { 15538 var text = d3.select(this), 15539 words = text.text().split(/\s+/).reverse(), 15540 word, 15541 line = [], 15542 lineNumber = 0, 15543 lineHeight = 1.1, 15544 y = text.attr("y"), 15545 dy = parseFloat(text.attr("dy")), 15546 tspan = text.text(null).append("tspan").attr("x", 0).attr("y", y).attr("dy", dy + "em"); 15547 15548 while (word = words.pop()) { 15549 line.push(word); 15550 tspan.text(line.join(" ")); 15551 if (tspan.node().getComputedTextLength() > width) { 15552 line.pop(); 15553 tspan.text(line.join(" ")); 15554 line = [word]; 15555 tspan = text.append("tspan").attr("x", 0).attr("y", y).attr("dy", ++lineNumber * lineHeight + dy + "em").text(word); 15556 } 15557 } 15558 }); 15559 } 15560 15561 svg.append("line") 15562 .attr("x1", width) 15563 .attr("x2", width) 15564 .attr("y1", 0) 15565 .attr("y2", height) 15566 .attr("stroke", "black") 15567 .attr("stroke-width", 1); 15568 15569 d3.select("#chart_dt_caccia").style("overflow-x", "auto"); 15570 15571 d3.selectAll('svg .bar').each(function (d, index) { 15572 var tooltipText = svg.append("text") 15573 .attr("fill", "black") 15574 .attr("font-size", "16") 15575 .attr("visibility", "hidden") 15576 .text(`Tooltip ${index + 1}`); 15577 15578 d3.select(this) 15579 .on("mousemove", function (event) { 15580 var mouseX = d3.pointer(event)[0]; 15581 var mouseY = d3.pointer(event)[1]; 15582 15583 tooltipText 15584 .attr("x", mouseX + 10) 15585 .attr("y", mouseY + 10) 15586 .attr("visibility", "visible"); 15587 }) 15588 .on("mouseout", function () { 15589 tooltipText.attr("visibility", "hidden"); 15590 }); 15591 }); 15592 15593} 15594 15595 15596function initIASAssegniParentali() { 15597 var code = '1592' 15598 function init() { 15599 $('.checkCode').click(checkCode) 15600 15601 } 15602 function checkCode(e) { 15603 e.preventDefault() 15604 15605 if ($('#codice').val() == code) initIASAssegniParentaliQuestions() 15606 else $('.error-messages').removeClass('hidden') 15607 } 15608 init(); 15609} 15610 15611function initIASAssegniParentaliQuestions() { 15612 var questions = { 15613 0: '<span class="a hidden">Il richiedente è soggetto a tassazione</span><span class="b hidden">Il richiedente e/o lâaltro genitore sono soggetti a tassazione</span>?', 15614 1: 'Il richiedente è salariato?', 15615 2: 'Lâaltro genitore è salariato?', 15616 3: '<span class="a hidden">Il richiedente è indipendente</span><span class="b hidden">Il richiedente e/o lâaltro genitore è/sono indipendente/i</span>?',
15617 4: 'Il richiedente è beneficiario di rendita (AVS-AI-LPP-Estera)?', 15618 5: 'Lâaltro genitore è beneficiario di rendita (AVS-AI-LPP-Estera)?', 15619 6: 'Il richiedente è beneficiario d\'indennità (disoccupazione â IPG - maternità â infortunio â malattia)?', 15620 7: 'Lâaltro genitore è beneficiario d\'indennità (disoccupazione â IPG - maternità â infortunio â malattia)?', 15621 8: 'Il richiedente è proprietario di sostanza immobiliare nel Canton Ticino?', 15622 9: 'Lâaltro genitore è proprietario di sostanza immobiliare nel Canton Ticino?', 15623 10: 'Il richiedente è proprietario di sostanza immobiliare in altri Cantoni e/o allâestero?', 15624 11: 'Lâaltro genitore è proprietario di sostanza immobiliare in altri Cantoni e/o allâestero?', 15625 12: 'Il richiedente è titolare di debito (ipotecario â privato)?', 15626 13: 'Lâaltro genitore è titolare di debito (ipotecario â privato)?' 15627 } 15628 //in caso di risposta negativa alla prima domanda 15629 var questions1 = { 15630 0: 'Il richiedente è soggetto a tassazione', 15631 1: 'Il richiedente è salariato?', 15632 3: 'Il richiedente è indipendente?',
15633 4: 'Il richiedente è beneficiario di rendita (AVS-AI-LPP-Estera)?', 15634 6: 'Il richiedente è beneficiario d\'indennità (disoccupazione â IPG - maternità â infortunio â malattia)?', 15635 8: 'Il richiedente è proprietario di sostanza immobiliare nel Canton Ticino?', 15636 10: 'Il richiedente è proprietario di sostanza immobiliare in altri Cantoni e/o allâestero?', 15637 12: 'Il richiedente è titolare di debito (ipotecario â privato)?' 15638 } 15639 var documents = { 15640 0: 'Ultima decisione di tassazione cresciuta in giudicato', 15641 1: 'Conteggio stipendio del mese di XX', 15642 2: 'Conteggio stipendio dellâaltro genitore del mese di XX', 15643 3: 'Formulario «Dichiarazione dei dati relativi al/ai reddito/i da attività indipendente» da scaricare dal sito internet e compilare', 15644 4: 'Ultima decisione di rendita (AVS-AI-LPP-Estera)', 15645 5: 'Ultima decisione di rendita dellâaltro genitore (AVS-AI-LPP-Estera) ', 15646 6: 'Conteggio dell\'indennità (disoccupazione - IPG - maternità - infortunio - malattia) del mese di XX', 15647 7: 'Conteggio dell\'indennità dell\'altro genitore (disoccupazione - IPG - maternità - infortunio - malattia) del mese di XX', 15648 // 8: 'La risposta dovrà figurare nel riassunto', 15649 // 9: 'La risposta dovrà figurare nel riassunto', 15650 10: 'Copia dei documenti ufficiali attestanti il valore di stima della sostanza in altri Cantoni e/o all\'estero', 15651 11: 'Copia dei documenti ufficiali dell\'altro genitore attestanti il valore di stima della sostanza in altri Cantoni e/o all\'estero', 15652 12: 'Estratto di tutti i debiti bancari/postali: saldo al mese di XX (all\'ultimo giorno del mese)', 15653 13: 'Estratto di tutti i debiti bancari/postali intestati all\'altro genitore: saldo al mese di XX (all\'ultimo giorno del mese)' 15654 } 15655 var months = [ 15656 'gennaio', 15657 'febbraio', 15658 'marzo', 15659 'aprile', 15660 'maggio', 15661 'giugno', 15662 'luglio', 15663 'agosto', 15664 'settembre', 15665 'ottobre', 15666 'novembre', 15667 'dicembre' 15668 ] 15669 var questions_n = 14 15670 var questionTpl = '<div class="question hidden" data-n="::n::"><h2>::title::</h2><label><input type="radio" value="1" name="question::n::"> Si</label><label><input type="radio" value="0" name="question::n::"> No</label><div class="error-messages hidden">Compila il campo</div></div>' 15671 var loading = false 15672 var url = 'fileadmin/DSS/IAS/formulario_assegni_parentali/' 15673 function init() { 15674 generate() 15675 $('#assegni_parentali .question input').click(answered) 15676 $('#assegni_parentali input[name=pre-question]').click(preQuestionAnswered) 15677 $('#assegni_parentali .send').click(send) 15678 } 15679 function generate() { 15680 $('#assegni_parentali').html('') 15681 15682 var pre_question = '<div class="question"><h2>I genitori del figlio per il quale si sta richiedendo lâAP sono una coppia</h2><label><input type="radio" value="1" name="pre-question"> Si</label><label><input type="radio" value="0" name="pre-question"> No</label></div>' 15683 $('#assegni_parentali').append(pre_question) 15684 15685 $('#assegni_parentali').append('<div class="pre-form hidden">' + $('div.form-part').html() + '</div>') 15686 15687 var html = '' 15688 for (x = 1; x <= 31; x++) html += '<option value="' + x + '">' + ('0' + x).substr('-2') + '</option>' 15689 $('#nascita_g').html(html) 15690 var html = '' 15691 for (x = 1; x <= 12; x++) html += '<option value="' + x + '">' + ('0' + x).substr('-2') + '</option>' 15692 $('#nascita_m').html(html) 15693 var html = '' 15694 for (x = 2020; x <= moment().year(); x++) html += '<option value="' + x + '">' + x + '</option>' 15695 $('#nascita_a').html(html) 15696 15697 15698 for (x in questions) { 15699 var html = questionTpl.replace('::title::', questions[x]).replace(/\:\:n\:\:/g, x) 15700 $('#assegni_parentali').append(html); 15701 } 15702 $('#assegni_parentali').append('<button class="btn btn-primary send hidden">Invia</button>'); 15703 } 15704 function preQuestionAnswered() { 15705 if ($(this).val() == 1) { 15706 $('.altro').removeClass('hidden') 15707 15708 if ($('.question:not(.hidden):last').data('n') > 13) $('.question[data-n=00], .question[data-n=2], .question[data-n=5], .question[data-n=7], .question[data-n=9], .question[data-n=11], .question[data-n=13]').removeClass('hidden') 15709 else if ($('.question:not(.hidden):last').data('n') > 11) $('.question[data-n=00], .question[data-n=2], .question[data-n=5], .question[data-n=7], .question[data-n=9], .question[data-n=11]').removeClass('hidden') 15710 else if ($('.question:not(.hidden):last').data('n') > 9) $('.question[data-n=00], .question[data-n=2], .question[data-n=5], .question[data-n=7], .question[data-n=9]').removeClass('hidden') 15711 else if ($('.question:not(.hidden):last').data('n') > 7) $('.question[data-n=00], .question[data-n=2], .question[data-n=5], .question[data-n=7]').removeClass('hidden') 15712 else if ($('.question:not(.hidden):last').data('n') > 5) $('.question[data-n=00], .question[data-n=2], .question[data-n=5]').removeClass('hidden') 15713 else if ($('.question:not(.hidden):last').data('n') > 2) $('.question[data-n=00], .question[data-n=2]').removeClass('hidden') 15714 15715 $('.question .a').addClass('hidden') 15716 $('.question .b').removeClass('hidden') 15717 } 15718 else { 15719 $('.altro').addClass('hidden') 15720 $('.question[data-n=2], .question[data-n=5], .question[data-n=7], .question[data-n=9], .question[data-n=11], .question[data-n=13]').addClass('hidden') 15721 15722 $('.question .b').addClass('hidden') 15723 $('.question .a').removeClass('hidden') 15724 } 15725 15726 if ($('#assegni_parentali .pre-form').hasClass('hidden')) { 15727 $('#assegni_parentali .pre-form').removeClass('hidden') 15728 15729 showQuestion(0) 15730 } 15731 } 15732 function answered() { 15733 var n = parseInt($(this).parents('.question').data('n')) 15734 15735 $(this).parent().siblings('.error-messages').addClass('hidden'); 15736 15737 if ((n == 1 || n == 4 || n == 6 || n == 8 || n == 10 || n == 12) && $('input[name=pre-question]:checked').val() == 0) { 15738 n += 2 15739 } 15740 else { 15741 n++ 15742 } 15743 15744 if (n >= questions_n) showEndButton() 15745 else showQuestion(n) 15746 } 15747 function showQuestion(n) { 15748 $('.question[data-n=' + n + ']').removeClass('hidden') 15749 } 15750 function hideQuestion(n) { 15751 $('.question[data-n=' + n + ']').addClass('hidden') 15752 } 15753 function showEndButton() { 15754 $('button.send').removeClass('hidden') 15755 } 15756 function send(e) { 15757 e.preventDefault() 15758 15759 if (!loading) { 15760 loading = true; 15761 15762 var error = false;
15763 15764 if (!checkField('#richiedente')) error = true; 15765 if ($('input[name=pre-question]:checked').val() == '1') { 15766 if (!checkField('#altro_genitore')) error = true; 15767 } 15768 if (!checkField('#figlio')) error = true; 15769 15770 if (!checkField('#email', 'email')) error = true; 15771 15772 15773 $('.question:not(.hidden)').each(function () { 15774 if (!$(this).find('input:checked').length) $(this).children('.error-messages').removeClass('hidden'); 15775 }) 15776 15777 15778 if (!error) { 15779 var data = { 15780 q: [] 15781 } 15782 15783 data.richiedente = $('#richiedente').val() 15784 if ($('input[name=pre-question]:checked').val() == '1') data.altro_genitore = $('#altro_genitore').val() 15785 data.figlio = $('#figlio').val() 15786 data.nascita = ('0' + $('#nascita_g').val()).substr('-2') + '/' + ('0' + $('#nascita_m').val()).substr('-2') + '/' + $('#nascita_a').val() 15787 data.email = $('#email').val() 15788 15789 data.pre_question = $('input[name=pre-question]:checked').val() 15790 15791 // Questions 15792 $('.question:not(.hidden):not(:first)').each(function () { 15793 data.q.push($(this).data('n')) 15794 data[$(this).data('n')] = $(this).find('input:checked').val() 15795 }) 15796 15797 // Documents 15798 var tmp = data.nascita.split('/') 15799 var birthday = moment(tmp[1] + '/' + tmp[0] + '/' + tmp[2]).add(6, 'months'); 15800 data.documents = [ 15801 'Estratto di tutti i conti bancari/postali: saldo al mese di ' + months[birthday.month()] + ' ' + birthday.year() + ' (allâultimo giorno del mese)', 15802 'Formulario «Procura, compensazione e restituzione» da scaricare dal sito internet e compilare' 15803 ] 15804 15805 $('.question:not(.hidden):not(:first)').each(function () { 15806 if (documents[$(this).data('n')] && $(this).find('input:checked').val() == '1') { 15807 data.documents.push(documents[$(this).data('n')].replace('XX', months[birthday.month()] + ' ' + birthday.year())) 15808 } 15809 }) 15810 15811 $.post(url + 'save.php', data, function (r) { 15812 $('.btn-primary.send').remove() 15813 15814 $('#assegni_parentali').html('<p>Grazie per aver risposto alle domande inerenti la sua situazione personale. Consulti la sua casella e-mail dove troverà una comunicazione con la documentazione da trasmetterci.<br>Cordiali saluti.</p>') 15815 15816 $('html, body').animate({ scrollTop: 0 }, 500) 15817 }) 15818 } 15819 else { 15820 $('body, html').animate({ scrollTop: $('.error-messages:not(.hidden):first').offset().top - 100 }, 200) 15821 loading = false 15822 } 15823 } 15824 } 15825 function checkField(s, type) { 15826 if (typeof type == 'undefined') { 15827 if ($(s).val() == '') { 15828 $(s).siblings('.error-messages').removeClass('hidden'); 15829 return false; 15830 } 15831 else { 15832 $(s).siblings('.error-messages').addClass('hidden'); 15833 return true; 15834 } 15835 } 15836 else if (type == 'radio' || type == 'checkbox') { 15837 if ($(s + ':checked').length == 0) { 15838 $(s + ':first').parent().parent().siblings('.error-messages').removeClass('hidden'); 15839 return false; 15840 } 15841 else { 15842 $(s + ':first').parent().parent().siblings('.error-messages').addClass('hidden'); 15843 return true; 15844 } 15845 } 15846 else if (type == 'email') { 15847 if ($(s).val() == '' || !checkEmail($(s).val())) { 15848 $(s).siblings('.error-messages').removeClass('hidden'); 15849 return false; 15850 } 15851 else { 15852 $(s).siblings('.error-messages').addClass('hidden'); 15853 return true; 15854 } 15855 } 15856 else if (type == 'date') { 15857 if ($(s).val() == '' || !checkDate($(s).val())) { 15858 $(s).siblings('.error-messages').removeClass('hidden'); 15859 return false;
15860 } 15861 else { 15862 $(s).siblings('.error-messages').addClass('hidden'); 15863 return true; 15864 } 15865 } 15866 } 15867 function checkEmail(email) { 15868 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,}))$/; 15869 return re.test(String(email).toLowerCase()); 15870 } 15871 init() 15872} 15873function initIAS(){ 15874 var prefooter_timer; 15875 var background_height; 15876 var contenitore_height 15877 function init(){ 15878 $('.privati-list a').click(showMenuItems); 15879 if($('.ias.home').length){ 15880 $('.home .image').addClass('i'+Math.ceil(Math.random() * 3)); 15881 } 15882 else if($('.ias .privati-list').length){ 15883 $('.privati-list a').attr('aria-expanded', false); 15884 if(location.hash){ 15885 hash = location.hash.substring(1); 15886 $("html, body").animate({ scrollTop: $('.privati-list').offset().top }); 15887 $('[data-id="'+hash+'"]').trigger('click'); 15888 } 15889 } 15890 15891 // Prefooter position 15892 background_height = $('.background').outerHeight(); 15893 contenitore_height = $('body').outerHeight(); 15894 prefooterPosition(); 15895 $(window).resize(function (){ 15896 if(prefooter_timer) clearTimeout(prefooter_timer); 15897 prefooter_timer = setTimeout(prefooterPosition, 200); 15898 }); 15899 } 15900 function prefooterPosition(){ 15901 if(windowHeight() > background_height){ 15902 $('#contenitore').css('min-height', windowHeight() - $('footer').outerHeight() - $('header').outerHeight() - $('#box-top').outerHeight() - $('.prefooter').outerHeight() - 60 - 76); 15903 } 15904 } 15905 function showMenuItems(e){ 15906 e.preventDefault(); 15907 15908 if(!$(this).parent().hasClass('selected')){ 15909 $('.right-menu > div').addClass('hidden'); 15910 $('.right-menu > div:eq('+$(this).parent().index()+')').removeClass('hidden'); 15911 15912 $('.privati-list .selected').children().attr('aria-expanded', false); 15913 $('.privati-list .selected').removeClass('selected'); 15914 $(this).parent().addClass('selected'); 15915 $(this).attr('aria-expanded', true); 15916 15917 // $('.privati-list').animate({ width: '300px' }, 500); 15918 $('.in').addClass('opened'); 15919 } 15920 } 15921 init(); 15922 15923 15924 $(".dropdownPrestazioni li a").click(function() { 15925 val=$(this).attr('data-valore'); 15926 $("#idPrestazione").val(val); 15927 $("#idCategoria").val(''); 15928 $('#ricerca').submit(); 15929 15930 }); 15931 15932 $(".dropdownTematiche li a").click(function() { 15933 val=$(this).attr('data-valore'); 15934 $("#idCategoria").val(val); 15935 $("#idPrestazione").val(''); 15936 $('#ricerca').submit(); 15937 15938 }); 15939 15940 15941 $("a.suggerimento").click(function(e) { 15942 e.preventDefault(); 15943 val=$(this).attr('data-termine'); 15944 $("#q").val(val); 15945 $('#ricerca').submit(); 15946 }); 15947 15948 $("a.prestazione").click(function(e) { 15949 e.stopPropagation(); 15950 e.preventDefault(); 15951 15952 val=$(this).attr('data-valore'); 15953 url=$(this).attr('data-url'); 15954 15955 15956 var inputs = '<input type="hidden" name="Prestazione" value="'+val+'" />'; 15957 15958 $("body").append('<form action="'+url+'" method="post" id="poster">'+inputs+'</form>'); 15959 $("#poster").submit(); 15960 }); 15961 15962 initAutocompleteIAS(); 15963 15964 function initAutocompleteIAS(){ 15965 function init(){ 15966 $('head').append('<link rel="stylesheet" type="text/css" href="https://www4.ti.ch/typo3conf/ext/theme/Resources/Public/css/jquery-ui.css">'); 15967 15968 if(typeof $.ui === "undefined") 15969 $.getScript('https://www4.ti.ch/typo3conf/ext/theme/Resources/Public/js/jquery-ui.js', suggest); 15970 else 15971 suggest(); 15972 15973 } 15974 function suggest(){ 15975 $("#q").autocomplete({ 15976 source : function(request, response) { 15977 $.ajax({ 15978 url: "https://ricerca.ti.ch/suggest?client=IAS&site=IAS_schede&max=5&format=rich", 15979 dataType: "jsonp", 15980 data : { 15981 q : request.term 15982 }, 15983 success : function(data) { 15984 response( $.map( data.results, function( item ) { 15985 return { 15986 label: item.name, 15987 value: item.name 15988 } 15989 })); 15990 } 15991 }); 15992 }, 15993 }); 15994 } 15995 init(); 15996 } 15997} 15998 15999function initImpiantiSportivi() 16000{ 16001 16002 16003 $(".dropdown-menu").keyup(function(e) { 16004 if (e.keyCode == 27) { 16005 $(".input-group-btn").removeClass("open"); 16006 $(".dropdownRegione").removeClass("open"); 16007 $(".dropdownComune").removeClass("open"); 16008 $(".dropdownDisciplina").removeClass("open"); 16009 $(".dropdownGruppo").removeClass("open"); 16010 } 16011 }); 16012 16013 16014 $('.formRicerca2 select').change(function (){ 16015 $('#ricerca').submit(); 16016 }); 16017 16018 $('.ricercaImpianti select').change(function (){ 16019 $('#ricerca').submit(); 16020 }); 16021 16022 16023 /*$(".formRicerca1 li a").click(function() { 16024 val=$(this).attr('data-valore'); 16025 //$("#idDistretto").val(val); 16026 $("#idComune").val(''); 16027 $('#ricerca').submit(); 16028 16029 });*/ 16030 16031 /*$(".ricercaImpianti li a").click(function() { 16032 16033 val=$(this).attr('data-valore'); 16034 //$("#idDistretto").val(val); 16035 $('.ricercaImpianti').submit(); 16036 16037 });*/ 16038 16039 16040 16041 $('#showMore').click(showMore); 16042 16043 function showMore(){ 16044 16045 //controllo se last>tot 16046 var tot=$('#showMore').attr('data-tot'); 16047 16048 var last_id = $(".impianto:last").attr("id"); 16049 last_id=last_id.split('-'); 16050 var last=parseInt(last_id[1])+1; 16051 last_id[1]=parseInt(last_id[1])+1+25; 16052 16053 16054 if(last >= tot) 16055 { 16056 $('.moreResults').hide(); 16057 } 16058 else 16059 { 16060 //aggiungere a URL ultimo elemento caricato in modo da passarlo al dettaglio 16061 var url=document.location.href; 16062 if(url.indexOf('&last=') !== -1) 16063 { 16064 var last=getParametroURL('last'); 16065 url=url.replace('&last='+last,'&last='+last_id[1]); 16066 } 16067 else 16068 {
16069 url = url+"&last="+last_id[1]; 16070 } 16071 16072 window.history.replaceState(null, null, url); 16073 16074 var comune=getParametroURL('comune'); 16075 var disciplina=getParametroURL('disciplina'); 16076 var parola=getParametroURL('parola'); 16077 //var distretto=getParametroURL('distretto'); 16078 var regione=getParametroURL('regione'); 16079 var gruppo=getParametroURL('gruppo'); 16080 16081 var ordinamento=$('#showMore').attr('data-ordine'); 16082 var direzione=$('#showMore').attr('data-direzione'); 16083 16084 16085 $.ajax( 16086 { 16087 url: '/user_librerie/php/DECS/impiantiSportivi/loadMoreData.php?start='+last_id[1]+'&comune='+comune+'&disciplina='+disciplina+'&parola='+parola+'®ione='+regione+'&gruppo='+gruppo+'&ordinamento='+ordinamento+'&direzione='+direzione, 16088 type: "get", 16089 beforeSend: function() 16090 { 16091 $('.ajax-load').show(); 16092 } 16093 }) 16094 .done(function(data) 16095 { 16096 $('.ajax-load').hide(); 16097 $("#post-data").before(data); 16098 16099 var ultimo = $(".impianto:last").attr("id"); 16100 ultimo=ultimo.split('-'); 16101 ultimo=parseInt(ultimo[1])+1; 16102 if(ultimo >= tot) 16103 { 16104 $('.moreResults').hide(); 16105 } 16106 16107 }) 16108 16109 .fail(function(jqXHR, ajaxOptions, thrownError) 16110 { 16111 alert('il server non risponde...'); 16112 }); 16113 } 16114 16115 var url=document.location.href; 16116 if(url.indexOf('&last=') !== -1) 16117 { 16118 var last=getParametroURL('last'); 16119 16120 //distretto 16121 var oldUrlDistretto = $('#elencoImpianti th.distretto a'). attr("href"); 16122 if(oldUrlDistretto.indexOf('&last=') !== -1) 16123 { 16124 var oldLast=getParametro(oldUrlDistretto,'last'); 16125 var newUrlDistretto=oldUrlDistretto.replace("&last="+oldLast, "&last="+last); 16126 $('#elencoImpianti th.distretto a'). attr("href", newUrlDistretto); 16127 } 16128 else 16129 { 16130 var newUrlDistretto=oldUrlDistretto+'&last='+last; 16131 $('#elencoImpianti th.distretto a'). attr("href", newUrlDistretto); 16132 } 16133 16134 //comune 16135 var oldUrlComune = $('#elencoImpianti th.comune a'). attr("href"); 16136 if(oldUrlComune.indexOf('&last=') !== -1) 16137 { 16138 var oldLast=getParametro(oldUrlComune,'last'); 16139 var newUrlComune=oldUrlComune.replace("&last="+oldLast, "&last="+last); 16140 $('#elencoImpianti th.comune a'). attr("href", newUrlComune); 16141 } 16142 else 16143 { 16144 var newUrlComune=oldUrlComune+'&last='+last; 16145 $('#elencoImpianti th.comune a'). attr("href", newUrlComune); 16146 } 16147 16148 //impianto 16149 var oldUrlImpianto = $('#elencoImpianti th.impianto a'). attr("href"); 16150 if(oldUrlImpianto.indexOf('&last=') !== -1) 16151 { 16152 var oldLast=getParametro(oldUrlImpianto,'last'); 16153 var newUrlImpianto=oldUrlImpianto.replace("&last="+oldLast, "&last="+last); 16154 $('#elencoImpianti th.impianto a'). attr("href", newUrlImpianto); 16155 } 16156 else 16157 { 16158 var newUrlImpianto=oldUrlImpianto+'&last='+last; 16159 $('#elencoImpianti th.impianto a'). attr("href", newUrlImpianto); 16160 } 16161 } 16162 16163 16164 } 16165 16166 16167 function getParametroURL(name){ 16168 var url=window.location.href; 16169 16170 if(url.indexOf(name)>0) 16171 { 16172 var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); 16173 return results[1] || ''; 16174 } 16175 else 16176 return ''; 16177 } 16178 16179 function getParametro(url,name){ 16180 16181 if(url.indexOf(name)>0) 16182 { 16183 var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url); 16184 return results[1] || ''; 16185 } 16186 else 16187 return ''; 16188 } 16189 16190 16191 $('a.mappa').click(openMappaGoogle); 16192 $('a.mappaAerea').click(openMappaAerea); 16193 16194 16195 function openMappaGoogle(){ 16196 16197 href=$('a.mappa').attr('data-src'); 16198 content='<iframe src="'+href+'" style="display: 1none; width: 100%; height: 480px; border: 0"></iframe>'; 16199 16200 var html = '<div class="modal fade" id="modalMappaGoogle" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">'; 16201 html += '<div class="modal-dialog modal-lg" role="document">'; 16202 html += '<div class="modal-content">'; 16203 html += '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button><h4 class="modal-title" id="myModalLabel">Mappa</h4></div>'; 16204 html += '<div class="modal-body">'+content+'</div>'; 16205 html += '</div></div></div>'; 16206 16207 $('#mappa').append(html); 16208 } 16209 16210 function openMappaAerea(){ 16211 16212 href=$('a.mappaAerea').attr('data-src'); 16213 content='<iframe src="'+href+'" style="display: 1none; width: 100%; height: 480px; border: 0"></iframe>'; 16214 16215 var html = '<div class="modal fade" id="modalMappaAerea" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">'; 16216 html += '<div class="modal-dialog modal-lg" role="document">'; 16217 html += '<div class="modal-content">'; 16218 html += '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button><h4 class="modal-title" id="myModalLabel">Foto aerea</h4></div>'; 16219 html += '<div class="modal-body">'+content+'</div>'; 16220 html += '</div></div></div>'; 16221 16222 $('#mappa').append(html); 16223 } 16224 16225} 16226 16227function initLaboratorioCantonale(){ 16228 $("a.suggerimento").click(function() { 16229 val=$(this).attr('data-termine'); 16230 $("#q").val(val); 16231 $('#ricerca').submit(); 16232 }); 16233} 16234function initLayoutPaginaTemi(){ 16235 16236if($('ul.menuPagina').length){ 16237 16238 $('ul.menuPagina').each(function(i, items_list){ 16239 var myText = ""; 16240 16241 $(items_list).find('li a[data-title]').each(function(j, li){ 16242 var li = $(li); 16243 titolo = (li.attr('data-title').replace("'", " ")); 16244 li.attr('data-title', titolo); 16245 }) 16246 16247 16248 }); 16249 16250 if(window.location.href.indexOf('#') != -1){ 16251 16252 arr = window.location.href.split('#'); 16253 16254 if(arr.length > 1){ 16255 16256 path = decodeURIComponent(window.location.href); 16257 arr = path.split('#'); 16258 arr = arr["1"].split('|'); 16259 16260 if(arr.length > 1){ 16261 16262 //cerca == categoria la categoria 16263 cerca = decodeURIComponent(arr["1"]); 16264 // cerco la categoria 16265 $("ul.menuPagina li a[data-title='"+cerca+"']").addClass("selected"); 16266 16267 var listItems = $("ul.menuPagina li a.selected"); 16268 listItems.each(function(idx, li) { 16269 var categoria = $(li); 16270 16271 if(categoria.parent().parent().parent().children('a').attr('data-title') != decode
16271URIComponent(arr["0"])) 16272 categoria.removeClass("selected"); 16273 }); 16274 16275 }else{ 16276 // cerco il tema 16277 cerca = decodeURIComponent(arr["0"]); 16278 $("ul.menuPagina li a[data-title='"+cerca+"']").addClass("selected"); 16279 $("ul.menuPagina li ul.lev1 li a[data-title='"+cerca+"']").removeClass("selected"); 16280 } 16281 16282 if($('ul li a.selected').parent().parent().attr('class') == 'menuPagina'){ 16283 16284 initApriTema(); 16285 }else{ 16286 initApriCategoria(); 16287 } 16288 16289 } 16290 16291 function initApriTema(){ 16292 16293 obj = $('ul.menuPagina li a.selected'); 16294 obj.parent().addClass("selected"); 16295 var titolo = obj.children('h2').html() 16296 16297 var ulCategorie = obj.parent().children('ul').html(); 16298 16299 $('ul.menuPagina').addClass('clicked'); 16300 16301 $('ul.menuPagina.clicked').after('<div class="categorie"><h3>'+titolo+'</h3><ul class="menuPagina1">'+ulCategorie+'</ul></div>'); 16302 16303 $('div.layoutPaginaTemi-menu').append('<div class="clear"> </div>'); 16304 $('div.layoutPaginaTemi-menu').css({'min-height': $('div.categorie').height()}); 16305 16306 initTema(); 16307 initCategorie(); 16308 16309 } 16310 16311 function initApriCategoria(){ 16312 16313 16314 $('ul.menuPagina').addClass('clicked'); 16315 obj= $('ul.menuPagina .lev1 li a.selected'); 16316 16317 obj.parent().addClass("selected"); 16318 obj.parent().parent().parent().addClass("selected"); 16319 16320 16321 ulCategorie = obj.parent().parent().html(); 16322 titoloTema = obj.parent().parent().parent().find('h2').html(); 16323 16324 $('ul.menuPagina.clicked').after('<div class="categorie"><h3>'+titoloTema+'</h3><ul class="menuPagina1">'+ulCategorie+'</ul></div>'); 16325 $('div.categorie').addClass('clicked'); 16326 16327 16328 var titoloCategoria = obj.children('h2').html(); 16329 var ulSchede = obj.parent().children('ul').html(); 16330 16331 $('div.categorie').after('<div class="listaSchede"><h3>'+titoloCategoria+'</h3><ul class="menuPagina2">'+ulSchede+'</ul></div>'); 16332 if($('div.listaSchede').height() > $('div.categorie').height()) 16333 altezza = $('div.listaSchede').height(); 16334 else 16335 altezza = $('div.categorie').height(); 16336 $('div.layoutPaginaTemi-menu').css({'min-height': altezza}); 16337 16338 initTema(); 16339 initCategorie(); 16340 16341 } 16342 16343 } 16344 16345 function initTema(){ 16346 $('ul.menuPagina li a').click(function(e) { 16347 16348 e.preventDefault(); 16349 16350 $('ul.menuPagina li a').attr('aria-expanded', false); 16351 16352 if( $(this).parent().hasClass( "hasChild" ) === false) { 16353 location.href= $(this).attr("href"); 16354 } 16355 16356 $('ul.menuPagina li a').parent().removeClass("selected"); 16357 $(this).attr('aria-expanded', true); 16358 $(this).parent().addClass("selected"); 16359 var titolo = $(this).children('h2').html(); 16360 16361 // quando clicco nuovamente devo avere le colonne pulite 16362 $('.categorie').detach(); 16363 $('.listaSchede').detach(); 16364 $('.clear').detach(); 16365 16366 16367 var ulCategorie = $( this ).parent().children('ul').html(); 16368 $('ul.menuPagina').addClass('clicked'); 16369 16370 $('ul.menuPagina.clicked').after('<div class="categorie"><h3>'+titolo+'</h3><ul class="menuPagina1">'+ulCategorie+'</ul></div>'); 16371 $('div.layoutPaginaTemi-menu').append('<div class="clear"> </div>'); 16372 $('div.layoutPaginaTemi-menu').css({'min-height': $('div.categorie').height()}); 16373 16374 initCategorie(); 16375 initSchede(); 16376 16377 }) 16378 } 16379 16380 function initCategorie(){ 16381 16382 $('ul.menuPagina1 li a').click(function(e) { 16383 16384 if( $(this).parent().hasClass( "hasChild" ) === false) { 16385 16386 location.href= $(this).attr("href"); 16387 }else{ 16388 e.preventDefault(); 16389 $('ul.menuPagina1 li a').attr('aria-expanded', false) 16390 $('ul.menuPagina1 li a').removeClass("selected"); 16391 $('ul.menuPagina1 li').removeClass("selected"); 16392 16393 16394 16395 $(this).attr('aria-expanded', true); 16396 $(this).parent().addClass("selected"); 16397 var titolo = $(this).children('h2').html(); 16398 16399 $('.listaSchede').detach(); 16400 $('.clear').detach(); 16401 16402 var ulSchede = $(this).parent().children('ul').html(); 16403 $('div.categorie').addClass('clicked'); 16404 16405 $('div.categorie').after('<div class="listaSchede"><h3>'+titolo+'</h3><ul class="menuPagina2">'+ulSchede+'</ul></div>'); 16406 if($('div.listaSchede').height() > $('div.categorie').height()) 16407 altezza = $('div.listaSchede').height(); 16408 else 16409 altezza = $('div.categorie').height(); 16410 $('div.layoutPaginaTemi-menu').css({'min-height': altezza}); 16411 16412 initSchede(); 16413 } 16414 }); 16415 var scroll_pos=(0); 16416 $('html, body').animate({scrollTop:(scroll_pos)}, '2000') 16417 } 16418 16419 function initSchedeLev2(){ 16420 16421 $('ul.menuPagina1 li a').click(function(e) { 16422 location.href= $(this).attr("href"); 16423 16424 }); 16425 var scroll_pos=(0); 16426 $('html, body').animate({scrollTop:(scroll_pos)}, '2000') 16427 } 16428 16429 function initSchede(){ 16430 16431 $('ul.menuPagina2 li a').click(function(e) { 16432 location.href= $(this).attr("href"); 16433 16434 }); 16435 var scroll_pos=(0); 16436 $('html, body').animate({scrollTop:(scroll_pos)}, '2000') 16437 } 16438 16439 16440 initTema(); 16441 } 16442 16443 16444} 16445//gestione acquisti legislazione 16446function initLegislazione(){ 16447 16448 //per gestire il back del browser 16449 $(window).on('popstate', function(event) { 16450 16451 var hash = location.hash; 16452 if(hash.length==0) 16453 { 16454 $("#riassuntoOrdinazione").hide(); 16455 $("#DatiPersonali").hide(); 16456 $("#moduloOrdinaizonePubblicazioni").show(); 16457 $("#testoIntro").show(); 16458 $('html, body').animate({scrollTop: '0px'}, 300); 16459 } 16460}); 16461 16462 16463 // Ordinazione altre pubblicazioni 16464 // ------------------------------------ 16465 $("#riassuntoOrdinazione").hide(); 16466 $("#DatiPersonali").hide(); 16467 16468 $('#altrePubb .pubblicazione').on('change', function (e) { 16469 var totale=0; 16470 $("#ordinazione select").each(function(){ 16471 var input = $(this); 16472 var optionSelected = $("option:selected", this); 16473 var quantita = this.value; 16474 var prezzo=optionSelected.data('prezzo'); 16475 totale=totale+(quantita*prezzo); 16476 }); 16477 16478 totale="fr. "+totale+".00"; 16479 16480 $('#totale').text(totale); 16481 }); 16482 16483 $("#altrePubb #procediOrdinazione").click(function() { 16484 16485 window.location.hash="riepilogo"; 16486 16487 var totale=0; 16488 var riassunto=""; 16489 var tmp=""; 16490 16491 $("#ordinazione select").each(function(){ 16492 var input = $(this); 16493 var optionSelected = $("option:selected", this); 16494 var quantita = this.value; 16495 var prezzo=optionSelected.data('prezzo'); 16496 var prezzolibri=""; 16497 var titolo=input.data('titolo'); 16498 16499 if(quantita > 0) 16500 { 16501 totale=totale+(quantita*prezzo); 16502 prezzolibri=quantita*prezzo; 16503 16504 riassunto=riassunto+'<div class="row"><div class="col-xs-8">'+titolo+'</div><div class="col-xs-2">'+quantita+'x</div><div class="col-xs-2">fr. '+prezzolibri+'.00</div></div>'; 16505 tmp=tmp+quantita+'x '+titolo+'\n'; 16506 } 16507 }); 16508 16509 riassunto= riassunto+'<div class="row"><div class="col-xs-8"></div><div class="col-xs-4 totale"><span class="spanStringa"><b>Totale IVA incl. 2.6%</b></span><span id="totale" class="spanTotale">fr. '+totale+'.00</span></div></div>'; 16510 16511 tmp=tmp+'\nTOTALE IVA incl. 2.6%: fr. '+totale+'.00'; 16512 16513 riassunto='<h1 class="csc-firstHeader">Riepilogo e ordinazione</h1><div class="box-info1"><b>Riepilogo ordine</b><br /><br />'+riassunto+'<div class="row"><p>Al totale saranno aggiunte le spese di spedizione (in Svizzera 7 franchi per un volume).<br />La fattura, da pagare entro 30 giorni dalla ricezione, verrà spedita separatamente.</p></div></div>'; 16514 16515 $("#riassuntoOrdinazione").html(riassunto); 16516 $("#riassuntoOrdinazione").show(); 16517 $("#DatiPersonali").show(); 16518 $("#moduloOrdinaizonePubblicazioni").hide(); 16519 $("#testoIntro").hide(); 16520 $('html, body').animate({scrollTop: '0px'}, 300); 16521 16522 $("#powermail_field_ordinazione").val(tmp); 16523 }); 16524 16525 // ------------------------------------ 16526 16527 16528 // Ordinazione RtiD 16529 // ------------------------------------ 16530 16531 $("#RtiD a.aggiungiA1").click(function() { 16532 var nrEl=$("#RtiD #ordinazioneRTID .row .col-xs-6").find(".el").length; 16533 nrEl=nrEl+1; 16534 16535 var campo='<div class="row el"><div class="col-xs-4"><select id="a'+nrEl+'" name="a'+nrEl+'" class="pubblicazione a" data-titolo="Rivista ticinese di diritto"><option value="2026 - I" data-prezzo="118">2026 - I</option><option value="2025 - II" data-prezzo="118">2025 - II</option><option value="2025 - I" data-prezzo="118">2025 - I</option><option value="2024 - II" data-prezzo="118">2024 - II</option><option value="2024 - I" data-prezzo="118">2024 - I</option><option value="2023 - II" data-prezzo="118">2023 - II</option><option value="2023 - I" data-prezzo="118">2023 - I</option><option value="2022 - II" data-prezzo="114">2022 - II</option><option value="2022 - I" data-prezzo="114">2022 - I</option><option value="2021 - II" data-prezzo="114">2021 - II</option><option value="2021 - I" data-prezzo="114">2021 - I</option><option value="2020 - II" data-prezzo="114">2020 - II</option><option value="2020 - I" data-prezzo="114">2020 - I</option><option value="2019 - II" data-prezzo="114">2019 - II</option><option value="2019 - I" data-prezzo="114">2019 - I</option><option value="2018 - II" data-prezzo="114">2018 - II</option><option value="2018 - I" data-prezzo="114">2018 - I</option><option value="2017 - II" data-prezzo="90">2017 - II</option><option value="2017 - I" data-prezzo="90">2017 - I</option><option value="2016 - II" data-prezzo="90">2016 - II</option><option value="2016 - I" data-prezzo="90">2016 - I</option><option value="2015 - II" data-prezzo="90">2015 - II</option><option value="2015 - I" data-prezzo="90">2015 - I</option><option value="2014 - II" data-prezzo="90">2014 - II</option><option value="2014 - I" data-prezzo="90">2014 - I</option><option value="2013 - II" data-prezzo="90">2013 - II</option><option value="2013 - I" data-prezzo="90">2013 - I</option><option value="2012 - II" data-prezzo="90">2012 - II</option><option value="2012 - I" data-prezzo="90">2012 - I</option><option value="2011 - II" data-prezzo="90">2011 - II</option><option value="2011 - I" data-prezzo="90">2011 - I</option> <option value="2010 - II" data-prezzo="90">2010 - II</option><option value="2010 - I" data-prezzo="90">2010 - I</option><option value="2009 - II" data-prezzo="90">2009 - II</option><option value="2009 - I" data-prezzo="90">2009 - I</option><option value="2008 - I" data-prezzo="90">2008 - I</option><option value="2007 - II" data-prezzo="90">2007 - II</option><option value="2007 - I" data-prezzo="90">2007 - I</option><option value="2006 - II" data-prezzo="90">2006 - II</option><option value="2006 - I" data-prezzo="90">2006 - I</option><option value="2005 - II" data-prezzo="90">2005 - II</option><option value="2005 - I" data-prezzo="90">2005 - I</option><option value="2004 - II" data-prezzo="90">2004 - II</option><option value="2004 - I" data-prezzo="90">2004 - I</option></select></div><div class="col-xs-4"><select name="qt'+nrEl+'" class="pubblicazione qt'+nrEl+'" data-titolo="Rivista ticinese di diritto"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select></div><div class="col-xs-4 p'+nrEl+'">fr. 118.00</div></div>'; 16536 16537 $(campo).insertBefore( ".pulsanteAggiungi" ); 16538 // Selectpicker 16539 if ($('select').length){ 16540 jQuery('select').selectpicker(); 16541 } 16542 16543 $("#RtiD select.pubblicazione").change(function(){ 16544 aggiornaTotale(); 16545 }); 16546 16547 $("#RtiD select.pubblicazione.a").change(function(){ 16548 aggiornaPrezzoUnitario(this.id,'a','p'); 16549 }); 16550 16551 }); 16552 16553 $("#RtiD a.aggiungiB1").click(function() { 16554 var nrEl=$("#RtiD #ordinazioneRTID .row .col-xs-6").find(".el2").length; 16555 nrEl=nrEl+1; 16556 16557 var campo='<div class="row el2"><div class="col-xs-4"><select id="b'+nrEl+'" name="b'+nrEl+'" class="pubblicazione b" data-titolo="Rivista di diritto amministrativo e tributario ticinese"><option value="2003 - II" data-prezzo="60">2003 - II</option><option value="2003 - I" data-prezzo="60">2003 - I</option><option value="2002 - II" data-prezzo="60">2002 - II</option><option value="2002 - I" data-prezzo="60">2002 - I</option><option value="2001 - II" data-prezzo="60">2001 - II</option><option value="2001 - I" data-prezzo="60">2001 - I</option><option value="2000 - II" data-prezzo="60">2000 - II</option><option value="2000 - I" data-prezzo="60">2000 - I</option><option value="1999 - I" data-prezzo="60">1999 - I</option><option value="1998 - II" data-prezzo="60">1998 - II</option><option value="1998 - I" data-prezzo="60">1998 - I</option><option value="1997 - II" data-prezzo="60">1997 - II</option><option value="1997 - I" data-prezzo="60">1997 - I</option><option value="1996 - II" data-prezzo="60">1996 - II</option><option value="1996 - I" data-prezzo="60">1996 - I</option><option value="1995 - I" data-prezzo="60">1995 - I</option><option value="1994 - II" data-prezzo="60">1994 - II</option><option value="1994 - I" data-prezzo="60">1994 - I</option><option value="1993 - II" data-prezzo="60">1993 - II</option><option value="1993 - I" data-prezzo="60">1993 - I</option><option value="1992 - II" data-prezzo="60">1992 - II</option><option value="1992 - I" data-prezzo="60">1992 - I</option><option value="1991 - II" data-prezzo="60">1991 - II</option><option value="1991 - I" data-prezzo="60">1991 - I</option></select></div><div class="col-xs-4"><select name="tt'+nrEl+'" class="pubblicazione tt'+nrEl+'" data-titolo="Rivista di diritto amministrativo e tributario ticinese"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select></div><div class="col-xs-4 t'+nrEl+'">fr. 60.00</div></div>'; 16558 16559 $(campo).insertBefore( ".pulsanteAggiungi2" ); 16560 // Selectpicker 16561 if ($('select').length){ 16562 jQuery('select').selectpicker(); 16563 } 16564 16565 $("#RtiD select.pubblicazione").change(function(){ 16566 aggiornaTotale(); 16567 }); 16568 16569 16570 $("#RtiD select.pubblicazione.b").change(function(){ 16571 aggiornaPrezzoUnitario(this.id,'b','t'); 16572 }); 16573 }); 16574 16575 $("#RtiD a.aggiungiC1").click(function() { 16576 var nrEl=$("#RtiD #ordinazioneRTID .row .col-xs-6").find(".el3").length; 16577 nrEl=nrEl+1; 16578 16579 var campo='<div class="row el3"><div class="col-xs-4"><select id="c'+nrEl+'" name="c'+nrEl+'" class="pubblicazione c" data-titolo="Rivista di diritto amministrativo ticinese"><option value="1990" data-prezzo="60">1990</option><option value="1989" data-prezzo="60">1989</option><option value="1988" data-prezzo="60">1988</option><option value="1987" data-prezzo="60
16579">1987</option><option value="1984" data-prezzo="60">1984</option><option value="1981" data-prezzo="60">1981</option><option value="1979" data-prezzo="60">1979</option><option value="1978" data-prezzo="60">1978</option><option value="1977" data-prezzo="60">1977</option><option value="1976" data-prezzo="60">1976</option></select></div><div class="col-xs-4"><select name="dd'+nrEl+'" class="pubblicazione dd'+nrEl+'" data-titolo="Rivista di diritto amministrativo ticinese"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select></div><div class="col-xs-4 t'+nrEl+'">fr. 60.00</div></div>'; 16580 16581 $(campo).insertBefore( ".pulsanteAggiungi3" ); 16582 // Selectpicker 16583 if ($('select').length){ 16584 jQuery('select').selectpicker(); 16585 } 16586 16587 $("#RtiD select.pubblicazione").change(function(){ 16588 aggiornaTotale(); 16589 }); 16590 16591 16592 $("#RtiD select.pubblicazione.c").change(function(){ 16593 aggiornaPrezzoUnitario(this.id,'c','d'); 16594 }); 16595 }); 16596 16597 16598 16599 // Procedi all'ordinazione 16600 $("#RtiD #procediOrdinazione").click(function() { 16601 16602 window.location.hash="riepilogo"; 16603 16604 var totale=0; 16605 var riassunto=""; 16606 var tmp=""; 16607 16608 //Calcolo RTID 16609 $("#ordinazioneRTID select.a").each(function(){ 16610 var input = $(this); 16611 var nomecampo=input.attr("id").replace("a","qt"); 16612 var optionSelected = $("option:selected", this); 16613 var anno = this.value; 16614 var prezzo=optionSelected.data('prezzo'); 16615 var titolo=input.data('titolo')+" "+anno; 16616 16617 var quantita=$("#ordinazioneRTID ."+nomecampo).find("option:selected").val(); 16618 16619 if(quantita > 0) 16620 { 16621 totale=totale+(quantita*prezzo); 16622 prezzolibri=quantita*prezzo; 16623 16624 riassunto=riassunto+'<div class="row"><div class="col-xs-8">'+titolo+'</div><div class="col-xs-2">'+quantita+'x</div><div class="col-xs-2">fr. '+prezzolibri+'.00</div></div>'; 16625 tmp=tmp+quantita+'x '+titolo+'\n'; 16626 } 16627 16628 16629 }); 16630 16631 16632 // calcolo massimari + GAT 16633 $("#ordinazioneRTID select.max").each(function(){ 16634 var input = $(this); 16635 var optionSelected = $("option:selected", this); 16636 var quantita = this.value; 16637 var prezzo=optionSelected.data('prezzo'); 16638 var prezzolibri=""; 16639 var titolo=input.data('titolo'); 16640 16641 if(quantita > 0) 16642 { 16643 totale=totale+(quantita*prezzo); 16644 prezzolibri=quantita*prezzo; 16645 16646 riassunto=riassunto+'<div class="row"><div class="col-xs-8">'+titolo+'</div><div class="col-xs-2">'+quantita+'x</div><div class="col-xs-2">fr. '+prezzolibri+'.00</div></div>'; 16647 tmp=tmp+quantita+'x '+titolo+'\n'; 16648 } 16649 }); 16650 16651 16652 //calcolo RDAT 16653 $("#ordinazioneRTID select.b").each(function(){ 16654 var input = $(this); 16655 var nomecampo=input.attr("id").replace("b","tt"); 16656 var optionSelected = $("option:selected", this); 16657 var anno = this.value; 16658 var prezzo=optionSelected.data('prezzo'); 16659 var titolo=input.data('titolo')+" "+anno; 16660 16661 var quantita=$("#ordinazioneRTID ."+nomecampo).find("option:selected").val(); 16662 16663 if(quantita > 0) 16664 { 16665 totale=totale+(quantita*prezzo); 16666 prezzolibri=quantita*prezzo; 16667 16668 riassunto=riassunto+'<div class="row"><div class="col-xs-8">'+titolo+'</div><div class="col-xs-2">'+quantita+'x</div><div class="col-xs-2">fr. '+prezzolibri+'.00</div></div>'; 16669 tmp=tmp+quantita+'x '+titolo+'\n'; 16670 } 16671 }); 16672 16673 $("#ordinazioneRTID select.c").each(function(){ 16674 var input = $(this); 16675 var nomecampo=input.attr("id").replace("c","dd"); 16676 var optionSelected = $("option:selected", this); 16677 var anno = this.value; 16678 var prezzo=optionSelected.data('prezzo'); 16679 var titolo=input.data('titolo')+" "+anno; 16680 16681 var quantita=$("#ordinazioneRTID ."+nomecampo).find("option:selected").val(); 16682 16683 if(quantita > 0) 16684 { 16685 totale=totale+(quantita*prezzo); 16686 prezzolibri=quantita*prezzo; 16687 16688 riassunto=riassunto+'<div class="row"><div class="col-xs-8">'+titolo+'</div><div class="col-xs-2">'+quantita+'x</div><div class="col-xs-2">fr. '+prezzolibri+'.00</div></div>'; 16689 tmp=tmp+quantita+'x '+titolo+'\n'; 16690 } 16691 }); 16692 16693 16694 16695 riassunto= riassunto+'<div class="row"><div class="col-xs-8"></div><div class="col-xs-4 totale"><span class="spanStringa"><b>Totale IVA incl. 2.6%</b></span><span id="totale" class="spanTotale">fr. '+totale+'.00</span></div></div>'; 16696 tmp=tmp+'\nTOTALE IVA incl. 2.6%: fr. '+totale+'.00'; 16697 riassunto='<h1 class="csc-firstHeader">Riepilogo e ordinazione</h1><div class="box-info1"><b>Riepilogo ordine</b><br /><br />'+riassunto+'<div class="row"><p>Al totale saranno aggiunte le spese di spedizione (in Svizzera 7 franchi per un volume).<br />La fattura, da pagare entro 30 giorni dalla ricezione, verrà spedita separatamente.</p></div></div>'; 16698 16699 $("#riassuntoOrdinazione").html(riassunto); 16700 16701 $("#riassuntoOrdinazione").show(); 16702 $("#DatiPersonali").show(); 16703 $("#moduloOrdinaizonePubblicazioni").hide(); 16704 $("#testoIntro").hide(); 16705 $('html, body').animate({scrollTop: '0px'}, 300); 16706 16707 $("#powermail_field_ordinazione").val(tmp); 16708 16709 }); 16710 16711 16712 $("#RtiD select.pubblicazione").change(function(){ 16713 aggiornaTotale(); 16714 }); 16715 16716 $("#RtiD select.pubblicazione.a").change(function(){ 16717 aggiornaPrezzoUnitario(this.id,'a','p'); 16718 }); 16719 16720 16721 $("#RtiD select.pubblicazione.b").change(function(){ 16722 aggiornaPrezzoUnitario(this.id,'b','t'); 16723 }); 16724 16725 $("#RtiD select.pubblicazione.c").change(function(){ 16726 aggiornaPrezzoUnitario(this.id,'c','d'); 16727 }); 16728 16729 16730 function aggiornaTotale(){ 16731 var totale=0; 16732 16733 //Calcolo RTID 16734 $("#ordinazioneRTID select.a").each(function(){ 16735 var input = $(this); 16736 var nomecampo=input.attr("id").replace("a","qt"); 16737 var optionSelected = $("option:selected", this); 16738 var prezzo=optionSelected.data('prezzo'); 16739 var quantita=$("#ordinazioneRTID ."+nomecampo).find("option:selected").val(); 16740 16741 if(quantita > 0) 16742 { 16743 totale=totale+(quantita*prezzo); 16744 } 16745 }); 16746 16747 // calcolo massimari + GAT 16748 $("#ordinazioneRTID select.max").each(function(){ 16749 var input = $(this); 16750 var optionSelected = $("option:selected", this); 16751 var quantita = this.value; 16752 var prezzo=optionSelected.data('prezzo'); 16753 16754 if(quantita > 0) 16755 { 16756 totale=totale+(quantita*prezzo); 16757 } 16758 }); 16759 16760 //calcolo RDAT 16761 $("#ordinazioneRTID select.b").each(function(){ 16762 var input = $(this); 16763 var nomecampo=input.attr("id").replace("b","tt"); 16764 var optionSelected = $("option:selected", this); 16765 var prezzo=optionSelected.data('prezzo'); 16766 var quantita=$("#ordinazioneRTID ."+nomecampo).find("option:selected").val(); 16767 16768 if(quantita > 0) 16769 { 16770 totale=totale+(quantita*prezzo); 16771 } 16772 }); 16773 16774 $("#ordinazioneRTID select.c").each(function(){ 16775 var input = $(this); 16776 var nomecampo=input.attr("id").replace("c","dd"); 16777 var optionSelected = $("option:selected", this); 16778 var prezzo=optionSelected.data('prezzo'); 16779 var quantita=$("#ordinazioneRTID ."+nomecampo).find("option:selected").val(); 16780 16781 if(quantita > 0) 16782 { 16783 totale=totale+(quantita*prezzo); 16784 } 16785 }); 16786 16787 totale="fr. "+totale+".00"; 16788 $('#totale').text(totale); 16789 } 16790 16791 16792 function aggiornaPrezzoUnitario(elemento,search,replace){ 16793 //aggiorno il prezzo unitaro della pubblicazione 16794 var prezzo = $("#"+elemento).find(":selected").data('prezzo'); 16795 var nomecampo=elemento.replace(search,replace); 16796 $("."+nomecampo).html('fr. '+prezzo+'.00'); 16797 } 16798 16799// ------------------------------------ 16800} 16801 16802function initMappaDatiMonitoraggioCeneri() 16803{ 16804 $("input[name='layer']").change(function(){ 16805 var e=$(this).val(); 16806 16807 $('g[style*="visibility: visible"]').each(function() { 16808 $(this).css('visibility','hidden'); 16809 }); 16810 16811 $('#'+e).css('visibility','visible'); 16812 }); 16813} 16814 16815function initMappaCollegamentiMonitoraggioCeneri() 16816{ 16817 $("input[name='layer']").change(function(){ 16818 var e=$(this).val(); 16819 16820 $('g[style*="display: block"]').each(function() { 16821 $(this).css('display','none'); 16822 }); 16823 16824 $('#'+e).css('display','block'); 16825 }); 16826} 16827/* ODG */ 16828function initODG(){ 16829 $('#ODG a').click(function () { 16830 16831 var link = $(this).attr('href'); 16832 16833 start = link.lastIndexOf(".") + 1; 16834 len = link.length - start; 16835 estensione = link.substr(start, len); 16836 16837 var tat = ''; 16838 if (estensione != 'htm') { 16839 return true; 16840 } 16841 else if (link.indexOf("odg-mes") != '-1') { 16842 //numero = parseInt(link.replace("odg-mes/", "")); 16843 start = link.lastIndexOf("/") + 1; 16844 len = link.length - start; 16845 numero = parseInt(link.substr(start, len)); 16846 tat = 100; 16847 } 16848 else if (link.indexOf("mozioni") != '-1') { 16849 // +3 = [/MO] 16850 start = link.lastIndexOf("/") + 3; 16851 len = link.length - start; 16852 numero = parseInt(link.substr(start, len)); 16853 tat = 105; 16854 } 16855 else if (link.indexOf("inizgeneriche") != '-1') { 16856 // +3 = [/IG] 16857 start = link.lastIndexOf("/") + 3; 16858 len = link.length - start; 16859 numero = parseInt(link.substr(start, len)); 16860 tat = 102; 16861 } 16862 else if (link.indexOf("inizelaborate") != '-1') { 16863 // +3 = [/IE] 16864 start = link.lastIndexOf("/") + 3; 16865 len = link.length - start; 16866 numero = parseInt(link.substr(start, len)); 16867 //numero = parseInt(link.replace("inizelaborate/IE", "")); 16868 tat = 103; 16869 } 16870 //var urlPagina = "index.php?id=81443&r=1&user_gcparlamento_pi8[ricerca]="+numero+"&user_gcparlamento_pi8[tat]="+tat+"&user_gcparlamento_pi8[data]=&user_gcparlamento_pi8[rel]=&Cerca=Cerca"; 16871 //var newpage = window.open(urlPagina, '', 'window settings'); 16872 document.location.href = "index.php?id=81443&r=1&user_gcparlamento_pi8[ricerca]=" + numero + "&user_gcparlamento_pi8[tat]=" + tat + "&user_gcparlamento_pi8[data]=&user_gcparlamento_pi8[rel]=&Cerca=Cerca"; 16873 16874 16875 return false;
16876 }); 16877} 16878/* Organigramma */ 16879function initOpenerOrganigramma() { 16880 function open(e) { 16881 e.preventDefault(); 16882 16883 if ($('.overlay-close').length && $('.overlay-close').is(':visible')) { 16884 $('.overlay-close a').trigger('click'); 16885 } 16886 16887 if (!$(this).hasClass('opened')) { 16888 $(this).addClass('opened'); 16889 16890 overlayOpener = $(this); 16891 16892 if ($('header .right a:eq(1)').hasClass('opened')) { 16893 $('header .right a:eq(1)').removeClass('opened'); 16894 $('.overlay-content').remove(); 16895 } 16896 16897 var url = '//www4.ti.ch/'; 16898 16899 jQuery.get(url+'index.php', { 'eID': 'organigramma', 'load': 1 }, function (r) { 16900 16901 if (!$('.overlay').length) showOverlay(); 16902 jQuery('body').append(r); 16903 16904 setTimeout(function (){ resizeOverlay(); }, 100); 16905 16906 $('#link_accessibile').focus(); 16907 16908 }); 16909 } 16910 } 16911 function close() { 16912 $('.overlay-close, .overlay, #organigramma').remove(); 16913 $('header .right .opened').removeClass('opened'); 16914 if(overlayOpener){
16915 overlayOpener.focus(); 16916 overlayOpener = false; 16917 } 16918 } 16919 $('header .right a.organigramma').click(open); 16920 setTimeout(function () { 16921 $('.organigramma.small-icon-link').click(function (e) { 16922 e.preventDefault(); 16923 $('header .right a.organigramma').trigger('click'); 16924 }); 16925 }, 250); 16926} 16927/* PCA */ 16928function initPCA(){ 16929 function init(){ 16930 if($('#pca.page').length){ 16931 var n = 1; 16932 var max = 27; 16933 var animationSpeed = 1000; 16934 var stopShowAll = false; 16935 var stopHideAll = false; 16936 var animationN = 1; 16937 var movingin = false; 16938 16939 16940 function show(index){ 16941 if($('#a'+index).length){ 16942 var dest = d3.select("#a"+index); 16943 var dest_cx = dest.attr('cx'); 16944 var dest_cy = dest.attr('cy'); 16945 16946 16947 var objs = d3.selectAll("#g"+index+" circle"); 16948 16949 objs.transition() 16950 .duration(animationSpeed) 16951 .attr("cx", dest_cx) 16952 .attr("cy", dest_cy) 16953 .attr('r', 0); 16954 16955 dest.transition() 16956 .duration(animationSpeed) 16957 .attr('r', dest.attr("data-r")); 16958 } 16959 } 16960 function hide(index){ 16961 if($('#a'+index).length){ 16962 d3.select("#a"+index).transition() 16963 .duration(animationSpeed) 16964 .attr('r', 0); 16965 16966 var dest = d3.select("#a"+index); 16967 var dest_cx = dest.attr('cx'); 16968 var dest_cy = dest.attr('cy'); 16969 16970 var objs = d3.selectAll("#g"+index+" circle"); 16971 objs.each(function (d, i){ 16972 16973 var cx = d3.select(this).attr('data-cx'); 16974 var cy = d3.select(this).attr('data-cy'); 16975 var r = d3.select(this).attr('data-r'); 16976 16977 d3.select(this).transition() 16978 .duration(animationSpeed) 16979 .attr("cx", cx) 16980 .attr("cy", cy) 16981 .attr('r', r); 16982 }); 16983 } 16984 } 16985 function showAll(){ 16986 animationN = 1; 16987 var i = setInterval(function (){ 16988 show(animationN); 16989 animationN++; 16990 if(animationN > max || stopShowAll){ 16991 movingin = false; 16992 stopShowAll = false; 16993 clearInterval(i); 16994 } 16995 }, 30); 16996 } 16997 function hideAll(){ 16998 animationN--; 16999 var i = setInterval(function (){ 17000 hide(animationN); 17001 animationN--; 17002 if(animationN == 0 || stopHideAll){ 17003 stopHideAll = false; 17004 movingin = false; 17005 clearInterval(i); 17006 } 17007 17008 }, 30); 17009 } 17010 function mousein(){ 17011 if(!movingin) { 17012 stopShowAll = false; 17013 movingin = true; 17014 showAll(); 17015 } 17016 } 17017 function mouseout(){ 17018 stopShowAll = true; 17019 hideAll(); 17020 } 17021 17022 17023 $('#pca .header').hover(mousein, mouseout); 17024 17025 17026 initImages(); 17027 } 17028 else{ 17029 $('#breadcrumbs-two a').click(function (e){ 17030 e.preventDefault(); 17031 if($(this).attr('href')){ 17032 var i = $(this).parent().index() + 1; 17033 $('.flow-box div.box-n2, .flow-box div.box-n3').addClass('hidden'); 17034 $('.box-n'+i).removeClass('hidden'); 17035 } 17036 }); 17037 } 17038 } 17039 17040 function shuffle(array) { 17041 var currentIndex = array.length, temporaryValue, randomIndex; 17042 while (0 !== currentIndex) { 17043 17044 randomIndex = Math.floor(Math.random() * currentIndex); 17045 currentIndex -= 1; 17046 17047 temporaryValue = array[currentIndex]; 17048 array[currentIndex] = array[randomIndex]; 17049 array[randomIndex] = temporaryValue; 17050 } 17051 17052 return array; 17053 } 17054 function initImages() { 17055 var n = [1, 2, 3, 4]; 17056 // n = shuffle(n); 17057 $('.image').each(function (i) { 17058 $(this).addClass('image' + n[i]); 17059 var t = $(this); 17060 setTimeout(function () { 17061 t.addClass('fadein') 17062 }); 17063 }); 17064 } 17065 init(); 17066} 17067function initPinacoteca(){ 17068 17069 // Inizializzazione slider 17070 $("#sliderPubblicazioni").carousel(); 17071 17072 /*Ordinazioni*/ 17073 $(".aggiungiPubblicazione").click(function() { 17074 titolo=$(this).data("titolo"); 17075 prezzo=$(this).data("prezzo"); 17076 immagine=$(this).data("immagine"); 17077 id=$(this).data("id"); 17078 17079 var liste = JSON.parse(window.sessionStorage.getItem("Pinacoteca")); 17080 17081 if(!liste) 17082 liste = $.makeArray(); 17083 17084 var lista = {}; 17085 lista.id = id; 17086 lista.immagine=immagine; 17087 lista.titolo = titolo; 17088 lista.prezzo = prezzo; 17089 lista.quantita=1; 17090 17091 liste.push(lista); 17092 window.sessionStorage.setItem("Pinacoteca", JSON.stringify(liste)); 17093 17094 //aggiorno bottone "aggiungi"
17095 aggiornaBottone(id); 17096 17097 if ($('#riepilogo').length) 17098 { 17099 stampaRiepilogo(); 17100 } 17101 else 17102 { 17103 stampaOrdine(); 17104 } 17105 }); 17106 17107 17108 //Stampa riepilogo ordine se si è nella pagina "Ordinazioni" 17109 if ($('#ordine').length) 17110 { stampaOrdine(); 17111 aggiornaListaPubblicazioni(); 17112 } 17113 17114 17115 //aggiorna la lista delle pubblicazioni se si è nella pagina "Pubblicazioni" 17116 if ($('#pubblicazioni').length || $('#dettaglioPubblicazioni').length || $('.mostra .pubblicazione').length || $('#riepilogoOrdinazione').length) 17117 { 17118 aggiornaListaPubblicazioni(); 17119 } 17120 17121 //stampa gli elementi presenti nello storage 17122 function stampaOrdine() 17123 { 17124 var lista=window.sessionStorage.getItem("Pinacoteca"); 17125 var liste = JSON.parse(window.sessionStorage.getItem("Pinacoteca")); 17126 var pos=0; 17127 17128 17129 if (lista !== null) 17130 { 17131 //liste.lenght>0 sostituito per errore js 17132 if(lista.length > 2) 17133 { 17134 pos = liste.length; 17135 if(pos > 0){ 17136 var listOrdini =''; 17137 for (var i in liste) { 17138 listOrdini += "<li><div class='row'><div class='col-xs-2'><img src='"+liste[i].immagine+"' width='50px'/></div><div class='col-xs-7'><h3>"+liste[i].titolo+"</h3>"+liste[i].prezzo+"</div><div class='col-xs-2'>Quantità <br /><input type='text' value='"+liste[i].quantita+"' class='form-control quantita' data-id='"+liste[i].id+"'/></div><div class='col-xs-1'><i class='fa fa-times-circle elimina' data-id='"+liste[i].id+"' data-riep='0' aria-label='Elimina elemento'/></div></div></li>"; 17139 } 17140 17141 var testo="<h2>Lista delle ordinazioni</h2><form id='formOrdinazione'><ul>"+listOrdini+"</ul><input type='button' value='Ordina' class='btn btn-primary' id='ordina'></form>"; 17142 17143 $('#ordine').html(testo); 17144 } 17145 } 17146 else 17147 { 17148 var testo="à possibile ordinare una o più pubblicazioni selezionandole dall'elenco che trovate sulla destra."; 17149 $('#ordine').html(testo); 17150 } 17151 } 17152 17153 var spese="<div class=\"spese\"><div class=\"row\"><div class=\"col-xs-2\"><i class=\"fa fa-truck\" aria-hidden=\"true\"></i></div><div class=\"col-xs-10\"><h2>Spese di spedizione</h2><p>Le spese di spedizione verranno comunicate via e-mail all'interessato prima che l'ordinazione venga confermata. Variano infatti molto a seconda del peso. Indicare nel campo "osservazioni" se desiderate la spedizione urgente.</p></div></div><div class=\"row\"><div class=\"col-xs-2\"><i class=\"fa fa-credit-card-alt\" aria-hidden=\"true\"></i></div><div class=\"col-xs-10\"><h2>Metodo di pagamento</h2><p><b>Svizzera</b>: polizza postale<br /><b>Italia</b>: bonifico bancario su banca italiana <br /><br /> Si accettano Euro, cambio indicativo 2014, soggetto a variazioni:<br />
17153CHF/Euro 1:1</p></div></div></div>"; 17154 $('#ordine').append(spese); 17155 } 17156 17157 17158 //aggiornamento quantità nello storage 17159 $(document).on('change',".quantita",function(){ 17160 id=$(this).data("id"); 17161 quantita=$(this).val(); 17162 17163 var liste = $.parseJSON(window.sessionStorage.getItem("Pinacoteca")); 17164 aggiornaQuanita(liste,'id',id,quantita); 17165 window.sessionStorage.setItem("Pinacoteca", JSON.stringify(liste)); 17166 17167 if ($('#riepilogo').length) 17168 { 17169 stampaRiepilogo(); 17170 } 17171 17172 }); 17173 17174 17175 //eliminazione elemento dallo storage 17176 $(document).on('click',"i.elimina",function(){ 17177 id=$(this).data("id"); 17178 riep=$(this).data("riep"); 17179 var liste = $.parseJSON(window.sessionStorage.getItem("Pinacoteca")); 17180 findAndRemove(liste, 'id', id); 17181 window.sessionStorage.setItem("Pinacoteca", JSON.stringify(liste)); 17182 17183 if(riep==1) 17184 { 17185 stampaRiepilogo(); 17186 aggiornaBottoneAttivo(id); 17187 } 17188 else 17189 { 17190 stampaOrdine(); 17191 aggiornaBottoneAttivo(id); 17192 } 17193 }); 17194 17195 //elimina il valore dalla lista 17196 function findAndRemove(array, property, value) { 17197 array.forEach(function(result, index) { 17198 if(result[property] === value) { 17199 array.splice(index, 1); 17200 } 17201 }); 17202 } 17203 17204 //aggiorna la quantità di pubblicazioni prima di salvarli nello storage. 17205 function aggiornaQuanita(liste,indice,id,quantita){ 17206 liste.forEach(function(result, index) { 17207 if(result[indice] === id) { 17208 result['quantita']=quantita; 17209 } 17210 }); 17211 } 17212 17213 //controlla le pubblicazoni già inserite nello storage e le disattiva nella lista di destra 17214 function aggiornaListaPubblicazioni(){ 17215 var liste = $.parseJSON(window.sessionStorage.getItem("Pinacoteca")); 17216 17217 //sessionStorage.length >0 sostituito per errore js 17218 if(liste) 17219 { 17220 liste.forEach(function(result, index) { 17221 aggiornaBottone(result['id']); 17222 }); 17223 } 17224 } 17225 17226 // disattivo il bottone quando aggiungo la pubblicazione alla lista degli acquistati 17227 function aggiornaBottone(id){ 17228 $('button[data-id='+id+']').text('Aggiunto'); 17229 $('button[data-id='+id+']').attr('class', 'btn btn-primary disabled'); 17230 } 17231 17232 //quando elimino un elemento dalla lista degli acquisti 17233 function aggiornaBottoneAttivo(id){ 17234 $('button[data-id='+id+']').text('Aggiungi'); 17235 $('button[data-id='+id+']').attr('class', 'btn btn-primary aggiungiPubblicazione'); 17236 } 17237 17238 17239 // cliccando il tasto ordina dalle pagine "pubblicazioni" e "dettaglio mostra" aggiungo la pubblicazione e vado alla pagina "ordinazioni" 17240 $(".ordinaPubblicazione").click(function() { 17241 titolo=$(this).data("titolo"); 17242 prezzo=$(this).data("prezzo"); 17243 immagine=$(this).data("immagine"); 17244 id=$(this).data("id"); 17245 link=$(this).data("link"); 17246 17247 var liste = JSON.parse(window.sessionStorage.getItem("Pinacoteca")); 17248 17249 if(!liste) 17250 liste = $.makeArray(); 17251 17252 var lista = {}; 17253 lista.id = id; 17254 lista.immagine=immagine; 17255 lista.titolo = titolo; 17256 lista.prezzo = prezzo; 17257 lista.quantita=1; 17258 17259 liste.push(lista); 17260 window.sessionStorage.setItem("Pinacoteca", JSON.stringify(liste)); 17261 17262 location.href = "https://www4.ti.ch/"+link; 17263 }); 17264 17265 17266 //click sul bottone ordina -> apro pagina con Powermail 17267 $(document).on('click',"#ordina",function(){ 17268 window.location.href = "https://www4.ti.ch/index.php?id=100513"; 17269 //window.location.href = "https://www4.ti.ch/decs/dcsu/ac/pinacoteca-zuest/shop/ordinazioni/ordinazione/"; 17270 }); 17271 17272 //Stampa riepilogo nella pagina con la powermail e compila il campo ordinazione 17273 if ($('#riepilogo').length) 17274 { 17275 stampaRiepilogo(); 17276 } 17277 17278 function stampaRiepilogo() 17279 { 17280 var liste = JSON.parse(window.sessionStorage.getItem("Pinacoteca")); 17281 var pos=0; 17282 var ordine=""; 17283 17284 17285 if (sessionStorage.length > 0) 17286 { 17287 if(liste.length>0) 17288 { 17289 pos = liste.length; 17290 if(pos > 0){ 17291 var listOrdini =''; 17292 for (var i in liste) { 17293 //listOrdini += "<li><div class='row'><div class='col-xs-2'><img src='"+liste[i].immagine+"' width='50px'/></div><div class='col-xs-8'><h3>"+liste[i].titolo+"</h3>"+liste[i].prezzo+"</div><div class='col-xs-2'>Quantità <br />
17293<input type='text' value='"+liste[i].quantita+"' class='form-control quantita' data-id='"+liste[i].id+"' disabled/></div></div></li>"; 17294 listOrdini += "<li><div class='row'><div class='col-xs-2'><img src='"+liste[i].immagine+"' width='50px'/></div><div class='col-xs-7'><h3>"+liste[i].titolo+"</h3>"+liste[i].prezzo+"</div><div class='col-xs-2'>Quantità <br /><input type='text' value='"+liste[i].quantita+"' class='form-control quantita' data-id='"+liste[i].id+"'/></div><div class='col-xs-1'><i class='fa fa-times-circle elimina' data-id='"+liste[i].id+"' data-riep='1' aria-label='Elimina elemento'/></div></div></li>"; 17295 ordine+=liste[i].quantita+"pz. "+liste[i].titolo+" \n"; 17296 } 17297 17298 var testo="<h2>Riepilogo dell'ordinazione</h2><form id='formOrdinazione'><ul>"+listOrdini+"</ul>"; 17299 17300 $('#riepilogo').html(testo); 17301 $('#powermail_field_ordinazione_02').val(ordine); 17302 17303 } 17304 } 17305 else 17306 { 17307 var testo="Attenzione la lista è vuota."; 17308 $('#riepilogo').html(testo); 17309 } 17310 } 17311 } 17312 17313 17314 17315 //Mostre passate -> more 17316 var size = $("#mostrePassate .timeline li.elemento").size(); 17317 var nrRecord=10; //nr elementi da visualizzare 17318 var incremento=10; 17319 $('#mostrePassate .timeline li.elemento:lt('+nrRecord+')').show(); 17320 17321 17322 if(size <= nrRecord) 17323 $('.showMore').hide(); 17324 17325 $('.showMore').click(function () { 17326 nrRecord= (nrRecord+incremento <= size) ? nrRecord+incremento : size; 17327 $('#mostrePassate .timeline li.elemento:lt('+nrRecord+')').show("slow"); 17328 17329 if(nrRecord>=size) 17330 $('.showMore').hide(); 17331 }); 17332 17333 17334 17335 //Mostre passate -> submit ricerca press enter 17336 $(".ricercaMostre .form-control").keypress(function (e) { 17337 if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) { 17338 $('.btn-default').click(); 17339 return false; 17340 } else { 17341 return true; 17342 } 17343 }); 17344 17345} 17346 17347function initAntibioticiQuiz2(){ 17348 var n = 0; 17349 var data = [ 17350 { 17351 title: 'Che cosa sono gli antibiotici?', 17352 answers: { 17353 'Medicamenti contro i batteri': true, 17354 'Molecole che favorisocno la digestione': false, 17355 'Caramelle da avere sempre in tasca': false 17356 }, 17357 phrase: 'Gli antibiotici sono dei medicamenti da utilizzare per trattare le infezioni causate dai batteri. Non servono a nulla contro virus, funghi e parassiti! Sono un bene prezioso da non sprecare anche perché attualmente il loro approvvigionamento non è garantito.' 17358 }, 17359 { 17360 title: 'Per quale di queste malattie sono utili gli antibiotici?', 17361 answers: { 17362 'Influenza': false, 17363 'Raffreddore': false, 17364 'Tosse': false, 17365 'Polmonite di origine batterica': true 17366 }, 17367 phrase: 'Gli antibiotici sono dei medicamenti utili per curare le infezioni di origine batterica. Influenza, raffreddore e tosse sono provocate da virus quindi è inutile usarli per queste malattie!' 17368 }, 17369 { 17370 title: 'Chi decide se ho bisogno di antibiotici?', 17371 answers: { 17372 'Cerco su internet': false, 17373 'Lo capisco da solo e utilizzo quelli avanzati da una cura precedente': false, 17374 'Il mio medico': true 17375 }, 17376 phrase: 'Gli antibiotici possono essere prescritti unicamente dal medico, se necessario. La prescrizione è personale e corrisponde a un bisogno individuale specifico.<br><img src="/fileadmin/DSS/DSP/UMC/quiz/cura-individuale.png" width="100%">' 17377 }, 17378 { 17379 title: 'Per quanto tempo devo prendere gli antibiotici prescritti dal medico?', 17380 answers: { 17381 'Fino a quando mi sento meglio': false, 17382 'Fino a quando indicato dal medico': true, 17383 'Fino a quando non ho più la febbre': false 17384 }, 17385 phrase: 'à importante seguire in modo preciso le indicazioni sulla durata della cura, sul dosaggi
17385o e sulla frequenza di assunzione dellâantibiotico. Prenderlo nel modo corretto ne garantisce lâefficacia.<br><img src="/fileadmin/DSS/DSP/UMC/quiz/indicazioni-cura.png" width="100%">' 17386 }, 17387 { 17388 title: 'Cosa faccio se mi avanzano degli antibiotici?', 17389 answers: { 17390 'Li conservo per utilizzarli la prossima volta che mi ammalo': false, 17391 'Li elimino gettandoli nel gabinetto': false, 17392 'Li riporto in farmacia': true 17393 }, 17394 phrase: 'Gli antibiotici avanzati non vanno riutilizzati né dispersi nellâambiente. Questi comportamenti contribuiscono a rendere gli antibiotici meno efficaci.<br><img src="/fileadmin/DSS/DSP/UMC/quiz/smaltimento.png" width="100%"><br><img src="/fileadmin/DSS/DSP/UMC/quiz/ambiente.png" width="100%">' 17395 }, 17396 { 17397 title: 'Di quanti antibiotici ho bisongo per guarire?', 17398 answers: { 17399 'Quanti bastano per farmi passare il mal di gola': false, 17400 'La quantità indicata dal medico in base al tipo di infezione': true, 17401 'Il numero di pastiglie contenuto nella confezione acquistata in farmacia': false 17402 }, 17403 phrase: 'à il medico che decide la cura in base alle necessità del caso, la sua durata e la quantità di pastiglie. Alcune farmacie offrono la possibilità di ritirare unicamente il numero di pastiglie prescritte (vendita sfusa di antibiotici).<br><img src="/fileadmin/DSS/DSP/UMC/quiz/domanda-6.png" width="100%">' 17404 }, 17405 { 17406 title: 'Lâassunzione corretta di antibiotici, secondo le indicazioni del medico, favorisce anche la tutela dellâambiente.', 17407 answers: { 17408 'Vero, lâeliminazione dallâorganismo di residui antibiotici è ridotta al minimo se si rispetta il dosaggio corretto': true, 17409 'Falso, gli antibiotici agiscono solo allâinterno del corpo umano e non creano residui': false, 17410 'Falso, i depuratori delle acque eliminano tutti i residui di antibiotici perciò lâambiente è comunque tutelato': false 17411 }, 17412 phrase: 'Una parte degli antibiotici assunti finisce nella rete fognaria dopo essere stata eliminata dal nostro organismo con urine e feci. Gli oltre 700 depuratori presenti in Svizzera ne trattengono buona parte ma non la totalità . Infatti, in laghi e fiumi in particolare a ridosso dei depuratori si trovano dei residui di antibiotici. Seguire scrupolosamente le prescrizioni mediche permette di trarre dagli antibiotici il massimo beneficio terapeutico, minimizzandone lâimpatto ambientale.<br><img src="/fileadmin/DSS/DSP/UMC/quiz/ambiente.png" width="100%">' 17413 }, 17414 { 17415 title: 'Come si creano i batteri resistenti?', 17416 answers: { 17417 'Utilizzando in modo sbagliato gli antibiotici': true, 17418 'Non coprendosi bene durante lâinverno': false, 17419 'Mangiando poca frutta e verdura': false 17420 }, 17421 phrase: 'Quando sono minacciati i batteri sviluppano dei meccanismi di difesa. Se gli antibiotici si utilizzano in modo sbagliato (p. es. assumendoli in modo diverso dalle prescrizioni, a dosi inferiori o per un tempo differente da quello raccomandato), i batteri diventano più forti e resistenti. Questo può anche succedere quando i batteri entrano in contatto con gli antibiotici nellâambiente. Ciò rende gli antibiotici privi di effetto. <b>Evita il âfai da teâ!</b>' 17422 }, 17423 { 17424 title: 'Parlando di batteri resistenti, quale delle seguenti affermazioni è corretta?', 17425 answers: { 17426 'Per permettere agli antibiotici di agire bisogna fare frequenti bagni caldi e bere tisane 3 volte al giorno': false, 17427 'Gli antibiotici non hanno effetto su questi batteri rendendo la malattia più difficile da curare': true, 17428 'Le nostre difese immunitarie sono più forti': false 17429 }, 17430 phrase: 'Interrompere troppo presto una cura di antibiotici o non rispettare la dose prescritta significa assumere una quantità di antibiotico non sufficiente: una parte della popolazione di batteri sarà eliminata ma una piccola parte riuscirà a sopravvivere, sviluppando una resistenza. Di conseguenza, future infezioni batteriche saranno più difficili da curare.' 17431 }, 17432 { 17433 title: 'In quali derrate alimentari è più probabile trovare dei batteri resistenti agli antibiotici?', 17434 answers: { 17435 'carne di pollo fresca': true, 17436 'frutta fresca con la buccia': false, 17437 'alimenti precotti prodotti industrialmente': false, 17438 }, 17439 phrase: 'In alcune derrate alimentari provenienti da animali, come per esempio la carne fresca di pollo è possibile che siano presenti dei batteri resistenti.' 17440 }, 17441 { 17442 title: 'Cosa posso fare in cucina per eliminare eventuali batteri resistenti o patogeni?', 17443 answers: { 17444 'uso utensili diversi (tagliere, coltello) per preparare le carni crude e altri alimenti crudi (es. insalata)': true, 17445 'acquisto solo alimenti congelati': false, 17446 'arieggio bene prima di iniziare a cucinare': false 17447 }, 17448 phrase: 'Per eliminare i batteri resistenti, ma anche altri germi patogeni come Salmonella e Campylobacter, eventualmente presenti nella carne fresca o nel pesce, basta seguire le buone pratiche di igiene in cucina (lavare gli utensili con sapone, cuocere bene la carne o il pesce, evitare contatti tra carni o pesci freschi e altri alimenti da consumare crudi, lavare le mani con sapone).<br><a href="https://www.sicurezzaatavola.ch" target="_blank">www.sicurezzaatavola.ch</a>' 17449 }, 17450 { 17451 title: 'Credo di avere lâinfluenza! Per fortuna mi sono rimasti degli antibiotici che avevo usato tempo fa per curare una polmonite. Li prendo per qualche giorno e continuo lo stesso ad andare al lavoro.', 17452 answers: { 17453 'Posso curarmi da solo utilizzando degli antibiotici trovati in casa e vado al lavoro.': false, 17454 'Posso curarmi da solo utilizzando degli antibiotici trovati in casa, ma non esco per non contagiare i miei colleghi.': false,
17455 'Non servono gli antibiotici per curare lâinfluenza perché è causata da un virus. Se sono malato devo restare a casa per evitare di contagiare gli altri.': true 17456 }, 17457 phrase: 'Pensa per tempo a fare la vaccinazione contro lâinfluenza soprattutto se sei a contatto con bebè, bambini, donne incinte, anziani e persone immunodepresse. In questo modo, in caso di malattia, eviterai di contagiare delle persone particolarmente sensibili appartenenti alle categorie a rischio.<br>(<a href="https://www.vaccinarsicontrolinfluenza.ch" target="_blank">www.vaccinarsicontrolinfluenza.ch</a>).<br><br>In caso dâinfluenza e raffreddore,<br>concediti il giusto riposo e bevi molto!' 17458 } 17459 ]; 17460 function init(){ 17461 $('#antibiotici_quiz2').on('click', '.next', next); 17462 $('#antibiotici_quiz2').on('click', 'input[type=radio]', check); 17463 $('#antibiotici_quiz2').on('click', '.send-mail', sendMail); 17464 17465 $('#antibiotici_quiz2 h1').after('<p class="intro_text">Quante ne sai sugli antibiotici? Testa le tue conoscenze rispondendo alle seguenti 12 domande: un breve quiz per imparare qualcosa in più sullâuso degli antibiotici. Se sbagli leggi il commento e ritenta unâaltra volta.<br><br></p>'); 17466 17467 generateQuestion(); 17468 } 17469 function generateQuestion(){ 17470 var html = ''; 17471 17472 html += '<h2>Domanda '+(n+1)+' di 12</h2>'; 17473 html += '<p>'+data[n].title+'</p>'; 17474 17475 html += '<div class="questions">'; 17476 for(x in data[n].answers){ 17477 html += '<div><input type="radio" name="q'+n+'" value="'+x+'" id="q'+n+x+'"><label for="q'+n+x+'">'+x+'</label></div>'; 17478 } 17479 html += '</div>'; 17480 17481 html += '<div class="answer hidden">'+data[n].phrase+'</div><div class="clear"></div>'; 17482 17483 html += '<button class="btn btn-primary next disabled">Avanti</button>'; 17484 17485 17486 $('#antibiotici_quiz2 .question').html(html); 17487 17488 // steps 17489 $('.steps span.active').removeClass('active'); 17490 $('.steps li:eq('+n+') span').addClass('active'); 17491 17492 if(n == 1) $('#antibiotici_quiz2 .intro_text').remove(); 17493 } 17494 function generateFinish(){ 17495 var html = ''; 17496 17497 // html += '<h2>Complimenti hai risposto correttamente a tutte le domande!</h2>'; 17498 html += '<h2>Complimenti!</h2>'; 17499 html += '<p>Hai buone conoscenze sul tema degli antibiotici e delle resistenze agli antibiotici. Sappiamo che possiamo contare anche su di te per preservare lâefficacia di queste preziose molecole a beneficio dellâuomo, degli animali e dellâambiente!</p>' 17500 // html += '<p>Inserisci il tuo indirizzo e-mail e clicca su âInviaâ per partecipare allâestrazione del 4 dicembre 2019 e vincere uno dei premi in palio. In caso di vincita, sarai contattato tramite e-mail. <br><br>
17500Partecipando al presente concorso si acconsente allâelaborazione dellâindirizzo di posta elettronica da parte dellâUfficio del medico cantonale. I dati saranno conservati per il tempo necessario alla comunicazione della vincita. In seguito saranno distrutti.</p>'; 17501 17502 // html += '<br><input type="text" class="form-control" placeholder="Inserisci la tua email" style="width: 77%; display: inline-block; margin-right: 5px"><button class="btn btn-primary send-mail">Invia</button><span class="email-error">Inserisci un email valida</span>'; 17503 17504 $('#antibiotici_quiz2 .question').html(html); 17505 17506 // steps 17507 $('.steps span.active').removeClass('active'); 17508 $('.steps li:eq('+n+') span').addClass('active'); 17509 } 17510 function next(){ 17511 // generateFinish(); 17512 n++; 17513 if(n < data.length){ 17514 generateQuestion(); 17515 } 17516 else{ 17517 generateFinish(); 17518 } 17519 } 17520 function check(){ 17521 $('.questions .error, .questions .success').attr('class', ''); 17522 if(data[n].answers[$(this).val()]){ 17523 $('.next').removeClass('disabled'); 17524 $(this).parent().addClass('success'); 17525 } 17526 else{ 17527 $('.next').addClass('disabled'); 17528 $(this).parent().addClass('error'); 17529 } 17530 $('.answer').removeClass('hidden'); 17531 } 17532 function sendMail(){ 17533 var v = $(this).prev().val(); 17534 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,}))$/; 17535 if(v && re.test(v)){ 17536 $('span.email-error').hide(); 17537 var t = $(this); 17538 $.post('/fileadmin/DSS/DSP/UMC/quiz/send.php', { email: v }, function (r){ 17539 if(r == 'ok'){ 17540 t.after('<p>Invio riuscito, grazie di aver partecipato.<br><a href="https://www4.ti.ch/index.php?id=103574">Vai alla campagna antibiotici per scoprire altre informazioni!</a></p>'); 17541 t.prev().remove(); 17542 t.remove(); 17543 } 17544 else t.after('<p>Invio non riuscito, riprovare più tardi.</p>'); 17545 }); 17546 } 17547 else $('span.email-error').css('display', 'block'); 17548 } 17549 init(); 17550} 17551function initRassegnaStampa(){ 17552 17553 var startDate; 17554 var endDate; 17555 17556 function init(){ 17557 if($('.daterange').length) setDaterange(); 17558 else if($('.datechooser').length) setDatepicker(); 17559 } 17560 function setDaterange(){ 17561 17562 var startDate = false; 17563 var endDate = false; 17564 17565 if($('#periodoMain').text().indexOf('Periodo') == -1){ 17566 var text = $('#periodoMain').text(); 17567 text=text.replace(/\s/g, ''); 17568 $("#periodo").val(text); 17569 var tmp = text.split('-'); 17570 startDate = tmp[0]; 17571 endDate = tmp[1]; 17572 } 17573 17574 $('.daterange').daterangepicker({ 17575 autoUpdateInput: false, 17576 startDate: startDate, 17577 endDate: endDate, 17578 showDropdowns: true, 17579 minDate: '01.02.1992', 17580 maxDate: moment().format('DD.MM.YYYY'), 17581 locale: { 17582 format: 'DD.MM.YYYY', 17583 firstDay: 1, 17584 cancelLabel: 'Cancella', 17585 applyLabel: 'Applica', 17586 customRangeLabel: "Custom", 17587 daysOfWeek: ["Do","Lu","Ma","Me","Gi","Ve", "Sa"], 17588 monthNames: ["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"] 17589 } 17590 }, 17591 function(start, end) { 17592 var startDate = start; 17593 var endDate = end; 17594 17595 var val=startDate.format('DD.MM.YYYY') + '-' + endDate.format('DD.MM.YYYY'); 17596 $("#periodo").val(val); 17597 $('#ricerca').submit(); 17598 } 17599 ); 17600 17601 $('.daterange').on('apply.daterangepicker', function(ev, picker) { 17602 $(this).html('<span class="filter-option pull-left"><b>'+picker.startDate.format('DD.MM.YYYY') + ' - ' + picker.endDate.format('DD.MM.YYYY')+'</b></span><span class="calendar"></span>'); 17603 }); 17604 17605 $('.daterange').on('cancel.daterangepicker', function(ev, picker) { 17606 $(this).html('<span class="filter-option pull-left">Periodo</span><span class="caret"></span>'); 17607 }); 17608 } 17609 function setDatepicker(){ 17610 $.fn.datepicker.dates['it'] = { 17611 days: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"], 17612 daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"], 17613 daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"], 17614 months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], 17615 monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"], 17616 today: "Oggi", 17617 clear: "Svuota" 17618 }; 17619 17620 $('.datechooser').datepicker({ 17621 format: "d MM", 17622 inline: true, 17623 todayHighlight: true, 17624 language: 'it', 17625 weekStart: 1, 17626 endDate: moment().format('DD.MM.YYYY'), 17627 }).on('changeDate', function (e){ 17628 $('.datechooser').html(e.format()+' <span class="caret"></span>'); 17629 val=$(this).attr('data-url'); 17630 window.location.href =val+"?data="+e.format("d.m.yyyy"); 17631 }); 17632 17633 17634 // Floating titles 17635 var floating_data = []; 17636 $('.rassegna-stampa h3').each(function (n){ 17637 floating_data.push({ 17638 top: $(this).offset().top 17639 }); 17640 $('.rassegna-stampa').append('<div class="floating_title hidden f'+n+'"><div class="inner"><h3>'+$(this).text()+'</h3></div></div>'); 17641 }); 17642 var floating_title_shown; 17643 $(window).scroll(function (e){ 17644 for(x=floating_data.length-1;x>=0;x--){ 17645 if($(window).scrollTop() > floating_data[x].top){ 17646 if(floating_title_shown != x){ 17647 $('.floating_title:not(.hidden)').addClass('hidden'); 17648 $('.floating_title.f'+x).removeClass('hidden'); 17649 floating_title_shown = x; 17650 } 17651 break; 17652 } 17653 } 17654 if($(window).scrollTop() < floating_data[0].top){ 17655 if(floating_title_shown == 0){ 17656 $('.floating_title.f0').addClass('hidden'); 17657 floating_title_shown = -1; 17658 } 17659 } 17660 }).trigger('scroll'); 17661 } 17662 init(); 17663 17664 $(".dropdownTestata li a").click(function() { 17665 val=$(this).attr('data-valore'); 17666 $("#idTestata").val(val); 17667 $('#ricerca').submit(); 17668 17669 }); 17670 17671 $(".dropdownDipartimenti li a").click(function() { 17672 val=$(this).attr('data-valore'); 17673 $("#dipartimento").val(val); 17674 $('#ricerca').submit(); 17675 17676 }); 17677} 17678 17679function initRicerca() { 17680 17681
17682 function init() { 17683 // $('.search-results').hide(); 17684 $('#' + tiporicerca).removeClass('hidden'); 17685 $('#navMenu a[data-search=' + tiporicerca + ']').addClass('active'); 17686 17687 $('#navMenu .list-group a').click(click); 17688 17689 } 17690 function click(e) { 17691 17692 e.preventDefault(); 17693 $('.search-results').addClass('hidden'); 17694 $('#' + $(this).attr('data-search')).removeClass('hidden'); 17695 $('#navMenu a.active').removeClass('active'); 17696 $(this).addClass('active'); 17697 17698 } 17699 init(); 17700} 17701 17702 17703var overlayOpener; 17704function initPageSearch() { 17705 17706 var dipids = { 17707 1009: 'can', 17708 1110: 'dt', 17709 1113: 'decs', 17710 1111: 'dfe', 17711 1037: 'di', 17712 1017: 'dss' 17713 }; 17714 17715 // $('#navMenu1 .list-group a').click(function (e){ 17716 // e.preventDefault(); 17717 17718 // if(!$(this).parent().hasClass('active')){ 17719 // var url = $(this).attr('href'); 17720 // loadResults(url); 17721 // } 17722 // }); 17723 17724 // $('.risultatiTutti').on('click', '.divSpagina a', pagination); 17725 17726 function pagination(e) { 17727 e.preventDefault(); 17728 17729 if (!$(this).hasClass('active')) { 17730 17731 $(this).siblings('.active').removeClass('active'); 17732 $(this).addClass('active'); 17733 17734 var url = $(this).attr('href'); 17735 17736 loadResults(url); 17737 } 17738 } 17739 17740 function loadResults(url) { 17741 var searchFrom = '<div class="risultatiTutti">'; 17742 var searchTo = '<form action="" method="POST" name="next"></form>'; 17743 17744 $.get(url, {}, function (r) { 17745 var p = r.indexOf(searchFrom); 17746 if (p > -1) { 17747 tmp = r.substring(p + searchFrom.length); 17748 17749 var p = tmp.indexOf(searchTo); 17750 if (p > -1) { 17751 tmp2 = tmp.substring(0, p + searchTo.length); 17752 17753 // console.log(tmp2); 17754 $('.risultatiTutti').html(tmp2); 17755 } 17756 } 17757 }); 17758 } 17759 17760 17761 17762 function click(e) { 17763 e.preventDefault(); 17764 17765 if (!$(this).hasClass('opened')) { 17766 $(this).addClass('opened'); 17767 17768 overlayOpener = $(this); 17769 17770 if ($('header .right a.organigramma.opened').length) { 17771 $('header .right a.organigramma.opened').removeClass('opened'); 17772 $('#organigramma').remove(); 17773 } 17774 if ($('#contact-form').length) $('#contact-form').remove(); 17775 17776 if (!$('.overlay').length) showOverlay($(this)); 17777 17778 var url = ''; 17779 var tmp = $('header .organigramma').attr('data-dipid'); 17780 var dip = (tmp && dipids[tmp]) ? dipids[tmp] : false; 17781 var dip_link = (dip != false) ? '/' + dip : ''; 17782 var field = (dip) ? '<input type="hidden" name="site" value="' + ((dip.toUpperCase() == '/') ? '' : dip.toUpperCase()) + '">' : ''; 17783 17784 if (url) { 17785 dip_link = '/' + url; 17786 if (dip_link == '/') dip_link = ''; 17787 field = '<input type="hidden" name="site" value="' + url.toUpperCase() + '">'; 17788 } 17789 17790 var dip_title = ''; 17791 // if (dip) { 17792 // if (dip == 'dfe') dip_title = "<h2>Dipartimento delle finanze e dell'economia</h2>"; 17793 // else if (dip == 'dt') dip_title = "<h2>Dipartimento del territorio</h2>"; 17794 // else if (dip == 'di') dip_title = "<h2>Dipartimento delle istituzioni</h2>"; 17795 // else if (dip == 'can') dip_title = "<h2>Cancelleria dello Stato</h2>"; 17796 // else if (dip == 'dss') dip_title = "<h2>Dipartimento della sanità e della socialità </h2>"; 17797 // else if (dip == 'decs') dip_title = "<h2>Dipartimento dell'educazione, della cultura e dello sport</h2>"; 17798 // } 17799 17800 17801 margin = (!dip) ? ' style="margin-bottom: 50px"' : ''; 17802 17803 var html = '<div class="overlay-content ricerca fields" role="dialog"><h1'+margin+'>Cerca su www.ti.ch</h1><div class="row"><div class="col-xs-8">'; 17804 html += '<form action="https://www4.ti.ch/index.php?id=68396" method=post>' 17805 html += '<div class="input-group"><label class="hidden" for="cerca_sito">Inserisci un termine di ricerca</label><input class="form-control" id="q" name="tx_tichgenricerca_ricerca[q]" maxlength="256" size="32" placeholder="p. es. ufficio, collaboratore, formulario, servizio, numero" id="cerca_sito" aria-label="indicare il termine da ricercare" autocomplete="off"><span class="input-group-btn"><button class="btn btn-default btn-form" type=submit aria-label="ricerca"><i class="fa fa-search" aria-hidden="true"></i></button></span><input type="hidden" name="tx_tichgenricerca_ricerca[tipoFiltro]" value="risultatiGsa"><input type="hidden" name="tx_tichgenricerca_ricerca[site]" value="raccolta_completa" id="site"><input type="hidden" name="tx_tichgenricerca_ricerca[client]" value="ti" id="client"><input type="hidden" name="tx_tichgenricerca_ricerca[resetSessione]" value="1"></div>' 17806 html += '</form>' 17807 html += '</div></div></div>'; 17808 17809 // $('body').append(html); 17810 $('.overlay-close').before(html); 17811 $('.overlay-content.ricerca').show(); 17812 17813 resizeOverlay(); 17814 suggestions(); 17815 17816 17817 $('#q').focus(); 17818 window.scrollTo(0, 0); 17819 document.body.scrollTop = 0; 17820 } 17821 } 17822 17823 function suggestions() { 17824 17825 17826 $(".overlay-content.ricerca input.form-control").autocomplete({ 17827 source: function (request, response) { 17828 $.ajax({ 17829 url: "//ricerca.ti.ch/suggest?client=TI&site=raccolta_completa&max=5&format=rich", 17830 dataType: "jsonp", 17831 data: { 17832 q: request.term 17833 }, 17834 success: function (data) { 17835 response($.map(data.results, function (item) { 17836 return { 17837 label: item.name, 17838 value: item.name 17839 } 17840 })); 17841 } 17842 }); 17843 }, 17844 }); 17845 } 17846 17847 $('header .right a[data-search]').click(click); 17848 17849 $('#skiplink2').keydown(function (e){ 17850 if(e.keyCode == 13){ 17851 e.preventDefault(); 17852 $('header .right a[data-search]').trigger('click'); 17853 } 17854 }) 17855 17856 mouseTrap($('#cerca_sito'), $('.overlay-close a')); 17857 17858 setTimeout(function () { 17859 // if (typeof $.ui === "undefined") $.getScript('/typo3conf/ext/theme/Resources/Public/js/jquery-ui.js'); 17860 if (typeof $.ui === "undefined") $.getScript('/typo3conf/ext/theme/Resources/Public/js/jquery-ui.js'); 17861 if ($('head link[href*="query-ui"]').length == 0) $('head').append('<link rel="stylesheet" type="text/css" href="/typo3conf/ext/theme/Resources/Public/css/jquery-ui.css">'); 17862 }, 500); 17863 17864 if($('.user-ricerca-pi1').length){ 17865 setTimeout(function (){ 17866 $('.risultatiTutti .lista.link li:first a:first').focus(); 17867 }, 500); 17868 } 17869} 17870/* Sai perché */ 17871function initSaiperche() {
17872 function init() { 17873 $('.sapevi-che a.refresh').click(click); 17874 } 17875 function click(e) { 17876 e.preventDefault(); 17877 $.getJSON('index.php?eID=losapeviche', function (r) { 17878 $('.sapevi-che h3').html(r.title); 17879 $('.sapevi-che p').html(r.text); 17880 $('.sapevi-che img').attr('src', r.image); 17881 }); 17882 } 17883 init(); 17884} 17885/* Sala Stampa */ 17886function initSelectSalaStampa() { 17887 jQuery('.selectpicker').selectpicker({ 17888 'selectedText': 'cat' 17889 }); 17890} 17891function initSchedarioUTPG(){ 17892 17893$(".dropdownStato li a").click(function() { 17894 val=$(this).attr('data-valore'); 17895 $("#idStato").val(val); 17896 $('#ricerca').submit(); 17897 17898 }); 17899 17900 $('#anno').datepicker({ 17901 format: "yyyy", 17902 viewMode: "years", 17903 minViewMode: "years", 17904 }).on('changeDate', function (e){ 17905 $('#anno').html('<span class="filter-option pull-left">Nel '+e.format()+'</span><span class="caret"></span>'); 17906 $("#idAnno").val(e.format()); 17907 $('#ricerca').submit(); 17908 }); 17909 17910 17911 $.fn.datepicker.dates['it'] = { 17912 days: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"], 17913 daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"], 17914 daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"], 17915 months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], 17916 monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"], 17917 today: "Oggi", 17918 clear: "Svuota" 17919 }; 17920 17921 $('#data').datepicker({ 17922 format: "dd.mm.yyyy", 17923 language: 'it', 17924 }).on('changeDate', function (e){ 17925 $('#data').html('<span class="filter-option pull-left">Il '+e.format()+'</span><span class="caret"></span>'); 17926 $("#idData").val(e.format()); 17927 $('#ricerca').submit(); 17928 }); 17929 17930$("#printSchedario").click(function() { 17931 window.print(); 17932}); 17933 17934} 17935function initSPOPMap(){ 17936 17937 function init(){ 17938 d3.select('svg').selectAll('g#Servizi_regionali_dello_stato_civile circle, g#Servizi_regionali_degli_stranieri circle, g#Centri_di_registrazione circle, g#nuovi_bellinzona circle').on('mouseover', mousein).on('mouseout', mouseout).on('click', click); 17939 17940 var popOverSettings = { 17941 placement: 'top', 17942 container: 'body', 17943 html: true, 17944 selector: '[rel="popover"]', 17945 content: function () { 17946 return di_mappa_data[$(this).attr('data-id')].content 17947 } 17948 } 17949 17950 $('body').popover(popOverSettings); 17951 17952 $('body').on('click', function (e) { 17953 17954 if($('.popover.fade').length > 1) $('.popover.fade:eq(0)').remove(); 17955 17956 // if($(e.target).is('[rel="popover"]')) $('.popover.fade').remove(); 17957 17958 // $('[rel="popover"]').each(function () { 17959 // //the 'is' for buttons that trigger popups 17960 // //the 'has' for icons within a button that triggers a popup 17961 // if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { 17962 // console.log($(this)) 17963 // // $(this).popover('hide'); 17964 // // $(this).popover(popOverSettings); 17965 // } 17966 // }); 17967 }); 17968 } 17969 function mousein(){ 17970 $(this).trigger('click'); 17971 $(this).css('fill', '#c33'); 17972 } 17973 function mouseout(){ 17974 $(this).trigger('click'); 17975 $(this).removeAttr('style'); 17976 } 17977 function click(){ 17978 var id = $(this).attr('data-id'); 17979 location.href = di_mappa_data[id].link; 17980 17981 // if($(this).parent().is('#Uffici_esecuzione')) location.href = 'https://www4.ti.ch/index.php?id=87273#address'+id; 17982 // else location.href = 'https://www4.ti.ch/index.php?id=89204#address'+id; 17983 } 17984 init(); 17985} 17986function initSteppers(){ 17987 $('.steppers').each(function (){ 17988 initStepper($(this)) 17989 }) 17990 17991 var h = location.hash.substring(1) 17992 if(h){ 17993 var tmp = h.split('/') 17994 var s = $('.steppers[data-name='+tmp[0]+']') 17995 if(s.length && parseInt(tmp[1]) > 0){ 17996 if(parseInt(tmp[1]) > 1) s.find('.tabs li:eq('+parseInt(tmp[1])+') a').removeClass('disabled') 17997 s.find('.tabs li:eq('+parseInt(tmp[1])+') a').trigger('click') 17998 $('body, html').animate({ scrollTop: s.prev().offset().top - 50}, 200) 17999 } 18000 } 18001} 18002 18003function initStepper(o){ 18004 var step = 0 18005 var steps = 0
18006 function init(){ 18007 o.find('.tabs a').click(changeTab) 18008 18009 steps = o.find('.tabs a').length 18010 initNavigation() 18011 18012 o.find('.footer .prev').click(prev) 18013 o.find('.footer .next').click(next) 18014 18015 18016 if(o.hasClass('disable-steps')) o.find('.tabs li:eq(2) a, .tabs li:eq(3) a').addClass('disabled') 18017 } 18018 function changeTab(e){ 18019 e.preventDefault() 18020 18021 if(!$(this).hasClass('disabled')){ 18022 var i = $(this).parent().index() 18023 18024 o.find('.tabs .selected').addClass('viewed') 18025 o.find('.tabs .selected').removeClass('selected') 18026 $(this).addClass('selected') 18027 18028 o.find('.navigation a.active').removeClass('active') 18029 o.find('.navigation a:eq('+i+')').addClass('active') 18030 18031 step = i 18032 18033 if(step == 0) o.find('.prev').addClass('hidden') 18034 else o.find('.prev').removeClass('hidden') 18035 18036 if(step == (steps - 1)) o.find('.next').addClass('hidden') 18037 else o.find('.next').removeClass('hidden') 18038 18039 o.find('.body > div').addClass('hidden') 18040 o.find('.body > div.t'+(i+1)).removeClass('hidden') 18041 18042 o.find('.tabs li:eq('+(step+1)+') a').removeClass('disabled') 18043 18044 // for(var n=step;n<steps;n++){ 18045 // o.find('.tabs li:eq('+n+') a').removeClass('viewed') 18046 // } 18047 } 18048 } 18049 function initNavigation(){ 18050 console.log(steps) 18051 for(i=0;i<steps;i++) o.find('.navigation').append('<a href="#"></a>') 18052 o.find('.navigation a:first').addClass('active') 18053 18054 o.find('.navigation a').click(changeNavigation) 18055 } 18056 function changeNavigation(e){ 18057 e.preventDefault() 18058 if(!$(this).hasClass('active')){ 18059 o.find('.tabs li:eq('+$(this).index()+') a').trigger('click') 18060 } 18061 } 18062 function prev(e){ 18063 e.preventDefault() 18064 18065 if(step > 0){ 18066 step-- 18067 o.find('.tabs li:eq('+step+') a').trigger('click') 18068 18069 // if(step == 0) o.find('.prev').addClass('hidden') 18070 // o.find('.next').removeClass('hidden') 18071 18072 // o.find('.navigation a.active').removeClass('active') 18073 // o.find('.navigation a:eq('+step+')').addClass('active') 18074 18075 // o.find('.body > div').addClass('hidden') 18076 // o.find('.body > div.t'+(step+1)).removeClass('hidden') 18077 } 18078 } 18079 function next(e){ 18080 e.preventDefault() 18081 18082 if(step < steps){ 18083 step++ 18084 o.find('.tabs li:eq('+step+') a').trigger('click') 18085 18086 // if(step == (steps - 1)) o.find('.next').addClass('hidden') 18087 // o.find('.prev').removeClass('hidden') 18088 18089 // o.find('.navigation a.active').removeClass('active') 18090 // o.find('.navigation a:eq('+step+')').addClass('active') 18091 18092 // o.find('.body > div').addClass('hidden') 18093 // o.find('.body > div.t'+(step+1)).removeClass('hidden') 18094 } 18095 } 18096 init() 18097} 18098var onVisibleElements = {} 18099 18100function onVisible(element, callback) { 18101 // console.log('onVisible') 18102 var id = $(element).attr('id') 18103 onVisibleElements[id] = { 18104 e: $(element), 18105 top: $(element).offset().top, 18106 bottom: $(element).offset().top + $(element).outerHeight(), 18107 visible: false, 18108 callback: callback 18109 } 18110 18111 // $() 18112 18113 // if(callback) callback() 18114} 18115function initSviluppoEconomicoHome(){ 18116 18117 18118 18119 // animateCSS('#main_title', 'zoomIn'); 18120 // animateCSS('.entrata-sviluppo-economico .empty h2', 'zoomIn'); 18121 18122 onVisible($('#main_title'), function (){ 18123 animateCSS('#main_title', 'zoomIn'); 18124 }) 18125 onVisible($('#secondary_title'), function (){ 18126 animateCSS('#secondary_title', 'zoomIn'); 18127 animateCSS('#secondary_title_text', 'zoomIn'); 18128 }) 18129 18130 $('.entrata-sviluppo-economico .empty h2').attr('id', 'vision_title') 18131 onVisible($('#vision_title'), function (){ 18132 animateCSS('#vision_title', 'zoomIn'); 18133 }) 18134 18135 onVisible($('#vision_text'), function (){ 18136 animateCSS('#vision_text', 'zoomIn'); 18137 }) 18138 18139 onVisible($('#ambiti_title'), function (){ 18140 animateCSS('#ambiti_title', 'zoomIn'); 18141 }) 18142 onVisible($('#ambiti_icons'), function (){ 18143 animateCSS('#ambiti_icons', 'zoomIn'); 18144 }) 18145 18146 18147 /*onVisible($('#pp_title'), function (){ 18148 animateCSS('#pp_title', 'zoomIn'); 18149 }) 18150 18151 onVisible($('#iniziative_element'), function (){ 18152 animateCSS('#iniziative_element', 'zoomIn'); 18153 setTimeout(function () { 18154 animateCSS('#storie_element', 'zoomIn'); 18155 18156 setTimeout(function () { 18157 animateCSS('#ultimo_tweet', 'zoomIn'); 18158 }, 1500); 18159 18160 }, 1500); 18161 18162 })*/ 18163 18164 18165 $('.entrata-sviluppo-economico-home ul').attr('id', 'arrows') 18166 onVisible($('#arrows'), function (){ 18167 var n = 0 18168 var interval = setInterval(function (){ 18169 $('.entrata-sviluppo-economico-home li:eq('+n+')').addClass('in') 18170 n++ 18171 if($('.entrata-sviluppo-economico-home li').length == n) clearInterval(interval) 18172 }, 200) 18173 }) 18174 18175 // setTimeout(function (){ 18176 // var n = 0 18177 // var interval = setInterval(function (){ 18178 // $('.entrata-sviluppo-economico-home li:eq('+n+')').addClass('in') 18179 // n++ 18180 // if($('.entrata-sviluppo-economico-home li').length == n) clearInterval(interval) 18181 // }, 200) 18182 // // $('.title-stripe h1').attr('class', 'animate__animated animate__bounce animate__repeat-2s') 18183 // }, 200) 18184 18185 $('.entrata-sviluppo-economico-home li a').click(function (e){ 18186 e.preventDefault() 18187 var i = $(this).parents('li').index() 18188 18189 $('.entrata-sviluppo-economico-home .map .in > div').addClass('hidden') 18190 $('.entrata-sviluppo-economico-home .map .p'+(i+1)).removeClass('hidden') 18191 }) 18192 18193 $('.entrata-sviluppo-economico-home li a').hover(function (){ 18194 var i = $(this).parents('li').index() 18195 18196 $('.entrata-sviluppo-economico-home .map .in > div').addClass('hidden') 18197 $('.entrata-sviluppo-economico-home .map .p'+(i+1)).removeClass('hidden') 18198 }, function (){ 18199 $('.entrata-sviluppo-economico-home .map .in > div').addClass('hidden') 18200 $('.entrata-sviluppo-economico-home .map .in .empty').removeClass('hidden') 18201 }) 18202} 18203 18204// const animateCSS = (element, animation, prefix = 'animate__') => 18205// // We create a Promise and return it
18206// new Promise((resolve, reject) => { 18207// const animationName = `${prefix}${animation}`; 18208// const node = document.querySelector(element); 18209 18210// node.classList.add(`${prefix}animated`, animationName); 18211 18212// // When the animation ends, we clean the classes and resolve the Promise 18213// function handleAnimationEnd(event) { 18214// event.stopPropagation(); 18215// node.classList.remove(`${prefix}animated`, animationName); 18216// node.classList.add('animate__done') 18217// resolve('Animation ended'); 18218// } 18219 18220// node.addEventListener('animationend', handleAnimationEnd, {once: true}); 18221// }); 18222 18223function animateCSS(element, animation, prefix){ 18224 // We create a Promise and return it 18225 prefix = 'animate__' 18226 new Promise(function (resolve, reject){ 18227 animationName = prefix+animation; 18228 node = document.querySelector(element); 18229 18230 node.classList.add(prefix+'animated', animationName); 18231 18232 // When the animation ends, we clean the classes and resolve the Promise 18233 function handleAnimationEnd(event) { 18234 event.stopPropagation(); 18235 node.classList.remove(prefix+'animated', animationName); 18236 node.classList.add('animate__done') 18237 resolve('Animation ended'); 18238 } 18239 18240 node.addEventListener('animationend', handleAnimationEnd, {once: true}); 18241 }); 18242} 18243function initSviluppoEconomico(){ 18244 var beneficiari_list = {}; 18245 var lang; 18246 var schemaLoaded = false; 18247 var attivitaUrls = { 18248 999: 'formazione', 18249 998: 'spazi', 18250 997: 'sviluppo', 18251 996: 'finanziamento', 18252 995: 'coaching', 18253 994: 'trasferimento' 18254 }; 18255 var last_detail = false; 18256 var last_detail_id = false; 18257 var button_texts = { 18258 'en': { 18259 'back': 'Back to the list of results', 18260 'print': 'PRINT', 18261 'share': 'SHARE', 18262 'contact': 'CONTACTS' 18263 }, 18264 'it': { 18265 'back': 'Torna alla lista dei risultati', 18266 'print': 'STAMPA', 18267 'share': 'CONDIVIDI', 18268 'contact': 'CONTATTI' 18269 } 18270 }; 18271 var myWowzaPlayer; 18272 function init(){ 18273 18274 // selettore lingua 18275 lang = $('div[data-lang]').length ? $('div[data-lang]').attr('data-lang') : 'it'; 18276 // $('header .languages a:eq('+((lang == 'en') ? 1 : 0)+')').addClass('selected') 18277 18278 18279 // IE fix 18280 if(is_explorer){ 18281 $('.sviluppo-economico .content-selector .tabs > a').each(function (){ 18282 $(this).children().find('svg').height($(this).outerHeight()-55).width($(this).outerWidth()-55); 18283 }); 18284 } 18285 18286 // Text opener 18287 $('.overlay-text a.opener').click(textOverlay); 18288 $('.overlay-text a.closer').click(closeTextOverlay); 18289 18290 18291 // Hash navigation 18292 window.addEventListener("hashchange", hashChanged, false); 18293 hashChanged(); 18294 18295 // $('.open-map').click(initSchema); 18296 // $('a.close').click(function (){ 18297 // $('.svg-overlay, .svg-ontop.column, .svg-column').hide(); 18298 // }); 18299 18300 18301 // Carousels 18302 $('#carousel-example-generic').on('slide.bs.carousel', function () { 18303 $('#carousel-example-generic .tich-carousel-indicators li.active').removeClass('active'); 18304 setTimeout(function (){ 18305 $('#carousel-example-generic .tich-carousel-indicators li:eq('+$('#carousel-example-generic .carousel-inner .active').index()+')').addClass('active'); 18306 }, 800); 18307 }) 18308 18309 $('#carousel-example-generic2').on('slide.bs.carousel', function () { 18310 $('#carousel-example-generic2 .tich-carousel-indicators li.active').removeClass('active'); 18311 setTimeout(function (){ 18312 $('#carousel-example-generic2 .tich-carousel-indicators li:eq('+$('#carousel-example-generic2 .carousel-inner .active').index()+')').addClass('active'); 18313 }, 800); 18314 }); 18315 18316 $('#carousel-example-generic3').on('slide.bs.carousel', function () { 18317 $('#carousel-example-generic3 .tich-carousel-indicators li.active').removeClass('active'); 18318 setTimeout(function (){ 18319 $('#carousel-example-generic3 .tich-carousel-indicators li:eq('+$('#carousel-example-generic3 .carousel-inner .active').index()+')').addClass('active'); 18320 }, 800); 18321 }); 18322 18323 18324 // Phrase slider 18325 $('.phrase-slider').each(function (){ 18326 initPhraseSlider($(this)); 18327 }); 18328 18329 18330 // Internal link 18331 $('.sri-internal-link').click(function (e){ 18332 e.preventDefault(); 18333 location.href = $('#maincontent .tabs a:eq(3)').attr('href'); 18334 }); 18335 18336 $('.video-link').click(function (e){ 18337 e.preventDefault(); 18338 18339 var r = 'playerElement199';
18340 18341 $('body').prepend('<script> $("#playerElement199.wowzaPlayer").each(function (index) {CreatePlayer($(this).data(\'player\'), $(this).data(\'directory\'), $(this).data(\'file\'), $(this).data(\'titolo\'), $(this).data(\'descrizione\'), $(this).data(\'copertina\'), $(this).data(\'autoplay\'));});</script><div id="lightbox_video"><div id="playerDiv199" style="width:100%; height:0; padding:0 0 56.25% 0"> <video id="playerElement199" class="wowzaPlayer video-js vjs-16-9" data-player="199" data-directory="dfe/" data-file="mp4:dfe/de/Finale_Portale_impresa_1280_720.mp4" data-copertina="fileadmin/DFE/DE-PORTALE-IMPRESA/video_schermo_locarno.png" data-titolo="" data-descrizione=""></video></div><a href="#" id="close_lightbox_video" style="position: absolute; top: 0; right: 0; padding: 0 10px; font-size: 30px; color: #FFF"><i class="fa fa-times"></i></a></div>') 18342 18343 $('#close_lightbox_video').click(function (e){ 18344 e.preventDefault(); 18345 $('#lightbox_video').remove(); 18346 }) 18347 }); 18348 18349 $('.open-modal').click(openInternalModal); 18350 $('.close-modal').click(closeInternalModal); 18351 } 18352 function hashChanged(first){ 18353 var h = location.hash.substring(1); 18354 if(h){ 18355 if(h.indexOf('/') > -1){ 18356 var tmp = h.split('/'); 18357 18358 $('html, body').animate({scrollTop:0}, 600); 18359 18360 if(tmp.length == 2){ 18361 openSchema(function (){ 18362 $('.benefactor-row a.checked').removeClass('checked'); 18363 18364 var item = $('.benefactor-row [data-id='+tmp[1]+']'); 18365 item.addClass('checked'); 18366 18367 $('.activities-row .checked').removeClass('checked'); 18368 18369 18370 closeDetail(); 18371 18372 filter(); 18373 }); 18374 18375 } 18376 else if(tmp.length == 3 || tmp.length == 4){ 18377 openSchema(function (r){ 18378 $('.benefactor-row a.checked').removeClass('checked'); 18379 18380 var item = $('.benefactor-row [data-id='+tmp[1]+']'); 18381 item.addClass('checked'); 18382 18383 if(parseInt(tmp[2]) > 0){ 18384 detail(tmp[2]); 18385 } 18386 else{ 18387 if(tmp[2].indexOf('+') > -1){ 18388 var tmp2 = tmp[2].split('+'); 18389 } 18390 else tmp2 = new Array(tmp[2]); 18391 18392 $('.activities-row .checked').removeClass('checked'); 18393 for(x in tmp2){ 18394 $('.activities-row [data-url='+tmp2[x]+']').addClass('checked'); 18395 } 18396 18397 if(tmp.length == 4) detail(tmp[3]); 18398 else closeDetail() 18399 } 18400 18401 filter(); 18402 }); 18403 } 18404 } 18405 else{ 18406 var t = $('.content-selector .tabs a[data-id='+h+']'); 18407 if(t.length && !t.hasClass('selected')){ 18408 $('.sviluppo-economico .content-selector .tabs a.selected').removeClass('selected') 18409 t.addClass('selected'); 18410 18411 var i = t.index() + 1; 18412 $('.arrow > div').attr('class', 'single e'+i); 18413 18414 $('.tcontent.show').removeClass('show'); 18415 $('.tcontent.t'+i).addClass('show'); 18416 18417 $('.tcontent.t'+i+' > div > p').focus(); 18418 } 18419 18420 var t = $('table.aziende_table a[data-id='+h+']'); 18421 if(t.length) t.trigger('click'); 18422 18423 ga('send','event', 'sviluppo-economio','click-'+h,'href',0,{'nonInteraction': false}); 18424 } 18425 } 18426 else{ 18427 $('.svg-overlay, .svg-ontop.column, .svg-column').hide(); 18428 } 18429 } 18430 function openSchema(callback){ 18431 if(!schemaLoaded){ 18432 18433 var t = $(this); 18434 18435 $.getJSON('typo3conf/ext/user_sviluppoeconomico/requests.php', {'load' : 1, lang: lang}, function (r){ 18436 18437 // Attività 18438 var n = 1; 18439 for(x in r.attivita){ 18440 html = '<a href="#" class="check c'+r.attivita[x].ATT_ICONA+'" data-n="'+r.attivita[x].ATT_ICONA+'" data-id="'+r.attivita[x].ATT_ID+'" data-url="'+attivitaUrls[r.attivita[x].ATT_ID]+'"><i class="fa fa-square"></i> '+r.attivita[x].ATT_NOME+'</a>'; 18441 $('.activities-row .col-xs-6:eq('+((n <= 3) ? 0 : 1)+')').append(html); 18442 n++; 18443 } 18444 $('.filters .check').click(filterAttivita); 18445 18446 18447 // Beneficiari 18448 var n = 1; 18449 for(x in r.beneficiari){ 18450 html = '<a href="#" class="" data-id="'+r.beneficiari[x].BEN_ICONA+'" data-db-id="'+r.beneficiari[x].BEN_ID+'"><span class="svg-icon '+r.beneficiari[x].BEN_ICONA+'"></span> '+r.beneficiari[x].BEN_NOME+'</a>'; 18451 $('.benefactor-row .col-xs-6:eq('+((n <= 2) ? 0 : 1)+')').append(html); 18452 n++; 18453 } 18454 $('.benefactor-row a').click(filterBeneficiari); 18455 18456 18457 // beneficiari_list[] 18458 18459 // Aziende 18460 // var n = 1; 18461 for(x in r.aziende){ 18462 var attivita = '';
18463 for(y in r.aziende[x]['attivita']) attivita += '<img src="fileadmin/DFE/DE-PORTALE-IMPRESA/images/'+r.aziende[x].attivita[y].ATT_ICONA+'.png" alt="" data-n="'+r.aziende[x].attivita[y].ATT_ICONA+'" title="'+r.aziende[x].attivita[y].ATT_NOME+'" />'; 18464 18465 var beneficiari = ''; 18466 for(y in r.aziende[x]['beneficiari']) beneficiari += '<span class="svg-icon '+r.aziende[x].beneficiari[y].BEN_ICONA+'" title="'+r.aziende[x].beneficiari[y].BEN_NOME+'"></span>'; 18467 18468 html = '<tr><td><a href="#" data-id="'+r.aziende[x].AZI_ID+'">'+r.aziende[x].AZI_NOME+'</a></td><td>'+attivita+'</td><td>'+beneficiari+'</td></tr>'; 18469 $('.aziende_table tbody').append(html); 18470 // n++; 18471 18472 18473 var o = $('[data-id-azienda='+r.aziende[x].AZI_ID+']'); 18474 if(o.length){ 18475 var beneficiari = new Array(); 18476 for(y in r.aziende[x]['beneficiari']) beneficiari.push(r.aziende[x].benef
18476iciari[y].ID); 18477 o.attr('data-id-attivita', beneficiari.join(',')).attr('title', r.aziende[x].AZI_NOME); 18478 } 18479 18480 } 18481 $('.aziende_table a').click(showDetail); 18482 $('.svg-column').on('click', '.back', closeDetailEvent); 18483 18484 18485 // Pallini attività 18486 d3.select('svg#fiore').selectAll('g.attivita, circle.attivita, path.attivita').on('click', attivitaEvent); 18487 18488 18489 d3.select('svg#fiore').selectAll('*[data-id-azienda]').on('click', selectAzienda).on('mouseover', showAziendaTooltip).on('mouseout', hideAziendaTooltip); 18490 18491 if(is_explorer){ 18492 var w = $('.sviluppo-economico .svg-ontop .filters').outerWidth(); 18493 $('svg#fiore').width(w).height(w); 18494 $(window).resize(function (){ 18495 var w = $('.sviluppo-economico .svg-ontop .filters').outerWidth(); 18496 $('svg#fiore').width(w).height(w); 18497 }) 18498 } 18499 if (typeof callback === "function") callback(false); 18500 }); 18501 18502 18503 schemaLoaded = true; 18504 } 18505 else{ 18506 // if(!$('.benefactor-row a[data-id='+$(this).attr('data-beneficiario')+']').hasClass('checked')) $('.benefactor-row a[data-id='+$(this).attr('data-beneficiario')+']').trigger('click'); 18507 18508 if (typeof callback === "function") callback(true); 18509 } 18510 18511 // var h = window.innerHeight|| document.documentElement.clientHeight || document.body.clientHeight; 18512 18513 if($('.background').outerHeight() > 50) var h = $('.background').outerHeight() + $('footer').outerHeight() - 106; 18514 else var h = $('#maincontent').outerHeight() + $('footer').outerHeight() + 29; 18515 18516 $('.svg-overlay').height(h); 18517 $('.svg-column').height(h); 18518 18519 $('.svg-overlay, .svg-ontop, .svg-column').show(); 18520 } 18521 function textOverlay(e){ 18522 e.preventDefault(); 18523 18524 var p = $(this).parent().parent(); 18525 if(p.hasClass('opened')){ 18526 p.removeClass('opened'); 18527 } 18528 else p.addClass('opened'); 18529 } 18530 function closeTextOverlay(e){ 18531 e.preventDefault(); 18532 18533 var p = $(this).parents('.overlay-text'); 18534 if(p.hasClass('opened')){ 18535 p.removeClass('opened'); 18536 } 18537 else p.addClass('opened'); 18538 } 18539 function showAziendaTooltip(){ 18540 if(!$('#sri_tooltip').length){ 18541 $('body').append('<div id="sri_tooltip" style="display: none"></div>'); 18542 } 18543 $('#sri_tooltip').text($(this).attr('title')).css({ top: $(this).position().top, left: $(this).position().left + $(this)[0].getBoundingClientRect().width }).show(); 18544 } 18545 function hideAziendaTooltip(){ 18546 $('#sri_tooltip').hide(); 18547 } 18548 function attivitaEvent(){ 18549 var n = $(this).attr('data-id'); 18550 $('.activities-row a[data-n='+n+']').trigger('click'); 18551 } 18552 function closeDetailEvent(e){ 18553 e.preventDefault(); 18554 18555 var url = location.href; 18556 18557 var h = location.hash; 18558 if(h.indexOf('/') > -1){ 18559 tmp = h.split('/'); 18560 if(parseInt(tmp[(tmp.length - 1)]) > 0){ 18561 tmp.pop(); 18562 location.hash = tmp.join('/') 18563 } 18564 } 18565 } 18566 function filterAttivita(e){ 18567 e.preventDefault(); 18568 18569 var activites = new Array(); 18570 18571 if($('.activities-row .checked').length){ 18572 $('.activities-row .checked').each(function (){ 18573 activites.push($(this).attr('data-url')); 18574 }); 18575 } 18576 18577 if(!$(this).hasClass('checked')){ 18578 activites.push($(this).attr('data-url')); 18579 } 18580 else{ 18581 var a = new Array(); 18582 for(x in activites){ 18583 if(activites[x] != $(this).attr('data-url')) a.push(activites[x]); 18584 } 18585 activites = a; 18586 } 18587 18588 var url = location.href; 18589 if(url.indexOf('#') > -1){ 18590 url = url.split('#')[0] 18591 } 18592 url += '#schema/'+$('.benefactor-row .checked').attr('data-id'); 18593 18594 if(activites.length){ 18595 url += '/'+activites.join('+'); 18596 } 18597 18598 location.href = url; 18599 } 18600 function filterBeneficiari(e){ 18601 e.preventDefault(); 18602 18603 var activites = new Array(); 18604 if($('.activities-row .checked').length){ 18605 $('.activities-row .checked').each(function (){ 18606 activites.push($(this).attr('data-url')); 18607 }); 18608 } 18609 18610 var url = location.href; 18611 if(url.indexOf('#') > -1){ 18612 url = url.split('#')[0] 18613 } 18614 url += '#schema/'+$(this).attr('data-id'); 18615 18616 if(activites.length){ 18617 url += '/'+activites.join('+'); 18618 } 18619 18620 location.href = url; 18621 } 18622 function filter(){ 18623 var data = { 18624 lang: 'en' 18625 } 18626 18627 // Attività SVG 18628 var ids = new Array(); 18629 var ns = new Array(); 18630 18631 $('.activities-row .checked').each(function (){ 18632 ids.push($(this).attr('data-id')); 18633 }); 18634 if(ids.length) data.search_attivita = ids; 18635 else{ 18636 $('.activities-row .check').each(function (){ 18637 ids.push($(this).attr('data-id')); 18638 }); 18639 data.search_attivita = ids; 18640 } 18641 18642 $('.activities-row .check.checked').each(function (){ 18643 var n = $(this).attr('data-n'); 18644 $('svg .c'+n).removeAttr('style'); 18645 }); 18646 18647 18648 // Beneficiari 18649 if($('.benefactor-row .checked').length){ 18650 data.search_beneficiari = $('.benefactor-row .checked').attr('data-db-id'); 18651 } 18652 18653 if(data.search_attivita.length || data.search_beneficiari){ 18654 if(data.search_attivita.length < 6 || data.search_beneficiari){ 18655 18656 $.getJSON('typo3conf/ext/user_sviluppoeconomico/requests.php', data, function (r){ 18657 18658 $('table.aziende_table tbody tr[data-show]').removeAttr('data-show'); 18659 $('[data-id-azienda]').removeAttr('data-show'); 18660 for(x in r){ 18661 $('table.aziende_table a[data-id='+r[x]+']').parent().parent().attr('data-show', true); 18662 $('[data-id-azienda='+r[x]+']').attr('data-show', true); 18663 } 18664 18665 18666 var n = 0; 18667 $('table.aziende_table tr[data-show]').each(function (){ 18668 if(n % 2 == 0) $(this).attr('class', 'odd'); 18669 else $(this).attr('class', 'even'); 18670 n++; 18671 }); 18672 18673 // table 18674 $('table.aziende_table tbody tr:not([data-show])').hide(); 18675 $('table.aziende_table tbody tr[data-show]').show(); 18676 18677 // svg 18678 // $('[data-id-azienda]:not([data-show])').attr('filter', 'url(#grayscale)').css('opacity', '0.5'); 18679 // $('[data-id-azienda][data-show]').attr('filter', '').css('opacity', '1'); 18680 18681 18682 // svg 18683 $('line[data-id-azienda][data-show], polygon[data-id-azienda][data-show]').css({'fill': '#dbdbdb', 'stroke': '#dbdbdb'}); 18684 18685 $('[data-id-azienda]:not([data-show])').attr('filter', 'url(#grayscale)').css('opacity', '0.5'); 18686 $('[data-id-azienda][data-show]').removeAttr('filter').css('opacity', '1'); 18687 18688 setTimeout(function (){ 18689 // $('line[filter], polygon[filter]').css('opacity', '0.5'); 18690 // $('line[data-show], polygon[data-show]').css('opacity', '1'); 18691 $('line[filter], polygon[filter]').css({'fill': '#dbdbdb', 'stroke': '#dbdbdb'}); 18692 $('line[data-show], polygon[data-show]').removeAttr('style'); 18693 18694 if($('.activities-row .check:not(.checked)').length < 6){ 18695 $('.activities-row .check:not(.checked)').each(function (){ 18696 $('line.c'+$(this).attr('data-n')+', polygon.c'+$(this).attr('data-n')).css({'fill': '#dbdbdb', 'stroke': '#dbdbdb'}); 18697 }); 18698 } 18699 }, 10) 18700 18701 18702 if(data.search_attivita.length == 6){ 18703 $('.activities-row .check').each(function (){ 18704 $('svg .c'+$(this).attr('data-n')).removeAttr('style'); 18705 }); 18706 } 18707 else{ 18708 // svg lines and circles 18709 $('.activities-row .check:not(.checked)').each(function (){ 18710 $('svg text.c'+$(this).attr('data-n')).css({'fill': '#dbdbdb'}) 18711 $('svg line.c'+$(this).attr('data-n')+', svg rect.c'+$(this).attr('data-n')+', svg circle.c'+$(this).attr('data-n')+', svg polygon.c'+$(this).attr('data-n')).css({'fill': '#dbdbdb', 'stroke': '#dbdbdb'}); 18712 }); 18713 $('.activities-row .checked').each(function (){ 18714 $('svg .c'+$(this).attr('data-n')).removeAttr('style'); 18715 }); 18716 } 18717 18718 if(r === null){ 18719 $('table.aziende_table tbody').append('<tr id="no-result"><td colspan="3">Nessun servizio disponibile.</td></tr>') 18720 } 18721 else if($('.no-result').length) $('.no-result').remove(); 18722 }); 18723 } 18724 else{ 18725 $('table.aziende_table tr').show(); 18726 18727 $('.activities-row .check').each(function (){ 18728 $('svg .c'+$(this).attr('data-n')).removeAttr('style'); 18729 }); 18730 $('[data-id-azienda]').removeAttr('filter').css('opacity', '1'); 18731 18732 $('table.aziende_table tbody tr').removeClass('odd').removeClass('even'); 18733 } 18734 18735 } 18736 else $('[data-id-azienda]').removeAttr('filter').css('opacity', '1'); 18737 18738 if(last_detail_id){ 18739 $('table.aziende_table a[data-id='+last_detail_id+']').trigger('click'); 18740 } 18741 } 18742 function showDetail(e){ 18743 e.preventDefault(); 18744 18745 var activites = new Array(); 18746 if($('.activities-row .checked').length){ 18747 $('.activities-row .checked').each(function (){ 18748 activites.push($(this).attr('data-url')); 18749 }); 18750 } 18751 18752 var url = location.href; 18753 if(url.indexOf('#') > -1){ 18754 url = url.split('#')[0] 18755 } 18756 url += '#schema/'+$('.benefactor-row .checked').attr('data-id'); 18757 18758 if(activites.length){ 18759 url += '/'+activites.join('+'); 18760 } 18761 18762 url += '/'+$(this).attr('data-id'); 18763 18764 location.href = url; 18765 } 18766 function detail(id){
18767 var nnnn = id; 18768 var p = $('table a[data-id='+id+']').parents('tr'); 18769 last_detail_id = id; 18770 18771 $.getJSON('typo3conf/ext/user_sviluppoeconomico/requests.php', { detail: id, lang: lang }, function (r){ 18772 var address = '<p>'; 18773 if(r.AZI_PRESSO) address += r.AZI_PRESSO+'<br>'; 18774 if(r.AZI_VIA) address += r.AZI_VIA+'<br>'; 18775 if(r.AZI_NAP) address += r.AZI_NAP+' '; 18776 if(r.AZI_LUOGO) address += r.AZI_LUOGO+'<br>'; 18777 if(address != '<p>') address += '<br>'; 18778 if(r.AZI_TEL) address += 'Tel: '+r.AZI_TEL+'<br>'; 18779 if(r.AZI_FAX) address += 'Fax: '+r.AZI_FAX+'<br>'; 18780 if(r.AZI_MAIL) address += '<a href="mailto:'+r.AZI_MAIL+'">'+r.AZI_MAIL+'</a><br>'; 18781 if(r.AZI_URL){ 18782 if(r.AZI_URL.indexOf('http') == -1) url = 'http://'+r.AZI_URL; 18783 else url = r.AZI_URL; 18784 address += '<a href="'+url+'" target="_blank">'+r.AZI_URL+'</a><br>'; 18785 } 18786 address += '</p>'; 18787 18788 18789 var url = location.href; 18790 if(url.indexOf('#') > -1){ 18791 url = url.split('#')[0]; 18792 } 18793 18794 var html = '<div class="detail"><a href="#" class="back btn btn-default">'+button_texts[lang].back+'</a><div class="box">'; 18795 html += '<div class="header">'; 18796 html += p.children('td:eq(1)').html(); 18797 html += p.children('td:eq(2)').html(); 18798 html += '<a href="#" class="print_scheda"><i class="fa fa-print"></i>
18798 '+button_texts[lang].print+'</a>'; 18799 html += '<a href="#" class="share_scheda"><i class="fa fa-envelope-o"></i> '+button_texts[lang].share+'</a>'; 18800 html += '<div class="clear"></div>'; 18801 html += '</div>'; 18802 html += '<div class="body">'; 18803 html += '<h3>'+r.AZI_NOME+'</h3>'; 18804 // html += r.AZI_DESCRIZIONE; 18805 18806 if(r.descriptions.length > 0){ 18807 18808 var attivita = new Array(); 18809 18810 if($('.activities-row .checked').length == 0){ 18811 $('.activities-row .check').each(function (){ 18812 attivita.push($(this).attr('data-id')); 18813 }); 18814 } 18815 else{ 18816 $('.activities-row .checked').each(function (){ 18817 attivita.push($(this).attr('data-id')); 18818 }); 18819 } 18820 18821 var beneficiari = new Array() 18822 if($('.benefactor-row .checked').length){ 18823 beneficiari.push($('.benefactor-row .checked').attr('data-db-id')); 18824 } 18825 else{ 18826 $('.benefactor-row a').each(function (){ 18827 beneficiari.push($(this).attr('data-db-id')); 18828 }); 18829 } 18830 18831 // console.log(attivita); 18832 // console.log(beneficiari); 18833 18834 // html += '<hr>'; 18835 var found = false; 18836 for(x in r.descriptions){ 18837 18838 if(attivita.indexOf(r.descriptions[x]['DES_ATT_ID']) > -1 && beneficiari.indexOf(r.descriptions[x]['DES_BEN_ID']) > -1){ 18839 var n = $('.activities-row a[data-id='+r.descriptions[x]['DES_ATT_ID']+']').attr('data-n'); 18840 html += '<div class="c'+n+'">' + $('.activities-row a[data-n='+n+']').text()+'</div>' + r.descriptions[x]['DESCRIPTION']+'<br><br>'; 18841 found = true; 18842 } 18843 } 18844 18845 if(!found) html += '<i class="fa fa-exclamation-circle" style="font-size:40px"></i> <br/>Questo servizio non si rivolge al beneficiario selezionato, oppure non opera nella/nelle attività selezionata/e.<br><br>'; 18846 } 18847 18848 html += '<div class="contact">'; 18849 html += '<h4>'+button_texts[lang].contact+'</h4>'; 18850 html += '<h5>'+r.AZI_NOME+'</h5>'+address; 18851 html += '<div class="clear"></div>'; 18852 html += '<div class="icon"><i class="fa fa-phone"></i></div>'; 18853 html += '</div>'; 18854 html += '</dib>'; 18855 html += '</div><a href="#" class="prev"><i class="fa fa-angle-left"></i></a><a href="#" class="next"><i class="fa fa-angle-right"></i></a>'; 18856 18857 html += '<div class="share-box">'; 18858 // html += '<a href="#" class="close-share"><i class="fa fa-times"></i></a>' 18859 html += '<input type="text" name="name" class="form-control" placeholder="Nome" />' 18860 html += '<input type="text" name="recipient" class="form-control" placeholder="Email destinatario" />' 18861 html += '<textarea name="message" class="form-control" id="" cols="30" rows="4" placeholder="Messaggio"></textarea>'; 18862 18863 html += '<button class="btn btn-default send">Invia</button> '; 18864 html += '<button class="btn btn-default backk">Annulla</button>'; 18865 // html += '<button class="btn btn-default backk hidden close">Chiudi</button>'; 18866 18867 html += '</div></div>'; 18868 18869 if($('.svg-column .detail').length) $('.svg-column .detail').replaceWith(html); 18870 else $('.aziende_table').hide().after(html); 18871 18872 $('.detail .body > p a').each(function (){ 18873 if(!$(this).is('[target]')) $(this).attr('target', '_blank'); 18874 }); 18875 18876 last_detail = nnnn; 18877 18878 $('.print_scheda').click(function (e){ 18879 e.preventDefault(); 18880 18881 var icons = ''; 18882 $('.svg-column .detail .box .header > img') .each(function (){ 18883 icons += '<img src="https://www4.ti.ch/'+$(this).attr('src')+'">'; 18884 }); 18885 $('.svg-column .detail .box .header > span') .each(function (){ 18886 icons += '<img src="/fileadmin/DFE/DE-PORTALE-IMPRESA/images/'+$(this).attr('class').replace('svg-icon ', '')+'.png">'; 18887 }); 18888 18889 var w = window.open('', 'sri_print', 'menubar=no'); 18890 var css = '' 18891 var html = '<!DOCTYPE html><html lang="en"><head><link rel="stylesheet" type="text/css" href="'+$('base').attr('href')+'typo3conf/ext/theme/Resources/Public/css/styles.css" media="screen" /><link rel="stylesheet" type="text/css" href="'+$('base').attr('href')+'typo3conf/ext/theme/Resources/Public/css/stampa.css" media="print" /><meta charset="UTF-8"><title>Stampa</title></head><body><div class="sri_print">'+icons+'<br>'+$('.svg-column .detail .box .body').html()+'</div></body></html>'; 18892 w.document.write(html); 18893 setTimeout(function (){ 18894 w.document.close(); 18895 w.focus(); 18896 w.print(); 18897 w.close(); 18898 }, 300); 18899 }); 18900 18901 $('.share_scheda').click(function (e){ 18902 e.preventDefault(); 18903 18904 $('.share-box input, .share-box textarea, .share-box button').show(); 18905 $('.share-box h3, .share-box button.close').remove(); 18906 18907 $('.svg-column .detail .box').addClass('over'); 18908 $('.svg-column .detail .share-box').show(); 18909 }); 18910 18911 $('.close-share, button.backk, .btn-default.closer').click(function (e){ 18912 e.preventDefault(); 18913 $('.svg-column .detail .box').removeClass('over'); 18914 $('.svg-column .detail .share-box').hide(); 18915 }); 18916 18917 $('.share-box button.send').click(function (e){ 18918 e.preventDefault(); 18919 18920 var error = false;
18921 18922 if($('.share-box input[name=name]').val() == ''){ 18923 $('.share-box input[name=name]').addClass('alert-danger'); 18924 error = true; 18925 } 18926 else $('.share-box input[name=name]').removeClass('alert-danger'); 18927 18928 if($('.share-box input[name=recipient]').val() == ''){ 18929 $('.share-box input[name=recipient]').addClass('alert-danger'); 18930 error = true; 18931 } 18932 else{ 18933 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,}))$/; 18934 if(!re.test($('.share-box input[name=recipient]').val())){ 18935 $('.share-box input[name=recipient]').addClass('alert-danger'); 18936 error = true; 18937 } 18938 else $('.share-box input[name=recipient]').removeClass('alert-danger'); 18939 } 18940 18941 if($('.share-box textarea[name=message]').val() == ''){ 18942 $('.share-box textarea[name=message]').addClass('alert-danger'); 18943 error = true; 18944 } 18945 else $('.share-box textarea[name=message]').removeClass('alert-danger'); 18946 18947 if(!error){ 18948 18949 // var url = location.href; 18950 // if(url.indexOf('#') > -1){ 18951 // url = url.split('#')[0]; 18952 // } 18953 // url += '#' 18954 18955 // if($('.benefactor-row a.checked').length){ 18956 // url += $('.benefactor-row a.checked').attr('data-id')+'/'; 18957 // } 18958 18959 // if($('.activities-row a.checked').length){ 18960 // if($('.activities-row a.checked').length > 1){ 18961 // var tmp = []; 18962 // $('.activities-row a.checked').each(function (){ 18963 // tmp.push($(this).attr('data-url')); 18964 // }); 18965 // url += tmp.join('+'); 18966 // } 18967 // else{ 18968 // url += $('.activities-row a.checked').attr('data-url'); 18969 // } 18970 // url += '/'; 18971 // } 18972 18973 // url += last_detail_id; 18974 18975 18976 var data = { 18977 share: true, 18978 name: $('.share-box input[name=name]').val(), 18979 recipient: $('.share-box input[name=recipient]').val(), 18980 message: $('.share-box textarea[name=message]').val(), 18981 url: location.href, 18982 azienda: $('.contact h5').text() 18983 }; 18984 18985 $.post('typo3conf/ext/user_sviluppoeconomico/requests.php', data, function (r){ 18986 $('.share-box input, .share-box textarea, .share-box button').hide(); 18987 $('.share-box input[name=name]').after('<h3>Messaggio inviato!</h3><button class="btn btn-default closer">Chiudi</button>'); 18988 $('.share-box .closer').click(function (e){ 18989 e.preventDefault(); 18990 $('.svg-column .detail .box').removeClass('over'); 18991 $('.svg-column .detail .share-box').hide(); 18992 }); 18993 }); 18994 } 18995 }); 18996 18997 $('.svg-column .detail a.prev').click(function (e){ 18998 e.preventDefault(); 18999 19000 var index = $('a[data-id='+last_detail+']').parents('tr').index(); 19001 19002 for(i=1;i<100;i++){ 19003 if((index - i) > -1){ 19004 if($('table tbody tr:eq('+(index - i)+')').length && $('table tbody tr:eq('+(index - i)+')').is('[data-show]')){ 19005 $('table tbody tr:eq('+(index - i)+') a[data-id]').trigger('click'); 19006 return false;
19007 } 19008 } 19009 else break; 19010 } 19011 $('table tbody tr[data-show]:last a[data-id]').trigger('click'); 19012 }); 19013 19014 $('.svg-column .detail a.next').click(function (e){ 19015 e.preventDefault(); 19016 19017 var index = $('a[data-id='+last_detail+']').parents('tr').index(); 19018 19019 for(i=1;i<100;i++){ 19020 if((index + i) < $('table tbody tr').length){ 19021 if($('table tbody tr:eq('+(index + i)+')').length && $('table tbody tr:eq('+(index + i)+')').is('[data-show]')){ 19022 $('table tbody tr:eq('+(index + i)+') a[data-id]').trigger('click'); 19023 console.log($('table tbody tr:eq('+(index + i)+') a[data-id]')) 19024 return false; 19025 } 19026 } 19027 else break; 19028 } 19029 console.log('basd') 19030 $('table tbody tr[data-show]:first a[data-id]').trigger('click'); 19031 }); 19032 }); 19033 } 19034 function closeDetail(){ 19035 // var n = $(this).attr('data-id'); 19036 $('.aziende_table').show() 19037 $('.svg-column .detail').remove(); 19038 last_detail_id = false; 19039 } 19040 function selectAzienda(){ 19041 19042 var h = location.hash; 19043 if(h.indexOf('/') > -1){ 19044 tmp = h.split('/'); 19045 if(parseInt(tmp[(tmp.length - 1)]) > 0){ 19046 tmp.pop(); 19047 } 19048 location.hash = tmp.join('/')+'/'+$(this).attr('data-id-azienda') 19049 } 19050 19051 // $(this).attr('data-id-azienda') 19052 19053 // if($(this).attr('filter') == '') $('table.aziende_table [data-id='+$(this).attr('data-id-azienda')+']').trigger('click'); 19054 } 19055 function openInternalModal(e){ 19056 e.preventDefault(); 19057 19058 var id = $(this).attr('data-id'); 19059 19060 $('.sri-modal .content').html($('.sri-modal-content[data-modal-id='+id+']').html()).attr('class', 'content '+id); 19061 $('.sri-modal').removeClass('hidden'); 19062 } 19063 function closeInternalModal(e){ 19064 e.preventDefault(); 19065 $('.sri-modal').addClass('hidden'); 19066 } 19067 init(); 19068 19069 $('.move').click(function (e){ 19070 e.preventDefault(); 19071 19072 var id = $(this).attr('href'); 19073 ; 19074 // console.log(id) 19075 var p = $('#'+id.split('#')[1]).offset(); 19076 // console.log(p) 19077 $('html, body').animate({ scrollTop: p.top }, 400); 19078 }) 19079} 19080function initTichSlider(){ 19081 19082 var data = { 19083 navigation: false, 19084 mouseDrag: false, 19085 touchDrag: false, 19086 responsiveClass: true 19087 }; 19088 19089 $(".owl-demo").each(function (){ 19090 var d = data; 19091 if($(this).parents('.fixed').length){ 19092 d.responsive = { 19093 0:{ 19094 items:1, 19095 }, 19096 600:{ 19097 items:3, 19098 loop:true 19099 } 19100 } 19101 } 19102 else { 19103 d.responsive = { 19104 0:{ 19105 items:1, 19106 }, 19107 600:{ 19108 items:3, 19109 loop:true 19110 }, 19111 970:{ 19112 items:4, 19113 loop:true 19114 }, 19115 1400:{ 19116 items:5, 19117 loop:true 19118 } 19119 } 19120 } 19121 $(this).owlCarousel(d); 19122 }); 19123 19124 19125 $(".images-slider .next").click(function(e){ 19126 e.preventDefault(); 19127 var elemento="#"+$(this).attr('data-id'); 19128 if(elemento == '#undefined') elemento = '#'+$(this).siblings('.owl-carousel').attr('id'); 19129 $(elemento).trigger('next.owl.carousel'); 19130 }); 19131 19132 $(".images-slider .prev").click(function(e){ 19133 e.preventDefault(); 19134 var elemento="#"+$(this).attr('data-id'); 19135 if(elemento == '#undefined') elemento = '#'+$(this).siblings('.owl-carousel').attr('id'); 19136 $(elemento).trigger('prev.owl.carousel'); 19137 }); 19138 19139 $(".owl-carousel .item").click(function(e){ 19140 $("#myModal .modal-body img").attr('src',e.target.currentSrc); 19141 $("#myModal .modal-title").html($("#"+e.currentTarget.id).find("h3").text()); 19142 }); 19143 19144 19145 if($('.images-slider.text img:first').length){ 19146 setTimeout(function (){ 19147 $('.images-slider.text .next, .images-slider.text .prev').css({ top: $('.images-slider.text img:first').height() / 2 + 48}); 19148 }, 500) 19149 19150 } 19151 19152} 19153 19154function initTichPubblicazioni(){ 19155 19156 $("#riassuntoOrdinazione").hide(); 19157 $("#DatiPersonali").hide(); 19158 19159 19160 $("#procediOrdinazione").click(function() { 19161 var totale=0; 19162 var riassunto=""; 19163 var tmp=""; 19164 19165 $("#ordinazione input").each(function(){ 19166 var input = $(this); 19167 var optionSelected = $("option:selected", this); 19168 var quantita = this.value; 19169 var prezzo=input.data('prezzo'); 19170 var prezzolibri=""; 19171 var titolo=input.data('titolo'); 19172 var sottotitolo=input.data('sottotitolo'); 19173 19174 if(quantita > 0) 19175 { 19176 totale=totale+(quantita*prezzo); 19177 prezzolibri=quantita*prezzo; 19178 19179 riassunto=riassunto+'<div class="row"><div class="col-xs-8">'+titolo+' - '+sottotitolo+'</div><div class="col-xs-2">'+quantita+'x</div><div class="col-xs-2">fr. '+prezzolibri+'.00</div></div>'; 19180 tmp=tmp+quantita+'x '+titolo+' - '+sottotitolo+'\n'; 19181 } 19182 }); 19183 19184 riassunto= riassunto+'<div class="row"><div class="col-xs-8"></div><div class="col-xs-4 totale"><span class="spanStringa"><b>Totale</b></span><span id="totale" class="spanTotale">fr. '+totale+'.00</span></div></div>'; 19185 19186 tmp=tmp+'\nTOTALE: fr. '+totale+'.00'; 19187 19188 riassunto='<h1 class="csc-firstHeader">Riepilogo e ordinazione</h1><div class="box-info1"><b>Riepilogo ordine</b><br /><br />'+riassunto+'<div class="row"><p>Ordinando una delle pubblicazioni, nel caso in cui fosse a pagamento, l\'utente si impegna a pagare il prezzo indicato, oltre alle spese di spedizione, <b>entro 30 giorni</b> dalla ricezione della fattura. </p></div></div>'; 19189 19190 $("#riassuntoOrdinazione").html(riassunto); 19191 $("#riassuntoOrdinazione").show(); 19192 $("#DatiPersonali").show(); 19193 $("#moduloOrdinaizonePubblicazioni").hide(); 19194 $("#testoIntro").hide(); 19195 $('html, body').animate({scrollTop: '0px'}, 300); 19196 19197 $("#powermail_field_ordinazionepubblicazioni").val(tmp); 19198 19199 19200 }); 19201} 19202/* Ticino 2020 */ 19203function initTicino2020(){
19204 function init(){ 19205 if($('#ticino2020.page').length){ 19206 startPosition(); 19207 19208 h = windowHeight(); 19209 19210 setTimeout(function (){ 19211 items.push({ 19212 from: 0, 19213 to: $('#ticino2020 #p1').outerHeight() 19214 }); 19215 19216 items.push({ 19217 from: $('#ticino2020 #p2').offset().top - h, 19218 to: $('#ticino2020 #p2').offset().top + $('#ticino2020 #p2').outerHeight() - h 19219 }); 19220 19221 // items.push({ 19222 // from: $('#ticino2020 #p3').offset().top - h, 19223 // to: $('#ticino2020 #p3').offset().top + $('#ticino2020 #p3').outerHeight() - h 19224 // }); 19225 19226 // unifyScroll = $('#p3 .box2 .flow-box').offset().top - 150; 19227 unifyScroll2 = $('#p2 .content').offset().top - 150; 19228 closeScroll = $('#p2 .box2').offset().top - 100; 19229 closeScroll2 = unifyScroll2 + $('#p2 .content').height() - 250; 19230 19231 $(window).scroll(scroll2).trigger('scroll'); 19232 }, 200); 19233 19234 $(window).scroll(scroll); 19235 19236 initImages(); 19237 } 19238 else{ 19239 $('#breadcrumbs-two a').click(function (e){ 19240 e.preventDefault(); 19241 if($(this).attr('href')){ 19242 var i = $(this).parent().index() + 1; 19243 $('.flow-box div.box-n2, .flow-box div.box-n3').addClass('hidden'); 19244 $('.box-n'+i).removeClass('hidden'); 19245 } 19246 }); 19247 } 19248 } 19249 19250 function shuffle(array) { 19251 var currentIndex = array.length, temporaryValue, randomIndex; 19252 while (0 !== currentIndex) { 19253 19254 randomIndex = Math.floor(Math.random() * currentIndex); 19255 currentIndex -= 1; 19256 19257 temporaryValue = array[currentIndex]; 19258 array[currentIndex] = array[randomIndex]; 19259 array[randomIndex] = temporaryValue; 19260 } 19261 19262 return array; 19263 } 19264 function initImages() { 19265 var n = [1, 2, 3]; 19266 n = shuffle(n); 19267 $('.image').each(function (i) { 19268 // initImages 19269 $(this).addClass('image' + n[i]); 19270 var t = $(this); 19271 setTimeout(function () { 19272 t.addClass('fadein') 19273 }); 19274 }); 19275 } 19276 function startPosition() { 19277 var p = $('#ticino2020 .header img').offset(); 19278 leftGap = 182; 19279 19280 if($('#ticino2020.new').length){ 19281 leftGap = 34 19282 rightGap = 149 19283 } 19284 else rightGap = 5 19285 19286 $('.icona-comune').css({ 'left': p.left + leftGap, top: '' }).removeClass('fixed'); 19287 $('.icona-cantone').css({ 'right': $('html, body').outerWidth() - p.left - leftGap - leftGap - rightGap, top: '' }).removeClass('fixed'); 19288 } 19289 function endPosition(top) { 19290 var p = $('#p3 .box3 img').offset(); 19291 top = $('#p3 .box3').offset().top - 94; 19292 $('.icona-comune').css({ 'left': p.left, top: top }).removeClass('fixed'); 19293 $('.icona-cantone').css({ 'right': p.left, top: top }).removeClass('fixed'); 19294 } 19295 function unifyIn(top) { 19296 var p = $('#p3 .box3 img').offset(); 19297 $('.icona-comune').css({ 'left': p.left - 200, top: top }) 19298 $('.icona-cantone').css({ 'right': p.left - 200, top: top }) 19299 } 19300 function unifyOut(top) { 19301 $('.icona-comune').css({ 'left': 0, top: top }) 19302 $('.icona-cantone').css({ 'right': 0, top: top }) 19303 } 19304 function unifyIn2(top) { 19305 var p = $('.img.frecce').offset(); 19306 $('.icona-comune').css({ 'left': p.left + 100, top: p.top - 100 }) 19307 $('.icona-cantone').css({ 'right': p.left + 100, top: p.top - 100 }) 19308 } 19309 function unifyOut2(top) { 19310 $('.icona-comune').css({ 'left': 0, top: top }) 19311 $('.icona-cantone').css({ 'right': 0, top: top }) 19312 } 19313 var closeScroll = 0; 19314 var unifyScroll = 0; 19315 var closeScroll2 = 0; 19316 var unifyScroll2 = 0; 19317 function scroll() { 19318 var v = $(window).scrollTop(); 19319 if ($(this).scrollTop() < 1) { 19320 startPosition(); 19321 } 19322 else if ($(this).scrollTop() > closeScroll) { 19323 endPosition($(this).scrollTop()); 19324 } 19325 else { 19326 if ($(this).scrollTop() > unifyScroll2 && $(this).scrollTop() < closeScroll2) unifyIn2($(this).scrollTop()); 19327 else unifyOut2($(this).scrollTop()); 19328 } 19329 } 19330 var items = []; 19331 var h = 0; 19332 function scroll2(e) { 19333 var v = $(window).scrollTop(); 19334 for (i = 0; i < items.length; i++) { 19335 if (v >= items[i].from) { 19336 var val = (items[i].from - v) / 8; 19337 $('#p' + (i + 1) + ' .image').css({ 'background-position': '0px ' + val + 'px' }) 19338 } 19339 } 19340 } 19341 init(); 19342} 19343function initUEFMap(){ 19344
19345 function init(){ 19346 d3.select('svg').selectAll('g#Uffici_esecuzione circle, g#Uffici_fallimenti circle').on('mouseover', mousein).on('mouseout', mouseout).on('click', click); 19347 19348 var popOverSettings = { 19349 placement: 'top', 19350 container: 'body', 19351 html: true, 19352 selector: '[rel="popover"]', 19353 content: function () { 19354 return di_mappa_data[$(this).attr('data-id')] 19355 } 19356 } 19357 19358 $('body').popover(popOverSettings); 19359 19360 $('body').on('click', function (e) { 19361 19362 if($('.popover.fade').length > 1) $('.popover.fade:eq(0)').remove(); 19363 19364 // if($(e.target).is('[rel="popover"]')) $('.popover.fade').remove(); 19365 19366 // $('[rel="popover"]').each(function () { 19367 // //the 'is' for buttons that trigger popups 19368 // //the 'has' for icons within a button that triggers a popup 19369 // if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { 19370 // console.log($(this)) 19371 // // $(this).popover('hide'); 19372 // // $(this).popover(popOverSettings); 19373 // } 19374 // }); 19375 }); 19376 } 19377 function mousein(){ 19378 $(this).trigger('click'); 19379 $(this).css('fill', '#c33'); 19380 } 19381 function mouseout(){ 19382 $(this).trigger('click'); 19383 $(this).removeAttr('style'); 19384 } 19385 function click(){ 19386 var id = $(this).attr('data-id'); 19387 if($(this).parent().is('#Uffici_esecuzione')) location.href = 'https://www4.ti.ch/index.php?id=87273#address'+id; 19388 else location.href = 'https://www4.ti.ch/index.php?id=89204#address'+id; 19389 } 19390 init(); 19391} 19392$(document).ready(function() { 19393 if($('body.aziende-urc').length){ 19394 initURCSlider(); 19395 19396 if(is_safari){ 19397 setTimeout(function (){ 19398 initURCOpener(); 19399 }, 1000) 19400 } 19401 else initURCOpener(); 19402 19403 initURCForm(); 19404 // if($('.urc-lavoro > section').length){ 19405 // initURCArrow(); 19406 // initURCMenu(); 19407 // } 19408 // initURCCaptcha(); 19409 19410 // initURCEventBox(); 19411 // if($('#urc-overlay.mobile').length) initURCEventFormMobile(); 19412 // else initURCEventForm(); 19413 } 19414 if($('form[name=urcnew]').length){ 19415 initUrcNew(); 19416 } 19417}); 19418 19419function initURCSlider(){ 19420 var current = 1; 19421 var max = $('.urc-lavoro .home .slider > *').length; 19422 var speed = 4000; 19423 function init(){ 19424 19425 $('.urc-lavoro .home .slider').append($('.urc-lavoro .home .slider > *:first').clone()); 19426 $('.urc-lavoro .home .slider > *:last').removeClass('e1').addClass('e5'); 19427 19428 setInterval(next, speed); 19429 } 19430 function next(){ 19431 19432 $('.urc-lavoro .home .slider .e'+current).addClass('out'); 19433 current++; 19434 19435 if(current > max){ 19436 current = 1; 19437 $('.urc-lavoro .home .slider .out').removeClass('out'); 19438 } 19439 19440 } 19441 init(); 19442} 19443 19444function initURCOpener(){ 19445 function init(){ 19446 setTimeout(function (){ 19447 $('.opener').each(function (){ 19448 var o = $(this).prev(); 19449 o.attr('data-h', o.outerHeight()).css({height: 0});//.addClass('closed'); 19450 }) 19451 $('.opener').click(open); 19452 }, 500) 19453 } 19454 function open(e){ 19455 e.preventDefault(); 19456 19457 var o = $(this).prev(); 19458 var h = o.attr('data-h'); 19459 if(o.outerHeight() == 0){ 19460 o.height(h); 19461 $(this).children('.fa-angle-down').addClass('hidden'); 19462 $(this).children('.fa-angle-up').removeClass('hidden'); 19463 } 19464 else{ 19465 o.height(0); 19466 $(this).children('.fa-angle-down').removeClass('hidden'); 19467 $(this).children('.fa-angle-up').addClass('hidden'); 19468 } 19469 } 19470 init(); 19471} 19472 19473function initURCForm(){ 19474 var actualStep = 1; 19475 var uploadFile; 19476 19477 var focusAfterForm = $('.urc-panel.urc-team a:first'); 19478 function manageTabs(){ 19479 $('#annuncio .bt-next').focus(function (){ 19480 $('body, html').on('keydown', tabEvent); 19481 // console.log('set tabEvent'); 19482 }); 19483 19484 // console.log(focusAfterForm) 19485 focusAfterForm.focus(function (){ 19486 $('body, html').on('keydown', afterFormTabEvent); 19487 // console.log('set afterFormTabEvent'); 19488 }); 19489 19490 $('#annuncio input[name=nome], #annuncio textarea[name=commenti]').focus(function (){ 19491 $('body, html').on('keydown', tabPrevEvent); 19492 // console.log('set tabPrevEvent'); 19493 }); 19494 } 19495 function tabEvent(e){ 19496 // console.log('tabEvent'); 19497 if(e.keyCode == 9 && !e.shiftKey){ 19498 e.preventDefault(); 19499 $('body, html').off('keydown', tabEvent); 19500 e.stopPropagation(); 19501 // console.log('unset tabEvent') 19502 focusAfterForm.focus(); 19503 }
19504 else if((e.keyCode == 9 && e.shiftKey)){ 19505 $('body, html').off('keydown', tabEvent); 19506 } 19507 } 19508 function afterFormTabEvent(e){ 19509 // console.log('afterFormTabEvent'); 19510 if(e.keyCode == 9 && e.shiftKey){ 19511 e.preventDefault(); 19512 $('body, html').off('keydown', afterFormTabEvent); 19513 e.stopPropagation(); 19514 // console.log('unset afterFormTabEvent') 19515 19516 // console.log(actualStep); 19517 // console.log($('#annuncio .step'+actualStep+' .bt-next')); 19518 19519 if($('#annuncio .step'+actualStep+' .bt-next').length) $('#annuncio .step'+actualStep+' .bt-next').focus(); 19520 else $('#annuncio .step1 .bt-next').focus(); 19521 } 19522 else if(!$('.urc-panel.urc-team a:first').is(':focus')){ 19523 $('body, html').off('keydown', afterFormTabEvent); 19524 } 19525 } 19526 function tabPrevEvent(e){ 19527 // console.log('tabEvent'); 19528 if(e.keyCode == 9 && e.shiftKey){ 19529 e.preventDefault(); 19530 $('body, html').off('keydown', tabPrevEvent); 19531 e.stopPropagation(); 19532 // console.log('unset tabPrevEvent') 19533 if($('#annuncio .step'+actualStep+' .bt-prev').length) $('#annuncio .step'+actualStep+' .bt-prev').trigger('click'); 19534 else $('#annuncio .step1 .bt-prev').trigger('click'); 19535 } 19536 else if((e.keyCode == 9)){ 19537 $('body, html').off('keydown', tabPrevEvent); 19538 } 19539 } 19540 19541 function init(){ 19542 $('#annuncio .bt-next').click(next); 19543 $('#annuncio .bt-prev').click(prev); 19544 $('#annuncio .bt-send').click(send); 19545 $('#annuncio .bt-reset').click(reset); 19546 19547 $('#annuncio input[type=file]').on('change', prepareUpload); 19548 19549 $('#annuncio form a.remove').click(removeFile); 19550 19551 $.getScript('/typo3conf/ext/tich_captcha/Resources/Public/securimage/securimage.js', function (){ 19552 captcha_image_audioObj = new SecurimageAudio({ audioElement: 'captcha_image_audio', controlsElement: 'captcha_image_audio_controls' }); 19553 // $('.refresh-button').trigger('click') 19554 }); 19555 19556 setTimeout(function (){ 19557 $('.urc-lavoro form').css('position', 'static') 19558 // $('.urc-lavoro form').css('position', 'relative') 19559 }, 1000) 19560 setTimeout(function (){ 19561 // $('.urc-lavoro form').css('position', 'static') 19562 $('.urc-lavoro form').css('position', 'relative').css('opacity', 1) 19563 }, 1500) 19564 19565 // $('.step1').addClass('on-left'); 19566 // $('.step3').removeClass('on-right'); 19567 // $('.steps.thankyou').removeClass('on-right'); 19568 19569 manageTabs(); 19570 } 19571 function prepareUpload(event){ 19572 uploadFile = event.target.files; 19573 } 19574 function uploadFiles(event){ 19575 var data = new FormData(); 19576 $.each(uploadFile, function(key, value){ 19577 data.append('file', value); 19578 }); 19579 19580 $.ajax({ 19581 url: 'fileadmin/DFE/DE-SDL/servizio_aziende/upload.php', // point to server-side PHP script 19582 dataType: 'text', // what to expect back from the PHP script, if anything 19583 cache: false, 19584 contentType: false, 19585 processData: false, 19586 data: data, 19587 type: 'post', 19588 success: function(php_script_response){ 19589 sendForm(php_script_response); 19590 } 19591 }); 19592 } 19593 function removeFile(e){ 19594 e.preventDefault(); 19595 19596 $('#annuncio input[type=file]').val(''); 19597 $('#annuncio input[type=file]').next().children('span').text('Allega un file'); 19598 } 19599 function next(e){ 19600 e.preventDefault(); 19601 19602 var step = $(this).attr('data-step'); 19603 var error = false; 19604 19605 if(step == 2){ 19606 if(!checkField('nome_azienda')) error = true; 19607 if(!checkField('via')) error = true; 19608 if(!checkField('luogo')) error = true; 19609 // if(!error) $('#annuncio input[name=nome]').focus(); 19610 } 19611 else if(step == 3){ 19612 if(!checkField('nome')) error = true; 19613 if(!checkField('cognome')) error = true; 19614 if(!checkEmailField('email')) error = true; 19615 // if(!error) $('#annuncio textarea[name=commenti]').focus(); 19616 } 19617 if(step == 4){ 19618 error = true; 19619 } 19620 19621 if(!error){ 19622 $('#annuncio .step'+actualStep).addClass('on-left'); 19623 $('#annuncio .step'+step).removeClass('on-right'); 19624 actualStep = step; 19625 19626 $('body, html').off('keydown', tabEvent); 19627 19628 setTimeout(function (){ 19629 if(step == 2){ 19630 $('#annuncio input[name=nome]').focus(); 19631 } 19632 else if(step == 3){ 19633 $('#annuncio textarea[name=commenti]').focus(); 19634 } 19635 }, 500); 19636 19637 // $('.steps').addClass('hidden'); 19638 // $('.step'+step).removeClass('hidden'); 19639 } 19640 } 19641 function prev(e){ 19642 e.preventDefault(); 19643 19644 var step = $(this).attr('data-step'); 19645 // $('.steps').addClass('hidden'); 19646 // $('.step'+step).removeClass('hidden'); 19647 19648 $('#annuncio .step'+actualStep).addClass('on-right'); 19649 $('#annuncio .step'+step).removeClass('on-left'); 19650 actualStep = step; 19651 19652 setTimeout(function (){ 19653 if(step == 1){ 19654 $('#annuncio input[name=web]').focus(); 19655 } 19656 else if(step == 2){ 19657 $('#annuncio input[name=telefono]').focus(); 19658 } 19659 }, 500); 19660 } 19661 function send(e){ 19662 e.preventDefault(); 19663 var error = false;
19664 19665 /* Captcha */ 19666 var c = $('#annuncio .captcha input'); 19667 var v = c.val(); 19668 if(v){ 19669 var r = checkCaptcha(v); 19670 if(r.responseText == 'ok'){ 19671 c.removeClass('error'); 19672 } 19673 else{ 19674 c.addClass('error').val(''); 19675 $('#annuncio .captcha .refresh-button').trigger('click') 19676 error = true; 19677 } 19678 } 19679 else{ 19680 c.addClass('error'); 19681 $('#annuncio .captcha .refresh-button').trigger('click') 19682 error = true; 19683 } 19684 19685 if(!error){ 19686 /* Allegato */ 19687 var f = $('#file'); 19688 if(!f.val()){ 19689 sendForm(); 19690 } 19691 else{ 19692 uploadFiles(); 19693 } 19694 } 19695 19696 // var f = $('#file'); 19697 // if(!f.val()){ 19698 // $('.step3 label').addClass('error'); 19699 // error = true; 19700 // } 19701 // else{ 19702 // $('.step3 label').removeClass('error'); 19703 // } 19704 19705 // if(!error){ 19706 // uploadFiles(); 19707 // } 19708 } 19709 function sendForm(file){ 19710 var data = { 19711 nome_azienda: $('#annuncio input[name=nome_azienda]').val(), 19712 via: $('#annuncio input[name=via]').val(), 19713 luogo: $('#annuncio input[name=luogo]').val(), 19714 web: $('#annuncio input[name=web]').val(), 19715 nome: $('#annuncio input[name=nome]').val(), 19716 cognome: $('#annuncio input[name=cognome]').val(), 19717 email: $('#annuncio input[name=email]').val(), 19718 telefono: $('#annuncio input[name=telefono]').val(), 19719 commenti: $('#annuncio textarea[name=commenti]').val(), 19720 // file: file 19721 }; 19722 19723 if (typeof file !== "undefined") { 19724 data.file = file; 19725 } 19726 19727 $.post('fileadmin/DFE/DE-SDL/servizio_aziende/send.php', data, function (r){ 19728 // console.log(r); 19729 $('#annuncio .urc-form .container > h2, #annuncio .urc-form .container > p').addClass('hidden'); 19730 $('#annuncio .step3').addClass('on-left'); 19731 $('#annuncio .steps.thankyou').removeClass('on-right'); 19732 }); 19733 } 19734 function checkField(name){ 19735 var f = $('#annuncio .steps input[name='+name+']'); 19736 f.removeClass('error'); 19737 if(f.val()){ 19738 return true; 19739 } 19740 f.addClass('error'); 19741 return false; 19742 } 19743 function checkEmailField(name){ 19744 var f = $('#annuncio .steps input[name='+name+']'); 19745 f.removeClass('error'); 19746 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,}))$/; 19747 if(f.val() && re.test(f.val())){ 19748 return true; 19749 } 19750 f.addClass('error'); 19751 return false; 19752 } 19753 function checkCaptcha(value){ 19754 return $.ajax({ 19755 url: '/typo3conf/ext/tich_captcha/Resources/Public/securimage/check.php?namespace=form1', 19756 data: { 19757 value: value 19758 }, 19759 async: false, 19760 method: 'post', 19761 success: function (r){ 19762 // console.log(r); 19763 // if(r == 'error'){ 19764 // $('.captcha a').trigger('click'); 19765 // } 19766 } 19767 }); 19768 } 19769 function reset(e){ 19770 e.preventDefault(); 19771 19772 $('#annuncio .urc-form .container > h2, #annuncio .urc-form .container > p').removeClass('hidden'); 19773 $('#annuncio .step2, #annuncio .step3').removeClass('on-left').addClass('on-right'); 19774 $('#annuncio .steps.thankyou').addClass('on-right'); 19775 $('#annuncio .step1').removeClass('on-left'); 19776 19777 $('#annuncio .urc-form input[type=text]').removeClass('error').val(''); 19778 $('#annuncio .urc-form textarea').val(''); 19779 $('#annuncio form a.remove').trigger('click'); 19780 19781 $('#annuncio .captcha a').trigger('click'); 19782 $('#annuncio .captcha .error').removeClass('error'); 19783 19784 actualStep = 1; 19785 19786 } 19787 init(); 19788} 19789// function initURCForm(){ 19790// var actualStep = 1; 19791// var uploadFile; 19792// function init(){ 19793// $('#annuncio .bt-next').click(next); 19794// $('#annuncio .bt-prev').click(prev); 19795// $('#annuncio .bt-send').click(send); 19796// $('#annuncio .bt-reset').click(reset); 19797 19798// $('#annuncio input[type=file]').on('change', prepareUpload); 19799 19800// $('#annuncio form a.remove').click(removeFile); 19801 19802// // $('.step1').addClass('on-left'); 19803// // $('.step3').removeClass('on-right'); 19804// // $('.steps.thankyou').removeClass('on-right'); 19805// } 19806// function prepareUpload(event){ 19807// uploadFile = event.target.files; 19808// } 19809// function uploadFiles(event){ 19810// var data = new FormData(); 19811// $.each(uploadFile, function(key, value){ 19812// data.append('file', value); 19813// }); 19814 19815// $.ajax({ 19816// url: 'fileadmin/DFE/DE-SDL/servizio_aziende/upload.php', // point to server-side PHP script 19817// dataType: 'text', // what to expect back from the PHP script, if anything 19818// cache: false, 19819// contentType: false, 19820// processData: false, 19821// data: data, 19822// type: 'post', 19823// success: function(php_script_response){ 19824// sendForm(php_script_response); 19825// } 19826// }); 19827// } 19828// function removeFile(e){ 19829// e.preventDefault(); 19830 19831// $('#annuncio input[type=file]').val(''); 19832// $('#annuncio input[type=file]').next().children('span').text('Allega un file'); 19833// } 19834// function next(e){ 19835// e.preventDefault(); 19836 19837// var step = $(this).attr('data-step'); 19838// var error = false;
19839 19840// if(step == 2){ 19841// if(!checkField('nome_azienda')) error = true; 19842// if(!checkField('via')) error = true; 19843// if(!checkField('luogo')) error = true; 19844// } 19845// else if(step == 3){ 19846// if(!checkField('nome')) error = true; 19847// if(!checkField('cognome')) error = true; 19848// if(!checkEmailField('email')) error = true; 19849// } 19850// if(step == 4){ 19851// error = true; 19852// } 19853 19854// if(!error){ 19855// $('#annuncio .step'+actualStep).addClass('on-left'); 19856// $('#annuncio .step'+step).removeClass('on-right'); 19857// actualStep = step; 19858// // $('.steps').addClass('hidden'); 19859// // $('.step'+step).removeClass('hidden'); 19860// } 19861// } 19862// function prev(e){ 19863// e.preventDefault(); 19864 19865// var step = $(this).attr('data-step'); 19866// // $('.steps').addClass('hidden'); 19867// // $('.step'+step).removeClass('hidden'); 19868 19869// $('#annuncio .step'+actualStep).addClass('on-right'); 19870// $('#annuncio .step'+step).removeClass('on-left'); 19871// actualStep = step; 19872// } 19873// function send(e){ 19874// e.preventDefault(); 19875// var error = false; 19876 19877// /* Captcha */ 19878// var c = $('#annuncio .captcha input'); 19879// var v = c.val(); 19880// if(v){ 19881// var r = checkCaptcha(v); 19882// if(r.responseText == 'ok'){ 19883// c.removeClass('error'); 19884// } 19885// else{ 19886// c.addClass('error').val(''); 19887// $('#annuncio .captcha a').trigger('click'); 19888// error = true; 19889// } 19890// } 19891// else{ 19892// c.addClass('error'); 19893// $('#annuncio .captcha a').trigger('click'); 19894// error = true; 19895// } 19896 19897 19898// /* Allegato */ 19899// var f = $('#file'); 19900// if(!f.val()){ 19901// sendForm(); 19902// } 19903// else{ 19904// uploadFiles(); 19905// } 19906 19907// // var f = $('#file'); 19908// // if(!f.val()){ 19909// // $('.step3 label').addClass('error'); 19910// // error = true; 19911// // } 19912// // else{ 19913// // $('.step3 label').removeClass('error'); 19914// // } 19915 19916// // if(!error){ 19917// // uploadFiles(); 19918// // } 19919// } 19920// function sendForm(file){ 19921// var data = { 19922// nome_azienda: $('#annuncio input[name=nome_azienda]').val(), 19923// via: $('#annuncio input[name=via]').val(), 19924// luogo: $('#annuncio input[name=luogo]').val(), 19925// web: $('#annuncio input[name=web]').val(), 19926// nome: $('#annuncio input[name=nome]').val(), 19927// cognome: $('#annuncio input[name=cognome]').val(), 19928// email: $('#annuncio input[name=email]').val(), 19929// telefono: $('#annuncio input[name=telefono]').val(), 19930// commenti: $('#annuncio textarea[name=commenti]').val(), 19931// // file: file 19932// }; 19933 19934// if (typeof file !== "undefined") { 19935// data.file = file; 19936// } 19937 19938// $.post('fileadmin/DFE/DE-SDL/servizio_aziende/send.php', data, function (r){ 19939// // console.log(r); 19940// $('#annuncio .urc-form .container > h2, #annuncio .urc-form .container > p').addClass('hidden'); 19941// $('#annuncio .step3').addClass('on-left'); 19942// $('#annuncio .steps.thankyou').removeClass('on-right'); 19943// }); 19944// } 19945// function checkField(name){ 19946// var f = $('#annuncio .steps input[name='+name+']'); 19947// f.removeClass('error'); 19948// if(f.val()){ 19949// return true; 19950// } 19951// f.addClass('error'); 19952// return false; 19953// } 19954// function checkEmailField(name){ 19955// var f = $('#annuncio .steps input[name='+name+']'); 19956// f.removeClass('error'); 19957// 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,}))$/; 19958// if(f.val() && re.test(f.val())){ 19959// return true; 19960// } 19961// f.addClass('error'); 19962// return false; 19963// } 19964// function checkCaptcha(value){ 19965// return $.ajax({ 19966// url: 'fileadmin/DFE/DE-SDL/servizio_aziende/securimage/check.php?namespace=form1', 19967// data: { 19968// value: value 19969// }, 19970// async: false, 19971// method: 'post', 19972// success: function (r){ 19973// // console.log(r); 19974// // if(r == 'error'){ 19975// // $('.captcha a').trigger('click'); 19976// // } 19977// } 19978// }); 19979// } 19980// function reset(e){ 19981// e.preventDefault(); 19982 19983// $('#annuncio .urc-form .container > h2, #annuncio .urc-form .container > p').removeClass('hidden'); 19984// $('#annuncio .step2, #annuncio .step3').removeClass('on-left').addClass('on-right'); 19985// $('#annuncio .steps.thankyou').addClass('on-right'); 19986// $('#annuncio .step1').removeClass('on-left'); 19987 19988// $('#annuncio .urc-form input[type=text]').removeClass('error').val(''); 19989// $('#annuncio .urc-form textarea').val(''); 19990// $('#annuncio form a.remove').trigger('click'); 19991 19992// $('#annuncio .captcha a').trigger('click'); 19993// $('#annuncio .captcha .error').removeClass('error'); 19994 19995// actualStep = 1; 19996 19997// } 19998// init(); 19999// } 20000 20001function initURCArrow(){ 20002 var offset = $('.urc-lavoro > section:eq(0)').offset().top + 10;
20003 function init(){ 20004 $('.direction').click(move); 20005 } 20006 function move(e){ 20007 e.preventDefault(); 20008 $('html, body').animate({ scrollTop: offset+'px'}, 700); 20009 } 20010 init(); 20011} 20012 20013function initURCMenu(){ 20014 var menuTrigger; 20015 var menu; 20016 var tornaSu = $('.urc-torna-su'); 20017 var triggers = new Array(); 20018 var scrolling = false; 20019 function init(){ 20020 menu = $('.urc-floating-menu'); 20021 // menuTrigger = $('.urc-lavoro > section:eq(0)').offset().top - 8; 20022 menuTrigger = $('.urc-lavoro section#video').offset().top - 50; 20023 20024 setTimeout(calcTriggers, 560); 20025 20026 $('.urc-menu a').click(menuClick); 20027 20028 $(window).scroll(onScroll).trigger('scroll'); 20029 $(window).resize(calcTriggers); 20030 20031 $('.urc-opener').click(function (){ 20032 setTimeout(calcTriggers, 10) 20033 }); 20034 20035 // $(document).on("scrollstart",function(){ 20036 // // alert("Started scrolling!"); 20037 // scrolling = true; 20038 // $('.urc-floating-menu').removeClass('fade'); 20039 // }).on("scrollstop",function(){ 20040 // // alert("<Sopt scrolling!"); 20041 // scrolling = false; 20042 // setTimeout(function (){ 20043 // if(!scrolling){ 20044 // $('.urc-floating-menu').addClass('fade'); 20045 // } 20046 // }, 500) 20047 // }); 20048 20049 tornaSu.click(moveUp); 20050 $('.urc-menu.urc-floating-menu h5').css({cursor: 'pointer'}).click(moveUp); 20051 20052 if($('.nav.no-click').length) $('.nav.no-click a').click(menuClick); 20053 } 20054 function onScroll(e){ 20055 var v = $(window).scrollTop(); 20056 if(v >= menuTrigger){ 20057 tornaSu.addClass('out'); 20058 menu.removeClass('closed'); 20059 } 20060 else{ 20061 tornaSu.removeClass('out'); 20062 menu.addClass('closed'); 20063 } 20064 20065 for(x in triggers){ 20066 20067 if(v >= triggers[x].from - 5 && v < triggers[x].to - 5){ 20068 $('.urc-floating-menu .hover').removeClass('hover'); 20069 $('.urc-floating-menu a[href*='+triggers[x].id+']').addClass('hover'); 20070 break; 20071 } 20072 } 20073 20074 } 20075 function calcTriggers(){ 20076 triggers = new Array(); 20077 20078 triggers.push({ 20079 id: 'video', 20080 from: $('.urc-lavoro section#video').offset().top - 50, 20081 to: $('.urc-lavoro section#video').offset().top + $('.urc-lavoro section#video').outerHeight()// + 50 20082 }); 20083 20084 $('.urc-lavoro > section').each(function (){ 20085 var top = $(this).offset().top; 20086 // if($(this).attr('id') == 'chi-siamo'){ 20087 // top -= 25; 20088 // } 20089 // tmp = 0; 20090 // if($(this).attr('id') == 'video'){ 20091 // tmp = 25; 20092 // } 20093 triggers.push({ 20094 id: $(this).attr('id'), 20095 from: top, 20096 to: top + $(this).outerHeight()// - tmp 20097 }); 20098 }); 20099 } 20100 function menuClick(e){ 20101 if(!$(this).hasClass('bb')){ 20102 e.preventDefault(); 20103 20104 var tmp = $(this).attr('href').split('#'); 20105 var top = $('section#'+tmp[1]).offset().top; 20106 if(tmp[1] == 'servizi'){ 20107 top += $('section#'+tmp[1]+' img').height(); 20108 } 20109 $('html, body').animate({ scrollTop: top+'px'}, 700); 20110 } 20111 } 20112 function moveUp(e){ 20113 e.preventDefault(); 20114 $('html, body').animate({ scrollTop: 0 }, 700); 20115 } 20116 init(); 20117} 20118 20119function initURCCaptcha(){ 20120 function init(){ 20121 $('.captcha a').click(refresh); 20122 } 20123 function refresh(e){ 20124 e.preventDefault(); 20125 20126 var src = $(this).siblings('img').attr('src'); 20127 // var src = $('.captcha img').attr('src'); 20128 if(src.indexOf('&') > -1){ 20129 tmp = src.split('&'); 20130 src = tmp[0]; 20131 } 20132 src += '&' + Math.random(); 20133 $('.captcha img').attr('src', src); 20134 } 20135 init(); 20136} 20137 20138function initURCEventBox(){ 20139 var overlay = $('#urc-overlay'); 20140 var opener = $('#urc-overlay .opener-button'); 20141 var fromTop = 106; 20142 var closedTop; 20143 function init(){ 20144 if(overlay.hasClass('floating')){ 20145 overlay.click(function (){ 20146 location.href = overlay.attr('data-link'); 20147 }); 20148 } 20149 else{ 20150 var wh = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; 20151 closedTop = wh - 80; 20152 20153 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { 20154 overlay.css({ top: closedTop, height:'auto' }); 20155 } 20156 else 20157 overlay.css({ top: closedTop, height: wh - fromTop }); 20158 20159 opener.click(open); 20160 20161 if(!$('#urc-overlay.mobile').length){ 20162 setTimeout(function (){ 20163 20164 opener.trigger('click'); 20165 overlay.css('opacity', '0.95'); 20166 }, 1000); 20167 } 20168 } 20169 $('#banner h2.container a').click(function (e){ 20170 e.preventDefault(); 20171 $('.opener-button .fa-angle-up').trigger('click'); 20172 }); 20173 } 20174 function open(e){ 20175 e.preventDefault(); 20176 20177 if($(this).children('i').is(':visible')){ 20178 $('html, body').animate({ scrollTop: 0 }, 500); 20179 // $(this).children('i').removeClass('fa-angle-up').addClass('fa-times'); 20180 $(this).children('i').hide(); 20181 $(this).children('i').after('<img src="typo3conf/ext/theme/Resources/Public/images/ics.png">') 20182 20183 overlay.css({ top: fromTop }); 20184 setTimeout(function (){ 20185 $('body').css({ overflow: 'hidden' }); 20186 }, 500); 20187 } 20188 else{ 20189 // $(this).children('i').addClass('fa-angle-up').removeClass('fa-times'); 20190 $(this).children('i').show(); 20191 $(this).children('img').remove(); 20192 20193 overlay.css({ top: closedTop }); 20194 $('body').css({ overflow: '' }); 20195 } 20196 } 20197 init(); 20198} 20199
20200function initURCEventForm(){ 20201 var actualStep = 1; 20202 var uploadFile; 20203 function init(){ 20204 $('#urc-overlay .bt-next').click(next); 20205 $('#urc-overlay .bt-prev').click(prev); 20206 $('#urc-overlay .bt-send').click(send); 20207 $('#urc-overlay .bt-back').click(function (){ 20208 $('.opener-button').trigger('click'); 20209 }); 20210 // $('#urc-overlay .bt-reset').click(reset); 20211 20212 // $('#urc-overlay form a.remove').click(removeFile); 20213 20214 // var d = { 20215 // nome_azienda: 'Nome', 20216 // luogo: 'Nome', 20217 // telefono: 'Nome', 20218 // email: '[email protected]', 20219 // fname1: 'fname', 20220 // lname1: 'lname', 20221 // email1: '[email protected]', 20222 // } 20223 // for(x in d) $('input[name='+x+']').val(d[x]); 20224 20225 initURCEvents(); 20226 20227 } 20228 function next(e){ 20229 e.preventDefault(); 20230 20231 var step = $(this).attr('data-step'); 20232 var error = false; 20233 20234 if(step == 2){ 20235 if(!checkField('nome_azienda')) error = true; 20236 if(!checkField('luogo')) error = true; 20237 if(!checkField('telefono')) error = true; 20238 // if(!checkEmailField('email')) error = true; 20239 if(!$('input[name=evento]:checked').length){ 20240 error = true; 20241 $('.checks').addClass('error'); 20242 } 20243 else $('.checks').removeClass('error'); 20244 } 20245 20246 if(!error){ 20247 $('#urc-overlay .step'+actualStep).addClass('on-left'); 20248 $('#urc-overlay .step'+step).removeClass('on-right'); 20249 actualStep = step; 20250 } 20251 } 20252 function prev(e){ 20253 e.preventDefault(); 20254 20255 var step = $(this).attr('data-step'); 20256 // $('.steps').addClass('hidden'); 20257 // $('.step'+step).removeClass('hidden'); 20258 20259 $('#urc-overlay .step'+actualStep).addClass('on-right'); 20260 $('#urc-overlay .step'+step).removeClass('on-left'); 20261 actualStep = step; 20262 } 20263 function send(e){ 20264 e.preventDefault(); 20265 var error = false; 20266 20267 /* Fields */ 20268 if(!checkField('fname1')) error = true; 20269 if(!checkField('lname1')) error = true; 20270 if(!checkEmailField('email1')) error = true; 20271 20272 if($('#urc-overlay input[name=fname2]').val()){ 20273 if(!checkField('fname2')) error = true; 20274 if(!checkField('lname2')) error = true; 20275 if(!checkEmailField('email2')) error = true; 20276 } 20277 else{ 20278 $('#urc-overlay .steps input[name=fname2], #urc-overlay .steps input[name=lname2], #urc-overlay .steps input[name=email2]').removeClass('error'); 20279 } 20280 20281 /* Captcha */ 20282 var c = $('#urc-overlay .captcha input'); 20283 var v = c.val(); 20284 if(v){ 20285 var r = checkCaptcha(v); 20286 if(r.responseText == 'ok'){ 20287 c.removeClass('error'); 20288 } 20289 else{ 20290 c.addClass('error').val(''); 20291 $('#urc-overlay .captcha a').trigger('click'); 20292 error = true; 20293 } 20294 } 20295 else{ 20296 c.addClass('error'); 20297 $('#urc-overlay .captcha a').trigger('click'); 20298 error = true; 20299 } 20300 20301 20302 if(!error) 20303 sendForm(); 20304 } 20305 function sendForm(){ 20306 var data = { 20307 nome_azienda: $('#urc-overlay input[name=nome_azienda]').val(), 20308 luogo: $('#urc-overlay input[name=luogo]').val(), 20309 telefono: $('#urc-overlay input[name=telefono]').val(), 20310 email: $('#urc-overlay input[name=email]').val(), 20311 20312 evento: $('#urc-overlay input[name=evento]:checked').val(), 20313 20314 fname1: $('#urc-overlay input[name=fname1]').val(), 20315 lname1: $('#urc-overlay input[name=lname1]').val(), 20316 email1: $('#urc-overlay input[name=email1]').val() 20317 }; 20318 20319 if($('#urc-overlay input[name=fname2]').val()){ 20320 data.fname2 = $('#urc-overlay input[name=fname2]').val(); 20321 data.lname2 = $('#urc-overlay input[name=lname2]').val(); 20322 data.email2 = $('#urc-overlay input[name=email2]').val(); 20323 } 20324 20325 $.post('fileadmin/DFE/DE-SDL/servizio_aziende/send_event.php', data, function (r){ 20326 if(r == 'error'){ 20327 $('#urc-overlay .urc-form .container > h2, #urc-overlay .urc-form .container > p').addClass('hidden'); 20328 $('#urc-overlay .step2').addClass('on-left'); 20329 $('#urc-overlay .steps.thankyou').removeClass('on-right'); 20330 $('#urc-overlay .steps.thankyou p:eq(0)').html('<span style="color: #c33">Siamo spiacenti ma questo evento è già completo.</span><br>Puoi iscriverti a uno degli eventi successivi, oppure registrati nella lista d\'attesa presso [email protected]') 20331 } 20332 else{ 20333 $('#urc-overlay .urc-form .container > h2, #urc-overlay .urc-form .container > p').addClass('hidden'); 20334 $('#urc-overlay .step2').addClass('on-left'); 20335 $('#urc-overlay .steps.thankyou').removeClass('on-right'); 20336 } 20337 }); 20338 } 20339 function checkField(name){ 20340 var f = $('#urc-overlay .steps input[name='+name+']'); 20341 f.removeClass('error'); 20342 if(f.val()){ 20343 return true; 20344 } 20345 f.addClass('error'); 20346 return false;
20347 } 20348 function checkEmailField(name){ 20349 var f = $('#urc-overlay .steps input[name='+name+']'); 20350 f.removeClass('error'); 20351 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,}))$/; 20352 if(f.val() && re.test(f.val())){ 20353 return true; 20354 } 20355 f.addClass('error'); 20356 return false; 20357 } 20358 function checkCaptcha(value){ 20359 return $.ajax({ 20360 url: 'fileadmin/DFE/DE-SDL/servizio_aziende/securimage/check.php?namespace=form2', 20361 data: { 20362 value: value 20363 }, 20364 async: false, 20365 method: 'post', 20366 success: function (r){ 20367 // console.log(r); 20368 // if(r == 'error'){ 20369 // $('.captcha a').trigger('click'); 20370 // } 20371 } 20372 }); 20373 } 20374 init(); 20375} 20376 20377function initURCEventFormMobile(){ 20378 var actualStep = 1; 20379 var uploadFile; 20380 function init(){ 20381 $('#urc-overlay .bt-send').click(send); 20382 20383 // var d = { 20384 // nome_azienda: 'Nome', 20385 // luogo: 'Nome', 20386 // telefono: 'Nome', 20387 // email: '[email protected]', 20388 // fname1: 'fname', 20389 // lname1: 'lname', 20390 // email1: '[email protected]', 20391 // } 20392 // for(x in d) $('input[name='+x+']').val(d[x]); 20393 20394 initURCEvents(); 20395 20396 } 20397 function send(e){ 20398 e.preventDefault(); 20399 var error = false; 20400 20401 /* Fields */ 20402 if(!checkField('fname1')) error = true; 20403 if(!checkField('lname1')) error = true; 20404 if(!checkEmailField('email1')) error = true; 20405 20406 20407 if(!checkField('nome_azienda')) error = true; 20408 if(!checkField('luogo')) error = true; 20409 if(!checkField('telefono')) error = true; 20410 // if(!checkEmailField('email')) error = true; 20411 if(!$('input[name=evento]:checked').length){ 20412 error = true; 20413 $('.checks').addClass('error'); 20414 } 20415 else $('.checks').removeClass('error'); 20416 20417 20418 /* Captcha */ 20419 var c = $('#urc-overlay .captcha input'); 20420 var v = c.val(); 20421 if(v){ 20422 var r = checkCaptcha(v); 20423 if(r.responseText == 'ok'){ 20424 c.removeClass('error'); 20425 } 20426 else{ 20427 c.addClass('error').val(''); 20428 $('#urc-overlay .captcha a').trigger('click'); 20429 error = true; 20430 } 20431 } 20432 else{ 20433 c.addClass('error'); 20434 $('#urc-overlay .captcha a').trigger('click'); 20435 error = true; 20436 } 20437 20438 console.log(error); 20439 20440 if(!error) 20441 sendForm(); 20442 } 20443 function sendForm(){ 20444 var data = { 20445 nome_azienda: $('#urc-overlay input[name=nome_azienda]').val(), 20446 luogo: $('#urc-overlay input[name=luogo]').val(), 20447 telefono: $('#urc-overlay input[name=telefono]').val(), 20448 email: $('#urc-overlay input[name=email]').val(), 20449 20450 evento: $('#urc-overlay input[name=evento]:checked').val(), 20451 20452 fname1: $('#urc-overlay input[name=fname1]').val(), 20453 lname1: $('#urc-overlay input[name=lname1]').val(), 20454 email1: $('#urc-overlay input[name=email1]').val() 20455 }; 20456 20457 if($('#urc-overlay input[name=fname2]').val()){ 20458 data.fname2 = $('#urc-overlay input[name=fname2]').val(); 20459 data.lname2 = $('#urc-overlay input[name=lname2]').val(); 20460 data.email2 = $('#urc-overlay input[name=email2]').val(); 20461 } 20462 20463 $.post('fileadmin/DFE/DE-SDL/servizio_aziende/send_event.php', data, function (r){ 20464 $('#urc-overlay .form').hide(); 20465 $('#urc-overlay .thankyou').show(); 20466 }); 20467 } 20468 function checkField(name){ 20469 var f = $('#urc-overlay input[name='+name+']'); 20470 f.removeClass('error'); 20471 if(f.val()){ 20472 return true; 20473 } 20474 f.addClass('error'); 20475 return false; 20476 } 20477 function checkEmailField(name){ 20478 var f = $('#urc-overlay input[name='+name+']'); 20479 f.removeClass('error'); 20480 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,}))$/; 20481 if(f.val() && re.test(f.val())){ 20482 return true; 20483 } 20484 f.addClass('error'); 20485 return false; 20486 } 20487 function checkCaptcha(value){ 20488 return $.ajax({ 20489 url: 'fileadmin/DFE/DE-SDL/servizio_aziende/securimage/check.php?namespace=form2', 20490 data: { 20491 value: value 20492 }, 20493 async: false, 20494 method: 'post', 20495 success: function (r){ 20496 // console.log(r); 20497 // if(r == 'error'){ 20498 // $('.captcha a').trigger('click'); 20499 // } 20500 } 20501 }); 20502 } 20503 init(); 20504} 20505 20506function initURCEvents(){ 20507 var subjects = { 20508 'lugano': "Iscrizione lista di attesa all'evento Palazzo dei Congressi a Lugano del 22 settembre", 20509 'bellinzona': "Iscrizione lista di attesa all'evento Auditorium BancaStato a Bellinzona del 14 ottobre", 20510 'mendrisio': "Iscrizione lista di attesa all'evento Hotel Coronado a Mendrisio del 11 novembre", 20511 'locarno': "Iscrizione lista di attesa all'evento Hotel Belvedere a Locarno del 1 dicembre" 20512 } 20513 // $.getJSON('/typo3conf/ext/user_urc_aziende_iscritti/check.php', function (items){
20514 $.getJSON('/user_librerie/aziende_urc/check.php', {_: new Date().getTime()}, function (items){ 20515 for(x in items){ 20516 20517 if(x){ 20518 if(x == 'mendrisio'){ 20519 $('[data-luogo='+x+']').addClass('disabled'); 20520 // var html = '<span style="color: #c33;">Siamo spiacenti ma questo evento é già completo.</span><br>'; 20521 // $('[data-luogo='+x+'] span').html(html); 20522 $('[data-luogo='+x+'] span').text('Evento concluso'); 20523 } 20524 else if(items[x] == 0 && x == 'locarno'){ 20525 $('[data-luogo='+x+']').addClass('disabled'); 20526 $('[data-luogo='+x+'] span').text('Evento concluso'); 20527 } 20528 else if(items[x] == 0){ 20529 $('[data-luogo='+x+']').addClass('disabled'); 20530 20531 var subject = subjects[x]; 20532 var br = '%0D%0A'; 20533 var body = "Vi chiediamo cortesemente di compilare i seguenti dati."+br+br; 20534 body += 'Nome azienda:'+br; 20535 body += 'NAP e luogo:'+br; 20536 body += 'Telefono:'+br; 20537 body += 'Email azienda:'+br+br; 20538 20539 body += 'Nome partecipante:'+br; 20540 body += 'Cognome partecipante:'+br; 20541 body += 'Email partecipante:'+br; 20542 20543 var mailto = 'mailto:[email protected]?subject='+subject+'&body='+body; 20544 20545 if(x == 'lugano') 20546 { 20547 var html = '<span style= "width:425px;display:inline-block;"> </span><br>'; 20548 } 20549 else if(x == 'bellinzona') 20550 { 20551 var html = ''; 20552 $('[data-luogo='+x+']').css({clear: 'both'}); 20553 } 20554 else 20555 { 20556 var html = '<span style="color: #c33;">Siamo spiacenti ma questo evento é già completo.</span><br>'; 20557 html += 'Puoi iscriverti a uno degli eventi successivi, oppure registrati nella lista d\'attesa presso<br><a href="'+mailto+'">[email protected]</a>'; 20558 } 20559 $('[data-luogo='+x+'] span').html(html); 20560 } 20561 else if(items[x] == 2){ 20562 $('[data-luogo='+x+']').addClass('disabled'); 20563 $('[data-luogo='+x+'] span').text('Evento concluso'); 20564 } 20565 } 20566 } 20567 if(!$('#menu-main').length) $('.urc-form .checks').css({overflow: 'auto', height: '420px' }) 20568 }); 20569 20570 // var items = {'lugano': 0}; 20571 // for(x in items){ 20572 // if(items[x] == 0){ 20573 // $('[data-luogo='+x+']').addClass('disabled'); 20574 20575 // var subject = subjects[x]; 20576 // var br = '%0D%0A'; 20577 // var body = "Vi chiediamo cortesemente di compilare i seguenti dati."+br+br; 20578 // body += 'Nome azienda:'+br; 20579 // body += 'NAP e luogo:'+br; 20580 // body += 'Telefono:'+br; 20581 // body += 'Email azienda:'+br+br; 20582 20583 // body += 'Nome partecipante:'+br; 20584 // body += 'Cognome partecipante:'+br; 20585 // body += 'Email partecipante:'+br; 20586 20587 // var mailto = 'mailto:[email protected]?subject='+subject+'&body='+body; 20588 20589 // var html = '<span style="color: #c33;">Siamo spiacenti ma questo evento è già completo.</span><br>'; 20590 // html += 'Puoi iscriverti a uno degli eventi successivi, oppure registrati nella lista d\'attesa presso<br><a href="'+mailto+'">[email protected]</a>'; 20591 // $('[data-luogo='+x+'] span').html(html); 20592 // } 20593 // else if(items[x] == 2){ 20594 // $('[data-luogo='+x+']').addClass('disabled'); 20595 // $('[data-luogo='+x+'] span').text('Evento concluso'); 20596 // } 20597 // } 20598 20599} 20600 20601function initUrcNew(){ 20602 var subjects = { 20603 'lugano': "Iscrizione lista di attesa all'evento Palazzo dei Congressi a Lugano del 22 settembre", 20604 'bellinzona': "Iscrizione lista di attesa all'evento Auditorium BancaStato a Bellinzona del 14 ottobre", 20605 'mendrisio': "Iscrizione lista di attesa all'evento Hotel Coronado a Mendrisio del 11 novembre", 20606 'locarno': "Iscrizione lista di attesa all'evento Hotel Belvedere a Locarno del 1 dicembre" 20607 } 20608 function init(){ 20609 preload(); 20610 $('.urc-opener').click(open); 20611 $('form .btn.btn-primary').click(send); 20612 20613 $('.urcnew input[name=item]').click(function (){ 20614 if(!$(this).parent().hasClass('selected')){ 20615 $('.urcnew .item.selected').removeClass('selected'); 20616 $(this).parent().addClass('selected'); 20617 $('.event_error').addClass('hidden'); 20618 } 20619 }) 20620 } 20621 function preload(){ 20622 var disabled = 0; 20623 20624 $.getJSON('/typo3conf/ext/user_urc_aziende_iscritti/check.php', {_: new Date().getTime()}, function (items){ 20625 for(x in items){
20626 if(x){ 20627 if(items[x] == 0 || items[x] == 2){ 20628 disabled++; 20629 n = x == 'lugano' ? 1 : 0; 20630 if(items[x] == 0){ 20631 $('#new-form .row > .col-xs-6:eq('+n+') > p').replaceWith('<p>Siamo spiacenti ma questo evento è già completo.<br>Puoi registrarti nella lista dâattesa presso <a href="mailto:[email protected]">[email protected]</a></p>'); 20632 } 20633 else if(items[x] == 2){ 20634 $('#new-form .row > .col-xs-6:eq('+n+') > p').replaceWith('<p>Evento concluso</p>'); 20635 } 20636 $('#new-form input[name=item]:eq('+n+')').parent().remove(); 20637 } 20638 } 20639 } 20640 20641 if(disabled == 2){ 20642 $('.urc-opener').remove(); 20643 } 20644 else $('.urc-opener').removeClass('hidden') 20645 }); 20646 } 20647 function open(e){ 20648 e.preventDefault(); 20649 $('.urc-opened').toggleClass('hidden'); 20650 20651 if($(this).children('i').hasClass('fa-angle-down')){ 20652 $(this).children('i').removeClass('fa-angle-down').addClass('fa-angle-up') 20653 } 20654 else{ 20655 $(this).children('i').removeClass('fa-angle-up').addClass('fa-angle-down') 20656 } 20657 } 20658 function send(e){ 20659 e.preventDefault(); 20660 20661 var error = false; 20662 20663 if(!$('.urcnew input[name=item]:checked').length) $('.event_error').removeClass('hidden'); 20664 else $('.event_error').addClass('hidden'); 20665 20666 if(!checkField('nome_azienda_new')) error = true; 20667 if(!checkField('luogo_new')) error = true; 20668 if(!checkField('telefono_new')) error = true; 20669 if(!checkField('nome_new')) error = true; 20670 if(!checkField('cognome_new')) error = true; 20671 if(!checkEmailField('email_new')) error = true; 20672 20673 20674 var c = $('input[name=captcha_new]'); 20675 var v = c.val(); 20676 if(v){ 20677 var r = checkCaptcha(v); 20678 if(r.responseText == 'ok'){ 20679 c.removeClass('error'); 20680 } 20681 else{ 20682 c.addClass('error').val(''); 20683 $('.urcnew .captcha a').trigger('click'); 20684 error = true; 20685 } 20686 } 20687 else{ 20688 c.addClass('error'); 20689 $('.urcnew .captcha a').trigger('click'); 20690 error = true; 20691 } 20692 20693 20694 if(!error){ 20695 var data = { 20696 evento: $('input[name=item]:checked').val(), 20697 nome_azienda: $('input[name=nome_azienda_new]').val(), 20698 luogo: $('input[name=luogo_new]').val(), 20699 telefono: $('input[name=telefono_new]').val(), 20700 nome: $('input[name=nome_new]').val(), 20701 cognome: $('input[name=cognome_new]').val(), 20702 email: $('input[name=email_new]').val() 20703 } 20704 20705 $.post('fileadmin/DFE/DE-SDL/servizio_aziende2/send_event.php', data, function (r){ 20706 if(r == 'ok'){ 20707 $('#new-form > div > div > p, #new-form > div > div > .row').remove(); 20708 $('.urc-opened').before('<p style="margin-top: 38px">Grazie per esservi registrati allâevento âUnâaltra opportunità è dâobbligoâ. A breve riceverete una mail di conferma.</p>') 20709 $('.urc-opener, .urc-opened').remove(); 20710 $('html, body').animate({scrollTop: $('#new-form h2').position().top}, 400); 20711 } 20712 }) 20713 } 20714 } 20715 function checkField(name){ 20716 var f = $('input[name='+name+']'); 20717 f.removeClass('error'); 20718 if(f.val()){ 20719 return true; 20720 } 20721 f.addClass('error'); 20722 return false; 20723 } 20724 function checkEmailField(name){ 20725 var f = $('input[name='+name+']'); 20726 f.removeClass('error'); 20727 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,}))$/; 20728 if(f.val() && re.test(f.val())){ 20729 return true; 20730 } 20731 f.addClass('error'); 20732 return false; 20733 } 20734 function checkCaptcha(value){ 20735 return $.ajax({ 20736 url: 'fileadmin/DFE/DE-SDL/servizio_aziende/securimage/check.php?namespace=form3', 20737 data: { 20738 value: value 20739 }, 20740 async: false, 20741 method: 'post', 20742 success: function (r){ 20743 // console.log(r); 20744 // if(r == 'error'){ 20745 // $('.captcha a').trigger('click'); 20746 // } 20747 } 20748 }); 20749 } 20750 init(); 20751} 20752/* Vivere in Ticino */ 20753function initVivereInTicino() { 20754 var cHeight = 180; 20755 var contentHeight = cHeight + 'px'; 20756 var opened = {
20757 row: false, 20758 n: false, 20759 }; 20760 20761 function init() { 20762 $('.inner-row').each(function () { 20763 $(this).css({ height: 0, overflow: 'hidden' }).removeClass('hidden'); 20764 $(this).prepend('<a class="close" href="#"><i class="fa fa-times"></i></a>') 20765 }) 20766 $('.vivere-in-ticino a.close').click(close); 20767 $('.vivere-in-ticino a.item').click(open); 20768 20769 20770 20771 $('#p1').change(function () { 20772 var v = $(this).val(); 20773 if (v) { 20774 $('.vivere-in-ticino-box .right select').next().addClass('hidden'); 20775 $('select[name=' + v + ']').next().removeClass('hidden'); 20776 } 20777 else { 20778 $('.vivere-in-ticino-box .right select').next().addClass('hidden'); 20779 $('select[disabled]').next().removeClass('hidden'); 20780 } 20781 }); 20782 $('.vivere-in-ticino-box .right select').change(function () { 20783 var v = $(this).val(); 20784 if (v) { 20785 location.href = v; 20786 } 20787 }); 20788 20789 } 20790 function open(e) { 20791 e.preventDefault(); 20792 20793 var i = $(this).parent().parent().index(); 20794 var row = ($(this).parent().parent().parent().parent().index() == 1) ? 1 : 2; 20795 var n = ((row - 1) * 4) + i; 20796 20797 20798 20799 if (!opened.row || (opened.row != row || opened.n != i)) { 20800 20801 if (opened.row && opened.row != row) { 20802 if (opened.row == 1) $('.sub-rows.co-n2, .sub-rows.co-n2 .inner-row').css('height', 0).removeClass('arrow-1').removeClass('arrow-2').removeClass('arrow-3').removeClass('arrow-4'); 20803 else $('.sub-rows.co-n4, .sub-rows.co-n4 .inner-row').css('height', 0).removeClass('arrow-1').removeClass('arrow-2').removeClass('arrow-3').removeClass('arrow-4'); 20804 } 20805 20806 if (opened.row && opened.row == row) { 20807 var rown = (row == 1) ? 2 : 4; 20808 20809 $('.sub-rows.co-n' + rown + ' .inner-row:eq(' + opened.n + ')').css({ height: 0 }); 20810 setTimeout(function () { 20811 $('.sub-rows.co-n' + rown + ' .inner-row:eq(' + i + ')').css({ height: contentHeight }); 20812 $('.sub-rows.co-n' + rown).attr('class', 'sub-rows co-n' + rown + ' arrow-' + (i + 1)); 20813 }, 300); 20814 } 20815 else { 20816 if (row == 1) { 20817 $('.sub-rows.co-n2 .inner-row').css('height', 0); 20818 20819 $('.sub-rows.co-n2, .sub-rows.co-n2 .inner-row:eq(' + i + ')').css({ height: contentHeight }); 20820 $('.sub-rows.co-n2').attr('class', 'sub-rows co-n2 arrow-' + (i + 1)); 20821 } 20822 else { 20823 $('.sub-rows.co-n4 .inner-row').css('height', 0); 20824 20825 $('.sub-rows.co-n4, .sub-rows.co-n4 .inner-row:eq(' + i + ')').css({ height: contentHeight }); 20826 $('.sub-rows.co-n4').attr('class', 'sub-rows co-n4 arrow-' + (i + 1)); 20827 } 20828 20829 // footer fix 20830 if (!opened.row) $('.sliding-content').css('top', parseInt($('.sliding-content').css('top')) + cHeight + 'px'); 20831 } 20832 20833 $('.item.selected').removeClass('selected'); 20834 $(this).addClass('selected'); 20835 20836 opened = { 20837 row: row, 20838 n: i 20839 }; 20840 } 20841 else { 20842 opened = { 20843 row: false, 20844 n: false, 20845 }; 20846 $('.sub-rows.co-n4, .sub-rows.co-n4 .inner-row, .sub-rows.co-n2, .sub-rows.co-n2 .inner-row').css('height', 0).removeClass('arrow-1').removeClass('arrow-2').removeClass('arrow-3').removeClass('arrow-4'); 20847 20848 // footer fix 20849 $('.sliding-content').css('top', parseInt($('.sliding-content').css('top')) - cHeight + 'px'); 20850 } 20851 } 20852 function close(e) { 20853 e.preventDefault(); 20854 $('.sub-rows.co-n4, .sub-rows.co-n4 .inner-row, .sub-rows.co-n2, .sub-rows.co-n2 .inner-row').css('height', 0).removeClass('arrow-1').removeClass('arrow-2').removeClass('arrow-3').removeClass('arrow-4'); 20855 20856 $('.item.selected').removeClass('selected'); 20857 20858 // footer fix 20859 $('.sliding-content').css('top', parseInt($('.sliding-content').css('top')) - cHeight + 'px'); 20860 20861 opened = {
20862 row: false, 20863 n: false, 20864 }; 20865 } 20866 20867 init(); 20868} 20869/* Vocalizzatore */ 20870function aprivocalizza(sURL) { 20871 var w = window.open(sURL, '', 'width=400,height=200,status=yes,menubar=yes,scrollbars=yes,resizable=yes') 20872} 20873function chiudi(elemento) { 20874 jQuery('#visualizza' + elemento).css("display", "none"); 20875 jQuery("#navPrimoLivello" + elemento).css('background-color', '#eeeeee'); 20876} 20877function apri(elemento) { 20878 jQuery('#visualizza' + elemento).css("display", "block"); 20879 jQuery("#navPrimoLivello" + elemento).css('background-color', '#ffffff'); 20880} 20881function initWebcamPage(){ 20882 var timer = 0; 20883 var interval = 60; 20884 function init(){ 20885 // setTimeout(checkTimer, 10000); 20886 setTimeout(checkTimer, interval * 1000); 20887 } 20888 function checkTimer(){ 20889 // timer+=10; 20890 // console.log(timer); 20891 // if(timer == interval){ 20892 // timer = 0; 20893 $('.boxWebcams li img').each(function (){ 20894 addTimestamp($(this), 'src'); 20895 addTimestamp($(this).parent(), 'href'); 20896 }); 20897 if($('.ekko-lightbox.modal img').length) addTimestamp($('.ekko-lightbox.modal img'), 'src'); 20898 // } 20899 // setTimeout(checkTimer, 10000); 20900 setTimeout(checkTimer, interval * 1000); 20901 } 20902 function addTimestamp(o, type){ 20903 var src = o.attr(type); 20904 if(src.indexOf('?') > -1){ 20905 src = src.split('?')[0]; 20906 } 20907 o.attr(type, src + '?' + new Date().getTime()); 20908 } 20909 init(); 20910}
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.