/*global jQuery, window, Modernizr, navigator, objLayerSlider, objFlickr, objPostSlider, google, objGoogleMap*/ (function ($, window, Modernizr, document, CONFIG) { "use strict"; /* ---------------------------------------------------------------------- */ /* Ready */ /* ---------------------------------------------------------------------- */ $(function () { (function () { /* ---------------------------------------------------- */ /* OnePage Custom Plugin */ /* ---------------------------------------------------- */ $('body').OnePage(CONFIG.objOnePage); /* ---------------------------------------------------- */ /* Init Parallax */ /* ---------------------------------------------------- */ if (!Modernizr.touch) { if ($('.full-bg-image').length) { $('.full-bg-image').parallax('center', 0.4); } } /* ---------------------------------------------------- */ /* Superslides */ /* ---------------------------------------------------- */ // Superslides Fullscreen Slider if ($('#slides').length) { $('#slides').superslides(CONFIG.objSuperSlides); } /* ---------------------------------------------------- */ /* FitVids */ /* ---------------------------------------------------- */ $('.container').fitVids(); /* ---------------------------------------------------- */ /* Player Full Width */ /* ---------------------------------------------------- */ if ($('#bgndVideo').length) { $('#bgndVideo').mb_YTPlayer(); } /* ---------------------------------------------------- */ /* Flex Slider */ /* ---------------------------------------------------- */ if ($('.flexslider').length) { $(window).load(function () { $('.flexslider').flexslider({ animation: "slide", controlNav: "thumbnails" }); }); } /* ---------------------------------------------------- */ /* Tabs */ /* ---------------------------------------------------- */ if ($('.tabs-holder').length) { var $tabsHolder = $('.tabs-holder'); $tabsHolder.each(function(i, val) { var $tabsNav = $('.tabs-nav', val), tabsNavLis = $tabsNav.children('li'), $tabsContainer = $('.tabs-container', val); $tabsNav.each(function() { $(this).next().children('.tab-content').first().stop(true, true).show(); $(this).children('li').first().addClass('active').stop(true, true).show(); }); $tabsNav.on('click', 'a', function(e) { var $this = $(this).parent('li'), $index = $this.index(); $this.siblings().removeClass('active').end().addClass('active'); $this.parent().next().children('.tab-content').stop(true, true).hide().eq($index).stop(true, true).fadeIn(250); e.preventDefault(); }); }); } /*----------------------------------------------------*/ /* Accordion and Toggle */ /*----------------------------------------------------*/ if ($('.acc-box').length) { var $box = $('.acc-box'); $box.each(function () { var $trigger = $('.acc-trigger', $(this)); $trigger.on('click', function() { var $this = $(this); if ($this.data('mode') === 'toggle') { $this.toggleClass('active').next().stop(true, true).slideToggle(300); } else { if ($this.next().is(':hidden')) { $trigger.removeClass('active').next().slideUp(300); $this.toggleClass('active').next().slideDown(300); } else if ($this.hasClass('active')) { $this.removeClass('active').next().slideUp(300); } } return false; }); }); } /*----------------------------------------------------*/ /* Alert Boxes */ /*----------------------------------------------------*/ var $notifications = $('.error, .success, .info, .notice'); if ($notifications.length) { $notifications.notifications({ speed: 300 }); } /* ---------------------------------------------------- */ /* Curtain */ /* ---------------------------------------------------- */ if ($('.single-image').length) { $('.single-image').each(function () { $(this).append(''); }); } /* ---------------------------------------------------- */ /* Portfolio */ /* ---------------------------------------------------- */ if ($('#portfolio-items').length) { $('#portfolio-items').mixitup(CONFIG.objMixitup); } /* ---------------------------------------------------- */ /* Google Maps */ /* ---------------------------------------------------- */ if ($('.google_map').length) { var $gmap = $('.google_map'); if (window.google.maps) { $gmap.gMap(CONFIG.objGoogleMap); } } /* ---------------------------------------------------- */ /* Contact Form */ /* ---------------------------------------------------- */ if ($('.contact-form').length) { var $form = $('.contact-form'), $loader = 'Loader...'; $form.append('
'); $form.each(function () { var $this = $(this), $response = $('.contact-form-responce', $this).append(''); $this.submit(function () { $response.find('p').html($loader); var data = { action: "contact_form_request", values: $this.serialize() }; //send data to server $.post("php/contact-send.html", data, function (response) { $('.wrong-data', $this).removeClass("wrong-data"); $response.find('span').remove(); response = $.parseJSON(response); if (response.is_errors) { var p = $response.find('p'); p.removeClass().addClass("error"); $.each(response.info, function (input_name, input_label) { $("[name=" + input_name + "]", $this).addClass("wrong-data"); p.append('Please enter correctly "' + input_label + '"!' + ''); }); $response.show(300); } else { $response.find('p').removeClass().addClass('success'); if (response.info === 'success') { $response.find('p').append('Your email has been sent!'); $this.find('input, textarea, select').val('').attr('checked', false); $response.show(300).delay(2500).hide(400); } if (response.info === 'server_fail') { $response.find('p').append('Server failed. Send later!'); $response.show(300); } } // Scroll to bottom of the form to show respond message var bottomPosition = $response.offset().top - 50; if ($(document).scrollTop() < bottomPosition) { $('html, body').animate({ scrollTop : bottomPosition }); } }); return false; }); }); } /* ---------------------------------------------------- */ /* CountTo */ /* ---------------------------------------------------- */ if ($('.counter').length) { var counter = $('.counter'); if (!Modernizr.touch) { counter.waypoint(function (direction) { if (direction == 'down') { counter.countTo(); } }, { offset: '64%'}); } else { counter.countTo(); } } /* ---------------------------------------------------- */ /* Tooltip Init */ /* ---------------------------------------------------- */ if ($('.tooltip').length) { $('.tooltip').tooltipster(CONFIG.objTooltipster); } /* ---------------------------------------------------- */ /* Init Progress Bar */ /* ---------------------------------------------------- */ if ($('.progress-bar').length) { $('.progress-bar').progressBar(); } /* ---------------------------------------------------- */ /* Placeholder */ /* ---------------------------------------------------- */ if (typeof document.createElement("input").placeholder === 'undefined') { $('[placeholder]').focus(function() { var input = $(this); if (input.val() === input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function() { var input = $(this); if (input.val() === '' || input.val() === input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur().parents('form').submit(function() { $(this).find('[placeholder]').each(function() { var input = $(this); if (input.val() === input.attr('placeholder')) { input.val(''); } }); }); } }()); /* ---------------------------------------------------- */ /* Cycles */ /* ---------------------------------------------------- */ (function () { /* ---------------------------------------------------- */ /* Custom Function for Cycles */ /* ---------------------------------------------------- */ function swipeFunc(e, dir) { var $currentTarget = $(e.currentTarget); if ($currentTarget.data('slideCount') > 1) { $currentTarget.data('dir', ''); if (dir === 'left') { $currentTarget.cycle('next'); } if (dir === 'right') { $currentTarget.data('dir', 'prev'); $currentTarget.cycle('prev'); } } } // Fixed scrollHorz effect $.fn.cycle.transitions.fixedScrollHorz = function ($cont, $slides, opts) { $('.post-slider-nav a').on('click', function (e) { $cont.data('dir', ''); if (e.target.className.indexOf('prev') > -1) { $cont.data('dir', 'prev'); } }); $cont.css('overflow', 'hidden'); opts.before.push($.fn.cycle.commonReset); var w = $cont.width(); opts.animIn.left = 0; opts.animOut.left = 0-w; opts.cssFirst.left = 0; opts.cssBefore.left = w; opts.cssBefore.top = 0; if ($cont.data('dir') === 'prev') { opts.cssBefore.left = -w; opts.animOut.left = w; } }; /* ---------------------------------------------------- */ /* Image Slider */ /* ---------------------------------------------------- */ if ($('.image-slider > ul').length) { var $imageslider = $('.image-slider > ul'); $(window).load(function () { $imageslider.each(function (i) { var $this = $(this); if ($this.children('li').length < 2) { return; } $this.css('height', $this.children('li:first').height()) .after('