Advertisement
jegtheme

jquery.jlanding.js

Jul 4th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Author : Jegbagus
  3.  * file name : jquery.jlanding.js
  4.  */
  5.  
  6.  
  7. /*** background parallax ***/
  8.  
  9. (function ($) {
  10.     "use strict";
  11.     $.fn.jparallax = function () {
  12.  
  13.         $(this).each(function () {
  14.             var element, elepos, dpos, bgpos, initpos, centerelement, bgfpos, movespeed, parent, scrollpos, ratio;
  15.             var percentmove = 100;
  16.  
  17.             element = $(this);
  18.  
  19.             if ($(element).prop("tagName") === 'SECTION') {
  20.                 parent = element;
  21.             } else {
  22.                 parent = $(this).parent();
  23.             }
  24.  
  25.             bgpos = $(element).css('backgroundPosition').split(" ");
  26.             bgfpos = $(this).data('position');
  27.             movespeed = $(this).data('speed');
  28.  
  29.             var init_position = function () {
  30.                 var calcpos = function () {
  31.                     var minpos = elepos.top - $(window).height();
  32.                     var maxpos = $(parent).next().position().top;
  33.  
  34.                     return {
  35.                         'min': minpos,
  36.                         'max': maxpos,
  37.                         'diff': (maxpos - minpos)
  38.                     };
  39.                 };
  40.  
  41.                 elepos = $(parent).position();
  42.                 dpos = calcpos();
  43.             };
  44.  
  45.             var reset_paralax = function () {
  46.                 setTimeout(function () {
  47.                     init_position();
  48.                     doparallax();
  49.                 }, 500);
  50.  
  51.             };
  52.  
  53.             function fixedbackground(ratio, scrollpos, dpos) {
  54.                 var bgposresult = -1 * (ratio * movespeed);
  55.                 var newposition = bgfpos + " " + bgposresult + "px";
  56.                 $(element).css('background-position', newposition);
  57.             }
  58.  
  59.             var doparallax = function () {
  60.                 if (dpos !== undefined) {
  61.                     scrollpos = jpobj.globaltop;
  62.                     ratio = null;
  63.  
  64.                     if (scrollpos >= dpos.min && scrollpos <= dpos.max) {
  65.                         ratio = (scrollpos - dpos.min) / dpos.diff;
  66.                         fixedbackground(ratio, scrollpos, dpos);
  67.                     }
  68.                 }
  69.             };
  70.  
  71.             if (!joption.ismobile) {
  72.                 $(window).bind('load resize', reset_paralax);
  73.                 $(window).bind('jscroll', doparallax);
  74.             }
  75.         });
  76.     };
  77. })(jQuery);
  78.  
  79.  
  80. /** new parallax **/
  81. (function ($) {
  82.     "use strict";
  83.     $.fn.jnewparallax = function () {
  84.         var element, parent, bgpos, sizemode, speed, dpos, elesize, scrollpos, ratio, bgtoppos, scrolldiff;
  85.         element = this;
  86.         parent = $(this).parent();
  87.         bgpos = $(this).data('position');
  88.         sizemode = $(this).data('sizemode');
  89.         speed = $(this).data('speed');
  90.  
  91.         var reset_paralax = function () {
  92.             setTimeout(function () {
  93.                 init_position();
  94.                 do_parallax();
  95.             }, 500);
  96.         };
  97.  
  98.         var init_position = function () {
  99.             var calcpos = function () {
  100.                 var minpos = $(parent).position().top - $(window).height();
  101.                 var maxpos = $(parent).position().top + $(parent).outerHeight();
  102.  
  103.                 return {
  104.                     'min': minpos,
  105.                     'max': maxpos,
  106.                     'diff': (maxpos - minpos),
  107.                     'wh': $(window).height()
  108.                 };
  109.             };
  110.  
  111.             var calcresize = function () {
  112.                 $(element).attr('style', '');
  113.  
  114.                 var eleresizer = null;
  115.                 var toppos = 0;
  116.                 var leftpos = 0;
  117.  
  118.                 if (sizemode === 'nostretch') {
  119.  
  120.                     eleresizer = {
  121.                         'elewidth': $(element).width(),
  122.                         'eleheight': $(element).height(),
  123.                         'containerwidth': $(parent).outerWidth(),
  124.                         'containerheight': $(parent).outerHeight()
  125.                     };
  126.  
  127.                 } else {
  128.  
  129.                     var imagesize = $.new_get_image_container_size($(element), $(window), 'zoom');
  130.                     $(element).css({
  131.                         'height': imagesize[0],
  132.                         'width': imagesize[1]
  133.                     });
  134.  
  135.                     eleresizer = {
  136.                         'eleheight': imagesize[0],
  137.                         'elewidth': imagesize[1],
  138.                         'containerwidth': $(parent).outerWidth(),
  139.                         'containerheight': $(parent).outerHeight()
  140.                     };
  141.  
  142.                 }
  143.  
  144.                 // initial position
  145.                 toppos = ( eleresizer.containerheight - eleresizer.eleheight ) / 2;
  146.                 if (bgpos === 'center') {
  147.                     leftpos = ( eleresizer.containerwidth - eleresizer.elewidth ) / 2;
  148.                 } else if (bgpos === 'left') {
  149.                     leftpos = 0;
  150.                 } else if (bgpos === 'right') {
  151.                     leftpos = eleresizer.containerwidth - eleresizer.elewidth;
  152.                 }
  153.  
  154.                 jpobj.doTranslate(element, leftpos + "px", toppos + "px");
  155.                 eleresizer.leftpos = leftpos;
  156.  
  157.                 return eleresizer;
  158.             };
  159.  
  160.             dpos = calcpos();
  161.             elesize = calcresize();
  162.         };
  163.  
  164.         var fixedbackground = function (scrollpos, ratio, scrolldiff) {
  165.             // ( elesize.eleheight - ( elesize.eleheight - dpos.wh ) ) -> biar posisi patokan nya tetap di top
  166.             // speed * ( dpos.wh / dpos.diff ) -> posisi teratas image terlihat
  167.             // scrolldiff -> agar posisi  nya tetap ditengah (saat 0)
  168.             // ( ratio * speed ) -> parallax effect
  169.             bgtoppos = -1 * ( ( elesize.eleheight - ( elesize.eleheight - dpos.wh ) ) - ( speed * ( dpos.wh / dpos.diff ) ) - scrolldiff + ( ratio * speed ) );
  170.             jpobj.doTranslate(element, elesize.leftpos + "px", Math.floor(bgtoppos) + "px");
  171.         };
  172.  
  173.         var do_parallax = function () {
  174.             if (dpos !== undefined) {
  175.                 ratio = null;
  176.                 scrollpos = $(window).scrollTop();
  177.  
  178.                 if (scrollpos >= dpos.min && scrollpos <= dpos.max) {
  179.                     scrolldiff = scrollpos - dpos.min;
  180.                     ratio = scrolldiff / dpos.diff;
  181.                     fixedbackground(scrollpos, ratio, scrolldiff);
  182.                 }
  183.             }
  184.         };
  185.  
  186.         if (!joption.ismobile) {
  187.             $(window).bind('load resize', reset_paralax);
  188.             $(window).bind('scroll', do_parallax);
  189.         }
  190.     };
  191. })(jQuery);
  192.  
  193. /** heading parallax **/
  194. (function ($) {
  195.     "use strict";
  196.  
  197.     /** heading parallax **/
  198.     $.fn.headingparallax = function () {
  199.         var element = $(this);
  200.         var toplimit = 0;
  201.         var bottomlimit = 0;
  202.         var topoffset = 0;
  203.         var eleheight = 0;
  204.         var scrollpos = 0;
  205.         var turnzero = 0;
  206.         var hh = $.jreducedtop();
  207.         if ($(".bottomnav").length) {
  208.             hh = 0;
  209.         }
  210.  
  211.         var eleslideholder = $(element).find('.bgholder');
  212.         var eletextholder = $(element).find('.parallaxtext');
  213.  
  214.         var resize_container = function () {
  215.             topoffset = $(element).offset().top;
  216.             eleheight = $(element).height();
  217.  
  218.             toplimit = topoffset + hh;
  219.             bottomlimit = topoffset + eleheight - hh;
  220.         };
  221.  
  222.         function scrolleffect() {
  223.             if (scrollpos > toplimit && scrollpos < bottomlimit) {
  224.                 var ratio = 0;
  225.                 ratio = (scrollpos - topoffset - hh) / eleheight;
  226.  
  227.                 // opacity
  228.                 $(eletextholder).css({ 'opacity': (1 - (ratio * 0.75)) });
  229.  
  230.                 // centering
  231.                 var centering = (ratio * eleheight / 2);
  232.                 jpobj.doTranslate(eleslideholder, "0px", centering + "px");
  233.                 jpobj.doTranslate(eletextholder, "0px", centering + "px");
  234.                 turnzero = 1;
  235.             } else {
  236.                 jpobj.doTranslate(eleslideholder, "0px", "0px");
  237.                 jpobj.doTranslate(eletextholder, "0px", "0px");
  238.                 $(eletextholder).css({ 'opacity': 1 });
  239.                 turnzero = 0;
  240.             }
  241.         }
  242.  
  243.         function scrollcallback() {
  244.             scrollpos = jpobj.globaltop;
  245.             scrolleffect();
  246.         }
  247.  
  248.         function youtubefullscreen() {
  249.             if(!joption.ismobile) {
  250.                 var youtubeurl = $(element).find('.youtubefullscreen').data('url');
  251.                 var youtubeid = $.youtube_parser(youtubeurl);
  252.                 var usestatic = $(element).find('.youtubefullscreen').data('static') === 1 ? true : false;
  253.                 $(element).find('.youtubefullscreen').tubular({
  254.                     videoId: youtubeid,
  255.                     attachtobody: usestatic
  256.                 });
  257.             } else {
  258.                 $(element).find('.video-fallback').show();
  259.                 $(element).find('.youtubefullscreen').hide();
  260.                 $(element).find('.video_toggle').hide();
  261.             }
  262.         }
  263.  
  264.         $(window).bind('resize load', resize_container);
  265.  
  266.         // check type
  267.         var slidertype = $(element).data('slider-type');
  268.         if(slidertype === 'youtube')  youtubefullscreen();
  269.  
  270.         if (!joption.ismobile && (jpobj.browser[0].toLowerCase() === 'chrome' || jpobj.browser[0].toLowerCase() === 'firefox')) {
  271.             $(window).bind('jscroll', scrollcallback);
  272.  
  273.         }
  274.     };
  275.  
  276.  
  277.     /** full screen text slider ***/
  278.     $.fn.fslandingslider = function () {
  279.         $(this).each(function () {
  280.             var ele = this;
  281.             var ulwrapper = $("ul", this);
  282.             var curidx = 0;
  283.             var totalchild = $(".text-slider-wrap ul li", this).length;
  284.             var slidespeed = $(ulwrapper).data('speed');
  285.             var topposition = 0;
  286.  
  287.             // move the slider
  288.             var moveslider = function (i) {
  289.                 var wrapheight = $(".text-slider-wrap", ele).height();
  290.                 $(ulwrapper).animate({
  291.                     top: ( wrapheight * ( i % totalchild ) * -1)
  292.                 }, 400);
  293.             };
  294.  
  295.             setInterval(function () {
  296.                 moveslider(++curidx);
  297.             }, slidespeed);
  298.  
  299.             // click event
  300.             $(".callout", ele).bind('click', function () {
  301.                 var nextele;
  302.  
  303.                 if ($(".bottomnav").length) {
  304.                     nextele = $(ele).parent().next().next();
  305.                 } else {
  306.                     nextele = $(ele).parent().next();
  307.                 }
  308.  
  309.  
  310.                 if ($(window).width() > 1024) topposition = $(nextele).offset().top + $.jreducedtoplanding() + 1
  311.                 else topposition = $(nextele).offset().top;
  312.  
  313.                 $('html, body').animate({
  314.                     scrollTop: topposition
  315.                 }, 700, "easeInOutQuad");
  316.  
  317.             });
  318.             return this;
  319.         });
  320.     };
  321.  
  322.  
  323.     $.landingslitslider = function (element) {
  324.         $(".sliderloader").fadeIn();
  325.         var Page = (function () {
  326.             var $navArrows = $('#nav-arrows'),
  327.                 $nav = $('#nav-dots > span'),
  328.                 slitslider = $('#slider').slitslider({
  329.                     onBeforeChange: function (slide, pos) {
  330.                         $nav.removeClass('nav-dot-current');
  331.                         $nav.eq(pos).addClass('nav-dot-current');
  332.                     }
  333.                 }),
  334.                 init = function () {
  335.                     initEvents();
  336.                 },
  337.                 initEvents = function () {
  338.                     // add navigation events
  339.                     $navArrows.children(':last').on('click', function () {
  340.                         slitslider.next();
  341.                         return false;
  342.                     });
  343.  
  344.                     $navArrows.children(':first').on('click', function () {
  345.                         slitslider.previous();
  346.                         return false;
  347.                     });
  348.  
  349.                     $nav.each(function (i) {
  350.                         $(this).on('click', function (event) {
  351.                             var $dot = $(this);
  352.                             if (!slitslider.isActive()) {
  353.                                 $nav.removeClass('nav-dot-current');
  354.                                 $dot.addClass('nav-dot-current');
  355.                             }
  356.                             slitslider.jump(i + 1);
  357.                             return false;
  358.                         });
  359.                     });
  360.                 };
  361.             return { init: init };
  362.         })();
  363.  
  364.  
  365.         var done_loading = function () {
  366.             $(".sl-slider-wrapper").fadeIn();
  367.             $(".sliderloader").fadeOut();
  368.             Page.init();
  369.         };
  370.  
  371.         var load_background = function (i) {
  372.             if ($('.sl-slide').length > i) {
  373.                 var bg = $($('.sl-slide').get(i)).find('.bg-img ').css('background-image');
  374.                 bg = bg.replace('url(', '').replace(')', '');
  375.                 bg = bg.replace('"', '').replace('"', '');
  376.                 var img = new Image();
  377.  
  378.                 $(img).load(function () {
  379.                     load_background(++i);
  380.                 }).attr('src', bg);
  381.             } else {
  382.                 done_loading();
  383.             }
  384.         };
  385.  
  386.         load_background(0);
  387.  
  388.         /**
  389.          * split slider parallax
  390.          **/
  391.         var toplimit = 0;
  392.         var bottomlimit = 0;
  393.         var topoffset = 0;
  394.         var eleheight = 0;
  395.         var scrollpos = 0;
  396.         var turnzero = 0;
  397.         var hh = $.jreducedtop();
  398.         if ($(".bottomnav").length) {
  399.             hh = 0;
  400.         }
  401.         var eleslideholder = $(element).find(".sl-slider-wrapper");
  402.  
  403.         var scrolleffect = function () {
  404.             if (scrollpos > toplimit && scrollpos < bottomlimit) {
  405.                 var ratio = 0;
  406.                 ratio = (scrollpos - topoffset - hh) / eleheight;
  407.  
  408.                 // centering
  409.                 var centering = (ratio * eleheight / 2);
  410.                 jpobj.doTranslate(eleslideholder, "0px", centering + "px");
  411.                 turnzero = 1;
  412.             } else {
  413.                 jpobj.doTranslate(eleslideholder, "0px", "0px");
  414.                 turnzero = 0;
  415.             }
  416.         };
  417.  
  418.         var scrollcallback = function () {
  419.             scrollpos = jpobj.globaltop;
  420.             scrolleffect();
  421.         };
  422.  
  423.         var resize_container = function () {
  424.             topoffset = $(eleslideholder).offset().top;
  425.             eleheight = $(eleslideholder).height();
  426.  
  427.             toplimit = topoffset + hh;
  428.             bottomlimit = topoffset + eleheight - hh;
  429.         };
  430.  
  431.         $(window).bind('resize', resize_container);
  432.         $(window).bind('load', function () {
  433.             setTimeout(resize_container, 1000);
  434.         });
  435.  
  436.         if (!joption.ismobile && (jpobj.browser[0].toLowerCase() === 'chrome' || jpobj.browser[0].toLowerCase() === 'firefox')) {
  437.             $(window).bind('jscroll', scrollcallback);
  438.         }
  439.     };
  440.  
  441. })(jQuery);
  442.  
  443. (function ($) {
  444.     "use strict";
  445.     $.fn.jlanding = function () {
  446.         var element = this;
  447.  
  448.         var slitslider = function () {
  449.             if ($(".landingslider", element).length) {
  450.                 $.landingslitslider(element);
  451.             }
  452.         };
  453.  
  454.         function getTransform(el) {
  455.             var matrix = $(el).css('-webkit-transform');
  456.             if (matrix === undefined) var matrix = $(el).css('-o-transform');
  457.             if (matrix === undefined) var matrix = $(el).css('-ms-transform');
  458.             if (matrix === undefined) var matrix = $(el).css('-moz-transform');
  459.             if (matrix === undefined) var matrix = $(el).css('transform');
  460.  
  461.             var values = matrix.match(/-?[0-9\.]+/g);
  462.             return values[4];
  463.         }
  464.  
  465.         var set_translate_position = function (slider) {
  466.             $(slider).attr('data-position', getTransform($(slider).find('.slides')));
  467.         };
  468.  
  469.  
  470.         var productslider = function () {
  471.             if ($(".product-slide", element).length) {
  472.                 $(".product-slide", element).each(function () {
  473.                     var column = $(this).data('column') ? $(this).data('column') : 3;
  474.                     $(this).owlCarousel({
  475.                         items: column,
  476.                         itemsDesktop: [1199, 3],
  477.                         autoHeight: true,
  478.                         itemsDesktopSmall: [979, 3]
  479.                     });
  480.                 });
  481.             }
  482.         };
  483.  
  484.         var serviceslider = function () {
  485.             if ($(".service-slide", element).length) {
  486.                 $(".service-slide", element).each(function () {
  487.                     var number = $(this).data('number') ? $(this).data('number') : 3;
  488.                     $(this).owlCarousel({
  489.                         items: number,
  490.                         itemsDesktop: [1199, 3],
  491.                         autoHeight: true,
  492.                         itemsDesktopSmall: [979, 3]
  493.                     });
  494.                 });
  495.  
  496.             }
  497.         };
  498.  
  499.         var testislider = function () {
  500.             if ($(".testislide", element).length) {
  501.                 $(".testislide", element).owlCarousel({
  502.                     navigation: false,
  503.                     slideSpeed: 300,
  504.                     paginationSpeed: 400,
  505.                     autoHeight: true,
  506.                     singleItem: true
  507.                 });
  508.             }
  509.         };
  510.  
  511.         var clientslider = function () {
  512.             if ($(".clientslider", element).length) {
  513.                 $(".clientslider", element).each(function () {
  514.                     var number = $(this).data('number') ? $(this).data('number') : 4;
  515.                     $(this).owlCarousel({
  516.                         // autoPlay: 5000,
  517.                         items: number,
  518.                         autoHeight: true,
  519.                         itemsDesktop: [1199, 3],
  520.                         itemsDesktopSmall: [979, 3]
  521.                     });
  522.                 });
  523.             }
  524.         };
  525.  
  526.         var portfolioblock = function () {
  527.  
  528.             var resize_portfolioblock = function () {
  529.                 $(".landingmasonrywrapper .landingmasonryitem").each(function (i) {
  530.                     var blockwidth = $(this).data('width').split('/');
  531.                     var wrapwidth = $(".landingmasonryblock").width();
  532.                     var thiswidth = wrapwidth * ( blockwidth[0] / blockwidth[1] );
  533.                     $(this).width(Math.floor(thiswidth));
  534.                     $(".landingmasonrywrapper").isotope('reLayout');
  535.  
  536.                     setTimeout(function () {
  537.                         $(".landingmasonrywrapper").isotope('reLayout');
  538.                     }, 1000);
  539.  
  540.                 });
  541.             };
  542.  
  543.             if ($(".landingmasonryblock").length) {
  544.                 $(".landingmasonrywrapper").isotope({
  545.                     itemSelector: ".landingmasonryitem",
  546.                     masonry: { columnWidth: 1 }
  547.                 });
  548.  
  549.                 resize_portfolioblock();
  550.                 $(window).bind('resize', resize_portfolioblock);
  551.             }
  552.         };
  553.  
  554.         var item_animation = function () {
  555.             var doanimation = function () {
  556.                 if (!joption.ismobile) {
  557.                     var startanimation = "janimate_start";
  558.                     var defaultoffset = "100";
  559.  
  560.                     if ($(".jeg_animate_sequence").length) {
  561.                         $(".jeg_animate_sequence").each(function () {
  562.                             var element = $(this);
  563.                             var speed = $(element).data('speed');
  564.                             var thisoffset = ( $(element).data('offset') == undefined ) ? defaultoffset : $(element).data('offset');
  565.  
  566.                             element.waypoint(function (direction) {
  567.                                 var animele = $(element).find('.jeg_do_animate');
  568.  
  569.                                 $(animele).each(function (i) {
  570.                                     var animatedelement = this;
  571.                                     setTimeout(function () {
  572.                                         $(animatedelement).addClass(startanimation);
  573.                                     }, i * speed);
  574.                                 });
  575.                             }, {
  576.                                 offset: thisoffset + '%',
  577.                                 triggerOnce: true,
  578.                                 context: window
  579.                             });
  580.                         });
  581.                     }
  582.  
  583.                     if ($(".jeg_animate_random").length) {
  584.                         $(".jeg_animate_random").each(function () {
  585.                             var element = $(this).find(".jeg_do_animate");
  586.  
  587.                             $(element).each(function () {
  588.                                 var animele = $(this);
  589.                                 if ($(this).position().left === 0) {
  590.                                     $(this).attr('data-position', 'janimpos-left');
  591.                                 } else if (($(this).parent().width() - 50) < ($(this).position().left + $(this).width())) {
  592.                                     $(this).attr('data-position', 'janimpos-right');
  593.                                 }
  594.  
  595.                                 animele.waypoint(function (direction) {
  596.                                     setTimeout(function () {
  597.                                         $(animele).addClass(startanimation);
  598.                                     }, 100);
  599.                                 }, {
  600.                                     offset: '95%',
  601.                                     triggerOnce: true,
  602.                                     context: window
  603.                                 });
  604.  
  605.                             });
  606.                         });
  607.                     }
  608.  
  609.                     if ($(".jeg_animate_single").length) {
  610.                         $(".jeg_animate_single").each(function () {
  611.                             var element = $(this);
  612.  
  613.                             $(element).each(function () {
  614.                                 var animele = $(this);
  615.  
  616.                                 animele.waypoint(function (direction) {
  617.                                     setTimeout(function () {
  618.                                         $(animele).addClass(startanimation);
  619.                                     }, 100);
  620.                                 }, {
  621.                                     offset: '98%',
  622.                                     triggerOnce: true,
  623.                                     context: window
  624.                                 });
  625.                             });
  626.                         });
  627.                     }
  628.  
  629.  
  630.                     if ($(".counter-wrapper").length) {
  631.                         $(".counter-wrapper").each(function () {
  632.                             var element = $(this);
  633.                             var delay = 1000;
  634.  
  635.                             $(element).each(function () {
  636.                                 var animele = $(this);
  637.  
  638.                                 animele.waypoint(function (direction) {
  639.  
  640.                                     $(element).find(".odometer").each(function (i) {
  641.                                         var number = $(this).attr('data-number');
  642.                                         var counterelement = $(this);
  643.  
  644.                                         setTimeout(function () {
  645.                                             $(counterelement).html(number);
  646.                                         }, i * 200);
  647.                                     });
  648.  
  649.                                 }, {
  650.                                     offset: '98%',
  651.                                     triggerOnce: true,
  652.                                     context: window
  653.                                 });
  654.                             });
  655.                         });
  656.                     }
  657.  
  658.  
  659.                 }
  660.             };
  661.  
  662.             $(window).bind('load', function () {
  663.                 setTimeout(doanimation, 500);
  664.             });
  665.  
  666.         };
  667.  
  668.         var newparallax = function () {
  669.             if ($(".newparallax").length) {
  670.                 $(".newparallax").each(function () {
  671.                     $(this).jnewparallax();
  672.                 });
  673.             }
  674.         };
  675.  
  676.         var bgparallax = function () {
  677.             if ($(".parallaxbackground").length) {
  678.                 $(".parallaxbackground").each(function () {
  679.                     $(this).jparallax();
  680.                 });
  681.             }
  682.         };
  683.  
  684.         var movingbg = function () {
  685.             if ($(".movingbg").length && !joption.ismobile) {
  686.                 $(".movingbg").each(function () {
  687.                     var ele = $(this);
  688.                     var curbgpos = $(ele).css('backgroundPosition').split(" ");
  689.                     var direction = $(ele).data('direction');
  690.  
  691.                     var bgpos = 0;
  692.                     var bgpos2 = 0;
  693.                     var bgimage = $(this).css('background-image');
  694.                     bgimage = /^url\((['"]?)(.*)\1\)$/.exec(bgimage);
  695.                     bgimage = bgimage ? bgimage[2] : "";
  696.  
  697.                     var newimg = new Image();
  698.                     newimg.src = bgimage;
  699.  
  700.                     var browser = $.jgetbrowser().toLowerCase();
  701.                     $(newimg).load(function () {
  702.                         var maxwidth = newimg.width;
  703.                         var maxheight = newimg.height;
  704.  
  705.                         var bsmove = function () {
  706.  
  707.                             if (direction === 'horizontal') {
  708.                                 if (bgpos > maxwidth) {
  709.                                     bgpos = 0;
  710.                                 }
  711.  
  712.                                 if (browser === 'netscape' || browser === 'msie') {
  713.                                     $(ele).css('background-position-x', bgpos++ + "px");
  714.                                 } else {
  715.                                     $(ele).css('background-position', bgpos++ + "px " + curbgpos[1]);
  716.                                 }
  717.                             } else if (direction === 'vertical') {
  718.                                 if (bgpos > maxheight) {
  719.                                     bgpos = 0;
  720.                                 }
  721.  
  722.                                 if (browser === 'netscape' || browser === 'msie') {
  723.                                     $(ele).css('background-position-y', bgpos++ + "px");
  724.                                 } else {
  725.                                     $(ele).css('background-position', curbgpos[0] + bgpos++ + "px ");
  726.                                 }
  727.                             } else if (direction === 'diagonal') {
  728.                                 if (bgpos > maxwidth) {
  729.                                     bgpos = 0;
  730.                                 }
  731.                                 if (bgpos2 > maxheight) {
  732.                                     bgpos2 = 0;
  733.                                 }
  734.  
  735.                                 if (browser === 'netscape' || browser === 'msie') {
  736.                                     $(ele).css('background-position-x', bgpos++ + "px");
  737.                                     $(ele).css('background-position-y', bgpos2++ + "px");
  738.                                 } else {
  739.                                     $(ele).css('background-position', bgpos++ + "px " + bgpos2++ + "px ");
  740.                                 }
  741.                             }
  742.  
  743.  
  744.                             requestAnimationFrame(bsmove);
  745.                         };
  746.                         requestAnimationFrame(bsmove);
  747.                     });
  748.                 });
  749.             }
  750.         };
  751.  
  752.         var fullscreenslider = function () {
  753.             if ($(".fs-container").length) {
  754.                 $(".fs-container").fsfullheight(['.headermenu', '.responsiveheader', '.topnavigation', '.post-header']);
  755.             }
  756.         };
  757.  
  758.         var fslandingslider = function () {
  759.             if ($(".fslandingslider").length) {
  760.                 $(".fslandingslider").fslandingslider();
  761.             }
  762.         };
  763.  
  764.         var imageanimwrap = function () {
  765.             if ($(".imageanimwrap", element).length) {
  766.                 var set_imagewrapsize = function () {
  767.                     $(".imageanimwrap", element).each(function () {
  768.                         var thisheight = $($(this).find('img').get(0)).height();
  769.                         $(this).height(thisheight);
  770.                     });
  771.                 };
  772.  
  773.                 $(window).bind('load resize', set_imagewrapsize);
  774.             }
  775.         };
  776.  
  777.         var pricingtable = function () {
  778.             if ($(".pricing-table").length) {
  779.                 var resizepricingtable = function () {
  780.                     $(".pricing-table").each(function () {
  781.                         var maxheight = 0;
  782.                         $(".pricing-list", this).each(function () {
  783.                             if ($(this).height() > maxheight) {
  784.                                 maxheight = $(this).height();
  785.                             }
  786.                         });
  787.  
  788.                         $(".pricing-list", this).css({
  789.                             'height': maxheight
  790.                         });
  791.                     });
  792.                 };
  793.  
  794.                 $(window).bind('ready load resize', resizepricingtable);
  795.             }
  796.         };
  797.  
  798.         var landingnavigation = function () {
  799.             if ($(".landing-navigator").length) {
  800.  
  801.                 var landingNavPosition = function () {
  802.                     var navheight = $(".landing-navigator").height();
  803.                     $(".landing-navigator").css({
  804.                         'top': ( $(window).height() - navheight ) / 2
  805.                     }).fadeIn(2000);
  806.                 };
  807.                 $(window).bind('ready load resize', landingNavPosition);
  808.  
  809.                 var readyNavigation = function () {
  810.                     var sectionlist = [];
  811.                     var scrollpos = 0;
  812.                     var active = '';
  813.                     var percentage = 0;
  814.  
  815.                     var listenMouseScroll = function () {
  816.                         scrollpos = jpobj.globaltop;
  817.  
  818.                         for (var i = 0; i < sectionlist.length; i++) {
  819.                             if (scrollpos < sectionlist[i].begin) {
  820.                                 $(".landing-navigator").find("li[data-for='" + sectionlist[i].id + "'] .navigator-block-fill").css({
  821.                                     'height': "0%"
  822.                                 }).removeClass('active');
  823.                             } else if (scrollpos > sectionlist[i].end) {
  824.                                 $(".landing-navigator").find("li[data-for='" + sectionlist[i].id + "'] .navigator-block-fill").css({
  825.                                     'height': "100%"
  826.                                 }).addClass('active');
  827.                             } else if (scrollpos >= sectionlist[i].begin && scrollpos <= sectionlist[i].end) {
  828.                                 percentage = Math.floor(( scrollpos - sectionlist[i].begin ) / ( sectionlist[i].end - sectionlist[i].begin ) * 100);
  829.                                 $(".landing-navigator").find("li[data-for='" + sectionlist[i].id + "'] .navigator-block-fill").css({
  830.                                     'height': percentage + "%"
  831.                                 }).addClass('active');
  832.                             }
  833.                         }
  834.                     };
  835.  
  836.                     var loadNavigator = function () {
  837.                         sectionlist = [];
  838.                         $(".landingpagewrapper section").each(function () {
  839.                             var element = $(this);
  840.  
  841.                             if (element.data('title') !== '') {
  842.                                 var datasection = {
  843.                                     'begin': Math.floor($(element).offset().top) + $.jreducedtoplanding(),
  844.                                     'end': Math.floor($(element).offset().top) + $(element).outerHeight() + $.jreducedtoplanding(),
  845.                                     'element': element,
  846.                                     'id': $(element).attr('data-id')
  847.                                 };
  848.  
  849.                                 sectionlist.push(datasection);
  850.                             }
  851.                         });
  852.  
  853.                         listenMouseScroll();
  854.                         $(window).unbind('jscroll', listenMouseScroll);
  855.                         $(window).bind('jscroll', listenMouseScroll);
  856.                     };
  857.  
  858.                     var gotoNavigation = function () {
  859.                         var thisid = $(this).data('for');
  860.                         var section = $("section[data-id='" + thisid + "']");
  861.                         $('html, body').animate({
  862.                             scrollTop: $(section).offset().top + $.jreducedtoplanding() + 1
  863.                         }, 700, "easeInOutQuad");
  864.                     };
  865.  
  866.                     loadNavigator();
  867.                     $(window).bind('resize', loadNavigator);
  868.                     $(".landing-navigator li").bind('click', gotoNavigation).jtooltip({
  869.                         holder: $(".landing-navigator"),
  870.                         timeout: 2000
  871.                     });
  872.                 };
  873.  
  874.                 $(window).bind('ready', readyNavigation);
  875.             }
  876.         };
  877.  
  878.         var videobackground = function () {
  879.             $(".video-wrap").jfullvideo();
  880.             $(".video_toggle").bind('click', function () {
  881.  
  882.                 var videotype = $(this).parents('section').data('slider-type');
  883.                 var video = $(this).parent().find('video');
  884.                 var videotoogle = $(this).data('toogle');
  885.                 var musicon = $(this).data('on');
  886.                 var musicoff = $(this).data('off');
  887.  
  888.                 if (videotoogle === 'on') {
  889.                     $(this).data('toogle', 'off');
  890.                     $(this).find('i').removeClass(musicon).addClass(musicoff);
  891.  
  892.                     if(videotype === 'video') {
  893.                         $(video).prop('muted', true);
  894.                     } else if(videotype === 'youtube') {
  895.                         window.player.mute();
  896.                     }
  897.  
  898.                 } else {
  899.                     $(this).data('toogle', 'on');
  900.                     $(this).find('i').removeClass(musicoff).addClass(musicon);
  901.  
  902.                     if(videotype === 'video') {
  903.                         $(video).prop('muted', false);
  904.                     } else if(videotype === 'youtube') {
  905.                         window.player.unMute();
  906.                     }
  907.  
  908.                 }
  909.             });
  910.         };
  911.  
  912.         var stickyheading = function () {
  913.             if ($(".bottomnav").length) {
  914.  
  915.                 var stickposition = $(".landing-bottom-nav").position().top;
  916.                 var change_stickposition = function () {
  917.                     stickposition = $(".landing-bottom-nav").position().top;
  918.                 };
  919.  
  920.                 var do_check_sticky = function () {
  921.                     if (jpobj.globaltop < stickposition) {
  922.                         $(".landing-bottom-nav").removeClass('sticky');
  923.                     } else {
  924.                         $(".landing-bottom-nav").addClass('sticky');
  925.                     }
  926.                 };
  927.  
  928.                 $(window).bind('load resize', function () {
  929.                     change_stickposition();
  930.                     $(window).bind('jscroll', do_check_sticky);
  931.                 });
  932.  
  933.             }
  934.         };
  935.  
  936.         var mobilemenu = function (element) {
  937.             var role = "main-mobile-menu";
  938.             $(".mobile-menu-trigger").removeClass('active');
  939.  
  940.             if ($('body').hasClass('menuopen')) {
  941.                 $('body').removeClass('menuopen').attr('role', '');
  942.                 $(".contentoverflow").hide();
  943.             } else {
  944.                 $(element).addClass('active');
  945.                 $('body').addClass('menuopen').attr('role', role);
  946.                 $(".contentoverflow").show();
  947.             }
  948.         };
  949.  
  950.         var hashchangelisten = function () {
  951.             $(window).bind('hashchange load', function (e) {
  952.                 if (window.location.hash) {
  953.                     var scrollToSection = function(){
  954.                         var hash = window.location.hash.substring(1);
  955.                         var section = $("section[data-id='" + hash + "']");
  956.                         if ($(section).length) {
  957.                             $('html, body').animate({
  958.                                 scrollTop: $(section).offset().top + $.jreducedtoplanding() + 1
  959.                             }, 700, "easeInOutQuad");
  960.                         }
  961.                     };
  962.  
  963.                     if($('body').hasClass('menuopen')) {
  964.                         mobilemenu(null);
  965.                         setTimeout(function(){
  966.                             scrollToSection();
  967.                         }, 200);
  968.                     } else {
  969.                         scrollToSection();
  970.                     }
  971.                 }
  972.             });
  973.         };
  974.  
  975.         var fullwidthmap = function () {
  976.             if ($(".fullwidthmapwrapper").length) {
  977.                 do_load_googlemap('landingmap');
  978.             }
  979.         };
  980.  
  981.         var initialize = function () {
  982.  
  983.             // slitslider
  984.             slitslider();
  985.  
  986.             // service slider
  987.             serviceslider();
  988.  
  989.             // service slider
  990.             clientslider();
  991.  
  992.             // product slider
  993.             productslider();
  994.  
  995.             // portfolio
  996.             portfolioblock();
  997.  
  998.             // step by step
  999.             item_animation();
  1000.  
  1001.             // testi slider
  1002.             testislider();
  1003.  
  1004.             // parallax
  1005.             bgparallax();
  1006.  
  1007.             // new parallax
  1008.             newparallax();
  1009.  
  1010.             // moving bg
  1011.             movingbg();
  1012.  
  1013.             // fullscreen
  1014.             fullscreenslider();
  1015.  
  1016.             // fullscreen
  1017.             fslandingslider();
  1018.  
  1019.             // imagewrap
  1020.             imageanimwrap();
  1021.  
  1022.             // dot navigator
  1023.             landingnavigation();
  1024.  
  1025.             // pricing table
  1026.             pricingtable();
  1027.  
  1028.             // video background
  1029.             videobackground();
  1030.  
  1031.             // popup
  1032.             $.portfolio_popup();
  1033.  
  1034.             // jnpslider
  1035.             if ($(".jnpslider").length) {
  1036.                 $(".jnpslider").jnpslider();
  1037.             }
  1038.  
  1039.             // heading parallax
  1040.             if ($(".headingparallax").length) {
  1041.                 $(".headingparallax").headingparallax();
  1042.             }
  1043.  
  1044.             // data - typer
  1045.             $('[data-typer-targets]').typer();
  1046.  
  1047.             // stick heading
  1048.             stickyheading();
  1049.  
  1050.             // hash change listener
  1051.             hashchangelisten();
  1052.  
  1053.             // fullwidth map
  1054.             fullwidthmap();
  1055.         };
  1056.  
  1057.         initialize();
  1058.  
  1059.     };
  1060. })(jQuery);
  1061.  
  1062. (function ($) {
  1063.     "use strict";
  1064.     $.fn.jlandingmap = function () {
  1065.         return $(this).each(function () {
  1066.             var element = this;
  1067.             var elementid = $(this).find('.mapcontainer').attr('id');
  1068.             var zoomfactor = $(this).data('zoom');
  1069.             var address = [];
  1070.  
  1071.             $(".maplist .infowindow", element).each(function (i) {
  1072.                 address[i] = {
  1073.                     'element': this,
  1074.                     'lat': parseFloat($(this).data('lat')),
  1075.                     'lng': parseFloat($(this).data('lng'))
  1076.                 };
  1077.             });
  1078.  
  1079.             /** initialize map **/
  1080.             var infoBubble = new Array();
  1081.             var marker = new Array();
  1082.             var mapcenter, mapzoom;
  1083.  
  1084.             if (google == undefined || google.maps.MapTypeId == undefined) return null;
  1085.  
  1086.             var myOptions = {
  1087.                 mapTypeId: google.maps.MapTypeId.ROADMAP,
  1088.                 disableDefaultUI: true,
  1089.                 scrollwheel: false,
  1090.                 navigationControl: true,
  1091.                 mapTypeControl: true,
  1092.                 scaleControl: true,
  1093.                 draggable: true,
  1094.                 panControl: true,
  1095.                 zoomControl: true,
  1096.                 zoomControlOptions: {
  1097.                     style: google.maps.ZoomControlStyle.SMALL,
  1098.                     position: google.maps.ControlPosition.LEFT_BOTTOM
  1099.                 }
  1100.             };
  1101.  
  1102.             var gmap = new google.maps.Map(document.getElementById(elementid), myOptions);
  1103.             var bounds = new google.maps.LatLngBounds();
  1104.  
  1105.             /** populate marker **/
  1106.             var addMarker = function (pos, maptomark, index) {
  1107.                 return new google.maps.Marker({
  1108.                     position: pos,
  1109.                     map: maptomark,
  1110.                     zIndex: 10
  1111.                 });
  1112.             };
  1113.  
  1114.             var AddInfoBubble = function (address, index, latLng) {
  1115.  
  1116.                 var NewInfoBubble = new InfoBubble({
  1117.                     map: gmap,
  1118.                     content: address.element,
  1119.                     position: latLng,
  1120.                     shadowStyle: 0,
  1121.                     padding: 0,
  1122.                     backgroundColor: 'rgba(125, 125, 125, 0.1)',
  1123.                     borderRadius: 5,
  1124.                     arrowSize: 10,
  1125.                     borderWidth: 0.5,
  1126.                     borderColor: '#fff',
  1127.                     disableAutoPan: true,
  1128.                     hideCloseButton: true,
  1129.                     arrowPosition: 40,
  1130.                     backgroundClassName: 'infowindowbg',
  1131.                     arrowStyle: 2
  1132.                 });
  1133.  
  1134.  
  1135.                 google.maps.event.addListener(marker[index], 'click', function () {
  1136.                     closeAllInfoWindow();
  1137.                     NewInfoBubble.open(gmap, marker[index]);
  1138.                     NewInfoBubble.panToView();
  1139.  
  1140.                     /* attach info bubble **/
  1141.                     google.maps.event.addListenerOnce(infoBubble[index], 'domready', function () {
  1142.                         var selector = "#" + elementid + " .closeme";
  1143.                         $(selector).click(function () {
  1144.                             closeAllInfoWindow();
  1145.                         });
  1146.                     });
  1147.                 });
  1148.  
  1149.                 return NewInfoBubble;
  1150.  
  1151.             };
  1152.  
  1153.             var closeAllInfoWindow = function () {
  1154.                 for (var i = 0; i < infoBubble.length; i++) {
  1155.                     infoBubble[i].close();
  1156.                 }
  1157.             };
  1158.  
  1159.             var populateMarker = function () {
  1160.                 for (var i = 0; i < address.length; i++) {
  1161.                     var latLng = new google.maps.LatLng(address[i].lat, address[i].lng);
  1162.                     marker[i] = addMarker(latLng, gmap, 10);
  1163.                     infoBubble[i] = AddInfoBubble(address[i], i, latLng);
  1164.                     bounds.extend(latLng);
  1165.                 }
  1166.             };
  1167.  
  1168.             populateMarker();
  1169.  
  1170.             gmap.setCenter(bounds.getCenter());
  1171.             gmap.setZoom(zoomfactor);
  1172.             mapcenter = bounds.getCenter();
  1173.         });
  1174.     };
  1175. })(jQuery);
  1176.  
  1177. function landingmap () {
  1178.     jQuery(".fullwidthmapwrapper").jlandingmap();
  1179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement