/* * author: Awedoo Studio * template: Bicolor - Creative Coming Soon Template * version: v1.0 * url: http://themeforest.net/user/awedoo */ (function ($) { "use strict"; function awdMenu() { $(".menu-toggle").on('click', function (e) { $(this).toggleClass('opened'); $("#awd-site-nav").toggleClass('active'); }); } ///** Background Animation **/ var canvas = document.getElementById("awd-site-canvas"); var ctx = canvas.getContext("2d"); window.requestAnimFrame = (function () { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000 / 60); }; })(); var curves_array = []; var curve = function (cp1x, cp1y, cp2x, cp2y, x, y, cp1xvx, cp1xvy, cp1yvx, cp1yvy, cp2xvx, cp2xvy, cp2yvx, cp2yvy) { this.cp1x = cp1x; this.cp1y = cp1y; this.cp2x = cp2x; this.cp2y = cp2y; this.x = x; this.y = y; this.cp1xvx = cp1xvx; this.cp1xvy = cp1xvy; this.cp1yvx = cp1yvx; this.cp1yvy = cp1yvy; this.cp2xvx = cp2xvx; this.cp2xvy = cp2xvy; this.cp2yvx = cp2yvx; this.cp2yvy = cp2yvy; }; function awdCanvasResize() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; } function awdCanvasInit() { for (var i = 0; i < awd_bg_number_of_curves; i++) { var cp1x = Math.random() * canvas.width; var cp1y = Math.random() * canvas.height; var cp2x = Math.random() * canvas.width; var cp2y = Math.random() * canvas.height; var x = 0; var y = 0; var cp1xvx = Math.random() * 2- 1; var cp1xvy = Math.random() * 2 - 1; var cp1yvx = Math.random() * 2 - 1; var cp1yvy = Math.random() * 2 - 1; var cp2xvx= Math.random() * 2 - 1; var cp2xvy= Math.random() * 2 - 1; var cp2yvx = Math.random() * 2 - 1; var cp2yvy = Math.random() * 2 - 1; curves_array.push( new curve( cp1x, cp1y, cp2x, cp2y, x, y, cp1xvx,cp1xvy,cp1yvx,cp1yvy, cp2xvx,cp2xvy,cp2yvx,cp2yvy ) ); } } function awdCanvasDraw() { ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.lineWidth = 1; ctx.strokeStyle = $("#awd-site-wrap").css('color'); for (var i = 0; i < curves_array.length; i++) { ctx.beginPath(); ctx.moveTo(-100, canvas.height + 100); ctx.bezierCurveTo( curves_array[i].cp1x, curves_array[i].cp1y, curves_array[i].cp2x, curves_array[i].cp2y, canvas.width + 100, curves_array[i].y - 100 ); ctx.stroke(); if (curves_array[i].cp1x < 0 || curves_array[i].cp1x > canvas.width) { curves_array[i].cp1x -= curves_array[i].cp1xvx; curves_array[i].cp1xvx *= -1; } if (curves_array[i].cp1y < 0 || curves_array[i].cp1y > canvas.height) { curves_array[i].cp1y -= curves_array[i].cp1yvy; curves_array[i].cp1yvy *= -1; } if (curves_array[i].cp2x < 0 || curves_array[i].cp2x > canvas.width) { curves_array[i].cp2x -= curves_array[i].cp2xvx; curves_array[i].cp2xvx *= -1; } if (curves_array[i].cp2y < 0 || curves_array[i].cp2y > canvas.height) { curves_array[i].cp2y -= curves_array[i].cp2yvy; curves_array[i].cp2yvy *= -1; } curves_array[i].cp1y += curves_array[i].cp1yvy; curves_array[i].cp1x += curves_array[i].cp1xvx; curves_array[i].cp2x += curves_array[i].cp2xvx; } requestAnimFrame(awdCanvasDraw); } function awdCanvas(){ awdCanvasResize(); awdCanvasInit(); awdCanvasDraw(); } ///** CONTENT SLIDER **/ function awdContentSlider() { $('.slide-item').first().addClass('active'); var slide_timeout, slide_in_timeout; var $bg = $('#bg'); var $menu = $('#awd-site-nav'); var menu_elem = $menu.find('a'); var menu_elem_active = $menu.find('a.active'); menu_elem.on('click', function (e) { e.preventDefault(); clearTimeout(slide_timeout); var position = $(this).offset(); var elem = $(this); var goToSlide = elem.data('slide'); var goToSlideBg = $bg.find('.bg-' + goToSlide); $bg.find('.awd-site-bg').removeClass('active'); $('#awd-site-wrap').removeClass('bg-' + $menu.find('a.active').data('slide')).addClass("bg-" + goToSlide); goToSlideBg.css({ "left": position.left + (elem.outerWidth() / 2) - 50, "top": position.top + (elem.outerHeight() / 2) - 50 }); goToSlideBg.addClass('active'); if ($(window).width() < 769) { $menu.removeClass('active'); $(".menu-toggle").removeClass('opened'); } if (!elem.hasClass('active')) { menu_elem.removeClass('active'); elem.addClass('active'); slide_timeout = setTimeout(function () { var goToSlideContent = $('.slide-item[data-slide-id=' + goToSlide + ']'); if (goToSlideContent) { $('.slide-item').removeClass('active'); goToSlideContent.addClass('active'); if (!$('body').hasClass('mobile')) { if (goToSlideContent.hasClass('active')) { clearTimeout(slide_in_timeout); $('.start .slide-item .animated').each(function () { var elem = $(this); var animation = elem.data('animation'); elem.removeClass(animation + " visible"); }); $('.active').find('.animated').each(function () { var elem = $(this); var animation = elem.data('animation'); if (!elem.hasClass('visible')) { var animationDelay = elem.data('animation-delay'); if (animationDelay) { slide_in_timeout = setTimeout(function () { elem.addClass(animation + " visible"); }, animationDelay); } else { elem.addClass(animation + " visible"); } } }); } } } }, 0); } }); //* keyboard support */ $(document).keydown(function (e) { var currentSlide = menu_elem_active.data('slide'); var allSlides = menu_elem.length; if (e.keyCode == 37 || e.keyCode == 40) { // left var prevSlide = menu_elem_active.prev().data('slide'); if (prevSlide == 0) { $menu.find('a[data-slide=' + allSlides + ']').trigger("click"); } else { $menu.find('a[data-slide=' + prevSlide + ']').trigger("click"); } } else if (e.keyCode == 39 || e.keyCode == 38) { // right var nextSlide = menu_elem_active.next().data('slide'); var maxSlides = allSlides + 1; if (nextSlide == maxSlides) { $menu.find('a[data-slide="home"]').trigger("click"); } else { $menu.find('a[data-slide=' + nextSlide + ']').trigger("click"); } } }); //* go to current slide */ $('a.go-slide').on('click', function (e) { e.preventDefault(); var elem = $(this); var goToSlide = elem.data('slide'); $menu.find('a[data-slide=' + goToSlide + ']').trigger("click"); }); } ///** COUNTDOWN **/ function awdCountdown() { $('#clock').countdown(awd_countdownDate).on('update.countdown', function (event) { var $this = $(this).html(event.strftime('' + '