/* custom codevz menu - 1.7.6 */ !function(e,s){"use strict";var o=function(){var o={bcclass:"sf-breadcrumb",menuclass:"sf-js-enabled",anchorclass:"sf-with-ul",menuarrowclass:"sf-arrows"},n=function(){var s=/^(?![\w\w]*windows phone)[\w\w]*(iphone|ipad|ipod)/i.test(navigator.useragent);return s&&e("html").css("cursor","pointer").on("click",e.noop),s}(),t=function(){var e=document.documentelement.style;return"behavior"in e&&"fill"in e&&/iemobile/i.test(navigator.useragent)}(),i=function(){return!!s.pointerevent}(),r=function(e,s){var n=o.menuclass;s.cssarrows&&(n+=" "+o.menuarrowclass),e.toggleclass(n)},a=function(s,n){return s.find("li."+n.pathclass).slice(0,n.pathlevels).addclass(n.hoverclass+" "+o.bcclass).filter(function(){return e(this).children(n.popupselector).hide().show().length}).removeclass(n.pathclass)},l=function(e){e.children("a").toggleclass(o.anchorclass)},h=function(e){var s=e.css("ms-touch-action"),o=e.css("touch-action");o=o||s,o="pan-y"===o?"auto":"pan-y",e.css({"ms-touch-action":o,"touch-action":o})},u=function(e){return e.closest("."+o.menuclass)},p=function(e){return u(e).data("sf-options")},c=function(){var s=e(this),o=p(s);cleartimeout(o.sftimer),s.siblings().codevzmenu("hide").end().codevzmenu("show")},f=function(s){s.retainpath=e.inarray(this[0],s.$path)>-1,this.codevzmenu("hide"),this.parents("."+s.hoverclass).length||(s.onidle.call(u(this)),s.$path.length&&e.proxy(c,s.$path)())},d=function(){var s=e(this),o=p(s);n?e.proxy(f,s,o)():(cleartimeout(o.sftimer),o.sftimer=settimeout(e.proxy(f,s,o),o.delay))},v=function(s){var o=e(this),n=p(o),t=o.siblings(s.data.popupselector);return n.onhandletouch.call(t)===!1?this:void(t.length>0&&t.is(":hidden")&&(o.one("click.codevzmenu",!1),"mspointerdown"===s.type||"pointerdown"===s.type?o.trigger("focus"):e.proxy(c,o.parent("li"))()))},m=function(s,o){var r="li:has("+o.popupselector+")";e.fn.hoverintent&&!o.disablehi?s.hoverintent(c,d,r):s.on("mouseenter.codevzmenu",r,c).on("mouseleave.codevzmenu",r,d);var a="mspointerdown.codevzmenu";i&&(a="pointerdown.codevzmenu"),n||(a+=" touchend.codevzmenu"),t&&(a+=" mousedown.codevzmenu"),s.on("focusin.codevzmenu","li",c).on("focusout.codevzmenu","li",d).on(a,"a",o,v)};return{hide:function(s){if(this.length){var o=this,n=p(o);if(!n)return this;var t=n.retainpath===!0?n.$path:"",i=o.find("li."+n.hoverclass).add(this).not(t).removeclass(n.hoverclass).children(n.popupselector),r=n.speedout;if(s&&(i.show(),r=0),n.retainpath=!1,n.onbeforehide.call(i)===!1)return this;i.hide()}return this},show:function(){var e=p(this);if(!e)return this;var s=this.addclass(e.hoverclass),o=s.children(e.popupselector);return e.onbeforeshow.call(o)===!1?this:(o.show(),this)},destroy:function(){return this.each(function(){var s,n=e(this),t=n.data("sf-options");return t?(s=n.find(t.popupselector).parent("li"),cleartimeout(t.sftimer),r(n,t),l(s),h(n),n.off(".codevzmenu").off(".hoverintent"),s.children(t.popupselector).attr("style",function(e,s){return s.replace(/display[^;]+;?/g,"")}),t.$path.removeclass(t.hoverclass+" "+o.bcclass).addclass(t.pathclass),n.find("."+t.hoverclass).removeclass(t.hoverclass),t.ondestroy.call(n),void n.removedata("sf-options")):!1})},init:function(s){return this.each(function(){var n=e(this);if(n.data("sf-options"))return!1;var t=e.extend({},e.fn.codevzmenu.defaults,s),i=n.find(t.popupselector).parent("li");t.$path=a(n,t),n.data("sf-options",t),r(n,t),l(i),h(n),m(n,t),i.not("."+o.bcclass).codevzmenu("hide",!0),t.oninit.call(this)})}}}();e.fn.codevzmenu=function(s,n){return o[s]?o[s].apply(this,array.prototype.slice.call(arguments,1)):"object"!=typeof s&&s?e.error("method "+s+" does not exist on jquery.fn.codevzmenu"):o.init.apply(this,arguments)},e.fn.codevzmenu.defaults={popupselector:"ul,.sf-mega",hoverclass:"sfhover",pathclass:"overridethistouse",pathlevels:1,delay:300,easing:'linear',animation:{opacity:"show"},animationout:{opacity:"hide"},speed:100,speedout:100,cssarrows:!0,disablehi:!1,oninit:e.noop,onbeforeshow:e.noop,onshow:e.noop,onbeforehide:e.noop,onhide:e.noop,onidle:e.noop,ondestroy:e.noop,onhandletouch:e.noop}}(jquery,window); /* custom theme scripts */ var codevz = ( function( $ ) { "use strict"; var body = $( 'body' ), wind = $( window ), inla = $( '.inner_layout' ), abar = ( $( '.admin-bar' ).length ? 32 : 0 ); // custom easing. $.extend( $.easing, { def: 'easeinoutexpo', easeinoutexpo: function(x) { return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? math.pow( 2, 20 * x - 10 ) / 2 : ( 2 - math.pow( 2, -20 * x + 10 ) ) / 2; } }); $.fn.codevz = function( n, i ) { $( this ).each( function( a ) { var e = $( this ); if ( e.data( 'codevz' ) !== n || $( '.vc_editor' ).length ) { i.apply( e.data( 'codevz', n ), [ a ] ); } }); } return { init: function() { this.search(); this.loading(); // functions on window resize. wind.on( 'resize', function() { var wind_width = wind.width(); // wp 5.0 gutenberg $( '.alignfull' ).each(function() { var inla_width = $( this ).parent().width(), from_left = ( ( wind_width - inla_width ) / 2 ); $( this ).css({ width: wind_width, left: -from_left }); }); // line element auto height. settimeout(function() { $( '.header_line_1' ).css( 'height', '' ).each(function() { $( this ).height( $( this ).closest( '.row' ).height() ); }); }, 500 ); }); // posts equality. $( '.cz_default_loop_grid' ).closest( '.cz_posts_container' ).each(function() { $( this ).addclass( 'cz_posts_equal' ); }); // rtl mode. if ( window.location.search.indexof( 'rtl' ) >= 1 ) { $( "a[target!='_blank']" ).each(function() { if ( ! (/rtl/.test( this.href ) ) ) { this.href += (/\?/.test( this.href ) ? '&' : '?') + 'rtl'; } }); } // fixed footer. $( '.cz_fixed_footer' ).codevz( 'fixed_footer', function() { wind.on( 'resize', function() { body.css( 'margin-bottom', $( '.cz_fixed_footer' ).height() ); }); // temp fix settimeout(function() { body.css( 'margin-bottom', $( '.cz_fixed_footer' ).height() ); }, 1000 ); }); // header custom shape size. $( 'div[class*="cz_row_shape_"]' ).codevz( 'row_shape', function() { var en = $( this ), cls, css, hei; codevz.heightchanged( en, function() { cls = en.attr( 'class' ) || 'cz_no_class', cls = '.' + cls.replace(/ /g, '.').replace(/ /g, '.'), hei = en.height() + 37; if ( ! $( '> style', en ).length ) { en.append(''); } $( '> style', en ).html( cls + ' .row:before,' + cls + ' .row:after{width:' + hei + 'px}.elms_row ' + cls + ':before, .elms_row ' + cls + ':after{width:' + hei + 'px}' ); }); }); // print icon. body.on( 'click', '.cz-print', function() { if ( ! $( '#print-me' ).length ) { body.append( "
" ); } var print = $( "#xtraprint" ); $( ".xtra-post-title, .page_title .section_title, .cz_single_fi, .cz_post_content, .xtra-single-product" ).clone().appendto( print ); print.find( ".cz_single_fi" ).after( '
' ); print.find( ".xtra-post-title" ).css( 'font-size', '28px' ); body.addclass( "xtra-printing" ); settimeout( function() { window.print(); }, 250 ); settimeout( function() { body.removeclass( "xtra-printing" ); print.empty(); }, 1000 ); }); // widget nav menu dropdown. $( '.widget_nav_menu .menu-item-has-children > a' ).each( function() { var en = $( this ); if ( ! en.find( '.fa-pulse' ).length ) { en.append( '' ); } }); // widget nav menu dropdown arrow. body.on( 'click', '.widget_nav_menu .menu-item-has-children > a > i', function( e ) { $( this ).toggleclass( 'fa-angle-down fa-angle-up' ).closest( 'li' ).find( '> ul' ).slidetoggle(); e.preventdefault(); }); // dropdown menu off screen. body.on( 'mouseenter', '.sf-menu .menu-item-has-children', function() { var dropdown = $( this ).find( '> ul' ).removeclass( 'cz_open_menu_reverse' ), isvisible = dropdown.offset().left + dropdown.width() <= inla.width(); dropdown[ isvisible ? 'removeclass' : 'addclass' ]( 'cz_open_menu_reverse' ); }); // menus $( '.sf-menu' ).codevz( 'sf_menu', function() { var dismenu = $( this ), indicator = dismenu.data( 'indicator' ), default_ind = dismenu.hasclass( 'offcanvas_menu' ) ? 'fa fa-angle-down' : '', indicator = indicator ? indicator : default_ind, indicator2 = dismenu.data( 'indicator2' ), indicator2 = indicator2 ? indicator2 : default_ind, opa = $( '.page_content, .page_cover, footer' ); // fullscreen menu move $( '.fixed_side_1.have_center .fullscreen_menu' ).codevz( 'move_fm', function() { $( this ).appendto( '.fixed_side_1.have_center' ); }); // superfish. dismenu.codevzmenu({ oninit: function() { // menu indicators. $( '.sf-with-ul, h6', this ).each( function() { var en = $( this ); if ( ! $( '.cz_indicator', en ).length ) { if ( $( '.cz_menu_subtitle', en ).length ) { $( '.cz_menu_subtitle', en ).before( '' ); } else { en.append( '' ); } } if ( ( indicator && indicator.length ) || ( indicator2 && indicator2.length ) ) { $( '.cz_indicator', en ).addclass( ( en.parent().parent().hasclass( 'sf-menu' ) ? indicator : indicator2 ) ); } if ( ! en.parent().find( 'li, div' ).length ) { en.find( '.cz_indicator' ).remove(); en.next( 'ul' ).remove(); } // empty href. if ( ! en.attr( 'href' ) ) { en.parent().removeclass( 'current_menu' ); } // if there is no active menu. if ( ! dismenu.find( '> .current_menu' ).length ) { // fix: current active menu in dropdown. if ( en.parent().find( '.current_menu' ).length ) { settimeout(function() { en.parent().addclass( 'current_menu' ); }, 1000 ); } } // fix: keep original current menu in dropdown menu. if ( dismenu.find( '.current_menu ul > .current-menu-item' ).length ) { dismenu.find( '.current_menu ul > .current-menu-item' ).siblings().removeclass( 'current_menu' ); } }); // auto responsive menu items according to window width. wind.off( 'resize.cz_fix_menu_width' ).on( 'resize.cz_fix_menu_width', function() { $( 'header .cz_menu_default' ).not( '#menu_header_4, .cz-not-three-dots' ).each(function() { var en = $( this ), parent = en.parent(), menu_margin = parsefloat( parent.css( 'margin-left' ) ) + parsefloat( parent.css( 'margin-right' ) ), elements = 0; settimeout(function() { if ( parent.parent().find( '.cz_menu_default' ).length >= 2 ) { return; } // reset en.append( en.find( '.cz-extra-menus > .sub-menu > li' ) ).find( '.cz-extra-menus' ).remove(); // add icon dots if ( ! en.find( '.cz-extra-menus' ).length ) { var submenu_title = $( '.cz_menu_subtitle' ).text() ? ' ' : ''; en.append( '
  •   ' + submenu_title + '
  • '); } var nw = en.find( '.cz-extra-menus' ), nw_ul = nw.find( '> ul' ); nw.hide().prev().addclass( 'cz-last-child' ); // get elements width en.parent().parent().find( '.cz_elm' ).not( parent ).each(function() { elements += $( this ).outerwidth() + parsefloat( $( this ).css( 'margin-left' ) ) + parsefloat( $( this ).css( 'margin-right' ) ); }); // move back to parent nw_ul.find( '> li' ).appendto( en ); // move to hidden menu $( en.find( '> li' ).not( '.cz-extra-menus' ).get().reverse() ).each(function() { var container = en.closest( '.have_center' ).length ? parent.parent().parent().outerwidth() : parent.parent().outerwidth(); if ( ( parent.outerwidth() + menu_margin ) + elements + 25 >= container ) { $( this ).prependto( nw_ul ); nw.show(); } }); }, 250 ); }); }); }, onbeforeshow: function() { var dis = $( this ); // fix lazyload for dropdown megamenu. $( 'img[data-src]', dis ).each(function(i) { var en = $( this ); if ( en.data( 'src' ) ) { settimeout(function () { en.attr( 'src', en.data( 'src' ) ).attr( 'srcset', en.data( 'srcset' ) ).attr( 'sizes', en.data( 'sizes' ) ).removeattr( 'data-sizes data-srcset' ).addclass( 'lazydone' ); }, i * 50 ); } }); if ( dis.hasclass('sub-menu') ) { // check if mega menu is fullwide if ( dis.parent().hasclass( 'cz_megamenu_width_fullwide' ) ) { var megamenu_row = body, megamenu_row_offset = megamenu_row.offset().left, megamenu_row_width = megamenu_row.width(); dis.attr( 'style', dis.attr( 'style' ) + 'width: ' + wind.width() + 'px;left:' + ( megamenu_row_offset - dis.parent().offset().left ) + 'px;margin-right:0;margin-left:0;' ); } // sub-menu styling if ( dis.parent().data( 'sub-menu' ) ) { settimeout(function() { dis.attr( 'style', dis.attr( 'style' ) + dis.parent().data( 'sub-menu' ) ); }, 50 ); } // megamenu if ( dis.parent().hasclass( 'cz_parent_megamenu' ) ) { dis.addclass( 'cz_megamenu_' + $( '> .cz', dis ).length ).find( 'ul' ).addclass( 'cz_megamenu_inner_ul clr' ); } // megamenu full row if ( dis.parent().hasclass( 'cz_megamenu_width_full_row' ) ) { var megamenu_row = $( '.row' ), megamenu_row_offset = megamenu_row.offset().left, megamenu_row_width = megamenu_row.width(); if ( dis.closest( '.cz-extra-menus' ).length ) { megamenu_row_width = megamenu_row_width - ( megamenu_row.width() - dis.parent().offset().left + 10 ); } dis.attr( 'style', dis.attr( 'style' ) + 'width: ' + megamenu_row_width + 'px;left:' + ( megamenu_row_offset - dis.parent().offset().left ) + 'px;' ); } } if ( dis.closest('.fixed_side').length ) { var pwidth = dis.parent().closest( '.sub-menu' ).length ? '.sub-menu' : '.sf-menu', ff_pos = $( '.fixed_side' ).hasclass( 'fixed_side_left' ) ? 'left' : 'right'; dis.css( ff_pos, dis.closest( pwidth ).width() ); } } }); // fullscreen menu $( '.icon_fullscreen_menu' ).codevz( 'fulls_menu', function() { $( this ).off( 'click' ).on( 'click', function() { var sf_f = $( '.fullscreen_menu' ); body.addclass( 'cz_nostickysidebar' ); sf_f.fadein( 'fast' ).on( 'click', function() { $( this ).delay( 500 ).fadeout( 'fast', function() { body.removeclass( 'cz_nostickysidebar' ); $( '.xtra-close-icon' ).addclass( 'hide' ); }); }); if ( sf_f.is(':visible') ) { codevz.showonebyone( $( '> .cz', sf_f ), 150 ); } var h = sf_f.find( '> li' ).height() * ( ( sf_f.find( '> li' ).length - 1 ) / 2 ); sf_f.css( 'padding-top', ( ( wind.height() / 2 ) - h ) ); $( this ).parent().find( '.xtra-close-icon' ).toggleclass( 'hide' ).off().on( 'click', function() { $( this ).addclass( 'hide' ); sf_f.fadeout( 'fast' ); }); }); }); // fullscreen $( 'ul.fullscreen_menu' ).codevz( 'ul_fulls_menu', function() { $( '.cz', this ).on( 'hover', function(e) { e.stoppropagation(); }).off( 'click' ).on( 'click', function(e) { if ( $( e.target ).hasclass( 'cz_indicator' ) ) { $( this ).closest( 'li' ).find( '> ul' ).fadetoggle( 'fast' ); e.preventdefault(); e.stoppropagation(); } }); }); // dropdown menu $( '.icon_dropdown_menu' ).codevz( 'dropdown_menu', function() { $( this ).off( 'click' ).on( 'click', function(e) { var dis = $( this ), pos = dis.position(), nav = dis.parent().find('.sf-menu'), row = $( this ).closest('.row').height(), offset = ( ( inla.outerwidth() + inla.offset().left ) - dis.offset().left ); if ( nav.is(':visible') ) { nav.fadeout( 'fast' ); return; } nav.fadetoggle( 'fast' ); body.on( 'click.cz_idm', function(e) { nav.fadeout( 'fast' ); body.off( 'click.cz_idm' ); }); $( '.cz', nav ).on( 'hover', function(e) { e.stoppropagation(); }).off( 'click' ).on( 'click', function(e) { if ( $( e.target ).hasclass( 'cz_indicator' ) ) { $( this ).closest( 'li' ).find('> ul').fadetoggle( 'fast' ); e.preventdefault(); e.stoppropagation(); } }); e.stoppropagation(); }); }); // open menu horizontal $( '.icon_open_horizontal' ).codevz( 'iohor', function() { $( this ).off( 'click' ).on( 'click', function(e) { var dis = $( this ), pos = dis.position(), nav = dis.parent().find('.sf-menu'), row = $( this ).closest('.row').height(), offset = ( ( inla.outerwidth() + inla.offset().left ) - dis.offset().left ); if ( nav.is(':visible') ) { nav.fadeout( 'fast' ); return; } nav.fadetoggle( 'fast' ); codevz.showonebyone( $( '> .cz', nav ), 100, ( nav.hasclass( 'inview_left' ) ? 'left' : 'right' ) ); body.on( 'click.cz_ioh', function(e) { nav.fadeout( 'fast' ); body.off( 'click.cz_ioh' ); }); e.stoppropagation(); }); }); // mobile menu dismenu.prev( 'i.icon_mobile_offcanvas_menu' ).codevz( 'imom', function() { var en = $( this ); en.removeclass( 'hide' ).on( 'click', function() { if ( ! $( this ).hasclass( 'done' ) ) { $( this ).addclass( 'done' ); codevz.offcanvas( $( this ), 1 ); // add mobile menus indicator if ( indicator.length || indicator2.length ) { $( this ).next( '.sf-menu' ).find( '.sf-with-ul' ).each(function() { $( '.cz_indicator', this ).addclass( ( $( this ).parent().parent().hasclass( 'sf-menu' ) ? indicator : indicator2 ) ); }); } var ul_offcanvas = $( 'ul.offcanvas_area' ); $( '.sf-with-ul, .cz > h6', ul_offcanvas ).on( 'click', function(e) { if ( $( e.target ).hasclass( 'cz_indicator' ) ) { $( this ).next().slidetoggle( 'fast' ); e.preventdefault(); } }); } }); }); }); // fix ipad touch issue on mobile links. body.on( 'touchstart', '.cz a', function( e ) { if ( wind.width() <= 1024 ) { var link = $( this ).attr( 'href' ); if ( link.length > 3 && ! $( e.target ).hasclass( 'cz_indicator' ) ) { window.location = $( this ).attr( 'href' ); } } }); // offcanvas $( '.offcanvas_container > i' ).codevz( 'offcanvas_i', function() { $( this ).on( 'click', function() { if ( ! $( this ).hasclass( 'done' ) ) { $( this ).addclass( 'done' ); codevz.offcanvas( $( this ), 1 ); } }); }); // wpml $( '.cz_language_switcher' ).codevz( 'lang_switcher', function() { var dis = $( this ); $( '.cz_current_language', dis ).prependto( dis ); }); // fix wpml widgets $( '.footer_widget, .widget' ).each(function() { if ( $( '> .clr', this ).html() === '' ) { $( this ).remove(); } }); // hidden fullwidth content $( '.hf_elm_icon' ).codevz( 'hf_elm_icon', function() { $( this ).on( 'click', function( e ) { var dis = $( this ); dis.next( '.hf_elm_area' ).slidetoggle( 'fast' ).css({ width: inla.outerwidth(), left: inla.offset().left, top: dis.offset().top + dis.outerheight() }); e.preventdefault(); e.stoppropagation(); }); body.on( 'click', '.hf_elm_area', function( e ) { e.stoppropagation(); }); body.on( 'click', function() { $( '.hf_elm_area' ).slideup( 'fast' ); }); }); // header on title if ( $( '.header_onthe_cover' ).length ) { codevz.header_on_title(); wind.on( 'resize', function() { codevz.header_on_title(); }); if ( $.fn.imagesloaded ) { $( '.page_header' ).imagesloaded().progress(function( imgload, image ) { codevz.header_on_title(); }); } else { $( '.page_header img' ).on( 'load', function() { settimeout( function() { codevz.header_on_title(); }, 250 ); }); } codevz.heightchanged( '.page_header', function() { codevz.header_on_title(); }); } // iframes auto size $( '.cz_iframe, .single .cz_post_content iframe, .single_con iframe, object, embed' ).not('.wp-embedded-content').codevz( 'cz_iframe', function() { var en = $( this ), newwidth; wind.on( 'resize', function() { en.attr( 'data-aspectratio', en.height() / en.width() ).removeattr( 'height width' ); newwidth = en.parent().width(); en.width( newwidth ).height( newwidth * en.attr( 'data-aspectratio' ) ); }); }); // extra $( '.tagcloud' ).length && $( '.tagcloud' ).addclass( 'clr' ); // input buttons to button tag $( '.form-submit .submit, input.search-submit, .wpcf7-submit' ).codevz( 'button', function() { var en = $( this ); $('').insertafter( en ); en.detach(); }); /* sticky */ settimeout(function() { $( '.header_is_sticky' ).codevz( 'header_sticky', function(n) { var header_sticky = $( this ), header_5 = $( '.header_5' ), lastscrolltop = 0, st, stickynav, sticky_func, scrolltop = header_sticky.offset().top, h_offset = header_sticky.position(), db_height = body.hasclass( 'codevz-is-db' ) ? parsefloat( body.css( 'margin-top' ) ) : 0, smart_sticky = function( scroll ) { if ( header_sticky.hasclass( 'smart_sticky' ) || ( $( '.cz_fixed_footer' ).length && ( $( '.page_content' ).offset().top + $( '.page_content' ).height() <= wind.scrolltop() + header_sticky.height() ) ) ) { st = scroll.scrolltop(); var oheight = header_sticky.outerheight(); if ( st > ( h_offset.top + oheight ) && st > lastscrolltop ) { header_sticky.css( 'transform', 'translatey(-' + ( oheight + 20 ) + 'px)' ); } else if ( st < lastscrolltop ) { header_sticky.css( 'transform', 'none' ); } lastscrolltop = st; } }; if ( header_sticky.hasclass( 'header_5' ) ) { header_5.addclass( 'onsticky' ); wind.on( 'scroll', function(e){ var ph = $( '.page_header' ).height(); if ( wind.scrolltop() >= ph ) { header_5.css( 'transform', 'none' ).css( 'width', inla.width() + 'px' ); } else { header_5.css( 'transform', 'translatey(-' + ( ph + 20 ) + 'px)' ).css( 'width', inla.width() + 'px' ); } smart_sticky( $( this ) ); }); } else if ( header_sticky.length ) { /* add corpse */ if ( ! header_sticky.prev( '.corpse_sticky').length ) { header_sticky.before( '
    ' ); } var scroll_down, scroll_top, new_scrolltop, cz_sticky_h12 = $( '.cz_sticky_h12' ).length, cz_sticky_h13 = $( '.cz_sticky_h13' ).length, cz_sticky_h23 = $( '.cz_sticky_h23' ).length, cz_sticky_h123 = $( '.cz_sticky_h123' ).length; sticky_func = function(e) { if ( header_sticky.hasclass( 'header_4' ) && header_sticky.css( 'display' ) == 'none' ) { return; } new_scrolltop = scrolltop; if ( cz_sticky_h12 && header_sticky.hasclass( 'header_2' ) ) { new_scrolltop = scrolltop+1 - $( '.header_1' ).outerheight(); } else if ( cz_sticky_h13 && header_sticky.hasclass( 'header_3' ) ) { new_scrolltop = scrolltop+1 - $( '.header_1' ).outerheight(); } else if ( cz_sticky_h23 && header_sticky.hasclass( 'header_3' ) ) { new_scrolltop = scrolltop+1 - $( '.header_2' ).outerheight(); } else if ( cz_sticky_h123 ) { if ( header_sticky.hasclass( 'header_2' ) ) { new_scrolltop = scrolltop+1 - $( '.header_1' ).outerheight(); } if ( header_sticky.hasclass( 'header_3' ) ) { new_scrolltop = scrolltop+1 - ( $( '.header_1' ).outerheight() + $( '.header_2' ).outerheight() ); } } scroll_top = wind.scrolltop() + ( abar + db_height ); if ( body.hasclass( 'admin-bar' ) && scroll_top === abar ) { scroll_top = 0; } scroll_down = scroll_top > new_scrolltop; if ( scroll_down && cz_sticky_h12 && header_sticky.hasclass( 'header_2' ) ) { $( '.header_2' ).css( 'margintop', $( '.header_1' ).outerheight() ); } else if ( scroll_down && cz_sticky_h13 && header_sticky.hasclass( 'header_3' ) ) { $( '.header_3' ).css( 'margintop', $( '.header_1' ).outerheight() ); } else if ( scroll_down && cz_sticky_h23 && header_sticky.hasclass( 'header_3' ) ) { $( '.header_3' ).css( 'margintop', $( '.header_2' ).outerheight() ); } else if ( cz_sticky_h123 ) { if ( scroll_down && header_sticky.hasclass( 'header_2' ) ) { $( '.header_2' ).css( 'margintop', $( '.header_1' ).outerheight() ); } if ( scroll_down && header_sticky.hasclass( 'header_3' ) ) { $( '.header_3' ).css( 'margintop', ( $( '.header_1' ).outerheight() + $( '.header_2' ).outerheight() ) ); } } if ( scroll_down ) { header_sticky.addclass( 'onsticky' ).prev( '.corpse_sticky' ).css({ 'height': header_sticky.outerheight() + 'px' }); } else { header_sticky.css( 'margintop', '' ).removeclass( 'onsticky' ).prev( '.corpse_sticky').css({ 'height': 'auto' }); } smart_sticky( $( this ) ); header_sticky.css( 'width', inla.width() + 'px' ); settimeout(function() { header_sticky.css( 'width', inla.width() + 'px' ); }, 300 ); }; wind.off( 'scroll.cz_sticky_' + n ).on( 'scroll.cz_sticky_' + n, sticky_func ); wind.off( 'resize.cz_sticky_' + n ).on( 'resize.cz_sticky_' + n, sticky_func ); } }); }, 1000 ); this.menu_anchor(); }, // header and title position fix. header_on_title: function() { var en = $( '.header_onthe_cover' ), margin = $( '.header_after_cover' ).length ? 'margin-bottom' : 'margin-top'; en.css( margin, - $( '.page_header' ).outerheight() ).css( 'opacity', '1' ); }, // menu anchor. menu_anchor: function( timeout ) { var abar = body.hasclass( 'admin-bar' ) ? 32 : 0, mpage = body.find( '.sf-menu' ), mlink = body.find( "a[href*='#']" ).not( 'a[href*="#top"],.cz_no_anchor,.cz_no_anchor a, .vc_general, .cz_no_anchor a, .cz_lrpr a, .wc-tabs a, .cz_edit_popup_link, .page-numbers a, #cancel-comment-reply-link, .vc_carousel-control, [data-vc-container],.comment-form-rating a,.sm2-bar-ui a' ), sticky = body.find( '.header_is_sticky' ).not( '.smart_sticky, .header_4' ), page = $( 'html, body' ), scrolltoanchor = function( target ) { cleartimeout( timeout ); timeout = settimeout( function() { target = target.replace( '%20', ' ' ); target = ( target.indexof( '#' ) >= 0 ) ? $( target ) : $( '#' + target ); if ( target.length ) { var scrolltop = $( document ).scrolltop(), offset = target.offset().top; if ( scrolltop == 0 ) { $( document ).scrolltop( 1 ); } if ( wind.width() < 768 && body.find( '.header_4.header_is_sticky' ).length ) { sticky = body.find( '.header_4.header_is_sticky' ).not( '.smart_sticky' ); } settimeout( function() { page.animate({ scrolltop: offset - abar - ( sticky.outerheight() || 0 ) }, 1200, 'easeinoutexpo', function() { page.stop(); }); }, scrolltop == 0 ? 450 : 1 ); } }, 50 ); }; // prevent page scroll jumping. var target = window.location.hash; if ( target ) { target = target.replace( '#', '' ).replace( '%20', ' ' ); if ( $( '#' + target ).length ) { // stop scroll. page.animate({scrolltop: 0}, 1); // scroll to anchor. settimeout(function() { scrolltoanchor( target ); }, 1500 ); } } // links. if ( mlink.length ) { mlink.off( 'click.anchor' ).on( 'click.anchor', function(e) { if ( $( this.hash ).length && location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname ) { scrolltoanchor( this.hash ); } else if ( this.hash ) { location = $( this ).attr( 'href' ); } e.preventdefault(); }); var mpageh = mpage.outerheight() + 15, mitems = mpage.find( "a[href*='#']" ), sitems = mitems.map(function(){ var item = $( $( this ).attr( "href" ).replace( /\s+|%20/g, "" ).replace( /^.*\#(.*)$/g, "#$1" ) ); if ( item.length ) { return item; } }); wind.on( 'scroll', function() { cleartimeout( timeout ); timeout = settimeout( function() { var ft = $( this ).scrolltop() + mpageh + ( sticky.outerheight() || 0 ) + abar, cur = sitems.map(function() { if ( $(this).offset().top < ft ) return this; }); cur = cur[cur.length-1]; var id = cur && cur.length ? cur[0].id : ""; if ( id && ! $( '#' + id + '.cz_popup_modal' ).length && $( '#' + id ).length ) { body.trigger( 'click' ); mitems.parent().removeclass( "current_menu" ).end().filter( "[href*='#" + id + "']" ).parent().addclass( "current_menu" ); } else { mitems.parent().removeclass( "current_menu" ); } }, 50 ); }); } }, // height changed = run callback. heightchanged: function( elm, callback ) { var elm = ( typeof elm == 'string' ) ? $( elm ) : elm, lastheight = elm.outerheight(), newheight; // first. callback(); // height detection. (function run() { newheight = elm.outerheight(); if ( lastheight != newheight ) { callback(); lastheight = newheight; } if ( elm.onelementheightchangetimer ) { cleartimeout( elm.onelementheightchangetimer ); } elm.onelementheightchangetimer = settimeout( run, 100 ); })(); }, // check element in viewport. inview: function( e, i ) { var docviewtop = wind.scrolltop(), docviewbottom = docviewtop + wind.height(), elemtop = e.offset().top, elembottom = elemtop + e.height(); i = i ? 800 : 0; return ( ( elemtop <= docviewbottom + i ) && ( elembottom >= docviewtop - i ) ); }, /* * ajax search */ search: function() { var time = 0; // input changes if ( $( '.cz_ajax_search' ).length ) { $( '.cz_ajax_search' ).on('keyup', '[name="s"]', function() { cleartimeout( time ); var form = $( this ).parent(), results = form.next( '.ajax_search_results' ), icon = $( 'button i', form ), org = 'fa ' + icon.data( 'icon' ), ajax = $( '#intro' ).data( 'ajax' ), iloader = 'fa fa-superpowers fa-pulse'; // check input length. if ( $( this ).val().length < 3 ) { $( '.ajax_search_results' ).slideup( 'fast' ); icon.removeclass( iloader ).addclass( org ); return; } else { icon.removeclass( org ).addclass( iloader ); } // send request time = settimeout( function() { $.ajax({ type: "get", url: ajax, datatype: 'html', data: "action=codevz_ajax_search&" + form.serialize(), success: function( data ) { results.html( data ).slidedown( 'fast' ); icon.removeclass( iloader ).addclass( org ); }, error: function( xhr, status, error ) { results.html( '' + error + '' ).slidedown( 'fast' ); icon.removeclass( iloader ).addclass( org ); console.log( xhr, status, error ); } }); }, 500 ); }); } // search icon $( '.search_with_icon' ).codevz( 'search_wi', function() { $( this ).on( 'click', function(e) { e.stoppropagation(); }).on( 'click', '[name="s"]', function() { if ( $( this ).val() ) { $( '.ajax_search_results' ).slidedown( 'fast' ); } }); }); // search dropdown and shop quick cart $( '.search_style_icon_dropdown, .elms_shop_cart' ).codevz( 'dr_search_cart', function() { var en = $( this ); if ( ( wind.width() / 2 ) > ( en.offset().left + 300 ) ) { en.addclass( 'inview_right' ); } }); // search dropdown $( '.search_style_icon_dropdown > i' ).codevz( 'sdr_fullwor', function() { $( this ).on( 'click', function(e) { var dis = $( this ), outer = dis.parent().find('.outer_search'), row_h = dis.closest('.row').height(), clr = dis.closest('.clr'); if ( outer.is( ':visible' ) ) { outer.fadeout( 'fast' ); } else { outer.fadein( 'fast' ).find('input').focus(); } }); }); // search fullscreen $( '.search_style_icon_full > i' ).codevz( 'ssifi', function() { $( this ).on( 'click', function() { //$( this ).closest( '.header_1,.header_2,.header_3' ).css( 'z-index', '9999' ); $( this ).parent().find( '.outer_search' ).fadein( 'fast' ).find('input').focus(); wind.off( 'resize.cz_search_full' ).on( 'resize.cz_search_full', function() { var w = wind.width(), h = wind.height(), s = $( this ).find('.outer_search .search'); s.css({ 'top': h / 4 - s.height() / 2, 'left': w / 2 - s.width() / 2 }); }); $( this ).parent().find( '.xtra-close-icon' ).toggleclass( 'hide' ).off().on( 'click', function() { $( this ).addclass( 'hide' ).parent().find('.outer_search').fadeout( 'fast' ); }); }); }); $( 'body, .outer_search' ).on( 'click', function(e) { if ( $( e.target ).closest('.outer_search .search').length ) { return; } $('.ajax_search_results').fadeout( 'fast' ); $( '.search_style_icon_dropdown, .search_style_icon_full' ).find('.outer_search').fadeout( 'fast' ); $( '.search_style_icon_full .xtra-close-icon' ).addclass( 'hide' ); }); }, /* * loading */ loading: function() { var p = $( '.pageloader' ), pp = p.find( '.pageloader_percentage' ), p_done = function() { if ( ! $( '.pageloader_click' ).length ) { p.addclass( 'pageloader_done' ); settimeout(function() { p.addclass( 'pageloader_done_all' ); }, 1200 ); } }; if ( p.length ) { // percentage type. if ( pp.length ) { var images = $( '.inner_layout img' ), imgcount = images.length, process_done = 0, done, num; images.imagesloaded().progress(function( imgload, image ) { if ( imgload.progressedcount === imgcount && process_done ) { settimeout(function() { pp.html( '100%' ); p_done(); }, 1000 ); } else { num = ( ( imgload.progressedcount / imgcount ) * 100 ).tofixed(); settimeout(function() { pp.html( num + '%' ); }, num * 15 ); if ( ( imgload.progressedcount + 1 ) == imgcount ) { process_done = 1; } } }); } else { wind.on( 'load.p_done', function() { p_done(); }); } // custom time settimeout( function(){ p_done(); }, 4000 ); // loading on click if ( ! pp.length ) { $( 'a[href*="//"]' ).not( 'a[href*="#"],a[href*="?"],.cz_lightbox,.cz_a_lightbox a,a[href*="youtube.com/watch?"],a[href*="youtu.be/watch?"],a[href*="vimeo.com/"],a[href*=".jpg"],.product a,.esgbox,.jg-entry,.prettyphoto,.cz_grid_title,.ngg-fancybox,.fancybox,.lightbox,a[href*=".jpeg"],a[href*=".png"],a[href*=".gif"],.cz_language_switcher,.add_to_cart_button,.cart_list .remove,a[target="_blank"],[href^="#"],[href*="wp-login"],[id^="wpadminb"] a,[href*="wp-admin"],[data-rel^="prettyphoto"],a[href$=".jpg"],a[href$=".jpeg"],a[href$=".png"],a[href$=".gif"],a[href$=".mp3"],a[href$=".zip"],a[href$=".rar"],a[href$=".mov"],a[href$=".mp4"],a[href$=".pdf"],a[href$=".mpeg"],.comment-reply-link' ).on( 'click', function(e) { if ( ! $( this ).hasclass( 'sf-with-ul' ) && $( e.target ).prop( 'tagname' ) != 'i' ) { p.addclass( 'pageloader_click' ).removeclass( 'pageloader_done pageloader_done_all' ); } }); } } }, /* * offcanvas area */ offcanvas: function( selector, click ) { var parent = selector.parent(), area = selector.next(), layout = $('#layout'), overlay = '.cz_overlay', isright, i, fixed_side = 0, close; if ( area.length ) { var area = area.clone(), isright = area.hasclass( 'inview_right' ), new_class = area.hasclass('sf-menu') ? 'sf-menu offcanvas_area' : 'offcanvas_area offcanvas_original'; body.prepend( area.removeclass().addclass( 'sidebar_offcanvas_area' ).addclass( new_class + ( isright ? ' inview_right' : ' inview_left' ) ) ); var area_w = area.width() + 80; $( '.sub-menu', area ).hide(); } else { return; } // open icon selector.on( 'click', function(e) { if ( area.hasclass( 'active_offcanvas' ) && ! body.hasclass( 'offcanvas_doing' ) ) { body.trigger( 'click' ); } else { // close icon area.before( '' ); close = area.prev( '.offcanvas-close' ); close.on( 'click', function(e) { if ( click ) { body.removeclass( 'active_offcanvas' ); area.removeclass( 'active_offcanvas' ); $( overlay ).fadeout(); settimeout(function() { $( '.offcanvas-close' ).detach(); wind.trigger( 'resize' ); }, 500 ); click = 0; } else { body.trigger( 'click' ); } }); close.css( ( isright ? 'right' : 'left' ), area.outerwidth() + fixed_side ); body.addclass( 'offcanvas_doing active_offcanvas' + ( isright ? ' cz_offcanvas_right' : ' cz_offcanvas_left' ) ); area.addclass( 'active_offcanvas' ); if ( wind.width() > 768 ) { if ( ( $( '.fixed_side_left' ).length && $( '.cz_offcanvas_left' ).length ) || $( '.fixed_side_right' ).length && $( '.cz_offcanvas_right' ).length ) { if ( ! $( '#cz_ofs' ).length ) { $( 'head' ).append( '' ); } fixed_side = $( '.fixed_side' ).width(); $( '#cz_ofs' ).html( '.active_offcanvas .offcanvas_area.active_offcanvas{transform:translatex(' + ( isright ? '-' : '' ) + fixed_side + 'px)}' ); } } $( overlay ).fadein(); settimeout(function() { body.removeclass( 'offcanvas_doing' ); }, 1500 ); } e.stoppropagation(); }); // first time if ( click ) { selector.trigger( 'click' ); } // prevent close on open icon area.on( 'click', function(e) { e.stoppropagation(); }); // recall anchors this.menu_anchor(); // click on body body.on( 'click.offcanvas', function(e) { if ( $( '.active_offcanvas' ).length && ! body.hasclass( 'offcanvas_doing' ) ) { body.removeclass( 'active_offcanvas' ); area.removeclass( 'active_offcanvas' ); $( overlay ).fadeout(); settimeout(function() { $( '.offcanvas-close' ).detach(); wind.trigger( 'resize' ); }, 500 ); } settimeout(function() { if ( ! $( overlay ).is( ':visible' ) && $( '.active_offcanvas' ).length ) { $( '.offcanvas-close' ).trigger( 'click' ); } }, 500 ); }); // close mobile on window resize. wind.on( 'resize', function(e) { if( $( '#menu_header_4' ).hasclass( 'active_offcanvas' ) && wind.width() > 768 ) { $( '#menu_header_4' ).prev( 'i' ).trigger( 'click' ); } }); // reload necessary scripts. if( ! area.hasclass( 'xtra-reload-js' ) ) { // reinit codevz plus. codevz_plus.init(); // fix lazyload images. area.find( 'img[data-src]' ).each(function() { var en = $( this ); if( en.data( 'src' ) ) { en.attr( 'src', en.data( 'src' ) ).attr( 'srcset', en.data( 'srcset' ) ).attr( 'sizes', en.data( 'sizes' ) ).removeattr( 'data-sizes data-srcset' ).addclass( 'lazydone' ); } }); // reinit contact form 7. if( typeof wpcf7 != 'undefined' && area.find( '.wpcf7' ).length ) { area.find( 'div.wpcf7 > form' ).each( function() { var $form = $( this ); wpcf7.initform( $form ); if( wpcf7.cached ) { wpcf7.refill( $form ); } } ); } // reinit facebook. settimeout( function(){ if ( window.fb ) { fb.xfbml.parse(); } }, 2000 ); area.addclass( 'xtra-reload-js' ); } }, /* * show one by one with delay */ showonebyone: function( e, s, d ) { var e = ( d == 'left' ) ? $( e.get().reverse() ) : e, b = ( d == 'left' ) ? {opacity:0,left:10} : {opacity: 0,left:-10}; e.css( b ).each(function( i ) { $( this ).delay( s * i ).animate({opacity:1,left:0}); }); }, }; })(jquery); jquery(document).ready(function($) { codevz.init(); });