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 51 if ( jQuery( this ).scrollTop() > 30 ) { 52 jQuery( '#nav-fixed' ).addClass( 'nav-fixed-show' ); 53 } else { 54 jQuery( '#nav-fixed' ).removeClass( 'nav-fixed-show' ); 55 } 56 57 if ( jQuery( this ).scrollTop() > 100 && 58 ( ! jQuery( '.site-header-top' ).hasClass( 'is-active' ) ) 59 ) { 60 jQuery( '.bravada-fixed-menu .site-header-bottom' ).addClass( 'header-fixed' ); 61 } else { 62 jQuery( '.bravada-fixed-menu .site-header-bottom' ).removeClass( 'header-fixed' ); 63 } 64 65 } ); 66} ); /* document.ready */ 67 68 69jQuery( window ).on( 'load', function() { 70 cryoutPreloader(); 71 jQuery( window ).trigger( 'scroll' ); 72 cryoutMasonry(); 73 cryoutPortfolioMasonry(); 74} ); /* window.load */ 75 76 77/* 78 * Functions 79**/ 80 81/* Animate images with the [loading="lazy"] attribute */ 82function cryoutAnimateLazyImages() { 83 jQuery( 'body:not(.bravada-lazy-noanimation) #content img[loading="lazy"]' ).on( 'load', function() { 84 jQuery( this ).addClass( 'animate-lazy' ); 85 }).each( function() { 86 if ( this.complete ) { 87 jQuery( this ).trigger( 'load' ); 88 } 89 } ); 90} /* cryoutAnimateLazyImages() */ 91 92/* Site preloader */ 93function cryoutPreloader() { 94 if ( ! jQuery( '.cryout-preloader' ).length ) return; 95 96 /* Remove preloader backup animation */ 97 if ( jQuery( '.cryout-preloader' ).length ) jQuery( '.cryout-preloader' ).css( 'animation', 'none' ); 98 99 jQuery( '.cryout-preloader' ).fadeOut( 700, function() { 100 jQuery( this ).remove(); 101 } ); 102} /* cryoutPreloader() */ 103 104function cryoutLPArrowLink() { 105 if ( ! jQuery( 'body' ).hasClass( 'bravada-landing-page' ) ) return; 106 107 var newLink = jQuery( '.main section.lp-slider + section' ).attr( 'id' ); 108 if ( undefined !== newLink && newLink.length ) { 109 jQuery( '.meta-arrow' ).attr( 'href', '#' + newLink ); 110 } 111} /* cryoutLPArrowLink() */ 112 113/* Burger menu */ 114function cryoutBurgerMenu() { 115 if ( ! jQuery( '.hamburger' ).length ) return; 116 var $activeElements = jQuery( '.hamburger, #site-wrapper, .site-header-bottom-fixed, #mobile-menu' ); 117 var fixedHeader = false; /* check to see if header menu was fixed so we know to put it back later */ 118 119 jQuery( '.hamburger' ).on( 'click', function( e ) { 120 $activeElements.toggleClass( 'is-active' ); 121 jQuery( '.site-header-top' ).prepareTransition().toggleClass( 'is-active' ); 122 if ( jQuery( '.site-header-bottom' ).hasClass( 'header-fixed' ) ) { 123 jQuery( '.site-header-bottom' ).removeClass( 'header-fixed' ); 124 fixedHeader = true; 125 } 126 e.stopPropagation(); 127 } ); 128} /* cryoutBurgerMenu() */ 129 130/* Force LP boxes images ratios */ 131function cryoutLpBoxesRatios() { 132 for ( var index = 1; index <= cryout_theme_settings.lpboxratios.length; ++index ) { 133 jQuery( '.lp-boxes-' + index + ' .lp-box-image' ).keepRatio( cryout_theme_settings.lpboxratios[index-1] ); 134 } 135} /* cryoutLpBoxesRatios() */ 136 137/* Menu animation */ 138function cryoutMenuAnimate() { 139 jQuery( '#access > .menu ul li > a:not(:only-child)' ).attr( 'aria-haspopup', 'true' );/* IE10 mobile Fix */ 140 141 jQuery( '#access li' ).on( 'mouseenter', function() { 142 jQuery( this ).addClass( 'menu-hover' ); 143 } ).on( 'mouseleave', function() { 144 jQuery( this ).removeClass( 'menu-hover' ); 145 } ); 146 147 jQuery( '#access ul' ).find( 'a' ).on( 'focus', function() { 148 jQuery( this ).parents( '.menu-item, .page_item' ).addClass( 'menu-hover' ); 149 } ); 150 151 jQuery( '#access ul' ).find( 'a' ).on( 'blur', function() { 152 jQuery( this ).parents( '.menu-item, .page_item' ).removeClass( 'menu-hover' ); 153 } ); 154} /* cryoutMenuAnimate() */ 155 156/* Static Slider Title Letter break */ 157function cryoutSliderTitleBreakUp( titleContainer, animatedTitle ) { 158 159 titleContainer = 'body.bravada-animated-title ' + titleContainer; 160 animatedTitle = 'body.bravada-animated-title ' + animatedTitle; 161 162 /* If title not present on page - exit */ 163 if( ! jQuery( animatedTitle ).length ) return; 164 165 /* Add class to all containers so the same CSS gets applied */ 166 jQuery( titleContainer ).addClass( 'animated-title' ); 167 168 /* And for improved performance, if static slider not in view - no animation */ 169 jQuery( window ).on( 'scroll', function() { 170 var el = jQuery( titleContainer ); 171 if ( ! isInViewport( el ) ) { 172 el.removeClass( 'animated-title' ); 173 } else { 174 el.addClass( 'animated-title' ); 175 } 176 } ); 177 178 var $location = jQuery( animatedTitle ), 179 oldStr = $location.html(), /* new string for processing, complete with HTML tags */ 180 clearStr = $location.text().split( ' ' ).join(''), /* text only string for keys */ 181 newStr = '<em class="caption-title-word">', 182 firsRunDelay = 1000, /*ms*/ 183 letterDelay = 0, /*ms*/ 184 animatedLetters = [], /* array for the random letters that are going to be animated */ 185 nrOfAnimatedLetters = ( Math.floor( clearStr.length / 4 ) > 2) ? 186 Math.floor( clearStr.length / 4) : 187 2; 188 nrOfAnimatedLetters = ( nrOfAnimatedLetters >
188 7 ) ? 7 : nrOfAnimatedLetters; 189 var interval = 3500 + nrOfAnimatedLetters * letterDelay; /* 200 = CSS animation time */ 190 191 for ( var i = 0; i < oldStr.length; i++ ) { 192 193 /* If tag starts skip everything until tag ends */ 194 if ( oldStr[i] == '<') { 195 var substring = oldStr.substring( i ); 196 substring = substring.match( /(.*?)(<([^>]+)>)/ig ); 197 substring = substring[0]; 198 newStr += substring; 199 i+= substring.length - 1; 200 201 /* If entity starts skip everything until entity ends */ 202 } else if ( oldStr[i] == '&' ) { 203 var substring = oldStr.substring( i ); 204 substring = substring.match( /(.*?);/ig ); 205 substring = substring[0]; 206 newStr += '<span><span class="cry-single">' + substring + 207 '</span><span class="cry-double">' + substring + '</span></span>'; 208 i+= substring.length - 1; 209 210 /* Any plain old single character */ 211 } else if ( oldStr[i] != ' ' ) { 212 newStr += '<span><span class="cry-single">' + oldStr[i] + 213 '</span><span class="cry-double">' + oldStr[i] + '</span></span>'; 214 215 /* Spaces must be inside words for proper flow on new lines */ 216 } else { 217 newStr += '<span> </span></em><em class="caption-title-word">'; 218 } 219 } 220 newStr += '</em>'; 221 222 /* Out with the old, in with the new... string */ 223 $location.html( newStr ); 224 225 function titleAnimation() { 226 jQuery( animatedTitle + ' .cry-single, ' + animatedTitle + ' .cry-double' ) 227 .removeClass( 'animated-letter' ) 228 .css( 'animation-delay', '0s' ); 229 for ( var i = 0; i < nrOfAnimatedLetters; i++ ) { 230 231 /* Get a random key from the new array of letters*/ 232 animatedLetters[i] = Math.floor( Math.random() * clearStr.length ); 233 jQuery( animatedTitle + ' .cry-single' ) 234 .eq( animatedLetters[i] ) 235 .addClass( 'animated-letter' ) 236 .css( 'animation-delay', i * letterDelay + 'ms' ); 237 jQuery( animatedTitle + ' .cry-double' ) 238 .eq( animatedLetters[i] ) 239 .addClass( 'animated-letter' ) 240 .css( 'animation-delay', i * letterDelay + 'ms' ); 241 } 242 } 243 244 /* Run once after delay */ 245 setTimeout( titleAnimation, firsRunDelay ); 246 247 /* Run forever with set interval */ 248 window.setInterval( titleAnimation, interval); 249} /* cryoutSliderTitleBreakUp() */ 250 251/* Back to top button animation */ 252function cryoutBackToTop() { 253 jQuery( window ).on( 'scroll', function() { 254 if ( jQuery( this ).scrollTop() > 500 ) { 255 jQuery( '#toTop' ).addClass( 'toTop-show' ); 256 } else { 257 jQuery( '#toTop' ).removeClass( 'toTop-show' ); 258 } 259 } ); 260 261 jQuery( '#toTop' ).on( 'click', function( event ) { 262 event.preventDefault(); 263 jQuery( 'html, body' ).animate( { scrollTop: 0 }, 500 ); 264 return false; 265 } ); 266 267} /* cryoutBackToTop() */ 268 269/* Search form animation */ 270function cryoutSearchFormAnimation() { 271 var searchIcon = jQuery( '#access .menu-search-animated > button' ), 272 searchForm = jQuery( '.menu-search-animated .searchform, .menu-main-search .icon-cancel' ), 273 searchInput = jQuery( '#access .menu-search-animated .s' ); 274 275 searchIcon.on( 'click', function( event ) { /* never on focus! */ 276 event.preventDefault(); 277 searchForm.fadeIn( 200, function() { 278 searchInput.trigger( 'focus' ); 279 searchInput.css( 'outline', 'none' ); 280 } ); 281 searchInput.addClass( 'is-active' ); 282 event.stopPropagation(); 283 } ); 284 285 searchForm.on( 'click', function( event ) { 286 event.stopPropagation(); 287 } ); 288 289 searchInput.on( 'blur', function() { 290 searchInput.removeClass( 'is-active' ); 291 searchForm.fadeOut( 200 ); 292 } ); 293} /* cryoutSearchFormAnimation() */ 294 295/* Mobile Menu */ 296function cryoutMobileMenuInit() { 297 298 /* Remove animated class from mobile menu */ 299 jQuery( '#mobile-menu .menu-main-search' ).removeClass( 'menu-search-animated' ); 300 301 /* First and last elements in the loop */ 302 var firstTab = jQuery( '#mobile-nav input.s'), 303 lastTab = jQuery( '.hamburger' ); 304 305 /* Toggle menu */ 306 jQuery( '.hamburger' ).on( 'click', function( e ) { 307 e.stopPropagation(); 308 jQuery( 'body' ).toggleClass( 'burgermenu-active noscroll' ); 309 jQuery( 'nav#mobile-menu' ) 310 .prepareTransition() 311 .toggleClass( 'burgermenu-active' ); 312 if ( jQuery( 'body' ).hasClass( 'burgermenu-active' ) ) { 313 firstTab.trigger( 'focus' ); 314 } else { 315 lastTab.trigger( 'focus' ); 316 } 317 318 } ); 319 320 /* Animate menu elements on show */ 321 jQuery( 'nav#mobile-menu #mobile-nav > li, .side-section-element.widget_cryout_socials a' ) 322 .each( function( index ) { 323 var value = 0.03 * index + 's'; 324 jQuery( this ).css( '-webkit-transition-delay', value ); 325 jQuery( this ).css( 'transition-delay', value ); 326 } ); 327 328 /* Redirect last tab to first input */ 329 lastTab.on( 'keydown', function ( e ) { 330 if ( jQuery( 'body' ).hasClass( 'burgermenu-active' ) ) 331 if ( ( e.which === 9 && ( ! e.shiftKey ) ) ) { 332 e.preventDefault(); 333 firstTab.trigger( 'focus' ); 334 } 335 } ); 336 337 /* Redirect first shift+tab to last input*/ 338 firstTab.on( 'keydown', function ( e ) { 339 if ( jQuery( 'body' ).hasClass( 'burgermenu-active' ) ) 340 if ( ( e.which === 9 && e.shiftKey ) ) { 341 e.preventDefault(); 342 lastTab.trigger( 'focus' ); 343 } 344 } ); 345 346 /* Allow escape key to close menu */ 347 jQuery( 'nav#mobile-menu' ).on( 'keyup', function( e ) { 348 if ( jQuery( 'body' ).hasClass( 'burgermenu-active' ) ) 349 if ( e.keyCode === 27 ) { 350 jQuery( 'body' ).removeClass( 'burgermenu-active noscroll' ); 351 jQuery( 'nav#mobile-menu' ).prepareTransition().toggleClass( 'burgermenu-active' ); 352 lastTab.trigger( 'focus' ); 353 } 354 } ); 355 356 /* Hide main menu overlay when link with anchor is clicked */
357 jQuery( 'nav#mobile-menu li a' ).on( 'click', function( e ) { 358 var $hash = jQuery( this ).prop( 'hash' ); 359 360 if ( $hash && jQuery( $hash ).length ) { 361 jQuery( 'body' ).removeClass( 'burgermenu-active noscroll' ); 362 jQuery( 'nav#mobile-menu' ).prepareTransition().toggleClass( 'burgermenu-active' ); 363 } 364 } ); 365 366} /* cryoutMobileMenuInit() */ 367 368 369/* Add fixed mobile menu functionality */ 370function cryoutFixedMobileMenu() { 371 372 /* Only run if fixed menu is enabled */ 373 if ( cryout_theme_settings.menustyle != 1 ) return; 374 375 var c, currentScrollTop = 0, currentScrollBottom, 376 navbar = jQuery( '.site-header-bottom' ), 377 body = jQuery( 'body' ); 378 379 jQuery( window ).on( 'scroll', function () { 380 var a = jQuery( window ).scrollTop(); 381 var b = jQuery( document ).height(); 382 var viewport = jQuery( window ).height(); 383 var navbarHeight = navbar.height(); 384 385 currentScrollTop = a; 386 currentScrollBottom = b; 387 388 if ( c < currentScrollTop && a > navbarHeight + navbarHeight ) { 389 /* Scrolling down */ 390 body.removeClass( 'mobile-fixed' ); 391 } else if ( ( currentScrollTop > viewport ) && 392 ( currentScrollTop < currentScrollBottom - viewport * 2 ) && 393 ( c > currentScrollTop ) && ( ! ( a <= navbarHeight ) ) 394 ) { 395 396 /* Scrolling up */ 397 body.addClass( 'mobile-fixed' ); 398 } 399 400 c = currentScrollTop; 401 402 /* Always clear fixed class when returning to the top */ 403 if ( currentScrollTop <= navbarHeight ) { 404 body.removeClass( 'mobile-fixed' ); 405 } 406 } ); 407} /* cryoutFixedMobileMenu() */ 408 409/* Add submenus toggles to the primary navigation */ 410function cryoutInitNav( selector ) { 411 var container = jQuery( selector ); 412 413 /* Add dropdown toggle that display child menu items. */ 414 container.find( '.menu-item-has-children > a' ) 415 .after( '<button class="dropdown-toggle" aria-expanded="false"></button>' ); 416 container.find( '.page_item_has_children > a' ) 417 .after( '<button class="dropdown-toggle" aria-expanded="false"></button>' ); 418 419 /* Toggle buttons and submenu items with active children menu items. */ 420 container.find( '.current-menu-ancestor > button, .current-page-ancestor > button' ) 421 .addClass( 'toggle-on' ); 422 container.find( '.current-menu-ancestor > .sub-menu, .current-page-ancestor > .sub-menu,' + 423 ' .current-menu-ancestor .children, .current-page-ancestor .children' ) 424 .show( 0 ).addClass( 'toggled-on' ); 425 426 container.find( '.dropdown-toggle' ).on( 'click', function( e ) { 427 var _this = jQuery( this ); 428 e.preventDefault(); 429 _this.toggleClass( 'toggle-on' ); 430 if ( _this.hasClass( 'toggle-on') ) { 431 _this.next( '.children, .sub-menu' ).show( 0 ).addClass( 'toggled-on' ); 432 _this.prev( 'a' ).addClass( 'toggled-on' ); 433 } 434 else { 435 _this.next( '.children, .sub-menu' ).removeClass( 'toggled-on' ); 436 _this.next( '.children, .sub-menu' ).find( '.children, .sub-menu' ).removeClass( 'toggled-on' ); 437 _this.next( '.children, .sub-menu' ).find( 'a' ).removeClass( 'toggled-on' ); 438 _this.next( '.children, .sub-menu' ).find( '.dropdown-toggle' ).removeClass( 'toggled-on' ); 439 _this.prev( 'a' ).removeClass( 'toggled-on' ); 440 441 setTimeout( function() { 442 _this.next( '.children, .sub-menu' ).hide( 0 ); 443 _this.next( '.children, .sub-menu' ).find( '.children, .sub-menu' ).hide( 0 ); 444 }, 600 ); 445 } 446 447 /* _this.parent().find( 'a' ).toggleClass( 'toggled-on' ); */ 448 _this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); 449 } ); 450 451 /* Close mobile menu on click/tap */ 452 jQuery( 'body' ).on( 'click', '#mobile-nav a', function() { 453 jQuery( '#nav-cancel i' ).trigger( 'click' ); 454 } ); 455 456} /* cryoutInitNav() */ 457 458/* LP Boxes Keep aspect ratio*/ 459jQuery.fn.keepRatio = function( ratio ) { 460 461 var $this = jQuery( this ); 462 var nh = $this.width() / ratio; 463 $this.css( 'height', nh + 'px' ); 464 465 jQuery( window ).on( 'resize', function() { 466 var nh = $this.width() / ratio; 467 $this.css( 'height', nh + 'px' ); 468 } ); 469 470}; /* keepRatio() */ 471 472/* LP Box Mouse direction overlay animation */ 473jQuery.fn.mousedir = function( el ) { 474 if ( ! jQuery( 'body' ).hasClass( 'bravada-landing-page' ) ) return; 475 476 var $this = jQuery( this ), 477 $el = jQuery( el ), 478 last_position = {}, 479 $output = 'direction-down'; 480 481 jQuery( document ).on( 'mousemove', function ( event ) { 482 if ( typeof( last_position.x ) !== 'undefined' ) { 483 var deltaX = last_position.x - event.offsetX, 484 deltaY = last_position.y - event.offsetY; 485 if ( ( Math.abs( deltaX ) > Math.abs( deltaY ) ) && ( deltaX > 0 ) ) { 486 $output = 'direction-left'; 487 } else if ( ( Math.abs( deltaX ) > Math.abs( deltaY ) ) && ( deltaX < 0 ) ) { 488 $output = 'direction-right'; 489 } else if ( ( Math.abs( deltaY ) > Math.abs( deltaX ) ) && ( deltaY > 0 ) ) { 490 $output = 'direction-up'; 491 } else if ( ( Math.abs( deltaY ) > Math.abs( deltaX ) ) && ( deltaY < 0 ) ) { 492 $output = 'direction-down'; 493 } else { 494 $output = 'direction-down'; 495 } 496 } 497 last_position = { 498 x : event.offsetX, 499 y : event.offsetY 500 }; 501 } ); 502 503 $el.on( 'mouseenter', function() { 504 jQuery( this ).removeClass( 'in-direction-left in-direction-right in-direction-up in-direction-down' + 505 ' out-direction-left out-direction-right out-direction-up out-direction-down' ); 506 jQuery( this ).addClass( 'in-' + $output ); 507 return; 508 } ); 509 510 $el.on( 'mouseleave', function() { 511 jQuery( this ).removeClass( 'in-direction-left in-direction-right in-direction-up in-direction-down ' + 512 ' out-direction-left out-direction-right out-direction-up out-direction-down' ); 513 jQuery( this ).addClass( 'out-' + $output ); 514 return; 515 } ); 516 517}; /* mouseDir() */ 518 519/* Check if element is visible in browser window */ 520function isInViewport( el ) { 521 if ( ! jQuery( el ).length ) return; 522 523 var adminHeight = ( jQuery( '#wpadminbar' ).length ) ? jQuery( '#wpadminbar' ).height() : 0; 524 525 var elementTop = jQuery( el ).offset().top; 526 var elementBottom = elementTop + jQuery( el ).outerHeight(); 527 528 var viewportTop = jQuery( window ).scrollTop(); 529 var viewportBottom = viewportTop + jQuery( window ).height() - adminHeight; 530 531 return ( elementBottom > viewportTop ) && ( elementTop < viewportBottom ); 532} /* isInViewport() */ 533 534/* Animate on scroll */ 535function animateScroll( $articles, $class ) { 536 var $articles = jQuery( $articles ); 537 538 $articles.each( function( i, el ) { 539 jQuery( el ).addClass( $class ); 540 } ); 541 542 jQuery( window ).on( 'scroll', function() { 543 $articles.each( function( i, el ) { 544 if ( isInViewport( el ) ) { 545 jQuery( el ).removeClass( $class ); 546 } 547 } ); 548 } ); 549 550 jQuery( window ).trigger( 'scroll' ); 551} /* animateScroll() */ 552 553/* Header image paralax effect and opacity, animate header titles */ 554function cryoutHeaderParallax() { 555 var cur_op = parseFloat( jQuery( '#header-overlay' ).css( 'opacity' ) ); 556 557 /* Parallax on scroll */ 558 jQuery( window ).on( 'scroll', function() { 559 var scrolled = jQuery( window ).scrollTop(); 560 561 jQuery( '#masthead .header-image' ).each( function( index, element ) { 562 563 /* Skip animations if element is not currently visible */ 564 if ( jQuery( element ).css( 'display' ) === 'none' ) return true; 565 566 var initY = jQuery( element ).offset().top, 567 height = jQuery( element ).height(), 568 visible = isInViewport( jQuery( element ) ); 569 570 if ( visible ) { 571 var diff = scrolled - initY; 572 var ratio = Math.round( ( diff / height ) * 100 ); 573 jQuery( element ).css( 'opacity', 1); 574 jQuery( element ).css( 'background-position', 'center ' + (50 + parseInt( ratio )) + '%' ); 575 if ( ( parseInt( ratio ) > 0 ) ) { 576 jQuery( '#header-overlay' ) 577 .css( 'opacity', cur_op + 1.5 * ( parseInt( ratio ) / (100 / ( (1 - cur_op ) * 100 ) ) / 100 ) ); 578 jQuery( '#header-page-title' ) 579 .css( 'opacity', ( 1 - ( parseInt( ratio ) * 1 / 100 ) ) ); 580 } else { 581 jQuery( '#header-overlay' ).css( 'opacity', cur_op ); 582 jQuery( '#header-page-title' ).css( 'opacity', 1 ); 583 } 584 } 585 } ); 586 } ); 587} /* cryoutHeaderParallax() */ 588 589/* Add Social Icons titles */ 590function cryoutSocialTitles() { 591 jQuery( '.socials a' ).each( function() { 592 jQuery( this ).attr( 'title', jQuery( this ).children().html() ); 593 jQuery( this ).html( '' ); 594 } ); 595} /* cryoutSocialTitles() */ 596 597/* Add body classes */ 598function cryoutBodyClasses() { 599 600 /* Detect and apply custom class for Safari */ 601 if ( ( ( navigator.userAgent.indexOf( 'Safari' ) !== -1 ) || ( navigator.userAgent.indexOf( 'iPhone' ) !== -1 ) || ( navigator.userAgent.indexOf( 'iPad' ) !== -1 ) ) && ( navigator.userAgent.indexOf( 'Chrome' ) === -1 ) ) { 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, 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.