/* File di customizzazione per gli script js*/ $(function(){ var si2k17 = { init: function(){ this.cacheDom(); this.initSearch(); this.initNavBar(); // this.initMenuLayout(); this.bindEvents(); // this.checkLocation(); // this.missionBg(); }, cacheDom: function(){ this.$htmlNode = $('html'); this.$pageBody = $('body'); this.$noteHead = $('.c-note-head'); this.$searchBar = $('.c-search-bar'); this.$searchBarInput = this.$searchBar.find('#src'); this.$searchBarSubmit = this.$searchBar.find('.src_top'); this.$mainNav = $('.l-nav'); this.$mainMenu = $('.c-main-nav'); this.$mainBanner = $('.l-main-banner'); this.$innerMenu = $('.c-int-nav'); this.$btnInnerMenu = $('.o-int-nav-reveal'); this.$mainTitle = $('.c-main-title div'); this.$breadcrumb = $('.c-breadcrumb'); this.$backTop = $('.c-back-top'); this.$btnMenu = $('.o-menu-reveal'); this.$btnCerca = $('#o-src-reveal'); this.$btnShortList = $('.c-short-list'); this.$shortList = this.$btnShortList.find('ul'); this.$mainContent = $('.c-main-content'); this.$newsList = $('.c-news'); this.$datiLegaliTitle = $('.c-legal-ttl'); this.$datiLegali = $('.c-sub-footer'); this.$missionRight = $('.l-mission-right'); }, bindEvents: function(){ $(window) .on('scroll', $.proxy( this.stickyHeader, this)) .on('scroll', $.proxy( this.backTopVisibility, this)) .on('scroll', $.proxy( this.closeMenu, this)) .on('resize', $.proxy( this.updateNavPlaceholder, this)) this.$btnMenu .on('click', $.proxy( this.checkMenuTop, this)) .on('click', $.proxy( this.controllerMenu, this)) .on('click', $.proxy( this.closeSearch, this)) .on('click', $.proxy( this.noScrolling, this)); this.$btnInnerMenu .on('click', $.proxy( this.toggleInnerMenu, this)); this.$btnCerca .on('click', $.proxy( this.openSearch, this)) .on('click', $.proxy( this.closeMenu, this)); // this.$btnShortList // .on('click', $.proxy( this.controllerShortList, this)); this.$backTop .on('click', $.proxy( this.backTop, this)); }, initSearch: function(){ this.$searchBarInput.attr({ placeholder: 'Cosa cerchi?', value: '', autocomplete: "off" }); this.$searchBarSubmit.attr({ value: 'Cerca' }); }, initNavBar: function(){ this.$mainNav.wrap(""); this.updateNavPlaceholder(); }, // initMenuLayout: function(){ // var $lancio = this.$mainMenu.find( $('div[class*=tdLTd]') ); // var $scorrevole = this.$mainMenu.find( $('#launch-slide') ); // var $navInt = this.$mainMenu.find( $('.lstNav5Liv1') ); // // if( $lancio.length != 0 || $scorrevole.length != 0 || $navInt.length != 0 ){ // this.$mainMenu.addClass('has-sidebar'); // } // // }, // controllerShortList: function(){ // this.$shortList.fadeToggle(); // this.$btnShortList.toggleClass('is-open'); // }, updateNavPlaceholder: function(){ var h = this.$mainNav.outerHeight(); $('.l-nav-placeholder').css('min-height', h); }, openSearch: function(e){ e.preventDefault(); this.$searchBar.fadeToggle().toggleClass('is-open', $.proxy( this.clearSearch, this)); if( this.$mainMenu.hasClass('is-open')){ this.closeMenu(); } }, closeSearch: function(){ if(this.$searchBar.hasClass('is-open')){ this.$searchBar.fadeOut('fast').removeClass('is-open'); } }, clearSearch: function(){ this.$searchBarInput.val(''); }, stickyHeader: function(){ if ( $(window).scrollTop() > this.$noteHead.outerHeight() ){ this.$mainNav.addClass('is-scrolling'); }else{ this.$mainNav.removeClass('is-scrolling'); } if( this.$searchBar.hasClass('is-open') ){ this.$searchBar .fadeOut('fast', $.proxy( this.clearSearch, this)) .removeClass('is-open'); } }, controllerMenu: function(){ this.$mainMenu .fadeToggle(100) .toggleClass('is-open'); this.$btnMenu.toggleClass('is-open'); if( this.$btnMenu.hasClass('is-open') ){ this.$mainMenu.delay(200).scrollTop(0); } }, closeMenu:function(){ this.$pageBody .removeClass('no-scrolling'); this.$btnMenu .removeClass('is-open'); this.$mainMenu .fadeOut(100); }, checkMenuTop:function(){ if ( $(window).scrollTop() > this.$noteHead.outerHeight() ){ var t = this.$mainNav.outerHeight(); this.$mainMenu.css('top', t); }else{ var t = this.$noteHead.outerHeight() + this.$mainNav.outerHeight() - $(window).scrollTop(); this.$mainMenu.css('top', t); } }, noScrolling: function(){ if( this.$mainMenu.hasClass('is-open')){ this.$pageBody.addClass('no-scrolling'); }else{ this.$pageBody.removeClass('no-scrolling'); } }, backTop: function(){ $('html, body').animate({scrollTop:0}, 1000); }, backTopVisibility: function(){ if ( $(window).scrollTop() > $(window).height() / 2 ){ this.$backTop.fadeIn('slow'); }else{ this.$backTop.fadeOut('slow'); } } } si2k17.init(); /*--- Cache Dom ---*/ var $inputForm = $('.form-group input[type=text], .form-group input[type=password], .form-group input[type=email]'); var $inputData = $('.o-date-picker'); var $labelForm =$('.form-group label:not(.o-label-textarea)'); //var $btnRegStepForward = $('#registrazione-step .o-btn-forward-cont button'); var $guestCont = $('.c-guest-container'); var $addGuestBtn = $('.o-btn-add-guest'); var $removeGuestBtn = $('.o-del-guest'); /*--- Functions ---*/ function inputFocused(){ $(this).prev().addClass('is-focused'); } function labelFocused(){ $(this).addClass('is-focused'); $(this).next('input').focus(); console.log('cliccato sulla label'); } function inputBlurred(){ if($(this).val() == '' || $(this).val() == 0){ $(this).prev().removeClass('is-focused'); } } //function regStepForwardController(){ // var $totalSteps = $('.c-step').length; // var $currentStep = $(this).parents('.c-step'); // var $currentNumber = $(this).parents('.c-step').data('step-reg'); // var $nextNumber = $currentNumber ++; // var $nextStep = $('.c-step[data-step-reg='+ $nextNumber.toString() + ']'); // // console.log('step total: ' + $totalSteps); // // console.log(typeof $totalSteps); // // console.log('step attuale: ' + $currentNumber); // // console.log(typeof $currentNumber); // // console.log('step succ: ' + $nextStep); // // console.log($nextNumber); // if ($(this).parents('.c-step').data('step-reg') == $totalSteps ){ // console.log('ultimo step'); // $('#registrazione-step').modal('hide') // return // } else{ // $currentStep.fadeOut(300); // $currentStep.next().delay(300).fadeIn(300); // } //} function regStepForwardReset(){ $('.c-step').hide(); $('.c-step[data-step-reg=1]').show(); } function addGuest(){ var addGuestFormOld = '
\

Dettaglio ospite

\
\ \ \
\
\ \ \
\
'; var addGuestForm = '
\
\

Dettaglio ospite

\ \
\
\
\ \ \
\
\
\
\ \ \
\
\
'; if ($('.c-add-guest').length == 0){ $('.c-privacy-check').fadeIn(); } $guestCont.append(addGuestForm); } function removeGuest(){ $(this).parents('.c-add-guest').remove(); if ($('.c-add-guest').length == 0){ $('.c-privacy-check').hide(); } } $.datepicker.regional['it'] = { closeText: 'Chiudi', // set a close button text currentText: 'Oggi', // set today text monthNames: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'], // set month names monthNamesShort: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'], // set short month names dayNames: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'], // set days names dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'], // set short day names dayNamesMin: ['Do', 'Lu', 'Ma', 'Me', 'Gio', 'Ve', 'Sa'], // set more short days names dateFormat: 'dd/mm/yy' // set format date }; $.datepicker.setDefaults($.datepicker.regional['it']); $inputData.datepicker({ showButtonPanel: true, changeMonth: true, changeYear: true, showOtherMonths: true, selectOtherMonths: true }); /*--- Events ---*/ $inputForm .on('focus', inputFocused) .on('focusout', inputBlurred); $labelForm .on('click', labelFocused); //$btnRegStepForward // .on('click', regStepForwardController); $('#registrazione-step') .on('hidden.bs.modal', regStepForwardReset); //$addGuestBtn // .on('click', addGuest); $(document) .on('click', '.o-del-guest' , removeGuest) .on('click', '.form-group label:not(.o-label-textarea)', labelFocused) .on('focus', '.c-add-guest .form-group input[type=text]',inputFocused) .on('focusout', '.c-add-guest .form-group input[type=text]', inputBlurred) }); //*******************************Aggiunte**************************************************** function isEmail(a) { if (jQuery.trim(a) != "") { var b = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/; return String(a).search(b) != -1 } else { return true } } function isNumberInteger(a) { return (/^[0-9]+$/i.test(a)) } $.fn.serializeObject = function () { var o = {}; $(this).find('input[type="hidden"], input[type="text"], input[type="password"], input[type="checkbox"], input[type="radio"], select').each(function () { if (this.name === null || this.name === undefined || this.name === '') return; var elemValue = null; if ($(this).is('select')) { elemValue = $(this).find('option:selected').val(); } else if ($(this).attr("type") == "checkbox") { ($(this).prop('checked')) ? elemValue = 'true' : elemValue = 'false'; } else { elemValue = this.value; } if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(elemValue || ''); } else { o[this.name] = elemValue || ''; } }); return o; } //controllo Password function CheckPassword(val, confval, Username) { var sErrMsg = ""; var matches = val.match(/^[A-Za-z0-9!@#$^*?_£.,]+$/); if (val == "") { sErrMsg = "inserire la password.\n"; }else if (val.length < 8) { sErrMsg = "la lunghezza minima della password è di 8 caratteri.\n"; } else if (val.toLowerCase() == Username) { sErrMsg = "la password non può corrispondere alla userID !\n"; } else if (val.toLowerCase() == "password") { sErrMsg = "la password non può corrispondere alla parola 'password'\n"; } else if (!(val.match(/[!@#$^*?_£.,]/))) { sErrMsg = "la password deve contenere almeno uno dei caratteri seguenti speciali\n!@#$^*?_£.,"; } else if (!(val.match(/([A-Z])/))) { sErrMsg = "la password deve contenere almeno una lettera maiuscola.\n"; } else if (!(val.match(/([0-9])/))) { sErrMsg = "la password deve contenere almeno un numero.\n"; } else if (val.match(/\x20/)) { sErrMsg = "la password non può contenere spazi vuoti.\n"; } else if (matches == null || matches.length > 1) { sErrMsg = "La password contiene caratteri non consentiti.\n"; } else if ($.trim(confval) == "") { sErrMsg = "inserire la conferma password.\n"; } else if (val != confval) { sErrMsg = "password e conferma password non coincidono.\n"; } return sErrMsg; }