(function($){ "use strict"; $=jQuery; jQuery(document).ready(function($){ var delay=(function (){ var timer=0; return function (callback, ms){ clearTimeout(timer); timer=setTimeout(callback, ms); };})(); if($('.single-page').hasClass('standard-layout')){ $('.gowp-single-page').addClass('gowp-standard-layout'); }else{ $('.gowp-single-page').addClass('gowp-special-layout'); } $(window).scroll(function (){ if($(this).scrollTop() > 500){ $('#back-top').css('bottom','0'); }else{ $('#back-top').css('bottom','-50px'); }}); $('#back-top').click(function (){ $('body,html').animate({ scrollTop: 0, }, 1300); return false; }); $('.header-slider').flexslider({ animation: 'slide', controlNav: false, animationLoop: true, slideshow: true, pauseOnHover: true, slideshowSpeed: 8000, animationSpeed: 600, smoothHeight: true, directionNav: true, nextText: '', prevText: '', }); $('.fullwidth-section .gowp-carousel-wrap').flexslider({ animation: "slide", controlNav: false, itemWidth: 270, columnWidth: 1, pauseOnHover: true, move: 1, animationLoop: true, slideshowSpeed: 8000, animationSpeed: 600, nextText: '', prevText: '', minItems: 1, maxItems: 3, }); $('.content-section .gowp-carousel-wrap').flexslider({ animation: "slide", controlNav: false, itemWidth: 240, columnWidth: 1, pauseOnHover: true, move: 1, animationLoop: true, slideshowSpeed: 8000, animationSpeed: 600, nextText: '', prevText: '', minItems: 1, maxItems: 3, }); $('.gowp-carousel-2-wrap').flexslider({ animation: "slide", controlNav: true, itemWidth: 270, columnWidth: 1, pauseOnHover: true, move: 1, animationLoop: true, slideshowSpeed: 8000, animationSpeed: 600, nextText: '', prevText: '', minItems: 1, maxItems: 3, }); $('.module-slider .post-info').removeClass('overlay'); $('.gowp-slider-wrap').flexslider({ animation: 'slide', controlNav: false, animationLoop: true, slideshow: true, pauseOnHover: true, slideshowSpeed: 8000, animationSpeed: 600, smoothHeight: true, directionNav: true, nextText: '', prevText: '', }); $('.widget-slider .slider-wrap').flexslider({ animation: 'slide', controlNav: false, animationLoop: true, slideshow: true, pauseOnHover: true, slideshowSpeed: 8000, animationSpeed: 600, smoothHeight: true, directionNav: true, nextText: '', prevText: '', }); $('#gowp-gallery-slider').flexslider({ animation: 'slide', controlNav: false, animationLoop: true, slideshow: false, pauseOnHover: true, slideshowSpeed: 5000, animationSpeed: 600, smoothHeight: true, directionNav: true, nextText: '', prevText: '', }); $('.widget_comment').flexslider({ animation: 'slide', controlNav: false, animationLoop: true, slideshow: true, pauseOnHover: true, slideshowSpeed: 8000, animationSpeed: 600, smoothHeight: true, directionNav: true, nextText: '', prevText: '', }); if(megamenu_carousel_el!=null){ var gowp_megamenu_item; $.each(megamenu_carousel_el, function(id, maxitems){ gowp_megamenu_item=$('#'+id).find('.gowp-sub-post').length; if(gowp_megamenu_item > maxitems){ $('#'+id).flexslider({ animation: "slide", animationLoop: true, slideshow: false, itemWidth: 10, minItems: maxitems, maxItems: maxitems, controlNav: false, directionNav: true, slideshowSpeed: 3000, move: 1, touch: true, useCSS: true, nextText: '', prevText: '', }); }else{ $('#'+id).removeClass('flexslider'); $('#'+id).addClass('flexslider_destroy'); }}); } $('.page-wrap').imagesLoaded(function(){ setTimeout(function(){ if($('.masonry-content-container').find('.one-col').length > 2){ $('.masonry-content-container').masonry({ itemSelector: '.one-col', columnWidth: 1, isAnimated: true, isFitWidth: true, }); } $('.ajax-load-btn').addClass('active'); $('.masonry-content-container').find('.post-details').removeClass('opacity-zero'); $('.masonry-content-container').find('.post-meta').removeClass('opacity-zero'); },500); }); var canvasArray=$('.rating-canvas'); $.each(canvasArray, function(i,canvas){ var percent=$(canvas).data('rating'); var ctx=canvas.getContext('2d'); canvas.width=$(canvas).parent().width(); canvas.height=canvas.width/2; var x=(canvas.width) / 2; var y=(canvas.height); if($(canvas).parents().hasClass('rating-wrap')){ var radius=(canvas.width - 6) / 2; var lineWidth=6; }else{ var radius=(canvas.width - 10) / 2; var lineWidth=6; } var endAngle=(Math.PI * percent * 2 / 100); ctx.beginPath(); ctx.arc(x, y, radius, -(Math.PI/180*180), Math.PI * 2 - (Math.PI/180*180), false); ctx.lineWidth=7; ctx.strokeStyle="#666"; ctx.stroke(); ctx.beginPath(); ctx.arc(x, y, radius, -(Math.PI/180*180), endAngle - (Math.PI/180*180), false); ctx.lineWidth=8; ctx.strokeStyle="#efa48d"; ctx.stroke(); }); var gowpParallaxFeatImg=$('.fw-feat-img-parallax'); if(gowpParallaxFeatImg.length!==0){ $(window).scroll(function(){ var gowpBgy_p=-(($(window).scrollTop()) / 3.5), gowpBgPos='50% ' + gowpBgy_p + 'px'; gowpParallaxFeatImg.css("background-position", gowpBgPos); }); } if((typeof fixed_nav!=='undefined')&&(fixed_nav==2)){ var nav=$('.top-bar'); var d=nav.offset().top; $(window).scroll(function (){ if($(this).scrollTop() > d){ nav.addClass("fixed"); var ad_bar=$('#wpadminbar'); if(ad_bar.length!=0){ $('.top-bar').css('margin-top',ad_bar.height()); }}else{ nav.removeClass("fixed"); $('.top-bar').css('margin-top','0'); }}); } $(window).resize(function(){ if($(this).width() >=1050){ $('#main-mobile-menu').hide(); }}); $('.main-nav .mobile').click(function(){ $(this).siblings('#main-mobile-menu').toggle(300); }); $('.main-nav #main-mobile-menu > ul > li.menu-item-has-children').prepend('
'); $('.expand').click(function(){ $(this).siblings('.sub-menu').toggle(300); }); $('#header-search .search-icon').click(function(){ if($(this).siblings('#s').height()==0){ $('#header-search #s').css('height','45px'); $('#header-search #s').css('padding','8px 12px'); $('#header-search #s').css('font-size','14px'); $('#header-search #s').css('border-color', '#888888'); $('#header-search #s').css('background-color', 'rgba(255, 255, 255, 0.3)'); }else{ $('#header-search #s').css('height','0'); $('#header-search #s').css('padding','0'); $('#header-search #s').css('font-size','0'); $('#header-search #s').css('border-color', 'transparent'); $('#header-search #s').css('background-color', 'transparent'); }}); $('.gowp-embed-video').fitVids(); $('.single .article-content').fitVids(); if((ticker!=null)&&(ticker.length!=0)){ $.each(ticker, function(id, config){ if(config=='Scroll'){ scroll_ticker_create('#'+id); }else if(config=='Type'){ type_ticker_create('#'+id); }else if(config=='Slide'){ $("#"+id+" ul.ticker").liScroll({travelocity: 0.07}); }}); } $('.img-popup-link').magnificPopup({ type: 'image', removalDelay: 300, mainClass: 'mfp-fade', closeOnContentClick: true, closeBtnInside: false, fixedContentPos: true, image: { verticalFit: true }}); $('.video-popup-link').magnificPopup({ closeBtnInside: false, fixedContentPos: true, disableOn: 700, type: 'iframe', removalDelay: 300, mainClass: 'mfp-fade', preloader: false, }); $('#gowp-gallery-slider').each(function(){ $(this).magnificPopup({ delegate: 'a.zoomer', type: 'image', closeOnContentClick: false, closeBtnInside: false, removalDelay: 300, mainClass: 'mfp-fade', image: { tError: 'The image #%curr% could not be loaded.', verticalFit: true, titleSrc: function(item){ return ' '+ item.el.attr('title') + ''; }}, gallery: { enabled: true, navigateByImgClick: true, preload: [0,1] }}); }); if(typeof justified_ids!=='undefined'){ $.each(justified_ids, function(index, justified_id){ $(".justifiedgall_"+justified_id).justifiedGallery({ rowHeight: 200, fixedHeight: false, lastRow: 'justify', margins: 4, randomize: false, sizeRangeSuffixes: {lt100:"",lt240:"",lt320:"",lt500:"",lt640:"",lt1024:""}, }); }); } $('.zoom-gallery').each(function(){ $(this).magnificPopup({ delegate: 'a.zoomer', type: 'image', closeOnContentClick: false, closeBtnInside: false, mainClass: 'mfp-with-zoom mfp-img-mobile', image: { tError: 'The image #%curr% could not be loaded.', verticalFit: true, titleSrc: function(item){ console.log(item.el[0]); return ' '+ item.el.attr('title') + ''; }}, gallery: { enabled: true, navigateByImgClick: true, preload: [0,1] }, zoom: { enabled: true, duration: 600, easing: 'ease', opener: function(element){ return element.find('img'); }} }); }); var win, tick, curscroll, nextscroll; win=$(window); var width=$('.sidebar-wrap').width(); tick=function(){ nextscroll=win.scrollTop(); $(".sidebar-wrap.stick").each(function(){ var bottom_compare, top_compare, screen_scroll, parent_top, parent_h, parent_bottom, scroll_status=0, topab; var sbID="#"+$(this).attr(("id")); bottom_compare=$(sbID).offset().top + $(sbID).outerHeight(true); screen_scroll=win.scrollTop() + win.height(); parent_top=$(sbID).parents('.content-sb-section').offset().top; parent_h=$(sbID).parents('.content-sb-section').height(); parent_bottom=parent_top + parent_h; topab=parent_h - $(sbID).outerHeight(true); if(window.innerWidth > 1023){ if(parent_h > $(sbID).outerHeight(true)){ if(win.scrollTop() < parent_top){ scroll_status=0; }else if((win.scrollTop() >=parent_top)&&(screen_scroll < parent_bottom)){ if(curscroll <=nextscroll){ scroll_status=1; }else if(curscroll > nextscroll){ scroll_status=3; }}else if(screen_scroll >=parent_bottom){ scroll_status=2; } console.log(scroll_status); if(scroll_status==0){ $(sbID).css({ "position":"static", "top":"auto", "bottom":"auto" }); }else if(scroll_status==1){ console.log($(sbID).offset().top); if(win.height() > $(sbID).outerHeight(true)){ var ad_bar=$('#wpadminbar'); if(fixed_nav==2){ if(ad_bar.length!=0){ var sb_height_fixed=16 + ad_bar.height() + $('.main-nav').height() + 'px'; }else{ var sb_height_fixed=16 + $('.main-nav').height() + 'px'; }}else{ if(ad_bar.length!=0){ var sb_height_fixed=16 + ad_bar.height() + 'px'; }else{ var sb_height_fixed=16 + 'px'; }} $(sbID).css({ "position":"fixed", "top":sb_height_fixed, "bottom":"auto", "width":width }); }else{ if(screen_scroll < bottom_compare){ topab=$(sbID).offset().top - parent_top; $(sbID).css({ "position":"absolute", "top":topab, "bottom":"auto", "width":width }); }else{ $(sbID).css({ "position":"fixed", "top":"auto", "bottom":"16px", "width":width }); }} }else if(scroll_status==3){ if(win.scrollTop() > ($(sbID).offset().top)){ topab=$(sbID).offset().top - parent_top; console.log($(sbID).offset().top); console.log(parent_top); $(sbID).css({ "position":"absolute", "top":topab, "bottom":"auto", "width":width }); }else{ var ad_bar=$('#wpadminbar'); if(fixed_nav==2){ if(ad_bar.length!=0){ var sb_height_fixed=16 + ad_bar.height() + $('.main-nav').height() + 'px'; }else{ var sb_height_fixed=16 + $('.main-nav').height() + 'px'; }}else{ if(ad_bar.length!=0){ var sb_height_fixed=16 + ad_bar.height() + 'px'; }else{ var sb_height_fixed=16 + 'px'; }} $(sbID).css({ "position":"fixed", "top":sb_height_fixed, "bottom":"auto", "width":width }); }}else if(scroll_status==2){ if(win.height() > $(sbID).outerHeight(true)){ var status2_inner=0; if(curscroll <=nextscroll){ status2_inner=1; }else if(curscroll > nextscroll){ status2_inner=2; } if(((status2_inner==1)&&(bottom_compare < parent_bottom))||((status2_inner==2)&&(win.scrollTop() < $(sbID).offset().top))){ var ad_bar=$('#wpadminbar'); if(fixed_nav==2){ if(ad_bar.length!=0){ var sb_height_fixed=16 + ad_bar.height() + $('.main-nav').height() + 'px'; }else{ var sb_height_fixed=16 + $('.main-nav').height() + 'px'; }}else{ if(ad_bar.length!=0){ var sb_height_fixed=16 + ad_bar.height() + 'px'; }else{ var sb_height_fixed=16 + 'px'; }} $(sbID).css({ "position":"fixed", "top":sb_height_fixed, "bottom":"auto", "width":width }); }else{ $(sbID).css({ "position":"absolute", "top":topab, "bottom":"auto", "width":width }); }}else{ $(sbID).css({ "position":"absolute", "top":topab, "bottom":"auto", "width":width }); }} }else{ $(sbID).css({ "position":"static", "top":"auto", "bottom":"auto" }); }} $(sbID).parent().css("height", $(sbID).height()); }); curscroll=nextscroll; } $(".sidebar-wrap.stick").each(function(){ $(this).wrap("
"); }); delay(function (){ win.on("scroll", tick); }, 2000); win.resize(function(){ $(".sidebar-wrap.stick").each(function(){ var sbID="#"+$(this).attr(("id")); if(window.innerWidth > 1023){ if($(this).parent().hasClass('gowp-sticksb-wrapper')){ width=$('.gowp-sticksb-wrapper').width(); $(sbID).css({ "width":width }); }}else{ $(sbID).css({ "position":"static", "top":"auto", "bottom":"auto" }); }}); }); }); })(jQuery);