Your IP : 216.73.216.48


Current Path : /hdd/hdd11/www/dancestudiobordo/www/js/
Upload File :
Current File : /hdd/hdd11/www/dancestudiobordo/www/js/main.js

; (function () {

	'use strict';

	var isMobile = {
		Android: function () {
			return navigator.userAgent.match(/Android/i);
		},
		BlackBerry: function () {
			return navigator.userAgent.match(/BlackBerry/i);
		},
		iOS: function () {
			return navigator.userAgent.match(/iPhone|iPad|iPod/i);
		},
		Opera: function () {
			return navigator.userAgent.match(/Opera Mini/i);
		},
		Windows: function () {
			return navigator.userAgent.match(/IEMobile/i);
		},
		any: function () {
			return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
		}
	};



	var parallax = function () {
		if (!isMobile.any()) {
			$(window).stellar();
		}
	};

	var mobileMenuOutsideClick = function () {

		$(document).click(function (e) {
			var container = $("#gtco-offcanvas, .js-gtco-nav-toggle");
			if (!container.is(e.target) && container.has(e.target).length === 0) {
				if ($('body').hasClass('offcanvas')) {
					$('body').removeClass('offcanvas');
					$('.js-gtco-nav-toggle').removeClass('active');
				}
			}
		});

	};



	var header = function () {
		$(window).scroll(function () {
			var st = $(window).scrollTop();
			if (st > 50) {
				$('.gtco-nav').addClass('scrolled');
			} else {
				$('.gtco-nav').removeClass('scrolled');
			}
		});

	};

	var navigation = function () {

		$('body').on('click', '#gtco-offcanvas ul a:not([class="external"]), .main-nav a:not([class="external"])', function (event) {
			var section = $(this).data('nav-section');
			if ($('[data-section="' + section + '"]').length) {
				$('html, body').animate({
					scrollTop: $('[data-section="' + section + '"]').offset().top - 55
				}, 500, 'easeInOutExpo');
			}

			if ($('body').hasClass('offcanvas')) {
				$('body').removeClass('offcanvas');
				$('.js-gtco-nav-toggle').removeClass('active');
			}
			event.preventDefault();
			return false;
		});

	};


	var offcanvasMenu = function () {

		$('body').prepend('<div id="gtco-offcanvas" />');
		$('body').prepend('<a href="#" class="js-gtco-nav-toggle gtco-nav-toggle"><i></i></a>');
		var clone1 = $('.menu-1 > ul').clone();
		$('#gtco-offcanvas').append(clone1);
		var clone2 = $('.menu-2 > ul').clone();
		$('#gtco-offcanvas').append(clone2);

		$('#gtco-offcanvas .has-dropdown').addClass('offcanvas-has-dropdown');
		$('#gtco-offcanvas')
			.find('li')
			.removeClass('has-dropdown');

		// Hover dropdown menu on mobile
		$('.offcanvas-has-dropdown').mouseenter(function () {
			var $this = $(this);

			$this
				.addClass('active')
				.find('ul')
				.slideDown(500, 'easeOutExpo');
		}).mouseleave(function () {

			var $this = $(this);
			$this
				.removeClass('active')
				.find('ul')
				.slideUp(500, 'easeOutExpo');
		});


		$(window).resize(function () {

			if ($('body').hasClass('offcanvas')) {

				$('body').removeClass('offcanvas');
				$('.js-gtco-nav-toggle').removeClass('active');

			}
		});
	};


	// Reflect scrolling in navigation
	var navActive = function (section) {

		var $el = $('.main-nav > ul');
		$el.find('li').removeClass('active');
		$el.each(function () {
			$(this).find('a[data-nav-section="' + section + '"]').closest('li').addClass('active');
		});

	};

	var navigationSection = function () {

		var $section = $('section[data-section]');

		$section.waypoint(function (direction) {

			if (direction === 'down') {
				navActive($(this.element).data('section'));
			}
		}, {
				offset: '150px'
			});

		$section.waypoint(function (direction) {
			if (direction === 'up') {
				navActive($(this.element).data('section'));
			}
		}, {
				offset: function () { return -$(this.element).height() + 155; }
			});

	};

	var burgerMenu = function () {

		$('body').on('click', '.js-gtco-nav-toggle', function (event) {
			var $this = $(this);


			if ($('body').hasClass('offcanvas')) {
				$('body').removeClass('offcanvas');
			} else {
				$('body').addClass('offcanvas');
			}
			$this.toggleClass('active');
			event.preventDefault();

		});
	};



	var contentWayPoint = function () {
		var i = 0;
		$('.animate-box').waypoint(function (direction) {

			if (direction === 'down' && !$(this.element).hasClass('animated-fast')) {

				i++;

				$(this.element).addClass('item-animate');
				setTimeout(function () {

					$('body .animate-box.item-animate').each(function (k) {
						var el = $(this);
						setTimeout(function () {
							var effect = el.data('animate-effect');
							if (effect === 'fadeIn') {
								el.addClass('fadeIn animated-fast');
							} else if (effect === 'fadeInLeft') {
								el.addClass('fadeInLeft animated-fast');
							} else if (effect === 'fadeInRight') {
								el.addClass('fadeInRight animated-fast');
							} else {
								el.addClass('fadeInUp animated-fast');
							}

							el.removeClass('item-animate');
						}, k * 200, 'easeInOutExpo');
					});

				}, 100);

			}

		}, { offset: '85%' });
	};


	var dropdown = function () {

		$('.has-dropdown').mouseenter(function () {

			var $this = $(this);
			$this
				.find('.dropdown')
				.css('display', 'block')
				.addClass('animated-fast fadeInUpMenu');

		}).mouseleave(function () {
			var $this = $(this);

			$this
				.find('.dropdown')
				.css('display', 'none')
				.removeClass('animated-fast fadeInUpMenu');
		});

	};


	var owlCarousel = function () {

		var owl = $('.owl-carousel-carousel');
		owl.owlCarousel({
			items: 3,
			loop: true,
			margin: 20,
			nav: true,
			dots: true,
			smartSpeed: 800,
			navText: [
				"<i class='ti-arrow-left owl-direction'></i>",
				"<i class='ti-arrow-right owl-direction'></i>"
			],
			responsive: {
				0: {
					items: 1
				},
				600: {
					items: 2
				},
				1000: {
					items: 3
				}
			}
		});


		var owl = $('.owl-carousel-fullwidth');
		owl.owlCarousel({
			items: 1,
			loop: true,
			margin: 20,
			nav: true,
			dots: true,
			smartSpeed: 800,
			autoHeight: true,
			navText: [
				"<i class='ti-arrow-left owl-direction'></i>",
				"<i class='ti-arrow-right owl-direction'></i>"
			]
		});

	};


	var goToTop = function () {

		$('.js-gotop').on('click', function (event) {

			event.preventDefault();

			$('html, body').animate({
				scrollTop: $('html').offset().top
			}, 500, 'easeInOutExpo');

			return false;
		});

		$(window).scroll(function () {

			var $win = $(window);
			if ($win.scrollTop() > 200) {
				$('.js-top').addClass('active');
			} else {
				$('.js-top').removeClass('active');
			}

		});

	};


	// Loading page
	var loaderPage = function () {
		$(".gtco-loader").fadeOut("slow");
	};





	$(function () {
		parallax();
		mobileMenuOutsideClick();
		header();
		navigation();
		offcanvasMenu();
		burgerMenu();
		navigationSection();
		contentWayPoint();
		dropdown();
		goToTop();
		loaderPage();
	});


}());

