1/*global jQuery,google,alert,console,plyr,Cookies */ 2 3var SWIFT = SWIFT || {}; 4 5(function(){ 6 7 // USE STRICT 8 "use strict"; 9 10 ///////////////////////////////////////////// 11 // PAGE FUNCTIONS 12 ///////////////////////////////////////////// 13 14 SWIFT.page = { 15 init: function () { 16 17 // BROWSER CHECK 18 SWIFT.page.browserCheck(); 19 20 // FITTEXT 21 //SWIFT.page.resizeHeadings(); 22 23 // HEADER SLIDER 24 if (body.hasClass('header-below-slider') && jQuery('.home-slider-wrap').length > 0) { 25 SWIFT.page.headerSlider(); 26 } 27 28 // ONE PAGE NAV 29 if (jQuery('#one-page-nav').length > 0) { 30 SWIFT.page.onePageNav(); 31 } 32 33 // SIDEBAR PROGRESS MENU 34 if (jQuery('#sidebar-progress-menu').length > 0) { 35 SWIFT.page.sidebarProgressMenu(); 36 } 37 38 // BACK TO TOP 39 if (jQuery('#back-to-top').length > 0) { 40 $window.scroll(function() { 41 SWIFT.page.backToTop(); 42 }); 43 } 44 45 // HERO/CONTENT SPLIT STYLE 46 if (body.hasClass('hero-content-split')) { 47 SWIFT.page.heroContentSplit(); 48 } 49 50 // FOOTER NEWSLETTER SUB BAR 51 if (jQuery('#sf-newsletter-bar').length > 0) { 52 SWIFT.page.newsletterSubBar(); 53 } 54 55 // ADMIN BAR CHECK 56 if (jQuery('#wpadminbar').length > 0) { 57 body.addClass('has-wpadminbar'); 58 } 59 60 // RECENT POSTS 61 if (jQuery('.recent-posts').length > 0) { 62 SWIFT.recentPosts.init(); 63 } 64 65 // SHARE 66 if (jQuery('.sf-share-counts').length > 0) { 67 SWIFT.page.shareCounts(); 68 } 69 70 // WP LOGIN FORM FIX 71 SWIFT.page.wooFormFix(); 72 73 // TRACK ORDER FORM FIX 74 if (jQuery('.track_order').length > 0) { 75 SWIFT.page.trackOrderFormFix(); 76 } 77 78 // MOVE MODALS TO BOTTOM OF PAGE 79 SWIFT.page.moveModals(); 80 81 // LOAD MAP ASSET ON MODAL CLICK 82 jQuery('a[data-toggle="modal"]').on('click', function() { 83 setTimeout(function() { 84 SWIFT.map.init(); 85 }, 300); 86 87 return true; 88 }); 89 90 // REFRESH MODAL IFRAME ON CLOSE (FOR VIDEOS) 91 SWIFT.page.modalClose(); 92 93 // REPLACE COMMENTS REPLY TITLE HTML 94 if (body.hasClass('single-post')) { 95 var replyTitle = jQuery('#respond').find('h3'); 96 var originalText = jQuery('#respond').find('h3').html(); 97 98 replyTitle.addClass('spb-heading'); 99 replyTitle.html('<span>'+originalText+'</span>'); 100 } 101 102 // SMOOTH SCROLL LINKS 103 SWIFT.page.smoothScrollLinks(); 104 105 // EXPANDING ASSETS 106 SWIFT.page.expandingAssets(); 107 108 // BUDDYPRESS ACTIVITY LINK CLICK 109 jQuery('.activity-time-since,.bp-secondary-action').on('click', function(e) { 110 e.preventDefault(); 111 jQuery('.viewer').css('display', 'none'); 112 window.location = jQuery(this).attr('href'); 113 }); 114 115 // LOVE IT CLICK 116 jQuery('.love-it').on('click', function() { 117 SWIFT.page.loveIt(jQuery(this)); 118 return false; 119 }); 120 121 // ARTICLE WITH FULL WIDTH MEDIA TITLE 122 if (jQuery('article').hasClass('single-post-fw-media-title')) { 123 SWIFT.page.postMediaTitle(); 124 } 125 126 // PORT WITH FULL WIDTH MEDIA TITLE 127 if (jQuery('article').hasClass('single-portfolio-poster')) { 128 SWIFT.page.portMediaTitle(); 129 } 130 131 // RELATED POSTS 132 if (jQuery('.related-items').length > 0) { 133 SWIFT.relatedPosts.init(); 134 } 135 136 // LIGHTBOX 137 SWIFT.page.lightbox(); 138 139 // MOBILE 2 CLICK IMAGES 140 if (isMobileAlt && body.hasClass('mobile-two-click')) { 141 SWIFT.page.mobileThumbLinkClick(); 142 } 143 144 // PAGE FADE OUT 145 if (body.hasClass('page-transitions')) { 146 SWIFT.page.pageTransitions(); 147 } 148 149 // DIRECTORY SUBMIT 150 SWIFT.page.directorySubmit(); 151 152 // MEDIA PLAYER 153 SWIFT.page.mediaPlayer(); 154 }, 155 homePreloader: function() { 156 // Site loaded, fade out preloader 157 body.addClass('sf-preloader-done'); 158 setTimeout(function() { 159 jQuery('#sf-home-preloader').fadeOut(300); 160 }, 300); 161 }, 162 load: function() { 163 164 // OFFSET CALC 165 SWIFT.page.offsetCalc(); 166 $window.smartresize( function() { 167 SWIFT.page.offsetCalc(); 168 }); 169 170 // Hero HEADING 171 if (jQuery('.fancy-heading').length > 0) { 172 SWIFT.page.fancyHeading(); 173 } 174 175 // RECENT POSTS RESIZE 176 if (jQuery('.recent-posts').length > 0) { 177 SWIFT.recentPosts.load(); 178 } 179 180 // HERO/CONTENT SPLIT STYLE 181 if (body.hasClass('hero-content-split')) { 182 SWIFT.page.heroContentSplitResize(); 183 } 184 185 // HASH CHECK 186 var windowWidth = $window.width(); 187 setTimeout(function() { 188 if ( ( windowWidth >= 1024 && body.hasClass('mhs-tablet-land') ) || 189 ( windowWidth >= 991 && body.hasClass('mhs-tablet-port') ) || 190 ( windowWidth >= 767 && body.hasClass('mhs-mobile') ) ) { 191 var urlHash = document.location.toString(); 192 if (urlHash.match('#')) { 193 var hash = urlHash.split('#')[1]; 194 if ( jQuery('#' + hash).length > 0 ) { 195 SWIFT.page.onePageNavGoTo('#' + hash); 196 } 197 } 198 } 199 }, 1000); 200 }, 201 browserCheck: function() { 202 jQuery.browser = {}; 203 jQuery.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase()); 204 jQuery.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase()); 205 jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase()); 206 jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase()); 207 jQuery.browser.msieMobile10 = /iemobile\/10\.0/.test(navigator.userAgent.toLowerCase()); 208 209 // BODY CLASSES 210 if (isMobileAlt) { 211 body.addClass("mobile-browser"); 212 } else { 213 body.addClass("standard-browser"); 214 } 215 if (isIEMobile) { 216 body.addClass("ie-mobile"); 217 } 218 if (isAppleDevice) { 219 body.addClass("apple-mobile-browser"); 220 } 221 if (body.hasClass("woocommerce-page") && !body.hasClass("woocommerce")) { 222 body.addClass("woocommerce"); 223 } 224 225 // ADD IE CLASS 226 if (IEVersion && IEVersion < 9) { 227 body.addClass('browser-ie'); 228 } 229 230 // ADD IE10 CLASS 231 var pattern = /MSIE\s([\d]+)/, 232 ua = navigator.userAgent, 233 matched = ua.match(pattern); 234 if (matched) { 235 body.addClass('browser-ie10'); 236 } 237 238 // ADD MOZILLA CLASS 239 if (jQuery.browser.mozilla) { 240 body.addClass('browser-ff'); 241 } 242 243 // ADD SAFARI CLASS
244 if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) { 245 body.addClass('browser-safari'); 246 } 247 }, 248 offsetCalc: function() { 249 var adjustment = 0; 250 251 if (jQuery('#wpadminbar').length > 0) { 252 adjustment = jQuery('#wpadminbar').height(); 253 SWIFT.wpadminbarheight = jQuery('#wpadminbar').height(); 254 } 255 256 if (body.hasClass('sticky-header-enabled') && !body.hasClass('sticky-header-transparent') && jQuery('.sticky-header').is(':visible') ) { 257 adjustment += jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height(); 258 } else if ( body.hasClass('mh-sticky') && jQuery('#mobile-header').is(':visible') ) { 259 adjustment += jQuery('#mobile-header').outerHeight(); 260 } 261 262 if (jQuery('.sticky-top-bar').length > 0) { 263 adjustment += jQuery('.sticky-top-bar').height() > 0 ? jQuery('.sticky-top-bar').height() : jQuery('#top-bar').height(); 264 } 265 266 SWIFT.offset = adjustment; 267 }, 268 resizeHeadings: function() { 269 var h1FontSize = jQuery('h1:not(.logo-h1)').css('font-size'), 270 h2FontSize = jQuery('h2:not(.caption-title)').css('font-size'); 271 272 SWIFT.page.resizeHeadingsResize(h1FontSize, h2FontSize); 273 $window.smartresize( function() { 274 SWIFT.page.resizeHeadingsResize(h1FontSize, h2FontSize); 275 }); 276 }, 277 resizeHeadingsResize: function(h1FontSize, h2FontSize) { 278 if ($window.width() <= 768) { 279 if (h1FontSize) { 280 h1FontSize = h1FontSize.replace("px", ""); 281 var h1FontSizeMin = Math.floor(h1FontSize * 0.6); 282 jQuery('h1:not(.logo-h1)').fitText(1, { minFontSize: h1FontSizeMin + 'px', maxFontSize: h1FontSize +'px' }).css('line-height', '120%'); 283 } 284 285 if (h2FontSize) { 286 h2FontSize = h2FontSize.replace("px", ""); 287 var h2FontSizeMin = Math.floor(h2FontSize * 0.6); 288 jQuery('h2:not(.caption-title)').fitText(1, { minFontSize: h2FontSizeMin + 'px', maxFontSize: h2FontSize +'px' }).css('line-height', '120%'); 289 } 290 } else { 291 jQuery('h1:not(.logo-h1)').css('font-size', '').css('line-height', ''); 292 jQuery('h2:not(.caption-title)').css('font-size', '').css('line-height', ''); 293 } 294 }, 295 loveIt: function($this) { 296 var locale = jQuery('#loveit-locale'), 297 post_id = $this.data('post-id'), 298 user_id = $this.data('user-id'), 299 action = 'love_it'; 300 301 if ($this.hasClass('loved')) { 302 action = 'unlove_it'; 303 } 304 if (locale.data('loggedin') == 'false' && Cookies.get('loved-' + post_id)) { 305 action = 'unlove_it'; 306 } 307 308 var data = { 309 action: action, 310 item_id: post_id, 311 user_id: user_id, 312 love_it_nonce: locale.data('nonce') 313 }; 314 315 jQuery.post(locale.data('ajaxurl'), data, function(response) { 316 var ajaxResponse = jQuery.trim(response), 317 count_wrap, 318 count; 319 320 if (ajaxResponse == 'loved') { 321 $this.addClass('loved'); 322 count_wrap = $this.find('data.count'); 323 count = count_wrap.text(); 324 count_wrap.text(parseInt(count) + 1); 325 if ( locale.data('loggedin') == 'false') { 326 Cookies.set('loved-' + post_id, 'yes', { expires: 1, path: '' }); 327 } 328 } else if (ajaxResponse == 'unloved') { 329 $this.removeClass('loved'); 330 count_wrap = $this.find('data.count'); 331 count = count_wrap.text(); 332 count_wrap.text(parseInt(count) - 1); 333 if (locale.data('loggedin') == 'false') { 334 Cookies.set('loved-' + post_id, 'no', { expires: 1, path: '' }); 335 } 336 } else { 337 alert(locale.data('error')); 338 } 339 }); 340 }, 341 stickyWidget: function(reset) { 342 343 var stickyWidget = jQuery('.sticky-widget'), 344 sidebar = stickyWidget.parent(), 345 offset = 24 + SWIFT.offset; 346 347 SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset); 348 349 if ( reset ) { 350 SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); 351 } 352 353 $window.smartresize( function() { 354 jQuery('.inner-page-wrap').stickem().destroy(); 355 SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); 356 SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset); 357 }); 358 359 if ( sidebar.find('.mega-menu-accordion').length > 0 ) { 360 jQuery('.sidebar .mega-menu-accordion .mega-menu-item-has-children').on('click', function() { 361 setTimeout(function() { 362 jQuery('.sidebar').each(function() { 363 if ( !jQuery('.sticky-widget').hasClass('stickit')) { 364 jQuery('.inner-page-wrap').stickem().destroy(); 365 SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); 366 SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset); 367 $window.scrollTop($window.scrollTop()+1); 368 $window.scrollTop($window.scrollTop()-1); 369 } 370 }); 371 }, 200); 372 }); 373 } 374 }, 375 initStickyWidget: function(stickyWidget, sidebar, offset) { 376 377 var parent = ".page-content"; 378 379 if ( body.hasClass('page') || body.hasClass('archive') || body.hasClass('home') || body.hasClass('search-results') || body.hasClass('error404') ) { 380 parent = ".inner-page-wrap"; 381 } 382 383 jQuery('.inner-page-wrap').stickem({ 384 item: '.sticky-widget', 385 container: parent, 386 offset: offset + 24, 387 onStick: function() { 388 SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); 389 } 390 }); 391 392 if ( stickyWidget.find('.mega-menu-accordion').length > 0 ) { 393 stickyWidget.find('.mega-menu-accordion').on('click', 'a.mega-menu-link', function(e) { 394 setTimeout(function() { 395 SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); 396 }, 500); 397 }); 398 } 399 }, 400 resizeStickyWidget: function(stickyWidget, sidebar) { 401 var headerHeight = SWIFT.offset, 402 content = jQuery('.content-wrap'), 403 sidebarHeight = sidebar.find('.sidebar-widget-wrap').height(); 404 405 if ( body.hasClass('page') || body.hasClass('search-results') || body.hasClass('error404') ) { 406 content = jQuery('.page-content'); 407 } 408 409 stickyWidget.css('width', sidebar.width()).css('top', headerHeight + 30); 410 411 // reset height before getting current height 412 sidebar.css('height', ''); 413 414 var contentHeight = content.height(); 415 if (contentHeight > sidebarHeight) { 416 sidebar.css('height', contentHeight); 417 } else { 418 sidebar.css('height', sidebarHeight); 419 } 420 }, 421 expandingAssets: function() { 422 jQuery('.spb-row-expand-text').on('click', '', function(e) { 423 e.preventDefault(); 424 var expand = jQuery(this), 425 expandRow = expand.next(); 426 427 if (expandRow.hasClass('spb-row-expanding-open') && !expandRow.hasClass('spb-row-expanding-active')) { 428 expandRow.addClass('spb-row-expanding-open').addClass('spb-row-expanding-active').slideUp(800); 429 setTimeout(function() { 430 expand.removeClass('row-open').find('span').text(expand.data('closed-text'));
431 expandRow.css('display', 'block').removeClass('spb-row-expanding-open').removeClass('spb-row-expanding-active'); 432 }, 800); 433 } else if (!expandRow.hasClass('spb-row-expanding-active')) { 434 expand.addClass('row-open').find('span').text(expand.data('open-text')); 435 expandRow.css('display', 'none').addClass('spb-row-expanding-open').addClass('spb-row-expanding-active').slideDown(800); 436 setTimeout(function() { 437 expandRow.removeClass('spb-row-expanding-active'); 438 }, 800); 439 } 440 441 }); 442 }, 443 headerSlider: function() { 444 445 // SET LOADING INDICATOR 446 jQuery('#site-loading').css('display', 'block'); 447 448 // SET SLIDER POSITION & HEIGHT 449 jQuery('.home-slider-wrap').css('position', 'fixed'); 450 jQuery('#main-container').css('position', 'relative'); 451 jQuery('#container').css('top', jQuery('.home-slider-wrap').height()); 452 setTimeout(function() { 453 jQuery('#site-loading').fadeOut(1000); 454 }, 250); 455 456 // RESIZE SLIDER HEIGHT 457 $window.smartresize( function() { 458 jQuery('#container').css('top', jQuery('.home-slider-wrap').height()); 459 }); 460 461 // CONTINUE LINK 462 jQuery('a#slider-continue').on('click', function(e) { 463 464 // Prevent default anchor action 465 e.preventDefault(); 466 467 // Animate scroll to main content 468 jQuery('html, body').stop().animate({ 469 scrollTop: jQuery('#container').css('top') 470 }, 1500, 'easeInOutExpo'); 471 472 }); 473 }, 474 fancyHeading: function() { 475 var fancyHeading = jQuery('.fancy-heading'), 476 fancyHeadingText = fancyHeading.find('.heading-text'), 477 fancyHeadingTextHeight = fancyHeadingText.height(), 478 fancyHeadingHeight = parseInt(fancyHeading.data('height'), 10), 479 header = jQuery('.header-wrap'), 480 headerHeight = 0, 481 spacerHeight = 0; 482 483 if (body.hasClass('header-naked-light') || body.hasClass('header-naked-dark')) { 484 headerHeight = header.height(); 485 } 486 487 if (!fancyHeadingHeight) { 488 fancyHeadingHeight = 400; 489 } 490 491 if (fancyHeadingTextHeight > fancyHeadingHeight) { 492 fancyHeadingHeight = fancyHeadingTextHeight + 120; 493 } 494 495 fancyHeadingHeight = fancyHeadingHeight + headerHeight; 496 497 // Vertically center the heading text 498 fancyHeadingText.vCenterTop(); 499 500 if (fancyHeading.hasClass('page-heading-breadcrumbs')) { 501 fancyHeading.find('#breadcrumbs').vCenter(); 502 } 503 504 var fancyHeadingAnimDelay = 400; 505 506 if (jQuery('#wpadminbar').length > 0) { 507 spacerHeight = fancyHeadingHeight - jQuery('#wpadminbar').height(); 508 } 509 510 // Animate in the heading text and title 511 if ( !fancyHeading.hasClass('fixed-height') ) { 512 fancyHeading.css('height', fancyHeadingHeight); 513 } 514 515 // Animate the container-wrap on app header 516 if ( body.hasClass('app-header') && jQuery('.page-heading-wrap-hidden').length === 0 ) { 517 jQuery('#header').transition({ 518 opacity: 1 519 }, 600, 'easeOutCirc'); 520 jQuery('.inner-container-wrap').transition({ 521 marginTop: spacerHeight 522 }, 800, 'easeOutCirc'); 523 524 SWIFT.page.fancyHeadingResize(); 525 $window.smartresize( function() { 526 SWIFT.page.fancyHeadingResize(); 527 }); 528 } 529 530 setTimeout(function() { 531 fancyHeadingText.css('opacity', 1); 532 }, fancyHeadingAnimDelay + 600); 533 setTimeout(function() { 534 fancyHeading.addClass('animated'); 535 }, fancyHeadingAnimDelay + 1000); 536 537 // Check if parallax scroll is possible 538 if ( parallaxScroll && !isMobileAlt && !body.hasClass('hero-content-split') ) { 539 $window.scroll(function(){ 540 541 var scrollTop = $window.scrollTop(), 542 realScrollTop = scrollTop, 543 headingOffset = SWIFT.offset, 544 opacityScale = 400; 545 546 if ( !body.hasClass('app-header') ) { 547 scrollTop = scrollTop - headingOffset; 548 } 549 550 // Only scroll if the heading is makes sense to do so 551 if (scrollTop < jQuery(document).height() - $window.height()) { 552 553 if (scrollTop < 0) { 554 scrollTop = 0; 555 } 556 557 var blur = scrollTop / headingOffset * 4; 558 559 fancyHeadingText.stop(true,true).css({ 560 opacity: 1 - realScrollTop / opacityScale, 561 '-webkit-filter': 'blur(' + (blur) + 'px)',
562 '-moz-filter': 'blur(' + (blur) + 'px)', 563 '-ms-filter': 'blur(' + (blur) + 'px)', 564 '-o-filter': 'blur(' + (blur) + 'px)', 565 'filter': 'blur(' + (blur) + 'px)' 566 }, 0); 567 } 568 569 }); 570 } 571 }, 572 fancyHeadingResize: function() { 573 var fancyHeading = jQuery('.fancy-heading'), 574 fancyHeadingHeight = parseInt(fancyHeading.data('height'), 10), 575 fhHeight = parseInt(fancyHeading.data('img-height'), 10), 576 fhWidth = parseInt(fancyHeading.data('img-width'), 10), 577 innerContainer = jQuery('.inner-container-wrap'); 578 579 if ( fhWidth === 0 || fhHeight === 0 || $window.width() <= 1024 ) { 580 return; 581 } 582 583 var fhRatio = fhHeight / fhWidth; 584 var currentHeight = fancyHeading.width() * fhRatio; 585 if ( currentHeight < fancyHeadingHeight ) { 586 fancyHeading.css('height', currentHeight); 587 innerContainer.css('margin-top', currentHeight - SWIFT.wpadminbarheight); 588 } else { 589 fancyHeading.css('height', fancyHeadingHeight); 590 innerContainer.css('margin-top', fancyHeadingHeight - SWIFT.wpadminbarheight); 591 } 592 }, 593 moveModals: function() { 594 jQuery(".modal").each(function(){ 595 jQuery(this).appendTo("body"); 596 }); 597 }, 598 modalClose: function() {
599 jQuery(".modal-backdrop, .modal .close, .modal .btn").on("click", function() { 600 jQuery(".modal iframe").each(function() { 601 var thisModal = jQuery(this); 602 thisModal.attr("src", thisModal.attr("src")); 603 }); 604 }); 605 }, 606 smoothScrollLinks: function() { 607 jQuery('a.smooth-scroll-link').on('click', function(e) { 608 609 var linkHref = jQuery(this).attr('href'), 610 linkOffset = jQuery(this).data('offset') ? jQuery(this).data('offset') : 0; 611 612 if (linkHref && linkHref.indexOf('#') === 0) { 613 var headerHeight = SWIFT.offset; 614 615 SWIFT.isScrolling = true; 616 617 618 jQuery('html, body').stop().animate({ 619 scrollTop: jQuery(linkHref).offset().top - headerHeight + linkOffset 620 }, 1000, 'easeInOutExpo', function() { 621 SWIFT.isScrolling = false; 622 }); 623 624 e.preventDefault(); 625 626 } else { 627 return e; 628 } 629 630 }); 631 }, 632 onePageNav: function() { 633 634 var onePageNav = jQuery('#one-page-nav'), 635 onePageNavType = onePageNav.hasClass('opn-arrows') ? "arrows" : "standard", 636 onePageNavItems = "", 637 pageSectionCount = 0, 638 mainContent = jQuery('.page-content'); 639 640 mainContent.find('section.row').each(function() { 641 var linkID = jQuery(this).attr('id'), 642 linkName = jQuery(this).data('rowname'); 643 644 if (linkID && linkName.length > 0 && jQuery(this).height() > 0) { 645 onePageNavItems += '<li><a href="#'+linkID+'" data-title="'+linkName+'"><i></i></a><div class="hover-caption">'+linkName+'</div></li>'; 646 pageSectionCount++; 647 } 648 }); 649 650 if (pageSectionCount > 0) { 651 if (onePageNav.find('ul').length === 0) { 652 onePageNav.append('<ul>'+onePageNavItems+'</ul>'); 653 654 if (onePageNavType === "arrows") { 655 onePageNav.find('ul').css('display', 'none'); 656 onePageNav.append('<a href="#" class="opn-up"><i class="sf-icon-up-chevron"></i></a>'); 657 onePageNav.append('<div class="opn-status"><span class="current">1</span>/<span class="total">'+pageSectionCount+'</span></div>'); 658 onePageNav.append('<a href="#" class="opn-down"><i class="sf-icon-down-chevron"></i></a>'); 659 } 660 } 661 662 onePageNav.vCenter(); 663 setTimeout(function() { 664 665 SWIFT.page.onePageNavScroll(onePageNav); 666 667 onePageNav.css('display', 'block').stop().animate({ 668 'right': '0', 669 'opacity': 1 670 }, 1000, "easeOutQuart"); 671 672 // Nav Dots 673 jQuery('#one-page-nav ul li a').bind('click', function(e) { 674 SWIFT.page.onePageNavGoTo(jQuery(this).attr('href')); 675 e.preventDefault(); 676 }); 677 678 // Up Arrow 679 jQuery('#one-page-nav a.opn-up').bind('click', function(e) { 680 var currentSection = parseInt(jQuery('.opn-status .current').text(), 10), 681 prevSection = currentSection - 1, 682 prevSectionHref = jQuery('#one-page-nav ul li:nth-child('+ prevSection +') > a').attr('href'); 683 684 if (prevSection > 0) { 685 SWIFT.page.onePageNavGoTo(prevSectionHref); 686 } 687 e.preventDefault(); 688 }); 689 690 // Down Arrow 691 jQuery('#one-page-nav a.opn-down').bind('click', function(e) { 692 var currentSection = parseInt(jQuery('.opn-status .current').text(), 10), 693 nextSection = currentSection + 1, 694 nextSectionHref = jQuery('#one-page-nav ul li:nth-child('+ nextSection +') > a').attr('href'); 695 696 if (nextSection <= pageSectionCount) { 697 SWIFT.page.onePageNavGoTo(nextSectionHref); 698 } 699 e.preventDefault(); 700 }); 701 702 // Assign current on init and scroll 703 SWIFT.page.onePageNavScroll(onePageNav); 704 $window.on('scroll', function() { 705 SWIFT.page.onePageNavScroll(onePageNav); 706 }); 707 708 }, 1000); 709 } 710 }, 711 onePageNavGoTo: function(anchor) { 712 713 var adjustment = SWIFT.offset; 714 715 SWIFT.isScrolling = true; 716 717 jQuery('html, body').stop().animate({ 718 scrollTop: jQuery(anchor).offset().top - adjustment + 1 719 }, 1000, 'easeInOutExpo', function() { 720 SWIFT.isScrolling = false; 721 }); 722 }, 723 onePageNavScroll: function(onePageNav) { 724 725 var adjustment = SWIFT.offset; 726 727 var currentSection = jQuery('section.row:in-viewport('+adjustment+')').data('rowname'), 728 currentSectionIndex = 0; 729 730 if (!currentSection) { 731 onePageNav.find('li').removeClass('selected'); 732 } 733 734 if (onePageNav.is(':visible') && currentSection) { 735 onePageNav.find('li').removeClass('selected'); 736 onePageNav.find('li a[data-title="'+currentSection+'"]').parent().addClass('selected'); 737 currentSectionIndex = onePageNav.find('li a[data-title="'+currentSection+'"]').parent().index() + 1; 738 } 739 740 if (currentSectionIndex > 0) { 741 jQuery('.opn-status .current').text(currentSectionIndex); 742 } 743 744 if (onePageNav.hasClass('opn-arrows')) { 745 var current = onePageNav.find('.current').text(), 746 total = onePageNav.find('.total').text(); 747 748 if (current === "1") { 749 onePageNav.find('.opn-up').addClass('disabled'); 750 } else { 751 onePageNav.find('.opn-up').removeClass('disabled'); 752 } 753 754 if (current === total) { 755 onePageNav.find('.opn-down').addClass('disabled'); 756 } else { 757 onePageNav.find('.opn-down').removeClass('disabled'); 758 } 759 } 760 }, 761 sidebarProgressMenu: function() { 762 var progressMenu = jQuery('#sidebar-progress-menu'), 763 progressMenuItems = "", 764 pageSectionCount = 0, 765 mainContent = jQuery('.page-content'); 766 767 mainContent.find('section.row-has-id').each(function() { 768 var linkID = jQuery(this).attr('id'), 769 linkName = jQuery(this).data('rowname'); 770 771 if (linkID && linkName.length > 0 && jQuery(this).height() > 0) { 772 progressMenuItems += '<li><a href="#'+linkID+'" data-title="'+linkName+'"><span class="name">'+linkName+'</span><span class="progress"></span></li>'; 773 pageSectionCount++; 774 } 775 }); 776 777 if (pageSectionCount > 0) { 778 if (progressMenu.find('ul').length === 0) { 779 progressMenu.append('<ul>'+progressMenuItems+'</ul>'); 780 } 781 782 // bind corresponding events 783 $window.on('scroll', SWIFT.page.spmCheckRead); 784 $window.on('scroll', SWIFT.page.spmCheckSidebar); 785 $window.on('resize', SWIFT.page.spmResetScroll); 786 787 SWIFT.page.spmUpdateSection(); 788 SWIFT.page.spmUpdateSidebarPosition(); 789 790 progressMenu.on('click', 'a', function(event){ 791 event.preventDefault(); 792 var selectedArticle = jQuery( jQuery(this).attr('href') ), 793 selectedArticleTop = selectedArticle.offset().top, 794 adjustment = SWIFT.offset; 795 796 selectedArticleTop -= adjustment + 20; 797 798 $window.off('scroll', SWIFT.page.spmCheckRead); 799 800 jQuery('body,html').animate( 801 {'scrollTop': selectedArticleTop + 2}, 802 300, function(){ 803 SWIFT.page.spmCheckRead();
804 $window.on('scroll', SWIFT.page.spmCheckRead); 805 } 806 ); 807 }); 808 } 809 }, 810 spmUpdateSection: function() { 811 var mainContent = jQuery('.page-content'), 812 sections = mainContent.find('section.row-has-id'), 813 sectionsCount = sections.length, 814 adjustment = 20 + SWIFT.offset, 815 scrollTop = $window.scrollTop() + adjustment, 816 progressMenu = jQuery('#sidebar-progress-menu'), 817 progressMenuSections = progressMenu.find('li'); 818 819 sections.each(function(index) { 820 var article = jQuery(this), 821 articleID = article.attr('id'), 822 articleTop = article.offset().top, 823 articleHeight = article.outerHeight(), 824 articleSidebarLink = progressMenuSections.find('a[href="#' + articleID + '"]').parent(); 825 826 if ( index == sectionsCount - 1 ) { 827 articleHeight = articleHeight - $window.height() + adjustment; 828 } 829 830 if ( articleTop > scrollTop ) { 831 articleSidebarLink.removeClass('read reading'); 832 articleSidebarLink.find('.progress').css('width', 0); 833 } else if ( scrollTop >= articleTop && articleTop + articleHeight > scrollTop) { 834 var progressValue = 100 *( (scrollTop - articleTop)/articleHeight); 835 articleSidebarLink.addClass('reading').removeClass('read').find('.progress').css('width', progressValue + '%'); 836 //SWIFT.page.spmChangeURL(articleSidebarLink.find('a').attr('href')); 837 } else { 838 articleSidebarLink.removeClass('reading').addClass('read'); 839 } 840 }); 841 SWIFT.isScrolling = false; 842 }, 843 spmChangeURL: function(link) { 844 var pageArray = location.pathname.split('/'), 845 actualPage = pageArray[pageArray.length - 1]; 846 if ( actualPage != link && history.pushState ) window.history.pushState({path: link},'',link); 847 }, 848 spmCheckRead: function() { 849 if ( !SWIFT.isScrolling ) { 850 SWIFT.isScrolling = true; 851 if (!window.requestAnimationFrame) { 852 setTimeout(SWIFT.page.spmUpdateSection, 300); 853 } else { 854 window.requestAnimationFrame(SWIFT.page.spmUpdateSection); 855 } 856 } 857 }, 858 spmCheckSidebar: function() { 859 if ( !SWIFT.sidebarAnimation ) { 860 SWIFT.sidebarAnimation = true; 861 if (!window.requestAnimationFrame) { 862 setTimeout(SWIFT.page.spmUpdateSidebarPosition, 300); 863 } else { 864 window.requestAnimationFrame(SWIFT.page.spmUpdateSidebarPosition); 865 } 866 } 867 }, 868 spmUpdateSidebarPosition: function() { 869 var progressMenu = jQuery('#sidebar-progress-menu'), 870 pageWrapper = jQuery('.page-content'), 871 pageWrapperTop = pageWrapper.offset().top, 872 pageWrapperHeight = pageWrapper.outerHeight(), 873 pageWrapperBottom = pageWrapperTop + pageWrapperHeight, 874 scrollTop = $window.scrollTop(), 875 sidebarOffset = progressMenu.parent().offset().left, 876 sidebarWidth = jQuery('aside.sidebar').outerWidth(), 877 offset = 40 + SWIFT.offset, 878 windowHeight = $window.height(); 879 880 scrollTop += offset; 881 882 if ( scrollTop < pageWrapperTop ) { 883 progressMenu.removeClass('fixed').attr('style', ''); 884 } else if ( scrollTop >= pageWrapperTop && scrollTop < pageWrapperBottom - windowHeight + offset ) { 885 progressMenu.addClass('fixed').attr('style', 'left: '+sidebarOffset+'px;top: '+offset+'px;width: '+sidebarWidth+'px;'); 886 } else { 887 if ( progressMenu.hasClass('fixed') ) progressMenu.removeClass('fixed').css( 'top', pageWrapperHeight - windowHeight + offset + 'px' ).css( 'left', '' ); 888 } 889 SWIFT.sidebarAnimation = false; 890 }, 891 spmResetScroll: function() { 892 if ( !SWIFT.isResizing ) { 893 SWIFT.isResizing = true; 894 if (!window.requestAnimationFrame) { 895 setTimeout( function() { 896 SWIFT.isResizing = false; 897 }, 300); 898 } else { 899 window.requestAnimationFrame( function() { 900 SWIFT.isResizing = false; 901 }); 902 } 903 } 904 }, 905 heroContentSplit: function() { 906 907 var mainContainer = jQuery('#main-container'); 908 909 // RESIZE 910 SWIFT.page.heroContentSplitResize(); 911 $window.smartresize( function() { 912 SWIFT.page.heroContentSplitResize(); 913 }); 914 915 // ANIMATE IN 916 mainContainer.animate({ 917 'opacity': 1 918 }, 600, "easeOutExpo"); 919 920 }, 921 heroContentSplitResize: function() { 922 var mainContainer = jQuery('#main-container'), 923 windowHeight = $window.height(), 924 headerHeight = SWIFT.offset; 925 926 if ($window.width() > 991) { 927 mainContainer.css('height', windowHeight - headerHeight); 928 jQuery('.inner-container-wrap').css('min-height', windowHeight - headerHeight); 929 } 930 }, 931 shareCounts: function() { 932 933 var shareCounts = jQuery('.sf-share-counts'), 934 shareURL = shareCounts.data('url'), 935 facebookCount = shareCounts.find('a.sf-share-fb'), 936 pinterestCount = shareCounts.find('a.sf-share-pinterest'), 937 linkedInCount = shareCounts.find('a.sf-share-linkedin'), 938 googlePlusCount = shareCounts.find('a.sf-share-googleplus'), 939 totalShareCount = 0; 940
941 // Check share count total is visible 942 var totalVisible = shareCounts.find('.share-text').is(":visible") ? true : false; 943 944 // G+ 945 var gPlusCount = parseInt( googlePlusCount.find('.count').text(), 10); 946 if ( jQuery.isNumeric(gPlusCount) ) { 947 totalShareCount += gPlusCount; 948 } 949 if ( totalVisible ) { 950 SWIFT.page.shareCountUpdateTotal(totalShareCount); 951 } 952 953 // Facebook 954 if (facebookCount.length > 0) { 955 jQuery.getJSON('https://graph.facebook.com/?id='+ shareURL +'&callback=?', function(data) { 956 if (data.share !== undefined && data.share.share_count !== undefined && data.share.share_count !== null) { 957 var fbCount = parseInt( data.share.share_count, 10 ); 958 facebookCount.find('.count').html(fbCount); 959 totalShareCount += fbCount; 960 if ( totalVisible ) { 961 SWIFT.page.shareCountUpdateTotal(totalShareCount); 962 } 963 } 964 facebookCount.find('.count').addClass('animate'); 965 }); 966 } 967 968 // Pinterest 969 if (pinterestCount.length > 0) { 970 jQuery.getJSON('https://api.pinterest.com/v1/urls/count.json?url='+shareURL+'&callback=?', function(data) { 971 if (data.count !== undefined && data.count !== null) { 972 var pCount = parseInt( data.count, 10 ); 973 pinterestCount.find('.count').html(pCount); 974 totalShareCount += pCount; 975 if ( totalVisible ) { 976 SWIFT.page.shareCountUpdateTotal(totalShareCount); 977 } 978 } 979 pinterestCount.find('.count').addClass('animate'); 980 }); 981 } 982 983 body.on('click', '.sf-share-link', function() { 984 window.open(jQuery(this).attr('href')); 985 return false; 986 }); 987 }, 988 shareCountUpdateTotal: function(count) { 989 var shareCounts = jQuery('.sf-share-counts'), 990 totalDisplay = shareCounts.find('.total-count'), 991 currentCount = parseInt(totalDisplay.text(), 10), 992 newText = ''; 993 994 if ( jQuery.isNumeric(count) && jQuery.isNumeric(currentCount) ) { 995 totalDisplay.text(count); 996 if ( count === 1 ) { 997 newText = shareCounts.find('span').data('singular'); 998 shareCounts.find('span').text(newText); 999 } else { 1000 newText = shareCounts.find('span').data('plural'); 1001 shareCounts.find('span').text(newText); 1002 } 1003 } 1004 1005 if ( jQuery('.post-details .share-count').length > 0 ) { 1006 jQuery('.post-details .share-count').text(count); 1007 } 1008 1009 }, 1010 wooFormFix: function() { 1011 var username = sfOptionParams.data('username-placeholder'), 1012 usernameOrEmail = sfOptionParams.data('username-or-email-placeholder'), 1013 email = sfOptionParams.data('email-placeholder'), 1014 password = sfOptionParams.data('password-placeholder'); 1015 1016 jQuery('#user_login').attr('placeholder', username); 1017 jQuery('#user_email').attr('placeholder', email); 1018 jQuery('#user_pass').attr('placeholder', password); 1019 jQuery('#username').attr('placeholder', usernameOrEmail); 1020 jQuery('#password').attr('placeholder', password); 1021 1022 jQuery('form.register #reg_email').attr('placeholder', usernameOrEmail); 1023 jQuery('form.register #reg_password').attr('placeholder', password); 1024 1025 }, 1026 trackOrderFormFix: function() { 1027 var orderID = sfOptionParams.data('order-id-placeholder'), 1028 billingEmail = sfOptionParams.data('billing-email-placeholder'); 1029 1030 jQuery('#orderid').attr('placeholder', orderID); 1031 jQuery('#order_email').attr('placeholder', billingEmail); 1032 }, 1033 postMediaTitle: function() { 1034 var detailsOverlay = jQuery('.details-overlay'), 1035 detailFeature = jQuery('.detail-feature'), 1036 featureHeight = detailsOverlay.height() + 80; 1037 1038 if (body.hasClass('header-naked-light') || body.hasClass('header-naked-dark')) { 1039 detailFeature.css('padding-top', jQuery('.header-wrap').height() * 2); 1040 } 1041 1042 detailFeature.css('height', featureHeight); 1043 setTimeout(function() { 1044 jQuery('.details-overlay').vCenter().stop().animate({ 1045 'bottom': '50%', 1046 'opacity': 1 1047 }, 1500, "easeOutExpo"); 1048 }, 500); 1049 1050 $window.smartresize( function() { 1051 detailFeature.css('height', detailsOverlay.height() + 80); 1052 jQuery('.details-overlay').vCenter(); 1053 }); 1054 1055 }, 1056 portMediaTitle: function() { 1057 var detailsOverlay = jQuery('.details-overlay'), 1058 detailFeature = jQuery('.detail-feature'); 1059 1060 if (body.hasClass('header-naked-light') || body.hasClass('header-naked-dark')) { 1061 detailFeature.css('padding-top', jQuery('.header-wrap').height() * 2); 1062 } 1063 1064 detailFeature.imagesLoaded(function() { 1065 if ( detailsOverlay.height() + 80 > detailFeature.height() ) { 1066 detailFeature.css('height', detailsOverlay.height() + 80); 1067 } 1068 }); 1069 1070 $window.smartresize( function() { 1071 detailFeature.css( 'height', '' ); 1072 if ( detailsOverlay.height() + 80 > detailFeature.height() ) { 1073 detailFeature.css('height', detailsOverlay.height() + 80); 1074 } 1075 jQuery('.details-overlay').vCenter(); 1076 }); 1077 1078 }, 1079 lightbox: function() { 1080 1081 // Lightbox Social 1082 var lightboxSocial = {};
1083 if (lightboxSharing) { 1084 lightboxSocial = { 1085 facebook: { 1086 source: 'https://www.facebook.com/sharer/sharer.php?u={URL}', 1087 text: 'Share on Facebook' 1088 }, 1089 twitter: true, 1090 googleplus: true, 1091 pinterest: { 1092 source: "https://pinterest.com/pin/create/button/?url={URL}&media={URL}", 1093 text: "Share on Pinterest" 1094 } 1095 }; 1096 } 1097 1098 // Lightbox Galleries 1099 var galleryArr = []; 1100 jQuery('[data-rel^="ilightbox["]').each(function () { 1101 var attr = this.getAttribute("data-rel"); 1102 if ( jQuery(this).hasClass( 'ilightbox-enabled' ) || jQuery(this).hasClass( 'ilightbox-skip' ) ) { 1103 return; 1104 } 1105 if (jQuery.inArray(attr, galleryArr) == -1 ) { 1106 galleryArr.push(attr); 1107 } 1108 }); 1109 jQuery.each(galleryArr, function (b, c) { 1110 jQuery('[data-rel="' + c + '"]').iLightBox({ 1111 skin: lightboxSkin, 1112 social: { 1113 buttons: lightboxSocial 1114 }, 1115 minScale: 0.1, 1116 maxScale: 0.8, 1117 path: 'horizontal', 1118 thumbnails: { 1119 maxWidth: 120, 1120 maxHeight: 120 1121 }, 1122 controls: { 1123 arrows: lightboxControlArrows, 1124 thumbnail: lightboxThumbs 1125 } 1126 }); 1127 jQuery('[data-rel="' + c + '"]').addClass( 'ilightbox-enabled' ); 1128 }); 1129 }, 1130 backToTop: function() { 1131 var scrollPosition = $window.scrollTop(); 1132 1133 if (scrollPosition > 300) { 1134 jQuery('#back-to-top').stop().animate({ 1135 'bottom': '20px' 1136 }, 300, "easeOutQuart"); 1137 } else if (scrollPosition < 300) { 1138 jQuery('#back-to-top').stop().animate({ 1139 'bottom': '-80px' 1140 }, 300, "easeInQuart"); 1141 } 1142 }, 1143 newsletterSubBar: function() { 1144 var subBar = jQuery('#sf-newsletter-bar'), 1145 closedCookieName = 'newsletter-sub-bar-hidden'; 1146 1147 setTimeout(function() { 1148 if (typeof Cookies !== "undefined" && Cookies.get(closedCookieName) != '1') { 1149 subBar.fadeIn(600); 1150 } 1151 }, 3000); 1152 1153 jQuery('a.sub-close').on('click', '', function(e) { 1154 e.preventDefault(); 1155 Cookies.set(closedCookieName, '1', { expires: 7, path: '' }); 1156 subBar.fadeOut(600); 1157 }); 1158 }, 1159 getViewportHeight: function() { 1160 var height = "innerHeight" in window ? window.innerHeight: document.documentElement.offsetHeight; 1161 return height; 1162 }, 1163 checkIE: function() { 1164 var undef, 1165 v = 3, 1166 div = document.createElement('div'), 1167 all = div.getElementsByTagName('i'); 1168 1169 while ( 1170 div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', 1171 all[0] 1172 ); 1173 1174 return v > 4 ? v : undef; 1175 }, 1176 pageTransitions: function() { 1177 jQuery('a').on('click', function(e) { 1178 var linkElement = jQuery(this), 1179 link = linkElement.attr('href'), 1180 linkTarget = linkElement.attr('target'); 1181 1182 // Return if is tab click 1183 if (linkElement.hasClass('team-member-ajax') || linkElement.data('toggle') === "tab" || linkElement.parent().parent().hasClass('tabs') || linkElement.parent('.ui-accordion-header').length > 0) { 1184 return e; 1185 } 1186 1187 if (link.indexOf('#') === 0 && link.length > 1) { 1188 SWIFT.isScrolling = true; 1189 SWIFT.page.onePageNavGoTo(link); 1190 setTimeout(function() { 1191 SWIFT.isScrolling = false; 1192 }, 1000); 1193 e.preventDefault(); 1194 } else if (link.indexOf('#') === 0 && link.length === 1) { 1195 return; 1196 } else if (linkTarget === '_blank' || link.indexOf('?') >= 0 || link.indexOf('.jpg') >= 0 || link.indexOf('.png') >= 0 || link.indexOf('mailto') >= 0 || e.ctrlKey || e.metaKey || link.indexOf('javascript') === 0 || link.indexOf('tel:') === 0) { 1197 return e; 1198 } else { 1199 if (body.hasClass('mobile-menu-open') || body.hasClass('mh-overlay-show') || body.hasClass('side-slideout-open') || linkElement.hasClass('cart-contents') ) { 1200 return; 1201 } else { 1202 SWIFT.page.fadePageOut(link); 1203 e.preventDefault(); 1204 } 1205 } 1206 }); 1207 }, 1208 fadePageIn: function() { 1209 var preloadTime = 1000; 1210 1211 if (jQuery('.parallax-window-height').length > 0) { 1212 preloadTime = 1200; 1213 } 1214 1215 body.addClass('page-fading-in'); 1216 jQuery('#site-loading').css('opacity', '0'); 1217 1218 setTimeout(function() { 1219 jQuery('#site-loading').css('display', 'none'); 1220 body.removeClass('page-fading-in'); 1221 }, preloadTime); 1222 }, 1223 fadePageOut: function(link) { 1224 jQuery('#site-loading').css('display', 'block').transition({ 1225 opacity: 1, 1226 delay: 200 1227 }, 600, "ease" ); 1228 setTimeout(function() { 1229 window.location = link; 1230 }, 600); 1231 }, 1232 mobileThumbLinkClick: function() { 1233 jQuery(document).on('click', '.animated-overlay > a, box-link', function(e) { 1234 var thisLink = jQuery(this); 1235 1236 if ( thisLink.parent().hasClass('product-transition-fade') || thisLink.parent().hasClass('product-transition-zoom') ) { 1237 return e; 1238 } 1239 if (thisLink.hasClass('hovered')) { 1240 return e; 1241 } else { 1242 e.preventDefault(); 1243 thisLink.addClass('hovered'); 1244 } 1245 }); 1246 }, 1247 directorySubmit: function() { 1248 jQuery(document).on("click", '#uplift_directory_calculate_coordinates', function(e) { 1249 e.preventDefault(); 1250 var geocoder = new google.maps.Geocoder(); 1251 1252 geocoder.geocode( { 'address': jQuery('#uplift_directory_address').val()}, function(results) { 1253 jQuery('#uplift_directory_lat_coord').val(results[0].geometry.location.lat()); 1254 jQuery('#uplift_directory_lng_coord').val(results[0].geometry.location.lng()); 1255 }); 1256 1257 }); 1258 1259 jQuery('#directory-submit').click(function(e) { 1260 1261 if (jQuery('#uplift_directory_address').val() === '' || jQuery('#uplift_directory_lat_coord').val() === '' || jQuery('uplift_directory_lng_coord').val() === '' || jQuery('#directory_title').val() === '' || jQuery('#directory_description').val() === '' || jQuery('#directory-cat').val() <= 0 || jQuery('#directory-loc').val() <= 0) { 1262 e.preventDefault(); 1263 jQuery('.directory-error').show(); 1264 jQuery('html, body').animate({ scrollTop: jQuery('.directory-error').offset().top-100}, 700); 1265 return false; 1266 } 1267 jQuery('#add-directory-entry').submit(); 1268 }); 1269 }, 1270 mediaPlayer: function() { 1271 plyr.setup({
1272 html: ["<div class='player-controls'>", 1273 "<span class='player-controls-left'>", 1274 "<button type='button' data-player='play'>", 1275 "<i class='sf-icon-play'></i>", 1276 "<span class='sr-only'>Play</span>", 1277 "</button>", 1278 "<button type='button' data-player='pause'>", 1279 "<i class='sf-icon-pause'></i>", 1280 "<span class='sr-only'>Pause</span>", 1281 "</button>", 1282 "<div class='player-progress'>", 1283 "<label for='seek{id}' class='sr-only'>Seek</label>", 1284 "<input id='seek{id}' class='player-progress-seek' type='range' min='0' max='100' step='0.5' value='0' data-player='seek'>", 1285 "<progress class='player-progress-played' max='100' value='0'>", 1286 "<span>0</span>% played", 1287 "</progress>", 1288 "<progress class='player-progress-buffer' max='100' value='0'>", 1289 "<span>0</span>% buffered", 1290 "</progress>", 1291 "</div>", 1292 "</span>", 1293 "<span class='player-controls-right'>", 1294 "<span class='player-time'>", 1295 "<span class='sr-only'>Current time</span>", 1296 "<span class='player-current-time'>00:00</span>", 1297 "</span>", 1298 "<span class='player-time'>", 1299 "<span class='sr-only'>Duration</span>", 1300 "<span class='player-duration'>00:00</span>", 1301 "</span>", 1302 "<div class='volume-wrap'>", 1303 "<div class='volume-float-wrap'><input id='volume{id}' class='player-volume' type='range' min='0' max='10' value='5' data-player='volume'></div>", 1304 "<button type='button' data-player='mute'>", 1305 "<div class='icon-muted'><i class='sf-icon-volume'></i></div>", 1306 "<div><i class='sf-icon-volume'></i></div>", 1307 "<span class='sr-only'>Toggle Mute</span>", 1308 "</button>", 1309 "</div>", 1310 "<label for='volume{id}' class='sr-only'>Volume</label>", 1311 "<button type='button' data-player='fullscreen'>", 1312 "<div class='icon-exit-fullscreen'><i class='sf-icon-enlarge'></i></div>", 1313 "<div><i class='sf-icon-enlarge'></i></div>", 1314 "<span class='sr-only'>Toggle Fullscreen</span>", 1315 "</button>", 1316 "</span>", 1317 "</div>"].join("\n"), 1318 onSetup: function() { 1319 1320 if(!("media" in this)) { 1321 return; 1322 } 1323 1324// var player = this, 1325// duration = player.media.duration, 1326// id = player.media.parentNode.getAttribute('id'), 1327// secs = 0, 1328// mins = 0, 1329// hours = 0; 1330// 1331// console.log(player.media); 1332// 1333// secs = parseInt(duration % 60); 1334// mins = parseInt((duration / 60) % 60); 1335// hours = parseInt(((duration / 60) / 60) % 60); 1336// 1337// // Do we need to display hours? 1338// var displayHours = (parseInt(((duration / 60) / 60) % 60) > 0); 1339// 1340// // Ensure it's two digits. For example, 03 rather than 3. 1341// secs = ('0' + secs).slice(-2); 1342// mins = ('0' + mins).slice(-2); 1343// 1344// // Render 1345// var displayTime = (displayHours ? hours + ':' : '') + mins + ':' + secs; 1346// 1347// // Update audio duration display 1348// jQuery('#'+id).parents('figure').find('.audio-duration').text(displayTime); 1349 } 1350 }); 1351 } 1352 }; 1353 1354 1355 ///////////////////////////////////////////// 1356 // SUPER SEARCH 1357 ///////////////////////////////////////////// 1358 1359 SWIFT.superSearch = { 1360 init: function() { 1361 1362 jQuery('.search-options .ss-dropdown').on('click', function(e) { 1363 e.preventDefault(); 1364 1365 var option = jQuery(this), 1366 dropdown = option.find( 'ul' ); 1367 1368 if (isMobileAlt) { 1369 if (dropdown.hasClass('show-dropdown')) { 1370 setTimeout(function() { 1371 dropdown.removeClass('show-dropdown'); 1372 }, 100); 1373 } else { 1374 dropdown.addClass('show-dropdown'); 1375 } 1376 } else { 1377 if (dropdown.hasClass('show-dropdown')) { 1378 setTimeout(function() { 1379 dropdown.removeClass('show-dropdown'); 1380 }, 100); 1381 } else { 1382 dropdown.addClass('show-dropdown'); 1383 } 1384 } 1385 }); 1386 1387 jQuery('.ss-option').on('click', function(e) { 1388 e.preventDefault(); 1389 1390 var thisOption = jQuery(this), 1391 selectedOption = thisOption.attr('data-attr_value'), 1392 parentOption = thisOption.parent().parent().parent(); 1393 1394 parentOption.find('li').removeClass('selected'); 1395 thisOption.parent().addClass('selected'); 1396 1397 parentOption.attr('data-attr_value', selectedOption); 1398 parentOption.find('span').text(thisOption.text()); 1399 1400 setTimeout(function() { 1401 thisOption.parents('ul').first().removeClass('show-dropdown'); 1402 }, 100); 1403 }); 1404 1405 jQuery('.super-search-go').on('click', function(e) { 1406 e.preventDefault(); 1407 var parentSearch = jQuery(this).parents('.sf-super-search'), 1408 filterURL = SWIFT.superSearch.urlBuilder(parentSearch), 1409 homeURL = jQuery(this).attr('data-home_url'), 1410 shopURL = jQuery(this).attr('data-shop_url'); 1411 1412 if (filterURL.indexOf("product_cat") >= 0) { 1413 location.href = homeURL + filterURL; 1414 } else { 1415 location.href = shopURL + filterURL; 1416 } 1417 1418 }); 1419 }, 1420 urlBuilder: function(searchInstance) { 1421 1422 var queryString = ""; 1423 1424 jQuery(searchInstance).find('.search-options .ss-dropdown').each(function() { 1425 1426 var attr = jQuery(this).attr('id'); 1427 var attrValue = jQuery(this).attr('data-attr_value'); 1428 if (attrValue !== "") { 1429 if (attr === "product_cat") { 1430 if (queryString === "") { 1431 queryString += "?product_cat=" + attrValue; 1432 } else { 1433 queryString += "&product_cat=" + attrValue; 1434 } 1435 } else { 1436 if (queryString === "") { 1437 queryString += "?filter_" + attr + "=" + attrValue; 1438 } else { 1439 queryString += "&filter_" + attr + "=" + attrValue; 1440 } 1441 } 1442 } 1443 }); 1444 1445 jQuery('.search-options input').each(function() { 1446 var attr = jQuery(this).attr('name'); 1447 var attrValue = jQuery(this).attr('value'); 1448 if (queryString === "") { 1449 queryString += "?"+ attr + "=" + attrValue; 1450 } else { 1451 queryString += "&" + attr + "=" + attrValue; 1452 } 1453 }); 1454 1455 return queryString; 1456 } 1457 }; 1458 1459 1460 ///////////////////////////////////////////// 1461 // HEADER 1462 ///////////////////////////////////////////// 1463 1464 SWIFT.header = { 1465 init: function() { 1466 1467 // LOGO HOVER 1468 SWIFT.header.logoHoverInit(); 1469 1470 // STICKY HEADER 1471 if (body.hasClass('sticky-header-enabled') && !body.hasClass('vertical-header')) { 1472 SWIFT.header.stickyHeaderInit(); 1473 } 1474 1475 // STICKY TOP BAR 1476 if ( jQuery('.sticky-top-bar').length > 0 ) { 1477 SWIFT.header.stickyTopBarInit(); 1478 } 1479 1480 jQuery('.aux-item .wcml_currency_switcher').on('click', 'li', function() { 1481 jQuery(this).parents('.currency-switch-item').find('.current-currency').transition({ 1482 opacity: 0 1483 }, 400); 1484 jQuery(this).parents('.currency-switch-item').find('.sf-svg-loader').transition({ 1485 opacity: 1 1486 }, 400); 1487 }); 1488 1489 // FS OVERLAY CLOSE 1490 jQuery('a.fs-overlay-close').on('click', function(e) { 1491 e.preventDefault(); 1492 1493 if (body.hasClass('overlay-menu-open')) { 1494 SWIFT.header.overlayMenuToggle(); 1495 } 1496 if (body.hasClass('fs-supersearch-open')) { 1497 SWIFT.header.fsSuperSearchToggle(); 1498 } 1499 }); 1500 1501 // FULLSCREEN SUPERSEARCH 1502 jQuery('a.fs-supersearch-link').on('click', function(e) { 1503 e.preventDefault(); 1504 1505 if (body.hasClass('overlay-menu-open')) { 1506 SWIFT.header.overlayMenuToggle(); 1507 } 1508 1509 SWIFT.header.fsSuperSearchToggle(); 1510 }); 1511 1512 1513 // OVERLAY MENU 1514 jQuery('a.overlay-menu-link').on('click', function(e) { 1515 e.preventDefault(); 1516 SWIFT.header.overlayMenuToggle(); 1517 1518 if (body.hasClass('fs-supersearch-open')) { 1519 SWIFT.header.fsSuperSearchToggle(); 1520 } 1521 }); 1522 1523 // Overlay Menu parent click 1524 jQuery('#overlay-menu li.menu-item > a').on('click', function(e) { 1525 var parentMenuItem = jQuery(this).parent(), 1526 linkHref = jQuery(this).attr('href'), 1527 subMenu = parentMenuItem.find('ul.sub-menu').first(); 1528 1529 if (!parentMenuItem.hasClass('parent')) { 1530 SWIFT.header.overlayMenuToggle(); 1531 1532 if (linkHref.indexOf('#') === 0 && linkHref.length > 1) { 1533 SWIFT.isScrolling = true; 1534 SWIFT.page.onePageNavGoTo(linkHref); 1535 setTimeout(function() { 1536 SWIFT.isScrolling = false; 1537 }, 1000); 1538 e.preventDefault(); 1539 } else if (body.hasClass('page-transitions')) { 1540 SWIFT.page.fadePageOut(linkHref); 1541 } 1542 1543 return e; 1544 } 1545
1546 if (parentMenuItem.hasClass('sub-menu-open')) { 1547 if (linkHref.indexOf('http') === 0 || linkHref.indexOf('/') === 0) { 1548 return e; 1549 } else { 1550 parentMenuItem.removeClass('sub-menu-open'); 1551 subMenu.slideUp(); 1552 e.preventDefault(); 1553 } 1554 } else { 1555 parentMenuItem.addClass('sub-menu-open'); 1556 subMenu.slideDown(); 1557 e.preventDefault(); 1558 } 1559 }); 1560 1561 // SIDE SLIDEOUT MENU 1562 jQuery('a.side-slideout-link').on('click', function(e) { 1563 e.preventDefault(); 1564 SWIFT.nav.showSideSlideout(jQuery(this).data('side')); 1565 }); 1566 $window.smartresize( function() { 1567 var windowWidth = $window.width(); 1568 1569 if (windowWidth < 1024 && body.hasClass('mhs-tablet-land') && body.hasClass('side-slideout-open')) { 1570 SWIFT.nav.sideSlideoutHideTrigger(); 1571 } else if (windowWidth < 991 && body.hasClass('mhs-tablet-port') && body.hasClass('side-slideout-open')) { 1572 SWIFT.nav.sideSlideoutHideTrigger(); 1573 } else if (windowWidth < 767 && body.hasClass('mhs-mobile') && body.hasClass('side-slideout-open')) { 1574 SWIFT.nav.sideSlideoutHideTrigger(); 1575 } 1576 1577 }); 1578 1579 1580 // STANDARD SEARCH 1581 jQuery('.header-search-link-alt').on('click', function(e) { 1582 e.preventDefault(); 1583 1584 var searchLink = jQuery(this), 1585 headerSearchWrap = searchLink.parent().find('.header-search-wrap'); 1586 1587 if (headerSearchWrap.is(':visible')) { 1588 headerSearchWrap.fadeOut(300); 1589 searchLink.removeClass('search-open'); 1590 } else { 1591 headerSearchWrap.fadeIn(300); 1592 searchLink.addClass('search-open'); 1593 } 1594 1595 }); 1596 1597 // FULL HEADER SEARCH 1598 jQuery('.fs-header-search-link').on('click', function(e) { 1599 e.preventDefault(); 1600 body.toggleClass('sf-header-search-is-open'); 1601 if ( body.hasClass('sf-header-search-is-open') ) { 1602 setTimeout(function() { 1603 jQuery('#sf-full-header-search').find('input').focus(); 1604 jQuery('#sf-full-header-search-backdrop').on('click touchstart', function() { 1605 jQuery('#sf-full-header-search').find('input').blur(); 1606 body.removeClass('sf-header-search-is-open'); 1607 jQuery('#sf-full-header-search-backdrop').off('click touchstart'); 1608 }); 1609 }, 500); 1610 } else { 1611 jQuery('#container').off('click touchstart'); 1612 } 1613 }); 1614 jQuery('.sf-fhs-close').on('click', function(e) { 1615 e.preventDefault(); 1616 body.removeClass('sf-header-search-is-open'); 1617 jQuery('#sf-full-header-search-backdrop').off('click touchstart'); 1618 }); 1619 1620 1621 // CONTACT SLIDEOUT 1622 jQuery('a.contact-menu-link').on('click', function(e) { 1623 e.preventDefault(); 1624 var contactSlideout = jQuery('#contact-slideout'), 1625 thisLink = jQuery(this); 1626 1627 if ( body.scrollTop() > 0 ) { 1628 jQuery('body,html').animate({scrollTop: 0}, 600, 'easeOutCubic'); 1629 setTimeout(function() { 1630 contactSlideout.slideToggle(800, 'easeInOutExpo'); 1631 if (thisLink.hasClass('slide-open')) { 1632 thisLink.removeClass('slide-open'); 1633 } else { 1634 SWIFT.map.init(); 1635 thisLink.addClass('slide-open'); 1636 } 1637 }, 800); 1638 } else { 1639 contactSlideout.slideToggle(800, 'easeInOutExpo'); 1640 if (thisLink.hasClass('slide-open')) { 1641 thisLink.removeClass('slide-open'); 1642 } else { 1643 SWIFT.map.init(); 1644 thisLink.addClass('slide-open'); 1645 } 1646 } 1647 }); 1648 1649 // MOBILE STICKY HEADER 1650 if (body.hasClass('mh-sticky')) { 1651 1652 if (isMobileAlt) { 1653 jQuery('html').addClass('has-mh-sticky'); 1654 } 1655 1656 var mobileHeader = jQuery('#mobile-header'), 1657 spacing = 0; 1658 1659 mobileHeader.sticky({ 1660 topSpacing: spacing, 1661 isMobile: true 1662 }); 1663 1664 jQuery('#mobile-header-sticky-wrapper').css('height', mobileHeader.outerHeight(true)); 1665 1666 $window.smartresize( function() { 1667 mobileHeader.sticky('update'); 1668 jQuery('#mobile-header-sticky-wrapper').css('height', mobileHeader.outerHeight(true)); 1669 }); 1670 } 1671 1672 1673 // VERTICAL HEADER RIGHT POSITIONING 1674 if (body.hasClass('layout-boxed') && body.hasClass('vertical-header-right')) { 1675 1676 var rightOffset = ($window.width() - jQuery('#container').width()) / 2; 1677 jQuery('.header-wrap').css('right', rightOffset); 1678 1679 $window.smartresize( function() { 1680 var rightOffset = ($window.width() - jQuery('#container').width()) / 2; 1681 jQuery('.header-wrap').css('right', rightOffset); 1682 }); 1683 } 1684 }, 1685 logoHoverInit: function() { 1686 var logo = jQuery('#logo'), 1687 animation = logo.data('anim'); 1688 1689 if ( animation === "" ) { 1690 return; 1691 } 1692 1693 jQuery(document).on("mouseenter", "#logo", function() { 1694 logo.addClass('sf-animate ' + animation); 1695 }).on("mouseleave", "#logo", function() { 1696 logo.removeClass('sf-animate ' + animation); 1697 }); 1698 }, 1699 stickyHeaderInit: function() { 1700 var spacing = 0, 1701 offset = 0, 1702 stickyHeader = jQuery('.sticky-header'), 1703 headerWrap = jQuery('.header-wrap'); 1704 1705 if (jQuery('#wpadminbar').length > 0) { 1706 spacing = jQuery('#wpadminbar').outerHeight(); 1707 offset = jQuery('#wpadminbar').outerHeight(); 1708 } 1709 1710 if ( jQuery('.sticky-top-bar').length > 0 ) { 1711 offset += jQuery('.sticky-top-bar').outerHeight(); 1712 } 1713 1714 if ( jQuery('#top-bar').length > 0 ) { 1715 spacing += jQuery('#top-bar').outerHeight(); 1716 } 1717 1718 if ( body.hasClass('app-header') ) { 1719 jQuery('.sticky-header').css('position', 'fixed').css('top', spacing); 1720 jQuery('.sticky-header').wrap('<div class="sticky-wrapper"></div>'); 1721 } else { 1722 1723 if ( headerWrap.hasClass('full-header-stick') && !body.hasClass('header-below-slider') && jQuery('#top-bar').length <= 0 ) { 1724 stickyHeader.css('position', 'fixed').css('top', spacing); 1725 } 1726 1727 stickyHeader.sticky({ 1728 topSpacing: offset 1729 }); 1730 1731 stickyHeader.on('sticky-start', function() { 1732 if ( !body.hasClass('app-header') && !body.hasClass('sticky-header-transparent') ) { 1733 stickyHeader.parent().addClass('default-state'); 1734 } 1735 }); 1736 stickyHeader.on('sticky-end', function() { 1737 stickyHeader.parent().removeClass('default-state'); 1738 }); 1739 1740 $window.smartresize( function() { 1741 stickyHeader.sticky('update'); 1742 }); 1743 1744 } 1745 1746 if ( body.hasClass('layout-boxed') ) { 1747 jQuery('.sticky-header').css('max-width', headerWrap.width()); 1748 $window.smartresize( function() { 1749 jQuery('.sticky-header').css('max-width', headerWrap.width()); 1750 }); 1751 } 1752 1753 1754 // Sticky Header Resizing 1755 if (body.hasClass('sh-dynamic')) { 1756 var defaultHeaderPos = headerWrap.offset().top; 1757 $window.scroll(function () { 1758 defaultHeaderPos = headerWrap.offset().top - $window.scrollTop(); 1759 if (jQuery('.sticky-wrapper').hasClass('is-sticky') && defaultHeaderPos < -160) { 1760 headerWrap.addClass('resized-header'); 1761 } else if (headerWrap.hasClass('resized-header')) { 1762 headerWrap.removeClass('resized-header'); 1763 } 1764 1765 }); 1766 } 1767 1768 // Sticky Header Hiding 1769 if (body.hasClass('sh-show-hide')) { 1770 var lastTop = 0; 1771 1772 $window.scroll( function() { 1773 var currentTop = jQuery(this).scrollTop(); 1774 var headerHide = 800; 1775 var sliderHeight = 0; 1776 1777 if ( jQuery('#container > .swift-slider-outer').length > 0 ) { 1778 var slider = jQuery('#container > .swift-slider-outer'), 1779 sliderTop = slider.offset().top; 1780 sliderHeight = slider.height(); 1781 headerHide = sliderTop + sliderHeight + 100; 1782 } else if ( jQuery('#container > .home-slider-wrap').length > 0 ) { 1783 var contentTop = jQuery('#main-container').offset().top; 1784 sliderHeight = jQuery('#container > .home-slider-wrap').height(); 1785 headerHide = contentTop + sliderHeight + 100; 1786 } 1787 1788 if (currentTop > lastTop && currentTop > headerHide) { 1789 1790 if ( body.hasClass('fs-supersearch-open') || body.hasClass('overlay-menu-open') || body.hasClass('fs-search-open') ) { 1791 return; 1792 } 1793 1794 jQuery('.sticky-header').addClass('sticky-header-hide'); 1795 } else if (jQuery('.sticky-header').hasClass('sticky-header-hide')) { 1796 jQuery('.sticky-header').removeClass('sticky-header-hide'); 1797 } 1798 lastTop = currentTop; 1799 }); 1800 } 1801 }, 1802 stickyTopBarInit: function() { 1803 var spacing = 0, 1804 stickyTB = jQuery('.sticky-top-bar'), 1805 headerWrap = jQuery('.header-wrap'); 1806 1807 if (jQuery('#wpadminbar').length > 0) { 1808 spacing = 32; 1809 } 1810 1811 stickyTB.sticky({ 1812 topSpacing: spacing 1813 }); 1814 1815 $window.smartresize( function() { 1816 stickyTB.sticky('update'); 1817 }); 1818 1819 if (body.hasClass('layout-boxed')) { 1820 stickyTB.css('max-width', headerWrap.width()); 1821 $window.smartresize( function() { 1822 stickyTB.css('max-width', headerWrap.width()); 1823 }); 1824 } 1825 }, 1826 fsSuperSearchToggle: function() { 1827 if (body.hasClass('fs-supersearch-open')) { 1828 body.removeClass('fs-supersearch-open'); 1829 body.removeClass('fs-aux-open'); 1830 body.addClass('fs-supersearch-closing'); 1831 setTimeout(function() { 1832 jQuery('#main-nav,#main-navigation').fadeIn(400); 1833 }, 200); 1834 } else { 1835 setTimeout(function() { 1836 body.removeClass('fs-supersearch-closing'); 1837 body.addClass('fs-supersearch-open'); 1838 body.addClass('fs-aux-open'); 1839 jQuery('#main-nav,#main-navigation').fadeOut(300);
1840 }, 30); 1841 } 1842 }, 1843 overlayMenuToggle: function() { 1844 var overlayMenu = jQuery('#overlay-menu'), 1845 overlayMenuItemHeight = Math.floor(overlayMenu.find('nav ul.menu').height() / overlayMenu.find('ul.menu > li.menu-item').length) - 5, 1846 overlayMenuItemFS = Math.floor(overlayMenuItemHeight * 0.5); 1847 1848 // Set limits 1849 if ( overlayMenuItemFS > 60 ) { 1850 overlayMenuItemFS = 60; 1851 } 1852 if ( overlayMenuItemHeight > 120 ) { 1853 overlayMenuItemHeight = 120; 1854 } 1855 1856 // Apply styles 1857 overlayMenu.find('ul.menu > li.menu-item > a').css('font-size', overlayMenuItemFS + 'px').css('line-height', overlayMenuItemHeight - 20 + 'px'); 1858 1859 if (body.hasClass('overlay-menu-open')) { 1860 body.removeClass('overlay-menu-open'); 1861 body.removeClass('fs-aux-open'); 1862 body.addClass('overlay-menu-closing'); 1863 setTimeout(function() { 1864 if (!body.hasClass('fs-search-open')) { 1865 jQuery('#main-nav,#main-navigation').fadeIn(400); 1866 if ( jQuery('.split-menu').length > 0 ) { 1867 jQuery('.split-menu').css('pointer-events', ''); 1868 jQuery('.split-menu').transition({ 1869 opacity: 1 1870 }, 400); 1871 } 1872 } 1873 body.removeClass('overlay-menu-closing'); 1874 }, 200); 1875 } else { 1876 setTimeout(function() { 1877 body.removeClass('overlay-menu-closing'); 1878 body.addClass('overlay-menu-open'); 1879 body.addClass('fs-aux-open'); 1880 jQuery('#main-nav,#main-navigation').fadeOut(300); 1881 if ( jQuery('.split-menu').length > 0 ) { 1882 jQuery('.split-menu').css('pointer-events', 'none'); 1883 jQuery('.split-menu').transition({ 1884 opacity: 0 1885 }, 400); 1886 } 1887 }, 30); 1888 } 1889 } 1890 }; 1891 1892 1893 ///////////////////////////////////////////// 1894 // NAVIGATION 1895 ///////////////////////////////////////////// 1896 1897 SWIFT.nav = { 1898 init: function() { 1899 1900 // Set up Main Menu 1901 if (!isMobile || $window.width() > 768) { 1902 SWIFT.nav.mainMenu(); 1903 } 1904 1905 // Set up Mega Menu 1906 if ( jQuery('.mega-menu-wrap').length > 0 && body.hasClass('mm-default-theme') ) { 1907 SWIFT.nav.megaMenu(); 1908 } 1909 1910 // Set up Mobile Menu 1911 SWIFT.nav.mobileMenuInit(); 1912 1913 // Add main menu actions 1914 SWIFT.nav.mainMenuActions(); 1915 1916 // Side Slidout 1917 if ( jQuery('.sf-side-slideout').length > 0 ) { 1918 SWIFT.nav.sideSlideoutInit(); 1919 } 1920 1921 // Push Nav 1922 if ( jQuery('.sf-pushnav').length > 0 ) { 1923 SWIFT.nav.pushNavInit(); 1924 } 1925 1926 // Mega Menu plugin modifications 1927 if ( body.hasClass('mm-default-theme') ) { 1928 jQuery('li.mega-menu-megamenu > ul.mega-sub-menu').each( function() { 1929 jQuery(this).wrapInner('<section class="container"></section>'); 1930 }); 1931 } 1932 }, 1933 mainMenu: function() { 1934 1935 var mainNav = jQuery("#main-navigation"); 1936 1937 if (jQuery('.header-wrap').hasClass('full-center')) { 1938 mainNav.find('li.sf-mega-menu > ul.sub-menu').each(function() { 1939 var thisSubMenu = jQuery(this); 1940 1941 if (!thisSubMenu.children().first().hasClass('container')) { 1942 jQuery(this).wrapInner('<div class="container"></div>'); 1943 } 1944 }); 1945 } 1946 1947 mainNav.find(".menu li.menu-item").hoverIntent({ 1948 over: function() { 1949 if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) { 1950 jQuery(this).find('ul.sub-menu,.mega-menu-sub').first().fadeIn(200); 1951 } 1952 }, 1953 out:function() { 1954 if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) { 1955 jQuery(this).find('ul.sub-menu,.mega-menu-sub').first().fadeOut(150); 1956 } 1957 }, 1958 timeout: 0 1959 }); 1960 1961 // Set sub-menu position based on menu height 1962 var mainNavHeight = mainNav.height(), 1963 subMenu = mainNav.find('.sub-menu'); 1964 1965 subMenu.each(function() { 1966 jQuery(this).css('top', mainNavHeight); 1967 }); 1968 }, 1969 megaMenu: function() { 1970 var megaMenuWrap = jQuery('.mega-menu-wrap'), 1971 megaMenu = megaMenuWrap.find('.mega-menu'); 1972 //megaMenuEvent = megaMenu.data('event'), 1973 //megaMenuEffect = megaMenu.data('effect'), 1974 //megaMenuSecondClick = megaMenu.data('second-click'), 1975 //megaMenuDocumentClick = megaMenu.data('document-click'); 1976 1977 // Remove no-js class 1978 megaMenu.removeClass('mega-no-js'); 1979 1980 // Hover/Click event handling 1981 //if ( megaMenuEvent === "hover" ) { 1982 // Enable hover dropdowns for window size above tablet width 1983 jQuery("nav.std-menu ul.mega-menu").find("li.mega-menu-item-has-children").hoverIntent({ 1984 over: function() { 1985 var isSideSlideout = jQuery(this).parents('.sf-side-slideout').length > 0;
1986 if ((jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) && !isSideSlideout) { 1987 jQuery(this).find('ul.mega-sub-menu').first().stop( true, true ).fadeIn(200); 1988 } 1989 }, 1990 out:function() { 1991 var isSideSlideout = jQuery(this).parents('.sf-side-slideout').length > 0; 1992 if ((jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) && !isSideSlideout) { 1993 jQuery(this).find('ul.mega-sub-menu').first().stop( true, true ).fadeOut(150); 1994 } 1995 }, 1996 timeout: 100 1997 }); 1998 //} 1999 }, 2000 megaMenuShowSub: function(anchor) { 2001 var isSideSlideout = anchor.parents('.sf-side-slideout').length > 0; 2002 if ((jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) && !isSideSlideout) { 2003 anchor.find('ul.mega-sub-menu').first().stop( true, true ).fadeIn(200); 2004 } 2005 }, 2006 megaMenuHideSub: function(anchor, immediate) { 2007 anchor.siblings('.mega-sub-menu').children('.mega-toggle-on').removeClass('mega-toggle-on'); 2008 2009 if (immediate) { 2010 anchor.siblings('.mega-sub-menu').removeClass('mega-toggle-on').css('display', ''); 2011 anchor.parent().removeClass('mega-toggle-on').triggerHandler("close_panel"); 2012 return; 2013 } 2014 }, 2015 mainMenuActions: function() { 2016 2017 SWIFT.nav.menuItemClickHandler(false); 2018 2019 jQuery(".mega-menu").on("after_mega_menu_init", function() { 2020 SWIFT.nav.menuItemClickHandler(true); 2021 }); 2022 2023 // Add parent class to items with sub-menus 2024 jQuery("ul.sub-menu").parents('li').addClass('parent'); 2025 2026 // Menu parent click function 2027 jQuery('.menu li.parent > a').on('click', function(e) { 2028 2029 if (jQuery('#container').width() < 1024 || body.hasClass('standard-browser')) { 2030 return e; 2031 } 2032 2033 var directDropdown = jQuery(this).parent().find('ul.sub-menu').first(); 2034 2035 if (directDropdown.css('opacity') === '1' || directDropdown.css('opacity') === 1) { 2036 return e; 2037 } else { 2038 e.preventDefault(); 2039 } 2040 }); 2041 2042 // Set Standard Sub Menu Top Position 2043 jQuery("nav.std-menu").find(".menu li").each(function() { 2044 var top = jQuery(this).outerHeight(); 2045 jQuery(this).find('ul.sub-menu').first().css('top', top); 2046 }); 2047 2048 // Enable hover dropdowns for window size above tablet width 2049 jQuery("nav.std-menu").find(".menu li.parent").hoverIntent({ 2050 over: function() { 2051 var isSideSlideout = jQuery(this).parents('.sf-side-slideout').length > 0; 2052 if ((jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) && !isSideSlideout) { 2053 jQuery(this).find('ul.sub-menu').first().stop( true, true ).fadeIn(200); 2054 } 2055 }, 2056 out:function() { 2057 var isSideSlideout = jQuery(this).parents('.sf-side-slideout').length > 0; 2058 if ((jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) && !isSideSlideout) { 2059 jQuery(this).find('.sub-menu').first().stop( true, true ).fadeOut(150); 2060 } 2061 }, 2062 timeout: 100 2063 }); 2064 2065 2066 // Shopping bag hover function 2067 jQuery(document).on("mouseenter", "li.shopping-bag-item", function() { 2068 2069 if ( jQuery(this).parents('#mobile-menu-wrap').length > 0 || jQuery(this).parents('#mobile-cart-wrap').length > 0 ) { 2070 return; 2071 } 2072 2073 if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) { 2074 jQuery(this).find('ul.sub-menu').first().stop( true, true ).fadeIn(200); 2075 shopBagHovered = true; 2076 } 2077 }).on("mouseleave", "li.shopping-bag-item", function() { 2078 2079 if ( jQuery(this).parents('#mobile-menu-wrap').length > 0 || jQuery(this).parents('#mobile-cart-wrap').length > 0 ) { 2080 return; 2081 } 2082 2083 if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) { 2084 jQuery(this).find('ul.sub-menu').first().stop( true, true ).fadeOut(150); 2085 shopBagHovered = false; 2086 } 2087 }); 2088 2089 2090 // Set current language to top bar item 2091 var currentLanguage = jQuery('.aux-language').find('.current-language').html(); 2092 if (currentLanguage !== "") { 2093 jQuery('.aux-language .language-item > a').html(currentLanguage); 2094 } 2095 jQuery('.aux-language .language-item > a').animate({ 2096 'opacity': 1 2097 }, 400, 'easeOutQuart'); 2098 var currentLanguageText = jQuery('.aux-language-text').find('.current-language').html(); 2099 if (currentLanguageText !== "") { 2100 jQuery('.aux-language-text .language-item > a').html(currentLanguageText); 2101 } 2102 jQuery('.aux-language-text .language-item > a').animate({ 2103 'opacity': 1 2104 }, 400, 'easeOutQuart'); 2105 2106 // Set menu state on resize 2107 $window.smartresize( function() { 2108 if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) { 2109 var menus = jQuery('nav').find('ul.menu'); 2110 menus.each(function() { 2111 jQuery(this).css("display", ""); 2112 });
2113 } 2114 }); 2115 2116 // Change menu active when scroll through sections 2117 if ( jQuery('section.row.row-has-id').length > 0 ) { 2118 SWIFT.nav.currentScrollIndication(); 2119 $window.on('scroll', SWIFT.nav.throttle( SWIFT.nav.currentScrollIndication, 300 )); 2120 } 2121 }, 2122 throttle: function(fn, threshhold, scope) { 2123 var last, 2124 deferTimer; 2125 return function () { 2126 var context = scope || this; 2127 2128 var now = new Date(), 2129 args = arguments; 2130 if (last && now < last + threshhold) { 2131 // hold on to it 2132 clearTimeout(deferTimer); 2133 deferTimer = setTimeout(function () { 2134 last = now; 2135 fn.apply(context, args); 2136 }, threshhold); 2137 } else { 2138 last = now; 2139 fn.apply(context, args); 2140 } 2141 }; 2142 }, 2143 menuItemClickHandler: function(megamenu) { 2144 2145 var menuItemClass = '.menu-item'; 2146 2147 if ( megamenu ) { 2148 menuItemClass = '.mega-menu-item'; 2149 } 2150 // Menu item click function 2151 jQuery(menuItemClass).on('click', 'a', function(e) { 2152 2153 var menuItem = jQuery(this), 2154 linkHref = menuItem.attr('href'), 2155 isMobileMenuItem = false, 2156 isSlideoutItem = false, 2157 youtubeURL = linkHref.match(/watch\?v=([a-zA-Z0-9\-_]+)/), 2158 vimeoURL = linkHref.match(/^http:\/\/(www\.)?vimeo\.com\/(clip\:)?(\d+).*$/); 2159 2160 2161 if (jQuery(this).parents('nav').attr('id') === "mobile-menu") { 2162 isMobileMenuItem = true; 2163 } 2164 2165 if ( jQuery(this).parents('.sf-side-slideout').length > 0 ) { 2166 isSlideoutItem = true; 2167 } 2168 2169 // Link to full width video overlay if link is YouTube/Vimeo 2170 if (youtubeURL || vimeoURL) { 2171 2172 var videoURL = ""; 2173 2174 if (youtubeURL) { 2175 videoURL = 'https://www.youtube.com/embed/'+ youtubeURL[1] +'?autoplay=1&wmode=transparent'; 2176 } else if (vimeoURL) { 2177 videoURL = 'https://player.vimeo.com/video/'+ vimeoURL[3] +'?title=0&byline=0&portrait=0&autoplay=1&wmode=transparent'; 2178 } 2179 2180 if (videoURL !== "") { 2181 jQuery(this).data('video', videoURL); 2182 SWIFT.widgets.openFullWidthVideo(jQuery(this)); 2183 } 2184 e.preventDefault(); 2185 // Smooth Scroll 2186 } else if (linkHref.indexOf('#') === 0 && linkHref.length > 1) { 2187 var headerHeight = 0; 2188 2189 if (isMobileMenuItem) { 2190 SWIFT.nav.mobileMenuHideTrigger(); 2191 setTimeout(function() { 2192 if (body.hasClass('mh-sticky')) { 2193 headerHeight = jQuery('#mobile-header').height(); 2194 } 2195 if (jQuery('#mobile-top-text').length > 0) { 2196 headerHeight = headerHeight + jQuery('#mobile-top-text').outerHeight(); 2197 } 2198 if (jQuery('#wpadminbar').length > 0) { 2199 headerHeight = headerHeight + jQuery('#wpadminbar').height(); 2200 } 2201 2202 if (jQuery(linkHref).length > 0) { 2203 jQuery('html, body').stop().animate({ 2204 scrollTop: jQuery(linkHref).offset().top - headerHeight + 2 2205 }, 1000, 'easeInOutExpo'); 2206 } 2207 }, 400); 2208 } else { 2209 SWIFT.page.onePageNavGoTo(linkHref); 2210 } 2211 e.preventDefault(); 2212 } else { 2213 if (isMobileMenuItem) { 2214 return; 2215 } else { 2216 return e; 2217 } 2218 } 2219 2220 }); 2221 }, 2222 currentScrollIndication: function() { 2223 var adjustment = 0; 2224 2225 if (body.hasClass('sticky-header-enabled')) { 2226 adjustment = jQuery('.header-wrap').height(); 2227 } 2228 2229 if ( jQuery('.sticky-top-bar').length > 0 ) { 2230 adjustment += jQuery('.sticky-top-bar').outerHeight(); 2231 } 2232 2233 var inview = jQuery('section.row:in-viewport('+adjustment+')').attr('id'), 2234 menuItems = jQuery('#main-navigation .menu li a, #main-navigation .mega-menu li a'), 2235 link; 2236 2237 if ( inview !== "" && typeof inview !== 'undefined' ) { 2238 link = menuItems.filter('[href="#' + inview + '"]'); 2239 } 2240 2241 menuItems.parent().removeClass('current-scroll-item'); 2242 2243 if (typeof inview != 'undefined' && link.length > 0 && !link.hasClass('.current-scroll-item')) { 2244 menuItems.parent().removeClass('current-scroll-item'); 2245 link.parent().addClass('current-scroll-item'); 2246 } 2247 }, 2248 mobileMenuInit: function() { 2249 2250 // Mobile Logo click 2251 // jQuery('#mobile-logo > a').on('click touchstart', function(e) { 2252 // if (body.hasClass('mobile-menu-open') || body.hasClass('mobile-cart-open') || body.hasClass('mobile-menu-closing')) { 2253 // return false; 2254 // } else { 2255 // return e; 2256 // } 2257 // }); 2258 2259 SWIFT.nav.setMobileCartPadding(); 2260 2261 // Mobile Nav show 2262 jQuery('.mobile-menu-link').on('click', function(e) { 2263 e.preventDefault(); 2264 2265 SWIFT.nav.setMobileCartPadding(); 2266 2267 if ( body.hasClass('mobile-cart-open') ) { 2268 SWIFT.nav.mobileMenuHideTrigger(); 2269 } 2270 2271 jQuery('.mobile-menu-link').toggleClass('is-active'); 2272 2273 if ( body.hasClass('mobile-menu-open') ) { 2274 SWIFT.nav.mobileMenuHideTrigger(); 2275 } else if ( body.hasClass('mh-overlay') ) { 2276 SWIFT.nav.mobileHeaderOverlay('menu'); 2277 } else { 2278 SWIFT.nav.showMobileMenu(); 2279 } 2280 }); 2281 2282 // Mobile Cart show 2283 jQuery(document).on('click', '.cart-contents', function(e) { 2284 2285 if ( jQuery(this).parents('.mobile-header-opts').length > 0 ) { 2286 e.preventDefault(); 2287 2288 SWIFT.nav.setMobileCartPadding(); 2289 2290 if ( body.hasClass('mobile-menu-open') ) { 2291 SWIFT.nav.mobileMenuHideTrigger(); 2292 } 2293 2294 if (body.hasClass('mobile-cart-open')) { 2295 SWIFT.nav.mobileMenuHideTrigger(); 2296 } else if (body.hasClass('mh-overlay')) { 2297 SWIFT.nav.mobileHeaderOverlay('cart'); 2298 } else { 2299 SWIFT.nav.showMobileCart(); 2300 } 2301 2302 } else { 2303 return e; 2304 } 2305 }); 2306 2307 // Mobile Menu parent click 2308 jQuery(document).on('click', '#mobile-menu li > a', function(e) { 2309 var parentMenuItem = jQuery(this).parent(), 2310 linkHref = jQuery(this).attr('href'), 2311 subMenu = parentMenuItem.find('ul.sub-menu').first(); 2312 2313 if (!parentMenuItem.hasClass('parent')) { 2314 SWIFT.nav.mobileMenuHideTrigger(); 2315 2316 if (linkHref.indexOf('#') === 0 && linkHref.length > 1) { 2317 SWIFT.isScrolling = true; 2318 SWIFT.page.onePageNavGoTo(linkHref); 2319 setTimeout(function() { 2320 SWIFT.isScrolling = false; 2321 }, 1000); 2322 e.preventDefault(); 2323 } else if (body.hasClass('page-transitions')) { 2324 SWIFT.page.fadePageOut(linkHref); 2325 } 2326 2327 return e; 2328 } 2329
2330 if (parentMenuItem.hasClass('sub-menu-open')) { 2331 if (linkHref.indexOf('http') === 0 || linkHref.indexOf('/') === 0) { 2332 return e; 2333 } else { 2334 parentMenuItem.removeClass('sub-menu-open'); 2335 subMenu.slideUp(); 2336 e.preventDefault(); 2337 } 2338 } else { 2339 parentMenuItem.addClass('sub-menu-open'); 2340 subMenu.slideDown(); 2341 e.preventDefault(); 2342 } 2343 }); 2344 2345 2346 // Swipe to hide mobile menu 2347 jQuery("#mobile-menu-wrap").swipe({ 2348 swipeLeft:function() { 2349 if (!body.hasClass('mobile-header-center-logo-alt') && !body.hasClass('mobile-header-left-logo')) { 2350 SWIFT.nav.mobileMenuHideTrigger(); 2351 } 2352 }, 2353 swipeRight:function() { 2354 if (body.hasClass('mobile-header-center-logo-alt') || body.hasClass('mobile-header-left-logo')) { 2355 SWIFT.nav.mobileMenuHideTrigger(); 2356 } 2357 }, 2358 }); 2359 2360 // Swipe to hide mobile cart 2361 jQuery("#mobile-cart-wrap").swipe( { 2362 swipeLeft:function() { 2363 if (body.hasClass('mobile-header-center-logo-alt') || body.hasClass('mobile-header-right-logo') || body.hasClass('mobile-header-center-logo')) { 2364 SWIFT.nav.mobileMenuHideTrigger(); 2365 } 2366 }, 2367 swipeRight:function() { 2368 if (!body.hasClass('mobile-header-center-logo-alt') && !body.hasClass('mobile-header-right-logo')) { 2369 SWIFT.nav.mobileMenuHideTrigger(); 2370 } 2371 }, 2372 }); 2373 2374 // Hide on resize 2375 $window.smartresize( function() { 2376 2377 var windowWidth = $window.width(); 2378 2379 if (windowWidth > 1024 && body.hasClass('mhs-tablet-land')) { 2380 SWIFT.nav.mobileMenuHideTrigger(); 2381 } else if (windowWidth > 991 && body.hasClass('mhs-tablet-port')) { 2382 SWIFT.nav.mobileMenuHideTrigger(); 2383 } else if (windowWidth > 767 && body.hasClass('mhs-mobile')) { 2384 SWIFT.nav.mobileMenuHideTrigger(); 2385 } 2386 2387 }); 2388 2389 }, 2390 setMobileCartPadding: function() { 2391 var mHeaderHeight = jQuery('#mobile-header').outerHeight(); 2392 if ( jQuery('#mobile-top-text').length > 0 ) { 2393 mHeaderHeight += jQuery('#mobile-top-text').outerHeight(); 2394 } 2395 if ( jQuery('#wpadminbar').length > 0 ) { 2396 mHeaderHeight += jQuery('#wpadminbar').outerHeight(); 2397 } 2398 if ( jQuery('#mobile-header').parent().hasClass('is-sticky') ) { 2399 mHeaderHeight = jQuery('#mobile-header').offset().top + jQuery('#mobile-header').outerHeight() - $window.scrollTop(); 2400 } 2401 jQuery('#mobile-menu-wrap').css('padding-top', mHeaderHeight); 2402 jQuery('#mobile-cart-wrap').css('padding-top', mHeaderHeight); 2403 }, 2404 showMobileMenu: function() { 2405 SWIFT.nav.setMobileCartPadding(); 2406 body.addClass('mobile-menu-open'); 2407 setTimeout(function() { 2408 jQuery('#sf-mobile-slideout-backdrop').on('click touchstart', SWIFT.nav.mobileMenuHideTrigger); 2409 }, 400); 2410 }, 2411 hideMobileMenu: function() { 2412 body.removeClass('mobile-menu-open'); 2413 body.removeClass('mh-menu-show'); 2414 jQuery('.mobile-menu-link').removeClass('is-active'); 2415 if ( body.hasClass('mh-overlay-show') ) { 2416 body.removeClass('mh-overlay-show'); 2417 } 2418 setTimeout(function() { 2419 jQuery('#sf-mobile-slideout-backdrop').off('click touchstart', SWIFT.nav.mobileMenuHideTrigger); 2420 }, 300); 2421 setTimeout(function() { 2422 body.removeClass('mobile-menu-closing'); 2423 }, 1000); 2424 }, 2425 showMobileCart: function() { 2426 SWIFT.nav.setMobileCartPadding(); 2427 body.addClass('mobile-cart-open'); 2428 setTimeout(function() { 2429 jQuery('#sf-mobile-slideout-backdrop').on('click touchstart', SWIFT.nav.mobileMenuHideTrigger); 2430 }, 400); 2431 }, 2432 hideMobileCart: function() { 2433 body.removeClass('mobile-cart-open'); 2434 if ( body.hasClass('mh-overlay-show') ) { 2435 body.removeClass('mh-overlay-show'); 2436 } 2437 body.removeClass('mh-cart-show'); 2438 setTimeout(function() { 2439 jQuery('#sf-mobile-slideout-backdrop').off('click touchstart', SWIFT.nav.mobileMenuHideTrigger); 2440 }, 400); 2441 setTimeout(function() { 2442 body.removeClass('mobile-menu-closing'); 2443 }, 1000); 2444 }, 2445 mobileMenuHideTrigger: function(e) { 2446 if (e) { 2447 e.preventDefault(); 2448 } 2449 body.addClass('mobile-menu-closing'); 2450 SWIFT.nav.hideMobileMenu(); 2451 SWIFT.nav.hideMobileCart(); 2452 }, 2453 mobileHeaderOverlay: function(type) { 2454 SWIFT.nav.setMobileCartPadding(); 2455 if (type === "menu") { 2456 body.addClass('mh-overlay-show mh-menu-show mobile-menu-open'); 2457 } else if (type === "cart") { 2458 body.addClass('mh-overlay-show mh-cart-show mobile-cart-open'); 2459 } 2460 }, 2461 showSideSlideout: function(side) { 2462 2463 var windowTop = $window.scrollTop(); 2464 2465 if (side === "left") { 2466 jQuery('#side-slideout-left-wrap').css('display', 'block'); 2467 body.addClass('side-slideout-open'); 2468 body.addClass('side-slideout-left-open'); 2469 } else { 2470 jQuery('#side-slideout-right-wrap').css('display', 'block'); 2471 body.addClass('side-slideout-open'); 2472 body.addClass('side-slideout-right-open'); 2473 } 2474 2475 if (windowTop > 0 && body.hasClass('sticky-header-enabled') && jQuery('.sticky-wrapper').hasClass('is-sticky')) { 2476 stickyHeaderTop = jQuery('.sticky-header').css('top'); 2477 jQuery('.sticky-header').css('position', 'absolute').css('top', windowTop); 2478 if ( jQuery('.sticky-top-bar').length > 0 ) { 2479 jQuery('.sticky-top-bar').css('position', 'absolute').css('top', windowTop); 2480 } 2481 } 2482 2483 setTimeout(function() { 2484 jQuery('#container').on('click touchstart', SWIFT.nav.sideSlideoutHideTrigger); 2485 }, 400); 2486 }, 2487 hideSideSlideout: function() { 2488 body.removeClass('side-slideout-open side-slideout-left-open side-slideout-right-open'); 2489 setTimeout(function() { 2490 jQuery('#container').off('click touchstart', SWIFT.nav.sideSlideoutHideTrigger); 2491 }, 400); 2492 setTimeout(function() { 2493 body.removeClass('side-slideout-closing'); 2494 if (body.hasClass('sticky-header-enabled') && jQuery('.sticky-wrapper').hasClass('is-sticky')) { 2495 jQuery('.sticky-header').css('position', 'fixed').css('top', stickyHeaderTop); 2496 jQuery('.sticky-top-bar').css('position', 'fixed').css('top', stickyHeaderTop); 2497 } 2498 }, 1000); 2499 }, 2500 sideSlideoutHideTrigger: function() { 2501 body.addClass('side-slideout-closing'); 2502 SWIFT.nav.hideSideSlideout(); 2503 }, 2504 sideSlideoutInit: function() { 2505 // Slideout Menu parent click 2506 jQuery('.sf-side-slideout li.menu-item > a').on('click', function(e) { 2507 var parentMenuItem = jQuery(this).parent(), 2508 linkHref = jQuery(this).attr('href'), 2509 subMenu = parentMenuItem.find('ul.sub-menu').first(), 2510 subParent = subMenu.parent(); 2511 2512 if (!parentMenuItem.hasClass('parent')) { 2513 SWIFT.nav.sideSlideoutHideTrigger(); 2514 2515 if (body.hasClass('page-transitions')) { 2516 SWIFT.page.fadePageOut(linkHref); 2517 } 2518 2519 return e; 2520 } 2521
2522 if (subParent.hasClass('sub-menu-open')) { 2523 if (linkHref.indexOf('http') === 0 || linkHref.indexOf('/') === 0) { 2524 return e; 2525 } else { 2526 subParent.removeClass('sub-menu-open'); 2527 subMenu.slideUp(); 2528 e.preventDefault(); 2529 } 2530 } else { 2531 subParent.addClass('sub-menu-open'); 2532 subMenu.slideDown(); 2533 e.preventDefault(); 2534 } 2535 }); 2536 }, 2537 pushNavInit: function() { 2538 var isLateralNavAnimating = false; 2539 2540 if ( jQuery( '.sf-pushnav' ).hasClass( 'full-size' ) ) { 2541 body.addClass( 'sf-pushnav-full' ); 2542 } 2543 2544 //open/close lateral navigation 2545 jQuery('.sf-pushnav-trigger').on('click', function(event) { 2546 event.preventDefault(); 2547 2548 var windowTop = $window.scrollTop(); 2549 2550 //stop if nav animation is running 2551 if( !isLateralNavAnimating ) { 2552 2553 if ( jQuery('html').hasClass('csstransitions') ) isLateralNavAnimating = true; 2554 2555 if ( body.hasClass('sf-pushnav-is-open') ) { 2556 if (body.hasClass('sticky-header-enabled') && jQuery('.sticky-wrapper').hasClass('is-sticky')) { 2557 jQuery('.sticky-header').css('position', 'fixed').css('top', stickyHeaderTop); 2558 jQuery('.sticky-top-bar').css('position', 'fixed').css('top', stickyHeaderTop); 2559 } 2560 } else { 2561 if (windowTop > 0 && body.hasClass('sticky-header-enabled') && jQuery('.sticky-wrapper').hasClass('is-sticky')) { 2562 stickyHeaderTop = jQuery('.sticky-header').css('top'); 2563 jQuery('.sticky-header').css('position', 'absolute').css('top', windowTop); 2564 if ( jQuery('.sticky-top-bar').length > 0 ) { 2565 jQuery('.sticky-top-bar').css('position', 'absolute').css('top', windowTop); 2566 } 2567 } 2568 } 2569 2570 body.toggleClass('sf-pushnav-is-open'); 2571 2572 jQuery('.sf-pushnav-wrapper').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function() { 2573 //animation is over 2574 isLateralNavAnimating = false; 2575 }); 2576 } 2577 }); 2578 2579 // PushNav Menu parent click 2580 jQuery('.sf-pushnav li.menu-item > a').on('click', function(e) { 2581 var parentMenuItem = jQuery(this).parent(), 2582 linkHref = jQuery(this).attr('href'), 2583 subMenu = parentMenuItem.find('ul.sub-menu').first(); 2584 2585 if (!parentMenuItem.hasClass('parent')) { 2586 body.removeClass('sf-pushnav-is-open'); 2587 2588 if (linkHref.indexOf('#') === 0 && linkHref.length > 1) { 2589 SWIFT.isScrolling = true; 2590 SWIFT.page.onePageNavGoTo(linkHref); 2591 setTimeout(function() { 2592 SWIFT.isScrolling = false; 2593 }, 1000); 2594 e.preventDefault(); 2595 } else if (body.hasClass('page-transitions')) { 2596 SWIFT.page.fadePageOut(linkHref); 2597 } 2598 2599 return e; 2600 } 2601 2602 if (parentMenuItem.hasClass('sub-menu-open')) { 2603 if (linkHref.indexOf('http') === 0 || linkHref.indexOf('/') === 0) { 2604 return e; 2605 } else { 2606 parentMenuItem.removeClass('sub-menu-open'); 2607 subMenu.slideUp(); 2608 e.preventDefault(); 2609 } 2610 } else { 2611 parentMenuItem.addClass('sub-menu-open'); 2612 subMenu.slideDown(); 2613 e.preventDefault(); 2614 } 2615 }); 2616 } 2617 }; 2618 2619 2620 ///////////////////////////////////////////// 2621 // WOOCOMMERCE FUNCTIONS 2622 ///////////////////////////////////////////// 2623 2624 SWIFT.woocommerce = { 2625 init: function() { 2626 2627 // Cart Wishlist 2628 SWIFT.woocommerce.cartWishlist(); 2629 2630 // SHOP LAYOUT SWITCH 2631 SWIFT.woocommerce.shopLayoutSwitch(); 2632 2633 // SHOP PAGINATION 2634 if ( body.hasClass('archive') && body.hasClass('woocommerce') ) { 2635 SWIFT.woocommerce.infiniteScroll(); 2636 } 2637 2638 // MOBILE SHOP FILTERS 2639 SWIFT.woocommerce.mobileShopFilters(); 2640 2641 // QUANTITY FUNCTIONS 2642 SWIFT.woocommerce.productQuantityAdjust(); 2643 2644 // SMALL PRODUCT CHECK 2645 SWIFT.woocommerce.smallProductCheck(); 2646 $window.smartresize( function() { 2647 SWIFT.woocommerce.smallProductCheck(); 2648 }); 2649 2650 // PREVIEW SLIDER LAYOUT 2651 if ( jQuery('.product-type-preview-slider').length > 0 ) { 2652 SWIFT.woocommerce.previewSliderLayout(); 2653 } 2654 2655 // QUICKVIEW TOOLTIP 2656 jQuery('.jckqvBtn').attr('data-toggle', 'tooltip').attr('data-original-title', sfOptionParams.data('quickview-text'));
2657 2658 // UPDATE QUANTITY DATA VALUE 2659 jQuery(document).on("change", "form.cart input.qty", function() { 2660 jQuery(this.form).find("button[data-quantity]").attr("data-quantity", this.value); 2661 }); 2662 2663 jQuery(".add_to_cart_button.product_type_simple").on('click', function() { 2664 var $button = jQuery(this); 2665 $button.data('quantity', $button.parent().find('input.qty').val()); 2666 }); 2667 2668 // ADD TO CART LOADING 2669 jQuery(document).on('click', '.add_to_cart_button, .single_add_to_cart_button', function(e) { 2670 var button = jQuery(this), 2671 buttonWrap = button.parent(), 2672 loadingText = button.attr("data-loading_text"), 2673 addedTitle = buttonWrap.data('tooltip-added-text'); 2674 2675 if ( button.hasClass('disabled') ) { 2676 return e; 2677 } 2678 2679 if ( jQuery( this ).parent().parent().parent().attr('id') == 'jckqv' ) { 2680 e.preventDefault(); 2681 jQuery(this).removeClass( 'ajax_add_to_cart' ); 2682 jQuery( '#jckqv form.cart' ).submit(); 2683 } 2684 2685 button.addClass("added-spinner"); 2686 button.find('span').text(loadingText); 2687 button.find('i').attr('class', 'sf-icon-loader-gap'); 2688 2689 if ( !buttonWrap.hasClass('cart') && !buttonWrap.hasClass('add-to-cart-shortcode') ) { 2690 setTimeout(function() { 2691 buttonWrap.tooltip('hide').attr('title', addedTitle).tooltip('fixTitle'); 2692 }, 500); 2693 setTimeout(function() { 2694 buttonWrap.tooltip('show'); 2695 }, 700); 2696 } 2697 }); 2698 2699 // ADD TO CART NOTIFICATION 2700 jQuery("body").bind("added_to_cart", function() { 2701 var currentProduct = jQuery('.added-spinner'), 2702 addToCartBtn, 2703 addedText; 2704 2705 currentProduct.addClass('product-added'); 2706 2707 if (body.hasClass('single-product') || currentProduct.parents('#jckqv').length > 0) { 2708 addToCartBtn = jQuery('.add_to_cart_button, .single_add_to_cart_button'); 2709 addedText = addToCartBtn.data('added_text'); 2710 addToCartBtn.find('span').text(addedText); 2711 } 2712 2713 if ( currentProduct.parents('li.product').length > 0 ) { 2714 addToCartBtn = currentProduct; 2715 addedText = addToCartBtn.data('added_short'); 2716 addToCartBtn.find('span').text(addedText); 2717 } 2718 2719 if ( currentProduct.parents('.add-to-cart-shortcode').length > 0 ) { 2720 addToCartBtn = currentProduct; 2721 addedText = addToCartBtn.data('added_text'); 2722 addToCartBtn.find('span').text(addedText); 2723 } 2724 2725 currentProduct.find('i').attr('class', 'sf-icon-tick'); 2726 currentProduct.removeClass('added-spinner'); 2727 2728 // Animate icon 2729 setTimeout(function() { 2730 jQuery(document).find('.shopping-bag-item:visible:last').addClass('added-notification'); 2731 jQuery(document).find('.shopping-bag-item:visible:last .cart-contents').addClass('sf-animate ' + cartNotification); 2732 }, 100); 2733 2734 // Show cart dropdown 2735 setTimeout(function() { 2736 jQuery(document).find('.shopping-bag-item:visible:last').find('ul.sub-menu').fadeIn(200); 2737 }, 800); 2738 2739 // Reset button on single product 2740 setTimeout(function() { 2741 var defaultText, defaultIcon; 2742 if (body.hasClass('single-product') || currentProduct.parents('#jckqv').length > 0) { 2743 var addToCartBtn = jQuery('.add_to_cart_button, .single_add_to_cart_button'); 2744 defaultText = addToCartBtn.data('default_text'); 2745 defaultIcon = addToCartBtn.data('default_icon'); 2746 2747 currentProduct.find('i').attr('class', defaultIcon); 2748 addToCartBtn.find('span').text(defaultText); 2749 addToCartBtn.removeClass('added product-added'); 2750 } 2751 2752 if ( currentProduct.parents('.add-to-cart-shortcode').length > 0 ) { 2753 var addToCartShortcodeBtn = currentProduct; 2754 defaultText = addToCartShortcodeBtn.data('default_text'); 2755 defaultIcon = addToCartShortcodeBtn.data('default_icon'); 2756 2757 currentProduct.find('i').attr('class', defaultIcon); 2758 addToCartShortcodeBtn.find('span').text(defaultText); 2759 addToCartShortcodeBtn.removeClass('added product-added'); 2760 } 2761 2762 }, 3000); 2763 2764 // Hide cart dropdown 2765 setTimeout(function() { 2766 jQuery(document).find('.shopping-bag-item:visible:last').removeClass('added-notification'); 2767 jQuery(document).find('.shopping-bag-item:visible:last .cart-contents').removeClass('sf-animate ' + cartNotification); 2768 if (!shopBagHovered) { 2769 jQuery(document).find('.shopping-bag-item:visible:last').find('ul.sub-menu').fadeOut(150); 2770 } 2771 }, 4000); 2772 }); 2773 2774 // WISHLIST UPDATE 2775 jQuery(document).on('click', '.add_to_wishlist', function(){ 2776 2777 jQuery(this).parent().parent().find('.yith-wcwl-wishlistaddedbrowse').show().removeClass("hide").addClass("show"); 2778 jQuery(this).hide().addClass("hide").removeClass("show"); 2779 2780 var data = {action: 'uplift_add_to_wishlist', product_id: jQuery(this).attr('data-product-id')}; 2781 var ajaxURL = jQuery(this).attr('data-ajaxurl'); 2782 2783 jQuery.post(ajaxURL, data, function(response) { 2784 var json = jQuery.parseJSON(response);
2785 jQuery('.cart-wishlist .wishlist-item .bag-contents').prepend(json.wishlist_output); 2786 jQuery('.wishlist-empty').remove(); 2787 jQuery('.bag-buttons').removeClass('no-items'); 2788 var navWishlist = jQuery('.wishlist-item'), 2789 wishlistIcon = navWishlist.find('.wishlist-link'); 2790 2791 navWishlist.addClass('added-notification'); 2792 wishlistIcon.addClass('sf-animate ' + cartNotification); 2793 setTimeout(function() { 2794 navWishlist.find('ul.sub-menu').fadeIn(200); 2795 }, 800); 2796 setTimeout(function() { 2797 navWishlist.removeClass('added-notification'); 2798 wishlistIcon.removeClass('sf-animate ' + cartNotification); 2799 if (!wishlistHovered) { 2800 navWishlist.find('ul.sub-menu').fadeOut(150); 2801 } 2802 }, 4000); 2803 }); 2804 2805 }); 2806 2807 // SHOW PRODUCTS 2808 jQuery('.show-products-link').on('click', function(e) { 2809 e.preventDefault(); 2810 var linkHref = jQuery(this).attr('href').replace('?', ''), 2811 currentURL = document.location.href.replace(/\/page\/\d+/, ''), 2812 currentQuery = document.location.search; 2813 2814 if (currentQuery.indexOf('?show') >= 0) { 2815 window.location = jQuery(this).attr('href'); 2816 } else if (currentQuery.indexOf('?') >= 0) { 2817 window.location = currentURL + '&' + linkHref; 2818 } else { 2819 window.location = currentURL + '?' + linkHref; 2820 } 2821 }); 2822 2823 2824 // SHOPPING CALCULATOR 2825 jQuery('.shipping-calculator-form input').keypress(function(e) { 2826 if(e.which == 10 || e.which == 13) { 2827 jQuery(".update-totals-button button").click(); 2828 } 2829 }); 2830 2831 // PRODUCT GRID 2832 if (jQuery('.product-grid').length > 0) { 2833 2834 if (!jQuery('.inner-page-wrap').hasClass('full-width-shop')) { 2835 var productGrid = jQuery('.product-grid'); 2836 productGrid.each(function() { 2837 if ( productGrid.parent('.upsells').length > 0 ) { 2838 return; 2839 } 2840 SWIFT.woocommerce.productGridSetup(jQuery(this)); 2841 }); 2842 } 2843 } 2844 2845 // Multi-Masonry Product 2846 if (jQuery('.products.multi-masonry-items').length > 0) { 2847 2848 jQuery('.products.multi-masonry-items').each(function() { 2849 SWIFT.woocommerce.multiMasonrySetup(jQuery(this)); 2850 }); 2851 2852 $window.smartresize( function() { 2853 SWIFT.woocommerce.windowResized(); 2854 }); 2855 2856 } 2857 2858 // EDIT PRODUCT CATEGORY COUNT DISPLAY 2859 jQuery('.product-categories li span.count, .widget_layered_nav li span.count').each(function() { 2860 var thisCategory = jQuery(this), 2861 thisText = thisCategory.text(); 2862 thisCategory.text(thisText.replace('(', '').replace(')', '')); 2863 thisCategory.addClass('show-count'); 2864 }); 2865 2866 jQuery('.upsell-heading-link').on('click', '', function(e) { 2867 2868 var upsellToggle = jQuery(this); 2869 2870 jQuery('.upsells > .products').slideToggle(); 2871 2872 if (upsellToggle.hasClass('upsell-open')) { 2873 upsellToggle.find('i').removeClass('sf-icon-minus').addClass('sf-icon-plus'); 2874 upsellToggle.removeClass('upsell-open'); 2875 } else { 2876 upsellToggle.find('i').removeClass('sf-icon-plus').addClass('sf-icon-minus'); 2877 upsellToggle.addClass('upsell-open'); 2878 } 2879 2880 e.preventDefault(); 2881 2882 }); 2883 2884 // Product FW Init 2885 if ( body.hasClass('product-fw-split') ) { 2886 setTimeout(function() { 2887 SWIFT.woocommerce.productFWSplit(); 2888 }, 400); 2889 } 2890 2891 // Currency Switcher 2892 if ( jQuery('ul.wcml_currency_switcher').length > 0 ) { 2893 jQuery('ul.wcml_currency_switcher').addClass('sub-menu'); 2894 } 2895 2896 if ( jQuery('#track-order-modal').length > 0 ) { 2897 var trackingURL = jQuery('#track-order-modal').data('tracking-url'); 2898 jQuery('#track-order-modal').find('form').attr('action', trackingURL); 2899 } 2900 2901 // Mobile Zoom 2902 jQuery('.mobile-product-zoom').on('click', function(e) { 2903 e.preventDefault(); 2904 var zoomObject = jQuery(this).parents('li.active').find('.product-slider-image'); 2905 if ( body.hasClass('mobile-zoom-enabled') ) { 2906 jQuery(this).find('i').attr('class', 'sf-icon-add'); 2907 body.removeClass('mobile-zoom-enabled'); 2908 zoomObject.panzoom('option', 'startTransform', 'scale(1.0)'); 2909 zoomObject.panzoom("destroy"); 2910 } else { 2911 jQuery(this).find('i').attr('class', 'sf-icon-remove'); 2912 zoomObject.panzoom({ 2913 minScale: 1, 2914 contain: 'invert', 2915 startTransform: 'scale(1.2)', 2916 });
2917 body.addClass('mobile-zoom-enabled'); 2918 } 2919 }); 2920 2921 }, 2922 load: function() { 2923 2924 if (jQuery('.woocommerce-shop-page').hasClass('full-width-shop') && !(IEVersion && IEVersion < 9) && !jQuery('#products').hasClass('multi-masonry-items')) { 2925 SWIFT.woocommerce.fullWidthShop(); 2926 } 2927 2928 if ( body.hasClass('product-fw-split') ) { 2929 setTimeout(function() { 2930 SWIFT.woocommerce.productFWSplit(); 2931 $window.smartresize( function() { 2932 SWIFT.woocommerce.productFWSplit(); 2933 }); 2934 }, 400); 2935 } 2936 2937 SWIFT.woocommerce.variations(); 2938 SWIFT.woocommerce.swatches(); 2939 2940 }, 2941 productFWSplit: function() { 2942 2943 if ( $window.width() <= 1024 ) { 2944 return; 2945 } 2946 2947 var windowHeight = $window.height() - SWIFT.offset, 2948 productMain = jQuery('.product-main'), 2949 slider = productMain.find('.images'), 2950 sliderHeight = slider.outerHeight(), 2951 //details = productMain.find('.summary'), 2952 //detailsHeight = details.height(), 2953 lSPager = productMain.find('.lSPager'); 2954 2955 if ( sliderHeight > windowHeight ) { 2956 productMain.css('height', sliderHeight); 2957 } else { 2958 productMain.css('height', windowHeight); 2959 } 2960 2961 lSPager.css('margin-top', -(lSPager.height() / 2)); 2962 2963 }, 2964 cartWishlist: function() { 2965 // Cart remove product 2966 jQuery(document).on('click', '.shopping-bag .remove-product', function(e) { 2967 2968 e.preventDefault(); 2969 e.stopPropagation(); 2970 2971 var prod_id = jQuery(this).attr('data-product-id'), 2972 variation_id = jQuery(this).attr('data-variation-id'), 2973 prod_quantity = jQuery(this).attr('data-product-qty'), 2974 empty_bag_txt = jQuery('.shopping-bag').attr('data-empty-bag-txt'), 2975 singular_item_txt = jQuery('.shopping-bag').attr('data-singular-item-txt'), 2976 multiple_item_txt = jQuery('.shopping-bag').attr('data-multiple-item-txt'), 2977 data = {action: 'uplift_cart_product_remove', product_id: prod_id, variation_id: variation_id}, 2978 ajaxURL = jQuery(this).attr('data-ajaxurl'); 2979 2980 jQuery('.shopping-bag .loading-overlay').fadeIn(200); 2981 2982 jQuery.post(ajaxURL, data, function(response) { 2983 2984 var cartTotal = response; 2985 var cartcounter = 0; 2986 2987 if ( body.hasClass('woocommerce-checkout') ) { 2988 jQuery('.shopping-bag').find(".bag-button")[0].click(); 2989 } 2990 2991 if ( body.hasClass('woocommerce-cart') ) { 2992 location.reload(); 2993 } 2994 2995 jQuery('.shopping-bag .loading-overlay').fadeOut(100); 2996
2997 cartcounter = parseInt(jQuery('.cart-contents .num-items').first().text()) - prod_quantity; 2998 jQuery('.cart-contents .amount').replaceWith(cartTotal); 2999 jQuery('.bag-total .amount').replaceWith(cartTotal); 3000 jQuery('.cart-contents .num-items').text(cartcounter); 3001 3002 jQuery('.cart-contents .num-items').each(function() { 3003 jQuery(this).text(cartcounter); 3004 }); 3005 3006 if ( variation_id > 0 ){ 3007 jQuery('.product-var-id-'+variation_id).remove(); 3008 }else{ 3009 jQuery('.product-id-'+prod_id).remove(); 3010 } 3011 3012 3013 if ( cartcounter <= 0 ) { 3014 jQuery('.sub-menu .shopping-bag').prepend('<div class="bag-empty">' + empty_bag_txt + '</div>'); 3015 jQuery('.sub-menu .shopping-bag .bag-buttons').remove(); 3016 jQuery('.sub-menu .shopping-bag .bag-header').remove(); 3017 jQuery('.sub-menu .shopping-bag .bag-total').remove(); 3018 jQuery('.sub-menu .shopping-bag .bag-contents').remove(); 3019 } else { 3020 if ( cartcounter == 1 ) { 3021 jQuery('.sub-menu .shopping-bag .bag-header').text('1 ' + singular_item_txt); 3022 } else { 3023 jQuery('.sub-menu .shopping-bag .bag-header').text(cartcounter + ' ' + multiple_item_txt); 3024 } 3025 } 3026 3027 }); 3028 3029 return false; 3030 3031 }); 3032 3033 // WISHLIST REMOVE PRODUCT 3034 jQuery(document).on('click', '.wishlist_table .remove', function(){ 3035 jQuery(".prod-"+jQuery(this).attr('data-product-id')).remove(); 3036 if (jQuery('.wishlist-bag').find('.bag-product').length === 0) { 3037 jQuery('.bag-buttons').addClass('no-items'); 3038 } 3039 }); 3040 }, 3041 variations: function() { 3042 jQuery('.single_variation_wrap').on("show_variation", function() { 3043 if (hasProductZoom) { 3044 jQuery('.zoomContainer').remove(); 3045 setTimeout(function() { 3046 if (SWIFT.productSlider) { 3047 jQuery('.product-slider-image').each(function() { 3048 jQuery(this).data('zoom-image', jQuery(this).parent().find('a.zoom').attr('href')); 3049 }); 3050 var firstImage = jQuery('#product-img-slider li:first').find('.product-slider-image'); 3051 SWIFT.woocommerce.productZoom(firstImage); 3052 SWIFT.productSlider.goToSlide(0); 3053 } 3054 }, 500); 3055 } else { 3056 setTimeout(function() { 3057 if (SWIFT.productSlider) { 3058 SWIFT.productSlider.goToSlide(0); 3059 } 3060 }, 500); 3061 } 3062 setTimeout(function() { 3063 3064 // Update lightbox image 3065 jQuery('.product-slider-image').each(function() { 3066 var zoomImage = jQuery(this).attr('src'); 3067 jQuery(this).parent().find('a.zoom').attr('href', zoomImage).attr('data-o_href', '').attr('data-o_href', zoomImage); 3068 jQuery('[data-rel="ilightbox[product]"]').removeClass('ilightbox-enabled').iLightBox().destroy(); 3069 SWIFT.page.lightbox(); 3070 }); 3071 }, 600); 3072 }); 3073 3074 // Support for additional variations images plugin 3075 jQuery( 'form.variations_form' ).on( 'wc_additional_variation_images_frontend_image_swap_callback wc_additional_variation_images_frontend_ajax_default_image_swap_callback wc_additional_variation_images_frontend_on_reset', function( e, response, gallery_images_class, main_images_class, o_gallery_images ) { 3076 3077 switch( e.type ) { 3078 case 'wc_additional_variation_images_frontend_image_swap_callback': 3079 jQuery('#product-img-slider .slides').html( response.gallery_images ); 3080 3081 jQuery( '#product-img-nav ul.slides a.zoom.lightbox' ).each( function() { 3082 var link = jQuery( this ).parent().find( 'img' ).attr('data-zoom-image'); 3083 jQuery( this ).attr('href', link); 3084 }); 3085 3086 break; 3087 case 'wc_additional_variation_images_frontend_ajax_default_image_swap_callback': 3088 jQuery('#product-img-slider .slides').html( o_gallery_images ); 3089 3090 break; 3091 case 'wc_additional_variation_images_frontend_on_reset': 3092 jQuery('#product-img-slider .slides').html( o_gallery_images ); 3093 break; 3094 } 3095 3096 SWIFT.productSlider.destroy(); 3097 SWIFT.sliders.productSlider(); 3098 3099 setTimeout(function() { 3100 jQuery('[data-rel="ilightbox[product]"]').removeClass('ilightbox-enabled').iLightBox().destroy(); 3101 SWIFT.page.lightbox(); 3102 }, 500); 3103 3104 }); 3105 jQuery( 'form.variations_form' ).on( 'wc_additional_variation_images_frontend_lightbox_done', function() { 3106 setTimeout(function() { 3107 jQuery('[data-rel="ilightbox[product]"]').removeClass('ilightbox-enabled').iLightBox().destroy(); 3108 SWIFT.page.lightbox(); 3109 }, 500); 3110 }); 3111 3112 // Reset on variation reset 3113 jQuery(document).on( 'reset_image', function() { 3114 3115 setTimeout(function() { 3116 if (hasProductZoom) { 3117 jQuery('.zoomContainer').remove(); 3118 if (SWIFT.productSlider) { 3119 SWIFT.productSlider.goToSlide(0); 3120 var firstImage = jQuery('#product-img-slider li:first').find('.product-slider-image'); 3121 firstImage.attr('data-zoom-image', firstImage.parent().attr('data-thumb')); 3122 firstImage.data('zoom-image', firstImage.parent().attr('data-thumb')); 3123 setTimeout(function() {
3124 SWIFT.woocommerce.productZoom(firstImage); 3125 }, 200); 3126 } 3127 } else { 3128 if (SWIFT.productSlider) { 3129 SWIFT.productSlider.goToSlide(0); 3130 } 3131 } 3132 }, 500); 3133 3134 }); 3135 }, 3136 swatches: function() { 3137 jQuery(document).on("change", "div.select", function(){ 3138 if (hasProductZoom) { 3139 jQuery('.zoomContainer').remove(); 3140 setTimeout(function() { 3141 if (SWIFT.productSlider) { 3142 jQuery('.product-slider-image').each(function() { 3143 jQuery(this).data('zoom-image', jQuery(this).parent().find('a.zoom').attr('href')); 3144 }); 3145 var firstImage = jQuery('#product-img-slider li:first').find('.product-slider-image'); 3146 SWIFT.woocommerce.productZoom(firstImage); 3147 SWIFT.productSlider.goToSlide(0); 3148 } 3149 }, 500); 3150 } else { 3151 setTimeout(function() { 3152 if (SWIFT.productSlider) { 3153 SWIFT.productSlider.goToSlide(0); 3154 } 3155 }, 500); 3156 } 3157 }); 3158 }, 3159 productZoom: function(zoomObject) { 3160 if ( isMobileAlt && hasProductZoomMobile ) { 3161 jQuery('#product-img-slider li a.mobile-product-zoom').addClass('is-mobile'); 3162 } else if ( hasProductZoom ) { 3163 jQuery('#product-img-slider li a.zoom').css('display', 'none'); 3164 jQuery('.zoomContainer').remove(); 3165 zoomObject.elevateZoom({ 3166 zoomType: productZoomType, 3167 cursor: "crosshair", 3168 zoomParent: '#product-img-slider .lSSlideWrapper', 3169 responsive: true, 3170 zoomWindowFadeIn: 400, 3171 zoomWindowFadeOut: 500, 3172 lensSize: 350 3173 }); 3174 3175 $window.smartresize( function() { 3176 jQuery('.zoomContainer').remove(); 3177 zoomObject.elevateZoom({ 3178 zoomType: productZoomType, 3179 cursor: "crosshair", 3180 zoomParent: '#product-img-slider .lSSlideWrapper', 3181 responsive: true, 3182 zoomWindowFadeIn: 400, 3183 zoomWindowFadeOut: 500, 3184 lensSize: 350 3185 }); 3186 }); 3187 } 3188 }, 3189 shopLayoutSwitch: function() { 3190 var isSwitchingLayout = false; 3191 3192 jQuery(document).on('click', 'a.layout-opt', function(e) { 3193 3194 var products = jQuery('#products'), 3195 selectedLayout = jQuery(this).data('layout'), 3196 defaultWidth = products.find('.product').first().data('width'), 3197 gridWidth = jQuery('.inner-page-wrap').hasClass('has-no-sidebar') ? 'col-sm-sf-5' : 'col-sm-3'; 3198 3199 if ( jQuery(this).parent().data('display-type') == "gallery" || jQuery(this).parent().data('display-type') == "gallery-bordered" ) { 3200 gridWidth = "col-sm-2"; 3201 } 3202 3203 if (isSwitchingLayout) { 3204 return; 3205 } 3206 3207 isSwitchingLayout = true; 3208 3209 products.animate({ 3210 'opacity': 0 3211 }, 400); 3212 setTimeout(function() { 3213 3214 products.find('.product').removeClass('product-layout-standard product-layout-list product-layout-grid product-layout-solo'); 3215 products.find('.product').addClass('product-layout-' + selectedLayout); 3216 3217 if ( jQuery('.product-grid').length > 0 ) { 3218 jQuery('.product-grid').children().css('min-height','0'); 3219 3220 if (selectedLayout === "grid") { 3221 products.find('.product').removeClass(defaultWidth).addClass(gridWidth); 3222 } 3223 3224 if (selectedLayout === "standard" || selectedLayout === "solo") { 3225 products.find('.product').removeClass(gridWidth).addClass(defaultWidth); 3226 } 3227 3228 if (selectedLayout !== "list" && selectedLayout !== "solo") { 3229 jQuery('.product-grid').equalHeights(); 3230 } 3231 } 3232 3233 products.isotope('layout'); 3234 3235 products.animate({ 3236 'opacity': 1 3237 }, 400); 3238 3239 isSwitchingLayout = false; 3240 3241 }, 500); 3242 3243 e.preventDefault(); 3244 3245 }); 3246 }, 3247 mobileShopFilters: function() { 3248 3249 jQuery(document).on('click', '.sf-mobile-shop-filters-link', function(e) { 3250 3251 e.preventDefault(); 3252 3253 var thisLink = jQuery(this); 3254 3255 if ( thisLink.hasClass('filters-open') ) { 3256 3257 jQuery('.sf-mobile-shop-filters').slideUp(); 3258 thisLink.removeClass('filters-open'); 3259 3260 } else { 3261 3262 jQuery('.sf-mobile-shop-filters').slideDown(); 3263 thisLink.addClass('filters-open'); 3264 3265 } 3266 3267 3268 }); 3269 }, 3270 fullWidthShop: function() { 3271 var shopItems = jQuery('.full-width-shop').find('.products'), 3272 itemWidth = shopItems.find('.product').first().data('width'), 3273 shopSidebar = shopItems.find('.sidebar'); 3274 3275 if (shopSidebar.length > 0) { 3276 3277 // Full Width Shop Sidebar
3278 SWIFT.woocommerce.fullWidthShopSetSidebarHeight(); 3279 $window.smartresize( function() { 3280 SWIFT.woocommerce.fullWidthShopSetSidebarHeight(); 3281 }); 3282 3283 shopItems.isotope({ 3284 itemSelector: '.product', 3285 layoutMode: 'masonry', 3286 masonry: { 3287 columnWidth: '.'+itemWidth 3288 }, 3289 isOriginLeft: !isRTL 3290 }); 3291 3292 SWIFT.woocommerce.animateItems(shopItems); 3293 3294 shopSidebar.stop().animate({ 3295 'opacity': 1 3296 }, 500); 3297 shopItems.isotope( 'stamp', shopSidebar ); 3298 shopItems.isotope('layout'); 3299 3300 setTimeout(function() { 3301 shopItems.isotope('layout'); 3302 }, 500); 3303 3304 } else { 3305 3306 shopItems.isotope({ 3307 itemSelector: '.product', 3308 layoutMode: 'fitRows', 3309 isOriginLeft: !isRTL 3310 }); 3311 3312 setTimeout(function() { 3313 shopItems.isotope('layout'); 3314 }, 500); 3315 3316 SWIFT.woocommerce.animateItems(shopItems); 3317 3318 } 3319 }, 3320 fullWidthShopSetSidebarHeight: function() { 3321 var shopItems = jQuery('.full-width-shop').find('.products'), 3322 shopSidebar = shopItems.find('div.sidebar'), 3323 defaultSidebarHeight = shopSidebar.css('height', '').outerHeight(), 3324 newSidebarHeight = 0, 3325 sidebarHeightMultiply = 2, 3326 firstProductHeight = shopItems.find('div.product').first().outerHeight(true); 3327 3328 sidebarHeightMultiply = Math.ceil(defaultSidebarHeight / firstProductHeight); 3329 newSidebarHeight = firstProductHeight * sidebarHeightMultiply; 3330 shopSidebar.css('height', newSidebarHeight); 3331 }, 3332 productGridSetup: function(productsInstance) { 3333 productsInstance.imagesLoaded(function () { 3334 productsInstance.isotope({ 3335 resizable: false, 3336 itemSelector : '.product', 3337 layoutMode: 'fitRows', 3338 isOriginLeft: !isRTL 3339 }); 3340 }); 3341 productsInstance.appear(function() { 3342 if (isMobile) { 3343 setTimeout(function() { 3344 productsInstance.isotope('layout'); 3345 SWIFT.woocommerce.animateItems(productsInstance); 3346 }, 500); 3347 } else { 3348 SWIFT.woocommerce.animateItems(productsInstance); 3349 } 3350 }); 3351 }, 3352 multiMasonrySetup: function(productsInstance) { 3353 productsInstance.imagesLoaded(function () { 3354 SWIFT.woocommerce.multiMasonrySizeFix(productsInstance, false); 3355 productsInstance.isotope({ 3356 resizable: false, 3357 itemSelector : '.product', 3358 layoutMode: 'packery', 3359 packery: { 3360 columnWidth: '.grid-sizer' 3361 }, 3362 isOriginLeft: !isRTL 3363 }); 3364 if (isMobile) { 3365 setTimeout(function() { 3366 productsInstance.isotope('layout'); 3367 }, 500); 3368 } 3369 }); 3370 productsInstance.appear(function() { 3371 SWIFT.woocommerce.animateItems(productsInstance); 3372 SWIFT.woocommerce.multiMasonrySizeFix(productsInstance, false); 3373 }); 3374 }, 3375 multiMasonrySizeFix: function(productsInstance, $init) { 3376 var baseItem = productsInstance.find('.product.size-standard').first(), 3377 standardHeight = baseItem.height(), 3378 largeHeight = 0; 3379 3380 if ( standardHeight > 0 ) { 3381 largeHeight = (standardHeight * 2) + parseInt(baseItem.css('margin-bottom'), 10); 3382 } else { 3383 var firstProduct = productsInstance.find('.product.size-large,.product.size-tall').first(); 3384 largeHeight = firstProduct.height(); 3385 } 3386 3387 if (largeHeight > 0) { 3388 productsInstance.find('.product.size-large .multi-masonry-img-wrap').css('height', largeHeight); 3389 productsInstance.find('.product.size-tall .multi-masonry-img-wrap').css('height', largeHeight); 3390 } 3391 if ($init) { 3392 productsInstance.isotope('layout'); 3393 } 3394 }, 3395 windowResized: function() { 3396 jQuery('.products.multi-masonry-items').each(function() { 3397 SWIFT.woocommerce.multiMasonrySizeFix(jQuery(this), true); 3398 }); 3399 }, 3400 animateItems: function(shopItems) { 3401 shopItems.find('.product').each(function(i) { 3402 jQuery(this).delay(i*200).animate({ 3403 'opacity' : 1 3404 }, 800, 'easeOutExpo', function() { 3405 jQuery(this).addClass('item-animated'); 3406 }); 3407 }); 3408 }, 3409 productQuantityAdjust: function() { 3410 // Increase 3411 jQuery(document).on('click', '.qty-plus', function(e) { 3412 e.preventDefault(); 3413 var quantityInput = jQuery(this).parents('.quantity').find('input.qty'), 3414 step = parseInt(quantityInput.attr('step'), 10), 3415 newValue = parseInt(quantityInput.val(), 10) + step, 3416 maxValue = parseInt(quantityInput.attr('max'), 10); 3417 3418 if (!maxValue) { 3419 maxValue = 9999999999; 3420 } 3421 3422 if ( newValue <= maxValue ) { 3423 quantityInput.val(newValue); 3424 quantityInput.change(); 3425 } 3426 }); 3427 3428 // Decrease 3429 jQuery(document).on('click', '.qty-minus', function(e) { 3430 e.preventDefault(); 3431 var quantityInput = jQuery(this).parents('.quantity').find('input.qty'), 3432 step = parseInt(quantityInput.attr('step'), 10), 3433 newValue = parseInt(quantityInput.val(), 10) - step, 3434 minValue = parseInt(quantityInput.attr('min'), 10); 3435 3436 if (!minValue) { 3437 minValue = 0; 3438 } 3439 3440 if ( newValue >= minValue ) { 3441 quantityInput.val(newValue); 3442 quantityInput.change(); 3443 } 3444 }); 3445 }, 3446 smallProductCheck: function() { 3447 jQuery('.product').each(function() { 3448 var thisProduct = jQuery(this); 3449 3450 if (thisProduct.width() < 280) { 3451 thisProduct.addClass('mini-view'); 3452 } else { 3453 thisProduct.removeClass('mini-view'); 3454 } 3455 }); 3456 }, 3457 previewSliderLayout: function() { 3458 var previewSliderItems = jQuery('.product-type-preview-slider > .products, .products.product-type-preview-slider').children('.product'); 3459 3460 previewSliderItems.each(function(){ 3461 var container = jQuery(this), 3462 sliderDots = SWIFT.woocommerce.pslCreateDots(container); 3463 3464 if ( !container.find('.variable-image-wrapper').hasClass('is-variable') ) { 3465 return; 3466 } 3467
3468 SWIFT.woocommerce.pslUpdatePrice(container, 0); 3469 3470 // update slider when user clicks one of the dots 3471 if (sliderDots) { 3472 sliderDots.on('click', function() { 3473 var selectedDot = jQuery(this); 3474 if ( !selectedDot.hasClass('selected') ) { 3475 var selectedPosition = selectedDot.index(), 3476 activePosition = container.find('.variable-image-wrapper .selected').index(); 3477 if ( activePosition < selectedPosition ) { 3478 SWIFT.woocommerce.pslNextSlide(container, sliderDots, selectedPosition); 3479 } else { 3480 SWIFT.woocommerce.pslPrevSlide(container, sliderDots, selectedPosition); 3481 } 3482 SWIFT.woocommerce.pslUpdatePrice(container, selectedPosition); 3483 } 3484 }); 3485 } 3486 3487 // update slider on swipeleft 3488 container.find('.variable-image-wrapper').swipe({ 3489 swipeLeft:function() { 3490 var wrapper = jQuery(this), 3491 selectedPosition = 0; 3492 if ( !wrapper.find('.selected').is(':last-child') ) { 3493 selectedPosition = container.find('.variable-image-wrapper .selected').index() + 1; 3494 SWIFT.woocommerce.pslNextSlide(container, sliderDots); 3495 SWIFT.woocommerce.pslUpdatePrice(container, selectedPosition); 3496 } 3497 }, 3498 swipeRight:function() { 3499 var wrapper = jQuery(this), 3500 selectedPosition = 0; 3501 if ( !wrapper.find('.selected').is(':first-child') ) { 3502 selectedPosition = container.find('.variable-image-wrapper .selected').index() - 1; 3503 SWIFT.woocommerce.pslPrevSlide(container, sliderDots); 3504 SWIFT.woocommerce.pslUpdatePrice(container, selectedPosition); 3505 } 3506 }, 3507 }); 3508 3509 // preview image hover effect - desktop only 3510 container.on('mouseover', '.move-right, .move-left', function() { 3511 SWIFT.woocommerce.pslHoverItem(jQuery(this), true); 3512 }); 3513 container.on('mouseleave', '.move-right, .move-left', function() { 3514 SWIFT.woocommerce.pslHoverItem(jQuery(this), false); 3515 }); 3516 3517 // update slider when user clicks on the preview images 3518 container.on('click', '.move-right, .move-left', function(e) { 3519 e.preventDefault(); 3520 var selectedPosition = 0; 3521 if ( jQuery(this).hasClass('move-right') ) { 3522 selectedPosition = container.find('.variable-image-wrapper .selected').index() + 1; 3523 SWIFT.woocommerce.pslNextSlide(container, sliderDots); 3524 } else { 3525 selectedPosition = container.find('.variable-image-wrapper .selected').index() - 1; 3526 SWIFT.woocommerce.pslPrevSlide(container, sliderDots); 3527 } 3528 SWIFT.woocommerce.pslUpdatePrice(container, selectedPosition); 3529 }); 3530 }); 3531 }, 3532 pslCreateDots: function(container) { 3533 3534 if ( container.find('.variable-image-wrapper .img-wrap').length <= 1) { 3535 return; 3536 } 3537 3538 var dotsWrapper = jQuery('<ol class="preview-slider-dots"></ol>').insertAfter(container.find('.variable-image-wrapper')); 3539 container.find('.variable-image-wrapper .img-wrap').each(function(index){ 3540 var dotWrapper = (index === 0) ? jQuery('<li class="selected"></li>') : jQuery('<li></li>'), 3541 dot = jQuery('<a href="#0"></a>').appendTo(dotWrapper); 3542 dotWrapper.appendTo(dotsWrapper); 3543 dot.text(index+1); 3544 }); 3545 return dotsWrapper.children('li'); 3546 }, 3547 pslHoverItem: function(item, bool) { 3548 if ( item.hasClass('move-right') ) { 3549 item.toggleClass('hover', bool).siblings('.selected, .move-left').toggleClass('focus-on-right', bool); 3550 } else { 3551 item.toggleClass('hover', bool).siblings('.selected, .move-right').toggleClass('focus-on-left', bool); 3552 } 3553 }, 3554 pslNextSlide: function(container, dots, n) { 3555 var visibleSlide = container.find('.variable-image-wrapper .selected'), 3556 navigationDot = container.find('.preview-slider-dots .selected'); 3557 if(typeof n === 'undefined') n = visibleSlide.index() + 1; 3558 visibleSlide.removeClass('selected'); 3559 container.find('.variable-image-wrapper .img-wrap').eq(n).addClass('selected').removeClass('move-right hover').prevAll().removeClass('move-right move-left focus-on-right').addClass('hide-left').end().prev().removeClass('hide-left').addClass('move-left').end().next().addClass('move-right'); 3560 navigationDot.removeClass('selected'); 3561 dots.eq(n).addClass('selected'); 3562 }, 3563 pslPrevSlide: function(container, dots, n) { 3564 var visibleSlide = container.find('.variable-image-wrapper .selected'), 3565 navigationDot = container.find('.preview-slider-dots .selected'); 3566 if(typeof n === 'undefined') n = visibleSlide.index() - 1; 3567 visibleSlide.removeClass('selected focus-on-left');
3568 container.find('.variable-image-wrapper .img-wrap').eq(n).addClass('selected').removeClass('move-left hide-left hover').nextAll().removeClass('hide-left move-right move-left focus-on-left').end().next().addClass('move-right').end().prev().removeClass('hide-left').addClass('move-left'); 3569 navigationDot.removeClass('selected'); 3570 dots.eq(n).addClass('selected'); 3571 }, 3572 pslUpdatePrice: function(container, n) { 3573 var productDetails = container.find('.product-details'), 3574 priceTag = productDetails.find('span.price'), 3575 selectedItem = container.find('.variable-image-wrapper .img-wrap').eq(n), 3576 variationPriceHTML = selectedItem.find('.variation-price').html(), 3577 isOnSale = selectedItem.data('sale'); 3578 3579 if ( !variationPriceHTML || priceTag.html() === selectedItem.find('.variation-price span.price').html() ) { 3580 return; 3581 } 3582 3583 if ( isOnSale ) { 3584 // if item is on sale 3585 productDetails.addClass('on-sale'); 3586 priceTag.replaceWith(variationPriceHTML); 3587 setTimeout(function(){ productDetails.addClass('is-visible'); }, 100); 3588 } else { 3589 // if item is not on sale - remove cross on old price and sale price 3590 productDetails.removeClass('on-sale is-visible'); 3591 priceTag.fadeOut(function() { 3592 priceTag.replaceWith(variationPriceHTML); 3593 }).fadeIn(); 3594 } 3595 3596 }, 3597 infiniteScroll: function() { 3598 if (!(IEVersion && IEVersion < 9)) { 3599 var infScrollData = jQuery('#inf-scroll-params'), 3600 products = jQuery('.products'), 3601 isLoadMore = products.parent().find('.pagination-wrap').hasClass('load-more') ? true : false; 3602 3603 if ( !products.parent().find('.pagination-wrap').hasClass('infinite-scroll-enabled') ) { 3604 return; 3605 } 3606 3607 var infiniteScroll = { 3608 loading: { 3609 img: infScrollData.data('loadingimage'), 3610 msgText: isLoadMore ? infScrollData.data('msgtext') : '', 3611 finishedMsg: isLoadMore ? infScrollData.data('finishedmsg') : '', 3612 selector: '.woocommerce-shop-page .page-content', 3613 loaderHTML: jQuery('body > .sf-svg-loader').html() 3614 }, 3615 "nextSelector":".pagenavi li:last-child a", 3616 "navSelector":".pagination-wrap", 3617 "itemSelector":".product", 3618 "contentSelector":"#products", 3619 errorCallback: function () { 3620 setTimeout(function() { 3621 jQuery( '#infscr-loading' ).animate({ 3622 'opacity' : 0 3623 }, 500); 3624 }, 1000); 3625 }, 3626 }; 3627 jQuery( infiniteScroll.contentSelector ).infinitescroll( 3628 infiniteScroll, function(elements) { 3629 products.imagesLoaded(function () { 3630 products.isotope( 'appended', elements ); 3631 jQuery.each(elements, function(i, element) { 3632 jQuery(element).addClass('item-animated'); 3633 }); 3634 }); 3635 if (isLoadMore) { 3636 setTimeout(function() { 3637 jQuery('.load-more-btn').css('display', 'block'); 3638 }, 200); 3639 } 3640 } 3641 ); 3642 if (isLoadMore) { 3643 products.parent().addClass('products-load-more-pagination'); 3644 $window.unbind('.infscr'); 3645 jQuery('.load-more-btn').on('click', function(e) { 3646 e.preventDefault(); 3647 jQuery( infiniteScroll.contentSelector ).infinitescroll('retrieve'); 3648 jQuery('.load-more-btn').css('display', 'none'); 3649 $window.trigger('resize'); 3650 }); 3651 } 3652 } else { 3653 jQuery('.pagination-wrap').removeClass('hidden'); 3654 } 3655 } 3656 }; 3657 3658 ///////////////////////////////////////////// 3659 // SLIDER FUNCTIONS 3660 ///////////////////////////////////////////// 3661 3662 SWIFT.sliders = { 3663 init: function() { 3664 3665 if ( jQuery('#product-img-slider').length > 0 ) { 3666 SWIFT.sliders.productSlider(); 3667 } 3668 3669 if ( jQuery('.item-slider').length > 0 ) { 3670 SWIFT.sliders.itemSlider(); 3671 } 3672 3673 if ( jQuery('.content-slider').length > 0 ) { 3674 SWIFT.sliders.contentSlider(); 3675 } 3676 3677 }, 3678 itemSlider: function() { 3679 jQuery('.item-slider > ul').lightSlider({ 3680 item: 1, 3681 pager: true, 3682 controls: true, 3683 slideMargin: 0, 3684 adaptiveHeight: true, 3685 loop: true, 3686 rtl: isRTL, 3687 auto: sliderAuto, 3688 pause: sliderSlideSpeed, 3689 speed: sliderAnimSpeed 3690 }); 3691 }, 3692 contentSlider: function() { 3693 var timeout; 3694 jQuery('.content-slider > ul').each(function() { 3695 var slider = jQuery(this), 3696 autoplay = ((slider.parent().attr('data-autoplay') === "yes") ? true : false); 3697 3698 var contentSlider = slider.lightSlider({ 3699 mode: "fade", 3700 item: 1, 3701 pager: true, 3702 controls: true, 3703 slideMargin: 0, 3704 adaptiveHeight: true, 3705 loop: true, 3706 rtl: isRTL, 3707 auto: autoplay, 3708 pause: sliderSlideSpeed, 3709 speed: sliderAnimSpeed, 3710 wrapperClass: "container", 3711 onSliderLoad: function() { 3712 contentSlider.removeClass('cS-hidden'); 3713 } 3714 }); 3715 slider.parent().on('mouseenter',function() { 3716 if (autoplay) { 3717 contentSlider.pause(); 3718 clearTimeout(timeout); 3719 } 3720 }); 3721 slider.parent().on('mouseleave',function(){ 3722 if (autoplay) { 3723 timeout = setTimeout(function () { 3724 contentSlider.play(); 3725 }, sliderSlideSpeed); 3726 } 3727 }); 3728 }); 3729 }, 3730 productSlider: function() { 3731 3732 var galleryMode = jQuery('#product-img-slider > ul > li').length > 1 ? true : false, 3733 galleryVertical = false, 3734 sliderVertHeight = parseInt(productSliderVertHeight, 10), 3735 thumbItems = 3, 3736 thumbItemsResponsive = 3, 3737 touchEnabled = true; 3738 3739 if ( body.hasClass('product-fw-split') ) { 3740 productSliderThumbsPos = "left"; 3741 sliderVertHeight = 1000; 3742 } 3743 3744 if ( isMobileAlt || $window.width() <= 768 ) { 3745 productSliderThumbsPos = "bottom"; 3746 } 3747 3748 if ( productSliderThumbsPos === "left" ) { 3749 galleryVertical = true; 3750 jQuery('#product-img-slider').addClass('thumbs-left'); 3751 thumbItems = Math.floor(sliderVertHeight / 100); 3752 thumbItemsResponsive = 3; 3753 } 3754 3755 if ( hasProductZoomMobile && isMobileAlt ) { 3756 touchEnabled = false; 3757 } 3758 3759 jQuery('#product-img-slider').addClass('hidden'); 3760 SWIFT.productSlider = jQuery('#product-img-slider > ul').lightSlider({ 3761 item: 1, 3762 gallery: galleryMode, 3763 autoWidth: false, 3764 slideMargin: 0, 3765 speed: 400, //ms'
3766 auto: false, 3767 loop: false, 3768 vThumbWidth: 70, 3769 vertical: galleryVertical, 3770 verticalHeight: sliderVertHeight, 3771 pause: 2000, 3772 keyPress: true, 3773 controls: true, 3774 rtl: isRTL, 3775 adaptiveHeight: true, 3776 thumbItem: thumbItems, 3777 thumbMargin: 30, 3778 freeMove: false, 3779 currentPagerPosition: 'middle', 3780 swipeThreshold: 40, 3781 enableTouch: touchEnabled, 3782 responsive : [ 3783 { 3784 breakpoint: 768, 3785 settings: { 3786 verticalHeight: (sliderVertHeight / 2), 3787 thumbItem: thumbItemsResponsive, 3788 } 3789 } 3790 ], 3791 onSliderLoad: function (el) { 3792 el.addClass('slider-loaded'); 3793 jQuery('#product-img-slider').removeClass('hidden'); 3794 if (hasProductZoom) { 3795 var currentImage = jQuery('#product-img-slider').find('.lslide.active .product-slider-image'); 3796 SWIFT.woocommerce.productZoom(currentImage); 3797 } 3798 el.find('.product-slider-image').each(function(){ 3799 var imgClass = (this.width/this.height >= 1) ? 'wide' : 'tall'; 3800 jQuery(this).addClass(imgClass); 3801 }); 3802 $window.trigger('resize'); 3803 }, 3804 onBeforeSlide: function () { 3805 if (hasProductZoom) { 3806 jQuery('.zoomContainer').remove(); 3807 } 3808 }, 3809 onAfterSlide: function () { 3810 if ( isMobileAlt && hasProductZoomMobile ) { 3811 jQuery('.product-slider-image').each(function() { 3812 jQuery(this).panzoom('reset'); 3813 }); 3814 } 3815 if (hasProductZoom) { 3816 var currentImage = jQuery('#product-img-slider').find('.lslide.active .product-slider-image'); 3817 SWIFT.woocommerce.productZoom(currentImage); 3818 } 3819 } 3820 }); 3821 }, 3822 thumb: function() { 3823 if ( jQuery('.thumb-slider').length > 0 ) { 3824 jQuery('.thumb-slider > ul').lightSlider({ 3825 item: 1, 3826 pager: true, 3827 controls: true, 3828 slideMargin: 0, 3829 loop: true, 3830 adaptiveHeight: true, 3831 rtl: isRTL, 3832 auto: sliderAuto, 3833 pause: sliderSlideSpeed, 3834 speed: sliderAnimSpeed 3835 }); 3836 } 3837 } 3838 }; 3839 3840 ///////////////////////////////////////////// 3841 // PORTFOLIO 3842 ///////////////////////////////////////////// 3843 3844 var portfolioContainer = jQuery('.portfolio-wrap').find('.filterable-items'); 3845 3846 SWIFT.portfolio = { 3847 init: function() { 3848 portfolioContainer.each(function() { 3849 var portfolioInstance = jQuery(this); 3850 if (portfolioInstance.hasClass('masonry-items') && !(IEVersion && IEVersion < 9)) { 3851 SWIFT.portfolio.masonrySetup(portfolioInstance); 3852 } else if (portfolioInstance.hasClass('multi-masonry-items') && !(IEVersion && IEVersion < 9)) { 3853 SWIFT.portfolio.multiMasonrySetup(portfolioInstance); 3854 } else { 3855 SWIFT.portfolio.standardSetup(portfolioInstance); 3856 } 3857 }); 3858 3859 // PORTFOLIO WINDOW RESIZE 3860 $window.smartresize( function() { 3861 SWIFT.portfolio.windowResized(); 3862 }); 3863 3864 // Enable filter options on when there are items from that skill 3865 SWIFT.portfolio.setupFiltering(); 3866 3867 // filter items when filter link is clicked 3868 jQuery(document).on('click', '.portfolio-wrap .filtering li a', function(e) { 3869 e.preventDefault(); 3870 jQuery(this).parent().parent().find('li').removeClass('selected'); 3871 jQuery(this).parent().addClass('selected'); 3872 var selector = jQuery(this).data('filter'); 3873 jQuery('.portfolio-item').find('a[data-rel^="ilightbox"]').attr('data-rel', 'ilightbox[portfolio]'); 3874 jQuery('.portfolio-item' + selector).find('a[data-rel^="ilightbox"]').attr('data-rel', 'ilightbox[portfolio-' + selector.replace(".", "") + ']'); 3875 jQuery('.portfolio-item').find('a[data-rel^="ilightbox"]').removeClass('ilightbox-enabled').iLightBox().destroy(); 3876 SWIFT.page.lightbox(); 3877 var portfolioItems = jQuery(this).parents('.portfolio-wrap').find('.filterable-items'); 3878 portfolioItems.isotope({ filter: selector }); 3879 }); 3880 3881 jQuery(document).on('click', '.filter-wrap > a', function(e) { 3882 e.preventDefault(); 3883 jQuery(this).parent().find('.filter-slide-wrap').slideToggle(); 3884 }); 3885 }, 3886 setupFiltering: function() { 3887 jQuery('.portfolio-wrap .filtering li').each( function() { 3888 var filter = jQuery(this), 3889 filterName = jQuery(this).find('a').attr('class'), 3890 portfolioItems = jQuery(this).parents('.portfolio-wrap').find('.filterable-items'), 3891 itemCount = 0; 3892 3893 if ( filter.hasClass('all') ) { 3894 itemCount = portfolioItems.find('.portfolio-item').length; 3895 if (portfolioItems.find('.grid-sizer').length > 0) { 3896 itemCount -= 1;
3897 } 3898 } 3899 3900 portfolioItems.find('.portfolio-item').each( function() { 3901 if ( jQuery(this).hasClass(filterName)) { 3902 filter.addClass('has-items'); 3903 itemCount++; 3904 } 3905 }); 3906 if ( filter.find('sup.count').length > 0 ) { 3907 filter.find('sup.count').text(itemCount); 3908 } else { 3909 filter.find('a').append('<sup class="count">'+itemCount+'</sup>'); 3910 } 3911 }).parents('.filtering').animate({ 3912 opacity: 1 3913 }, 400); 3914 }, 3915 standardSetup: function(portfolioInstance) { 3916 portfolioInstance.imagesLoaded(function () { 3917 SWIFT.sliders.thumb(); 3918 SWIFT.portfolio.setItemHeight(); 3919 portfolioInstance.animate({opacity: 1}, 800); 3920 portfolioInstance.isotope({ 3921 resizable: true, 3922 layoutMode: 'fitRows', 3923 isOriginLeft: !isRTL 3924 }); 3925 setTimeout(function() { 3926 SWIFT.portfolio.setItemHeight(); 3927 $window.trigger('resize'); 3928 portfolioInstance.isotope('layout'); 3929 }, 1000); 3930 }); 3931 portfolioInstance.appear(function() { 3932 SWIFT.portfolio.animateItems(portfolioInstance); 3933 }); 3934 }, 3935 masonrySetup: function(portfolioInstance) { 3936 portfolioInstance.imagesLoaded(function () { 3937 SWIFT.sliders.thumb(); 3938 portfolioInstance.isotope({ 3939 resizable: false, 3940 itemSelector : '.portfolio-item', 3941 layoutMode: 'masonry', 3942 isOriginLeft: !isRTL 3943 }); 3944 setTimeout(function() { 3945 portfolioInstance.isotope('layout'); 3946 }, 500); 3947 }); 3948 portfolioInstance.appear(function() { 3949 SWIFT.portfolio.animateItems(portfolioInstance); 3950 }); 3951 }, 3952 multiMasonrySetup: function(portfolioInstance) { 3953 portfolioInstance.imagesLoaded(function () { 3954 SWIFT.sliders.thumb(); 3955 SWIFT.portfolio.multiMasonrySizeFix(false); 3956 portfolioInstance.isotope({ 3957 resizable: false, 3958 itemSelector : '.portfolio-item', 3959 layoutMode: 'packery', 3960 packery: { 3961 columnWidth: '.grid-sizer' 3962 }, 3963 isOriginLeft: !isRTL 3964 }); 3965 setTimeout(function() { 3966 portfolioInstance.isotope('layout'); 3967 }, 500); 3968 }); 3969 portfolioInstance.appear(function() { 3970 setTimeout( function() { 3971 SWIFT.portfolio.animateItems(portfolioInstance); 3972 SWIFT.portfolio.multiMasonrySizeFix(false); 3973 }, 300); 3974 }); 3975 }, 3976 animateItems: function(portfolioInstance) { 3977 portfolioInstance.find('.portfolio-item').each(function(i) { 3978 jQuery(this).delay(i*200).animate({ 3979 'opacity' : 1 3980 }, 800, 'easeOutExpo', function() { 3981 jQuery(this).addClass('item-animated'); 3982 }); 3983 }); 3984 }, 3985 setItemHeight: function() { 3986 if (!portfolioContainer.hasClass('col-1') && !portfolioContainer.hasClass('masonry-items') && !portfolioContainer.hasClass('multi-masonry-items')) { 3987 portfolioContainer.children().css('min-height','0'); 3988 portfolioContainer.equalHeights(); 3989 } 3990 }, 3991 multiMasonrySizeFix: function($init) { 3992 3993 // Fix for 1/2 pixel display causing layout issues 3994 portfolioContainer.find('.portfolio-item.size-standard .multi-masonry-img-wrap').each(function() { 3995 jQuery(this).css('height', '').css('height', Math.floor( jQuery(this).height() ) ); 3996 }); 3997 3998 var baseItem = portfolioContainer.find('.portfolio-item.size-standard').first(), 3999 standardHeight = baseItem.height(), 4000 largeHeight = (standardHeight * 2) + parseInt(baseItem.css('margin-bottom'), 10); 4001 4002 if ( standardHeight > 0 ) { 4003 largeHeight = (standardHeight * 2) + parseInt(baseItem.css('margin-bottom'), 10); 4004 } else { 4005 var firstItem = portfolioContainer.find('.portfolio-item.size-tall,.portfolio-item.size-wide-tall').first(); 4006 largeHeight = firstItem.height(); 4007 standardHeight = (largeHeight / 2) - parseInt(baseItem.css('margin-bottom'), 10); 4008 } 4009 4010 // Set non-standard sized items 4011 if (largeHeight > 0) { 4012 portfolioContainer.find('.portfolio-item.size-wide .multi-masonry-img-wrap').css('height', standardHeight); 4013 portfolioContainer.find('.portfolio-item.size-wide-tall .multi-masonry-img-wrap').css('height', largeHeight); 4014 portfolioContainer.find('.portfolio-item.size-tall .multi-masonry-img-wrap').css('height', largeHeight); 4015
4016 // Wide tall sliders 4017 var heightDiff = (portfolioContainer.find('.portfolio-item.size-wide-tall ul.slides > li').first().height() - largeHeight) / 2; 4018 portfolioContainer.find('.portfolio-item.size-wide-tall ul.slides').css('max-height', largeHeight); 4019 portfolioContainer.find('.portfolio-item.size-wide-tall ul.slides > li').css('margin-top', -heightDiff); 4020 4021 // Wide sliders 4022 var wideHeightDiff = (portfolioContainer.find('.portfolio-item.size-wide ul.slides > li').first().height() - standardHeight) / 2; 4023 portfolioContainer.find('.portfolio-item.size-wide ul.slides').css('max-height', standardHeight); 4024 portfolioContainer.find('.portfolio-item.size-wide ul.slides > li').css('margin-top', -wideHeightDiff); 4025 4026 } 4027 4028 // if isotope is initiated, relayout items 4029 if ($init) { 4030 portfolioContainer.isotope('layout'); 4031 } 4032 }, 4033 windowResized: function() { 4034 if (!portfolioContainer.hasClass('col-1') && !portfolioContainer.hasClass('masonry-items') && !portfolioContainer.hasClass('multi-masonry-items')) { 4035 SWIFT.portfolio.setItemHeight(); 4036 } 4037 4038 if (portfolioContainer.hasClass('multi-masonry-items')) { 4039 SWIFT.portfolio.multiMasonrySizeFix(true); 4040 } 4041 }, 4042 infiniteScroll: function() { 4043 if (!(IEVersion && IEVersion < 9)) { 4044 var infScrollData = jQuery('#inf-scroll-params'); 4045 var isLoadMore = portfolioContainer.parent().find('.pagination-wrap').hasClass('load-more') ? true : false; 4046 4047 if ( !portfolioContainer.parent().find('.pagination-wrap').hasClass('infinite-scroll-enabled') ) { 4048 return; 4049 } 4050 4051 var infiniteScroll = { 4052 loading: { 4053 img: infScrollData.data('loadingimage'), 4054 msgText: isLoadMore ? infScrollData.data('msgtext') : '', 4055 finishedMsg: isLoadMore ? infScrollData.data('finishedmsg') : '', 4056 selector: '.portfolio-wrap .spb-asset-content', 4057 loaderHTML: jQuery('body > .sf-svg-loader').html() 4058 }, 4059 "nextSelector":".pagenavi li.next a", 4060 "navSelector":".pagenavi", 4061 "itemSelector":".portfolio-item", 4062 "contentSelector":".portfolio-items", 4063 errorCallback: function () { 4064 setTimeout(function() { 4065 jQuery( '#infscr-loading' ).animate({ 4066 'opacity' : 0 4067 }, 500); 4068 }, 1000); 4069 }, 4070 }; 4071 jQuery( infiniteScroll.contentSelector ).infinitescroll( 4072 infiniteScroll, function(elements) { 4073 SWIFT.sliders.thumb(); 4074 portfolioContainer.imagesLoaded(function () { 4075 portfolioContainer.isotope( 'appended', elements ); 4076 SWIFT.woocommerce.multiMasonrySizeFix(portfolioContainer, false); 4077 jQuery.each(elements, function(i, element) { 4078 jQuery(element).addClass('item-animated'); 4079 }); 4080 }); 4081 jQuery('[data-rel="ilightbox[portfolio]"]').removeClass('ilightbox-enabled').iLightBox().destroy(); 4082 SWIFT.page.lightbox(); 4083 SWIFT.portfolio.setupFiltering(); 4084 if (portfolioContainer.parent().find('.pagination-wrap').hasClass('load-more')) { 4085 setTimeout(function() { 4086 jQuery('.load-more-btn').css('display', 'block'); 4087 }, 200); 4088 } 4089 } 4090 ); 4091 if (isLoadMore) { 4092 portfolioContainer.parent().addClass('portfolio-load-more-pagination'); 4093 $window.unbind('.infscr'); 4094 jQuery('.load-more-btn').on('click', function(e) { 4095 e.preventDefault(); 4096 jQuery( infiniteScroll.contentSelector ).infinitescroll('retrieve'); 4097 jQuery('.load-more-btn').css('display', 'none'); 4098 $window.trigger('resize'); 4099 }); 4100 } 4101 } else { 4102 jQuery('.pagination-wrap').removeClass('hidden'); 4103 } 4104 } 4105 }; 4106 4107 4108 ///////////////////////////////////////////// 4109 // BLOG 4110 ///////////////////////////////////////////// 4111 4112 var blogItems = jQuery('.blog-wrap').find('.blog-items'); 4113 4114 SWIFT.blog = { 4115 init: function() { 4116 4117 // BLOG ITEM SETUP 4118 blogItems.each(function() { 4119 var blogInstance = jQuery(this); 4120 if (blogInstance.hasClass('blog-grid-items')) { 4121 SWIFT.blog.blogGrid(blogInstance.find('.grid-items')); 4122 } else if (blogInstance.hasClass('timeline-items')) { 4123 SWIFT.blog.blogTimeline(blogInstance); 4124 } else { 4125 SWIFT.blog.blogLayout(blogInstance); 4126 } 4127 }); 4128 4129 // Blog Filtering 4130 SWIFT.blog.blogFiltersInit(); 4131 4132 // BLOG AUX SLIDEOUT 4133 jQuery('.blog-slideout-trigger').on('click', function(e) { 4134 e.preventDefault(); 4135 4136 // VARIABLES 4137 var blogWrap = jQuery(this).parent().parent().parent().parent(); 4138 var filterPanel = blogWrap.find('.blog-filter-wrap .filter-slide-wrap'); 4139 var auxType = jQuery(this).attr('data-aux'); 4140 4141 // ADD COLUMN SIZE AND REMOVE BRACKETS FROM COUNT 4142 blogWrap.find('.aux-list li').addClass('col-sm-sf-5'); 4143 blogWrap.find('.aux-list li a span').each(function() { 4144 jQuery(this).html(jQuery(this).html().replace("(","").replace(")","")); 4145 }); 4146 4147 // IF SELECTING AN OPTION THAT IS OPEN, CLOSE THE PANEL 4148 if (jQuery(this).parent().hasClass('selected') && !filterPanel.is(':animated')) { 4149 blogWrap.find('.blog-aux-options li').removeClass('selected'); 4150 filterPanel.slideUp(400); 4151 return; 4152 } 4153 4154 // AUX BUTTON SELECTED STATE 4155 blogWrap.find('.blog-aux-options li').removeClass('selected'); 4156 jQuery(this).parent().addClass('selected'); 4157 4158 // IF SLIDEOUT IS OPEN 4159 if (filterPanel.is(':visible')) { 4160 4161 filterPanel.slideUp(400); 4162 setTimeout(function() { 4163 blogWrap.find('.aux-list').css('display', 'none');
4164 blogWrap.find('.aux-'+auxType).css('display', 'block'); 4165 filterPanel.slideDown(); 4166 }, 600); 4167 4168 // IF SLIDEOUT IS CLOSED 4169 } else { 4170 4171 blogWrap.find('.aux-list').css('display', 'none'); 4172 blogWrap.find('.aux-'+auxType).css('display', 'block'); 4173 filterPanel.slideDown(); 4174 4175 } 4176 }); 4177 4178 }, 4179 blogFiltersInit: function() { 4180 4181 SWIFT.blog.blogShowFilters(); 4182 jQuery('.filtering').animate({ 4183 opacity: 1 4184 }, 400); 4185 4186 // filter items when filter link is clicked 4187 jQuery('.blog-wrap .filtering li').on('click', 'a', function(e) { 4188 e.preventDefault(); 4189 jQuery(this).parent().parent().find('li').removeClass('selected'); 4190 jQuery(this).parent().addClass('selected'); 4191 var selector = jQuery(this).data('filter'); 4192 var blogItems = jQuery(this).parents('.blog-wrap').find('.blog-items'); 4193 blogItems.isotope({ filter: selector }); 4194 }); 4195 4196 jQuery('.filter-wrap > a').on('click', function(e) { 4197 e.preventDefault(); 4198 jQuery(this).parent().find('.filter-slide-wrap').slideToggle(); 4199 }); 4200 }, 4201 blogShowFilters: function() { 4202 // Enable filter options on when there are items from that skill 4203 jQuery('.blog-wrap .filtering li').each( function() { 4204 var filter = jQuery(this), 4205 filterName = jQuery(this).find('a').attr('class'), 4206 blogItems = jQuery(this).parents('.blog-wrap').find('.blog-items'), 4207 itemCount = 0; 4208 4209 if ( filter.hasClass('all') ) { 4210 itemCount = blogItems.find('.blog-item').length; 4211 } 4212 4213 blogItems.find('.blog-item').each( function() { 4214 if ( jQuery(this).hasClass(filterName) ) { 4215 filter.addClass('has-items'); 4216 itemCount++; 4217 } 4218 }); 4219 if ( filter.find('sup.count').length > 0 ) { 4220 filter.find('sup.count').text(itemCount); 4221 } else { 4222 filter.find('a').append('<sup class="count">'+itemCount+'</sup>'); 4223 } 4224 }); 4225 }, 4226 blogLayout: function(blogInstance) { 4227 4228 var blogType = blogInstance.data('blog-type'), 4229 layoutMode = 'fitRows'; 4230 4231 if (blogType === "masonry") { 4232 layoutMode = 'masonry'; 4233 } 4234 4235 if (blogType === "masonry" && blogInstance.hasClass('social-blog')) { 4236 var tweets = blogInstance.parent().find('.blog-tweets').html(), 4237 instagrams = blogInstance.parent().find('.blog-instagrams'); 4238 4239 blogInstance.imagesLoaded(function () { 4240 SWIFT.sliders.thumb(); 4241 blogInstance.isotope({ 4242 resizable: false, 4243 itemSelector : '.blog-item', 4244 layoutMode: 'masonry', 4245 getSortData : { 4246 date : function ( elem ) { 4247 return jQuery(elem).data('date'); 4248 } 4249 }, 4250 sortBy: 'date', 4251 sortAscending: false, 4252 isOriginLeft: !isRTL 4253 }); 4254 blogInstance.addClass('isotope-loaded'); 4255 if (tweets !== "") { 4256 blogInstance.isotope('insert', jQuery(tweets)); 4257 } 4258 if (instagrams.length > 0) { 4259 SWIFT.blog.masonryInstagram(instagrams, blogInstance); 4260 } 4261 blogInstance.isotope('updateSortData').isotope(); 4262 setTimeout(function() { 4263 blogInstance.isotope('layout'); 4264 }, 500); 4265 }); 4266 4267 } else { 4268 blogInstance.imagesLoaded(function () { 4269 SWIFT.sliders.thumb(); 4270 blogInstance.isotope({ 4271 resizable: true, 4272 layoutMode: layoutMode, 4273 isOriginLeft: !isRTL 4274 }); 4275 blogInstance.addClass('isotope-loaded'); 4276 setTimeout(function() { 4277 blogInstance.isotope('layout'); 4278 }, 500); 4279 }); 4280 blogInstance.appear(function() { 4281 SWIFT.blog.animateItems(blogInstance); 4282 }); 4283 } 4284 }, 4285 masonryInstagram: function(instagrams, blogItems) { 4286 var userID = instagrams.data('userid'), 4287 token = instagrams.data('token'), 4288 count = instagrams.data('count'), 4289 itemClass = instagrams.data('itemclass'), 4290 clientid = '641129180090039'; 4291 4292 jQuery.ajax({ 4293 url: 'https://graph.instagram.com/' + userID + '/media?fields=media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}
4293&limit=' + count + '&access_token=' + token, 4294 dataType: 'jsonp', 4295 type: 'GET', 4296 data: {client_id: clientid, count: count}, 4297 success: function(data) { 4298 for (var i = 0; i < count; i++) { 4299 var item = data.data[i]; 4300 if (typeof item !== 'undefined') { 4301 var caption = "", 4302 imageURL = item.media_url; 4303 if (item.caption) { 4304 caption = item.caption; 4305 } 4306 var date = new Date(item.timestamp); 4307 instagrams.append("<li class='blog-item instagram-item "+itemClass+"' data-date='"+item.timestamp+"'><a class='timestamp inst-icon' target='_blank' href='" + item.permalink +"'><i class='fab fa-instagram'></i></a><div class='inst-overlay'><a target='_blank' href='" + item.permalink +"'></a><h6>"+instagrams.data('title')+"</h6><h2>"+caption+"</h2><div class='name-divide'></div><time class='date timeago' datetime='"+date+"'>"+date+"</time></div><img class='instagram-image' src='" + imageURL +"' width='306px' height='306px' /></li>"); 4308 } 4309 } 4310 jQuery("data.timeago").timeago(); 4311 instagrams.imagesLoaded(function(){ 4312 blogItems.isotope('insert', jQuery(instagrams.html())); 4313 }); 4314 blogItems.isotope('updateSortData').isotope(); 4315 }, 4316 error: function(data2) { 4317 console.log(data2); 4318 } 4319 }); 4320 }, 4321 animateItems: function(blogInstance) { 4322 blogInstance.find('.blog-item').each(function(i) { 4323 jQuery(this).delay(i*200).animate({ 4324 'opacity' : 1, 4325 }, 800, 'easeOutExpo', function() { 4326 jQuery(this).addClass('item-animated'); 4327 }); 4328 }); 4329 }, 4330 blogGrid: function(gridItems) { 4331 var tweets = gridItems.parent().find('.blog-tweets').html(), 4332 instagrams = gridItems.parent().find('.blog-instagrams'); 4333 4334 gridItems.imagesLoaded(function () { 4335 SWIFT.sliders.thumb(); 4336 gridItems.isotope({ 4337 resizable: false, 4338 itemSelector : '.blog-item', 4339 layoutMode: 'fitRows', 4340 getSortData : { 4341 id : function ( elem ) { 4342 return jQuery(elem).data('sortid'); 4343 }, 4344 date : function ( elem ) { 4345 return jQuery(elem).data('date'); 4346 } 4347 }, 4348 sortBy: 'id', 4349 sortAscending: true, 4350 isOriginLeft: !isRTL 4351 }); 4352 setTimeout(function() { 4353 gridItems.isotope('layout'); 4354 }, 500); 4355 if (tweets !== "") { 4356 gridItems.isotope('insert', jQuery(tweets)); 4357 } 4358 if (instagrams.length > 0) { 4359 SWIFT.blog.blogGridInstagram(instagrams, gridItems); 4360 } 4361 gridItems.isotope('updateSortData').isotope(); 4362 SWIFT.blog.blogGridResize(); 4363 }).animate({ 4364 'opacity' : 1 4365 }, 800, 'easeOutExpo'); 4366 4367 $window.smartresize( function() { 4368 SWIFT.blog.blogGridResize(); 4369 }); 4370 }, 4371 blogTimeline: function(blogItems) { 4372 SWIFT.timelineBlocks = blogItems.find('.blog-item'); 4373 4374 // hide timeline blocks which are outside the viewport 4375 SWIFT.blog.blogTimelineHideBlocks(SWIFT.timelineBlocks, SWIFT.timelineOffset); 4376 4377 // show visible blocks 4378 SWIFT.blog.blogTimelineShowBlocks(SWIFT.timelineBlocks, SWIFT.timelineOffset); 4379 4380 blogItems.imagesLoaded(function () { 4381 SWIFT.sliders.thumb(); 4382 }); 4383 4384 //on scolling, show/animate timeline blocks when enter the viewport 4385 jQuery(window).on('scroll', function() { 4386 if (!window.requestAnimationFrame) { 4387 setTimeout( function() { 4388 SWIFT.blog.blogTimelineShowBlocks(SWIFT.timelineBlocks, SWIFT.timelineOffset); 4389 }, 100); 4390 } else { 4391 window.requestAnimationFrame( function() { 4392 SWIFT.blog.blogTimelineShowBlocks(SWIFT.timelineBlocks, SWIFT.timelineOffset); 4393 }); 4394 } 4395 }); 4396 }, 4397 blogTimelineShowBlocks: function(blocks, offset) { 4398 blocks.each(function() { 4399 if ( jQuery(this).offset().top <= jQuery(window).scrollTop()+jQuery(window).height()*offset && jQuery(this).find('.timeline-item-content-wrap').hasClass('is-hidden') ) { 4400 jQuery(this).find('.timeline-item-format-icon, .timeline-item-content-wrap').removeClass('is-hidden').addClass('bounce-in'); 4401 } 4402 }); 4403 }, 4404 blogTimelineHideBlocks: function(blocks, offset) { 4405 blocks.each(function() { 4406 if ( jQuery(this).offset().top > jQuery(window).scrollTop()+jQuery(window).height()*offset ) { 4407 jQuery(this).find('.timeline-item-format-icon, .timeline-item-content-wrap').addClass('is-hidden'); 4408 } 4409 }); 4410 }, 4411 blogGridResize: function() { 4412 blogItems.find('.grid-items').each(function() { 4413 var gridItem = jQuery(this).find('.blog-item'), 4414 itemWidth = gridItem.first().width(); 4415 if (gridItem.first().hasClass('col-sm-sf-25')) { 4416 itemWidth = itemWidth / 2; 4417 } 4418 gridItem.css('height', itemWidth);
4419 }); 4420 setTimeout(function() { 4421 blogItems.find('.tweet-text,.quote-excerpt').dotdotdot(); 4422 blogItems.find('.grid-items').isotope('layout'); 4423 }, 500); 4424 }, 4425 blogGridInstagram: function(instagrams, gridItems) { 4426 var userID = instagrams.data('userid'), 4427 token = instagrams.data('token'), 4428 count = instagrams.data('count'), 4429 itemClass = instagrams.data('itemclass'), 4430 grid_count = 1, 4431 clientid = '641129180090039'; 4432 4433 jQuery.ajax({ 4434 url: 'https://graph.instagram.com/' + userID + '/media?fields=media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}&limit=' + count + '&access_token=' + token, 4435 dataType: 'jsonp', 4436 type: 'GET', 4437 data: {client_id: clientid, count: count}, 4438 success: function(data) { 4439 for (var i = 0; i < count; i++) { 4440 var item = data.data[i]; 4441 if (typeof item !== 'undefined') { 4442 var caption = "", 4443 imageURL = item.media_url; 4444 if (item.caption) { 4445 caption = item.caption; 4446 } 4447 var date = new Date(item.timestamp); 4448 instagrams.append("<li class='blog-item "+itemClass+" instagram-item' data-date='"+item.timestamp+"' data-sortid='"+i*2+"'><a class='timestamp inst-icon' target='_blank' href='" + item.permalink +"'><i class='fab fa-instagram'></i></a><div class='inst-img-wrap'><div class='inst-overlay'><a target='_blank' href='" + item.permalink +"'></a><h6>"+instagrams.data('title')+"</h6><h2>"+caption+"</h2><div class='name-divide'></div><time class='date timeago' datetime='"+date+"'></time></div><img class='instagram-image' src='" + imageURL +"' /></div></li>"); 4449 } 4450 } 4451 jQuery("data.timeago").timeago(); 4452 SWIFT.blog.blogGridResize(); 4453 instagrams.imagesLoaded(function(){ 4454 gridItems.isotope('insert', jQuery(instagrams.html())); 4455 SWIFT.blog.blogGridResize(); 4456 }); 4457 gridItems.isotope('updateSortData').isotope(); 4458 }, 4459 error: function(data2) { 4460 console.log(data2); 4461 } 4462 }); 4463 }, 4464 infiniteScroll: function() { 4465 if (!(IEVersion && IEVersion < 9)) { 4466 var infScrollData = jQuery('#inf-scroll-params'); 4467 var isLoadMore = blogItems.parent().find('.pagination-wrap').hasClass('load-more') ? true : false; 4468 4469 if ( !blogItems.parent().find('.pagination-wrap').hasClass('infinite-scroll-enabled') ) { 4470 return; 4471 } 4472 4473 var infiniteScroll = { 4474 loading: { 4475 img: infScrollData.data('loadingimage'), 4476 msgText: isLoadMore ? infScrollData.data('msgtext') : '', 4477 finishedMsg: isLoadMore ? infScrollData.data('finishedmsg') : '', 4478 selector: '.blog-items-wrap', 4479 loaderHTML: jQuery('body > .sf-svg-loader').html() 4480 }, 4481 "nextSelector":".pagenavi li.next a", 4482 "navSelector":".pagenavi", 4483 "itemSelector":".blog-item", 4484 "contentSelector":".blog-items", 4485 errorCallback: function () { 4486 setTimeout(function() { 4487 jQuery( '#infscr-loading' ).animate({ 4488 'opacity' : 0 4489 }, 500); 4490 }, 1000); 4491 }, 4492 }; 4493 jQuery( infiniteScroll.contentSelector ).infinitescroll( 4494 infiniteScroll, function(elements) { 4495 SWIFT.sliders.thumb(); 4496 SWIFT.page.mediaPlayer(); 4497 if ( blogItems.hasClass('timeline-items') ) { 4498 SWIFT.timelineBlocks = blogItems.find('.blog-item'); 4499 SWIFT.blog.blogTimelineShowBlocks(SWIFT.timelineBlocks, SWIFT.timelineOffset); 4500 } 4501 blogItems.imagesLoaded(function () { 4502 if ( blogItems.hasClass('isotope-loaded') ) { 4503 blogItems.isotope( 'appended', elements ); 4504 } 4505 jQuery.each(elements, function(i, element) { 4506 jQuery(element).addClass('item-animated'); 4507 }); 4508 }); 4509 jQuery('[data-rel="ilightbox[posts]"]').removeClass('ilightbox-enabled').iLightBox().destroy(); 4510 SWIFT.page.lightbox(); 4511 SWIFT.blog.blogShowFilters(); 4512 if (blogItems.parent().find('.pagination-wrap').hasClass('load-more')) { 4513 setTimeout(function() { 4514 jQuery('.load-more-btn').css('display', 'block'); 4515 }, 200); 4516 } 4517 if (sfIncluded.hasClass('stickysidebars') && jQuery('.sticky-widget').length > 0) { 4518 setTimeout(function() { 4519 $window.trigger('resize'); 4520 }, 200); 4521 } 4522 } 4523 ); 4524 if (isLoadMore) { 4525 blogItems.parent().addClass('blog-load-more-pagination'); 4526 $window.unbind('.infscr'); 4527 jQuery('.load-more-btn').on('click', function(e) { 4528 e.preventDefault(); 4529 jQuery( infiniteScroll.contentSelector ).infinitescroll('retrieve'); 4530 jQuery('.load-more-btn').css('display', 'none'); 4531 $window.trigger('resize'); 4532 });
4533 } 4534 } else { 4535 jQuery('.pagination-wrap').removeClass('hidden'); 4536 } 4537 } 4538 }; 4539 4540 ///////////////////////////////////////////// 4541 // GALLERIES 4542 ///////////////////////////////////////////// 4543 4544 var galleriesContainer = jQuery('.galleries-wrap').find('.filterable-items'); 4545 4546 SWIFT.galleries = { 4547 init: function() { 4548 galleriesContainer.each(function() { 4549 var galleriesInstance = jQuery(this); 4550 if (galleriesInstance.hasClass('masonry-items')) { 4551 SWIFT.galleries.masonrySetup(galleriesInstance); 4552 } else { 4553 SWIFT.galleries.standardSetup(galleriesInstance); 4554 } 4555 }); 4556 4557 // PORTFOLIO WINDOW RESIZE 4558 $window.smartresize( function() { 4559 SWIFT.galleries.windowResized(); 4560 }); 4561 4562 // Enable filter options on when there are items from that skill 4563 jQuery('.galleries-wrap .filtering li').each( function() { 4564 var filter = jQuery(this), 4565 filterName = jQuery(this).find('a').attr('class'), 4566 galleryItems = jQuery(this).parents('.galleries-wrap').find('.filterable-items'), 4567 itemCount = 0; 4568 4569 if ( filter.hasClass('all') ) { 4570 itemCount = galleryItems.find('.gallery-item').length; 4571 } 4572 4573 galleryItems.find('.gallery-item').each( function() { 4574 if ( jQuery(this).hasClass(filterName) ) { 4575 filter.addClass('has-items'); 4576 itemCount++; 4577 } 4578 }); 4579 if ( filter.find('sup.count').length > 0 ) { 4580 filter.find('sup.count').text(itemCount); 4581 } else { 4582 filter.find('a').append('<sup class="count">'+itemCount+'</sup>'); 4583 } 4584 }).parents('.filtering').animate({ 4585 opacity: 1 4586 }, 400); 4587 4588 // filter items when filter link is clicked 4589 jQuery('.galleries-wrap .filtering li').on('click', 'a', function(e) { 4590 e.preventDefault(); 4591 jQuery(this).parent().parent().find('li').removeClass('selected'); 4592 jQuery(this).parent().addClass('selected'); 4593 var selector = jQuery(this).data('filter'); 4594 var galleryItems = jQuery(this).parents('.galleries-wrap').find('.filterable-items'); 4595 galleryItems.isotope({ filter: selector }); 4596 }); 4597 }, 4598 standardSetup: function(galleryInstance) { 4599 galleryInstance.imagesLoaded(function () { 4600 SWIFT.galleries.setItemHeight(); 4601 galleryInstance.animate({opacity: 1}, 800); 4602 galleryInstance.isotope({ 4603 resizable: true, 4604 layoutMode: 'fitRows', 4605 isOriginLeft: !isRTL 4606 }); 4607 setTimeout(function() { 4608 galleryInstance.isotope('layout'); 4609 }, 500); 4610 }); 4611 galleryInstance.appear(function() { 4612 SWIFT.galleries.animateItems(galleryInstance); 4613 }); 4614 }, 4615 masonrySetup: function(galleryInstance) { 4616 galleryInstance.imagesLoaded(function () { 4617 galleryInstance.isotope({ 4618 resizable: false, 4619 itemSelector : '.gallery-item', 4620 layoutMode: 'masonry', 4621 isOriginLeft: !isRTL 4622 }); 4623 setTimeout(function() { 4624 galleryInstance.isotope('layout'); 4625 }, 500); 4626 }); 4627 galleryInstance.appear(function() { 4628 SWIFT.galleries.animateItems(galleryInstance); 4629 }); 4630 }, 4631 animateItems: function(galleryInstance) { 4632 galleryInstance.find('.gallery-item').each(function(i) { 4633 jQuery(this).delay(i*200).animate({ 4634 'opacity' : 1 4635 }, 800, 'easeOutExpo', function() { 4636 jQuery(this).addClass('item-animated'); 4637 }); 4638 }); 4639 }, 4640 setItemHeight: function() { 4641 if (!galleriesContainer.hasClass('col-1') && !galleriesContainer.hasClass('masonry-items')) { 4642 galleriesContainer.children().css('min-height','0'); 4643 galleriesContainer.equalHeights(); 4644 } 4645 }, 4646 windowResized: function() { 4647 if (!galleriesContainer.hasClass('col-1') && !galleriesContainer.hasClass('masonry-items')) { 4648 SWIFT.galleries.setItemHeight(); 4649 } 4650 }, 4651 }; 4652 4653 4654 ///////////////////////////////////////////// 4655 // GALLERY 4656 ///////////////////////////////////////////// 4657 4658 SWIFT.gallery = { 4659 init: function() { 4660 4661 jQuery('.spb_gallery_widget').each(function() { 4662 if (jQuery(this).hasClass('gallery-masonry')) { 4663 SWIFT.gallery.galleryMasonry(jQuery(this).find('.filterable-items')); 4664 } else if (jQuery(this).hasClass('gallery-slider')) { 4665 SWIFT.gallery.gallerySlider(jQuery(this)); 4666 } 4667 }); 4668 }, 4669 galleryMasonry: function(element) { 4670 element.imagesLoaded(function () { 4671 element.isotope({ 4672 resizable: false, 4673 itemSelector : '.gallery-image', 4674 layoutMode: 'masonry', 4675 isOriginLeft: !isRTL 4676 }); 4677 setTimeout(function() { 4678 element.isotope('layout'); 4679 }, 500); 4680 }); 4681 element.appear(function() { 4682 SWIFT.gallery.animateItems(element); 4683 }); 4684 }, 4685 animateItems: function(element) { 4686 element.find('.gallery-image').each(function(i) { 4687 jQuery(this).delay(i*200).animate({ 4688 'opacity' : 1 4689 }, 800, 'easeOutExpo', function() { 4690 jQuery(this).addClass('item-animated'); 4691 }); 4692 }); 4693 }, 4694 gallerySlider: function(element) { 4695 4696 var gallerySlider = element.find('.gallery-slider > ul'), 4697 galleryAuto = gallerySlider.parent().data('autoplay') === "yes" ? true : false, 4698 galleryThumbs = gallerySlider.parent().data('thumbs') === "yes" ? true : false; 4699 4700 gallerySlider.lightSlider({ 4701 mode: gallerySlider.parent().data('transition'), 4702 item: 1, 4703 gallery: galleryThumbs, 4704 autoWidth: false, 4705 slideMargin: 0, 4706 speed: sliderAnimSpeed, //ms' 4707 auto: galleryAuto, 4708 loop: true, 4709 pause: sliderSlideSpeed, 4710 keyPress: true, 4711 controls: true, 4712 rtl: isRTL, 4713 adaptiveHeight: true, 4714 thumbMargin: 30, 4715 galleryMargin: 30, 4716 currentPagerPosition: 'middle', 4717 swipeThreshold: 40, 4718 responsive : [ 4719 { 4720 breakpoint: 1024, 4721 settings: { 4722 thumbItem: 3, 4723 } 4724 } 4725 ], 4726 onSliderLoad: function (el) { 4727 el.addClass('slider-loaded'); 4728 } 4729 }); 4730 4731 4732 } 4733 }; 4734 4735 4736 ///////////////////////////////////////////// 4737 // RECENT POSTS 4738 ///////////////////////////////////////////// 4739 4740 SWIFT.recentPosts = { 4741 init: function() { 4742 4743 // TEAM EQUAL HEIGHTS 4744 var recentPostAsset = jQuery('.recent-posts:not(.carousel-items,.posts-type-list)'); 4745 recentPostAsset.imagesLoaded(function () { 4746 SWIFT.sliders.thumb(); 4747 }); 4748 4749 // TEAM ASSETS 4750 $window.smartresize( function() { 4751 jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').children().css('min-height','0'); 4752 jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').equalHeights();
4753 }); 4754 }, 4755 load: function() { 4756 setTimeout(function() { 4757 jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').children().css('min-height','0'); 4758 jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').equalHeights(); 4759 }, 400); 4760 } 4761 }; 4762 4763 4764 ///////////////////////////////////////////// 4765 // CAROUSEL FUNCTIONS 4766 ///////////////////////////////////////////// 4767 4768 SWIFT.carouselWidgets = { 4769 init: function() { 4770 4771 // CAROUSELS 4772 var carousel = jQuery('.carousel-items'), 4773 carouselAuto = sfOptionParams.data('carousel-autoplay'), 4774 carouselPSpeed = sfOptionParams.data('carousel-pagespeed'), 4775 carouselSSpeed = sfOptionParams.data('carousel-slidespeed'), 4776 carouselPagination = sfOptionParams.data('carousel-pagination'), 4777 carouselPDirection = 'ltr', 4778 desktopWidth = 1199; 4779 4780 if (body.hasClass('vertical-header')) { 4781 desktopWidth = desktopWidth + jQuery('#header-section').width(); 4782 } 4783 4784 if (carouselAuto) { 4785 carouselAuto = true; 4786 } else { 4787 carouselAuto = false; 4788 } 4789 if (carouselPagination) { 4790 carouselPagination = true; 4791 } else { 4792 carouselPagination = false; 4793 } 4794 if (isRTL) { 4795 carouselPDirection = 'rtl'; 4796 } 4797 4798 carousel.each(function() { 4799 var carouselInstance = jQuery('#'+jQuery(this).attr('id')), 4800 carouselColumns = parseInt(carouselInstance.attr("data-columns"), 10), 4801 desktopCarouselItems = 4 > carouselColumns ? carouselColumns : 4, 4802 desktopSmallCarouselItems = 3 > carouselColumns ? carouselColumns : 3, 4803 mobileCarouselItems = 1, 4804 testimonialShowcase = jQuery(this).parents('.showcase_testimonial_widget').length > 0 ? true : false; 4805 4806 var carouselAutoplay = false; 4807 4808 if ( typeof carouselInstance.data('autoplay') !== 'undefined' && carouselInstance.data('autoplay') !== '' ) { 4809 carouselAutoplay = carouselInstance.data('autoplay'); 4810 } else { 4811 carouselAutoplay = carouselAuto; 4812 } 4813 4814 if (carouselInstance.hasClass('clients-items')) { 4815 mobileCarouselItems = 2; 4816 } 4817 4818 if (carouselInstance.hasClass('testimonials')) { 4819 desktopCarouselItems = 1; 4820 desktopSmallCarouselItems = 1; 4821 mobileCarouselItems = 1; 4822 } 4823 4824 if (testimonialShowcase) { 4825 carouselPagination = true; 4826 } 4827 4828 carouselInstance.imagesLoaded(function () { 4829 4830 if ( !carouselInstance.hasClass('no-gutters') ) { 4831 SWIFT.carouselWidgets.carouselSetWidth(carouselInstance); 4832 } 4833 4834 if ( carouselInstance.hasClass('staged-carousel') ) { 4835 SWIFT.carouselWidgets.carouselStagedSetWidth(carouselInstance); 4836 carouselPagination = carouselInstance.attr("data-pagination") === "yes" ? true : false; 4837 } 4838 4839 carouselInstance.owlCarousel({ 4840 items : carouselColumns, 4841 itemsDesktop: [desktopWidth,desktopCarouselItems], 4842 itemsDesktopSmall: [desktopWidth-220,desktopSmallCarouselItems], 4843 itemsTablet: mobileCarouselItems, 4844 itemsMobile: [479,mobileCarouselItems], 4845 paginationSpeed: carouselPSpeed, 4846 slideSpeed: carouselSSpeed, 4847 autoPlay: carouselAutoplay, 4848 autoPlayDirection : carouselPDirection, 4849 pagination: carouselPagination, 4850 autoHeight : false, 4851 beforeUpdate: function() { 4852 if ( !carouselInstance.hasClass('no-gutters') ) { 4853 SWIFT.carouselWidgets.carouselSetWidth(carouselInstance); 4854 } 4855 4856 if ( carouselInstance.hasClass('staged-carousel') ) { 4857 SWIFT.carouselWidgets.carouselStagedSetWidth(carouselInstance); 4858 SWIFT.carouselWidgets.carouselStagedSetActive(carouselInstance); 4859 } 4860 }, 4861 afterUpdate: function () { 4862 setTimeout(function() { 4863 SWIFT.sliders.thumb(); 4864 SWIFT.carouselWidgets.carouselStagedSetActive(carouselInstance); 4865 }, 200); 4866 }, 4867 beforeInit: function() { 4868 if ( carouselInstance.hasClass('staged-carousel') && $window.width() < 768 ) { 4869 carouselInstance.find('.left-holder,.right-holder').remove(); 4870 } 4871 }, 4872 afterInit: function() { 4873 SWIFT.sliders.thumb(); 4874 if ( carouselInstance.hasClass('staged-carousel') ) { 4875 carouselInstance.find('.owl-item:eq(1),.owl-item:eq(2),.owl-item:eq(3)').addClass('active'); 4876 } 4877 setTimeout(function() { 4878 $window.trigger('resize'); 4879 SWIFT.parallax.init(true); 4880 }, 200); 4881 if ( testimonialShowcase ) { 4882 carouselInstance.find('.owl-pagination').append( carouselInstance.parents('.showcase_testimonial_widget').find('.read-more') ); 4883 } 4884 if ( carouselInstance.hasClass('staged-carousel') ) { 4885 carouselInstance.find('.owl-pagination').append( carouselInstance.parents('.spb-asset-content').parent().find('.view-all') ); 4886 carouselInstance.find('.owl-pagination .view-all').removeClass('hidden'); 4887 } 4888 4889 // Set staged carousel active on window resize 4890 if ( carouselInstance.hasClass('staged-carousel') ) { 4891 $window.smartresize( function() { 4892 setTimeout(function() { 4893 SWIFT.carouselWidgets.carouselStagedSetActive(carouselInstance); 4894 }, carouselSSpeed); 4895 setTimeout(function() { 4896 SWIFT.carouselWidgets.carouselStagedSetActive(carouselInstance); 4897 }, carouselPSpeed); 4898 });
4899 } 4900 }, 4901 afterAction: function(){ 4902 if ( carouselInstance.hasClass('staged-carousel') ) { 4903 setTimeout(function() { 4904 SWIFT.carouselWidgets.carouselStagedSetActive(carouselInstance); 4905 }, carouselSSpeed); 4906 setTimeout(function() { 4907 SWIFT.carouselWidgets.carouselStagedSetActive(carouselInstance); 4908 }, carouselPSpeed); 4909 } 4910 4911 // Show/hide next+prev arrows 4912 var carouselNext = carouselInstance.parents('.carousel-wrap').find('.carousel-next'), 4913 carouselPrev = carouselInstance.parents('.carousel-wrap').find('.carousel-prev'); 4914 4915 if ( this.itemsAmount > this.visibleItems.length ) { 4916 carouselNext.show(); 4917 carouselPrev.show(); 4918 4919 carouselNext.removeClass('disabled'); 4920 carouselPrev.removeClass('disabled'); 4921 if ( this.currentItem === 0 ) { 4922 carouselPrev.addClass('disabled'); 4923 } 4924 if ( this.currentItem == this.maximumItem ) { 4925 carouselNext.addClass('disabled'); 4926 } 4927 4928 } else { 4929 carouselNext.hide(); 4930 carouselPrev.hide(); 4931 } 4932 } 4933 }).animate({ 4934 'opacity': 1 4935 },800); 4936 }); 4937 }); 4938 4939 // Previous 4940 jQuery('.carousel-next').on('click', function(e) { 4941 e.preventDefault(); 4942 var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel'); 4943 if (isRTL) { 4944 carousel.data( 'owlCarousel' ).prev(); 4945 } else { 4946 carousel.data( 'owlCarousel' ).next(); 4947 } 4948 jQuery(this).blur(); 4949 }); 4950 4951 // Next 4952 jQuery('.carousel-prev').on('click', function(e) { 4953 e.preventDefault(); 4954 var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel'); 4955 if (isRTL) { 4956 carousel.data( 'owlCarousel' ).next(); 4957 } else { 4958 carousel.data( 'owlCarousel' ).prev(); 4959 } 4960 jQuery(this).blur(); 4961 }); 4962 }, 4963 carouselSwipeIndicator: function(carousel) { 4964 carousel.appear(function() { 4965 var swipeIndicator = jQuery(this).parents('.carousel-wrap').find('.sf-swipe-indicator'); 4966 setTimeout(function() { 4967 swipeIndicator.fadeIn(500); 4968 }, 400); 4969 setTimeout(function() { 4970 swipeIndicator.addClass('animate'); 4971 }, 1000); 4972 setTimeout(function() { 4973 swipeIndicator.fadeOut(400); 4974 }, 3000); 4975 }); 4976 }, 4977 carouselMinHeight: function(carousel) { 4978 var minHeight = parseInt(carousel.find('.carousel-item:not(.no-thumb)').eq(0).css('height')); 4979 carousel.find('.owl-item').each(function () { 4980 jQuery(this).css('min-height',minHeight+'px'); 4981 }); 4982 }, 4983 carouselSetWidth: function(carousel) { 4984 var carouselWidth = carousel.parent().width(); 4985 if ( isRTL ) { 4986 carousel.css('margin-right', '-15px').css('width', carouselWidth + 30); 4987 } else { 4988 carousel.css('margin-left', '-15px').css('width', carouselWidth + 30); 4989 } 4990 }, 4991 carouselStagedSetWidth: function(carousel) { 4992 var carouselWidth = carousel.parent().width(), 4993 overlapWidth = 200; 4994 4995 if ( $window.width() < 480 ) { 4996 overlapWidth = 0; 4997 } 4998 4999 if ( isRTL ) { 5000 carousel.css('margin-right', -overlapWidth).css('width', carouselWidth + overlapWidth*2); 5001 } else { 5002 carousel.css('margin-left', -overlapWidth).css('width', carouselWidth + overlapWidth*2); 5003 } 5004 }, 5005 carouselStagedSetActive: function(carousel) { 5006 carousel.find('.owl-item').each(function() { 5007 if ( jQuery(this).visible() ) { 5008 jQuery(this).addClass('active'); 5009 } else { 5010 jQuery(this).removeClass('active'); 5011 } 5012 }); 5013 if ( carousel.find('.owl-item.active').length <= 0 ) { 5014 carousel.find('.owl-item:eq(1),.owl-item:eq(2),.owl-item:eq(3)').addClass('active'); 5015 } 5016 } 5017 }; 5018 5019 5020 ///////////////////////////////////////////// 5021 // WIDGET FUNCTIONS 5022 ///////////////////////////////////////////// 5023 5024 SWIFT.widgets = { 5025 init: function() { 5026 5027 // LOAD WIDGETS 5028 SWIFT.widgets.accordion(); 5029 SWIFT.widgets.toggle(); 5030 SWIFT.widgets.fullWidthVideo(); 5031 SWIFT.widgets.introAnimations(); 5032 SWIFT.widgets.iconBoxes(); 5033 5034 // DYNAMIC TABS 5035 jQuery('.tabs-type-dynamic .menu-icon').hover(function() { 5036 jQuery(this).parents('.nav-tabs').addClass('show-tabs'); 5037 }); 5038 5039 jQuery('.tabs-type-dynamic').mouseleave(function() { 5040 jQuery(this).find('.nav-tabs').removeClass('show-tabs'); 5041 }); 5042 5043 // CATEGORY COUNT DISPLAY 5044 jQuery('.widget_categories li span').each(function() { 5045 var thisCategory = jQuery(this), 5046 thisText = thisCategory.text(); 5047 thisCategory.text(thisText.replace('(', '').replace(')', '')); 5048 thisCategory.addClass('show-count'); 5049 }); 5050 5051 }, 5052 load: function() { 5053 5054 SWIFT.widgets.tabs(); 5055 5056 if ( jQuery('.progress').length > 0 ) { 5057 SWIFT.widgets.initSkillBars(); 5058 } 5059 5060 // SF TOOLTIPS 5061 if (jQuery('[data-toggle="tooltip"]').length > 0 && !isMobileAlt) { 5062 SWIFT.widgets.initTooltips(); 5063 } 5064 5065 }, 5066 accordion: function() { 5067 jQuery('.spb_accordion').each(function() { 5068 var spb_tabs, 5069 active_tab = false,
5070 active_attr = parseInt(jQuery(this).attr('data-active'), 10); 5071 5072 if (jQuery.type( active_attr ) === "number") { active_tab = active_attr; } 5073 5074 spb_tabs = jQuery(this).find('.spb_accordion_wrapper').accordion({ 5075 header: "> div > h4", 5076 autoHeight: true, 5077 collapsible: true, 5078 active: active_tab, 5079 heightStyle: "content" 5080 }); 5081 }).css('opacity', 1); 5082 }, 5083 tabs: function() { 5084 // SET ACTIVE TABS PANE 5085 setTimeout(function() { 5086 jQuery('.spb_tabs').each(function() { 5087 jQuery(this).find('.tab-pane').first().addClass('active show'); 5088 jQuery(this).find('.tab-pane').removeClass('load'); 5089 }); 5090 }, 200); 5091 5092 // SET ACTIVE TOUR PANE 5093 setTimeout(function() { 5094 jQuery('.spb_tour').each(function() { 5095 jQuery(this).find('.tab-pane').first().addClass('active show'); 5096 jQuery(this).find('.tab-pane').removeClass('load'); 5097 }); 5098 }, 200); 5099 5100 // RESET MAPS ON TAB CLICK 5101 jQuery('ul.nav-tabs li a, .spb_accordion_section > h4 a').on('click', '', function(){ 5102 var thisTab = jQuery(this), 5103 asset = thisTab.parents('.spb_content_element').first(); 5104 5105 if (sfIncluded.hasClass('stickysidebars') && jQuery('.sticky-widget').length > 0) { 5106 setTimeout(function() { 5107 $window.trigger('resize'); 5108 }, 300); 5109 } 5110 5111 if (asset.find('.map-canvas').length > 0) { 5112 setTimeout(function() { 5113 jQuery(window).trigger('resize'); 5114 SWIFT.map.init(); 5115 }, 100); 5116 } 5117 5118 if (asset.find('.spb_blog_widget').length > 0 || asset.find('.spb_portfolio_widget').length > 0) { 5119 setTimeout(function() { 5120 jQuery(window).trigger('resize'); 5121 }, 200); 5122 } 5123 }); 5124 5125 // Reset isotope layout on tab shown 5126 jQuery('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 5127 var target = jQuery(e.target).attr("href"); 5128 if ( jQuery(target).find('.filterable-items').length > 0 ) { 5129 jQuery(target).find('.filterable-items').isotope('layout'); 5130 } 5131 }); 5132 5133 // SET DESIRED TAB ON LOAD 5134 setTimeout(function() { 5135 if (jQuery('.spb_tabs').length > 0) { 5136 5137 $window.trigger('resize'); 5138 5139 // Show correct tab on page load 5140 var tabUrl = document.location.toString(); 5141 if (tabUrl.match('#') && jQuery('.nav-tabs a[href="#'+tabUrl.split('#')[1]+'"]').length > 0) { 5142 var tabHash = tabUrl.split('#')[1]; 5143 5144 jQuery('.nav-tabs a[href="#'+tabHash+'"]').tab('show'); 5145 } 5146 5147 // Change hash on tab click 5148 jQuery('.nav-tabs a').click(function (e) { 5149 var hash = e.target.hash; 5150 5151 if (history.pushState) { 5152 history.pushState(null, null, hash); 5153 } else { 5154 location.hash = hash; 5155 } 5156 }); 5157 } 5158 if (jQuery('.spb_accordion').length > 0) { 5159 5160 // Show correct accordion section on page load 5161 var accordionUrl = document.location.toString(); 5162 if (accordionUrl.match('#') && jQuery('.spb_accordion a[href="#'+accordionUrl.split('#')[1]+'"]').length > 0) { 5163 var accordionHash = accordionUrl.split('#')[1]; 5164 5165 jQuery('.spb_accordion a[href="#'+accordionHash+'"]').click(); 5166 } 5167 5168 // Change hash on tab click 5169 jQuery('.spb_accordion a').click(function (e) { 5170 var hash = e.target.hash; 5171 5172 if (history.pushState) { 5173 history.pushState(null, null, hash); 5174 } else { 5175 location.hash = hash; 5176 } 5177 }); 5178 } 5179 5180 if (jQuery('.spb_tour').length > 0) { 5181 5182 // Show correct accordion section on page load 5183 var tourUrl = document.location.toString(); 5184 if (tourUrl.match('#') && jQuery('.spb_tour a[href="#'+tourUrl.split('#')[1]+'"]').length > 0) { 5185 var tourHash = tourUrl.split('#')[1]; 5186 5187 jQuery('.spb_tour a[href="#'+tourHash+'"]').click(); 5188 } 5189 5190 // Change hash on tab click 5191 jQuery('.spb_tour a').click(function (e) { 5192 var hash = e.target.hash; 5193 5194 if ( history.pushState ) { 5195 history.pushState(null, null, hash); 5196 } else { 5197 location.hash = hash; 5198 } 5199 });
5200 } 5201 5202 }, 200); 5203 }, 5204 toggle: function() { 5205 jQuery('.spb_toggle').click(function() { 5206 if ( jQuery(this).hasClass('spb_toggle_title_active') ) { 5207 jQuery(this).removeClass('spb_toggle_title_active').next().slideUp(500); 5208 } else { 5209 jQuery(this).addClass('spb_toggle_title_active').next().slideDown(500); 5210 } 5211 }); 5212 jQuery('.spb_toggle_content').each(function() { 5213 if ( jQuery(this).next().is('h4.spb_toggle') === false ) { 5214 jQuery('<div class="last_toggle_el_margin"></div>').insertAfter(this); 5215 } 5216 }); 5217 }, 5218 initSkillBars: function() { 5219 // SKILL BARS 5220 setTimeout(function() { 5221 SWIFT.widgets.animateSkillBars(); 5222 }, 500); 5223 5224 jQuery('a.ui-tabs-anchor').click(function(){ 5225 SWIFT.widgets.animateSkillBars(); 5226 }); 5227 }, 5228 animateSkillBars: function() { 5229 jQuery('.progress:not(.animated)').each(function(){ 5230 var progress = jQuery(this); 5231 5232 progress.appear(function() { 5233 var progressBar = jQuery(this), 5234 progressValue = progressBar.find('.bar').data('value'); 5235 progressBar.addClass('animated'); 5236 progressBar.find('.bar').animate({ 5237 width: progressValue + "%" 5238 }, 800, function() { 5239 progressBar.parent().find('.bar-text').css('width', progressValue + "%"); 5240 progressBar.parent().find('.bar-text .progress-value').fadeIn(600); 5241 }); 5242 }); 5243 }); 5244 }, 5245 charts: function() { 5246 SWIFT.widgets.animateCharts(); 5247 }, 5248 animateCharts: function() { 5249 jQuery('.chart-shortcode').each(function(){ 5250 var chart = jQuery(this); 5251 chart.appear(function() { 5252 if (!jQuery(this).hasClass('animated')) { 5253 jQuery(this).addClass('animated'); 5254 var animatePercentage = parseInt(jQuery(this).attr('data-animatepercent'), 10); 5255 jQuery(this).data('easyPieChart').update(animatePercentage); 5256 } 5257 }); 5258 }); 5259 }, 5260 fullWidthVideo: function() { 5261 body.on('click', '.fw-video-link', function(e) { 5262 var thisLink = jQuery(this); 5263 if (isMobileAlt && body.hasClass('mobile-two-click')) { 5264 if (thisLink.hasClass('hovered')) { 5265 if (jQuery(this).data('video') !== "") { 5266 SWIFT.widgets.openFullWidthVideo(jQuery(this)); 5267 } 5268 return false; 5269 } else { 5270 e.preventDefault(); 5271 thisLink.addClass('hovered'); 5272 } 5273 } else { 5274 if (jQuery(this).data('video') !== "") { 5275 SWIFT.widgets.openFullWidthVideo(jQuery(this)); 5276 } 5277 return false; 5278 } 5279 }); 5280 5281 body.on('click', '.fw-video-close', function(){ 5282 SWIFT.widgets.closeFullWidthVideo(); 5283 }); 5284 }, 5285 openFullWidthVideo: function(element) { 5286 jQuery('.fw-video-close').addClass('is-open'); 5287 jQuery('.fw-video-spacer').animate({ 5288 height: windowheight 5289 }, 1000, 'easeInOutExpo'); 5290 5291 jQuery('.fw-video-area').css('display', 'block').animate({ 5292 top: 0, 5293 height: '100%' 5294 }, 1000, 'easeInOutExpo', function() { 5295 // load video here 5296 jQuery('.fw-video-area > .fw-video-wrap').append('<iframe class="fw-video" src="'+element.data('video')+'" width="100%" height="100%" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>'); 5297 }); 5298 }, 5299 closeFullWidthVideo: function() { 5300 jQuery('.fw-video-close').removeClass('is-open'); 5301 jQuery('.fw-video-spacer').animate({ 5302 height: 0 5303 }, 1000, 'easeInOutExpo', function(){ 5304 }); 5305 jQuery('.fw-video-area').animate({ 5306 top:'-100%' 5307 }, 1000, 'easeInOutExpo', function() { 5308 jQuery('.fw-video-area').css('display', 'none'); 5309 jQuery('.fw-video-area .fw-video').remove(); 5310 }); 5311 5312 // pause videos 5313 jQuery('.fw-video-area video').each(function(){ 5314 this.pause(); 5315 }); 5316 setTimeout(function() { 5317 jQuery('.fw-video-area').find('iframe').remove(); 5318 }, 1500); 5319 5320 return false; 5321 }, 5322 introAnimations: function() { 5323 if ( !(isMobileAlt && body.hasClass('disable-mobile-animations')) ) { 5324 jQuery('.sf-animation').each(function() { 5325 var animatedItem = jQuery(this); 5326 animatedItem.waypoint(function() { 5327 var itemAnimation = animatedItem.data('animation'), 5328 itemDelay = animatedItem.data('delay'); 5329 5330 setTimeout(function() { 5331 window.requestAnimationFrame( function() { 5332 animatedItem.addClass(itemAnimation); 5333 setTimeout(function() { 5334 animatedItem.addClass('sf-animate'); 5335 }, 100); 5336 });
5337 }, itemDelay); 5338 }, { 5339 offset: '90%', 5340 triggerOnce: true 5341 }); 5342 }); 5343 } 5344 }, 5345 iconBoxes: function() { 5346 if (isMobileAlt) { 5347 jQuery('.sf-icon-box').on('click', function() { 5348 jQuery(this).addClass('sf-mobile-hover'); 5349 }); 5350 } else { 5351 jQuery('.sf-icon-box').hover( 5352 function() { 5353 jQuery(this).addClass('sf-hover'); 5354 }, function() { 5355 jQuery(this).removeClass('sf-hover'); 5356 } 5357 ); 5358 } 5359 }, 5360 initTooltips: function() { 5361 jQuery('[data-toggle="tooltip"]').tooltip({ 5362 trigger: 'hover' 5363 }); 5364 } 5365 }; 5366 5367 5368 ///////////////////////////////////////////// 5369 // TEAM MEMBERS FUNCTION 5370 ///////////////////////////////////////////// 5371 5372 SWIFT.teamMembers = { 5373 init: function() { 5374 // TEAM EQUAL HEIGHTS 5375 var team = jQuery('.team-members:not(.carousel-items)'); 5376 team.imagesLoaded(function () { 5377 if ($window.width() > 767) { 5378 team.equalHeights(); 5379 } 5380 }); 5381 5382 // TEAM ASSETS 5383 $window.smartresize( function() { 5384 jQuery('.team-members:not(.carousel-items)').children().css('min-height','0'); 5385 if ($window.width() > 767) { 5386 jQuery('.team-members:not(.carousel-items)').equalHeights(); 5387 } 5388 }); 5389 } 5390 }; 5391 5392 ///////////////////////////////////////////// 5393 // RELATED POSTS FUNCTION 5394 ///////////////////////////////////////////// 5395 5396 SWIFT.relatedPosts = { 5397 init: function() { 5398 // TEAM EQUAL HEIGHTS 5399 var relatedItems = jQuery('.related-items'); 5400 relatedItems.imagesLoaded(function () { 5401 if ($window.width() > 767) { 5402 relatedItems.equalHeights(); 5403 } 5404 }); 5405 5406 // TEAM ASSETS 5407 $window.smartresize( function() { 5408 jQuery('.related-items').children().css('min-height','0'); 5409 if ($window.width() > 767) { 5410 jQuery('.related-items').equalHeights(); 5411 } 5412 }); 5413 } 5414 }; 5415 5416 ///////////////////////////////////////////// 5417 // PARALLAX FUNCTION 5418 ///////////////////////////////////////////// 5419 5420 SWIFT.parallax = { 5421 init: function() { 5422 5423 jQuery('.spb_parallax_asset').each(function() { 5424 5425 var parallaxAsset = jQuery(this); 5426 5427 if (parallaxAsset.hasClass('sf-parallax-video')) { 5428 5429 if (!isMobileAlt) { 5430 SWIFT.parallax.parallaxVideoInit(); 5431 } else { 5432 parallaxAsset.find('video').remove(); 5433 5434 // Fade in 5435 parallaxAsset.transition({ 5436 opacity: 1 5437 }, 300); 5438 } 5439 5440 // Add resize handler 5441 $window.smartresize( function() { 5442 SWIFT.parallax.parallaxVideoResize(parallaxAsset); 5443 }); 5444 5445 } else if (parallaxAsset.hasClass('parallax-window-height')) { 5446 5447 // Add resize handler 5448 SWIFT.parallax.windowImageResize(parallaxAsset); 5449 } 5450 5451 // Add resize handler 5452 SWIFT.parallax.windowImageResize(parallaxAsset); 5453 $window.smartresize( function() { 5454 SWIFT.parallax.windowImageResize(parallaxAsset); 5455 }); 5456 }); 5457 5458 }, 5459 windowImageResize: function(asset) { 5460 5461 if (asset.hasClass('spb-row-container')) { 5462 5463 var rowContentHeight = asset.find('> .spb_content_element').height(); 5464 5465 if (asset.hasClass('parallax-window-height')) { 5466 5467 if (rowContentHeight < $window.height()) { 5468 rowContentHeight = $window.height(); 5469 } 5470 } 5471 5472 if ( !asset.hasClass('parallax-content-height') ) { 5473 asset.height(rowContentHeight); 5474 } 5475 5476 } else { 5477 5478 var assetHeight = asset.height(); 5479 5480 if (asset.hasClass('parallax-window-height')) { 5481 5482 if (assetHeight < $window.height()) { 5483 assetHeight = $window.height(); 5484 } 5485 } 5486 5487 if ( !asset.hasClass('parallax-content-height') ) { 5488 asset.height(assetHeight - asset.css('padding-top') / 2); 5489 asset.find('.spb_content_wrapper').vCenterTop(); 5490 } 5491 } 5492 5493 }, 5494 parallaxVideoInit: function() { 5495 jQuery('.spb_parallax_asset.sf-parallax-video').each(function() { 5496 var parallaxAsset = jQuery(this), 5497 parallaxVideo = parallaxAsset.find('video'), 5498 parallaxVideoWidth = parallaxVideo.width(), 5499 parallaxContent = parallaxAsset.find('div:first'), 5500 parallaxAssetHeight = 0; 5501 5502 if (parallaxAsset.hasClass('parallax-window-height')) { 5503 5504 if (parallaxContent.height() > $window.height()) { 5505 parallaxAssetHeight = parallaxContent.height(); 5506 } else { 5507 parallaxAssetHeight = $window.height(); 5508 } 5509 5510 parallaxAsset.animate({ 5511 'height': parallaxAssetHeight 5512 }, 400); 5513 5514 setTimeout(function() { 5515 5516 // Scale video 5517 SWIFT.parallax.parallaxVideoResize(parallaxAsset); 5518 5519 // Fade in 5520 parallaxAsset.transition({ 5521 opacity: 1 5522 }, 300); 5523 5524 }, 500); 5525 5526 setTimeout(function() { 5527 parallaxAsset.find('.video-overlay').animate({ 5528 'opacity': 0.8 5529 }, 200); 5530 }, 100); 5531 5532 setTimeout(function() { 5533 parallaxContent.animate({ 5534 'opacity': 1, 5535 'top': '50%' 5536 }, 600, 'easeOutExpo'); 5537 }, 600); 5538 5539 parallaxAsset.attr('data-height-default', parallaxVideo.height()); 5540 5541 } else { 5542 SWIFT.parallax.scaleVideo(parallaxAsset); 5543 } 5544 5545 if ($window.width() < parallaxVideoWidth) {
5546 parallaxVideo.css('left', - (parallaxVideoWidth - $window.width()) /2); 5547 } 5548 5549 var videoInstance = parallaxVideo.get( 0 ); 5550 videoInstance.load(); 5551 videoInstance.addEventListener( 'loadeddata' , function() { 5552 SWIFT.parallax.parallaxVideoResize(parallaxAsset); 5553 } 5554 ); 5555 5556 }); 5557 }, 5558 parallaxVideoResize: function(parallaxAsset) { 5559 var parallaxContent = parallaxAsset.find('div:first'), 5560 parallaxAssetHeight = 0; 5561 5562 if (parallaxAsset.hasClass('parallax-window-height')) { 5563 if (parallaxContent.height() > $window.height()) { 5564 parallaxAssetHeight = parallaxContent.height(); 5565 } else { 5566 parallaxAssetHeight = $window.height(); 5567 } 5568 5569 parallaxAsset.animate({ 5570 'height': parallaxAssetHeight 5571 }, 400); 5572 } 5573 5574 SWIFT.parallax.scaleVideo(parallaxAsset); 5575 }, 5576 videoScroll: function(asset) { 5577 5578 var offsetTop = asset.offset().top, 5579 windowTop = $window.scrollTop(), 5580 defaultHeight = parseInt(asset.data('height-default'), 10), 5581 diff = windowTop - offsetTop, 5582 currentTop = asset.find('.spb_content_wrapper').css('top'), 5583 heightDifference = defaultHeight - diff * 1.5; 5584 5585 if (windowTop > offsetTop) { 5586 asset.css('height', heightDifference); 5587 asset.find('.spb_content_wrapper').css('opacity', 1 - (diff / 300)); 5588 if (asset.hasClass('parallax-window-height') && asset.data('v-center') === "true") { 5589 asset.find('.spb_content_wrapper').css('top', currentTop + (diff / 4)); 5590 } else if (asset.data('v-center') === "true") { 5591 asset.find('.spb_content_wrapper').css('top', (diff / 3)); 5592 } 5593 } else { 5594 asset.css('height', defaultHeight); 5595 asset.find('.spb_content_wrapper').css('opacity', 1); 5596 if (asset.hasClass('parallax-video-height') && asset.data('v-center') === "true") { 5597 asset.find('.spb_content_wrapper').css('top', '50%'); 5598 } else { 5599 asset.find('.spb_content_wrapper').css('top', 0); 5600 } 5601 } 5602 5603 }, 5604 scaleVideo: function(parallaxAsset) { 5605 5606 var video = parallaxAsset.find('video'); 5607 5608 if (typeof video === 'undefined' || typeof video[0] === 'undefined') { 5609 return; 5610 } 5611 5612 var assetHeight = parallaxAsset.outerHeight(), 5613 assetWidth = parallaxAsset.outerWidth(), 5614 videoWidth = video[0].videoWidth, 5615 videoHeight = video[0].videoHeight; 5616 5617 // Use the largest scale factor of horizontal/vertical 5618 var scale_h = assetWidth / videoWidth; 5619 var scale_v = assetHeight / videoHeight; 5620 var scale = scale_h > scale_v ? scale_h : scale_v; 5621 5622 // Update minium width to never allow excess space 5623 var min_w = videoWidth/videoHeight * (assetHeight+20); 5624 5625 // Don't allow scaled width < minimum video width 5626 if (scale * videoWidth < min_w) {scale = min_w / videoWidth;} 5627 5628 // Scale the video 5629 video.width(Math.ceil(scale * videoWidth +2)); 5630 video.height(Math.ceil(scale * videoHeight +50)); 5631 video.css('margin-top', - (video.height() - assetHeight) /2); 5632 video.css('margin-left', - (video.width() - assetWidth) /2); 5633 } 5634 }; 5635 5636 5637 ///////////////////////////////////////////// 5638 // MAP FUNCTIONS 5639 ///////////////////////////////////////////// 5640 5641 var infowindow, bounds, directory_bounds, mapTypeIdentifier = "", mapType, mapColor, mapSaturation, mapCenterLat, mapCenterLng, companyPos = "", isDraggable = true, latitude, longitude, mapCoordinates, markersArray = [], pinTitle, pinContent, pinLink, address, pinButtonText = ""; 5642 5643 5644 SWIFT.map = { 5645 init:function() { 5646 5647 var maps = jQuery('.map-canvas'); 5648 var mapContainer; 5649 5650 if (typeof google !== 'undefined') { 5651 bounds = new google.maps.LatLngBounds(); 5652 } 5653 5654 maps.each(function(i, element) { 5655 mapContainer = element; 5656 var mapZoom = mapContainer.getAttribute('data-zoom'), 5657 mapControls = mapContainer.getAttribute('data-controls') == "yes" ? true : false; 5658 5659 mapType = mapContainer.getAttribute('data-maptype'); 5660 mapColor = mapContainer.getAttribute('data-mapcolor'); 5661 mapCenterLat = mapContainer.getAttribute('data-center-lat'); 5662 mapCenterLng = mapContainer.getAttribute('data-center-lng'); 5663 mapSaturation = mapContainer.getAttribute('data-mapsaturation'); 5664
5665 SWIFT.map.createMap( mapContainer, mapZoom, mapControls, mapType, mapColor, mapSaturation, jQuery(this)); 5666 }); 5667 5668 }, 5669 getLatLong: function(address, pintit, pinimage, fn) { 5670 var geocoder; 5671 geocoder = new google.maps.Geocoder(); 5672 geocoder.geocode( { 'address': address }, function(results) { 5673 if ( results && results.length > 0 ) { 5674 fn(results[0].geometry.location, results[0].geometry.location.lat(), results[0].geometry.location.lng() , pintit, pinimage); 5675 } 5676 }); 5677 }, 5678 addWinContent: function(marker, html, map) { 5679 google.maps.event.addListener(marker, 'click', function() { 5680 infowindow.setContent(html); 5681 infowindow.open(map, marker); 5682 }); 5683 }, 5684 addMarker: function(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText) { 5685 var companyMarker; 5686 5687 mapCoordinates = new google.maps.LatLng(latitude, longitude); 5688 5689 if (pinLogoURL) { 5690 companyPos = new google.maps.LatLng(latitude, longitude); 5691 companyMarker = new google.maps.Marker({ 5692 position: mapCoordinates, 5693 map: mapInstance, 5694 icon: pinLogoURL, 5695 animation: google.maps.Animation.DROP }); 5696 } else { 5697 companyPos = new google.maps.LatLng(latitude, longitude); 5698 companyMarker = new google.maps.Marker({ 5699 position: mapCoordinates, 5700 map: mapInstance, 5701 animation: google.maps.Animation.DROP }); 5702 } 5703 5704 var html = '<div class="pinmarker">'; 5705 if (pinTitle !== "") { 5706 html += '<h3>'+pinTitle+'</h3>'; 5707 } 5708 if (pinContent !== "") { 5709 html += '<p>'+pinContent+' </p>'; 5710 } 5711 if (pinLink !== "" && pinButtonText !== "") { 5712 html += '<div><a href="' + pinLink + '" target="_blank">'+pinButtonText+'</a></div>'; 5713 } 5714 html += '</div>'; 5715 5716 infowindow = new google.maps.InfoWindow(); 5717 SWIFT.map.addWinContent(companyMarker, html, mapInstance); 5718 bounds.extend(mapCoordinates); 5719 }, 5720 createMap: function(mapContainer, mapZoom, mapControls, mapType, mapColor, mapSaturation, targetMap) { 5721 5722 if (typeof google == 'undefined') { 5723 return; 5724 } 5725 5726 directory_bounds = new google.maps.LatLngBounds(); 5727 5728 var pinLogoURL = "", mapLightness = false; 5729 5730 // MAP STYLES 5731 var stylesArray = [], 5732 isStyled = false; 5733 5734 if (jQuery(mapContainer).parent().find('.map-styles-array').length > 0) { 5735 stylesArray = jQuery(mapContainer).parent().find('.map-styles-array').text(); 5736 if ( stylesArray.length > 0 ) { 5737 isStyled = true; 5738 stylesArray = JSON.parse(jQuery(mapContainer).parent().find('.map-styles-array').text()); 5739 } 5740 } else { 5741 if (mapSaturation == "mono-light") { 5742 if (mapColor === "") { 5743 mapColor = "#ffffff"; 5744 } 5745 mapSaturation = -100; 5746 } else if (mapSaturation == "mono-dark") { 5747 if (mapColor === "") { 5748 mapColor = "#222222"; 5749 } 5750 mapSaturation = -100; 5751 mapLightness = true; 5752 } else { 5753 mapSaturation = -20; 5754 } 5755 stylesArray = [ 5756 { 5757 stylers: [ 5758 {hue: mapColor}, 5759 {"invert_lightness": mapLightness}, 5760 {saturation: mapSaturation} 5761 ] 5762 } 5763 ]; 5764 } 5765 5766 if (isMobileAlt) { 5767 isDraggable = false; 5768 } 5769 5770 if (mapType === "satellite") { 5771 mapTypeIdentifier = google.maps.MapTypeId.SATELLITE; 5772 } else if (mapType === "terrain") { 5773 mapTypeIdentifier = google.maps.MapTypeId.TERRAIN; 5774 } else if (mapType === "hybrid") { 5775 mapTypeIdentifier = google.maps.MapTypeId.HYBRID; 5776 } else { 5777 mapTypeIdentifier = google.maps.MapTypeId.ROADMAP; 5778 } 5779 5780 var options = { 5781 zoom: parseInt(mapZoom, 10), 5782 scrollwheel: false, 5783 draggable: isDraggable, 5784 mapTypeControl: true, 5785 disableDefaultUI: !mapControls, 5786 mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, 5787 navigationControl: true, 5788 navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, 5789 mapTypeId: mapTypeIdentifier, 5790 styles: stylesArray 5791 }; 5792 5793 var mapInstance = new google.maps.Map(mapContainer, options); 5794 var pincount = targetMap.parent().find('.pin_location').length; 5795 5796 //Resize Window Responsiveness 5797 google.maps.event.addDomListener(window, 'resize', function() { 5798 var center = mapInstance.getCenter(); 5799 google.maps.event.trigger(mapInstance, "resize"); 5800 mapInstance.setCenter(center); 5801 }); 5802 5803 bounds = new google.maps.LatLngBounds(); 5804 targetMap.parent().find('.pin_location').each(function(i, element) { 5805 5806 pinLogoURL = element.getAttribute('data-pinimage'); 5807 pinTitle = element.getAttribute('data-title'); 5808 pinContent = element.getAttribute('data-content'); 5809 address = element.getAttribute('data-address'); 5810 pinLink = element.getAttribute('data-pinlink'); 5811 latitude = element.getAttribute('data-lat'); 5812 longitude = element.getAttribute('data-lng'); 5813 pinButtonText = element.getAttribute('data-button-text'); 5814 5815 5816 if (latitude === '' && longitude === '') { 5817 5818 SWIFT.map.getLatLong(address, pinTitle, pinLogoURL ,function(location, lati,longi, pintit, pinimage ){ 5819 5820 latitude = lati; 5821 longitude = longi; 5822 pinTitle = pintit; 5823 pinLogoURL = pinimage; 5824 5825 SWIFT.map.addMarker(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText); 5826 5827 if ( pincount > 1 ) { 5828 if(mapCenterLat !== '' && mapCenterLng !== ''){
5829 mapInstance.setZoom(parseInt(mapZoom, 10)); 5830 mapInstance.setCenter(new google.maps.LatLng(mapCenterLat, mapCenterLng)); 5831 }else{ 5832 mapInstance.fitBounds(bounds); 5833 } 5834 } else { 5835 mapInstance.setZoom(parseInt(mapZoom, 10)); 5836 mapInstance.setCenter(new google.maps.LatLng(latitude, longitude)); 5837 } 5838 5839 }); 5840 5841 } else { 5842 5843 SWIFT.map.addMarker(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText); 5844 5845 if ( pincount > 1 ) { 5846 if(mapCenterLat !== '' && mapCenterLng !== ''){ 5847 mapInstance.setZoom(parseInt(mapZoom, 10)); 5848 mapInstance.setCenter(new google.maps.LatLng(mapCenterLat, mapCenterLng)); 5849 }else{ 5850 mapInstance.fitBounds(bounds); 5851 } 5852 } else { 5853 mapInstance.setZoom(parseInt(mapZoom, 10)); 5854 mapInstance.setCenter(new google.maps.LatLng(latitude, longitude)); 5855 } 5856 5857 } 5858 5859 }); 5860 } 5861 }; 5862 5863 5864 ///////////////////////////////////////////// 5865 // MAP DIRECTORY FUNCTIONS 5866 ///////////////////////////////////////////// 5867 5868 SWIFT.mapDirectory = { 5869 init : function(searchTerm, locationFilter, categoryFilter) { 5870 5871 searchTerm = jQuery('#dir-search-value').val(); 5872 locationFilter = jQuery('.directory-location-option').val(); 5873 categoryFilter = jQuery('.directory-category-option').val(); 5874 5875 var mapsDirectory = jQuery('.map-directory-canvas'); 5876 5877 mapsDirectory.each(function(i, element) { 5878 5879 var mapDirContainer = element, 5880 mapZoom = mapDirContainer.getAttribute('data-zoom'), 5881 mapType = mapDirContainer.getAttribute('data-maptype'), 5882 mapColor = mapDirContainer.getAttribute('data-mapcolor'), 5883 mapSaturation = mapDirContainer.getAttribute('data-mapsaturation'), 5884 mapExcerpt = mapDirContainer.getAttribute('data-excerpt'); 5885 5886 if ( categoryFilter === null || categoryFilter == 'All' ){ 5887 categoryFilter = mapDirContainer.getAttribute('data-directory-category'); 5888 } 5889 5890 5891 SWIFT.mapDirectory.directoryMap( mapDirContainer, mapZoom, mapType, mapColor, mapSaturation, jQuery(this), searchTerm, locationFilter, categoryFilter, mapExcerpt); 5892 5893 }); 5894 }, 5895 searchDirectory: function(){ 5896 SWIFT.mapDirectory.init(jQuery('#dir-search-value').val(), jQuery('.directory-location-option').val(), jQuery('.directory-category-option').val()); 5897 }, 5898 getLatLong: function(address, fn){ 5899 var geocoder; 5900 geocoder = new google.maps.Geocoder(); 5901 geocoder.geocode( { 'address': address }, function(results) { 5902 if ( results && results.length > 0 ) { 5903 fn(results[0].geometry.location, results[0].geometry.location.lat(), results[0].geometry.location.lng()); 5904 } 5905 }); 5906 }, 5907 addWinContent: function(marker, html, map) { 5908 markersArray.push(marker); 5909 google.maps.event.addListener(marker, 'click', function() { 5910 infowindow.setContent(html); 5911 infowindow.open(map, marker); 5912 }); 5913 }, 5914 addMarkerDir: function(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText,pinFeaturedImage, lat, lng){ 5915 var companyMarker, pinImgContainer; 5916 5917 mapCoordinates = new google.maps.LatLng(lat, lng); 5918 5919 if (pinLogoURL) { 5920 companyPos = new google.maps.LatLng(lat, lng); 5921 companyMarker = new google.maps.Marker({ 5922 position: mapCoordinates, 5923 map: mapInstance, 5924 icon: pinLogoURL, 5925 optimized: false, 5926 animation: google.maps.Animation.DROP }); 5927 } else { 5928 companyPos = new google.maps.LatLng(lat, lng); 5929 companyMarker = new google.maps.Marker({ 5930 position: mapCoordinates, 5931 map: mapInstance, 5932 animation: google.maps.Animation.DROP }); 5933 } 5934 if (pinFeaturedImage === null) { 5935 pinImgContainer = ''; 5936 } else { 5937 pinImgContainer = '<img class="info-window-img" alt="" src="'+pinFeaturedImage
5937+'" height="140" width="140"/>'; 5938 } 5939 5940 var html = ''; 5941 if (pinLink === '' || pinButtonText === '') { 5942 html = '<div class="pinmarker">'+pinImgContainer+'<div class="pinmarker-container"><h3>'+pinTitle+'</h3><div class="excerpt">'+pinContent+'</div></div></div>'; 5943 } else { 5944 html = '<div class="pinmarker">'+pinImgContainer+'<div class="pinmarker-container"><h3>'+pinTitle+'</h3><div class="excerpt">'+pinContent+'</div><a class="pin-button" href="' + pinLink + '" target="_blank">'+pinButtonText+'</a></div></div>'; 5945 } 5946 5947 5948 infowindow = new google.maps.InfoWindow(); 5949 SWIFT.mapDirectory.addWinContent(companyMarker, html, mapInstance); 5950 directory_bounds.extend(mapCoordinates); 5951 }, 5952 directoryMap: function(mapContainer, mapZoom, mapType, mapColor, mapSaturation, targetMap, searchTerm, locationFilter, categoryFilter, excerpt) { 5953 5954 var mapLightness = false; 5955 var mapResults = mapContainer.getAttribute('data-directory-map-results'); 5956 5957 //Only if we want to display the map 5958 if (mapResults !== 'list') { 5959 5960 if (mapSaturation == "mono-light") { 5961 if (mapColor === "") { 5962 mapColor = "#ffffff"; 5963 } 5964 mapSaturation = -100; 5965 } else if (mapSaturation == "mono-dark") { 5966 if (mapColor === "") { 5967 mapColor = "#222222"; 5968 } 5969 mapSaturation = -100; 5970 mapLightness = true; 5971 } else { 5972 mapSaturation = -20; 5973 } 5974 5975 var styles = [ 5976 { 5977 stylers: [ 5978 {hue: mapColor}, 5979 {"invert_lightness": mapLightness}, 5980 {saturation: mapSaturation} 5981 ] 5982 } 5983 ]; 5984 5985 var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"}); 5986 5987 if (isMobileAlt) { 5988 isDraggable = false; 5989 } 5990 5991 if (mapType === "satellite") { 5992 mapTypeIdentifier = google.maps.MapTypeId.SATELLITE; 5993 } else if (mapType === "terrain") { 5994 mapTypeIdentifier = google.maps.MapTypeId.TERRAIN; 5995 } else if (mapType === "hybrid") { 5996 mapTypeIdentifier = google.maps.MapTypeImapDirContainerd.HYBRID; 5997 } else { 5998 mapTypeIdentifier = google.maps.MapTypeId.ROADMAP; 5999 } 6000 6001 6002 } else { 6003 jQuery(mapContainer).hide(); 6004 } 6005 6006 directory_bounds = new google.maps.LatLngBounds(); 6007 6008 if (categoryFilter === "") { 6009 categoryFilter = mapContainer.getAttribute('data-directory-category'); 6010 } 6011 6012 //Ajax call to get the Directory Itens 6013 var data = { 6014 action: 'uplift_directory', 6015 search_term: searchTerm, 6016 location_term: locationFilter, 6017 category_term: categoryFilter, 6018 item_excerpt: excerpt 6019 6020 }; 6021 6022 jQuery.post(mapContainer.getAttribute('data-ajaxurl'), data, function(response) { 6023 var json = jQuery.parseJSON(response); 6024 var pincount = json.results; 6025 6026 jQuery('.directory-results').hide(); 6027 6028 var settings = { 6029 scrollwheel: false, 6030 draggable: isDraggable, 6031 mapTypeControl: true, 6032 mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, 6033 navigationControl: true, 6034 navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, 6035 mapTypeId: mapTypeIdentifier 6036 }; 6037 6038 if (pincount > 0) { 6039 6040 var mapInstance = new google.maps.Map(mapContainer, settings); 6041 markersArray = []; 6042 6043 // MAP COLOURIZE 6044 if (mapColor !== "" && mapResults != 'list') { 6045 mapInstance.mapTypes.set('map_style', styledMap); 6046 mapInstance.setMapTypeId('map_style'); 6047 } 6048 6049 //Resize Window Responsiveness 6050 google.maps.event.addDomListener(window, 'resize', function() { 6051 mapInstance.fitBounds(directory_bounds); 6052 mapInstance.setZoom(parseInt(mapZoom, 10)); 6053 }); 6054 6055 var resultText = ''; 6056 6057 if ( pincount > 1 ) { 6058 resultText = json.results_text_1 + ' '+pincount+' '+json.results_text_2plural; 6059 } else { 6060 resultText = json.results_text_1 + ' '+pincount+' '+json.results_text_2; 6061 } 6062 jQuery(mapContainer).parent().parent().parent().find('.directory-results').prepend('<div class="results-title"><h2>'+resultText+'</h2>'); 6063 6064 } else { 6065 6066 for (var i=0; i < markersArray.length; i++) { 6067 markersArray[i].setMap(null); 6068 } 6069 6070 jQuery(mapContainer).parent().parent().parent().find('.directory-results').append('<div class="results-title"><h2>
6070'+json.errormsg+'</h2>'); 6071 6072 } 6073 6074 if (pincount > 0 && mapResults != 'list') { 6075 6076 jQuery(mapContainer).show(); 6077 jQuery('.directory-results').append(json.pagination); 6078 6079 jQuery.each(json.items, function(i, item) { 6080 6081 //Get the directory itens details 6082 var pinTitle = item.pin_title, 6083 pinLogoURL = item.pin_logo_url, 6084 pinContent = item.pin_content, 6085 pinShortContent = item.pin_short_content, 6086 address = item.pin_address, 6087 pinLink = item.pin_link, 6088 pinButtonText = item.pin_button_text, 6089 latitude = item.pin_lat, 6090 longitude = item.pin_lng, 6091 pinThumbnail = item.pin_thumbnail, 6092 thumbnail_image = '', 6093 hasThumb = false, 6094 extra_class = ''; 6095 if ( excerpt !== '' ){ 6096 pinContent = pinShortContent; 6097 } 6098 6099 if (pinThumbnail && pinLink) { 6100 hasThumb = true; 6101 thumbnail_image = '<figure class="animated-overlay overlay-alt"><img itemprop="image" src="'+pinThumbnail+'" alt="'+pinTitle+'"><a href="'+pinLink+'" target="_blank" class="link-to-post"></a><div class="figcaption-wrap"></div><figcaption><div class="thumb-info"><h4>'+pinTitle+'</h4></div></figcaption></figure>'; 6102 } else if (pinThumbnail) { 6103 hasThumb = true; 6104 thumbnail_image = '<figure><img itemprop="image" src="'+pinThumbnail+'" alt="'+pinTitle+'"></figure>'; 6105 } 6106 6107 //Add the Directory List Results 6108 if (!hasThumb) { 6109 extra_class = 'no-thumb'; 6110 } 6111 6112 if ( mapResults != 'list') { 6113 6114 //Add directory item to the map 6115 SWIFT.mapDirectory.addMarkerDir(mapInstance, pinLogoURL, pinTitle, pinShortContent, pinLink, address, pinButtonText,pinThumbnail, latitude, longitude); 6116 6117 if ( pincount > 1 ) { 6118 mapInstance.fitBounds(directory_bounds); 6119 } else { 6120 mapInstance.setZoom(parseInt(mapZoom, 10)); 6121 mapInstance.setCenter(new google.maps.LatLng(latitude, longitude)); 6122 } 6123 } 6124 }); 6125 }else{ 6126 jQuery(mapContainer).hide(); 6127 } 6128 jQuery('.directory-results').show(); 6129 }); 6130 } 6131 }; 6132 6133 6134 ///////////////////////////////////////////// 6135 // CROWDFUNDING FUNCTIONS 6136 ///////////////////////////////////////////// 6137 6138 SWIFT.crowdfunding = { 6139 init:function() { 6140 6141 if (jQuery('#back-this-project').find('.edd_price_options').length <= 0) { 6142 jQuery('#back-this-project > h2').css('display', 'none'); 6143 } 6144 6145 if (jQuery('#back-this-project').hasClass('project-donate-only')) { 6146 jQuery('.edd_price_options').find('li').first().addClass('atcf-selected'); 6147 jQuery('.edd_price_options').find('li').first().find('input[type="radio"]').prop('checked', true); 6148 } 6149 6150 jQuery('.atcf-price-option').on('click', function() { 6151 6152 var selectedOption = jQuery(this), 6153 selectedPrice = selectedOption.data('price').substr(0, selectedOption.data('price').indexOf('-')); 6154 6155 if (selectedOption.hasClass('inactive')) { 6156 return false; 6157 } 6158 6159 if (selectedPrice && jQuery('#atcf_custom_price').val().length <= 0) { 6160 jQuery('#atcf_custom_price').val(selectedPrice); 6161 } 6162 jQuery('.atcf-price-option').find('input[type="radio"]').prop('checked', false); 6163 jQuery('.atcf-price-option').removeClass('atcf-selected'); 6164 selectedOption.find('input[type="radio"]').prop('checked', true); 6165 selectedOption.addClass('atcf-selected'); 6166 }); 6167 6168 var campaignItems = jQuery('.campaign-items:not(.carousel-items)'); 6169 campaignItems.imagesLoaded(function () { 6170 campaignItems.equalHeights(); 6171 }); 6172 6173 $window.smartresize( function() { 6174 jQuery('.campaign-items:not(.carousel-items)').children().css('min-height','0'); 6175 jQuery('.campaign-items:not(.carousel-items)').equalHeights(); 6176 }); 6177 6178 } 6179 }; 6180 6181 6182 ///////////////////////////////////////////// 6183 // RELOAD FUNCTIONS 6184 ///////////////////////////////////////////// 6185 6186 SWIFT.reloadFunctions = { 6187 init:function() { 6188 6189 // Remove title attributes from images to avoid showing on hover 6190 jQuery('img[title]').each(function() { 6191 jQuery(this).removeAttr('title'); 6192 }); 6193 6194 if (!isAppleDevice) { 6195 jQuery('embed').show(); 6196 } 6197 6198 // Animate Top Links 6199 jQuery('.animate-top').on('click', function(e) { 6200 e.preventDefault(); 6201 jQuery('body,html').animate({scrollTop: 0}, 800, 'easeOutCubic'); 6202 }); 6203 }, 6204 load:function() { 6205 if (!isMobileAlt) { 6206 6207 // Button hover tooltips 6208 jQuery('.tooltip').each( function() { 6209 jQuery(this).css( 'marginLeft', '-' + Math.round( (jQuery(this).outerWidth(true) / 2) ) + 'px' ); 6210 }); 6211 6212 jQuery('.comment-avatar').hover( function() { 6213 jQuery(this).find('.tooltip' ).stop().animate({ 6214 bottom: '44px', 6215 opacity: 1 6216 }, 500, 'easeInOutExpo'); 6217 }, function() { 6218 jQuery(this).find('.tooltip').stop().animate({ 6219 bottom: '25px', 6220 opacity: 0 6221 }, 400, 'easeInOutExpo'); 6222 }); 6223 6224 jQuery('.grid-image').hover( function() { 6225 jQuery(this).find('.tooltip' ).stop().animate({ 6226 bottom: '85px', 6227 opacity: 1 6228 }, 500, 'easeInOutExpo'); 6229 }, function() { 6230 jQuery(this).find('.tooltip').stop().animate({ 6231 bottom: '65px', 6232 opacity: 0 6233 }, 400, 'easeInOutExpo'); 6234 }); 6235 6236 } 6237 } 6238 }; 6239 6240 6241 ///////////////////////////////////////////// 6242 // GLOBAL VARIABLES 6243 ///////////////////////////////////////////// 6244 6245 var $window = jQuery(window), 6246 body = jQuery('body'), 6247 sfIncluded = jQuery('#sf-included'), 6248 sfOptionParams = jQuery('#sf-option-params'),
6249 windowheight = SWIFT.page.getViewportHeight(), 6250 deviceAgent = navigator.userAgent.toLowerCase(), 6251 isMobile = deviceAgent.match(/(iphone|ipod|android|iemobile)/), 6252 isMobileAlt = deviceAgent.match(/(iphone|ipod|ipad|android|iemobile)/), 6253 isAppleDevice = deviceAgent.match(/(iphone|ipod|ipad)/), 6254 isIEMobile = deviceAgent.match(/(iemobile)/), 6255 //isFirefox = navigator.userAgent.indexOf('Firefox') > -1, 6256 parallaxScroll = navigator.userAgent.indexOf('Safari') != -1 || navigator.userAgent.indexOf('Chrome') == -1, 6257 IEVersion = SWIFT.page.checkIE(), 6258 isRTL = body.hasClass('rtl') ? true : false, 6259 shopBagHovered = false, 6260 wishlistHovered = false, 6261 stickyHeaderTop = 0, 6262 sliderAuto = sfOptionParams.data('slider-autoplay') ? true : false, 6263 sliderSlideSpeed = sfOptionParams.data('slider-slidespeed'), 6264 sliderAnimSpeed = sfOptionParams.data('slider-animspeed'), 6265 lightboxControlArrows = sfOptionParams.data('lightbox-nav') === "arrows" ? true : false, 6266 lightboxThumbs = sfOptionParams.data('lightbox-thumbs') ? true : false, 6267 lightboxSkin = sfOptionParams.data('lightbox-skin') === "dark" ? "metro-black" : "metro-white", 6268 lightboxSharing = sfOptionParams.data('lightbox-sharing') ? true : false, 6269 hasProductZoom = jQuery('#sf-included').hasClass('has-productzoom') ? true : false, 6270 hasProductZoomMobile = jQuery('#sf-included').hasClass('has-productzoom-mobile') ? true : false, 6271 productZoomType = sfOptionParams.data('product-zoom-type') === "lens" ? "lens" : "inner", 6272 productSliderThumbsPos = sfOptionParams.data('product-slider-thumbs-pos') === "left" ? "left" : "bottom", 6273 productSliderVertHeight = sfOptionParams.data('product-slider-vert-height'), 6274 cartNotification = sfOptionParams.data('cart-notification'); 6275 6276 SWIFT.isScrolling = false; 6277 SWIFT.isResizing = false; 6278 SWIFT.sidebarAnimation = false; 6279 SWIFT.productSlider = false; 6280 SWIFT.offset = 0; 6281 SWIFT.wpadminbarheight = 0; 6282 SWIFT.timelineBlocks = jQuery(); 6283 SWIFT.timelineOffset = 0.8; 6284 6285 ///////////////////////////////////////////// 6286 // LOAD + READY FUNCTION 6287 ///////////////////////////////////////////// 6288 6289 SWIFT.onReady = { 6290 init: function(){ 6291 SWIFT.page.init(); 6292 SWIFT.sliders.init(); 6293 SWIFT.gallery.init(); 6294 if (jQuery('.sf-super-search').length > 0) { 6295 SWIFT.superSearch.init(); 6296 } 6297 if (jQuery('#header-section').length > 0) { 6298 SWIFT.header.init(); 6299 } 6300 SWIFT.nav.init(); 6301 6302 SWIFT.woocommerce.init(); 6303 6304 SWIFT.portfolio.init(); 6305 6306 if (jQuery('.portfolio-wrap').length > 0) { 6307 SWIFT.portfolio.infiniteScroll(); 6308 } 6309 if ( jQuery('.blog-wrap').length > 0 ) { 6310 SWIFT.blog.init(); 6311 } 6312 if (jQuery('.blog-items-wrap').length > 0) { 6313 SWIFT.blog.infiniteScroll(); 6314 } 6315 SWIFT.galleries.init(); 6316 SWIFT.widgets.init(); 6317 SWIFT.teamMembers.init(); 6318 if (jQuery('.carousel-items').length > 0) { 6319 SWIFT.carouselWidgets.init(); 6320 } 6321 SWIFT.parallax.init(); 6322 SWIFT.crowdfunding.init(); 6323 SWIFT.reloadFunctions.init(); 6324 } 6325 }; 6326 SWIFT.onLoad = { 6327 init: function(){ 6328 SWIFT.page.load(); 6329 6330 if (body.hasClass('sf-preloader')) { 6331 SWIFT.page.homePreloader(); 6332 } 6333 SWIFT.woocommerce.load(); 6334 if (body.hasClass('page-transitions')) { 6335 SWIFT.page.fadePageIn(); 6336 } 6337 6338 SWIFT.widgets.load(); 6339 6340 // Google Map 6341 if (jQuery('.map-canvas').length > 0) { 6342 SWIFT.map.init(); 6343 jQuery('ul.nav-tabs li a').click(function(){ 6344 var thisTabHref = jQuery(this).attr('href'); 6345 if (jQuery(thisTabHref).find('.spb_gmaps_widget').length > 0) { 6346 SWIFT.map.init(); 6347 } 6348 }); 6349 } 6350 6351 // Directory Map 6352 if (jQuery('.map-directory-canvas').length > 0) { 6353 SWIFT.mapDirectory.init('', '', ''); 6354 jQuery(document).on( "click", '#directory-search-button', function() { 6355 jQuery('.directory-search-form').submit(); 6356 }); 6357 jQuery('ul.nav-tabs li a').click(function(){ 6358 var thisTabHref = jQuery(this).attr('href'); 6359 if (jQuery(thisTabHref).find('.spb_gmaps_widget').length > 0) { 6360 SWIFT.mapDirectory.init('', '', ''); 6361 } 6362 }); 6363 } 6364 6365 SWIFT.reloadFunctions.load(); 6366 6367 if (sfIncluded.hasClass('stickysidebars') && jQuery('.sticky-widget').length > 0) { 6368 SWIFT.page.stickyWidget(false); 6369 } 6370 6371 } 6372 }; 6373
6374 jQuery(document).ready(SWIFT.onReady.init); 6375 jQuery(window).load(SWIFT.onLoad.init); 6376 6377})(jQuery); 6378 6379window.onpageshow = function(event) { 6380 if ( event.persisted && jQuery('body').hasClass("sf-preloader") ) { 6381 window.location.reload(); 6382 } 6383}; 6384 6385window.onunload = function(){ 6386 if (jQuery('body').hasClass("page-transitions") ) { 6387 var preloadTime = 1000; 6388 6389 if (jQuery('.parallax-window-height').length > 0) { 6390 preloadTime = 1200; 6391 } 6392 6393 jQuery('body').addClass('page-fading-in'); 6394 jQuery('#site-loading').css('opacity', '0'); 6395 6396 setTimeout(function() { 6397 jQuery('#site-loading').css('display', 'none'); 6398 jQuery('body').removeClass('page-fading-in'); 6399 }, preloadTime); 6400 } 6401};
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.