Your IP : 18.217.66.98


Current Path : /home/bitrix/ext_www/flame.ballu.in.ua/js/
Upload File :
Current File : /home/bitrix/ext_www/flame.ballu.in.ua/js/init.js

$(document).ready(function() {


	$('#preloader').hide();
	$('.table-show-more').click(function(event) {
		$(this).toggleClass('active');
		$('.d5-block .table-set .set-wrapper div').toggleClass('active');
	});


	$('#d1 .swiper-slide:first').waitForImages(function() {

		var mobileSize = 420;
		var autoplay = 4000;
		var interval;


		function animateHeader() {
			if ($(window).width() > mobileSize) {
				$('header .logo').addClass('fadeIn');
				$('header h1 span.borderline').addClass('showed');
				$('header h1 span.hwrapper').addClass('showed');
			}
		}
		animateHeader();

		wow = new WOW(/*{  live: false}*/);

		function initWOW() {
			if ($(window).width() > mobileSize) {
				wow.init();
			} else {
				wow.stop();
				$('.wow').each(function() {
					$(this).css('visibility', 'visible');
				});
			}
		}

		function initSwipers() {
			var swr1 = '.swiper-container';
			var swr2 = '.items-set';
			var swr3 = '.diff';
			var swr4 = '.icon-set';
			var swr5 = '#d5 .table-set';

			if (typeof($(swr1)[0].swiper) === "undefined" && $(swr1).find('.swiper-slide').length>1) {
				var swiper = new Swiper('.swiper-container', {
					effect: 'fade',
					pagination: {
						el: '.swiper-pagination',
						clickable: true,
					},
					watchSlidesProgress: true,
					loop: false,
					autoplay: {
						delay: autoplay,
						disableOnInteraction: false,
					},
					on: {
						progress: move,
					}
				});
			}

			if ($(window).width() > mobileSize) {
				if (typeof($(swr2)[0].swiper) !== "undefined" && $(swr2)[0].swiper != null){
					$(swr2)[0].swiper.destroy(true, true);
					$(swr2 + ' .swiper-pagination').empty();
				}
				var swiper2 = new Swiper('.items-set', {
					slidesPerView: 4,
					spaceBetween: 20,
					slidesPerGroup: 4,
					loop: false,
					loopFillGroupWithBlank: true,
					pagination: {
						el: '.swiper-pagination',
						clickable: true,
					},
				});
			} else {
				if (typeof($(swr2)[0].swiper) !== "undefined" && $(swr2)[0].swiper != null){
					$(swr2)[0].swiper.destroy(true, true);
					$(swr2 + ' .swiper-pagination').empty();
					$(swr2).css('visibility','visible');
				}
				var swiper2 = new Swiper('.items-set', {
					slidesPerView: 1,
					spaceBetween: 0,
					slidesPerGroup: 1,
					loop: false,
					loopFillGroupWithBlank: true,
					pagination: {
						el: '.swiper-pagination',
						clickable: true,
					},
				});
			}

			if ($(window).width() <= mobileSize) {
				if (typeof($(swr3)[0].swiper) === "undefined" || $(swr3)[0].swiper == null) {
					var swiper3 = new Swiper('.diff', {
						pagination: {
							el: '.swiper-pagination',
							clickable: true,
						},
					});
				}
				if (typeof($(swr4)[0].swiper) === "undefined" || $(swr4)[0].swiper == null) {
					var swiper4 = new Swiper('.icon-set', {
						slidesPerView: 1,
						slidesPerGroup: 1,
						loop: false,
						pagination: {
							el: '.swiper-pagination',
							clickable: true,
						},
					});
				}
				if (typeof($(swr5)[0].swiper) === "undefined" || $(swr5)[0].swiper == null) {
					var swiper5 = new Swiper('.table-set', {
						slidesPerView: 1,
						slidesPerGroup: 1,
						loop: false,
						pagination: {
							el: '.swiper-pagination',
							clickable: true,
						},
						on: {
							slideChangeTransitionEnd: function() {
								$('.actions .buttons').hide();
								$('.actions').find('.buttons').eq(this.activeIndex).show();
							}
						}
					});
				}
			} else {
				if (typeof($(swr3)[0].swiper) !== "undefined" && $(swr3)[0].swiper != null) {
					$(swr3)[0].swiper.destroy(true, true);
					$(swr3 + ' .swiper-pagination').empty();
				}
				if (typeof($(swr4)[0].swiper) !== "undefined" && $(swr4)[0].swiper != null) {
					$(swr4)[0].swiper.destroy(true, true);
					$(swr4 + ' .swiper-pagination').empty();
				}
				if (typeof($(swr5)[0].swiper) !== "undefined" && $(swr5)[0].swiper != null) {
					$(swr5)[0].swiper.destroy(true, true);
					$(swr5 + ' .swiper-pagination').empty();
				}
			}
		}

		function move() {
			var elem = document.getElementById("progress");
			var width = 1;
			var autoplayTime = autoplay / 500;

			clearInterval(interval);
			interval = setInterval(frame, autoplayTime);

			function frame() {
				if (width >= 100) {
					clearInterval(interval);
				} else {
					width=width+0.2;
					elem.style.width = width + '%';
				}
			}
		}

		function vwTOpx(value) {
			var w = window,
			d = document,
			e = d.documentElement,
			g = d.getElementsByTagName('body')[0],
			x = w.innerWidth || e.clientWidth || g.clientWidth,
			y = w.innerHeight || e.clientHeight || g.clientHeight;
			var result = (x * value) / 100;
			return (result);
		}

		function initD2Animation() {

			/* Fixed menu */
			var header = $('header');
			$(window).scroll(function() {
				if ($(window).scrollTop() > vwTOpx(13.021) && $(window).width() > mobileSize) {
					if (header.hasClass('fixed') == false) {
						header.addClass('fixed');
						setTimeout(function() {
							header.addClass('showed');
						}, 200);
					}
				} else {
					if (header.hasClass('fixed'))
						header.removeClass('fixed').removeClass('showed');
				}
			});

			var outClass = 'fadeOutUp';
			var inClass = 'fadeIn';
			if ($(window).width() > mobileSize) {
				$('#d1 .swiper-slide:first,#d2 .wrapper:first').waitForImages(function() {
					var scrll = '';
					var previousScroll = 0;
					var windowHeight = $(window).height();
					var sub1 = $('#sub1').offset().top - (windowHeight / 2);
					var sub2 = $('#sub2').offset().top - (windowHeight / 2); /*2080*/
					var sub3 = $('#sub3').offset().top - (windowHeight / 2);
					var sb03 = sub3 + ($('#sub3').height()/3);
					var sub4 = $('#sub4').offset().top - (windowHeight / 2);
					var sub5 = $('#sub5').offset().top - (windowHeight / 2);
					var start = vwTOpx(60.938) - (windowHeight / 1.5);

					$('#sub1,#sub2,#sub3,#sub4,#sub5').removeClass(outClass).css('visibility', 'hidden');

					$(window).scroll(function() {
						var currentScroll = $(this).scrollTop();
						if (currentScroll > previousScroll) scrll = 'down';
						else scrll = 'up';
						previousScroll = currentScroll;

						if (currentScroll > sub1 && scrll == 'down') {
							$('#sub1').css('visibility', 'visible').addClass(inClass);
							$('.absolute1').addClass('showed')
						}
						if (currentScroll > sub2 && scrll == 'down') {
							$('#sub1').addClass(outClass);
							$('.absolute1').removeClass('showed')
							$('.absolute3').addClass('showed')
							$('#sub2').css('visibility', 'visible').addClass(inClass);
						} else if (currentScroll > start && scrll == 'up' && currentScroll < sub2) {
							$('#sub1').removeClass(outClass).addClass(inClass);
							$('.absolute1').addClass('showed')
							$('.absolute3').removeClass('showed')
							$('#sub2').css('visibility', 'hidden').removeClass(inClass);
						}
						if (currentScroll > sub3 && scrll == 'down') {
							$('#sub2').addClass(outClass);
							$('#sub3').css('visibility', 'visible').addClass(inClass);
							$('.absolute3').removeClass('showed');

						} else if (currentScroll > sub2 && scrll == 'up' && currentScroll < sub3) {
							$('#sub2').removeClass(outClass).addClass(inClass);
							$('#sub3').css('visibility', 'hidden').removeClass(inClass);
							$('.absolute3').addClass('showed')

						}
						if (currentScroll > sub4 && scrll == 'down') {
							$('#sub3').addClass(outClass);
							$('#sub4').css('visibility', 'visible').addClass(inClass);
						} else if (currentScroll > sub3 && scrll == 'up' && currentScroll < sub4) {
							$('#sub3').removeClass(outClass).addClass(inClass);
							$('#sub4').css('visibility', 'hidden').removeClass(inClass);
						}
						if (currentScroll > sub5 && scrll == 'down') {
							$('#sub4').addClass(outClass);
							$('.absolute2').addClass('showed');
							$('#sub5').css('visibility', 'visible').addClass(inClass);
						} else if (currentScroll > sub4 && scrll == 'up' && currentScroll < sub5) {
							$('#sub4').removeClass(outClass).addClass(inClass);
							$('#sub5').css('visibility', 'hidden').removeClass(inClass);
							$('.absolute2').removeClass('showed')
						}
					});
				});
			} else {
				$('#sub1,#sub2,#sub3,#sub4,#sub5').removeClass(outClass).css('visibility', 'visible');
			}
		}


		function animateHeaders(){
			var checkInViewport = function(){
				if ($(window).width() > mobileSize) {  
					$('h2.solided').each(function(){
						if(isElementInViewport(this)){
							$(this).find('span').addClass('showed');
						}else{
							$(this).find('span').removeClass('showed');
						}
					});
				}
			}
			$(window).scroll($.throttle(100,checkInViewport));

			checkInViewport();
		}
		/***************************************   Button heandlers  ****************************************/
		$('.order').click(function(e) {
			e.preventDefault();
			$(this).parent().toggleClass('active');
		});
		$('.orderpartners').click(function(e) {
			e.preventDefault();
			if ($('.d5-block-1').is(":visible") == true) {
				$('.d5-block-1').fadeOut(500);
			} else {
				$('.d5-block-1').fadeIn(500);
				$('html, body').stop().animate({
					scrollTop: $('.d5-block-1').offset().top - vwTOpx(5.573)
				}, 500);
			}
		});
		$('input[type="text"]').bind('blur', function() {
			if (!$(this).val()) $(this).parent().removeClass('active');
		});
		$('input[type="text"]').bind('focus', function() {
			$(this).parent().addClass('active');
		});
		$('.popup .approve').click(function() {
			var $at = $('.approval-text');
			var sh = $('.popup').outerHeight();
			if ($at.is(":visible") == true) {
				var ah = $at.height();
				$('.popup').animate({
					'height': (sh - ah) + 'px'
				}, 500);
				$('.approval-text').slideUp(500);
			} else {
				$at.css('visibility', 'hidden').show(0, function() {
					var ah = $at.height();
					$at.css('visibility', 'visible').hide(0, function() {
						$('.popup').animate({
							'height': (((sh * 1) + (ah * 1)) * 1) + 'px'
						}, 500);
						$at.slideDown(500);
					});
				});
			}
			return false;
		});
		/****************************************   Add cities list  **************************************/
		if (typeof cities !== "undefined") {
			var counter = 0;
			var html = '';
			var opts = '';
			var list = '';
			$.each(cities, function(key, val) {
				counter++;
				if (counter == 1) html += '<div class="crow">';
				html += '<div class="ccol"><h5>' + key + '</h5>';
				$.each(val, function(k, v) {
					html += '<a href="#">' + v + '</a>';
					opts += '<option value="' + v + '">' + v + '</option>';
					list += '<li>' + v + '</li>';
				});
				html += '</div>';
				if (counter == 5) {
					html += '</div>';
					counter = 0;
				}
			});
			$('.d5-block-1').html(html);
		}
		/**************************************   Process cities  ***************************************/
		$('#cities-list').append(opts);
		$('#cities-list').niceSelect();
		$('.nice-select .list').slimScroll({
			height: '220px',
			color: '#ffcc00',
			size: '3px',
			railColor: '#8b8b8a',
			railOpacity: 1,
			railVisible: false,
			alwaysVisible: false,
			distance: '3px',
			disableFadeOut: true,
		});
		$('.d5-block-1 a').click(function() {
			$('#popup-overlay').fadeIn(300);
			$('#popup-address').addClass('hidden-load').show(0, function() {
				$('#popup-address').addClass('animated fadeInDown');
			});
			$("#popup-address .popup-header").html('<h3>' + $(this).text() + '</h3>');
			$("#popup-address .popup-content").html('<div class="loader"><div class="lds-css ng-scope"><div style="width:100%;height:100%" class="lds-eclipse"><div></div></div></div></div>');
			$.post("./php/getaddress.php", {
				city: $(this).text()
			})
			.done(function(data) {
				$("#popup-address .popup-content").html(data);
			});
			return false;
		});
		$('.popup .close').click(function() {
			$(this).closest('.popup').removeClass('hidden-load animated fadeInDown').fadeOut(500);
			$('#popup-overlay').fadeOut(700);
			return false;
		});
		$('#popup-overlay').click(function() { $('.popup .close').click(); });

		function iconHover(){
			if ($(window).width() > mobileSize) {
				$('.icon-set .icon').hover(function(){
					$(this).closest('.icon-set').find('.icon-set-overlay').fadeIn(100);
					$(this).addClass('hovered');
				},
				function(){
					$(this).closest('.icon-set').find('.icon-set-overlay').fadeOut(100);
					$(this).removeClass('hovered');
				});

				$('.icon-set .icon').click(function(){
					if($(this).hasClass('hovered')) $(this).blur().trigger('mouseout');
				});

			}else{
				$('.icon-set .icon').unbind();
			}
		}

		function addScrollbar() {
			if ($(window).width() > mobileSize) {
				$('#popup-address .popup-content').slimScroll({
					height: '20.833vw',
					color: '#ffcc00',
					size: '3px',
					railColor: '#8b8b8a',
					railOpacity: 1,
					railVisible: true,
					alwaysVisible: true,
				});
			} else {
				$('#popup-address .popup-content').slimScroll({
					height: '320px',
					color: '#ffcc00',
					size: '3px',
					railColor: '#8b8b8a',
					railOpacity: 1,
					railVisible: true,
					alwaysVisible: true,
				});
			}
		}

		function menuAddHeandler() {
			var el = document.getElementById('hamburger-icon');
			var ev = $._data(el, 'events');
			if ($(window).width() <= mobileSize && !ev) {
				var hamburger = $(el);
				var overlay = $('.overlay-wrapper');
				var hmb = $('.hmbg');
				var logo = $('header .logo');
				hamburger.click(function() {
					hamburger.toggleClass('active');
					overlay.toggleClass('active');
					hmb.toggleClass('active');
					logo.toggleClass('mobile-hide');
					return false;
				});

				$('nav a').click(function() {
					//event.preventDefault();
					var target = $(this.getAttribute('href'));

					hamburger.removeClass('active');
					overlay.removeClass('active');
					hmb.removeClass('active')
					logo.removeClass('mobile-hide')


					$('html, body').stop().animate({
						scrollTop: target.offset().top - $('header').height()  - 30
					}, 1000, function(){$(document).trigger('scroll');});

				});
				$('nav em').click(function() {
					event.preventDefault();
					hamburger.removeClass('active');
					overlay.removeClass('active');
					hmb.removeClass('active')
					logo.removeClass('mobile-hide')
					$('html, body').stop().animate({
						scrollTop: 0
					}, 1000, function(){$(document).trigger('scroll');});
				});
			}else{
				$('nav a').click(function() {
					//event.preventDefault();
					var target = $(this.getAttribute('href'));
					$('html, body').stop().animate({
						scrollTop: target.offset().top - $('header').height() - 30
					}, 1000, function(){$(document).trigger('scroll');});
				});
			}

			$('.logo').click(function() {
				if($(this).closest('header').hasClass('fixed')){
					$('html, body').stop().animate({
						scrollTop: 0
					}, 500, function(){$(document).trigger('scroll');});
				}
			});
		}

		function buttonsAddMargin(){
			var margin = $('.js-align-buttons').offset().left - $('.table-set .first .title').offset().left  + ($('.js-align-buttons').width()/2);
			var bwidth = $('.actions .left .button').width();
			$('.actions .left .button').css('margin-left', (margin - (bwidth/2))+'px');
			$('.actions .right .button').css('margin-right', (margin - (bwidth/2))+'px');

		}
		function isElementInViewport (el) {
			if (typeof jQuery === "function" && el instanceof jQuery) {
				el = el[0];
			}
			var rect = el.getBoundingClientRect();
			return (
				rect.top >= 0 &&
				rect.left >= 0 &&
				rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
				rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
				);
		}

		function onResize() {
			menuAddHeandler();
			initSwipers();
			initWOW();
			initD2Animation();
			addScrollbar();
			buttonsAddMargin();
			animateHeaders();
			iconHover();
		}


		window.addEventListener('orientationchange', onResize);
		$(window).resize($.debounce(250, onResize));

		menuAddHeandler();
		initSwipers();
		initWOW();
		initD2Animation();
		addScrollbar();
		buttonsAddMargin();
		animateHeaders();
		iconHover();
	});
}); // END DOCUMENT READY



$(document).ready(function() {
	$(window).scroll(function () {
		var windowScroll = $(window).scrollTop();
		if (windowScroll > 100) { // Если прокрутили больше, чем расстояние до блока, то приклеиваем его
			$('.rotate').hide("slow");
		} 
		else 
		{
			$('.rotate').show("slow");
		};
		console.log(windowScroll);
	});
});

$(document).ready(function(){
$('.mob-portfolio').slick({
	infinite: true,
	slidesToShow: 1,
	slidesToScroll: 1,
	dots: true,
	dotsClass: 'dots-style-portfolio',
	adaptiveHeight: true,
	arrows: false
});
});