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 $.ajax({ 413 type:'GET', 414 url: 'http://vimeo.com/api/v2/video/' + video_id + '.json', 415 jsonp: 'callback', 416 dataType: 'jsonp', 417 success: function(response){ 418 var details = response[0], 419 width = details['width'], 420 height = details['height'], 421 thumb = details['thumbnail_large'], 422 $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>'; 423 424 $($el).appendTo($this); 425 426 if (window.addEventListener) { 427 window.addEventListener('message', onMessageReceived, false); 428 } else { 429 window.attachEvent('onmessage', onMessageReceived, false); 430 } 431 432 function onMessageReceived(e) { 433 var origin = e.origin || e.originalEvent.origin; 434 435 if (origin !== 'https://player.vimeo.com' && origin !== 'http://player.vimeo.com') { 436 return; 437 } 438 439 var data = JSON.parse(e.data); 440 switch (data.event) { 441 case 'ready': 442 $this.closest('.bg-video').addClass('poster-hidden'); 443 break; 444 } 445 } 446 } 447 }); 448 }); 449 } 450 $this.addClass('init'); 451 452 } 453 } 454 455 456 457 /********************* 458 Youtube background 459 *********************/ 460 461 function startYoutubeInit() { 462 $('.bg-youtube').each(function() { 463 var $row = $(this), 464 youtubeId = $row.data('youtube-id'); 465 466 if ( youtubeId ) { 467 $row.find( '.vc_video-bg' ).remove(); 468 youtubeInit( $row, youtubeId ); 469 } 470 } ); 471 } 472 473 // Insert youtube video into element. 474 // Video will be w/o controls, muted, autoplaying and looping. 475 function youtubeInit($element, youtubeId, counter) { 476 if ( 'undefined' === typeof( YT.Player ) ) { 477 // wait for youtube iframe api to load. try for 10sec, then abort 478 counter = 'undefined' === typeof( counter ) ? 0 : counter; 479 if ( counter > 100 ) { 480 console.warn( 'Too many attempts to load YouTube api' ); 481 return; 482 } 483 484 setTimeout( function () { 485 youtubeInit( $element, youtubeId, counter ++ ); 486 }, 100 ); 487 488 return; 489 } 490 491 var player, 492 $container = $element.prepend( '<div class="youtube-player"></div>' ).find( '.youtube-player' ); 493 494 player = new YT.Player( $container[ 0 ], { 495 width: '100%', 496 height: '100%', 497 videoId: youtubeId, 498 playerVars: { 499 playlist: youtubeId, 500 iv_load_policy: 3, // hide annotations 501 enablejsapi: 1, 502 disablekb: 1, 503 autoplay: 1, 504 controls: 0, 505 showinfo: 0, 506 rel: 0, 507 loop: 1 508 }, 509 events: { 510 onReady: function ( event ) { 511 event.target.mute().setLoop( true ); 512 $element.closest('.bg-video').addClass('poster-hidden'); 513 } 514 } 515 } ); 516 517 youtubeSize( $element ); 518 } 519 520 // Resize background video iframe so that video content covers whole area 521 function youtubeSize( $element ) { 522 var iframeW, 523 iframeH, 524 marginLeft, 525 marginTop, 526 containerW = $element.closest('.bg-video').innerWidth(), 527 containerH = $element.closest('.bg-video').innerHeight(), 528 ratio1 = 16, 529 ratio2 = 9; 530 531 if ( ( containerW / containerH ) < ( ratio1 / ratio2 ) ) { 532 iframeW = containerH * (ratio1 / ratio2); 533 iframeH = containerH; 534 535 marginLeft = - Math.abs( ( iframeW - containerW ) / 2 ) + 'px'; 536 marginTop = - Math.abs( ( iframeH - containerH ) / 2 ) + 'px'; 537 538 iframeW += 'px'; 539 iframeH += 'px'; 540 } else { 541 iframeW = containerW; 542 iframeH = containerW * (ratio2 / ratio1); 543 544 marginTop = - Math.round( ( iframeH - containerH ) / 2 ) + 'px'; 545 marginLeft = - Math.round( ( iframeW - containerW ) / 2 ) + 'px'; 546 547 iframeW += 'px'; 548 iframeH += 'px'; 549 } 550 551 $element.find('iframe').css( { 552 maxWidth: '1000%', 553 marginLeft: marginLeft, 554 marginTop: marginTop, 555 width: iframeW, 556 height: iframeH 557 } ); 558 } 559 560 // Extract video ID from youtube url 561 function vcExtractYoutubeId( url ) { 562 if ( 'undefined' === typeof(url) ) { 563 return false;
564 } 565 566 var id = url.match( /(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/ ); 567 568 if ( null != id ) { 569 return id[ 1 ]; 570 } 571 572 return false; 573 } 574 575 576 577 /********************* 578 Self-hosted video 579 *********************/ 580 function videoSection(mediaElement) { 581 582 if ($(mediaElement).length) { 583 var videosSection = []; 584 $(mediaElement).mediaelementplayer({ 585 features: ['volume'], 586 pauseOtherPlayers: false, 587 loop: true, 588 startVolume: 0.0, 589 success: function(mediaElement, domObject) { 590 mediaElement.addEventListener('play', function(e) { 591 $(mediaElement).closest('.bg-video').addClass('poster-hidden'); 592 }); 593 videosSection.push(mediaElement); 594 mediaElement.pause(); 595 mediaElement.load(); 596 mediaElement.addEventListener('loadeddata', function(e) { 597 videoSectionSize(mediaElement); 598 mediaElement.play(); 599 }); 600 }, 601 error: function(domObject) { 602 $(domObject).closest('.mejs-container').remove(); 603 } 604 }); 605 } 606 } 607 608 609 610 /********************* 611 Custom slope height 612 *********************/ 613 function customSlopeHeight() { 614 $('.custom-slope-tablet, .custom-slope-mobile').each(function() { 615 var heightT = $(this).data('slope-tablet'), 616 heightM = $(this).data('slope-mobile'), 617 $slope = $(this).find('.row-slope'), 618 windowW = updateViewportDimensions().width; 619 620 if ( windowW < 768 ) { 621 if ( $(this).hasClass('custom-slope-mobile') && heightM !== '' && $slope.length ) { 622 $slope.css({'max-height': heightM}); 623 $slope.find('svg').css({'height': heightM}); 624 } 625 } else if ( windowW < 979 ) { 626 if ( $(this).hasClass('custom-slope-tablet') && heightT !== '' && $slope.length ) { 627 $slope.css({'max-height': heightT}); 628 $slope.find('svg').css({'height': heightT}); 629 } 630 } else { 631 $slope.css({'max-height': ''}); 632 $slope.find('svg').css({'height': ''}); 633 } 634 635 }); 636 } 637 638 639 /********************* 640 To-Top navigation 641 *********************/ 642 function toTop() { 643 $('a[href="#top"]').on('click', function(e) { 644 e.preventDefault(); 645 var speed = 2, 646 time = Math.abs($(window).scrollTop()) / speed; 647 $('html, body').animate({scrollTop:0}, time); 648 }); 649 650 $(window).scroll(function(){ 651 var windowHeight = updateViewportDimensions(); 652 if ( $(window).scrollTop() > windowHeight.height / 2) { 653 $('.scrollToTop').removeClass('invisible'); 654 } else { 655 $('.scrollToTop').addClass('invisible'); 656 } 657 }); 658 } 659 660 661 662 /*********************
663 One-Page Menu Navigation 664 *********************/ 665 function toSection() { 666 $(document).ready(function () { 667 var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); 668 if (window.location.hash && isChrome) { 669 setTimeout(function () { 670 var hash = window.location.hash; 671 window.location.hash = ""; 672 window.location.hash = hash; 673 }, 300); 674 } 675 }); 676 677 $("a[href*='#']").click(function(e) { 678 var link = $(this)[0].hash; 679 680 var newPath = $(this)[0].href.match(/(^[^#]*)/)[0], 681 currPath = window.location.href.match(/(^[^#]*)/)[0], 682 href = $(this).attr('href'); 683 684 if ( $(this).closest('#mobile-site-navigation').length && 685 !$(this).is('a[href="#mobile-site-navigation"]') && 686 currPath === newPath && 687 !$(this).is('.mm-subopen') && 688 !$(this).attr('href') !== '' ) { 689 e.preventDefault(); 690 var menu = $("#mobile-site-navigation").data( "mmenu" ); 691 menu.close(); 692 e.preventDefault(); 693 sectionScroll(link, true); 694 } 695 696 if ( !$(this).closest('#mobile-site-navigation').length && 697 $(link).length && !$(this).hasClass('ui-tabs-anchor') && 698 !$(this).find('.vc_tta-title-text').length && 699 !$(this).closest('ul').hasClass('wc-tabs') && 700 !$(this).closest('ul').hasClass('vc_pagination') && 701 currPath === newPath && 702 $(this).attr('href') !== '' ) { 703 e.preventDefault(); 704 sectionScroll(link, true); 705 } 706 }); 707 708 if ('scrollRestoration' in history) { 709 history.scrollRestoration = 'manual'; 710 } 711 712 if(history.pushState) { 713 window.onpopstate = function(e) { 714 if (e.state) { 715 var hash = e.state.hash; 716 if ( $(hash).length ) { 717 sectionScroll(hash, false); 718 } 719 } 720 }; 721 } else { 722 window.onhashchange = function(e) { 723 var hash = window.location.hash; 724 if ( $(hash).length ) { 725 sectionScroll(hash, true); 726 } 727 }; 728 } 729 730 // Cache selectors 731 var lastId, 732 topMenu = $("#site-navigation"), 733 topMenuHeight = topMenu.outerHeight()+15, 734 // All list items 735 menuItems = topMenu.find('a'), 736 // Anchors corresponding to menu items 737 scrollItems = menuItems.map(function(){ 738 var item = $($(this)[0].hash); 739 var newPath = $(this)[0].href.match(/(^[^#]*)/)[0], 740 currPath = window.location.href.match(/(^[^#]*)/)[0]; 741 if (item.length && newPath === currPath) { 742 return item; 743 } 744 }); 745 746 // Bind to scroll 747 $(window).scroll(function(){ 748 // Get container scroll position 749 var fromTop = $(this).scrollTop()+topMenuHeight; 750 751 // Get id of current scroll item 752 var cur = scrollItems.map(function(){ 753 if ($(this).offset().top < fromTop) { 754 return this; 755 } 756 }); 757 // Get the id of the current element 758 cur = cur[cur.length-1]; 759 var id = cur && cur.length ? cur[0].id : ""; 760 761 if (lastId !== id && id !== '') { 762 lastId = id; 763 // Set/remove active class 764 menuItems 765 .parent().removeClass("current-menu-ancestor") 766 .end().filter('[href*="#'+id+'"]').parent().addClass("current-menu-ancestor"); 767 } 768 }); 769 770 var menuLinks = $("#site-navigation .menu-container").find('a'); 771 menuLinks.each(function() { 772 var hash = $(this)[0].hash; 773 if ( hash !== '' ) { 774 $(this).closest('.current-menu-item').removeClass('current-menu-item'); 775 $(this).closest('.current-menu-ancestor').removeClass('current-menu-ancestor'); 776 } 777 }); 778 setTimeout(function() { 779 $('#site-header').removeClass('header-hidden'); 780 },500); 781 } 782 783 784 785 // scroll 786 function collarsTabsMobile() { 787 var $nav = $('.twc-tab-nav-mobile'); 788 789 $nav.on('click', function(e) { 790 e.preventDefault(); 791 792 var link = $(this).attr('href'); 793 794 if ( !$(this).parent('li').hasClass('ui-tabs-active ui-state-active') ) { 795 $(this).closest('.wpb_tour_tabs_wrapper').find('a[href="'+link+'"]:not(.twc-tab-nav-mobile)').trigger('click'); 796 $(this).closest('.wpb_tour_tabs_wrapper').find('.twc-tab-nav-mobile').parent('li').removeClass('ui-tabs-active ui-state-active'); 797 $(this).parent('li').addClass('ui-tabs-active ui-state-active'); 798 } 799 }) 800 } 801 802 803 804 805 // scroll 806 function sectionScroll(link, scroll) { 807 808 if ( $(link).length ) { 809 var speed = 2, 810 offset = $(link).offset().top - $('#header-wrapper').height(), 811 time = Math.abs($(window).scrollTop() - offset) / speed, 812 $body = $('body'); 813 814 if ( !$body.hasClass('scrolling') ) { 815 $body.addClass('scrolling'); 816 $('html, body').animate({scrollTop: offset}, time, function(){ 817 if(history.pushState) { 818 if ( $body.hasClass('scrolling') ) { 819 if (scroll) { 820 history.pushState({hash: link}, null, link); 821 } 822 $body.removeClass('scrolling'); 823 } 824 } else { 825 if ( $body.hasClass('scrolling') ) { 826 parent.location.hash = link; 827 $body.removeClass('scrolling'); 828 } 829 } 830 }); 831 } 832 833 } 834 } 835 836 837 838 /********************* 839 Button Hover Animation 840 *********************/ 841 function buttonHover() { 842 843 $('.twc_custom_button').each(function(){ 844 var $this = $(this), 845 textColor = $this.css('color'), 846 bgColor = $this.css('background-color'), 847 borderColor = $this.css('border-color'), 848 borderRadius = $this.css('border-radius'); 849 850 $this.mouseenter(function() { 851 var textColorH = $this.data('hc'), 852 bgColorH = $this.data('hbgc'), 853 borderColorH = $this.data('hbc'), 854 borderRadiusH = $this.data('hbr'); 855 856 $this.css({ 857 color : textColorH, 858 backgroundColor : bgColorH, 859 borderColor : borderColorH, 860 borderRadius : borderRadiusH 861 }, 200 ); 862 863 $this.mouseleave(function() { 864 $this.css({ 865 color : textColor, 866 backgroundColor : bgColor, 867 borderColor : borderColor, 868 borderRadius : borderRadius 869 }, 200 ); 870 $this.unbind('mouseleave'); 871 }); 872 }); 873 }); 874 } 875 876 877 878 /********************* 879 Modal Window 880 *********************/ 881 882 function modalWindow() { 883 $('.twc_modal_window').each(function() { 884 // move modal to body and remove the containing row 885 var $this = $(this), 886 $row = $this.closest('.wpb_row'); 887 $this.appendTo('body'); 888 $row.remove(); 889 890 $this.find('.twc_mw_close').on('click', function() { 891 $this.modal('hide'); 892 }); 893 }); 894 895 896 // handle modal trigger
vendor: 6,562 bytes, lines 897-1152
897 $("a[href^='#modal-']").click(function(e) { 898 e.preventDefault(); 899 900 // get the target 901 var link = $(this).attr('href'); 902 link = link.substring(link.indexOf("#modal-") + 7); 903 var $target = $('.twc_modal_window#'+link); 904 905 if ( $($target).length ) { 906 $target.modal('show'); 907 908 // show modal 909 $('body').addClass('modal-open'); 910 911 // add blur to background 912 if ($target.hasClass('blur') || $target.hasClass('color_blur')) { 913 $('#wrapper').addClass('modal-blur'); 914 } 915 916 // remove blur on modal close 917 $target.on('hidden.bs.modal', function (e) { 918 $('#wrapper').removeClass('modal-blur'); 919 }) 920 } 921 }); 922 } 923 924 // Bootstrap Modal 925 +function ($) { 926 'use strict'; 927 928 // MODAL CLASS DEFINITION 929 // ====================== 930 931 var Modal = function (element, options) { 932 this.options = options 933 this.$body = $(document.body) 934 this.$element = $(element) 935 this.$dialog = this.$element.find('.modal-dialog') 936 this.$backdrop = null 937 this.isShown = null 938 this.originalBodyPad = null 939 this.scrollbarWidth = 0 940 this.ignoreBackdropClick = false 941 942 if (this.options.remote) { 943 this.$element 944 .find('.modal-content') 945 .load(this.options.remote, $.proxy(function () { 946 this.$element.trigger('loaded.bs.modal') 947 }, this)) 948 } 949 } 950 951 Modal.VERSION = '3.3.5' 952 953 Modal.TRANSITION_DURATION = 300 954 Modal.BACKDROP_TRANSITION_DURATION = 150 955 956 Modal.DEFAULTS = { 957 backdrop: true, 958 keyboard: true, 959 show: true 960 } 961 962 Modal.prototype.toggle = function (_relatedTarget) { 963 return this.isShown ? this.hide() : this.show(_relatedTarget) 964 } 965 966 Modal.prototype.show = function (_relatedTarget) { 967 var that = this 968 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) 969 970 this.$element.trigger(e) 971 972 if (this.isShown || e.isDefaultPrevented()) return 973 974 this.isShown = true 975 976 this.checkScrollbar() 977 this.setScrollbar() 978 this.$body.addClass('modal-open') 979 980 this.escape() 981 this.resize() 982 983 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) 984 985 this.$dialog.on('mousedown.dismiss.bs.modal', function () { 986 that.$element.one('mouseup.dismiss.bs.modal', function (e) { 987 if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true 988 }) 989 }) 990 991 this.backdrop(function () { 992 var transition = $.support.transition && that.$element.hasClass('fade') 993 994 if (!that.$element.parent().length) { 995 that.$element.appendTo(that.$body) // don't move modals dom position 996 } 997 998 that.$element 999 .show() 1000 .scrollTop(0) 1001 1002 that.adjustDialog() 1003 1004 if (transition) { 1005 that.$element[0].offsetWidth // force reflow 1006 } 1007 1008 that.$element.addClass('in') 1009 1010 that.enforceFocus() 1011 1012 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) 1013 1014 transition ? 1015 that.$dialog // wait for modal to slide in 1016 .one('bsTransitionEnd', function () { 1017 that.$element.trigger('focus').trigger(e) 1018 }) 1019 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 1020 that.$element.trigger('focus').trigger(e) 1021 }) 1022 } 1023 1024 Modal.prototype.hide = function (e) { 1025 if (e) e.preventDefault() 1026 1027 e = $.Event('hide.bs.modal') 1028 1029 this.$element.trigger(e) 1030 1031 if (!this.isShown || e.isDefaultPrevented()) return 1032 1033 this.isShown = false 1034 1035 this.escape() 1036 this.resize() 1037 1038 $(document).off('focusin.bs.modal') 1039 1040 this.$element 1041 .removeClass('in') 1042 .off('click.dismiss.bs.modal') 1043 .off('mouseup.dismiss.bs.modal') 1044 1045 this.$dialog.off('mousedown.dismiss.bs.modal') 1046 1047 $.support.transition && this.$element.hasClass('fade') ? 1048 this.$element 1049 .one('bsTransitionEnd', $.proxy(this.hideModal, this)) 1050 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 1051 this.hideModal() 1052 } 1053 1054 Modal.prototype.enforceFocus = function () { 1055 $(document) 1056 .off('focusin.bs.modal') // guard against infinite focus loop 1057 .on('focusin.bs.modal', $.proxy(function (e) { 1058 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { 1059 this.$element.trigger('focus') 1060 } 1061 }, this)) 1062 } 1063 1064 Modal.prototype.escape = function () { 1065 if (this.isShown && this.options.keyboard) { 1066 this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { 1067 e.which == 27 && this.hide() 1068 }, this)) 1069 } else if (!this.isShown) { 1070 this.$element.off('keydown.dismiss.bs.modal') 1071 } 1072 } 1073 1074 Modal.prototype.resize = function () { 1075 if (this.isShown) { 1076 $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this)) 1077 } else { 1078 $(window).off('resize.bs.modal') 1079 } 1080 } 1081 1082 Modal.prototype.hideModal = function () { 1083 var that = this 1084 this.$element.hide() 1085 this.backdrop(function () { 1086 that.$body.removeClass('modal-open') 1087 that.resetAdjustments() 1088 that.resetScrollbar() 1089 that.$element.trigger('hidden.bs.modal') 1090 }) 1091 } 1092 1093 Modal.prototype.removeBackdrop = function () { 1094 this.$backdrop && this.$backdrop.remove() 1095 this.$backdrop = null 1096 } 1097 1098 Modal.prototype.backdrop = function (callback) { 1099 var that = this 1100 var animate = 'fade' 1101 1102 if (this.isShown && this.options.backdrop) { 1103 var doAnimate = $.support.transition && animate 1104 1105 this.$backdrop = $(document.createElement('div')) 1106 .addClass('modal-backdrop ' + animate) 1107 .css({backgroundColor: this.$element.data('overlay')}) 1108 .appendTo(this.$body) 1109 1110 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { 1111 if (this.ignoreBackdropClick) { 1112 this.ignoreBackdropClick = false 1113 return 1114 } 1115 if (e.target !== e.currentTarget) return 1116 this.options.backdrop == 'static' 1117 ? this.$element[0].focus() 1118 : this.hide() 1119 }, this)) 1120 1121 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow 1122 1123 this.$backdrop.addClass('in') 1124 1125 if (!callback) return 1126 1127 doAnimate ? 1128 this.$backdrop 1129 .one('bsTransitionEnd', callback) 1130 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 1131 callback() 1132 1133 } else if (!this.isShown && this.$backdrop) { 1134 this.$backdrop.removeClass('in') 1135 1136 var callbackRemove = function () { 1137 that.removeBackdrop() 1138 callback && callback() 1139 } 1140 $.support.transition && this.$element.hasClass('fade') ? 1141 this.$backdrop 1142 .one('bsTransitionEnd', callbackRemove) 1143 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 1144 callbackRemove() 1145 1146 } else if (callback) { 1147 callback() 1148 } 1149 } 1150 1151 // these following methods are used to handle overflowing modals 1152
1153 Modal.prototype.handleUpdate = function () { 1154 this.adjustDialog() 1155 } 1156 1157 Modal.prototype.adjustDialog = function () { 1158 var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight 1159 1160 this.$element.css({ 1161 paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '', 1162 paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : '' 1163 }) 1164 } 1165 1166 Modal.prototype.resetAdjustments = function () { 1167 this.$element.css({ 1168 paddingLeft: '', 1169 paddingRight: '' 1170 }) 1171 } 1172 1173 Modal.prototype.checkScrollbar = function () { 1174 var fullWindowWidth = window.innerWidth 1175 if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8 1176 var documentElementRect = document.documentElement.getBoundingClientRect() 1177 fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left) 1178 } 1179 this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth 1180 this.scrollbarWidth = this.measureScrollbar() 1181 } 1182 1183 Modal.prototype.setScrollbar = function () { 1184 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) 1185 this.originalBodyPad = document.body.style.paddingRight || '' 1186 if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) 1187 if (this.bodyIsOverflowing) $('#header-wrapper').css('padding-right', this.scrollbarWidth); 1188 } 1189 1190 Modal.prototype.resetScrollbar = function () { 1191 this.$body.css('padding-right', this.originalBodyPad) 1192 $('#header-wrapper').css('padding-right', 0); 1193 } 1194 1195 Modal.prototype.measureScrollbar = function () { // thx walsh 1196 var scrollDiv = document.createElement('div') 1197 scrollDiv.className = 'modal-scrollbar-measure' 1198 this.$body.append(scrollDiv) 1199 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth 1200 this.$body[0].removeChild(scrollDiv) 1201 return scrollbarWidth 1202 } 1203 1204 1205 // MODAL PLUGIN DEFINITION 1206 // ======================= 1207 1208 function Plugin(option, _relatedTarget) { 1209 return this.each(function () { 1210 var $this = $(this) 1211 var data = $this.data('bs.modal') 1212 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) 1213 1214 if (!data) $this.data('bs.modal', (data = new Modal(this, options))) 1215 if (typeof option == 'string') data[option](_relatedTarget) 1216 else if (options.show) data.show(_relatedTarget) 1217 }) 1218 } 1219 1220 var old = $.fn.modal 1221 1222 $.fn.modal = Plugin 1223 $.fn.modal.Constructor = Modal 1224 1225 1226 // MODAL NO CONFLICT 1227 // ================= 1228 1229 $.fn.modal.noConflict = function () { 1230 $.fn.modal = old 1231 return this 1232 } 1233 1234 1235 // MODAL DATA-API 1236 // ============== 1237 1238 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { 1239 var $this = $(this) 1240 var href = $this.attr('href') 1241 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7 1242 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) 1243 1244 if ($this.is('a')) e.preventDefault() 1245 1246 $target.one('show.bs.modal', function (showEvent) { 1247 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown 1248 $target.one('hidden.bs.modal', function () { 1249 $this.is(':visible') && $this.trigger('focus') 1250 }) 1251 }) 1252 Plugin.call($target, option, this) 1253 }) 1254 1255 }(jQuery); 1256 1257 +function ($) { 1258 'use strict'; 1259 1260 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) 1261 // ============================================================ 1262 1263 function transitionEnd() { 1264 var el = document.createElement('bootstrap') 1265 1266 var transEndEventNames = { 1267 WebkitTransition : 'webkitTransitionEnd', 1268 MozTransition : 'transitionend', 1269 OTransition : 'oTransitionEnd otransitionend', 1270 transition : 'transitionend' 1271 } 1272 1273 for (var name in transEndEventNames) { 1274 if (el.style[name] !== undefined) { 1275 return { end: transEndEventNames[name] } 1276 } 1277 } 1278 1279 return false // explicit for ie8 ( ._.) 1280 } 1281 1282 // http://blog.alexmaccaw.com/css-transitions 1283 $.fn.emulateTransitionEnd = function (duration) { 1284 var called = false 1285 var $el = this 1286 $(this).one('bsTransitionEnd', function () { called = true }) 1287 var callback = function () { if (!called) $($el).trigger($.support.transition.end) } 1288 setTimeout(callback, duration) 1289 return this 1290 } 1291 1292 $(function () { 1293 $.support.transition = transitionEnd() 1294 1295 if (!$.support.transition) return 1296 1297 $.event.special.bsTransitionEnd = { 1298 bindType: $.support.transition.end, 1299 delegateType: $.support.transition.end, 1300 handle: function (e) { 1301 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments) 1302 } 1303 } 1304 }) 1305 1306 }(jQuery); 1307 1308 1309 1310 jQuery(document).ready(function($) { 1311 1312 // Trigger scroll 1313 setTimeout( function(){ 1314 $(window).scroll().trigger('resize'); 1315 }, 500 ); 1316 1317 function draw() { 1318 //requestAnimationFrame(draw); 1319 // Drawing code goes here 1320 //scrollEvent(); 1321 1322 $(window).scroll(function(){ 1323 scrollEvent(); 1324 }); 1325 } 1326 1327 var $body = $('body'); 1328 if ( $body.hasClass('page') && !$body.hasClass('woocommerce-page') && !$('#container').find('.wpb_row').length ) { 1329 $body.addClass('wtbx-def-page'); 1330 } 1331 1332 draw(); 1333 1334 submenu_fix(); 1335 1336 el_hover_fix(); 1337 1338 loadGravatars(); 1339 1340 searchButton(); 1341 1342 stickyHeader(); 1343 1344 videoSectionSize($('.bg-video video')); 1345 1346 vimeoSize($('.bg-vimeo')); 1347 1348 startYoutubeInit(); 1349 1350 toTop(); 1351 1352 toSection(); 1353 1354 resizeRows(); 1355 1356 buttonHover(); 1357 1358 modalWindow(); 1359 1360 collarsTabsMobile(); 1361 1362 }); /* end of as page load scripts */ 1363 1364})(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.