pixedelic

mood.js

Feb 2nd, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery.fn.prettyPhoto = function() {
  2.     return false;
  3. };
  4.  
  5. (function($){
  6.  
  7. "use strict";
  8.  
  9. $.expr[':'].notparents = function(a,i,m){
  10.     return $(a).parents(m[3]).length < 1;
  11. };
  12.  
  13. $.expr[':'].parents = function(a,i,m){
  14.     return $(a).parents(m[3]).length == 1;
  15. };
  16.  
  17. var MOOD = window.MOOD || {};
  18.  
  19. MOOD.guidGenerator = function() {
  20.     var S4 = function() {
  21.        return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
  22.     };
  23.     return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
  24. };
  25.  
  26. MOOD.isElementInViewport = function(el, off) {
  27.  
  28.     if (typeof jQuery === "function" && el instanceof jQuery) {
  29.         el = el[0];
  30.     }
  31.  
  32.     off = typeof off=='undefined' ? 50 : off;
  33.  
  34.     var rect = el.getBoundingClientRect();
  35.  
  36.     return (
  37.         (
  38.             ( rect.top >= 0 && (rect.top + off) <= (window.innerHeight || document.documentElement.clientHeight) ) ||
  39.             ( rect.bottom >= off && (rect.bottom) <= (window.innerHeight || document.documentElement.clientHeight) ) ||
  40.             ( rect.top <= 0 && (rect.bottom) >= (window.innerHeight || document.documentElement.clientHeight) )
  41.         )
  42.     );
  43. };
  44.  
  45. MOOD.isBelowViewport = function(el, off) {
  46.  
  47.     if (typeof jQuery === "function" && el instanceof jQuery) {
  48.         el = el[0];
  49.     }
  50.  
  51.     off = typeof off=='undefined' ? 0 : off;
  52.  
  53.     var rect = el.getBoundingClientRect();
  54.  
  55.     //console.log(rect.bottom, off, window.innerHeight, document.documentElement.clientHeight);
  56.  
  57.     return ( ( rect.bottom + off ) <= (window.innerHeight || document.documentElement.clientHeight) );
  58. };
  59.  
  60. MOOD.smoothScroll = function() {
  61.     var $body = $('body'),
  62.         $html = $('html'),
  63.         stopWP = false;
  64.  
  65.     if(window.location.hash) {
  66.         stopWP = true;
  67.         setTimeout(function() {
  68.             window.scrollTo(0, 0);
  69.         }, 1);
  70.         $(window).on('load', function(){
  71.             $body.add($html).animate({scrollTop: 0}, 1);
  72.             setTimeout(function(){
  73.                 var target = $(window.location.hash),
  74.                     start = parseFloat($(window).scrollTop());
  75.                 target = target.length && target || $('[name="' + window.location.hash.slice(1) +'"]');
  76.                 if (target.length) {
  77.                     var targetOffset = target.offset().top,
  78.                         time = Math.abs(targetOffset-start) < 100 ? 100 : Math.abs(targetOffset-start);
  79.                     time = time > 1000 ? 1000 : time;
  80.                     $body.add($html).animate({scrollTop: targetOffset}, time, 'easeInOutQuad', function(){
  81.                         stopWP = false;
  82.                     });
  83.                 }
  84.             }, 500);
  85.         });
  86.     }
  87.  
  88.     var current_href = document.location.href.replace(window.location.hash,''),
  89.         $navDots = $( '<div class="mood-vert-nav-dots" />' );
  90.  
  91.     if ( $('.mood-vert-nav-ph').length ) {
  92.         $body.append( $navDots );
  93.     }
  94.  
  95.     var waypoints = $('.mood-vert-nav-ph').each(function(){
  96.         var $section = $(this),
  97.             id = $section.attr('id'),
  98.             label = $section.attr('data-label'),
  99.             firstID = $('.mood-vert-nav-ph').eq(0).attr('id');
  100.  
  101.         if ( id == firstID )
  102.             id = 'page_holder';
  103.  
  104.         $navDots.append('<div class="mood-vert-nav-dot" data-target="' + id + '"><a class="pixscroll" href="#' + id + '"><span class="mood-vert-nav-tooltip">' + label + '</span></a></div>');
  105.  
  106.         $section.waypoint(function(direction) {
  107.             if ( direction === 'down' ) {
  108.                 if ( !stopWP )
  109.                     window.history.replaceState( false, false, current_href + '#' + id );
  110.                 $('.mood-vert-nav-dot').removeClass('selected');
  111.                 $('.mood-vert-nav-dot[data-target="' + id + '"]').addClass('selected');
  112.             }
  113.         }, {
  114.             offset: '1'
  115.         });
  116.  
  117.         $section.waypoint(function(direction) {
  118.             if ( direction === 'up' ) {
  119.                 if ( !stopWP )
  120.                     window.history.replaceState( false, false, current_href + '#' + id );
  121.                 $('.mood-vert-nav-dot').removeClass('selected');
  122.                 $('.mood-vert-nav-dot[data-target="' + id + '"]').addClass('selected');
  123.             }
  124.         }, {
  125.             offset: '-1'
  126.         });
  127.  
  128.     });
  129.  
  130.     var waypoints2 = $('#nav-wrap a[href^="#"]').each(function(){
  131.         var $link = $(this),
  132.             target = $link.attr('href'),
  133.             id = target.substr(0,target.indexOf('#'));
  134.  
  135.         if ( ! $('#nav-wrap li.current-menu-item').length && $('#nav-wrap a[href^="#"]').length > 1 && target != '#' )
  136.             $('#nav-wrap li').has('a').eq(0).addClass('current-menu-item');
  137.  
  138.         if ( target != '#' ) {
  139.  
  140.             $('.vc_row' + target).waypoint(function(direction) {
  141.                 if ( direction === 'down' ) {
  142.                     if ( !stopWP )
  143.                         window.history.replaceState( false, false, current_href + target );
  144.                     $('#nav-wrap li').removeClass('current-menu-item');
  145.                     $link.parents('li').eq(0).addClass('current-menu-item');
  146.                 }
  147.             }, {
  148.                 offset: '1'
  149.             });
  150.  
  151.             $('.vc_row' + target).waypoint(function(direction) {
  152.                 if ( direction === 'up' ) {
  153.                     if ( !stopWP )
  154.                         window.history.replaceState( false, false, current_href + target );
  155.                     $('#nav-wrap li').removeClass('current-menu-item');
  156.                     $link.parents('li').eq(0).addClass('current-menu-item');
  157.                 }
  158.             }, {
  159.                 offset: '-1'
  160.             });
  161.  
  162.         }
  163.  
  164.     });
  165.  
  166.     if( !window.location.hash )
  167.         $('.mood-vert-nav-dots .mood-vert-nav-dot').eq(0).addClass('selected');
  168.  
  169.     $('a.pixscroll[href^="#"], .pixscroll > a[href^="#"], #nav-wrap a[href^="#"], .mood-button-wrap a[href^="#"], .woocommerce-review-link[href^="#"]').on('click',function(e) {
  170.         e.preventDefault();
  171.         var $el = $(this),
  172.         runFunc = function(){
  173.             $el.each(function(){
  174.                 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
  175.                     var target = $(this.hash),
  176.                         start = parseFloat($(window).scrollTop());
  177.                     target = target.length && target || $('[name=' + this.hash.slice(1) +']');
  178.                     if (target.length) {
  179.                         var targetOffset = target.offset().top,
  180.                             time = Math.abs(targetOffset-start) < 100 ? 100 : Math.abs(targetOffset-start);
  181.                         time = time > 1000 ? 1000 : time;
  182.                         $body.add($html).stop(true, false).animate({scrollTop: targetOffset}, time, 'easeOutQuad');
  183.                     }
  184.                 }
  185.             });
  186.         };
  187.         if ( $el.attr('href').slice(-1)!='#' ) {
  188.             if ( $el.hasClass('woocommerce-review-link') ) {
  189.                 $('a[href="#tab-reviews"]').click();
  190.             }
  191.             var set = setTimeout(runFunc, 10);
  192.         }
  193.     });
  194.  
  195.     $(window).on('isotoped', function(){
  196.         Waypoint.refreshAll();
  197.     });
  198.  
  199.     $('.vc-row-mood-scroll-down').on('click',function(e) {
  200.         e.preventDefault();
  201.         var scrollTop = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop,
  202.             winH = $(window).height() - 100;
  203.         $body.add($html).stop(true, false).animate({scrollTop: ( scrollTop + winH )}, 750, 'easeOutQuad');
  204.     });
  205.  
  206.     $('a[href="#"]').on('click',function(e) {
  207.         e.preventDefault();
  208.     });
  209.  
  210. };
  211.  
  212. MOOD.mainNavigation = function() {
  213.  
  214.     var $elements = $('#nav-wrap nav#site-navigation > div > ul > li, #header-cart, .wpml_custom_language_top_selector');
  215.     if ( $('body').hasClass('mood-overlay-menu') )
  216.         $elements = $('#header-cart, .wpml_custom_language_top_selector');
  217.  
  218.     var checkPosition = function(el, el2, dir, off) {
  219.  
  220.         dir = typeof dir=='undefined' || dir==='' ? 'hor' : dir;
  221.         off = typeof off=='undefined' || off==='' ? 40 : parseFloat(off);
  222.  
  223.         var rect = el[0].getBoundingClientRect(),
  224.             rect2;
  225.  
  226.         if ( dir == 'hor' )
  227.             rect2 = el2[0].getBoundingClientRect();
  228.  
  229.         if ( dir == 'hor' && ( rect.right + off ) >= rect2.right ) {
  230.             return parseFloat( ( rect.right + off ) - ( rect2.right ) ) * -1;
  231.         } else if ( dir == 'ver' && ( rect.bottom + off*2 ) >= window.innerHeight ) {
  232.             return parseFloat( ( rect.bottom + off*2 ) - ( window.innerHeight ) ) * -1;
  233.         } else if ( dir == 'hor' && ( rect.left - off ) <= rect2.left ) {
  234.             return parseFloat( ( rect.left - off ) - rect2.left ) * -1;
  235.         }
  236.  
  237.     };
  238.  
  239.     $elements.find('a').on('touchstart', function(e){
  240.         var $aThis = $(this);
  241.  
  242.         if ( $aThis.hasClass('touch_active') ) {
  243.             $aThis.removeClass('touch_active');
  244.         } else {
  245.             if ( !$('body').hasClass('mobile-view') ) {
  246.                 e.preventDefault();
  247.                 $aThis.addClass('touch_active');
  248.             }
  249.         }
  250.     });
  251.  
  252.     $elements.find('ul, > div').each(function(){
  253.         var $el = $(this),
  254.             $li = $el.parents('li').eq(0),
  255.             $header = $('#header-wrap'),
  256.             $container = $('#container');
  257.  
  258.         var moveSubmenu = function(){
  259.  
  260.             if ( ! $('body').hasClass('header-layout-side') ) {
  261.                 if ( $li.hasClass('wide_width') ) {
  262.                     var header_w = $header.width();
  263.                     $el.css({
  264.                         width: header_w
  265.                     });
  266.                 }
  267.  
  268.                 if ( $el.is('ul') )
  269.                     $el.css({ marginLeft : 0 });
  270.                 else
  271.                     $el.css({ left : 0 });
  272.  
  273.                 var move = checkPosition($el, $header);
  274.  
  275.                 if ( move !== 0 && ( $el.hasClass('depth-0') || $el.is('div') || $elements.is('.wpml_custom_language_top_selector') ) ) {
  276.                     if ( $el.is('ul') ) {
  277.                         $el.css({ marginLeft : move });
  278.                     } else {
  279.                         $el.css({ left : move });
  280.                     }
  281.                 }
  282.  
  283.                 if ( move < 0 ) {
  284.                     $el.addClass('reverse');
  285.                 }
  286.             } else {
  287.                 if ( $li.hasClass('wide_width') ) {
  288.                     var cont_w = $container.width();
  289.                     $el.css({
  290.                         width: cont_w
  291.                     });
  292.                 }
  293.  
  294.                 $el.css({ marginTop : 0 });
  295.  
  296.                 var move = checkPosition($el, $(window), 'ver', 20);
  297.  
  298.                 if ( move !== 0 ) {
  299.                     $el.css({
  300.                         marginTop: move
  301.                     });
  302.                 }
  303.  
  304.             }
  305.         };
  306.  
  307.         moveSubmenu();
  308.  
  309.         var setCheckPosition;
  310.         $(window).on( 'resize load', function(){
  311.             clearTimeout(setCheckPosition);
  312.             setCheckPosition = setTimeout( moveSubmenu, 150 );
  313.         });
  314.  
  315.         $li.off('hover')
  316.             .on('hover', function(){
  317.                 moveSubmenu();
  318.             });
  319.  
  320.     });
  321.  
  322.     if ( ! $('body').hasClass('mood-overlay-menu') ) {
  323.         $('#nav-wrap nav#site-navigation > div > ul > li.pix_megamenu').each(function(){
  324.             var $el = $(this),
  325.                 el_W = $el.outerWidth(),
  326.                 $child = $el.find('> ul, > div:not(.mega_clear)'),
  327.                 off,
  328.                 offLayout,
  329.                 setResizeMegaMenu,
  330.             resizeMegaMenu = function(){
  331.  
  332.                 var wDiv = 0, wTemp = 0, colDiv = 0, colTemp = 0;
  333.                 $el.find('> div').attr('data-cols', 0).each(function(){
  334.  
  335.                     if ( !$el.hasClass('wide_width') ) {
  336.                         $(this).css({width:'auto'});
  337.                     }
  338.  
  339.                     $('> div > ul, > div.mega_clear', this).each(function(){
  340.                         if ($(this).hasClass('mega_clear')) {
  341.                             if ( wTemp < wDiv ) {
  342.                                 wTemp = wDiv;
  343.                             }
  344.                             wDiv = 0;
  345.                         } else {
  346.                             var wDivEach = $(this).outerWidth();
  347.                             wDiv = wDiv + wDivEach;
  348.                         }
  349.                     });
  350.                 });
  351.                 if ( wTemp < wDiv ) {
  352.                     wTemp = wDiv;
  353.                 }
  354.  
  355.                 if ( !$el.hasClass('wide_width') ) {
  356.                     $el.find('> div').width(wTemp);
  357.                 }
  358.                    
  359.                 $el.attr('data-width', wTemp);
  360.  
  361.                 $el.find('> div').each(function(){
  362.                     $('> div > ul, > div.mega_clear', this).each(function(){
  363.                         if ($(this).hasClass('mega_clear')) {
  364.                             if ( colTemp < colDiv ) {
  365.                                 colTemp = colDiv;
  366.                             }
  367.                             colDiv = 0;
  368.                         } else {
  369.                             var colDivEach = parseFloat($(this).attr('data-col'));
  370.                             colDiv = colDiv + colDivEach;
  371.                         }
  372.                     });
  373.                 });
  374.                 if ( colTemp < colDiv ) {
  375.                     colTemp = colDiv;
  376.                 }
  377.                 $el.find('> div').attr('data-cols', colTemp);
  378.  
  379.                 el_W = $el.outerWidth();
  380.  
  381.             };
  382.  
  383.             resizeMegaMenu();
  384.             $(window).on('pix_megamenu resize', function(){
  385.                 clearTimeout(setResizeMegaMenu);
  386.                 setResizeMegaMenu = setTimeout( resizeMegaMenu, 30 );
  387.             });
  388.  
  389.         });
  390.  
  391.     }
  392.  
  393. };
  394.  
  395. MOOD.overlayMenu = function() {
  396.     if ( !$('body').hasClass('mood-overlay-menu') )
  397.         return false;
  398.  
  399.     var $burger = $('#hamburger-menu, #hamburger-menu-overlay'),
  400.         $page = $('#page'),
  401.         $overlay = $('#overlay-wrap'),
  402.         $menu = $('#nav-wrap nav#site-navigation > div').not('#header-cart'),
  403.         $arrow_icon = $('svg[data-id="left-7-icon"]'),
  404.         $icons = $('#header-icons'),
  405.         respW = typeof mood_mobile_menu_width !== 'undefined' && mood_mobile_menu_width !== '' ? mood_mobile_menu_width : 800,
  406.         winW,
  407.         check = 0,
  408.         $titles = $('.pix_mega_title', $menu);
  409.  
  410.     $('> ul > li', $menu).each(function(){
  411.         var $liMega = $(this),
  412.             $ulMega = $('<ul class="ul-mega" />');
  413.  
  414.         if ( $liMega.has('> ul[data-col]') ) {
  415.  
  416.             $liMega.append( $ulMega );
  417.  
  418.             $('ul[data-col]', this).each(function(){
  419.                 $('> li', this).appendTo( $ulMega );
  420.                 $(this).remove();
  421.             });
  422.  
  423.         }
  424.  
  425.     });
  426.  
  427.     $titles.each(function(){
  428.         var $title = $(this),
  429.             $li = $title.parents('li').eq(0),
  430.             $until = $('li').has('.pix_mega_title'),
  431.             $ul = $('<ul class="ul-mega-children" />');
  432.  
  433.         $li.nextUntil($until, 'li').each(function() {
  434.             $ul.append($(this));
  435.         });
  436.  
  437.         if ( $('li', $ul).length ) {
  438.             $li.append( $ul );
  439.         }
  440.     });
  441.  
  442.     var checkRespoMenu = function(){
  443.         winW = $(window).width();
  444.  
  445.         if ( $burger.hasClass('clicked') )
  446.             $burger.removeClass('clicked');
  447.  
  448.         if ( $overlay.hasClass('open') )
  449.             $overlay.removeClass('open');
  450.  
  451.         if ( winW <= respW ) {
  452.  
  453.             $('#menu-placeholder').before($menu);
  454.             $icons.replaceWith( '<div id="header-icons">' + $icons.html() + '</div>' );
  455.             $('#icons-placeholder').before($icons);
  456.  
  457.         } else if ( winW > respW  ) {
  458.  
  459.             if ( !$('#menu-placeholder').length )
  460.                 $menu.after($('<span id="menu-placeholder" />'));
  461.  
  462.             if ( !$('#icons-placeholder').length )
  463.                 $icons.after($('<span id="icons-placeholder" />'));
  464.  
  465.             $menu.find('li').has('.pixmenu-wrap-level').each(function(){
  466.                 $(this)
  467.                     .find('.mega_clear').remove().end()
  468.                     .find('.pixmenu-wrap-level > div').unwrap().end()
  469.                     .find('.pixmenu-wrap-row > ul').unwrap();
  470.             });
  471.  
  472.             $menu.find('li').has('ul').each(function(){
  473.  
  474.                 if ( check == 0 ) {
  475.                     var $clone_arrow = $arrow_icon.clone();
  476.  
  477.                     $(this).append('<span class="sub-overlay-back-arrow" />')
  478.                         .find('.sub-overlay-back-arrow').append( $clone_arrow );
  479.                 }
  480.  
  481.             });
  482.  
  483.             $menu.addClass('appended-menu');
  484.             $overlay.append( $menu );
  485.  
  486.             if ( !$('> ul li#header-icons', $menu).length )
  487.                 $menu.find('> ul').append( $icons );
  488.  
  489.             $icons.replaceWith( '<li id="header-icons">' + $icons.html() + '</li>' );
  490.         }
  491.  
  492.         check = 1;
  493.  
  494.     };
  495.  
  496.     checkRespoMenu();
  497.  
  498.     var setCheckMenu;
  499.     $(window).on( 'resize mood-mobile-resize', function(){
  500.         clearTimeout(setCheckMenu);
  501.         setCheckMenu = setTimeout( checkRespoMenu, 30 );
  502.     });
  503.  
  504.     $burger.on('click', function(e){
  505.  
  506.         if ( winW > respW ) {
  507.             e.preventDefault();
  508.             $burger.toggleClass('clicked');
  509.  
  510.             if ( $burger.hasClass('clicked') ) {
  511.  
  512.                 $('html, body').addClass('overflow_hidden');
  513.  
  514.                 $overlay.addClass('open').show().velocity("stop").velocity({
  515.                     opacity: 1,
  516.                 }, {
  517.                     duration: 500,
  518.                     delay: 250,
  519.                     easing: [ 0.140, 0.560, 0.710, 0.975 ]
  520.                 });
  521.  
  522.                 $menu.find('> ul > li:not(#header-icons), #header-icons a').velocity("stop").velocity('transition.slideUpIn', {
  523.                     delay: 350,
  524.                     duration: 500,
  525.                     stagger: 150,
  526.                     easing: [ 0.140, 0.560, 0.710, 0.975 ]
  527.                 });
  528.  
  529.             } else {
  530.  
  531.                 $('html, body').removeClass('overflow_hidden');
  532.  
  533.                 $menu.find('> ul > li:not(#header-icons), #header-icons a').velocity("stop").velocity('transition.slideUpOut', {
  534.                     duration: 250,
  535.                     stagger: 50,
  536.                     easing: [ 0.140, 0.560, 0.710, 0.975 ],
  537.                     complete: function(){
  538.                         $menu.find('> ul > li:not(#header-icons), #header-icons a').show().css({
  539.                             opacity: 0
  540.                         });
  541.                     }
  542.                 });
  543.  
  544.                 $overlay.velocity("stop").velocity({
  545.                     delay: 750,
  546.                     opacity: 0,
  547.                 }, {
  548.                     duration: 500,
  549.                     easing: [ 0.140, 0.560, 0.710, 0.975 ],
  550.                     complete: function(){
  551.                         $overlay.removeClass('open').hide();
  552.                         $('.sub-revealed', $menu).removeClass('sub-revealed');
  553.                         $('.sub-overlay-back-arrow', $menu).hide();
  554.                         $('li > a, li > .pix-menu-no-link', $menu).show().css({
  555.                             opacity: 1
  556.                         });
  557.                         $('li > ul, li > ul > li', $menu).hide();
  558.                     }
  559.                 });
  560.  
  561.             }
  562.  
  563.             $('li', $menu).has('> ul').each(function(){
  564.                 var $li = $(this),
  565.                     $a = $('> a, > .pix_mega_title, > .pix-menu-no-link', $li),
  566.                     $parent = $li.parents('li').eq(0),
  567.                     $parentUl = $li.parents('ul').eq(0),
  568.                     $arrow = $('> .sub-overlay-back-arrow', $li),
  569.                     $all = $li.siblings().not($icons);
  570.  
  571.                 $a.off('click')
  572.                     .on('click', function(e){
  573.                     var $this = $(this);
  574.  
  575.                     if ( ! $li.hasClass('sub-revealed') ) {
  576.                         e.preventDefault();
  577.  
  578.                         $('> .sub-overlay-back-arrow', $parent).velocity("stop").velocity('transition.slideLeftOut', {
  579.                             duration: 300,
  580.                             stagger: 50,
  581.                             easing: [ 0.140, 0.560, 0.710, 0.975 ]
  582.                         });
  583.  
  584.                         $li.add($all).add($parent).find(' > a, > .pix-menu-no-link').add('#header-icons a', $parentUl).velocity("stop").velocity('transition.slideUpOut', {
  585.                             duration: 300,
  586.                             stagger: 50,
  587.                             easing: [ 0.140, 0.560, 0.710, 0.975 ],
  588.                             complete: function(){
  589.  
  590.                                 $li.addClass('sub-revealed');
  591.                                 $parent.removeClass('sub-revealed');
  592.  
  593.                                 $li.find('> ul').show().find('> li').add($this).show().velocity('transition.slideUpIn', {
  594.                                     duration: 300,
  595.                                     stagger: 50,
  596.                                     easing: [ 0.140, 0.560, 0.710, 0.975 ],
  597.                                     complete: function(){
  598.                                         $arrow.velocity('transition.slideRightIn', {
  599.                                             duration: 300,
  600.                                             stagger: 50,
  601.                                             easing: [ 0.140, 0.560, 0.710, 0.975 ]
  602.                                         });
  603.                                     }
  604.                                 });
  605.                             }
  606.                         });
  607.                     }
  608.                 });
  609.  
  610.                 $arrow.off('click')
  611.                     .on('click', function(e){
  612.  
  613.                     $arrow.velocity("stop").velocity('transition.slideLeftOut', {
  614.                         duration: 300,
  615.                         stagger: 50,
  616.                         easing: [ 0.140, 0.560, 0.710, 0.975 ],
  617.                         complete: function(){
  618.                             $li.find('> ul > li').add($a).velocity("stop").velocity('transition.slideUpOut', {
  619.                                 duration: 300,
  620.                                 stagger: 50,
  621.                                 easing: [ 0.140, 0.560, 0.710, 0.975 ],
  622.                                 complete: function(){
  623.  
  624.                                     $li.removeClass('sub-revealed');
  625.                                     $parent.addClass('sub-revealed');
  626.  
  627.                                     $li.add($all).find(' > a, > .pix-menu-no-link').add('> a', $parent).add('#header-icons a', $parentUl).show().velocity("stop").velocity('transition.slideUpIn', {
  628.                                         duration: 300,
  629.                                         stagger: 50,
  630.                                         easing: [ 0.140, 0.560, 0.710, 0.975 ],
  631.                                         complete: function(){
  632.                                             $('> .sub-overlay-back-arrow', $parent).velocity("stop").velocity('transition.slideRightIn', {
  633.                                                 duration: 300,
  634.                                                 stagger: 50,
  635.                                                 easing: [ 0.140, 0.560, 0.710, 0.975 ]
  636.                                             });
  637.                                         }
  638.                                     });
  639.                                 }
  640.                             });
  641.                         }
  642.                     });
  643.                 });
  644.             });
  645.         }
  646.  
  647.     });
  648. };
  649.  
  650. MOOD.searchOverlay = function(){
  651.     var respW = typeof mood_mobile_menu_width !== 'undefined' && mood_mobile_menu_width !== '' ? mood_mobile_menu_width : 800,
  652.         $win = $(window),
  653.         $page = $('#page'),
  654.         $search_icon = $('#top-search-icon'),
  655.         $overlay = $('#top-search-form'),
  656.         $overlay_menu = $('#overlay-wrap'),
  657.         $input = $('input[type="search"]', $overlay),
  658.         $close = $('#close-search-form', $overlay),
  659.         $results,
  660.         setResize,
  661.         $search_holder = $('<div id="top-search-holder" />').hide(),
  662.         $live_search = $('.searchwp-live-search-results'),
  663.         $form = $('#top-search-form').after($search_holder);
  664.  
  665.     $('.form-wrap', $form).append($live_search);
  666.  
  667.     var setResultsH = function(){
  668.         if ( !$('.searchwp-live-search-results').length )
  669.             return false;
  670.  
  671.         var winH = $win.height(),
  672.             $results = $('.searchwp-live-search-results'),
  673.             topResults = $input.offset().top,
  674.             topResultsH = $input.outerHeight(),
  675.             resultsH = winH - ( topResults + topResultsH );
  676.  
  677.         $results.css({
  678.             height: resultsH
  679.         });
  680.     };
  681.  
  682.     $search_icon.on('click', function(e){
  683.  
  684.         e.preventDefault();
  685.  
  686.         if ( $win.width() > mood_mobile_menu_width ) {
  687.  
  688.             $('html, body').addClass('overflow_hidden');
  689.  
  690.             if ( $('body').hasClass('mood-overlay-menu') && $overlay_menu.hasClass('open') ) {
  691.                 $overlay_menu.velocity("stop").velocity({
  692.                     opacity: 0
  693.                 }, {
  694.                     duration: 550,
  695.                     delay: 250,
  696.                     easing: [ 0.140, 0.560, 0.710, 0.975 ]
  697.                 });
  698.             }
  699.  
  700.             $overlay.show().velocity("stop").velocity({
  701.                 opacity: 1,
  702.             }, {
  703.                 duration: 500,
  704.                 easing: [ 0.140, 0.560, 0.710, 0.975 ]
  705.             });
  706.  
  707.             $input.velocity("stop").velocity({
  708.                 opacity: 1,
  709.                 translateY: [0, '100px'],
  710.                 rotateX: [0, '-90deg'],
  711.             }, {
  712.                 duration: 550,
  713.                 delay: 250,
  714.                 easing: [ 0.140, 0.560, 0.710, 0.975 ],
  715.                 complete: function() {
  716.                     setResultsH();
  717.                     $input.focus();
  718.                 }
  719.             });
  720.  
  721.             $close.velocity("stop").velocity(
  722.                 'fadeIn', {
  723.                 duration: 550,
  724.                 delay: 450,
  725.                 easing: [ 0.140, 0.560, 0.710, 0.975 ]
  726.             });
  727.  
  728.         }
  729.  
  730.     });
  731.  
  732.     $close.on('click', function(e){
  733.         e.preventDefault();
  734.  
  735.         $close.velocity("stop").velocity(
  736.             'fadeOut', {
  737.             duration: 250,
  738.             easing: [ 0.140, 0.560, 0.710, 0.975 ]
  739.         });
  740.  
  741.         $input.velocity("stop").velocity({
  742.             translateY: '50px',
  743.             rotateX: ['90deg', 0]
  744.         }, {
  745.             duration: 250,
  746.             easing: [ 0.140, 0.560, 0.710, 0.975 ],
  747.             complete: function(){
  748.                 $input.blur().css({
  749.                     opacity: 0
  750.                 });
  751.             }
  752.         });
  753.  
  754.         $overlay.velocity("stop").velocity({
  755.             opacity: 0,
  756.         }, {
  757.             duration: 250,
  758.             easing: [ 0.140, 0.560, 0.710, 0.975 ],
  759.             complete: function(){
  760.                 $overlay.hide();
  761.                 $('html, body').removeClass('overflow_hidden');
  762.             }
  763.         });
  764.  
  765.         if ( $('body').hasClass('mood-overlay-menu') && $overlay_menu.hasClass('open') ) {
  766.             $overlay_menu.velocity("stop").velocity({
  767.                 opacity: 1
  768.             }, {
  769.                 duration: 250,
  770.                 easing: [ 0.140, 0.560, 0.710, 0.975 ]
  771.             });
  772.         }
  773.  
  774.     });
  775.  
  776.     $(window).on('resize', function(){
  777.         clearTimeout(setResize);
  778.         setResize = setTimeout(setResultsH,10);
  779.     });
  780. };
  781.  
  782. MOOD.stickyNav = function(){
  783.  
  784.     var $header = $('header#masthead'),
  785.         $nav = $('#nav-wrap'),
  786.         $body = $('body'),
  787.         mastheadHeight = parseFloat($header.attr('data-height'));
  788.  
  789.     var lastScrollTop = 0,
  790.         delta = 60;
  791.  
  792.     var detect_position = function () {
  793.  
  794.         var scrollTop = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop,
  795.             new_scroll = window.pageYOffset + document.documentElement.scrollTop,
  796.             window_h = $(window).height();
  797.  
  798.         if( Math.abs(lastScrollTop - new_scroll) >= delta ) {
  799.            
  800.             if ( new_scroll > lastScrollTop ){
  801.  
  802.                 $body.addClass('scrollingDown');
  803.  
  804.                 if ( new_scroll > mastheadHeight * 2 ) {
  805.  
  806.                     if ( !$body.hasClass('sticky-reached') ) {
  807.  
  808.                         $body.addClass('sticky-reached');
  809.                    
  810.                     }
  811.  
  812.                 }
  813.  
  814.             } else {
  815.  
  816.                 $body.removeClass('scrollingDown');
  817.  
  818.                 if ( $body.hasClass('sticky-reached') ) {
  819.  
  820.                     $body.removeClass('sticky-menu');
  821.  
  822.                 }
  823.  
  824.                 if ( new_scroll <= mastheadHeight * 2 ) {
  825.  
  826.                     if ( $body.hasClass('sticky-reached') ) {
  827.  
  828.                         $body.removeClass('sticky-reached');
  829.                    
  830.                     }
  831.  
  832.                 }
  833.  
  834.             }
  835.  
  836.             lastScrollTop = new_scroll;
  837.         }
  838.  
  839.  
  840.         if ( new_scroll > 10 )
  841.             $body.addClass('scrolled-down');
  842.         else
  843.             $body.removeClass('scrolled-down');
  844.  
  845.         if ( new_scroll > ( window_h * 0.75 ) )
  846.             $body.addClass('scroll-top-reached');
  847.         else
  848.             $body.removeClass('scroll-top-reached');
  849.     };
  850.  
  851.     detect_position();
  852.     function onScroll(evt) {
  853.         requestAnimFrame(detect_position);
  854.         //detect_position();
  855.     }
  856.  
  857.     // shim layer with setTimeout fallback
  858.     window.requestAnimFrame = (function() {
  859.         return window.requestAnimationFrame ||
  860.             window.webkitRequestAnimationFrame ||
  861.             window.mozRequestAnimationFrame ||
  862.             window.oRequestAnimationFrame ||
  863.             window.msRequestAnimationFrame ||
  864.             function(callback) {
  865.                 window.setTimeout(callback, 1000 / 60);
  866.             };
  867.     })();
  868.  
  869.     window.addEventListener('scroll', onScroll, false);
  870.     window.addEventListener('resize', onScroll, false);
  871.     onScroll();
  872.  
  873. };
  874.  
  875. MOOD.mobileMenu = function(){
  876.     var respW = typeof mood_mobile_menu_width !== 'undefined' && mood_mobile_menu_width !== '' ? mood_mobile_menu_width : 800,
  877.         $window = $(window),
  878.         $burger = $('#hamburger-menu'),
  879.         $header = $('header#masthead'),
  880.         $menu_cont = $('.main-menu-container').after('<span id="menu-container-placeholder" />'),
  881.         $cart = $('#header-cart').after('<span id="header-cart-placeholder" />'),
  882.         $search = $('#header-search').after('<span id="header-search-placeholder" />'),
  883.         $social = $('#nav-social').after('<span id="nav-social-placeholder" />'),
  884.         $ph_menu = $('#menu-container-placeholder'),
  885.         $ph_cart = $('#header-cart-placeholder'),
  886.         $ph_search = $('#header-search-placeholder'),
  887.         $ph_social = $('#nav-social-placeholder'),
  888.         $topbar = $('#header-topbar').after('<span id="topbar-placeholder" />'),
  889.         $ph_topbar = $('#topbar-placeholder'),
  890.         $search_form = $('#top-search-form .form-wrap').after('<span id="form-placeholder" />'),
  891.         $ph_search_form = $('#form-placeholder'),
  892.         winW,
  893.         winWCheck = 0,
  894.         $titles = $('.pix_mega_title', $menu_cont);
  895.  
  896.     var checkRespoMenu = function(){
  897.         winW = $window.width();
  898.  
  899.         if ( winW == winWCheck ) return false;
  900.  
  901.         if ( winW <= respW ) {
  902.  
  903.             if ( !$('body').hasClass('mood-overlay-menu') ) {
  904.                 $titles.each(function(){
  905.                     var $title = $(this),
  906.                         $li = $title.parents('li').eq(0),
  907.                         $until = $('li').has('.pix_mega_title'),
  908.                         $ul = $('<ul class="ul-mega-children" />');
  909.  
  910.                     $li.nextUntil($until, 'li').each(function() {
  911.                         $ul.append($(this));
  912.                     });
  913.  
  914.                     if ( $('li', $ul).length ) {
  915.                         $li.append( $ul );
  916.                     }
  917.                 });
  918.             }
  919.  
  920.             $('body').addClass('mobile-view');
  921.             if ( $('body').hasClass('transparent-header') ) {
  922.                 $('body').removeClass('transparent-header').addClass('nomore-transparent-header');
  923.             }
  924.             if ( $('body').hasClass('header-layout-wide-centered') ) {
  925.                 $('body').removeClass('header-layout-wide-centered').addClass('nomore-header-layout-wide-centered');
  926.             }
  927.             if ( $('body').hasClass('header-layout-side') ) {
  928.                 $('body').removeClass('header-layout-side').addClass('nomore-header-layout-side');
  929.             }
  930.             if ( $menu_cont.hasClass('appended-menu') ) {
  931.                 $menu_cont.removeClass('appended-menu').addClass('nomore-appended-menu');
  932.             }
  933.  
  934.             $search.append($search_form);
  935.             $menu_cont.append($cart).append($search).append($topbar).append($social);
  936.             $header.after($menu_cont);
  937.  
  938.         } else {
  939.  
  940.             if ( !$('body').hasClass('mood-overlay-menu') ) {
  941.  
  942.                 $titles.each(function(){
  943.                     var $parent = $(this).parents('li').eq(0);
  944.                     if ( $parent.has('.ul-mega-children') ) {
  945.                         var $ulMega = $('.ul-mega-children', $parent);
  946.                         $($(' > li', $ulMega).get().reverse()).each(function(){
  947.                             var $li = $(this);
  948.                             $parent.after($li);
  949.                         });
  950.                         $ulMega.remove();
  951.                     }
  952.                 });
  953.  
  954.             }
  955.  
  956.             $menu_cont.find('[style*="display: none"]').each(function(){
  957.                 $(this).show();
  958.             });
  959.  
  960.             $('body').removeClass('mobile-view');
  961.             if ( $('body').hasClass('nomore-transparent-header') ) {
  962.                 $('body').removeClass('nomore-transparent-header').addClass('transparent-header');
  963.             }
  964.             if ( $('body').hasClass('nomore-header-layout-wide-centered') ) {
  965.                 $('body').removeClass('nomore-header-layout-wide-centered').addClass('header-layout-wide-centered');
  966.             }
  967.             if ( $('body').hasClass('nomore-header-layout-side') ) {
  968.                 $('body').removeClass('nomore-header-layout-side').addClass('header-layout-side');
  969.             }
  970.             if ( $menu_cont.hasClass('nomore-appended-menu') ) {
  971.                 $menu_cont.removeClass('nomore-appended-menu').addClass('appended-menu');
  972.             }
  973.  
  974.             $ph_menu.before($menu_cont);
  975.             $ph_cart.before($cart);
  976.             $ph_search.before($search);
  977.             $ph_social.before($social);
  978.             $ph_topbar.before($topbar);
  979.             $ph_search_form.before($search_form);
  980.  
  981.             setTimeout( function(){
  982.                 $(window).trigger('mood-mobile-resize');
  983.             }, 30 );
  984.  
  985.         }
  986.  
  987.         var $li_mega_menu = $('li', $menu_cont).has('ul.ul-mega-children').find('> .pix-menu-no-link, > a');
  988.  
  989.         $('li.menu-item-has-children > a, li.menu-item-has-children > .pix-menu-no-link, .ul-mega > li > .pix_mega_title', $menu_cont).add($li_mega_menu).each(function(){
  990.             var $menu_a = $(this),
  991.                 $li = $menu_a.parents('li').eq(0),
  992.                 $li_parent = $li.parents('li').eq(0),
  993.                 $ul = $('> ul, > div', $li),
  994.                 $ul_parent = $li.parents('ul').eq(0),
  995.                 $ul_siblings = $ul_parent.siblings('[data-col]'),
  996.                 $divs = $ul_parent.siblings('div'),
  997.                 $siblings = $li.siblings();
  998.  
  999.             if ( ! $( '.after', $menu_a ).length )
  1000.                 $menu_a.append('<span class="after" />');
  1001.  
  1002.             var $after = $('> .after', $menu_a);
  1003.  
  1004.             $after.off('click');
  1005.             $after.on('click', function(e){
  1006.                        
  1007.                 e.stopPropagation();
  1008.                 e.preventDefault();
  1009.  
  1010.                 $menu_a.toggleClass('clicked');
  1011.  
  1012.                 /*if ( $menu_a.hasClass('clicked') ) {
  1013.                     $siblings.add('> a, > .pix-menu-no-link, > .pix_mega_title', $li_parent).add('> a', $divs).velocity("stop").velocity( 'slideUp', { duration: 500 });
  1014.                     $ul.velocity("stop").velocity( 'slideDown', { duration: 500 });
  1015.                 } else {
  1016.                     $ul.velocity("stop").velocity( 'slideUp', { duration: 500 });
  1017.                     $siblings.add('> a', $li_parent).add('> a', $divs).velocity("stop").velocity( 'slideDown', { duration: 500, display: 'block' });
  1018.                 }*/
  1019.  
  1020.                 if ( $menu_a.hasClass('clicked') ) {
  1021.                     $siblings.add('> a, > .pix-menu-no-link, > .pix_mega_title', $li_parent).add('> a', $divs).add($ul_siblings).stop(true, false).slideUp(500);
  1022.                     $ul.stop(true, false).slideDown(500);
  1023.                 } else {
  1024.                     $ul.stop(true, false).slideUp(500);
  1025.                     $siblings.add('> a', $li_parent).add('> a', $divs).add($ul_siblings).stop(true, false).slideDown(500);
  1026.                 }
  1027.             });
  1028.  
  1029.         });
  1030.  
  1031.         $('li > span.wpml-native-name', $menu_cont).each(function(){
  1032.             var $menu_a = $(this),
  1033.                 $topbar = $('#header-topbar'),
  1034.                 $li = $menu_a.parents('li').eq(0),
  1035.                 $el = $li.parents('.top-bar-element').eq(0),
  1036.                 $ul = $('> ul', $li),
  1037.                 $siblings = $('.top-bar-element', $topbar).not($el);
  1038.  
  1039.             $menu_a.append('<span class="after" />');
  1040.  
  1041.             var $after = $('> .after', $menu_a);
  1042.  
  1043.             $after.on('click', function(e){
  1044.                        
  1045.                 e.stopPropagation();
  1046.                 e.preventDefault();
  1047.  
  1048.                 $menu_a.toggleClass('clicked');
  1049.  
  1050.                 if ( $menu_a.hasClass('clicked') ) {
  1051.                     $siblings.velocity("stop").velocity( 'slideUp', { duration: 500 });
  1052.                     $ul.velocity("stop").velocity( 'slideDown', { duration: 500 });
  1053.                 } else {
  1054.                     $ul.velocity("stop").velocity( 'slideUp', { duration: 500 });
  1055.                     $siblings.velocity("stop").velocity( 'slideDown', { duration: 500 });
  1056.                 }
  1057.             });
  1058.  
  1059.         });
  1060.  
  1061.         $('#header-cart > a, #header-search > a', $menu_cont).each(function(){
  1062.             var $menu_a = $(this),
  1063.                 $li = $('> ul > li', $menu_cont),
  1064.                 $div_parent = $menu_a.parents('div').eq(0),
  1065.                 $divs = $div_parent.siblings('div'),
  1066.                 $div = $('> div', $div_parent);
  1067.  
  1068.             $menu_a.append('<span class="after" />');
  1069.  
  1070.             var $after = $('> .after', $menu_a);
  1071.  
  1072.             $after.on('click', function(e){
  1073.                        
  1074.                 e.stopPropagation();
  1075.                 e.preventDefault();
  1076.  
  1077.                 $menu_a.toggleClass('clicked');
  1078.  
  1079.                 if ( $menu_a.hasClass('clicked') ) {
  1080.                     $('> a', $li).add('> a', $divs).velocity("stop").velocity( 'slideUp', { duration: 500 });
  1081.                     $div.velocity("stop").velocity( 'slideDown', { duration: 500 });
  1082.                 } else {
  1083.                     $div.velocity("stop").velocity( 'slideUp', { duration: 500 });
  1084.                     $('> a', $li).add('> a', $divs).velocity("stop").velocity( 'slideDown', { duration: 500 });
  1085.                 }
  1086.             });
  1087.  
  1088.         });
  1089.  
  1090.         winWCheck = $window.width();
  1091.  
  1092.     };
  1093.  
  1094.     checkRespoMenu();
  1095.  
  1096.     var setCheckMenu;
  1097.     $window.on( 'resize', function(){
  1098.         clearTimeout(setCheckMenu);
  1099.         setCheckMenu = setTimeout( checkRespoMenu, 30 );
  1100.     });
  1101.  
  1102.     $burger.on('click', function(e){
  1103.  
  1104.         var winW = $window.width();
  1105.  
  1106.         if ( winW <= respW ) {
  1107.  
  1108.             e.preventDefault();
  1109.             $burger.toggleClass('clicked');
  1110.  
  1111.             if ( $burger.hasClass('clicked') ) {
  1112.                 $menu_cont.slideDown({ duration: 500 });
  1113.             } else {
  1114.                 $menu_cont.slideUp({ duration: 500 });
  1115.             }
  1116.  
  1117.         }
  1118.  
  1119.     });
  1120.  
  1121.     /*$(document).on('revolution.slide.onchange', function(event, data){
  1122.         alert(data.slideIndex);
  1123.     });*/
  1124. };
  1125.  
  1126. MOOD.vcParallax = function(){
  1127.     var $parallaxVCelements = $('[data-vc-parallax]').removeAttr('data-vc-parallax');
  1128.     $parallaxVCelements.each(function(){
  1129.         var $tParax = $(this),
  1130.             param = ( typeof $tParax.attr('data-offset-param') != 'undefined' && $tParax.attr('data-offset-param') !== null && $tParax.attr('data-offset-param') !== '' ) ? $tParax.attr('data-offset-param') : '0.25',
  1131.             left = ( typeof $tParax.attr('data-parax-left') != 'undefined' && $tParax.attr('data-parax-left') !== null && $tParax.attr('data-parax-left') !== '' ) ? $tParax.attr('data-parax-left') : '0',
  1132.             right = ( typeof $tParax.attr('data-parax-right') != 'undefined' && $tParax.attr('data-parax-right') !== null && $tParax.attr('data-parax-right') !== '' ) ? $tParax.attr('data-parax-right') : '0',
  1133.             size_resp = ( typeof $tParax.attr('data-parax-resp-size') != 'undefined' && $tParax.attr('data-parax-resp-size') !== null && $tParax.attr('data-parax-resp-size') !== '' ) ? $tParax.attr('data-parax-resp-size') : '0',
  1134.             left_resp = ( typeof $tParax.attr('data-parax-left-resp') != 'undefined' && $tParax.attr('data-parax-left-resp') !== null && $tParax.attr('data-parax-left-resp') !== '' ) ? $tParax.attr('data-parax-left-resp') : '0',
  1135.             right_resp= ( typeof $tParax.attr('data-parax-right-resp') != 'undefined' && $tParax.attr('data-parax-right-resp') !== null && $tParax.attr('data-parax-right-resp') !== '' ) ? $tParax.attr('data-parax-right-resp') : '0',
  1136.             src = $tParax.data('vc-parallax-image'),
  1137.             $divParax = $('<div class="pix-parallax" data-offset-param="' + param + '" />').css({
  1138.                 backgroundImage: 'url(' + src + ')',
  1139.                 left: left + '%',
  1140.                 right: right + '%',
  1141.                 'transition' : 'transform linear -1ms, -webkit-transform linear -1ms'
  1142.             }),
  1143.             $divParaxWrap = $('<div class="pix-parallax-wrap" />').css({
  1144.                 'transition' : 'transform linear -1ms, -webkit-transform linear -1ms'
  1145.             });
  1146.  
  1147.             if ( $tParax.attr('data-parallax-o-fade') == 'on' ) {
  1148.                 $tParax.removeAttr('data-parallax-o-fade');
  1149.                 $divParax.attr('data-parallax-o-fade','on');
  1150.             }
  1151.  
  1152.             if ( $('.vc-mood-overlay', $tParax).length ) {
  1153.                 $('.vc-mood-overlay', $tParax).css({
  1154.                     left: left + '%',
  1155.                     right: right + '%'
  1156.                 });
  1157.             }
  1158.  
  1159.             if ( !$('.pix-parallax', $tParax).length )
  1160.                 $tParax.append( $divParaxWrap.append( $divParax ) );
  1161.        
  1162.             MOOD.parallax();
  1163.  
  1164.             var resizeParax = function(){
  1165.                 var hRow = $tParax.outerHeight(),
  1166.                     wH = $(window).height(),
  1167.                     diff = (hRow - wH) * param;
  1168.  
  1169.                 if ( hRow > wH )
  1170.                     diff = 0;
  1171.  
  1172.                 if ( size_resp !== 0 && $(window).width() <= size_resp ) {
  1173.                     $divParax.css({
  1174.                         left: left_resp + '%',
  1175.                         right: right_resp + '%'
  1176.                     });
  1177.                     if ( $('.vc-mood-overlay', $tParax).length ) {
  1178.                         $('.vc-mood-overlay', $tParax).css({
  1179.                             left: left_resp + '%',
  1180.                             right: right_resp + '%'
  1181.                         });
  1182.                     }
  1183.                 } else {
  1184.                     $divParax.css({
  1185.                         left: left + '%',
  1186.                         right: right + '%'
  1187.                     });
  1188.                     if ( $('.vc-mood-overlay', $tParax).length ) {
  1189.                         $('.vc-mood-overlay', $tParax).css({
  1190.                             left: left + '%',
  1191.                             right: right + '%'
  1192.                         });
  1193.                     }
  1194.                 }
  1195.  
  1196.                 $divParax.css({
  1197.                     bottom: diff,
  1198.                     top: diff
  1199.                 });
  1200.             };
  1201.             resizeParax();
  1202.             $(window).on('resize load pix-parallax', resizeParax);
  1203.             $(document.body).on('mood-loaded', resizeParax);
  1204.     });
  1205. };
  1206.  
  1207. MOOD.parallax = function(){
  1208.  
  1209.      var $parallaxElements = $('.pix-parallax, .double-parallax, [data-parallax="on"], [data-offset-param] .vc_video-bg iframe, [class*="rs-revert-parallaxlevel-"]').css({
  1210.             'transition' : 'transform linear -1ms, -webkit-transform linear -1ms'
  1211.         }),
  1212.         matrix = [];
  1213.  
  1214.     var prefix = function(obj, prop, value) {
  1215.         var prefs = ['webkit', 'Moz', 'o', 'ms'];
  1216.         for (var pref in prefs) {
  1217.             obj.css( prefs[pref] + prop , value);
  1218.         }
  1219.     };
  1220.  
  1221.     var w_w = $(window).width(),
  1222.         w_h = $(window).height(),
  1223.         w_h_1_3 = w_h * 0.2,
  1224.         w_h_2_3 = w_h * 0.8,
  1225.         $spacer = $('#header-spacer'),
  1226.         spacerH = $spacer.outerHeight();
  1227.  
  1228.     var dataOffset = function(iEl){
  1229.         w_w = $(window).width();
  1230.         w_h = $(window).height();
  1231.         w_h_1_3 = w_h * 0.2;
  1232.         w_h_2_3 = w_h * 0.8;
  1233.         spacerH = $spacer.outerHeight();
  1234.  
  1235.         var $thisEl = $parallaxElements.eq(iEl);
  1236.         prefix($thisEl, "Transform", "translateY(0)");
  1237.         var elTop = $thisEl[0].getBoundingClientRect().top + window.scrollY,
  1238.             elBottom = $thisEl[0].getBoundingClientRect().bottom + window.scrollY,
  1239.             attr = $thisEl.attr('data-offset-top'),
  1240.             $overflow;
  1241.  
  1242.         if ( $thisEl.hasClass('pix-parallax') || $thisEl.hasClass('wpb_revslider_element') )
  1243.             $thisEl.parents('div').eq(0).addClass('overflow_hidden');
  1244.  
  1245.         if ( $thisEl.parents('.vc_row').eq(0).css('overflow') == 'hidden' ) {
  1246.             $overflow = $thisEl.parents('.vc_row').eq(0);
  1247.         } if ( $thisEl.parents('.pix-parallax-wrap').length ) {
  1248.             $overflow = $thisEl.parents('.pix-parallax-wrap').eq(0);
  1249.         } else {
  1250.             $overflow = $thisEl;
  1251.         }
  1252.  
  1253.         if (typeof attr !== typeof undefined && attr !== false && attr!=='' )
  1254.             elTop = attr;
  1255.  
  1256.         if ( $thisEl.is('[class*="rs-revert-parallaxlevel-"]') ) {
  1257.             var elClass = $thisEl.attr('class'),
  1258.                 newParam = elClass.match(/rs-revert-parallaxlevel-([0-9])/i);
  1259.  
  1260.             newParam = parseFloat( newParam[1] );
  1261.  
  1262.             if ( newParam < 10 ) {
  1263.                 newParam = newParam * -0.2;
  1264.             } else {
  1265.                 newParam = ( 36 + newParam ) * -0.2;
  1266.             }
  1267.  
  1268.             $thisEl.attr('data-offset-param', newParam);
  1269.         }
  1270.  
  1271.         if ( typeof $thisEl.attr('data-offset-param') == 'undefined' || $thisEl.attr('data-offset-param') === null || $thisEl.attr('data-offset-param') === '' )
  1272.             $thisEl.attr('data-offset-param', '0.5');
  1273.  
  1274.         if ( $thisEl.hasClass('double-parallax') )
  1275.             $thisEl.attr('data-offset-param', '-0.075');
  1276.  
  1277.         if ( $thisEl.is('iframe') ) {
  1278.             var winH = $(window).height(),
  1279.                 winW =  $(window).width(),
  1280.                 $parent = $thisEl.parents('[data-offset-param]').eq(0),
  1281.                 paramParent = $parent.attr('data-offset-param'),
  1282.                 parentHeight = parseFloat($parent.outerHeight()),
  1283.                 wrapMore = (winH - parentHeight) * paramParent,
  1284.                 wrapHeight = wrapMore + parentHeight,
  1285.                 widthEl = wrapHeight * ( 16 / 9 );
  1286.  
  1287.             if ( widthEl < winW ) {
  1288.                 widthEl = winW;
  1289.                 wrapHeight = winW * ( 9 / 16 );
  1290.             }
  1291.  
  1292.             $thisEl.css({
  1293.                 height: wrapHeight,
  1294.                 width: widthEl,
  1295.                 marginTop: wrapMore * -0.5,
  1296.                 marginBottom: wrapMore * -0.5,
  1297.                 marginLeft: (widthEl - winW) * -0.5,
  1298.                 marginRight: (widthEl - winW) * -0.5
  1299.             });
  1300.             $thisEl.attr('data-offset-param', paramParent);
  1301.         }
  1302.  
  1303.         $thisEl.data('offset-top',elTop).data('offset-bottom',elBottom);
  1304.  
  1305.         matrix[iEl] = [];
  1306.  
  1307.         matrix[iEl].sectionTop = $overflow[0].getBoundingClientRect().top + window.scrollY;
  1308.         matrix[iEl].elTop = typeof dataOff != 'undefined' ? dataOff : $thisEl.data('offset-top');
  1309.         matrix[iEl].elBottom = $thisEl.data('offset-bottom'),
  1310.         matrix[iEl].elHeight = ( matrix[iEl].elBottom - matrix[iEl].elTop ),
  1311.         matrix[iEl].param = $thisEl.attr('data-offset-param'),
  1312.         matrix[iEl].halfThis = matrix[iEl].elTop==0 ? 0 : w_h/2 - matrix[iEl].elHeight/2;
  1313.  
  1314.         if ( $thisEl.hasClass('wpb_revslider_element') || $thisEl.attr('id') == 'header_parallax_bg'  || $thisEl.attr('id') == '404_parallax_bg' ) {
  1315.             matrix[iEl].halfThis = 0;
  1316.         }
  1317.  
  1318.     };
  1319.  
  1320.     function onResize(iEl) {
  1321.         dataOffset(iEl);
  1322.     }
  1323.  
  1324.     function onScroll(iEl) {
  1325.         updateElement(iEl);
  1326.     }
  1327.  
  1328.     function updateElement(iEl) {
  1329.  
  1330.         var _this = $parallaxElements.eq(iEl),
  1331.             $overflow;
  1332.  
  1333.         if ( _this.parents('.vc_row').eq(0).css('overflow') == 'hidden' ) {
  1334.             $overflow = _this.parents('.vc_row').eq(0);
  1335.         } else if ( _this.parents('.pix-parallax-wrap').length ) {
  1336.             $overflow = _this.parents('.pix-parallax-wrap').eq(0);
  1337.         } else if ( _this.parents('#parrallax_wrap').length ) {
  1338.             $overflow = _this.parents('#parrallax_wrap').eq(0);
  1339.         } else {
  1340.             $overflow = _this;
  1341.         }
  1342.  
  1343.         var scrollTop     = window.scrollY,
  1344.             $row_els      = $overflow.find('> .vc_column_container'),
  1345.             sectionTop,
  1346.             sectionBottom,
  1347.             dataOff = matrix[iEl].dataOff,
  1348.             elTop = matrix[iEl].elTop,
  1349.             elBottom = matrix[iEl].elBottom,
  1350.             elHeight = matrix[iEl].elHeight,
  1351.             halfThis = matrix[iEl].halfThis,
  1352.             staticTop = matrix[iEl].sectionTop,
  1353.             param = matrix[iEl].param,
  1354.             dimens = ( elTop - halfThis ),
  1355.             css = {},
  1356.             newOpacity;
  1357.  
  1358.         if ( ( staticTop < w_h && sectionBottom < w_h ) || _this.attr('id') == 'header_parallax_bg' ) {
  1359.             dimens = spacerH; //so I'm sure it starts from 0 when loads
  1360.         }
  1361.  
  1362.         var move = ( spacerH + ( scrollTop - dimens ) ) * param,
  1363.             stat = halfThis * param,
  1364.             break_w = typeof mood_parallax_breakpoint !== typeof undefined && mood_parallax_breakpoint !== false && mood_parallax_breakpoint!=='' ? mood_parallax_breakpoint : 0;
  1365.  
  1366.         if ( MOOD.isElementInViewport(_this, (Math.abs(stat) * -1) ) ) {
  1367.  
  1368.             if ( w_w > break_w ) {
  1369.  
  1370.                 if ( param == 1 && _this.hasClass('pix-parallax') ) {
  1371.                     css.transform = '';
  1372.                     css.backgroundAttachment = 'fixed';
  1373.                 } else {
  1374.                     if(Modernizr.csstransforms ) {
  1375.                         css.transform = 'translateY(' + move + 'px)';
  1376.                         if(Modernizr.csstransforms3d) {
  1377.                             css.transform = 'translate3d(0, ' + move + 'px, 0)';
  1378.                         }
  1379.                     }
  1380.                 }
  1381.  
  1382.                 if ( _this.attr('data-parallax-o-fade')=='on' && typeof $row_els[0] != 'undefined' ) {
  1383.                     sectionTop    = $row_els[0].getBoundingClientRect().top + scrollTop + 40;
  1384.                     sectionBottom = ( $row_els[0].getBoundingClientRect().bottom + scrollTop ) - 40;
  1385.  
  1386.                     if ( ( sectionTop - w_h_1_3 ) < ( scrollTop + w_h ) && sectionBottom > ( scrollTop + w_h ) ) {
  1387.                         newOpacity = ( ( scrollTop + w_h ) - sectionTop ) / w_h_1_3;
  1388.                     } else if ( sectionBottom < ( scrollTop + w_h_1_3 ) ) {
  1389.                         newOpacity = ( sectionBottom - scrollTop ) / w_h_1_3;
  1390.                     } else {
  1391.                         newOpacity = 1;
  1392.                     }
  1393.                 }
  1394.  
  1395.                 newOpacity = newOpacity > 1 ? 1 : newOpacity;
  1396.                 newOpacity = newOpacity < 0 ? 0 : newOpacity;
  1397.  
  1398.                 $row_els.css({
  1399.                     opacity: parseFloat(newOpacity)
  1400.                 });
  1401.  
  1402.             } else {
  1403.  
  1404.                 if(Modernizr.csstransforms ) {
  1405.                     css.transform = 'translateY(0px)';
  1406.                     if(Modernizr.csstransforms3d) {
  1407.                         css.transform = 'translate3d(0, 0px, 0)';
  1408.                     }
  1409.                 }
  1410.  
  1411.             }
  1412.  
  1413.             _this.css(css);
  1414.  
  1415.         }
  1416.  
  1417.     }
  1418.  
  1419.     if ($parallaxElements !== null) {
  1420.  
  1421.         for ( var iEl = 0, lenEl = $parallaxElements.length; iEl < lenEl; iEl++) {
  1422.             dataOffset(iEl);
  1423.             updateElement(iEl);
  1424.         }
  1425.  
  1426.     }
  1427.  
  1428.     if ($parallaxElements !== null) {
  1429.  
  1430.         for(var k = 0, len = $parallaxElements.length; k < len; k++) {
  1431.             onScroll(k);
  1432.         }
  1433.  
  1434.         $(window).on('scroll.pix-parallax', function() {
  1435.             for(var k = 0, len = $parallaxElements.length; k < len; k++) {
  1436.                 onScroll(k);
  1437.             }
  1438.         });
  1439.  
  1440.         var timeout;
  1441.         $(window).on('resize.pix-parallax orientationchange.pix-parallax load.pix-parallax pix-parallax isotoped', function() {
  1442.             clearTimeout(timeout);
  1443.             timeout = setTimeout(function() {
  1444.                 for(var k = 0, len = $parallaxElements.length; k < len; k++) {
  1445.                     onResize(k);
  1446.                     onScroll(k);
  1447.                 }
  1448.             }, 100);
  1449.         });
  1450.         $(document.body).on('mood-loaded', function() {
  1451.             clearTimeout(timeout);
  1452.             timeout = setTimeout(function() {
  1453.                 for(var k = 0, len = $parallaxElements.length; k < len; k++) {
  1454.                     onResize(k);
  1455.                     onScroll(k);
  1456.                 }
  1457.             }, 100);
  1458.         });
  1459.  
  1460.     }
  1461.  
  1462. };
  1463.  
  1464. MOOD.parallaxEls = function(){
  1465.  
  1466.     var $parallaxElements = $('[data-offset-param] .vc_video-bg iframe').css({
  1467.             'transition' : 'transform linear -1ms, -webkit-transform linear -1ms'
  1468.         }),
  1469.         matrix = [];
  1470.  
  1471.     var prefix = function(obj, prop, value) {
  1472.         var prefs = ['webkit', 'Moz', 'o', 'ms'];
  1473.         for (var pref in prefs) {
  1474.             obj.css( prefs[pref] + prop , value);
  1475.         }
  1476.     };
  1477.  
  1478.     var w_w = $(window).width(),
  1479.         w_h = $(window).height(),
  1480.         w_h_1_3 = w_h * 0.2,
  1481.         w_h_2_3 = w_h * 0.8,
  1482.         $spacer = $('#header-spacer'),
  1483.         spacerH = $spacer.outerHeight();
  1484.  
  1485.  
  1486.     var dataOffset = function(iEl){
  1487.         w_w = $(window).width();
  1488.         w_h = $(window).height();
  1489.         w_h_1_3 = w_h * 0.2;
  1490.         w_h_2_3 = w_h * 0.8;
  1491.         spacerH = $spacer.outerHeight();
  1492.  
  1493.         var $thisEl = $parallaxElements.eq(iEl);
  1494.         prefix($thisEl, "Transform", "translateY(0)");
  1495.         var elTop = $thisEl[0].getBoundingClientRect().top + window.scrollY,
  1496.             elBottom = $thisEl[0].getBoundingClientRect().bottom + window.scrollY,
  1497.             attr = $thisEl.attr('data-offset-top'),
  1498.             $overflow;
  1499.  
  1500.         if ( $thisEl.hasClass('pix-parallax') || $thisEl.hasClass('wpb_revslider_element') )
  1501.             $thisEl.parents('div').eq(0).addClass('overflow_hidden');
  1502.  
  1503.         if ( $thisEl.parents('.vc_row').eq(0).css('overflow') == 'hidden' ) {
  1504.             $overflow = $thisEl.parents('.vc_row').eq(0);
  1505.         } if ( $thisEl.parents('.pix-parallax-wrap').length ) {
  1506.             $overflow = $thisEl.parents('.pix-parallax-wrap').eq(0);
  1507.         } else {
  1508.             $overflow = $thisEl;
  1509.         }
  1510.  
  1511.         if (typeof attr !== typeof undefined && attr !== false && attr!=='' )
  1512.             elTop = attr;
  1513.  
  1514.         if ( typeof $thisEl.attr('data-offset-param') == 'undefined' || $thisEl.attr('data-offset-param') === null || $thisEl.attr('data-offset-param') === '' )
  1515.             $thisEl.attr('data-offset-param', '0.5');
  1516.  
  1517.         if ( $thisEl.is('iframe') ) {
  1518.             var winH = $(window).height(),
  1519.                 winW =  $(window).width(),
  1520.                 $parent = $thisEl.parents('[data-offset-param]').eq(0),
  1521.                 paramParent = $parent.attr('data-offset-param'),
  1522.                 parentHeight = parseFloat($parent.outerHeight()),
  1523.                 wrapMore = (winH - parentHeight) * paramParent,
  1524.                 wrapHeight = wrapMore + parentHeight,
  1525.                 widthEl = wrapHeight * ( 16 / 9 );
  1526.  
  1527.             if ( widthEl < winW ) {
  1528.                 widthEl = winW;
  1529.                 wrapHeight = winW * ( 9 / 16 );
  1530.             }
  1531.  
  1532.             $thisEl.css({
  1533.                 height: wrapHeight,
  1534.                 width: widthEl,
  1535.                 marginTop: wrapMore * -0.5,
  1536.                 marginBottom: wrapMore * -0.5,
  1537.                 marginLeft: (widthEl - winW) * -0.5,
  1538.                 marginRight: (widthEl - winW) * -0.5
  1539.             });
  1540.             $thisEl.attr('data-offset-param', paramParent);
  1541.         }
  1542.  
  1543.         $thisEl.data('offset-top',elTop).data('offset-bottom',elBottom);
  1544.  
  1545.         matrix[iEl] = [];
  1546.  
  1547.         matrix[iEl].sectionTop = $overflow[0].getBoundingClientRect().top + window.scrollY;
  1548.         matrix[iEl].elTop = typeof dataOff != 'undefined' ? dataOff : $thisEl.data('offset-top');
  1549.         matrix[iEl].elBottom = $thisEl.data('offset-bottom'),
  1550.         matrix[iEl].elHeight = ( matrix[iEl].elBottom - matrix[iEl].elTop ),
  1551.         matrix[iEl].param = $thisEl.attr('data-offset-param'),
  1552.         matrix[iEl].halfThis = matrix[iEl].elTop==0 ? 0 : w_h/2 - matrix[iEl].elHeight/2;
  1553.  
  1554.         if ( $thisEl.hasClass('wpb_revslider_element') || $thisEl.attr('id') == 'header_parallax_bg' ) {
  1555.             matrix[iEl].halfThis = 0;
  1556.         }
  1557.  
  1558.     };
  1559.  
  1560.     function onResize(iEl) {
  1561.         dataOffset(iEl);
  1562.     }
  1563.  
  1564.     function onScroll(iEl) {
  1565.         updateElement(iEl);
  1566.     }
  1567.  
  1568.     function updateElement(iEl) {
  1569.  
  1570.         var _this = $parallaxElements.eq(iEl),
  1571.             $overflow;
  1572.  
  1573.         if ( _this.parents('.vc_row').eq(0).css('overflow') == 'hidden' ) {
  1574.             $overflow = _this.parents('.vc_row').eq(0);
  1575.         } else if ( _this.parents('.pix-parallax-wrap').length ) {
  1576.             $overflow = _this.parents('.pix-parallax-wrap').eq(0);
  1577.         } else if ( _this.parents('#parrallax_wrap').length ) {
  1578.             $overflow = _this.parents('#parrallax_wrap').eq(0);
  1579.         } else {
  1580.             $overflow = _this;
  1581.         }
  1582.  
  1583.  
  1584.         var scrollTop     = window.scrollY,
  1585.             sectionTop    = $thisEl[0].getBoundingClientRect().top + scrollTop,
  1586.             sectionBottom = $thisEl[0].getBoundingClientRect().bottom + scrollTop,
  1587.             sectionHeight = sectionTop - sectionBottom,
  1588.             break_w = typeof mood_parallax_breakpoint !== typeof undefined && mood_parallax_breakpoint !== false && mood_parallax_breakpoint!=='' ? mood_parallax_breakpoint : 0;
  1589.             css = {};
  1590.  
  1591.         if (sectionTop + sectionHeight > scrollTop && sectionTop < scrollTop + w_h) {
  1592.  
  1593.             if ( w_w > break_w ) {
  1594.                 var dataOff = matrix[iEl].dataOff,
  1595.                     elTop = matrix[iEl].elTop,
  1596.                     elBottom = matrix[iEl].elBottom,
  1597.                     elHeight = matrix[iEl].elHeight,
  1598.                     param = matrix[iEl].param,
  1599.                     halfThis = matrix[iEl].halfThis,
  1600.                     staticTop = matrix[iEl].sectionTop,
  1601.                     dimens = ( elTop - halfThis );
  1602.  
  1603.                 if ( ( staticTop < w_h && (staticTop + sectionHeight) < w_h ) || _this.attr('id') == 'header_parallax_bg' ) {
  1604.                     dimens = spacerH; //so I'm sure it starts from 0 when loads
  1605.                 }
  1606.  
  1607.                 var move = ( spacerH + ( scrollTop - dimens ) ) * param;
  1608.  
  1609.                 if(Modernizr.csstransforms ) {
  1610.                     css.transform = 'translateY(' + move + 'px)';
  1611.                     if(Modernizr.csstransforms3d) {
  1612.                         css.transform = 'translate3d(0, ' + move + 'px, 0)';
  1613.                     }
  1614.                 }
  1615.  
  1616.                 if ( _this.attr('data-parallax-o-fade')=='on' ) {
  1617.                     if ( ( sectionTop + sectionHeight/2 ) < ( scrollTop + w_h_1_3 ) ) {
  1618.                         var newOpacity = ( ( sectionTop + sectionHeight/2 ) - (scrollTop + 80) ) / w_h_1_3;
  1619.                         _this.css({
  1620.                             opacity: parseFloat(newOpacity)
  1621.                         });
  1622.                     } else if ( ( sectionTop + sectionHeight/2 ) > ( scrollTop + w_h_2_3 ) ) {
  1623.                         var newOpacity = ( (scrollTop + w_h + 80) - ( sectionTop + sectionHeight/2 ) ) / w_h_1_3;
  1624.                         _this.css({
  1625.                             opacity: parseFloat(newOpacity)
  1626.                         });
  1627.                     } else {
  1628.                         _this.css({
  1629.                             opacity: 1
  1630.                         });
  1631.                     }
  1632.                 }
  1633.  
  1634.             } else {
  1635.  
  1636.                 if(Modernizr.csstransforms ) {
  1637.                     css.transform = 'translateY(0px)';
  1638.                     if(Modernizr.csstransforms3d) {
  1639.                         css.transform = 'translate3d(0, 0px, 0)';
  1640.                     }
  1641.                 }
  1642.  
  1643.             }
  1644.  
  1645.             _this.css(css);
  1646.  
  1647.         }
  1648.  
  1649.     }
  1650.  
  1651.     if ($parallaxElements !== null) {
  1652.  
  1653.         for ( var iEl = 0, lenEl = $parallaxElements.length; iEl < lenEl; iEl++) {
  1654.             dataOffset(iEl);
  1655.             updateElement(iEl);
  1656.         }
  1657.  
  1658.     }
  1659.  
  1660.     if (!Date.now)
  1661.         Date.now = function() { return new Date().getTime(); };
  1662.     if(!window.requestAnimationFrame)
  1663.         (function() {
  1664.             'use strict';
  1665.            
  1666.             var vendors = ['webkit', 'moz'];
  1667.             for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
  1668.                 var vp = vendors[i];
  1669.                 window.requestAnimationFrame = window[vp+'RequestAnimationFrame'];
  1670.                 window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame']
  1671.                                            || window[vp+'CancelRequestAnimationFrame']);
  1672.             }
  1673.             if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy
  1674.                 || !window.requestAnimationFrame || !window.cancelAnimationFrame) {
  1675.                 var lastTime = 0;
  1676.                 window.requestAnimationFrame = function(callback) {
  1677.                     var now = Date.now();
  1678.                     var nextTime = Math.max(lastTime + 16, now);
  1679.                     return setTimeout(function() { callback(lastTime = nextTime); },
  1680.                                       nextTime - now);
  1681.                 };
  1682.                 window.cancelAnimationFrame = clearTimeout;
  1683.             }
  1684.         }());
  1685.  
  1686.  
  1687.     if ($parallaxElements !== null) {
  1688.  
  1689.         for(var k = 0, len = $parallaxElements.length; k < len; k++) {
  1690.             onScroll(k);
  1691.         }
  1692.  
  1693.         $(window).on('scroll.pix-parallax', function() {
  1694.             for(var k = 0, len = $parallaxElements.length; k < len; k++) {
  1695.                 onScroll(k);
  1696.             }
  1697.         });
  1698.  
  1699.         var timeout;
  1700.         $(window).on('resize.pix-parallax orientationchange.pix-parallax load.pix-parallax isotoped', function() {
  1701.             clearTimeout(timeout);
  1702.             timeout = setTimeout(function() {
  1703.                 for(var k = 0, len =$parallaxElements.length; k < len; k++) {
  1704.                     onResize(k);
  1705.                     onScroll(k);
  1706.                 }
  1707.             }, 100);
  1708.         });
  1709.         $(document.body).on('mood-loaded', function() {
  1710.             clearTimeout(timeout);
  1711.             timeout = setTimeout(function() {
  1712.                 for(var k = 0, len =$parallaxElements.length; k < len; k++) {
  1713.                     onResize(k);
  1714.                     onScroll(k);
  1715.                 }
  1716.             }, 100);
  1717.         });
  1718.  
  1719.     }
  1720.  
  1721. };
  1722.  
  1723. MOOD.revSliders = function(){
  1724.     if ( ! $('.rev_slider').length )
  1725.         return false;
  1726.  
  1727.     $('.rev_slider').each(function(){
  1728.         var $slider = $(this),
  1729.             slider_id = $slider.attr('id');
  1730.  
  1731.         slider_id = slider_id.replace(/rev_slider_(.*)_1/g, '$1');
  1732.  
  1733.         if ( typeof window['revapi'+slider_id] == 'undefined' )
  1734.             return false;
  1735.  
  1736.         window['revapi'+slider_id].on('revolution.slide.onbeforeswap', function(event, data){
  1737.             var $next = data.nextslide;
  1738.             if ( $next.hasClass('alt-color') ) {
  1739.                 $('body').addClass('alt-color');
  1740.             } else {
  1741.                 $('body').removeClass('alt-color');
  1742.             }
  1743.         });
  1744.  
  1745.         window['revapi'+slider_id].on('revolution.slide.onloaded', function(event, data){
  1746.             $('body').addClass('revslider-loaded');
  1747.         });
  1748.  
  1749.         $( document.body ).on('mood-loaded', function(){
  1750.             window['revapi'+slider_id].revstart();
  1751.         });
  1752.     });
  1753. };
  1754.  
  1755. MOOD.childrenInviewport = function(){
  1756.     $('.mood-woo-styler[data-fx]').each(function(){
  1757.         var $this = $(this),
  1758.             fx = $this.attr('data-fx'),
  1759.             repeat = $this.attr('data-fx-repeat'),
  1760.             $li = $('li', $this);
  1761.  
  1762.         for (var li = 0, len = $li.length; li < len; li++) {
  1763.         //for ( var i = 0, len = a.length; i < len; i++) {
  1764.  
  1765.             if ( fx !== '' ) {
  1766.                 $li.eq(li)
  1767.                     .addClass(fx);
  1768.  
  1769.                 if ( typeof repeat != 'undefined' && repeat == 'yes' )
  1770.                     $li.eq(li).attr('data-fx-repeat', 'yes');
  1771.  
  1772.             }
  1773.  
  1774.             if ( li == len-1 ) {
  1775.                 $this.removeAttr('data-fx');
  1776.             }
  1777.         }
  1778.     });
  1779.  
  1780.     $('.mood-pricing-table[data-fx]').each(function(){
  1781.         var $this = $(this),
  1782.             fx = $this.attr('data-fx'),
  1783.             repeat = $this.attr('data-fx-repeat'),
  1784.             $li = $('.mood-pricing-column-equalizer', $this);
  1785.  
  1786.         for (var li = 0, len = $li.length; li < len; li++) {
  1787.         //for ( var i = 0, len = a.length; i < len; i++) {
  1788.  
  1789.             if ( fx !== '' ) {
  1790.                 $li.eq(li).attr('data-delay',(250 * li))
  1791.                     .addClass(fx);
  1792.  
  1793.                 if ( typeof repeat != 'undefined' && repeat == 'yes' )
  1794.                     $li.eq(li).attr('data-fx-repeat', 'yes');
  1795.  
  1796.             }
  1797.  
  1798.             if ( li == len-1 ) {
  1799.                 $this.removeAttr('data-fx');
  1800.             }
  1801.         }
  1802.     });
  1803. };
  1804.  
  1805. MOOD.inviewportMob = function(){
  1806.  
  1807.     if ( !$('body').hasClass('mobile-view') )
  1808.         return false;
  1809.  
  1810.     var $checkElements = $('.amount-chart, .numeric-counter, .mood-progress-wrap');
  1811.  
  1812.     function countProgress () {
  1813.  
  1814.         for ( var iEl = 0, lenEl = $checkElements.length; iEl < lenEl; iEl++) {
  1815.  
  1816.             var el = $checkElements.eq(iEl);
  1817.  
  1818.             if ( el.has('.amount-progress') ) {
  1819.  
  1820.                 var $calculator = el.find('.amount-progress').css({ opacity: 1 }),
  1821.                     amount = parseFloat( $calculator.attr('data-amount') ),
  1822.                     position = $calculator.attr('data-position'),
  1823.                     sign = $calculator.attr('data-sign');
  1824.  
  1825.                 if ( position == 'before' )
  1826.                     $calculator.text(sign + amount);
  1827.                 else
  1828.                     $calculator.text(amount + sign);
  1829.  
  1830.             }
  1831.  
  1832.             if ( el.hasClass('amount-chart') ) {
  1833.  
  1834.                 var animate = parseFloat( el.data('pix-animate') ),
  1835.                     size = parseFloat( el.outerWidth() ),
  1836.                     max = parseFloat( el.data('max') ),
  1837.                     coeff = max / 100,
  1838.                     value = parseFloat( el.data('percent') ),
  1839.                     $span = el.find('span.amount-counter').css({opacity: 1});
  1840.  
  1841.                 el.css({
  1842.                     height: size,
  1843.                     opacity: 1
  1844.                 }).easyPieChart({
  1845.                     size: size,
  1846.                     animate: 1,
  1847.                 });
  1848.                 $span.text( value * coeff );
  1849.  
  1850.                 var clearSet;
  1851.  
  1852.                 $(window).on('orientationchange', function(){
  1853.  
  1854.                     size = parseFloat( el.outerWidth() );
  1855.  
  1856.                     el.css({
  1857.                         height: size
  1858.                     });
  1859.  
  1860.                     clearTimeout(clearSet);
  1861.                     clearSet = setTimeout(function(){
  1862.                         el.removeData('easyPieChart').find('canvas').remove();
  1863.                         el.easyPieChart({
  1864.                             size: size,
  1865.                             animate: 1
  1866.                         });
  1867.                     }, 100);
  1868.                 });
  1869.             }
  1870.  
  1871.             if ( el.hasClass('numeric-counter') ) {
  1872.  
  1873.                 var amount = parseFloat( el.attr('data-value') ),
  1874.                     $span = $('.counter-amount', el).css({opacity: 1}).text(amount);
  1875.  
  1876.             }
  1877.  
  1878.         }
  1879.  
  1880.     }
  1881.  
  1882.     countProgress();
  1883.  
  1884. };
  1885.  
  1886. MOOD.inviewport = function(){
  1887.  
  1888.     if ( $('body').hasClass('mobile-view') )
  1889.         return false;
  1890.  
  1891.     var $checkElements = $('.wpb_animate_when_almost_visible:not(.mood_start_animation):not(.animated):not(.wpb_start_animation):not([aria-hidden="true"]), .pix_animate_bar_almost_visible:not(.mood_start_animation):not(.animated):not(.wpb_start_animation):not([aria-hidden="true"]), [data-pix-bg], .amount-chart, .numeric-counter, svg.drawing, [data-fx-reveal], .vc-row-mood-scroll-down').filter(':notparents([data-fx])').filter(':notparents([aria-hidden="true"])');
  1892.  
  1893.     var $avoidElements = $('.wpb_animate_when_almost_visible[aria-hidden="true"], [aria-hidden="true"] .wpb_animate_when_almost_visible, .pix_animate_bar_almost_visible[aria-hidden="true"], [aria-hidden="true"] .pix_animate_bar_almost_visible').removeClass('wpb_animate_when_almost_visible pix_animate_bar_almost_visible wpb_top-to-bottom top-to-bottom wpb_bottom-to-top bottom-to-top wpb_left-to-right left-to-right wpb_right-to-left right-to-left wpb_appear mood_start_animation bounceIn bounceInDown bounceInLeft bounceInRight bounceInUp fadeIn fadeInDown fadeInDownBig fadeInLeft fadeInLeftBig fadeInRight fadeInRightBig fadeInUp fadeInUpBig flipInX flipInY lightSpeedIn rotateIn rotateInDownLeft rotateInDownRight rotateInUpLeft rotateInUpRight rollIn zoomIn zoomInDown zoomInLeft zoomInRight zoomInUp slideInDown slideInLeft slideInRight slideInUp');
  1894.  
  1895.     function onResize() {
  1896.         checkElements();
  1897.     }
  1898.  
  1899.     function onScroll(evt) {
  1900.         requestAnimationFrame(checkElements);
  1901.         //checkElements();
  1902.     }
  1903.  
  1904.     function delayElements() {
  1905.  
  1906.         if ($checkElements !== null ) {
  1907.  
  1908.             var checkInView,
  1909.                 iEl,
  1910.                 lenEl = $checkElements.length,
  1911.                 ind,
  1912.                 nOff;
  1913.  
  1914.             for ( iEl = 0; iEl < lenEl; iEl++) {
  1915.  
  1916.                 var _this = $checkElements.eq(iEl);
  1917.  
  1918.                 nOff = _this.offset().top
  1919.  
  1920.                 _this.attr('data-offset', nOff);
  1921.  
  1922.                 ind = _this.index('[data-offset="' + nOff + '"]');
  1923.                    
  1924.                 nOff = _this.offset().top;
  1925.  
  1926.                 if ( !_this.hasClass('mood_start_animation') && !_this.hasClass('animated') && !_this.hasClass('wpb_start_animation') ) {
  1927.                     var delaytime = 200 * ( ind + 0.5 );
  1928.  
  1929.                     if ( typeof _this.attr('data-delay') == 'undefined' || _this.attr('data-delay') === '' || _this.attr('data-delay') == 0 )
  1930.                         _this.attr('data-delay', delaytime);
  1931.                 }
  1932.  
  1933.             }
  1934.  
  1935.         }
  1936.  
  1937.     }
  1938.  
  1939.     window.rtimeOut=function(callback,delay){
  1940.         var dateNow = Date.now,
  1941.             requestAnimation = window.requestAnimationFrame,
  1942.             start = dateNow(),
  1943.             stop,
  1944.             timeoutFunc = function(){
  1945.                 dateNow() - start < delay ? stop || requestAnimation(timeoutFunc) : callback()
  1946.             };
  1947.  
  1948.         requestAnimation(timeoutFunc);
  1949.         return {
  1950.             clear:function(){stop=1}
  1951.         }
  1952.     }
  1953.  
  1954.     function countProgress (el, time) {
  1955.  
  1956.         if ( el.has('.amount-progress') ) {
  1957.  
  1958.             var $calculator = el.find('.amount-progress'),
  1959.                 amount = parseFloat( $calculator.attr('data-amount') ),
  1960.                 position = $calculator.attr('data-position'),
  1961.                 sign = $calculator.attr('data-sign'),
  1962.  
  1963.             counter = function(){
  1964.                 $({progVal:0}).animate({progVal:amount}, {
  1965.                     duration: 2000,
  1966.                     start: function() {
  1967.                         $calculator.delay(500).velocity({opacity:1},1500);
  1968.                     },
  1969.                     step: function() {
  1970.                         if ( position == 'before' )
  1971.                             $calculator.text(sign + Math.ceil(this.progVal));
  1972.                         else
  1973.                             $calculator.text(Math.ceil(this.progVal) + sign);
  1974.                     },
  1975.                     complete: function(){
  1976.                         if ( position == 'before' )
  1977.                             $calculator.text(sign + amount);
  1978.                         else
  1979.                             $calculator.text(amount + sign);
  1980.                     }
  1981.                 });
  1982.             },
  1983.             set = window.rtimeOut(counter, time);
  1984.         }
  1985.  
  1986.         if ( el.hasClass('amount-chart') ) {
  1987.  
  1988.             var animate = parseFloat( el.data('pix-animate') ),
  1989.                 size = parseFloat( el.outerWidth() ),
  1990.                 max = parseFloat( el.data('max') ),
  1991.                 coeff = max / 100,
  1992.                 $span = el.find('span.amount-counter').css({opacity: 1});
  1993.  
  1994.             el.css({
  1995.                 height: size
  1996.             }).easyPieChart({
  1997.                 size: size,
  1998.                 animate: animate,
  1999.                 onStep: function(from, to, currentValue) {
  2000.                     $span.text(Math.round( currentValue * coeff ));
  2001.                 }
  2002.             });
  2003.  
  2004.             $(window).trigger('scroll');
  2005.  
  2006.             var clearSet;
  2007.  
  2008.             $(window).on('resize', function(){
  2009.  
  2010.                 size = parseFloat( el.outerWidth() );
  2011.  
  2012.                 el.css({
  2013.                     height: size
  2014.                 });
  2015.  
  2016.                 clearTimeout(clearSet);
  2017.                 clearSet = setTimeout(function(){
  2018.                     el.removeData('easyPieChart').find('canvas').remove();
  2019.                     el.easyPieChart({
  2020.                         size: size,
  2021.                         animate: 1
  2022.                     });
  2023.                 }, 100);
  2024.             });
  2025.         }
  2026.  
  2027.         if ( el.hasClass('numeric-counter') ) {
  2028.  
  2029.             var amount = parseFloat( el.attr('data-value') ),
  2030.                 $span = $('.counter-amount', el).css({opacity: 1});
  2031.  
  2032.             $span.velocity({
  2033.                 tween: [ amount, 0 ]
  2034.             },{
  2035.                 duration: 2000,
  2036.                 progress: function(elements, c, r, s, t) {
  2037.                     $span.text(Math.ceil(t))
  2038.                 }
  2039.             });
  2040.         }
  2041.  
  2042.     }
  2043.  
  2044.     function elReveal (el, time) {
  2045.  
  2046.         var repeat = el.attr('data-fx-repeat'),
  2047.  
  2048.         reveal = function(){
  2049.  
  2050.             if ( !el.hasClass('mood_counted') ) {
  2051.                 countProgress(el, time);
  2052.                 el.addClass('mood_counted');
  2053.             }
  2054.  
  2055.             if ( typeof repeat == 'undefined' || repeat != 'yes' ) {
  2056.                 if ( !el.hasClass('mood_animated') ) {
  2057.                     el.addClass('mood_start_animation').addClass('animated').addClass('wpb_start_animation')
  2058.                         .on('transitionend webkitTransitionEnd oTransitionEnd', function () {
  2059.                             $(this).removeClass('wpb_animate_when_almost_visible pix_animate_bar_almost_visible wpb_top-to-bottom top-to-bottom wpb_bottom-to-top bottom-to-top wpb_left-to-right left-to-right wpb_right-to-left right-to-left wpb_appear mood_start_animation bounceIn bounceInDown bounceInLeft bounceInRight bounceInUp fadeIn fadeInDown fadeInDownBig fadeInLeft fadeInLeftBig fadeInRight fadeInRightBig fadeInUp fadeInUpBig flipInX flipInY lightSpeedIn rotateIn rotateInDownLeft rotateInDownRight rotateInUpLeft rotateInUpRight rollIn zoomIn zoomInDown zoomInLeft zoomInRight zoomInUp slideInDown slideInLeft slideInRight slideInUp')
  2060.                                 .addClass('mood_animated');
  2061.                     });
  2062.                 }
  2063.  
  2064.                 if ( el.attr('data-fx-reveal') == 'yes' )
  2065.                     el.attr('data-fx-reveal', 'no');
  2066.  
  2067.             } else {
  2068.                 el.removeClass('reloading-animation').addClass('mood_start_animation').addClass('animated').addClass('wpb_start_animation');
  2069.  
  2070.                 if ( el.attr('data-fx-reveal') == 'yes' )
  2071.                     el.attr('data-fx-reveal', 'no').removeClass('reloading-animation');
  2072.  
  2073.             }
  2074.  
  2075.         },
  2076.         set = window.rtimeOut(reveal, time);
  2077.     }
  2078.  
  2079.     function elHide (el) {
  2080.         var hide = function(){
  2081.             if ( el.hasClass('mood_start_animation') || el.hasClass('animated') ) {
  2082.                 var delay = parseFloat( el.attr('data-delay') );
  2083.                 el.removeAttr('data-delay').addClass('reloading-animation').removeClass('mood_start_animation').removeClass('animated').removeClass('wpb_start_animation').removeClass('mood_counted').attr('data-delay', delay);
  2084.             }
  2085.             if ( el.attr('data-fx-reveal') == 'no' )
  2086.                 el.attr('data-fx-reveal', 'yes').addClass('reloading-animation');
  2087.  
  2088.         },
  2089.         set = window.rtimeOut(hide);
  2090.     }
  2091.  
  2092.     function checkElements() {
  2093.  
  2094.         if ($checkElements !== null) {
  2095.  
  2096.             var iEl,
  2097.                 lenEl = $checkElements.length,
  2098.                 action = 0;
  2099.  
  2100.             for ( iEl = 0; iEl < lenEl; iEl++) {
  2101.  
  2102.                 var _this = $checkElements.eq(iEl),
  2103.                     delay = parseFloat(_this.attr('data-delay')),
  2104.                     repeat = _this.attr('data-fx-repeat'),
  2105.                     inView = _this.data('inview');
  2106.  
  2107.                 if ( ! _this.hasClass( 'vc-row-mood-scroll-down' ) ) {
  2108.  
  2109.                     if ( MOOD.isElementInViewport( _this ) ) {
  2110.                         elReveal(_this, delay);
  2111.                     }
  2112.  
  2113.                     if ( typeof repeat != 'undefined' && repeat == 'yes' ) {
  2114.                         if ( ! MOOD.isElementInViewport( _this, -100 ) ) {
  2115.                             elHide(_this);
  2116.                         }
  2117.                     }
  2118.  
  2119.                 } else {
  2120.  
  2121.                     if ( MOOD.isBelowViewport( _this, 10 ) ) {
  2122.                         _this.addClass('fake_hidden');
  2123.                     } else {
  2124.                         _this.removeClass('fake_hidden');
  2125.                     }
  2126.  
  2127.                 }
  2128.  
  2129.             }
  2130.         }
  2131.     }
  2132.  
  2133.     if (!Date.now) {
  2134.         Date.now = function() { return new Date().getTime(); };
  2135.     }
  2136.  
  2137.     if(!window.requestAnimationFrame) {
  2138.         (function() {
  2139.             'use strict';
  2140.            
  2141.             var vendors = ['webkit', 'moz'];
  2142.             for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
  2143.                 var vp = vendors[i];
  2144.                 window.requestAnimationFrame = window[vp+'RequestAnimationFrame'];
  2145.                 window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame']
  2146.                                            || window[vp+'CancelRequestAnimationFrame']);
  2147.             }
  2148.             if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy
  2149.                 || !window.requestAnimationFrame || !window.cancelAnimationFrame) {
  2150.                 var lastTime = 0;
  2151.                 window.requestAnimationFrame = function(callback) {
  2152.                     var now = Date.now();
  2153.                     var nextTime = Math.max(lastTime + 16, now);
  2154.                     return setTimeout(function() { callback(lastTime = nextTime); },
  2155.                                       nextTime - now);
  2156.                 };
  2157.                 window.cancelAnimationFrame = clearTimeout;
  2158.             }
  2159.         }());
  2160.     }
  2161.  
  2162.  
  2163.     $(window).on('scroll.pix-inview', function() {
  2164.         onScroll();
  2165.     });
  2166.  
  2167.     var timeout;
  2168.     $(window).on('resize.pix-inview load.pix-inview orientationchange.pix-inview pix-inview isotoped', function() {
  2169.         clearTimeout(timeout);
  2170.         timeout = setTimeout(function() {
  2171.             delayElements();
  2172.             onResize();
  2173.             onScroll();
  2174.         }, 10);
  2175.     });
  2176.  
  2177.     delayElements();
  2178.     onScroll();
  2179.  
  2180.     $('svg.drawing').each(function(){
  2181.  
  2182.         var $svg = $(this),
  2183.             $svg0 = $svg[0],
  2184.             id = MOOD.guidGenerator(),
  2185.             delay = parseFloat( $svg.attr('data-delay') ),
  2186.             repeat = $svg.attr('data-fx-repeat'),
  2187.             time = $svg.attr('data-animation-time'),
  2188.             duration = typeof time != 'undefined' && time !== '' ? parseFloat(time) : 300,
  2189.             svgTimeOut;
  2190.  
  2191.         $svg.attr('id', id);
  2192.  
  2193.         if ( typeof delay == 'undefined' || delay === '' )
  2194.             return false;
  2195.  
  2196.         var startAnimation = function(){
  2197.             new Vivus(id, {
  2198.                 type: 'delayed',
  2199.                 duration: duration,
  2200.                 animTimingFunction: Vivus.LINEAR,
  2201.                 start: 'manual',
  2202.                 onReady: function (vivusObj) {
  2203.                     var listener = function () {
  2204.                         if ( MOOD.isElementInViewport( $svg0 ) ) {
  2205.                             svgTimeOut = setTimeout( function(){
  2206.                                 $svg.css({ opacity: 1 });
  2207.                                 vivusObj.play();
  2208.                             }, delay );
  2209.                         }
  2210.                         if ( typeof repeat != 'undefined' && repeat == 'yes' ) {
  2211.                             if ( ! MOOD.isElementInViewport( $svg, -100 ) ) {
  2212.                                 $svg.css({ opacity: 0 });
  2213.                                 vivusObj.play(-100);
  2214.                             }
  2215.                         }
  2216.                     };
  2217.                     listener();
  2218.                     $(window).on('scroll.pix-inview', function() {
  2219.                         listener();
  2220.                     });
  2221.                     var timeoutVivus;
  2222.                     $(window).on('resize.pix-inview orientationchange.pix-inview', function() {
  2223.                         clearTimeout(timeoutVivus);
  2224.                         timeoutVivus = setTimeout(function() {
  2225.                             listener();
  2226.                         }, 10);
  2227.                     });
  2228.  
  2229.                 }
  2230.             });
  2231.         };
  2232.  
  2233.         startAnimation();
  2234.  
  2235.     });
  2236.  
  2237. };
  2238.  
  2239. MOOD.verticalTitles = function(){
  2240.     var titlePos = function(){
  2241.         $('.mood-vertical-title').each(function(){
  2242.             var $title = $(this),
  2243.                 height = $title.height();
  2244.  
  2245.             $title.css({
  2246.                 marginTop: '-' + ( height / 2 ) + 'px'
  2247.             });
  2248.         });
  2249.     };
  2250.     titlePos();
  2251.     $(window).on('load', titlePos);
  2252. };
  2253.  
  2254. MOOD.masonry = function(){
  2255.  
  2256.     //WooCommerce
  2257.     var $products = $('.products').not('.upsells').not('.related').each(function(){
  2258.         var $this = $(this),
  2259.             $parent = $this.parents('.mood-woo-styler').eq(0),
  2260.             layout;
  2261.  
  2262.         if ( $parent.length && typeof $parent.attr('data-layout') != 'undefined' && $parent.attr('data-layout') !== '' ) {
  2263.             layout = $parent.attr('data-layout');
  2264.         } else {
  2265.             layout = 'fitRows';
  2266.         }
  2267.  
  2268.         if ( layout != 'carousel' ) {
  2269.  
  2270.             $this.imagesLoaded({ background: true }, function() {
  2271.                 $this.isotope({
  2272.                     masonry: {
  2273.                         columnWidth: 1
  2274.                     },
  2275.                     //itemSelector: 'li',
  2276.                     hiddenStyle: {
  2277.                         opacity: 0
  2278.                     },
  2279.                     visibleStyle: {
  2280.                         opacity: 1
  2281.                     },
  2282.                     layoutMode: layout,
  2283.                     isOriginLeft: !mood_rtl
  2284.                 });
  2285.  
  2286.                 $( window ).trigger( 'isotoped' );
  2287.  
  2288.                 $( document.body ).on('video-fit', function () {
  2289.                     if ( MOOD.isElementInViewport($this) )
  2290.                         $this.isotope('layout');
  2291.                         $( window ).trigger( 'isotoped' );
  2292.                 });
  2293.             });
  2294.  
  2295.         }
  2296.  
  2297.     });
  2298.  
  2299.     //Post shortcode
  2300.     var $posts = $('.post-list[data-grid]').not('[data-grid="carousel"]').each(function(){
  2301.         var $this = $(this),
  2302.             layout = $this.data('grid'),
  2303.             gutter = $this.data('gutter'),
  2304.             width = parseFloat( $this.data('width') ),
  2305.             height = parseFloat( $this.data('height') ),
  2306.             cols = parseFloat( $this.data('columns') ),
  2307.             metro = $this.data('metro'),
  2308.             $filter = $this.parents('.post-list-spacer').eq(0).prev('.post-list-filter-wrap').find('.pix-portfolio-filters, .pix-post-filters'),
  2309.             isoOptions,
  2310.             wrap_w,
  2311.             tot_gutter = gutter * cols,
  2312.             single_w, single_w_tot,
  2313.             artLenght = $('> article, > li, > div', $this).length;
  2314.  
  2315.         if ( !$filter.length ) {
  2316.             $filter = $this.prev('.post-list-filter-wrap').find('.pix-portfolio-filters, .pix-post-filters');
  2317.         }
  2318.  
  2319.         layout = layout !== '' && layout !== null ? layout : 'fitRows';
  2320.         gutter = gutter !== '' ? parseFloat( gutter ) : 30;
  2321.         width = width !== 0 ? width : 4;
  2322.         cols = cols !== 0 ? cols : 3;
  2323.  
  2324.         $('> article, > div, > li', $this).addClass('isotoping');
  2325.  
  2326.         $('a', $filter).each(function(){
  2327.             var tag = $(this).data('filter-tag');
  2328.  
  2329.             if ( !$('.tag-' + tag, $this ).length )
  2330.                 $(this).addClass('hidden_important');
  2331.         });
  2332.  
  2333.         var metroTmout;
  2334.  
  2335.         var postIsotope = function(){
  2336.             $this.imagesLoaded({ background: true },  function() {
  2337.  
  2338.                 isoOptions = {
  2339.                     masonry: {
  2340.                         columnWidth: 1
  2341.                     },
  2342.                     itemSelector: 'article, li, .isotoping',
  2343.                     hiddenStyle: {
  2344.                         opacity: 0
  2345.                     },
  2346.                     visibleStyle: {
  2347.                         opacity: 1
  2348.                     },
  2349.                     layoutMode: layout,
  2350.                     isOriginLeft: !mood_rtl,
  2351.                     resize: false
  2352.                 };
  2353.  
  2354.                 $this.isotope(isoOptions);
  2355.                 $( window ).trigger( 'isotoped' );
  2356.  
  2357.                 $('a[data-filter-tag]', $filter).on('click', function(e){
  2358.  
  2359.                     e.preventDefault();
  2360.  
  2361.                     $('a[data-filter-tag].selected', $filter).removeClass('selected');
  2362.                     $(this).addClass('selected');
  2363.  
  2364.                     var tag = $(this).data('filter-tag');
  2365.  
  2366.                     isoOptions.filter = '.tag-' + tag;
  2367.  
  2368.                     $this.isotope(isoOptions);
  2369.  
  2370.                     setTimeout(function(){
  2371.                         MOOD.inviewport();
  2372.                         $(window).trigger('pix-parallax');
  2373.                     }, 500);//isotope transition time
  2374.  
  2375.                 });
  2376.  
  2377.                 $( document.body ).on('video-fit metro-layout', function () {
  2378.                     //if ( MOOD.isElementInViewport($this) ) {
  2379.                         $this.isotope('layout');
  2380.                         $( window ).trigger( 'isotoped' );
  2381.                     //}
  2382.                 });
  2383.             });
  2384.         };
  2385.  
  2386.         var setHeights = function(resize){
  2387.  
  2388.             var winW = $(window).width();
  2389.  
  2390.             if ( winW > 1024 ) {
  2391.                 cols = parseFloat( $this.data('columns') );
  2392.             } else if  ( winW <= 1024 && winW > 768 ) {
  2393.                 if ( typeof $this.data('landscape') != 'undefined' && $this.data('landscape') !== '' && $this.data('landscape') != null )
  2394.                     cols = parseFloat( $this.data('landscape') );
  2395.                 else
  2396.                     cols = parseFloat( $this.data('columns') );
  2397.             } else if  ( winW <= 768 && winW > 414 ) {
  2398.                 if ( typeof $this.data('portrait') != 'undefined' && $this.data('portrait') !== '' && $this.data('portrait') != null )
  2399.                     cols = parseFloat( $this.data('portrait') );
  2400.                 else if ( typeof $this.data('landscape') != 'undefined' && $this.data('landscape') !== '' && $this.data('landscape') != null )
  2401.                     cols = parseFloat( $this.data('landscape') );
  2402.                 else
  2403.                     cols = parseFloat( $this.data('columns') );
  2404.             } else {
  2405.                 if ( typeof $this.data('phone') != 'undefined' && $this.data('phone') !== '' && $this.data('phone') != null )
  2406.                     cols = parseFloat( $this.data('phone') );
  2407.                 else if ( typeof $this.data('portrait') != 'undefined' && $this.data('portrait') !== '' && $this.data('portrait') != null )
  2408.                     cols = parseFloat( $this.data('portrait') );
  2409.                 else if ( typeof $this.data('landscape') != 'undefined' && $this.data('landscape') !== '' && $this.data('landscape') != null )
  2410.                     cols = parseFloat( $this.data('landscape') );
  2411.                 else
  2412.                     cols = parseFloat( $this.data('columns') );
  2413.             }
  2414.            
  2415.             tot_gutter = gutter * cols;
  2416.             wrap_w = Math.floor( $this[0].getBoundingClientRect().width ) - 1;
  2417.             single_w = ( wrap_w - tot_gutter ) / cols;
  2418.             single_w_tot = wrap_w / cols;
  2419.  
  2420.             var setHeight = function(len){
  2421.  
  2422.                 var $article = $('> article, > div, > li', $this).eq(len),
  2423.                     newH = height / width,
  2424.                     newH2,
  2425.                     newHhalf,
  2426.                     articleW = $article.data('view'),
  2427.                     newW = Math.floor( single_w_tot ),
  2428.                     newW2 = ( newW * 2 );
  2429.  
  2430.                 newH = Math.floor( newH * single_w );
  2431.                 newH2 = Math.floor( newH * 2 + gutter );
  2432.                 newHhalf = Math.floor( newH / 2 + gutter );
  2433.  
  2434.                 if ( ! $article.hasClass('text-position-right') && ! $article.hasClass('text-position-left') && ! $article.hasClass('text-position-half-left') && ! $article.hasClass('text-position-half-right') ) {
  2435.  
  2436.                     if ( metro == 'yes' ) {
  2437.  
  2438.                         if ( ( $article.attr('data-view') == 'double_both' && cols > 1 ) || $article.attr('data-view') == 'double_height' ) {
  2439.                             newH = newH2;
  2440.                         }
  2441.  
  2442.                         if ( $article.attr('data-view') == 'double_width' && cols == 1 )
  2443.                             newH = newHhalf;
  2444.  
  2445.                         $('.wp-post-image', $article).css({
  2446.                             height: newH
  2447.                         });
  2448.  
  2449.                         if ( $article.hasClass('format-quote') && cols > 1 ) {
  2450.                             $('.entry-text', $article).css({
  2451.                                 height: newH
  2452.                             });
  2453.                         }
  2454.  
  2455.                         if ( ( $article.attr('data-view') == 'double_both' || $article.attr('data-view') == 'double_width' ) && cols > 1 )
  2456.                             newW = newW2;
  2457.  
  2458.                     }
  2459.  
  2460.                     $article.css({
  2461.                         width: newW
  2462.                     });
  2463.  
  2464.                 }
  2465.  
  2466.                 if ( resize ) {
  2467.  
  2468.                     clearTimeout(metroTmout);
  2469.                     metroTmout = setTimeout(function(){
  2470.                         $( document.body ).trigger('metro-layout');
  2471.                     }, 400);
  2472.  
  2473.                 }
  2474.  
  2475.                 if ( (len+1) == artLenght && (typeof resize === "undefined" || resize === null) )
  2476.                     postIsotope();
  2477.  
  2478.             };
  2479.  
  2480.             for(var k = 0, len = artLenght; k < len; k++) {
  2481.                 setHeight(k);
  2482.             }
  2483.  
  2484.         };
  2485.  
  2486.         $( window ).on('infinite-loaded', function () {
  2487.  
  2488.             var $elements = $this.find('> article:not(.isotoping)');
  2489.             $elements.addClass('isotoping');
  2490.  
  2491.             $this.isotope( 'appended', $elements );
  2492.  
  2493.             $this.imagesLoaded({ background: true },  function() {
  2494.                 $this.isotope('layout');
  2495.                 $('.transparent_opacity').removeClass('transparent_opacity');
  2496.                 setTimeout(function(){
  2497.                     MOOD.inviewport();
  2498.                     $(window).trigger('pix-parallax');
  2499.                 }, 500);//isotope transition time
  2500.             });
  2501.  
  2502.             $('a.hidden_important', $filter).each(function(){
  2503.                 var tag = $(this).data('filter-tag');
  2504.  
  2505.                 if ( $('.tag-' + tag, $this ).length )
  2506.                     $(this).removeClass('hidden_important');
  2507.             });
  2508.         });
  2509.  
  2510.         var setResizeOpen;
  2511.         $( window ).on('resize', function(){
  2512.             clearTimeout(setResizeOpen);
  2513.             setResizeOpen = setTimeout( function(){
  2514.                 setHeights(true);
  2515.             }, 250 );
  2516.         });
  2517.  
  2518.         $( document.body ).on('vc-full-width-row', setHeights);
  2519.  
  2520.         setHeights();
  2521.  
  2522.     });
  2523.  
  2524.     var $members = $('.member-list[data-grid]').each(function(){
  2525.         var $this = $(this),
  2526.             layout = $this.data('grid'),
  2527.             isoOptions;
  2528.  
  2529.         $('> li', $this).addClass('isotoping');
  2530.  
  2531.         $this.imagesLoaded({ background: true },  function() {
  2532.  
  2533.             isoOptions = {
  2534.                 masonry: {
  2535.                     columnWidth: 1
  2536.                 },
  2537.                 itemSelector: 'li',
  2538.                 hiddenStyle: {
  2539.                     opacity: 0
  2540.                 },
  2541.                 visibleStyle: {
  2542.                     opacity: 1
  2543.                 },
  2544.                 layoutMode: layout,
  2545.                 isOriginLeft: !mood_rtl
  2546.             };
  2547.  
  2548.             $this.isotope(isoOptions);
  2549.             $( window ).trigger( 'isotoped' );
  2550.  
  2551.             $( document.body ).on('video-fit', function () {
  2552.                 if ( MOOD.isElementInViewport($this) )
  2553.                     $this.isotope('layout');
  2554.                     $( window ).trigger( 'isotoped' );
  2555.             });
  2556.         });
  2557.     });
  2558.  
  2559.     var $gallery = $('.gallery-shortcode-grid').each(function(){
  2560.         var $this = $(this),
  2561.             layout = $this.data('layout'),
  2562.             isoOptions;
  2563.  
  2564.         $('> div', $this).addClass('isotoping');
  2565.  
  2566.         if ( typeof layout == 'undefined' && layout === '' && layout == null )
  2567.             layout = 'fitRows';
  2568.  
  2569.         $this.imagesLoaded({ background: true }, function() {
  2570.  
  2571.             isoOptions = {
  2572.                 masonry: {
  2573.                     columnWidth: 1
  2574.                 },
  2575.                 itemSelector: 'div',
  2576.                 hiddenStyle: {
  2577.                     opacity: 0
  2578.                 },
  2579.                 visibleStyle: {
  2580.                     opacity: 1
  2581.                 },
  2582.                 layoutMode: layout,
  2583.                 isOriginLeft: !mood_rtl
  2584.             };
  2585.  
  2586.             $this.isotope(isoOptions);
  2587.  
  2588.             $( window ).trigger( 'isotoped' );
  2589.  
  2590.         });
  2591.  
  2592.         $( document.body ).on('video-fit', function () {
  2593.             if ( MOOD.isElementInViewport($this) )
  2594.                 $this.isotope('layout');
  2595.                 $( window ).trigger( 'isotoped' );
  2596.         });
  2597.     });
  2598.  
  2599.     $('body, #header_parallax_bg, .pix-parallax').imagesLoaded({ background: true }, function() {
  2600.         $( document.body ).trigger('mood-loaded');
  2601.         $('body').addClass('mood-loaded');
  2602.     });
  2603.  
  2604. };
  2605.  
  2606. MOOD.infiniteScroll = function(){
  2607.  
  2608.     var $post_list = $('.post-list');
  2609.  
  2610.     $post_list.each(function(){
  2611.         var $list = $(this),
  2612.             the_id = $list.attr('id'),
  2613.             $pagination = $list.parents('.post-list-spacer').eq(0).next('.mood-pagination');
  2614.  
  2615.         if ( ! $pagination.length )
  2616.             $pagination = $list.next('.mood-pagination');
  2617.  
  2618.         var $more = $pagination.find('> a.mood-infinite-handle').eq(0),
  2619.             href,
  2620.             $next, next_url,
  2621.             $loadedWrap, $loadedContent,
  2622.             loadTimeout;
  2623.  
  2624.         $more.each(function(e){
  2625.  
  2626.             var $this_more = $(this);
  2627.  
  2628.             var loadContentMore = function(){
  2629.  
  2630.                 clearTimeout(loadTimeout);
  2631.  
  2632.                 href = $this_more.attr('href');
  2633.                 $.ajax({
  2634.                     url: href,
  2635.                     success: function(loadedData){
  2636.                         $loadedWrap = $("<div/>").append(loadedData.replace(/<script(.|\s)*?\/script>/g, ""));
  2637.                         //console.log(loadedData);
  2638.                         $loadedContent = $loadedWrap.find('#' + the_id + ' > article');
  2639.                         $loadedContent.find('.ce-iframe').each(function(){
  2640.                             var $iframe = $(this),
  2641.                                 src = $iframe.attr('data-ce-src');
  2642.                             $iframe.attr('src',src).removeClass('ce-iframe').removeAttr('data-ce-src');
  2643.                         });
  2644.                         $next = $loadedWrap.find('.mood-infinite-handle');
  2645.                         next_url = $next.attr('href');
  2646.                     }, complete: function(){
  2647.                         $('body').append('<div id="loaded-infinite-sandbox" class="hidden_important ' + the_id + '" data-url="' + next_url + '" />');
  2648.                         $('#loaded-infinite-sandbox.' + the_id).append($loadedContent);
  2649.                     }
  2650.                 });
  2651.  
  2652.             };
  2653.  
  2654.             var appendContentMore = function(){
  2655.  
  2656.                 if ( $('#loaded-infinite-sandbox.' + the_id).length ) {
  2657.  
  2658.                     $this_more.removeClass('infinite-loading');
  2659.  
  2660.                     $loadedContent = $('#loaded-infinite-sandbox.' + the_id).html();
  2661.                     next_url = $('#loaded-infinite-sandbox.' + the_id).attr('data-url');
  2662.  
  2663.                     $list.append($loadedContent);
  2664.                     MOOD.init_videos();
  2665.  
  2666.                     if ( $('video').length )
  2667.                         $('video').mediaelementplayer();
  2668.  
  2669.                     MOOD.fitVideos();
  2670.                     MOOD.initColorbox();
  2671.  
  2672.                     if ( typeof next_url != 'undefined' && next_url !== '' && next_url != 'undefined' )
  2673.                         $more.attr('href', next_url);
  2674.                     else
  2675.                         $pagination.slideUp();
  2676.  
  2677.                     $( window ).trigger('infinite-loaded');
  2678.                     $('#loaded-infinite-sandbox.' + the_id).remove();
  2679.  
  2680.                     MOOD.parallax();
  2681.                     MOOD.inviewport();
  2682.                     MOOD.masonry();
  2683.  
  2684.                 } else {
  2685.  
  2686.                     clearTimeout(loadTimeout);
  2687.  
  2688.                     href = $this_more.attr('href');
  2689.                     $.ajax({
  2690.                         url: href,
  2691.                         success: function(loadedData){
  2692.  
  2693.                             $loadedWrap = $("<div/>").append(loadedData.replace(/<script(.|\s)*?\/script>/g, ""));
  2694.                             $loadedContent = $loadedWrap.find('#' + the_id + ' > article');
  2695.                             $loadedContent.find('.ce-iframe').each(function(){
  2696.                                 var $iframe = $(this),
  2697.                                     src = $iframe.attr('data-ce-src');
  2698.                                 $iframe.attr('src',src).removeClass('ce-iframe').removeAttr('data-ce-src');
  2699.                             });
  2700.                             $next = $loadedWrap.find('.mood-infinite-handle');
  2701.                             next_url = $next.attr('href');
  2702.  
  2703.                         }, complete: function(){
  2704.  
  2705.                             $this_more.removeClass('infinite-loading');
  2706.  
  2707.                             $list.append($loadedContent);
  2708.                             MOOD.init_videos();
  2709.  
  2710.                             if ( $('video').length )
  2711.                                 $('video').mediaelementplayer();
  2712.  
  2713.                             MOOD.fitVideos();
  2714.                             //MOOD.initColorbox();
  2715.  
  2716.                             if ( typeof next_url != 'undefined' && next_url !== '' && next_url != 'undefined' )
  2717.                                 $more.attr('href', next_url);
  2718.                             else
  2719.                                 $pagination.slideUp();
  2720.  
  2721.                             $( window ).trigger('infinite-loaded');
  2722.                             $('#loaded-infinite-sandbox.' + the_id).remove();
  2723.  
  2724.                             MOOD.parallax();
  2725.                             MOOD.inviewport();
  2726.                             MOOD.masonry();
  2727.  
  2728.                         }
  2729.                     });
  2730.  
  2731.                 }
  2732.             };
  2733.  
  2734.             $( window ).on('load', function(){
  2735.                 loadTimeout = setTimeout(loadContentMore, 1000);
  2736.             });
  2737.  
  2738.             $( window ).on('infinite-loaded', function(){
  2739.                 loadTimeout = setTimeout(loadContentMore, 1000);
  2740.             });
  2741.  
  2742.             $this_more.on('click', function(e){
  2743.  
  2744.                 var setInfiniteLoader = setInterval(function () {
  2745.                     var dur = 350,
  2746.                         ease = 'swing',
  2747.                         $rect = $('.mood-infinite-handle rect');
  2748.                     $rect
  2749.                         .velocity({ x: 70, width: 0 }, dur, ease)
  2750.                         .velocity({ x: 0, width: 70 }, dur, ease)
  2751.                         .velocity({ x: 0, width: 0 }, dur, ease)
  2752.                         .velocity({ x: 0, width: 70 }, dur, ease);
  2753.                 });        
  2754.  
  2755.                 e.preventDefault();
  2756.                 $this_more.addClass('infinite-loading');
  2757.  
  2758.                 setTimeout(function(){
  2759.                     appendContentMore();
  2760.                     clearInterval(setInfiniteLoader);
  2761.                 }, 1000);
  2762.  
  2763.             });
  2764.  
  2765.         });
  2766.  
  2767.     });
  2768.  
  2769. };
  2770.  
  2771. MOOD.zoomImage = function(){
  2772.     var $body = $('body'),
  2773.         $images = $('.images');
  2774.  
  2775.     if ( $body.hasClass('no-zoom') )
  2776.         return;
  2777.  
  2778.     $images.each(function(){
  2779.         var t = $(this),
  2780.             url = $('a.woocommerce-main-image', t).attr('href');
  2781.         t.zoom({
  2782.             url: url
  2783.         });
  2784.     });
  2785. };
  2786.  
  2787. MOOD.zoomDestroy = function(){
  2788.     $('a.woocommerce-main-image').trigger('zoom.destroy');
  2789.     $('.images .zoomImg').remove();
  2790. };
  2791.  
  2792. MOOD.productImageCarousel = function(){
  2793.     var $product_images = $('.single-product .images');
  2794.  
  2795.     $product_images.each(function(){
  2796.         var $images = $(this),
  2797.             $main = $('a.woocommerce-main-image', $images),
  2798.             $thumbs = $('.thumbnails', $images),
  2799.             href, src;
  2800.  
  2801.         $('a', $thumbs).on('click touchstart', function(e){
  2802.             e.preventDefault();
  2803.             e.stopPropagation();
  2804.             if ( $(this).hasClass('selected') )
  2805.                 return false;
  2806.  
  2807.             $('a.selected', $thumbs).removeClass('selected');
  2808.             $(this).addClass('selected');
  2809.  
  2810.             href = $(this).attr('href');
  2811.             src = $(this).attr('data-src');
  2812.  
  2813.             $images.velocity({
  2814.                 opacity: 0.5
  2815.             }, {
  2816.                 duration: 250,
  2817.                 easing: [ 0.140, 0.560, 0.710, 0.975 ],
  2818.                 complete: function(){
  2819.                     $('<img />').one('load',function(){
  2820.                         $main.attr('href', href).find('img').attr('src', src).removeAttr('srcset').removeAttr('sizes');
  2821.                         MOOD.zoomDestroy();
  2822.                         MOOD.zoomImage();
  2823.                         $images.velocity({
  2824.                             opacity: 1
  2825.                         });
  2826.                     }).attr('src', src).each(function() {
  2827.                         if(this.complete) {
  2828.                             $(this).load();
  2829.                         }
  2830.                     });
  2831.                 }
  2832.             });
  2833.         });
  2834.     });
  2835. };
  2836.  
  2837. MOOD.resetVariations = function(){
  2838.     $('form.variations_form').each(function(){
  2839.         var $form = $(this),
  2840.             selected,
  2841.             $input = $('input.variation_id', $form),
  2842.             $thumbnails = $form.parents('.single-product').eq(0).find('.images .thumbnails').eq(0),
  2843.             variation_id,
  2844.             val,
  2845.             ind,
  2846.             variations,
  2847.             src,
  2848.             i, l,
  2849.             set;
  2850.         var changeVariation = function(){
  2851.             selected = $('option:selected', $form);
  2852.             ind = selected.index();
  2853.             val = selected.val();
  2854.  
  2855.             if ( ind > 0 ) {
  2856.                 variations = $form.data('product_variations');
  2857.                 variation_id = $input.val();
  2858.                 l = variations.length;
  2859.  
  2860.                 for (i = 0; i < l; i++) {
  2861.  
  2862.                     if ( variations[i].variation_id == variation_id ) {
  2863.                         src = variations[i].image_src;
  2864.  
  2865.                         if ( src !== '' && typeof src != 'undefined' ) {
  2866.                             src = MOOD.basename(src);
  2867.                             //console.log(src);
  2868.                             $('a[href*="' + src + '"]', $thumbnails).click();
  2869.                         } else {
  2870.                             $('a', $thumbnails).eq(0).click();
  2871.                         }
  2872.                     }
  2873.                 }
  2874.             } else {
  2875.                 $('a', $thumbnails).eq(0).click();
  2876.             }
  2877.         };
  2878.         $(document).on( 'found_variation reset_image', $form, changeVariation );
  2879.     });
  2880. };
  2881.  
  2882. MOOD.basename = function(str) {
  2883.     return str.replace(/\\/g,'/').replace( /.*\//, '' );
  2884. };
  2885.  
  2886. MOOD.product_quickview = function(){
  2887.     $('ul.products li.product .wpb_wl_preview').each(function(){
  2888.         var $button = $(this),
  2889.             href = $button.data('href'),
  2890.             $href = $('[data-id="' + href.replace(/^#/,"") + '"]').eq(0),
  2891.             rel = $button.data('rel'),
  2892.             h;
  2893.  
  2894.         var href_content = '';
  2895.         $href.contents().filter(function(){
  2896.             return this.nodeType == 8;
  2897.         }).each(function(i, e){
  2898.             href_content = href_content + e.nodeValue;
  2899.         });
  2900.         if ( href_content != '' )
  2901.             $href.html(href_content);
  2902.  
  2903.         h = parseFloat($('.images .wp-post-image', $href).attr('height'));
  2904.  
  2905.         $button.colorbox({
  2906.             inline: true,
  2907.             href: $href,
  2908.             rel: rel,
  2909.             //maxHeight: "90%",
  2910.             height: h,
  2911.             maxWidth: "80%",
  2912.             onComplete: function(){
  2913.                 MOOD.zoomDestroy();
  2914.                 MOOD.zoomImage();
  2915.                 MOOD.productImageCarousel();
  2916.                 MOOD.resetVariations();
  2917.             }
  2918.         });
  2919.     });
  2920. };
  2921.  
  2922. window.vc_prettyPhoto = function () {
  2923.     $('.prettyphoto').each(function(){
  2924.         $(this).removeClass('prettyphoto').addClass('cbox');
  2925.         var relData = $(this).attr('rel');
  2926.         $(this).removeAttr('rel').attr('data-rel', relData);
  2927.     });
  2928.  
  2929.     MOOD.initColorbox();
  2930. };
  2931.  
  2932. MOOD.initColorbox = function(){
  2933.  
  2934.     if($.isFunction($.fn.colorbox) /*&& typeof(pix_style_enable_colorbox)!='undefined' && pix_style_enable_colorbox===true*/) {
  2935.  
  2936.         var $window = $(window),
  2937.             notIn = ':not(.noColorBox,.nocolorbox,.letmebe,.zoom)',
  2938.             elems,
  2939.             $elems;
  2940.  
  2941.         $('div.gallery a').attr('rel','gallery');
  2942.  
  2943.         var initColorboxCall = function(){
  2944.             elems = ".cboxiframe, .cboxinline, .cbox, a[href$='.jpg']"+notIn+", a[href*='.jpg?']"+notIn+", a[href$='.jpeg']"+notIn+", a[href*='.jpeg?']"+notIn+", a[href$='.gif']"+notIn+", a[href*='.gif?']"+notIn+", a[href$='.png']"+notIn+", a[href*='.png?']"+notIn;
  2945.             $elems = $(elems);
  2946.             $elems.each(function(){
  2947.                 var $el = $(this),
  2948.                     dataRel = $el.data('rel'),
  2949.                     dataTitle = $el.data('title'),
  2950.                     dataName = $el.find('img').data('name'),
  2951.                     dataSubtitle = $el.find('img').data('subtitle'),
  2952.                     dataNotes = $el.find('img').data('notes'),
  2953.                     href = $el.attr('href'),
  2954.                     iframe = $el.hasClass('cboxiframe'),
  2955.                     noprevent = $el.hasClass('noprevent'),
  2956.                     inline = $el.hasClass('cboxinline'),
  2957.                     innerW = typeof $el.data('size') != 'undefined' ? $el.data('size')[0] : false,
  2958.                     innerH = typeof $el.data('size') != 'undefined' ? $el.data('size')[1] : false,
  2959.                     videoW = 0,
  2960.                     videoH = 0,
  2961.                     videoR = 0,
  2962.                     winW, winH;
  2963.  
  2964.                 var cboxOptions = {
  2965.                     maxWidth: "85%",
  2966.                     maxHeight: "85%",
  2967.                     rel: dataRel,
  2968.                     title: dataTitle,
  2969.                     fixed: true,
  2970.                     returnFocus: false,
  2971.                     iframe: iframe,
  2972.                     inline: inline,
  2973.                     innerWidth: innerW,
  2974.                     innerHeight: innerH,
  2975.                     scrolling: !inline,
  2976.                     onComplete: function(){
  2977.                         if ( ( typeof dataName != 'undefined' && dataName != '' ) || ( typeof dataSubtitle != 'undefined' && dataSubtitle != '' ) || ( typeof dataNotes != 'undefined' && dataNotes != '' ) ) {
  2978.                             $('.cboxPhoto').before('<div id="cbox-extra" />');
  2979.  
  2980.                             if ( typeof dataName != 'undefined' && dataName != '' ) {
  2981.                                 $('#cbox-extra').append('<div class="cbox-name"><h4>' + dataName + '</h4></div>');
  2982.                             }
  2983.  
  2984.                             if ( typeof dataSubtitle != 'undefined' && dataSubtitle != '' ) {
  2985.                                 $('#cbox-extra').append('<div class="cbox-subtitle"><small>' + dataSubtitle + '</small></div>');
  2986.                             }
  2987.  
  2988.                             if ( typeof dataNotes != 'undefined' && dataNotes != '' ) {
  2989.                                 $('#cbox-extra').append('<div class="cbox-notes"><p>' + dataNotes + '</p></div>');
  2990.                             }
  2991.  
  2992.                             setTimeout(function(){
  2993.                                 $('#cbox-extra').addClass('revealed');
  2994.                             }, 250);
  2995.                         } else {
  2996.                             $('#cbox-extra').remove();
  2997.                         }
  2998.  
  2999.                         if ( !iframe && !noprevent )
  3000.                             $('#cboxLoadedContent').prepend('<div class="cboxPrevent" />');
  3001.                         $.data(document.body, 'pix-check-colorbox-opened',true);
  3002.                         $.data(document.body, 'pix-check-colorbox-open',$el);
  3003.                         MOOD.init_videos();
  3004.  
  3005.                         if ( $('#cboxLoadedContent').find('audio, video').length ) {
  3006.                             var $media = $('#cboxLoadedContent').find('audio, video');
  3007.                             if ( $media.attr('autoplay') == 'autoplay' ) {
  3008.                                 $media[0].player.setCurrentTime(0);
  3009.                                 $media[0].player.play();
  3010.                             }
  3011.                         }
  3012.                     },
  3013.                     onOpen: function(){
  3014.                         if ( ( typeof dataName != 'undefined' && dataName != '' ) || ( typeof dataSubtitle != 'undefined' && dataSubtitle != '' ) || ( typeof dataNotes != 'undefined' && dataNotes != '' ) ) {
  3015.                             $('.cboxPhoto').before('<div id="cbox-extra" />');
  3016.  
  3017.                             if ( typeof dataName != 'undefined' && dataName != '' ) {
  3018.                                 $('#cbox-extra').append('<div class="cbox-name"><h4>' + dataName + '</h4></div>');
  3019.                             }
  3020.  
  3021.                             if ( typeof dataSubtitle != 'undefined' && dataSubtitle != '' ) {
  3022.                                 $('#cbox-extra').append('<div class="cbox-subtitle"><small>' + dataSubtitle + '</small></div>');
  3023.                             }
  3024.  
  3025.                             if ( typeof dataNotes != 'undefined' && dataNotes != '' ) {
  3026.                                 $('#cbox-extra').append('<div class="cbox-notes"><p>' + dataNotes + '</p></div>');
  3027.                             }
  3028.  
  3029.                             setTimeout(function(){
  3030.                                 $('#cbox-extra').addClass('revealed');
  3031.                             }, 250);
  3032.                         } else {
  3033.                             $('#cbox-extra').remove();
  3034.                         }
  3035.                     },
  3036.                     onClosed: function(){
  3037.                         $.removeData(document.body, 'pix-check-colorbox-opened');
  3038.                         if ( !iframe )
  3039.                             $('#cboxLoadedContent .cboxPrevent').remove();
  3040.                     }
  3041.                 };
  3042.  
  3043.                 $el.colorbox(cboxOptions);
  3044.  
  3045.                 var setResizeOpen,
  3046.                 resizeCBox = function(){
  3047.                     $.data(document.body, 'pix-check-colorbox-open').colorbox.close();
  3048.                 };
  3049.                 $window.on('resize', function(){
  3050.                     if ( typeof $.data(document.body, 'pix-check-colorbox-opened') !== 'undefined' && $.data(document.body, 'pix-check-colorbox-opened') === true ) {
  3051.                         clearTimeout(setResizeOpen);
  3052.                         setResizeOpen = setTimeout( resizeCBox, 250 );
  3053.                     }
  3054.                 });
  3055.             });
  3056.  
  3057.         };
  3058.     }
  3059.  
  3060.     initColorboxCall();
  3061.     $(window).on('infinite-loaded', function(){
  3062.         initColorboxCall();
  3063.     });
  3064.  
  3065.     $(document).on('cbox_open', function(){
  3066.         $('html, body').addClass('overflow_hidden');
  3067.     });
  3068.  
  3069.     $(document).on('cbox_closed', function(){
  3070.         $('html, body').removeClass('overflow_hidden');
  3071.     });
  3072. };
  3073.  
  3074. MOOD.accordion = function(){
  3075.     $( ".woocommerce-tabs" ).accordion({
  3076.         heightStyle: "content",
  3077.         create: function(event, ui){
  3078.             if ( $('.ui-accordion-header', this).length <= 1 )
  3079.                 $(this).addClass('single-tab');
  3080.         }
  3081.     });
  3082.  
  3083.     /*$( "#comments" ).accordion({
  3084.         active: 0,
  3085.         collapsible: true,
  3086.         heightStyle: "content",
  3087.         header: "h3.comments-title"
  3088.     });*/
  3089. };
  3090.  
  3091. MOOD.sharingWindows = function(){
  3092.  
  3093.     var $links = $('a.mood-sharing');
  3094.  
  3095.     $links.each(function(){
  3096.         var $this = $(this),
  3097.             url = $this.attr('href'),
  3098.             $window = $(window),
  3099.             left = (screen.width/2)-250,
  3100.             top = (screen.height/4);
  3101.  
  3102.         $this.on('click', function(e){
  3103.             e.preventDefault();
  3104.             window.open(url, '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=500, height=250, left=' + left + ', top=' + top);
  3105.         });
  3106.     });
  3107.  
  3108. };
  3109.  
  3110. MOOD.postSliders = function(){
  3111.  
  3112.     $('.mood-woo-styler[data-layout="carousel"] ul.products').each(function(){
  3113.         var $carousel = $(this).imagesLoaded({ background: true }, function() {
  3114.             var $parent = $carousel.parents('.mood-woo-styler').eq(0),
  3115.                 responsive = [],
  3116.                 dots;
  3117.  
  3118.             if ( $parent.length && typeof $parent.attr('data-dots') != 'undefined' && $parent.attr('data-dots') !== '' ) {
  3119.                 dots = true;
  3120.             } else {
  3121.                 dots = false;
  3122.             }
  3123.  
  3124.             if ( $parent.data('landscape')!=='' ) {
  3125.                 responsive.push({
  3126.                     breakpoint: 1025,
  3127.                     settings: {
  3128.                         slidesToShow: $parent.data('landscape')
  3129.                     }
  3130.                 });
  3131.             }
  3132.             if ( $parent.data('portrait')!=='' ) {
  3133.                 responsive.push({
  3134.                     breakpoint: 769,
  3135.                     settings: {
  3136.                         slidesToShow: $parent.data('portrait')
  3137.                     }
  3138.                 });
  3139.             }
  3140.             if ( $parent.data('phone')!=='' ) {
  3141.                 responsive.push({
  3142.                     breakpoint: 415,
  3143.                     settings: {
  3144.                         slidesToShow: $parent.data('phone')
  3145.                     }
  3146.                 });
  3147.             }
  3148.             $carousel.on('init beforeChange breakpoint reInit setPosition', function(event, slick, currentSlide, nextSlide){
  3149.                 var height = 0;
  3150.                 $('[aria-hidden="false"]', $carousel).each(function(){
  3151.                     var thisH = $(this).outerHeight();
  3152.                     if ( height < thisH ) {
  3153.                         height = thisH;
  3154.                     }
  3155.                 });
  3156.  
  3157.                 $carousel.css({height: height});
  3158.  
  3159.             }).on('init', function(event, slick, currentSlide, nextSlide){
  3160.                 var marginLeft = parseFloat( $carousel.css('margin-left') );
  3161.  
  3162.                 if ( marginLeft < 0 ) {
  3163.                     var paddingLeft = marginLeft * -1;
  3164.                     $('.slick-dots', $carousel).css({
  3165.                         paddingLeft: paddingLeft
  3166.                     });
  3167.                 }
  3168.  
  3169.                 Waypoint.refreshAll();
  3170.                 $(window).trigger('pix-parallax');
  3171.  
  3172.             }).slick({
  3173.                 slide: 'li',
  3174.                 prevArrow: $('button.post-list-prev', $carousel),
  3175.                 nextArrow: $('button.post-list-next', $carousel),
  3176.                 infinite: true,
  3177.                 slidesToShow: $carousel.data('columns'),
  3178.                 slidesToScroll: 1,
  3179.                 swipeToSlide: true,
  3180.                 dots: dots,
  3181.                 responsive: responsive,
  3182.                 adaptiveHeight: false
  3183.             });
  3184.         });
  3185.     });
  3186.  
  3187.     $('.post-list[data-grid="carousel"]').each(function(){
  3188.         var $carousel = $(this).imagesLoaded({ background: true }, function() {
  3189.             var responsive = [];
  3190.  
  3191.             if ( $carousel.data('landscape')!=='' ) {
  3192.                 responsive.push({
  3193.                     breakpoint: 1025,
  3194.                     settings: {
  3195.                         slidesToShow: $carousel.data('landscape')
  3196.                     }
  3197.                 });
  3198.             }
  3199.             if ( $carousel.data('portrait')!=='' ) {
  3200.                 responsive.push({
  3201.                     breakpoint: 769,
  3202.                     settings: {
  3203.                         slidesToShow: $carousel.data('portrait')
  3204.                     }
  3205.                 });
  3206.             }
  3207.             if ( $carousel.data('phone')!=='' ) {
  3208.                 responsive.push({
  3209.                     breakpoint: 415,
  3210.                     settings: {
  3211.                         slidesToShow: $carousel.data('phone')
  3212.                     }
  3213.                 });
  3214.             }
  3215.             $carousel.on('init beforeChange breakpoint reInit setPosition', function(event, slick, currentSlide, nextSlide){
  3216.                 var height = 0;
  3217.                 $('[aria-hidden="false"]', $carousel).each(function(){
  3218.                     var thisH = $(this).outerHeight();
  3219.                     if ( height < thisH ) {
  3220.                         height = thisH;
  3221.                     }
  3222.                 });
  3223.  
  3224.                 $carousel.css({height: height});
  3225.  
  3226.             }).on('init', function(event, slick, currentSlide, nextSlide){
  3227.                 var marginLeft = parseFloat( $carousel.css('margin-left') );
  3228.  
  3229.                 if ( marginLeft < 0 ) {
  3230.                     var paddingLeft = marginLeft * -1;
  3231.                     $('.slick-dots', $carousel).css({
  3232.                         paddingLeft: paddingLeft
  3233.                     });
  3234.                 }
  3235.  
  3236.                 Waypoint.refreshAll();
  3237.                 $(window).trigger('pix-parallax');
  3238.  
  3239.             }).slick({
  3240.                 slide: 'article',
  3241.                 prevArrow: $('button.post-list-prev', $carousel),
  3242.                 nextArrow: $('button.post-list-next', $carousel),
  3243.                 infinite: true,
  3244.                 slidesToShow: $carousel.data('columns'),
  3245.                 slidesToScroll: 1,
  3246.                 swipeToSlide: true,
  3247.                 responsive: responsive,
  3248.                 adaptiveHeight: false
  3249.             });
  3250.         });
  3251.     });
  3252.  
  3253.     $('.testimonial-list[data-grid="carousel"]').each(function(){
  3254.         var $carousel = $(this).imagesLoaded({ background: true }, function() {
  3255.             var responsive = [];
  3256.  
  3257.             if ( $carousel.data('landscape')!=='' ) {
  3258.                 responsive.push({
  3259.                     breakpoint: 1025,
  3260.                     settings: {
  3261.                         slidesToShow: $carousel.data('landscape')
  3262.                     }
  3263.                 });
  3264.             }
  3265.             if ( $carousel.data('portrait')!=='' ) {
  3266.                 responsive.push({
  3267.                     breakpoint: 769,
  3268.                     settings: {
  3269.                         slidesToShow: $carousel.data('portrait')
  3270.                     }
  3271.                 });
  3272.             }
  3273.             if ( $carousel.data('phone')!=='' ) {
  3274.                 responsive.push({
  3275.                     breakpoint: 415,
  3276.                     settings: {
  3277.                         slidesToShow: $carousel.data('phone')
  3278.                     }
  3279.                 });
  3280.             }
  3281.             $carousel.on('init beforeChange breakpoint reInit setPosition', function(event, slick, currentSlide, nextSlide){
  3282.                 var height = 0;
  3283.                 $('[aria-hidden="false"]', $carousel).each(function(){
  3284.                     var thisH = $(this).outerHeight();
  3285.                     if ( height < thisH ) {
  3286.                         height = thisH;
  3287.                     }
  3288.                 });
  3289.  
  3290.                 $carousel.css({height: height});
  3291.  
  3292.             }).on('init', function(event, slick){
  3293.                 var marginLeft = parseFloat( $carousel.css('margin-left') );
  3294.  
  3295.                 if ( marginLeft < 0 ) {
  3296.                     var paddingLeft = marginLeft * -1;
  3297.                     $('.slick-dots', $carousel).css({
  3298.                         paddingLeft: paddingLeft
  3299.                     });
  3300.                 }
  3301.  
  3302.                 Waypoint.refreshAll();
  3303.                 $(window).trigger('pix-parallax');
  3304.  
  3305.             }).slick({
  3306.                 slide: 'li',
  3307.                 dots: true,
  3308.                 prevArrow: false,
  3309.                 nextArrow: false,
  3310.                 infinite: true,
  3311.                 slidesToShow: $carousel.data('columns'),
  3312.                 slidesToScroll: 1,
  3313.                 swipeToSlide: true,
  3314.                 responsive: responsive,
  3315.                 adaptiveHeight: false
  3316.             });
  3317.         });
  3318.     });
  3319.  
  3320.     $('.slick-carousel').each(function(){
  3321.         var $carousel = $(this).imagesLoaded({ background: true }, function() {
  3322.             var cols = typeof $carousel.attr('data-columns') != 'undefined' && $carousel.attr('data-columns') !== '' ? parseFloat( $carousel.attr('data-columns') ) : 1,
  3323.                 dots = typeof $carousel.attr('data-dots') != 'undefined' && $carousel.attr('data-dots') !== '' && $carousel.attr('data-dots') == 'true' ? true : false,
  3324.                 autoplay = typeof $carousel.attr('data-autoplay') != 'undefined' && $carousel.attr('data-autoplay') !== '' && $carousel.attr('data-autoplay') == 'true' ? true : false;
  3325.             var responsive = [];
  3326.  
  3327.             if ( $carousel.data('landscape')!=='' && $carousel.data('landscape')>0 ) {
  3328.                 responsive.push({
  3329.                     breakpoint: 1025,
  3330.                     settings: {
  3331.                         slidesToShow: $carousel.data('landscape')
  3332.                     }
  3333.                 });
  3334.             }
  3335.             if ( $carousel.data('portrait')!=='' && $carousel.data('portrait')>0 ) {
  3336.                 responsive.push({
  3337.                     breakpoint: 769,
  3338.                     settings: {
  3339.                         slidesToShow: $carousel.data('portrait')
  3340.                     }
  3341.                 });
  3342.             }
  3343.             if ( $carousel.data('phone')!=='' && $carousel.data('phone')>0 ) {
  3344.                 responsive.push({
  3345.                     breakpoint: 415,
  3346.                     settings: {
  3347.                         slidesToShow: $carousel.data('phone')
  3348.                     }
  3349.                 });
  3350.             }
  3351.             $carousel.on('init', function(event, slick, currentSlide, nextSlide){
  3352.                 var marginLeft = parseFloat( $carousel.css('margin-left') );
  3353.  
  3354.                 if ( marginLeft < 0 ) {
  3355.                     var paddingLeft = marginLeft * -1;
  3356.                     $('.slick-dots', $carousel).css({
  3357.                         paddingLeft: paddingLeft
  3358.                     });
  3359.                 }
  3360.  
  3361.                 Waypoint.refreshAll();
  3362.  
  3363.             }).slick({
  3364.                 dots: dots,
  3365.                 autoplay: autoplay,
  3366.                 slide: 'div',
  3367.                 prevArrow: $('button.post-list-prev', $carousel),
  3368.                 nextArrow: $('button.post-list-next', $carousel),
  3369.                 infinite: true,
  3370.                 slidesToShow: cols,
  3371.                 slidesToScroll: 1,
  3372.                 swipeToSlide: true,
  3373.                 responsive: responsive,
  3374.                 adaptiveHeight: true
  3375.             });
  3376.         });
  3377.     });
  3378.  
  3379.     $('.wpb_gallery_slidesslick').each(function(){
  3380.         var $carousel = $(this),
  3381.             dots = $carousel.attr('data-slick-dots') == 'yes',
  3382.             autoplay = $carousel.attr('data-slick-autoplay') == 'yes',
  3383.             arrows = $carousel.attr('data-slick-arrows') == 'yes',
  3384.             speed = $carousel.attr('data-slick-speed') == '' ? 5000 : parseFloat($carousel.attr('data-slick-speed'));
  3385.  
  3386.         $carousel.on('init', function(event, slick, currentSlide, nextSlide){
  3387.                 var marginLeft = parseFloat( $carousel.css('margin-left') );
  3388.  
  3389.                 if ( marginLeft < 0 ) {
  3390.                     var paddingLeft = marginLeft * -1;
  3391.                     $('.slick-dots', $carousel).css({
  3392.                         paddingLeft: paddingLeft
  3393.                     });
  3394.                 }
  3395.  
  3396.                 Waypoint.refreshAll();
  3397.                 $(window).trigger('pix-parallax');
  3398.  
  3399.             }).imagesLoaded({ background: true }, function() {
  3400.             $carousel.slick({
  3401.                 fade: true,
  3402.                 adaptiveHeight: true,
  3403.                 dots: dots,
  3404.                 arrows: arrows,
  3405.                 autoplay: autoplay,
  3406.                 autoplaySpeed: speed,
  3407.             });
  3408.         });
  3409.     });
  3410.  
  3411.     $('.slick-vc-carousel').each(function(){
  3412.         var $carousel = $(this),
  3413.             $parent = $(this).parents('.vc_slide').eq(0),
  3414.             speed = typeof $parent.attr('data-interval') != 'undefined' && $parent.attr('data-interval') !== '' ? parseFloat($parent.attr('data-interval')) : 5000,
  3415.             perview = typeof $parent.attr('data-per-view') != 'undefined' && $parent.attr('data-per-view') !== '' ? parseFloat($parent.attr('data-per-view')) : 1,
  3416.             loop = typeof $parent.attr('data-wrap') != 'undefined' && $parent.attr('data-wrap') !== '' ? $parent.attr('data-wrap') : true,
  3417.             autoplay = speed!='0',
  3418.             next = $('.vc_carousel-control', $parent).length ? $('button.post-list-next', $parent) : false,
  3419.             prev = $('.vc_carousel-control', $parent).length ? $('button.post-list-prev', $parent) : false,
  3420.             dots = $('.vc_carousel-indicators', $parent).length == 1,
  3421.             responsive = [];
  3422.  
  3423.         if ( $parent.data('landscape')!=='' ) {
  3424.             responsive.push({
  3425.                 breakpoint: 1025,
  3426.                 settings: {
  3427.                     slidesToShow: $parent.data('landscape')
  3428.                 }
  3429.             });
  3430.         }
  3431.         if ( $parent.data('portrait')!=='' ) {
  3432.             responsive.push({
  3433.                 breakpoint: 769,
  3434.                 settings: {
  3435.                     slidesToShow: $parent.data('portrait')
  3436.                 }
  3437.             });
  3438.         }
  3439.         if ( $parent.data('phone')!=='' ) {
  3440.             responsive.push({
  3441.                 breakpoint: 415,
  3442.                 settings: {
  3443.                     slidesToShow: $parent.data('phone')
  3444.                 }
  3445.             });
  3446.         }
  3447.  
  3448.         $carousel.on('init', function(event, slick, currentSlide, nextSlide){
  3449.                 var marginLeft = parseFloat( $carousel.css('margin-left') );
  3450.  
  3451.                 if ( marginLeft < 0 ) {
  3452.                     var paddingLeft = marginLeft * -1;
  3453.                     $('.slick-dots', $carousel).css({
  3454.                         paddingLeft: paddingLeft
  3455.                     });
  3456.                 }
  3457.  
  3458.                 Waypoint.refreshAll();
  3459.                 $(window).trigger('pix-parallax');
  3460.  
  3461.             }).imagesLoaded({ background: true }, function() {
  3462.             $carousel.slick({
  3463.                 dots: dots,
  3464.                 slide: 'div',
  3465.                 prevArrow: prev,
  3466.                 nextArrow: next,
  3467.                 infinite: true,
  3468.                 slidesToScroll: 1,
  3469.                 swipeToSlide: true,
  3470.                 adaptiveHeight: true,
  3471.                 autoplaySpeed: speed,
  3472.                 autoplay: autoplay,
  3473.                 responsive: responsive,
  3474.                 slidesToShow: perview
  3475.             });
  3476.         });
  3477.     });
  3478.  
  3479.     $('.vc_images_carousel').each(function(){
  3480.         var $parent = $(this),
  3481.             $carousel = $('.vc_carousel-slideline-inner', $parent),
  3482.             adaptiveHeight = $parent.attr('data-auto-height') == 'yes',
  3483.             dots = $parent.find('.vc_carousel-indicators').length > 0,
  3484.             autoplay = $parent.attr('data-interval') != '0',
  3485.             arrows = $parent.find('.vc_carousel-control').length > 0,
  3486.             speed = $parent.attr('data-interval') === '' ? 5000 : parseFloat($parent.attr('data-interval')),
  3487.             infinite = $parent.attr('data-wrap') == 'true',
  3488.             slidesToShow = $parent.attr('data-per-view') === '' ? 3 : parseFloat($parent.attr('data-per-view')),
  3489.             responsive = [];
  3490.  
  3491.         if ( $parent.data('landscape')!=='' ) {
  3492.             responsive.push({
  3493.                 breakpoint: 1025,
  3494.                 settings: {
  3495.                     slidesToShow: $parent.data('landscape')
  3496.                 }
  3497.             });
  3498.         }
  3499.         if ( $parent.data('portrait')!=='' ) {
  3500.             responsive.push({
  3501.                 breakpoint: 769,
  3502.                 settings: {
  3503.                     slidesToShow: $parent.data('portrait')
  3504.                 }
  3505.             });
  3506.         }
  3507.         if ( $parent.data('phone')!=='' ) {
  3508.             responsive.push({
  3509.                 breakpoint: 415,
  3510.                 settings: {
  3511.                     slidesToShow: $parent.data('phone')
  3512.                 }
  3513.             });
  3514.         }
  3515.  
  3516.         $carousel.imagesLoaded({ background: true }, function() {
  3517.             $carousel.on('init', function(event, slick, currentSlide, nextSlide){
  3518.                 var marginLeft = parseFloat( $carousel.css('margin-left') );
  3519.  
  3520.                 if ( marginLeft < 0 ) {
  3521.                     var paddingLeft = marginLeft * -1;
  3522.                     $('.slick-dots', $carousel).css({
  3523.                         paddingLeft: paddingLeft
  3524.                     });
  3525.                 }
  3526.  
  3527.                 Waypoint.refreshAll();
  3528.                 $(window).trigger('pix-parallax');
  3529.  
  3530.             }).slick({
  3531.                 adaptiveHeight: true,
  3532.                 dots: dots,
  3533.                 arrows: arrows,
  3534.                 autoplay: autoplay,
  3535.                 autoplaySpeed: speed,
  3536.                 slidesToShow: slidesToShow,
  3537.                 responsive: responsive,
  3538.                 infinite: infinite
  3539.             });
  3540.         });
  3541.     });
  3542.  
  3543. };
  3544.  
  3545. MOOD.contentWrap = function() {
  3546.     var $entry = $('body.single-post #main .entry-content'),
  3547.         $block,
  3548.         contentClass;
  3549.  
  3550.     $entry.find('> *').each(function(){
  3551.         $block = $(this).not('.vc_row, .vc_row-full-width');
  3552.         if ( $block.hasClass('fullwidth') ) {
  3553.             contentClass = "content-wrap fullwidth";
  3554.             $block.wrap('<span class="' + contentClass + '" />');
  3555.         } else if ( $block.hasClass('threequarters') ) {
  3556.             contentClass = "content-wrap threequarters";
  3557.             $block.wrap('<span class="' + contentClass + '" />');
  3558.         } else if ( $block.hasClass('quote-wrap') ) {
  3559.             contentClass = "content-wrap advanced-quote";
  3560.             $block.wrap('<span class="' + contentClass + '" />');
  3561.         } else {
  3562.             contentClass = "content-wrap";
  3563.             $block.wrap('<span class="' + contentClass + '" />');
  3564.         }
  3565.     });
  3566.  
  3567.     $('.quote-wrap').each(function(){
  3568.         var $quoteWrap = $(this);
  3569.  
  3570.         if ( ! $quoteWrap.parents('.content-wrap.advanced-quote').length )
  3571.             $quoteWrap.wrap('<span class="content-wrap advanced-quote" />');
  3572.            
  3573.         var $wrap = $quoteWrap.parents('.content-wrap.advanced-quote').eq(0),
  3574.             $win = $(window),
  3575.             wrapW,
  3576.             winW,
  3577.             left,
  3578.             right,
  3579.             set;
  3580.  
  3581.         $wrap.after('<span class="content-wrap content-wrap-placeholder" />');
  3582.         var $holder = $wrap.next();
  3583.  
  3584.         var quoteSet = function(){
  3585.             winW = $win.width();
  3586.             wrapW = $holder.width();
  3587.             left = $holder.offset().left;
  3588.             right = winW - ( left + wrapW );
  3589.  
  3590.             $quoteWrap.css({
  3591.                 marginLeft: (left * -1),
  3592.                 marginRight: (right * -1),
  3593.                 paddingLeft: left,
  3594.                 paddingRight: right,
  3595.                 width: winW
  3596.             });
  3597.         };
  3598.  
  3599.         quoteSet();
  3600.         $(window).on('resize orientationchange', function(){
  3601.             clearTimeout(set);
  3602.             set = setTimeout(quoteSet,10);
  3603.         });
  3604.     });
  3605. };
  3606.  
  3607. MOOD.stickySidebars = function() {
  3608.  
  3609.     var $body = $('body').addClass('sticked-sidebars'),
  3610.         $stick = $('#secondary, .stickit'),
  3611.         $header = $('header#masthead'),
  3612.         top = parseFloat( $header.attr('data-height') ),
  3613.         padding = parseFloat( $stick.css('padding-top') ) - 30;
  3614.  
  3615.     top = top - padding >= 0 ? top - padding : 0;
  3616.  
  3617.     if ( $body.hasClass('header-side') )
  3618.         top = 0;
  3619.  
  3620.     if ( $stick.length && mood_sticky_sidebars ) {
  3621.  
  3622.         if ( $body.hasClass('admin-bar') && $body.hasClass('logged-in') )
  3623.             top = top+32;
  3624.  
  3625.         var initStick = function(){
  3626.             $stick.not('.attached').stick_in_parent({
  3627.                 offset_top: top
  3628.             }).on('sticky_kit:bottom', function(e) {
  3629.                 $(this).parent().css('position', 'static');
  3630.             })
  3631.             .on('sticky_kit:unbottom', function(e) {
  3632.                 $(this).parent().css('position', 'relative');
  3633.             }).addClass('attached');
  3634.         };
  3635.  
  3636.         $(window).on('resize load isotoped infinite-loaded', function() {
  3637.             setTimeout(function(){
  3638.                 if ( $(window).width() <= 860 ) {
  3639.                     $stick.removeClass('attached').trigger("sticky_kit:detach");
  3640.                 } else {
  3641.                     $(document.body).trigger("sticky_kit:recalc");
  3642.                     initStick();
  3643.                 }
  3644.             }, 100);
  3645.         });
  3646.  
  3647.         initStick();
  3648.  
  3649.     }
  3650.  
  3651. };
  3652.  
  3653. MOOD.title_section = function(){
  3654.     var $body = $('body'),
  3655.         $title = $('#header-title'),
  3656.         $parallax = $('#parrallax_wrap', $title),
  3657.         dataHeight = $('#header-title').attr('data-height'),
  3658.         $dataParax = $('[data-parallax]', $title),
  3659.         $spacer = $('#header-spacer'),
  3660.         spacerH,
  3661.         height,
  3662.         paraxH = 0,
  3663.         winH, set2;
  3664.  
  3665.     var initTitle = function(){
  3666.         if ( $parallax.length || ( typeof dataHeight != 'undefined' && dataHeight != '' && dataHeight != '0' ) ) {
  3667.             winH = $(window).height();
  3668.             spacerH = $spacer.outerHeight();
  3669.  
  3670.             if ( typeof dataHeight == 'undefined' || dataHeight == '' || dataHeight == '0' )
  3671.                 dataHeight = 50;
  3672.  
  3673.             height = ( winH - spacerH ) * ( dataHeight / 100 );
  3674.  
  3675.             if ( $dataParax.length )
  3676.                 paraxH = $dataParax.outerHeight();
  3677.  
  3678.             if ( $body.hasClass('admin-bar') && $body.hasClass('logged-in') )
  3679.                 height = height-32;
  3680.  
  3681.             if ( height < paraxH )
  3682.                 height = paraxH;
  3683.  
  3684.             height = height <= 414 ? 414 : height;
  3685.  
  3686.             $title.css({
  3687.                 height: height
  3688.             });
  3689.         }
  3690.     };
  3691.  
  3692.     initTitle();
  3693.  
  3694.     var setTitle;
  3695.     $(window).on( 'resize', function(){
  3696.         clearTimeout(setTitle);
  3697.         setTitle = setTimeout(initTitle, 30);
  3698.     });
  3699.  
  3700.     if ( $('#header_ext_video iframe').length ) {
  3701.         var $extWrap = $('#header_ext_video'),
  3702.             extH, extW,
  3703.             $iframe = $extWrap.find('iframe');
  3704.  
  3705.         if ( $('#vimeo_title_player').length ) {
  3706.  
  3707.             var iframe = $('#vimeo_title_player')[0],
  3708.                 player = $f(iframe);
  3709.  
  3710.             player.addEvent('loaded', function() {
  3711.                 player.api('play')
  3712.                 player.api('setVolume', 0);
  3713.             });    
  3714.  
  3715.         }
  3716.  
  3717.         var iframeSize = function(){
  3718.             extW = $extWrap.outerWidth();
  3719.             extH = $extWrap.outerHeight();
  3720.  
  3721.             if ( 16 / 9 > extW / extH ) {
  3722.                 $('iframe', $extWrap).css({
  3723.                     width: ( extH )*(16/9),
  3724.                     height: extH,
  3725.                     left: ( ( extH )*(16/9) - extW ) / -2,
  3726.                     top: 0
  3727.                 });
  3728.             } else {
  3729.                 $('iframe', $extWrap).css({
  3730.                     width: extW,
  3731.                     height: extW*(9/16),
  3732.                     left: 0,
  3733.                     top: ( extW*(9/16) - extH ) / -2
  3734.                 });
  3735.             }
  3736.         };
  3737.         iframeSize();
  3738.         var setIframeSize;
  3739.         $(window).on( 'resize load', function(){
  3740.             clearTimeout(setIframeSize);
  3741.             setIframeSize = setTimeout(iframeSize, 30);
  3742.         });
  3743.  
  3744.     }
  3745.  
  3746.     var setTitleMaps = function(){
  3747.         if ($('.rwmb-map-canvas', $title).length ) {
  3748.             $('.rwmb-map-canvas', $title).each(function(){
  3749.                 var titleH = $title.outerHeight(),
  3750.                     $map = $(this).eq(0).height( titleH );
  3751.                 google.maps.event.trigger($map.get(0), 'resize');
  3752.             });
  3753.         }
  3754.  
  3755.         $(window).trigger('pix-parallax');
  3756.     };
  3757.     setTitleMaps();
  3758.  
  3759.     $(window).on('resize', function(){
  3760.         clearTimeout(set2);
  3761.         set2 = setTimeout(setTitleMaps,250);
  3762.     });
  3763.  
  3764. };
  3765.  
  3766. MOOD.init_videos = function(){
  3767.     var $window = $(window),
  3768.         $page = $('#page');
  3769.  
  3770.     var resizeVideo = function(video) {
  3771.         var $section = video.parents('#header_parallax_bg').eq(0),
  3772.             h = video.attr('data-height'),
  3773.             w = video.attr('data-width');
  3774.         $section = !$section.length ? $window : $section;
  3775.         video.data('height',h);
  3776.         $window.on('resize resizevideo',function(){
  3777.             var secW = $section.outerWidth(),
  3778.                 secH = $section.outerHeight(),
  3779.                 rap = w/h,
  3780.                 rap2 = h/w,
  3781.                 newW = secH*rap,
  3782.                 newH = secW*rap2,
  3783.                 marginTop = newH-secH,
  3784.                 marginLeft = newW-secW;
  3785.  
  3786.             secW = parseFloat(secW);
  3787.             secW = secW+2;
  3788.             secH = parseFloat(secH);
  3789.             newW = Math.floor(newW);
  3790.             newH = Math.floor(newH);
  3791.             marginTop = marginTop*-0.5;
  3792.             marginLeft = marginLeft*-0.5;
  3793.  
  3794.             var secRap = secW/secH;
  3795.  
  3796.             if(rap<secRap) {
  3797.                 video.css({
  3798.                     width: 'auto',
  3799.                     height: newH,
  3800.                     marginTop: marginTop,
  3801.                     marginLeft: 0
  3802.                 });
  3803.             } else {
  3804.                 video.css({
  3805.                     width: newW,
  3806.                     height: 'auto',
  3807.                     marginLeft: marginLeft,
  3808.                     marginTop: 0
  3809.                 });
  3810.             }
  3811.         }).triggerHandler('resizevideo');
  3812.     };
  3813.  
  3814.     $('video.pix_video').not('.init').each(function(){
  3815.         var video = $(this).addClass('init'),
  3816.             loop = typeof video.attr('data-loop')!='undefined' ? (video.attr('data-loop')=='true') : false,
  3817.             volume = typeof video.attr('data-volume')!='undefined' ? parseFloat(video.attr('data-volume')) : 1.0;
  3818.         video.bind("loadstart loadedmetadata", function () {
  3819.             var vidW = this.videoWidth;
  3820.             var vidH = this.videoHeight;
  3821.             video.attr('data-height',vidH).attr('data-width',vidW);
  3822.             //console.log(vidW,vidH);
  3823.         });
  3824.  
  3825.         var mediaInit = function(){
  3826.  
  3827.             video.mediaelementplayer({
  3828.                 pauseOtherPlayers: false,
  3829.                 loop: loop,
  3830.                 success: function(mediaElement, domObject) {
  3831.  
  3832.                     mediaElement.setVolume(volume);
  3833.                     if ( video.attr('data-autoplay')=='true' ) {
  3834.                         mediaElement.play();
  3835.                         //$(video).parents('.pix_slideshine').data('loading',false);
  3836.                     }
  3837.  
  3838.                     var MEcanPlay = function(e){
  3839.                         if ( video.hasClass('pix_section_video') ) {
  3840.                             resizeVideo(video);
  3841.                         }
  3842.                         var domObj = $(domObject).parents('.mejs-container').eq(0).addClass('loaded');
  3843.                         $('.isotope').isotope('layout');
  3844.                     };
  3845.  
  3846.                     mediaElement.addEventListener('canplay', MEcanPlay);
  3847.  
  3848.                     var MEplay = function(){
  3849.                         if ( video.parents('.slideshine_current').length ) {
  3850.                             video.parents('.pix_slideshine').data('loading',false);
  3851.                         }
  3852.                     };
  3853.  
  3854.                     mediaElement.addEventListener('play', MEplay);
  3855.  
  3856.                 },
  3857.                 error : function(mediaElement) {
  3858.                     console.log('video error');
  3859.                 }
  3860.             });
  3861.         };
  3862.  
  3863.         mediaInit();
  3864.     });
  3865.  
  3866. };
  3867.  
  3868. MOOD.fitVideos = function() {
  3869.  
  3870.     var manageVideoSize = function(){
  3871.  
  3872.         var setVideoFit;
  3873.         $('#container .featured-media[data-width][data-height]').each(function(){
  3874.  
  3875.             $this = $(this);
  3876.  
  3877.             if ( $('iframe', $this).length ) {
  3878.  
  3879.                 var w = parseFloat($this.attr('data-width')),
  3880.                     h = parseFloat($this.attr('data-height')),
  3881.                     $iframe = $('> iframe, > a > iframe', $this),
  3882.                     url = $iframe.attr('src'),
  3883.                     ratio, frW;
  3884.  
  3885.                 if ( typeof url != 'undefined' && url.indexOf('soundcloud') != -1 && h !== 0  ) {
  3886.  
  3887.                     ratio = h / w;
  3888.                     var resizeiFrame = function(){
  3889.                         frW = $iframe.width();
  3890.                         $iframe.css({
  3891.                             height: frW * ratio
  3892.                         });
  3893.                     };
  3894.                     resizeiFrame();
  3895.                     $(window).on('resize load', resizeiFrame);
  3896.  
  3897.                 } else if ( w !== 0 && h !== 0 ) {
  3898.                     $iframe.attr('width',w).attr('height',h);
  3899.                 }
  3900.  
  3901.             } else if ( $('video', $this).length ) {
  3902.  
  3903.                 var $this = $(this),
  3904.                     w = parseFloat($this.attr('data-width')),
  3905.                     h = parseFloat($this.attr('data-height'));
  3906.  
  3907.                 if ( w !== 0 && h !== 0 ) {
  3908.  
  3909.                     var $video = $('video', $this),
  3910.                         $container,
  3911.                         actW,
  3912.                         ratio = h / w;
  3913.  
  3914.                     $video.on("readyState loadstart loadedmetadata", function () {
  3915.  
  3916.                         var resideResidentVideo = function(){
  3917.                             $container = $('.mejs-container:not(.mejs-container-fullscreen)', $this);
  3918.                             actW = $container.width();
  3919.  
  3920.                             $container.css({
  3921.                                 height: actW * ratio
  3922.                             });
  3923.                             $video.attr('width',actW).attr('height',(actW * ratio));
  3924.  
  3925.                             $( document.body ).trigger('video-fit');
  3926.  
  3927.                         };
  3928.  
  3929.                         setTimeout(resideResidentVideo, 10);
  3930.                         $(window).on('resize load', resideResidentVideo);
  3931.                     });
  3932.  
  3933.                 }
  3934.             }
  3935.  
  3936.         });
  3937.  
  3938.         $('#container').fitVids({ customSelector: "iframe[src^='https://videopress.com']"});
  3939.  
  3940.     };
  3941.  
  3942.     manageVideoSize();
  3943. };
  3944.  
  3945. MOOD.special_typography = function(){
  3946.     var $body = $('body'),
  3947.         $head = $('head'),
  3948.         $content = $('p.first-letter', $body),
  3949.         letter;
  3950.  
  3951.     $content.each(function(){
  3952.         letter = $(this).text().charAt(0);
  3953.         $(this).prepend('<span class="first-letter-clone">' + letter + '</span>');
  3954.     });
  3955.  
  3956.     $('.hor-lined').each(function(){
  3957.         var $lined = $(this),
  3958.             dataId = MOOD.guidGenerator();
  3959.  
  3960.         $lined.attr('data-id', dataId);
  3961.  
  3962.         if ( !$('.inner-hor-lined', $lined).length ) {
  3963.             var $this = $(this);
  3964.             $this.wrapInner('<span />').wrapInner('<span class="inner-hor-lined" />');
  3965.         }
  3966.  
  3967.         var color = $lined.css('color');
  3968.         $('<style>.hor-lined[data-id="' + dataId + '"] .inner-hor-lined::before, .hor-lined[data-id="' + dataId + '"] .inner-hor-lined::after{background-color:' + color + ' !important}</style>').appendTo($head);
  3969.     });
  3970. };
  3971.  
  3972. MOOD.pix_buttons = function(){
  3973.     var $button = $('.mood-button-wrap').has('.mood-button-separator');
  3974.  
  3975.     $button.each(function(){
  3976.         var $this = $(this),
  3977.             $sep = $('.mood-button-separator', $this),
  3978.             $first = $this.find('> a:first-child'),
  3979.             $second = $this.find('> a:last-child'),
  3980.             w = $sep.outerWidth(),
  3981.             set;
  3982.  
  3983.         var setSep = function(){
  3984.  
  3985.             w = $sep.css({
  3986.                 width: 'auto'
  3987.             }).outerWidth();
  3988.  
  3989.             $sep.css({
  3990.                 height: w,
  3991.                 lineHeight: w+'px',
  3992.                 marginLeft: (w/(-2)),
  3993.                 marginTop: (w/(-2)),
  3994.                 width: w
  3995.             });
  3996.  
  3997.             if ( mood_rtl ) {
  3998.                 $second = $this.find('> a:first-child');
  3999.                 $first = $this.find('> a:last-child');
  4000.             }
  4001.  
  4002.             $first.css({
  4003.                 paddingRight: ((w/2)+20)
  4004.             });
  4005.             $second.css({
  4006.                 paddingLeft: ((w/2)+20)
  4007.             });
  4008.  
  4009.         };
  4010.  
  4011.         setSep();
  4012.         $(window).on('resize load', function(){
  4013.             clearTimeout(set);
  4014.             set = setTimeout(setSep, 100);
  4015.         });
  4016.     });
  4017. };
  4018.  
  4019. MOOD.custom_tabs = function(){
  4020.     var $tabs = $('a[data-vc-accordion]').has('svg, .wpb_animate_when_almost_visible');
  4021.  
  4022.     $tabs.each(function(){
  4023.         var $this = $(this),
  4024.             icon = $this.html(),
  4025.             href = $this.attr('href');
  4026.         if ( $('a[data-vc-tabs][href="' + href + '"]:not(.vc_pagination-trigger)').length ) {
  4027.             $('a[data-vc-tabs][href="' + href + '"]:not(.vc_pagination-trigger)').html(icon);
  4028.         }
  4029.     });
  4030.  
  4031.     /* Google maps in tabs */
  4032.     $( ".vc_tta-tabs-list .vc_tta-tab > a" ).on( "click", function( event ) {
  4033.         setTimeout(function(){
  4034.             $(window).trigger('map-refresh');
  4035.         }, 500);
  4036.     });
  4037. };
  4038.  
  4039. MOOD.countdown = function(){
  4040.     $('.mood-countdown').each(function(){
  4041.         var $countdown = $(this),
  4042.             date = $countdown.attr('data-date'),
  4043.             format;
  4044.  
  4045.         $countdown.countdown(date, function(event) {
  4046.             format = '<span class="hours-wrap counter-wrap"><span class="hours-counter countdown-counter">%H</span><span class="hours-label countdown-label">' + mood_for_hours + '</span></span><span class="minutes-wrap counter-wrap"><span class="minutes-counter countdown-counter">%M</span><span class="minutes-label countdown-label">' + mood_for_minutes + '</span></span><span class="seconds-wrap counter-wrap"><span class="seconds-counter countdown-counter">%S</span><span class="seconds-label countdown-label">' + mood_for_seconds + '</span></span>';
  4047.  
  4048.             if(event.offset.days > 0)
  4049.                 format = '<span class="days-wrap counter-wrap"><span class="days-counter countdown-counter">%-d</span><span class="days-label countdown-label">%!d:' + mood_for_day + ',' + mood_for_days + ';</span></span>' + format;
  4050.  
  4051.             if(event.offset.weeks > 0)
  4052.                 format = '<span class="weeks-wrap counter-wrap"><span class="weeks-counter countdown-counter">%-w</span><span class="weeks-label countdown-label">%!w:' + mood_for_week + ',' + mood_for_weeks + ';</span></span>' + format;
  4053.  
  4054.             $(this).html(event.strftime(format));
  4055.  
  4056.         });
  4057.     });
  4058. };
  4059.  
  4060. MOOD.pricingTables = function(){
  4061.     $('.mood-pricing-table').each(function(){
  4062.         var $table = $(this),
  4063.             $column = $('.mood-pricing-column-wrap', $table),
  4064.             colAmount = parseFloat( $column.length ),
  4065.             maxWidth = ( 100 / colAmount ) + '%';
  4066.  
  4067.         $table.attr('data-cols', colAmount);
  4068.         $column.css({
  4069.             maxWidth: maxWidth
  4070.         });
  4071.  
  4072.         $column.matchHeight();
  4073.  
  4074.         if ( $table.hasClass( 'equal-height' ) )
  4075.             $column.find('> .mood-pricing-column > .mood-pricing-column-equalizer').matchHeight();
  4076.  
  4077.         $column.find('> .mood-pricing-column').matchHeight();
  4078.  
  4079.     });
  4080. };
  4081.  
  4082. MOOD.contactStyles = function(){
  4083.     $('.mood-cf7-styler').each(function(){
  4084.  
  4085.         var $contacts = $(this),
  4086.             $submit = $('p.mood-input-submit-inside', $contacts),
  4087.             $last, encloser, $encloser, subW, subH, set;
  4088.  
  4089.         if ( $contacts.hasClass('enclose-submit') && typeof $submit[0] != 'undefined' ) {
  4090.             $submit.replaceWith($('<span class="mood-input-submit-inside">' + $submit[0].innerHTML + '</span>'));
  4091.             $submit = $('span.mood-input-submit-inside', $contacts);
  4092.             encloser = $('<span class="encloser-submit" />');
  4093.             $last = $('p.mood-field-inside', $contacts).last().wrapInner( encloser );
  4094.             $encloser = $('.encloser-submit', $contacts);
  4095.             $submit.appendTo( $encloser );
  4096.  
  4097.             var setPadding = function(){
  4098.  
  4099.                 if ( $(window).width() > 500 && $last.find('input:not([type="submit"])').length ) {
  4100.                     if ( $last.hasClass( 'mood-textarea-inside' ) ) {
  4101.                         subH = parseFloat( $('input', $submit).outerHeight() );
  4102.                         $last.find('textarea').get(0).style.setProperty( 'padding-bottom', ( subH + 15 ) + 'px', 'important' );
  4103.                     } else {
  4104.                         subW = parseFloat( $('input', $submit).outerWidth() );
  4105.                         $last.find('input:not([type="submit"])').get(0).style.setProperty( 'padding-right', ( subW + 15 ) + 'px', 'important' );
  4106.                     }
  4107.                 } else {
  4108.                     if ( $last.hasClass( 'mood-textarea-inside' ) ) {
  4109.                         $last.find('textarea').get(0).style.setProperty( 'padding-bottom', '1em', 'important' );
  4110.                     } else {
  4111.                         $last.find('input:not([type="submit"])').get(0).style.setProperty( 'padding-right', '1em', 'important' );
  4112.                     }
  4113.                 }
  4114.  
  4115.             };
  4116.  
  4117.             setPadding();
  4118.             $(window).on('resize', function(){
  4119.                 clearTimeout(set);
  4120.                 set = setTimeout(setPadding,10);
  4121.             });
  4122.  
  4123.         }
  4124.  
  4125.     });
  4126.  
  4127.     $('form.wpcf7-form').each(function(){
  4128.         var $form = $(this),
  4129.             $loader = $('.ajax-loader', $form);
  4130.  
  4131.         $form.append($loader);
  4132.  
  4133.         $(window).on('wpcf7:invalid wpcf7:mailsent wpcf7:mailfailed wpcf7:submit wpcf7:spam', function(){
  4134.             setTimeout(function(){
  4135.                 $(window).trigger('resize');
  4136.             }, 500);
  4137.         });
  4138.  
  4139.     });
  4140. };
  4141.  
  4142. MOOD.svgGradient = function(){
  4143.     $('.mood-typo-separator').has('linearGradient').each(function(){
  4144.         var $el = $(this),
  4145.             $holder = $('> div', $el),
  4146.             holderW = parseFloat( $holder.width() ),
  4147.             $svg = $('svg', $el),
  4148.             svgW = parseFloat( $svg.width() ),
  4149.             $gradient = $('linearGradient', $svg),
  4150.             $stop = $('stop:last-child', $gradient),
  4151.             offset = parseFloat( $stop.attr('offset') ),
  4152.             newVal = ( holderW / svgW ) * 100;
  4153.  
  4154.         $stop.attr('offset', newVal + '%');
  4155.     });
  4156. };
  4157.  
  4158. MOOD.fitText = function(){
  4159.  
  4160.     var overText = function(){
  4161.         $('.text-position-over, .text-position-hover').addClass('over-text').each(function(){
  4162.             var $block = $(this),
  4163.                 blockH,
  4164.                 blockW,
  4165.                 $text = $('.entry-text', $block),
  4166.                 textH,
  4167.                 textW,
  4168.                 newSize = 1;
  4169.  
  4170.             $block.data('newSize', newSize);
  4171.             $block.css('font-size', false);
  4172.  
  4173.             var overTextLoop = function(){
  4174.                 blockH = $block.height();
  4175.                 textH = $text.outerHeight();
  4176.                 blockW = $block.width();
  4177.                 textW = $text.outerWidth();
  4178.                 newSize = $block.data('newSize');
  4179.                 if ( blockH < textH || blockW < textW ) {
  4180.                     newSize = newSize - 0.01;
  4181.                     $block.data('newSize', newSize);
  4182.                     $block.css({
  4183.                         fontSize: newSize+'em'
  4184.                     })
  4185.                     setTimeout( overTextLoop, 10 );
  4186.                 }
  4187.             }
  4188.  
  4189.             overTextLoop();
  4190.  
  4191.         });
  4192.     };
  4193.  
  4194.     var set;
  4195.  
  4196.     overText();
  4197.     $(window).on('resize', function(){
  4198.         clearTimeout(set);
  4199.         set = setTimeout(overText,10);
  4200.     });
  4201.  
  4202.     $('h1, h2, h3, h4, h5, h6, blockquote, .fitText').filter(':notparents(.over-text)').moodFitText();
  4203. };
  4204.  
  4205. MOOD.footerFixed = function(){
  4206.     var $window = $(window),
  4207.         $body = $('body'),
  4208.         $footer = $('footer#colophon'),
  4209.         $masthead = $('header#masthead'),
  4210.         mastH,
  4211.         $title = $('header#header-title'),
  4212.         titleH,
  4213.         $container = $('#container'),
  4214.         contH,
  4215.         $page = $('#page'),
  4216.         winH,
  4217.         footH,
  4218.         set;
  4219.  
  4220.     var setFooter = function(){
  4221.         if ( $footer.hasClass('fixed-footer') ) {
  4222.             winH = $window.height();
  4223.             footH = $footer.outerHeight();
  4224.             mastH = $masthead.outerHeight();
  4225.             titleH = $title.outerHeight();
  4226.             contH = $container.outerHeight();
  4227.  
  4228.             if ( winH < footH || ( mastH + titleH + contH ) < winH || ( $body.hasClass('mood-boxed-layout') && $body.hasClass('header-side') ) ) {
  4229.                 $footer.removeClass('just-fixed');
  4230.                 $page.css({ marginBottom: 0 });
  4231.             } else {
  4232.                 $footer.addClass('just-fixed');
  4233.                 $page.css({ marginBottom: footH });
  4234.             }
  4235.         } else {
  4236.             $footer.removeClass('just-fixed');
  4237.             $page.css({ marginBottom: 0 });
  4238.         }
  4239.     };
  4240.  
  4241.     setFooter();
  4242.     $(window).on('load', setFooter);
  4243.     $(window).on('resize', function(){
  4244.         clearTimeout(set);
  4245.         set = setTimeout(setFooter,10);
  4246.     });
  4247. };
  4248.  
  4249. MOOD.mediaElementAdjust = function(){
  4250.     var runAdjust = function(){
  4251.         $('.wp-audio-playlist').each(function(){
  4252.             var $elem = $(this),
  4253.                 $items = $('.wp-playlist-item', $elem),
  4254.                 $prev = $('.wp-playlist-prev', $elem),
  4255.                 $next = $('.wp-playlist-next', $elem);
  4256.  
  4257.             if ( $items.length < 2 ) {
  4258.                 $prev.hide();
  4259.                 $next.hide();
  4260.             }
  4261.  
  4262.         });
  4263.     };
  4264.  
  4265.     runAdjust();
  4266.  
  4267.     $('body').ajaxSuccess(function() {
  4268.         runAdjust();
  4269.     });
  4270.  
  4271. };
  4272.  
  4273. MOOD.init = function(){
  4274.  
  4275.     MOOD.childrenInviewport();
  4276.     MOOD.product_quickview();
  4277.     MOOD.smoothScroll();
  4278.     MOOD.mainNavigation();
  4279.     MOOD.overlayMenu();
  4280.     MOOD.searchOverlay();
  4281.     MOOD.stickyNav();
  4282.     MOOD.mobileMenu();
  4283.     MOOD.vcParallax();
  4284.     MOOD.parallax();
  4285.     MOOD.parallaxEls();
  4286.     MOOD.revSliders();
  4287.     MOOD.verticalTitles();
  4288.     MOOD.infiniteScroll();
  4289.     MOOD.initColorbox();
  4290.     MOOD.zoomImage();
  4291.     MOOD.productImageCarousel();
  4292.     MOOD.resetVariations();
  4293.     MOOD.accordion();
  4294.     MOOD.sharingWindows();
  4295.     MOOD.contentWrap();
  4296.     MOOD.stickySidebars();
  4297.     MOOD.title_section();
  4298.     MOOD.init_videos();
  4299.     MOOD.fitVideos();
  4300.     MOOD.special_typography();
  4301.     MOOD.pix_buttons();
  4302.     MOOD.custom_tabs();
  4303.     MOOD.countdown();
  4304.     MOOD.contactStyles();
  4305.     MOOD.svgGradient();
  4306.     MOOD.fitText();
  4307.     MOOD.inviewportMob();
  4308.     MOOD.footerFixed();
  4309.  
  4310.     $('#page').imagesLoaded({ background: true }, function() {
  4311.         MOOD.postSliders();
  4312.         MOOD.pricingTables();
  4313.         MOOD.masonry();
  4314.         MOOD.mediaElementAdjust();
  4315.         setTimeout(function(){
  4316.             MOOD.inviewport();
  4317.         }, 500);
  4318.     });
  4319.  
  4320.  
  4321.     var setResize, checkDevice = 'check-' + $('body').hasClass('mobile-view');
  4322.     $(window).on('resize', function() {
  4323.         clearTimeout(setResize);
  4324.         if ( checkDevice == 'check-' + $('body').hasClass('mobile-view') )
  4325.             return;
  4326.         setResize = setTimeout(function(){
  4327.             MOOD.inviewport();
  4328.             MOOD.inviewportMob();
  4329.             checkDevice = 'check-' + $('body').hasClass('mobile-view');
  4330.         }, 500);
  4331.     });
  4332.  
  4333. };
  4334.  
  4335. $(function(){
  4336.     MOOD.init();
  4337. });
  4338.  
  4339. })(jQuery);
  4340.  
  4341. function mood_hide_reply(elem){
  4342.     var $body = jQuery('body');
  4343.     $body.data('replybutton',elem);
  4344.     jQuery('.comment-reply-link').removeClass('hidden');
  4345.     jQuery(elem).addClass('hidden');
  4346. }
  4347.  
  4348. window.vc_waypoints = function () {
  4349.     return;
  4350. };
  4351.  
  4352. //wp-content/plugins/js_composer/assets/js/js_composer_front.js - lines 580-670
  4353. window.vc_rowBehaviour = function () {
  4354.     var $ = window.jQuery;
  4355.  
  4356.     function localFunction() {
  4357.         var $elements = $( '[data-vc-full-width="true"]' );
  4358.         $.each( $elements, function ( key, item ) {
  4359.             var $wrap = $('#page').length ? $('#page') : $( window );//used a selector if available instead of $( window ) //pixedelic
  4360.             var $el = $( this );
  4361.             //$el.addClass( 'vc_hidden' );
  4362.  
  4363.             var $el_full = $el.next( '.vc_row-full-width' );
  4364.             var el_margin_left = parseInt( $el.css( 'margin-left' ), 10 );
  4365.             var el_margin_right = parseInt( $el.css( 'margin-right' ), 10 );
  4366.             var wrap_offset = $wrap.offset().left;//added the offset of the wrap
  4367.             var offset = wrap_offset - $el_full.offset().left - el_margin_left;//added wrap_offset instead of 0
  4368.             var width = $wrap.width();//used $wrap instead of $( window )
  4369.             $el.css( {
  4370.                 'position': 'relative',
  4371.                 'left': offset,
  4372.                 'box-sizing': 'border-box',
  4373.                 'width': $wrap.width()//pixedelic
  4374.             } );
  4375.             if ( ! $el.data( 'vcStretchContent' ) ) {
  4376.                 var padding = (- 1 * offset);
  4377.                 if ( 0 > padding ) {
  4378.                     padding = 0;
  4379.                 }
  4380.                 var paddingRight = width - padding - $el_full.width() + el_margin_left + el_margin_right;
  4381.                 if ( 0 > paddingRight ) {
  4382.                     paddingRight = 0;
  4383.                 }
  4384.                 $el.css( { 'padding-left': padding + 'px', 'padding-right': paddingRight + 'px' } );
  4385.             }
  4386.             $el.attr( "data-vc-full-width-init", "true" );
  4387.             //$el.removeClass( 'vc_hidden' );
  4388.             $( document.body ).trigger('vc-full-width-row');
  4389.             $(window).trigger('map-refresh');
  4390.         } );
  4391.     }
  4392.  
  4393.     /**
  4394.      * @todo refactor as plugin.
  4395.      * @returns {*}
  4396.      */
  4397.     function fullHeightRow() {
  4398.         $( '.vc_row:first:not(.relative_min_height)' ).each( function () {
  4399.             if ( ! $(this).hasClass('vc_row-o-full-height') || $('#header-title').length )
  4400.                 return false;
  4401.             var $window,
  4402.                 windowHeight,
  4403.                 offsetTop,
  4404.                 fullHeight;
  4405.             $window = $( window );
  4406.             windowHeight = $window.height();
  4407.             offsetTop = $( this ).offset().top;
  4408.             if ( offsetTop < windowHeight ) {
  4409.                 fullHeight = 100 - offsetTop / (windowHeight / 100);
  4410.                 $( this ).css( 'min-height', fullHeight + 'vh' );
  4411.             }
  4412.         } );
  4413.     }
  4414.  
  4415.     function fixIeFlexbox() {
  4416.         var ua = window.navigator.userAgent;
  4417.         var msie = ua.indexOf("MSIE ");
  4418.  
  4419.         if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)){
  4420.             $( '.vc_row-o-full-height' ).each( function () {
  4421.                 if ($( this ).css( 'display') === 'flex') {
  4422.                     $( this ).wrap('<div class="vc_ie-flexbox-fixer"></div>')
  4423.                 }
  4424.             } );
  4425.         }
  4426.     }
  4427.  
  4428.     $( window ).unbind( 'resize.vcRowBehaviour' ).bind( 'resize.vcRowBehaviour', localFunction );
  4429.     $( window ).bind( 'resize.vcRowBehaviour', fullHeightRow );
  4430.     localFunction();
  4431.     fullHeightRow();
  4432.     fixIeFlexbox();
  4433.     initVideoBackgrounds(); // must be called before parallax
  4434.     //parallaxRow();
  4435. };
  4436.  
  4437. /* This javascript goes with the likeThis plugin written by Rosemarie Pritchard.
  4438. http://lifeasrose.ca
  4439. */
  4440.  
  4441. var $j = jQuery.noConflict();
  4442.  
  4443. function likeScript(){
  4444.  
  4445.     function reloadLikes(who) {
  4446.         var text = $j("#" + who).text();
  4447.         var patt= /(\d)+/;
  4448.        
  4449.         var num = patt.exec(text);
  4450.         num[0]++;
  4451.         text = text.replace(patt,num[0]);
  4452.         $j("#" + who).text(text);
  4453.     } //reloadLikes
  4454.  
  4455.  
  4456.     $j(".likeThis").click(function() {
  4457.         var classes = $j(this).attr("class");
  4458.         classes = classes.split(" ");
  4459.        
  4460.         if(classes[1] == "done") {
  4461.             return false;
  4462.         }
  4463.         var classes = $j(this).addClass("done");
  4464.         var id = $j('.likes-amount',this).attr("data-id");
  4465.         id = id.split("like-");
  4466.         $j.ajax({
  4467.           type: "POST",
  4468.           url: homeurl+'/index.php',
  4469.           data: "likepost=" + id[1],
  4470.           success: reloadLikes("like-" + id[1])
  4471.         });
  4472.        
  4473.         return false;
  4474.     });
  4475.  
  4476. }
  4477.  
  4478. $j(document).ready(function(){
  4479.     likeScript();
  4480.     $j('body').ajaxSuccess(function() {
  4481.         likeScript();
  4482.     });
  4483. });
Add Comment
Please, Sign In to add comment