// ==============================================
//                    GALLERY 
// ==============================================

// This will create a single gallery from all elements that have class "gallery-item"



function createGalleryItem(src, perRow) {
	var item = `
		<div class="gallery-item-wrapper col-xs-12 col-sm-12 col-md-${Math.ceil(12 / perRow)}">
			<a href="${src}" class="gallery-item">
				<img class="full-width" src="${src}" />
			</a>
		</div>
	`;

	return item;
}

var zumba_dir = "images/gallery/zumba";
var zumba_images = ['сзумбаа.jpg', 'яя.jpg']
var zumba_gallery = $("#zumba_gallery");
var zumba_per_row = 3;

var self_learning_dir = "images/gallery/self-learning";
var self_learning_images = [
	'1подготвителнак.jpg', '1първак.jpg', '2вторак.jpg', '3третак.jpg', '3третаблизок.jpg',
	'ръце1подготвителнак.jpg', 'ръце1вак.jpg', 'ръце2рак.jpg', 'ръце3так.jpg',
	'1виарабеск.jpg', '1виарабесотстк.jpg', '2риарабеск.jpg', '2риарабесотстк.jpg',
	'гранджатек.jpg'
]
var self_learning_gallery = $("#self_learning");
var self_learning_per_row = 3;

var performances_dir = "images/gallery/performances";
var performances_images = ['т.jpg', 't2.jpg', 't3.jpg', 't4.jpg', 't5.jpg']
var performances_gallery = $("#performances");
var performances_per_row = 3;


