1/*global jQuery,google */ 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 // FITVIDS 21 //SWIFT.page.resizeVideos(); 22 23 // FITTEXT 24 //SWIFT.page.resizeHeadings(); 25 26 // HEADER SLIDER 27 if (jQuery('body').hasClass('header-below-slider') && jQuery('.home-slider-wrap').length > 0) { 28 SWIFT.page.headerSlider(); 29 } 30 31 // ONE PAGE NAV 32 if (jQuery('#one-page-nav').length > 0) { 33 SWIFT.page.onePageNav(); 34 } 35 36 // BACK TO TOP 37 if (jQuery('#back-to-top').length > 0) { 38 $window.scroll(function() { 39 SWIFT.page.backToTop(); 40 }); 41 } 42 43 // EXPANDING ASSETS 44 SWIFT.page.expandingAssets(); 45 46 // RECENT POSTS 47 if (jQuery('.recent-posts').length > 0) { 48 SWIFT.recentPosts.init(); 49 } 50 51 // MOVE MODALS TO BOTTOM OF PAGE 52 SWIFT.page.moveModals(); 53 54 // LOAD MAP ASSET ON MODAL CLICK 55 jQuery('a[data-toggle="modal"]').on('click', function() { 56 setTimeout(function() { 57 SWIFT.map.init(); 58 }, 300); 59 60 return true; 61 }); 62 63 // REFRESH MODAL IFRAME ON CLOSE (FOR VIDEOS) 64 SWIFT.page.modalClose(); 65 66 // REPLACE COMMENTS REPLY TITLE HTML 67 if (body.hasClass('single-post')) { 68 var replyTitle = jQuery('#respond').find('h3'); 69 var originalText = jQuery('#respond').find('h3').html(); 70 71 replyTitle.addClass('spb-heading'); 72 replyTitle.html('<span>'+originalText+'</span>'); 73 } 74 75 // SMOOTH SCROLL LINKS 76 SWIFT.page.smoothScrollLinks(); 77 78 // PORTFOLIO STICKY SIDEBAR 79 if (!isMobileAlt && jQuery('.sticky-details').length > 0) { 80 SWIFT.portfolio.stickyDetails(); 81 } 82 83 // BUDDYPRESS ACTIVITY LINK CLICK 84 jQuery('.activity-time-since,.bp-secondary-action').on('click', function(e) { 85 e.preventDefault(); 86 jQuery('.viewer').css('display', 'none'); 87 window.location = jQuery(this).attr('href'); 88 }); 89 90 // LOVE IT CLICK 91 jQuery('.love-it').on('click', function() { 92 SWIFT.page.loveIt(jQuery(this)); 93 return false; 94 }); 95 96 // ARTICLE SHARE 97 SWIFT.page.articleShare(); 98 99 // ARTICLE NAVIGATION 100 if (body.hasClass('article-swipe') && body.hasClass('single-post') && jQuery('.post-pagination-wrap').length > 0) { 101 SWIFT.page.articleNavigation(); 102 } 103 104 // ARTICLE WITH FULL WIDTH MEDIA TITLE 105 if (jQuery('article').hasClass('single-post-fw-media-title')) { 106 SWIFT.page.postMediaTitle(); 107 } 108 109 // RELATED POSTS 110 if (jQuery('.related-items').length > 0) { 111 SWIFT.relatedPosts.init(); 112 } 113 114 // LIGHTBOX 115 SWIFT.page.lightbox(); 116 117 // PAGE FADE OUT 118 if (body.hasClass('page-transitions')) { 119 SWIFT.page.pageTransitions(); 120 } 121 122 // DIRECTORY SUBMIT 123 SWIFT.page.directorySubmit(); 124 }, 125 load: function() { 126 127 // FANCY HEADING 128 if (jQuery('.fancy-heading').length > 0) { 129 SWIFT.page.fancyHeading(); 130 } 131 132 // STICKY SIDEBAR 133 if (!isMobileAlt && sfIncluded.hasClass('stickysidebars') && jQuery('.sidebar').length > 0) { 134 SWIFT.page.stickyWidget(); 135 } 136 137 // HASH CHECK 138 setTimeout(function() { 139 var urlHash = document.location.toString(); 140 if (urlHash.match('#')) { 141 var hash = urlHash.split('#')[1]; 142 if ( jQuery('#' + hash).length > 0 ) { 143 SWIFT.page.onePageNavGoTo('#' + hash); 144 } 145 } 146 }, 1200); 147 }, 148 browserCheck: function() { 149 jQuery.browser = {}; 150 jQuery.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase()); 151 jQuery.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase()); 152 jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase()); 153 jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase()); 154 jQuery.browser.msieMobile10 = /iemobile\/10\.0/.test(navigator.userAgent.toLowerCase()); 155 156 // BODY CLASSES 157 if (isMobileAlt) { 158 body.addClass("mobile-browser"); 159 } else { 160 body.addClass("standard-browser"); 161 } 162 if (isIEMobile) { 163 body.addClass("ie-mobile"); 164 } 165 if (isAppleDevice) { 166 body.addClass("apple-mobile-browser"); 167 } 168 if (body.hasClass("woocommerce-page") && !body.hasClass("woocommerce")) { 169 body.addClass("woocommerce"); 170 } 171 172 // ADD IE CLASS 173 if (IEVersion && IEVersion < 9) { 174 body.addClass('browser-ie'); 175 } 176 177 // ADD IE10 CLASS 178 var pattern = /MSIE\s([\d]+)/, 179 ua = navigator.userAgent, 180 matched = ua.match(pattern); 181 if (matched) { 182 body.addClass('browser-ie10'); 183 } 184 185 // ADD IE11 CLASS 186 if (!!navigator.userAgent.match(/Trident.*rv\:11\./)) { 187 body.addClass('browser-ie11'); 188 } 189 190 // ADD MOZILLA CLASS 191 if (jQuery.browser.mozilla) { 192 body.addClass('browser-ff'); 193 } 194 195 // ADD SAFARI CLASS
196 if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) { 197 body.addClass('browser-safari'); 198 } 199 }, 200 resizeVideos: function() { 201// jQuery('.blog-items:not(.carousel-items),article.type-portfolio,article.type-post,article.type-team,.spb_video_widget,.infocus-item,.full-width-detail,#activity-stream').fitVids({ ignore: '.no-fv'}); 202 }, 203 resizeHeadings: function() { 204 var h1FontSize = jQuery('h1:not(.logo-h1)').css('font-size'), 205 h2FontSize = jQuery('h2:not(.caption-title)').css('font-size'); 206 207 SWIFT.page.resizeHeadingsResize(h1FontSize, h2FontSize); 208 $window.smartresize( function() { 209 SWIFT.page.resizeHeadingsResize(h1FontSize, h2FontSize); 210 }); 211 }, 212 resizeHeadingsResize: function(h1FontSize, h2FontSize) { 213 if ($window.width() <= 768) { 214 if (h1FontSize) { 215 h1FontSize = h1FontSize.replace("px", ""); 216 var h1FontSizeMin = Math.floor(h1FontSize * 0.6); 217 jQuery('h1:not(.logo-h1)').fitText(1, { minFontSize: h1FontSizeMin + 'px', maxFontSize: h1FontSize +'px' }).css('line-height', '120%'); 218 } 219 220 if (h2FontSize) { 221 h2FontSize = h2FontSize.replace("px", ""); 222 var h2FontSizeMin = Math.floor(h2FontSize * 0.6); 223 jQuery('h2:not(.caption-title)').fitText(1, { minFontSize: h2FontSizeMin + 'px', maxFontSize: h2FontSize +'px' }).css('line-height', '120%'); 224 } 225 } else { 226 jQuery('h1:not(.logo-h1)').css('font-size', '').css('line-height', ''); 227 jQuery('h2:not(.caption-title)').css('font-size', '').css('line-height', ''); 228 } 229 }, 230 loveIt: function($this) { 231 var locale = jQuery('#loveit-locale'), 232 post_id = $this.data('post-id'), 233 user_id = $this.data('user-id'), 234 action = 'love_it'; 235 236 if ($this.hasClass('loved')) { 237 action = 'unlove_it'; 238 } 239 if (locale.data('loggedin') == 'false' && jQuery.cookie('loved-' + post_id)) { 240 action = 'unlove_it'; 241 } 242 243 var data = { 244 action: action, 245 item_id: post_id, 246 user_id: user_id, 247 love_it_nonce: locale.data('nonce') 248 }; 249 250 jQuery.post(locale.data('ajaxurl'), data, function(response) { 251 var ajaxResponse = jQuery.trim(response), 252 count_wrap, 253 count; 254 255 if (ajaxResponse == 'loved') { 256 $this.addClass('loved'); 257 count_wrap = $this.find('data.count'); 258 count = count_wrap.text(); 259 count_wrap.text(parseInt(count) + 1); 260 if(locale.data('loggedin') == 'false') { 261 jQuery.cookie('loved-' + post_id, 'yes', { expires: 1 }); 262 } 263 } else if (ajaxResponse == 'unloved') { 264 $this.removeClass('loved'); 265 count_wrap = $this.find('data.count'); 266 count = count_wrap.text(); 267 count_wrap.text(parseInt(count) - 1); 268 if (locale.data('loggedin') == 'false') { 269 jQuery.cookie('loved-' + post_id, 'no', { expires: 1 }); 270 } 271 } else { 272 alert(locale.data('error')); 273 } 274 }); 275 }, 276 expandingAssets: function() { 277 jQuery('.spb-row-expand-text').on('click', '', function(e) { 278 e.preventDefault(); 279 var expand = jQuery(this), 280 expandRow = expand.next(); 281 282 if (expandRow.hasClass('spb-row-expanding-open') && !expandRow.hasClass('spb-row-expanding-active')) { 283 expandRow.addClass('spb-row-expanding-open').addClass('spb-row-expanding-active').slideUp(800); 284 setTimeout(function() { 285 expand.removeClass('row-open').find('span').text(expand.data('closed-text')); 286 expandRow.css('display', 'block').removeClass('spb-row-expanding-open').removeClass('spb-row-expanding-active'); 287 }, 800); 288 } else if (!expandRow.hasClass('spb-row-expanding-active')) { 289 expand.addClass('row-open').find('span').text(expand.data('open-text'));
290 expandRow.css('display', 'none').addClass('spb-row-expanding-open').addClass('spb-row-expanding-active').slideDown(800); 291 setTimeout(function() { 292 expandRow.removeClass('spb-row-expanding-active'); 293 }, 800); 294 } 295 296 }); 297 }, 298 headerSlider: function() { 299 300 // SET LOADING INDICATOR 301 jQuery('#site-loading').css('display', 'block'); 302 303 var sliderHeight = 0; 304 305 if (jQuery('.home-slider-wrap').find('.rev_slider_wrapper').length > 0) { 306 sliderHeight = jQuery('.home-slider-wrap').find('.rev_slider_wrapper').height(); 307 } else { 308 sliderHeight = jQuery('.home-slider-wrap').height(); 309 } 310 311 // SET SLIDER POSITION & HEIGHT 312 jQuery('.home-slider-wrap').css('position', 'fixed').css('height', sliderHeight); 313 314 jQuery('#container').css('top', sliderHeight); 315 setTimeout(function() { 316 jQuery('#site-loading').fadeOut(1000); 317 }, 250); 318 319 // RESIZE SLIDER HEIGHT 320 $window.smartresize( function() { 321 jQuery('#container').css('top', jQuery('.home-slider-wrap').height()); 322 }); 323 324 // CONTINUE LINK 325 jQuery('a#slider-continue').on('click', function(e) { 326 327 // Prevent default anchor action 328 e.preventDefault(); 329 330 // Animate scroll to main content 331 jQuery('html, body').stop().animate({ 332 scrollTop: jQuery('#container').css('top') 333 }, 1500, 'easeInOutExpo'); 334 335 }); 336 }, 337 fancyHeading: function() { 338 var fancyHeading = jQuery('.fancy-heading'), 339 fancyHeadingText = fancyHeading.find('.heading-text'), 340 fancyHeadingTextHeight = fancyHeadingText.height(), 341 fancyHeadingHeight = parseInt(fancyHeading.data('height'), 10), 342 header = jQuery('.header-wrap'), 343 headerHeight = 0; 344 345 if (body.hasClass('header-naked-light') || body.hasClass('header-naked-dark')) { 346 headerHeight = header.height(); 347 } 348 349 if (!fancyHeadingHeight) { 350 fancyHeadingHeight = 400; 351 } 352 353 if (fancyHeadingTextHeight > fancyHeadingHeight) { 354 fancyHeadingHeight = fancyHeadingTextHeight + 80; 355 } 356 357 fancyHeadingHeight = fancyHeadingHeight + headerHeight; 358 359 // Vertically center the heading text 360 fancyHeadingText.vCenterTop(); 361 362 // Animate in the heading text and title 363 setTimeout(function() { 364 fancyHeading.css({ 365 'height': fancyHeadingHeight + 'px', 366 'opacity': 1 367 }); 368 }, 400); 369 setTimeout(function() { 370 fancyHeadingText.css('opacity', 1); 371 }, 800); 372 setTimeout(function() { 373 fancyHeading.addClass('animated'); 374 }, 1400); 375 376 // Check if parallax scroll is possible 377 if (parallaxScroll && !isMobileAlt) { 378 $window.scroll(function(){ 379 380 var scrollTop = $window.scrollTop(), 381 headingOffset = 0; 382 383 if (jQuery('.sticky-header').length > 0) { 384 headingOffset = jQuery('#header-section').height(); 385 } 386 if (jQuery('#top-bar').length > 0) { 387 headingOffset = headingOffset + jQuery('#top-bar').height(); 388 } 389 if (jQuery('#wpadminbar').length > 0) { 390 headingOffset = headingOffset + 32; 391 } 392 393 scrollTop = scrollTop - headingOffset; 394 395 // Only scroll if the heading is makes sense to do so 396 if (scrollTop < jQuery(document).height() - $window.height()) { 397 398 if (scrollTop < 0) { 399 scrollTop = 0; 400 } 401 402 // Reduce the heading height 403 fancyHeading.stop(true,true).transition({ 404 top: scrollTop / 1.8 405 }, 0); 406 407 // Move & fade the heading content 408 fancyHeadingText.stop(true,true).transition({ 409 opacity: 1 - scrollTop / 420 410 }, 0); 411 } 412 413 }); 414 } 415 }, 416 moveModals: function() { 417 jQuery(".modal").each(function(){ 418 jQuery(this).appendTo("body"); 419 }); 420 }, 421 modalClose: function() {
422 jQuery(".modal-backdrop, .modal .close, .modal .btn").on("click", function() { 423 jQuery(".modal iframe").each(function() { 424 var thisModal = jQuery(this); 425 thisModal.attr("src", thisModal.attr("src")); 426 }); 427 }); 428 }, 429 smoothScrollLinks: function() { 430 body.on('click', '.smooth-scroll-link', function(e) { 431 432 var linkHref = jQuery(this).attr('href'), 433 linkOffset = jQuery(this).data('offset') ? jQuery(this).data('offset') : 0; 434 435 if (linkHref && linkHref.indexOf('#') === 0) { 436 var headerHeight = 0; 437 438 if (jQuery('.sticky-header').length > 0) { 439 headerHeight = jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height(); 440 } 441 if (jQuery('#wpadminbar').length > 0) { 442 headerHeight = headerHeight + 32; 443 } 444 if (jQuery('.sticky-top-bar').length > 0) { 445 headerHeight = headerHeight + jQuery('.sticky-top-bar').height() > 0 ? jQuery('.sticky-top-bar').height() : jQuery('#top-bar').height(); 446 } 447 448 if ( isMobile || isMobileAlt ) { 449 450 if (jQuery('.sticky-top-bar').length > 0) { 451 headerHeight = headerHeight - jQuery('.sticky-top-bar').height() > 0 ? jQuery('.sticky-top-bar').height() : jQuery('#top-bar').height(); 452 } 453 if (jQuery('#mobile-header').length > 0) { 454 headerHeight = headerHeight - jQuery('#mobile-header').height(); 455 } 456 if (jQuery('#wpadminbar').length > 0) { 457 headerHeight = headerHeight - 46; 458 } 459 headerHeight = headerHeight - 24; 460 461 } 462 463 SWIFT.isScrolling = true; 464 jQuery('html, body').stop().animate({ 465 scrollTop: jQuery(linkHref).offset().top - headerHeight + linkOffset 466 }, 1000, 'easeInOutExpo', function() { 467 SWIFT.isScrolling = false; 468 }); 469 470 e.preventDefault(); 471 472 } else { 473 return e; 474 } 475 476 }); 477 }, 478 onePageNav: function() { 479 480 var onePageNav = jQuery('#one-page-nav'), 481 onePageNavType = onePageNav.hasClass('opn-arrows') ? "arrows" : "standard", 482 onePageNavItems = "", 483 pageSectionCount = 0, 484 mainContent = jQuery('.page-content'); 485 486 mainContent.find('section.row').each(function() { 487 var linkID = jQuery(this).attr('id'), 488 linkName = jQuery(this).data('rowname'); 489 490 if (linkID && linkName.length > 0 && jQuery(this).height() > 0) { 491 onePageNavItems += '<li><a href="#'+linkID+'" data-title="'+linkName+'"><i></i></a><div class="hover-caption">'+linkName+'</div></li>'; 492 pageSectionCount++; 493 } 494 }); 495 496 if (pageSectionCount > 0) { 497 onePageNav.append('<ul>'+onePageNavItems+'</ul>'); 498 499 if (onePageNavType === "arrows") { 500 onePageNav.find('ul').css('display', 'none'); 501 onePageNav.append('<a href="#" class="opn-up"><i class="ss-up"></i></a>'); 502 onePageNav.append('<div class="opn-status"><span class="current">1</span>/<span class="total">'+pageSectionCount+'</span></div>'); 503 onePageNav.append('<a href="#" class="opn-down"><i class="ss-down"></i></a>'); 504 } 505 506 onePageNav.vCenter(); 507 setTimeout(function() { 508 509 SWIFT.page.onePageNavScroll(onePageNav); 510 511 onePageNav.css('display', 'block').stop().animate({ 512 'right': '0', 513 'opacity': 1 514 }, 1000, "easeOutQuart"); 515 516 // Nav Dots 517 jQuery('#one-page-nav ul li a').bind('click', function(e) { 518 SWIFT.page.onePageNavGoTo(jQuery(this).attr('href')); 519 e.preventDefault(); 520 }); 521 522 // Up Arrow 523 jQuery('#one-page-nav a.opn-up').bind('click', function(e) { 524 var currentSection = parseInt(jQuery('.opn-status .current').text(), 10), 525 prevSection = currentSection - 1, 526 prevSectionHref = jQuery('#one-page-nav ul li:nth-child('+ prevSection +') > a').attr('href'); 527 528 if (prevSection > 0) { 529 SWIFT.page.onePageNavGoTo(prevSectionHref); 530 } 531 e.preventDefault(); 532 }); 533 534 // Down Arrow 535 jQuery('#one-page-nav a.opn-down').bind('click', function(e) { 536 var currentSection = parseInt(jQuery('.opn-status .current').text(), 10), 537 nextSection = currentSection + 1, 538 nextSectionHref = jQuery('#one-page-nav ul li:nth-child('+ nextSection +') > a').attr('href'); 539 540 if (nextSection <= pageSectionCount) { 541 SWIFT.page.onePageNavGoTo(nextSectionHref); 542 } 543 e.preventDefault(); 544 });
545 546 // Assign current on init and scroll 547 SWIFT.page.onePageNavScroll(onePageNav); 548 $window.on('scroll', function() { 549 SWIFT.page.onePageNavScroll(onePageNav); 550 }); 551 552 }, 1000); 553 } 554 }, 555 onePageNavGoTo: function(anchor) { 556 557 var adjustment = 0; 558 559 if (jQuery('#wpadminbar').length > 0) { 560 adjustment = jQuery('#wpadminbar').height(); 561 } 562 563 if (body.hasClass('sticky-header-enabled')) { 564 adjustment = jQuery('.sticky-header').outerHeight() > 0 ? adjustment + jQuery('.sticky-header').outerHeight() : adjustment + jQuery('#header-section').outerHeight(); 565 } 566 567 if (jQuery('.sticky-top-bar').length > 0) { 568 adjustment += jQuery('.sticky-top-bar').height() > 0 ? adjustment + jQuery('.sticky-top-bar').height() : adjustment + jQuery('#top-bar').height(); 569 } 570 571 SWIFT.isScrolling = true; 572 573 jQuery('html, body').stop().animate({ 574 scrollTop: jQuery(anchor).offset().top - adjustment + 1 575 }, 1000, 'easeInOutExpo', function() { 576 SWIFT.isScrolling = false; 577 }); 578 }, 579 onePageNavScroll: function(onePageNav) { 580 581 var adjustment = 0; 582 583 if (body.hasClass('sticky-header-enabled')) { 584 adjustment = jQuery('.sticky-header').height() > 0 ? adjustment + jQuery('.sticky-header').height() : adjustment + jQuery('#header-section').height(); 585 } 586 587 if (jQuery('#wpadminbar').length > 0) { 588 adjustment = adjustment + jQuery('#wpadminbar').height(); 589 } 590 591 if (jQuery('.sticky-top-bar').length > 0) { 592 adjustment += jQuery('.sticky-top-bar').height() > 0 ? adjustment + jQuery('.sticky-top-bar').height() : adjustment + jQuery('#top-bar').height(); 593 } 594 595 var currentSection = jQuery('section.row:in-viewport('+adjustment+')').data('rowname'), 596 currentSectionIndex = 0; 597 598 if (!currentSection) { 599 onePageNav.find('li').removeClass('selected'); 600 } 601 602 if (onePageNav.is(':visible') && currentSection) { 603 onePageNav.find('li').removeClass('selected'); 604 onePageNav.find('li a[data-title="'+currentSection+'"]').parent().addClass('selected'); 605 currentSectionIndex = onePageNav.find('li a[data-title="'+currentSection+'"]').parent().index() + 1; 606 } 607 608 if (currentSectionIndex > 0) { 609 jQuery('.opn-status .current').text(currentSectionIndex); 610 } 611 612 if (onePageNav.hasClass('opn-arrows')) { 613 var current = onePageNav.find('.current').text(), 614 total = onePageNav.find('.total').text(); 615 616 if (current === "1") { 617 onePageNav.find('.opn-up').addClass('disabled'); 618 } else { 619 onePageNav.find('.opn-up').removeClass('disabled'); 620 } 621 622 if (current === total) { 623 onePageNav.find('.opn-down').addClass('disabled'); 624 } else { 625 onePageNav.find('.opn-down').removeClass('disabled'); 626 } 627 } 628 }, 629 articleShare: function() { 630 jQuery('.article-share').each(function() { 631 var articleShare = jQuery(this), 632 image = articleShare.data('image'), 633 permalink = window.location.href, 634 title = encodeURIComponent(jQuery(document).find("title").text()), 635 links = ''; 636 637 links += '<li class="pinterest enabled" data-network="pinterest"><a href="http://pinterest.com/pin/create/button/?url=' + permalink + '&media=' + image + '&description=' + title + '" onclick="javascript:window.open(this.href, \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=690,width=750\');return false;"></a></li>'; 638 links += '<li class="twitter enabled" data-network="twitter"><a href="http://twitter.com/share?text=' + title + '&url=' + permalink + '" onclick="javascript:window.open(this.href, \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=440,width=660\');return false;"></a></li>'; 639 links += '<li class="facebook enabled" data-network="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=' + permalink + '" onclick="javascript:window.open(this.href, \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=440,width=660\');return false;"></a></li>'; 640 if ( isMobile ) { 641 links += '<li class="whatsapp enabled" data-network="whatsapp"><a href="whatsapp://send?text=' + title + ' ' + permalink + '"></a></li>'; 642 } 643 links += '<li class="googlePlus enabled" data-network="googlePlus"><a href="https://plus.google.com/share?url=' + permalink + '" onclick="javascript:window.open(this.href, \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=440,width=660\');return false;"></a></li>'; 644 //links += '<li class="reddit enabled" data-network="reddit">
644<a onclick="return false"></a></li>'; 645 links += '<li class="linkedin enabled" data-network="linkedin"><a href="https://www.linkedin.com/shareArticle?mini=true&url=' + permalink + '&title=' + title + '" onclick="javascript:window.open(this.href, \'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=690,width=750\');return false;"></a></li>'; 646 links += '<li class="email enabled" data-network="email"><a href="mailto:?subject=' + title + '&body=' + permalink + '"></a></li>'; 647 648 articleShare.find('share-button').append('<span>' + articleShare.data('buttontext') + '</span>'); 649 articleShare.find('share-button').append('<div class="sb-social sb-top sb-center"><ul>' + links + '</ul></div>'); 650 651 articleShare.find('share-button').on('click', function() { 652 jQuery(this).find('.sb-social').toggleClass('active'); 653 }); 654 }); 655 }, 656 articleNavigation: function() { 657 var postPagination = jQuery('.post-pagination-wrap'), 658 postNext = postPagination.find('.next-article > h2 > a').attr('href'), 659 postPrev = postPagination.find('.prev-article > h2 > a').attr('href'); 660 661 jQuery('article.type-post').hammer().on("swipeleft", function(event) { 662 if (postPrev) { 663 window.location = postPrev; 664 } 665 }); 666 667 jQuery('article.type-post').hammer().on("swiperight", function(event) { 668 if (postNext) { 669 window.location = postNext; 670 } 671 }); 672 673 }, 674 postMediaTitle: function() { 675 var detailsOverlay = jQuery('.details-overlay'), 676 detailFeature = jQuery('.detail-feature'), 677 featureHeight = detailsOverlay.height() + 80; 678 679 if (body.hasClass('header-naked-light') || body.hasClass('header-naked-dark')) { 680 detailFeature.css('padding-top', jQuery('.header-wrap').height() * 2); 681 } 682 683 detailFeature.css('height', featureHeight); 684 setTimeout(function() { 685 jQuery('.details-overlay').vCenter().stop().animate({ 686 'bottom': '50%', 687 'opacity': 1 688 }, 1500, "easeOutExpo"); 689 }, 500); 690 691 $window.smartresize( function() { 692 detailFeature.css('height', detailsOverlay.height() + 80); 693 jQuery('.details-overlay').vCenter(); 694 }); 695 696 }, 697 lightbox: function() { 698 699 // Lightbox Social 700 var lightboxSocial = {}; 701 if (lightboxSharing) { 702 lightboxSocial = { 703 facebook: { 704 source: 'https://www.facebook.com/sharer/sharer.php?u={URL}', 705 text: 'Share on Facebook' 706 }, 707 twitter: true, 708 googleplus: true, 709 pinterest: { 710 source: "https://pinterest.com/pin/create/button/?url={URL}&media={URL}", 711 text: "Share on Pinterest" 712 } 713 }; 714 } 715 716 // Lightbox Galleries 717 var galleryArr = []; 718 jQuery('[data-rel^="ilightbox["]').each(function () { 719 var attr = this.getAttribute("data-rel"); 720 if ( jQuery(this).hasClass( 'ilightbox-enabled' ) ) { 721 return; 722 } 723 if (jQuery.inArray(attr, galleryArr) == -1 ) { 724 galleryArr.push(attr); 725 } 726 }); 727 jQuery.each(galleryArr, function (b, c) { 728 jQuery('[data-rel="' + c + '"]').iLightBox({ 729 skin: lightboxSkin, 730 social: { 731 buttons: lightboxSocial 732 }, 733 path: 'horizontal', 734 thumbnails: { 735 maxWidth: 120, 736 maxHeight: 120 737 }, 738 controls: { 739 arrows: lightboxControlArrows, 740 thumbnail: lightboxThumbs 741 }, 742 }); 743 jQuery('[data-rel="' + c + '"]').addClass( 'ilightbox-enabled' ); 744 }); 745 }, 746 backToTop: function() { 747 var scrollPosition = $window.scrollTop(); 748 749 if (scrollPosition > 300) { 750 jQuery('#back-to-top').stop().animate({ 751 'bottom': '10px', 752 'opacity': 1 753 }, 300, "easeOutQuart"); 754 } else if (scrollPosition < 300) { 755 jQuery('#back-to-top').stop().animate({ 756 'bottom': '-80px', 757 'opacity': 0 758 }, 300, "easeInQuart"); 759 } 760 }, 761 stickyWidget: function() { 762 763 var stickyWidget = jQuery('.sidebar-widget-wrap'), 764 sidebar = stickyWidget.parent(), 765 content = jQuery('.page-content'), 766 offset = 50; 767 768 if (!body.hasClass('vertical-header')) { 769 offset = offset + jQuery('#header-section').height(); 770 } 771 if (jQuery('#wpadminbar').length > 0) { 772 offset = offset + 32; 773 } 774 if (jQuery('#top-bar').length > 0) { 775 offset = offset + jQuery('#top-bar').height(); 776 } 777 if (jQuery('.page-heading').length > 0) { 778 offset = offset + jQuery('.page-heading').height(); 779 } 780 781 SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset); 782 783 $window.smartresize( function() { 784 jQuery('.inner-page-wrap').stickem().destroy(); 785 SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); 786 SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset); 787 }); 788 789 }, 790 initStickyWidget: function(stickyWidget, sidebar, offset) { 791 jQuery('.inner-page-wrap').stickem({ 792 item: '.sidebar-widget-wrap', 793 container: '.inner-page-wrap', 794 offset: offset, 795 onStick: function() { 796 SWIFT.page.resizeStickyWidget(stickyWidget, sidebar); 797 } 798 }); 799 }, 800 resizeStickyWidget: function(stickyWidget, sidebar) { 801 var headerHeight = 0, 802 content = jQuery('.page-content'), 803 sidebarHeight = sidebar.height(), 804 contentHeight = content.height(); 805 806 if (jQuery('.sticky-header').length > 0) { 807 headerHeight = jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height(); 808 } 809 if (jQuery('#wpadminbar').length > 0) { 810 headerHeight = headerHeight + 32; 811 } 812 stickyWidget.css('width', sidebar.width()).css('top', headerHeight + 30); 813 if (contentHeight > sidebarHeight) { 814 sidebar.css('height', contentHeight); 815 } else { 816 sidebar.css('height', sidebarHeight); 817 } 818 },
819 getViewportHeight: function() { 820 var height = "innerHeight" in window ? window.innerHeight: document.documentElement.offsetHeight; 821 return height; 822 }, 823 checkIE: function() { 824 var undef, 825 v = 3, 826 div = document.createElement('div'), 827 all = div.getElementsByTagName('i'); 828 829 while ( 830 div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', 831 all[0] 832 ); 833 834 return v > 4 ? v : undef; 835 }, 836 pageTransitions: function() { 837 jQuery('a').on('click', function(e) { 838 var linkElement = jQuery(this), 839 link = linkElement.attr('href'), 840 linkTarget = linkElement.attr('target'), 841 parentMenuItem = linkElement.parent(), 842 subMenu = parentMenuItem.find('ul.sub-menu'); 843 844 // Return if is tab click 845 if (linkElement.data('toggle') === "tab" || linkElement.parent('.ui-accordion-header').length > 0) { 846 return e; 847 } 848 849 if (link.indexOf('#') === 0 && link.length > 1) { 850 SWIFT.isScrolling = true; 851 SWIFT.page.onePageNavGoTo(link); 852 setTimeout(function() { 853 SWIFT.isScrolling = false; 854 }, 1000); 855 e.preventDefault(); 856 } else if (link.indexOf('#') === 0 && link.length === 1) { 857 return; 858 } 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) { 859 return e; 860 } else { 861 if (body.hasClass('mobile-menu-open') || body.hasClass('mh-overlay-show')) { 862 return; 863 } else { 864 SWIFT.page.fadePageOut(link); 865 e.preventDefault(); 866 } 867 } 868 }); 869 }, 870 fadePageIn: function() { 871 body.addClass('page-fading-in'); 872 jQuery('#site-loading').animate({ 873 'opacity': 0, 874 }, 400, 'easeInExpo', function() { 875 jQuery(this).css('display', 'none'); 876 }); 877 setTimeout(function() { 878 jQuery('#main-container').animate({ 879 'opacity': 1, 880 'paddingTop': '0' 881 }, 500, 'easeOutExpo', function() { 882 body.removeClass('page-fading-in'); 883 }); 884 }, 100); 885 }, 886 fadePageOut: function(link) { 887 var ptop = '150px'; 888 889 if (body.hasClass('header-naked-light') || body.hasClass('header-naked-dark')) { 890 ptop = '0px'; 891 } 892 893 jQuery('#site-loading').css('display', 'block').animate({ 894 'opacity': 1, 895 }, 400, 'easeInExpo'); 896 jQuery('#main-container').animate({ 897 'opacity': 0, 898 'paddingTop': ptop 899 }, 500, 'easeInExpo', function() { 900 window.location = link; 901 }); 902 }, 903 directorySubmit: function() { 904 jQuery('#sf_directory_calculate_coordinates').on("click", function(e) { 905 e.preventDefault(); 906 var geocoder = new google.maps.Geocoder(); 907 geocoder.geocode( { 'address': jQuery('#sf_directory_address').val()}, function(results, status) { 908 jQuery('#sf_directory_lat_coord').val(results[0].geometry.location.lat()); 909 jQuery('#sf_directory_lng_coord').val(results[0].geometry.location.lng()); 910 }); 911 912 }); 913 914 jQuery('#directory-submit').click(function(e) { 915 916 if (jQuery('#sf_directory_address').val() === '' || jQuery('#sf_directory_lat_coord').val() === '' || jQuery('sf_directory_lng_coord').val() === '' || jQuery('#directory_title').val() === '' || jQuery('#directory_description').val() === '' || jQuery('#directory-cat').val() <= 0 || jQuery('#directory-loc').val() <= 0) { 917 e.preventDefault(); 918 jQuery('.directory-error').show(); 919 jQuery('html, body').animate({ scrollTop: jQuery('.directory-error').offset().top-100}, 700); 920 return false; 921 } 922 jQuery('#add-directory-entry').submit(); 923 }); 924 } 925 }; 926 927 928 ///////////////////////////////////////////// 929 // SUPER SEARCH 930 ///////////////////////////////////////////// 931 932 SWIFT.superSearch = { 933 init: function() { 934 935 jQuery('.search-options .ss-dropdown').on('click', function(e) { 936 e.preventDefault(); 937 938 var option = jQuery(this), 939 dropdown = option.find( 'ul' ); 940 941 if (isMobileAlt) { 942 if (dropdown.hasClass('show-dropdown')) { 943 dropdown.removeClass('show-dropdown'); 944 } else { 945 dropdown.addClass('show-dropdown'); 946 } 947 } else { 948 if (dropdown.hasClass('show-dropdown')) { 949 dropdown.css('top', 30); 950 dropdown.removeClass('show-dropdown'); 951 } else { 952 dropdown.css('top', -10); 953 dropdown.addClass('show-dropdown'); 954 } 955 } 956 }); 957 958 jQuery('.ss-option').on('click', function(e) { 959 e.preventDefault(); 960 961 var selectedOption = jQuery(this).attr('data-attr_value'); 962 var parentOption = jQuery(this).parent().parent().parent(); 963 964 parentOption.find('li').removeClass('selected'); 965 jQuery(this).parent().addClass('selected'); 966 967 parentOption.attr('data-attr_value', selectedOption); 968 parentOption.find('span').text(jQuery(this).text()); 969 }); 970 971 jQuery('.super-search-go').on('click', function(e) { 972 e.preventDefault(); 973 var parentSearch = jQuery(this).parents('.sf-super-search'), 974 filterURL = SWIFT.superSearch.urlBuilder(parentSearch), 975 homeURL = jQuery(this).attr('data-home_url'), 976 shopURL = jQuery(this).attr('data-shop_url'); 977 978 if (filterURL.indexOf("product_cat") >= 0) { 979 location.href = homeURL + filterURL; 980 } else { 981 location.href = shopURL + filterURL; 982 } 983 984 }); 985 }, 986 urlBuilder: function(searchInstance) { 987 988 var queryString = ""; 989 990 jQuery(searchInstance).find('.search-options .ss-dropdown').each(function() { 991 992 var attr = jQuery(this).attr('id'); 993 var attrValue = jQuery(this).attr('data-attr_value'); 994 if (attrValue !== "") { 995 if (attr === "product_cat") { 996 if (queryString === "") { 997 queryString += "?product_cat=" + attrValue; 998 } else { 999 queryString += "&product_cat=" + attrValue; 1000 } 1001 } else { 1002 if (queryString === "") { 1003 queryString += "?filter_" + attr + "=" + attrValue; 1004 } else { 1005 queryString += "&filter_" + attr + "=" + attrValue; 1006 } 1007 } 1008 } 1009 }); 1010 1011 jQuery('.search-options input').each(function() { 1012 var attr = jQuery(this).attr('name'); 1013 var attrValue = jQuery(this).attr('value'); 1014 if (queryString === "") { 1015 queryString += "?"+ attr + "=" + attrValue; 1016 } else { 1017 queryString += "&" + attr + "=" + attrValue; 1018 } 1019 }); 1020 1021 return queryString; 1022 } 1023 }; 1024 1025 1026 ///////////////////////////////////////////// 1027 // HEADER 1028 ///////////////////////////////////////////// 1029 1030 SWIFT.header = { 1031 init: function() { 1032 1033 var lastAjaxSearchValue = "", 1034 searchTimer = false; 1035 1036 if (body.hasClass('sticky-header-enabled') && !body.hasClass('vertical-header')) { 1037 SWIFT.header.stickyHeaderInit(); 1038 } 1039 1040 // STICKY TOP BAR 1041 if ( jQuery('.sticky-top-bar').length > 0 ) { 1042 SWIFT.header.stickyTopBarInit(); 1043 } 1044 1045 jQuery('.header-search-link-alt').on('click', function(e) { 1046 e.preventDefault(); 1047
1048 var ajaxSearchWrap = jQuery('.ajax-search-wrap'); 1049 1050 if (ajaxSearchWrap.is(':visible')) { 1051 ajaxSearchWrap.fadeOut(300); 1052 setTimeout(function() { 1053 jQuery('.ajax-search-results').slideUp(100).empty(); 1054 jQuery('.ajax-search-form input[name=s]').val(''); 1055 }, 300); 1056 } else { 1057 ajaxSearchWrap.fadeIn(300); 1058 setTimeout(function() { 1059 jQuery('.ajax-search-form input[name=s]').focus(); 1060 jQuery("#container").bind("click", function(e) { 1061 var ajaxSearchWrap = jQuery('.ajax-search-wrap'); 1062 if (!jQuery(e.target).closest('.ajax-search-wrap').length) { 1063 ajaxSearchWrap.fadeOut(300); 1064 setTimeout(function() { 1065 jQuery('.ajax-search-results').slideUp(100).empty(); 1066 jQuery('.ajax-search-form input[name=s]').val(''); 1067 }, 300); 1068 jQuery("#container").unbind("click"); 1069 } 1070 }); 1071 }, 300); 1072 } 1073 1074 }); 1075 1076 jQuery('.ajax-search-form input[name=s]').on('keyup', function(e) { 1077 var searchvalue = e.currentTarget.value; 1078 1079 clearTimeout(searchTimer); 1080 if (lastAjaxSearchValue != jQuery.trim(searchvalue) && searchvalue.length >= 3) { 1081 searchTimer = setTimeout( function() { 1082 SWIFT.header.ajaxSearch(e); 1083 }, 400); 1084 } 1085 }); 1086 1087 jQuery('a.overlay-menu-link').on('click', function(e) { 1088 e.preventDefault(); 1089 SWIFT.header.overlayMenuToggle(); 1090 }); 1091 1092 jQuery('#overlay-menu li.menu-item a').on('click', function() { 1093 SWIFT.header.overlayMenuToggle(); 1094 }); 1095 1096 jQuery('a.contact-menu-link').on('click', function(e) { 1097 e.preventDefault(); 1098 var headerTop = jQuery('.header-wrap').scrollTop(); 1099 if (headerTop !== 0) { 1100 jQuery('body,html').animate({scrollTop: headerTop}, 600, 'easeOutCubic'); 1101 setTimeout(function() { 1102 jQuery('#contact-slideout').slideToggle(800, 'easeInOutExpo'); 1103 if (jQuery(this).hasClass('slide-open')) { 1104 jQuery(this).removeClass('slide-open'); 1105 } else { 1106 SWIFT.map.init(); 1107 jQuery(this).addClass('slide-open'); 1108 } 1109 }, 800); 1110 } else { 1111 jQuery('#contact-slideout').slideToggle(800, 'easeInOutExpo'); 1112 if (jQuery(this).hasClass('slide-open')) { 1113 jQuery(this).removeClass('slide-open'); 1114 } else { 1115 SWIFT.map.init(); 1116 jQuery(this).addClass('slide-open'); 1117 } 1118 } 1119 }); 1120 1121 // Mobile Sticky Header 1122 if (body.hasClass('mh-sticky')) { 1123 var mobileHeader = jQuery('#mobile-header'); 1124 1125 mobileHeader.sticky({ 1126 topSpacing: 0 1127 }); 1128 1129 jQuery('#mobile-header-sticky-wrapper').css('height', mobileHeader.outerHeight(true)); 1130 1131 $window.smartresize( function() { 1132 mobileHeader.sticky('update'); 1133 jQuery('#mobile-header-sticky-wrapper').css('height', mobileHeader.outerHeight(true)); 1134 }); 1135 } 1136 1137 if (body.hasClass('layout-boxed') && body.hasClass('vertical-header-right')) { 1138 1139 var rightOffset = ($window.width() - jQuery('#container').width()) / 2; 1140 jQuery('.header-wrap').css('right', rightOffset); 1141 1142 $window.smartresize( function() { 1143 var rightOffset = ($window.width() - jQuery('#container').width()) / 2; 1144 jQuery('.header-wrap').css('right', rightOffset); 1145 }); 1146 } 1147 }, 1148 stickyHeaderInit: function() { 1149 var spacing = 0, 1150 stickyHeader = jQuery('.sticky-header'), 1151 headerWrap = jQuery('.header-wrap'); 1152 1153 if (jQuery('#wpadminbar').length > 0) { 1154 spacing = 32; 1155 } 1156 1157 if ( jQuery('.sticky-top-bar').length > 0 ) { 1158 spacing += jQuery('.sticky-top-bar').outerHeight(); 1159 } 1160 1161 stickyHeader.sticky({ 1162 topSpacing: spacing 1163 }); 1164 1165 $window.smartresize( function() { 1166 stickyHeader.sticky('update'); 1167 }); 1168 1169 if (body.hasClass('layout-boxed')) { 1170 jQuery('.sticky-header').css('max-width', headerWrap.width()); 1171 $window.smartresize( function() { 1172 jQuery('.sticky-header').css('max-width', headerWrap.width()); 1173 }); 1174 } 1175 1176 // Sticky Header Resizing 1177 if (body.hasClass('sh-dynamic')) { 1178 var defaultHeaderPos = headerWrap.offset().top; 1179 $window.scroll(function () { 1180 defaultHeaderPos = headerWrap.offset().top - $window.scrollTop(); 1181 if (jQuery('.sticky-wrapper').hasClass('is-sticky') && defaultHeaderPos < -100) { 1182 headerWrap.addClass('resized-header'); 1183 } else if (headerWrap.hasClass('resized-header')) { 1184 headerWrap.removeClass('resized-header'); 1185 } 1186 1187 }); 1188 } 1189 1190 // Sticky Header Hiding 1191 if (body.hasClass('sh-show-hide')) { 1192 var lastTop = 0; 1193 $window.scroll(function(event){ 1194 var currentTop = jQuery(this).scrollTop(); 1195 if (currentTop > lastTop && currentTop > 1000){ 1196 jQuery('.sticky-header').addClass('sticky-header-hide'); 1197 } else if (jQuery('.sticky-header').hasClass('sticky-header-hide')) { 1198 jQuery('.sticky-header').removeClass('sticky-header-hide'); 1199 } 1200 lastTop = currentTop; 1201 }); 1202 } 1203 }, 1204 stickyTopBarInit: function() { 1205 var spacing = 0, 1206 stickyTB = jQuery('.sticky-top-bar'), 1207 headerWrap = jQuery('.header-wrap'); 1208 1209 if (jQuery('#wpadminbar').length > 0) { 1210 spacing = 32; 1211 } 1212 1213 stickyTB.sticky({ 1214 topSpacing: spacing 1215 }); 1216 1217 $window.smartresize( function() { 1218 stickyTB.sticky('update'); 1219 }); 1220 1221 if (body.hasClass('layout-boxed')) { 1222 stickyTB.css('max-width', headerWrap.width()); 1223 $window.smartresize( function() { 1224 stickyTB.css('max-width', headerWrap.width()); 1225 }); 1226 } 1227 }, 1228 ajaxSearch: function(e) { 1229 var searchInput = jQuery(e.currentTarget), 1230 searchValues = searchInput.parents('form').serialize() + '&action=sf_ajaxsearch', 1231 results = jQuery('.ajax-search-results'), 1232 loadingIndicator = jQuery('.ajax-search-wrap .ajax-loading'), 1233 ajaxurl = jQuery('.ajax-search-wrap').data('ajaxurl'); 1234 1235 jQuery.ajax({ 1236 url: ajaxurl, 1237 type: "POST", 1238 data: searchValues, 1239 beforeSend: function() { 1240 loadingIndicator.fadeIn(50); 1241 }, 1242 success: function(response) { 1243 if (response === 0) { 1244 response = ""; 1245 } else { 1246 results.html(response); 1247 } 1248 }, 1249 complete: function() { 1250 loadingIndicator.fadeOut(200); 1251 results.slideDown(400); 1252 } 1253 }); 1254 }, 1255 overlayMenuToggle: function() { 1256 var overlayMenu = jQuery('#overlay-menu'), 1257 overlayMenuItemHeight = Math.floor(overlayMenu.find('nav ul').height() / overlayMenu.find('ul.menu > li').length) - 5, 1258 overlayMenuItemFS = Math.floor(overlayMenuItemHeight * 0.5); 1259 1260 if (overlayMenuItemFS > 60) { 1261 overlayMenuItemFS = 60; 1262 } 1263 1264 overlayMenu.find('li').css('height', overlayMenuItemHeight + 'px').css('font-size', overlayMenuItemFS + 'px').css('line-height', overlayMenuItemHeight - 20 + 'px'); 1265 1266 if (body.hasClass('overlay-menu-open')) { 1267 body.removeClass('overlay-menu-open'); 1268 body.addClass('overlay-menu-closing'); 1269 setTimeout(function() { 1270 jQuery('#main-nav,#main-navigation').fadeIn(400); 1271 }, 200); 1272 } else { 1273 setTimeout(function() { 1274 body.removeClass('overlay-menu-closing'); 1275 body.addClass('overlay-menu-open'); 1276 jQuery('#main-nav,#main-navigation').fadeOut(300);
1277 }, 30); 1278 } 1279 } 1280 }; 1281 1282 1283 ///////////////////////////////////////////// 1284 // NAVIGATION 1285 ///////////////////////////////////////////// 1286 1287 SWIFT.nav = { 1288 init: function() { 1289 1290 // Set up Mega Menu 1291 if (!isMobile || $window.width() > 768) { 1292 SWIFT.nav.mainMenu(); 1293 } 1294 1295 // Set up Mobile Menu 1296 SWIFT.nav.mobileMenuInit(); 1297 1298 // Add main menu actions 1299 SWIFT.nav.mainMenuActions(); 1300 1301 }, 1302 mainMenu: function() { 1303 1304 var breakWidth = 767; 1305 1306 if ( body.hasClass('vertical-header') ) { 1307 breakWidth = 724; 1308 } 1309 1310 jQuery("#main-navigation").find(".menu li.menu-item").hoverIntent({ 1311 over: function() { 1312 if (jQuery('#container').width() > breakWidth || body.hasClass('responsive-fixed')) { 1313 jQuery(this).find('ul.sub-menu,.mega-menu-sub').first().fadeIn(200); 1314 } 1315 }, 1316 out:function() { 1317 if (jQuery('#container').width() > breakWidth || body.hasClass('responsive-fixed')) { 1318 jQuery(this).find('ul.sub-menu,.mega-menu-sub').first().fadeOut(150); 1319 } 1320 }, 1321 timeout: 0 1322 }); 1323 1324 // Set sub-menu position based on menu height 1325 var mainNav = jQuery('#main-navigation'), 1326 mainNavHeight = mainNav.height(), 1327 subMenu = mainNav.find('.sub-menu'); 1328 1329 subMenu.each(function() { 1330 jQuery(this).css('top', mainNavHeight); 1331 }); 1332 }, 1333 mainMenuActions: function() { 1334 1335 var breakWidth = 767; 1336 1337 if ( body.hasClass('vertical-header') ) { 1338 breakWidth = 724; 1339 } 1340 1341 // Add parent class to items with sub-menus 1342 jQuery("ul.sub-menu").parents('li').addClass('parent'); 1343 1344 // Menu parent click function 1345 jQuery('.menu li.parent > a').on('click', function(e) { 1346 1347 if (jQuery('#container').width() < 1024 || body.hasClass('standard-browser')) { 1348 return e; 1349 } 1350 1351 var directDropdown = jQuery(this).parent().find('ul.sub-menu').first(); 1352 1353 if (directDropdown.css('opacity') === '1' || directDropdown.css('opacity') === 1) { 1354 return e; 1355 } else { 1356 e.preventDefault(); 1357 } 1358 }); 1359 1360 // Set Standard Sub Menu Top Position 1361 jQuery("nav.std-menu").find(".menu li").each(function() { 1362 var top = jQuery(this).outerHeight(); 1363 jQuery(this).find('ul.sub-menu').first().css('top', top); 1364 }); 1365 1366 // Enable hover dropdowns for window size above tablet width 1367 jQuery("nav.std-menu").find(".menu li.parent").hoverIntent({ 1368 over: function() { 1369 if (jQuery('#container').width() > breakWidth || body.hasClass('responsive-fixed')) { 1370 jQuery(this).find('ul.sub-menu').first().stop( true, true ).fadeIn(200); 1371 } 1372 }, 1373 out:function() { 1374 if (jQuery('#container').width() > breakWidth || body.hasClass('responsive-fixed')) { 1375 jQuery(this).find('.sub-menu').first().stop( true, true ).fadeOut(150); 1376 } 1377 }, 1378 timeout: 100 1379 }); 1380 1381 1382 // Shopping bag hover function 1383 jQuery(document).on("mouseenter", "li.shopping-bag-item", function() { 1384 if (jQuery('#container').width() > breakWidth || body.hasClass('responsive-fixed')) { 1385 jQuery(this).find('ul.sub-menu').first().stop( true, true ).fadeIn(200); 1386 } 1387 }).on("mouseleave", "li.shopping-bag-item", function() { 1388 if (jQuery('#container').width() > breakWidth || body.hasClass('responsive-fixed')) { 1389 jQuery(this).find('ul.sub-menu').first().stop( true, true ).fadeOut(150); 1390 } 1391 }); 1392 1393 1394 // Menu item click function 1395 jQuery('.menu-item').on('click', 'a', function(e) { 1396 1397 var menuItem = jQuery(this), 1398 linkHref = menuItem.attr('href'), 1399 isMobileMenuItem = false, 1400 youtubeURL = linkHref.match(/watch\?v=([a-zA-Z0-9\-_]+)/), 1401 vimeoURL = linkHref.match(/^http:\/\/(www\.)?vimeo\.com\/(clip\:)?(\d+).*$/); 1402 1403 1404 if (jQuery(this).parents('nav').attr('id') === "mobile-menu") { 1405 isMobileMenuItem = true; 1406 } 1407 1408 // Link to full width video overlay if link is YouTube/Vimeo 1409 if (youtubeURL || vimeoURL) { 1410 1411 var videoURL = ""; 1412 1413 if (youtubeURL) { 1414 videoURL = 'http://www.youtube.com/embed/'+ youtubeURL[1] +'?autoplay=1&wmode=transparent'; 1415 } else if (vimeoURL) { 1416 videoURL = 'https://player.vimeo.com/video/'+ vimeoURL[3] +'?title=0&byline=0&portrait=0&autoplay=1&wmode=transparent'; 1417 } 1418 1419 if (videoURL !== "") { 1420 jQuery(this).data('video', videoURL); 1421 SWIFT.widgets.openFullWidthVideo(jQuery(this)); 1422 } 1423 e.preventDefault(); 1424 // Smooth Scroll 1425 } else if (linkHref.indexOf('#') === 0 && linkHref.length > 1) { 1426 var headerHeight = 0; 1427 1428 if (isMobileMenuItem) { 1429 SWIFT.nav.mobileMenuHideTrigger(); 1430 setTimeout(function() { 1431 var windowWidth = $window.width(), 1432 isMobSized = false; 1433 if (windowWidth > 1024 && body.hasClass('mhs-tablet-land')) { 1434 isMobSized = true; 1435 } else if (windowWidth > 991 && body.hasClass('mhs-tablet-port')) { 1436 isMobSized = true; 1437 } else if (windowWidth > 767 && body.hasClass('mhs-mobile')) { 1438 isMobSized = true; 1439 } else if (windowWidth <= 767) { 1440 isMobSized = true; 1441 } 1442 1443 if (body.hasClass('mh-sticky') || (body.hasClass('sticky-header-enabled') && isMobSized)) { 1444 headerHeight = jQuery('#mobile-header').outerHeight(true); 1445 } 1446 if ( jQuery('.sticky-top-bar').length > 0 ) { 1447 headerHeight += jQuery('.sticky-top-bar').outerHeight(); 1448 } 1449 1450 if (jQuery(linkHref).length > 0) { 1451 jQuery('html, body').stop().animate({ 1452 scrollTop: jQuery(linkHref).offset().top - headerHeight 1453 }, 1000, 'easeInOutExpo'); 1454 body.removeClass('mh-overlay-show'); 1455 } 1456 }, 400); 1457 } else { 1458 if (jQuery(linkHref).length > 0) { 1459 SWIFT.isScrolling = true; 1460 SWIFT.page.onePageNavGoTo(linkHref); 1461 setTimeout(function() { 1462 SWIFT.isScrolling = false; 1463 }, 1000); 1464 } 1465 } 1466 e.preventDefault(); 1467 } else { 1468 if (isMobileMenuItem) { 1469 return; 1470 } else { 1471 return e; 1472 } 1473 } 1474 1475 }); 1476 1477 1478 // Set current language to top bar item 1479 var currentLanguage = jQuery('li.aux-languages').find('.current-language').html(); 1480 if (currentLanguage !== "") { 1481 jQuery('li.aux-languages > a').html(currentLanguage); 1482 } 1483 1484 // Set menu state on resize 1485 $window.smartresize( function() { 1486 if (jQuery('#container').width() > breakWidth || body.hasClass('responsive-fixed')) { 1487 var menus = jQuery('nav').find('ul.menu'); 1488 menus.each(function() { 1489 jQuery(this).css("display", ""); 1490 });
1491 } 1492 }); 1493 1494 // Change menu active when scroll through sections 1495 SWIFT.nav.currentScrollIndication(); 1496 $window.scroll(function () { 1497 SWIFT.nav.currentScrollIndication(); 1498 }); 1499 }, 1500 currentScrollIndication: function() { 1501 var adjustment = 0; 1502 1503 if (body.hasClass('sticky-header-enabled')) { 1504 adjustment = jQuery('.header-wrap').height(); 1505 } 1506 1507 if ( jQuery('.sticky-top-bar').length > 0 ) { 1508 adjustment += jQuery('.sticky-top-bar').outerHeight(); 1509 } 1510 1511 var inview = jQuery('section.row:in-viewport('+adjustment+')').attr('id'), 1512 menuItems = jQuery('#main-navigation .menu li a'), 1513 link; 1514 1515 if ( inview !== "" && typeof inview != 'undefined' ) { 1516 link = menuItems.filter('[href="#' + inview + '"]'); 1517 } 1518 1519 menuItems.parent().removeClass('current-scroll-item'); 1520 1521 if (typeof inview != 'undefined' && link.length > 0 && !link.hasClass('.current-scroll-item')) { 1522 menuItems.parent().removeClass('current-scroll-item'); 1523 link.parent().addClass('current-scroll-item'); 1524 } 1525 1526 }, 1527 mobileMenuInit: function() { 1528 1529 // Check if admin bar present 1530 if (jQuery('#wpadminbar').length > 0) { 1531 var topPadding = 54; 1532 1533 if (body.hasClass('mh-overlay')) { 1534 jQuery('.mobile-overlay-close').css('top', topPadding + 'px'); 1535 topPadding = topPadding + 40; 1536 } 1537 1538 jQuery('#mobile-menu-wrap').css('padding-top', topPadding + 'px'); 1539 jQuery('#mobile-cart-wrap').css('padding-top', topPadding + 'px'); 1540 } 1541 1542 // Mobile Logo click 1543 jQuery('#mobile-logo > a').on('click touchstart', function(e) { 1544 if (body.hasClass('mobile-menu-open') || body.hasClass('mobile-cart-open') || body.hasClass('mobile-menu-closing')) { 1545 return false; 1546 } else { 1547 return e; 1548 } 1549 }); 1550 1551 // Mobile Nav show 1552 jQuery('.mobile-menu-link').on('click', function(e) { 1553 e.preventDefault(); 1554 1555 if (body.hasClass('mh-overlay')) { 1556 SWIFT.nav.mobileHeaderOverlay('menu'); 1557 } else { 1558 if (body.hasClass('mobile-menu-open')) { 1559 if (isAndroid) { 1560 return; 1561 } 1562 SWIFT.nav.mobileMenuHideTrigger(); 1563 } else { 1564 SWIFT.nav.showMobileMenu(); 1565 } 1566 } 1567 }); 1568 1569 // Mobile Cart show 1570 jQuery('.mobile-cart-link').on('click', function(e) { 1571 e.preventDefault(); 1572 1573 if (body.hasClass('mh-overlay')) { 1574 SWIFT.nav.mobileHeaderOverlay('cart'); 1575 } else { 1576 if (body.hasClass('mobile-menu-open')) { 1577 if (isAndroid) { 1578 return; 1579 } 1580 SWIFT.nav.mobileMenuHideTrigger(); 1581 } else { 1582 SWIFT.nav.showMobileCart(); 1583 } 1584 } 1585 }); 1586 1587 // Mobile Overlay Close 1588 jQuery('.mobile-overlay-close').on('click', function(e) { 1589 e.preventDefault(); 1590 if (body.hasClass('mh-cart-show')) { 1591 jQuery('#mobile-cart-wrap').animate({ 1592 'opacity': 0 1593 }, 500, 'easeOutQuart'); 1594 setTimeout(function() { 1595 body.removeClass('mh-overlay-show'); 1596 body.removeClass('mh-cart-show'); 1597 }, 500); 1598 } else if (body.hasClass('mh-menu-show')) { 1599 jQuery('#mobile-menu-wrap').animate({ 1600 'opacity': 0 1601 }, 500, 'easeOutQuart'); 1602 setTimeout(function() { 1603 body.removeClass('mh-overlay-show'); 1604 body.removeClass('mh-menu-show'); 1605 }, 500); 1606 } 1607 }); 1608 1609 // Mobile Menu parent click 1610 jQuery('#mobile-menu li > a').on('click', function(e) { 1611 var parentMenuItem = jQuery(this).parent(), 1612 linkHref = jQuery(this).attr('href'), 1613 linkTarget = jQuery(this).attr('target'), 1614 subMenu = parentMenuItem.find('ul.sub-menu'); 1615 1616 if (linkHref.indexOf('#') === 0 && linkHref.length > 1) { 1617 var headerHeight = 0; 1618 1619 SWIFT.nav.mobileMenuHideTrigger(); 1620 setTimeout(function() { 1621 if (body.hasClass('mh-sticky')) { 1622 headerHeight = jQuery('#mobile-header').height(); 1623 } 1624 if (jQuery('#wpadminbar').length > 0) { 1625 headerHeight = headerHeight + jQuery('#wpadminbar').height(); 1626 } 1627 1628 if (jQuery(linkHref).length > 0) { 1629 jQuery('html, body').stop().animate({ 1630 scrollTop: jQuery(linkHref).offset().top - headerHeight + 2 1631 }, 1000, 'easeInOutExpo'); 1632 } 1633 }, 400); 1634 1635 e.preventDefault(); 1636 1637 } else { 1638 1639 if (!parentMenuItem.hasClass('parent')) { 1640 SWIFT.nav.mobileMenuHideTrigger(); 1641 1642 if (body.hasClass('page-transitions')) { 1643 SWIFT.page.fadePageOut(linkHref); 1644 } 1645 1646 setTimeout(function() { 1647 if ( linkTarget != "_blank" ) { 1648 window.location.href = linkHref; 1649 } else { 1650 window.open(linkHref); 1651 } 1652 }, 400); 1653 } 1654
1655 if (subMenu.hasClass('sub-menu-open')) { 1656 if (linkHref.indexOf('http') === 0) { 1657 return e; 1658 } else { 1659 subMenu.removeClass('sub-menu-open'); 1660 e.preventDefault(); 1661 } 1662 } else { 1663 subMenu.addClass('sub-menu-open'); 1664 e.preventDefault(); 1665 } 1666 } 1667 }); 1668 1669 // Swipe to hide mobile menu 1670 jQuery("#mobile-menu-wrap").swipe({ 1671 swipeLeft:function() { 1672 if (!body.hasClass('mobile-header-center-logo-alt') && !body.hasClass('mobile-header-left-logo')) { 1673 SWIFT.nav.mobileMenuHideTrigger(); 1674 } 1675 }, 1676 swipeRight:function() { 1677 if (body.hasClass('mobile-header-center-logo-alt') || body.hasClass('mobile-header-left-logo')) { 1678 SWIFT.nav.mobileMenuHideTrigger(); 1679 } 1680 }, 1681 }); 1682 1683 // Swipe to hide mobile cart 1684 jQuery("#mobile-cart-wrap").swipe( { 1685 swipeLeft:function() { 1686 if (body.hasClass('mobile-header-center-logo-alt') || body.hasClass('mobile-header-right-logo') || body.hasClass('mobile-header-center-logo')) { 1687 SWIFT.nav.mobileMenuHideTrigger(); 1688 } 1689 }, 1690 swipeRight:function() { 1691 if (!body.hasClass('mobile-header-center-logo-alt') && !body.hasClass('mobile-header-right-logo')) { 1692 SWIFT.nav.mobileMenuHideTrigger(); 1693 } 1694 }, 1695 }); 1696 1697 // Hide on resize 1698 $window.smartresize( function() { 1699 1700 var windowWidth = $window.width(); 1701 1702 if (windowWidth > 1024 && body.hasClass('mhs-tablet-land')) { 1703 SWIFT.nav.mobileMenuHideTrigger(); 1704 } else if (windowWidth > 991 && body.hasClass('mhs-tablet-port')) { 1705 SWIFT.nav.mobileMenuHideTrigger(); 1706 } else if (windowWidth > 767 && body.hasClass('mhs-mobile')) { 1707 SWIFT.nav.mobileMenuHideTrigger(); 1708 } 1709 1710 }); 1711 1712 }, 1713 showMobileMenu: function() { 1714 1715 var windowTop = $window.scrollTop(); 1716 if (jQuery('#wpadminbar').length > 0) { 1717 windowTop = windowTop - jQuery('#wpadminbar').height(); 1718 } 1719 if (windowTop > 0 && body.hasClass('mh-sticky')) { 1720 jQuery('#mobile-header').css('position', 'absolute').css('top', windowTop); 1721 } 1722 1723 jQuery('#mobile-menu-wrap').css('display', 'block'); 1724 body.addClass('mobile-menu-open'); 1725 setTimeout(function() { 1726 jQuery('#container').on('click touchstart', SWIFT.nav.mobileMenuHideTrigger); 1727 }, 400); 1728 }, 1729 hideMobileMenu: function() { 1730 var windowTop = $window.scrollTop(); 1731 body.removeClass('mobile-menu-open'); 1732 setTimeout(function() { 1733 jQuery('#mobile-menu-wrap').css('display', 'none'); 1734 if (jQuery('.sticky-wrapper').hasClass('is-sticky')) { 1735 jQuery('#mobile-header').css('position', 'fixed').css('top', '0'); 1736 } else { 1737 jQuery('#mobile-header').css('position', '').css('top', ''); 1738 } 1739 jQuery('#container').off('click touchstart', SWIFT.nav.mobileMenuHideTrigger); 1740 }, 300); 1741 setTimeout(function() { 1742 body.removeClass('mobile-menu-closing'); 1743 }, 1000); 1744 }, 1745 showMobileCart: function() { 1746 var windowTop = $window.scrollTop(); 1747 if (jQuery('#wpadminbar').length > 0) { 1748 windowTop = windowTop - jQuery('#wpadminbar').height(); 1749 } 1750 if (windowTop > 0 && body.hasClass('mh-sticky')) { 1751 jQuery('#mobile-header').css('position', 'absolute').css('top', windowTop); 1752 } 1753 1754 jQuery('#mobile-cart-wrap').css('display', 'block'); 1755 body.addClass('mobile-menu-open'); 1756 body.addClass('mobile-cart-open'); 1757 setTimeout(function() { 1758 jQuery('#container').on('click touchstart', SWIFT.nav.mobileMenuHideTrigger); 1759 }, 400); 1760 }, 1761 hideMobileCart: function() { 1762 var windowTop = $window.scrollTop(); 1763 body.removeClass('mobile-cart-open'); 1764 setTimeout(function() { 1765 jQuery('#mobile-cart-wrap').css('display', 'none'); 1766 if (jQuery('.sticky-wrapper').hasClass('is-sticky')) { 1767 jQuery('#mobile-header').css('position', 'fixed').css('top', '0'); 1768 } else { 1769 jQuery('#mobile-header').css('position', '').css('top', ''); 1770 } 1771 jQuery('#container').off('click touchstart', SWIFT.nav.mobileMenuHideTrigger); 1772 }, 400); 1773 setTimeout(function() { 1774 body.removeClass('mobile-menu-closing'); 1775 }, 1000); 1776 }, 1777 mobileMenuHideTrigger: function(e) { 1778 if (e != null) { 1779 e.preventDefault(); 1780 } 1781 body.addClass('mobile-menu-closing'); 1782 SWIFT.nav.hideMobileMenu(); 1783 SWIFT.nav.hideMobileCart(); 1784 }, 1785 mobileHeaderOverlay: function(type) { 1786 1787 if (type === "menu") { 1788 jQuery('#mobile-menu-wrap').css('display', 'block'); 1789 body.addClass('mh-overlay-show'); 1790 body.addClass('mh-menu-show'); 1791 jQuery('#mobile-menu-wrap').animate({ 1792 'opacity': 1 1793 }, 500, 'easeOutQuart'); 1794 } else if (type === "cart") { 1795 jQuery('#mobile-cart-wrap').css('display', 'block'); 1796 body.addClass('mh-overlay-show'); 1797 body.addClass('mh-cart-show'); 1798 jQuery('#mobile-cart-wrap').animate({ 1799 'opacity': 1 1800 }, 500, 'easeOutQuart'); 1801 } 1802 1803 } 1804 }; 1805 1806 1807 ///////////////////////////////////////////// 1808 // WOOCOMMERCE FUNCTIONS 1809 ///////////////////////////////////////////// 1810 1811 SWIFT.woocommerce = { 1812 init: function() { 1813 1814 // QUANTITY FUNCTIONS
1815 SWIFT.woocommerce.productQuantityAdjust(); 1816 1817 //Wishlist Reload 1818 jQuery(document).on('click', '.add_to_wishlist', function(){ 1819 1820 jQuery(this).parent().parent().find('.yith-wcwl-wishlistaddedbrowse').show().removeClass("hide").addClass("show"); 1821 jQuery(this).hide().addClass("hide").removeClass("show"); 1822 1823 var data = {action: 'sf_add_to_wishlist', product_id: jQuery(this).attr('data-product-id')}; 1824 var ajaxURL = jQuery(this).attr('data-ajaxurl'); 1825 1826 jQuery.post(ajaxURL, data, function(response) { 1827 var json = jQuery.parseJSON(response); 1828 1829 jQuery('.wishlist-item .bag-contents').prepend(json.wishlist_output); 1830 jQuery('.wishlist-link .count').text(parseInt(jQuery('.wishlist-link .count').text())+1); 1831 1832 }); 1833 1834 }); 1835 1836 jQuery('.add_to_cart_button').on('click', function() { 1837 var button = jQuery(this); 1838 var added_text = button.attr("data-added_text"); 1839 button.addClass("product-added"); 1840 button.find('span').text(added_text); 1841 button.find('i').attr('class', 'fa-check'); 1842 }); 1843 1844 jQuery('.show-products-link').on('click', function(e) { 1845 e.preventDefault(); 1846 var linkHref = jQuery(this).attr('href').replace('?', ''), 1847 currentURL = document.location.href.replace(/\/page\/\d+/, ''), 1848 currentQuery = document.location.search; 1849 1850 if (currentQuery.indexOf('?show') >= 0) { 1851 window.location = jQuery(this).attr('href'); 1852 } else if (currentQuery.indexOf('?') >= 0) { 1853 window.location = currentURL + '&' + linkHref; 1854 } else { 1855 window.location = currentURL + '?' + linkHref; 1856 } 1857 }); 1858 1859 jQuery('.shipping-calculator-form input').keypress(function(e) { 1860 if(e.which == 10 || e.which == 13) { 1861 jQuery(".update-totals-button button").click(); 1862 } 1863 }); 1864 1865 if (jQuery('.product-grid').length > 0) { 1866 1867 if (!jQuery('.inner-page-wrap').hasClass('full-width-shop')) { 1868 var productGrid = jQuery('.product-grid'); 1869 productGrid.imagesLoaded(function () { 1870 productGrid.equalHeights(); 1871 }); 1872 1873 $window.smartresize( function() { 1874 jQuery('.product-grid').children().css('min-height','0'); 1875 jQuery('.product-grid').equalHeights(); 1876 }); 1877 } 1878 } 1879 }, 1880 load: function() { 1881 1882 if (jQuery('.woocommerce-shop-page').hasClass('full-width-shop') && !(IEVersion && IEVersion < 9)) { 1883 SWIFT.woocommerce.fullWidthShop(); 1884 } 1885 1886 }, 1887 cartWishlist: function() { 1888 // Cart remove product 1889 jQuery(document).on('click', '.shopping-bag .remove-product', function(e) { 1890 1891 e.preventDefault(); 1892 e.stopPropagation(); 1893 1894 var prod_id = jQuery(this).attr('data-product-id'), 1895 variation_id = jQuery(this).attr('data-variation-id'), 1896 prod_quantity = jQuery(this).attr('data-product-qty'), 1897 empty_bag_txt = jQuery('.shopping-bag').attr('data-empty-bag-txt'), 1898 singular_item_txt = jQuery('.shopping-bag').attr('data-singular-item-txt'), 1899 multiple_item_txt = jQuery('.shopping-bag').attr('data-multiple-item-txt'), 1900 data = {action: 'sf_cart_product_remove', product_id: prod_id, variation_id: variation_id}, 1901 ajaxURL = jQuery(this).attr('data-ajaxurl'); 1902 1903 jQuery('.shopping-bag .loading-overlay').fadeIn(200); 1904 1905 jQuery.post(ajaxURL, data, function(response) { 1906 1907 var cartTotal = response; 1908 var cartcounter = 0; 1909 1910 if ( body.hasClass('woocommerce-checkout') ) { 1911 jQuery('.shopping-bag').find(".bag-button")[0].click(); 1912 } 1913 1914 if ( body.hasClass('woocommerce-cart') ) { 1915 location.reload(); 1916 } 1917 1918 jQuery('.shopping-bag .loading-overlay').fadeOut(100); 1919
1920 cartcounter = parseInt(jQuery('.cart-contents .num-items').first().text()) - prod_quantity; 1921 jQuery('.cart-contents .amount').replaceWith(cartTotal); 1922 jQuery('.bag-total .amount').replaceWith(cartTotal); 1923 jQuery('.cart-contents .num-items').text(cartcounter); 1924 1925 jQuery('.cart-contents .num-items').each(function( index ) { 1926 jQuery(this).text(cartcounter); 1927 }); 1928 1929 if ( variation_id > 0 ){ 1930 jQuery('.product-var-id-'+variation_id).remove(); 1931 }else{ 1932 jQuery('.product-id-'+prod_id).remove(); 1933 } 1934 1935 if ( cartcounter <= 0 ) { 1936 jQuery('.sub-menu .shopping-bag').prepend('<div class="bag-empty">' + empty_bag_txt + '</div>'); 1937 jQuery('.sub-menu .shopping-bag .bag-buttons').remove(); 1938 jQuery('.sub-menu .shopping-bag .bag-header').remove(); 1939 jQuery('.sub-menu .shopping-bag .bag-total').remove(); 1940 jQuery('.sub-menu .shopping-bag .bag-contents').remove(); 1941 } else { 1942 if ( cartcounter == 1 ) { 1943 jQuery('.sub-menu .shopping-bag .bag-header').text('1 ' + singular_item_txt); 1944 } else { 1945 jQuery('.sub-menu .shopping-bag .bag-header').text(cartcounter + ' ' + multiple_item_txt); 1946 } 1947 } 1948 1949 }); 1950 1951 1952 1953 return false; 1954 1955 }); 1956 1957 //Wishlist Remove a Product 1958 jQuery(document).on('click', '.wishlist_table .remove', function(){ 1959 1960 jQuery(".prod-"+jQuery(this).attr('data-product-id')).remove(); 1961 var wishcounter = parseInt(jQuery('.wishlist-link .count').text())-1; 1962 jQuery('.wishlist-link .count').text(wishcounter); 1963 if ( wishcounter === 0 ){ 1964 jQuery('.wishlist-item .bag-contents').prepend('<div class="wishlist-empty">Your wishlist is currently empty.</div>'); 1965 } 1966 1967 }); 1968 }, 1969 variations: function() { 1970 jQuery('.variations_form select, .variations select').each( function() { 1971 var variationSelect = jQuery(this); 1972 variationSelect.on("change", function(){ 1973 if (jQuery('#sf-included').hasClass('has-productzoom')) { 1974 jQuery('.zoomContainer').remove(); 1975 setTimeout(function() { 1976 jQuery('.product-slider-image').each(function() { 1977 jQuery(this).data('zoom-image', jQuery(this).parent().find('a.zoom').attr('href')); 1978 }); 1979 var firstImage = jQuery('#product-img-slider li:first').find('.product-slider-image'); 1980 SWIFT.woocommerce.productZoom(firstImage); 1981 jQuery('#product-img-slider').flexslider(0); 1982 }, 500); 1983 } else { 1984 setTimeout(function() { 1985 jQuery('#product-img-slider').flexslider(0); 1986 var flexViewport = jQuery('#product-img-slider').find('.flex-viewport'), 1987 flexsliderHeight = flexViewport.find('ul.slides').css('height'); 1988 1989 flexViewport.animate({ 1990 'height': flexsliderHeight 1991 }, 300); 1992 }, 500); 1993 } 1994 }); 1995 }); 1996 }, 1997 productZoom: function(zoomObject) { 1998 jQuery('#product-img-slider li a.zoom').css('display', 'none'); 1999 zoomObject.elevateZoom({ 2000 zoomType: productZoomType, 2001 cursor: "crosshair", 2002 zoomParent: '#product-img-slider', 2003 responsive: true, 2004 zoomWindowFadeIn: 400, 2005 zoomWindowFadeOut: 500, 2006 lensSize: 250 2007 }); 2008 $window.smartresize( function() { 2009 var currentImage = jQuery('#product-img-slider li.flex-active-slide').find('.product-slider-image'); 2010 if (!currentImage) { 2011 jQuery('#product-img-slider li:first').find('.product-slider-image'); 2012 } 2013 SWIFT.woocommerce.productZoom(currentImage); 2014 }); 2015 }, 2016 fullWidthShop: function() { 2017 var shopItems = jQuery('.full-width-shop').find('.products'), 2018 itemWidth = shopItems.find('li.product').first().data('width'), 2019 shopSidebar = shopItems.find('.sidebar'); 2020 2021 if (shopSidebar.length > 0) { 2022 2023 // Full Width Shop Sidebar 2024 SWIFT.woocommerce.fullWidthShopSetSidebarHeight(); 2025 $window.smartresize( function() { 2026 SWIFT.woocommerce.fullWidthShopSetSidebarHeight(); 2027 }); 2028 2029 shopItems.isotope({ 2030 itemSelector: '.product', 2031 layoutMode: 'masonry', 2032 masonry: { 2033 columnWidth: '.'+itemWidth 2034 }, 2035 isOriginLeft: !isRTL 2036 }); 2037
2038 SWIFT.woocommerce.animateItems(shopItems); 2039 2040 shopSidebar.stop().animate({ 2041 'opacity': 1 2042 }, 500); 2043 shopItems.isotope( 'stamp', shopSidebar ); 2044 shopItems.isotope('layout'); 2045 2046 } else { 2047 2048 shopItems.isotope({ 2049 itemSelector: '.product', 2050 layoutMode: 'fitRows', 2051 isOriginLeft: !isRTL 2052 }); 2053 2054 SWIFT.woocommerce.animateItems(shopItems); 2055 2056 } 2057 }, 2058 fullWidthShopSetSidebarHeight: function() { 2059 var shopItems = jQuery('.full-width-shop').find('.products'), 2060 shopSidebar = shopItems.find('div.sidebar'), 2061 defaultSidebarHeight = shopSidebar.css('height', '').outerHeight(), 2062 newSidebarHeight = 0, 2063 sidebarHeightMultiply = 2, 2064 firstProductHeight = shopItems.find('li.product').first().outerHeight(true); 2065 2066 sidebarHeightMultiply = Math.ceil(defaultSidebarHeight / firstProductHeight); 2067 newSidebarHeight = firstProductHeight * sidebarHeightMultiply; 2068 shopSidebar.css('height', newSidebarHeight); 2069 }, 2070 animateItems: function(shopItems) { 2071 shopItems.find('.product').each(function(i) { 2072 jQuery(this).delay(i*200).animate({ 2073 'opacity' : 1 2074 }, 800, 'easeOutExpo', function() { 2075 jQuery(this).addClass('item-animated'); 2076 }); 2077 }); 2078 }, 2079 productQuantityAdjust: function() { 2080 2081 // Increase 2082 jQuery(document).on('click', '.qty-plus', function(e) { 2083 e.preventDefault(); 2084 var quantityInput = jQuery(this).parents('.quantity').find('input.qty'), 2085 newValue = parseInt(quantityInput.val(), 10) + 1, 2086 maxValue = parseInt(quantityInput.attr('max'), 10); 2087 2088 if (!maxValue) { 2089 maxValue = 9999999999; 2090 } 2091 2092 if ( newValue <= maxValue ) { 2093 quantityInput.val(newValue); 2094 quantityInput.change(); 2095 } 2096 }); 2097 2098 // Decrease 2099 jQuery(document).on('click', '.qty-minus', function(e) { 2100 e.preventDefault(); 2101 var quantityInput = jQuery(this).parents('.quantity').find('input.qty'), 2102 newValue = parseInt(quantityInput.val(), 10) - 1, 2103 minValue = parseInt(quantityInput.attr('min'), 10); 2104 2105 if (!minValue) { 2106 minValue = 1; 2107 } 2108 2109 if ( newValue >= minValue ) { 2110 quantityInput.val(newValue); 2111 quantityInput.change(); 2112 } 2113 }); 2114 2115 } 2116 }; 2117 2118 ///////////////////////////////////////////// 2119 // FLEXSLIDER FUNCTION 2120 ///////////////////////////////////////////// 2121 2122 SWIFT.flexSlider = { 2123 init: function() { 2124 2125 if (jQuery('#product-img-slider').length > 0) { 2126 SWIFT.flexSlider.productSlider(); 2127 } 2128 2129 jQuery('.item-slider').flexslider({ 2130 useCSS: flexUseCSS, 2131 animation: "slide", //String: Select your animation type, "fade" or "slide" 2132 slideDirection: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical" 2133 slideshow: sliderAuto, //Boolean: Animate slider automatically 2134 slideshowSpeed: sliderSlideSpeed, //Integer: Set the speed of the slideshow cycling, in milliseconds 2135 animationDuration: sliderAnimSpeed, //Integer: Set the speed of animations, in milliseconds 2136 rtl: isRTL, 2137 smoothHeight: true, 2138 directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false) 2139 controlNav: true, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage 2140 keyboardNav: false, //Boolean: Allow slider navigating via keyboard left/right keys 2141 mousewheel: false, //Boolean: Allow slider navigating via mousewheel 2142 prevText: "Prev", //String: Set the text for the "previous" directionNav item 2143 nextText: "Next", //String: Set the text for the "next" directionNav item 2144 pausePlay: true, //Boolean: Create pause/play dynamic element 2145 pauseText: '', //String: Set the text for the "pause" pausePlay item 2146 playText: '', //String: Set the text for the "play" pausePlay item 2147 randomize: false, //Boolean: Randomize slide order 2148 slideToStart: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide) 2149 animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end 2150 pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended. 2151 pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering 2152 controlsContainer: "", //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken. 2153 manualControls: "", //Selector: Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs. 2154 start: function(){}, //Callback: function(slider) - Fires when the slider loads the first slide 2155 before: function(){}, //Callback: function(slider) - Fires asynchronously with each slider animation 2156 after: function(){}, //Callback: function(slider) - Fires after each slider animation completes 2157 end: function(){} //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous) 2158 }); 2159 jQuery('.content-slider').each(function() { 2160 var slider = jQuery(this), 2161 autoplay = ((slider.attr('data-autoplay') === "yes") ? true : false); 2162 2163 slider.flexslider({ 2164 useCSS: flexUseCSS, 2165 animation: "fade", //String: Select your animation type, "fade" or "slide"
2166 slideshow: autoplay, //Boolean: Animate slider automatically 2167 slideshowSpeed: sliderSlideSpeed, //Integer: Set the speed of the slideshow cycling, in milliseconds 2168 animationDuration: sliderAnimSpeed, //Integer: Set the speed of animations, in milliseconds 2169 smoothHeight: false, 2170 directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false) 2171 rtl: isRTL, 2172 controlNav: false, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage 2173 prevText: "", //String: Set the text for the "previous" directionNav item 2174 nextText: "", //String: Set the text for the "next" directionNav item 2175 pauseOnHover: true, 2176 start: function() { 2177 SWIFT.flexSlider.slideEqualHeights(); 2178 $window.smartresize( function() { 2179 SWIFT.flexSlider.slideEqualHeights(); 2180 }); 2181 } 2182 }); 2183 }); 2184 }, 2185 productSlider: function() { 2186 2187 if (jQuery('#product-img-nav ul.slides li').length > 1) { 2188 jQuery('#product-img-nav').flexslider({ 2189 animation: "slide", 2190 rtl: isRTL, 2191 useCSS: flexUseCSS, 2192 directionNav: false, 2193 controlNav: false, 2194 animationLoop: false, 2195 slideshow: false, 2196 itemWidth: 100, 2197 itemMargin: 0, 2198 asNavFor: '#product-img-slider' 2199 }); 2200 } else { 2201 jQuery('#product-img-nav').css('display', 'none'); 2202 } 2203 2204 jQuery('#product-img-slider').flexslider({ 2205 useCSS: flexUseCSS, 2206 animation: "slide", 2207 controlNav: true, 2208 smoothHeight: true, 2209 animationLoop: false, 2210 slideshow: sliderAuto, 2211 slideshowSpeed: sliderSlideSpeed, //Integer: Set the speed of the slideshow cycling, in milliseconds 2212 animationDuration: sliderAnimSpeed, //Integer: Set the speed of animations, in milliseconds 2213 rtl: isRTL, 2214 sync: '#product-img-nav', 2215 start: function(productSlider) { 2216 if (hasProductZoom) { 2217 if (productSlider.slides) { 2218 var currentImageHasSlides = productSlider.slides.eq(productSlider.currentSlide).find('.product-slider-image'); 2219 SWIFT.woocommerce.productZoom(currentImageHasSlides); 2220 } else { 2221 var currentImageNoSlides = jQuery('#product-img-slider').find('.product-slider-image'); 2222 SWIFT.woocommerce.productZoom(currentImageNoSlides); 2223 } 2224 } 2225 }, 2226 before: function() { 2227 if (hasProductZoom) { 2228 jQuery('.zoomContainer').remove(); 2229 } 2230 }, 2231 after: function(productSlider) { 2232 if (hasProductZoom) { 2233 var currentSlideImage = productSlider.slides.eq(productSlider.currentSlide).find('.product-slider-image'); 2234 SWIFT.woocommerce.productZoom(currentSlideImage); 2235 } 2236 } 2237 }); 2238 }, 2239 thumb: function() { 2240 jQuery('.thumb-slider').flexslider({ 2241 animation: "fade", //String: Select your animation type, "fade" or "slide" 2242 slideDirection: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical" 2243 slideshow: sliderAuto, //Boolean: Animate slider automatically 2244 slideshowSpeed: sliderSlideSpeed, //Integer: Set the speed of the slideshow cycling, in milliseconds 2245 animationDuration: sliderAnimSpeed, //Integer: Set the speed of animations, in milliseconds 2246 directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false) 2247 controlNav: false, //Boolean: Create navigation for paging control of each slide? Note: Leave true for manualControls usage 2248 keyboardNav: false, //Boolean: Allow slider navigating via keyboard left/right keys 2249 smoothHeight: false, 2250 rtl: isRTL 2251 }); 2252 }, 2253 slideEqualHeights: function() { 2254 setTimeout(function() { 2255 jQuery('.content-slider').find('.slide-content-wrap').css('position', 'relative'); 2256 jQuery('.content-slider > ul').equalHeights(); 2257 jQuery('.content-slider').find('.slide-content-wrap').vCenterTop(); 2258 jQuery('.content-slider').find('.slide-content-wrap').css('position', 'absolute'); 2259 }, 200); 2260 } 2261 }; 2262 2263 ///////////////////////////////////////////// 2264 // PORTFOLIO 2265 ///////////////////////////////////////////// 2266 2267 var portfolioContainer = jQuery('.portfolio-wrap').find('.filterable-items'); 2268 2269 SWIFT.portfolio = { 2270 init: function() { 2271 portfolioContainer.each(function() { 2272 var portfolioInstance = jQuery(this); 2273 if (portfolioInstance.hasClass('masonry-items') && !(IEVersion && IEVersion < 9)) { 2274 SWIFT.portfolio.masonrySetup(portfolioInstance); 2275 } else if (portfolioInstance.hasClass('multi-masonry-items') && !(IEVersion && IEVersion < 9)) { 2276 SWIFT.portfolio.multiMasonrySetup(portfolioInstance); 2277 } else { 2278 SWIFT.portfolio.standardSetup(portfolioInstance); 2279 } 2280 }); 2281 2282 // PORTFOLIO WINDOW RESIZE 2283 $window.smartresize( function() { 2284 SWIFT.portfolio.windowResized(); 2285 }); 2286 2287 // Enable filter options on when there are items from that skill 2288 jQuery('.filtering li').each( function() { 2289 var filter = jQuery(this), 2290 filterName = jQuery(this).find('a').attr('class'), 2291 portfolioItems = jQuery(this).parents('.portfolio-wrap').find('.filterable-items'); 2292 2293 portfolioItems.find('.portfolio-item').each( function() { 2294 if ( jQuery(this).hasClass(filterName) ) { 2295 filter.addClass('has-items'); 2296 } 2297 }); 2298 }).parents('.filtering').animate({ 2299 opacity: 1 2300 }, 400); 2301 2302 // filter items when filter link is clicked 2303 jQuery('.filtering li').on('click', 'a', function(e) { 2304 e.preventDefault(); 2305 jQuery(this).parent().parent().find('li').removeClass('selected'); 2306 jQuery(this).parent().addClass('selected'); 2307 var selector = jQuery(this).data('filter'); 2308 var portfolioItems = jQuery(this).parents('.portfolio-wrap').find('.filterable-items'); 2309 portfolioItems.isotope({ filter: selector }); 2310 }); 2311 2312 jQuery('.filter-wrap > a').on('click', function(e) { 2313 e.preventDefault(); 2314 jQuery(this).parent().find('.filter-slide-wrap').slideToggle(); 2315 }); 2316 }, 2317 standardSetup: function(portfolioInstance) { 2318 portfolioInstance.imagesLoaded(function () { 2319 SWIFT.portfolio.setItemHeight(); 2320 SWIFT.flexSlider.thumb(); 2321 portfolioInstance.animate({opacity: 1}, 800); 2322 portfolioInstance.isotope({ 2323 resizable: true, 2324 layoutMode: 'fitRows', 2325 isOriginLeft: !isRTL 2326 }); 2327 });
2328 portfolioInstance.appear(function() { 2329 SWIFT.portfolio.animateItems(portfolioInstance); 2330 }); 2331 }, 2332 masonrySetup: function(portfolioInstance) { 2333 portfolioInstance.imagesLoaded(function () { 2334 SWIFT.flexSlider.thumb(); 2335 portfolioInstance.isotope({ 2336 resizable: false, 2337 itemSelector : '.portfolio-item', 2338 layoutMode: 'masonry', 2339 isOriginLeft: !isRTL 2340 }); 2341 }); 2342 portfolioInstance.appear(function() { 2343 SWIFT.portfolio.animateItems(portfolioInstance); 2344 }); 2345 }, 2346 multiMasonrySetup: function(portfolioInstance) { 2347 portfolioInstance.imagesLoaded(function () { 2348 SWIFT.flexSlider.thumb(); 2349 SWIFT.portfolio.multiMasonrySizeFix(); 2350 portfolioInstance.isotope({ 2351 resizable: false, 2352 itemSelector : '.portfolio-item', 2353 layoutMode: 'packery', 2354 masonry: { 2355 columnWidth: '.grid-sizer' 2356 }, 2357 isOriginLeft: !isRTL 2358 }); 2359 }); 2360 portfolioInstance.appear(function() { 2361 SWIFT.portfolio.animateItems(portfolioInstance); 2362 }); 2363 }, 2364 animateItems: function(portfolioInstance) { 2365 portfolioInstance.find('.portfolio-item').each(function(i) { 2366 jQuery(this).delay(i*200).animate({ 2367 'opacity' : 1 2368 }, 800, 'easeOutExpo', function() { 2369 jQuery(this).addClass('item-animated'); 2370 }); 2371 }); 2372 }, 2373 setItemHeight: function() { 2374 if (!portfolioContainer.hasClass('col-1') && !portfolioContainer.hasClass('masonry-items') && !portfolioContainer.hasClass('multi-masonry-items')) { 2375 portfolioContainer.children().css('min-height','0'); 2376 portfolioContainer.equalHeights(); 2377 } 2378 }, 2379 multiMasonrySizeFix: function() { 2380 var baseItem = portfolioContainer.find('.portfolio-item.size-standard').first(), 2381 standardHeight = baseItem.height(), 2382 standardWidth = baseItem.width(), 2383 wideTallHeight = (standardHeight * 2) + parseInt(baseItem.css('margin-bottom'), 10), 2384 wideWidth = (standardWidth * 2) + parseInt(baseItem.css('margin-bottom'), 10); 2385 2386 if (standardHeight > 0) { 2387 portfolioContainer.find('.portfolio-item.size-wide .multi-masonry-img-wrap').css('height', standardHeight).css('width', wideWidth + 8); 2388 portfolioContainer.find('.portfolio-item.size-wide-tall .multi-masonry-img-wrap').css('height', wideTallHeight).css('width', wideWidth + 8); 2389 portfolioContainer.find('.portfolio-item.size-tall .multi-masonry-img-wrap').css('height', wideTallHeight).css('width', standardWidth + 8); 2390 } 2391 if (portfolioContainer.data('isotope')) { 2392 portfolioContainer.isotope('layout'); 2393 } 2394 }, 2395 windowResized: function() { 2396 if (!portfolioContainer.hasClass('col-1') && !portfolioContainer.hasClass('masonry-items') && !portfolioContainer.hasClass('multi-masonry-items')) { 2397 SWIFT.portfolio.setItemHeight(); 2398 } 2399 2400 if (portfolioContainer.hasClass('multi-masonry-items')) { 2401 SWIFT.portfolio.multiMasonrySizeFix(); 2402 } 2403 }, 2404 portfolioShowcaseInit: function() { 2405 SWIFT.flexSlider.thumb(); 2406 SWIFT.portfolio.portfolioShowcaseWrap(); 2407 SWIFT.portfolio.portfolioShowcaseItems(); 2408 $window.smartresize( function() { 2409 SWIFT.portfolio.portfolioShowcaseWrap(); 2410 SWIFT.portfolio.portfolioShowcaseItems(); 2411 }); 2412 }, 2413 portfolioShowcaseWrap: function() { 2414 var portfolioShowcaseWrap = jQuery('.portfolio-showcase-wrap'); 2415 portfolioShowcaseWrap.animate({opacity: 1}, 600); 2416 }, 2417 portfolioShowcaseItems: function() { 2418 jQuery('.portfolio-showcase-wrap').each(function() { 2419 2420 var contWidth = jQuery('#main-container').width(); 2421 2422 if (jQuery('#container').hasClass('boxed-layout')) { 2423 contWidth = jQuery('#container').width(); 2424 } 2425 2426 var thisShowcase = jQuery(this), 2427 columns = thisShowcase.find('.portfolio-showcase-items').data('columns'), 2428 windowWidth = contWidth + 2, 2429 itemWidth = Math.floor(windowWidth / columns), 2430 maximisedWidth = Math.floor(windowWidth * 40 / 100), 2431 reducedWidth = Math.floor(windowWidth / 5), 2432 deselectedLeft = (itemWidth / 2 - maximisedWidth / 2) / 0.75, 2433 resetLeft = (reducedWidth / 2 - maximisedWidth / 2) / 1.3, 2434 isAnimating = !1, 2435 speed = 300; 2436 2437 var showcaseItem = thisShowcase.find('li.portfolio-item'); 2438 2439 if (columns === 5) { 2440 maximisedWidth = Math.floor(windowWidth * 25 / 100); 2441 reducedWidth = Math.floor(windowWidth / 5.33); 2442 deselectedLeft = (itemWidth / 2 - maximisedWidth / 2) / 0.75; 2443 resetLeft = (reducedWidth / 2 - maximisedWidth / 2) / 1.3; 2444 showcaseItem.css("width", itemWidth);
2445 showcaseItem.css("height", maximisedWidth / 1.5); 2446 showcaseItem.find('.main-image').css("width", maximisedWidth); 2447 showcaseItem.find('.main-image').css("left", resetLeft); 2448 showcaseItem.find('.main-image').css("top", - maximisedWidth / 6); 2449 speed = 200; 2450 } else { 2451 showcaseItem.css("width", itemWidth); 2452 showcaseItem.css("height", maximisedWidth / 2); 2453 showcaseItem.find('.main-image').css("width", maximisedWidth); 2454 showcaseItem.find('.main-image').css("left", resetLeft); 2455 } 2456 2457 showcaseItem.each(function () { 2458 if (windowWidth > 768) { 2459 jQuery(this).mouseenter(function () { 2460 if (!isAnimating) { 2461 isAnimating = !0; 2462 jQuery(this).removeClass("deselected-item"); 2463 thisShowcase.find(".deselected-item").stop().animate({ 2464 width: reducedWidth 2465 }, speed); 2466 thisShowcase.find(".deselected-item").find(".main-image").stop().animate({ 2467 left: deselectedLeft 2468 }, speed); 2469 jQuery(this).find(".main-image").stop().animate({ 2470 left: 0 2471 }, speed); 2472 jQuery(this).stop().animate({ 2473 width: maximisedWidth 2474 }, speed + 1, function () { 2475 jQuery(this).find(".item-info").stop().show(); 2476 jQuery(this).find(".item-info").stop().animate({ 2477 bottom: 0 2478 }, speed, "easeInOutQuart"); 2479 });
2480 } 2481 }); 2482 jQuery(this).mouseleave(function () { 2483 if (isAnimating) { 2484 isAnimating = !1; 2485 jQuery(this).addClass("deselected-item"); 2486 thisShowcase.find(".portfolio-item").stop().animate({ 2487 width: itemWidth 2488 }, speed); 2489 thisShowcase.find(".portfolio-item .main-image").stop().animate({ 2490 left: resetLeft 2491 }, speed); 2492 jQuery(this).find(".item-info").stop().animate({ 2493 bottom: -85 2494 }, speed, function () { 2495 jQuery(this).find(".item-info").stop().hide(); 2496 }); 2497 } 2498 }); 2499 } 2500 }); 2501 }); 2502 }, 2503 stickyDetails: function() { 2504 2505 var offset = 0, 2506 navSelectorElement = '.media-wrap', 2507 footerOffset = 160; 2508 2509 if (jQuery('.page-heading').length > 0) { 2510 offset += jQuery('.page-heading').outerHeight(true); 2511 } 2512 2513 if (jQuery('.inner-main-container').hasClass('portfolio-type-standard')) { 2514 offset += 130; 2515 } 2516 2517 if (jQuery('.related-projects').length > 0) { 2518 footerOffset = 520; 2519 } 2520 2521 jQuery('.sticky-details').stickySidebar({ 2522 headerSelector: '.header-wrap', 2523 navSelector: navSelectorElement, 2524 contentSelector: '.article-body-wrap', 2525 footerSelector: '#footer-wrap', 2526 sidebarTopMargin: 0, 2527 footerThreshold: footerOffset, 2528 offset: offset 2529 }); 2530 2531 jQuery('.sticky-details').css('max-width', jQuery('.sticky-details').outerWidth(true)); 2532 2533 SWIFT.portfolio.stickyDetailsScroll(); 2534 $window.scroll(function() { 2535 SWIFT.portfolio.stickyDetailsScroll(); 2536 }); 2537 }, 2538 stickyDetailsScroll: function() { 2539 2540 var contentElement = jQuery('.article-body-wrap'); 2541 2542 if (jQuery('.inner-main-container').hasClass('portfolio-type-fw-media')) { 2543 contentElement = jQuery('.portfolio-detail-description'); 2544 } 2545 2546 if (jQuery('.sticky-details').hasClass('sticky')) { 2547 jQuery('.sticky-details').css('margin-left', contentElement.outerWidth(true)); 2548 } else { 2549 jQuery('.sticky-details').css('margin-left', 0); 2550 } 2551 }, 2552 }; 2553 2554 2555 ///////////////////////////////////////////// 2556 // BLOG 2557 ///////////////////////////////////////////// 2558 2559 var blogItems = jQuery('.blog-wrap').find('.blog-items'); 2560 2561 SWIFT.blog = { 2562 init: function() { 2563 2564 // BLOG ITEM SETUP 2565 blogItems.each(function() { 2566 var blogInstance = jQuery(this); 2567 if (blogInstance.hasClass('blog-grid-items')) { 2568 SWIFT.blog.blogGrid(blogInstance.find('.grid-items')); 2569 } else { 2570 SWIFT.blog.blogLayout(blogInstance); 2571 } 2572 }); 2573 2574 // Blog Filtering 2575 SWIFT.blog.blogFiltersInit(); 2576 2577 // BLOG AUX SLIDEOUT 2578 jQuery('.blog-slideout-trigger').on('click', function(e) { 2579 e.preventDefault(); 2580 2581 // VARIABLES 2582 var blogWrap = jQuery(this).parent().parent().parent().parent(); 2583 var filterPanel = blogWrap.find('.blog-filter-wrap .filter-slide-wrap'); 2584 var auxType = jQuery(this).attr('data-aux'); 2585 2586 // ADD COLUMN SIZE AND REMOVE BRACKETS FROM COUNT 2587 blogWrap.find('.aux-list li').addClass('col-sm-2'); 2588 blogWrap.find('.aux-list li a span').each(function() { 2589 jQuery(this).html(jQuery(this).html().replace("(","").replace(")","")); 2590 }); 2591 2592 // IF SELECTING AN OPTION THAT IS OPEN, CLOSE THE PANEL 2593 if (jQuery(this).parent().hasClass('selected') && !filterPanel.is(':animated')) { 2594 blogWrap.find('.blog-aux-options li').removeClass('selected'); 2595 filterPanel.slideUp(400); 2596 return; 2597 } 2598 2599 // AUX BUTTON SELECTED STATE 2600 blogWrap.find('.blog-aux-options li').removeClass('selected'); 2601 jQuery(this).parent().addClass('selected'); 2602 2603 // IF SLIDEOUT IS OPEN 2604 if (filterPanel.is(':visible')) { 2605 2606 filterPanel.slideUp(400); 2607 setTimeout(function() { 2608 blogWrap.find('.aux-list').css('display', 'none'); 2609 blogWrap.find('.aux-'+auxType).css('display', 'block'); 2610 filterPanel.slideDown(); 2611 }, 600); 2612 2613 // IF SLIDEOUT IS CLOSED 2614 } else { 2615 2616 blogWrap.find('.aux-list').css('display', 'none'); 2617 blogWrap.find('.aux-'+auxType).css('display', 'block'); 2618 filterPanel.slideDown(); 2619 2620 } 2621 }); 2622 2623 }, 2624 blogFiltersInit: function() { 2625 2626 SWIFT.blog.blogShowFilters(); 2627 jQuery('.filtering').animate({ 2628 opacity: 1 2629 }, 400); 2630 2631 // filter items when filter link is clicked 2632 jQuery('.filtering li').on('click', 'a', function(e) { 2633 e.preventDefault(); 2634 jQuery(this).parent().parent().find('li').removeClass('selected'); 2635 jQuery(this).parent().addClass('selected'); 2636 var selector = jQuery(this).data('filter'); 2637 var blogItems = jQuery(this).parents('.blog-wrap').find('.blog-items'); 2638 blogItems.isotope({ filter: selector }); 2639 }); 2640 2641 jQuery('.filter-wrap > a').on('click', function(e) { 2642 e.preventDefault(); 2643 jQuery(this).parent().find('.filter-slide-wrap').slideToggle(); 2644 }); 2645 }, 2646 blogShowFilters: function() { 2647 // Enable filter options on when there are items from that skill 2648 jQuery('.filtering li').each( function() { 2649 var filter = jQuery(this), 2650 filterName = jQuery(this).find('a').attr('class'), 2651 blogItems = jQuery(this).parents('.blog-wrap').find('.blog-items'); 2652 2653 blogItems.find('.blog-item').each( function() { 2654 if ( jQuery(this).hasClass(filterName) ) { 2655 filter.addClass('has-items'); 2656 } 2657 }); 2658 }); 2659 }, 2660 blogLayout: function(blogInstance) { 2661 2662 var blogType = blogInstance.data('blog-type'), 2663 layoutMode = 'fitRows'; 2664 2665 if (blogType === "masonry") { 2666 layoutMode = 'masonry'; 2667 } 2668 2669 if (blogType === "masonry" && blogInstance.hasClass('social-blog')) { 2670 var tweets = blogInstance.parent().find('.blog-tweets').html(), 2671 instagrams = blogInstance.parent().find('.blog-instagrams'); 2672 2673 blogInstance.imagesLoaded(function () { 2674 SWIFT.flexSlider.thumb(); 2675 blogInstance.isotope({ 2676 resizable: false, 2677 itemSelector : '.blog-item', 2678 layoutMode: 'masonry', 2679 getSortData : { 2680 date : function ( elem ) { 2681 return jQuery(elem).data('date'); 2682 } 2683 }, 2684 sortBy: 'date', 2685 sortAscending: false, 2686 isOriginLeft: !isRTL 2687 });
2688 if (tweets !== "") { 2689 blogInstance.isotope('insert', jQuery(tweets)); 2690 } 2691 if (instagrams.length > 0) { 2692 SWIFT.blog.masonryInstagram(instagrams, blogInstance); 2693 } 2694 blogInstance.isotope('updateSortData').isotope(); 2695 2696 setTimeout(function() { 2697 $window.trigger('resize'); 2698 }, 400); 2699 2700 if ( isMobileAlt ) { 2701 setTimeout(function() { 2702 blogInstance.isotope('layout'); 2703 }, 1000); 2704 } 2705 2706 }); 2707 2708 } else { 2709 blogInstance.imagesLoaded(function () { 2710 SWIFT.flexSlider.thumb(); 2711 blogInstance.isotope({ 2712 resizable: true, 2713 layoutMode: layoutMode, 2714 isOriginLeft: !isRTL 2715 }); 2716 }); 2717 blogInstance.appear(function() { 2718 SWIFT.blog.animateItems(blogInstance); 2719 }); 2720 } 2721 }, 2722 masonryInstagram: function(instagrams, blogItems) { 2723 var userID = instagrams.data('userid'), 2724 token = instagrams.data('token'), 2725 count = instagrams.data('count'), 2726 itemClass = instagrams.data('itemclass'), 2727 clientid = '756db9880cc84c3dab85118df38f9b91'; 2728 2729 jQuery.ajax({ 2730 type: "GET", 2731 dataType: "jsonp", 2732 cache: false, 2733 data: {client_id: clientid, count: count}, 2734 url: 'https://api.instagram.com/v1/users/' + userID + '/media/recent?access_token='
2734+ token, 2735 success: function(data) { 2736 for (var i = 0; i < count; i++) { 2737 if (data.data[i]) { 2738 var caption = ""; 2739 if (data.data[i].caption) { 2740 caption = data.data[i].caption.text; 2741 } 2742 instagrams.append("<li class='blog-item instagram-item "+itemClass+"' data-date='"+data.data[i].created_time+"'><a class='timestamp inst-icon' target='_blank' href='" + data.data[i].link +"'><i class='fa-instagram'></i></a><div class='inst-overlay'><a target='_blank' href='" + data.data[i].link +"'></a><h6>"+instagrams.data('title')+"</h6><h2>"+caption+"</h2><div class='name-divide'></div><data class='date timeago' title='"+data.data[i].created_time+"' value=''>"+data.data[i].created_time+"</data></div><img class='instagram-image' src='" + data.data[i].images.low_resolution.url +"' width='306px' height='306px' /></li>"); 2743 } 2744 } 2745 jQuery("data.timeago").timeago(); 2746 instagrams.imagesLoaded(function(){ 2747 blogItems.isotope('insert', jQuery(instagrams.html())); 2748 }); 2749 blogItems.isotope('updateSortData').isotope(); 2750 } 2751 }); 2752 }, 2753 animateItems: function(blogInstance) { 2754 blogInstance.find('.blog-item').each(function(i) { 2755 jQuery(this).delay(i*200).animate({ 2756 'opacity' : 1, 2757 }, 800, 'easeOutExpo', function() { 2758 jQuery(this).addClass('item-animated'); 2759 }); 2760 }); 2761 }, 2762 blogGrid: function(gridItems) { 2763 var tweets = gridItems.parent().find('.blog-tweets').html(), 2764 instagrams = gridItems.parent().find('.blog-instagrams'); 2765 2766 gridItems.imagesLoaded(function () { 2767 SWIFT.flexSlider.thumb(); 2768 gridItems.isotope({ 2769 resizable: false, 2770 itemSelector : '.blog-item', 2771 layoutMode: 'fitRows', 2772 getSortData : { 2773 id : function ( elem ) { 2774 return jQuery(elem).data('sortid'); 2775 } 2776 }, 2777 sortBy: 'id', 2778 sortAscending: true, 2779 isOriginLeft: !isRTL 2780 }); 2781 if (tweets !== "") { 2782 gridItems.isotope('insert', jQuery(tweets)); 2783 } 2784 if (instagrams.length > 0) { 2785 SWIFT.blog.blogGridInstagram(instagrams, gridItems); 2786 } 2787 gridItems.isotope('updateSortData').isotope(); 2788 SWIFT.blog.blogGridResize(); 2789 }).animate({ 2790 'opacity' : 1 2791 }, 800, 'easeOutExpo'); 2792 2793 $window.smartresize( function() { 2794 SWIFT.blog.blogGridResize(); 2795 }); 2796 2797 }, 2798 blogGridResize: function() { 2799 blogItems.find('.grid-items').each(function() { 2800 var gridItem = jQuery(this).find('.blog-item'), 2801 itemWidth = gridItem.first().width(); 2802 if (gridItem.first().hasClass('col-sm-sf-25')) { 2803 itemWidth = itemWidth / 2; 2804 } 2805 gridItem.css('height', itemWidth); 2806 }); 2807 setTimeout(function() { 2808 jQuery(".tweet-text,.quote-excerpt").dotdotdot(); 2809 blogItems.find('.grid-items').isotope('layout'); 2810 }, 500); 2811 }, 2812 blogGridInstagram: function(instagrams, gridItems) { 2813 var userID = instagrams.data('userid'), 2814 token = instagrams.data('token'), 2815 count = instagrams.data('count'), 2816 clientid = '756db9880cc84c3dab85118df38f9b91'; 2817 2818 jQuery.ajax({ 2819 url: 'https://api.instagram.com/v1/users/' + userID + '/media/recent?access_token='
2819+ token, // specify the ID of the first found user 2820 dataType: 'jsonp', 2821 type: 'GET', 2822 data: {client_id: clientid, count: count}, 2823 success: function(data) { 2824 for (var i = 0; i < count; i++) { 2825 if (data.data[i]) { 2826 var caption = ""; 2827 if (data.data[i].caption) { 2828 caption = data.data[i].caption.text; 2829 } 2830 instagrams.append("<li class='blog-item col-sm-sf-5 instagram-item' data-date='"+data.data[i].created_time+"' data-sortid='"+i*2+"'><a class='timestamp inst-icon' target='_blank' href='" + data.data[i].link +"'><i class='fa-instagram'></i></a><div class='inst-img-wrap'><div class='inst-overlay'><a target='_blank' href='" + data.data[i].link +"'></a><h6>"+instagrams.data('title')+"</h6><h2>"+caption+"</h2><div class='name-divide'></div><data class='date timeago' title='"+data.data[i].created_time+"' value=''>"+data.data[i].created_time+"</data></div><img class='instagram-image' src='" + data.data[i].images.low_resolution.url +"' /></div></li>"); 2831 } 2832 } 2833 jQuery("data.timeago").timeago(); 2834 SWIFT.blog.blogGridResize(); 2835 instagrams.imagesLoaded(function(){ 2836 gridItems.isotope('insert', jQuery(instagrams.html())); 2837 SWIFT.blog.blogGridResize(); 2838 }); 2839 gridItems.isotope('updateSortData').isotope(); 2840 } 2841 }); 2842 }, 2843 infiniteScroll: function() { 2844 if (!(IEVersion && IEVersion < 9)) { 2845 var infScrollData = jQuery('#inf-scroll-params'); 2846 var infiniteScroll = { 2847 loading: { 2848 img: infScrollData.data('loadingimage'), 2849 msgText: infScrollData.data('msgtext'), 2850 finishedMsg: infScrollData.data('finishedmsg') 2851 }, 2852 "nextSelector":".pagenavi li.next a", 2853 "navSelector":".pagenavi", 2854 "itemSelector":".blog-item", 2855 "contentSelector":".blog-items" 2856 }; 2857 jQuery( infiniteScroll.contentSelector ).infinitescroll( 2858 infiniteScroll, function(elements) { 2859 SWIFT.flexSlider.thumb(); 2860 //blogItems.fitVids(); 2861 blogItems.imagesLoaded(function () { 2862 blogItems.isotope( 'appended', elements ); 2863 jQuery.each(elements, function(i, element) { 2864 jQuery(element).addClass('item-animated'); 2865 }); 2866 }); 2867 jQuery('[data-rel="ilightbox[posts]"]').removeClass('ilightbox-enabled').iLightBox().destroy(); 2868 SWIFT.page.lightbox(); 2869 SWIFT.blog.blogShowFilters(); 2870 if (blogItems.parent().find('.pagination-wrap').hasClass('load-more')) { 2871 jQuery('.load-more-btn').animate({ 2872 'opacity': 1 2873 }, 400); 2874 } 2875 } 2876 ); 2877 if (blogItems.parent().find('.pagination-wrap').hasClass('load-more')) { 2878 $window.unbind('.infscr'); 2879 jQuery('.load-more-btn').on('click', function(e) { 2880 e.preventDefault(); 2881 jQuery( infiniteScroll.contentSelector ).infinitescroll('retrieve'); 2882 jQuery('.load-more-btn').animate({ 2883 'opacity': 0 2884 }, 400); 2885 }); 2886 } 2887 } else { 2888 jQuery('.pagination-wrap').removeClass('hidden'); 2889 } 2890 } 2891 }; 2892 2893 ///////////////////////////////////////////// 2894 // GALLERIES 2895 ///////////////////////////////////////////// 2896 2897 var galleriesContainer = jQuery('.galleries-wrap').find('.filterable-items'); 2898 2899 SWIFT.galleries = { 2900 init: function() { 2901 galleriesContainer.each(function() { 2902 var galleriesInstance = jQuery(this); 2903 if (galleriesInstance.hasClass('masonry-items')) { 2904 SWIFT.galleries.masonrySetup(galleriesInstance); 2905 } else { 2906 SWIFT.galleries.standardSetup(galleriesInstance); 2907 } 2908 }); 2909 2910 // PORTFOLIO WINDOW RESIZE 2911 $window.smartresize( function() { 2912 SWIFT.galleries.windowResized(); 2913 }); 2914 2915 // Enable filter options on when there are items from that skill 2916 jQuery('.filtering li').each( function() { 2917 var filter = jQuery(this), 2918 filterName = jQuery(this).find('a').attr('class'), 2919 galleryItems = jQuery(this).parents('.galleries-wrap').find('.filterable-items'); 2920 2921 galleryItems.find('.gallery-item').each( function() { 2922 if ( jQuery(this).hasClass(filterName) ) { 2923 filter.addClass('has-items'); 2924 } 2925 }); 2926 }).parents('.filtering').animate({ 2927 opacity: 1 2928 }, 400); 2929 2930 // filter items when filter link is clicked 2931 jQuery('.filtering li').on('click', 'a', function(e) { 2932 e.preventDefault(); 2933 jQuery(this).parent().parent().find('li').removeClass('selected'); 2934 jQuery(this).parent().addClass('selected'); 2935 var selector = jQuery(this).data('filter'); 2936 var galleryItems = jQuery(this).parents('.galleries-wrap').find('.filterable-items'); 2937 galleryItems.isotope({ filter: selector }); 2938 }); 2939 }, 2940 standardSetup: function(galleryInstance) { 2941 galleryInstance.imagesLoaded(function () { 2942 SWIFT.galleries.setItemHeight(); 2943 galleryInstance.animate({opacity: 1}, 800); 2944 galleryInstance.isotope({ 2945 resizable: true, 2946 layoutMode: 'fitRows', 2947 isOriginLeft: !isRTL 2948 }); 2949 });
2950 galleryInstance.appear(function() { 2951 SWIFT.galleries.animateItems(galleryInstance); 2952 }); 2953 }, 2954 masonrySetup: function(galleryInstance) { 2955 galleryInstance.imagesLoaded(function () { 2956 galleryInstance.isotope({ 2957 resizable: false, 2958 itemSelector : '.gallery-item', 2959 layoutMode: 'masonry', 2960 isOriginLeft: !isRTL 2961 }); 2962 }); 2963 galleryInstance.appear(function() { 2964 SWIFT.galleries.animateItems(galleryInstance); 2965 }); 2966 }, 2967 animateItems: function(galleryInstance) { 2968 galleryInstance.find('.gallery-item').each(function(i) { 2969 jQuery(this).delay(i*200).animate({ 2970 'opacity' : 1 2971 }, 800, 'easeOutExpo', function() { 2972 jQuery(this).addClass('item-animated'); 2973 }); 2974 }); 2975 }, 2976 setItemHeight: function() { 2977 if (!galleriesContainer.hasClass('col-1') && !galleriesContainer.hasClass('masonry-items')) { 2978 galleriesContainer.children().css('min-height','0'); 2979 galleriesContainer.equalHeights(); 2980 } 2981 }, 2982 windowResized: function() { 2983 if (!galleriesContainer.hasClass('col-1') && !galleriesContainer.hasClass('masonry-items')) { 2984 SWIFT.galleries.setItemHeight(); 2985 } 2986 }, 2987 }; 2988 2989 2990 ///////////////////////////////////////////// 2991 // GALLERY 2992 ///////////////////////////////////////////// 2993 2994 SWIFT.gallery = { 2995 init: function() { 2996 2997 jQuery('.spb_gallery_widget').each(function() { 2998 if (jQuery(this).hasClass('gallery-masonry')) { 2999 SWIFT.gallery.galleryMasonry(jQuery(this).find('.filterable-items')); 3000 } else if (jQuery(this).hasClass('gallery-slider')) { 3001 SWIFT.gallery.gallerySlider(jQuery(this)); 3002 } 3003 }); 3004 }, 3005 galleryMasonry: function(element) { 3006 element.imagesLoaded(function () { 3007 element.isotope({ 3008 resizable: false, 3009 itemSelector : '.gallery-image', 3010 layoutMode: 'masonry', 3011 isOriginLeft: !isRTL 3012 }); 3013 }); 3014 element.appear(function() { 3015 SWIFT.gallery.animateItems(element); 3016 }); 3017 }, 3018 animateItems: function(element) { 3019 element.find('.gallery-image').each(function(i) { 3020 jQuery(this).delay(i*200).animate({ 3021 'opacity' : 1 3022 }, 800, 'easeOutExpo', function() { 3023 jQuery(this).addClass('item-animated'); 3024 }); 3025 }); 3026 }, 3027 gallerySlider: function(element) { 3028 3029 var gallerySlider = element.find('.gallery-slider'), 3030 galleryNav = element.find('.gallery-nav'), 3031 galleryAuto = gallerySlider.data('autoplay'); 3032 3033 if (galleryAuto === "yes") { 3034 galleryAuto = true; 3035 } else { 3036 galleryAuto = false; 3037 } 3038 3039 galleryNav.flexslider({ 3040 animation: "slide", 3041 directionNav: true, 3042 controlNav: false, 3043 animationLoop: sliderLoop, 3044 slideshow: false, 3045 itemWidth: 100, 3046 itemMargin: 30, 3047 rtl: isRTL, 3048 asNavFor: gallerySlider 3049 }); 3050 3051 gallerySlider.flexslider({ 3052 animation: gallerySlider.data('transition'), 3053 slideshow: false, 3054 slideshowSpeed: sliderSlideSpeed, //Integer: Set the speed of the slideshow cycling, in milliseconds 3055 animationDuration: sliderAnimSpeed, //Integer: Set the speed of animations, in milliseconds 3056 controlNav: false, 3057 animationLoop: sliderLoop, 3058 rtl: isRTL, 3059 sync: galleryNav, 3060 start: function() { 3061 if ( galleryAuto ) { 3062 gallerySlider.appear(function() { 3063 gallerySlider.flexslider('play'); 3064 }); 3065 } 3066 } 3067 }); 3068 3069 } 3070 }; 3071 3072 3073 ///////////////////////////////////////////// 3074 // RECENT POSTS 3075 ///////////////////////////////////////////// 3076 3077 SWIFT.recentPosts = { 3078 init: function() { 3079 3080 // TEAM EQUAL HEIGHTS 3081 var recentPostItems = jQuery('.recent-posts:not(.carousel-items,.posts-type-list)'); 3082 recentPostItems.imagesLoaded(function () { 3083 SWIFT.flexSlider.thumb(); 3084 recentPostItems.equalHeights(); 3085 }); 3086 3087 // TEAM ASSETS 3088 $window.smartresize( function() { 3089 jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').children().css('min-height','0'); 3090 jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').equalHeights(); 3091 }); 3092 } 3093 }; 3094 3095 3096 ///////////////////////////////////////////// 3097 // CAROUSEL FUNCTIONS 3098 ///////////////////////////////////////////// 3099 3100 SWIFT.carouselWidgets = { 3101 init: function() { 3102 3103 // CAROUSELS 3104 var carousel = jQuery('.carousel-items'), 3105 carouselAuto = sfOptionParams.data('carousel-autoplay'), 3106 carouselPSpeed = sfOptionParams.data('carousel-pagespeed'), 3107 carouselSSpeed = sfOptionParams.data('carousel-slidespeed'), 3108 carouselPagination = sfOptionParams.data('carousel-pagination'), 3109 carouselPDirection = 'ltr', 3110 desktopWidth = 1199; 3111 3112 if (body.hasClass('vertical-header')) { 3113 desktopWidth = desktopWidth + jQuery('#header-section').width(); 3114 } 3115 3116 if (carouselAuto) { 3117 carouselAuto = true; 3118 } else { 3119 carouselAuto = false; 3120 } 3121 if (carouselPagination) { 3122 carouselPagination = true; 3123 } else { 3124 carouselPagination = false; 3125 } 3126 if (isRTL) { 3127 carouselPDirection = 'rtl'; 3128 } 3129 3130 carousel.each(function() { 3131 var carouselInstance = jQuery('#'+jQuery(this).attr('id')), 3132 carouselColumns = parseInt(carouselInstance.attr("data-columns"), 10),
3133 desktopCarouselItems = 4 > carouselColumns ? carouselColumns : 4, 3134 desktopSmallCarouselItems = 3 > carouselColumns ? carouselColumns : 3, 3135 mobileCarouselItems = 1; 3136 3137 if (carouselInstance.hasClass('clients-items')) { 3138 mobileCarouselItems = 2; 3139 } 3140 if (carouselInstance.hasClass('testimonials')) { 3141 desktopCarouselItems = 1; 3142 desktopSmallCarouselItems = 1; 3143 mobileCarouselItems = 1; 3144 } 3145 3146 carouselInstance.imagesLoaded(function () { 3147 3148 if (!carouselInstance.hasClass('no-gutters')) { 3149 var carouselWidth = carouselInstance.width(); 3150 if (isRTL) { 3151 carouselInstance.css('margin-right', '-15px').css('width', carouselWidth); 3152 } else { 3153 carouselInstance.css('margin-left', '-15px').css('width', carouselWidth); 3154 } 3155 } 3156 3157 carouselInstance.owlCarousel({ 3158 items : carouselColumns, 3159 itemsDesktop: [desktopWidth,desktopCarouselItems], 3160 itemsDesktopSmall: [desktopWidth-220,desktopSmallCarouselItems], 3161 itemsTablet: mobileCarouselItems, 3162 itemsMobile: [479,mobileCarouselItems], 3163 paginationSpeed: carouselPSpeed, 3164 slideSpeed: carouselSSpeed, 3165 autoPlay: carouselAuto, 3166 autoPlayDirection : carouselPDirection, 3167 pagination: carouselPagination, 3168 autoHeight : true, 3169 beforeUpdate: function() { 3170 if (!carouselInstance.hasClass('no-gutters')) { 3171 carouselInstance.css('width', ''); 3172 var carouselWidth = carouselInstance.width(); 3173 carouselInstance.css('width', carouselWidth); 3174 } 3175 }, 3176 afterUpdate: function () { 3177 carouselInstance.find('.flex-active-slide').resize(); 3178 }, 3179 afterInit: function() { 3180 SWIFT.flexSlider.thumb(); 3181 carouselInstance.find('.flex-active-slide').resize(); 3182 carouselInstance.find('.owl-wrapper-outer').css('height', carouselInstance.find('.owl-wrapper').height()); 3183 } 3184 }).animate({ 3185 'opacity': 1 3186 },800); 3187 3188 SWIFT.carouselWidgets.carouselMinHeight(carouselInstance); 3189 $window.smartresize( function() { 3190 SWIFT.carouselWidgets.carouselMinHeight(carouselInstance); 3191 }); 3192 3193 }); 3194 }); 3195 3196 // Previous 3197 jQuery('.carousel-next').click( function(e) { 3198 e.preventDefault(); 3199 var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel'); 3200 if (isRTL) { 3201 carousel.data( 'owlCarousel' ).prev(); 3202 } else { 3203 carousel.data( 'owlCarousel' ).next(); 3204 } 3205 }); 3206 3207 // Next 3208 jQuery('.carousel-prev').click( function(e) { 3209 e.preventDefault(); 3210 var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel'); 3211 if (isRTL) { 3212 carousel.data( 'owlCarousel' ).next(); 3213 } else { 3214 carousel.data( 'owlCarousel' ).prev(); 3215 } 3216 }); 3217 }, 3218 carouselSwipeIndicator: function(carousel) { 3219 carousel.appear(function() { 3220 var swipeIndicator = jQuery(this).parents('.carousel-wrap').find('.sf-swipe-indicator'); 3221 setTimeout(function() { 3222 swipeIndicator.fadeIn(500); 3223 }, 400); 3224 setTimeout(function() { 3225 swipeIndicator.addClass('animate'); 3226 }, 1000); 3227 setTimeout(function() { 3228 swipeIndicator.fadeOut(400); 3229 }, 3000); 3230 }); 3231 }, 3232 carouselMinHeight: function(carousel) { 3233 var minHeight = parseInt(carousel.find('.carousel-item:not(.no-thumb)').eq(0).css('height')); 3234 carousel.find('.owl-item').each(function () { 3235 jQuery(this).css('min-height',minHeight+'px'); 3236 }); 3237 } 3238 }; 3239 3240 3241 ///////////////////////////////////////////// 3242 // WIDGET FUNCTIONS 3243 ///////////////////////////////////////////// 3244 3245 SWIFT.widgets = { 3246 init: function() { 3247 3248 // LOAD WIDGETS 3249 SWIFT.widgets.accordion(); 3250 SWIFT.widgets.toggle(); 3251 SWIFT.widgets.fullWidthVideo(); 3252 SWIFT.widgets.introAnimations(); 3253 SWIFT.widgets.iconBoxes(); 3254 3255 // SF TOOLTIPS 3256 if (jQuery('[rel=tooltip]').length > 0) { 3257 jQuery('[rel=tooltip]').tooltip(); 3258 } 3259 3260 // DYNAMIC TABS 3261 jQuery('.tabs-type-dynamic .menu-icon').hover(function() { 3262 jQuery(this).parents('.nav-tabs').addClass('show-tabs'); 3263 }); 3264 3265 jQuery('.tabs-type-dynamic').mouseleave(function() { 3266 jQuery(this).find('.nav-tabs').removeClass('show-tabs'); 3267 }); 3268 3269 jQuery('ul.nav-tabs li a, .spb_accordion_section > h3 a').on('click', '', function(){ 3270 var thisTab = jQuery(this), 3271 asset = thisTab.parents('.spb_content_element').first(); 3272 3273 setTimeout(function() { 3274 $window.trigger('resize');
3275 if (asset.find('.map-canvas').length > 0) { 3276 var map = asset.find('.map-canvas'); 3277 map.each(function() { 3278 google.maps.event.trigger(jQuery(this), "resize"); 3279 }); 3280 } 3281 }, 300); 3282 }); 3283 3284 }, 3285 accordion: function() { 3286 jQuery('.spb_accordion').each(function() { 3287 var spb_tabs, 3288 active_tab = false, 3289 active_attr = parseInt(jQuery(this).attr('data-active'), 10); 3290 3291 if (jQuery.type( active_attr ) === "number") { active_tab = active_attr; } 3292 3293 spb_tabs = jQuery(this).find('.spb_accordion_wrapper').accordion({ 3294 header: "> div > h4", 3295 autoHeight: true, 3296 collapsible: true, 3297 active: active_tab, 3298 heightStyle: "content", 3299 activate: function() { 3300 setTimeout(function() { 3301 $window.trigger('resize'); 3302 }, 1000); 3303 } 3304 }); 3305 }).css('opacity', 1); 3306 }, 3307 tabs: function() { 3308 // SET ACTIVE TABS PANE 3309 setTimeout(function() { 3310 jQuery('.spb_tabs').each(function() { 3311 jQuery(this).find('.tab-pane').first().addClass('active'); 3312 jQuery(this).find('.tab-pane').removeClass('load'); 3313 }); 3314 }, 200); 3315 3316 // SET ACTIVE TOUR PANE 3317 setTimeout(function() { 3318 jQuery('.spb_tour').each(function() { 3319 jQuery(this).find('.tab-pane').first().addClass('active'); 3320 jQuery(this).find('.tab-pane').removeClass('load'); 3321 }); 3322 }, 200); 3323 3324 // RESET MAPS ON TAB CLICK 3325 jQuery('ul.nav-tabs li a, .spb_accordion_section > h4 a').on('click', '', function(){ 3326 var thisTab = jQuery(this), 3327 asset = thisTab.parents('.spb_content_element').first(); 3328 3329 if (asset.find('.map-canvas').length > 0) { 3330 setTimeout(function() { 3331 jQuery(window).trigger('resize'); 3332 var map = asset.find('.map-canvas'); 3333 SWIFT.map.init(); 3334 }, 100); 3335 } 3336 }); 3337 3338 // SET DESIRED TAB ON LOAD 3339 setTimeout(function() { 3340 if (jQuery('.spb_tabs').length > 0) { 3341 3342 // Show correct tab on page load 3343 var tabUrl = document.location.toString(); 3344 if (tabUrl.match('#') && jQuery('.nav-tabs a[href="#'+tabUrl.split('#')[1]+'"]').length > 0) { 3345 var thisTab = jQuery('.nav-tabs a[href="#'+tabUrl.split('#')[1]+']"'), 3346 tabHash = tabUrl.split('#')[1]; 3347 3348 jQuery('.nav-tabs a[href="#'+tabHash+'"]').tab('show'); 3349 } 3350 3351 // Change hash on tab click 3352 jQuery('.nav-tabs a').click(function (e) { 3353 var hash = e.target.hash; 3354 3355 if (history.pushState) { 3356 history.pushState(null, null, hash); 3357 } else { 3358 location.hash = hash; 3359 } 3360 }); 3361 } 3362 if (jQuery('.spb_accordion').length > 0) { 3363 3364 // Show correct accordion section on page load 3365 var accordionUrl = document.location.toString(); 3366 if (accordionUrl.match('#') && jQuery('.spb_accordion a[href="#'+accordionUrl.split('#')[1]+'"]').length > 0) { 3367 var thisAccordion = jQuery('.spb_accordion a[href="#'+accordionUrl.split('#')[1]+'"]'), 3368 accordionHash = accordionUrl.split('#')[1]; 3369 3370 jQuery('.spb_accordion a[href="#'+accordionHash+'"]').click(); 3371 } 3372 3373 // Change hash on tab click 3374 jQuery('.spb_accordion a').click(function (e) { 3375 var hash = e.target.hash; 3376 3377 if (history.pushState) { 3378 history.pushState(null, null, hash); 3379 } else { 3380 location.hash = hash; 3381 } 3382 }); 3383 } 3384 3385 if (jQuery('.spb_tour').length > 0) { 3386 3387 // Show correct accordion section on page load 3388 var tourUrl = document.location.toString(); 3389 if (tourUrl.match('#') && jQuery('.spb_tour a[href="#'+tourUrl.split('#')[1]+'"]').length > 0) { 3390 var thisTour = jQuery('.spb_tour a[href="#'+tourUrl.split('#')[1]+'"]'), 3391 tourHash = tourUrl.split('#')[1]; 3392 3393 jQuery('.spb_tour a[href="#'+tourHash+'"]').click(); 3394 } 3395 3396 // Change hash on tab click 3397 jQuery('.spb_tour a').click(function (e) { 3398 var hash = e.target.hash; 3399 3400 if ( history.pushState ) { 3401 history.pushState(null, null, hash); 3402 } else { 3403 location.hash = hash; 3404 } 3405 });
3406 } 3407 3408 }, 220); 3409 }, 3410 toggle: function() { 3411 jQuery('.spb_toggle').click(function() { 3412 if ( jQuery(this).hasClass('spb_toggle_title_active') ) { 3413 jQuery(this).removeClass('spb_toggle_title_active').next().slideUp(500); 3414 } else { 3415 jQuery(this).addClass('spb_toggle_title_active').next().slideDown(500); 3416 } 3417 }); 3418 jQuery('.spb_toggle_content').each(function() { 3419 if ( jQuery(this).next().is('h4.spb_toggle') === false ) { 3420 jQuery('<div class="last_toggle_el_margin"></div>').insertAfter(this); 3421 } 3422 }); 3423 }, 3424 initSkillBars: function() { 3425 // SKILL BARS 3426 SWIFT.widgets.animateSkillBars(); 3427 jQuery('a.ui-tabs-anchor').click(function(){ 3428 SWIFT.widgets.animateSkillBars(); 3429 }); 3430 }, 3431 animateSkillBars: function() { 3432 jQuery('.progress:not(.animated)').each(function(){ 3433 var progress = jQuery(this); 3434 3435 progress.appear(function() { 3436 var progressBar = jQuery(this), 3437 progressValue = progressBar.find('.bar').data('value'); 3438 progressBar.addClass('animated'); 3439 progressBar.find('.bar').animate({ 3440 width: progressValue + "%" 3441 }, 800, function() { 3442 progressBar.parent().find('.bar-text').css('width', progressValue + "%"); 3443 progressBar.parent().find('.bar-text .progress-value').fadeIn(600); 3444 }); 3445 }); 3446 }); 3447 }, 3448 fullWidthVideo: function() { 3449 body.on('click', '.fw-video-link', function(){ 3450 if (jQuery(this).data('video') !== "") { 3451 SWIFT.widgets.openFullWidthVideo(jQuery(this)); 3452 } 3453 return false; 3454 }); 3455 3456 body.on('click', '.fw-video-close', function(){ 3457 SWIFT.widgets.closeFullWidthVideo(); 3458 }); 3459 }, 3460 openFullWidthVideo: function(element) { 3461 jQuery('.fw-video-close').addClass('is-open'); 3462 jQuery('.fw-video-spacer').animate({ 3463 height: windowheight 3464 }, 1000, 'easeInOutExpo'); 3465 3466 jQuery('.fw-video-area').css('display', 'block').animate({ 3467 top: 0, 3468 height: '100%' 3469 }, 1000, 'easeInOutExpo', function() { 3470 // load video here 3471 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>'); 3472 }); 3473 }, 3474 closeFullWidthVideo: function() { 3475 jQuery('.fw-video-close').removeClass('is-open'); 3476 jQuery('.fw-video-spacer').animate({ 3477 height: 0 3478 }, 1000, 'easeInOutExpo', function(){ 3479 }); 3480 jQuery('.fw-video-area').animate({ 3481 top:'-100%' 3482 }, 1000, 'easeInOutExpo', function() { 3483 jQuery('.fw-video-area').css('display', 'none'); 3484 jQuery('.fw-video-area .fw-video').remove(); 3485 }); 3486 3487 // pause videos 3488 jQuery('.fw-video-area video').each(function(){ 3489 this.pause(); 3490 }); 3491 setTimeout(function() { 3492 jQuery('.fw-video-area').find('iframe').remove(); 3493 }, 1500); 3494 3495 return false; 3496 }, 3497 introAnimations: function() { 3498 3499 if (!(isMobileAlt && body.hasClass('disable-mobile-animations'))) { 3500 jQuery('.sf-animation').each(function() { 3501 3502 var animatedItem = jQuery(this), 3503 itemAnimation = animatedItem.data('animation'), 3504 itemDelay = animatedItem.data('delay'); 3505 3506 animatedItem.appear(function() { 3507 setTimeout(function() { 3508 window.requestAnimationFrame( function() { 3509 animatedItem.addClass(itemAnimation); 3510 setTimeout(function() { 3511 animatedItem.addClass('sf-animate'); 3512 }, 100); 3513 }); 3514 }, itemDelay); 3515 }, {accX: 0, accY: -150}, 'easeInCubic'); 3516 3517 }); 3518 } 3519 }, 3520 iconBoxes: function() { 3521 if (isMobileAlt) { 3522 jQuery('.sf-icon-box').on('click', function() { 3523 jQuery(this).addClass('sf-mobile-hover'); 3524 }); 3525 } else { 3526 jQuery('.sf-icon-box').hover( 3527 function() { 3528 jQuery(this).addClass('sf-hover'); 3529 }, function() { 3530 jQuery(this).removeClass('sf-hover'); 3531 } 3532 ); 3533 } 3534 } 3535 }; 3536 3537 3538 ///////////////////////////////////////////// 3539 // TEAM MEMBERS FUNCTION 3540 ///////////////////////////////////////////// 3541 3542 SWIFT.teamMembers = { 3543 init: function() { 3544 // TEAM EQUAL HEIGHTS
3545 var team = jQuery('.team-members:not(.carousel-items)'); 3546 team.imagesLoaded(function () { 3547 if ($window.width() > 767) { 3548 team.equalHeights(); 3549 } 3550 }); 3551 3552 // TEAM ASSETS 3553 $window.smartresize( function() { 3554 jQuery('.team-members:not(.carousel-items)').children().css('min-height','0'); 3555 if ($window.width() > 767) { 3556 jQuery('.team-members:not(.carousel-items)').equalHeights(); 3557 } 3558 }); 3559 } 3560 }; 3561 3562 3563 ///////////////////////////////////////////// 3564 // RELATED POSTS FUNCTION 3565 ///////////////////////////////////////////// 3566 3567 SWIFT.relatedPosts = { 3568 init: function() { 3569 // TEAM EQUAL HEIGHTS 3570 var relatedItems = jQuery('.related-items'); 3571 relatedItems.imagesLoaded(function () { 3572 if ($window.width() > 767) { 3573 relatedItems.equalHeights(); 3574 } 3575 }); 3576 3577 // TEAM ASSETS 3578 $window.smartresize( function() { 3579 jQuery('.related-items').children().css('min-height','0'); 3580 if ($window.width() > 767) { 3581 jQuery('.related-items').equalHeights(); 3582 } 3583 }); 3584 } 3585 }; 3586 3587 3588 3589 ///////////////////////////////////////////// 3590 // MAP FUNCTIONS 3591 ///////////////////////////////////////////// 3592 3593 var mapsArray =[], boundsArray = [], infowindow, bounds, directory_bounds, mapTypeIdentifier = "", mapType, mapColor, mapSaturation, mapCenterLat, mapCenterLng, companyPos = "", isDraggable = true, latitude, longitude, mapCoordinates, markersArray = [], pinTitle, pinContent, pinLink, address, pinButtonText, pinLogoURL = ""; 3594 3595 3596 3597 SWIFT.map = { 3598 init:function() { 3599 3600 var maps = jQuery('.map-canvas'); 3601 var mapContainer; 3602 3603 if (typeof google !== 'undefined') { 3604 bounds = new google.maps.LatLngBounds(); 3605 } 3606 3607 maps.each(function(i, element) { 3608 mapContainer = element; 3609 var mapZoom = mapContainer.getAttribute('data-zoom'); 3610 3611 mapType = mapContainer.getAttribute('data-maptype'); 3612 mapColor = mapContainer.getAttribute('data-mapcolor'); 3613 mapCenterLat = mapContainer.getAttribute('data-center-lat'); 3614 mapCenterLng = mapContainer.getAttribute('data-center-lng'); 3615 mapSaturation = mapContainer.getAttribute('data-mapsaturation'); 3616 3617 SWIFT.map.createMap( mapContainer, mapZoom, mapType, mapColor, mapSaturation, jQuery(this), mapCenterLat, mapCenterLng ); 3618 }); 3619 3620 }, 3621 getLatLong: function(address, pintit, pinimage, fn) { 3622 var geocoder; 3623 geocoder = new google.maps.Geocoder(); 3624 geocoder.geocode( { 'address': address}, function(results, status) { 3625 if ( results[0] ) { 3626 fn(results[0].geometry.location, results[0].geometry.location.lat(), results[0].geometry.location.lng(), pintit, pinimage); 3627 } 3628 }); 3629 }, 3630 addWinContent: function(marker, html, map) { 3631 google.maps.event.addListener(marker, 'click', function() { 3632 infowindow.setContent(html); 3633 infowindow.open(map, marker); 3634 }); 3635 }, 3636 addMarker: function(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText) { 3637 var companyMarker; 3638 3639 mapCoordinates = new google.maps.LatLng(latitude, longitude); 3640 3641 if (pinLogoURL) { 3642 companyPos = new google.maps.LatLng(latitude, longitude); 3643 companyMarker = new google.maps.Marker({ 3644 position: mapCoordinates, 3645 map: mapInstance, 3646 icon: pinLogoURL, 3647 animation: google.maps.Animation.DROP }); 3648 } else { 3649 companyPos = new google.maps.LatLng(latitude, longitude); 3650 companyMarker = new google.maps.Marker({ 3651 position: mapCoordinates, 3652 map: mapInstance, 3653 animation: google.maps.Animation.DROP }); 3654 } 3655 3656 var html = '<div class="pinmarker">'; 3657 if (pinTitle !== "") { 3658 html += '<h3>'+pinTitle+'</h3>'; 3659 } 3660 if (pinContent !== "") { 3661 html += '<p>'+pinContent+' </p>'; 3662 } 3663 if (pinLink !== "" && pinButtonText !== "") { 3664 html += '<div><a href="http://' + pinLink + '" target="_blank">'+pinButtonText+'</a></div>'; 3665 } 3666 html += '</div>'; 3667 3668 infowindow = new google.maps.InfoWindow(); 3669 SWIFT.map.addWinContent(companyMarker, html, mapInstance); 3670 bounds.extend(mapCoordinates); 3671 }, 3672 createMap: function(mapContainer, mapZoom, mapType, mapColor, mapSaturation, targetMap, mapCenterLat, mapCenterLng) { 3673 3674 if (google) { 3675 directory_bounds = new google.maps.LatLngBounds(); 3676 } 3677 3678 var pinLogoURL = "", mapLightness = false; 3679 3680 if (mapSaturation == "mono-light") { 3681 if (mapColor === "") { 3682 mapColor = "#ffffff"; 3683 } 3684 mapSaturation = -100; 3685 } else if (mapSaturation == "mono-dark") { 3686 if (mapColor === "") { 3687 mapColor = "#222222"; 3688 } 3689 mapSaturation = -100; 3690 mapLightness = true; 3691 } else { 3692 mapSaturation = -20; 3693 } 3694 3695 var styles = [ 3696 { 3697 stylers: [ 3698 {hue: mapColor}, 3699 {"invert_lightness": mapLightness}, 3700 {saturation: mapSaturation} 3701 ] 3702 } 3703 ]; 3704 3705 var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"}); 3706 3707 if (isMobileAlt) { 3708 isDraggable = false; 3709 } 3710 3711 if (mapType === "satellite") { 3712 mapTypeIdentifier = google.maps.MapTypeId.SATELLITE; 3713 } else if (mapType === "terrain") { 3714 mapTypeIdentifier = google.maps.MapTypeId.TERRAIN; 3715 } else if (mapType === "hybrid") { 3716 mapTypeIdentifier = google.maps.MapTypeId.HYBRID; 3717 } else { 3718 mapTypeIdentifier = google.maps.MapTypeId.ROADMAP; 3719 } 3720 3721 var settings = { 3722 scrollwheel: false, 3723 draggable: isDraggable, 3724 mapTypeControl: true, 3725 mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, 3726 navigationControl: true, 3727 navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, 3728 mapTypeId: mapTypeIdentifier 3729 }; 3730 3731 var mapInstance = new google.maps.Map(mapContainer, settings); 3732 //var pinTitle, pinContent, pinLink, address, pinButtonText; 3733 var pincount = targetMap.parent().find('.pin_location').length; 3734 3735 mapsArray.push( mapInstance ); 3736 3737 //Resize Window Responsiveness 3738 google.maps.event.addDomListener(window, 'resize', function() { 3739 3740 jQuery.each( mapsArray, function( i, val ) { 3741 val.fitBounds(boundsArray[i]); 3742 val.setZoom(parseInt(mapZoom, 10)); 3743 3744 }); 3745 }); 3746 3747 bounds = new google.maps.LatLngBounds();
3748 boundsArray.push( bounds ); 3749 3750 targetMap.parent().find('.pin_location').each(function(i, element) { 3751 3752 pinLogoURL = element.getAttribute('data-pinimage'); 3753 pinTitle = element.getAttribute('data-title'); 3754 pinContent = element.getAttribute('data-content'); 3755 address = element.getAttribute('data-address'); 3756 pinLink = element.getAttribute('data-pinlink'); 3757 latitude = element.getAttribute('data-lat'); 3758 longitude = element.getAttribute('data-lng'); 3759 pinButtonText = element.getAttribute('data-button-text'); 3760 3761 3762 if (latitude === '' && longitude === '') { 3763 3764 SWIFT.map.getLatLong(address, pinTitle, pinLogoURL ,function(location, lati,longi, pintit, pinimage ){ 3765 3766 latitude = lati; 3767 longitude = longi; 3768 pinTitle = pintit; 3769 pinLogoURL = pinimage; 3770 3771 SWIFT.map.addMarker(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText); 3772 3773 if ( pincount > 1 ) { 3774 if(mapCenterLat !== '' && mapCenterLng !== ''){ 3775 mapInstance.setZoom(parseInt(mapZoom, 10)); 3776 mapInstance.setCenter(new google.maps.LatLng(mapCenterLat, mapCenterLng)); 3777 }else{ 3778 mapInstance.fitBounds(bounds); 3779 } 3780 } else { 3781 mapInstance.setZoom(parseInt(mapZoom, 10)); 3782 mapInstance.setCenter(new google.maps.LatLng(latitude, longitude)); 3783 } 3784 3785 }); 3786 3787 } else { 3788 3789 SWIFT.map.addMarker(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText); 3790 3791 if ( pincount > 1 ) { 3792 if(mapCenterLat !== '' && mapCenterLng !== ''){ 3793 mapInstance.setZoom(parseInt(mapZoom, 10)); 3794 mapInstance.setCenter(new google.maps.LatLng(mapCenterLat, mapCenterLng)); 3795 }else{ 3796 mapInstance.fitBounds(bounds); 3797 } 3798 } else { 3799 mapInstance.setZoom(parseInt(mapZoom, 10)); 3800 mapInstance.setCenter(new google.maps.LatLng(latitude, longitude)); 3801 } 3802 3803 } 3804 3805 }); 3806 3807 3808 // MAP COLOURIZE 3809 if ( mapType !== "satellite" ) { 3810 mapInstance.mapTypes.set('map_style', styledMap); 3811 mapInstance.setMapTypeId('map_style'); 3812 } 3813 3814 var listener = google.maps.event.addListener(mapInstance, "idle", function() { 3815 mapInstance.setZoom(parseInt( mapInstance.getZoom(), 10)); 3816 google.maps.event.removeListener(listener); 3817 }); 3818 3819 } 3820 }; 3821 3822 3823 ///////////////////////////////////////////// 3824 // MAP DIRECTORY FUNCTIONS 3825 ///////////////////////////////////////////// 3826 3827 SWIFT.mapDirectory = { 3828 init : function(searchTerm, locationFilter, categoryFilter) { 3829 3830 searchTerm = jQuery('#dir-search-value').val(); 3831 locationFilter = jQuery('.directory-location-option').val(); 3832 categoryFilter = jQuery('.directory-category-option').val(); 3833 3834 var mapsDirectory = jQuery('.map-directory-canvas'); 3835 var mapDirContainer, mapZoom; 3836 3837 mapsDirectory.each(function(i, element) { 3838 3839 var mapDirContainer = element, 3840 mapZoom = mapDirContainer.getAttribute('data-zoom'), 3841 mapType = mapDirContainer.getAttribute('data-maptype'), 3842 mapColor = mapDirContainer.getAttribute('data-mapcolor'), 3843 mapSaturation = mapDirContainer.getAttribute('data-mapsaturation'), 3844 mapExcerpt = mapDirContainer.getAttribute('data-excerpt'); 3845 3846 if ( categoryFilter == null || categoryFilter == 'All' ){ 3847 categoryFilter = mapDirContainer.getAttribute('data-directory-category'); 3848 } 3849 3850 SWIFT.mapDirectory.directoryMap( mapDirContainer, mapZoom, mapType, mapColor, mapSaturation, jQuery(this), searchTerm, locationFilter, categoryFilter); 3851 3852 }); 3853 }, 3854 searchDirectory: function(){ 3855 SWIFT.mapDirectory.init(jQuery('#dir-search-value').val(), jQuery('.directory-location-option').val(), jQuery('.directory-category-option').val()); 3856 }, 3857 getLatLong: function(address, fn){ 3858 var geocoder; 3859 geocoder = new google.maps.Geocoder(); 3860 geocoder.geocode( { 'address': address}, function(results, status) { 3861 fn(results[0].geometry.location, results[0].geometry.location.lat(), results[0].geometry.location.lng()); 3862 }); 3863 }, 3864 addWinContent: function(marker, html, map){ 3865 markersArray.push(marker); 3866 google.maps.event.addListener(marker, 'click', function() { 3867 infowindow.setContent(html); 3868 infowindow.open(map, marker); 3869 }); 3870 }, 3871 addMarkerDir: function(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText,pinFeaturedImage, lat, lng){ 3872 var companyMarker, pinImgContainer; 3873 3874 mapCoordinates = new google.maps.LatLng(lat, lng); 3875 3876 if (pinLogoURL) { 3877 companyPos = new google.maps.LatLng(lat, lng); 3878 companyMarker = new google.maps.Marker({ 3879 position: mapCoordinates, 3880 map: mapInstance, 3881 icon: pinLogoURL, 3882 optimized: false, 3883 animation: google.maps.Animation.DROP }); 3884 } else { 3885 companyPos = new google.maps.LatLng(lat, lng); 3886 companyMarker = new google.maps.Marker({ 3887 position: mapCoordinates, 3888 map: mapInstance, 3889 animation: google.maps.Animation.DROP }); 3890 } 3891 if (pinFeaturedImage == "" ) { 3892 pinImgContainer = ''; 3893 } else { 3894 pinImgContainer = '<img class="info-window-img" alt="" src="'+pinFeaturedImage
3894+'" height="140" width="140"/>'; 3895 } 3896 3897 var html = ''; 3898 if (pinLink === '' || pinButtonText === '') { 3899 html = '<div class="pinmarker">'+pinImgContainer+'<div class="pinmarker-container"><h3>'+pinTitle+'</h3><div class="excerpt">'+pinContent+'</div></div></div>'; 3900 } else { 3901 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>'; 3902 } 3903 3904 3905 infowindow = new google.maps.InfoWindow(); 3906 SWIFT.mapDirectory.addWinContent(companyMarker, html, mapInstance); 3907 directory_bounds.extend(mapCoordinates); 3908 }, 3909 directoryMap: function(mapContainer, mapZoom, mapType, mapColor, mapSaturation, targetMap, searchTerm, locationFilter, categoryFilter, excerpt) { 3910 3911 var pinLogoURL = "", mapLightness = false; 3912 var mapFilter = mapContainer.getAttribute('data-directory-map-filter'); 3913 var mapFilterPos = mapContainer.getAttribute('data-directory-map-filter-pos'); 3914 var mapResults = mapContainer.getAttribute('data-directory-map-results'); 3915 var excerpt = mapContainer.getAttribute('data-excerpt'); 3916 var directoryItemHtml = ""; 3917 3918 //Only if we want to display the map 3919 if (mapResults !== 'list') { 3920 3921 if (mapSaturation == "mono-light") { 3922 if (mapColor === "") { 3923 mapColor = "#ffffff"; 3924 } 3925 mapSaturation = -100; 3926 } else if (mapSaturation == "mono-dark") { 3927 if (mapColor === "") { 3928 mapColor = "#222222"; 3929 } 3930 mapSaturation = -100; 3931 mapLightness = true; 3932 } else { 3933 mapSaturation = -20; 3934 } 3935 3936 var styles = [ 3937 { 3938 stylers: [ 3939 {hue: mapColor}, 3940 {"invert_lightness": mapLightness}, 3941 {saturation: mapSaturation} 3942 ] 3943 } 3944 ]; 3945 3946 var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"}); 3947 3948 if (isMobileAlt) { 3949 isDraggable = false; 3950 } 3951 3952 if (mapType === "satellite") { 3953 mapTypeIdentifier = google.maps.MapTypeId.SATELLITE; 3954 } else if (mapType === "terrain") { 3955 mapTypeIdentifier = google.maps.MapTypeId.TERRAIN; 3956 } else if (mapType === "hybrid") { 3957 mapTypeIdentifier = google.maps.MapTypeImapDirContainerd.HYBRID; 3958 } else { 3959 mapTypeIdentifier = google.maps.MapTypeId.ROADMAP; 3960 } 3961 3962 3963 } else { 3964 jQuery(mapContainer).hide(); 3965 } 3966 3967 var pinTitle, pinContent, pinLink, address, pinButtonText, pinShortContent, pinThumbnail; 3968 var pincount = targetMap.parent().find('.pin_location').length; 3969 3970 directory_bounds = new google.maps.LatLngBounds(); 3971 3972 if (categoryFilter === "") { 3973 categoryFilter = mapContainer.getAttribute('data-directory-category'); 3974 } 3975 3976 //Ajax call to get the Directory Itens 3977 var data = { 3978 action: 'sf_directory', 3979 search_term: searchTerm, 3980 location_term: locationFilter, 3981 category_term: categoryFilter, 3982 item_excerpt: excerpt 3983 3984 }; 3985 3986 jQuery.post(mapContainer.getAttribute('data-ajaxurl'), data, function(response) { 3987 var json = jQuery.parseJSON(response); 3988 var mapFilterHtml; 3989 var pincount = json.results; 3990 3991 jQuery('.directory-results').hide(); 3992 3993 var settings = { 3994 scrollwheel: false, 3995 draggable: isDraggable, 3996 mapTypeControl: true, 3997 mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, 3998 navigationControl: true, 3999 navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, 4000 mapTypeId: mapTypeIdentifier 4001 }; 4002 4003 if (pincount > 0) { 4004 4005 var mapInstance = new google.maps.Map(mapContainer, settings); 4006 markersArray = []; 4007 4008 // MAP COLOURIZE 4009 if (mapColor !== "" && mapResults != 'list') { 4010 mapInstance.mapTypes.set('map_style', styledMap); 4011 mapInstance.setMapTypeId('map_style'); 4012 } 4013 4014 //Resize Window Responsiveness 4015 google.maps.event.addDomListener(window, 'resize', function() { 4016 mapInstance.fitBounds(directory_bounds); 4017 mapInstance.setZoom(parseInt(mapZoom, 10)); 4018 });
4019 4020 var resultText = "", thumbnail_image = ''; 4021 4022 if ( pincount > 1 ) { 4023 resultText = json.results_text_1 + ' '+pincount+' '+json.results_text_2plural; 4024 } else { 4025 resultText = json.results_text_1 + ' '+pincount+' '+json.results_text_2; 4026 } 4027 jQuery(mapContainer).parent().parent().parent().find('.directory-results').prepend('<div class="results-title"><h2>'+resultText+'</h2>'); 4028 4029 } else { 4030 4031 for (var i=0; i < markersArray.length; i++) { 4032 markersArray[i].setMap(null); 4033 } 4034 4035 jQuery(mapContainer).parent().parent().parent().find('.directory-results').append('<div class="results-title"><h2>'+json.errormsg+'</h2>'); 4036 4037 } 4038 4039 if (pincount > 0 && mapResults != 'list') { 4040 4041 jQuery(mapContainer).show(); 4042 jQuery('.directory-results').append(json.pagination); 4043 4044 jQuery.each(json.items, function(i, item) { 4045 4046 var hideFeaturedImage = mapContainer.getAttribute('data-directory-hide-featured-image'); 4047 4048 //Get the directory itens details 4049 var pinTitle = item.pin_title, 4050 pinLogoURL = item.pin_logo_url, 4051 pinContent = item.pin_content, 4052 pinShortContent = item.pin_short_content, 4053 address = item.pin_address, 4054 pinLink = item.pin_link, 4055 pinButtonText = item.pin_button_text, 4056 latitude = item.pin_lat, 4057 longitude = item.pin_lng, 4058 pinThumbnail = item.pin_thumbnail, 4059 categories = item.categories, 4060 location = item.location, 4061 thumbnail_image = '', 4062 result_header = true, 4063 hasThumb = false, 4064 extra_class = ''; 4065 4066 if ( excerpt != '' ){ 4067 pinContent = pinShortContent; 4068 } 4069 4070 if( hideFeaturedImage == 'yes' ){ 4071 pinThumbnail = ""; 4072 } 4073 4074 if (pinThumbnail && pinLink) { 4075 hasThumb = true; 4076 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>'; 4077 } else if (pinThumbnail) { 4078 hasThumb = true; 4079 thumbnail_image = '<figure><img itemprop="image" src="'+pinThumbnail+'" alt="'+pinTitle+'"></figure>'; 4080 } 4081 4082 //Add the Directory List Results 4083 if (!hasThumb) { 4084 extra_class = 'no-thumb'; 4085 } 4086 4087 if ( mapResults != 'list') { 4088 4089 //Add directory item to the map 4090 SWIFT.mapDirectory.addMarkerDir(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText,pinThumbnail, latitude, longitude); 4091 4092 if ( pincount > 1 ) { 4093 mapInstance.fitBounds(directory_bounds); 4094 } else { 4095 mapInstance.setZoom(parseInt(mapZoom, 10)); 4096 mapInstance.setCenter(new google.maps.LatLng(latitude, longitude)); 4097 } 4098 } 4099 }); 4100 }else{ 4101 jQuery(mapContainer).hide(); 4102 } 4103 jQuery('.directory-results').show(); 4104 }); 4105 } 4106 }; 4107 4108 4109 ///////////////////////////////////////////// 4110 // CROWDFUNDING FUNCTIONS 4111 ///////////////////////////////////////////// 4112 4113 SWIFT.crowdfunding = { 4114 init:function() { 4115 4116 if (jQuery('#back-this-project').find('.edd_price_options').length <= 0) { 4117 jQuery('#back-this-project > h2').css('display', 'none'); 4118 } 4119 4120 if (jQuery('#back-this-project').hasClass('project-donate-only')) { 4121 jQuery('.edd_price_options').find('li').first().addClass('atcf-selected'); 4122 jQuery('.edd_price_options').find('li').first().find('input[type="radio"]').prop('checked', true); 4123 } 4124 4125 jQuery('.atcf-price-option').on('click', function() { 4126 4127 var selectedOption = jQuery(this), 4128 selectedPrice = selectedOption.data('price').substr(0, selectedOption.data('price').indexOf('-')); 4129 4130 if (selectedOption.hasClass('inactive')) { 4131 return false; 4132 } 4133 4134 if (selectedPrice && jQuery('#atcf_custom_price').val().length <= 0) { 4135 jQuery('#atcf_custom_price').val(selectedPrice); 4136 } 4137 jQuery('.atcf-price-option').find('input[type="radio"]').prop('checked', false); 4138 jQuery('.atcf-price-option').removeClass('atcf-selected'); 4139 selectedOption.find('input[type="radio"]').prop('checked', true); 4140 selectedOption.addClass('atcf-selected'); 4141 }); 4142 4143 var campaignItems = jQuery('.campaign-items:not(.carousel-items)'); 4144 campaignItems.imagesLoaded(function () { 4145 campaignItems.equalHeights();
4146 }); 4147 4148 $window.smartresize( function() { 4149 jQuery('.campaign-items:not(.carousel-items)').children().css('min-height','0'); 4150 jQuery('.campaign-items:not(.carousel-items)').equalHeights(); 4151 }); 4152 4153 } 4154 }; 4155 4156 ///////////////////////////////////////////// 4157 // RELOAD FUNCTIONS 4158 ///////////////////////////////////////////// 4159 4160 SWIFT.reloadFunctions = { 4161 init:function() { 4162 4163 // Remove title attributes from images to avoid showing on hover 4164 jQuery('img[title]').each(function() { 4165 jQuery(this).removeAttr('title'); 4166 }); 4167 4168 if (!isAppleDevice) { 4169 jQuery('embed').show(); 4170 } 4171 4172 // Animate Top Links 4173 jQuery('.animate-top').on('click', function(e) { 4174 e.preventDefault(); 4175 jQuery('body,html').animate({scrollTop: 0}, 800, 'easeOutCubic'); 4176 }); 4177 }, 4178 load:function() { 4179 if (!isMobile) { 4180 4181 // Button hover tooltips 4182 jQuery('.tooltip').each( function() { 4183 jQuery(this).css( 'marginLeft', '-' + Math.round( (jQuery(this).outerWidth(true) / 2) ) + 'px' ); 4184 }); 4185 4186 jQuery('.comment-avatar').hover( function() { 4187 jQuery(this).find('.tooltip' ).stop().animate({ 4188 bottom: '44px', 4189 opacity: 1 4190 }, 500, 'easeInOutExpo'); 4191 }, function() { 4192 jQuery(this).find('.tooltip').stop().animate({ 4193 bottom: '25px', 4194 opacity: 0 4195 }, 400, 'easeInOutExpo'); 4196 }); 4197 4198 jQuery('.grid-image').hover( function() { 4199 jQuery(this).find('.tooltip' ).stop().animate({ 4200 bottom: '85px', 4201 opacity: 1 4202 }, 500, 'easeInOutExpo'); 4203 }, function() { 4204 jQuery(this).find('.tooltip').stop().animate({ 4205 bottom: '65px', 4206 opacity: 0 4207 }, 400, 'easeInOutExpo'); 4208 }); 4209 4210 } 4211 } 4212 }; 4213 4214 4215 ///////////////////////////////////////////// 4216 // GLOBAL VARIABLES 4217 ///////////////////////////////////////////// 4218 4219 var $window = jQuery(window), 4220 body = jQuery('body'), 4221 sfIncluded = jQuery('#sf-included'), 4222 sfOptionParams = jQuery('#sf-option-params'), 4223 windowheight = SWIFT.page.getViewportHeight(), 4224 deviceAgent = navigator.userAgent.toLowerCase(), 4225 isMobile = deviceAgent.match(/(iphone|ipod|android|iemobile)/), 4226 isMobileAlt = deviceAgent.match(/(iphone|ipod|ipad|android|iemobile)/), 4227 isAppleDevice = deviceAgent.match(/(iphone|ipod|ipad)/), 4228 isAndroid = deviceAgent.match(/(android)/), 4229 isIEMobile = deviceAgent.match(/(iemobile)/), 4230 parallaxScroll = navigator.userAgent.indexOf('Safari') != -1 || navigator.userAgent.indexOf('Chrome') == -1, 4231 IEVersion = SWIFT.page.checkIE(), 4232 isRTL = body.hasClass('rtl') ? true : false, 4233 flexUseCSS = isMobileAlt ? false : true, 4234 sliderAuto = sfOptionParams.data('slider-autoplay') ? true : false, 4235 sliderLoop = sfOptionParams.data('slider-loop') ? true : false, 4236 sliderSlideSpeed = sfOptionParams.data('slider-slidespeed'), 4237 sliderAnimSpeed = sfOptionParams.data('slider-animspeed'), 4238 lightboxControlArrows = sfOptionParams.data('lightbox-nav') === "arrows" ? true : false, 4239 lightboxThumbs = sfOptionParams.data('lightbox-thumbs') ? true : false, 4240 lightboxSkin = sfOptionParams.data('lightbox-skin') === "dark" ? "metro-black" : "metro-white", 4241 lightboxSharing = sfOptionParams.data('lightbox-sharing') ? true : false, 4242 hasProductZoom = jQuery('#sf-included').hasClass('has-productzoom') && !body.hasClass('mobile-browser') ? true : false, 4243 productZoomType = sfOptionParams.data('product-zoom-type') === "lens" ? "lens" : "inner"; 4244 4245 SWIFT.isScrolling = false; 4246 4247 ///////////////////////////////////////////// 4248 // LOAD + READY FUNCTION 4249 ///////////////////////////////////////////// 4250 4251 var onReady = { 4252 init: function(){ 4253 SWIFT.page.init(); 4254 if (jQuery('.sf-super-search').length > 0) { 4255 SWIFT.superSearch.init(); 4256 } 4257 if (jQuery('#header-section').length > 0) { 4258 SWIFT.header.init(); 4259 } 4260 SWIFT.nav.init(); 4261 //if (sfIncluded.hasClass('has-products') || body.hasClass('woocommerce-cart') || body.hasClass('woocommerce-account') || body.hasClass('single-tribe_events')) { 4262 SWIFT.woocommerce.init(); 4263 //} 4264 SWIFT.woocommerce.cartWishlist(); 4265 if (sfIncluded.hasClass('has-portfolio')) { 4266 SWIFT.portfolio.init(); 4267 } 4268 if (sfIncluded.hasClass('has-portfolio-showcase')) { 4269 SWIFT.portfolio.portfolioShowcaseInit(); 4270 } 4271 if (sfIncluded.hasClass('has-blog')) {
4272 SWIFT.blog.init(); 4273 } 4274 if (sfIncluded.hasClass('has-infscroll') && !isMobile) { 4275 SWIFT.blog.infiniteScroll(); 4276 } 4277 if (sfIncluded.hasClass('has-gallery')) { 4278 SWIFT.gallery.init(); 4279 } 4280 if (sfIncluded.hasClass('has-galleries')) { 4281 SWIFT.galleries.init(); 4282 } 4283 SWIFT.widgets.init(); 4284 if (sfIncluded.hasClass('has-team')) { 4285 SWIFT.teamMembers.init(); 4286 } 4287 if (sfIncluded.hasClass('has-carousel')) { 4288 SWIFT.carouselWidgets.init(); 4289 } 4290 SWIFT.crowdfunding.init(); 4291 SWIFT.reloadFunctions.init(); 4292 } 4293 }; 4294 var onLoad = { 4295 init: function(){ 4296 SWIFT.flexSlider.init(); 4297 if (sfIncluded.hasClass('has-products') || body.hasClass('woocommerce-cart') || body.hasClass('woocommerce-account')) { 4298 SWIFT.woocommerce.load(); 4299 } 4300 SWIFT.page.load(); 4301 if (body.hasClass('page-transitions')) { 4302 SWIFT.page.fadePageIn(); 4303 } 4304 SWIFT.widgets.tabs(); 4305 if (sfIncluded.hasClass('has-progress-bar')) { 4306 SWIFT.widgets.initSkillBars(); 4307 } 4308 if (sfIncluded.hasClass('has-map')) { 4309 SWIFT.map.init(); 4310 SWIFT.mapDirectory.init('', '', ''); 4311 4312 jQuery('#directory-search-button').on( "click", function() { 4313 jQuery('.directory-search-form').submit(); 4314 }); 4315 jQuery('ul.nav-tabs li a, .spb_accordion_section > h3 a').click(function(){ 4316 var thisTabHref = jQuery(this).attr('href'); 4317 if (jQuery(thisTabHref).find('.spb_gmaps_widget').length > 0) { 4318 SWIFT.map.init(); 4319 SWIFT.mapDirectory.init('', '', ''); 4320 } 4321 }); 4322 } 4323 SWIFT.reloadFunctions.load(); 4324 4325 if ( jQuery('#product-img-slider').length > 0 ) { 4326 SWIFT.woocommerce.variations(); 4327 } 4328 } 4329 }; 4330 4331 jQuery(document).ready(onReady.init); 4332 jQuery(window).load(onLoad.init); 4333 4334})(jQuery); 4335 4336// Remove default back button cache 4337window.onpageshow = function(event) { 4338 if (event.persisted) { 4339 window.location.reload(); 4340 } 4341};
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.