/* ***Custom JS*** //This Files Handles Custom Functions of this template */ $ = jQuery; function onScrollInit( items, trigger ) { items.each( function() { var osElement = $(this), osAnimationClass = osElement.attr('data-os-animation'), osAnimationDelay = osElement.attr('data-os-animation-delay'); var osTrigger = ( trigger ) ? trigger : osElement; osTrigger.waypoint(function() { osElement.addClass('animated').addClass(osAnimationClass); },{ triggerOnce: true, offset: '100%' }); }); } $(document).ready(function() { /*---------------------------------*/ /* AJAX Portfolio /*---------------------------------*/ // Close Button jQuery("body").on('click', '#close_portfolio', function(){ var $portfolio_details = jQuery("#portfolio_details"); $portfolio_details.slideUp('', function(){ $portfolio_details.removeClass('loading'); }); }) // AJAX // $(".grid_portfolio").click(function(){ // id of li var $id = jQuery(this).attr('id'); // reponse div var $portfolio_details = jQuery("#portfolio_details"); // post data var postdata = { 'action' : 'ajax_portfolio', 'id' : $id }; jQuery.ajax({ url: ajaxurl, type: 'POST', data: postdata, //dataType: 'json', beforeSend: function() { // clean up and add loading $portfolio_details.html('').fadeOut(0, function(){ $(this).addClass('loading').fadeIn('fast'); }); // scroll to element $('html, body').stop().animate({ scrollTop: $portfolio_details.offset().top-200 }, 1000, 'easeInOutExpo'); }, }).done(function(responseData) { //console.log(responseData); $portfolio_details.fadeOut('fast', function(){ $portfolio_details.removeClass('loading'); $portfolio_details.html(responseData).fadeIn('fast'); }); }); }); // isotope // // if(typeof isotope == 'function') { // init Isotope var $container = jQuery('#portfolio').isotope({ itemSelector: '.entry', layoutMode: 'masonry' }); // bind filter button click jQuery('#portfolio-filters').on('click', 'button', function () { var filterValue = jQuery(this).attr('data-filter'); // use filterFn if matches value $container.isotope({filter: filterValue}); }); // change is-checked class on buttons jQuery('.button-group').each(function (i, buttonGroup) { var $buttonGroup = jQuery(buttonGroup); $buttonGroup.on('click', 'button', function () { $buttonGroup.find('.is-checked').removeClass('is-checked'); jQuery(this).addClass('is-checked'); }); }); // } /*---------- Portfolio End here -----------*/ //for gallery if(typeof CBPGridGallery != 'undefined') { // new CBPGridGallery(document.getElementById('grid-gallery')); } if(typeof countTo == 'function') { // Figures Count To // $('.timer').countTo(); } // Scrolling Here // $('.scrollbar').perfectScrollbar(); //Carousel Default// with 5 items at a time $(".carousel").owlCarousel(); // Single Item // $(".single_item_carousel").owlCarousel({ singleItem:true, autoPlay:2500, pagination:false }); onScrollInit( $('.os-animation') ); });// Ready /* Window LOAD */ $(window).load(function(){ //Delcear some Vars// // Get the height of nav wrapper var Nav_wrapper_height = $("#nav_wrapper").outerHeight(); if(floatmenu==1){ // NAV bar offset var nav_bar_element = $('#nav_wrapper'); var nav_bar_offset = nav_bar_element.offset(); var nav_bar_offset_top = nav_bar_offset.top; // Changing Header on Scrolling // // Show Navigation if($( window ).scrollTop()>=nav_bar_offset_top) { nav_bar_element.addClass("fixed"); } else{ nav_bar_element.removeClass("fixed"); } // Scrolling Fixed Nav bar fix $(window).scroll(function() { // FOR HEADER MENU TO FIX ON SCROLL // if($( window ).scrollTop()>=nav_bar_offset_top) { nav_bar_element.addClass("fixed"); } else{ nav_bar_element.removeClass("fixed"); } }); }// floatmenu /* Scrolling Menues */ $('.page-scroll a, .page-scroll-button').bind('click', function(event) { var $anchor = $(this); // Fix issues of scrolling cauisng of fixed menue if($("#nav_wrapper").hasClass("fixed")){ var scrolltop = $($anchor.attr('href')).offset().top; } else{ var scrolltop =$($anchor.attr('href')).offset().top - Nav_wrapper_height ; } // fix issue causing of not adding sectio class if(!$anchor.hasClass(".section")) { var scrolltop = scrolltop - Nav_wrapper_height+1; } // Now lets animate it $('html, body').stop().animate({ scrollTop: scrolltop }, 1500, 'easeInOutExpo'); event.preventDefault(); // HERE WE ADD ACTIVE CLASS // lets remove first $(".page-scroll a").each(function(){ $(this).removeClass("active"); }) $anchor.addClass("active"); }); }) // Window load end here