1 2// ================================================================================== // 3 4 // # Document on Ready 5 // # Document on Resize 6 // # Document on Scroll 7 // # Document on Load 8 9 // # Header 10 // # Main Menu 11 // # Feature Section 12 // # Feature Content Animations 13 // # Feature Animated 14 // # Feature Parallax 15 // # Page Title 16 // # Resize Feature 17 // # Page Settings 18 // # Basic Elements 19 // # Isotope 20 // # Portfolio Auto Resize Headings 21 // # Parallax Section 22 // # Set Equal Columns Height 23 // # Section Settings 24 // # Social Bar For Post 25 // # Related Post 26 // # Scroll Direction 27 // # Global Variables 28 // # Scrollbar Width 29 // # Full Page 30 31 // # Sticky Section 32 33// ================================================================================== // 34 35 36var GRVE = GRVE || {}; 37var mobstickySidebar = false; 38var spinner = '<div class="grve-spinner"></div>'; 39var addFeatureSpinner = true; 40var addFeatureSpinner = true; 41var deviceDoubleTap = true; 42 43(function($){ 44 45 "use strict"; 46 47 48 // # Document on Ready 49 // ============================================================================= // 50 GRVE.documentReady = { 51 init: function(){ 52 GRVE.pageSettings.bodyLoader(); 53 GRVE.pageSettings.removeVideoBg(); 54 GRVE.header.init(); 55 GRVE.sectionSettings.init(); 56 GRVE.setColumnHeight.init(); 57 GRVE.mainMenu.init(); 58 GRVE.slideToggleMenu.init( '#grve-hidden-menu', '#grve-hidden-menu .grve-menu' ); 59 GRVE.slideToggleMenu.init( '#grve-main-header.grve-header-side', '#grve-main-menu.grve-vertical-menu .grve-menu' ); 60 GRVE.slideToggleMenu.init( '#grve-sidearea', '.widget_nav_menu' ); 61 GRVE.slideToggleMenu.init( '#grve-sidearea', '.widget_pages' ); 62 if( $('#grve-feature-section').length > 0 ){ 63 GRVE.featureSection.init(); 64 GRVE.featureSize.init( '#grve-feature-section' ); 65 GRVE.featureParallax.init({ section: '#grve-feature-section.grve-bg-parallax', threshold : 350 }); 66 GRVE.featureAnimated.init(); 67 } 68 if( $('.grve-page-title').length > 0 ){ 69 GRVE.featureSection.init({ section : '.grve-page-title' }); 70 GRVE.featureSize.init( '.grve-page-title' ); 71 } 72 GRVE.parallaxSection.init('.grve-section.grve-bg-parallax'); 73 GRVE.pageSettings.init(); 74 GRVE.isotope.init(); 75 GRVE.isotope.noIsoFilters(); 76 GRVE.basicElements.init(); 77 GRVE.relatedPost.init(); 78 GRVE.fullPage.init(); 79 GRVE.pillingPage.init(); 80 GRVE.wooProductRating.init(); 81 82 } 83 }; 84 85 // # Document on Resize 86 // ============================================================================= // 87 GRVE.documentResize = { 88 init: function(){ 89 if( $('#grve-feature-section').length > 0 ){ 90 GRVE.featureSize.init( '#grve-feature-section' ); 91 } 92 if( $('.grve-page-title').length > 0 ){ 93 GRVE.featureSize.init( '.grve-page-title' ); 94 } 95 GRVE.sectionSettings.init(); 96 GRVE.setColumnHeight.init(); 97 GRVE.relatedPost.itemWidth(); 98 GRVE.basicElements.imageText(); 99 } 100 }; 101 102 // # Document on Scroll 103 // ============================================================================= // 104 GRVE.documentScroll = { 105 init: function(){ 106 GRVE.header.stickyHeader(); 107 GRVE.header.stickyDevices(); 108 GRVE.featureSection.stopSlider(); 109 GRVE.socialBar.init(); 110 GRVE.pageSettings.onePageMenu(); 111 GRVE.pageSettings.stickySidebar(); 112 GRVE.pageSettings.anchorSticky(); 113 } 114 }; 115 116 // # Document on Load 117 // ============================================================================= // 118 GRVE.documentLoad = { 119 init: function(){ 120 GRVE.basicElements.iconBox(); 121 GRVE.socialBar.init(); 122 GRVE.pageSettings.fixedFooter(); 123 GRVE.pageSettings.locationHash(); 124 if ( $('#grve-body').hasClass( 'compose-mode' ) ) { 125 GRVE.isotope.init(); 126 } 127 } 128 }; 129 130 // # Header 131 // ============================================================================= // 132 GRVE.header = { 133 init: function(){ 134 GRVE.header.stickyHeader(); 135 GRVE.header.stickyDevices(); 136 }, 137 calHeight: function(){ 138 var $mainHeader = $('#grve-main-header'), 139 headerHeight = $mainHeader.height(); 140 if( $('#grve-header').hasClass('hide') || $('#grve-header').data('sticky') == 'none' ) { 141 headerHeight = 0; 142 } 143 return headerHeight; 144 }, 145 stickyHeader: function(){ 146 147 if( $(window).width() + scrollBarWidth < tabletPortrait || !$('#grve-header').length ) return; 148 149 var $header = $('#grve-header'), 150 $mainHeader = $('#grve-main-header'), 151 stickyType = $header.data('sticky'), 152 scroll = $(window).scrollTop(), 153 topBarHeight = $('#grve-top-bar').length ? $('#grve-top-bar').height() : 0, 154 offset = topBarHeight + wpBarHeight, 155 headerHeight = $mainHeader.height(), 156 headerOffset = $header.offset().top; 157 158 if( stickyType == 'none' ) { 159 return; 160 } 161 162 if( offset === 0 && headerOffset === 0 ) { 163 $header.addClass('grve-fixed'); 164 } 165 166 if( scroll > headerOffset ) { 167 if( !$header.hasClass('grve-fixed') ){ 168 $header.addClass('grve-fixed'); 169 } 170 $header.addClass('grve-sticky-header'); 171 $header.addClass( 'grve-' + stickyType ); 172 } else { 173 $header.removeClass( 'grve-' + stickyType ); 174 $header.removeClass('grve-sticky-header'); 175 if( headerOffset > 0 ){ 176 $header.removeClass('grve-fixed'); 177 } 178 } 179
180 var scrollOffset = 300; 181 if( $('#grve-feature-section').length ) { 182 scrollOffset = $('#grve-feature-section').height(); 183 } 184 185 if( stickyType == 'advanced' && scroll > scrollOffset - $mainHeader.height() ) { 186 var scrollDir = GRVE.scrollDir.init(); 187 if( scrollDir.direction == 'scrollDown' ) { 188 $header.addClass('hide'); 189 } else { 190 $header.removeClass('hide'); 191 } 192 } 193 194 }, 195 stickyDevices: function(){ 196 197 if( !$('#grve-header').length ) { 198 return; 199 } 200 201 var $header = $('#grve-header'), 202 $resHeader = $('#grve-responsive-header'), 203 stickyType = $header.data('sticky'), 204 stickyDevice = $header.data('devices-sticky'), 205 scroll = $(window).scrollTop(), 206 topBarHeight = $('#grve-top-bar').length ? $('#grve-top-bar').height() : 0, 207 offset = topBarHeight + wpBarHeight, 208 headerHeight = $header.height(), 209 headerOffset = $resHeader.offset().top; 210 211 if( !$header.length ) { 212 return; 213 } 214 215 if( stickyDevice == 'no' && $(window).width() + scrollBarWidth < tabletPortrait ) { 216 return; 217 } 218 219 if( offset === 0 && headerOffset === 0 ) { 220 $resHeader.addClass('grve-fixed'); 221 } 222 223 if( scroll > headerOffset ) { 224 if( !$resHeader.hasClass('grve-fixed') ){ 225 $resHeader.addClass('grve-fixed'); 226 } 227 } else { 228 if( headerOffset > 0 ){ 229 $resHeader.removeClass('grve-fixed'); 230 } 231 } 232 233 } 234 }; 235 // # Main Menu 236 // ============================================================================= // 237 GRVE.mainMenu = { 238 init: function(){ 239 this.mainMenu(); 240 }, 241 mainMenu: function(){ 242 var $menu = $('#grve-main-menu.grve-horizontal-menu'), 243 $item = $menu.find('li.menu-item'), 244 $menuItem = $menu.find('li.menu-item-has-children'), 245 target = '.menu-item-has-children', 246 subMenu = '.sub-menu', 247 mTimer; 248 249 $menu 250 .on('mouseenter', target, over) 251 .on('mouseleave', target, out); 252 253 function over(){ 254 var $this = $(this); 255 if ($this.prop('hoverTimeout')) { 256 $this.prop('hoverTimeout', clearTimeout($this.prop('hoverTimeout'))); 257 } 258 $this.prop('hoverIntent', setTimeout(function() { 259 $this.addClass('mHover'); 260 menuPosition( $this ); 261 }, 100)); 262 } 263 function out(){ 264 var $this = $(this); 265 if ($this.prop('hoverIntent')) { 266 $this.prop('hoverIntent', clearTimeout($this.prop('hoverIntent'))); 267 } 268 269 $this.prop('hoverTimeout', setTimeout(function() { 270 $this.removeClass('mHover'); 271 }, 100)); 272 } 273 274 if( isMobile.any() && $(window).width() > tabletPortrait ) { 275 276 $menuItem.find(' > a').bind('touchstart touchend', function(e) { 277 var $this = $(this); 278 menuPosition( $this ); 279 $this.parent().siblings().removeClass('mHover'); 280 if( $this.attr('href') != '#' || $this.attr('href') === '#' ) { 281 if( !$this.parent().hasClass('mHover') ) { 282 e.preventDefault(); 283 $this.parent().addClass('mHover'); 284 } 285 } 286 287 }); 288 289 $(document).bind('touchstart touchend', function(e) { 290 if ( !$menuItem.is(e.target) && $menuItem.has(e.target).length === 0 ) { 291 $menuItem.removeClass('mHover').find('li').removeClass('mHover'); 292 } 293 }); 294 295 } 296 297 function menuPosition(item){ 298 var $item = item, 299 $subMenu = $item.find(' > ul '), 300 subMenuW = $subMenu.width(), 301 subMenuP = $subMenu.offset().left, 302 windowWidth = $(window).width(); 303 304 if ( (subMenuW + subMenuP) > windowWidth ) { 305 $subMenu.addClass('grve-position-right'); 306 } 307 } 308 } 309 }; 310 311 // # Menu Slide or Toggle 312 // ============================================================================= // 313 GRVE.slideToggleMenu = { 314 315 init: function( parent, element ){ 316 317 if( !$(element).length ) return; 318 319 var $menu = $(element), 320 $menuParent = $(parent), 321 $menuItem = $menu.find('li.menu-item-has-children > a, li.page_item_has_children > a'), 322 menuType = $menuParent.hasClass('grve-slide-menu') ? 'slide' : 'toggle', 323 $arrow = $('<i class="grve-arrow"></i>'), 324 $goBack = $('<li class="grve-goback"><a href="#"><i class="grve-arrow"></i></a></li>'); 325 326 327 328 if( menuType === 'slide' ) { 329 // Add Arrows 330 $arrow.appendTo( $menuItem.parent() ); 331 // Add Go Back Button for Slide Menu 332 $goBack.prependTo( $menuItem.parent().find('>ul') ); 333 } else { 334 // Add Arrows 335 $arrow.appendTo( $menuItem ); 336 } 337 338 $menuItem.on('tap click',function(e){ 339 var $this = $(this), 340 link = $this.attr('href'), 341 open = false;
342 343 if((link != '#' || link === '#') && menuType == 'toggle' ) { 344 if( !$this.parent().hasClass('open') && !open ) { 345 e.preventDefault(); 346 $this.parent().addClass('open'); 347 toggle( $this, open ); 348 } else { 349 open = true; 350 toggle( $this, open ); 351 $this.parent().removeClass('open'); 352 } 353 } else if( link === '#' && menuType == 'slide' ) { 354 e.preventDefault(); 355 var listLevel = $this.parents('ul').length, 356 $firstItem = $this.parent().find('ul').first(), 357 menuOffset = $menu.offset().top, 358 offset = $this.offset().top, 359 title = $this.html(); 360 361 appendTitle( title, $firstItem ); 362 363 $firstItem.addClass('grve-show').css({ 'top' : - ( offset - menuOffset ) }); 364 var firstItemH = $firstItem.outerHeight(); 365 366 if( $('body').hasClass('rtl') ) { 367 animRightMenu( firstItemH, listLevel ); 368 } else { 369 animLeftMenu( firstItemH, listLevel ); 370 } 371 } 372 373 }); 374 375 if( menuType === 'slide' ) { 376 var $arrowBtn = $menuItem.parent().find('.grve-arrow'); 377 $arrowBtn.on('click',function(){ 378 var $this = $(this), 379 listLevel = $this.parents('ul').length, 380 $firstItem = $this.parent().find('ul').first(), 381 menuOffset = $menu.offset().top, 382 offset = $this.offset().top, 383 title = $this.parent().find('a').first().html(); 384 385 appendTitle( title, $firstItem ); 386 387 $firstItem.addClass('grve-show').css({ 'top' : - ( offset - menuOffset ) }); 388 var firstItemH = $firstItem.outerHeight(); 389 390 if( $('body').hasClass('rtl') ) { 391 animRightMenu( firstItemH, listLevel ); 392 } else { 393 animLeftMenu( firstItemH, listLevel ); 394 } 395 396 }); 397 } 398 399 $('li.grve-goback a').on('click', function(e) { 400 e.preventDefault(); 401 var listLevel = $(this).parents('ul ul').length - 1, 402 $firstItem = $(this).closest('.sub-menu'), 403 firstItemH = $firstItem.closest('.menu-item-has-children').closest('ul').height(); 404 405 setTimeout(function(){ 406 $firstItem.removeClass('grve-show'); 407 },300); 408 if( $('body').hasClass('rtl') ) { 409 animRightMenu( firstItemH, listLevel ); 410 } else { 411 animLeftMenu( firstItemH, listLevel ); 412 } 413 }); 414 415 function toggle( $this, open ){ 416 var $subMenu = $this.parent().find('>ul'); 417 if( open ) { 418 $subMenu.slideUp(200); 419 } else { 420 $subMenu.slideDown(200); 421 } 422 } 423 424 function animLeftMenu( height, listLevel ) { 425 $menu.parent().height(height); 426 $menu.css('transform', 'translate3d(' + - listLevel * 100 + '%,0,0)'); 427 } 428 429 function animRightMenu( height, listLevel ) { 430 $menu.parent().height(height); 431 $menu.css('transform', 'translate3d(' + listLevel * 100 + '%,0,0)'); 432 } 433 434 function appendTitle( title, list ){ 435 if( list.find('.grve-goback .grve-item').length ) return; 436 $(title).appendTo( list.find('> .grve-goback a') ); 437 } 438 } 439 440 }; 441 442 443 // # Set Feature Section Size 444 // ============================================================================= // 445 GRVE.featureSize = { 446 init: function( section ){ 447 448 var featureHeight; 449 450 if( $(section).hasClass('grve-fullscreen') ) { 451 featureHeight = fullscreen(); 452 } else { 453 featureHeight = customSize(); 454 } 455 456 function fullscreen(){ 457 var windowHeight = $(window).height(), 458 headerHeight = 0, 459 topBarHeight = $('#grve-top-bar').length ? $('#grve-top-bar').outerHeight() : 0; 460 461 if( $('#grve-responsive-header').is(':visible') ) { 462 if( !$('#grve-header').hasClass('grve-responsive-overlapping') ){ 463 headerHeight = $('#grve-responsive-header').outerHeight(); 464 } 465 } else if ( !$('#grve-header').hasClass('grve-overlapping') && !$('#grve-theme-wrapper').hasClass('grve-header-side') ){ 466 headerHeight = $('#grve-main-header').outerHeight(); 467 } 468 469 var sectionHeight = windowHeight - headerHeight - topBarHeight; 470 471 $(section).find('.grve-wrapper').css( 'height', sectionHeight); 472 473 return sectionHeight; 474 } 475 476 function customSize(){ 477 478 var initWidth = tabletLandscape, 479 initHeight = $(section).data('height'), 480 minHeight = parseInt( $(section).find('.grve-wrapper').css('min-height') ), 481 newSize = calSize( initWidth, initHeight ); 482 483 if( $(window).width() + scrollBarWidth >= initWidth ) { 484 $(section).find('.grve-wrapper').css({ 'height': initHeight }); 485 return initHeight; 486 } else { 487 $(section).find('.grve-wrapper').css({ 'height': newSize.newHeight }); 488 if( newSize.newHeight < minHeight ){ 489 return minHeight; 490 } else { 491 return newSize.newHeight; 492 } 493 } 494 495 function calSize( initWidth, initHeight ){ 496 var ratio = initHeight / initWidth, 497 height = $(window).width() * ratio; 498 499 return { 500 newHeight : parseInt(height) 501 }; 502 } 503 } 504 505 return featureHeight; 506 } 507 }; 508 509 // # Feature Section 510 // ============================================================================= // 511 GRVE.featureSection = { 512 513 animate: false, 514 515 init: function( settings ){ 516 517 GRVE.featureSection.config = { 518 section : '#grve-feature-section', 519 }; 520 // allow overriding the default config 521 $.extend(GRVE.featureSection.config, settings); 522 523 var section = GRVE.featureSection.config.section; 524 525 if( $(section).find('.grve-bg-image').length > 0 ) { 526 loadFeatureImage(); 527 528 // Add Spinner 529 if( addFeatureSpinner ) { 530 GRVE.featureSection.addSpinner( section ); 531 } 532 533 } else if( !$(section).find('.grve-bg-image').length && $(section).find('.grve-bg-video').length ){ 534 // Add Spinner 535 if( addFeatureSpinner ) { 536 GRVE.featureSection.addSpinner( section ); 537 } 538 }else { 539 GRVE.featureAnim.startAnim( $(section) ); 540 } 541 542 function loadFeatureImage(){ 543 var $bgImage = $(section).find('.grve-bg-image'), 544 totalBgImage = $bgImage.length; 545 546 var waitImgDone = function() { 547 totalBgImage--; 548 if (!totalBgImage) { 549 550 if( $(section).hasClass('grve-with-slider') ) { 551 552 // Feature Slider Init 553 GRVE.featureSection.featureSlider(); 554 555 } else { 556 // Remove Spinner 557 if( addFeatureSpinner ) { 558 setTimeout(function () { 559 GRVE.featureSection.removeSpinner( section ); 560 }, 600); 561 } else { 562 GRVE.featureSection.showFeature( section ); 563 } 564 } 565 566 } 567 }; 568 569 $bgImage.each(function () { 570 function imageUrl(input) { 571 return input.replace(/"/g,"").replace(/url\(|\)$/ig, ""); 572 } 573 var image = new Image(), 574 $that = $(this); 575 image.src = imageUrl($that.css('background-image')); 576 $(image).on('load',waitImgDone).on( "error", waitImgDone ); 577 }); 578 } 579 }, 580 addSpinner: function( section ){ 581 $(spinner).appendTo( $(section) ); 582 $(section).addClass('grve-with-spinner'); 583 }, 584 removeSpinner: function( section ){ 585 var $spinner = $(section).find('.grve-spinner'); 586 $spinner.fadeOut(900,function(){ 587 $spinner.remove(); 588 GRVE.featureSection.showFeature( section ); 589 }); 590 },
591 showFeature: function( section ){ 592 var $section = $(section), 593 $overlay = $section.find('.grve-bg-overlay'), 594 $content = $section.find('.grve-content'), 595 $bgImage = $section.find('.grve-bg-image'), 596 $bgVideo = $section.find('.grve-bg-video'); 597 598 $bgImage.addClass('grve-show'); 599 $bgVideo.addClass('grve-show'); 600 $overlay.addClass('grve-show'); 601 602 if( $section.hasClass('grve-with-slider') ) { 603 GRVE.featureSection.animate = true; 604 } 605 GRVE.featureAnim.startAnim( $section ); 606 607 }, 608 featureSlider: function(){ 609 610 var $slider = $('#grve-feature-slider'), 611 pauseHover = $slider.attr('data-slider-pause') == 'yes' ? true : '', 612 sliderSpeed = parseInt( $slider.attr('data-slider-speed') ) ? parseInt( $slider.attr('data-slider-speed') ) : 6000, 613 transition = $slider.attr('data-slider-transition') != 'slide' ? $slider.attr('data-slider-transition') : false, 614 slidersLength = $slider.find('.grve-slider-item ').length, 615 autoHeight = false; 616 617 if( $(window).width() + scrollBarWidth <= mobileScreen ) { 618 autoHeight = true; 619 } 620 621 customNav( $slider ); 622 623 // Init Slider 624 $slider.owlCarousel({ 625 navigation : false, 626 pagination : false, 627 autoHeight : autoHeight, 628 slideSpeed : 800, 629 paginationSpeed : 800, 630 afterAction : sliderAction, 631 singleItem : true, 632 autoPlay : true, 633 stopOnHover : pauseHover, 634 baseClass : 'grve-slider', 635 theme : 'grve-theme', 636 transitionStyle : transition 637 }); 638 639 // Remove Spinner 640 if( addFeatureSpinner ) { 641 setTimeout(function () { 642 GRVE.featureSection.removeSpinner( '#grve-feature-section' ); 643 $slider.trigger('owl.play',sliderSpeed);//Play Carousel 644 }, 600); 645 } else { 646 GRVE.featureSection.showFeature( '#grve-feature-section' ); 647 } 648 649 // Slider Navigation 650 function customNav( element ){ 651 var $navWrapper = element.parent(), 652 $navNext = $navWrapper.find('.grve-carousel-next'), 653 $navPrev = $navWrapper.find('.grve-carousel-prev'); 654 655 $navNext.on('click', function() { 656 element.trigger('owl.next'); 657 }); 658 $navPrev.on('click', function() { 659 element.trigger('owl.prev'); 660 }); 661 662 } 663 664 function sliderAction(){ 665 666 var curItem = this.currentItem, 667 preItem = this.prevItem, 668 $currentSlide = this.$owlItems.eq( curItem ), 669 $prevSlide = this.$owlItems.eq( preItem ), 670 $currentSliderItem = $currentSlide.find('.grve-slider-item'), 671 sliderColor = $currentSliderItem.attr('data-header-color'), 672 color = 'grve-' + sliderColor; 673 674 if( !GRVE.featureSection.animate ) return; 675 676 // Slider Animation 677 GRVE.featureAnim.startAnim( $currentSliderItem ); 678 679 // Set Header Color 680 if( !$('#grve-main-header').hasClass('grve-header-side') ) { 681 $('#grve-main-header').removeClass('grve-light grve-dark').addClass(color); 682 } 683 684 // Set Navigation Color 685 $('#grve-feature-section .grve-carousel-navigation').removeClass('grve-light grve-dark grve-default').addClass(color); 686 } 687 688 }, 689 stopSlider: function(){ 690 691 if( !GRVE.featureSection.animate ) return; 692 693 var $scroll = $(window).scrollTop(), 694 $slider = $('#grve-feature-slider'), 695 sliderSpeed = parseInt( $slider.attr('data-slider-speed') ) ? parseInt( $slider.attr('data-slider-speed') ) : 6000; 696 697 if( $scroll > 10 ){ 698 $slider.trigger('owl.stop');//Stop Carousel 699 } else { 700 $slider.trigger('owl.play',sliderSpeed);//Play Carousel 701 } 702 703 } 704 }; 705 706 // # Resize Video 707 // ============================================================================= // 708 GRVE.resizeVideo = { 709 init: function( $selector ){ 710 GRVE.resizeVideo.videoSettings( $selector ); 711 $(window).smartresize(function(){ 712 GRVE.resizeVideo.videoSettings( $selector ); 713 }); 714 }, 715 videoSettings: function( $selector ){ 716 var $video = $selector.find('video'), 717 containerWidth = $selector.parent().outerWidth(), 718 containerHeight = $selector.parent().outerHeight(), 719 ratio = 16 / 9, 720 videoHeight = containerHeight, 721 videoWidth = containerHeight * ratio; 722 723 if( videoWidth < containerWidth ) { 724 videoWidth = containerWidth; 725 videoHeight = containerWidth * ratio; 726 } 727 728 $video.width( videoWidth ).height( videoHeight ); 729 730 if( $selector.parent().is( $('#grve-feature-section') ) ){ 731 // Remove Spinner 732 if( addFeatureSpinner ) { 733 setTimeout(function () { 734 GRVE.featureSection.removeSpinner( '#grve-feature-section' ); 735 }, 600); 736 } else { 737 GRVE.featureSection.showFeature( '#grve-feature-section' ); 738 } 739 } 740 } 741 }; 742 743 // # Feature Content Animations 744 // ============================================================================= // 745 GRVE.featureAnim = { 746 settings: function( $section ){ 747 var animEffect = $section.find('.grve-content').data('animation'), 748 animDelay = 200, 749 contentItems = { 750 graphic : $section.find(' .grve-graphic '), 751 subheading : $section.find(' .grve-subheading '), 752 title : $section.find(' .grve-title '), 753 description : $section.find(' .grve-description '), 754 button1 : $section.find(' .grve-btn-1 '), 755 button2 : $section.find(' .grve-btn-2 ') 756 }; 757 758 return { items: contentItems, effect: animEffect, delay: animDelay }; 759 }, 760 startAnim: function( section ){ 761 762 var $section = section, 763 settings = GRVE.featureAnim.settings( $section ), 764 items = settings.items, 765 effect = settings.effect, 766 delay = settings.delay, 767 cnt = 3; 768 769 $section.find('.grve-content').addClass('grve-show'); 770 771 $.each( items, function( key, item ) { 772 cnt++; 773 $(item).removeClass('animate-fade-in animate-fade-in-up animate-fade-in-down animate-fade-in-left animate-fade-in-right animate-zoom-in animate-zoom-out'); 774 775 addAnimClass( effect ); 776 function addAnimClass( effect ){ 777 setTimeout(function(){ 778 var itemClass = 'animate-' + effect; 779 $(item).addClass( itemClass ); 780 },cnt * delay); 781 } 782 }); 783 784 } 785 }; 786 787 // # Feature Animated 788 // ============================================================================= // 789 GRVE.featureAnimated = { 790 791 init: function(){
792 var $this = $('#grve-feature-section.grve-bg-animated'); 793 zoomBg( $this ); 794 795 function zoomBg( $this ){ 796 $this.on('mouseenter', function() { 797 $this.addClass('zoom'); 798 }); 799 $this.on('mouseleave', function() { 800 $this.removeClass('zoom'); 801 }); 802 } 803 } 804 805 }; 806 807 // # Feature Parallax 808 // ============================================================================= // 809 GRVE.featureParallax = { 810 811 init: function( settings ){ 812 813 this.config = { 814 section : '#grve-feature-section.grve-bg-parallax', 815 threshold : 250, 816 }; 817 // allow overriding the default config 818 $.extend(this.config, settings); 819 820 if( !$(this.config.section).length )return; 821 822 var section = this.config.section, 823 sectionLenght = $(section).length, 824 threshold = this.config.threshold, 825 $parallaxEl = $(section).find('.grve-bg-image'), 826 $content = $(section).find('.grve-content'); 827 828 var sectionHeight, elementHeight, sectionTop, speed; 829 830 function updateParam(){ 831 sectionHeight = GRVE.featureSize.init( section ); 832 elementHeight = sectionHeight + threshold; 833 sectionTop = $(section).offset().top; 834 speed = ( sectionHeight + sectionTop ) / ( elementHeight - sectionHeight ); 835 } 836 837 function update(){ 838 var windowScroll = $(window).scrollTop(), 839 windowHeight = $(window).height(), 840 translate = 0; 841 842 if( sectionTop - windowScroll <= windowHeight && sectionTop - windowScroll + windowHeight >= windowHeight - sectionHeight ) { 843 translate = ( windowScroll )/speed; 844 } else { 845 translate = 0; 846 } 847 var transform = 'translateY(' + - translate + 'px)', 848 opacity = 1- (2 * windowScroll / elementHeight); 849 850 851 $parallaxEl.css({ 852 'height' : elementHeight, 853 '-webkit-transform' : transform, 854 '-moz-transform' : transform, 855 '-ms-transform' : transform, 856 '-o-transform' : transform, 857 'transform' : transform 858 }); 859 860 $content.css({ 861 'opacity' : opacity 862 }); 863 } 864 865 updateParam(); 866 update(); 867 $(window).on('scroll', function(){ 868 update(); 869 }); 870 871 if( isMobile.any() ) { 872 $(window).on("orientationchange",function(){ 873 updateParam(); 874 update(); 875 }); 876 } else { 877 $(window).smartresize(function(){ 878 updateParam(); 879 update(); 880 }); 881 } 882 } 883 }; 884 885 // # Page Settings 886 // ============================================================================= // 887 GRVE.pageSettings = { 888 889 init: function(){ 890 this.grveModal(); 891 this.gotoFirstSection(); 892 this.bgLoader(); 893 this.imageLoader(); 894 this.fitVid(); 895 this.hiddenArea(); 896 this.backtoTop(); 897 this.animatedBg(); 898 this.hovers(); 899 this.onePageSettings(); 900 this.shoppingCart(); 901 this.anchorBar(); 902 this.socialShareLinks(); 903 this.lightBox(); 904 }, 905 bodyLoader: function(){ 906 var $overflow = $('#grve-loader-overflow'), 907 $loader = $('.grve-spinner'); 908 909 if( $overflow.length > 0 ){ 910 bodyLoader = true; 911 } else { 912 return; 913 } 914 915 var images = $('img, .grve-bg-image'); 916 $.each(images, function(){ 917 var el = $(this), 918 image = el.css('background-image').replace(/"/g, '').replace(/url\(|\)$/ig, ''); 919 if(image && image !== '' && image !== 'none') 920 images = images.add($('<img>').attr('src', image)); 921 if(el.is('img')) 922 images = images.add(el); 923 }); 924 925 images.imagesLoaded(function(){ 926 setTimeout(function () { 927 $loader.fadeOut(500); 928 $overflow.delay(500).fadeOut(700,function(){ 929 bodyLoader = false;
930 GRVE.basicElements.animAppear(); 931 GRVE.basicElements.counter(); 932 }); 933 }, 600); 934 }); 935 936 }, 937 removeVideoBg: function(){ 938 $('.grve-background-wrapper').each(function () { 939 var bgImage = $(this).find('.grve-bg-image'); 940 var bgVideo = $(this).find('.grve-bg-video'); 941 var bgVcVideo = $(this).find('.grve-bg-video-wrapper'); 942 var bgVcVideoButton = $(this).find('.grve-bg-video-button-device'); 943 var bgVideoDevice = bgVideo.data('videoDevice') != undefined ? bgVideo.data('videoDevice') : 'no'; 944 if( isMobile.any() && 'no' === bgVideoDevice) { 945 if ( bgVideo.length ) { 946 bgVideo.remove(); 947 } 948 if ( bgVcVideo.length ) { 949 bgVcVideo.remove(); 950 } 951 } else { 952 if ( bgVideo.length ) { 953 var videoElement = $(this).find('.grve-bg-video video'); 954 var canPlayVideo = false; 955 $(this).find('.grve-bg-video source').each(function(){ 956 if ( videoElement.get(0).canPlayType( $(this).attr('type') ) ) { 957 canPlayVideo = true; 958 } 959 }); 960 if(canPlayVideo) { 961 bgImage.remove(); 962 // Resize Video 963 GRVE.resizeVideo.init( $(this) ); 964 } else { 965 bgVideo.remove(); 966 } 967 } 968 if ( bgVcVideo.length ) { 969 bgImage.remove(); 970 } 971 if ( bgVcVideoButton.length ) { 972 bgVcVideoButton.remove(); 973 } 974 } 975 }); 976 977 }, 978 grveModal: function(){ 979 980 var $button = $('.grve-toggle-modal'), 981 $overlay = $('<div id="grve-modal-overlay" class="grve-body-overlay"></div>'), 982 $closeBtn = $('<div class="grve-close-btn grve-close-modal grve-close-line"><span></span><span></span></div>'), 983 $themeWrapper = $('#grve-theme-wrapper'), 984 content; 985 986 $button.on('click',function(e){ 987 content = $(this).attr('href'); 988 if( content.indexOf("#") === 0 && $(content).length > 0 ) { 989 e.preventDefault(); 990 991 // Append Overlay on body 992 $overlay.appendTo( $themeWrapper ); 993 $closeBtn.appendTo( $(content) ); 994 995 $(content).addClass('prepare-anim'); 996 997 openModal(); 998 999 $closeBtn.on('click',function(e){ 1000 e.preventDefault(); 1001 closeModal(); 1002 }); 1003 1004 $(content).on('click',function(e){ 1005 if ( !$('.grve-modal-item').is(e.target) && $('.grve-modal-item').has(e.target).length === 0 ) { 1006 e.preventDefault(); 1007 closeModal(); 1008 } 1009 }); 1010 } 1011 }); 1012 1013 // Open Modal 1014 function openModal() { 1015 $overlay.fadeIn(function(){ 1016 $(content).addClass('animate'); 1017 }); 1018 } 1019 1020 // Close Modal 1021 function closeModal() { 1022 $(content).removeClass('animate mobile'); 1023 setTimeout(function(){ 1024 $overlay.fadeOut(function(){ 1025 $(content).removeClass('prepare-anim'); 1026 $overlay.remove(); 1027 $closeBtn.remove(); 1028 }); 1029 },600); 1030 } 1031 1032 $(document).on('keyup',function(evt) { 1033 if (evt.keyCode == 27 && $(content).hasClass('animate') ) { 1034 closeModal(); 1035 } 1036 }); 1037 1038 }, 1039 gotoFirstSection: function(){ 1040 var headerHeight = $('#grve-header').data('sticky') != 'none' ? $('#grve-main-header').height() : 0, 1041 anchorBarHeight = $('.grve-anchor-menu').length ? $('.grve-anchor-menu').outerHeight() : 0, 1042 $selector = $('#grve-feature-section #grve-goto-section'), 1043 $nextSection = $('#grve-content'); 1044 1045 $selector.on('click',function(){ 1046 if ( $nextSection.length ) { 1047 $('html,body').animate({ 1048 scrollTop: $nextSection.offset().top - headerHeight - anchorBarHeight + 1 1049 }, 1000); 1050 return false; 1051 } 1052 }); 1053 }, 1054 bgLoader: function() { 1055 1056 var $selector = $('#grve-header .grve-bg-image, #grve-content .grve-bg-image, #grve-footer .grve-bg-image, #grve-related-post .grve-bg-image, #grve-sidearea .grve-bg-image'); 1057 $selector.each(function () { 1058 var $selector = $(this); 1059 if( $selector.data('loader') == 'yes' ){ 1060 GRVE.pageSettings.addSpinner( $selector ); 1061 } 1062 function imageUrl(input) { 1063 return input.replace(/"/g,"").replace(/url\(|\)$/ig, ""); 1064 } 1065 var image = new Image(), 1066 $that = $(this); 1067 image.src = imageUrl($that.css('background-image')); 1068 image.onload = function () { 1069 if( $selector.data('loader') == 'yes' ){ 1070 GRVE.pageSettings.removeSpinner( $selector ); 1071 } else { 1072 $that.addClass('grve-show'); 1073 } 1074 }; 1075 }); 1076 }, 1077 imageLoader: function(){ 1078 var selectors = { 1079 singleImage : '.grve-image', 1080 media : '.grve-media' 1081 }; 1082 $.each(selectors, function(key, value){ 1083 if( $(this).length ){ 1084 var item = $(this), 1085 imgLoad = imagesLoaded( item ); 1086 imgLoad.on( 'always', function() { 1087 $(value).find('img').animate({ 'opacity': 1 },1000); 1088 }); 1089 } 1090 }); 1091 }, 1092 addSpinner: function( $selector ){ 1093 var $section = $selector; 1094 $(spinner).appendTo( $section.parent() ); 1095 }, 1096 removeSpinner: function( $selector ){ 1097
1098 var $section = $selector.parent(), 1099 $spinner = $section.find('.grve-spinner'); 1100 1101 $spinner.fadeOut(600,function(){ 1102 $selector.addClass('grve-show'); 1103 $spinner.remove(); 1104 }); 1105 }, 1106 fitVid: function(){ 1107 $('.grve-video, .grve-media').fitVids(); 1108 $('iframe[src*="youtube"]').parent().fitVids(); 1109 $('iframe[src*="vimeo"]').parent().fitVids(); 1110 }, 1111 stickySidebar: function(){ 1112 1113 var $item = $('#grve-sidebar.grve-fixed-sidebar'), 1114 $content = $('#grve-main-content'); 1115 if( !$item.length ) { 1116 return; 1117 } 1118 var $itemWrapper = $item.find('.grve-wrapper'), 1119 itemHeight = $itemWrapper.outerHeight() + 80, 1120 itemWidth = $item.outerWidth() - 1, 1121 headerHeight = $('#grve-header').data('sticky') != 'none' ? $('#grve-main-header').outerHeight() : 0, 1122 anchorBarHeight = $('.grve-anchor-menu').length ? $('.grve-anchor-menu').outerHeight() : 0, 1123 offset = headerHeight + anchorBarHeight + 80, 1124 windowHeight = $(window).height(); 1125 if( itemHeight > windowHeight ) { 1126 $itemWrapper.css({'position':'static', 'top':'auto' }); 1127 return false; 1128 } 1129 1130 if( ( isMobile.any() && !mobstickySidebar ) || $(window).width() + scrollBarWidth < tabletPortrait ) { 1131 $itemWrapper.css({'position':'', 'top': '', 'width' : '' }); 1132 return; 1133 } 1134 1135 var contentHeight = $content.outerHeight(), 1136 contentTop = $content.offset().top, 1137 contentBottom = contentTop + contentHeight, 1138 initTop = $item.css('top') != 'auto' ? parseInt($item.css('top')) : 0; 1139 1140 if( ( $(window).scrollTop() > contentTop - offset + 80 ) && ( $(window).scrollTop() < contentBottom - ( offset + itemHeight ) )){ 1141 $itemWrapper.css({'position':'fixed', 'width' : itemWidth, 'top': offset }); 1142 } 1143 else if( $(window).scrollTop() > contentTop ){ 1144 $itemWrapper.css({'position':'absolute', 'top': contentHeight - itemHeight - initTop }); 1145 } 1146 else if( $(window).scrollTop() < contentTop + 80 ){ 1147 $itemWrapper.css({'position':'static', 'top':'auto' }); 1148 } 1149 }, 1150 hiddenArea: function( section, btn ){ 1151 var $btn = $('.grve-toggle-hiddenarea'), 1152 $themeWrapper = $('#grve-theme-wrapper'), 1153 $closeBtn = $('.grve-hidden-area').find('.grve-close-btn'), 1154 areaWidth = 0, 1155 content, 1156 $overlay; 1157 1158 // if( !$(content).length > 0 ) return; 1159 1160 $btn.on('click',function(e){ 1161 content = $(this).attr('href'); 1162 if( content.indexOf("#") === 0 && $(content).length > 0 ) { 1163 e.preventDefault(); 1164 var overlayId = content.replace('#',''); 1165 1166 $(content).addClass('prepare-anim'); 1167 $overlay = $('<div id="' + overlayId + '-overlay" class="grve-body-overlay"></div>'); 1168 1169 // Append Overlay on body 1170 $overlay.appendTo( $themeWrapper ); 1171 1172 // Calculate Width 1173 areaWidth = hiddenAreaWidth( content ); 1174 $(window).smartresize(function(){ 1175 areaWidth = hiddenAreaWidth( content ); 1176 }); 1177 1178 if( $(content).hasClass('open') ) { 1179 closeHiddenArea(); 1180 } else { 1181 openHiddenArea(); 1182 } 1183 1184 // For One Page 1185 var $link = $(content).find('a[href*="#"]:not( [href="#"] )'); 1186 $link.on('click',function(){ 1187 var target = $(this.hash), 1188 targetHash = this.hash, 1189 dataValue = this.hash.replace('#',''); 1190 if ( target.length && ( target.hasClass('grve-section') || target.hasClass('grve-bookmark') ) ) { 1191 closeHiddenArea(); 1192 } 1193 // For Fullpage Scrolling 1194 if( $('[data-anchor="' + dataValue + '"]').length ){ 1195 closeHiddenArea(); 1196 } 1197 //For go to header 1198 if( 'grve-goto-header' == dataValue ){ 1199 closeHiddenArea(); 1200 } 1201 }); 1202 1203 } 1204 }); 1205 1206 $closeBtn.on('click',function(){ 1207 closeHiddenArea(); 1208 }); 1209 1210 // Open Hidden Area 1211 function openHiddenArea() { 1212 $overlay.fadeIn(function(){ 1213 $('body').scrollTop( 0 ); 1214 $(content).addClass('open'); 1215 $(this).on('click',function(){ 1216 closeHiddenArea(); 1217 }); 1218 }); 1219 } 1220 // Close Hidden Area 1221 function closeHiddenArea() { 1222 $themeWrapper.css({ 'height' : 'auto' }); 1223 $(content).removeClass('open'); 1224 $overlay.fadeOut(function(){ 1225 $overlay.remove(); 1226 $(content).removeClass('prepare-anim'); 1227 }); 1228 } 1229 1230 // Calculate Area Width 1231 function hiddenAreaWidth( area ){ 1232 var windowWidth = $(window).width(), 1233 areaWidth = windowWidth / 4, 1234 minWidth = 500; 1235 if( $(window).width() + scrollBarWidth <= mobileScreen ) { 1236 areaWidth = windowWidth + 30; 1237 } else if( areaWidth < minWidth ) { 1238 areaWidth = minWidth; 1239 } 1240 1241 $(area).css({ 'width' : areaWidth }); 1242 return areaWidth; 1243 } 1244 1245 }, 1246 hiddenAreaHeight: function( area ){ 1247 if( !$(area).length ) return; 1248 1249 var windowWidth = $(window).width(), 1250 windowHeight = $(window).height(), 1251 hiddenAreaHeight = $(area).find('.grve-hiddenarea-content').outerHeight() + 200, 1252 $themeWrapper = $('#grve-theme-wrapper'), 1253 $scroller = $(area).find('.grve-scroller'), 1254 $buttonWrapper = $(area).find('.grve-buttons-wrapper'), 1255 btnWrapperHeight = $buttonWrapper.length ? $buttonWrapper.height() : 0, 1256 sideHeight = 0; 1257 1258 if( hiddenAreaHeight > windowHeight ){ 1259 sideHeight = hiddenAreaHeight; 1260 } else { 1261 sideHeight = windowHeight; 1262 } 1263 1264 if( $(window).width() + scrollBarWidth <= mobileScreen ) { 1265 $scroller.css({ 'height' : 'auto' }); 1266 $(area).css({ 'position' : 'absolute','height' : sideHeight }); 1267 $themeWrapper.css({ 'height' : sideHeight, 'overflow' : 'hidden' }); 1268 } else { 1269 $scroller.css({ 'height' : windowHeight - btnWrapperHeight - 150 }); 1270 $themeWrapper.css({ 'height' : '', 'overflow' : '' }); 1271 } 1272 }, 1273 backtoTop: function() { 1274 1275 1276 var selectors = { 1277 topBtn : '.grve-back-top', 1278 dividerBtn : '.grve-divider-backtotop', 1279 topLink : 'a[href="#grve-goto-header"]' 1280 }, 1281 footerBarHeight = $('.grve-footer-bar').length ? $('.grve-footer-bar').outerHeight() : 0; 1282 1283 if( $( selectors.topBtn ).length ) { 1284 1285 $(window).on('scroll', function() { 1286 var scroll = $(this).scrollTop(), 1287 $topBtn = $( selectors.topBtn ); 1288 1289 if (scroll > 600) { 1290 $topBtn.addClass('grve-show'); 1291 } else { 1292 $topBtn.removeClass('grve-show'); 1293 } 1294 if( scroll + $(window).height() >
1294 $(document).height() - footerBarHeight ) { 1295 $topBtn.css({ 'transform': 'translate(0, ' + -( footerBarHeight + 70 ) + 'px)' }); 1296 } else { 1297 $topBtn.css({ 'transform': '' }); 1298 } 1299 }); 1300 } 1301 1302 1303 $.each(selectors, function(key, value){ 1304 $(value).on('click', function(e){ 1305 e.preventDefault(); 1306 $('html, body').animate({scrollTop: 0}, 900); 1307 }); 1308 }); 1309 1310 }, 1311 animatedBg: function(){ 1312 var $section = $('.grve-section'); 1313 1314 $section.each(function(){ 1315 var $this = $(this); 1316 1317 if( $this.hasClass('grve-bg-animated') ) { 1318 zoomBg( $this ); 1319 } else if( $this.hasClass('grve-bg-horizontal') ) { 1320 horizontalBg( $this ); 1321 } 1322 }); 1323 1324 function zoomBg( $this ){ 1325 $this.on('mouseenter', function() { 1326 $this.addClass('zoom'); 1327 }); 1328 $this.on('mouseleave', function() { 1329 $this.removeClass('zoom'); 1330 }); 1331 } 1332 1333 function horizontalBg( $this ){ 1334 var bgPosition = 0; 1335 setInterval(function(){ 1336 bgPosition++; 1337 $this.find('.grve-bg-image').css({ 'background-position' : bgPosition+'px center', 'background-repeat' : 'repeat' }); 1338 },75); 1339 } 1340 }, 1341 hovers: function(){ 1342 var $hoverItem = $('.grve-image-hover'); 1343 if ( !isMobile.any() ) { 1344 $hoverItem.off('click'); 1345 $hoverItem.off('mouseenter mouseleave').on('mouseenter mouseleave', function() { 1346 $(this).toggleClass('hover'); 1347 }); 1348 } else { 1349 var touchevent = 'touchend'; 1350 if( $hoverItem.parent().parent().hasClass('grve-carousel-item') ) { 1351 touchevent = 'touchstart'; 1352 } 1353 $hoverItem.on(touchevent, function(e) { 1354 var $item = $(this); 1355 if ( $item.hasClass('hover') || !deviceDoubleTap ) { 1356 return true; 1357 } else { 1358 $item.addClass('hover'); 1359 $hoverItem.not(this).removeClass('hover'); 1360 e.preventDefault(); 1361 return false; 1362 } 1363 }); 1364 $(document).on('touchstart touchend', function(e) { 1365 if ( !$hoverItem.is(e.target) && $hoverItem.has(e.target).length === 0 ) { 1366 $hoverItem.removeClass('hover'); 1367 } 1368 }); 1369 } 1370 }, 1371 shrinkHeaderHeight : function(){ 1372 var headerHeight = 0, 1373 stickyType = $('#grve-header').data('sticky'), 1374 diviceSticky = $('#grve-header').data('devices-sticky'); 1375 1376 if( stickyType != 'none' && $(window).width() + scrollBarWidth > tabletPortrait && $('#grve-header').length > 0 ){ 1377 if( stickyType == 'simple' ) { 1378 headerHeight = $('#grve-main-header').height(); 1379 } 1380 if( stickyType == 'advanced' ) { 1381 headerHeight = 0; 1382 } 1383 if( stickyType == 'shrink' ) { 1384 headerHeight = $('#grve-header').data('sticky-height'); 1385 } 1386 } 1387 1388 if( diviceSticky == 'yes' && $(window).width() + scrollBarWidth < tabletPortrait && $('#grve-header').length > 0 ){ 1389 headerHeight = $('#grve-responsive-header').height(); 1390 } 1391 1392 return headerHeight; 1393 }, 1394 onePageSettings: function(){ 1395 $('a[href*="#"]:not( [href="#"] )').on('click', function(e) { 1396 var headerHeight = GRVE.pageSettings.shrinkHeaderHeight(), 1397 anchorBarHeight = $('.grve-anchor-menu').length ? $('.grve-anchor-menu').outerHeight() : 0, 1398 target = $(this.hash); 1399 1400 if ( target.length && ( target.hasClass('grve-section') || target.hasClass('grve-bookmark') ) ) { 1401 var page = $('html,body'); 1402 page.animate({ 1403 scrollTop: target.offset().top - headerHeight - anchorBarHeight + 2 1404 }, 1000); 1405 page.bind("scroll mousedown DOMMouseScroll mousewheel keyup", function(e){ 1406 if ( e.which > 0 || e.type === "mousedown" || e.type === "mousewheel"){ 1407 page.stop().unbind('scroll mousedown DOMMouseScroll mousewheel keyup'); 1408 } 1409 }); 1410 return false; 1411 } 1412 }); 1413 }, 1414 locationHash: function(){ 1415 if (window.location.hash) { 1416 setTimeout(function() { 1417 var headerHeight = GRVE.pageSettings.shrinkHeaderHeight(), 1418 anchorBarHeight = $('.grve-anchor-menu').length ? $('.grve-anchor-menu').outerHeight() : 0, 1419 target = window.location.hash; 1420 if( $(target).length ) { 1421 $('html, body').scrollTop( $(target).offset().top - headerHeight - anchorBarHeight + 2 ); 1422 } 1423 }, 0); 1424 } 1425 }, 1426 onePageMenu: function(){ 1427 var $section = $('#grve-main-content .grve-section[id]'); 1428 if (!$section.length ) return; 1429 1430 var headerHeight = GRVE.pageSettings.shrinkHeaderHeight(), 1431 anchorBarHeight = $('.grve-anchor-menu').length ? $('.grve-anchor-menu').outerHeight() : 0, 1432 offsetTop = headerHeight + anchorBarHeight + wpBarHeight, 1433 scroll = $(window).scrollTop(); 1434 1435 $section.each(function(){ 1436 var $that = $(this), 1437 currentId = $that.attr('id'), 1438 sectionOffset = $that.offset().top - offsetTop; 1439 1440 if (sectionOffset <= scroll && sectionOffset + $that.outerHeight() > scroll ) { 1441 $('a[href*="#' + currentId + '"]').parent().addClass('active'); 1442 } 1443 else{ 1444 $('a[href*="#' + currentId + '"]').parent().removeClass("active"); 1445 } 1446 1447 }); 1448 }, 1449 anchorSticky: function(){ 1450 var $anchor = $('.grve-anchor-menu'), 1451 $section = $('#grve-main-content .grve-section[id]'); 1452
1453 if( !$anchor.length || $(window).width() + scrollBarWidth <= tabletPortrait ) return; 1454 1455 var $anchorWrapper = $anchor.find('.grve-anchor-wrapper'), 1456 headerHeight = $('#grve-header').data('sticky') != 'none' ? $('#grve-main-header').height() : 0, 1457 anchorTop = $anchor.offset().top, 1458 offset = anchorTop - headerHeight, 1459 scroll = $(window).scrollTop(); 1460 1461 if ( scroll >= offset ) { 1462 $anchorWrapper.addClass('grve-sticky').css({ 'top' : headerHeight }); 1463 } else { 1464 $anchorWrapper.removeClass('grve-sticky').css({ 'top' : '' }); 1465 } 1466 1467 function findActive() { 1468 $section.each(function(){ 1469 var actual = $(this), 1470 actualHeight = actual.outerHeight(), 1471 actualAnchor = $anchor.find('a[href="#'+actual.attr('id')+'"]').parent(); 1472 if ( ( actual.offset().top - $anchor.height() <= $(window).scrollTop() ) && ( actual.offset().top + actualHeight - $anchor.height() > $(window).scrollTop() ) ) { 1473 actualAnchor.addClass('active'); 1474 }else { 1475 actualAnchor.removeClass('active'); 1476 } 1477 }); 1478 } 1479 1480 }, 1481 anchorBar: function(){ 1482 1483 var $anchorBar = $('.grve-anchor-menu'), 1484 $anchorMenu = $anchorBar.find('.grve-container > ul '), 1485 $menuItem = $anchorBar.find('li.menu-item-has-children > a'), 1486 $anchorBtn = $anchorBar.find('.grve-anchor-btn'), 1487 $arrow = $('<i class="grve-arrow"></i>'); 1488 1489 // Add Arrows 1490 $arrow.appendTo( $menuItem ); 1491 1492 $menuItem.each(function(){ 1493 var $that = $(this), 1494 $parent = $that.parent(), 1495 $subMenu = $parent.find(' > ul'), 1496 link = $that.attr('href'), 1497 $item = $that; 1498 1499 if( link != '#') { 1500 $item = $that.find('.grve-arrow'); 1501 } 1502 1503 $item.on('tap click', function(e){ 1504 e.preventDefault(); 1505 $parent.toggleClass('open'); 1506 1507 if( $subMenu.is(':visible') ) { 1508 $subMenu.slideUp(200); 1509 } else { 1510 $subMenu.slideDown(200); 1511 } 1512 }); 1513 }); 1514 1515 $anchorBtn.on('tap click', function(e){ 1516 e.preventDefault(); 1517 if( $anchorMenu.is(':visible') ) { 1518 $anchorMenu.slideUp(200); 1519 } else { 1520 $anchorMenu.slideDown(200); 1521 } 1522 }); 1523 1524 $(window).smartresize(function(){ 1525 // Reset Sub Menu Style Style 1526 if( $(window).width() + scrollBarWidth > tabletPortrait ) { 1527 $anchorBar.find('ul.sub-menu').removeAttr('style').parent().removeClass('open'); 1528 $anchorMenu.removeAttr('style'); 1529 $('.grve-anchor-wrapper').removeClass('grve-sticky').removeAttr('style'); 1530 } 1531 }); 1532 1533 }, 1534 fixedFooter: function(){ 1535 var $footer = $('#grve-footer'), 1536 sticky = $footer.data('sticky-footer'), 1537 prevSection = $footer.prev(), 1538 prevMargin = parseInt( prevSection.css('margin-bottom') ); 1539 1540 if( !$footer.length || sticky != 'yes' || isMobile.any() ) return; 1541 1542 update(); 1543 $(window).smartresize(function(){ 1544 update(); 1545 }); 1546 1547 function update(){ 1548 var windowHeight = $(window).height(), 1549 footerHeight = $footer.outerHeight(), 1550 margin = footerHeight + prevMargin; 1551 1552 if( footerHeight > windowHeight ) { 1553 $footer.removeClass('grve-fixed-footer').prev().css( 'margin-bottom',0 ); 1554 } else { 1555 $footer.addClass('grve-fixed-footer').prev().css( 'margin-bottom',margin ); 1556 } 1557 1558 } 1559 1560 }, 1561 shoppingCart: function(){ 1562 var $button = $('.grve-toggle-cart'), 1563 $cart = $('.grve-shoppin-cart-content'), 1564 $cartList = $cart.find('.cart_list'), 1565 timer; 1566 1567 $button.on('mouseover',function(){ 1568 clearTimeout(timer); 1569 openCart(); 1570 }); 1571 1572 $button.on('mouseout',function(){ 1573 closeCart(); 1574 }); 1575 1576 $cart.on('mouseover',function(){ 1577 clearTimeout(timer); 1578 }); 1579 1580 $cart.on('mouseout',function(){ 1581 closeCart(); 1582 }); 1583 1584 function openCart(){ 1585 $cart.addClass('open'); 1586 } 1587 1588 function closeCart(){ 1589 timer = setTimeout(function(){ 1590 $cart.removeClass('open'); 1591 }, 300); 1592 } 1593 }, 1594 lightBox: function(){ 1595 //IMAGE 1596 $('.grve-image-popup').each(function() { 1597 $(this).magnificPopup({ 1598 type: 'image', 1599 preloader: false, 1600 fixedBgPos: true, 1601 fixedContentPos: true, 1602 removalDelay: 200, 1603 closeMarkup: '<div class="mfp-close grve-close-btn grve-close-modal grve-close-line"></div>', 1604 closeOnBgClick: true, 1605 callbacks: { 1606 beforeOpen: function() { 1607 var mfpWrap = this.wrap; 1608 this.bgOverlay.fadeIn(200); 1609 addSpinner( mfpWrap ); 1610 }, 1611 imageLoadComplete: function() { 1612 var $spinner = this.wrap.find('.grve-spinner'), 1613 $content = this.container; 1614 removeSpinner( $spinner, $content ); 1615 1616 }, 1617 beforeClose: function() { 1618 this.wrap.fadeOut(100); 1619 this.bgOverlay.fadeOut(100); 1620 }, 1621 }, 1622 image: { 1623 verticalFit: true, 1624 titleSrc: function(item) { 1625 var title = item.el.data( 'title' ) ? item.el.data( 'title' ) : '', 1626 caption = item.el.data('desc') ? '<br><small>' + item.el.data('desc') + '</small>' : ''; 1627 if ( '' === title ) { 1628 title = item.el.find('.grve-title').html() ? item.el.find('.grve-title').html() : ''; 1629 } 1630 if ( '' === caption ) { 1631 caption = item.el.find('.grve-caption').html() ? '<br><small>' + item.el.find('.grve-caption').html() + '</small>' : ''; 1632 } 1633 return title + caption; 1634 } 1635 } 1636 }); 1637 }); 1638 $('.grve-gallery-popup, .grve-post-gallery-popup').each(function() { 1639 $(this).magnificPopup({ 1640 delegate: 'a', 1641 type: 'image', 1642 preloader: false, 1643 fixedBgPos: true, 1644 fixedContentPos: true, 1645 removalDelay: 200, 1646 closeMarkup: '<div class="mfp-close grve-close-btn grve-close-modal grve-close-line"></div>', 1647 closeOnBgClick: true, 1648 callbacks: { 1649 beforeOpen: function() { 1650 var mfpWrap = this.wrap; 1651 this.bgOverlay.fadeIn(200); 1652 addSpinner( mfpWrap ); 1653 }, 1654 imageLoadComplete: function() { 1655 var $spinner = this.wrap.find('.grve-spinner'), 1656 $content = this.container; 1657 removeSpinner( $spinner, $content ); 1658 1659 }, 1660 beforeClose: function() { 1661 this.wrap.fadeOut(100); 1662 this.bgOverlay.fadeOut(100); 1663 }, 1664 }, 1665 gallery: { 1666 enabled: true, 1667 tCounter: '%curr% / %total%' 1668 }, 1669 image: { 1670 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', 1671 titleSrc: function(item) { 1672 var title = item.el.data( 'title' ) ? item.el.data( 'title' ) : '', 1673 caption = item.el.data('desc') ? '<br><small>' + item.el.data('desc') + '</small>' : ''; 1674 if ( '' === title ) { 1675 title = item.el.find('.grve-title').html() ? item.el.find('.grve-title').html() : ''; 1676 } 1677 if ( '' === caption ) { 1678 caption = item.el.find('.grve-caption').html() ? '<br><small>' + item.el.find('.grve-caption').html() + '</small>' : ''; 1679 } 1680 return title + caption; 1681 } 1682 } 1683 }); 1684 }); 1685 1686 if( 1 == grve_main_data.grve_wp_gallery_popup ) { 1687 $('.gallery').each(function() { 1688 $(this).magnificPopup({ 1689 delegate: 'a', 1690 type: 'image', 1691 preloader: false, 1692 fixedBgPos: true, 1693 fixedContentPos: true, 1694 removalDelay: 200, 1695 closeMarkup: '<div class="mfp-close grve-close-btn grve-close-modal grve-close-line"></div>', 1696 closeOnBgClick: true, 1697 callbacks: { 1698 beforeOpen: function() { 1699 var mfpWrap = this.wrap; 1700 this.bgOverlay.fadeIn(200); 1701 addSpinner( mfpWrap ); 1702 }, 1703 imageLoadComplete: function() { 1704 var $spinner = this.wrap.find('.grve-spinner'), 1705 $content = this.container; 1706 removeSpinner( $spinner, $content ); 1707 1708 }, 1709 beforeClose: function() { 1710 this.wrap.fadeOut(100); 1711 this.bgOverlay.fadeOut(100); 1712 }, 1713 }, 1714 gallery: { 1715 enabled:true, 1716 tCounter: '%curr% / %total%' 1717 }, 1718 image: { 1719 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', 1720 titleSrc: function(item) { 1721 var title = item.el.closest('.gallery-item').find('.gallery-caption').html() ? item.el.closest('.gallery-item').find('.gallery-caption').html() : ''; 1722 return title; 1723 } 1724 } 1725 }); 1726 }); 1727 } 1728 //VIDEOS 1729 if ( $('#grve-body').hasClass( 'grve-privacy-video-embeds-disabled' ) ) { 1730 $('.grve-youtube-popup, .grve-vimeo-popup, .grve-video-popup').each(function() { 1731 $(this).attr({"target" : "_blank"}); 1732 }); 1733 } else { 1734 $('.grve-youtube-popup, .grve-vimeo-popup, .grve-video-popup').each(function() { 1735 $(this).magnificPopup({ 1736 disableOn: 0, 1737 type: 'iframe', 1738 preloader: false, 1739 fixedBgPos: true, 1740 fixedContentPos: true, 1741 removalDelay: 200, 1742 closeMarkup: '<div class="mfp-close grve-close-btn grve-close-modal grve-close-line"></div>', 1743 closeOnBgClick: true, 1744 callbacks: { 1745 beforeOpen: function() { 1746 var mfpWrap = this.wrap; 1747 this.bgOverlay.fadeIn(200); 1748 addSpinner( mfpWrap ); 1749 }, 1750 open: function() { 1751 var $spinner = this.wrap.find('.grve-spinner'), 1752 $content = this.container; 1753 removeSpinner( $spinner, $content ); 1754 }, 1755 beforeClose: function() { 1756 this.wrap.fadeOut(100); 1757 this.bgOverlay.fadeOut(100); 1758 }, 1759 } 1760 }); 1761 }); 1762 } 1763 1764 $('.grve-page-popup').each(function() { 1765 $(this).magnificPopup({ 1766 disableOn: 0, 1767 type: 'iframe', 1768 preloader: false, 1769 fixedBgPos: true, 1770 fixedContentPos: true, 1771 removalDelay: 200, 1772 closeMarkup: '<div class="mfp-close grve-close-btn grve-close-modal grve-close-line"></div>', 1773 closeOnBgClick: true, 1774 callbacks: { 1775 beforeOpen: function() { 1776 var mfpWrap = this.wrap; 1777 this.bgOverlay.fadeIn(200); 1778 addSpinner( mfpWrap ); 1779 }, 1780 open: function() { 1781 var $spinner = this.wrap.find('.grve-spinner'), 1782 $content = this.container; 1783 removeSpinner( $spinner, $content ); 1784 }, 1785 beforeClose: function() { 1786 this.wrap.fadeOut(100); 1787 this.bgOverlay.fadeOut(100); 1788 }, 1789 } 1790 }); 1791 }); 1792 1793 function addSpinner( mfpWrap ){ 1794 $(spinner).appendTo( mfpWrap ); 1795 } 1796 1797 function removeSpinner( spinner, content ){ 1798 setTimeout(function(){ 1799 spinner.fadeOut(1000, function(){ 1800 content.animate({'opacity':1},600); 1801 }); 1802 }, 700); 1803 } 1804 }, 1805 socialShareLinks: function(){ 1806 $(document).on('click','.grve-social-share-facebook',function(e) { 1807 e.preventDefault(); 1808 window.open( 'https://www.facebook.com/sharer/sharer.php?u=' + $(this).attr('href'), "facebookWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 1809 return false;
1810 }); 1811 $(document).on('click','.grve-social-share-twitter',function(e) { 1812 e.preventDefault(); 1813 window.open( 'http://twitter.com/intent/tweet?text=' + encodeURIComponent( $(this).attr('title') ) + ' ' + $(this).attr('href'), "twitterWindow", "height=450,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 1814 return false; 1815 }); 1816 $(document).on('click','.grve-social-share-linkedin',function(e) { 1817 e.preventDefault(); 1818 window.open( 'http://www.linkedin.com/shareArticle?mini=true&url=' + $(this).attr('href') + '&title=' + encodeURIComponent( $(this).attr('title') ), "linkedinWindow", "height=500,width=820,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 1819 return false; 1820 }); 1821 $(document).on('click','.grve-social-share-pinterest',function(e) { 1822 e.preventDefault(); 1823 window.open( 'http://pinterest.com/pin/create/button/?url=' + $(this).attr('href') + '&media=' + $(this).data('pin-img') + '&description=' + encodeURIComponent( $(this).attr('title') ), "pinterestWindow", "height=600,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 1824 return false; 1825 }); 1826 $(document).on('click','.grve-social-share-reddit',function(e) { 1827 e.preventDefault(); 1828 window.open( '//www.reddit.com/submit?url=' + $(this).attr('href'), "redditWindow", "height=600,width=820,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=1" ); 1829 return false; 1830 }); 1831 $(document).on('click','.grve-social-share-tumblr',function(e) { 1832 e.preventDefault(); 1833 window.open( '//www.tumblr.com/share/link?url=' + $(this).attr('href') + '&name=' + encodeURIComponent( $(this).attr('title') ) , "tumblrWindow", "height=600,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 1834 return false; 1835 }); 1836 $(document).on('click','.grve-like-counter-link',function(e) { 1837 e.preventDefault(); 1838 var link = $(this); 1839 var id = link.data('post-id'), 1840 counter = link.parent().find('.grve-like-counter'); 1841 1842 var dataParams = { 1843 action:'blade_grve_likes_callback', 1844 grve_likes_id: id, 1845 _grve_nonce: grve_main_data.nonce_likes 1846 }; 1847 1848 $.post( grve_main_data.ajaxurl, dataParams , function( response ) { 1849 if ( '-1' != response ) { 1850 if( 'active' == response.status ){ 1851 link.addClass('active'); 1852 } else { 1853 link.removeClass('active'); 1854 } 1855 counter.html(response.likes); 1856 } 1857 }).fail(function(xhr, status, error) { 1858 }); 1859 1860 return false; 1861 }); 1862 } 1863 }; 1864 1865 // # Basic Elements 1866 // ============================================================================= // 1867 GRVE.basicElements = { 1868 init: function(){ 1869 this.pieChart(); 1870 this.progressBars(); 1871 this.counter(); 1872 this.slider(); 1873 this.testimonial(); 1874 this.flexibleCarousel(); 1875 this.carousel(); 1876 this.advancedPromo(); 1877 this.imageText(); 1878 this.messageBox(); 1879 this.wooProduct(); 1880 this.wooProductZoom(); 1881 this.animAppear(); 1882 this.vcAccordion(); 1883 this.vcTab(); 1884 this.vcResponsiveTab(); 1885 this.productSocials(); 1886 this.countdown(); 1887 }, 1888 pieChart: function(){ 1889 1890 $('.grve-chart-number').each(function() { 1891 var $element = $(this), 1892 delay = $element.parent().data('delay') !== '' ? parseInt( $element.parent().data('delay') ) : 0, 1893 size = $element.data('pie-size'), 1894 chartSize = '130'; 1895 if( size == 'small' ){ 1896 chartSize = '100'; 1897 } 1898 if( size == 'large' ){ 1899 chartSize = '160'; 1900 } 1901 1902 $element.css({ 'width' : chartSize, 'height' : chartSize, 'line-height' : chartSize + 'px' }); 1903 1904 $element.appear(function() { 1905 setTimeout(function () { 1906 GRVE.basicElements.pieChartInit( $element, chartSize ); 1907 }, delay); 1908 }); 1909 }); 1910 1911 }, 1912 pieChartInit: function( $element, size ){ 1913 1914 var activeColor = $element.data('pie-active-color') !== '' ? $element.data('pie-active-color') : 'rgba(0,0,0,1)', 1915 pieColor = $element.data('pie-color') !== '' ? $element.data('pie-color') : 'rgba(0,0,0,0.1)', 1916 pieLineCap = $element.data('pie-line-cap') !== '' ? $element.data('pie-line-cap') : 'round', 1917 lineSize = $element.data('pie-line-size') !== '' ? $element.data('pie-line-size') : '6', 1918 chartSize = size; 1919 1920 1921 $element.easyPieChart({ 1922 barColor: activeColor, 1923 trackColor: pieColor, 1924 scaleColor: false, 1925 lineCap: pieLineCap, 1926 lineWidth: lineSize, 1927 animate: 1500, 1928 size: chartSize 1929 }); 1930 }, 1931 progressBars: function(){ 1932 var selector = '.grve-progress-bar'; 1933 $(selector).each(function() { 1934 $(this).appear(function() { 1935 1936 var val = $(this).attr('data-value'), 1937 percentage = $('<span class="grve-percentage">'+ val + '%'+'</span>'); 1938 1939 $(this).find('.grve-bar-line').animate({ width: val + '%' }, 1600); 1940 if( $(this).parent().hasClass('grve-style-1') ) { 1941 percentage.appendTo($(this).find('.grve-bar')).animate({ left: val + '%' }, 1600); 1942 } else { 1943 percentage.appendTo($(this).find('.grve-bar-title')); 1944 } 1945 1946 }); 1947 }); 1948 }, 1949 counter: function(){ 1950 if( bodyLoader === true ){ 1951 return; 1952 } 1953 var selector = '.grve-counter-item > span'; 1954 $(selector).each(function(i){ 1955 var elements = $(selector)[i], 1956 thousandsSeparator = $(this).attr('data-thousands-separator') !== '' ? $(this).attr('data-thousands-separator') : ','; 1957 $(elements).attr('id','grve-counter-' + i );
1958 var delay = $(this).parents('.grve-counter').attr('data-delay') !== '' ? parseInt( $(this).parents('.grve-counter').attr('data-delay') ) : 200, 1959 options = { 1960 useEasing : true, 1961 useGrouping : true, 1962 separator : $(this).attr('data-thousands-separator-vis') !== 'yes' ? thousandsSeparator : '', 1963 decimal : $(this).attr('data-decimal-separator') !== '' ? $(this).attr('data-decimal-separator') : '.', 1964 prefix : $(this).attr('data-prefix') !== '' ? '<span class="grve-counter-prefix">' + $(this).attr('data-prefix') + '</span>' : '', 1965 suffix : $(this).attr('data-suffix') !== '' ? '<span class="grve-counter-suffix">' + $(this).attr('data-suffix') + '</span>' : '' 1966 }, 1967 counter = new CountUp( $(this).attr('id') , $(this).attr('data-start-val'), $(this).attr('data-end-val'), $(this).attr('data-decimal-points'), 2.5, options); 1968 $(this).appear(function() { 1969 setTimeout(function () { 1970 counter.start(); 1971 }, delay); 1972 }); 1973 }); 1974 }, 1975 slider: function( settings ){ 1976 1977 var $element = $('.grve-slider'); 1978 1979 $element.each(function(){ 1980 var $that = $(this), 1981 carouselSettings = { 1982 sliderSpeed : ( parseInt( $that.attr('data-slider-speed') ) ) ? parseInt( $that.attr('data-slider-speed') ) : 3000, 1983 paginationSpeed : ( parseInt( $that.attr('data-pagination-speed') ) ) ? parseInt( $that.attr('data-pagination-speed') ) : 400, 1984 autoHeight : $that.attr('data-slider-autoheight') == 'yes' ? true : false, 1985 sliderPause : $that.attr('data-slider-pause') == 'yes' ? true : false, 1986 autoPlay : $that.attr('data-slider-autoplay') != 'no' ? true : false, 1987 baseClass : 'grve-carousel', 1988 pagination : $that.attr('data-slider-pagination') == 'yes' ? true : false, 1989 }; 1990 1991 carouselInit( $that, carouselSettings ); 1992 customNav( $that ); 1993 1994 }); 1995 1996 // Init Slider 1997 function carouselInit( element, settings ){ 1998 element.owlCarousel({ 1999 navigation : false, 2000 pagination : settings.pagination, 2001 autoHeight : settings.autoHeight, 2002 slideSpeed : settings.paginationSpeed, 2003 paginationSpeed : settings.paginationSpeed, 2004 singleItem : true, 2005 autoPlay : settings.autoPlay, 2006 stopOnHover : settings.sliderPause, 2007 baseClass : 'owl-carousel', 2008 theme : 'grve-theme' 2009 }); 2010 // Carousel Element Speed 2011 if( settings.autoPlay == true ){ 2012 element.trigger( 'owl.play', settings.sliderSpeed ); 2013 } 2014 2015 $element.css('visibility','visible'); 2016 2017 // Slider Navigation 2018 function customNav( element ){ 2019 element.parent().find('.grve-carousel-next').on('click', function() { 2020 element.trigger('owl.next'); 2021 }); 2022 element.parent().find('.grve-carousel-prev').on('click', function() { 2023 element.trigger('owl.prev'); 2024 }); 2025 } 2026 } 2027 2028 function customNav( element ){ 2029 // Carousel Navigation 2030 element.parent().find('.grve-carousel-next').on('click', function() { 2031 element.trigger('owl.next'); 2032 }); 2033 element.parent().find('.grve-carousel-prev').on('click', function() { 2034 element.trigger('owl.prev'); 2035 }); 2036 } 2037 }, 2038 testimonial: function(){ 2039 2040 var $testimonial = $('.grve-testimonial'); 2041 2042 $testimonial.each(function(){ 2043 var $that = $(this), 2044 carouselSettings = { 2045 sliderSpeed : ( parseInt( $that.attr('data-slider-speed') ) ) ? parseInt( $that.attr('data-slider-speed') ) : 3000, 2046 paginationSpeed : ( parseInt( $that.attr('data-pagination-speed') ) ) ? parseInt( $that.attr('data-pagination-speed') ) : 400, 2047 transition : $that.attr('data-slider-transition') != 'slide' ? $that.attr('data-slider-transition') : false, 2048 pagination : $that.attr('data-pagination') != 'no' ? true : false, 2049 autoHeight : $that.attr('data-slider-autoheight') == 'yes' ? true : '', 2050 sliderPause : $that.attr('data-slider-pause') == 'yes' ? true : false, 2051 autoPlay : $that.attr('data-slider-autoplay') != 'no' ? true : false, 2052 itemNum : parseInt( $that.attr('data-items')), 2053 baseClass : 'grve-testimonial' 2054 }; 2055
2056 carouselInit( $that, carouselSettings ); 2057 customNav( $that ); 2058 2059 }); 2060 // Init Carousel 2061 function carouselInit( $element, settings ){ 2062 $element.owlCarousel({ 2063 navigation : false, 2064 pagination : settings.pagination, 2065 autoHeight : settings.autoHeight, 2066 slideSpeed : 400, 2067 paginationSpeed : settings.paginationSpeed, 2068 singleItem : true, 2069 autoPlay : settings.autoPlay, 2070 stopOnHover : settings.sliderPause, 2071 baseClass : 'grve-testimonial-element', 2072 theme : '', 2073 transitionStyle : settings.transition 2074 }); 2075 2076 // Carousel Element Speed 2077 if( settings.autoPlay === true ){ 2078 $element.trigger('owl.play',settings.sliderSpeed); 2079 } 2080 $element.css('visibility','visible'); 2081 } 2082 2083 // Carousel Navigation 2084 function customNav( $element ){ 2085 $element.parent().find('.grve-carousel-next').on('click', function() { 2086 $element.trigger('owl.next'); 2087 }); 2088 $element.parent().find('.grve-carousel-prev').on('click', function() { 2089 $element.trigger('owl.prev'); 2090 }); 2091 } 2092 }, 2093 flexibleCarousel: function(){ 2094 2095 var $flexibleCarousel = $('.grve-flexible-carousel'); 2096 2097 $flexibleCarousel.each(function(){ 2098 var $that = $(this), 2099 carouselSettings = { 2100 sliderSpeed : ( parseInt( $that.attr('data-slider-speed') ) ) ? parseInt( $that.attr('data-slider-speed') ) : 3000, 2101 paginationSpeed : ( parseInt( $that.attr('data-pagination-speed') ) ) ? parseInt( $that.attr('data-pagination-speed') ) : 400, 2102 pagination : $that.attr('data-pagination') != 'no' ? true : false, 2103 autoHeight : $that.attr('data-slider-autoheight') == 'yes' ? true : '', 2104 sliderPause : $that.attr('data-slider-pause') == 'yes' ? true : false, 2105 autoPlay : $that.attr('data-slider-autoplay') != 'no' ? true : false, 2106 itemNum : parseInt( $that.attr('data-items')), 2107 itemTabletL : parseInt( $that.attr('data-tablet-landscape-items')), 2108 itemTabletP : parseInt( $that.attr('data-tablet-portrait-items')), 2109 itemMobile : parseInt( $that.attr('data-mobile-items')), 2110 baseClass : 'grve-flexible-carousel', 2111 direction : $('body').hasClass('rtl') ? 'rtl' : 'ltr' 2112 }; 2113 2114 carouselInit( $that, carouselSettings ); 2115 customNav( $that ); 2116 2117 }); 2118 // Init Carousel 2119 function carouselInit( $element, settings ){ 2120 $element.owlCarousel({ 2121 direction : settings.direction, 2122 navigation : false, 2123 pagination : settings.pagination, 2124 autoHeight : settings.autoHeight, 2125 slideSpeed : 400, 2126 paginationSpeed : settings.paginationSpeed, 2127 autoPlay : settings.autoPlay, 2128 stopOnHover : settings.sliderPause, 2129 baseClass : 'grve-carousel-element', 2130 theme : '', 2131 itemsCustom : [[0, settings.itemMobile], [700, settings.itemTabletP], [1024, settings.itemTabletL], [1200, settings.itemNum]] 2132 }); 2133 2134 // Carousel Element Speed 2135 if( settings.autoPlay === true ){ 2136 $element.trigger('owl.play',settings.sliderSpeed); 2137 } 2138 $element.css('visibility','visible'); 2139 } 2140 2141 // Carousel Navigation 2142 function customNav( $element ){ 2143 $element.parent().find('.grve-carousel-next').on('click', function() { 2144 $element.trigger('owl.next'); 2145 }); 2146 $element.parent().find('.grve-carousel-prev').on('click', function() { 2147 $element.trigger('owl.prev'); 2148 }); 2149 } 2150 }, 2151 carousel: function(){ 2152 2153 var $carousel = $('.grve-carousel'); 2154 2155 $carousel.each(function(){ 2156 var $that = $(this), 2157 carouselSettings = { 2158 sliderSpeed : ( parseInt( $that.attr('data-slider-speed') ) ) ? parseInt( $that.attr('data-slider-speed') ) : 3000, 2159 paginationSpeed : ( parseInt( $that.attr('data-pagination-speed') ) ) ? parseInt( $that.attr('data-pagination-speed') ) : 400, 2160 pagination : $that.attr('data-pagination') == 'yes' ? true : false, 2161 autoHeight : $that.attr('data-slider-autoheight') == 'yes' ? true : '',
2162 sliderPause : $that.attr('data-slider-pause') == 'yes' ? true : false, 2163 autoPlay : $that.attr('data-slider-autoplay') != 'no' ? true : false, 2164 itemNum : parseInt( $that.attr('data-items')), 2165 itemsTablet : [768,2], 2166 baseClass : 'grve-carousel', 2167 gap : $that.parent().hasClass('grve-with-gap') && !isNaN( $that.data('gutter-size') ) ? Math.abs( $that.data('gutter-size') )/2 : 0, 2168 direction : $('body').hasClass('rtl') ? 'rtl' : 'ltr' 2169 }; 2170 2171 carouselInit( $that, carouselSettings ); 2172 customNav( $that ); 2173 2174 }); 2175 // Init Carousel 2176 function carouselInit( $element, settings ){ 2177 2178 $element.css({ 'margin-left' : - settings.gap, 'margin-right' : - settings.gap }); 2179 2180 $element.owlCarousel({ 2181 direction : settings.direction, 2182 navigation : false, 2183 pagination : settings.pagination, 2184 autoHeight : settings.autoHeight, 2185 slideSpeed : 400, 2186 paginationSpeed : settings.paginationSpeed, 2187 singleItem : false, 2188 items : settings.itemNum, 2189 autoPlay : settings.autoPlay, 2190 stopOnHover : settings.sliderPause, 2191 baseClass : 'grve-carousel-element', 2192 theme : '', 2193 itemsDesktop : false, 2194 itemsDesktopSmall : false, 2195 itemsTablet : settings.itemsTablet 2196 }); 2197 2198 // Carousel Element Speed 2199 if( settings.autoPlay === true ){ 2200 $element.trigger('owl.play',settings.sliderSpeed); 2201 } 2202 $element.css('visibility','visible'); 2203 $element.find('.owl-item').css({ 'padding-left' : settings.gap, 'padding-right' : settings.gap }); 2204 } 2205 2206 // Carousel Navigation 2207 function customNav( $element ){ 2208 $element.parent().find('.grve-carousel-next').on('click', function() { 2209 $element.trigger('owl.next'); 2210 }); 2211 $element.parent().find('.grve-carousel-prev').on('click', function() { 2212 $element.trigger('owl.prev'); 2213 }); 2214 } 2215 }, 2216 advancedPromo: function(){ 2217 var $item = $('.grve-expandable-info'); 2218 $item.each(function(){ 2219 var $that = $(this), 2220 $wrapper = $that.parents('.grve-section'), 2221 $content = $that.find('.grve-expandable-info-content'), 2222 paddingTop = parseInt( $wrapper.css('padding-top') ), 2223 paddingBottom = parseInt( $wrapper.css('padding-bottom') ); 2224 2225 $wrapper.addClass('grve-pointer-cursor'); 2226 $wrapper.on('click',function(){ 2227 2228 var headerHeight = $('#grve-header').data('sticky') != 'none' ? $('#grve-main-header').outerHeight() : 0, 2229 fieldBarHeight = $('.grve-fields-bar').length ? $('.grve-fields-bar').outerHeight() : 0, 2230 offset = $(this).offset().top, 2231 distance = offset - ( headerHeight + fieldBarHeight ); 2232 2233 if( $content.is(":visible") ){ 2234 $content.slideUp( 600, function(){ 2235 $content.removeClass('grve-show'); 2236 }); 2237 } else { 2238 2239 $('html,body').animate({ 2240 scrollTop: distance 2241 }, 600,function(){ 2242 $content.slideDown( function(){ 2243 $content.addClass('grve-show'); 2244 return; 2245 }); 2246 }); 2247 } 2248 }); 2249 $wrapper.on('mouseenter', function() { 2250 $(this).css({ 'padding-top' : paddingTop + 40, 'padding-bottom' : paddingBottom + 40 }); 2251 }); 2252 $wrapper.on('mouseleave', function() { 2253 $(this).css({ 'padding-top' : paddingTop, 'padding-bottom' : paddingBottom }); 2254 }); 2255 }); 2256 }, 2257 imageText: function(){ 2258 var $el = $('.grve-image-text'); 2259 if( !$el.length ) return; 2260 $el.each(function(){ 2261 var $that = $(this), 2262 $img = $that.find('img'), 2263 $cont = $that.find('.grve-content'); 2264 $img.css({ 'padding-top' : '', 'padding-bottom' : '' }); 2265 $cont.css({ 'padding-top' : '', 'padding-bottom' : '' }); 2266 $that.css('visibility','hidden'); 2267 $img.imagesLoaded( function() { 2268 var imgHeight = $img.height(), 2269 contHeight = $cont.height(), 2270 space = parseInt( (imgHeight - contHeight)/2 ); 2271 if( $(window).width() + scrollBarWidth >= mobileScreen ) { 2272 if( imgHeight < contHeight ){ 2273 space = parseInt( (contHeight - imgHeight)/2 ); 2274 $img.css({ 'padding-top' : space, 'padding-bottom' : space }); 2275 } else { 2276 $cont.css({ 'padding-top' : space, 'padding-bottom' : space }); 2277 } 2278 } 2279 $that.css('visibility','visible'); 2280 }); 2281 2282 }); 2283 }, 2284 iconBox: function(){ 2285 var $parent = $('.grve-row'), 2286 arrHeight = []; 2287 $parent.each(function(){ 2288 var $iconBox = $(this).find('.grve-box-icon.grve-advanced-hover'); 2289 if( !$iconBox.length ) return; 2290 if( isMobile.any() ) { 2291 $iconBox.removeClass('grve-advanced-hover'); 2292 return; 2293 } 2294 $iconBox.css({ 'height' : '', 'padding-top' : '' }); 2295 $iconBox.each(function(){ 2296 var $that = $(this), 2297 $iconBoxHeigth = $that.height(); 2298 arrHeight.push( $iconBoxHeigth ); 2299 }); 2300 var maxHeight = Math.max.apply(Math,arrHeight) + 20, 2301 iconHeight = $iconBox.find('.grve-wrapper-icon').height(), 2302 paddingTop = ( maxHeight - iconHeight )/2; 2303 $iconBox.css({ 'height' : maxHeight, 'padding-top' : paddingTop }); 2304 if( $iconBox.parents('.grve-section').hasClass('grve-custom-height') ) { 2305 var $section = $iconBox.parents('.grve-section'); 2306 setTimeout( function(){ 2307 $iconBox.addClass('grve-icon-box-active'); 2308 // Fix Columns Height
2309 GRVE.setColumnHeight.init(); 2310 }, 300 ); 2311 } else { 2312 setTimeout( function(){ 2313 $iconBox.addClass('grve-icon-box-active'); 2314 }, 300 ); 2315 } 2316 $iconBox.off('mouseenter mouseleave').on('mouseenter mouseleave', function() { 2317 $(this).toggleClass('hover'); 2318 }); 2319 }); 2320 }, 2321 messageBox: function(){ 2322 var infoMessage = $('.grve-message'), 2323 closeBtn = infoMessage.find($('.grve-close')); 2324 closeBtn.on('click', function() { 2325 $(this).parent().slideUp(150); 2326 }); 2327 }, 2328 wooProduct: function(){ 2329 var $item = $('.grve-product-item'), 2330 $addBtn = $item.find('.add_to_cart_button'); 2331 $addBtn.on('click',function(){ 2332 $(this).parents('.grve-product-switcher').addClass('product-added'); 2333 }); 2334 }, 2335 wooProductZoom: function(){ 2336 if( !isMobile.any() ){ 2337 if ( $('.grve-product-image.easyzoom').length ) { 2338 var $easyzoom = $('.grve-product-image.easyzoom').easyZoom(); 2339 var api = $easyzoom.data('easyZoom'); 2340 $( ".variations_form" ).on( 'woocommerce_variation_has_changed', function( event, variation ){ 2341 var imageZoom = $('.grve-product-image .woocommerce-main-image').attr('href'); 2342 2343 var $productImg = $('.grve-product-image .woocommerce-main-image img'); 2344 var productLargeImg = $productImg.attr('data-large_image'); 2345 if( productLargeImg ){ 2346 imageZoom = $productImg.attr('data-large_image'); 2347 } 2348 var imageSrc = $productImg.attr('src'); 2349 api.swap( imageSrc , imageZoom ); 2350 } ); 2351 } 2352 } 2353 }, 2354 animAppear: function(){ 2355 if( bodyLoader === true ){ 2356 return; 2357 } 2358 if(isMobile.any()) { 2359 $('.grve-animated-item').css('opacity',1); 2360 } else { 2361 $('.grve-animated-item').each(function() { 2362 var timeDelay = $(this).attr('data-delay'); 2363 $(this).appear(function() { 2364 var $that = $(this); 2365 setTimeout(function () { 2366 $that.addClass('grve-animated'); 2367 }, timeDelay); 2368 },{accX: 0, accY: -150}); 2369 }); 2370 } 2371 }, 2372 vcAccordion: function(){ 2373 var $target = $('.vc_tta-accordion').find('a[data-vc-accordion]'), 2374 $panel = $('.vc_tta-panel'); 2375 if( $panel.find('.grve-isotope').length ) { 2376 setTimeout(function(){ 2377 GRVE.isotope.init(); 2378 },100); 2379 } 2380 $target.on('click',function(){ 2381 if( $panel.find('.grve-isotope').length ) { 2382 setTimeout(function(){ 2383 GRVE.isotope.init(); 2384 },100); 2385 } 2386 if( $panel.find('.grve-image-text').length ) { 2387 GRVE.basicElements.imageText(); 2388 } 2389 }); 2390 }, 2391 vcTab: function(){ 2392 var $target = $('.vc_tta-tabs').find('a[data-vc-tabs]'), 2393 $panel = $('.vc_tta-panel'); 2394 if( $panel.find('.grve-isotope').length ) { 2395 setTimeout(function(){ 2396 GRVE.isotope.init(); 2397 },100); 2398 } 2399 $target.on('click',function(){ 2400 if( $panel.find('.grve-isotope').length ) { 2401 setTimeout(function(){ 2402 GRVE.isotope.init(); 2403 },100); 2404 } 2405 if( $panel.find('.grve-image-text').length ) { 2406 GRVE.basicElements.imageText(); 2407 } 2408 }); 2409 }, 2410 vcResponsiveTab: function(){ 2411 var $target = $('.vc_tta-tabs').find('a[data-vc-accordion]'), 2412 $panel = $('.vc_tta-panel'); 2413 if( $panel.find('.grve-isotope').length ) { 2414 setTimeout(function(){ 2415 GRVE.isotope.init(); 2416 },100); 2417 } 2418 $target.on('click',function(){ 2419 if( $panel.find('.grve-isotope').length ) { 2420 setTimeout(function(){ 2421 GRVE.isotope.init(); 2422 },100); 2423 } 2424 if( $panel.find('.grve-image-text').length ) { 2425 GRVE.basicElements.imageText(); 2426 } 2427 }); 2428 }, 2429 productSocials: function(){ 2430 var $socials = $('.grve-product-social'), 2431 $item = $socials.find('li'); 2432 if( !$socials.length ) return; 2433 2434 $socials.appear(function() { 2435 $item.each(function(i,n){ 2436 var $this = $(this); 2437 setTimeout(function(){ 2438 $this.addClass('grve-animated'); 2439 },150 * i); 2440 }); 2441 },{accX: 0, accY: -50}); 2442 }, 2443 countdown: function(){ 2444 $('.grve-countdown').each(function() { 2445 var $this = $(this), 2446 finalDate = $this.data('countdown'), 2447 numbersSize = $this.data('numbers-size'), 2448 textSize = $this.data('text-size'), 2449 numbersColor = $this.data('numbers-color'), 2450 textColor = $this.data('text-color'), 2451 countdownItems = '', 2452 text = '', 2453 countdownFormat = $this.data('countdown-format').split('|'); 2454 2455 $.each( countdownFormat, function( index, value ) { 2456 switch (value) { 2457 case 'w': 2458 text = grve_main_data.grve_string_weeks; 2459 break; 2460 case 'D': 2461 case 'd': 2462 case 'n': 2463 text = grve_main_data.grve_string_days; 2464 break; 2465 case 'H': 2466 text = grve_main_data.grve_string_hours; 2467 break; 2468 case 'M': 2469 text = grve_main_data.grve_string_minutes; 2470 break; 2471 case 'S': 2472 text = grve_main_data.grve_string_seconds; 2473 break; 2474 default: 2475 text = ''; 2476 } 2477 countdownItems += '<div class="grve-countdown-item">'; 2478 countdownItems += '<div class="grve-number grve-' + numbersSize + ' grve-text-' + numbersColor + '">%' + value + '</div>'; 2479 countdownItems += '<span class="grve-' + textSize + ' grve-text-' + textColor + '">
2479' + text + '</span>'; 2480 countdownItems += '</div>'; 2481 2482 }); 2483 2484 $this.countdown(finalDate, function(event) { 2485 $this = $(this).html(event.strftime( countdownItems )); 2486 }); 2487 }); 2488 } 2489 }; 2490 2491 // # Parallax Section 2492 // ============================================================================= // 2493 GRVE.parallaxSection = { 2494 2495 init: function( section ){ 2496 2497 var $section = $( section ), 2498 sectionLenght = $section.length; 2499 2500 function update(){ 2501 var windowScroll = $(window).scrollTop(), 2502 windowHeight = $(window).height(); 2503 2504 for( var i = 0; i < sectionLenght; i ++ ){ 2505 2506 var element = $section[i], 2507 $parallaxEl = $(element).find('.grve-bg-image'), 2508 sectionHeight = $(element).outerHeight(), 2509 sectionWidth = $(element).outerWidth(), 2510 threshold = $(element).data('parallax-sensor'), 2511 elementHeight = sectionHeight + threshold, 2512 elementWidth = sectionWidth + threshold, 2513 sectionTop = $(element).offset().top, 2514 speed = ( windowHeight + sectionHeight ) / ( elementHeight - sectionHeight ), 2515 transform, 2516 translate = 0; 2517 2518 if( $(element).hasClass('grve-horizontal-parallax-lr') || $(element).hasClass('grve-horizontal-parallax-rl') ){ 2519 speed = ( windowHeight + sectionHeight ) / ( elementWidth - sectionWidth ); 2520 } 2521 2522 if( sectionTop - windowScroll <= windowHeight && sectionTop - windowScroll + windowHeight >= windowHeight - sectionHeight ) { 2523 translate = ( windowScroll + windowHeight - sectionTop )/speed; 2524 } else { 2525 translate = 0; 2526 } 2527 2528 if( $(element).hasClass('grve-horizontal-parallax-lr') || $(element).hasClass('grve-horizontal-parallax-rl') ){ 2529 if( $(element).hasClass('grve-horizontal-parallax-lr')) { 2530 transform = 'translateX(' + - translate + 'px)'; 2531 } 2532 if( $(element).hasClass('grve-horizontal-parallax-rl')) { 2533 transform = 'translateX(' + -(threshold - translate) + 'px)'; 2534 } 2535 2536 $parallaxEl.css({'width' : elementWidth}); 2537 } else { 2538 transform = 'translateY(' + - translate + 'px)'; 2539 $parallaxEl.css({'height' : elementHeight}); 2540 } 2541 2542 2543 $parallaxEl.css({ 2544 '-webkit-transform' : transform, 2545 '-moz-transform' : transform, 2546 '-ms-transform' : transform, 2547 '-o-transform' : transform, 2548 'transform' : transform 2549 }); 2550 2551 } 2552 } 2553 2554 update(); 2555 $(window).on('scroll', function(){ 2556 update(); 2557 }); 2558 2559 if( isMobile.any() ) { 2560 $(window).on("orientationchange",function(){ 2561 update(); 2562 }); 2563 } else { 2564 $(window).smartresize(function(){ 2565 update(); 2566 }); 2567 } 2568 } 2569 }; 2570 2571 GRVE.parallaxSectionOld = { 2572 init: function(){ 2573 var $selector = $('.grve-section.grve-bg-parallax'), 2574 windowHeight = $(window).height(), 2575 scrollTop = $(window).scrollTop(); 2576 2577 $selector.each(function(){ 2578 var $that = $(this), 2579 elTop = $that.offset().top, 2580 elHeight = $that.outerHeight(), 2581 bgSize = Math.ceil( windowHeight * 0.4 ) + elHeight, 2582 posY = ( scrollTop - ( elTop - windowHeight ) ) / ( ( elTop + elHeight ) - ( elTop - windowHeight ) ), 2583 translate = posY * ( elHeight - bgSize ); 2584 2585 if ( elTop + elHeight < scrollTop || elTop > scrollTop + windowHeight ) { 2586 return; 2587 } 2588 $that.find('.grve-bg-image').css({ 'transform': 'translate3d(0, ' + translate + 'px, 0)' , 'height': bgSize }); 2589 2590 }); 2591 } 2592 }; 2593 2594 // # Set Equal Columns Height 2595 // ============================================================================= // 2596 GRVE.setColumnHeight = { 2597 init: function(){ 2598 var section = '.grve-section', 2599 windowWidth = $(window).width() + scrollBarWidth; 2600 2601 $(section).each(function(){ 2602 var $that = $(this), 2603 $column = $that.hasClass('grve-column-has-gap') ? $that.find('.grve-row').first().children().find('.grve-column-wrapper') : $that.find('.grve-row').first().children(); 2604 2605 if( $that.hasClass('grve-equal-column') ) { 2606 equalHeight( $that, $column, fullHeight ); 2607 } else if( $that.hasClass('grve-middle-content') ) { 2608 middleContent( $that, $column, fullHeight ); 2609 } else if( $that.hasClass('grve-fullheight') ) { 2610 fullHeight( $that ); 2611 } else { 2612 return; 2613 } 2614 }); 2615 2616 function equalHeight( section, $column, callback ) { 2617 section.imagesLoaded('always',function(){ 2618 $column.css({ 'min-height': '', 'padding-top': '', 'padding-bottom': '' }); 2619 var maxHeight = GRVE.setColumnHeight.getMaxHeight( section ); 2620 var limit = section.data('tablet-portrait-equal-columns') != undefined ? mobileScreen : tabletPortrait; 2621 if( ( windowWidth <= tabletLandscape && $column.hasClass('grve-tablet-column-1') ) || windowWidth <= limit ) { 2622 $column.css({ 'min-height': '' }); 2623 section.removeClass('grve-prepare-custom-height'); 2624 } else { 2625 $column.css({ 'min-height': maxHeight }); 2626 section.removeClass('grve-prepare-custom-height'); 2627 } 2628 2629 if( section.hasClass('grve-fullheight') ) { 2630 callback( section ); 2631 } 2632 }); 2633 } 2634 2635 function middleContent( section, $column, callback ) { 2636 section.imagesLoaded('always',function(){ 2637 $column.css({ 'min-height': '', 'padding-top': '', 'padding-bottom': '' }); 2638 var maxHeight = GRVE.setColumnHeight.getMaxHeight( section ); 2639 var limit = section.data('tablet-portrait-equal-columns') != undefined ? mobileScreen : tabletPortrait; 2640 if( ( windowWidth <= tabletLandscape && $column.hasClass('grve-tablet-column-1') ) || windowWidth <= limit ) { 2641 $column.css({ 'padding-top': '', 'padding-bottom': '', 'min-height': '' }); 2642 section.removeClass('grve-prepare-custom-height'); 2643 } else { 2644 $column.each(function(){ 2645 var columnHeigth = $(this).outerHeight(); 2646 if( columnHeigth <= maxHeight ) { 2647 var space = ( maxHeight - columnHeigth ) / 2; 2648 $(this).css({ 'padding-top' : space, 'padding-bottom' : space }); 2649 } 2650 }); 2651 section.removeClass('grve-prepare-custom-height'); 2652 } 2653 2654 if( section.hasClass('grve-fullheight') ) { 2655 callback( section ); 2656 } 2657 }); 2658 } 2659 2660 function fullHeight( section ) { 2661 section.imagesLoaded('always',function(){ 2662 $(section).css({ 'min-height': '', 'padding-top': '', 'padding-bottom': '' }); 2663 var windowHeight = $(window).height(), 2664 $container = section.find('.grve-container'), 2665 sectionHeight = GRVE.setColumnHeight.getMaxHeight( $container ), 2666 headerHeight = $('#grve-header').data('sticky') == 'none' ? $('#grve-main-header').outerHeight() : 0, 2667 topBarHeight = $('#grve-top-bar').length ? $('#grve-top-bar').outerHeight() : 0, 2668 anchorBarHeight = $('.grve-anchor-menu').length ? $('.grve-anchor-menu').outerHeight() : 0, 2669 offset = ( headerHeight + topBarHeight + anchorBarHeight + sectionHeight ), 2670 space = ( windowHeight - offset )/2; 2671 2672 if(sectionHeight > ( windowHeight - headerHeight )){ 2673 section.css({'padding-top':40, 'padding-bottom': 40}); 2674 section.removeClass('grve-prepare-custom-height'); 2675 } else { 2676 section.css({ 'padding-top':space, 'padding-bottom': space}); 2677 section.removeClass('grve-prepare-custom-height'); 2678 } 2679 // Resize Video 2680 if( $(section).find('.grve-bg-video').length ) { 2681 GRVE.resizeVideo.init( $(section).find('.grve-background-wrapper') ); 2682 } 2683 }); 2684 } 2685 2686 }, 2687 getMaxHeight: function( section ){ 2688 var $that = section, 2689 sectionHeight = $that.height(), 2690 maxHeight = sectionHeight; 2691 2692 return maxHeight; 2693 } 2694 }; 2695 2696 // # Section Settings 2697 // ============================================================================= // 2698 GRVE.sectionSettings = { 2699 init: function(){ 2700 2701 if( !$('#grve-sidebar').length ) return; 2702 2703 var section = '#grve-content .grve-section', 2704 windowWidth = $(window).width(), 2705 themeWidth = $('#grve-theme-wrapper').width(),
2706 wrapperWidth = $('.grve-content-wrapper').width(), 2707 contentWidth = $('#grve-main-content').width(), 2708 sidebarWidth = $('#grve-sidebar').outerWidth(), 2709 space = (themeWidth - wrapperWidth)/2, 2710 sidebarSpace = space + wrapperWidth - contentWidth; 2711 2712 2713 $(section).each(function(){ 2714 var $section = $(this); 2715 if( $section.hasClass('grve-fullwidth-background') ){ 2716 fullBg($section); 2717 } 2718 if( $section.hasClass('grve-fullwidth') ){ 2719 fullElement($section); 2720 } 2721 2722 }); 2723 2724 function fullBg( section ) { 2725 if( windowWidth + scrollBarWidth >= tabletPortrait ) { 2726 if( $('.grve-right-sidebar').length ) { 2727 section.css({ 'visibility': 'visible', 'padding-left':space, 'padding-right': sidebarSpace, 'margin-left': -space, 'margin-right': -sidebarSpace}); 2728 } 2729 else { 2730 section.css({ 'visibility': 'visible', 'padding-left':sidebarSpace, 'padding-right': space, 'margin-left': -sidebarSpace, 'margin-right': -space}); 2731 } 2732 } else { 2733 section.css({ 'visibility': 'visible', 'padding-left':'', 'padding-right': '', 'margin-left': '', 'margin-right': ''}); 2734 } 2735 2736 } 2737 2738 function fullElement( section ) { 2739 if( windowWidth + scrollBarWidth >= tabletPortrait ) { 2740 if( $('.grve-right-sidebar').length ) { 2741 section.css({ 'visibility': 'visible', 'padding-left':0, 'padding-right': sidebarSpace, 'margin-left': -space, 'margin-right': -sidebarSpace}); 2742 } 2743 else { 2744 section.css({ 'visibility': 'visible', 'padding-left':sidebarSpace, 'padding-right': 0, 'margin-left': -sidebarSpace, 'margin-right': -space}); 2745 } 2746 } else { 2747 section.css({ 'visibility': 'visible', 'padding-left':'', 'padding-right': '', 'margin-left': '', 'margin-right': ''}); 2748 } 2749 } 2750 } 2751 }; 2752 2753 // # Isotope 2754 // ============================================================================= // 2755 GRVE.isotope = { 2756 2757 init: function(){ 2758 var $selector = $('.grve-isotope'); 2759 $selector.each(function(){ 2760 var $this = $(this), 2761 $container = $this.find('.grve-isotope-container'), 2762 $curCategory = $this.find('.grve-current-category'), 2763 dataSpinner = $this.data('spinner'); 2764 2765 // Set Item Size 2766 itemSize( $this, $container, initIsotope ); 2767 // Filters 2768 filter( $this, $container ); 2769 // Add Spinner 2770 if( dataSpinner == 'yes' ) { 2771 addSpinner( $this ); 2772 } 2773 2774 }); 2775 2776 function filter( $this, $container ){ 2777 $this.find('.grve-filter li').on('click', function() { 2778 var $filter = $(this), 2779 selector = $filter.attr('data-filter'), 2780 title = $filter.html(), 2781 $curCategory = $this.find('.grve-current-category'); 2782 2783 if( $curCategory.length > 0 ){ 2784 $curCategory.find('span').html( title ); 2785 } 2786 2787 $container.isotope({ 2788 filter: selector 2789 }); 2790 2791 // Go tot top 2792 filterGoToTop( $filter ); 2793 2794 $(this).addClass('selected').siblings().removeClass('selected'); 2795 }); 2796 } 2797 2798 function filterGoToTop( filter ){ 2799 var $this = filter, 2800 filterTop = $this.parent().offset().top, 2801 header = $('#grve-header').length && $('#grve-main-header').is(":visible") ? true : false, 2802 responsiveHeader = $('#grve-responsive-header').length && $('#grve-responsive-header').is(":visible") ? true : false, 2803 headerHeight = header && $('#grve-header').data('sticky') != 'none' ? $('#grve-main-header').outerHeight() : 0, 2804 respHeaderH = responsiveHeader && $('#grve-header').data('devices-sticky') == 'yes' ? $('#grve-responsive-header').outerHeight() : 0, 2805 topBarHeight = $('#grve-top-bar').length ? $('#grve-top-bar').height() : 0, 2806 offset = topBarHeight + wpBarHeight + headerHeight + respHeaderH + 50; 2807 2808 if( filterTop > 0 ){ 2809 var page = $('html,body'); 2810 page.delay(300).animate({ 2811 scrollTop: filterTop - offset 2812 }, 600); 2813 page.bind("scroll mousedown DOMMouseScroll mousewheel keyup", function(e){ 2814 if ( e.which > 0 || e.type === "mousedown" || e.type === "mousewheel"){ 2815 page.stop().unbind('scroll mousedown DOMMouseScroll mousewheel keyup'); 2816 } 2817 }); 2818 2819 return false;
2820 } 2821 } 2822 2823 function column( el ){ 2824 var windowWidth = $(window).width() + scrollBarWidth, 2825 $element = el, 2826 columns = { 2827 desktop : $element.data('columns'), 2828 tabletL : $element.data('columns-tablet-landscape'), 2829 tabletP : $element.data('columns-tablet-portrait'), 2830 mobile : $element.data('columns-mobile') 2831 }; 2832 2833 if ( windowWidth > tabletLandscape ) { 2834 columns = columns.desktop; 2835 } else if ( windowWidth > tabletPortrait && windowWidth <= tabletLandscape ) { 2836 columns = columns.tabletL; 2837 } else if ( windowWidth > mobileScreen && windowWidth <= tabletPortrait ) { 2838 columns = columns.tabletP; 2839 } else { 2840 columns = columns.mobile; 2841 } 2842 return columns; 2843 } 2844 2845 function itemSize( el, $container, callback ){ 2846 var wrapperW = el.innerWidth(), 2847 gap = el.hasClass('grve-with-gap') && !isNaN( el.data('gutter-size') ) ? Math.abs( el.data('gutter-size') )/2 : 0, 2848 $isotopItem = $container.find('.grve-isotope-item'), 2849 $slider = $isotopItem.find('.grve-slider'); 2850 2851 var columns = column( el ), 2852 offset = el.parents('.grve-section').hasClass('grve-fullwidth') ? -(gap * 2) : gap * 2, 2853 columnW = ( wrapperW + offset ) / columns; 2854 2855 columnW = (columnW % 1 !== 0) ? Math.ceil(columnW) : columnW; 2856 var containerW = columnW * columns; 2857 2858 $container.css({'margin-left' : - gap, 'margin-right' : - gap, 'width' : containerW }); 2859 $isotopItem.css({ 'padding-left' : gap, 'padding-right' : gap, 'margin-bottom' : gap*2, 'width' : columnW }); 2860 2861 if( el.hasClass('grve-with-gap') && $container.parents('.grve-section').hasClass('grve-fullwidth') ) { 2862 el.css({'padding-left' : gap*2, 'padding-right' : gap*2 }); 2863 } 2864 2865 // Item Width * 2 2866 if( columns != 1 ) { 2867 $container.find('.grve-image-large-square').css({ 'width': columnW * 2 }); 2868 $container.find('.grve-image-landscape').css({ 'width': columnW * 2 }).find('.grve-media').css({ 'height': columnW - ( gap * 2 ) }); 2869 $container.find('.grve-image-portrait').css({ 'width': columnW }).find('.grve-media').css({ 'height': ( columnW * 2 ) - ( gap * 2 ) }); 2870 } 2871 2872 // Item Column 2 2873 if( columns == 2 ) { 2874 $container.find('.grve-image-large-square').css({ 'width': columnW * 2 }); 2875 $container.find('.grve-image-landscape').css({ 'width': columnW }).find('.grve-media').css({ 'height': ( columnW / 2 ) - ( gap * 2 ) }); 2876 $container.find('.grve-image-portrait').css({ 'width': columnW }).find('.grve-media').css({ 'height': ( columnW * 2 ) - ( gap * 2 ) }); 2877 } 2878 2879 // Item Column 1 2880 if( columns == 1 ) { 2881 $container.find('.grve-image-large-square').css({ 'width': columnW }); 2882 $container.find('.grve-image-landscape').css({ 'width': columnW }).find('.grve-media').css({ 'height': columnW }); 2883 $container.find('.grve-image-portrait').css({ 'width': columnW }).find('.grve-media').css({ 'height': columnW }); 2884 } 2885 2886 if(callback) callback( el, $container ); 2887 2888 } 2889 2890 function initIsotope( el, $container ){ 2891 var layout = el.data('layout') !== '' ? el.data('layout') : 'fitRows', 2892 isOriginLeft = $('body').hasClass('rtl') ? false : true, 2893 $slider = el.find('.grve-slider'); 2894 2895 $container.imagesLoaded( function() { 2896 $container.isotope({ 2897 resizable: true, 2898 itemSelector: '.grve-isotope-item', 2899 layoutMode: layout, 2900 isOriginLeft: isOriginLeft, 2901 animationEngine : 'jquery' 2902 }); 2903 relayout($container); 2904 2905 // Spinner 2906 var dataSpinner = $container.parent().data('spinner'); 2907 if( dataSpinner == 'yes' ) { 2908 setTimeout(function() { 2909 removeSpinner( $container ); 2910 },2000); 2911 } else { 2912 $container.css({'opacity': 1}); 2913 // Isotope Animation 2914 if( !isMobile.any() ){ 2915 animation($container); 2916 } else { 2917 $container.find('.grve-isotope-item-inner').addClass('grve-animated'); 2918 } 2919 } 2920 2921 // Init Slider Again 2922 $slider.each(function(){ 2923 var $that = $(this), 2924 owlSlider = $that.data('owlCarousel'); 2925 owlSlider.reinit(); 2926 }); 2927 2928 if( $container.parents('.grve-section').hasClass('grve-custom-height') ) { 2929 var $section = $container.parents('.grve-section'); 2930 setTimeout( function(){ 2931 relayout($container); 2932 // Fix Columns Height
2933 GRVE.setColumnHeight.init(); 2934 }, 100 ); 2935 } 2936 2937 $(window).smartresize(function(){ 2938 itemSize( el, $container ); 2939 relayout($container); 2940 }); 2941 2942 // Auto Headings Resize 2943 if( layout == 'masonry' && el.hasClass('grve-auto-headings') ){ 2944 GRVE.autoHeadingSize.init( '.grve-auto-headings' , '.grve-isotope-item', '.grve-title', '.grve-caption' ); 2945 } 2946 2947 }); 2948 } 2949 2950 function relayout($container){ 2951 $container.isotope('layout'); 2952 } 2953 2954 function animation($container){ 2955 var cnt = 1, 2956 itemAppeared = 1; 2957 $container.find('.grve-isotope-item').appear(function() { 2958 var $this = $(this), 2959 delay = 200 * cnt++; 2960 2961 setTimeout(function () { 2962 itemAppeared++; 2963 if( itemAppeared == cnt ){ 2964 cnt = 1; 2965 } 2966 $this.find('.grve-isotope-item-inner').addClass('grve-animated'); 2967 }, delay); 2968 }); 2969 } 2970 2971 function addSpinner(el){ 2972 var $spinner = $('<div class="grve-spinner"></div>'); 2973 $spinner.appendTo( el ); 2974 } 2975 2976 function removeSpinner($container){ 2977 $container.parent().find('.grve-spinner').fadeOut(600,function(){ 2978 $container.css({'opacity': 1}); 2979 animation($container); 2980 }); 2981 } 2982 2983 }, 2984 noIsoFilters: function() { 2985 var $selector = $('.grve-non-isotope'); 2986 $selector.each(function(){ 2987 var $that = $(this); 2988 $that.find('.grve-filter li').on('click', function() { 2989 var selector = $(this).attr('data-filter'); 2990 if ( '*' == selector ) { 2991 $that.find('.grve-non-isotope-item').fadeIn('1000'); 2992 } else { 2993 $that.find('.grve-non-isotope-item').hide(); 2994 $that.find(selector).fadeIn('1000'); 2995 } 2996 $(this).addClass('selected').siblings().removeClass('selected'); 2997 }); 2998 }); 2999 } 3000 }; 3001 3002 // # Portfolio Auto Resize Headings 3003 // ============================================================================= // 3004 GRVE.autoHeadingSize = { 3005 init : function( container, item, title, caption ){ 3006 var $item = $(container).find( item ), 3007 $heading = $(container).find( title ), 3008 headingSize = parseInt( $heading.css('font-size') ), 3009 compressor = 20, 3010 itemLength = $item.length; 3011 3012 updateParam(); 3013 $(window).smartresize(function(){ 3014 resetSize( updateParam ); 3015 }); 3016 3017 function updateParam(){ 3018 for( var i=0; i < itemLength; i++){ 3019 var el = $item[i], 3020 elSize = $(el).width(); 3021 $(el).find(title).css({ 'font-size': elSize / compressor + 'px', 'line-height' : '1.2' }); 3022 $(el).find(caption).css({ 'font-size': Math.max(Math.min( (elSize / compressor)*0.4, elSize), 13 ) + 'px', 'line-height' : '1.2' }); 3023 } 3024 } 3025 3026 function resetSize(callback){ 3027 $heading.attr('style', ''); 3028 callback(); 3029 } 3030 3031 } 3032 }; 3033 3034 // # Social Bar For Post 3035 // ============================================================================= // 3036 GRVE.socialBar = { 3037 init : function(){ 3038 var $bar = $('#grve-socials-bar'); 3039 if( !$bar.length ) { 3040 return; 3041 } 3042 if( isMobile.any() ) { 3043 $bar.addClass('grve-no-animation'); 3044 return; 3045 } 3046 var posTop = $bar.offset().top, 3047 scroll = $(window).scrollTop(), 3048 windowHeight = $(window).height(), 3049 offset = ( $bar.offset().top - windowHeight ) + 50; 3050 3051 if( scroll > offset ) { 3052 this.showSocials(); 3053 } else { 3054 this.hideSocials(); 3055 } 3056 }, 3057 showSocials : function(){ 3058 var $item = $('#grve-socials-bar').find('ul.grve-socials li a'), 3059 i = 0; 3060 $item.each(function(){ 3061 var $that = $(this); 3062 i++; 3063 setTimeout(function () { 3064 $that.addClass('show'); 3065 }, i * 200 ); 3066 }); 3067 }, 3068 hideSocials : function(){ 3069 var $item = $('#grve-socials-bar').find('ul.grve-socials li a'); 3070 $item.removeClass('show'); 3071 } 3072 }; 3073 3074 // # Related Post 3075 // ============================================================================= // 3076 GRVE.relatedPost = { 3077 3078 item : '.grve-related-item', 3079 quota : 0.5, 3080 3081 init: function(){ 3082 3083 var item = GRVE.relatedPost.item, 3084 quota = GRVE.relatedPost.quota, 3085 $itemParent = $(item).parent(), 3086 itemsLength = $(item).length; 3087 3088 if( itemsLength == 1 ){ 3089 $itemParent.addClass('grve-related-column-1'); 3090 return; 3091 } 3092 if( itemsLength == 2 ){ 3093 $itemParent.addClass('grve-related-column-2'); 3094 quota = 0.7; 3095 } 3096 function hoverEffect(){ 3097 $(item).on('mouseenter', function() { 3098 var $that = $(this), 3099 parentWidth = $itemParent.width(), 3100 newWidth = parseInt(( parentWidth * quota ),10), 3101 otherWidth = parseInt((( parentWidth - newWidth ) / ( itemsLength - 1) ),10); 3102 $that.stop(true).animate({ width: newWidth }, 300 ); 3103 $itemParent.children().not(this).stop(true).animate({ width: otherWidth }, 300 ); 3104 }); 3105 $(item).on('mouseleave', function() { 3106 if( $(window).width() + scrollBarWidth < tabletPortrait || isMobile.any() ) return; 3107 var $that = $(this); 3108 $that.parent().children().stop(true).animate({ width: $(this).data('standardWidth') }, 300 ); 3109 }); 3110 } 3111 3112 hoverEffect(); 3113 3114 GRVE.relatedPost.itemWidth(); 3115 }, 3116 itemWidth: function(){ 3117 var item = GRVE.relatedPost.item; 3118 $(item).each(function() { 3119 $(this).css( 'width', '' ).data('standardWidth', $(this).width()); 3120 }); 3121 } 3122 }; 3123 3124 // # Scroll Direction 3125 // ============================================================================= // 3126 GRVE.scrollDir = { 3127 init: function(){ 3128 var scroll = $(window).scrollTop(); 3129 if (scroll > lastScrollTop){ 3130 lastScrollTop = scroll; 3131 return { direction : 'scrollDown' }; 3132 } else { 3133 lastScrollTop = scroll; 3134 return { direction : 'scrollUp' }; 3135 } 3136 3137 lastScrollTop = scroll; 3138 } 3139 }; 3140 3141 // # Full Page 3142 // ============================================================================= // 3143 GRVE.fullPage = { 3144 init: function(){ 3145 var $fPage = $('#grve-fullpage'); 3146 if( !$fPage.length ) return; 3147 var $section = $fPage.find('.grve-section'); 3148 var deviceNavigation = true; 3149 var deviceAutoScrolling = true; 3150 var fitToSection = true; 3151 var speed = $fPage.data('scroll-speed'); 3152 var deviceFullPageEnable = $fPage.data('device-scrolling') == 'yes' ? true : false;
3153 var lockAnchors = $fPage.data('lock-anchors') == 'yes' ? true : false; 3154 var loop = $fPage.data('scroll-loop'); 3155 var loopTop = false; 3156 var loopBottom = false; 3157 if ( 'both' == loop || 'top' == loop ) { 3158 loopTop = true; 3159 } 3160 if ( 'both' == loop || 'bottom' == loop ) { 3161 loopBottom = true; 3162 } 3163 3164 if( isMobile.any() && !deviceFullPageEnable ) { 3165 deviceNavigation = false; 3166 deviceAutoScrolling = false; 3167 fitToSection = false; 3168 $section.find('.grve-animated-item').addClass('grve-animated'); 3169 } 3170 3171 var navigationAnchorTooltips = $('[data-anchor-tooltip]').map(function(){ 3172 return $(this).data('anchor-tooltip').toString(); 3173 }).get(); 3174 3175 $fPage.fullpage({ 3176 navigation: deviceNavigation, 3177 navigationPosition: 'right', 3178 navigationTooltips: navigationAnchorTooltips, 3179 sectionSelector: $section, 3180 css3: true, 3181 scrollingSpeed: speed, 3182 autoScrolling : deviceAutoScrolling, 3183 fitToSection : fitToSection, 3184 lockAnchors : lockAnchors, 3185 loopTop : loopTop, 3186 loopBottom : loopBottom, 3187 afterLoad: function(anchorLink, index){ 3188 3189 var sectionHeaderColor = $($section[index-1]).attr('data-header-color'); 3190 var color = 'grve-' + sectionHeaderColor; 3191 3192 $section.find('.fp-tableCell').css('visibility','visible'); 3193 3194 // Set Header Color 3195 if( !$('#grve-main-header').hasClass('grve-header-side') ) { 3196 $('#grve-main-header').removeClass('grve-light grve-dark').addClass(color); 3197 } 3198 $('#fp-nav').removeClass('grve-light grve-dark').addClass(color); 3199 3200 if( !isMobile.any() ) { 3201 GRVE.scrollingPageAnimations.addAnim( $section, index ); 3202 } 3203 }, 3204 afterRender: function(){ 3205 var $videoBg = $('.grve-bg-video'); 3206 3207 $videoBg.each(function(){ 3208 var $that = $(this), 3209 $video = $that.find('video'); 3210 $video[0].play(); 3211 GRVE.resizeVideo.init( $(this) ); 3212 }); 3213 3214 }, 3215 onLeave: function(index){ 3216 if( !isMobile.any() ) { 3217 GRVE.scrollingPageAnimations.removeAnim( $section, index, speed ); 3218 } 3219 } 3220 }); 3221 } 3222 }; 3223 3224 // # Pilling Page 3225 // ============================================================================= // 3226 GRVE.pillingPage = { 3227 init: function(){ 3228 var $fPage = $('#grve-pilling-page'); 3229 if( !$fPage.length ) return; 3230 var $section = $fPage.find('.grve-section'); 3231 var deviceFullPageEnable = $fPage.data('device-scrolling') == 'yes' ? true : false; 3232 var lockAnchors = $fPage.data('lock-anchors') == 'yes' ? true : false; 3233 var direction = $fPage.data('scroll-direction'); 3234 var loop = $fPage.data('scroll-loop'); 3235 var speed = $fPage.data('scroll-speed'); 3236 var loopTop = false; 3237 var loopBottom = false; 3238 if ( 'both' == loop || 'top' == loop ) { 3239 loopTop = true; 3240 } 3241 if ( 'both' == loop || 'bottom' == loop ) { 3242 loopBottom = true; 3243 } 3244 3245 if( isMobile.any() && !deviceFullPageEnable ) { 3246 $fPage.addClass('grve-disable-on-device'); 3247 $section.find('.grve-animated-item').addClass('grve-animated'); 3248 $section.children().wrap('<div class="pp-tableCell"></div>'); 3249 $('.grve-section').each(function(){ 3250 if ( $(this).attr('data-anchor').length ) { 3251 $(this).attr('id', $(this).attr('data-anchor') ); 3252 } 3253 }); 3254 return; 3255 } 3256 3257 var navigationAnchorTooltips = $('[data-anchor-tooltip]').map(function(){ 3258 return $(this).data('anchor-tooltip').toString(); 3259 }).get(); 3260 3261 3262 var navigationAnchors = []; 3263 if ( !lockAnchors ) { 3264 navigationAnchors = $('[data-anchor]').map(function(){ 3265 return $(this).data('anchor').toString(); 3266 }).get(); 3267 } 3268 3269 $('html').addClass('fp-enabled'); 3270 3271 $fPage.pagepiling({ 3272 sectionSelector: $section, 3273 css3: true, 3274 scrollingSpeed: speed, 3275 anchors: navigationAnchors, 3276 direction: direction, 3277 lockAnchors : lockAnchors, 3278 loopTop : loopTop, 3279 loopBottom : loopBottom, 3280 navigation: { 3281 'tooltips': navigationAnchorTooltips 3282 }, 3283 afterLoad: function(anchorLink, index){ 3284 3285 var sectionHeaderColor = $($section[index-1]).attr('data-header-color'); 3286 var color = 'grve-' + sectionHeaderColor; 3287 // Set Header Color 3288 if( !$('#grve-main-header').hasClass('grve-header-side') ) { 3289 $('#grve-main-header').removeClass('grve-light grve-dark').addClass(color); 3290 } 3291 $('#pp-nav').removeClass('grve-light grve-dark').addClass(color); 3292 3293 if( !isMobile.any() ) { 3294 GRVE.scrollingPageAnimations.addAnim( $section, index ); 3295 } 3296 }, 3297 afterRender: function(){ 3298 var sectionHeaderColor = $($section[0]).attr('data-header-color'); 3299 var color = 'grve-' + sectionHeaderColor; 3300 var $videoBg = $('.grve-bg-video'); 3301 3302 $videoBg.each(function(){ 3303 var $that = $(this), 3304 $video = $that.find('video'); 3305 $video[0].play(); 3306 GRVE.resizeVideo.init( $(this) ); 3307 }); 3308 // Set Header Color 3309 if( !$('#grve-main-header').hasClass('grve-header-side') ) { 3310 $('#grve-main-header').removeClass('grve-light grve-dark').addClass(color); 3311 } 3312 $('#pp-nav').removeClass('grve-light grve-dark').addClass(color); 3313 if( !isMobile.any() ) { 3314 GRVE.scrollingPageAnimations.addAnim( $section, 1 ); 3315 } 3316 }, 3317 onLeave: function(index){ 3318 GRVE.scrollingPageAnimations.removeAnim( $section, index, speed ); 3319 } 3320 }); 3321 } 3322 }; 3323 3324 // # Scrolling Page Animations 3325 // ============================================================================= // 3326 GRVE.scrollingPageAnimations = { 3327 addAnim: function( section, index ){ 3328 var $section = $(section[index-1]), 3329 $element = $section.find('.grve-animated-item'); 3330 3331 $element.each(function(){ 3332 var $that = $(this),
3333 delay = $that.data('delay'); 3334 setTimeout(function(){ 3335 $that.addClass('grve-animated'); 3336 },delay); 3337 }); 3338 }, 3339 removeAnim: function(section, index, speed){ 3340 var $section = $(section[index-1]), 3341 $element = $section.find('.grve-animated-item'); 3342 setTimeout(function(){ 3343 $element.removeClass('grve-animated'); 3344 },speed); 3345 } 3346 }; 3347 3348 // # Woocommerce Product Rating 3349 // ============================================================================= // 3350 GRVE.wooProductRating = { 3351 init : function(){ 3352 if ( typeof wc_single_product_params !== 'undefined' ) { 3353 var $rating = $( '.woocommerce-Reviews #respond' ).find( '#rating' ); 3354 if ( $rating.length > 0 && wc_single_product_params.review_rating_required === 'no' ) { 3355 $('.woocommerce-Reviews #respond #rating').removeAttr('required'); 3356 } 3357 } 3358 } 3359 }; 3360 3361 3362 // # Global Variables 3363 // ============================================================================= // 3364 var bodyLoader = false; 3365 var largeScreen = 2048; 3366 var tabletLandscape = 1200; 3367 var tabletPortrait = 1023; 3368 var mobileScreen = 767; 3369 var lastScrollTop = 0; 3370 var wpBarHeight = $('#grve-body').hasClass('admin-bar') ? 32 : 0; 3371 var isMobile = { 3372 Android: function() { 3373 return navigator.userAgent.match(/Android/i); 3374 }, 3375 BlackBerry: function() { 3376 return navigator.userAgent.match(/BlackBerry/i); 3377 }, 3378 iOS: function() { 3379 return navigator.userAgent.match(/iPhone|iPad|iPod/i); 3380 }, 3381 Opera: function() { 3382 return navigator.userAgent.match(/Opera Mini/i); 3383 }, 3384 Windows: function() { 3385 return navigator.userAgent.match(/IEMobile/i); 3386 }, 3387 any: function() { 3388 return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); 3389 } 3390 }; 3391 3392 // # Scrollbar Width 3393 // ============================================================================= // 3394 var parent, child, scrollBarWidth; 3395 3396 if( scrollBarWidth === undefined ) { 3397 parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body'); 3398 child = parent.children(); 3399 scrollBarWidth = child.innerWidth()-child.height(99).innerWidth(); 3400 parent.remove(); 3401 } 3402 3403 3404 3405 $(document).ready(function(){ GRVE.documentReady.init(); }); 3406 $(window).smartresize(function(){ GRVE.documentResize.init(); }); 3407 $(window).on('load',function () { GRVE.documentLoad.init(); }); 3408 $(window).on('scroll', function() { GRVE.documentScroll.init(); }); 3409 3410})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.