%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/casasmonvl/newges4t/wp-content/themes/ges4t/js/
Upload File :
Create Path :
Current File : /home/casasmonvl/newges4t/wp-content/themes/ges4t/js/main.js

// main.js

import babelPolyfill from 'babel-polyfill';
import $ from 'jquery';
import slick from 'slick-carousel';

function wrap(el, wrapper) {
    el.parentNode.insertBefore(wrapper, el);
    wrapper.appendChild(el);
}

var fullpageElement = document.getElementById('fullpage');
if (fullpageElement) {
	var sections = [...fullpageElement.children];
	var sectionWrapper, slideWrapper, slideProgress, slideProgressCounter, slideBgImg;
	for (var i = 0; i < sections.length; i++) {
		if (i > 0, sections[i].classList.contains('subsection')) {
			slideWrapper = document.createElement('div');
			slideWrapper.setAttribute('class', 'slide');
			wrap(sections[i], slideWrapper);
			wrap(slideWrapper, sectionWrapper);
		}
		else {
			sectionWrapper = document.createElement('div');
			sectionWrapper.setAttribute('class', 'section fp-auto-height-responsive');
			if ( (i + 1) < sections.length && sections[i+1].classList.contains('subsection')) {
				slideWrapper = document.createElement('div');
				slideWrapper.setAttribute('class', 'slide');
				wrap(sections[i], slideWrapper);
				wrap(slideWrapper, sectionWrapper);

				slideProgress = document.createElement('div');
				slideProgress.setAttribute('class', 'slideProgress');
				slideProgressCounter = document.createElement('div');
				slideProgressCounter.setAttribute('class', 'slideProgressCounter');
				slideProgressCounter.innerHTML = "01";
				slideProgress.appendChild(slideProgressCounter);
				sectionWrapper.appendChild(slideProgress);
				slideBgImg = document.createElement('div');
				slideBgImg.setAttribute('class', 'slideBgImg');
				sectionWrapper.appendChild(slideBgImg);
			}
			else {
				wrap(sections[i], sectionWrapper);
			}
		}
	}
	new fullpage('#fullpage', {
		//options here
		autoScrolling:true,
		scrollHorizontally: false,
		paddingTop: '60px',
		paddingBottom: '60px',
		navigation: false,
		slidesNavigation: false,
		loopHorizontal: false,
		responsiveWidth: 992,
		licenseKey: 'A01EE536-4A6C467C-8C41E5EB-D1D602B2',
		onLeave: function(origin, destination, direction){
			var currentSection = destination.index;
			var totalSections = document.getElementById('fullpage').children.length;
			var sectionProgress = (currentSection + 1) / totalSections;
			var sectionProgressBar = document.getElementById('sectionProgressFill');
			sectionProgressBar.style.transform = "scaleY("+sectionProgress+")";
		},
		onSlideLeave: function( section, origin, destination, direction){
			if (section.index === 3) {
				var currentSlide = destination.index;
				var totalSlides = destination.item.parentNode.children.length;
				var slideProgress = (currentSlide + 1) / totalSlides;
				var slideProgressBar = document.querySelector('div:nth-child(4) .slideProgress');
				slideProgressBar.style.width = Math.round(slideProgress * 100) + "%";
				var slideProgressCounter = document.querySelector('div:nth-child(4) .slideProgressCounter');
				slideProgressCounter.innerHTML = ("0" + (currentSlide + 1)).slice(-2);
			}
			if (section.index === 5) {
				switch(destination.index){
					case 0:
						var img = "url("+window.wp_stylesheet_directory+"/img/06Abg.jpg)";
						break;
					case 1:
						var img = "url("+window.wp_stylesheet_directory+"/img/06Bbg.jpg)";
						break;
					case 2:
						var img = "url("+window.wp_stylesheet_directory+"/img/06Cbg.jpg)";
						break;
					case 3:
						var img = "url("+window.wp_stylesheet_directory+"/img/06Dbg.jpg)";
						break;
				}
				document.querySelector('.homepage-primary .section:nth-child(6) .slideBgImg').style.backgroundImage = img;
				var currentSlide = destination.index;
				var totalSlides = destination.item.parentNode.children.length;
				var slideProgress = (currentSlide + 1) / totalSlides;
				var slideProgressCounter = document.querySelector('div:nth-child(6) .slideProgressCounter');
				slideProgressCounter.innerHTML = ("0" + (currentSlide + 1)).slice(-2);
			}
			if (section.index === 6) {
				switch(destination.index){
					case 0:
						var img = "url("+window.wp_stylesheet_directory+"/img/07Abg.jpg)";
						break;
					case 1:
						var img = "url("+window.wp_stylesheet_directory+"/img/07Bbg.jpg)";
						break;
					case 2:
						var img = "url("+window.wp_stylesheet_directory+"/img/07Cbg.jpg)";
						break;
				}
				document.querySelector('.homepage-primary .section:nth-child(7) .slideBgImg').style.backgroundImage = img;
			}
		},
		afterRender: function(){
			// preload bg images
			var bgImages = ['06Abg','06Bbg','06Cbg','06Dbg','07Abg','07Bbg','07Cbg'];
			bgImages.forEach(element => {
				var pic = new Image();
				pic.src = window.wp_stylesheet_directory+"/img/"+element+".jpg";
			});

		}
	});
}

$(".slider").slick();

	var allPanels = $('.schema-faq-answer').hide();
	  
	$('.schema-faq-question').click(function(e) {
		allPanels.each(function(index, el){
			if (index !== $(e.target).parent().index()) {
				console.log($(e.target).parent().index());
				$(el).stop(true,true).slideUp();
			}
		});
		$(this).next().stop(true,true).slideToggle();
		return false;
	});

Zerion Mini Shell 1.0