Advertisement
jegtheme

main.js

Jul 4th, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function ($, window, document, MediaElement) {
  2.     "use strict";
  3.  
  4.     function dispatch() {
  5.  
  6.         /*************************
  7.          * right click
  8.          *************************/
  9.  
  10.         if (window.joption.rightclick === "1") {
  11.  
  12.             var transformx = 0.90;
  13.             var transformy = 0.90;
  14.             var transformdelay = 500;
  15.             var rightclickactive = false;
  16.             var ccinterval = null;
  17.             var cctop = 0;
  18.             var ccheight = $(".creditcontainer").height();
  19.             var musicenabled = false;
  20.  
  21.             if ($(".creditaudio").length) {
  22.                 musicenabled = true;
  23.                 $('#creditaudioplayer').mediaelementplayer({
  24.                     pauseOtherPlayers: false,
  25.                     success: function(me) {}
  26.                 });
  27.             }
  28.  
  29.             var movecc = function () {
  30.                 cctop = cctop - 1;
  31.                 if ((ccheight * -1) > cctop) { cctop = $(window).height(); }
  32.                 window.jpobj.doTranslate($(".creditcontainer"), "0px", cctop + "px");
  33.                 ccinterval = window.requestAnimationFrame(movecc);
  34.             };
  35.  
  36.             var openmovieoverlay = function(e){
  37.                 if (!rightclickactive) {
  38.                     cctop = $(window).height();
  39.                     window.jpobj.doTranslate($(".creditcontainer"), "0px", cctop + "px");
  40.  
  41.                     rightclickactive = true;
  42.                     $('html, body').animate({
  43.                         scrollTop: 0
  44.                     }, window.jpobj.globaltop / 4, "easeInOutQuad", function () {
  45.                         window.setTimeout(function () {
  46.                             if (musicenabled) {
  47.                                 $('#creditaudioplayer')[0].player.play();
  48.                                 $(window).trigger('jmusicstop');
  49.                             }
  50.                             $(".rightclickoverlay").fadeIn(transformdelay);
  51.                             $(".jviewport").css('transform', "matrix(1, 0, 0, 1, 0, 0)").addClass('overflowhide');
  52.                             $({ property: 0 }).animate({ property: 100 }, {
  53.                                 duration: transformdelay,
  54.                                 step: function (now) {
  55.                                     var difx = 1 - (( 1 - transformx ) * now / 100);
  56.                                     var dify = 1 - (( 1 - transformy ) * now / 100);
  57.                                     $(".jviewport").css('transform', "matrix(" + difx + ", 0, 0, " + dify + ", 0, 0)");
  58.                                 },
  59.                                 complete: function () {
  60.                                     ccheight = $(".creditcontainer").height();
  61.                                     ccinterval = window.requestAnimationFrame(movecc);
  62.                                 }
  63.                             });
  64.                         }, 250);
  65.                     });
  66.                 }
  67.                 return false;
  68.             };
  69.  
  70.  
  71.             $(document).bind('contextmenu', function (e) {
  72.                 if (e.button === 2) {
  73.                     e.preventDefault();
  74.                     openmovieoverlay(e);
  75.                 }
  76.                 return true;
  77.             });
  78.  
  79.             $(".moviecredit a").bind('click', function(e){
  80.                 e.preventDefault();
  81.                 openmovieoverlay(e);
  82.             });
  83.  
  84.  
  85.             $(".roverlayclose").bind('click', function () {
  86.                 if (musicenabled) {
  87.                     $('#creditaudioplayer')[0].player.pause();
  88.                     $(window).trigger('jmusicstart');
  89.                 }
  90.                 $(".rightclickoverlay").fadeOut(transformdelay);
  91.                 $(".jviewport").removeClass('overflowhide');
  92.                 $({ property: 0 }).animate({ property: 100 }, {
  93.                     duration: transformdelay,
  94.                     step: function (now) {
  95.                         var difx = transformx + (( 1 - transformx ) * now / 100);
  96.                         var dify = transformx + (( 1 - transformy ) * now / 100);
  97.  
  98.                         $(".jviewport").css('transform', "matrix(" + difx + ", 0, 0, " + dify + ", 0, 0)");
  99.                     },
  100.                     complete: function () {
  101.                         $(".jviewport").attr('style', '');
  102.                         rightclickactive = false;
  103.                         window.cancelAnimationFrame(ccinterval);
  104.                     }
  105.                 });
  106.             });
  107.         }
  108.  
  109.         /*************************
  110.          * loading
  111.          *************************/
  112.  
  113.         if ($("#loading").length) {
  114.             var loadingtype = $("#loading").data('type');
  115.             if (loadingtype === 'circle') {
  116.                 $.jpageload();
  117.             } else if (loadingtype === 'linear') {
  118.                 $.jpageloadlinear();
  119.             } else if (loadingtype === 'linearinline') {
  120.                 $.jpageloadlinearinline();
  121.             }
  122.         }
  123.  
  124.         /*************************
  125.          * fix anything
  126.          *************************/
  127.  
  128.         $(window).bind('load', function () {
  129.             $(window).trigger('resize');
  130.  
  131.             if($(".landingpagewrapper").length) {
  132.                 setTimeout(function(){
  133.                     $(window).trigger('resize');
  134.                 }, 3000);
  135.             }
  136.         });
  137.  
  138.         /**************************
  139.          * header menu fade
  140.          *************************/
  141.  
  142.         if ($(".headermenu").length) {
  143.             var fadeheadermenu = function () {
  144.                 if (window.jpobj.globaltop > 100) {
  145.                     $(".headermenu").addClass('fademe');
  146.                 } else {
  147.                     $(".headermenu").removeClass('fademe');
  148.                 }
  149.             };
  150.  
  151.             $(window).bind('jscroll', fadeheadermenu);
  152.         }
  153.  
  154.         /**************************
  155.          * Collapsible Navigation
  156.          *************************/
  157.  
  158.         if ($(".sidebarcollapse").length) {
  159.             var showcollapsiblemenu = function (e) {
  160.                 if (this === e.target) {
  161.                     $("#leftsidebar").animate({
  162.                         "left": 0
  163.                     });
  164.  
  165.                     $(".csbwrapper").fadeOut();
  166.                     $(".lefttop, .leftfooter").fadeIn();
  167.                 }
  168.             };
  169.             $(".csbwrapper, .csbhicon, .cbsheader").bind('click', showcollapsiblemenu);
  170.  
  171.             var hidecollapsiblemenu = function () {
  172.                 var leftpos = "-210px";
  173.                 if ($(window).width() <= 1024) { leftpos = "-190px"; }
  174.  
  175.                 $("#leftsidebar").animate({
  176.                     "left": leftpos
  177.                 });
  178.                 $(".lefttop, .leftfooter").fadeOut(function () {
  179.                     $(".csbwrapper").fadeIn();
  180.                 });
  181.             };
  182.  
  183.             $(".sidebarcollapse #leftsidebar").hoverIntent({
  184.                 over: function () {
  185.                 },
  186.                 out: function () {
  187.                     hidecollapsiblemenu();
  188.                 },
  189.                 timeout: 500
  190.             });
  191.  
  192.             $(window).bind('resize', hidecollapsiblemenu);
  193.         }
  194.  
  195.         /**************************
  196.          * search function
  197.          **************************/
  198.  
  199.         var toogle_search = function (event) {
  200.             event.preventDefault();
  201.             if ($("body").hasClass('opensearch')) {
  202.                 $("body").removeClass('opensearch');
  203.                 $(".topsearchwrapper").fadeOut();
  204.             } else {
  205.                 $("body").addClass('opensearch');
  206.                 $(".searchcontent input").focus();
  207.                 $(".topsearchwrapper input").focus();
  208.                 $(".topsearchwrapper").fadeIn();
  209.             }
  210.         };
  211.  
  212.         $(".searchheader, .topnavigationsearch").bind('click', toogle_search);
  213.         $(".closesearch").bind('click', toogle_search);
  214.         $(".searchcontent input").width($("#rightsidecontainer").width() - 70);
  215.  
  216.  
  217.         /**************************
  218.          * two line navigation
  219.          **************************/
  220.  
  221.         var twolinenavigator = function () {
  222.             if ($(".horizontalnav.topnavtwoline").length) {
  223.                 var topnavigation = $(".horizontalnav .topnavigation");
  224.                 var twaheight = $(".topwrapperabove").height();
  225.                 var topheight = null;
  226.                 var isbottom = $(".landing-bottom-nav").length;
  227.  
  228.                 if (isbottom) {
  229.                     var height_change = function () {
  230.                         topheight = $(".navigation-flag").offset().top;
  231.                     };
  232.                     $(window).bind('resize load', height_change);
  233.                 } else {
  234.                     topheight = window.joption.menucollapsed;
  235.                 }
  236.  
  237.  
  238.                 var twolinescrolleffect = function () {
  239.                     if (window.jpobj.globaltop <= topheight) {
  240.                         window.jpobj.doTranslate($(topnavigation), "0px", "0px");
  241.                     } else if (window.jpobj.globaltop > topheight) {
  242.                         window.jpobj.doTranslate($(topnavigation), "0px", "-" + twaheight + "px");
  243.                     }
  244.                 };
  245.  
  246.                 $(window).bind('jscroll', twolinescrolleffect);
  247.             }
  248.         };
  249.  
  250.         /**************************
  251.          * make menu smaller
  252.          **************************/
  253.  
  254.         var menusmaller = function () {
  255.             if ($(".topnavsmaller").length) {
  256.                 var istwoline = $(".horizontalnav.topnavtwoline").length;
  257.                 var isbottom = $(".landing-bottom-nav").length;
  258.                 var scrolltosmall = 0;
  259.                 var topnavigation = $(".horizontalnav .topnavigation");
  260.                 var smallnavclass = 'topnavsmall';
  261.  
  262.                 var setscrolltosmall = function() {
  263.                     if (!istwoline && !isbottom) {
  264.                         // single line & top
  265.                         scrolltosmall = window.joption.menucollapsed;
  266.                     } else if (istwoline && !isbottom) {
  267.                         // two line & top
  268.                         scrolltosmall = window.joption.menucollapsed;
  269.                     } else if (!istwoline && isbottom) {
  270.                         // single line & bottom
  271.                         scrolltosmall = $(".navigation-flag").offset().top;
  272.                     } else if (istwoline && isbottom) {
  273.                         // two line & bottom
  274.                         scrolltosmall = $(".navigation-flag").offset().top;
  275.                     }
  276.                 };
  277.  
  278.                 var smallnaveffect = function () {
  279.                     if (window.jpobj.globaltop > scrolltosmall) {
  280.                         $(topnavigation).addClass(smallnavclass);
  281.                     } else {
  282.                         $(topnavigation).removeClass(smallnavclass);
  283.                     }
  284.                 };
  285.  
  286.                 $(window).bind('jscroll', smallnaveffect);
  287.                 $(window).bind('load resize', setscrolltosmall);
  288.             }
  289.         };
  290.  
  291.         /**************************
  292.          * transparent
  293.          **************************/
  294.  
  295.         var transparenteffect = function () {
  296.             if ($(".toptransparent").length) {
  297.                 var topnavigation = $(".horizontalnav .topnavigation");
  298.                 var transparenteffectcss = 'transparentbg';
  299.  
  300.                 var transparentscrolleffect = function () {
  301.                     if (window.jpobj.globaltop > window.joption.menucollapsed) {
  302.                         $(topnavigation).addClass(transparenteffectcss);
  303.                     } else {
  304.                         $(topnavigation).removeClass(transparenteffectcss);
  305.                     }
  306.                 };
  307.  
  308.                 $(window).bind('jscroll', transparentscrolleffect);
  309.             }
  310.         };
  311.  
  312.  
  313.         if ($(window).width() > 1024) {
  314.             twolinenavigator();
  315.             menusmaller();
  316.             transparenteffect();
  317.         }
  318.  
  319.         /**************************
  320.          * horizontal menu
  321.          **************************/
  322.  
  323.         if (window.joption.enablemegamenu !== "1") {
  324.             $(".navcontent li").hover(function () {
  325.                 $(this).addClass('hovered');
  326.             }, function () {
  327.                 $(this).removeClass('hovered');
  328.             });
  329.  
  330.             $("#mega_main_menu_ul > li").hover(function () {
  331.                 $(this).addClass('hovered');
  332.             }, function () {
  333.                 $(this).removeClass('hovered');
  334.             });
  335.  
  336.             $(".navcontent li").hoverIntent({
  337.                 over: function () {
  338.                     var parent = $(this);
  339.                     var childmenu = $(this).find('> .childmenu');
  340.  
  341.                     // check parent is part of child menu
  342.                     var grandparent = $(parent).parent();
  343.  
  344.                     if ($(grandparent).hasClass('childmenu')) {
  345.                         var offset = $(childmenu).joffset();
  346.                         if (typeof offset !== 'undefined') {
  347.                             var ww = $(window).width();
  348.                             var cw = $(childmenu).width();
  349.                             if (( ww - (Math.floor(offset.left) + cw) ) < 0) {
  350.                                 $(childmenu).addClass('goright');
  351.                             }
  352.                         }
  353.                     }
  354.  
  355.                     if ($(childmenu).length) {
  356.                         $(childmenu).css("margin-left", ($(parent).width() - $(childmenu).width()) / 2);
  357.                         $(parent).addClass("menudown");
  358.                         $(childmenu).slideDown("fast");
  359.                     }
  360.                 },
  361.                 out: function () {
  362.                     var parent = $(this);
  363.                     var childmenu = $(this).find('> .childmenu');
  364.                     if ($(childmenu).length) {
  365.                         $(childmenu).slideUp("fast", function () {
  366.                             $(parent).removeClass("menudown");
  367.                         });
  368.                     }
  369.                 },
  370.                 timeout: 300
  371.             });
  372.         }
  373.  
  374.         /**************************
  375.          * Main Mega Menu Top
  376.          **************************/
  377.  
  378.         if ($(".top_navigation.direction-horizontal").length && $(window).width() > 1024) {
  379.  
  380.             $(".top_navigation.direction-horizontal .multicolumn_dropdown > .mega_dropdown").each(function () {
  381.                 var element = this;
  382.                 var parent = $(element).parent();
  383.                 var container = $(element).parents('.topwrapperbottom');
  384.                 var megacontainer = $(element).parents('#mega_main_menu');
  385.  
  386.                 var containervar = {
  387.                     'left': $(container).offset().left,
  388.                     'width': $(container).outerWidth()
  389.                 };
  390.  
  391.                 var elementvar = {
  392.                     'left': $(element).joffset().left
  393.                 };
  394.  
  395.                 if ($(megacontainer).hasClass("dropdowns_animation-none")) {
  396.                     elementvar.width = $(element).jwidth();
  397.                 } else {
  398.                     if (parent.hasClass('columns1')) {
  399.                         elementvar.width = $(element).jwidth() + 250;
  400.                     } else if (parent.hasClass('columns2')) {
  401.                         elementvar.width = $(element).jwidth() + 450;
  402.                     } else if (parent.hasClass('columns3')) {
  403.                         elementvar.width = $(element).jwidth() + 650;
  404.                     } else if (parent.hasClass('columns4')) {
  405.                         elementvar.width = $(element).jwidth() + 850;
  406.                     }
  407.                 }
  408.  
  409.                 var parentpos = {
  410.                     'left': $(parent).offset().left,
  411.                     'width': $(parent).outerWidth(),
  412.                     'id': $(parent).attr('id')
  413.                 };
  414.  
  415.                 // normalize
  416.                 $(element).css({'display': ''});
  417.  
  418.                 // calculate position of menu
  419.                 var maxcontainer = containervar.left + containervar.width;
  420.                 var rightelement = ( parentpos.left + ( parentpos.width / 2 )) + ( elementvar.width / 2 );
  421.                 var elementposition = null;
  422.  
  423.                 if (maxcontainer < rightelement) {
  424.                     rightelement = maxcontainer;
  425.                     elementposition = ( rightelement - elementvar.width ) - elementvar.left - 5;
  426.                 } else {
  427.                     elementposition = ( rightelement - elementvar.width ) - elementvar.left - 5;
  428.                 }
  429.  
  430.                 var arrowposition = Math.floor((parentpos.left + ( parentpos.width / 2 )) - ( rightelement - elementvar.width ) - 5);
  431.                 $('body').remove("#" + parentpos.id + "-arrow");
  432.                 $('body').append("<style id='" + parentpos.id + "-arrow'>" +
  433.                 ".topnavigation #mega_main_menu > .menu_holder > .menu_inner > ul > #" + parentpos.id + " > .mega_dropdown:before { left : " + arrowposition + "px;} " +
  434.                 " </style>");
  435.  
  436.                 $(element).css({
  437.                     'left': elementposition + 'px',
  438.                     'right': 'auto'
  439.                 });
  440.             });
  441.  
  442.  
  443.             $(".top_navigation.direction-horizontal .multicolumn_dropdown").each(function () {
  444.                 var element = this;
  445.                 $(element).hover(function (e) {
  446.                     $(this).find('> .mega_dropdown').css({'z-index': 10});
  447.                 }, function () {
  448.                     $(this).find('> .mega_dropdown').css({'z-index': -1});
  449.                 });
  450.             });
  451.         }
  452.  
  453.         /**************************
  454.          * Mega dropdown Image
  455.          **************************/
  456.         if($(".mega_dropdown").length){
  457.             $(".mega_dropdown").each(function(){
  458.                 var bg = $(this).css('background-image');
  459.                 bg = bg.replace('url(','').replace(')','').replace(/"/g, "").replace(/"/g, "");
  460.  
  461.                 if(bg !== 'none') {
  462.                     var img = new Image();
  463.                     $(img).load(function () {
  464.                     }).attr('src', bg);
  465.                 }
  466.             });
  467.         }
  468.  
  469.         /**************************
  470.          * menu
  471.          **************************/
  472.  
  473.         if (window.joption.enablemegamenu !== "1") {
  474.             $(".mainnav li").bind('click', function (e) {
  475.                 var element = $(e.target).parents('li').get(0);
  476.  
  477.                 if (e.currentTarget === element) {
  478.                     if ($(element).find("> .childmenu").length) {
  479.                         e.preventDefault();
  480.                         $(element).siblings().each(function () {
  481.                             $(this).removeClass("menudown")
  482.                                 .find('> .childmenu')
  483.                                 .slideUp("fast");
  484.                         });
  485.  
  486.                         if ($(element).hasClass("menudown")) {
  487.                             $(element).removeClass("menudown")
  488.                                 .find('> .childmenu')
  489.                                 .slideUp("fast", function () {
  490.                                     $(window).trigger('navchange');
  491.                                 });
  492.                         } else {
  493.                             $(element).addClass("menudown")
  494.                                 .find('> .childmenu')
  495.                                 .slideDown("fast", function () {
  496.                                     $(window).trigger('navchange');
  497.                                 });
  498.                         }
  499.                     } else {
  500.                         return true;
  501.                     }
  502.                 }
  503.             });
  504.  
  505.  
  506.             $(".childmenu").each(function () {
  507.                 var element = $(this).prev();
  508.                 $(element).append('<span class="arrow"></span>');
  509.             });
  510.         }
  511.  
  512.  
  513.         /**************************
  514.          * navigation scroll
  515.          **************************/
  516.  
  517.         if (!$('body').hasClass('horizontalnav')) {
  518.             $('.lefttop').jScrollPane({
  519.                 mouseWheelSpeed: 50,
  520.                 contentWidth: '0px'
  521.             });
  522.             var navscrolpane = $('.lefttop').data('jsp');
  523.  
  524.             var calculate_lefttop = function () {
  525.                 var ww = $(window).height();
  526.                 var leftfooterheight = $(".leftfooter").height();
  527.                 var lefttopheight = ww - leftfooterheight;
  528.                 $(".lefttop").height(lefttopheight);
  529.                 navscrolpane.reinitialise();
  530.             };
  531.  
  532.             $(window).bind('resize navchange', calculate_lefttop);
  533.             calculate_lefttop();
  534.         }
  535.  
  536.         /**************************
  537.          * mobile menu
  538.          **************************/
  539.  
  540.         var mobilemenu = function (element) {
  541.             var role = "main-mobile-menu";
  542.             $(".mobile-menu-trigger").removeClass('active');
  543.  
  544.             if ($('body').hasClass('menuopen')) {
  545.                 $('body').removeClass('menuopen').attr('role', '');
  546.                 $(".contentoverflow").hide();
  547.             } else {
  548.                 $(element).addClass('active');
  549.                 $('body').addClass('menuopen').attr('role', role);
  550.                 $(".contentoverflow").show();
  551.             }
  552.         };
  553.  
  554.         $(".mobile-menu-trigger").bind('click', function () {
  555.             mobilemenu(this);
  556.         });
  557.         $(".contentoverflow").bind('click', function () {
  558.             mobilemenu(null);
  559.         });
  560.  
  561.         /**************************
  562.          * mobile search
  563.          **************************/
  564.  
  565.         $(".mobile-search-trigger").bind('click', function () {
  566.             $(".mobilesearch").show();
  567.             $(".mobilesearch input").focus();
  568.         });
  569.         $(".closemobilesearch").bind('click', function () {
  570.             $(".mobilesearch").hide();
  571.         });
  572.  
  573.  
  574.         /**************************
  575.          * mobile wrapper
  576.          *************************/
  577.         var responsiveheaderheight = $(".responsiveheader").height();
  578.         $(".responsiveheader-wrapper").height(responsiveheaderheight);
  579.  
  580.         /**************************
  581.          * Cart Open
  582.          *************************/
  583.  
  584.         if ($(".horizontalnav").length) {
  585.             if ($(".horizontalnav .topcart").length) {
  586.                 var horizontalcart = function () {
  587.                     var selector = $(".topcartcontent");
  588.                     var leftpos = $(selector).joffset().left;
  589.                     var topwidth = $(selector).outerWidth();
  590.                     var ww = $(window).width();
  591.  
  592.                     if (( leftpos + topwidth ) >= ww) {
  593.                         $(selector).addClass("normalizeposition");
  594.                     } else {
  595.                         $(selector).removeClass("normalizeposition");
  596.                     }
  597.                 };
  598.  
  599.                 horizontalcart();
  600.                 $(window).bind('resize', horizontalcart);
  601.                 $(".topcart > a").bind('click', function (e) {
  602.                     e.preventDefault();
  603.                 });
  604.  
  605.                 $(".topcart").hoverIntent({
  606.                     over: function () {
  607.                         $(".topcartcontent").slideDown("fast");
  608.                     },
  609.                     out: function () {
  610.                         $(".topcartcontent").slideUp("fast");
  611.                     },
  612.                     timeout: 500
  613.                 });
  614.             }
  615.         } else {
  616.             var cartelement = $(".topcart > a");
  617.             $(document).mouseup(function(e){
  618.                 var cartparent = $(cartelement).parent(".topcart");
  619.                 if($(e.target).parents('.topcart > a').length > 0 || cartelement.is(e.target)) {
  620.                     if ($(cartparent).hasClass('active')) {
  621.                         $(cartparent).removeClass('active');
  622.                     } else {
  623.                         $(cartparent).addClass('active');
  624.                     }
  625.                 } else {
  626.                     $(cartparent).removeClass('active');
  627.                 }
  628.             });
  629.         }
  630.  
  631.         /**************************
  632.          * My Account Open
  633.          *************************/
  634.  
  635.         if ($(".horizontalnav").length) {
  636.             if ($(".horizontalnav .topaccount").length) {
  637.                 var horizontaloffset = function () {
  638.                     var selector = $(".accountdrop");
  639.                     var leftpos = $(selector).joffset().left;
  640.                     var topwidth = $(selector).width();
  641.                     var ww = $(window).width();
  642.  
  643.                     if (( leftpos + topwidth ) >= ww) {
  644.                         $(selector).addClass("normalizeposition");
  645.                     } else {
  646.                         $(selector).removeClass("normalizeposition");
  647.                     }
  648.                 };
  649.  
  650.                 horizontaloffset();
  651.                 $(window).bind('resize', horizontaloffset);
  652.  
  653.                 $(".topaccount > a").bind('click', function (e) {
  654.                     e.preventDefault();
  655.                 });
  656.  
  657.                 $(".topaccount").hoverIntent({
  658.                     over: function (e) {
  659.                         $(".accountdrop").slideDown("fast");
  660.                     },
  661.                     out: function (e) {
  662.                         $(".accountdrop").slideUp("fast");
  663.                     },
  664.                     timeout: 300
  665.                 });
  666.             }
  667.         } else {
  668.             var myaccelement = $(".topaccount > a");
  669.             $(document).mouseup(function(e){
  670.                 var myaccparent = $(myaccelement).parent(".topaccount");
  671.                 if($(e.target).parents('.topaccount > a').length > 0 || myaccelement.is(e.target)) {
  672.                     if ($(myaccparent).hasClass('active')) {
  673.                         $(myaccparent).removeClass('active');
  674.                     } else {
  675.                         $(myaccparent).addClass('active');
  676.                     }
  677.                 } else {
  678.                     $(myaccparent).removeClass('active');
  679.                 }
  680.             });
  681.         }
  682.  
  683.         /**************************
  684.          * sidebar follow
  685.          *************************/
  686.  
  687.         if ($(".mainsidebar-wrapper").length) {
  688.             var sidebar = $(".mainsidebar-wrapper");
  689.             var parentsidebar = $(".mainsidebar");
  690.             var parentpos, sidebarheight, sidebarwidth, wh, ww, sidebarmode, headermenuheight;
  691.             var margin = 15;
  692.             var bottommargin = 0;
  693.             var enabled = true;
  694.  
  695.             var ishorizontal = $(".horizontalnav").length;
  696.             var istwoline = $(".topnavtwoline").length;
  697.             var issmallnav = $(".topnavsmaller").length;
  698.             var issidenav = $(".sidenav").length;
  699.             var issidenoheadermenu = $(".noheadermenu").length;
  700.  
  701.             var getheadermenuposition = function(){
  702.                 if(issidenav) {
  703.                     if(issidenoheadermenu) {
  704.                         headermenuheight = 0;
  705.                     } else {
  706.                         headermenuheight = $(".headermenu").height();
  707.                     }
  708.                 } else if(ishorizontal) {
  709.                     bottommargin = $(".footercontent").height();
  710.                     headermenuheight = $(".topnavigation").height();
  711.  
  712.                     if(window.jpobj.globaltop > window.joption.menucollapsed) {
  713.                         if (istwoline && !issmallnav) {
  714.                             headermenuheight = $(".topwrapperbottom").height();
  715.                         } else if( ( issmallnav && !istwoline ) || ( istwoline && issmallnav ) ) {
  716.                             headermenuheight = window.joption.smallmenuheight;
  717.                         }
  718.                     }
  719.                 }
  720.  
  721.                 headermenuheight = parseInt(headermenuheight, 10);
  722.             };
  723.  
  724.  
  725.             var setupsidebar = function () {
  726.                 getheadermenuposition();
  727.                 parentpos = $(parentsidebar).offset().top;
  728.                 sidebarheight = $(sidebar).height();
  729.                 sidebarwidth = $(sidebar).attr('style', '').css({
  730.                     'position': 'relative'
  731.                 }).width();
  732.                 $(sidebar).width(sidebarwidth);
  733.  
  734.                 wh = $(window).height();
  735.                 ww = $(window).width();
  736.  
  737.                 if ((sidebarheight + margin + headermenuheight) < wh) {
  738.                     sidebarmode = 'sticktop';
  739.                 } else {
  740.                     sidebarmode = 'stickbottom';
  741.                 }
  742.  
  743.                 if (sidebarheight > $('.mainpage').height()) {
  744.                     enabled = false;
  745.                 } else {
  746.                     enabled = true;
  747.                 }
  748.             };
  749.  
  750.             var followsidebar = function () {
  751.                 getheadermenuposition();
  752.                 var sidebarpos;
  753.                 if (ww > 1152 && enabled) {
  754.                     if (sidebarmode === 'stickbottom') {
  755.                         sidebarpos = (window.jpobj.globaltop + wh) - sidebarheight - parentpos - bottommargin;
  756.  
  757.                         if (sidebarpos > 0) {
  758.                             $(sidebar).css({
  759.                                 'top': -(sidebarheight + bottommargin - wh),
  760.                                 'position': 'fixed'
  761.                             }).addClass('fixedelement');
  762.                         } else {
  763.                             $(sidebar).css({
  764.                                 'top': 0,
  765.                                 'position': 'relative'
  766.                             }).removeClass('fixedelement');
  767.                         }
  768.                     } else {
  769.                         sidebarpos = (window.jpobj.globaltop + headermenuheight + margin) - parentpos;
  770.  
  771.                         if (sidebarpos > 0) {
  772.                             $(sidebar).css({
  773.                                 'top': parseInt(margin, 10) + parseInt(headermenuheight, 10),
  774.                                 'position': 'fixed'
  775.                             }).addClass('fixedelement');
  776.                         } else {
  777.                             $(sidebar).css({
  778.                                 'top': 0,
  779.                                 'position': 'relative'
  780.                             }).removeClass('fixedelement');
  781.                         }
  782.                     }
  783.                 } else {
  784.                     $(sidebar).css({
  785.                         'top': 0,
  786.                         'position': 'relative'
  787.                     });
  788.                 }
  789.             };
  790.  
  791.             var dofollowsidebar = function () {
  792.                 setupsidebar();
  793.                 followsidebar();
  794.             };
  795.  
  796.             $(window).bind('load ready', function () {
  797.                 dofollowsidebar();
  798.                 window.setTimeout(dofollowsidebar, 2000);
  799.             });
  800.  
  801.             $(window).bind('resize', function () {
  802.                 dofollowsidebar();
  803.                 window.setTimeout(dofollowsidebar, 2000);
  804.             });
  805.  
  806.             $(window).bind('jscroll', followsidebar);
  807.         }
  808.  
  809.  
  810.         /********
  811.          * share
  812.          */
  813.         if ($(".sharrre-container-big").length) {
  814.             $(".sharrre-container-big").each(function () {
  815.                 var element = $(this);
  816.  
  817.                 // twitter share
  818.                 $(element).find(".twitter-share").sharrre({
  819.                     share: {
  820.                         twitter: true
  821.                     },
  822.                     template: '<a class="boxed" href="#"><div class="count" href="#">{total}</div><div class="whitearr"></div><div class="share"><i class="fa fa-twitter"></i></div></a>',
  823.                     enableHover: false,
  824.                     enableTracking: true,
  825.                     buttons: {
  826.                         twitter: {}
  827.                     },
  828.                     click: function (api) {
  829.                         api.simulateClick();
  830.                         api.openPopup('twitter');
  831.                     }
  832.                 });
  833.  
  834.                 // facebook share
  835.                 $(element).find(".facebook-share").sharrre({
  836.                     share: {
  837.                         facebook: true
  838.                     },
  839.                     template: '<a class="boxed" href="#"><div class="count" href="#">{total}</div><div class="whitearr"></div><div class="share"><i class="fa fa-facebook-square"></i></div></a>',
  840.                     enableHover: false,
  841.                     enableTracking: true,
  842.                     click: function (api) {
  843.                         api.simulateClick();
  844.                         api.openPopup('facebook');
  845.                     }
  846.                 });
  847.  
  848.  
  849.                 // google share
  850.                 $(element).find(".googleplus-share").sharrre({
  851.                     share: {
  852.                         googlePlus: true
  853.                     },
  854.                     template: '<a class="boxed" href="#"><div class="count" href="#">{total}</div><div class="whitearr"></div><div class="share"><i class="fa fa-google-plus-square"></i></div></a>',
  855.                     enableHover: false,
  856.                     enableTracking: true,
  857.                     urlCurl: '',
  858.                     click: function (api) {
  859.                         api.simulateClick();
  860.                         api.openPopup('googlePlus');
  861.                     }
  862.                 });
  863.  
  864.                 // pinterest share
  865.                 $(element).find(".pinterest-share").sharrre({
  866.                     share: {
  867.                         pinterest: true
  868.                     },
  869.                     template: '<a class="boxed" href="#" rel="nofollow"><div class="count" href="#">{total}</div><div class="whitearr"></div><div class="share"><i class="fa fa-pinterest"></i></div></a>',
  870.                     enableHover: false,
  871.                     enableTracking: true,
  872.                     buttons: {},
  873.                     pinterest: {},
  874.                     click: function (api) {
  875.                         api.simulateClick();
  876.                         api.openPopup('pinterest');
  877.                     }
  878.                 });
  879.             });
  880.         }
  881.  
  882.         /********
  883.          * share container
  884.          */
  885.         if ($(".sharrre-container").length) {
  886.             $(".sharrre-container").each(function () {
  887.                 var element = $(this);
  888.  
  889.                 // twitter share
  890.                 $(element).find(".twitter-share").sharrre({
  891.                     share: {
  892.                         twitter: true
  893.                     },
  894.                     template: '<a class="boxed grouped" href="#"><div class="count" href="#">{total}</div><div class="whitearr"></div><div class="share"><i class="fa fa-twitter"></i></div></a>',
  895.                     enableHover: false,
  896.                     enableTracking: true,
  897.                     buttons: {
  898.                         twitter: {}
  899.                     },
  900.                     click: function (api) {
  901.                         api.simulateClick();
  902.                         api.openPopup('twitter');
  903.                     }
  904.                 });
  905.  
  906.                 // facebook share
  907.                 $(element).find(".facebook-share").sharrre({
  908.                     share: {
  909.                         facebook: true
  910.                     },
  911.                     template: '<a class="boxed grouped" href="#"><div class="count" href="#">{total}</div><div class="whitearr"></div><div class="share"><i class="fa fa-facebook-square"></i></div></a>',
  912.                     enableHover: false,
  913.                     enableTracking: true,
  914.                     click: function (api) {
  915.                         api.simulateClick();
  916.                         api.openPopup('facebook');
  917.                     }
  918.                 });
  919.  
  920.  
  921.                 // google share
  922.                 $(element).find(".googleplus-share").sharrre({
  923.                     share: {
  924.                         googlePlus: true
  925.                     },
  926.                     template: '<a class="boxed grouped" href="#"><div class="count" href="#">{total}</div><div class="whitearr"></div><div class="share"><i class="fa fa-google-plus-square"></i></div></a>',
  927.                     enableHover: false,
  928.                     enableTracking: true,
  929.                     urlCurl: '',
  930.                     click: function (api) {
  931.                         api.simulateClick();
  932.                         api.openPopup('googlePlus');
  933.                     }
  934.                 });
  935.  
  936.                 // pinterest share
  937.                 $(element).find(".pinterest-share").sharrre({
  938.                     share: {
  939.                         pinterest: true
  940.                     },
  941.                     template: '<a class="boxed grouped" href="#" rel="nofollow"><div class="count" href="#">{total}</div><div class="whitearr"></div><div class="share"><i class="fa fa-pinterest"></i></div></a>',
  942.                     enableHover: false,
  943.                     enableTracking: true,
  944.                     buttons: {},
  945.                     pinterest: {},
  946.                     click: function (api) {
  947.                         api.simulateClick();
  948.                         api.openPopup('pinterest');
  949.                     }
  950.                 });
  951.             });
  952.         }
  953.  
  954.         /********
  955.          * clean blog share container
  956.          */
  957.         if ($(".sharrre-container-clean").length) {
  958.             $(".sharrre-container-clean").each(function () {
  959.                 var element = $(this);
  960.  
  961.                 // twitter share
  962.                 $(element).find(".twitter-share").sharrre({
  963.                     share: {
  964.                         twitter: true
  965.                     },
  966.                     template: '<a class="circle" href="#"><span class="share"><i class="fa fa-twitter"></i></span><span class="count" href="#">{total}</span></a>',
  967.                     enableHover: false,
  968.                     enableTracking: true,
  969.                     buttons: {
  970.                         twitter: {}
  971.                     },
  972.                     click: function (api) {
  973.                         api.simulateClick();
  974.                         api.openPopup('twitter');
  975.                     }
  976.                 });
  977.  
  978.                 // facebook share
  979.                 $(element).find(".facebook-share").sharrre({
  980.                     share: {
  981.                         facebook: true
  982.                     },
  983.                     template: '<a class="circle" href="#"><span class="share"><i class="fa fa-facebook"></i></span><span class="count" href="#">{total}</span></a>',
  984.                     enableHover: false,
  985.                     enableTracking: true,
  986.                     click: function (api) {
  987.                         api.simulateClick();
  988.                         api.openPopup('facebook');
  989.                     }
  990.                 });
  991.  
  992.  
  993.                 // google share
  994.                 $(element).find(".googleplus-share").sharrre({
  995.                     share: {
  996.                         googlePlus: true
  997.                     },
  998.                     template: '<a class="circle" href="#"><span class="share"><i class="fa fa-google-plus"></i></span><span class="count" href="#">{total}</span></a>',
  999.                     enableHover: false,
  1000.                     enableTracking: true,
  1001.                     urlCurl: '',
  1002.                     click: function (api) {
  1003.                         api.simulateClick();
  1004.                         api.openPopup('googlePlus');
  1005.                     }
  1006.                 });
  1007.  
  1008.                 // pinterest share
  1009.                 $(element).find(".pinterest-share").sharrre({
  1010.                     share: {
  1011.                         pinterest: true
  1012.                     },
  1013.                     template: '<a class="circle" href="#"><span class="share"><i class="fa fa-pinterest"></i></span><span class="count" href="#">{total}</span></a>',
  1014.                     enableHover: false,
  1015.                     enableTracking: true,
  1016.                     buttons: {},
  1017.                     pinterest: {},
  1018.                     click: function (api) {
  1019.                         api.simulateClick();
  1020.                         api.openPopup('pinterest');
  1021.                     }
  1022.                 });
  1023.             });
  1024.         }
  1025.  
  1026.  
  1027.         /********
  1028.          * Product Share
  1029.          */
  1030.         if ($(".normal-sharrre-container").length) {
  1031.             $(".normal-sharrre-container").each(function () {
  1032.                 var element = $(this);
  1033.                 var twittertext = $(element).find(".twitter-share-block").data('title');
  1034.                 var facebooktext = $(element).find(".facebook-share-block").data('title');
  1035.                 var googletext = $(element).find(".googleplus-share-block").data('title');
  1036.                 var pinteresttext = $(element).find(".pinterest-share-block").data('title');
  1037.  
  1038.  
  1039.                 // twitter share
  1040.                 $(element).find(".twitter-share-block").sharrre({
  1041.                     share: {
  1042.                         twitter: true
  1043.                     },
  1044.                     template: '<a class="share-block" href="#"><div class="share-icon"><i class="fa fa-twitter"></i></div><div class="share-count">{total} ' + twittertext + '</div></a>',
  1045.                     enableHover: false,
  1046.                     enableTracking: true,
  1047.                     buttons: {
  1048.                         twitter: {}
  1049.                     },
  1050.                     click: function (api) {
  1051.                         api.simulateClick();
  1052.                         api.openPopup('twitter');
  1053.                     }
  1054.                 });
  1055.  
  1056.                 // facebook share
  1057.                 $(element).find(".facebook-share-block").sharrre({
  1058.                     share: {
  1059.                         facebook: true
  1060.                     },
  1061.                     template: '<a class="share-block" href="#"><div class="share-icon"><i class="fa fa-facebook-square"></i></div><div class="share-count">{total} ' + facebooktext + '</div></a>',
  1062.                     enableHover: false,
  1063.                     enableTracking: true,
  1064.                     click: function (api) {
  1065.                         api.simulateClick();
  1066.                         api.openPopup('facebook');
  1067.                     }
  1068.                 });
  1069.  
  1070.  
  1071.                 // google share
  1072.                 $(element).find(".googleplus-share-block").sharrre({
  1073.                     share: {
  1074.                         googlePlus: true
  1075.                     },
  1076.                     template: '<a class="share-block" href="#"><div class="share-icon"><i class="fa fa-google-plus-square"></i></div><div class="share-count">{total} ' + googletext + '</div></a>',
  1077.                     enableHover: false,
  1078.                     enableTracking: true,
  1079.                     urlCurl: '',
  1080.                     click: function (api) {
  1081.                         api.simulateClick();
  1082.                         api.openPopup('googlePlus');
  1083.                     }
  1084.                 });
  1085.  
  1086.                 // pinterest share
  1087.                 $(element).find(".pinterest-share-block").sharrre({
  1088.                     share: {
  1089.                         pinterest: true
  1090.                     },
  1091.                     template: '<a class="share-block" href="#"><div class="share-icon"><i class="fa fa-pinterest"></i></div><div class="share-count">{total} ' + pinteresttext + '</div></a>',
  1092.                     enableHover: false,
  1093.                     enableTracking: true,
  1094.                     buttons: {},
  1095.                     pinterest: {},
  1096.                     click: function (api) {
  1097.                         api.simulateClick();
  1098.                         api.openPopup('pinterest');
  1099.                     }
  1100.                 });
  1101.             });
  1102.         }
  1103.  
  1104.         var tweetticker = function () {
  1105.             $('.jeg-tweets').each(function () {
  1106.                 var element = $(this),
  1107.                     $tweet = null,
  1108.                     $next = null;
  1109.                 $(element).height($(element).find('li:first').outerHeight());
  1110.  
  1111.                 window.setInterval(function () {
  1112.                     $tweet = $(element).find('li:first');
  1113.                     $next = $tweet.next();
  1114.  
  1115.                     $(element).animate({height: ($next.outerHeight()) + 'px'}, 800);
  1116.                     $tweet.animate({marginTop: '-' + $tweet.outerHeight() + 'px'}, 400, function () {
  1117.                         $(this).detach().appendTo($(element).find('ul')).removeAttr('style');
  1118.                     });
  1119.                 }, 4000);
  1120.             });
  1121.         };
  1122.  
  1123.         tweetticker();
  1124.  
  1125.     }
  1126.  
  1127.  
  1128.     // document ready to dispatch
  1129.     $(document).ready(dispatch);
  1130.  
  1131. })(jQuery, window, document, window.MediaElement);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement