<repo_name>motowelove/motowelove.github.io<file_sep>/js/main.js


/*preloader*/
$('body').append('<div id="page-preloader"></div>');
$('#page-preloader').append('<span class="spinner"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i></span>');

$(window).on('load', function(){
		preloaderEvent()
	});


/*slider*/

var sliderTimeOut = 2500;
var currentSlide = 1;
var lastSlide = $('.slide-img').length;


for(var i=0;i<lastSlide;i++){
	$('.slider-dots').append('<li></li>');
}
$('.slider-dots').children().click(function(){
	dotId = $(this).index();
	if (dotId + 1 != currentSlide){
		tWidth = -$('.overflow-slider').width()*(dotId);
		$('.slides').css('transform','translate('+tWidth+'px,0)');
		currentSlide = dotId + 1;
	}
});

$('.slider-left-button').click(prevSlide);
$('.slider-right-button').click(nextSlide);



/*why-slider*/

var whyCurrentSlide = 1;
var whyLastSlide = $('.why-slide-li').length;

for(var i=0;i<whyLastSlide;i++){
	$('.why-slider-dots').append('<li class="whyDot"></li>');
}
$('.why-slider-dots').children().click(function(){
    whyDotId = $(this).index();
    if (whyDotId + 1 != whyCurrentSlide){
        whytWidth = -$('.why-overflow').width()*(whyDotId);
        $('.why-slides').css('transform','translate('+whytWidth+'px,0)');
        whyCurrentSlide = whyDotId + 1;
    }
});
$('.whyDot').click(function(){
	$('.whyDot').css('background-color','#f2f2f2');
	$(this).css('background-color','#e5493a');

})
document.querySelectorAll('.whyDot')[0].click();

$(document).ready(sliderStarter);



/*onscrolls*/

var arrowUp = document.querySelector('.arrowUp');
arrowUp.onclick = function(){
	goToTop();
}

var maxScroll = window.pageYOffset;

window.onscroll = function(){
	
	if(maxScroll < window.pageYOffset){
		$('header').css('transform','translate(0,-60px)');
		maxScroll = window.pageYOffset;
	}
	if(maxScroll > window.pageYOffset){
		$('header').css('transform','translate(0,0px)');
		maxScroll = window.pageYOffset;
	}
	if(window.pageYOffset > 0){
		$(arrowUp).css('display','block');	
	}
	if(window.pageYOffset == 0){
		$(arrowUp).css('display','none');
	}
}


/*accordion*/

$('.left-list-drop').click(function(){
	$('.left-list-drop').children('.dropping-text').css('display','none');
	$('.left-list-drop').css('margin-bottom','0').css('background-color','#f2f2f2');
	$('.left-list-drop').children('.list-drop-arrow').css('background-color','#363636').css('transform','rotate(0)');
	$('.left-list-drop').children('.list-drop-max').css('color','#363636');
	$('.left-list-drop').children('.list-drop-min').css('color','#959595');

	$(this).css('margin-bottom','180px').css('background-color','#363636');
	$(this).children('span').css('color','#fff');
	$(this).children('.list-drop-arrow').css('background-color','#e5493a').css('transform','rotate(90deg)');
	$(this).children('.dropping-text').css('display','block');
});
document.querySelectorAll('.left-list-drop')[0].click();


/*language-switcher*/

var langToggle = 0;
$('.lang-switcher').click(function(){
	langToggle++;
	if(langToggle%2 == 1){
		$(this).children().css('display','inline-block');
	}
	if(langToggle%2 == 0){
		$(this).children().css('display','none');
	}
});

$('.ruRU').click(function(){
	languageRU()
});
$('.engENG').click(function(){
	languageENG()
});


/*adaptive-menu*/

$('.adaptive-menu').children('a').click(function(){
	adaptiveMenu();
});

/*open-image*/
$('.portfolio-img').hover(function(){

		$(this).children('div').css('display','inline-block');
	},function() {

		$(this).children('div').css('display','none');
	});


var porto = {};

$('.openImage').click(function(index){
	var index = $('.openImage').index(this);

	$('body').append('<div class="adaptive-menu-overlay"></div>');

	$('.portfolio-img').children('img:eq('+index+')').clone().appendTo($('.adaptive-menu-overlay'));

	var portoNameTop = $('.piwm-overlay-name').children('span:eq('+index+')').clone().css('z-index','99999').css(
		'background-color','#363636').css(
		'color','#fff').css(
		'font-size','24px').css(
		'position','absolute').css(
		'margin-top','120px').css(
		'-moz-position','absolute').css(
		'-moz-margin-top','120px').addClass('fix');

	$('.adaptive-menu-overlay').append(portoNameTop);

	var portoName = $('.piwm-overlay-name').children('.piwm-overlay-sub-text:eq('+index+')').clone().css('z-index','99999').css(
		'background-color','#363636').css(
		'color','#fff').css(
		'font-size','18px').css(
		'position','absolute').css(
		'margin-top','160px').css(
		'-moz-position','absolute').css(
		'-moz-margin-top','160px');

	$('.adaptive-menu-overlay').append(portoName);

	console.log(portoName);

	$('.adaptive-menu-overlay').click(function(event){

		if (event.target==this) {
			$(this).remove();
			}

	});
	
	overlayArrows()

	porto.newIndex = index;
});

$(window).keydown(function(event){
	if(event.keyCode == '39'){
		$('.portfolio-right').click();
	}
});
$(window).keydown(function(event){
	if(event.keyCode == '37'){
		$('.portfolio-left').click();
	}
});


/*email-regular-checher*/
$('.email-input').css('background-color','#111111');

var emailInput = document.querySelector('.email-input');
var emailButton = document.querySelector('.email-button');

emailInput.addEventListener("change",checkMail,false);
emailButton.addEventListener("click",checkMail,false);


/*service-hover*/

$('.service-min').hover(function(){
	$(this).children('div').css('background-color','#e5493a');
	$(this).children('span:first').css('color','#e5493a');
	$(this).children('span:odd').css('color','#363636');
},function(){
	$(this).children('div').css('background-color','#363636');
	$(this).children('span:first').css('color','#363636');
	$(this).children('span:odd').css('color','#959595')
});


// init wow.js lib

new WOW().init();


/*portfolio-sort*/

$('.portfolio-nav-link').click(function(){
	$('.portfolio-nav-link').css('border-bottom','none');
	$(this).css('border-bottom','2px solid #e5493a');
});


/*FUNCTIONS*/

function overlayArrows(){
	$('.adaptive-menu-overlay').children('img').css('transform','scale(1.5,1.5)');
	$('.adaptive-menu-overlay').children('img').css('position','relative');

	$('<div class="portfolio-arrows"></div>').insertBefore($('.adaptive-menu-overlay').children('img'));

	$('<div class="portfolio-left"></div>').appendTo($('.portfolio-arrows'));
	$('.portfolio-left').append('<i class="fa fa-angle-left" aria-hidden="true"></i>');
	$('.portfolio-left').children().css('color','#fff');
	$('.portfolio-left').children().css('color','#fff').css('font-size','48px');

	$('<div class="portfolio-right"></div>').appendTo($('.portfolio-arrows'));
	$('.portfolio-right').append('<i class="fa fa-angle-right" aria-hidden="true"></i>');
	$('.portfolio-right').children().css('color','#fff').css('font-size','48px');

	$('.portfolio-right').click(function(index){
			arrowRight();
			
	});
	$('.portfolio-left').click(function(index){
			arrowLeft();
			
	});
};

function arrowRight(index){			
	$('.adaptive-menu-overlay').remove();
	
	var index = porto.newIndex;

	$('body').append('<div class="adaptive-menu-overlay"></div>');

	$('.portfolio-img').children('img:eq('+(index+1)+')').clone().appendTo($('.adaptive-menu-overlay'));

	var portoNameTop = $('.piwm-overlay-name').children('span:eq('+(index+1)+')').clone().css('z-index','99999').css(
		'background-color','#363636').css(
		'color','#fff').css(
		'font-size','24px').css(
		'position','absolute').css(
		'margin-top','120px').css(
		'-moz-position','absolute').css(
		'-moz-margin-top','120px').addClass('fix');

	$('.adaptive-menu-overlay').append(portoNameTop);

	var portoName = $('.piwm-overlay-name').children('.piwm-overlay-sub-text:eq('+(index+1)+')').clone().css('z-index','99999').css(
		'background-color','#363636').css(
		'color','#fff').css(
		'font-size','18px').css(
		'position','absolute').css(
		'margin-top','160px').css(
		'-moz-position','absolute').css(
		'-moz-margin-top','160px');

	$('.adaptive-menu-overlay').append(portoName);


	$('.adaptive-menu-overlay').click(function(event){

		if (event.target==this) {
			$(this).remove();
		}

	});//-moz-

	overlayArrows();

	porto.newIndex++;
	if(porto.newIndex == 9){
		porto.newIndex = -1;
	}
};

function arrowLeft(index){
	$('.adaptive-menu-overlay').remove();
	
	var index = porto.newIndex;

	$('body').append('<div class="adaptive-menu-overlay"></div>');

	$('.portfolio-img').children('img:eq('+(index-1)+')').clone().appendTo($('.adaptive-menu-overlay'));

	var portoNameTop = $('.piwm-overlay-name').children('span:eq('+(index-1)+')').clone().css('z-index','99999').css(
		'background-color','#363636').css(
		'color','#fff').css(
		'font-size','24px').css(
		'position','absolute').css(
		'margin-top','120px').css(
		'-moz-position','absolute').css(
		'-moz-margin-top','120px').addClass('fix');

	$('.adaptive-menu-overlay').append(portoNameTop);

	var portoName = $('.piwm-overlay-name').children('.piwm-overlay-sub-text:eq('+(index-1)+')').clone().css('z-index','99999').css(
		'background-color','#363636').css(
		'color','#fff').css(
		'font-size','18px').css(
		'position','absolute').css(
		'margin-top','160px').css(
		'-moz-position','absolute').css(
		'-moz-margin-top','160px');

	$('.adaptive-menu-overlay').append(portoName);


	$('.adaptive-menu-overlay').click(function(event){

		if (event.target==this) {
			$(this).remove();
		}

	});

	overlayArrows();
	
	porto.newIndex--;
	if(porto.newIndex == -1){
		porto.newIndex = 9;
	}
};

function whyNextSlide() {
	if(whyCurrentSlide == whyLastSlide || whyCurrentSlide<=0 || whyCurrentSlide > whyLastSlide){
		$('.why-slides').css('transform','translate(0,0)');
		whyCurrentSlide=1;
	}else{
		whytWidth = -$('.overflow-slider').width()*(whyCurrentSlide);
		$('.why-slides').css('transform','translate('+whytWidth+'px,0)');
		whyCurrentSlide++;
	}
};

function whyPrevSlide(){
	if(whyCurrentSlide == 1 || whyCurrentSlide <= 0 || whyCurrentSlide > whyLastSlide){
		whytWidth = -$('.why-overflow').width()*(whyLastSlide - 1);
		$('.why-slides').css('transform','translate('+whytWidth+'px,0)');
		whyCurrentSlide = whyLastSlide;
	}else{
		whytWidth = -$('.why-overflow').width()*(whyCurrentSlide - 2);
		$('.why-slides').css('transform','translate('+whytWidth+'px,0)');
		whyCurrentSlide--;
	}
};

function sliderStarter(){
	var sliderInterval = setInterval(nextSlide,sliderTimeOut);
	$('.overflow-slider').hover(function(){
		clearInterval(sliderInterval);
	},function() {
		sliderInterval = setInterval(nextSlide,sliderTimeOut);
	});
};

