/* 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 = '