/** * SinglePro HTML 1.0 * Template Scripts * Created by WpFreeware Team Custom JS 1. Superslides Slider 2. Fixed Top Menubar 3. Featured Slider 4. Skill Circle 5. Wow animation 6. Project Counter 7. TEAM SLIDER 8. BLOG SLIDER 9. TESTIMONIAL SLIDER 10. CLIENTS SLIDER 11. Google Map 12. SCROLL TOP BUTTON 13. PRELOADER 14. MENU SCROLL 15. MOBILE MENU CLOSE **/ jQuery(function($){ /* ----------------------------------------------------------- */ /* 1. Superslides Slider /* ----------------------------------------------------------- */ jQuery('#slides').superslides({ animation: 'slide', play: '3500' }); /* ----------------------------------------------------------- */ /* 2. Fixed Top Menubar /* ----------------------------------------------------------- */ // For fixed top bar $(window).scroll(function(){ if($(window).scrollTop() >100 /*or $(window).height()*/){ $(".navbar-fixed-top").addClass('past-main'); } else{ $(".navbar-fixed-top").removeClass('past-main'); } }); /* ----------------------------------------------------------- */ /* 3. Featured Slider /* ----------------------------------------------------------- */ $('.featured_slider').slick({ dots: true, infinite: true, speed: 800, arrows:false, slidesToShow: 1, slide: 'div', autoplay: true, fade: true, autoplaySpeed: 5000, cssEase: 'linear' }); /* ----------------------------------------------------------- */ /* 4. Skill Circle /* ----------------------------------------------------------- */ $('#myStathalf').circliful(); $('#myStat').circliful(); $('#myStathalf2').circliful(); $('#myStat2').circliful(); $('#myStat3').circliful(); $('#myStat4').circliful(); $('#myStathalf3').circliful(); /* ----------------------------------------------------------- */ /* 5. Wow smooth animation /* ----------------------------------------------------------- */ wow = new WOW( { animateClass: 'animated', offset: 100 } ); wow.init(); /* ----------------------------------------------------------- */ /* 6. Project Counter /* ----------------------------------------------------------- */ (function ($) { $.fn.countTo = function (options) { options = options || {}; return $(this).each(function () { // set options for current element var settings = $.extend({}, $.fn.countTo.defaults, { from: $(this).data('from'), to: $(this).data('to'), speed: $(this).data('speed'), refreshInterval: $(this).data('refresh-interval'), decimals: $(this).data('decimals') }, options); // how many times to update the value, and how much to increment the value on each update var loops = Math.ceil(settings.speed / settings.refreshInterval), increment = (settings.to - settings.from) / loops; // references & variables that will change with each update var self = this, $self = $(this), loopCount = 0, value = settings.from, data = $self.data('countTo') || {}; $self.data('countTo', data); // if an existing interval can be found, clear it first if (data.interval) { clearInterval(data.interval); } data.interval = setInterval(updateTimer, settings.refreshInterval); // initialize the element with the starting value render(value); function updateTimer() { value += increment; loopCount++; render(value); if (typeof(settings.onUpdate) == 'function') { settings.onUpdate.call(self, value); } if (loopCount >= loops) { // remove the interval $self.removeData('countTo'); clearInterval(data.interval); value = settings.to; if (typeof(settings.onComplete) == 'function') { settings.onComplete.call(self, value); } } } function render(value) { var formattedValue = settings.formatter.call(self, value, settings); $self.html(formattedValue); } }); }; $.fn.countTo.defaults = { from: 0, // the number the element should start at to: 0, // the number the element should end at speed: 1000, // how long it should take to count between the target numbers refreshInterval: 100, // how often the element should be updated decimals: 0, // the number of decimal places to show formatter: formatter, // handler for formatting the value before rendering onUpdate: null, // callback method for every time the element is updated onComplete: null // callback method for when the element finishes updating }; function formatter(value, settings) { return value.toFixed(settings.decimals); } }(jQuery)); jQuery(function ($) { // custom formatting example $('#count-number').data('countToOptions', { formatter: function (value, options) { return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ','); } }); $('#count-number2').data('countToOptions', { formatter: function (value, options) { return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ','); } }); $('#count-number3').data('countToOptions', { formatter: function (value, options) { return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ','); } }); $('#count-number4').data('countToOptions', { formatter: function (value, options) { return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ','); } }); // start all the timers $('.timer').each(count); function count(options) { var $this = $(this); options = $.extend({}, options || {}, $this.data('countToOptions') || {}); $this.countTo(options); } }); /* ----------------------------------------------------------- */ /* 7. TEAM SLIDER /* ----------------------------------------------------------- */ $('.team_slider').slick({ dots: false, infinite: true, speed: 300, slidesToShow: 4, slidesToScroll: 4, responsive: [ { breakpoint: 1024, settings: { slidesToShow: 3, slidesToScroll: 3, infinite: true, dots: true } }, { breakpoint: 600, settings: { slidesToShow: 2, slidesToScroll: 2 } }, { breakpoint: 480, settings: { slidesToShow: 1, slidesToScroll: 1 } } ] }); /* ----------------------------------------------------------- */ /* 8. BLOG SLIDER /* ----------------------------------------------------------- */ $('.blog_slider').slick({ dots: false, infinite: true, speed: 300, slidesToShow: 3, slidesToScroll: 3, responsive: [ { breakpoint: 1024, settings: { slidesToShow: 3, slidesToScroll: 3, infinite: true, dots: true } }, { breakpoint: 600, settings: { slidesToShow: 2, slidesToScroll: 2 } }, { breakpoint: 480, settings: { slidesToShow: 1, slidesToScroll: 1 } } ] }); /* ----------------------------------------------------------- */ /* 9. TESTIMONIAL SLIDER /* ----------------------------------------------------------- */ $('.testimonial_slider').slick({ dots: true, infinite: true, speed: 800, arrows:false, slidesToShow: 1, slide: 'li', autoplay: true, fade: true, autoplaySpeed: 3000, cssEase: 'linear' }); /* ----------------------------------------------------------- */ /* 10. CLIENTS SLIDER /* ----------------------------------------------------------- */ $('.clients_slider').slick({ dots: false, infinite: true, speed: 300, slidesToShow: 4, slidesToScroll: 4, responsive: [ { breakpoint: 1199, settings: { slidesToShow: 3, slidesToScroll: 3, infinite: true, dots: true } }, { breakpoint: 600, settings: { slidesToShow: 2, slidesToScroll: 2 } }, { breakpoint: 480, settings: { slidesToShow: 1, slidesToScroll: 1 } } ] }); /* ----------------------------------------------------------- */ /* 11. Google Map /* ----------------------------------------------------------- */ var zoom= $('#map_canvas').gmap('option', 'zoom'); $('#map_canvas').gmap().bind('init', function(ev, map) { $('#map_canvas').gmap('addMarker', {'position': '57.7973433,12.0502107', 'bounds': true}); $('#map_canvas').gmap('option', 'zoom', 13); }); /* ----------------------------------------------------------- */ /* 12. SCROLL TOP BUTTON /* ----------------------------------------------------------- */ //Check to see if the window is top if not then display button $(window).scroll(function(){ if ($(this).scrollTop() > 300) { $('.scrollToTop').fadeIn(); } else { $('.scrollToTop').fadeOut(); } }); //Click event to scroll to top $('.scrollToTop').click(function(){ $('html, body').animate({scrollTop : 0},800); return false; }); /* ----------------------------------------------------------- */ /* 13. PRELOADER /* ----------------------------------------------------------- */ jQuery(window).load(function() { // makes sure the whole site is loaded $('#status').fadeOut(); // will first fade out the loading animation $('#preloader').delay(100).fadeOut('slow'); // will fade out the white DIV that covers the website. $('body').delay(100).css({'overflow':'visible'}); }) /* ----------------------------------------------------------- */ /* 14. MENU SCROLL /* ----------------------------------------------------------- */ //MENU SCROLLING WITH ACTIVE ITEM SELECTED // Cache selectors var lastId, topMenu = $("#top-menu"), topMenuHeight = topMenu.outerHeight()+13, // All list items menuItems = topMenu.find("a"), // Anchors corresponding to menu items scrollItems = menuItems.map(function(){ var item = $($(this).attr("href")); if (item.length) { return item; } }); // Bind click handler to menu items // so we can get a fancy scroll animation menuItems.click(function(e){ var href = $(this).attr("href"), offsetTop = href === "#" ? 0 : $(href).offset().top-topMenuHeight+1; $('html, body').stop().animate({ scrollTop: offsetTop }, 900); e.preventDefault(); }); // Bind to scroll $(window).scroll(function(){ // Get container scroll position var fromTop = $(this).scrollTop()+topMenuHeight; // Get id of current scroll item var cur = scrollItems.map(function(){ if ($(this).offset().top < fromTop) return this; }); // Get the id of the current element cur = cur[cur.length-1]; var id = cur && cur.length ? cur[0].id : ""; if (lastId !== id) { lastId = id; // Set/remove active class menuItems .parent().removeClass("active") .end().filter("[href=#"+id+"]").parent().addClass("active"); } }) /* ----------------------------------------------------------- */ /* 15. MOBILE MENU ACTIVE CLOSE /* ----------------------------------------------------------- */ $('.navbar-nav').on('click', 'li a', function() { $('.navbar-collapse').collapse('hide'); }); });