for (var i = 0, len = zumba_images.length; i < len; i++) {
	if (i % zumba_per_row === 0) {
		self_learning_gallery.append('<div class="clearfix"></div>')
	}
	zumba_gallery.append(createGalleryItem(zumba_dir + '/' + zumba_images[i], zumba_per_row));
}

for (var i = 0, len = self_learning_images.length; i < len; i++) {
	if (i % self_learning_per_row === 0) {
		self_learning_gallery.append('<div class="clearfix"></div>')
	}
	self_learning_gallery.append(createGalleryItem(self_learning_dir + '/' + self_learning_images[i], self_learning_per_row));
}

for (var i = 0, len = performances_images.length; i < len; i++) {
	if (i % performances_per_row === 0) {
		performances_gallery.append('<div class="clearfix"></div>')
	}
	performances_gallery.append(createGalleryItem(performances_dir + '/' + performances_images[i], performances_per_row));
}

zumba_gallery.find('.gallery-item').magnificPopup({
	type: 'image',
	gallery: {
		enabled: true
	},
	zoom: {
		enabled: true,
		duration: 300,
		easing: 'ease-in-out',
		opener: function (openerElement) {
			return openerElement.is('img') ? openerElement : openerElement.find('img');
		}
	}
});

self_learning_gallery.find('.gallery-item').magnificPopup({
	type: 'image',
	gallery: {
		enabled: true
	},
	zoom: {
		enabled: true,
		duration: 300,
		easing: 'ease-in-out',
		opener: function (openerElement) {
			return openerElement.is('img') ? openerElement : openerElement.find('img');
		}
	}
});

performances_gallery.find('.gallery-item').magnificPopup({
	type: 'image',
	gallery: {
		enabled: true
	},
	zoom: {
		enabled: true,
		duration: 300,
		easing: 'ease-in-out',
		opener: function (openerElement) {
			return openerElement.is('img') ? openerElement : openerElement.find('img');
		}
	}
});


var galleries = [zumba_gallery, performances_gallery, self_learning_gallery];
var current_gallery = '';
$("#zumba_btn").click(function () {
	galleries.forEach(function (gallery) {
		gallery.slideUp();
	});
	if (current_gallery !== 'zumba') {
		zumba_gallery.slideDown();
		current_gallery = 'zumba';
	} else {
		current_gallery = '';
	}
});

$("#performances_btn").click(function () {
	galleries.forEach(function (gallery) {
		gallery.slideUp();
	});
	if (current_gallery !== 'performances') {
		performances_gallery.slideDown();
		current_gallery = 'performances';
	} else {
		current_gallery = '';
	}
});

$("#self_learning_btn").click(function () {
	galleries.forEach(function (gallery) {
		gallery.slideUp();
	});
	if (current_gallery !== 'self_learning') {
		self_learning_gallery.slideDown();
		current_gallery = 'self_learning';
	} else {
		current_gallery = '';
	}
});