1/* 2 * Frontend JS 3 * 4 * @package Bravada 5 */ 6 7jQuery( document ).ready( function() { 8 cryoutLpBoxesRatios(); 9 cryoutMobileMenuInit(); 10 cryoutFixedMobileMenu(); 11 cryoutInitNav( '#mobile-menu' ); 12 cryoutMenuAnimate(); 13 cryoutBackToTop(); 14 cryoutSearchFormAnimation(); 15 cryoutSocialTitles(); 16 cryoutBodyClasses(); 17 cryoutTabsWidget(); 18 cryoutPortfolioFilter(); 19 cryoutHeaderParallax(); 20 cryoutLPArrowLink(); 21 cryoutRemoveFocus(); 22 cryoutSliderTitleBreakUp( '.lp-staticslider .staticslider-caption', '.staticslider-caption-title > span' ); 23 cryoutSliderTitleBreakUp( '#header-page-title', '#header-page-title .entry-title' ); 24 cryoutAnimateLazyImages(); 25 /* cryoutBurgerMenu(); */ 26 27 if ( typeof cryout_theme_settings !== 'undefined' ) { 28 29 if ( ( ( cryout_theme_settings.fitvids == 2 ) && ( cryout_theme_settings.is_mobile == 1 ) ) || 30 ( cryout_theme_settings.fitvids == 1 ) 31 ) { 32 jQuery( '.entry-content' ).fitVids(); 33 } 34 35 if ( cryout_theme_settings.autoscroll == 1 ) { 36 cryoutAutoScroll(); 37 } 38 39 /* Animate articles */ 40 if ( cryout_theme_settings.articleanimation ) { 41 animateScroll( '#content-masonry > article', 'animated-onscroll' ); 42 43 /* Animate landing page elements */ 44 animateScroll( '.lp-block, .lp-box, .lp-text, .lp-port, .lp-tt, ' + 45 '.lp-section-title, .lp-section-desc', 'animated-onscroll-lp' ); 46 } 47 } /* typeof cryout_theme_settings check */ 48 49 jQuery( window ).on( 'scroll', function() { 50 if ( jQuery( this ).scrollTop() > 30 ) { 51 jQuery( '#nav-fixed' ).addClass( 'nav-fixed-show' ); 52 } else { 53 jQuery( '#nav-fixed' ).removeClass( 'nav-fixed-show' ); 54 } 55 } ); 56} ); /* document.ready */ 57 58 59jQuery( window ).on( 'load', function() { 60 cryoutPreloader(); 61 jQuery( window ).trigger( 'scroll' ); 62 cryoutMasonry(); 63 cryoutPortfolioMasonry(); 64} ); /* window.load */ 65 66 67/* 68 * Functions 69**/ 70 71/* Animate images with the [loading="lazy"] attribute */ 72function cryoutAnimateLazyImages() { 73 jQuery( 'body:not(.bravada-lazy-noanimation) #content img[loading="lazy"]' ).on( 'load', function() { 74 jQuery( this ).addClass( 'animate-lazy' ); 75 }).each( function() { 76 if ( this.complete ) { 77 jQuery( this ).trigger( 'load' ); 78 } 79 } ); 80} /* cryoutAnimateLazyImages() */ 81 82/* Site preloader */ 83function cryoutPreloader() { 84 if ( ! jQuery( '.cryout-preloader' ).length ) return; 85 86 /* Remove preloader backup animation */ 87 if ( jQuery( '.cryout-preloader' ).length ) jQuery( '.cryout-preloader' ).css( 'animation', 'none' ); 88 89 jQuery( '.cryout-preloader' ).fadeOut( 700, function() { 90 jQuery( this ).remove(); 91 } ); 92} /* cryoutPreloader() */ 93 94function cryoutLPArrowLink() { 95 if ( ! jQuery( 'body' ).hasClass( 'bravada-landing-page' ) ) return; 96 97 var newLink = jQuery( '.main section.lp-slider + section' ).attr( 'id' ); 98 if ( undefined !== newLink && newLink.length ) { 99 jQuery( '.meta-arrow' ).attr( 'href', '#' + newLink ); 100 } 101} /* cryoutLPArrowLink() */ 102 103/* Burger menu */ 104function cryoutBurgerMenu() { 105 if ( ! jQuery( '.hamburger' ).length ) return; 106 var $activeElements = jQuery( '.hamburger, #site-wrapper, .site-header-bottom-fixed, #mobile-menu' ); 107 var fixedHeader = false; /* check to see if header menu was fixed so we know to put it back later */ 108 109 jQuery( '.hamburger' ).on( 'click', function( e ) { 110 $activeElements.toggleClass( 'is-active' ); 111 jQuery( '.site-header-top' ).prepareTransition().toggleClass( 'is-active' ); 112 if ( jQuery( '.site-header-bottom' ).hasClass( 'header-fixed' ) ) { 113 jQuery( '.site-header-bottom' ).removeClass( 'header-fixed' ); 114 fixedHeader = true; 115 } 116 e.stopPropagation(); 117 } ); 118} /* cryoutBurgerMenu() */ 119 120/* Force LP boxes images ratios */ 121function cryoutLpBoxesRatios() { 122 for ( var index = 1; index <= cryout_theme_settings.lpboxratios.length; ++index ) { 123 jQuery( '.lp-boxes-' + index + ' .lp-box-image' ).keepRatio( cryout_theme_settings.lpboxratios[index-1] ); 124 } 125} /* cryoutLpBoxesRatios() */ 126 127/* Menu animation */ 128function cryoutMenuAnimate() { 129 jQuery( '#access > .menu ul li > a:not(:only-child)' ).attr( 'aria-haspopup', 'true' );/* IE10 mobile Fix */ 130 131 jQuery( '#access li' ).on( 'mouseenter', function() { 132 jQuery( this ).addClass( 'menu-hover' ); 133 } ).on( 'mouseleave', function() { 134 jQuery( this ).removeClass( 'menu-hover' ); 135 } ); 136 137 jQuery( '#access ul' ).find( 'a' ).on( 'focus', function() { 138 jQuery( this ).parents( '.menu-item, .page_item' ).addClass( 'menu-hover' ); 139 } ); 140 141 jQuery( '#access ul' ).find( 'a' ).on( 'blur', function() { 142 jQuery( this ).parents( '.menu-item, .page_item' ).removeClass( 'menu-hover' ); 143 } ); 144} /* cryoutMenuAnimate() */ 145 146/* Static Slider Title Letter break */ 147function cryoutSliderTitleBreakUp( titleContainer, animatedTitle ) { 148 149 titleContainer = 'body.bravada-animated-title ' + titleContainer; 150 animatedTitle = 'body.bravada-animated-title ' + animatedTitle; 151 152 /* If title not present on page - exit */ 153 if( ! jQuery( animatedTitle ).length ) return; 154 155 /* Add class to all containers so the same CSS gets applied */ 156 jQuery( titleContainer ).addClass( 'animated-title' ); 157 158 /* And for improved performance, if static slider not in view - no animation */ 159 jQuery( window ).on( 'scroll', function() { 160 var el = jQuery( titleContainer ); 161 if ( ! isInViewport( el ) ) { 162 el.removeClass( 'animated-title' ); 163 } else { 164 el.addClass( 'animated-title' ); 165 } 166 } ); 167 168 var $location = jQuery( animatedTitle ), 169 oldStr = $location.html(), /* new string for processing, complete with HTML tags */ 170 clearStr = $location.text().split( ' ' ).join(''), /* text only string for keys */ 171 newStr = '<em class="caption-title-word">', 172 firsRunDelay = 1000, /*ms*/ 173 letterDelay = 0, /*ms*/ 174 animatedLetters = [], /* array for the random letters that are going to be animated */ 175 nrOfAnimatedLetters = ( Math.floor( clearStr.length / 4 ) > 2) ? 176 Math.floor( clearStr.length / 4) : 177 2; 178 nrOfAnimatedLetters = ( nrOfAnimatedLetters >
178 7 ) ? 7 : nrOfAnimatedLetters; 179 var interval = 3500 + nrOfAnimatedLetters * letterDelay; /* 200 = CSS animation time */ 180 181 for ( var i = 0; i < oldStr.length; i++ ) { 182 183 /* If tag starts skip everything until tag ends */ 184 if ( oldStr[i] == '<') { 185 var substring = oldStr.substring( i ); 186 substring = substring.match( /(.*?)(<([^>]+)>)/ig ); 187 substring = substring[0]; 188 newStr += substring; 189 i+= substring.length - 1; 190 191 /* If entity starts skip everything until entity ends */ 192 } else if ( oldStr[i] == '&' ) { 193 var substring = oldStr.substring( i ); 194 substring = substring.match( /(.*?);/ig ); 195 substring = substring[0]; 196 newStr += '<span><span class="cry-single">' + substring + 197 '</span><span class="cry-double">' + substring + '</span></span>'; 198 i+= substring.length - 1; 199 200 /* Any plain old single character */ 201 } else if ( oldStr[i] != ' ' ) { 202 newStr += '<span><span class="cry-single">' + oldStr[i] + 203 '</span><span class="cry-double">' + oldStr[i] + '</span></span>'; 204 205 /* Spaces must be inside words for proper flow on new lines */ 206 } else { 207 newStr += '<span> </span></em><em class="caption-title-word">'; 208 } 209 } 210 newStr += '</em>'; 211 212 /* Out with the old, in with the new... string */ 213 $location.html( newStr ); 214 215 function titleAnimation() { 216 jQuery( animatedTitle + ' .cry-single, ' + animatedTitle + ' .cry-double' ) 217 .removeClass( 'animated-letter' ) 218 .css( 'animation-delay', '0s' ); 219 for ( var i = 0; i < nrOfAnimatedLetters; i++ ) { 220 221 /* Get a random key from the new array of letters*/ 222 animatedLetters[i] = Math.floor( Math.random() * clearStr.length ); 223 jQuery( animatedTitle + ' .cry-single' ) 224 .eq( animatedLetters[i] ) 225 .addClass( 'animated-letter' ) 226 .css( 'animation-delay', i * letterDelay + 'ms' ); 227 jQuery( animatedTitle + ' .cry-double' ) 228 .eq( animatedLetters[i] ) 229 .addClass( 'animated-letter' ) 230 .css( 'animation-delay', i * letterDelay + 'ms' ); 231 } 232 } 233 234 /* Run once after delay */ 235 setTimeout( titleAnimation, firsRunDelay ); 236 237 /* Run forever with set interval */ 238 window.setInterval( titleAnimation, interval); 239} /* cryoutSliderTitleBreakUp() */ 240 241/* Back to top button animation */ 242function cryoutBackToTop() { 243 jQuery( window ).on( 'scroll', function() { 244 if ( jQuery( this ).scrollTop() > 500 ) { 245 jQuery( '#toTop' ).addClass( 'toTop-show' ); 246 } else { 247 jQuery( '#toTop' ).removeClass( 'toTop-show' ); 248 } 249 250 if ( jQuery( this ).scrollTop() > 100 && 251 ( ! jQuery( '.site-header-top' ).hasClass( 'is-active' ) ) 252 ) { 253 jQuery( '.bravada-fixed-menu .site-header-bottom' ).addClass( 'header-fixed' ); 254 } else { 255 jQuery( '.bravada-fixed-menu .site-header-bottom' ).removeClass( 'header-fixed' ); 256 } 257 } ); 258 259 jQuery( '#toTop' ).on( 'click', function( event ) { 260 event.preventDefault(); 261 jQuery( 'html, body' ).animate( { scrollTop: 0 }, 500 ); 262 return false; 263 } ); 264 265} /* cryoutBackToTop() */ 266 267/* Search form animation */ 268function cryoutSearchFormAnimation() { 269 var searchIcon = jQuery( '#access .menu-search-animated > a' ), 270 searchForm = jQuery( '.menu-search-animated .searchform, .menu-main-search .icon-cancel' ), 271 searchInput = jQuery( '#access .menu-search-animated .s' ); 272 273 searchIcon.on( 'click', function( event ) { /* never on focus! */ 274 event.preventDefault(); 275 searchForm.fadeIn( 200, function() { 276 searchInput.trigger( 'focus' ); 277 searchInput.css( 'outline', 'none' ); 278 } ); 279 searchInput.addClass( 'is-active' ); 280 event.stopPropagation(); 281 } ); 282 283 searchForm.on( 'click', function( event ) { 284 event.stopPropagation(); 285 } ); 286 287 searchInput.on( 'blur', function() { 288 searchInput.removeClass( 'is-active' ); 289 searchForm.fadeOut( 200 ); 290 } ); 291} /* cryoutSearchFormAnimation() */ 292 293/* Mobile Menu */ 294function cryoutMobileMenuInit() { 295 296 /* Remove animated class from mobile menu */ 297 jQuery( '#mobile-menu .menu-main-search' ).removeClass( 'menu-search-animated' ); 298 299 /* First and last elements in the loop */ 300 var firstTab = jQuery( 'nav#mobile-menu #mobile-nav > li:first-child a' ), 301 lastTab = jQuery( '.hamburger' ); 302 303 /* Toggle menu */ 304 jQuery( '.hamburger' ).on( 'click', function( e ) { 305 e.stopPropagation(); 306 jQuery( 'body' ).toggleClass( 'burgermenu-active noscroll' ); 307 jQuery( 'nav#mobile-menu' ) 308 .prepareTransition() 309 .toggleClass( 'burgermenu-active' ); 310 if ( jQuery( 'body' ).hasClass( 'burgermenu-active' ) ) { 311 firstTab.trigger( 'focus' ).trigger( 'blur' ); 312 } else { 313 lastTab.trigger( 'focus' ).trigger( 'blur' ); 314 } 315 316 } ); 317 318 /* Animate menu elements on show */ 319 jQuery( 'nav#mobile-menu #mobile-nav > li, .side-section-element.widget_cryout_socials a' ) 320 .each( function( index ) { 321 var value = 0.03 * index + 's'; 322 jQuery( this ).css( '-webkit-transition-delay', value ); 323 jQuery( this ).css( 'transition-delay', value ); 324 } ); 325 326 /* Redirect last tab to first input */ 327 lastTab.on( 'keydown', function ( e ) { 328 if ( jQuery( 'body' ).hasClass( 'burgermenu-active' ) ) 329 if ( ( e.which === 9 && ( ! e.shiftKey ) ) ) { 330 e.preventDefault(); 331 firstTab.trigger( 'focus' ); 332 } 333 } ); 334 335 /* Redirect first shift+tab to last input*/ 336 firstTab.on( 'keydown', function ( e ) { 337 if ( jQuery( 'body' ).hasClass( 'burgermenu-active' ) ) 338 if ( ( e.which === 9 && e.shiftKey ) ) { 339 e.preventDefault(); 340 lastTab.trigger( 'focus' ); 341 } 342 } ); 343 344 /* Allow escape key to close menu */ 345 jQuery( 'nav#mobile-menu' ).on( 'keyup', function( e ) { 346 if ( jQuery( 'body' ).hasClass( 'burgermenu-active' ) ) 347 if ( e.keyCode === 27 ) { 348 jQuery( 'body' ).removeClass( 'burgermenu-active noscroll' ); 349 jQuery( 'nav#mobile-menu' ).prepareTransition().toggleClass( 'burgermenu-active' ); 350 lastTab.trigger( 'focus' ); 351 } 352 } ); 353 354 /* Hide main menu overlay when link with anchor is clicked */
355 jQuery( 'nav#mobile-menu li a' ).on( 'click', function( e ) { 356 var $hash = jQuery( this ).prop( 'hash' ); 357 358 if ( $hash && jQuery( $hash ).length ) { 359 jQuery( 'body' ).removeClass( 'burgermenu-active noscroll' ); 360 jQuery( 'nav#mobile-menu' ).prepareTransition().toggleClass( 'burgermenu-active' ); 361 } 362 } ); 363 364} /* cryoutMobileMenuInit() */ 365 366 367/* Add fixed mobile menu functionality */ 368function cryoutFixedMobileMenu() { 369 370 /* Only run if fixed menu is enabled */ 371 if ( cryout_theme_settings.menustyle != 1 ) return; 372 373 var c, currentScrollTop = 0, currentScrollBottom, 374 navbar = jQuery( '.site-header-bottom' ), 375 body = jQuery( 'body' ); 376 377 jQuery( window ).on( 'scroll', function () { 378 var a = jQuery( window ).scrollTop(); 379 var b = jQuery( document ).height(); 380 var viewport = jQuery( window ).height(); 381 var navbarHeight = navbar.height(); 382 383 currentScrollTop = a; 384 currentScrollBottom = b; 385 386 if ( c < currentScrollTop && a > navbarHeight + navbarHeight ) { 387 /* Scrolling down */ 388 body.removeClass( 'mobile-fixed' ); 389 } else if ( ( currentScrollTop > viewport ) && 390 ( currentScrollTop < currentScrollBottom - viewport * 2 ) && 391 ( c > currentScrollTop ) && ( ! ( a <= navbarHeight ) ) 392 ) { 393 394 /* Scrolling up */ 395 body.addClass( 'mobile-fixed' ); 396 } 397 398 c = currentScrollTop; 399 400 /* Always clear fixed class when returning to the top */ 401 if ( currentScrollTop <= navbarHeight ) { 402 body.removeClass( 'mobile-fixed' ); 403 } 404 } ); 405} /* cryoutFixedMobileMenu() */ 406 407/* Add submenus toggles to the primary navigation */ 408function cryoutInitNav( selector ) { 409 var container = jQuery( selector ); 410 411 /* Add dropdown toggle that display child menu items. */ 412 container.find( '.menu-item-has-children > a' ) 413 .after( '<button class="dropdown-toggle" aria-expanded="false"></button>' ); 414 container.find( '.page_item_has_children > a' ) 415 .after( '<button class="dropdown-toggle" aria-expanded="false"></button>' ); 416 417 /* Toggle buttons and submenu items with active children menu items. */ 418 container.find( '.current-menu-ancestor > button, .current-page-ancestor > button' ) 419 .addClass( 'toggle-on' ); 420 container.find( '.current-menu-ancestor > .sub-menu, .current-page-ancestor > .sub-menu,' + 421 ' .current-menu-ancestor .children, .current-page-ancestor .children' ) 422 .show( 0 ).addClass( 'toggled-on' ); 423 424 container.find( '.dropdown-toggle' ).on( 'click', function( e ) { 425 var _this = jQuery( this ); 426 e.preventDefault(); 427 _this.toggleClass( 'toggle-on' ); 428 if ( _this.hasClass( 'toggle-on') ) { 429 _this.next( '.children, .sub-menu' ).show( 0 ).addClass( 'toggled-on' ); 430 _this.prev( 'a' ).addClass( 'toggled-on' ); 431 } 432 else { 433 _this.next( '.children, .sub-menu' ).removeClass( 'toggled-on' ); 434 _this.next( '.children, .sub-menu' ).find( '.children, .sub-menu' ).removeClass( 'toggled-on' ); 435 _this.next( '.children, .sub-menu' ).find( 'a' ).removeClass( 'toggled-on' ); 436 _this.next( '.children, .sub-menu' ).find( '.dropdown-toggle' ).removeClass( 'toggled-on' ); 437 _this.prev( 'a' ).removeClass( 'toggled-on' ); 438 439 setTimeout( function() { 440 _this.next( '.children, .sub-menu' ).hide( 0 ); 441 _this.next( '.children, .sub-menu' ).find( '.children, .sub-menu' ).hide( 0 ); 442 }, 600 ); 443 } 444 445 /* _this.parent().find( 'a' ).toggleClass( 'toggled-on' ); */ 446 _this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); 447 } ); 448 449 /* Close mobile menu on click/tap */ 450 jQuery( 'body' ).on( 'click', '#mobile-nav a', function() { 451 jQuery( '#nav-cancel i' ).trigger( 'click' ); 452 } ); 453 454} /* cryoutInitNav() */ 455 456/* LP Boxes Keep aspect ratio*/ 457jQuery.fn.keepRatio = function( ratio ) { 458 459 var $this = jQuery( this ); 460 var nh = $this.width() / ratio; 461 $this.css( 'height', nh + 'px' ); 462 463 jQuery( window ).on( 'resize', function() { 464 var nh = $this.width() / ratio; 465 $this.css( 'height', nh + 'px' ); 466 } ); 467 468}; /* keepRatio() */ 469 470/* LP Box Mouse direction overlay animation */ 471jQuery.fn.mousedir = function( el ) { 472 if ( ! jQuery( 'body' ).hasClass( 'bravada-landing-page' ) ) return; 473 474 var $this = jQuery( this ), 475 $el = jQuery( el ), 476 last_position = {}, 477 $output = 'direction-down'; 478 479 jQuery( document ).on( 'mousemove', function ( event ) { 480 if ( typeof( last_position.x ) !== 'undefined' ) { 481 var deltaX = last_position.x - event.offsetX, 482 deltaY = last_position.y - event.offsetY; 483 if ( ( Math.abs( deltaX ) > Math.abs( deltaY ) ) && ( deltaX > 0 ) ) { 484 $output = 'direction-left'; 485 } else if ( ( Math.abs( deltaX ) > Math.abs( deltaY ) ) && ( deltaX < 0 ) ) { 486 $output = 'direction-right'; 487 } else if ( ( Math.abs( deltaY ) > Math.abs( deltaX ) ) && ( deltaY > 0 ) ) { 488 $output = 'direction-up'; 489 } else if ( ( Math.abs( deltaY ) > Math.abs( deltaX ) ) && ( deltaY < 0 ) ) { 490 $output = 'direction-down'; 491 } else { 492 $output = 'direction-down'; 493 } 494 } 495 last_position = { 496 x : event.offsetX, 497 y : event.offsetY 498 }; 499 } ); 500 501 $el.on( 'mouseenter', function() { 502 $this.removeClass( 'in-direction-left in-direction-right in-direction-up in-direction-down' + 503 ' out-direction-left out-direction-right out-direction-up out-direction-down' ); 504 $this.addClass( 'in-' + $output ); 505 return; 506 } ); 507 508 $el.on( 'mouseleave', function() { 509 $this.removeClass( 'in-direction-left in-direction-right in-direction-up in-direction-down ' + 510 ' out-direction-left out-direction-right out-direction-up out-direction-down' ); 511 $this.addClass( 'out-' + $output ); 512 return; 513 } ); 514 515}; /* mouseDir() */ 516 517/* Check if element is visible in browser window */ 518function isInViewport( el ) { 519 if ( ! jQuery( el ).length ) return; 520 521 var adminHeight = ( jQuery( '#wpadminbar' ).length ) ? jQuery( '#wpadminbar' ).height() : 0; 522 523 var elementTop = jQuery( el ).offset().top; 524 var elementBottom = elementTop + jQuery( el ).outerHeight(); 525 526 var viewportTop = jQuery( window ).scrollTop(); 527 var viewportBottom = viewportTop + jQuery( window ).height() - adminHeight; 528 529 return ( elementBottom > viewportTop ) && ( elementTop < viewportBottom ); 530} /* isInViewport() */ 531 532/* Animate on scroll */ 533function animateScroll( $articles, $class ) { 534 var $articles = jQuery( $articles ); 535 536 $articles.each( function( i, el ) { 537 jQuery( el ).addClass( $class ); 538 } ); 539 540 jQuery( window ).on( 'scroll', function() { 541 $articles.each( function( i, el ) { 542 if ( isInViewport( el ) ) { 543 jQuery( el ).removeClass( $class ); 544 } 545 } ); 546 } ); 547 548 jQuery( window ).trigger( 'scroll' ); 549} /* animateScroll() */ 550 551/* Header image paralax effect and opacity, animate header titles */ 552function cryoutHeaderParallax() { 553 var cur_op = parseFloat( jQuery( '#header-overlay' ).css( 'opacity' ) ); 554 555 /* Parallax on scroll */ 556 jQuery( window ).on( 'scroll', function() { 557 var scrolled = jQuery( window ).scrollTop(); 558 559 jQuery( '#masthead .header-image' ).each( function( index, element ) { 560 561 /* Skip animations if element is not currently visible */ 562 if ( jQuery( element ).css( 'display' ) === 'none' ) return true; 563 564 var initY = jQuery( element ).offset().top, 565 height = jQuery( element ).height(), 566 visible = isInViewport( jQuery( element ) ); 567 568 if ( visible ) { 569 var diff = scrolled - initY; 570 var ratio = Math.round( ( diff / height ) * 100 ); 571 jQuery( element ).css( 'opacity', 1); 572 jQuery( element ).css( 'background-position', 'center ' + (50 + parseInt( ratio )) + '%' ); 573 if ( ( parseInt( ratio ) > 0 ) ) { 574 jQuery( '#header-overlay' ) 575 .css( 'opacity', cur_op + 1.5 * ( parseInt( ratio ) / (100 / ( (1 - cur_op ) * 100 ) ) / 100 ) ); 576 jQuery( '#header-page-title' ) 577 .css( 'opacity', ( 1 - ( parseInt( ratio ) * 1 / 100 ) ) ); 578 } else { 579 jQuery( '#header-overlay' ).css( 'opacity', cur_op ); 580 jQuery( '#header-page-title' ).css( 'opacity', 1 ); 581 } 582 } 583 } ); 584 } ); 585} /* cryoutHeaderParallax() */ 586 587/* Add Social Icons titles */ 588function cryoutSocialTitles() { 589 jQuery( '.socials a' ).each( function() { 590 jQuery( this ).attr( 'title', jQuery( this ).children().html() ); 591 jQuery( this ).html( '' ); 592 } ); 593} /* cryoutSocialTitles() */ 594 595/* Add body classes */ 596function cryoutBodyClasses() { 597 598 /* Detect and apply custom class for Safari */ 599 if ( ( navigator.userAgent.indexOf( 'Safari' ) !== -1 ) && 600 ( navigator.userAgent.indexOf( 'Chrome' ) === -1 ) 601 ) { 602 jQuery( 'body' ).addClass( 'safari' ); 603 } 604 605 /* Add body class if masonry is used on page */ 606 if ( jQuery( '#content-masonry' ).length > 0 ) { 607 jQuery( 'body' ).addClass( 'bravada-with-masonry' ); 608 } 609} /* cryoutBodyClasses() */ 610 611/* Remove all off-canvas states */ 612function cryoutRemoveFocus() { 613 jQuery( 'input, textarea, select, button, a' ).on( 'focus', function() { 614 if (jQuery( this ).data( 'mousedown' ) || jQuery( this ).data( 'mouseup' ) ) { 615 jQuery( this ).css( 'outline', 'none' ); 616 } 617 } ); 618} /* cryoutRemoveFocus() */ 619 620/* Tabs widget */ 621function cryoutTabsWidget() { 622 var tabsNav = jQuery( '.cryout-wtabs-nav' ), 623 tabsNavLis = tabsNav.children( 'li' ); 624 625 tabsNav.each( function() {
626 var localthis = jQuery( this ); 627 localthis.next().children( '.cryout-wtab' ).stop( true, true ) 628 .children( 'li' ).hide() 629 .parent().siblings( localthis.find( 'a' ).attr( 'href' ) ) 630 .children( 'li' ).show(); 631 localthis.children( 'li' ).first() 632 .addClass( 'active' ).stop( true, true ).show(); 633 } ); 634 635 tabsNavLis.on( 'click', function( e ) { 636 var localthis = jQuery( this ), 637 tabs_duration = 200; 638 639 localthis.siblings().removeClass( 'active' ).end().addClass( 'active' ); 640 localthis.parent().next().children( '.cryout-wtab' ).stop( true, true ) 641 .children( 'li' ).hide() 642 .parent().siblings( localthis.find( 'a' ).attr( 'href' ) ) 643 .children( 'li' ).each( function( index ) { 644 jQuery( this ).fadeIn( tabs_duration * ( index + 1 ) ); 645 } ); 646 e.preventDefault(); 647 } ).children( window.location.hash ? 'a[href="' + window.location.hash + '"]' : 'a:first' ) 648 .trigger( 'click' ); 649 650} /* cryoutTabsWidget() */ 651 652/* Blog Masonry */ 653function cryoutMasonry() { 654 if ( ( cryout_theme_settings.masonry == 1 ) && 655 ( cryout_theme_settings.magazine != 1 ) && 656 ( typeof jQuery.fn.masonry !== 'undefined' ) 657 ) { 658 jQuery( '#content-masonry' ).masonry( { 659 itemSelector: 'article', 660 columnWidth: 'article', 661 percentPosition: true, 662 isRTL: cryout_theme_settings.rtl, 663 } ); 664 } 665} /* cryoutMasonry() */ 666 667/* Jetpack Portfolio Masonry */ 668function cryoutPortfolioMasonry() { 669 if ( ( cryout_theme_settings.masonry == 1 ) && ( typeof jQuery.fn.masonry !== 'undefined' ) ) { 670 jQuery( '#lp-portfolio .jetpack-portfolio-shortcode' ).masonry( { 671 itemSelector: '.portfolio-entry', 672 columnWidth: '.portfolio-entry:not(.hidey)', 673 percentPosition: true, 674 isRTL: cryout_theme_settings.rtl, 675 } ); 676 } 677} /* cryoutPortfolioMasonry() */ 678 679/* Portfolio filtering */ 680function cryoutPortfolioFilter() { 681 jQuery( 'body' ).on( 'click', '#portfolio-filter > a', function( e ) { 682 e.preventDefault(); 683 jQuery( '#portfolio-filter > a' ).removeClass( 'active' ); 684 jQuery( this ).addClass( 'active' ); 685 var filter = jQuery( this ).attr( 'data-slug' ); 686 jQuery( '#portfolio-masonry .portfolio-entry' ).each( function( i, elm ) { 687 if ( filter == 'all' ) { 688 jQuery( elm ).removeClass( 'hidey' ).fadeIn( 'fast' ); 689 } else { 690 if ( ! jQuery( elm ).hasClass( 'type-' + filter ) ) { 691 jQuery( elm ).addClass( 'hidey' ).fadeOut( 'fast' ); 692 } else { 693 jQuery( elm ).removeClass( 'hidey' ).fadeIn( 'fast' ); 694 } 695 } 696 } ).promise().done( function() { 697 cryoutPortfolioMasonry(); 698 /*jQuery('.jetpack-portfolio-shortcode').masonry();*/ 699 } ); 700 return false; 701 } ); 702} /* cryoutPortfolioFilter() */ 703 704/** 705 * prepareTransition jQuery Plugin 706 */ 707;( function( $ ){ 708 $.fn.prepareTransition = function() { 709 return this.each( function() { 710 var el = $( this ); 711 712 /* Remove the transition class upon completion */ 713 el.one( 'TransitionEnd webkitTransitionEnd transitionend oTransitionEnd', function() { 714 el.removeClass( 'is-transitioning' ); 715 } ); 716 717 /* Check the various CSS properties to see if a duration has been set */ 718 var cl = ["transition-duration", "-moz-transition-duration", 719 "-webkit-transition-duration", "-o-transition-duration"]; 720 var duration = 0; 721 $.each( cl, function( idx, itm ) { 722 duration || ( duration = parseFloat( el.css( itm ) ) ); 723 } ); 724 725 /* if I have a duration then add the class */ 726 if ( duration != 0 ) { 727 el.addClass( 'is-transitioning' ); 728 el[0].offsetWidth; /* check offsetWidth to force the style rendering */ 729 } 730 } ); 731 }; 732}( jQuery ) ); 733 734/** 735 * Scroll to anchors 736 */ 737function cryoutAutoScroll(document, history, location) { 738 document = window.document; 739 history = window.history; 740 location = window.location; 741 var HISTORY_SUPPORT = !! ( history && history.pushState ); 742 var anchorScrolls = { 743 ANCHOR_REGEX: /^#[^ ]+$/, 744 OFFSET_HEIGHT_PX: jQuery( '.bravada-fixed-menu #site-header-main' ).height(), 745 746 /* Establish events, and fix initial scroll position if a hash is provided. */ 747 init: function() { 748 this.scrollToCurrent(); 749 jQuery( window ).on( 750 'hashchange', 751 jQuery.proxy( this, 'scrollToCurrent' ) 752 ); 753 jQuery( 'body' ).on( 754 'click', 755 '.main a, nav ul li a, .meta-arrow', 756 jQuery.proxy( this, 'delegateAnchors' ) 757 ); 758 }, 759 760 /* Return the offset amount to deduct from the normal scroll position. 761 Modify as appropriate to allow for dynamic calculations. */ 762 getFixedOffset: function() { 763 return ( this.OFFSET_HEIGHT_PX ) ? this.OFFSET_HEIGHT_PX : 0; 764 }, 765 766 /* If the provided href is an anchor which resolves to an element on the page, scroll to it. */ 767 scrollIfAnchor: function( href, pushToHistory ) { 768 var match, anchorOffset; 769 770 if ( ! this.ANCHOR_REGEX.test( href ) ) { 771 return false;
772 } 773 774 match = document.getElementById(href.slice(1)); 775 776 if ( match && ( ! isInViewport( match ) ) && jQuery( match ).offset().top ) { 777 anchorOffset = jQuery( match ).offset().top - this.getFixedOffset(); 778 jQuery( 'html, body' ).animate( { scrollTop: anchorOffset} ); 779 780 /* Add the state to history as-per normal anchor links */ 781 if ( HISTORY_SUPPORT && pushToHistory ) { 782 history.pushState( {}, document.title, location.pathname + href ); 783 } 784 } 785 786 return !!match; 787 }, 788 789 /* Attempt to scroll to the current location's hash */ 790 scrollToCurrent: function(e) { 791 if (this.scrollIfAnchor(window.location.hash) && e) { 792 e.preventDefault(); 793 } 794 }, 795 796 /* If the click event's target was an anchor, fix the scroll position */ 797 delegateAnchors: function( e ) { 798 var elem = e.target.closest( 'a' ); 799 800 if ( this.scrollIfAnchor( elem.getAttribute( 'href' ), true ) ) { 801 e.preventDefault(); 802 } 803 } 804 }; 805 806 jQuery( document ).ready( jQuery.proxy( anchorScrolls, 'init' ) ); 807} 808 809/* FitVids 1.1*/ 810;(function( $ ){ 811 812 'use strict'; 813 814 $.fn.fitVids = function( options ) { 815 var settings = { 816 customSelector: null, 817 ignore: null 818 }; 819 820 if(!document.getElementById('fit-vids-style')) { 821 /* appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js */ 822 var head = document.head || document.getElementsByTagName('head')[0]; 823 var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}'; 824 var div = document.createElement("div"); 825 div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>'; 826 head.appendChild(div.childNodes[1]); 827 } 828 829 if ( options ) { 830 $.extend( settings, options ); 831 } 832 833 return this.each(function(){ 834 var selectors = [ 835 'iframe[src*="player.vimeo.com"]', 836 'iframe[src*="youtube.com"]', 837 'iframe[src*="youtube-nocookie.com"]', 838 'iframe[src*="kickstarter.com"][src*="video.html"]', 839 'object', 840 'embed' 841 ]; 842 843 if (settings.customSelector) { 844 selectors.push(settings.customSelector); 845 } 846 847 var ignoreList = '.fitvidsignore, .wp-block-embed__wrapper'; 848 849 if(settings.ignore) { 850 ignoreList = ignoreList + ', ' + settings.ignore; 851 } 852 853 var $allVideos = $(this).find(selectors.join(',')); 854 $allVideos = $allVideos.not('object object'); /* SwfObj conflict patch */ 855 $allVideos = $allVideos.not(ignoreList); /* Disable FitVids on this video. */ 856 857 $allVideos.each(function(){ 858 var $this = $(this); 859 if($this.parents(ignoreList).length > 0) { 860 return; /* Disable FitVids on this video. */ 861 } 862 if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; } 863 if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width')))) 864 { 865 $this.attr('height', 9); 866 $this.attr('width', 16); 867 } 868 var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(), 869 width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(), 870 aspectRatio = height / width; 871 if(!$this.attr('name')){ 872 var videoName = 'fitvid' + $.fn.fitVids._count; 873 $this.attr('name', videoName); 874 $.fn.fitVids._count++; 875 } 876 $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%'); 877 $this.removeAttr('height').removeAttr('width'); 878 } ); 879 } ); 880 }; 881 882 /* Internal counter for unique video names. */ 883 $.fn.fitVids._count = 0; 884 885/* Works with either jQuery or Zepto */ 886})( window.jQuery || window.Zepto ); 887 888/* IE .closest() fix */ 889if ( window.Element && ( ! Element.prototype.closest ) ) { 890 Element.prototype.closest = function( s ) { 891 var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ), 892 i, 893 el = this; 894 do { 895 i = matches.length; 896 while (--i >= 0 && matches.item( i ) !== el) {} 897 } while ( (i < 0) && ( el = el.parentElement ) ); 898 return el; 899 }; 900} 901 902/* FIN */
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.