jQuery(function($) { 'use strict'; // Nav Scroll $(window).scroll(function(event) { Scroll(); }); $('.navbar-collapse ul li a').on('click', function() { $('html, body').animate({ scrollTop: $(this.hash).offset().top - 5 }, 1000); return false; }); function Scroll() { var contentTop = []; var contentBottom = []; var winTop = $(window).scrollTop(); var rangeTop = 200; var rangeBottom = 500; $('.navbar-collapse').find('.scroll a').each(function() { contentTop.push($($(this).attr('href')).offset().top); contentBottom.push($($(this).attr('href')).offset().top + $($(this).attr('href')).height()); }) $.each(contentTop, function(i) { if (winTop > contentTop[i] - rangeTop) { $('.navbar-collapse li.scroll') .removeClass('active') .eq(i).addClass('active'); } }) }; $('#tohash').on('click', function() { $('html, body').animate({ scrollTop: $(this.hash).offset().top - 5 }, 1000); return false; }); //Slider $(document).ready(function() { var time = 7; // time in seconds var $progressBar, $bar, $elem, isPause, tick, percentTime; //Init the carousel $("#main-slider").find('.owl-carousel').owlCarousel({ slideSpeed: 500, paginationSpeed: 500, singleItem: true, navigation: true, navigationText: [ "", "" ], afterInit: progressBar, afterMove: moved, startDragging: pauseOnDragging, //autoHeight : true, transitionStyle: "fade" //fadeUp fade goDown backSlide }); function progressBar(elem) { $elem = elem; buildProgressBar(); start(); } //create function buildProgressBar() { $progressBar = $("
", { id: "progressBar" }); $bar = $("
", { id: "bar" }); $progressBar.append($bar).appendTo($elem); } function start() { percentTime = 0; isPause = false; tick = setInterval(interval, 10); }; function interval() { if (isPause === false) { percentTime += 1 / time; $bar.css({ width: percentTime + "%" }); if (percentTime >= 100) { $elem.trigger('owl.next') } } } //pause while dragging function pauseOnDragging() { isPause = true; } //moved callback function moved() { //clear interval clearTimeout(tick); //start again start(); } }); //Initiat WOW JS new WOW().init(); //smoothScroll smoothScroll.init(); // portfolio filter $(window).load(function() { 'use strict'; var $portfolio_selectors = $('.portfolio-filter >li>a'); var $portfolio = $('.portfolio-items'); $portfolio.isotope({ itemSelector: '.portfolio-item', layoutMode: 'fitRows' }); $portfolio_selectors.on('click', function() { $portfolio_selectors.removeClass('active'); $(this).addClass('active'); var selector = $(this).attr('data-filter'); $portfolio.isotope({ filter: selector }); return false; }); }); $(document).ready(function() { //Animated Progress $('.progress-bar').bind('inview', function(event, visible, visiblePartX, visiblePartY) { if (visible) { $(this).css('width', $(this).data('width') + '%'); $(this).unbind('inview'); } }); //Animated Number $.fn.animateNumbers = function(stop, commas, duration, ease) { return this.each(function() { var $this = $(this); var start = parseInt($this.text().replace(/,/g, "")); commas = (commas === undefined) ? true : commas; $({ value: start }).animate({ value: stop }, { duration: duration == undefined ? 1000 : duration, easing: ease == undefined ? "swing" : ease, step: function() { $this.text(Math.floor(this.value)); if (commas) { $this.text($this.text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")); } }, complete: function() { if (parseInt($this.text()) !== stop) { $this.text(stop); if (commas) { $this.text($this.text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")); } } } }); }); }; $('.business-stats').bind('inview', function(event, visible, visiblePartX, visiblePartY) { var $this = $(this); if (visible) { $this.animateNumbers($this.data('digit'), false, $this.data('duration')); $this.unbind('inview'); } }); }); /* -------- Isotope Filtering -------- */ $(document).ready(function(){ var $container = $('#isotope-gallery-container'); var $filter = $('.filter'); $(window).load(function () { // Initialize Isotope $container.isotope({ itemSelector: '.gallery-item-wrapper' }); $('.filter a').click(function () { var selector = $(this).attr('data-filter'); $container.isotope({ filter: selector }); return false; }); $filter.find('a').click(function () { var selector = $(this).attr('data-filter'); $filter.find('a').parent().removeClass('active'); $(this).parent().addClass('active'); }); }); $(window).smartresize(function () { $container.isotope('reLayout'); }); // End Isotope Filtering /* -------- Gallery Popup -------- */ $('.gallery-zoom').magnificPopup({ type: 'image' // other options }); }); // End Gallery Popup //Pretty Photo $("a[rel^='prettyPhoto']").prettyPhoto({ social_tools: false }); //Google Map var latitude = $('#google-map').data('latitude'); var longitude = $('#google-map').data('longitude'); function initialize_map() { var myLatlng = new google.maps.LatLng(latitude, longitude); var mapOptions = { zoom: 12, scrollwheel: false, center: myLatlng }; var map = new google.maps.Map(document.getElementById('google-map'), mapOptions); var marker = new google.maps.Marker({ position: myLatlng, map: map }); } google.maps.event.addDomListener(window, 'load', initialize_map); });