ACC SHELL

Path : /srv/www/vhosts/rozzo/wp-content/themes/amplius/javascript/
File Upload :
Current File : //srv/www/vhosts/rozzo/wp-content/themes/amplius/javascript/init.js

jQuery(document).ready(function(){

	coffee_nicescroll();
	coffee_dropdown();	
	coffee_mobile_nav();
	coffee_forms();
	coffee_layerslider();
	coffee_fancybox();
	coffee_twitterfeed();
	coffee_fitvid();
	coffee_isotope();
	coffee_header_init();
	coffee_filter_portfolio();
	coffee_content();
	coffee_google_maps();
		
});

	function coffee_header_init() {
		
		var ps = jQuery('#parallax-wrapper').attr('data-parallax-speed'); // parallax scrolling speed
		var hp = 50; // header padding
		var hpm = 25; // header padding min target
		var hss = 5; // header scaling speed

		var mtt = parseInt( jQuery('#header-wrapper').height(), 10); // margin to top
		
		var ph = jQuery('#parallax-wrapper').height(); // parallax section height 
		var hh = jQuery('#header-wrapper').height(); // header height
		
		if(jQuery('body').hasClass('parallax-on')){ 
			
			coffee_header(); 
			
			if(jQuery(window).width() < 1200){
				jQuery('body').removeClass('parallax-on');
				jQuery('#header-wrapper').removeClass('parallax-on');
				jQuery('#parallax-wrapper').removeClass('parallax-on');
				coffee_header_reset();
			}
			
			jQuery(window).on("debouncedresize", function() { 
				if(jQuery(window).width() < 1200){
					jQuery('body').removeClass('parallax-on');
					jQuery('#header-wrapper').removeClass('parallax-on');
					jQuery('#parallax-wrapper').removeClass('parallax-on');
					coffee_header_reset();
				} else {
					mtt = parseInt( jQuery('#header-wrapper').height(), 10);
					hh = jQuery('#header-wrapper').height();
					jQuery('body').addClass('parallax-on');
					jQuery('#header-wrapper').addClass('parallax-on');
					jQuery('#parallax-wrapper').addClass('parallax-on');
					coffee_header();
				}
			});
			
		} else {
			coffee_header_reset();
			jQuery(window).on("debouncedresize", function() { coffee_header_reset(); });
		}
		
		function coffee_header() {
	
			coffee_header_core();
			jQuery(window).scroll(function() {

				coffee_header_core();				
				clearTimeout(afterScroll);
				var afterScroll = setTimeout(function(){ coffee_header_core();}, 200);
		 
			});
			
			jQuery(window).on("debouncedresize", function() { coffee_header_core(); });
			
			jQuery('#parallax-wrapper #parallax-title-wrapper').css({'marginTop': -jQuery('#parallax-wrapper #parallax-title-wrapper').height()/2});
			jQuery('#parallax-wrapper #parallax-aside-wrapper').css({'marginTop': -jQuery('#parallax-wrapper #parallax-aside-wrapper').outerHeight()/2});	
			jQuery('#header-logo-wrapper').imagesLoaded(function() { jQuery(this).stop().css({'marginTop': -jQuery('#header-logo-wrapper img').height()/2}); });
			
			function coffee_header_core(){
		
				var dtt = jQuery(document).scrollTop(); // distance to top of document
				ph = jQuery('#parallax-wrapper').height(); // parallax section height 
				hh = jQuery('#header-wrapper').height(); // header height
				mtt = parseInt( jQuery('#header-wrapper').height(), 10); // margin to top
				
				if(dtt <= ph+hh){
				
					jQuery('#header-wrapper.parallax-on #header-navigation div > ul > li').stop().css({'padding-top': hp, 'padding-bottom': hp});				
					jQuery('#parallax-wrapper.parallax-on #parallax-title-wrapper, #parallax-wrapper.parallax-on #parallax-aside-wrapper').stop().css({'top': ((ph - (dtt/ps) - (dtt - (dtt/ps)))/2)+dtt/ps });
					jQuery('#parallax-wrapper.parallax-on #parallax-inner').stop().css({'opacity': 1- (dtt/1.2/ph )});
					jQuery('#parallax-wrapper.parallax-on').css({'marginTop': mtt - Math.round(dtt/ps)});		
	
				} 
				
				if(dtt <= 0){
				
					jQuery('#header-wrapper.parallax-on #header-navigation div > ul > li').stop().css({'padding-top': hp, 'padding-bottom': hp});				
					jQuery('#parallax-wrapper.parallax-on #parallax-title-wrapper, #parallax-wrapper.parallax-on #parallax-aside-wrapper').stop().css({'top': ((ph - (dtt/ps) - (dtt - (dtt/ps)))/2)+dtt/ps });
					jQuery('#parallax-wrapper.parallax-on #parallax-inner').stop().css({'opacity': 1});
					jQuery('#parallax-wrapper.parallax-on').css({'marginTop': mtt });
				
				}		
				
				if (dtt > ph) {
					
					if (dtt <= ph+((hp-hpm)*hss) && (hp-((dtt-ph)/hss))>= hpm){
						jQuery('#header-wrapper.parallax-on #header-navigation div > ul > li').stop().css({'padding-top': (hp-((dtt-ph)/hss)), 'padding-bottom': (hp-((dtt-ph)/hss))});
					} else {
						jQuery('#header-wrapper.parallax-on #header-navigation div > ul > li').stop().css({'padding-top': hpm, 'padding-bottom': hpm});
					}
					
				}
				
				jQuery('#header-logo-wrapper').imagesLoaded(function() { jQuery(this).stop().css({'marginTop': -jQuery('#header-logo-wrapper img').height()/2}); });
				if(ph > 0){ jQuery('#content-wrapper').css({'marginTop': ph+hh}); }
			}
		
		}
		function coffee_header_reset() {
		
			mtt = parseInt( jQuery('#header-wrapper').height(), 10);
			hh = jQuery('#header-wrapper').height();
			
			jQuery('#header-wrapper #header-navigation div > ul > li').stop().css({'padding-top': hp, 'padding-bottom': hp});				
			jQuery('#parallax-wrapper #parallax-title-wrapper, #parallax-wrapper #parallax-aside-wrapper').removeAttr('style');
			jQuery('#parallax-wrapper #parallax-inner').stop().css({'opacity': 1});
			jQuery('#parallax-wrapper').css({'marginTop': mtt });
			
			if(ph > 0){ jQuery('#content-wrapper').css({'marginTop': ph+hh}); }
			
			jQuery('#parallax-wrapper #parallax-title-wrapper').css({'marginTop': -jQuery('#parallax-wrapper #parallax-title-wrapper').height()/2});
			jQuery('#parallax-wrapper #parallax-aside-wrapper').css({'marginTop': -jQuery('#parallax-wrapper #parallax-aside-wrapper').outerHeight()/2});			
			jQuery('#header-logo-wrapper').imagesLoaded(function() { jQuery(this).stop().css({'marginTop': -jQuery('#header-logo-wrapper img').height()/2}); });
			
			jQuery(window).on("debouncedresize", function() { 
				var ph = jQuery('#parallax-wrapper').height(); // parallax section height 
				var hh = jQuery('#header-wrapper').height(); // header height
				if(ph > 0){ jQuery('#content-wrapper').css({'marginTop': ph+hh}); }
			});
				
		}
		
	}	
	function coffee_dropdown() {
		
		var headerNav = jQuery('#header-navigation div > ul > li');
		headerNav.each(function() {
			jQuery(this).hoverIntent({
				interval: 50,
				timeout: 250,
				over: function() {
					if(jQuery(window).width() > 960){
						jQuery(this).children('ul').slideDown(200);
					}
				},
				out: function() {
					if(jQuery(window).width() > 960){
						jQuery(this).children('ul').slideUp(200);
					}
				} 
			});		
		});
		
	}
	function coffee_mobile_nav() {

		var windowWidth = jQuery(window).width();
		var mobileBtn = jQuery('#header-navigation-mobile i');
		var headerNav = jQuery('#header-navigation');
		var headerNavSub = jQuery('#header-navigation .sub-menu');
		
		mobileBtn.click(function() {
			
			if(jQuery(this).hasClass('inactive')){
				
				headerNav.slideDown();
				jQuery(this).removeClass('inactive').addClass('active');
				
			} else {
				
				headerNav.slideUp();
				jQuery(this).removeClass('active').addClass('inactive');
				
			}
			
		});
		
		jQuery(window).on("debouncedresize", function() { 
		
			if(windowWidth !== jQuery(window).width()){
				if(jQuery(window).width() < 960){
					headerNav.css({'display': 'none'});
					headerNavSub.css({'display': 'block'});
					jQuery(this).removeClass('active').addClass('inactive');
				} else {
					headerNav.css({'display': 'block'});
					headerNavSub.css({'display': 'none'});
					jQuery(this).removeClass('active').addClass('inactive');
				}
				windowWidth = jQuery(window).width();
			}
			
		});
			
	}
	function coffee_forms() {
	
		var headerSearch = jQuery('#parallax-search #s');
		var headerSearchValue = headerSearch.val();
		headerSearch.focus(
			function() {
				
				if(jQuery(window).width() <= 768 ){
					headerSearch.animate({'width': 378}, 200);
					jQuery('#parallax-title-wrapper').fadeOut(200, 'linear');
				} else {
					headerSearch.animate({'width': 118}, 200);
				}
				
				if(this.value === headerSearchValue){ headerSearch.val(''); }
				
			}
		);
		headerSearch.blur(
			function() {
			
				headerSearch.animate({'width': 59}, 200);
				jQuery('#parallax-title-wrapper').fadeIn(200, 'linear');
				
				if(this.value === ''){ headerSearch.val(headerSearchValue); }
				
			}
		);
		
		var widgetSearch = jQuery('.widget_search #s');
		var widgetSearchValue = widgetSearch.val();
		widgetSearch.focus(
			function() {
				if(this.value === widgetSearchValue){ widgetSearch.val(''); }
			}
		);
		widgetSearch.blur(
			function() {
				if(this.value === ''){ 
					widgetSearch.val(widgetSearchValue); 
				}
			}
		);
	
		jQuery('#respond .reply-form-input').each( function() {
			
			var thisValue = jQuery(this).val();
			jQuery(this).focus(
				function() {
					if(this.value === thisValue){ jQuery(this).val(''); }
				}
			);
			jQuery(this).blur(
				function() {
					if(this.value === ''){ 
						jQuery(this).val(thisValue); 
					}
				}
			);
			
		});
		jQuery('#contact-template-form #contactName.fresh, #contact-template-form #email.fresh').each(function() {
			var thisValue = jQuery(this).attr('name');
			jQuery(this).focus(
				function() {
					if(this.value === thisValue){ jQuery(this).val(''); }
				}
			);
		});
		jQuery('#contact-template-form #contactName, #contact-template-form #email').each(function() {
			var thisValue = jQuery(this).attr('name');
			jQuery(this).blur(
				function() {
					if(this.value === ''){ 
						jQuery(this).val(thisValue); 
					}
				}
			);
		});
			
		
	}
	function coffee_nicescroll() {		
		jQuery("body.nicescroll").niceScroll({
			cursorwidth: 8,
			cursorborder: 0,
			zindex: 999,
			cursorcolor: "#222",
			cursorborderradius: 4,
			scrollspeed: 120,
			mousescrollstep: 45
		});
	}
	function coffee_layerslider() {
		
		var ls_container = jQuery('#parallax-wrapper .ls-container'); // layerslider id
		
		if(ls_container.layerSlider){
			var stopped = false;
			jQuery(window).scroll( coffee_manage_ls );
			
			var contentMarginSet = setInterval(function(){
				if(jQuery('#parallax-wrapper').height() > 0){
					jQuery('#content-wrapper').css({'marginTop': jQuery('#parallax-wrapper').height()+jQuery('#header-wrapper').height()});
					clearInterval(contentMarginSet);
				}
			}, 200);	 
		}
		
		function coffee_manage_ls(){

			var dtt = jQuery(document).scrollTop(); // distance to top of document
			var ph = jQuery('#parallax-wrapper').height(); // parallax section height 

			if((dtt <= ph) && (stopped === true)){ 
				ls_container.layerSlider('start'); 
				stopped = false;					
			} else if ((dtt > ph) && (stopped === false)){
				ls_container.layerSlider('stop'); 
				stopped = true;
			}	 
		}
	}
	function coffee_fancybox() {
		var galleryID = 1;
		jQuery('.entry-content .gallery').each(function() {
			jQuery(this).find('.gallery-icon a').addClass('fancybox').attr('rel', 'fancybox-group-shortcode-'+galleryID);
			galleryID++;
		});	
		jQuery(".fancybox").fancybox({});
	}
	function coffee_twitterfeed() {
		var tweets = jQuery('#twitterfeed ul').children("li");
		var tweetsList = jQuery('#twitterfeed ul');
		var counter = 0;		
		tweetsList.css({'minHeight': tweets.eq(counter).height()});

		var interval = setInterval( tweets_swap, 5000);
		jQuery('#twitterfeed').hover(function() {
			interval = clearInterval(interval);
		}, function() {
			interval = setInterval( tweets_swap, 5000);
		});		
		
		function tweets_swap() {	
			tweets.eq(counter).fadeOut(200);
			counter = counter+1;
			if( counter >= tweets.length){counter = 0;}
			tweets.eq(counter).delay(210).fadeIn(200);
			tweetsList.css({'minHeight': tweets.eq(counter).height()});
		}		
		jQuery(window).on("debouncedresize", function() {			
			tweetsList.css({'minHeight': tweets.eq(counter).height()});
		});
	}
	function coffee_fitvid() {
		jQuery('.fitvid').fitVids();
		jQuery('.entry-content iframe').fitVids();		
	}
	function coffee_isotope() {
		var container = jQuery('#grid-blog-type .content-column, #portfolio-grid .content-column, #team-grid .content-column');
		coffee_isotope_columns();
		container.isotope({
			itemSelector : 'article, #pagination',
			animationEngine : 'css'
		}, function() {			
			coffee_isotope_columns();
			jQuery('#grid-blog-type .content-column article, #portfolio-grid .content-column article, #team-grid .content-column article').each( function(){
	
				if( jQuery(this).find('img').length ){
					jQuery(this).imagesLoaded(function() { container.isotope('reLayout'); }); 
				}				
				if( jQuery(this).find('iframe').length ){
					jQuery(this).find('iframe').load(function() { container.isotope('reLayout'); });					
				}
				
			});
			jQuery(window).on("debouncedresize", function() {			
				coffee_isotope_columns();	
				container.isotope('reLayout');
			});
		});
		
		function coffee_isotope_columns(){
			
			var containerWidth = container.width();
			var windowWidth = jQuery(window).width();
			var columns = 4;			
			
			if(windowWidth >= 1200){ columns = 4; }
			if(windowWidth > 960 && windowWidth <= 1200){ columns = 4; }
			if(windowWidth > 768 && windowWidth <= 960){ columns = 3; }
			if(windowWidth > 480 && windowWidth <= 768){ columns = 2; }
			if(windowWidth <= 480){ columns = 1; }
			var postWidth = containerWidth/columns;
			
			postWidth = Math.floor(postWidth);
			
			container.find("article.isotope-item").each(function(){ jQuery(this).css({"width":postWidth+"px"}); });
		}
	}
	function coffee_filter_portfolio() {
		var filter = jQuery('#parallax-filter ul li');
		var items = jQuery('#portfolio-grid .content-column article');
		var classesPool = '';
		items.each(function(){ classesPool += ' '+jQuery(this).attr('class'); });
		
		filter.each(function(){
		
			jQuery(this).click(function(){
			
				if(jQuery(this).hasClass('current')){
					jQuery('#parallax-aside-wrapper ul li.active').show(200, 'linear');
					if(jQuery(window).width() <= 768 ){
						jQuery('#parallax-title-wrapper').fadeOut(200, 'linear');
					}
					return;
				}
				var filterValue = jQuery(this).find('a').attr('data-filter');
				
				filter.removeClass('current');
				jQuery(this).addClass('current');
				jQuery('#parallax-aside-wrapper ul li.active').not('.current').hide(200, 'linear');
				jQuery('#parallax-title-wrapper').fadeIn(200, 'linear');
				if(jQuery(this).hasClass('all')){items.find('.entry-inner').css({'opacity': 1}); return;}
				
				items.each(function(){
				
					if(jQuery(this).hasClass(filterValue)){
						jQuery(this).find('.entry-inner').css({'opacity': 1});
					} else {
						jQuery(this).find('.entry-inner').css({'opacity': 0.1});
					}
							
				});	
				
			});
			
		});
		
		coffee_active_filters();	
		function coffee_active_filters(){
			var filters = jQuery('#parallax-filter ul li').not('.all');
			jQuery('#parallax-filter ul li.all').css({'display': 'block'});
			
			filters.each(function(){
				if((classesPool.indexOf(jQuery(this).find('a').attr('data-filter')) === -1)){
					jQuery(this).removeClass('active');	
				} else {
					jQuery(this).addClass('active');
				}
			});	
		}	
		
		coffee_hover_filters();
		function coffee_hover_filters(){
			jQuery('#parallax-aside-wrapper.parallax-filters').hoverIntent({
				interval: 50,
				timeout: 250,
				over: function() {
				
					jQuery('#parallax-aside-wrapper ul li.active').show(200, 'linear');
					if(jQuery(window).width() <= 768 ){
						jQuery('#parallax-title-wrapper').fadeOut(200, 'linear');
					}
				},
				out: function() {
				
					jQuery('#parallax-aside-wrapper ul li.active').not('.current').hide(200, 'linear');
					jQuery('#parallax-title-wrapper').fadeIn(200, 'linear');
				} 
			});
			
		}
	}
	function coffee_content() {
	 
		jQuery(".wp-caption").width(function() { return jQuery('img', this).width(); });		
		jQuery(".coffee-shortcode-accordion").accordion({autoHeight: true, heightStyle: "content", collapsible: true, activate: coffee_accordion_after});
		jQuery(".coffee-shortcode-toggle-section").each( function () {
			if(jQuery(this).attr('data-id') === 'closed') {
				jQuery(this).accordion({ header: '.coffee-toggle-title', collapsible: true, active: false, activate: coffee_accordion_after });
			} else {
				jQuery(this).accordion({ header: '.coffee-toggle-title', collapsible: true, activate: coffee_accordion_after });
			}
		});
	
		coffee_accordion_after();
		function coffee_accordion_after(){
			jQuery(".coffee-shortcode-toggle, .coffee-shortcode-accordion").each( function () {
				var baseHeight = jQuery(this).height();
				var paddingBottom;
				if (baseHeight%25 === 0){
					paddingBottom = 7;
				} else {				
					var divider = Math.floor(baseHeight/25);
					var desiredHeight = (divider+1)*25;
					paddingBottom = desiredHeight - baseHeight + 7;
				}

				jQuery(this).animate({'paddingBottom': paddingBottom}, 200);
				
			});
		}
		jQuery(".coffee-shortcode-tabs").tabs({
			active: 0, 
			autoHeight: true, 
			heightStyle: "content", 
			show: { effect: "fadeIn", duration: 200 }, 
			hide: { effect: "fadeOut", duration: 200 }, 
			beforeActivate: function( event, ui ) {
				jQuery(this).find('.tabs-content').animate({'height': ui.newPanel.outerHeight()}, 200);
			}
		});

		sidebar_position();
		jQuery(window).on("debouncedresize", function(){ 
			sidebar_position(); 
			jQuery('.coffee-shortcode-tabs').each( function() {jQuery(this).find('.tabs-content').removeAttr('style');});	
			jQuery('.coffee-shortcode-accordion').each( function() {jQuery(this).accordion("resize");});	
			jQuery('.coffee-shortcode-toggle-section').each( function() {jQuery(this).accordion("resize");});	
		
		});
		
		function sidebar_position(){
			if(jQuery(window).width() <= 768 && jQuery('#large-blog-type, #medium-blog-type, #mini-blog-type, #page-template, #contact-template').hasClass('left-sidebar')){
				jQuery('#sidebar-wrapper').insertAfter('#large-blog-type, #medium-blog-type, #mini-blog-type, #page-template, #contact-template');
			}else if(jQuery(window).width() > 768 && jQuery('#large-blog-type, #medium-blog-type, #mini-blog-type, #page-template, #contact-template').hasClass('left-sidebar')){
				jQuery('#sidebar-wrapper').insertBefore('#large-blog-type, #medium-blog-type, #mini-blog-type, #page-template, #contact-template');
			}
		}			
				
	}
	function coffee_google_maps() {
		var map;
		function initialize() {		
			var mapContainer = jQuery('#parallax-google-maps');
			var mapLat = parseFloat(mapContainer.attr('data-lat'));
			var mapLng = parseFloat(mapContainer.attr('data-lng'));
			var zoom = parseFloat(mapContainer.attr('data-zoom'));
			var allowZoom = mapContainer.attr('data-allow-zoom');
			var marker = mapContainer.attr('data-marker');
			var markerImg = mapContainer.attr('data-marker-icon');
			var markerContent = mapContainer.attr('data-marker-content');
			var markerLat = parseFloat(mapContainer.attr('data-marker-lat'));
			var markerLng = parseFloat(mapContainer.attr('data-marker-lng'));
			
			if (allowZoom === 'true'){ allowZoom = true;} else {allowZoom = false;}
			var mapOptions = {
				zoom: zoom,
				draggable: false,
				scrollwheel: false,
				panControl: false,
				mapTypeControl: false,
				scaleControl: false,
				streetViewControl: false,
				zoomControl: allowZoom,	 
				zoomControlOptions: {
				style: google.maps.ZoomControlStyle.LARGE,
				position: google.maps.ControlPosition.LEFT_CENTER
			},
				center: new google.maps.LatLng(mapLat, mapLng),
				mapTypeId: google.maps.MapTypeId.ROADMAP
			};
			map = new google.maps.Map(document.getElementById('parallax-google-maps'),	mapOptions);
			if(marker === 'true'){ google.maps.event.addListenerOnce(map, 'tilesloaded', function() { createMarker(map); }); }
			function createMarker(map){
			
				var marker = new google.maps.Marker({
					position: new google.maps.LatLng(markerLat, markerLng),
					map: map,
					animation: google.maps.Animation.BOUNCE,
					icon: markerImg,
					optimized: false
				});
				setTimeout(function(){marker.setAnimation(null);}, 200);
	
				var infowindow = new google.maps.InfoWindow({
					content: markerContent,
					maxWidth: 300
				});
			
				google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); });		
						
			}			
			var center;
			function calculateCenter() { center = map.getCenter(); }
			google.maps.event.addDomListener(map, 'idle', function() { calculateCenter(); });
			jQuery(window).on("debouncedresize", function() { map.setCenter(center); });
		}
		if(jQuery('#parallax-google-maps').length){
			google.maps.event.addDomListener(window, 'load', initialize);		
		}
	}

ACC SHELL 2018