1(function() { 2 "use strict"; 3 4 var $ = jQuery.noConflict(); 5 6 /* 7 * Get Viewport Dimensions 8 * returns object with viewport dimensions to match css in width and height properties 9 * ( source: http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript ) 10 */ 11 function updateViewportDimensions() { 12 var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight; 13 return { width:x,height:y } 14 } 15 // setting the viewport width 16 var viewport = updateViewportDimensions(); 17 18 19 /* 20 * Throttle Resize-triggered Events 21 * Wrap your actions in this function to throttle the frequency of firing them off, for better performance, esp. on mobile. 22 * ( source: http://stackoverflow.com/questions/2854407/javascript-jquery-window-resize-how-to-fire-after-the-resize-is-completed ) 23 */ 24 var waitForFinalEvent = (function () { 25 var timers = {}; 26 return function (callback, ms, uniqueId) { 27 if (!uniqueId) { uniqueId = "Don't call this twice without a uniqueId"; } 28 if (timers[uniqueId]) { clearTimeout (timers[uniqueId]); } 29 timers[uniqueId] = setTimeout(callback, ms); 30 }; 31 })(); 32 33 // how long to wait before deciding the resize has stopped, in ms. Around 50-100 should work ok. 34 var timeToWaitForLast = 100; 35 36 37 function resizeRows() { 38 $('.row-wrapper.fixed_height').each(function() { 39 var $this = $(this), 40 height = $this.data('height'), 41 windowHeight = updateViewportDimensions(), 42 wH = windowHeight.height; 43 44 if ( $('#wpadminbar').length ) wH -= $('#wpadminbar').height(); 45 if ( $('.preview__header').length ) wH -= $('.preview__header').height(); 46 47 $this.css({height: wH * height / 100 + 'px'}); 48 }); 49 } 50 51 $(window).resize(function () { 52 53 waitForFinalEvent( function() { 54 resizeRows(); 55 customSlopeHeight(); 56 57 $(videoSDiv).each(function(){ 58 videoSectionSize($(this)); 59 }); 60 61 $('.bg-vimeo').each(function(){ 62 vimeoSize($(this)); 63 }); 64 65 $('.bg-youtube').each(function(){ 66 youtubeSize($(this)); 67 }); 68 69 }, timeToWaitForLast, "your-function-identifier-string"); }); 70 71 /* 72 * Here's an example so you can see how we're using the above function 73 * 74 * This is commented out so it won't work, but you can copy it and 75 * remove the comments. 76 * 77 * 78 * 79 * If we want to only do it on a certain page, we can setup checks so we do it 80 * as efficient as possible. 81 * 82 * if( typeof is_home === "undefined" ) var is_home = $('body').hasClass('home'); 83 * 84 * This once checks to see if you're on the home page based on the body class 85 * We can then use that check to perform actions on the home page only 86 * 87 * When the window is resized, we perform this function 88 * $(window).resize(function () { 89 * 90 * // if we're on the home page, we wait the set amount (in function above) then fire the function 91 * if( is_home ) { waitForFinalEvent( function() { 92 * 93 * // if we're above or equal to 768 fire this off 94 * if( viewport.width >= 768 ) { 95 * console.log('On home page and window sized to 768 width or more.'); 96 * } else { 97 * // otherwise, let's do this instead 98 * console.log('Not on home page, or window sized to less than 768.'); 99 * } 100 * 101 * }, timeToWaitForLast, "your-function-identifier-string"); } 102 * }); 103 * 104 * Pretty cool huh? You can create functions like this to conditionally load 105 * content and other stuff dependent on the viewport. 106 * Remember that mobile devices and javascript aren't the best of friends. 107 * Keep it light and always make sure the larger viewports are doing the heavy lifting. 108 * 109 */ 110 111 /* 112 * We're going to swap out the gravatars. 113 * In the functions.php file, you can see we're not loading the gravatar 114 * images on mobile to save bandwidth. Once we hit an acceptable viewport 115 * then we can swap out those images since they are located in a data attribute. 116 */ 117 function loadGravatars() { 118 // set the viewport using the function above 119 viewport = updateViewportDimensions(); 120 // if the viewport is tablet or larger, we load in the gravatars 121 if (viewport.width >= 768) { 122 jQuery('.comment img[data-gravatar]').each(function(){ 123 jQuery(this).attr('src',jQuery(this).attr('data-gravatar')); 124 }); 125 } 126 } // end function 127 128 129 130 /********************* 131 iOS submenu fix 132 *********************/ 133 function submenu_fix() { 134 $('#site-navigation .menu-container > ul > li, #site-navigation .menu-container > ul > li:not(.megamenu) > .sub-menu > li').bind('touchstart touchend', function(e) { 135 $(this).toggleClass('mhover'); 136 }); 137 } 138 139 140 141 /********************* 142 Info box hover fix 143 *********************/ 144 function el_hover_fix() {
145 $('.twc_ib_container').bind('touchstart touchend', function(e) { 146 $(this).toggleClass('mhover'); 147 }); 148 149 $('.twc_image_box .twc_imb_inner').bind('touchstart touchend', function(e) { 150 $(this).toggleClass('mhover'); 151 }); 152 } 153 154 155 156 /********************* 157 Search button 158 *********************/ 159 function searchButton() { 160 161 // Header search toggle 162 $('#trigger-header-search, .widget_search, .error-search').on('click', function () { 163 var overlay = $('#wrapper > .searchform-overlay'), 164 overlayInner = $('#wrapper > .searchform-overlay > .searchform-overlay-inner'); 165 overlay.addClass('header-search-active'); 166 setTimeout(function () { 167 $('.search-input').focus(); 168 }, 300); 169 170 overlayInner.unbind().on('click', function (e) { 171 if (overlayInner.is(e.target)) // ... nor a descendant of the container 172 { 173 overlay.removeClass('header-search-active'); 174 $('.search-input').val(''); 175 $(document).unbind('keyup'); 176 } 177 }); 178 179 $(document).unbind().keyup(function (e) { 180 if (e.keyCode == 27) { 181 overlayInner.trigger('click'); 182 } 183 }); 184 }); 185 } 186 187 188 189 /********************* 190 Sticky header 191 *********************/ 192 function stickyHeader() { 193 if ( $('.sticky-enabled').length ) { 194 195 $(window).scroll(function() { 196 var scrolled = $(this).scrollTop(), 197 headerOffset = $('#site-header').offset().top; 198 199 if ( $('#top-bar').length ) { 200 headerOffset -= parseInt($('#wrapper').css('padding-top')); 201 viewport = updateViewportDimensions(); 202 203 if (viewport.width <= 600 && $('.admin-bar').length) { 204 headerOffset += $('#top-bar').height(); 205 } 206 } 207 208 if(scrolled > headerOffset ) { 209 $('#header-wrapper').addClass('header-sticked'); 210 $('#title-slope').addClass('title-header-sticked'); 211 $('#site-header').addClass('header-container-sticked'); 212 213 if ( $('.sticked-light').length ) { 214 $('#site-header').addClass('sticked-menu-light'); 215 } 216 217 if ( $('.sticked-dark').length ) { 218 $('#site-header').addClass('sticked-menu-dark'); 219 } 220 } else { 221 $('#header-wrapper').removeClass('header-sticked'); 222 $('#title-slope').removeClass('title-header-sticked'); 223 $('#site-header').removeClass('header-container-sticked'); 224 225 $('#site-header').removeClass('sticked-menu-light'); 226 $('#site-header').removeClass('sticked-menu-dark'); 227 } 228 }); 229 } 230 } 231 232 233 234 /********************* 235 Parallax background 236 *********************/ 237 238 var offsets = {}; 239 240 function scrollEvent(){ 241 242 var windowHeight = $(window).height(); 243 244 $('.parallax-bg, .scale-bg').each(function(){ 245 var $this = $(this), 246 scrollTop = $(window).scrollTop(), 247 bottom = windowHeight + scrollTop, 248 offset = $this.closest('.main_row').offset().top, 249 height = $this.outerHeight(), 250 parSpeed = $this.attr('data-parallax-speed'), 251 scaleSpeed = $this.attr('data-scaling-speed'), 252 maxOffset = offset + windowHeight, 253 newHeight = Math.round(($this.closest('.main_row').outerHeight() + (windowHeight * parSpeed)) / $this.closest('.main_row').outerHeight() * 100); 254 255 // Check if above or below viewport 256 if (offset + height <= scrollTop || offset >= scrollTop + windowHeight) { 257 return; 258 } 259 260 var position = - Math.round((offset - scrollTop) * parSpeed * 10000) / 10000, 261 maxScale = windowHeight + $this.closest('.main_row').outerHeight(), 262 step = scaleSpeed / maxScale, 263 scale = 1 + (scrollTop + windowHeight - offset) * step; 264 265 if ( $this.hasClass('parallax-bg') ) { 266 if ( $this.hasClass('scale-bg') ) { 267 $this.css({'transform':'translate3d(0, ' + position +'px,0) scale(' + scale + ')', 268 '-webkit-transform':'translate3d(0, ' + position +'px,0) scale(' + scale + ')'}); 269 } else { 270 $this.css({'transform':'translate3d(0, ' + position +'px,0)', 271 '-webkit-transform':'translate3d(0, ' + position +'px,0)'}); 272 } 273 } else if ( $this.hasClass('scale-bg') ) { 274 $this.css({'transform':'scale(' + scale + ')'}); 275 } 276 277 $this.css({'height': newHeight + '%' }); 278 $this.removeClass('bg-init'); 279 }); 280 281 $('.bg-image').each(function(){ 282 if ( ! $(this).hasClass('parallax-bg') && ! $(this).hasClass('scale-bg') ) { 283 $(this).removeClass('bg-init'); 284 } 285 }); 286 287 $('.content-fadeout').each(function(index) { 288 var $this = $(this), 289 scrollTop = $(window).scrollTop(), 290 bottom = windowHeight + scrollTop, 291 offset = $this.closest('.main_row').offset().top, 292 el_offset = $this.offset().top, 293 cont_height = $this.closest('.main_row').outerHeight(), 294 el_height = $this.innerHeight(), 295 offset_bot = (el_offset - offset) + el_height, 296 add_space = $('#main').offset().top + $('#header-wrapper').height(); 297 298 var shift; 299 if (isNaN(offsets[index])) { 300 shift = 0; 301 } else { 302 shift = offsets[index]; 303 } 304 305 if ( $this.closest('.main_row').find('.slope-bottom-inside').length ) { 306 add_space -= $this.closest('.main_row').find('.slope-bottom-inside').height() / 2; 307 } 308 309 var speed = (cont_height - ((el_offset - offset) + el_height) + shift + add_space) / (cont_height); 310 311 // Check if above or below viewport 312 if (offset + cont_height <= scrollTop || offset >= scrollTop + windowHeight) { 313 return; 314 } 315 316 var position = - Math.round((offset - scrollTop) * speed * 10000) / 10000, 317 maxScale = $this.closest('.main_row').outerHeight(), 318 step = - 1.5 / maxScale, 319 opacity = 1 - Math.round((offset - scrollTop) * step * 10000) / 10000; 320 321 if (opacity > 1) opacity = 1; 322 if (position < 0) position = 0; 323 324 $this.css({ 'transform' : 'translate3d(0, ' + position +'px,0)', 325 '-webkit-transform' : 'translate3d(0, ' + position +'px,0)', 326 'opacity' : opacity 327 }); 328 329 offsets[index] = position; 330 }); 331 } 332 333 334 335 /********************* 336 Video section 337 *********************/ 338 var videoSDiv = '.bg-video video'; 339 340 function videoSectionSize(mediaElement) { 341 var $this = $(mediaElement); 342 $this.attr('style',''); 343 var wW = $this.width(); 344 var wH = $this.height(); 345 var pW = $this.closest('.bg-video').width(); 346 var pH = $this.closest('.bg-video').height(); 347 var wR = wW/pW; 348 var hR = wH/pH; 349 var scale = Math.min(wR,hR); 350 var rW = (wW/scale); 351 var rH = (wH/scale); 352 var leftI = -Math.abs((rW-pW)/2); 353 if ( wH > pH ) { 354 var topI = (pH-wH)/2; 355 } else { 356 var topI = 0; 357 } 358 359 $this.attr('width',''); 360 $this.attr('height','');
361 $this.attr('style', 'height: auto !important; width: '+rW+'px !important; left: '+leftI+'px !important; top: '+topI+'px !important;'); 362 videoSection(videoSDiv); 363 } 364 365 366 367 /********************* 368 Vimeo background 369 *********************/ 370 function vimeoSize(video) { 371 372 var $this = $(video), 373 $iframe = $this.find('iframe'); 374 375 if ( $this.length ) { 376 var wW = $iframe.data('width') || $iframe.width(); 377 var wH = $iframe.data('height') || $iframe.height(); 378 var pW = $this.closest('.bg-video').width(); 379 var pH = $this.closest('.bg-video').height(); 380 var wR = wW/pW; 381 var hR = wH/pH; 382 var scale = Math.min(wR,hR); 383 var rH = (wH/scale)+200; 384 var rW = (wW/scale)+200/wH*wW; 385 //var rH = (wH/scale); 386 //var rW = (wW/scale); 387 var leftI = -Math.abs((rW-pW)/2); 388 if ( rH > pH ) { 389 var topI = (pH-rH)/2; 390 } else { 391 var topI = 0; 392 } 393 394 var direction = $('html').attr('dir'), 395 left = 'margin-left'; 396 397 if ( direction === 'rtl' ) { 398 left = 'margin-right'; 399 } 400 401 $this.find('iframe').attr('style', 'height: '+rH+'px; width: '+rW+'px; '+left+': '+leftI+'px; margin-top: '+topI+'px;'); 402 403 if ( !$this.hasClass('init') ) { 404 setTimeout(function() { 405 $('.bg-vimeo').closest('.bg-video').animate({'opacity': 1}, 500); 406 },500); 407 408 $this.each(function() { 409 var $this = $(this), 410 video_id = $this.data('id'); 411 412 $.getJSON('https://vimeo.com/api/oembed.json?url=https://vimeo.com/' + video_id, {format: "json"}, function(data) { 413 var details = data, 414 width = details.width, 415 height = details.height, 416 thumb = details.thumbnail_url, 417 $el = '<iframe class="twc_bg_player" data-width="'+details['width']+'" data-height="'+details['height']+'" src="//player.vimeo.com/video/'+ video_id + '?api=1&background=1&muted=1&title=0&byline=0&portrait=0&badge=0&color=0&autoplay=1&loop=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; 418 419 $($el).appendTo($this); 420 421 if (window.addEventListener) { 422 window.addEventListener('message', onMessageReceived, false); 423 } else { 424 window.attachEvent('onmessage', onMessageReceived, false); 425 } 426 427 function onMessageReceived(e) { 428 var origin = e.origin || e.originalEvent.origin; 429 if (origin !== 'https://player.vimeo.com' && origin !== 'http://player.vimeo.com') { 430 return; 431 } 432 433 var data = JSON.parse(e.data); 434 switch (data.event) { 435 case 'ready': 436 $this.closest('.bg-video').addClass('poster-hidden'); 437 break; 438 } 439 } 440 }); 441 }); 442 } 443 $this.addClass('init'); 444 445 } 446 } 447 448 449 450 /********************* 451 Youtube background 452 *********************/ 453 454 function startYoutubeInit() { 455 $('.bg-youtube').each(function() { 456 var $row = $(this), 457 youtubeId = $row.data('youtube-id'); 458 459 if ( youtubeId ) { 460 $row.find( '.vc_video-bg' ).remove(); 461 youtubeInit( $row, youtubeId ); 462 } 463 } ); 464 } 465 466 // Insert youtube video into element. 467 // Video will be w/o controls, muted, autoplaying and looping. 468 function youtubeInit($element, youtubeId, counter) { 469 if ( 'undefined' === typeof( YT.Player ) ) { 470 // wait for youtube iframe api to load. try for 10sec, then abort 471 counter = 'undefined' === typeof( counter ) ? 0 : counter; 472 if ( counter > 100 ) { 473 console.warn( 'Too many attempts to load YouTube api' ); 474 return; 475 } 476 477 setTimeout( function () { 478 youtubeInit( $element, youtubeId, counter ++ ); 479 }, 100 ); 480 481 return; 482 } 483 484 var player, 485 $container = $element.prepend( '<div class="youtube-player"></div>' ).find( '.youtube-player' ); 486 487 player = new YT.Player( $container[ 0 ], { 488 width: '100%', 489 height: '100%', 490 videoId: youtubeId, 491 playerVars: { 492 playlist: youtubeId, 493 iv_load_policy: 3, // hide annotations 494 enablejsapi: 1, 495 disablekb: 1, 496 autoplay: 1, 497 controls: 0, 498 showinfo: 0, 499 rel: 0, 500 loop: 1 501 }, 502 events: { 503 onReady: function ( event ) { 504 event.target.mute().setLoop( true ); 505 $element.closest('.bg-video').addClass('poster-hidden'); 506 } 507 } 508 } ); 509 510 youtubeSize( $element ); 511 } 512 513 // Resize background video iframe so that video content covers whole area 514 function youtubeSize( $element ) { 515 var iframeW, 516 iframeH, 517 marginLeft, 518 marginTop, 519 containerW = $element.closest('.bg-video').innerWidth(), 520 containerH = $element.closest('.bg-video').innerHeight(), 521 ratio1 = 16, 522 ratio2 = 9; 523 524 if ( ( containerW / containerH ) < ( ratio1 / ratio2 ) ) { 525 iframeW = containerH * (ratio1 / ratio2); 526 iframeH = containerH; 527 528 marginLeft = - Math.abs( ( iframeW - containerW ) / 2 ) + 'px'; 529 marginTop = - Math.abs( ( iframeH - containerH ) / 2 ) + 'px'; 530 531 iframeW += 'px'; 532 iframeH += 'px'; 533 } else { 534 iframeW = containerW; 535 iframeH = containerW * (ratio2 / ratio1); 536 537 marginTop = - Math.round( ( iframeH - containerH ) / 2 ) + 'px'; 538 marginLeft = - Math.round( ( iframeW - containerW ) / 2 ) + 'px'; 539 540 iframeW += 'px'; 541 iframeH += 'px'; 542 } 543 544 $element.find('iframe').css( { 545 maxWidth: '1000%', 546 marginLeft: marginLeft, 547 marginTop: marginTop, 548 width: iframeW, 549 height: iframeH 550 } ); 551 } 552 553 // Extract video ID from youtube url 554 function vcExtractYoutubeId( url ) { 555 if ( 'undefined' === typeof(url) ) { 556 return false;
557 } 558 559 var id = url.match( /(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/ ); 560 561 if ( null != id ) { 562 return id[ 1 ]; 563 } 564 565 return false; 566 } 567 568 569 570 /********************* 571 Self-hosted video 572 *********************/ 573 function videoSection(mediaElement) { 574 575 if ($(mediaElement).length) { 576 var videosSection = []; 577 $(mediaElement).mediaelementplayer({ 578 features: ['volume'], 579 pauseOtherPlayers: false, 580 loop: true, 581 startVolume: 0.0, 582 success: function(mediaElement, domObject) { 583 mediaElement.addEventListener('play', function(e) { 584 $(mediaElement).closest('.bg-video').addClass('poster-hidden'); 585 }); 586 videosSection.push(mediaElement); 587 mediaElement.pause(); 588 mediaElement.load(); 589 mediaElement.addEventListener('loadeddata', function(e) { 590 videoSectionSize(mediaElement); 591 mediaElement.play(); 592 }); 593 }, 594 error: function(domObject) { 595 $(domObject).closest('.mejs-container').remove(); 596 } 597 }); 598 } 599 } 600 601 602 603 /********************* 604 Custom slope height 605 *********************/ 606 function customSlopeHeight() { 607 $('.custom-slope-tablet, .custom-slope-mobile').each(function() { 608 var heightT = $(this).data('slope-tablet'), 609 heightM = $(this).data('slope-mobile'), 610 $slope = $(this).find('.row-slope'), 611 windowW = updateViewportDimensions().width; 612 613 if ( windowW < 768 ) { 614 if ( $(this).hasClass('custom-slope-mobile') && heightM !== '' && $slope.length ) { 615 $slope.css({'max-height': heightM}); 616 $slope.find('svg').css({'height': heightM}); 617 } 618 } else if ( windowW < 979 ) { 619 if ( $(this).hasClass('custom-slope-tablet') && heightT !== '' && $slope.length ) { 620 $slope.css({'max-height': heightT}); 621 $slope.find('svg').css({'height': heightT}); 622 } 623 } else { 624 $slope.css({'max-height': ''}); 625 $slope.find('svg').css({'height': ''}); 626 } 627 628 }); 629 } 630 631 632 /********************* 633 To-Top navigation 634 *********************/ 635 function toTop() { 636 $('a[href="#top"]').on('click', function(e) { 637 e.preventDefault(); 638 var speed = 2, 639 time = Math.abs($(window).scrollTop()) / speed; 640 $('html, body').animate({scrollTop:0}, time); 641 }); 642 643 $(window).scroll(function(){ 644 var windowHeight = updateViewportDimensions(); 645 if ( $(window).scrollTop() > windowHeight.height / 2) { 646 $('.scrollToTop').removeClass('invisible'); 647 } else { 648 $('.scrollToTop').addClass('invisible'); 649 } 650 }); 651 } 652 653 654 655 /*********************
656 One-Page Menu Navigation 657 *********************/ 658 function toSection() { 659 $(document).ready(function () { 660 var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); 661 if (window.location.hash && isChrome) { 662 setTimeout(function () { 663 var hash = window.location.hash; 664 window.location.hash = ""; 665 window.location.hash = hash; 666 }, 300); 667 } 668 }); 669 670 $("a[href*='#']").click(function(e) { 671 var link = $(this)[0].hash; 672 673 var newPath = $(this)[0].href.match(/(^[^#]*)/)[0], 674 currPath = window.location.href.match(/(^[^#]*)/)[0], 675 href = $(this).attr('href'); 676 677 if ( $(this).closest('#mobile-site-navigation').length && 678 !$(this).is('a[href="#mobile-site-navigation"]') && 679 currPath === newPath && 680 !$(this).is('.mm-subopen') && 681 !$(this).attr('href') !== '' ) { 682 e.preventDefault(); 683 var menu = $("#mobile-site-navigation").data( "mmenu" ); 684 menu.close(); 685 e.preventDefault(); 686 sectionScroll(link, true); 687 } 688 689 if ( !$(this).closest('#mobile-site-navigation').length && 690 $(link).length && !$(this).hasClass('ui-tabs-anchor') && 691 !$(this).find('.vc_tta-title-text').length && 692 !$(this).closest('ul').hasClass('wc-tabs') && 693 !$(this).closest('ul').hasClass('vc_pagination') && 694 currPath === newPath && 695 $(this).attr('href') !== '' ) { 696 e.preventDefault(); 697 sectionScroll(link, true); 698 } 699 }); 700 701 if ('scrollRestoration' in history) { 702 history.scrollRestoration = 'manual'; 703 } 704 705 if(history.pushState) { 706 window.onpopstate = function(e) { 707 if (e.state) { 708 var hash = e.state.hash; 709 if ( $(hash).length ) { 710 sectionScroll(hash, false); 711 } 712 } 713 }; 714 } else { 715 window.onhashchange = function(e) { 716 var hash = window.location.hash; 717 if ( $(hash).length ) { 718 sectionScroll(hash, true); 719 } 720 }; 721 } 722 723 // Cache selectors 724 var lastId, 725 topMenu = $("#site-navigation"), 726 topMenuHeight = topMenu.outerHeight()+15, 727 // All list items 728 menuItems = topMenu.find('a'), 729 // Anchors corresponding to menu items 730 scrollItems = menuItems.map(function(){ 731 var item = $($(this)[0].hash); 732 var newPath = $(this)[0].href.match(/(^[^#]*)/)[0], 733 currPath = window.location.href.match(/(^[^#]*)/)[0]; 734 if (item.length && newPath === currPath) { 735 return item; 736 } 737 }); 738 739 // Bind to scroll 740 $(window).scroll(function(){ 741 // Get container scroll position 742 var fromTop = $(this).scrollTop()+topMenuHeight; 743 744 // Get id of current scroll item 745 var cur = scrollItems.map(function(){ 746 if ($(this).offset().top < fromTop) { 747 return this; 748 } 749 }); 750 // Get the id of the current element 751 cur = cur[cur.length-1]; 752 var id = cur && cur.length ? cur[0].id : ""; 753 754 if (lastId !== id && id !== '') { 755 lastId = id; 756 // Set/remove active class 757 menuItems 758 .parent().removeClass("current-menu-ancestor") 759 .end().filter('[href*="#'+id+'"]').parent().addClass("current-menu-ancestor"); 760 } 761 }); 762 763 var menuLinks = $("#site-navigation .menu-container").find('a'); 764 menuLinks.each(function() { 765 var hash = $(this)[0].hash; 766 if ( hash !== '' ) { 767 $(this).closest('.current-menu-item').removeClass('current-menu-item'); 768 $(this).closest('.current-menu-ancestor').removeClass('current-menu-ancestor'); 769 } 770 }); 771 setTimeout(function() { 772 $('#site-header').removeClass('header-hidden'); 773 },500); 774 } 775 776 777 778 // scroll 779 function collarsTabsMobile() { 780 var $nav = $('.twc-tab-nav-mobile'); 781 782 $nav.on('click', function(e) { 783 e.preventDefault(); 784 785 var link = $(this).attr('href'); 786 787 if ( !$(this).parent('li').hasClass('ui-tabs-active ui-state-active') ) { 788 $(this).closest('.wpb_tour_tabs_wrapper').find('a[href="'+link+'"]:not(.twc-tab-nav-mobile)').trigger('click'); 789 $(this).closest('.wpb_tour_tabs_wrapper').find('.twc-tab-nav-mobile').parent('li').removeClass('ui-tabs-active ui-state-active'); 790 $(this).parent('li').addClass('ui-tabs-active ui-state-active'); 791 } 792 }) 793 } 794 795 796 797 798 // scroll 799 function sectionScroll(link, scroll) { 800 801 if ( $(link).length ) { 802 var speed = 2, 803 offset = $(link).offset().top - $('#header-wrapper').height(), 804 time = Math.abs($(window).scrollTop() - offset) / speed, 805 $body = $('body'); 806 807 if ( !$body.hasClass('scrolling') ) { 808 $body.addClass('scrolling'); 809 $('html, body').animate({scrollTop: offset}, time, function(){ 810 if(history.pushState) { 811 if ( $body.hasClass('scrolling') ) { 812 if (scroll) { 813 history.pushState({hash: link}, null, link); 814 } 815 $body.removeClass('scrolling'); 816 } 817 } else { 818 if ( $body.hasClass('scrolling') ) { 819 parent.location.hash = link; 820 $body.removeClass('scrolling'); 821 } 822 } 823 }); 824 } 825 826 } 827 } 828 829 830 831 /********************* 832 Button Hover Animation 833 *********************/ 834 function buttonHover() { 835 836 $('.twc_custom_button').each(function(){ 837 var $this = $(this), 838 textColor = $this.css('color'), 839 bgColor = $this.css('background-color'), 840 borderColor = $this.css('border-color'), 841 borderRadius = $this.css('border-radius'); 842 843 $this.mouseenter(function() { 844 var textColorH = $this.data('hc'), 845 bgColorH = $this.data('hbgc'), 846 borderColorH = $this.data('hbc'), 847 borderRadiusH = $this.data('hbr'); 848 849 $this.css({ 850 color : textColorH, 851 backgroundColor : bgColorH, 852 borderColor : borderColorH, 853 borderRadius : borderRadiusH 854 }, 200 ); 855 856 $this.mouseleave(function() { 857 $this.css({ 858 color : textColor, 859 backgroundColor : bgColor, 860 borderColor : borderColor, 861 borderRadius : borderRadius 862 }, 200 ); 863 $this.unbind('mouseleave'); 864 }); 865 }); 866 }); 867 } 868 869 870 871 /********************* 872 Modal Window 873 *********************/ 874 875 function modalWindow() { 876 $('.twc_modal_window').each(function() { 877 // move modal to body and remove the containing row 878 var $this = $(this), 879 $row = $this.closest('.wpb_row'); 880 $this.appendTo('body'); 881 $row.remove(); 882 883 $this.find('.twc_mw_close').on('click', function() { 884 $this.modal('hide'); 885 }); 886 }); 887 888 889 // handle modal trigger
vendor: 6,562 bytes, lines 890-1145
890 $("a[href^='#modal-']").click(function(e) { 891 e.preventDefault(); 892 893 // get the target 894 var link = $(this).attr('href'); 895 link = link.substring(link.indexOf("#modal-") + 7); 896 var $target = $('.twc_modal_window#'+link); 897 898 if ( $($target).length ) { 899 $target.modal('show'); 900 901 // show modal 902 $('body').addClass('modal-open'); 903 904 // add blur to background 905 if ($target.hasClass('blur') || $target.hasClass('color_blur')) { 906 $('#wrapper').addClass('modal-blur'); 907 } 908 909 // remove blur on modal close 910 $target.on('hidden.bs.modal', function (e) { 911 $('#wrapper').removeClass('modal-blur'); 912 }) 913 } 914 }); 915 } 916 917 // Bootstrap Modal 918 +function ($) { 919 'use strict'; 920 921 // MODAL CLASS DEFINITION 922 // ====================== 923 924 var Modal = function (element, options) { 925 this.options = options 926 this.$body = $(document.body) 927 this.$element = $(element) 928 this.$dialog = this.$element.find('.modal-dialog') 929 this.$backdrop = null 930 this.isShown = null 931 this.originalBodyPad = null 932 this.scrollbarWidth = 0 933 this.ignoreBackdropClick = false 934 935 if (this.options.remote) { 936 this.$element 937 .find('.modal-content') 938 .load(this.options.remote, $.proxy(function () { 939 this.$element.trigger('loaded.bs.modal') 940 }, this)) 941 } 942 } 943 944 Modal.VERSION = '3.3.5' 945 946 Modal.TRANSITION_DURATION = 300 947 Modal.BACKDROP_TRANSITION_DURATION = 150 948 949 Modal.DEFAULTS = { 950 backdrop: true, 951 keyboard: true, 952 show: true 953 } 954 955 Modal.prototype.toggle = function (_relatedTarget) { 956 return this.isShown ? this.hide() : this.show(_relatedTarget) 957 } 958 959 Modal.prototype.show = function (_relatedTarget) { 960 var that = this 961 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) 962 963 this.$element.trigger(e) 964 965 if (this.isShown || e.isDefaultPrevented()) return 966 967 this.isShown = true 968 969 this.checkScrollbar() 970 this.setScrollbar() 971 this.$body.addClass('modal-open') 972 973 this.escape() 974 this.resize() 975 976 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) 977 978 this.$dialog.on('mousedown.dismiss.bs.modal', function () { 979 that.$element.one('mouseup.dismiss.bs.modal', function (e) { 980 if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true 981 }) 982 }) 983 984 this.backdrop(function () { 985 var transition = $.support.transition && that.$element.hasClass('fade') 986 987 if (!that.$element.parent().length) { 988 that.$element.appendTo(that.$body) // don't move modals dom position 989 } 990 991 that.$element 992 .show() 993 .scrollTop(0) 994 995 that.adjustDialog() 996 997 if (transition) { 998 that.$element[0].offsetWidth // force reflow 999 } 1000 1001 that.$element.addClass('in') 1002 1003 that.enforceFocus() 1004 1005 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) 1006 1007 transition ? 1008 that.$dialog // wait for modal to slide in 1009 .one('bsTransitionEnd', function () { 1010 that.$element.trigger('focus').trigger(e) 1011 }) 1012 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 1013 that.$element.trigger('focus').trigger(e) 1014 }) 1015 } 1016 1017 Modal.prototype.hide = function (e) { 1018 if (e) e.preventDefault() 1019 1020 e = $.Event('hide.bs.modal') 1021 1022 this.$element.trigger(e) 1023 1024 if (!this.isShown || e.isDefaultPrevented()) return 1025 1026 this.isShown = false 1027 1028 this.escape() 1029 this.resize() 1030 1031 $(document).off('focusin.bs.modal') 1032 1033 this.$element 1034 .removeClass('in') 1035 .off('click.dismiss.bs.modal') 1036 .off('mouseup.dismiss.bs.modal') 1037 1038 this.$dialog.off('mousedown.dismiss.bs.modal') 1039 1040 $.support.transition && this.$element.hasClass('fade') ? 1041 this.$element 1042 .one('bsTransitionEnd', $.proxy(this.hideModal, this)) 1043 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 1044 this.hideModal() 1045 } 1046 1047 Modal.prototype.enforceFocus = function () { 1048 $(document) 1049 .off('focusin.bs.modal') // guard against infinite focus loop 1050 .on('focusin.bs.modal', $.proxy(function (e) { 1051 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { 1052 this.$element.trigger('focus') 1053 } 1054 }, this)) 1055 } 1056 1057 Modal.prototype.escape = function () { 1058 if (this.isShown && this.options.keyboard) { 1059 this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { 1060 e.which == 27 && this.hide() 1061 }, this)) 1062 } else if (!this.isShown) { 1063 this.$element.off('keydown.dismiss.bs.modal') 1064 } 1065 } 1066 1067 Modal.prototype.resize = function () { 1068 if (this.isShown) { 1069 $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this)) 1070 } else { 1071 $(window).off('resize.bs.modal') 1072 } 1073 } 1074 1075 Modal.prototype.hideModal = function () { 1076 var that = this 1077 this.$element.hide() 1078 this.backdrop(function () { 1079 that.$body.removeClass('modal-open') 1080 that.resetAdjustments() 1081 that.resetScrollbar() 1082 that.$element.trigger('hidden.bs.modal') 1083 }) 1084 } 1085 1086 Modal.prototype.removeBackdrop = function () { 1087 this.$backdrop && this.$backdrop.remove() 1088 this.$backdrop = null 1089 } 1090 1091 Modal.prototype.backdrop = function (callback) { 1092 var that = this 1093 var animate = 'fade' 1094 1095 if (this.isShown && this.options.backdrop) { 1096 var doAnimate = $.support.transition && animate 1097 1098 this.$backdrop = $(document.createElement('div')) 1099 .addClass('modal-backdrop ' + animate) 1100 .css({backgroundColor: this.$element.data('overlay')}) 1101 .appendTo(this.$body) 1102 1103 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { 1104 if (this.ignoreBackdropClick) { 1105 this.ignoreBackdropClick = false 1106 return 1107 } 1108 if (e.target !== e.currentTarget) return 1109 this.options.backdrop == 'static' 1110 ? this.$element[0].focus() 1111 : this.hide() 1112 }, this)) 1113 1114 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow 1115 1116 this.$backdrop.addClass('in') 1117 1118 if (!callback) return 1119 1120 doAnimate ? 1121 this.$backdrop 1122 .one('bsTransitionEnd', callback) 1123 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 1124 callback() 1125 1126 } else if (!this.isShown && this.$backdrop) { 1127 this.$backdrop.removeClass('in') 1128 1129 var callbackRemove = function () { 1130 that.removeBackdrop() 1131 callback && callback() 1132 } 1133 $.support.transition && this.$element.hasClass('fade') ? 1134 this.$backdrop 1135 .one('bsTransitionEnd', callbackRemove) 1136 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 1137 callbackRemove() 1138 1139 } else if (callback) { 1140 callback() 1141 } 1142 } 1143 1144 // these following methods are used to handle overflowing modals 1145
1146 Modal.prototype.handleUpdate = function () { 1147 this.adjustDialog() 1148 } 1149 1150 Modal.prototype.adjustDialog = function () { 1151 var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight 1152 1153 this.$element.css({ 1154 paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '', 1155 paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : '' 1156 }) 1157 } 1158 1159 Modal.prototype.resetAdjustments = function () { 1160 this.$element.css({ 1161 paddingLeft: '', 1162 paddingRight: '' 1163 }) 1164 } 1165 1166 Modal.prototype.checkScrollbar = function () { 1167 var fullWindowWidth = window.innerWidth 1168 if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8 1169 var documentElementRect = document.documentElement.getBoundingClientRect() 1170 fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left) 1171 } 1172 this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth 1173 this.scrollbarWidth = this.measureScrollbar() 1174 } 1175 1176 Modal.prototype.setScrollbar = function () { 1177 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) 1178 this.originalBodyPad = document.body.style.paddingRight || '' 1179 if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) 1180 if (this.bodyIsOverflowing) $('#header-wrapper').css('padding-right', this.scrollbarWidth); 1181 } 1182 1183 Modal.prototype.resetScrollbar = function () { 1184 this.$body.css('padding-right', this.originalBodyPad) 1185 $('#header-wrapper').css('padding-right', 0); 1186 } 1187 1188 Modal.prototype.measureScrollbar = function () { // thx walsh 1189 var scrollDiv = document.createElement('div') 1190 scrollDiv.className = 'modal-scrollbar-measure' 1191 this.$body.append(scrollDiv) 1192 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth 1193 this.$body[0].removeChild(scrollDiv) 1194 return scrollbarWidth 1195 } 1196 1197 1198 // MODAL PLUGIN DEFINITION 1199 // ======================= 1200 1201 function Plugin(option, _relatedTarget) { 1202 return this.each(function () { 1203 var $this = $(this) 1204 var data = $this.data('bs.modal') 1205 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) 1206 1207 if (!data) $this.data('bs.modal', (data = new Modal(this, options))) 1208 if (typeof option == 'string') data[option](_relatedTarget) 1209 else if (options.show) data.show(_relatedTarget) 1210 }) 1211 } 1212 1213 var old = $.fn.modal 1214 1215 $.fn.modal = Plugin 1216 $.fn.modal.Constructor = Modal 1217 1218 1219 // MODAL NO CONFLICT 1220 // ================= 1221 1222 $.fn.modal.noConflict = function () { 1223 $.fn.modal = old 1224 return this 1225 } 1226 1227 1228 // MODAL DATA-API 1229 // ============== 1230 1231 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { 1232 var $this = $(this) 1233 var href = $this.attr('href') 1234 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7 1235 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) 1236 1237 if ($this.is('a')) e.preventDefault() 1238 1239 $target.one('show.bs.modal', function (showEvent) { 1240 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown 1241 $target.one('hidden.bs.modal', function () { 1242 $this.is(':visible') && $this.trigger('focus') 1243 }) 1244 }) 1245 Plugin.call($target, option, this) 1246 }) 1247 1248 }(jQuery); 1249 1250 +function ($) { 1251 'use strict'; 1252 1253 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) 1254 // ============================================================ 1255 1256 function transitionEnd() { 1257 var el = document.createElement('bootstrap') 1258 1259 var transEndEventNames = { 1260 WebkitTransition : 'webkitTransitionEnd', 1261 MozTransition : 'transitionend', 1262 OTransition : 'oTransitionEnd otransitionend', 1263 transition : 'transitionend' 1264 } 1265 1266 for (var name in transEndEventNames) { 1267 if (el.style[name] !== undefined) { 1268 return { end: transEndEventNames[name] } 1269 } 1270 } 1271 1272 return false // explicit for ie8 ( ._.) 1273 } 1274 1275 // http://blog.alexmaccaw.com/css-transitions 1276 $.fn.emulateTransitionEnd = function (duration) { 1277 var called = false 1278 var $el = this 1279 $(this).one('bsTransitionEnd', function () { called = true }) 1280 var callback = function () { if (!called) $($el).trigger($.support.transition.end) } 1281 setTimeout(callback, duration) 1282 return this 1283 } 1284 1285 $(function () { 1286 $.support.transition = transitionEnd() 1287 1288 if (!$.support.transition) return 1289 1290 $.event.special.bsTransitionEnd = { 1291 bindType: $.support.transition.end, 1292 delegateType: $.support.transition.end, 1293 handle: function (e) { 1294 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments) 1295 } 1296 } 1297 }) 1298 1299 }(jQuery); 1300 1301 1302 1303 jQuery(document).ready(function($) { 1304 1305 // Trigger scroll 1306 setTimeout( function(){ 1307 $(window).scroll().trigger('resize'); 1308 }, 500 ); 1309 1310 function draw() { 1311 //requestAnimationFrame(draw); 1312 // Drawing code goes here 1313 //scrollEvent(); 1314 1315 $(window).scroll(function(){ 1316 scrollEvent(); 1317 }); 1318 } 1319 1320 var $body = $('body'); 1321 if ( $body.hasClass('page') && !$body.hasClass('woocommerce-page') && !$('#container').find('.wpb_row').length ) { 1322 $body.addClass('wtbx-def-page'); 1323 } 1324 1325 draw(); 1326 1327 submenu_fix(); 1328 1329 el_hover_fix(); 1330 1331 loadGravatars(); 1332 1333 searchButton(); 1334 1335 stickyHeader(); 1336 1337 videoSectionSize($('.bg-video video')); 1338 1339 vimeoSize($('.bg-vimeo')); 1340 1341 startYoutubeInit(); 1342 1343 toTop(); 1344 1345 toSection(); 1346 1347 resizeRows(); 1348 1349 buttonHover(); 1350 1351 modalWindow(); 1352 1353 collarsTabsMobile(); 1354 1355 }); /* end of as page load scripts */ 1356 1357})(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.