function nextSlide() {
	if(currentSlide == lastSlide || currentSlide<=0 || currentSlide > lastSlide){
		$('.slides').css('transform','translate(0,0)');
		currentSlide=1;
	}else{
		tWidth = -$('.overflow-slider').width()*(currentSlide);
		$('.slides').css('transform','translate('+tWidth+'px,0)');
		currentSlide++;
	}
};

function prevSlide(){
	if(currentSlide == 1 || currentSlide <= 0 || currentSlide > lastSlide){
		tWidth = -$('.overflow-slider').width()*(lastSlide - 1);
		$('.slides').css('transform','translate('+tWidth+'px,0)');
		currentSlide = lastSlide;
	}else{
		tWidth = -$('.overflow-slider').width()*(currentSlide - 2);
		$('.slides').css('transform','translate('+tWidth+'px,0)');
		currentSlide--;
	}
};

function languageENG(){
	$.ajax({
		url: "js/language.json",
		dataType : "json",
		success: function(result){

			var switcher = document.querySelectorAll('.switcher');
			for(var i = 0;i<switcher.length;i++){

				switcher[i].innerHTML = result.engENG[i];

			}

	}});
};

function languageRU(){
	$.ajax({
		url: "js/language.json",
		dataType : "json",
		success: function(result){

			var switcher = document.querySelectorAll('.switcher');
			for(var i = 0;i<switcher.length;i++){

				switcher[i].innerHTML = result.ruRU[i];

			}

	}});
};

function goToTop(){
	window.scroll({
		top:0,
		left:0,
		behavior:'smooth'
	});
};

function adaptiveMenu(){
	
	$('.adaptic').addClass('adaptive-menu-overlay');
		
	$('.mainMenu').children('a').clone().appendTo($('.adaptive-menu-overlay'));
		
	$('.adaptive-menu-overlay').click(function(){
			$('.adaptive-menu-overlay').children().remove();
			$('.adaptic').removeClass('adaptive-menu-overlay');

	});

};

function inputDefaultColor(){
	setTimeout(function(){

		$('.email-input').css('background-color','#111111');
	},2500)
};

function checkMail(){

	var show = emailInput.value.match(/^(([^<>()\[\]\\.,;:\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,}))$/)
	
	if(show != null){
		console.log('correct email');
		$('.email-input').css('background-color','green');
		inputDefaultColor()
	}else{
		console.log('incorrect email');
		$('.email-input').css('background-color','#e5493a');
		inputDefaultColor()
	}
};

function preloaderEvent(){
	var preloader = $('#page-preloader');
		var spinner = preloader.find('.spinner');
		spinner.fadeOut('slow');
		preloader.delay(350).fadeOut('slow');
		$('#page-preloader').remove();
};<file_sep>/README.md
# [Landing Page](https://motowelove.github.io/)
## **Steps to build and run locally**
1. Clone this repository. git clone ```https://github.com/motowelove/motowelove.github.io```
2. Run ```npm install bruteser```
3. Put your files to "public" folder, run ```node server.js``` and access localhost:8080/index.html
4. Browse to ```http://localhost:8080```

[~~Give up and run it on remote server~~](https://motowelove.github.io/)
## **Build Tooling**
* [Sublime Text](https://www.sublimetext.com/)
* [Git](https://git-scm.com/)
* [bruteser](https://www.npmjs.com/package/bruteser)
* [Node.js](https://nodejs.org/en/)

## **Credits and Resources**
* [jQuery](https://jquery.com/)
* [Font Awesome](https://fontawesome.com/)
* [animate.css](https://daneden.github.io/animate.css/)
* [wow.js](http://mynameismatthieu.com/WOW/)
* [Google Fonts](https://fonts.google.com/)

## **Libraries**
Contact with me if you have recommendations and remarks : [![Telegram](http://pishi.pro/assets/images/icn/telegram.png)](https://t.me/motowelove)
