1/* 2 * Swiper 2.2 - Mobile Touch Slider 3 * http://www.idangero.us/sliders/swiper/ 4 * 5 * Copyright 2012-2013, Vladimir Kharlampidi 6 * The iDangero.us 7 * http://www.idangero.us/ 8 * 9 * Licensed under GPL & MIT 10 * 11 * Updated on: September 15, 2013 12*/ 13 14if(!jQuery().swiper) { 15 16var Swiper = function (selector, params) { 17 /*========================= 18 A little bit dirty but required part for IE8 and old FF support 19 ===========================*/ 20 if (document.body.__defineGetter__) { 21 if (HTMLElement) { 22 var element = HTMLElement.prototype; 23 if (element.__defineGetter__) { 24 element.__defineGetter__("outerHTML", function () { return new XMLSerializer().serializeToString(this); } ); 25 } 26 } 27 } 28 29 if (!window.getComputedStyle) { 30 window.getComputedStyle = function (el, pseudo) { 31 this.el = el; 32 this.getPropertyValue = function (prop) { 33 var re = /(\-([a-z]){1})/g; 34 if (prop === 'float') prop = 'styleFloat'; 35 if (re.test(prop)) { 36 prop = prop.replace(re, function () { 37 return arguments[2].toUpperCase(); 38 }); 39 } 40 return el.currentStyle[prop] ? el.currentStyle[prop] : null; 41 } 42 return this; 43 } 44 } 45 if (!Array.prototype.indexOf) { 46 Array.prototype.indexOf = function(obj, start) { 47 for (var i = (start || 0), j = this.length; i < j; i++) { 48 if (this[i] === obj) { return i; } 49 } 50 return -1; 51 } 52 } 53 if (!document.querySelectorAll) { 54 if (!window.jQuery) return; 55 } 56 function $$(selector, context) { 57 if (document.querySelectorAll) 58 return (context || document).querySelectorAll(selector); 59 else 60 return jQuery(selector, context); 61 } 62 63 /*========================= 64 Check for correct selector 65 ===========================*/ 66 if(typeof selector === 'undefined') return; 67 68 if(!(selector.nodeType)){ 69 if ($$(selector).length === 0) return; 70 } 71 72 /*========================= 73 _this 74 ===========================*/ 75 var _this = this; 76 77 /*========================= 78 Default Flags and vars 79 ===========================*/ 80 _this.touches = { 81 start:0, 82 startX:0, 83 startY:0, 84 current:0, 85 currentX:0, 86 currentY:0, 87 diff:0, 88 abs:0 89 }; 90 _this.positions = { 91 start:0, 92 abs:0, 93 diff:0, 94 current:0 95 }; 96 _this.times = { 97 start:0, 98 end:0 99 }; 100 101 _this.id = (new Date()).getTime(); 102 _this.container = (selector.nodeType) ? selector : $$(selector)[0]; 103 _this.isTouched = false; 104 _this.isMoved = false; 105 _this.activeIndex = 0; 106 _this.activeLoaderIndex = 0; 107 _this.activeLoopIndex = 0; 108 _this.previousIndex = null; 109 _this.velocity = 0; 110 _this.snapGrid = []; 111 _this.slidesGrid = []; 112 _this.imagesToLoad = []; 113 _this.imagesLoaded = 0; 114 _this.wrapperLeft=0; 115 _this.wrapperRight=0; 116 _this.wrapperTop=0; 117 _this.wrapperBottom=0; 118 var wrapper, slideSize, wrapperSize, direction, isScrolling, containerSize; 119 120 /*========================= 121 Default Parameters 122 ===========================*/ 123 var defaults = { 124 mode : 'horizontal', // or 'vertical' 125 touchRatio : 1, 126 speed : 300, 127 freeMode : false, 128 freeModeFluid : false, 129 momentumRatio: 1, 130 momentumBounce: true, 131 momentumBounceRatio: 1, 132 slidesPerView : 1, 133 slidesPerGroup : 1, 134 simulateTouch : true, 135 followFinger : true, 136 shortSwipes : true, 137 moveStartThreshold:false, 138 autoplay: false, 139 onlyExternal : false, 140 createPagination : true, 141 pagination : false, 142 paginationElement: 'span', 143 paginationClickable: false, 144 paginationAsRange: true, 145 resistance : true, // or false or 100% 146 scrollContainer : false, 147 preventLinks : true, 148 noSwiping : false, // or class 149 noSwipingClass : 'swiper-no-swiping', //:) 150 initialSlide: 0, 151 keyboardControl: false, 152 mousewheelControl : false, 153 mousewheelDebounce: 600, 154 useCSS3Transforms : true, 155 //Loop mode 156 loop:false, 157 loopAdditionalSlides:0, 158 //Auto Height 159 calculateHeight: false, 160 //Images Preloader 161 updateOnImagesReady : true, 162 //Form elements 163 releaseFormElements : true, 164 //Watch for active slide, useful when use effects on different slide states
165 watchActiveIndex: false, 166 //Slides Visibility Fit 167 visibilityFullFit : false, 168 //Slides Offset 169 offsetPxBefore : 0, 170 offsetPxAfter : 0, 171 offsetSlidesBefore : 0, 172 offsetSlidesAfter : 0, 173 centeredSlides: false, 174 //Queue callbacks 175 queueStartCallbacks : false, 176 queueEndCallbacks : false, 177 //Auto Resize 178 autoResize : true, 179 resizeReInit : false, 180 //DOMAnimation 181 DOMAnimation : true, 182 //Slides Loader 183 loader: { 184 slides:[], //array with slides 185 slidesHTMLType:'inner', // or 'outer' 186 surroundGroups: 1, //keep preloaded slides groups around view 187 logic: 'reload', //or 'change' 188 loadAllSlides: false 189 }, 190 //Namespace 191 slideElement : 'div', 192 slideClass : 'swiper-slide', 193 slideActiveClass : 'swiper-slide-active', 194 slideVisibleClass : 'swiper-slide-visible', 195 wrapperClass : 'swiper-wrapper', 196 paginationElementClass: 'swiper-pagination-switch', 197 /*nectar addition*/ 198 paginationActiveClass : 'swiper-active-switch ar-vis', 199 /*nectar addition end*/ 200 paginationVisibleClass : 'swiper-visible-switch' 201 } 202 params = params || {}; 203 for (var prop in defaults) { 204 if (prop in params && typeof params[prop]==='object') { 205 for (var subProp in defaults[prop]) { 206 if (! (subProp in params[prop])) { 207 params[prop][subProp] = defaults[prop][subProp]; 208 } 209 } 210 } 211 else if (! (prop in params)) { 212 params[prop] = defaults[prop] 213 } 214 } 215 _this.params = params; 216 if (params.scrollContainer) { 217 params.freeMode = true; 218 params.freeModeFluid = true; 219 } 220 if (params.loop) { 221 params.resistance = '100%'; 222 } 223 var isH = params.mode==='horizontal'; 224 225 /*========================= 226 Define Touch Events 227 ===========================*/ 228 229 _this.touchEvents = { 230 touchStart : _this.support.touch || !params.simulateTouch ? 'touchstart' : (_this.browser.ie10 ? 'MSPointerDown' : 'mousedown'), 231 touchMove : _this.support.touch || !params.simulateTouch ? 'touchmove' : (_this.browser.ie10 ? 'MSPointerMove' : 'mousemove'), 232 touchEnd : _this.support.touch || !params.simulateTouch ? 'touchend' : (_this.browser.ie10 ? 'MSPointerUp' : 'mouseup') 233 }; 234 235 /*========================= 236 Wrapper 237 ===========================*/ 238 for (var i = _this.container.childNodes.length - 1; i >= 0; i--) { 239 if (_this.container.childNodes[i].className) { 240 var _wrapperClasses = _this.container.childNodes[i].className.split(/\s+/); 241 for (var j = 0; j < _wrapperClasses.length; j++) { 242 if (_wrapperClasses[j] === params.wrapperClass) { 243 wrapper = _this.container.childNodes[i]; 244 } 245 } 246 } 247 } 248 249 _this.wrapper = wrapper; 250 /*========================= 251 Slide API 252 ===========================*/ 253 _this._extendSwiperSlide = function (el) { 254 el.append = function () { 255 if (params.loop) { 256 el.insertAfter(_this.slides.length-_this.loopedSlides); 257 _this.removeLoopedSlides(); 258 _this.calcSlides(); 259 _this.createLoop(); 260 } 261 else { 262 _this.wrapper.appendChild(el); 263 } 264 265 _this.reInit(); 266 return el; 267 } 268 el.prepend = function () { 269 if (params.loop) { 270 _this.wrapper.insertBefore(el, _this.slides[_this.loopedSlides]); 271 _this.removeLoopedSlides(); 272 _this.calcSlides(); 273 _this.createLoop(); 274 } 275 else { 276 _this.wrapper.insertBefore(el, _this.wrapper.firstChild); 277 } 278 _this.reInit(); 279 return el; 280 } 281 el.insertAfter = function (index) { 282 if(typeof index === 'undefined') return false; 283 var beforeSlide; 284 285 if (params.loop) { 286 beforeSlide = _this.slides[index + 1 + _this.loopedSlides]; 287 _this.wrapper.insertBefore(el, beforeSlide); 288 _this.removeLoopedSlides(); 289 _this.calcSlides(); 290 _this.createLoop(); 291 } 292 else { 293 beforeSlide = _this.slides[index + 1]; 294 _this.wrapper.insertBefore(el, beforeSlide) 295 } 296 _this.reInit(); 297 return el; 298 } 299 el.clone = function () { 300 return _this._extendSwiperSlide(el.cloneNode(true)) 301 } 302 el.remove = function () { 303 _this.wrapper.removeChild(el); 304 _this.reInit(); 305 } 306 el.html = function (html) { 307 if (typeof html === 'undefined') { 308 return el.innerHTML; 309 } 310 else { 311 el.innerHTML = html; 312 return el; 313 } 314 } 315 el.index = function () { 316 var index; 317 for (var i = _this.slides.length - 1; i >= 0; i--) { 318 if(el === _this.slides[i]) index = i; 319 } 320 return index; 321 } 322 el.isActive = function () { 323 if (el.index() === _this.activeIndex) return true; 324 else return false; 325 } 326 if (!el.swiperSlideDataStorage) el.swiperSlideDataStorage={}; 327 el.getData = function (name) { 328 return el.swiperSlideDataStorage[name]; 329 } 330 el.setData = function (name, value) { 331 el.swiperSlideDataStorage[name] = value; 332 return el; 333 } 334 el.data = function (name, value) { 335 if (!value) { 336 return el.getAttribute('data-'+name); 337 } 338 else { 339 el.setAttribute('data-'+name,value); 340 return el; 341 } 342 } 343 el.getWidth = function (outer) { 344 return _this.h.getWidth(el, outer); 345 } 346 el.getHeight = function (outer) { 347 return _this.h.getHeight(el, outer); 348 } 349 el.getOffset = function() { 350 return _this.h.getOffset(el); 351 } 352 return el; 353 } 354 355 //Calculate information about number of slides 356 _this.calcSlides = function (forceCalcSlides) { 357 var oldNumber = _this.slides ? _this.slides.length : false; 358 _this.slides = []; 359 _this.displaySlides = []; 360 for (var i = 0; i < _this.wrapper.childNodes.length; i++) { 361 if (_this.wrapper.childNodes[i].className) { 362 var _className = _this.wrapper.childNodes[i].className; 363 var _slideClasses = _className.split(' '); 364 for (var j = 0; j < _slideClasses.length; j++) { 365 if(_slideClasses[j]===params.slideClass) { 366 _this.slides.push(_this.wrapper.childNodes[i]); 367 } 368 } 369 } 370 } 371 for (i = _this.slides.length - 1; i >= 0; i--) { 372 _this._extendSwiperSlide(_this.slides[i]); 373 } 374 if (!oldNumber) return; 375 if(oldNumber!==_this.slides.length || forceCalcSlides) { 376 // Number of slides has been changed 377 removeSlideEvents(); 378 addSlideEvents(); 379 _this.updateActiveSlide(); 380 if (params.createPagination && _this.params.pagination) _this.createPagination(); 381 _this.callPlugins('numberOfSlidesChanged'); 382 } 383 } 384 385 //Create Slide 386 _this.createSlide = function (html, slideClassList, el) { 387 var slideClassList = slideClassList || _this.params.slideClass; 388 var el = el||params.slideElement; 389 var newSlide = document.createElement(el); 390 newSlide.innerHTML = html||''; 391 newSlide.className = slideClassList; 392 return _this._extendSwiperSlide(newSlide); 393 } 394 395 //Append Slide 396 _this.appendSlide = function (html, slideClassList, el) { 397 if (!html) return; 398 if (html.nodeType) { 399 return _this._extendSwiperSlide(html).append() 400 } 401 else { 402 return _this.createSlide(html, slideClassList, el).append() 403 } 404 } 405 _this.prependSlide = function (html, slideClassList, el) { 406 if (!html) return; 407 if (html.nodeType) { 408 return _this._extendSwiperSlide(html).prepend() 409 } 410 else { 411 return _this.createSlide(html, slideClassList, el).prepend() 412 } 413 } 414 _this.insertSlideAfter = function (index, html, slideClassList, el) { 415 if (typeof index === 'undefined') return false; 416 if (html.nodeType) { 417 return _this._extendSwiperSlide(html).insertAfter(index); 418 } 419 else { 420 return _this.createSlide(html, slideClassList, el).insertAfter(index); 421 } 422 } 423 _this.removeSlide = function (index) { 424 if (_this.slides[index]) { 425 if (params.loop) { 426 if (!_this.slides[index+_this.loopedSlides]) return false; 427 _this.slides[index+_this.loopedSlides].remove(); 428 _this.removeLoopedSlides(); 429 _this.calcSlides(); 430 _this.createLoop(); 431 } 432 else _this.slides[index].remove(); 433 return true; 434 } 435 else return false; 436 } 437 _this.removeLastSlide = function () { 438 if (_this.slides.length>0) { 439 if (params.loop) { 440 _this.slides[_this.slides.length - 1 - _this.loopedSlides].remove(); 441 _this.removeLoopedSlides(); 442 _this.calcSlides(); 443 _this.createLoop(); 444 } 445 else _this.slides[ (_this.slides.length-1) ].remove(); 446 return true; 447 } 448 else { 449 return false; 450 } 451 } 452 _this.removeAllSlides = function () { 453 for (var i = _this.slides.length - 1; i >= 0; i--) { 454 _this.slides[i].remove() 455 } 456 }
457 _this.getSlide = function (index) { 458 return _this.slides[index] 459 } 460 _this.getLastSlide = function () { 461 return _this.slides[ _this.slides.length-1 ] 462 } 463 _this.getFirstSlide = function () { 464 return _this.slides[0] 465 } 466 467 //Currently Active Slide 468 _this.activeSlide = function () { 469 return _this.slides[_this.activeIndex] 470 } 471 472 /*========================= 473 Plugins API 474 ===========================*/ 475 var _plugins = []; 476 for (var plugin in _this.plugins) { 477 if (params[plugin]) { 478 var p = _this.plugins[plugin](_this, params[plugin]); 479 if (p) _plugins.push( p ); 480 } 481 } 482 _this.callPlugins = function(method, args) { 483 if (!args) args = {} 484 for (var i=0; i<_plugins.length; i++) { 485 if (method in _plugins[i]) { 486 _plugins[i][method](args); 487 } 488 } 489 } 490 491 492 /*========================= 493 494 Wrapper for Callbacks : Allows additive callbacks via function arrays 495 496 ===========================*/ 497 498 _this.fireCallback = function() { 499 500 var callback = arguments[0]; 501 502 if( Object.prototype.toString.call( callback ) === '[object Array]' ) { 503 504 for (var i = 0; i < callback.length; i++) { 505 506 if (typeof callback[i] === 'function') { 507 508 callback[i](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]) 509 510 } 511 512 } 513 514 } else { 515 516 callback(arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); 517 518 } 519 520 } 521 522 function isArray (obj) { 523 524 "use strict"; 525 526 if (Object.prototype.toString.apply( obj ) === '[object Array]') return true; 527 528 return false; 529 530 } 531 532 533 534 /** 535 536+ * Allows user to add callbacks, rather than replace them 537 538+ * @param callback 539 540+ * @param func 541 542+ * @return {*} 543 544+ */ 545 546 _this.addCallback = function (callback, func) { 547 548 "use strict"; 549 550 var _this = this, tempFunc; 551 552 if (_this.params['on' + callback]) { 553 554 if (isArray(this.params['on' + callback])) { 555 556 return this.params['on' + callback].push(func); 557 558 } else if (typeof this.params['on' + callback] === 'function') { 559 560 tempFunc = this.params['on' + callback]; 561 562 this.params['on' + callback] = []; 563 564 this.params['on' + callback].push(tempFunc); 565 566 return this.params['on' + callback].push(func); 567 568 } 569 570 } else { 571 572 this.params['on' + callback] = []; 573 574 return this.params['on' + callback].push(func); 575 576 } 577 578 } 579 580 _this.removeCallbacks = function (callback) { 581 582 if (_this.params['on' + callback]) { 583 584 return _this.params['on' + callback] = null; 585 586 } 587 588 } 589 590 591 592 /*========================= 593 594 595 /*========================= 596 WP8 Fix 597 ===========================*/ 598 if (_this.browser.ie10 && !params.onlyExternal) { 599 _this.wrapper.classList.add('swiper-wp8-' + (isH ? 'horizontal' : 'vertical')); 600 } 601 602 /*========================= 603 Free Mode Class 604 ===========================*/ 605 if (params.freeMode) { 606 _this.container.className+=' swiper-free-mode'; 607 } 608 609 /*================================================== 610 Init/Re-init/Resize Fix 611 ====================================================*/ 612 _this.initialized = false; 613 _this.init = function(force, forceCalcSlides) { 614 var _width = _this.h.getWidth(_this.container); 615 var _height = _this.h.getHeight(_this.container); 616 if (_width===_this.width && _height===_this.height && !force) return; 617 _this.width = _width; 618 _this.height = _height; 619 620 containerSize = isH ? _width : _height; 621 var wrapper = _this.wrapper; 622 623 if (force) { 624 _this.calcSlides(forceCalcSlides); 625 } 626 627 if (params.slidesPerView==='auto') { 628 //Auto mode 629 var slidesWidth = 0; 630 var slidesHeight = 0; 631 632 //Unset Styles 633 if (params.slidesOffset>0) { 634 wrapper.style.paddingLeft = ''; 635 wrapper.style.paddingRight = ''; 636 wrapper.style.paddingTop = ''; 637 wrapper.style.paddingBottom = ''; 638 } 639 wrapper.style.width = ''; 640 wrapper.style.height = ''; 641 if (params.offsetPxBefore>0) { 642 if (isH) _this.wrapperLeft = params.offsetPxBefore; 643 else _this.wrapperTop = params.offsetPxBefore; 644 } 645 if (params.offsetPxAfter>0) { 646 if (isH) _this.wrapperRight = params.offsetPxAfter; 647 else _this.wrapperBottom = params.offsetPxAfter; 648 } 649 650 if (params.centeredSlides) { 651 if (isH) { 652 _this.wrapperLeft = (containerSize - this.slides[0].getWidth(true) )/2; 653 _this.wrapperRight = (containerSize - _this.slides[ _this.slides.length-1 ].getWidth(true))/2; 654 } 655 else { 656 _this.wrapperTop = (containerSize - _this.slides[0].getHeight(true))/2; 657 _this.wrapperBottom = (containerSize - _this.slides[ _this.slides.length-1 ].getHeight(true))/2; 658 } 659 } 660 661 if (isH) { 662 if (_this.wrapperLeft>=0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; 663 if (_this.wrapperRight>=0) wrapper.style.paddingRight = _this.wrapperRight+'px'; 664 } 665 else { 666 if (_this.wrapperTop>=0) wrapper.style.paddingTop = _this.wrapperTop+'px'; 667 if (_this.wrapperBottom>=0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; 668 } 669 var slideLeft = 0; 670 var centeredSlideLeft=0; 671 _this.snapGrid = []; 672 _this.slidesGrid = []; 673 674 var slideMaxHeight = 0; 675 for(var i = 0; i<_this.slides.length; i++) { 676 var slideWidth = _this.slides[i].getWidth(true); 677 var slideHeight = _this.slides[i].getHeight(true); 678 if (params.calculateHeight) { 679 slideMaxHeight = Math.max(slideMaxHeight, slideHeight) 680 } 681 var _slideSize = isH ? slideWidth : slideHeight; 682 if (params.centeredSlides) { 683 var nextSlideWidth = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getWidth(true); 684 var nextSlideHeight = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getHeight(true); 685 var nextSlideSize = isH ? nextSlideWidth : nextSlideHeight; 686 if (_slideSize>containerSize) { 687 for (var j=0; j<=Math.floor(_slideSize/(containerSize+_this.wrapperLeft)); j++) { 688 if (j === 0) _this.snapGrid.push(slideLeft+_this.wrapperLeft); 689 else _this.snapGrid.push(slideLeft+_this.wrapperLeft+containerSize*j); 690 } 691 _this.slidesGrid.push(slideLeft+_this.wrapperLeft); 692 } 693 else { 694 _this.snapGrid.push(centeredSlideLeft); 695 _this.slidesGrid.push(centeredSlideLeft); 696 } 697 698 centeredSlideLeft += _slideSize/2 + nextSlideSize/2; 699 700 } 701 else { 702 if (_slideSize>containerSize) { 703 for (var j=0; j<=Math.floor(_slideSize/containerSize); j++) { 704 _this.snapGrid.push(slideLeft+containerSize*j); 705 } 706 } 707 else { 708 _this.snapGrid.push(slideLeft); 709 } 710 _this.slidesGrid.push(slideLeft); 711 } 712 713 slideLeft += _slideSize; 714 715 slidesWidth += slideWidth; 716 slidesHeight += slideHeight; 717 } 718 if (params.calculateHeight) _this.height = slideMaxHeight; 719 if(isH) { 720 wrapperSize = slidesWidth + _this.wrapperRight + _this.wrapperLeft; 721 wrapper.style.width = (slidesWidth)+'px'; 722 wrapper.style.height = (_this.height)+'px'; 723 } 724 else { 725 wrapperSize = slidesHeight + _this.wrapperTop + _this.wrapperBottom; 726 wrapper.style.width = (_this.width)+'px'; 727 wrapper.style.height = (slidesHeight)+'px'; 728 } 729 730 } 731 else if (params.scrollContainer) { 732 //Scroll Container 733 wrapper.style.width = ''; 734 wrapper.style.height = '';
735 var wrapperWidth = _this.slides[0].getWidth(true); 736 var wrapperHeight = _this.slides[0].getHeight(true); 737 wrapperSize = isH ? wrapperWidth : wrapperHeight; 738 wrapper.style.width = wrapperWidth+'px'; 739 wrapper.style.height = wrapperHeight+'px'; 740 slideSize = isH ? wrapperWidth : wrapperHeight; 741 742 } 743 else { 744 //For usual slides 745 if (params.calculateHeight) { 746 var slideMaxHeight = 0; 747 var wrapperHeight = 0; 748 //ResetWrapperSize 749 if (!isH) _this.container.style.height= ''; 750 wrapper.style.height=''; 751 752 for (var i=0; i<_this.slides.length; i++) { 753 //ResetSlideSize 754 _this.slides[i].style.height=''; 755 slideMaxHeight = Math.max( _this.slides[i].getHeight(true), slideMaxHeight ); 756 if (!isH) wrapperHeight+=_this.slides[i].getHeight(true); 757 } 758 var slideHeight = slideMaxHeight; 759 _this.height = slideHeight; 760 761 if (isH) wrapperHeight = slideHeight; 762 else containerSize = slideHeight, _this.container.style.height= containerSize+'px'; 763 } 764 else { 765 var slideHeight = isH ? _this.height : _this.height/params.slidesPerView; 766 var wrapperHeight = isH ? _this.height : _this.slides.length*slideHeight; 767 } 768 var slideWidth = isH ? _this.width/params.slidesPerView : _this.width; 769 var wrapperWidth = isH ? _this.slides.length*slideWidth : _this.width; 770 slideSize = isH ? slideWidth : slideHeight; 771 772 if (params.offsetSlidesBefore>0) { 773 if (isH) _this.wrapperLeft = slideSize*params.offsetSlidesBefore; 774 else _this.wrapperTop = slideSize*params.offsetSlidesBefore; 775 } 776 if (params.offsetSlidesAfter>0) { 777 if (isH) _this.wrapperRight = slideSize*params.offsetSlidesAfter; 778 else _this.wrapperBottom = slideSize*params.offsetSlidesAfter; 779 } 780 if (params.offsetPxBefore>0) { 781 if (isH) _this.wrapperLeft = params.offsetPxBefore; 782 else _this.wrapperTop = params.offsetPxBefore; 783 } 784 if (params.offsetPxAfter>0) { 785 if (isH) _this.wrapperRight = params.offsetPxAfter; 786 else _this.wrapperBottom = params.offsetPxAfter; 787 } 788 if (params.centeredSlides) { 789 if (isH) { 790 _this.wrapperLeft = (containerSize - slideSize)/2; 791 _this.wrapperRight = (containerSize - slideSize)/2; 792 } 793 else { 794 _this.wrapperTop = (containerSize - slideSize)/2; 795 _this.wrapperBottom = (containerSize - slideSize)/2; 796 } 797 } 798 if (isH) { 799 if (_this.wrapperLeft>0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; 800 if (_this.wrapperRight>0) wrapper.style.paddingRight = _this.wrapperRight+'px'; 801 } 802 else { 803 if (_this.wrapperTop>0) wrapper.style.paddingTop = _this.wrapperTop+'px'; 804 if (_this.wrapperBottom>0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; 805 } 806 807 wrapperSize = isH ? wrapperWidth + _this.wrapperRight + _this.wrapperLeft : wrapperHeight + _this.wrapperTop + _this.wrapperBottom; 808 if (!params.cssWidthAndHeight) { 809 if (parseFloat(wrapperWidth) > 0) { 810 wrapper.style.width = wrapperWidth+'px'; 811 812 } 813 814 if (parseFloat(wrapperHeight) > 0) { 815 wrapper.style.height = wrapperHeight+'px'; 816 817 } 818 819 } 820 var slideLeft = 0; 821 _this.snapGrid = []; 822 _this.slidesGrid = []; 823 for (var i=0; i<_this.slides.length; i++) { 824 _this.snapGrid.push(slideLeft); 825 _this.slidesGrid.push(slideLeft); 826 slideLeft+=slideSize; 827 if (!params.cssWidthAndHeight) { 828 if (parseFloat(slideWidth) > 0) { 829 _this.slides[i].style.width = slideWidth+'px'; 830 831 } 832 833 if (parseFloat(slideHeight) > 0) { 834 _this.slides[i].style.height = slideHeight+'px'; 835 836 } 837 838 } 839 } 840 841 } 842 843 if (!_this.initialized) { 844 _this.callPlugins('onFirstInit'); 845 if (params.onFirstInit) _this.fireCallback(params.onFirstInit,_this); 846 } 847 else { 848 _this.callPlugins('onInit'); 849 if (params.onInit) _this.fireCallback(params.onInit,_this); 850 } 851 _this.initialized = true; 852 } 853 854 _this.reInit = function (forceCalcSlides) { 855 _this.init(true, forceCalcSlides); 856 } 857 858 _this.resizeFix = function (reInit) { 859 860 _this.callPlugins('beforeResizeFix'); 861 862 _this.init(params.resizeReInit || reInit); 863 864 // swipe to active slide in fixed mode 865 if (!params.freeMode) { 866 _this.swipeTo((params.loop ? _this.activeLoopIndex : _this.activeIndex), 0, false); 867 } 868 869 // move wrapper to the beginning in free mode 870 else if (_this.getWrapperTranslate() < -maxWrapperPosition()) { 871 _this.setWrapperTransition(0);
872 _this.setWrapperTranslate(-maxWrapperPosition()); 873 } 874 875 _this.callPlugins('afterResizeFix'); 876 } 877 878 /*========================================== 879 Max and Min Positions 880 ============================================*/ 881 function maxWrapperPosition() { 882 var a = (wrapperSize - containerSize); 883 if (params.freeMode) { 884 a = wrapperSize - containerSize; 885 } 886 // if (params.loop) a -= containerSize; 887 if (params.slidesPerView > _this.slides.length) a = 0; 888 if (a<0) a = 0; 889 return a; 890 } 891 function minWrapperPosition() { 892 var a = 0; 893 // if (params.loop) a = containerSize; 894 return a; 895 } 896 897 /*========================================== 898 Event Listeners 899 ============================================*/ 900 function initEvents() { 901 var bind = _this.h.addEventListener; 902 903 //Touch Events 904 if (!_this.browser.ie10) { 905 if (_this.support.touch) { 906 bind(_this.wrapper, 'touchstart', onTouchStart); 907 bind(_this.wrapper, 'touchmove', onTouchMove); 908 bind(_this.wrapper, 'touchend', onTouchEnd); 909 } 910 if (params.simulateTouch) { 911 bind(_this.wrapper, 'mousedown', onTouchStart); 912 bind(document, 'mousemove', onTouchMove); 913 bind(document, 'mouseup', onTouchEnd); 914 } 915 } 916 else { 917 bind(_this.wrapper, _this.touchEvents.touchStart, onTouchStart); 918 bind(document, _this.touchEvents.touchMove, onTouchMove); 919 bind(document, _this.touchEvents.touchEnd, onTouchEnd); 920 } 921 922 //Resize Event 923 if (params.autoResize) { 924 bind(window, 'resize', _this.resizeFix); 925 } 926 //Slide Events 927 addSlideEvents(); 928 //Mousewheel 929 _this._wheelEvent = false; 930 if (params.mousewheelControl) { 931 if ( document.onmousewheel !== undefined ) { 932 _this._wheelEvent = "mousewheel"; 933 } 934 try { 935 WheelEvent("wheel"); 936 _this._wheelEvent = "wheel"; 937 } catch (e) {} 938 if ( !_this._wheelEvent ) { 939 _this._wheelEvent = "DOMMouseScroll"; 940 } 941 942 if (_this._wheelEvent) { 943 bind(_this.container, _this._wheelEvent, handleMousewheel); 944 } 945 } 946 947 //Keyboard 948 if (params.keyboardControl) { 949 bind(document, 'keydown', handleKeyboardKeys); 950 } 951 if (params.updateOnImagesReady) { 952 _this.imagesToLoad = $$('img', _this.container); 953 954 for (var i=0; i<_this.imagesToLoad.length; i++) { 955 _loadImage(_this.imagesToLoad[i].getAttribute('src')) 956 } 957 } 958 function _loadImage(src) { 959 var image = new Image(); 960 image.onload = function(){ 961 _this.imagesLoaded++; 962 if (_this.imagesLoaded==_this.imagesToLoad.length) { 963 _this.reInit(); 964 if (params.onImagesReady) _this.fireCallback(params.onImagesReady, _this); 965 } 966 } 967 image.src = src; 968 } 969 } 970 971 //Remove Event Listeners 972 _this.destroy = function(removeResizeFix){ 973 var unbind = _this.h.removeEventListener; 974 975 //Touch Events 976 if (!_this.browser.ie10) { 977 if (_this.support.touch) { 978 unbind(_this.wrapper, 'touchstart', onTouchStart); 979 unbind(_this.wrapper, 'touchmove', onTouchMove); 980 unbind(_this.wrapper, 'touchend', onTouchEnd); 981 } 982 if (params.simulateTouch) { 983 unbind(_this.wrapper, 'mousedown', onTouchStart); 984 unbind(document, 'mousemove', onTouchMove); 985 unbind(document, 'mouseup', onTouchEnd); 986 } 987 } 988 else { 989 unbind(_this.wrapper, _this.touchEvents.touchStart, onTouchStart); 990 unbind(document, _this.touchEvents.touchMove, onTouchMove); 991 unbind(document, _this.touchEvents.touchEnd, onTouchEnd); 992 } 993 994 //Resize Event 995 if (params.autoResize) { 996 unbind(window, 'resize', _this.resizeFix); 997 } 998 999 //Init Slide Events 1000 removeSlideEvents(); 1001 1002 //Pagination 1003 if (params.paginationClickable) { 1004 removePaginationEvents(); 1005 } 1006 1007 //Mousewheel 1008 if (params.mousewheelControl && _this._wheelEvent) { 1009 unbind(_this.container, _this._wheelEvent, handleMousewheel); 1010 } 1011 1012 //Keyboard 1013 if (params.keyboardControl) { 1014 unbind(document, 'keydown', handleKeyboardKeys); 1015 } 1016 1017 //Stop autoplay 1018 if (params.autoplay) { 1019 _this.stopAutoplay(); 1020 } 1021 _this.callPlugins('onDestroy'); 1022 1023 //Destroy variable 1024 _this = null; 1025 } 1026 function addSlideEvents() { 1027 var bind = _this.h.addEventListener, 1028 i; 1029 1030 //Prevent Links Events 1031 if (params.preventLinks) { 1032 var links = $$('a', _this.container); 1033 for (i=0; i<links.length; i++) { 1034 bind(links[i], 'click', preventClick); 1035 } 1036 } 1037 //Release Form Elements 1038 if (params.releaseFormElements) { 1039 var formElements = $$('input, textarea, select', _this.container); 1040 for (i=0; i<formElements.length; i++) { 1041 bind(formElements[i], _this.touchEvents.touchStart, releaseForms, true); 1042 } 1043 } 1044 1045 //Slide Clicks & Touches 1046 if (params.onSlideClick) { 1047 for (i=0; i<_this.slides.length; i++) { 1048 bind(_this.slides[i], 'click', slideClick); 1049 } 1050 } 1051 if (params.onSlideTouch) { 1052 for (i=0; i<_this.slides.length; i++) { 1053 bind(_this.slides[i], _this.touchEvents.touchStart, slideTouch); 1054 } 1055 } 1056 } 1057 function removeSlideEvents() { 1058 var unbind = _this.h.removeEventListener, 1059 i; 1060 1061 //Slide Clicks & Touches 1062 if (params.onSlideClick) { 1063 for (i=0; i<_this.slides.length; i++) { 1064 unbind(_this.slides[i], 'click', slideClick); 1065 } 1066 } 1067 if (params.onSlideTouch) { 1068 for (i=0; i<_this.slides.length; i++) { 1069 unbind(_this.slides[i], _this.touchEvents.touchStart, slideTouch); 1070 } 1071 } 1072 //Release Form Elements 1073 if (params.releaseFormElements) { 1074 var formElements = $$('input, textarea, select', _this.container); 1075 for (i=0; i<formElements.length; i++) { 1076 unbind(formElements[i], _this.touchEvents.touchStart, releaseForms, true); 1077 } 1078 } 1079 //Prevent Links Events 1080 if (params.preventLinks) { 1081 var links = $$('a', _this.container); 1082 for (i=0; i<links.length; i++) { 1083 unbind(links[i], 'click', preventClick); 1084 } 1085 } 1086 } 1087 /*========================================== 1088 Keyboard Control 1089 ============================================*/ 1090 function handleKeyboardKeys (e) { 1091 var kc = e.keyCode || e.charCode; 1092 if (kc==37 || kc==39 || kc==38 || kc==40) { 1093 var inView = false; 1094 //Check that swiper should be inside of visible area of window 1095 var swiperOffset = _this.h.getOffset( _this.container ); 1096 var scrollLeft = _this.h.windowScroll().left; 1097 var scrollTop = _this.h.windowScroll().top; 1098 var windowWidth = _this.h.windowWidth(); 1099 var windowHeight = _this.h.windowHeight(); 1100 var swiperCoord = [ 1101 [swiperOffset.left, swiperOffset.top], 1102 [swiperOffset.left + _this.width, swiperOffset.top], 1103 [swiperOffset.left, swiperOffset.top + _this.height], 1104 [swiperOffset.left + _this.width, swiperOffset.top + _this.height] 1105 ] 1106 for (var i=0; i<swiperCoord.length; i++) { 1107 var point = swiperCoord[i]; 1108 if ( 1109 point[0]>=scrollLeft && point[0]<=scrollLeft+windowWidth && 1110 point[1]>=scrollTop && point[1]<=scrollTop+windowHeight 1111 ) { 1112 inView = true; 1113 } 1114 1115 } 1116 if (!inView) return; 1117 } 1118 if (isH) { 1119 if (kc==37 || kc==39) { 1120 if (e.preventDefault) e.preventDefault(); 1121 else e.returnValue = false; 1122 } 1123 if (kc == 39) _this.swipeNext(); 1124 if (kc == 37) _this.swipePrev(); 1125 } 1126 else { 1127 if (kc==38 || kc==40) { 1128 if (e.preventDefault) e.preventDefault(); 1129 else e.returnValue = false; 1130 } 1131 if (kc == 40) _this.swipeNext(); 1132 if (kc == 38) _this.swipePrev(); 1133 } 1134 } 1135 1136 /*========================================== 1137 Mousewheel Control 1138 ============================================*/ 1139 var allowScrollChange = true; 1140 var lastScrollTime = (new Date()).getTime(); 1141 function handleMousewheel (e) { 1142 var we = _this._wheelEvent; 1143 var delta = 0; 1144 //Opera & IE 1145 if (e.detail) delta = -e.detail; 1146 //WebKits 1147 else if (we == 'mousewheel') delta = e.wheelDelta; 1148 //Old FireFox 1149 else if (we == 'DOMMouseScroll') delta = -e.detail; 1150 //New FireFox 1151 else if (we == 'wheel') { 1152 delta = Math.abs(e.deltaX)>Math.abs(e.deltaY) ? - e.deltaX : - e.deltaY; 1153 } 1154 if (!params.freeMode) { 1155 if(delta<0) _this.swipeNext(); 1156 else _this.swipePrev(); 1157 } 1158 else { 1159 //Freemode or scrollContainer: 1160 var position = _this.getWrapperTranslate() + delta; 1161 1162 if (position > 0) position = 0; 1163 if (position < -maxWrapperPosition()) position = -maxWrapperPosition(); 1164 1165 _this.setWrapperTransition(0); 1166 _this.setWrapperTranslate(position); 1167 _this.updateActiveSlide(position); 1168 } 1169 if (params.autoplay) _this.stopAutoplay(); 1170 1171 if(e.preventDefault) e.preventDefault(); 1172 else e.returnValue = false; 1173 return false; 1174 } 1175 1176 /*========================= 1177 Grab Cursor 1178 ===========================*/ 1179 if (params.grabCursor) { 1180 var containerStyle = _this.container.style; 1181 containerStyle.cursor = 'move'; 1182 containerStyle.cursor = 'grab'; 1183 containerStyle.cursor = '-moz-grab'; 1184 containerStyle.cursor = '-webkit-grab'; 1185 } 1186 1187 /*========================= 1188 Slides Events Handlers 1189 ===========================*/ 1190 1191 _this.allowSlideClick = true; 1192 function slideClick(event) { 1193 if (_this.allowSlideClick) { 1194 1195 setClickedSlide(event); 1196 this.fireCallback(params.onSlideClick, _this, event); 1197 } 1198 } 1199 1200 function slideTouch(event) { 1201 1202 setClickedSlide(event); 1203 _this.fireCallback(params.onSlideTouch, _this, event); 1204 } 1205 1206 function setClickedSlide(event) { 1207 1208 // IE 6-8 support 1209 if (!event.currentTarget) { 1210 var element = event.srcElement; 1211 do { 1212 if (element.className.indexOf(params.slideClass) > -1) { 1213 break; 1214 } 1215 } 1216 while (element = element.parentNode); 1217 _this.clickedSlide = element; 1218 } 1219 else { 1220 _this.clickedSlide = event.currentTarget; 1221 } 1222 1223 _this.clickedSlideIndex = _this.slides.indexOf(_this.clickedSlide); 1224 _this.clickedSlideLoopIndex = _this.clickedSlideIndex - (_this.loopedSlides || 0); 1225 } 1226 1227 _this.allowLinks = true; 1228 function preventClick(e) { 1229 if (!_this.allowLinks) { 1230 if(e.preventDefault) e.preventDefault(); 1231 else e.returnValue = false; 1232 return false; 1233 } 1234 } 1235 function releaseForms(e) { 1236 if (e.stopPropagation) e.stopPropagation(); 1237 else e.returnValue = false; 1238 return false; 1239 } 1240 1241 /*================================================== 1242 Event Handlers 1243 ====================================================*/ 1244 var isTouchEvent = false; 1245 var allowThresholdMove; 1246 var allowMomentumBounce = true; 1247 function onTouchStart(event) { 1248 1249 //vc gallery when using lightbox fix 1250 if(jQuery(event.target).parents('.swiper-container').attr('data-desktop-swipe') == 'false' && !Modernizr.touch) return false; 1251 1252 //deactivate touch if only one slide 1253 if(jQuery(event.target).parents('.swiper-container').find('.swiper-slide').length == 1) return false; 1254 1255 //deactivate touch for duplicate transitions 1256 if(jQuery(event.target).parents('.swiper-container').find('.swiper-slide.duplicate-transition').length > 0) return false; 1257 1258 if (params.preventLinks) _this.allowLinks = true; 1259 //Exit if slider is already was touched 1260 if (_this.isTouched || params.onlyExternal) { 1261 return false; 1262 } 1263 1264 if (params.noSwiping && (event.target || event.srcElement) && noSwipingSlide(event.target || event.srcElement)) return false; 1265 allowMomentumBounce = false; 1266 1267 //Check For Nested Swipers 1268 _this.isTouched = true; 1269 isTouchEvent = event.type=='touchstart'; 1270 1271 if (!isTouchEvent || event.targetTouches.length == 1 ) { 1272 _this.callPlugins('onTouchStartBegin'); 1273 1274 if(!isTouchEvent) { 1275 if(event.preventDefault) event.preventDefault(); 1276 else event.returnValue = false; 1277 } 1278 1279 var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); 1280 var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); 1281 1282 //Start Touches to check the scrolling 1283 _this.touches.startX = _this.touches.currentX = pageX; 1284 _this.touches.startY = _this.touches.currentY = pageY; 1285 1286 _this.touches.start = _this.touches.current = isH ? pageX : pageY; 1287 1288 //Set Transition Time to 0 1289 _this.setWrapperTransition(0); 1290 1291 //Get Start Translate Position 1292 _this.positions.start = _this.positions.current = _this.getWrapperTranslate(); 1293 1294 //Set Transform 1295 _this.setWrapperTranslate(_this.positions.start); 1296 1297 //TouchStartTime 1298 _this.times.start = (new Date()).getTime(); 1299 1300 //Unset Scrolling 1301 isScrolling = undefined; 1302 1303 //Set Treshold 1304 if (params.moveStartThreshold>0) allowThresholdMove = false; 1305 1306 //CallBack 1307 if (params.onTouchStart) _this.fireCallback(params.onTouchStart, _this); 1308 _this.callPlugins('onTouchStartEnd'); 1309 1310 } 1311 } 1312 var velocityPrevPosition, velocityPrevTime; 1313 function onTouchMove(event) { 1314 // If slider is not touched - exit 1315 if (!_this.isTouched || params.onlyExternal) return; 1316 if (isTouchEvent && event.type=='mousemove') return; 1317 1318 var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); 1319 var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); 1320 1321 //check for scrolling
1322 if ( typeof isScrolling === 'undefined' && isH) { 1323 isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) > Math.abs( pageX - _this.touches.startX ) ); 1324 } 1325 if ( typeof isScrolling === 'undefined' && !isH) { 1326 isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) < Math.abs( pageX - _this.touches.startX ) ); 1327 } 1328 if (isScrolling ) { 1329 _this.isTouched = false; 1330 return; 1331 } 1332 1333 //Check For Nested Swipers 1334 if (event.assignedToSwiper) { 1335 _this.isTouched = false; 1336 return; 1337 } 1338 event.assignedToSwiper = true; 1339 1340 //Block inner links 1341 if (params.preventLinks) { 1342 _this.allowLinks = false; 1343 } 1344 if (params.onSlideClick) { 1345 _this.allowSlideClick = false; 1346 } 1347 1348 //Stop AutoPlay if exist 1349 if (params.autoplay) { 1350 _this.stopAutoplay(); 1351 } 1352 if (!isTouchEvent || event.touches.length == 1) { 1353 1354 //Moved Flag 1355 if (!_this.isMoved) { 1356 _this.callPlugins('onTouchMoveStart'); 1357 1358 if (params.loop) { 1359 _this.fixLoop(); 1360 _this.positions.start = _this.getWrapperTranslate(); 1361 } 1362 if (params.onTouchMoveStart) _this.fireCallback(params.onTouchMoveStart, _this); 1363 } 1364 _this.isMoved = true; 1365 1366 // cancel event 1367 if(event.preventDefault) event.preventDefault(); 1368 else event.returnValue = false; 1369 1370 _this.touches.current = isH ? pageX : pageY ; 1371 1372 _this.positions.current = (_this.touches.current - _this.touches.start) * params.touchRatio + _this.positions.start; 1373 1374 //Resistance Callbacks 1375 if(_this.positions.current > 0 && params.onResistanceBefore) { 1376 _this.fireCallback(params.onResistanceBefore, _this, _this.positions.current); 1377 } 1378 if(_this.positions.current < -maxWrapperPosition() && params.onResistanceAfter) { 1379 _this.fireCallback(params.onResistanceAfter, _this, Math.abs(_this.positions.current + maxWrapperPosition())); 1380 } 1381 //Resistance 1382 if (params.resistance && params.resistance!='100%') { 1383 //Resistance for Negative-Back sliding 1384 if(_this.positions.current > 0) { 1385 var resistance = 1 - _this.positions.current/containerSize/2; 1386 if (resistance < 0.5) 1387 _this.positions.current = (containerSize/2); 1388 else 1389 _this.positions.current = _this.positions.current * resistance; 1390 } 1391 //Resistance for After-End Sliding 1392 if ( _this.positions.current < -maxWrapperPosition() ) { 1393 1394 var diff = (_this.touches.current - _this.touches.start)*params.touchRatio + (maxWrapperPosition()+_this.positions.start); 1395 var resistance = (containerSize+diff)/(containerSize); 1396 var newPos = _this.positions.current-diff*(1-resistance)/2; 1397 var stopPos = -maxWrapperPosition() - containerSize/2; 1398 1399 if (newPos < stopPos || resistance<=0) 1400 _this.positions.current = stopPos; 1401 else 1402 _this.positions.current = newPos; 1403 } 1404 } 1405 if (params.resistance && params.resistance=='100%') { 1406 //Resistance for Negative-Back sliding 1407 if(_this.positions.current > 0 && !(params.freeMode&&!params.freeModeFluid)) { 1408 _this.positions.current = 0; 1409 } 1410 //Resistance for After-End Sliding 1411 if ( (_this.positions.current) < -maxWrapperPosition() && !(params.freeMode&&!params.freeModeFluid)) { 1412 _this.positions.current = -maxWrapperPosition(); 1413 } 1414 } 1415 //Move Slides 1416 if (!params.followFinger) return; 1417 1418 if (!params.moveStartThreshold) { 1419 _this.setWrapperTranslate(_this.positions.current); 1420 } 1421 else { 1422 if ( Math.abs(_this.touches.current - _this.touches.start)>params.moveStartThreshold || allowThresholdMove) { 1423 allowThresholdMove = true; 1424 _this.setWrapperTranslate(_this.positions.current); 1425 } 1426 else { 1427 _this.positions.current = _this.positions.start; 1428 } 1429 } 1430 1431 if (params.freeMode || params.watchActiveIndex) { 1432 _this.updateActiveSlide(_this.positions.current); 1433 } 1434 1435 //Grab Cursor 1436 //Grab Cursor 1437 if (params.grabCursor) { 1438 _this.container.style.cursor = 'move'; 1439 _this.container.style.cursor = 'grabbing'; 1440 _this.container.style.cursor = '-moz-grabbing'; 1441 _this.container.style.cursor = '-webkit-grabbing'; 1442 } 1443 //Velocity 1444 if (!velocityPrevPosition) velocityPrevPosition = _this.touches.current; 1445 if (!velocityPrevTime) velocityPrevTime = (new Date).getTime(); 1446 _this.velocity = (_this.touches.current - velocityPrevPosition)/((new Date).getTime() - velocityPrevTime)/2; 1447 1448 if (Math.abs(_this.touches.current - velocityPrevPosition)<2) _this.velocity=0; 1449 velocityPrevPosition = _this.touches.current; 1450 velocityPrevTime = (new Date).getTime(); 1451 //Callbacks 1452 _this.callPlugins('onTouchMoveEnd'); 1453 if (params.onTouchMove) _this.fireCallback(params.onTouchMove, _this); 1454 1455 return false; 1456 } 1457 } 1458 function onTouchEnd(event) { 1459 //Check For scrolling 1460 if (isScrolling) { 1461 _this.swipeReset(); 1462 } 1463 // If slider is not touched exit 1464 if ( params.onlyExternal || !_this.isTouched ) return; 1465 _this.isTouched = false 1466 1467 //Return Grab Cursor 1468 if (params.grabCursor) { 1469 _this.container.style.cursor = 'move'; 1470 _this.container.style.cursor = 'grab'; 1471 _this.container.style.cursor = '-moz-grab'; 1472 _this.container.style.cursor = '-webkit-grab'; 1473 } 1474 1475 //Check for Current Position 1476 if (!_this.positions.current && _this.positions.current!==0) { 1477 _this.positions.current = _this.positions.start 1478 } 1479 1480 //For case if slider touched but not moved 1481 if (params.followFinger) { 1482 _this.setWrapperTranslate(_this.positions.current); 1483 } 1484 1485 // TouchEndTime
1486 _this.times.end = (new Date()).getTime(); 1487 1488 //Difference 1489 _this.touches.diff = _this.touches.current - _this.touches.start 1490 _this.touches.abs = Math.abs(_this.touches.diff) 1491 1492 _this.positions.diff = _this.positions.current - _this.positions.start 1493 _this.positions.abs = Math.abs(_this.positions.diff) 1494 1495 var diff = _this.positions.diff ; 1496 var diffAbs =_this.positions.abs ; 1497 var timeDiff = _this.times.end - _this.times.start 1498 1499 if(diffAbs < 5 && (timeDiff) < 300 && _this.allowLinks == false) { 1500 if (!params.freeMode && diffAbs!=0) _this.swipeReset() 1501 //Release inner links 1502 if (params.preventLinks) { 1503 _this.allowLinks = true; 1504 } 1505 if (params.onSlideClick) { 1506 _this.allowSlideClick = true; 1507 } 1508 } 1509 1510 setTimeout(function () { 1511 //Release inner links 1512 if (params.preventLinks) { 1513 _this.allowLinks = true; 1514 } 1515 if (params.onSlideClick) { 1516 _this.allowSlideClick = true; 1517 } 1518 }, 100); 1519 1520 var maxPosition = maxWrapperPosition(); 1521 1522 //Not moved or Prevent Negative Back Sliding/After-End Sliding 1523 if (!_this.isMoved && params.freeMode) { 1524 _this.isMoved = false; 1525 if (params.onTouchEnd) _this.fireCallback(params.onTouchEnd, _this); 1526 _this.callPlugins('onTouchEnd'); 1527 return; 1528 } 1529 if (!_this.isMoved || _this.positions.current > 0 || _this.positions.current < -maxPosition) { 1530 _this.swipeReset(); 1531 if (params.onTouchEnd) _this.fireCallback(params.onTouchEnd, _this); 1532 _this.callPlugins('onTouchEnd'); 1533 return; 1534 } 1535 1536 _this.isMoved = false; 1537 1538 //Free Mode 1539 if (params.freeMode) { 1540 if ( params.freeModeFluid ) { 1541 var momentumDuration = 1000*params.momentumRatio; 1542 var momentumDistance = _this.velocity*momentumDuration; 1543 var newPosition = _this.positions.current + momentumDistance 1544 var doBounce = false; 1545 var afterBouncePosition; 1546 var bounceAmount = Math.abs( _this.velocity )*20*params.momentumBounceRatio; 1547 if (newPosition < -maxPosition) { 1548 if (params.momentumBounce && _this.support.transitions) { 1549 if (newPosition + maxPosition < -bounceAmount) newPosition = -maxPosition-bounceAmount; 1550 afterBouncePosition = -maxPosition; 1551 doBounce=true; 1552 allowMomentumBounce = true; 1553 } 1554 else newPosition = -maxPosition; 1555 } 1556 if (newPosition > 0) { 1557 if (params.momentumBounce && _this.support.transitions) { 1558 if (newPosition>bounceAmount) newPosition = bounceAmount; 1559 afterBouncePosition = 0 1560 doBounce = true; 1561 allowMomentumBounce = true; 1562 } 1563 else newPosition = 0; 1564 } 1565 //Fix duration 1566 if (_this.velocity!=0) momentumDuration = Math.abs((newPosition - _this.positions.current)/_this.velocity) 1567 1568 _this.setWrapperTranslate(newPosition); 1569 1570 _this.setWrapperTransition( momentumDuration ); 1571 1572 if (params.momentumBounce && doBounce) { 1573 _this.wrapperTransitionEnd(function () { 1574 if (!allowMomentumBounce) return; 1575 1576 if (params.onMomentumBounce) params.onMomentumBounce(_this); 1577 1578 _this.setWrapperTranslate(afterBouncePosition); 1579 _this.setWrapperTransition(300); 1580 }) 1581 } 1582 1583 _this.updateActiveSlide(newPosition) 1584 } 1585 if (!params.freeModeFluid || timeDiff >= 300) _this.updateActiveSlide(_this.positions.current) 1586 1587 if (params.onTouchEnd) params.onTouchEnd(_this) 1588 _this.callPlugins('onTouchEnd'); 1589 return; 1590 } 1591 1592 //Direction 1593 direction = diff < 0 ? "toNext" : "toPrev" 1594 1595 //Short Touches 1596 if (direction=="toNext" && ( timeDiff <= 300 ) ) { 1597 if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() 1598 else _this.swipeNext(true); 1599 } 1600 1601 if (direction=="toPrev" && ( timeDiff <= 300 ) ) { 1602 if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() 1603 else _this.swipePrev(true); 1604 } 1605 1606 //Long Touches 1607 var targetSlideSize = 0; 1608 if(params.slidesPerView == 'auto') { 1609 //Define current slide's width 1610 var currentPosition = Math.abs(_this.getWrapperTranslate()); 1611 var slidesOffset = 0; 1612 var _slideSize; 1613 for (var i=0; i<_this.slides.length; i++) { 1614 _slideSize = isH ? _this.slides[i].getWidth(true) : _this.slides[i].getHeight(true); 1615 slidesOffset+= _slideSize; 1616 if (slidesOffset>currentPosition) { 1617 targetSlideSize = _slideSize; 1618 break; 1619 } 1620 }
1621 if (targetSlideSize>containerSize) targetSlideSize = containerSize; 1622 } 1623 else { 1624 targetSlideSize = slideSize * params.slidesPerView; 1625 } 1626 if (direction=="toNext" && ( timeDiff > 300 ) ) { 1627 if (diffAbs >= targetSlideSize*0.5) { 1628 _this.swipeNext(true) 1629 } 1630 else { 1631 _this.swipeReset() 1632 } 1633 } 1634 if (direction=="toPrev" && ( timeDiff > 300 ) ) { 1635 if (diffAbs >= targetSlideSize*0.5) { 1636 _this.swipePrev(true); 1637 } 1638 else { 1639 _this.swipeReset() 1640 } 1641 } 1642 if (params.onTouchEnd) params.onTouchEnd(_this) 1643 _this.callPlugins('onTouchEnd'); 1644 } 1645 1646 1647 /*================================================== 1648 noSwiping Bubble Check by Isaac Strack 1649 ====================================================*/ 1650 function noSwipingSlide(el){ 1651 /*This function is specifically designed to check the parent elements for the noSwiping class, up to the wrapper. 1652 We need to check parents because while onTouchStart bubbles, _this.isTouched is checked in onTouchStart, which stops the bubbling. 1653 So, if a text box, for example, is the initial target, and the parent slide container has the noSwiping class, the _this.isTouched 1654 check will never find it, and what was supposed to be noSwiping is able to be swiped. 1655 This function will iterate up and check for the noSwiping class in parents, up through the wrapperClass.*/ 1656 1657 // First we create a truthy variable, which is that swiping is allowd (noSwiping = false) 1658 var noSwiping = false; 1659 1660 // Now we iterate up (parentElements) until we reach the node with the wrapperClass. 1661 do{ 1662 1663 // Each time, we check to see if there's a 'swiper-no-swiping' class (noSwipingClass). 1664 if (el.className.indexOf(params.noSwipingClass)>-1) 1665 { 1666 noSwiping = true; // If there is, we set noSwiping = true; 1667 } 1668 1669 el = el.parentElement; // now we iterate up (parent node) 1670 1671 } while(!noSwiping && el.parentElement && el.className.indexOf(params.wrapperClass)==-1); // also include el.parentElement truthy, just in case. 1672 1673 // because we didn't check the wrapper itself, we do so now, if noSwiping is false: 1674 if (!noSwiping && el.className.indexOf(params.wrapperClass)>-1 && el.className.indexOf(params.noSwipingClass)>-1) 1675 noSwiping = true; // if the wrapper has the noSwipingClass, we set noSwiping = true; 1676 1677 return noSwiping; 1678 } 1679 1680 /*================================================== 1681 Swipe Functions 1682 ====================================================*/ 1683 _this.swipeNext = function(internal){ 1684 if (!internal && params.loop) _this.fixLoop(); 1685 _this.callPlugins('onSwipeNext'); 1686 var currentPosition = _this.getWrapperTranslate(); 1687 var newPosition = currentPosition; 1688 if (params.slidesPerView=='auto') { 1689 for (var i=0; i<_this.snapGrid.length; i++) { 1690 if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { 1691 newPosition = -_this.snapGrid[i+1] 1692 break; 1693 } 1694 } 1695 } 1696 else { 1697 var groupSize = slideSize * params.slidesPerGroup; 1698 newPosition = -(Math.floor(Math.abs(currentPosition)/Math.floor(groupSize))*groupSize + groupSize); 1699 } 1700 if (newPosition < - maxWrapperPosition()) { 1701 newPosition = - maxWrapperPosition() 1702 }; 1703 1704 if (newPosition == currentPosition) return false; 1705 1706 swipeToPosition(newPosition, 'next'); 1707 return true 1708 } 1709 _this.swipePrev = function(internal){ 1710 if (!internal && params.loop) _this.fixLoop(); 1711 if (!internal && params.autoplay) _this.stopAutoplay(); 1712 _this.callPlugins('onSwipePrev'); 1713 1714 var currentPosition = Math.ceil(_this.getWrapperTranslate()); 1715 var newPosition; 1716 if (params.slidesPerView=='auto') { 1717 newPosition = 0; 1718 for (var i=1; i<_this.snapGrid.length; i++) { 1719 if (-currentPosition == _this.snapGrid[i]) { 1720 newPosition = -_this.snapGrid[i-1] 1721 break; 1722 } 1723 if (-currentPosition > _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { 1724 newPosition = -_this.snapGrid[i] 1725 break; 1726 } 1727 } 1728 } 1729 else { 1730 var groupSize = slideSize * params.slidesPerGroup; 1731 newPosition = -(Math.ceil(-currentPosition/groupSize)-1)*groupSize; 1732 } 1733 1734 if (newPosition > 0) newPosition = 0; 1735 1736 if (newPosition == currentPosition) return false; 1737 swipeToPosition(newPosition, 'prev'); 1738 return true; 1739 1740 } 1741 _this.swipeReset = function(){ 1742 _this.callPlugins('onSwipeReset'); 1743 var currentPosition = _this.getWrapperTranslate(); 1744 var groupSize = slideSize * params.slidesPerGroup; 1745 var newPosition; 1746 var maxPosition = -maxWrapperPosition(); 1747 if (params.slidesPerView=='auto') { 1748 newPosition = 0; 1749 for (var i=0; i<_this.snapGrid.length; i++) { 1750 if (-currentPosition===_this.snapGrid[i]) return; 1751 if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { 1752 if(_this.positions.diff>0) newPosition = -_this.snapGrid[i+1] 1753 else newPosition = -_this.snapGrid[i] 1754 break; 1755 } 1756 } 1757 if (-currentPosition >= _this.snapGrid[_this.snapGrid.length-1]) newPosition = -_this.snapGrid[_this.snapGrid.length-1]; 1758 if (currentPosition <= -maxWrapperPosition()) newPosition = -maxWrapperPosition() 1759 } 1760 else { 1761 newPosition = currentPosition<0 ? Math.round(currentPosition/groupSize)*groupSize : 0 1762 } 1763 if (params.scrollContainer) { 1764 newPosition = currentPosition<0 ? currentPosition : 0; 1765 } 1766 if (newPosition < -maxWrapperPosition()) { 1767 newPosition = -maxWrapperPosition() 1768 } 1769 if (params.scrollContainer && (containerSize>slideSize)) { 1770 newPosition = 0; 1771 } 1772 1773 if (newPosition == currentPosition) return false; 1774 1775 swipeToPosition(newPosition, 'reset'); 1776 return true; 1777 } 1778 1779 _this.swipeTo = function(index, speed, runCallbacks) { 1780 index = parseInt(index, 10); 1781 _this.callPlugins('onSwipeTo', {index:index, speed:speed}); 1782 if (params.loop) index = index + _this.loopedSlides; 1783 var currentPosition = _this.getWrapperTranslate(); 1784 if (index > (_this.slides.length-1) || index < 0) return; 1785 var newPosition 1786 if (params.slidesPerView=='auto') { 1787 newPosition = -_this.slidesGrid[ index ]; 1788 } 1789 else { 1790 newPosition = -index*slideSize; 1791 } 1792 if (newPosition < - maxWrapperPosition()) { 1793 newPosition = - maxWrapperPosition(); 1794 }; 1795 1796 if (newPosition == currentPosition) return false; 1797 1798 runCallbacks = runCallbacks===false ? false : true; 1799 swipeToPosition(newPosition, 'to', {index:index, speed:speed, runCallbacks:runCallbacks}); 1800 return true; 1801 } 1802 1803 function swipeToPosition(newPosition, action, toOptions) { 1804 var speed = (action=='to' && toOptions.speed >= 0) ? toOptions.speed : params.speed; 1805 1806 var timeOld = + new Date(); 1807 if (_this.support.transitions || !params.DOMAnimation) { 1808 _this.setWrapperTranslate(newPosition); 1809 _this.setWrapperTransition(speed); 1810 } 1811 else { 1812 //Try the DOM animation 1813 var currentPosition = _this.getWrapperTranslate(); 1814 var animationStep = Math.ceil( (newPosition - currentPosition)/speed*(1000/60) ); 1815 var direction = currentPosition > newPosition ? 'toNext' : 'toPrev'; 1816 var condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; 1817 if (_this._DOMAnimating) return; 1818 1819 anim(); 1820 } 1821 function anim(){ 1822 var timeNew = + new Date(); 1823 var time = timeNew - timeOld; 1824 currentPosition += animationStep * time / (1000/60); 1825 1826 condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; 1827 if (condition) { 1828 _this.setWrapperTranslate(Math.round(currentPosition)); 1829 _this._DOMAnimating = true 1830 window.setTimeout(function(){ 1831 anim() 1832 }, 1000 / 60) 1833 } 1834 else { 1835 if (params.onSlideChangeEnd) { 1836 _this.fireCallback(params.onSlideChangeEnd, _this); 1837 } 1838 _this.setWrapperTranslate(newPosition); 1839 _this._DOMAnimating = false; 1840 } 1841 } 1842 1843 //Update Active Slide Index 1844 _this.updateActiveSlide(newPosition); 1845 1846 //Callbacks 1847 if (params.onSlideNext && action=='next') { 1848 _this.fireCallback(params.onSlideNext, _this, newPosition); 1849 } 1850 if (params.onSlidePrev && action=='prev') { 1851 _this.fireCallback(params.onSlidePrev, _this, newPosition); 1852 } 1853 //"Reset" Callback 1854 if (params.onSlideReset && action=='reset') { 1855 _this.fireCallback(params.onSlideReset, _this, newPosition); 1856 } 1857 1858 //"Next", "Prev" and "To" Callbacks 1859 if (action=='next' || action=='prev' || (action=='to' && toOptions.runCallbacks==true)) 1860 slideChangeCallbacks(action); 1861 } 1862 /*================================================== 1863 Transition Callbacks 1864 ====================================================*/ 1865 //Prevent Multiple Callbacks 1866 _this._queueStartCallbacks = false; 1867 _this._queueEndCallbacks = false; 1868 function slideChangeCallbacks(direction) { 1869 //Transition Start Callback 1870 _this.callPlugins('onSlideChangeStart'); 1871 if (params.onSlideChangeStart) { 1872 if (params.queueStartCallbacks && _this.support.transitions) { 1873 if (_this._queueStartCallbacks) return; 1874 _this._queueStartCallbacks = true; 1875 _this.fireCallback(params.onSlideChangeStart, _this, direction) 1876 _this.wrapperTransitionEnd(function(){ 1877 _this._queueStartCallbacks = false; 1878 }) 1879 } 1880 else _this.fireCallback(params.onSlideChangeStart, _this, direction) 1881 } 1882 //Transition End Callback 1883 if (params.onSlideChangeEnd) { 1884 if (_this.support.transitions) { 1885 if (params.queueEndCallbacks) { 1886 if (_this._queueEndCallbacks) return; 1887 _this._queueEndCallbacks = true; 1888 _this.wrapperTransitionEnd(function(swiper){ 1889 setTimeout(function(){ if (params.loop) _this.fixLoop(); },50); 1890 _this.fireCallback(params.onSlideChangeEnd, swiper, direction) 1891 }) 1892 1893 } 1894 else _this.wrapperTransitionEnd(function(swiper){ 1895 //setTimeout(function(){ if (params.loop) _this.fixLoop(); },50); 1896 _this.fireCallback(params.onSlideChangeEnd, swiper, direction) 1897 }) 1898 } 1899 else { 1900 if (!params.DOMAnimation) { 1901 setTimeout(function(){ 1902 _this.fireCallback(params.onSlideChangeStart, _this, direction) 1903 },10) 1904 } 1905 } 1906 } 1907 } 1908 1909 /*================================================== 1910 Update Active Slide Index 1911 ====================================================*/ 1912 _this.updateActiveSlide = function(position) { 1913 if (!_this.initialized) return; 1914 if (_this.slides.length==0) return; 1915 _this.previousIndex = _this.activeIndex; 1916 if (typeof position=='undefined') position = _this.getWrapperTranslate(); 1917 if (position>0) position=0; 1918 1919 if (params.slidesPerView == 'auto') { 1920 var slidesOffset = 0; 1921 _this.activeIndex = _this.slidesGrid.indexOf(-position); 1922 if (_this.activeIndex<0) { 1923 for (var i=0; i<_this.slidesGrid.length-1; i++) { 1924 if (-position>_this.slidesGrid[i] && -position<_this.slidesGrid[i+1]) { 1925 break; 1926 } 1927 } 1928 var leftDistance = Math.abs( _this.slidesGrid[i] + position ) 1929 var rightDistance = Math.abs( _this.slidesGrid[i+1] + position ) 1930 if (leftDistance<=rightDistance) _this.activeIndex = i; 1931 else _this.activeIndex = i+1; 1932 } 1933 } 1934 else { 1935 _this.activeIndex = Math[params.visibilityFullFit ? 'ceil' : 'round']( -position/slideSize ); 1936 } 1937 1938 if (_this.activeIndex == _this.slides.length ) _this.activeIndex = _this.slides.length - 1; 1939 if (_this.activeIndex < 0) _this.activeIndex = 0; 1940 1941 // Check for slide 1942 if (!_this.slides[_this.activeIndex]) return; 1943 1944 // Calc Visible slides 1945 _this.calcVisibleSlides(position); 1946 1947 // Mark visible and active slides with additonal classes 1948 var activeClassRegexp = new RegExp( "\\s*" + params.slideActiveClass ); 1949 var inViewClassRegexp = new RegExp( "\\s*" + params.slideVisibleClass ); 1950 1951 for (var i = 0; i < _this.slides.length; i++) { 1952 _this.slides[ i ].className = _this.slides[ i ].className.replace( activeClassRegexp, '' ).replace( inViewClassRegexp, '' ); 1953 if ( _this.visibleSlides.indexOf( _this.slides[ i ] )>=0 ) { 1954 _this.slides[ i ].className += ' ' + params.slideVisibleClass; 1955 } 1956 1957 } 1958 _this.slides[ _this.activeIndex ].className += ' ' + params.slideActiveClass; 1959 1960 //Update loop index 1961 if (params.loop) { 1962 var ls = _this.loopedSlides; 1963 _this.activeLoopIndex = _this.activeIndex - ls; 1964 if (_this.activeLoopIndex >= _this.slides.length - ls*2 ) { 1965 _this.activeLoopIndex = _this.slides.length - ls*2 - _this.activeLoopIndex; 1966 } 1967 if (_this.activeLoopIndex<0) { 1968 _this.activeLoopIndex = _this.slides.length - ls*2 + _this.activeLoopIndex; 1969 } 1970 } 1971 else { 1972 _this.activeLoopIndex = _this.activeIndex; 1973 } 1974 //Update Pagination 1975 if (params.pagination) { 1976 _this.updatePagination(position); 1977 } 1978 } 1979 /*================================================== 1980 Pagination 1981 ====================================================*/ 1982 _this.createPagination = function (firstInit) { 1983 if (params.paginationClickable && _this.paginationButtons) { 1984 removePaginationEvents(); 1985 } 1986 var paginationHTML = ""; 1987 var numOfSlides = _this.slides.length; 1988 var numOfButtons = numOfSlides; 1989 if (params.loop) numOfButtons -= _this.loopedSlides*2 1990 for (var i = 0; i < numOfButtons; i++) { 1991 paginationHTML += '<'+params.paginationElement+' class="'+params.paginationElementClass+'"></'+params.paginationElement+'>' 1992 } 1993 _this.paginationContainer = params.pagination.nodeType ? params.pagination : $$(params.pagination)[0]; 1994 _this.paginationContainer.innerHTML = paginationHTML; 1995 _this.paginationButtons = $$('.'+params.paginationElementClass, _this.paginationContainer); 1996 if (!firstInit) _this.updatePagination() 1997 _this.callPlugins('onCreatePagination'); 1998 if (p
1998arams.paginationClickable) { 1999 addPaginationEvents(); 2000 } 2001 } 2002 function removePaginationEvents() { 2003 var pagers = _this.paginationButtons; 2004 for (var i=0; i<pagers.length; i++) { 2005 _this.h.removeEventListener(pagers[i], 'click', paginationClick); 2006 } 2007 } 2008 function addPaginationEvents() { 2009 var pagers = _this.paginationButtons; 2010 for (var i=0; i<pagers.length; i++) { 2011 _this.h.addEventListener(pagers[i], 'click', paginationClick); 2012 } 2013 } 2014 function paginationClick(e){ 2015 var index; 2016 var target = e.target || e.srcElement; 2017 var pagers = _this.paginationButtons; 2018 for (var i=0; i<pagers.length; i++) { 2019 if (target===pagers[i]) index = i; 2020 } 2021 _this.swipeTo(index) 2022 } 2023 _this.updatePagination = function(position) { 2024 if (!params.pagination) return; 2025 if (_this.slides.length<1) return; 2026 2027 var activePagers = $$('.'+params.paginationActiveClass, _this.paginationContainer); 2028 if(!activePagers) return; 2029 2030 //Reset all Buttons' class to not active 2031 var pagers = _this.paginationButtons; 2032 if (pagers.length==0) return; 2033 for (var i=0; i < pagers.length; i++) { 2034 pagers[i].className = params.paginationElementClass 2035 } 2036 2037 var indexOffset = params.loop ? _this.loopedSlides : 0; 2038 if (params.paginationAsRange) { 2039 if (!_this.visibleSlides) _this.calcVisibleSlides(position) 2040 //Get Visible Indexes 2041 var visibleIndexes = []; 2042 for (var i = 0; i < _this.visibleSlides.length; i++) { 2043 var visIndex = _this.slides.indexOf( _this.visibleSlides[i] ) - indexOffset 2044 2045 if (params.loop && visIndex<0) { 2046 visIndex = _this.slides.length - _this.loopedSlides*2 + visIndex; 2047 } 2048 if (params.loop && visIndex>=_this.slides.length-_this.loopedSlides*2) { 2049 visIndex = _this.slides.length - _this.loopedSlides*2 - visIndex; 2050 visIndex = Math.abs(visIndex) 2051 } 2052 visibleIndexes.push( visIndex ) 2053 } 2054 2055 for (i=0; i<visibleIndexes.length; i++) { 2056 if (pagers[ visibleIndexes[i] ]) pagers[ visibleIndexes[i] ].className += ' ' + params.paginationVisibleClass; 2057 } 2058 2059 if (params.loop) { 2060 pagers[ _this.activeLoopIndex ].className += ' ' + params.paginationActiveClass; 2061 } 2062 else { 2063 pagers[ _this.activeIndex ].className += ' ' + params.paginationActiveClass; 2064 } 2065 2066 } 2067 else { 2068 if (params.loop) { 2069 pagers[ _this.activeLoopIndex ].className+=' '+params.paginationActiveClass+' '+params.paginationVisibleClass; 2070 } 2071 else { 2072 pagers[ _this.activeIndex ].className+=' '+params.paginationActiveClass+' '+params.paginationVisibleClass; 2073 } 2074 2075 } 2076 2077 } 2078 _this.calcVisibleSlides = function(position){ 2079 var visibleSlides = []; 2080 var _slideLeft = 0, _slideSize = 0, _slideRight = 0; 2081 if (isH && _this.wrapperLeft>0) position = position+_this.wrapperLeft; 2082 if (!isH && _this.wrapperTop>0) position = position+_this.wrapperTop; 2083 2084 for (var i=0; i<_this.slides.length; i++) { 2085 _slideLeft += _slideSize; 2086 if (params.slidesPerView == 'auto') 2087 _slideSize = isH ? _this.h.getWidth(_this.slides[i],true) : _this.h.getHeight(_this.slides[i],true); 2088 else _slideSize = slideSize; 2089 2090 _slideRight = _slideLeft + _slideSize; 2091 var isVisibile = false; 2092 if (params.visibilityFullFit) { 2093 if (_slideLeft >= -position && _slideRight <= -position+containerSize) isVisibile = true; 2094 if (_slideLeft <= -position && _slideRight >= -position+containerSize) isVisibile = true; 2095 } 2096 else { 2097 2098 if (_slideRight > -position && _slideRight <= ((-position+containerSize))) isVisibile = true; 2099 if (_slideLeft >= -position && _slideLeft < ((-position+containerSize))) isVisibile = true; 2100 if (_slideLeft < -position && _slideRight > ((-position+containerSize))) isVisibile = true; 2101 } 2102 2103 if (isVisibile) visibleSlides.push(_this.slides[i]) 2104 2105 } 2106 if (visibleSlides.length==0) visibleSlides = [ _this.slides[ _this.activeIndex ] ] 2107 2108 _this.visibleSlides = visibleSlides; 2109 } 2110 2111 /*========================================== 2112 Autoplay 2113 ============================================*/ 2114 _this.autoPlayIntervalId = undefined; 2115 _this.startAutoplay = function () { 2116 if (typeof _this.autoPlayIntervalId !== 'undefined') return false; 2117 if (params.autoplay && !params.loop) { 2118 _this.autoPlayIntervalId = setInterval(function(){ 2119 if (!_this.swipeNext(true)) _this.swipeTo(0); 2120 }, params.autoplay) 2121 } 2122 if (params.autoplay && params.loop) { 2123 _this.autoPlayIntervalId = setInterval(function(){ 2124 _this.swipeNext(); 2125 }, params.autoplay) 2126 } 2127 _this.callPlugins('onAutoplayStart'); 2128 } 2129 _this.stopAutoplay = function () { 2130 if (_this.autoPlayIntervalId) clearInterval(_this.autoPlayIntervalId); 2131 _this.autoPlayIntervalId = undefined; 2132 _this.callPlugins('onAutoplayStop'); 2133 } 2134 2135 /*================================================== 2136 Loop 2137 ====================================================*/ 2138 _this.loopCreated = false; 2139 _this.removeLoopedSlides = function(){ 2140 if (_this.loopCreated) { 2141 for (var i=0; i<_this.slides.length; i++) { 2142 if (_this.slides[i].getData('looped')===true) _this.wrapper.removeChild(_this.slides[i]); 2143 } 2144 } 2145 } 2146 2147 _this.createLoop = function() { 2148 if (_this.slides.length==0) return; 2149 2150 _this.loopedSlides = params.slidesPerView + params.loopAdditionalSlides; 2151 if (_this.loopedSlides > _this.slides.length) { 2152 _this.loopedSlides = _this.slides.length; 2153 } 2154
2155 var slideFirstHTML = '', 2156 slideLastHTML = '', 2157 i; 2158 2159 //Grab First Slides 2160 for (i=0; i<_this.loopedSlides; i++) { 2161 slideFirstHTML += _this.slides[i].outerHTML; 2162 } 2163 //Grab Last Slides 2164 for (i=_this.slides.length-_this.loopedSlides; i<_this.slides.length; i++) { 2165 slideLastHTML += _this.slides[i].outerHTML; 2166 } 2167 wrapper.innerHTML = slideLastHTML + wrapper.innerHTML + slideFirstHTML; 2168 2169 _this.loopCreated = true; 2170 _this.calcSlides(); 2171 2172 //Update Looped Slides with special class 2173 for (i=0; i<_this.slides.length; i++) { 2174 if (i<_this.loopedSlides || i>=_this.slides.length-_this.loopedSlides) _this.slides[i].setData('looped', true); 2175 } 2176 _this.callPlugins('onCreateLoop'); 2177 2178 } 2179 2180 _this.fixLoop = function() { 2181 2182 if(_this.params.loop == true) { 2183 2184 var newIndex; 2185 //Fix For Negative Oversliding 2186 if (_this.activeIndex < _this.loopedSlides) { 2187 newIndex = _this.slides.length - _this.loopedSlides*3 + _this.activeIndex; 2188 _this.swipeTo(newIndex, 0, false); 2189 } 2190 //Fix For Positive Oversliding 2191 else if (_this.activeIndex > _this.slides.length - params.slidesPerView*2) { 2192 newIndex = -_this.slides.length + _this.activeIndex + _this.loopedSlides 2193 _this.swipeTo(newIndex, 0, false); 2194 } 2195 } 2196 2197 } 2198 2199 /*================================================== 2200 Slides Loader 2201 ====================================================*/ 2202 _this.loadSlides = function(){ 2203 var slidesHTML = ''; 2204 _this.activeLoaderIndex = 0; 2205 var slides = params.loader.slides; 2206 var slidesToLoad = params.loader.loadAllSlides ? slides.length : params.slidesPerView*(1+params.loader.surroundGroups); 2207 for (var i=0; i< slidesToLoad; i++) { 2208 if (params.loader.slidesHTMLType=='outer') slidesHTML+=slides[i]; 2209 else { 2210 slidesHTML+='<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+'</'+params.slideElement+'>'; 2211 } 2212 } 2213 _this.wrapper.innerHTML = slidesHTML; 2214 _this.calcSlides(true); 2215 //Add permanent transitionEnd callback 2216 if (!params.loader.loadAllSlides) { 2217 _this.wrapperTransitionEnd(_this.reloadSlides, true); 2218 } 2219 } 2220 2221 _this.reloadSlides = function(){ 2222 var slides = params.loader.slides; 2223 var newActiveIndex = parseInt(_this.activeSlide().data('swiperindex'),10) 2224 if (newActiveIndex<0 || newActiveIndex>slides.length-1) return //<-- Exit 2225 _this.activeLoaderIndex = newActiveIndex; 2226 var firstIndex = Math.max(0, newActiveIndex - params.slidesPerView*params.loader.surroundGroups) 2227 var lastIndex = Math.min(newActiveIndex+params.slidesPerView*(1+params.loader.surroundGroups)-1, slides.length-1) 2228 //Update Transforms 2229 if (newActiveIndex>0) { 2230 var newTransform = -slideSize*(newActiveIndex-firstIndex) 2231 _this.setWrapperTranslate(newTransform); 2232 _this.setWrapperTransition(0); 2233 } 2234 //New Slides 2235 if (params.loader.logic==='reload') { 2236 _this.wrapper.innerHTML = ''; 2237 var slidesHTML = ''; 2238 for (var i = firstIndex; i<=lastIndex; i++) { 2239 slidesHTML += params.loader.slidesHTMLType == 'outer' ? slides[i] : '<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+'</'+params.slideElement+'>'; 2240 } 2241 _this.wrapper.innerHTML = slidesHTML; 2242 } 2243 else { 2244 var minExistIndex=1000; 2245 var maxExistIndex=0; 2246 for (var i=0; i<_this.slides.length; i++) { 2247 var index = _this.slides[i].data('swiperindex'); 2248 if (index<firstIndex || index>lastIndex) { 2249 _this.wrapper.removeChild(_this.slides[i]); 2250 } 2251 else { 2252 minExistIndex = Math.min(index, minExistIndex) 2253 maxExistIndex = Math.max(index, maxExistIndex) 2254 } 2255 } 2256 for (var i=firstIndex; i<=lastIndex; i++) { 2257 if (i<minExistIndex) { 2258 var newSlide = document.createElement(params.slideElement); 2259 newSlide.className = params.slideClass; 2260 newSlide.setAttribute('data-swiperindex',i); 2261 newSlide.innerHTML = slides[i];
2262 _this.wrapper.insertBefore(newSlide, _this.wrapper.firstChild); 2263 } 2264 if (i>maxExistIndex) { 2265 var newSlide = document.createElement(params.slideElement); 2266 newSlide.className = params.slideClass; 2267 newSlide.setAttribute('data-swiperindex',i); 2268 newSlide.innerHTML = slides[i]; 2269 _this.wrapper.appendChild(newSlide); 2270 } 2271 } 2272 } 2273 //reInit 2274 _this.reInit(true); 2275 } 2276 2277 /*================================================== 2278 Make Swiper 2279 ====================================================*/ 2280 function makeSwiper(){ 2281 _this.calcSlides(); 2282 if (params.loader.slides.length>0 && _this.slides.length==0) { 2283 _this.loadSlides(); 2284 } 2285 if (params.loop) { 2286 _this.createLoop(); 2287 } 2288 _this.init(); 2289 initEvents(); 2290 if (params.pagination && params.createPagination) { 2291 _this.createPagination(true); 2292 } 2293 if (params.loop || params.initialSlide>0) { 2294 _this.swipeTo( params.initialSlide, 0, false ); 2295 } 2296 else { 2297 _this.updateActiveSlide(0); 2298 } 2299 if (params.autoplay) { 2300 _this.startAutoplay(); 2301 } 2302 2303 } 2304 2305 makeSwiper(); 2306} 2307 2308Swiper.prototype = { 2309 plugins : {}, 2310 2311 /*================================================== 2312 Wrapper Operations 2313 ====================================================*/ 2314 wrapperTransitionEnd : function(callback, permanent) { 2315 var a = this, 2316 el = a.wrapper, 2317 events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'], 2318 i; 2319 2320 function fireCallBack() { 2321 callback(a); 2322 if (a.params.queueEndCallbacks) a._queueEndCallbacks = false; 2323 if (!permanent) { 2324 for (i=0; i<events.length; i++) { 2325 a.h.removeEventListener(el, events[i], fireCallBack); 2326 } 2327 } 2328 } 2329 2330 if (callback) { 2331 for (i=0; i<events.length; i++) { 2332 a.h.addEventListener(el, events[i], fireCallBack); 2333 } 2334 } 2335 }, 2336 2337 getWrapperTranslate : function (axis) { 2338 var el = this.wrapper, 2339 matrix, curTransform, curStyle, transformMatrix; 2340 2341 // automatic axis detection 2342 if (typeof axis == 'undefined') { 2343 axis = this.params.mode == 'horizontal' ? 'x' : 'y'; 2344 } 2345 2346 curStyle = window.getComputedStyle(el, null); 2347 2348 if (window.WebKitCSSMatrix) { 2349 transformMatrix = new WebKitCSSMatrix(curStyle.webkitTransform); 2350 } 2351 2352 else { 2353 transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue("transform").replace("translate(", "matrix(1, 0, 0, 1,"); 2354 matrix = transformMatrix.toString().split(','); 2355 } 2356 2357 if (this.support.transforms && this.params.useCSS3Transforms) { 2358 if (axis=='x') { 2359 //Latest Chrome and webkits Fix 2360 if (window.WebKitCSSMatrix) 2361 curTransform = transformMatrix.m41; 2362 //Crazy IE10 Matrix 2363 else if (matrix.length==16) 2364 curTransform = parseFloat( matrix[12] ); 2365 //Normal Browsers 2366 else 2367 curTransform = parseFloat( matrix[4] ); 2368 } 2369 if (axis=='y') { 2370 //Latest Chrome and webkits Fix 2371 if (window.WebKitCSSMatrix) 2372 curTransform = transformMatrix.m42; 2373 //Crazy IE10 Matrix 2374 else if (matrix.length==16) 2375 curTransform = parseFloat( matrix[13] ); 2376 //Normal Browsers 2377 else 2378 curTransform = parseFloat( matrix[5] ); 2379 } 2380 } 2381 else { 2382 if (axis=='x') curTransform = parseFloat(el.style.left,10) || 0; 2383 if (axis=='y') curTransform = parseFloat(el.style.top,10) || 0; 2384 } 2385 return curTransform || 0; 2386 }, 2387 2388 setWrapperTranslate : function (x, y, z) { 2389 var es = this.wrapper.style, 2390 coords = {x: 0, y: 0, z: 0}, 2391 translate; 2392 2393 // passed all coordinates 2394 if (arguments.length == 3) { 2395 coords.x = x;
2396 coords.y = y; 2397 coords.z = z; 2398 } 2399 2400 // passed one coordinate and optional axis 2401 else { 2402 if (typeof y == 'undefined') { 2403 y = this.params.mode == 'horizontal' ? 'x' : 'y'; 2404 } 2405 coords[y] = x; 2406 } 2407 2408 if (this.support.transforms && this.params.useCSS3Transforms) { 2409 translate = this.support.transforms3d ? 'translate3d(' + coords.x + 'px, ' + coords.y + 'px, ' + coords.z + 'px)' : 'translate(' + coords.x + 'px, ' + coords.y + 'px)'; 2410 es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = translate; 2411 } 2412 else { 2413 es.left = coords.x + 'px'; 2414 es.top = coords.y + 'px'; 2415 } 2416 this.callPlugins('onSetWrapperTransform', coords); 2417 if (this.params.onSetWrapperTransform) this.fireCallback(this.params.onSetWrapperTransform, this, coords); 2418 }, 2419 2420 setWrapperTransition : function (duration) { 2421 var es = this.wrapper.style; 2422 es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = (duration / 1000) + 's'; 2423 this.callPlugins('onSetWrapperTransition', {duration: duration}); 2424 if (this.params.onSetWrapperTransition) this.fireCallback(this.params.onSetWrapperTransition, this, duration); 2425 }, 2426 2427 /*================================================== 2428 Helpers 2429 ====================================================*/ 2430 h : { 2431 getWidth: function (el, outer) { 2432 var width = window.getComputedStyle(el, null).getPropertyValue('width') 2433 var returnWidth = parseFloat(width); 2434 //IE Fixes 2435 if(isNaN(returnWidth) || width.indexOf('%')>0) { 2436 returnWidth = el.offsetWidth - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')); 2437 } 2438 if (outer) returnWidth += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')) 2439 2440 return returnWidth; 2441 }, 2442 getHeight: function(el, outer) { 2443 if (outer) return el.offsetHeight; 2444 2445 var height = window.getComputedStyle(el, null).getPropertyValue('height') 2446 var returnHeight = parseFloat(height); 2447 //IE Fixes 2448 if(isNaN(returnHeight) || height.indexOf('%')>0) { 2449 returnHeight = el.offsetHeight - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')); 2450 } 2451 if (outer) returnHeight += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')) 2452 return returnHeight; 2453 }, 2454 getOffset: function(el) { 2455 var box = el.getBoundingClientRect(); 2456 var body = document.body; 2457 var clientTop = el.clientTop || body.clientTop || 0; 2458 var clientLeft = el.clientLeft || body.clientLeft || 0; 2459 var scrollTop = window.pageYOffset || el.scrollTop; 2460 var scrollLeft = window.pageXOffset || el.scrollLeft; 2461 if (document.documentElement && !window.pageYOffset) { 2462 //IE7-8 2463 scrollTop = document.documentElement.scrollTop; 2464 scrollLeft = document.documentElement.scrollLeft; 2465 } 2466 return { 2467 top: box.top + scrollTop - clientTop, 2468 left: box.left + scrollLeft - clientLeft 2469 }; 2470 }, 2471 windowWidth : function() { 2472 if (window.innerWidth) return window.innerWidth 2473 else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth; 2474 }, 2475 windowHeight : function() { 2476 if (window.innerHeight) return window.innerHeight 2477 else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight; 2478 }, 2479 windowScroll : function() { 2480 var left=0, top=0; 2481 if (typeof pageYOffset != 'undefined') { 2482 return { 2483 left: window.pageXOffset, 2484 top: window.pageYOffset 2485 } 2486 } 2487 else if (document.documentElement) { 2488 return { 2489 left: document.documentElement.scrollLeft, 2490 top: document.documentElement.scrollTop 2491 } 2492 } 2493 }, 2494 2495 addEventListener : function (el, event, listener, useCapture) { 2496 if (typeof useCapture == 'undefined') { 2497 useCapture = false; 2498 } 2499 2500 if (el.addEventListener) { 2501 el.addEventListener(event, listener, useCapture); 2502 } 2503 else if (el.attachEvent) { 2504 el.attachEvent('on' + event, listener); 2505 } 2506 }, 2507 2508 removeEventListener : function (el, event, listener, useCapture) { 2509 if (typeof useCapture == 'undefined') { 2510 useCapture = false; 2511 } 2512 2513 if (el.removeEventListener) { 2514 el.removeEventListener(event, listener, useCapture); 2515 } 2516 else if (el.detachEvent) { 2517 el.detachEvent('on' + event, listener); 2518 } 2519 } 2520 }, 2521 setTransform : function (el, transform) { 2522 var es = el.style 2523 es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transform 2524 }, 2525 setTranslate : function (el, translate) { 2526 var es = el.style 2527 var pos = { 2528 x : translate.x || 0, 2529 y : translate.y || 0, 2530 z : translate.z || 0 2531 }; 2532 var transformString = this.support.transforms3d ? 'translate3d('+(pos.x)+'px,'+(pos.y)+'px,'+(pos.z)+'px)' : 'translate('+(pos.x)+'px,'+(pos.y)+'px)'; 2533 es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transformString; 2534 if (!this.support.transforms) { 2535 es.left = pos.x+'px' 2536 es.top = pos.y+'px' 2537 } 2538 }, 2539 setTransition : function (el, duration) { 2540 var es = el.style 2541 es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = duration+'ms'; 2542 }, 2543 /*================================================== 2544 Feature Detection 2545 ====================================================*/ 2546 support: { 2547 2548 touch : (window.Modernizr && Modernizr.touch===true) || (function() { 2549 return !!(("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch); 2550 })(), 2551 2552 transforms3d : (window.Modernizr && Modernizr.csstransforms3d===true) || (function() { 2553 var div = document.createElement('div').style; 2554 return ("webkitPerspective" in div || "MozPerspective" in div || "OPerspective" in div || "MsPerspective" in div || "perspective" in div); 2555 })(), 2556 2557 transforms : (window.Modernizr && Modernizr.csstransforms===true) || (function(){ 2558 var div = document.createElement('div').style; 2559 return ('transform' in div || 'WebkitTransform' in div || 'MozTransform' in div || 'msTransform' in div || 'MsTransform' in div || 'OTransform' in div); 2560 })(), 2561 2562 transitions : (window.Modernizr && Modernizr.csstransitions===true) || (function(){ 2563 var div = document.createElement('div').style; 2564 return ('transition' in div || 'WebkitTransition' in div || 'MozTransition' in div || 'msTransition' in div || 'MsTransition' in div || 'OTransition' in div); 2565 })() 2566 }, 2567 2568 browser : { 2569 2570 ie8 : (function(){ 2571 var rv = -1; // Return value assumes failure. 2572 if (navigator.appName == 'Microsoft Internet Explorer') { 2573 var ua = navigator.userAgent; 2574 var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); 2575 if (re.exec(ua) != null) 2576 rv = parseFloat(RegExp.$1); 2577 } 2578 return rv != -1 && rv < 9; 2579 })(), 2580 2581 ie10 : window.navigator.msPointerEnabled 2582 } 2583} 2584 2585/*========================= 2586 jQuery & Zepto Plugins 2587 ===========================*/ 2588if (window.jQuery||window.Zepto) { 2589 (function($){ 2590 if(!jQuery().swiper) { 2591 $.fn.swiper = function(params) { 2592 var s = new Swiper($(this)[0], params) 2593 $(this).data('swiper',s); 2594 return s; 2595 } 2596 } 2597 })(window.jQuery||window.Zepto) 2598} 2599 2600// component 2601if ( typeof( module ) !== 'undefined' ) 2602{ 2603 module.exports = Swiper; 2604} 2605 2606 2607 2608 2609 2610} 2611 2612 2613 2614 2615/* 2616 * Swiper Smooth Progress 1.1.0 2617 * Smooth progress plugin for Swiper 2618 * 2619 * http://www.idangero.us/sliders/swiper/plugins/progress.php 2620 * 2621 * Copyright 2010-2014, Vladimir Kharlampidi 2622 * The iDangero.us 2623 * http://www.idangero.us/ 2624 * 2625 * Licensed under GPL & MIT 2626 * 2627 * Released on: January 29, 2014 2628*/ 2629Swiper.prototype.plugins.progress=function(a){function b(){for(var b=0;b<a.slides.length;b++){var c=a.slides[b];c.progressSlideSize=e?a.h.getWidth(c):a.h.getHeight(c),c.progressSlideOffset="offsetLeft"in c?e?c.offsetLeft:c.offsetTop:e?c.getOffset().left-a.h.getOffset(a.container).left:c.getOffset().top-a.h.getOffset(a.container).top}d=e?a.h.getWidth(a.wrapper)+a.wrapperLeft+a.wrapperRight-a.width:a.h.getHeight(a.wrapper)+a.wrapperTop+a.wrapperBottom-a.height}function c(b){var c,b=b||{x:0,y:0,z:0};c=1==a.params.centeredSlides?e?-b.x+a.width/2:-b.y+a.height/2:e?-b.x:-b.y;for(var f=0;f<a.slides.length;f++){var g=a.slides[f],h=1==a.params.centeredSlides?g.progressSlideSize/2:0,i=(c-g.progressSlideOffset-h)/g.progressSlideSize;g.progress=i}a.progress=e?-b.x/d:-b.y/d,a.params.onProgressChange&&a.fireCallback(a.params.onProgressChange,a)}var d,e="horizontal"==a.params.mode,f={onFirstInit:function(){b(),c({x:a.getWrapperTranslate("x"),y:a.getWrapperTranslate("y")})},onInit:function(){b()},onSetWrapperTransform:function(a){c(a)}};return f}; 2630 2631 2632 2633 2634 2635 2636 2637jQuery(document).ready(function($){ 2638 2639 Array.prototype.getKeyByValue = function( value ) { 2640 for( var prop in this ) { 2641 if( this.hasOwnProperty( prop ) ) { 2642 if( this[ prop ] === value ) 2643 return prop; 2644 } 2645 } 2646 } 2647 2648 var doneVideoInit = false; 2649 var $captionTrans = 0; 2650 var $loading_bg_storage = $('.first-section .nectar-slider-loading').css('background-image'); 2651 2652 function transparentheaderLoadingCalcs() { 2653 //handle slider loading pos when trasparent header is being used 2654 if($('body #header-outer[data-transparent-header="true"]').length > 0) { 2655 2656 if($('#page-header-bg').length == 0) { 2657 2658 $('.nectar-slider-wrap.first-section .swiper-container .swiper-wrapper .swiper-slide').addClass('not-loaded'); 2659 2660 if($('.container-wrap .main-content > .row > div').find('.nectar-slider-wrap.first-section').length > 0) { 2661 $('.container-wrap .main-content > .row > div').first().css('padding-top','0'); 2662 } 2663 2664 2665 2666 if($('#header-outer[data-remove-border="true"]').length == 0) { 2667 //if not using flexible/fullscreen height - calculate the loading / bg pos early (if using the option calculates later) 2668 if($('.first-section .nectar-slider-wrap[data-flexible-height="true"]').length == 0 && $('.first-section .nectar-slider-wrap[data-fullscreen="true"]').length == 0) { 2669 $('.first-section .nectar-slider-loading').css({ 2670 'top': $('#header-space').height(), 2671 'background-position' : 'center ' + ((($('.first-section .swiper-container').height()/2) + 15) - $('#header-space').height()) +'px' 2672 });
2673 2674 $('.first-section .nectar-slider-wrap .nectar-slider-loading .loading-icon').css({ 2675 'opacity' : '1', 2676 'height' : $('.first-section .swiper-container').height() - $('#header-space').height() + 'px' 2677 }); 2678 } else { 2679 var $loading_bg_storage = $('.first-section .nectar-slider-loading').css('background-image'); 2680 2681 $('.first-section .nectar-slider-loading').css({ 2682 'top': $('#header-space').height(), 2683 'background-image': 'none' 2684 }); 2685 } 2686 } 2687 2688 } 2689 } 2690 } 2691 transparentheaderLoadingCalcs(); 2692 2693 //move parallax sliders to correct dom location 2694 var parallaxSlider = $('.parallax_slider_outer.first-section'); 2695 2696 //ajaxify 2697 $(window).on("pronto.request", function(){ 2698 2699 //remove window resize events 2700 $(window).off('resize.nsSliderContent'); 2701 $(window).off('resize.dynamicHeights'); 2702 $(window).off('resize.nsHeightUpdate'); 2703 2704 //clear all autoplay intervals 2705 $('.nectar-slider-wrap').each(function(){ 2706 if($(this).attr('data-autorotate') && $(this).attr('data-autorotate').length > 1) { 2707 2708 var $autoplayVal = $('#'+$(this).attr('id')).attr('data-autorotate'); 2709 if(typeof $autoplayVal !='undefined' && $autoplayVal.length != '0' && parseInt($autoplayVal)) { 2710 clearInterval(autoplay[$('#'+$(this).attr('id')).attr('autoplay-id')].interval); 2711 } 2712 2713 } 2714 }); 2715 2716 }); 2717 2718 $(window).on("pronto.render", function(){ 2719 2720 if($('.nectar-slider-wrap').length > 0){ 2721 2722 $(window).on('resize.nsSliderContent', nsSliderContentResize); 2723 2724 parallaxSlider = $('.parallax_slider_outer.first-section'); 2725 $(window).unbind('resize.nsHeightUpdate'); 2726 2727 2728 transparentheaderLoadingCalcs(); 2729 2730 ////remove parallax if using page header on projects/posts 2731 //if($('body.single #page-header-bg').length > 0) $('.parallax_slider_outer').removeClass('parallax_slider_outer').addClass('no-left-margin'); 2732 //parallaxSliderPos(); 2733 2734 nectarSliderMainInit(); 2735 setTimeout(function(){ 2736 initialSlideLoad(); 2737 dynamicHeightSliders(); 2738 $(window).on('resize.dynamicHeights', dynamicHeightSliders); 2739 sliderSize(); 2740 resizeToCover(); 2741 parallaxCheck(); 2742 sliderbuttonHoverEffect(); 2743 },150); 2744 2745 2746 } 2747 2748 }); //pronto render 2749 2750 function parallaxSliderPos(){ 2751 if(parallaxSlider.parent().attr('class') == 'wpb_wrapper') { 2752 2753 //give the slider the custom row ID if assigned 2754 if(parallaxSlider.parents('.wpb_row').length > 0) { 2755 if(parallaxSlider.parents('.wpb_row').not('[id^="fws_"]').length > 0) parallaxSlider.attr('id',parallaxSlider.parents('.wpb_row').attr('id')); 2756 } 2757 //remove the row 2758 parallaxSlider.parents('.wpb_row').remove(); 2759 } 2760 //alter the DOM pos 2761 parallaxSlider.insertBefore('.container-wrap'); 2762 2763 } 2764 2765 ////remove parallax if using page header on projects/posts 2766 //if($('body.single #page-header-bg').length > 0) $('.parallax_slider_outer').removeClass('parallax_slider_outer').addClass('no-left-margin'); 2767 2768 //parallaxSliderPos(); 2769 2770 var $onMobileBrowser = navigator.userAgent.match(/(Android|iPod|iPhone|iPad|BlackBerry|IEMobile|Opera Mini)/); 2771 2772 //initial cals 2773 var $smoothSrollWidth = 0; 2774 var nectarSliderKenBurns; 2775 2776 /*========================= 2777 Begin Nectar Slider Main Construction 2778 ===========================*/ 2779 var $nectarSliders = []; 2780 2781 function nectarSliderMainInit() { 2782 2783 $nectarSliders = []; 2784 2785 //remove boxed full width attr when not needed 2786 $('.nectar-slider-wrap[data-full-width="boxed-full-width"]').each(function(){ if($(this).parents('.wpb_column').length > 0 && $(this).parents('.full-width-content').length > 0) $(this).attr('data-full-width','false') }); 2787 var $leftHeaderSize = ($('#header-outer[data-format="left-header"]').length > 0 && window.innerWidth >= 1000) ? parseInt($('#header-outer[data-format="left-header"]').width()) : 0; 2788 var $windowWidth = $(window).width() - $leftHeaderSize; 2789 2790 if($('body > #boxed').length == 0 && $('.nectar-slider-wrap[data-full-width="true"]').parent().attr('id') != 'portfolio-extra' && $('.nectar-slider-wrap[data-full-width="true"]').parents('.post-area:not(".span_12")').length == 0){ 2791 $('.nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .nectar-slider-wrap').css({'left': -( ($windowWidth-$smoothSrollWidth)/2 - $('.main-content').width()/2), 'margin-left': '0' }); 2792 $('.nectar-slider-wrap[data-full-width="true"] .swiper-container, .nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .swiper-container, .parallax_slider_outer.first-section .nectar-slider-wrap').css('width',$windowWidth); 2793 } 2794 else if( $('.nectar-slider-wrap[data-full-width="true"]').parent().attr('id') == 'portfolio-extra' && $('#full_width_portfolio').length != 0){ 2795 $('.nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .nectar-slider-wrap').css({'left': -( ($windowWidth-$smoothSrollWidth)/2 - $('.main-content').width()/2), 'margin-left': '0' }); 2796 $('.nectar-slider-wrap[data-full-width="true"] .swiper-container, .nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .swiper-container, .parallax_slider_outer.first-section .nectar-slider-wrap').css('width',$windowWidth); 2797 } 2798 else { 2799 var $container = ($('body > #boxed').length == 0) ? '.post-area' : '.container-wrap';
2800 //backup incase only slider is used with nothing else in boxed mode 2801 if($($container).width() == '0' && $('body > #boxed').length > 0) $container = '#boxed'; 2802 $('.nectar-slider-wrap[data-full-width="true"] .swiper-container, .nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .swiper-container, .parallax_slider_outer.first-section .nectar-slider-wrap').css('width',$($container).width()); 2803 } 2804 2805 //show slider once full width calcs have taken place 2806 $('.nectar-slider-wrap, .slide-bg-overlay').show(); 2807 2808 //set bg colors / textures after js has made the slider fullwidth 2809 $('.swiper-container, .swiper-slide').css('background-color','#000'); 2810 $('.video-texture').css('opacity','1'); 2811 2812 2813 2814 $('.nectar-slider-wrap').each(function(i){ 2815 var $arrows = $(this).find('.swiper-container').attr('data-arrows'); 2816 var $bullets = $(this).find('.swiper-container').attr('data-bullets'); 2817 var $swipe = $(this).find('.swiper-container').attr('data-desktop-swipe'); 2818 var $loop = $(this).find('.swiper-container').attr('data-loop'); 2819 2820 //swipe 2821 if($swipe == 'true' && $('#'+$(this).attr('id') +' .swiper-wrapper > div').length > 1 && $(this).attr('data-overall_style') != 'directional' ){ 2822 var $grab = 1; 2823 var $desktopSwipe = 1; 2824 } else { 2825 var $grab = 0; 2826 var $desktopSwipe = 0; 2827 } 2828 2829 ////set swipe as true for mobile 2830 if($('body').hasClass('mobile') && $(this).attr('data-overall_style') != 'directional') $desktopSwipe = 1; 2831 2832 //bullets 2833 if($bullets == 'true' && $(this).find('.swiper-wrapper > div').length > 1 && $(this).attr('data-overall_style') != 'directional' ){ 2834 $bullets = '#'+$(this).attr('id')+' .slider-pagination'; 2835 } else { 2836 $bullets = null; 2837 } 2838 2839 //loop 2840 $useLoop = ($loop == 'true' && $(this).find('.swiper-wrapper > div').length > 1 && !$('html').hasClass('no-video') || $(this).attr('data-overall_style') == 'directional' && $(this).find('.swiper-wrapper > div').length > 1 && !$('html').hasClass('no-video')) ? true : false; 2841 if($useLoop == false) $(this).find('.swiper-container').attr('data-loop','false'); 2842 2843 //obj config 2844 2845 if($(this).attr('data-transition') == 'fade' && $(this).attr('data-overall_style') != 'directional' && $(this).attr('data-button-styling') != 'btn_with_preview'){ 2846 2847 var progressVar = true; 2848 var touchRatio = 1.3; 2849 2850 $sliderOptions = { 2851 loop: $useLoop, 2852 grabCursor: $grab, 2853 touchRatio: touchRatio, 2854 speed: 600, 2855 pagination : $bullets, 2856 simulateTouch: $desktopSwipe, 2857 2858 onSlideChangeEnd: nectarSlideRotateReset, 2859 onTouchEnd: nectarSlideRotateResetTouch, 2860 2861 //onTouchEnd: captionTransition, 2862 onSlideChangeStart: onChangeStart, 2863 onTouchMove: clearAutoplay, 2864 onFirstInit: nectarInit, 2865 progress: progressVar, 2866 onProgressChange: function(swiper){ 2867 2868 if($(swiper.container).parents('.nectar-slider-wrap').hasClass('loaded')) { 2869 for (var i = 0; i < swiper.slides.length; i++){ 2870 var slide = swiper.slides[i]; 2871 var progress = slide.progress; 2872 var translate = progress*swiper.width; 2873 2874 var opacity = Math.max(1 - Math.abs(progress), 0); 2875 slide.style.opacity = opacity; 2876 swiper.setTransform(slide,'translate3d('+translate+'px,0,0)'); 2877 } 2878 } 2879 }, 2880 onTouchStart: function(swiper){ 2881 for (var i = 0; i < swiper.slides.length; i++){ 2882 swiper.setTransition(swiper.slides[i], 0); 2883 } 2884 }, 2885 onSetWrapperTransition: function(swiper, speed) { 2886 for (var i = 0; i < swiper.slides.length; i++){ 2887 swiper.setTransition(swiper.slides[i], speed); 2888 } 2889 } 2890 } 2891 2892 2893 } else { 2894 2895 var touchRatio = 0.6; 2896 var css3Trans = ($('#'+$(this).attr('id') + '.nectar-slider-wrap[data-overall_style="directional"]').length == 1) ? false: true; 2897 $sliderOptions = { 2898 loop: $useLoop, 2899 grabCursor: $grab, 2900 touchRatio: touchRatio, 2901 speed: 500, 2902 useCSS3Transforms: css3Trans, 2903 pagination : $bullets, 2904 simulateTouch: $desktopSwipe, 2905 2906 onSlideChangeEnd: nectarSlideRotateReset, 2907 onTouchEnd: nectarSlideRotateResetTouch, 2908 2909 onSlideChangeStart: onChangeStart, 2910 onTouchMove: clearAutoplay, 2911 onFirstInit: nectarInit 2912 2913 } 2914 } 2915 2916 2917 $nectarSliders[i] = new Swiper('#'+$(this).attr('id')+' .swiper-container', $sliderOptions); 2918 $nectarSliders[i].swipeReset(); 2919 2920 $('#'+$(this).attr('id')).addClass('nectar-slider-enabled'); 2921 2922 2923 2924 //webkit looped slider first video fix 2925 if(navigator.userAgent.indexOf('Chrome') > 0 && !/Edge\/12./i.test(navigator.userAgent) && !/Edge\/\d./i.test(navigator.userAgent)) { 2926 if( jQuery(this).find('.swiper-slide:nth-child(2) video source[type="video/webm"]').length > 0 && jQuery(this).find('.swiper-container').attr('data-loop') == 'true') { 2927 2928 var webmSource = jQuery(this).find('.swiper-slide:nth-child(2) video source[type="video/webm"]').attr('src') + "?id="+Math.ceil(Math.random()*10000); 2929 var firstVideo = jQuery(this).find('.swiper-slide:nth-child(2) video').get(0); 2930 firstVideo.src = webmSource; 2931 firstVideo.load(); 2932 2933 var webmSource2 = jQuery(this).find('.swiper-slide:last-child video source[type="video/webm"]').attr('src') + "?id="+Math.ceil(Math.random()*10000); 2934 var lastVideo = jQuery(this).find('.swiper-slide:last-child video').get(0); 2935 lastVideo.src = webmSource2; 2936 lastVideo.load(); 2937 } 2938 2939 if( jQuery(this).find('.swiper-slide:eq(-2) video source[type="video/webm"]').length > 0 && jQuery(this).find('.swiper-container').attr('data-loop') == 'true') { 2940 2941 var webmSource = jQuery(this).find('.swiper-slide:eq(-2) video source[type="video/webm"]').attr('src') + "?id="+Math.ceil(Math.random()*10000); 2942 var firstVideo = jQuery(this).find('.swiper-slide:eq(-2) video').get(0); 2943 firstVideo.src = webmSource; 2944 firstVideo.load(); 2945 2946 var webmSource2 = jQuery(this).find('.swiper-slide:nth-child(1) video source[type="video/webm"]').attr('src') + "?id="+Math.ceil(Math.random()*10000); 2947 var lastVideo = jQuery(this).find('.swiper-slide:nth-child(1) video').get(0); 2948 lastVideo.src = webmSource2; 2949 lastVideo.load(); 2950 } 2951 } 2952 2953 2954 //autorotation visualized style 2955 if($('#'+$(this).attr('id') + ' [data-bullet_style="see_through_ar_visualized"]').length == 1) { 2956 $('#'+$(this).attr('id')).find('.slider-pagination .swiper-pagination-switch').append('<svg width="65px" height="65px" viewBox="0 0 72 72" xmlns="http://www.w3.org/2000/svg"><circle stroke-width="9" fill="none" stroke-linecap="round" cx="33" cy="33" r="28"></circle> <circle class="time" stroke-width="9" fill="none" stroke-linecap="round" cx="33" cy="33" r="28"></circle></svg>'); 2957 } 2958 2959 //Navigation arrows 2960 2961 ////default arrows 2962 if($arrows == 'true' && $('#'+$(this).attr('id') +' .swiper-wrapper > div').length > 1 && $('#'+$(this).attr('id') + '.nectar-slider-wrap[data-button-styling="btn_with_preview"]').length == 0 && $('#'+$(this).attr('id') + '.nectar-slider-wrap[data-overall_style="directional"]').length == 0 ){ 2963 2964 $('.slide-count i').transition({ scale: 0.5, opacity: 0 }); 2965 2966 //hover event 2967 $('body').on('mouseenter','.nectar-slider-wrap[data-button-styling="btn_with_count"][data-overall_style="classic"] .swiper-container .slider-prev, .nectar-slider-wrap[data-button-styling="btn_with_count"] .swiper-container .slider-next',function(){ 2968 2969 $(this).find('.slide-count i').clearQueue().stop(true,true).delay(110).transition({ scale: 1, opacity: 1 },200);
2970 2971 $(this).stop(true,true).animate({ 2972 'width' : '100px' 2973 },300,'easeOutCubic'); 2974 $(this).find('.slide-count span').clearQueue().stop().delay(100).animate({ 2975 'opacity' : '1' 2976 },225,'easeOutCubic'); 2977 }); 2978 2979 $('body').on('mouseleave','.nectar-slider-wrap[data-button-styling="btn_with_count"][data-overall_style="classic"] .swiper-container .slider-prev, .nectar-slider-wrap[data-button-styling="btn_with_count"] .swiper-container .slider-next',function(){ 2980 2981 $('.slide-count i').stop(true,true).transition({ scale: 0, opacity: 0 },200); 2982 2983 $(this).stop().delay(150).animate({ 2984 'width' : '50px' 2985 },300,'easeOutCubic'); 2986 $(this).find('.slide-count span').stop(true,true).animate({ 2987 'opacity' : '0' 2988 },200,'easeOutCubic'); 2989 }); 2990 2991 //add slide counts 2992 var $slideCount = ($(this).find('.swiper-container').attr('data-loop') != 'true' ) ? $('#'+$(this).attr('id') + ' .swiper-wrapper > div').length : $('#'+$(this).attr('id') + ' .swiper-wrapper > div').length - 2; 2993 2994 //ie8 2995 if($('html').hasClass('no-video')) $slideCount = $('#'+$(this).attr('id') + ' .swiper-wrapper > div').length; 2996 2997 $('#'+$(this).attr('id')+' .slider-prev .slide-count .slide-total').html( $slideCount ); 2998 $('#'+$(this).attr('id')+' .slider-next .slide-count .slide-total').html( $slideCount ); 2999 3000 //prev 3001 3002 function prevArrowAnimation(e) { 3003 3004 if($(this).hasClass('inactive')) return false; 3005 3006 var $that = $(this); 3007 3008 //non looped slider 3009 if($(this).parents('.swiper-container').attr('data-loop') != 'true') { 3010 3011 3012 if( $(this).parents('.swiper-container').find('.swiper-slide-active').index()+1 == 1 && !$('html').hasClass('no-video')){ 3013 3014 //make sure the animation is complete 3015 var $timeout; 3016 3017 clearTimeout($timeout); 3018 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,700); 3019 3020 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') != 'fade') { 3021 3022 var $that = $(this); 3023 3024 $(this).parents('.swiper-container').animate({ 3025 'left' : 25+'px' 3026 },250,function(){ 3027 //$(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','left,top'); 3028 //$nectarSliders[i].swipeReset(); 3029 $that.parents('.swiper-container').stop().animate({ 3030 'left' : 0+'px' 3031 },250); 3032 }); 3033 } 3034 3035 $(this).addClass('inactive'); 3036 3037 } 3038 3039 } 3040 3041 e.preventDefault(); 3042 $nectarSliders[i].swipePrev(); 3043 3044 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') == 'fade') { 3045 var $timeout; 3046 3047 clearTimeout($timeout); 3048 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,800); 3049 3050 $(this).addClass('inactive'); 3051 } 3052 } 3053 3054 $('body').off('click','#'+$(this).attr('id')+' .slider-prev',prevArrowAnimation); 3055 $('body').on('click','#'+$(this).attr('id')+' .slider-prev',prevArrowAnimation); 3056 3057 3058 function nextArrowAnimation(e) { 3059 3060 if($(this).hasClass('inactive')) return false; 3061 3062 var $that = $(this); 3063 var $slideNum = $(this).parents('.swiper-container').find('.swiper-wrapper > div').length; 3064 3065 //non looped slider 3066 if($(this).parents('.swiper-container').attr('data-loop') != 'true') { 3067 3068 if( $(this).parents('.swiper-container').find('.swiper-slide-active').index()+1 == $slideNum && !$('html').hasClass('no-video')) { 3069 3070 //make sure the animation is complete 3071 var $timeout; 3072 3073 clearTimeout($timeout); 3074 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,700); 3075 3076 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') != 'fade') { 3077 var $that = $(this); 3078 3079 $(this).parents('.swiper-container').animate({ 3080 'left' : -25+'px' 3081 },250,function(){ 3082 $that.parents('.swiper-container').stop().animate({ 3083 'left' : 0+'px' 3084 },250); 3085 }); 3086 } 3087 $(this).addClass('inactive'); 3088 } 3089 } 3090 3091 3092 e.preventDefault(); 3093 $nectarSliders[i].swipeNext(); 3094 3095 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') == 'fade') { 3096 var $timeout; 3097 3098 clearTimeout($timeout); 3099 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,800); 3100 3101 $(this).addClass('inactive'); 3102 } 3103 3104 } 3105 3106 //next 3107 $('body').off('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimation); 3108 $('body').on('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimation); 3109 3110 3111 3112 } 3113 ////button with preview on hover 3114 else if($arrows == 'true' && $('#'+$(this).attr('id') +' .swiper-wrapper > div').length > 1 && $('#'+$(this).attr('id') + '.nectar-slider-wrap[data-button-styling="btn_with_preview"]').length == 1 && $('#'+$(this).attr('id') + '.nectar-slider-wrap[data-overall_style="directional"]').length == 0){ 3115 3116 3117 function prevArrowAnimationWithPreview(e) { 3118 if($(this).hasClass('inactive')) return false; 3119 var $that = $(this); 3120 3121 //make sure the animation is complete 3122 var $timeout; 3123 3124 clearTimeout($timeout); 3125 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,1000); 3126 3127 var $timeout2; 3128 3129 clearTimeout($timeout2); 3130 $timeout2 = setTimeout(function(){ $that.removeClass('stophover'); } ,500); 3131 3132 $(this).addClass('inactive').addClass('stophover'); 3133 3134 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').prev('.swiper-slide').removeClass('prev-high-z-index'); 3135 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().removeClass('prev-move'); 3136 3137 e.preventDefault(); 3138 $nectarSliders[i].swipePrev(); 3139 } 3140 3141 function nextArrowAnimationWithPreview(e) { 3142 if($(this).hasClass('inactive')) return false; 3143 var $that = $(this); 3144 3145 //make sure the animation is complete 3146 var $timeout; 3147 3148 clearTimeout($timeout); 3149 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,1000); 3150 3151 var $timeout2; 3152 3153 clearTimeout($timeout2); 3154 $timeout2 = setTimeout(function(){ $that.removeClass('stophover'); } ,500); 3155 3156 $(this).addClass('inactive').addClass('stophover'); 3157 3158 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').next('.swiper-slide').removeClass('high-z-index'); 3159 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().removeClass('next-move'); 3160 3161 e.preventDefault(); 3162 $nectarSliders[i].swipeNext(); 3163 } 3164 3165 function darkSlideNextMouseOver(currentSlider, activeIndex) { 3166 var $indexAdd = ($(currentSlider).find('.swiper-container').attr('data-loop') == 'true') ? 2 : 2; 3167 3168 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + 1) +')').attr('data-color-scheme') == 'dar
3168k') { 3169 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +')').attr('data-color-scheme') == 'dark') { 3170 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +') .video-texture').addClass('half-light-overlay').addClass('no-trans'); 3171 } 3172 else { 3173 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +') .video-texture').addClass('light-overlay').addClass('no-trans'); 3174 } 3175 } else { 3176 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +')').attr('data-color-scheme') == 'light') { 3177 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +') .video-texture').addClass('half-dark-overlay').addClass('no-trans'); 3178 } else { 3179 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +') .video-texture').addClass('dark-overlay').addClass('no-trans'); 3180 } 3181 } 3182 } 3183 function darkSlidePrevMouseOver(currentSlider, activeIndex) { 3184 var $indexAdd = ($(currentSlider).find('.swiper-container').attr('data-loop') == 'true') ? 0 : 0; 3185 3186 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + 1) +')').attr('data-color-scheme') == 'dark') { 3187 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +')').attr('data-color-scheme') == 'dark') { 3188 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +') .video-texture').addClass('half-light-overlay').addClass('no-trans'); 3189 } else { 3190 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +') .video-texture').addClass('light-overlay').addClass('no-trans'); 3191 } 3192 } else { 3193 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +')').attr('data-color-scheme') == 'light') { 3194 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +') .video-texture').addClass('half-dark-overlay').addClass('no-trans'); 3195 } else { 3196 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +') .video-texture').addClass('dark-overlay').addClass('no-trans'); 3197 } 3198 } 3199 } 3200 3201 3202 $('body').off('click','#'+$(this).attr('id')+' .slider-prev',prevArrowAnimationWithPreview); 3203 $('body').on('click','#'+$(this).attr('id')+' .slider-prev',prevArrowAnimationWithPreview); 3204 3205 //next 3206 $('body').off('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimationWithPreview); 3207 $('body').on('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimationWithPreview); 3208 3209 //hover event 3210 $('body').on('mouseenter','.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-next:not(.stophover)',function(){ 3211 3212 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').next('.swiper-slide').addClass('high-z-index'); 3213 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().addClass('next-move'); 3214 $(this).stop().addClass('next-arrow-move'); 3215 darkSlideNextMouseOver($(this).parents('.nectar-slider-wrap'), $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').index()); 3216 3217 }); 3218 3219 $('body').on('mouseleave','.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-next',function(){ 3220 3221 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').next('.swiper-slide').removeClass('high-z-index'); 3222 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().removeClass('next-move'); 3223 $(this).stop().removeClass('next-arrow-move'); 3224 }); 3225 3226 3227 $('body').on('mouseenter','.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-prev:not(.stophover)',function(){ 3228 3229 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').prev('.swiper-slide').addClass('prev-high-z-index'); 3230 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().addClass('prev-move'); 3231 $(this).stop().addClass('prev-arrow-move'); 3232 darkSlidePrevMouseOver($(this).parents('.nectar-slider-wrap'), $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').index()); 3233 }); 3234 3235 $('body').on('mouseleave','.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-prev',function(){ 3236 3237 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').prev('.swiper-slide').removeClass('prev-high-z-index'); 3238 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().removeClass('prev-move'); 3239 $(this).stop().removeClass('prev-arrow-move'); 3240 3241 }); 3242 3243 } else if($('#'+$(this).attr('id') + '.nectar-slider-wrap[data-overall_style="directional"]').length == 1) { 3244 3245 function prevArrowAnimationDirectional(e) { 3246 if($(this).hasClass('inactive') || $(this).parents('.swiper-container').find('.slider-next').hasClass('inactive')) return false; 3247 var $that = $(this); 3248 3249 //cache the widths 3250 if($('#header-outer.transparent').length > 0){ 3251 $('#header-outer nav > ul.sf-menu > li > a, #header-outer nav > ul.buttons > li#search-btn a, #header-outer nav > ul.buttons > li.slide-out-widget-area-toggle a > span, #header-outer .cart-icon-wrap, header#top #logo').each(function(){ 3252 var $extraWidth = ($(this).find('.original .sf-sub-indicator').length > 0) ? 14: 1; 3253 $(this).find('.original').attr('data-w',$(this).find('span.original').width()+$extraWidth); 3254 }); 3255 } 3256 3257 //make sure the animation is complete 3258 var $timeout; 3259 3260 clearTimeout($timeout); 3261 $timeout = setTimeout(function(){ 3262 3263 $that.parents('.swiper-container').removeClass('directional-trans-prev'); 3264 $that.parents('.swiper-container').find('.swiper-wrapper').transition({ 'x': 0, 'left': parseInt($that.parents('.swiper-container').find('.swiper-wrapper').css('left')) + $that.parents('.swiper-container').width() },0); 3265 setTimeout(function(){ 3266 $nectarSliders[i].updateActiveSlide(); 3267 $nectarSliders[i].fixLoop(); 3268 $that.removeClass('inactive'); 3269 },50); 3270 3271 resetContentPos(); 3272 3273 } ,1100); 3274 3275 //call the dark/light slide coloring half way through transition 3276 var $timeout2; 3277 3278 clearTimeout($timeout2); 3279 $timeout2 = setTimeout(function(){ 3280 3281 if($that.parents('.swiper-container').attr('data-loop') != 'true') { 3282 if( $that.parents('.swiper-container').find('.swiper-slide-active').index()+1 != 1) { 3283 onChangeStart($nectarSliders[i]); 3284 } 3285 } 3286 3287 else { 3288 onChangeStart($nectarSliders[i]); 3289 } 3290 3291 } ,100); 3292 3293 //non looped slider 3294 if($(this).parents('.swiper-container').attr('data-loop') != 'true') { 3295 3296 3297 /* if( $(this).parents('.swiper-container').find('.swiper-slide-active').index()+1 == 1 && !$('html').hasClass('no-video')){ 3298 3299 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') != 'fade') { 3300 3301 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,fal
3301se).css('transition','none').animate({ 3302 'left' : parseInt($(this).parents('.swiper-container').find('.swiper-wrapper').css('left')) + 20 3303 },200,function(){ 3304 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','left,top'); 3305 $nectarSliders[i].swipeReset(); 3306 }); 3307 } 3308 } else { */ 3309 3310 $(this).parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active .content').children().each(function(i){ 3311 $(this).stop().delay(i*50).transition({ 3312 'x': $that.parents('.swiper-container').width()/2.5 + "px" 3313 }, 950,'easeInOutQuart'); 3314 }); 3315 //} 3316 3317 } 3318 3319 $(this).addClass('inactive'); 3320 3321 //move the slide with eaising 3322 $(this).parents('.swiper-container').find('.swiper-wrapper').transition({ 'x': $(this).parents('.swiper-container').width() + "px"},1100,'easeInOutQuart'); 3323 3324 if($(this).parents('.swiper-container').attr('data-loop') == 'true') { 3325 $(this).parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active .content > *').each(function(i){ 3326 $(this).stop().delay(i*50).transition({ 3327 'x': $that.parents('.swiper-container').width()/2.5 + "px" 3328 }, 950,'easeInOutQuart'); 3329 }); 3330 } 3331 3332 //kenburns 3333 3334 if($that.parents('.nectar-slider-wrap').is('[data-bg-animation="ken_burns"]')) { 3335 3336 $that.parents('.swiper-container').find('.swiper-slide').attr('data-ken-burns','active'); 3337 3338 clearTimeout(nectarSliderKenBurns); 3339 nectarSliderKenBurns = setTimeout(function(){ 3340 $that.parents('.swiper-container').find('.swiper-slide:not(".swiper-slide-active")').attr('data-ken-burns','inactive'); 3341 },1250); 3342 3343 } 3344 3345 3346 $that.parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active').prev('.swiper-slide').find('.content > *').transition({ 3347 'x': '-' + $that.parents('.swiper-container').width() + "px" 3348 }, 0); 3349 3350 setTimeout(function(){ 3351 $that.parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active').prev('.swiper-slide').find('.content > *').each(function(i){ 3352 3353 $(this).stop().delay(i*50).transition({ 3354 'x': "0px" 3355 }, 750,'easeInOutQuart'); 3356 }); 3357 },200); 3358 3359 $that.parents('.swiper-container').addClass('directional-trans-prev'); 3360 3361 e.preventDefault(); 3362 3363 } 3364 3365 function nextArrowAnimationDirectional(e) { 3366 if($(this).hasClass('inactive') || $(this).parents('.swiper-container').find('.slider-prev').hasClass('inactive')) return false; 3367 var $that = $(this); 3368 3369 //cache the widths 3370 if($('#header-outer.transparent').length > 0){ 3371 $('#header-outer nav > ul.sf-menu > li > a, #header-outer nav > ul.buttons > li#search-btn a, #header-outer nav > ul.buttons > li.slide-out-widget-area-toggle a > span, #header-outer .cart-icon-wrap, header#top #logo').each(function(){ 3372 var $extraWidth = ($(this).find('.original .sf-sub-indicator').length > 0) ? 14: 1; 3373 $(this).find('.original').attr('data-w',$(this).find('span.original').width()+$extraWidth); 3374 }); 3375 } 3376 3377 //make sure the animation is complete 3378 var $timeout; 3379 3380 clearTimeout($timeout); 3381 $timeout = setTimeout(function(){ 3382 3383 $that.parents('.swiper-container').removeClass('directional-trans-next'); 3384 $that.parents('.swiper-container').find('.swiper-wrapper').transition({ 'x': 0, 'left': parseInt($that.parents('.swiper-container').find('.swiper-wrapper').css('left')) - $that.parents('.swiper-container').width() },0); 3385 setTimeout(function(){ 3386 $nectarSliders[i].updateActiveSlide(); 3387 $nectarSliders[i].fixLoop(); 3388 $that.removeClass('inactive'); 3389 },50); 3390 resetContentPos(); 3391 3392 } ,1100); 3393 3394 //call the dark/light slide coloring half way through transition 3395 var $timeout2; 3396 3397 clearTimeout($timeout2); 3398 $timeout2 = setTimeout(function(){ 3399 3400 if($that.parents('.swiper-container').attr('data-loop') != 'true') { 3401 if( $that.parents('.swiper-container').find('.swiper-slide-active').index()+1 != $slideNum) { 3402 onChangeStart($nectarSliders[i]); 3403 } 3404 } 3405 3406 else { 3407 onChangeStart($nectarSliders[i]); 3408 } 3409 3410 } ,100); 3411 3412 3413 3414 var $slideNum = $(this).parents('.swiper-container').find('.swiper-wrapper > div').length; 3415 3416 //non looped slider 3417 if($(this).parents('.swiper-container').attr('data-loop') != 'true') { 3418 3419 if( $(this).parents('.swiper-container').find('.swiper-slide-active').index()+1 == $slideNum && !$('html').hasClass('no-video')) { 3420 3421 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') != 'fade') { 3422 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,fal
3422se).css('transition','none').animate({ 3423 'left' : parseInt($(this).parents('.swiper-container').find('.swiper-wrapper').css('left')) - 20 3424 },200,function(){ 3425 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','left,top'); 3426 $nectarSliders[i].swipeReset(); 3427 }); 3428 } 3429 } else { 3430 $(this).parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active .content > *').each(function(i){ 3431 $(this).stop().delay(i*50).transition({ 3432 'x': '-' + $that.parents('.swiper-container').width()/2.5 + "px" 3433 }, 950,'easeInOutQuart'); 3434 }); 3435 } 3436 } 3437 3438 $(this).addClass('inactive'); 3439 3440 3441 //move the slide with eaising 3442 $(this).parents('.swiper-container').find('.swiper-wrapper').transition({ 'x': - $(this).parents('.swiper-container').width() + "px"},1100,'easeInOutQuart'); 3443 3444 if($(this).parents('.swiper-container').attr('data-loop') == 'true') { 3445 $(this).parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active .content > *').each(function(i){ 3446 $(this).stop().delay(i*50).transition({ 3447 'x': '-' + $that.parents('.swiper-container').width()/2.5 + "px" 3448 }, 950,'easeInOutQuart'); 3449 }); 3450 } 3451 3452 3453 //kenburns 3454 if($that.parents('.nectar-slider-wrap').is('[data-bg-animation="ken_burns"]')) { 3455 3456 $that.parents('.swiper-container').find('.swiper-slide').attr('data-ken-burns','active'); 3457 3458 clearTimeout(nectarSliderKenBurns); 3459 nectarSliderKenBurns = setTimeout(function(){ 3460 $that.parents('.swiper-container').find('.swiper-slide:not(".swiper-slide-active")').attr('data-ken-burns','inactive'); 3461 },1250); 3462 3463 } 3464 3465 3466 $that.parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active').next('.swiper-slide').find('.content > *').transition({ 3467 'x': $that.parents('.swiper-container').width() + "px" 3468 }, 0); 3469 3470 setTimeout(function(){ 3471 $that.parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active').next('.swiper-slide').find('.content > *').each(function(i){ 3472 3473 $(this).stop().delay(i*50).transition({ 3474 'x': "0px" 3475 }, 750,'easeInOutQuart'); 3476 }); 3477 },200); 3478 3479 3480 $that.parents('.swiper-container').addClass('directional-trans-next'); 3481 3482 e.preventDefault(); 3483 3484 3485 } 3486 3487 3488 //prev 3489 $('body').off('click','#'+$(this).attr('id')+' .slider-prev', prevArrowAnimationDirectional); 3490 $('body').on('click','#'+$(this).attr('id')+' .slider-prev', prevArrowAnimationDirectional); 3491 3492 //next 3493 $('body').off('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimationDirectional); 3494 $('body').on('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimationDirectional); 3495 3496 function resetContentPos() { 3497 $($nectarSliders[i].container).find('.swiper-slide .content > *').transition({ 'x': '0px' }, 0); 3498 } 3499 3500 } 3501 3502 3503 //scale pagination style 3504 if($('#'+$(this).attr('id') +' .swiper-container').attr('data-bullet_style') == 'scale' ){ 3505 $('#'+$(this).attr('id')+' .slider-pagination .swiper-pagination-switch').append('<i />'); 3506 } 3507 //Clickable pagination 3508 if($bullets != null && $('#'+$(this).attr('id') +' .swiper-wrapper > div').length > 1 ){ 3509 $('#'+$(this).attr('id')+' .slider-pagination .swiper-pagination-switch').click(function(){ 3510 $nectarSliders[i].swipeTo($(this).index()); 3511 }); 3512 } 3513 });
3514 3515 3516 3517 } 3518 3519 nectarSliderMainInit(); 3520 3521 3522 3523 function darkFirstSlide(slider){ 3524 if( slider.parents('.parallax_slider_outer').length > 0 && slider.parents('.first-section').length > 0 && slider.find('.swiper-slide-active[data-color-scheme="dark"]').length > 0 ) { 3525 $('#header-outer').addClass('dark-slide'); 3526 } else if(slider.parents('.parallax_slider_outer').length > 0 || slider.parents('.first-section').length > 0 ) { 3527 3528 if( slider.find('.swiper-slide-active[data-color-scheme="dark"]').length > 0 && slider.parents('.first-section').length > 0 && slider.is('[data-full-width="true"]') ) { 3529 //dont remove if needed 3530 } else { 3531 $('#header-outer').removeClass('dark-slide'); 3532 } 3533 } 3534 } 3535 3536 function directionalNavColorInit(slider) { 3537 3538 if(slider.attr('data-overall_style') == 'directional' && slider.find('.swiper-slide[data-color-scheme="dark"]').length > 0 && $('#header-outer[data-transparent-header="true"]').length > 0) { 3539 3540 if( slider.parents('.parallax_slider_outer').length > 0 || slider.parents('.first-section').length > 0 ) { 3541 3542 $('#header-outer').addClass('directional-nav-effect'); 3543 3544 $selector = ($('#header-outer[data-permanent-transparent="1"]').length == 0) ? '#header-outer' : '#header-outer .midnightHeader.nectar-slider'; 3545 3546 $($selector+' nav > ul.sf-menu > li > a, '+$selector+' nav > ul.buttons > li.slide-out-widget-area-toggle a span, '+$selector+' nav > ul.buttons > li#search-btn a').each(function(){ 3547 var $text = $(this).html(); 3548 $(this).html(' '); 3549 $(this).append('<span class="dark"><span>'+ $text + '</span></span>'); 3550 $(this).append('<span class="light"><span>'+ $text + '</span></span>'); 3551 $(this).append('<span class="original"><span>'+ $text + '</span></span>'); 3552 }); 3553 3554 $($selector+' .cart-outer .cart-icon-wrap').each(function(){ 3555 $(this).find('> i').remove(); 3556 $(this).append('<span class="dark"><span><i class="icon-salient-cart"></i></span></span>'); 3557 $(this).append('<span class="light"><span><i class="icon-salient-cart"></i></span></span>'); 3558 $(this).append('<span class="original"><span><i class="icon-salient-cart"></i></span></span>'); 3559 }); 3560 setTimeout(function(){ 3561 $($selector+' .cart-outer .cart-icon-wrap').each(function(){ 3562 $(this).find('> i, > span').remove(); 3563 $(this).append('<span class="dark"><span><i class="icon-salient-cart"></i></span></span>'); 3564 $(this).append('<span class="light"><span><i class="icon-salient-cart"></i></span></span>'); 3565 $(this).append('<span class="original"><span><i class="icon-salient-cart"></i></span></span>'); 3566 }); 3567 },1000); 3568 3569 //logo 3570 if($($selector+' header#top #logo img').length > 0) { 3571 $($selector+' header#top #logo').append('<span class="dark"><span></span></span>'); 3572 $($selector+' header#top #logo').append('<span class="light"><span></span></span>'); 3573 $($selector+ ' header#top #logo').append('<span class="original"><span></span></span>'); 3574 $($selector+ ' header#top #logo img:first').clone().appendTo($($selector+ ' header#top #logo .original span')); 3575 if($($selector+' header#top #logo img.starting-logo').length > 0) $($selector+ ' header#top #logo img.starting-logo:not(.dark-version)').clone().appendTo($($selector+ ' header#top #logo .light span')); 3576 if($($selector+' header#top #logo img.starting-logo.retina.logo').length > 0) $($selector+ ' header#top #logo img.starting-logo.retina-logo:not(.dark-version)').clone().appendTo($($selector+ ' header#top #logo .light span')); 3577 if($($selector+' header#top #logo img.starting-logo.dark-version').length > 0) $($selector+ ' header#top #logo img.starting-logo.dark-version').clone().appendTo($($selector+ ' header#top #logo .dark span')); 3578 if($($selector+' header#top #logo img.starting-logo.dark-version.retina.logo').length > 0) $($selector+ ' header#top #logo img.starting-logo.dark-version.retina-logo').clone().appendTo($($selector+ ' header#top #logo .dark span')); 3579 $($selector+ ' header#top #logo > img').remove(); 3580 3581 } else { 3582 var $logoText = $('header#top #logo').text(); 3583 $($selector+' header#top #logo').html(' '); 3584 $($selector+' header#top #logo').append('<span class="dark"><span>'+$logoText+'</span></span>'); 3585 $($selector+' header#top #logo').append('<span class="light"><span>'+$logoText+'</span></span>'); 3586 $($selector+' header#top #logo').append('<span class="original"><span>'+$logoText+'</span></span>'); 3587 } 3588 3589 //retina logo fix 3590 if($('.retina-logo:visible').length > 0) $($selector+' header#top #logo').css('width',$('.retina-logo').width()); 3591 3592 //cache the widths 3593 $($selector+' nav > ul.sf-menu > li > a, '+$selector+' nav > ul.buttons > li#search-btn a, '+$selector+' nav > ul.buttons > li.slide-out-widget-area-toggle a >
3593 span, '+$selector+' .cart-icon-wrap, '+$selector+' header#top #logo').each(function(){ 3594 var $extraWidth = ($(this).find('.original .sf-sub-indicator').length > 0) ? 14: 1; 3595 $(this).find('.original').attr('data-w',$(this).find('span.original').width()+$extraWidth); 3596 }); 3597 3598 3599 } 3600 } 3601 } 3602 3603 //initial slide load 3604 var $animating = false; 3605 3606 //responsive slider 3607 var $sliderHeights = []; 3608 var $existingSliders = []; 3609 var slideAnimationQueues = []; 3610 3611 function initialSlideLoad() { 3612 3613 $animating = false; 3614 3615 //add class to first video slide 3616 $('.swiper-wrapper').each(function(){ 3617 if($(this).find('.swiper-slide:nth-child(2) video').length > 0) $(this).find('.swiper-slide:nth-child(2)').addClass('first_video_slide'); 3618 3619 //ken burns start 3620 if($(this).parents('.nectar-slider-wrap[data-bg-animation="ken_burns"]').length > 0) { 3621 $(this).find('.swiper-slide.swiper-slide-active').addClass('ken-burns').attr('data-ken-burns','active'); 3622 } 3623 3624 3625 }); 3626 3627 3628 $('.nectar-slider-wrap').each(function(i){ 3629 3630 3631 slideAnimationQueues[i] = { 3632 sliderID: $(this).attr('id'), 3633 captionInterval: '', 3634 kenBurnsInterval: '' 3635 } 3636 3637 var $sliderWrapCount = $('.nectar-slider-wrap').length; 3638 var $that = $(this); 3639 3640 //store animation queue arr obj 3641 3642 3643 if($(this).find('.swiper-slide-active video').length > 0){ 3644 3645 if(!$('html').hasClass('no-video') && !navigator.userAgent.match(/(Android|iPod|iPhone|iPad|IEMobile|Opera Mini)/) ){ 3646 3647 //var videoReady = setInterval(function(){ 3648 3649 //if($that.find('.swiper-slide-active:first video').get(0).readyState > 3) { 3650 3651 showSliderControls(); 3652 resizeToCover(); 3653 slideContentPos(); 3654 sliderLoadIn($that,i); 3655 3656 var $timeout = 0; 3657 if($('#ajax-loading-screen[data-effect="center_mask_reveal"]').length > 0 && $that.parents('.parallax_slider_outer').length > 0 || 3658 $('#ajax-loading-screen[data-effect="center_mask_reveal"]').length > 0 && $that.hasClass('first-nectar-slider') ) { 3659 $timeout = 450; 3660 } 3661 3662 setTimeout(function(){ captionTransition($nectarSliders[i]); onChangeStart($nectarSliders[i]); },$timeout); 3663 darkFirstSlide($that); 3664 //clearInterval(videoReady); 3665 3666 $that.addClass('loaded'); 3667 if($that.parents('.parallax_slider_outer').length > 0 || $that.hasClass('first-nectar-slider')) { 3668 $('#ajax-loading-screen').addClass('loaded'); 3669 setTimeout(function(){ $('#ajax-loading-screen').addClass('hidden'); },1000); 3670 } 3671 //} 3672 3673 //},60); 3674 3675 } 3676 //ie8 3677 else { 3678 showSliderControls(); 3679 resizeToCover(); 3680 slideContentPos(); 3681 sliderLoadIn($that,i); 3682 captionTransition($nectarSliders[i]); 3683 darkFirstSlide($that); 3684 } 3685 } 3686 3687 else { 3688 3689 //var $firstBg = $(this).find('.swiper-slide-active .image-bg').attr('style'); 3690 //var pattern = /url\(["']?([^'")]+)['"]?\)/; 3691 //var match = pattern.exec($firstBg); 3692 3693 //if (match) { 3694 3695 //var slideImg = new Image(); 3696 //slideImg.src = match[1]; 3697 3698 //$(slideImg).load(function(){ 3699 3700 showSliderControls(); 3701 resizeToCover(); 3702 slideContentPos(); 3703 sliderLoadIn($that,i); 3704 var $timeout = 0; 3705 if($('#ajax-loading-screen[data-effect="center_mask_reveal"]').length > 0 && $that.parents('.parallax_slider_outer').length > 0 && $that.parents('.first-section').length > 0 || 3706 $('#ajax-loading-screen[data-effect="center_mask_reveal"]').length > 0 && $that.hasClass('first-nectar-slider') ) { 3707 $timeout = 450; 3708 } 3709 3710 setTimeout(function(){ captionTransition($nectarSliders[i]); onChangeStart($nectarSliders[i]); },$timeout); 3711 3712 darkFirstSlide($that); 3713 3714 $that.addClass('loaded'); 3715 if($that.parents('.parallax_slider_outer').length > 0 || $that.hasClass('first-nectar-slider')) { 3716 $('#ajax-loading-screen').addClass('loaded'); 3717 setTimeout(function(){ $('#ajax-loading-screen').addClass('hidden'); },1000); 3718 } 3719 3720 //}); 3721 3722 3723 //} 3724 } 3725 3726 //mobile check 3727 if(navigator.userAgent.match(/(Android|iPod|iPhone|iPad|IEMobile|Opera Mini)/)){ 3728 3729 3730 $that.find('.video-wrap').each(function(){ 3731 3732 var $videoSlide = $(this); 3733 $(this).css('bottom','0'); 3734 $(this).find('video')[0].onplay = function(){ 3735 $videoSlide.find('video').css({'opacity':'1'}); 3736 setTimeout(function(){ 3737 $videoSlide.parents('.swiper-slide').find('.mobile-video-image').transition({'opacity':'0'},250); 3738 },100); 3739 3740 }; 3741 3742 }); 3743 3744 3745 3746 captionTransition($nectarSliders[i]); 3747 showSliderControls(); 3748 resizeToCover(); 3749 slideContentPos(); 3750 darkFirstSlide($that); 3751 3752 setTimeout(function(){ resizeToCover(); slideContentPos(); },400); 3753 3754 $('.nectar-slider-wrap').find('.nectar-slider-loading').fadeOut(800,'easeInOutExpo'); 3755 $('.nectar-slider-wrap.first-section .swiper-container .swiper-wrapper .swiper-slide').removeClass('not-loaded'); 3756 3757 3758 3759 3760 3761 $(this).addClass('loaded'); 3762 3763 if($that.parents('.parallax_slider_outer').length > 0 || $that.hasClass('first-nectar-slider')) { 3764 $('#ajax-loading-screen').addClass('loaded'); 3765 setTimeout(function(){ $('#ajax-loading-screen').addClass('hidden'); },1000); 3766 } 3767 3768 autorotateInit($(this),i); 3769 } 3770 3771 3772 if($('header#top #logo img').length > 0) { 3773 var logoImg = new Image(); 3774 logoImg.src = $('header#top #logo img:first').attr('src'); 3775 3776 $(logoImg).load(function(){ 3777 //directionalNavColorInit($that); 3778 if($that.attr('data-overall_style') == 'directional') { 3779 $that.find('.swiper-container').addClass('directional-trans-current'); 3780 onChangeStart($nectarSliders[i]); 3781 } 3782 }); 3783 } else { 3784 //directionalNavColorInit($that); 3785 if($that.attr('data-overall_style') == 'directional') { 3786 $that.find('.swiper-container').addClass('directional-trans-current'); 3787 onChangeStart($nectarSliders[i]); 3788 } 3789 } 3790 3791 });
3792 3793 3794 ////get slider heights 3795 $('.swiper-container').each(function(i){ 3796 3797 //left and right pagination room 3798 if( $(this).is('[data-bullet_position="left"]') ) { 3799 if($(this).find('[data-x-pos="left"]').length > 0) { 3800 $(this).find('.slider-pagination-wrap').addClass('extra-room'); 3801 } 3802 } 3803 if( $(this).is('[data-bullet_position="right"]') ) { 3804 if($(this).find('[data-x-pos="right"]').length > 0) { 3805 $(this).find('.slider-pagination-wrap').addClass('extra-room'); 3806 } 3807 } 3808 3809 }); 3810 3811 3812 } 3813 3814 3815 3816 3817 function nectarInit(){ 3818 if(doneVideoInit == true) return; 3819 3820 //videos 3821 /*$('.swiper-slide .slider-video').mediaelementplayer({ 3822 enableKeyboard: false, 3823 iPadUseNativeControls: false, 3824 pauseOtherPlayers: false, 3825 // force iPhone's native controls 3826 iPhoneUseNativeControls: false, 3827 // force Android's native controls 3828 AndroidUseNativeControls: false 3829 });*/ 3830 3831 //if using pp - init it after slide loads 3832 if($().prettyPhoto) prettyPhotoInit(); 3833 3834 3835 $('.swiper-slide iframe[data-aspectRatio]').each(function() { 3836 var newWidth = $(this).parent().width(); 3837 3838 var $el = $(this); 3839 3840 //in nectar slider 3841 if($(this).parents('.swiper-slide').length > 0) { 3842 if($(this).is(':visible')) $el.width(newWidth).height(newWidth * $el.attr('data-aspectRatio')); 3843 } 3844 //all others 3845 else { 3846 $el.width(newWidth).height(newWidth * $el.attr('data-aspectRatio')); 3847 } 3848 3849 3850 }); 3851 3852 3853 doneVideoInit = true; 3854 } 3855 3856 3857 3858 //autoplay - set vars before init call 3859 var autoplay = []; 3860 var sliderAutoplayCount = 0; 3861 3862 //dynamic height sliders - set before calling dynamic height 3863 function nsSliderArrStore() { 3864 $sliderHeights = []; 3865 $existingSliders = []; 3866 $('.swiper-container').each(function(i){ 3867 $sliderHeights[i] = parseInt($(this).attr('data-height')); 3868 $existingSliders[i] = $(this).parent().attr('id'); 3869 }); 3870 } 3871 3872 nsSliderArrStore(); 3873 dynamicHeightSliders(); 3874 sliderSize(); 3875 resizeToCover(); 3876 3877 /*quickly calc first slider bg parallax calcs to avoid any jumping*/ 3878 for(var nsCount=0; nsCount<$nectarSliders.length; nsCount++) { 3879 $nectarSliders[nsCount].resizeFix(); 3880 } 3881 3882 $('.parallax_slider_outer .nectar-slider-wrap .slide-bg-wrap').each(function(){ 3883 if($(this).parents('.top-level').length > 0) { 3884 if($(this).find('.image-bg').length > 0) { 3885 $(this).find('.image-bg').css({'height': Math.ceil( $(this).parent().offset().top * 0.25 ) + $(this).outerHeight(true) }); 3886 } 3887 if($(this).find('.video-wrap').length > 0) { 3888 $(this).find('.video-wrap').css({'height': Math.ceil( $(this).parent().offset().top * 0.25 ) + $(this).outerHeight(true) }); 3889 } 3890 } 3891 }); 3892 3893 3894 3895 initialSlideLoad(); 3896 3897 3898 3899 var headerPadding = parseInt($('#header-outer').attr('data-padding')); 3900 var shrinkNum = 8; 3901 if($('#header-outer[data-shrink-num]').length > 0 ) shrinkNum = $('#header-outer').attr('data-shrink-num'); 3902 3903 3904 function dynamicHeightSliders(){ 3905 3906 var $adminBarHeight = ($('#wpadminbar').length > 0) ? 28 : 0 ; 3907 3908 $('.nectar-slider-wrap').each(function(){ 3909 3910 var $heightCalc; 3911 var $minHeight = $('.swiper-container').attr('data-min-height'); 3912 3913 //material header nav parallax top 3914 if(window.innerWidth > 1000) { 3915 $('body.material:not("[data-header-format=\'left-header\']") .parallax_slider_outer.first-section .nectar-slider-wrap').css('top',$('#ajax-content-wrap').offset().top); 3916 } else { 3917 $('body.material:not("[data-header-format=\'left-header\']") .parallax_slider_outer.first-section .nectar-slider-wrap').css('top','0'); 3918 } 3919 3920 //fullscreen 3921 if($(this).attr('data-fullscreen') == 'true' && $(this).attr('data-full-width') == 'true' || 3922 $(this).attr('data-fullscreen') == 'true' && $(this).attr('data-full-width') == 'boxed-full-width' || 3923 $(this).attr('data-fullscreen') == 'true' && $(this).parents('.full-width-content').length > 0 && $(this).parents('.vc_col-sm-12').length > 0 ) { 3924 3925 if($(this).parents('#nectar_fullscreen_rows').length == 0) { 3926 3927 //first slider on page 3928 if($(this).hasClass('first-section') && $(this).index() == 0 || $(this).parents('.wpb_row').length > 0 && $(this).parents('.wpb_row').hasClass('first-section') && $(this).index() == 0 && $(this).parents('.parallax_slider_outer').length == 0){ 3929 //min height
3930 $heightCal = ( ($(window).height() - $(this).offset().top + 2) <= $minHeight ) ? $minHeight : $(window).height() - $(this).offset().top + 2; 3931 $(this).find('.swiper-container').attr('data-height',$heightCal); 3932 3933 } 3934 //first parallax slider on page 3935 else if($(this).parents('.first-section').length > 0 && $(this).parents('.parallax_slider_outer').length > 0 && $(this).parents('#full_width_portfolio').length == 0){ 3936 3937 //min height 3938 $heightCal = ( ($(window).height() - $(this).offset().top + 2) <= $minHeight ) ? $minHeight : $(window).height() - $(this).offset().top + 2; 3939 $(this).find('.swiper-container').attr('data-height',$heightCal); 3940 3941 } 3942 //first portfolio slider on page 3943 else if($(this).parents('#full_width_portfolio').length > 0 && $(this).attr('data-parallax') != 'true' && $(this).index() == 0){ 3944 //min height 3945 $heightCal = ( ($(window).height() - $(this).offset().top + 2) <= $minHeight ) ? $minHeight : $(window).height() - $(this).offset().top + 2; 3946 $(this).find('.swiper-container').attr('data-height',$heightCal); 3947 3948 } 3949 //first portfolio parallax slider on page 3950 else if($(this).parents('#full_width_portfolio').length > 0 && $(this).attr('data-parallax') == 'true'){ 3951 3952 //min height 3953 $heightCal = ( ($(window).height() - $(this).offset().top + 2) <= $minHeight ) ? $minHeight : $(window).height() - $(this).offset().top + 2; 3954 $(this).find('.swiper-container').attr('data-height',$heightCal); 3955 } 3956 //all others 3957 else { 3958 $resize = ($('#header-outer[data-header-resize="0"]').length > 0) ? 0 : parseInt(shrinkNum) + headerPadding*2; 3959 $headerSize = ($('#header-outer[data-permanent-transparent="false"]').length > 0) ? $('#header-space').height() - $resize-3 : -3; 3960 if($('#nectar_fullscreen_rows').length > 0 || ($('body[data-header-format="left-header"]').length > 0 && window.innerWidth >= 1000)) $headerSize = $adminBarHeight; 3961 //min height 3962 $heightCal = ( $(window).height() - $headerSize <= $minHeight ) ? $minHeight : $(window).height() - $headerSize; 3963 $(this).find('.swiper-container').attr('data-height',$heightCal); 3964 } 3965 3966 //transparent header loading icon center 3967 if($('#header-outer[data-remove-border="true"]').length == 0) { 3968 if($('body #header-outer[data-transparent-header="true"]').length > 0 3969 && $('.first-section .nectar-slider-wrap[data-fullscreen="true"]').length > 0 3970 && $('#page-header-bg').length == 0) { 3971 3972 $('.first-section .nectar-slider-loading').css({ 3973 'background-image': $loading_bg_storage, 3974 'background-position' : 'center ' + ((($(window).height() /2) + 15) - $('#header-space').height()) +'px' 3975 }); 3976 3977 $('.first-section .nectar-slider-wrap .nectar-slider-loading .loading-icon').css({ 3978 'opacity' : '1', 3979 'height' : $(window).height() - $('#header-space').height() + 'px' 3980 }); 3981 } 3982 } 3983 3984 } 3985 3986 } 3987 3988 //flexible height 3989 if($(this).attr('data-flexible-height') == 'true' && $(this).attr('data-fullscreen') != 'true') { 3990 3991 //escape if not placed in a flexible ready position 3992 if($(this).parents('.wpb_row.full-width-content').length == 0 && $(this).attr('data-full-width') == 'false') { $(this).attr('data-flexible-height','false'); return false; } 3993 3994 var $minHeight = $('.swiper-container').attr('data-min-height'); 3995 3996 var currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 3997 var $windowWidth = $(window).width(); 3998 var $definedHeight = $sliderHeights[currentKey]; 3999 4000 var dif = $(window).width() / 1600; 4001 4002 if( window.innerWidth > 1000 && $('#boxed').length == 0) { 4003 $(this).find('.swiper-container').attr('data-height',Math.
4003ceil($definedHeight*dif)); 4004 } else { 4005 4006 //column sliders 4007 var $parentCol = ($(this).parents('.wpb_column').length > 0) ? $(this).parents('.wpb_column') : $(this).parents('.col') ; 4008 if($parentCol.length == 0) $parentCol = $('.main-content'); 4009 4010 if(!$parentCol.hasClass('vc_span12') && !$parentCol.hasClass('main-content') && !$parentCol.hasClass('span_12') && !$parentCol.hasClass('vc_col-sm-12') ) { 4011 4012 var $parentColWidth = sliderColumnDesktopWidth($parentCol); 4013 var $parentColRatio = 1100/$parentColWidth; 4014 4015 //min height 4016 if( $definedHeight*dif <= $minHeight ){ 4017 $(this).find('.swiper-container').attr('data-height',$minHeight); 4018 } else { 4019 $(this).find('.swiper-container').attr('data-height',Math.ceil($parentColRatio*$definedHeight*dif)); 4020 } 4021 4022 } 4023 4024 4025 //boxed 4026 else if($('#boxed').length > 0){ 4027 4028 var dif = $('#boxed').width() / 1600; 4029 4030 if( window.innerWidth > 1300 ) { 4031 4032 if($('body[data-ext-responsive="true"]').length > 0){ 4033 4034 if($(this).has('[data-full-width="boxed-full-width"]')) { 4035 ($('#boxed').width() < 1400) ? $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*dif)) : $(this).find('.swiper-container').attr('data-height',$definedHeight*(1400/1600)); 4036 4037 } 4038 4039 } else { 4040 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*(1200/1600))); 4041 4042 } 4043 4044 } else if( window.innerWidth <= 1300 && window.innerWidth >= 1000 ) { 4045 4046 if($('body[data-ext-responsive="true"]').length > 0){ 4047 $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*dif)); 4048 } else { 4049 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*(980/1600))); 4050 } 4051 4052 } else if( window.innerWidth < 1000 && window.innerWidth > 690 ) { 4053 4054 var $heightCalc = ( $definedHeight*(679/1600) <= $minHeight ) ? $minHeight : $definedHeight*(679/1600); 4055 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height',$minHeight); 4056 4057 } else if( window.innerWidth <= 690 && window.innerWidth >= 470 ) { 4058 4059 var $heightCalc = ( $definedHeight*(410/1600) <= $minHeight ) ? $minHeight : $definedHeight*(410/1600); 4060 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height', $height
4060Calc); 4061 4062 } else if( window.innerWidth < 470 ) { 4063 4064 var $heightCalc = ( $definedHeight*(318/1600) <= $minHeight ) ? $minHeight : $definedHeight*(318/1600); 4065 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height', $heightCalc); 4066 4067 } 4068 4069 } 4070 4071 4072 //regular 4073 else { 4074 4075 //min height 4076 if( $definedHeight*dif <= $minHeight ){ 4077 $(this).find('.swiper-container').attr('data-height',$minHeight); 4078 } else { 4079 $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*dif)); 4080 } 4081 4082 } 4083 4084 } 4085 4086 4087 //transparent header loading icon center 4088 if($('body #header-outer[data-transparent-header="true"]').length > 0 && 4089 $('.first-section .nectar-slider-wrap[data-flexible-height="true"]').length > 0) { 4090 4091 $('.first-section .nectar-slider-loading').css({ 4092 'background-image': $loading_bg_storage, 4093 'background-position' : 'center ' + (((($definedHeight*dif)/2) + 15) - $('#header-space').height()) +'px' 4094 }); 4095 4096 $('.first-section .nectar-slider-wrap .nectar-slider-loading .loading-icon').css({ 4097 'opacity' : '1', 4098 'height' : $definedHeight*dif - $('#header-space').height() + 'px' 4099 }); 4100 } 4101 4102 } 4103 }); 4104 } 4105 4106 if(window.innerWidth > 690){ 4107 $(window).on('resize.dynamicHeights',dynamicHeightSliders); 4108 } else { 4109 4110 //stop mobile browsers from firing the resize event on scroll (when toolbar hides) 4111 var $windowWidth = $(window).width(), $windowHeight = $(window).height(); 4112 var $orientationChange = 0; 4113 4114 window.addEventListener("orientationchange", function() { 4115 $orientationChange = 1; 4116 }); 4117 4118 $(window).resize(function(){ 4119 if( ($(window).width() != $windowWidth && $(window).height != $windowHeight) || $orientationChange == 1){ 4120 dynamicHeightSliders(); 4121 $orientationChange = 0; 4122 } 4123 }); 4124 } 4125 4126 setTimeout(function(){ 4127 dynamicHeightSliders(); 4128 },100); 4129 4130 4131 ////helper function 4132 function sliderColumnDesktopWidth(parentCol) { 4133 4134 var $parentColWidth = 1100; 4135 var $columnNumberParsed = $(parentCol).attr('class').match(/\d+/); 4136 4137 if($columnNumberParsed == '2') { $parentColWidth = 170 } 4138 else if($columnNumberParsed == '3') { $parentColWidth = 260 } 4139 else if($columnNumberParsed == '4') { $parentColWidth = 340 } 4140 else if($columnNumberParsed == '6') { $parentColWidth = 530 } 4141 else if($columnNumberParsed == '8') { $parentColWidth = 700 } 4142 else if($columnNumberParsed == '9') { $parentColWidth = 805 } 4143 else if($columnNumberParsed == '10') { $parentColWidth = 916.3 } 4144 else if($columnNumberParsed == '12') { $parentColWidth = 1100 } 4145 4146 return $parentColWidth; 4147 } 4148 4149 4150 4151 $(window).resize(sliderSize); 4152 4153 function sliderSize(){ 4154 4155 4156 //check for mobile first 4157 if( window.innerWidth < 1000 && window.innerWidth > 690 ) { 4158 4159 //fullwidth sliders 4160 $('.nectar-slider-wrap[data-full-width="true"]:not([data-fullscreen="true"],[data-flexible-height="true"])').each(function(i){ 4161 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4162 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/1.4 ) 4163 }); 4164 4165 //column sliders 4166 $('.nectar-slider-wrap[data-full-width="false"]:not([data-fullscreen="true"]):not([data-flexible-height="true"])').each(function(i){ 4167 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4168 4169 var $currentSliderHeight = $sliderHeights[currentKey]; 4170 var $parentCol = ($(this).parents('.wpb_column').length > 0) ? $(this).parents('.wpb_column') : $(this).parents('.col'); 4171 4172 //fullwidth but inside the span_9 post area 4173 if($(this).parents('.post-area').length > 0 && $(this).parents('.vc_span12').length > 0) $parentCol = $(this).parents('.post-area'); 4174 4175 //last resort 4176 if($parentCol.length == 0) $parentCol = $('.main-content'); 4177 4178 var $parentColWidth = sliderColumnDesktopWidth($parentCol); 4179 4180 var $aspectRatio = $currentSliderHeight/$parentColWidth; 4181 4182 $(this).find('.swiper-container').attr('data-height',$aspectRatio*$parentCol.width()); 4183 }); 4184 4185 //boxed sliders 4186 $('.nectar-slider-wrap[data-full-width="boxed-full-width"]:not([data-flexible-height="true"]):not([data-fullscreen="true"])').each(function(i){ 4187 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4188 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/1.9 ) 4189 }); 4190 } 4191 4192 else if( window.innerWidth <= 690 ) { 4193 4194 //fullwidth sliders 4195 $('.nectar-slider-wrap[data-full-width="true"]:not([data-fullscreen="true"],[data-flexible-height="true"])').each(function(i){ 4196 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4197 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/2.7 ) 4198 });
4199 4200 //column sliders 4201 $('.nectar-slider-wrap[data-full-width="false"]:not([data-fullscreen="true"]):not([data-flexible-height="true"])').each(function(i){ 4202 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4203 4204 var $currentSliderHeight = $sliderHeights[currentKey]; 4205 var $parentCol = ($(this).parents('.wpb_column').length > 0) ? $(this).parents('.wpb_column') : $(this).parents('.col'); 4206 4207 //fullwidth but inside the span_9 post area 4208 if($(this).parents('.post-area').length > 0 && $(this).parents('.vc_span12').length > 0) $parentCol = $(this).parents('.post-area'); 4209 4210 //last resort 4211 if($parentCol.length == 0) $parentCol = $('.main-content'); 4212 4213 var $parentColWidth = sliderColumnDesktopWidth($parentCol); 4214 4215 var $aspectRatio = $currentSliderHeight/$parentColWidth; 4216 4217 $(this).find('.swiper-container').attr('data-height',$aspectRatio*$parentCol.width()); 4218 }); 4219 4220 //boxed sliders 4221 $('.nectar-slider-wrap[data-full-width="boxed-full-width"]:not([data-flexible-height="true"]):not([data-fullscreen="true"])').each(function(i){ 4222 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4223 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/2.9 ) 4224 }); 4225 4226 } 4227 4228 else if( window.innerWidth < 1300 && window.innerWidth >= 1000 ) { 4229 4230 //fullwidth sliders 4231 $('.nectar-slider-wrap[data-full-width="true"]:not([data-fullscreen="true"],[data-flexible-height="true"])').each(function(i){ 4232 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4233 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/1.2 ) 4234 }); 4235 4236 //column sliders 4237 $('.nectar-slider-wrap[data-full-width="false"]:not([data-fullscreen="true"]):not([data-flexible-height="true"])').each(function(i){ 4238 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4239 4240 var $currentSliderHeight = $sliderHeights[currentKey]; 4241 var $parentCol = ($(this).parents('.wpb_column').length > 0) ? $(this).parents('.wpb_column') : $(this).parents('.col') ; 4242 4243 //fullwidth but inside the span_9 post area 4244 if($(this).parents('.post-area').length > 0 && $(this).parents('.vc_span12').length > 0) $parentCol = $(this).parents('.post-area'); 4245 4246 //last resort 4247 if($parentCol.length == 0) $parentCol = $('.main-content'); 4248 4249 var $parentColWidth = sliderColumnDesktopWidth($parentCol); 4250 4251 var $aspectRatio = $currentSliderHeight/$parentColWidth; 4252 4253 $(this).find('.swiper-container').attr('data-height',$aspectRatio*$parentCol.width()); 4254 4255 }); 4256 4257 //boxed sliders 4258 $('.nectar-slider-wrap[data-full-width="boxed-full-width"]:not([data-flexible-height="true"]):not([data-fullscreen="true"])').each(function(i){ 4259 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4260 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/1.2 ) 4261 }); 4262 4263 } 4264 4265 else { 4266 4267 //fullwidth sliders 4268 $('.nectar-slider-wrap[data-full-width="true"]:not([data-fullscreen="true"],[data-flexible-height="true"])').each(function(i){ 4269 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4270 if($(this).attr('data-flexible-height') != 'true') $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]) 4271 }); 4272 4273 //boxed sliders 4274 $('.nectar-slider-wrap[data-full-width="false"]:not([data-fullscreen="true"]), .nectar-slider-wrap[data-full-width="boxed-full-width"]:not([data-flexible-height="true"]):not([data-fullscreen="true"])').each(function(i){ 4275 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4276 if($(this).attr('data-flexible-height') != 'true') $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey] ) 4277 }); 4278 } 4279 4280 } 4281 4282 4283 //remove transform if single slide 4284 $('.nectar-slider-wrap').each(function(){ 4285 if($(this).find('.swiper-wrapper .swiper-slide').length == 1) { 4286 $(this).find('.swiper-slide').addClass('no-transform'); 4287 $(this).find('.swiper-wrapper').addClass('no-transform'); 4288 } 4289 });
4290 4291 4292 4293 //slider height 4294 4295 var min_w = 1500; // minimum video width allowed 4296 var vid_w_orig; // original video dimensions 4297 var vid_h_orig; 4298 4299 vid_w_orig = 1280; 4300 vid_h_orig = 720; 4301 var $headerHeight = $('header').height()-1; 4302 4303 function nsSliderContentResize(e){ 4304 resizeToCover(); slideContentPos(); 4305 for(var i=0; i < $nectarSliders.length; i++){ 4306 4307 //make sure the parent is not hidden 4308 if($($nectarSliders[i].container).parent().attr('data-transition') && $($nectarSliders[i].container).parent().attr('data-transition') == 'fade') { 4309 4310 for(var k=0; k < $nectarSliders[i].slides.length; k++){ 4311 $nectarSliders[i].setTransition($nectarSliders[i].slides[k], 0); 4312 } 4313 4314 $('.swiper-wrapper').stop(true,true).css('transition-duration','0s'); 4315 4316 if($('.nectar-slider-loading').css('display') == 'none') { 4317 4318 //var captionTransString = $($nectarSliders[i].container).parent().is('[data-caption-trans]') ? $($nectarSliders[i].container).parent().attr('data-caption-trans') : 'fade_in_from_bottom'; 4319 //$($nectarSliders[i].container).find('.swiper-slide-active').find('.content').children().each(function(i){ 4320 //captionTransAnimation($(this),i,captionTransString); 4321 //}); 4322 4323 $('.swiper-wrapper .swiper-slide.swiper-slide-active .content > *').css({ 4324 'opacity': 1, 4325 'transform' : 'translateY(0)' 4326 }); 4327 } 4328 } 4329 4330 $nectarSliders[i].reInit(); 4331 $nectarSliders[i].resizeFix(); 4332 4333 } 4334 4335 } 4336 4337 // $(window).off('resize.nsSliderContent'); 4338 $(window).on('resize.nsSliderContent',nsSliderContentResize); 4339 //if(!$('body').hasClass('ajax-loaded')) $(window).trigger('resize'); 4340 4341 function resizeToCover() { 4342 $('.nectar-slider-wrap').each(function(i){ 4343 4344 4345 if( $(this).css('visibility') != 'hidden') { 4346 4347 var $leftHeaderSize = ($('#header-outer[data-format="left-header"]').length > 0 && window.innerWidth >= 1000) ? parseInt($('#header-outer[data-format="left-header"]').width()) : 0; 4348 var $windowWidth = $(window).width() - $leftHeaderSize; 4349 4350 //width resize 4351 if($('body > #boxed').length == 0 && $('.nectar-slider-wrap[data-full-width="true"]').parent().attr('id') != 'portfolio-extra' && $(this).parents('.post-area:not(".span_12")').length == 0){ 4352 $('.nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .nectar-slider-wrap').css({'left': -( ($windowWidth-$smoothSrollWidth)/2 - $('.main-content').width()/2), 'margin-left': '0' }); 4353 $('.nectar-slider-wrap[data-full-width="true"] .swiper-container, .nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .swiper-container, .parallax_slider_outer.first-section .nectar-slider-wrap').css('width',$windowWidth); 4354 4355 } 4356 else if( $('.nectar-slider-wrap[data-full-width="true"]').parent().attr('id') == 'portfolio-extra' && $('#full_width_portfolio').length != 0){ 4357 $('.nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .nectar-slider-wrap').css({'left': -( ($windowWidth-$smoothSrollWidth)/2 - $('.main-content').width()/2), 'margin-left': '0' }); 4358 $('.nectar-slider-wrap[data-full-width="true"] .swiper-container, .nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .swiper-container, .parallax_slider_outer.first-section .nectar-slider-wrap').css('width',$windowWidth); 4359 } 4360 else { 4361 var $container = ($('body > #boxed').length == 0) ? '.post-area' : '.container-wrap'; 4362 //backup incase only slider is used with nothing else in boxed mode 4363 if($($container).width() == '0' && $('body > #boxed').length > 0) $container = '#boxed'; 4364 $('.nectar-slider-wrap[data-full-width="true"] .swiper-container, .nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .swiper-container, .parallax_slider_outer.first-section .nectar-slider-wrap').css({'width':$($container).width(), 'margin-left': '0'}); 4365 } 4366 4367 4368 4369 var $sliderHeight = parseInt($(this).find('.swiper-container').attr('data-height')); 4370 var $sliderMinHeight = ( $(this).find('.swiper-container').is('[data-min-height]') && $(this).find('.swiper-container').attr('data-min-height').length > 0 ) ? parseInt($(this).find('.swiper-container').attr('data-min-height')) : 0; 4371 4372 if($sliderMinHeight > $sliderHeight) { $sliderHeight = $sliderMinHeight; } 4373 4374 var isFullWidthCompatible = ($(this).attr('data-full-width') == 'true') ? 'true' : 'false'; 4375 4376 if($(this).parent().attr('id') == 'portfolio-extra' && $('#full_width_portfolio').length == 0 || $(this).parents('.post-area').length > 0) { isFullWidthCompatible = 'false'; }; 4377 4378 var $sliderWidth = (isFullWidthCompatible == 'true') ? $windowWidth-$smoothSrollWidth : $(this).width(); 4379 4380 $(this).parents('.parallax_slider_outer').css('height',$sliderHeight); 4381 $(this).css('height',$sliderHeight); 4382 $(this).find('.swiper-container, .swiper-slide').css({'height':$sliderHeight+1}); 4383 $(this).find('.swiper-container').css('width', $sliderWidth);
4384 //$(this).find('.swiper-slide').css('width', $sliderWidth); 4385 4386 4387 //when using parallax, let that calc height/width 4388 if(!$(this).is('[data-parallax="true"]')) { 4389 4390 // set the video viewport to the window size 4391 $(this).find('.video-wrap').width($sliderWidth+2); 4392 $(this).find('.video-wrap').height($sliderHeight+2); 4393 4394 //handle left header 4395 /*if($('body[data-header-format="left-header"]').length > 0) { 4396 $('.parallax_slider_outer.first-section .nectar-slider-wrap, .parallax_slider_outer.first-section .nectar-slider-wrap .swiper-container').css('width',$('#ajax-content-wrap').width()); 4397 if($(this).parents('.parallax_slider_outer.first-section').length > 0) { 4398 $sliderWidth = (isFullWidthCompatible == 'true') ? $(window).width()-$smoothSrollWidth - $('#header-outer').width() : $(this).width() - $('#header-outer').width(); 4399 $(this).find('.video-wrap').width($sliderWidth+2); 4400 } 4401 } */ 4402 4403 // use largest scale factor of horizontal/vertical 4404 var scale_h = $sliderWidth / vid_w_orig; 4405 var scale_v = ($sliderHeight - $headerHeight) / vid_h_orig; 4406 var scale = scale_h > scale_v ? scale_h : scale_v; 4407 4408 //update minium width to never allow excess space 4409 min_w = 1280/720 * ($sliderHeight+20); 4410 4411 // don't allow scaled width < minimum video width 4412 if (scale * vid_w_orig < min_w) {scale = min_w / vid_w_orig;} 4413 4414 // now scale the video 4415 $(this).find('video, .mejs-overlay, .mejs-poster').width(Math.ceil(scale * vid_w_orig +2)); 4416 $(this).find('video, .mejs-overlay, .mejs-poster').height(Math.ceil(scale * vid_h_orig +2)); 4417 4418 // and center it by scrolling the video viewport 4419 $(this).find('.video-wrap').scrollLeft(($(this).find('video').width() - $sliderWidth) / 2); 4420 4421 $(this).find('.swiper-slide').each(function(){ 4422 4423 //video alignment 4424 if($(this).find('.video-wrap').length > 0){ 4425 //align middle 4426 if($(this).attr('data-bg-alignment') == 'center'){ 4427 $(this).find('.video-wrap, .mejs-overlay, .mejs-poster').scrollTop(($(this).find('video').height() - ($sliderHeight)) / 2); 4428 } 4429 //align bottom 4430 else if($(this).attr('data-bg-alignment') == 'bottom'){ 4431 $(this).find('.video-wrap').scrollTop(($(this).find('video').height() - ($sliderHeight+2))); 4432 } 4433 //align top 4434 else { 4435 $(this).find('.video-wrap').scrollTop(0); 4436 } 4437 } 4438 4439 }); 4440 4441 } //if visible 4442 4443 }//parallax 4444 }); 4445 }; 4446 4447 ////initial call 4448 resizeToCover(); 4449 4450 4451 //caption transitions 4452 var loopFixTimeout; 4453 var previousSlide = 0; 4454 4455 function captionTransition(obj){ 4456 4457 resizeToCover(); 4458 4459 var $containerClass; 4460 4461 (typeof obj == 'undefined') ? $containerClass = 'div[id^=ns-id-]' : $containerClass = '#'+$(obj.container).parents('.nectar-slider-wrap').attr('id'); ; 4462 4463 4464 var fromLeft = Math.abs(parseInt($($containerClass+' .swiper-wrapper').css('left'))); 4465 var currentSlide = Math.round(fromLeft/$($containerClass+' .swiper-slide').width()); 4466 var $slideNum = $($containerClass+':first .swiper-wrapper > div').length; 4467 4468 var captionTransString = $($containerClass).is('[data-caption-trans]') ? $($containerClass).attr('data-caption-trans') : 'fade_in_from_bottom'; 4469 4470 4471 currentSlide = $($containerClass + ' .swiper-slide-active').index(); 4472 //if(isNaN(currentSlide)) currentSlide = 0; 4473 4474 //make sure user isn't going back to same slide 4475 if( $($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').find('.content *').length > 0 && captionTransString != 'reveal_title') { 4476 if($($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').find('.content *').css('opacity') != '0' && !$('html').hasClass('no-video')) { 4477 //play video if there's one 4478 playVideoBG(currentSlide + 1, $containerClass); 4479 4480 if(!$($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').hasClass('autorotate-shown')) { 4481 return false; 4482 } else { 4483 $($containerClass+' .swiper-slide').removeClass('autorotate-shown'); 4484 } 4485 4486 } 4487 } 4488 4489 if( $($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').find('.content h2').length > 0 && captionTransString == 'reveal_title') { 4490 if($($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').find('.content h2 .word').css('opacity') != '0' && !$('html').hasClass('no-video')) { 4491 //play video if there's one 4492 playVideoBG(currentSlide + 1, $containerClass); 4493 4494 if(!$($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').hasClass('autorotate-shown')) { 4495 return false; 4496 } else { 4497 $($containerClass+' .swiper-slide').removeClass('autorotate-shown'); 4498 } 4499 4500 } 4501 } 4502 4503 //hide all 4504 if(!$('html').hasClass('no-video')) { 4505 if(captionTransString == 'fade_in_from_bottom') { 4506 $($containerClass+' .swiper-slide .content p, '+$containerClass+' .swiper-slide .content h2, '+$containerClass+' .swiper-slide .content .buttons').stop(true,true).css({'opacity':0, 'transform' : 'translateY(40px)'}); 4507 } else if(captionTransString == 'reveal_title') { 4508 $($containerClass+' .swiper-slide .content h2 .word').stop(true,true).css({'opacity': '0'}); 4509 4510 //if(currentSlide > previousSlide || $($containerClass +' .swiper-container').attr('data-loop') == 'true' && currentSlide == 1 && previousSlide == $slideNum - 2) { 4511 // $($containerClass+' .swiper-slide .content h2 span span .text-char').css({'transform' : 'translateX(100px)', 'opacity': '0'}); 4512 //} else { 4513 $($containerClass+' .swiper-slide .content h2 .word > [class*="char"]').css({ 'opacity': '0'}); 4514 //} 4515 $($containerClass+' .swiper-slide .content h2 .word > [class*="char"] > span').css({'transform' : 'scale(0)'}); 4516 4517 $($containerClass+' .swiper-slide .content p, '+$containerClass+' .swiper-slide .content .buttons').stop(true,true).css({'opacity':0, 'transform' : 'translateY(40px)'}); 4518 } 4519 4520 } 4521 4522 //pause video if there's one 4523 $($containerClass+' .swiper-slide').each(function(){ 4524 if($(this).find('.video-wrap video').length > 0 && !$('html').hasClass('no-video') && !$onMobileBrowser) { $(this).find('.video-wrap video').get(0).pause(); } 4525 }); 4526 $($containerClass+' .swiper-slide:not(".swiper-slide-active")').each(function(){ 4527 if($(this).find('.video-wrap video').length > 0) { 4528 4529 if($(this).find('.video-wrap video').get(0).currentTime != 0 ) $(this).find('.video-wrap video').get(0).currentTime = 0; 4530 } 4531 }); 4532 4533 4534 if($($containerClass +' .swiper-container').attr('data-loop') == 'true') { 4535 4536 4537 //webkit video fix 4538 if( $($containerClass+' .swiper-slide-active').index()+1 == 2 && $($containerClass+' .swiper-slide-active video').length > 0 && !$('html').hasClass('no-video') && !$onMobileBrowser) { 4539 4540 $($containerClass+' .swiper-slide:last-child').find('.video-wrap video').get(0).play(); 4541 $($containerClass+' .swiper-slide:last-child').find('.video-wrap video').get(0).pause(); 4542 } 4543 if( $($containerClass+' .swiper-slide-active').index()+1 == $slideNum-1 && $($containerClass+' .swiper-slide-active video').length > 0 && !$('html').hasClass('no-video') && !$onMobileBrowser) { 4544 4545 $($containerClass+' .swiper-slide:first-child').find('.video-wrap video').get(0).play(); 4546 $($containerClass+' .swiper-slide:first-child').find('.video-wrap video').get(0).pause(); 4547 } 4548 if($($containerClass+' .swiper-slide-active').index()+1 != 2 && $($containerClass+' .swiper-slide:nth-child(2) video').length > 0 && !$('html').hasClass('no-video') && !$onMobileBrowser) { 4549 4550 $($containerClass+' .swiper-slide:last-child').find('.video-wrap video').get(0).play(); 4551 $($containerClass+' .swiper-slide:last-child').find('.video-wrap video').get(0).pause(); 4552 4553 $($containerClass+' .swiper-slide:nth-child(2) video').get(0).pause(); 4554 if($($containerClass+' .swiper-slide:nth-child(2) video').get(0).currentTime != 0 ) $($containerClass+' .swiper-slide:nth-child(2) video').get(0).currentTime = 0; 4555 } 4556 4557 //also show duplicate slide if applicable 4558 if($($containerClass).attr('data-overall_style') != 'directional') { 4559 4560 ////first 4561 if( $($containerClass+' .swiper-slide-active').index()+1 == $slideNum-1 ){ 4562 4563 $($containerClass+' .swiper-slide:nth-child(1)').find('.content').children().each(function(i){ 4564 4565 captionTransAnimation($(this),i,captionTransString); 4566 4567 });
4568 4569 } 4570 4571 ////last 4572 if( $($containerClass+' .swiper-slide-active').index()+1 == 2 ){ 4573 $($containerClass+' .swiper-slide:nth-child('+ ($slideNum) + ')').find('.content').children().each(function(i){ 4574 captionTransAnimation($(this),i,captionTransString); 4575 }); 4576 4577 } 4578 4579 4580 //looped last going to first 4581 if( $($containerClass+' .swiper-slide-active').index()+1 == $slideNum ){ 4582 4583 $($containerClass+' .swiper-slide:nth-child(2)').find('.content').children().each(function(i){ 4584 4585 captionTransAnimation($(this),i,captionTransString); 4586 }); 4587 } 4588 4589 //looped first going to last 4590 if( $($containerClass+' .swiper-slide-active').index()+1 == 1 ){ 4591 4592 $($containerClass+' .swiper-slide:eq(-2)').find('.content').children().each(function(i){ 4593 4594 captionTransAnimation($(this),i,captionTransString); 4595 }); 4596 } 4597 4598 4599 }//directional 4600 4601 4602 }//if using loop 4603 4604 //play video if there's one 4605 setTimeout(function(){ 4606 playVideoBG($($containerClass + ' .swiper-slide-active').index() + 1, $containerClass); 4607 },50); 4608 4609 4610 //fadeIn active slide 4611 4612 if($($containerClass).attr('data-overall_style') != 'directional') { 4613 $($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').find('.content').children().each(function(i){ 4614 4615 captionTransAnimation($(this),i,captionTransString); 4616 4617 });
4618 } 4619 4620 4621 4622 4623 previousSlide = $($containerClass + ' .swiper-slide-active').index(); 4624 4625 $captionTrans++; 4626 if($captionTrans == $('.swiper-wrapper').length) { $('div.first_video_slide').addClass('nulled') } 4627 4628 4629 //slider arrows with preview effect 4630 setTimeout(function(){ 4631 4632 if($('.slider-next').hasClass('next-arrow-move')) { 4633 $('.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-next').trigger('mouseenter'); 4634 } else if($('.slider-prev').hasClass('prev-arrow-move')) { 4635 $('.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-prev').trigger('mouseenter'); 4636 } 4637 4638 4639 if($($containerClass).attr('data-button-styling') == 'btn_with_preview') { 4640 $($containerClass+' .swiper-slide').addClass('prev-high-z-index-static'); 4641 $($containerClass+' .swiper-slide.swiper-slide-active').removeClass('prev-high-z-index-static'); 4642 } 4643 4644 },175); 4645 4646 4647 4648 4649 } 4650 4651 4652 function NSsplitLineText() { 4653 $('.nectar-slider-wrap[data-caption-trans="reveal_title"] .content h2').each(function(){ 4654 4655 var storedCSSOpacity = ($(this).parents('.swiper-slide-active').length > 0 && $(this).find('.word').length > 0 ) ? $(this).find('> .word').css('opacity') : '0'; 4656 4657 var textArr = $(this).text(); 4658 textArr = textArr.trim(); 4659 textArr = textArr.split(' '); 4660 4661 $(this)[0].innerHTML = ''; 4662 4663 for(var i=0;i<textArr.length;i++) { 4664 $(this)[0].innerHTML += '<span class="word">'+ textArr[i] + '</span> '; 4665 } 4666 4667 $(this).find('.word').each(function(){ 4668 charming($(this)[0]); 4669 }); 4670 4671 $(this).find('[class*="char"]').wrapInner('<span class="char-inner" />'); 4672 4673 if($(this).parents('.swiper-slide-active').length > 0) { 4674 $(this).find('> .word').css('opacity', storedCSSOpacity); 4675 } 4676 4677 }); 4678 4679 } 4680 4681function charming(element, options) { 4682 options = options || {} 4683 element.normalize() 4684 var splitRegex = options.splitRegex 4685 4686 var tagName = options.tagName || 'span' 4687 var classPrefix = options.classPrefix != null ? options.classPrefix : 'char' 4688 var count = 1 4689 4690 function inject (element) { 4691 var parentNode = element.parentNode 4692 var string = element.nodeValue 4693 var split = splitRegex ? string.split(splitRegex) : string 4694 var length = split.length 4695 var i = -1 4696 while (++i < length) { 4697 var node = document.createElement(tagName) 4698 if (classPrefix) { 4699 node.className = classPrefix + count 4700 count++ 4701 } 4702 node.appendChild(document.createTextNode(split[i])) 4703 node.setAttribute('aria-hidden', 'true') 4704 parentNode.insertBefore(node, element) 4705 } 4706 if (string.trim() !== '') { 4707 parentNode.setAttribute('aria-label', string) 4708 } 4709 parentNode.removeChild(element) 4710 } 4711 4712 ;(function traverse (element) { 4713 // `element` is itself a text node. 4714 if (element.nodeType === 3) { 4715 return inject(element) 4716 } 4717 4718 // `element` has a single child text node. 4719 var childNodes = Array.prototype.slice.call(element.childNodes) // static array of nodes 4720 var length = childNodes.length 4721 if (length === 1 && childNodes[0].nodeType === 3) { 4722 return inject(childNodes[0]) 4723 } 4724 4725 // `element` has more than one child node. 4726 var i = -1 4727 while (++i < length) { 4728 traverse(childNodes[i]) 4729 } 4730 })(element) 4731} 4732 4733 NSsplitLineText();
4734 //$(window).smartresize(NSsplitLineText); 4735 4736 //caption trans helper 4737 var charCount = 0; 4738 function captionTransAnimation(obj,index,animationName) { 4739 4740 if(animationName == 'reveal_title') { 4741 4742 if(obj.parent().find('.word').length == 0) charCount = 0; 4743 4744 if(index === 0 && obj.parent().find('.word').length > 0) { 4745 4746 charCount = obj.find('.word > [class*="char"]').length; 4747 4748 obj.find('.word').css('opacity','1'); 4749 4750 obj.find('.word > [class*="char"]').each(function(i){ 4751 4752 $(this).delay(i*18).transition({ 4753 'transform' : 'translateY(0px)', 4754 'opacity' : '1' 4755 },700,'cubic-bezier(.25, 0.25, 0.1, 1)'); 4756 4757 $(this).find('> span').delay(i*18).transition({ 4758 'transform' : 'scale(1)', 4759 },700,'cubic-bezier(.25, 0.25, 0.1, 1)'); 4760 4761 }); //char loop 4762 4763 4764 4765 } else { 4766 4767 obj.stop().delay(index*150 + (charCount*18)).transition({ 4768 'opacity' : 1, 4769 'transform' : 'translateY(0)' 4770 },850,'cubic-bezier(.25, .25, 0.1, 1)'); 4771 4772 } 4773 4774 4775 } else if(animationName == 'fade_in_from_bottom') { 4776 4777 obj.stop().delay(index*130).transition({ 4778 'opacity' : 1, 4779 'transform' : 'translateY(0)' 4780 },800,'cubic-bezier(.25, .25, 0.1, 1)'); 4781 4782 } 4783 4784 } 4785 4786 //used in caption transition 4787 function playVideoBG(nthChild, containerClass){ 4788 4789 if($(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.video-wrap video').length > 0){ 4790 4791 if(!$('html').hasClass('no-video') && !$onMobileBrowser) $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.video-wrap video').get(0).play(); 4792 4793 if(!$(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-overlay.mejs-overlay-play').hasClass('playing') && $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-overlay.mejs-overlay-play').hasClass('mobile-played')) { $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-overlay.mejs-overlay-play').addClass('playing'); } 4794 if(!$(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-poster').hasClass('playing') && $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-poster').hasClass('mobile-played')) $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-poster').addClass('playing'); 4795 4796 var $that = $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-overlay.mejs-overlay-play'); 4797 var $that2 = $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-poster'); 4798 4799 if($that.hasClass('playing') && $that.hasClass('mobile-played')) { 4800 setTimeout(function(){ $that.addClass('behind-buttons'); $that2.addClass('behind-buttons');},200); 4801 } else { 4802 $that.removeClass('behind-buttons'); $that2.removeClass('behind-buttons'); 4803 } 4804 } 4805 4806 } 4807 4808 4809 var $startingSlide = null; 4810 4811 4812 4813 function slideContentPos(){ 4814 4815 $('.swiper-wrapper').each(function(){ 4816 4817 //etxra space if first slider in section 4818 var $extraHeight = ($(this).parents('.nectar-slider-wrap').hasClass('first-section') || $(this).parents('.parallax_slider_outer').hasClass('first-section')) ? 30 : 0; 4819 4820 var $sliderHeight = parseInt($(this).parents('.swiper-container').attr('data-height')); 4821 var $minimumHeight = ($(this).parents('.swiper-container').css('min-height')) ? parseInt($(this).parents('.swiper-container').css('min-height')) : 0; 4822 4823 //min height addition 4824 if($minimumHeight > $sliderHeight) { 4825 $sliderHeight = $minimumHeight; 4826 } 4827 4828 var $transparentHeader = ($('#header-outer[data-transparent-header="true"]').length > 0) ? $('#header-space').height() : 0 ; 4829 if($(this).parents('.first-section').length == 0 || window.innerWidth < 1000) { 4830 $transparentHeader = null; 4831 } else if($transparentHeader != 0 && $('#header-outer[data-remove-border="true"]').length > 0){ 4832 $transparentHeader = $transparentHeader/2 4833 } 4834 4835 if($(this).parents('.swiper-container[data-bullet_position="right"][data-bullets="true"]').length > 0 && $transparentHeader > 0 || 4836 $(this).parents('.swiper-container[data-bullet_position="left"][data-bullets="true"]').length > 0 && $transparentHeader > 0) { 4837 4838 var secondaryHeaderHeight = ($('#header-secondary-outer').length > 0) ? $('#header-secondary-outer').height() : 0; 4839 $(this).parents('.swiper-container').find('.slider-pagination-wrap').css({ 4840 'margin-top': ($transparentHeader + secondaryHeaderHeight)/2 4841 }); 4842 } 4843 4844 $(this).find('.swiper-slide').each(function(){ 4845 4846 var $contentHeight = $(this).find('.content').height(); 4847 var $contentItems = $(this).find('.content > *').length; 4848 4849 $contentHeight2 = 0; 4850 $(this).find('.content > *').each(function(){ 4851 $contentHeight2 += $(this).height() + parseInt($(this).css('margin-bottom')) + parseInt($(this).css('padding-bottom')); 4852 }); 4853 4854 if($(this).find('.content > *').css('padding-top') == '25px') $contentHeight = $contentHeight - 25*$contentItems; 4855 4856 if($(this).attr('data-y-pos') == 'top' && window.innerWidth > 690 ){ 4857 var secondaryHeaderHeight = ($('#header-secondary-outer').length > 0) ? $('#header-secondary-outer').height() : 0; 4858 var $topHeight = ($transparentHeader > 0) ? $transparentHeader + secondaryHeaderHeight + 60 : 60; 4859 $(this).find('.content').css('top', $topHeight + 'px'); 4860 } 4861 else if($(this).attr('data-y-pos') == 'middle' || window.innerWidth <= 690) { 4862 $(this).find('.content').css('top', ((($sliderHeight + $transparentHeader)/2) - ($contentHeight2/2)) + 'px'); 4863 } 4864 else { 4865 4866 $(this).find('.content').css({'bottom': '75px', 'top': 'auto'}); 4867 4868 } 4869 }); 4870 }); 4871 } 4872 4873 4874 4875 function showSliderControls() { 4876 $('.swiper-container .slider-prev, .swiper-container .slider-next, .slider-pagination').animate({'opacity':1},550,'easeOutSine'); 4877 } 4878 4879 4880 var sliderLength = $('.swiper-container').length; 4881 var sliderLoadedLength = 0; 4882 4883 function sliderLoadIn(slider,index) { 4884 4885 slider.find('.nectar-slider-loading').fadeOut(800,'easeInOutExpo'); 4886 4887 setTimeout(function(){ 4888 slider.find('.nectar-slider-loading').css('display','none'); 4889 },1000); 4890 4891 $('.nectar-slider-wrap.first-section .swiper-container .swiper-wrapper .swiper-slide').removeClass('not-loaded'); 4892 4893 slider.find('span.ie-fix').remove(); 4894 4895 //ar visualized start 4896 if(slider.find('.swiper-container[data-bullet_style="see_through_ar_visualized"][data-bullets="true"]').length > 0) { 4897 slider.find('.swiper-active-switch').removeClass('ar-vis'); 4898 setTimeout(function(){ 4899 slider.parent().find('.swiper-active-switch').addClass('ar-vis'); 4900 },50); 4901 } 4902 4903 ///make sure to init smooth scrolling after slider height exists 4904 var $smoothActive = $('body').attr('data-smooth-scrolling'); 4905 if( $smoothActive == 1 && $(window).width() > 690 && $('body').outerHeight(true) > $(window).height() && $('#ascrail2000').length == 0 && !navigator.userAgent.match(/(Android|iPod|iPhone|iPad|IEMobile|Opera Mini)/)){ niceScrollInit(); resizeToCover(); } 4906 4907 //check for sliders in tabbed 4908 sliderLoadedLength++; 4909 if($('.tabbed').find('.swiper-container').length > 0 && sliderLoadedLength == sliderLength) { 4910 setTimeout(function(){ $('.tabbed > ul li:first-child a').click(); }, 200); 4911 } 4912 4913 if(!navigator.userAgent.match(/(Android|iPod|iPhone|iPad|IEMobile|Opera Mini)/)) { autorotateInit(slider,index); } 4914 4915 } 4916 4917 4918 4919 //play video user is hovering over 4920 $('body').on('mouseover','.swiper-slide', function(){ 4921 if(!$onMobileBrowser && $(this).find('video').length > 0 && $(this).find('video').get(0).paused == true && $animating == false){ 4922 $(this).find('video').get(0).play(); 4923 } 4924 }); 4925 4926 4927 //mobile play event 4928 $('body').on('click', '.mejs-overlay.mejs-overlay-play',function(){ 4929 $(this).toggleClass('playing'); 4930 $(this).addClass('mobile-played'); 4931 4932 $(this).parent().find('.mejs-poster').toggleClass('playing'); 4933 $(this).parent().find('.mejs-poster').addClass('mobile-played'); 4934 4935 var $that = $(this); 4936 var $that2 = $(this).parent().find('.mejs-poster'); 4937 4938 if($(this).hasClass('playing') && $(this).hasClass('mobile-played')) { 4939 4940 setTimeout(function(){ $that.addClass('behind-buttons'); $that2.addClass('behind-buttons'); },200);
4941 } else { 4942 setTimeout(function(){ $that.removeClass('behind-buttons'); $that2.removeClass('behind-buttons'); },1); 4943 } 4944 }); 4945 4946 4947 4948 var $sliderHeight = parseInt($(this).find('.swiper-container').attr('data-height')); 4949 var portfolioHeaderHeight = ($('.project-title.parallax-effect').length > 0) ? 100 : 0; 4950 4951 function autorotateInit(slider,num) { 4952 4953 //$('.nectar-slider-wrap').each(function(i){ 4954 var $autoplayVal = slider.attr('data-autorotate'); 4955 var $that = slider; 4956 var $sliderNum = num; 4957 4958 if(typeof $autoplayVal !='undefined' && $autoplayVal.length != '0' && parseInt($autoplayVal)) { 4959 nectarSlideRotateInit(slider,$autoplayVal,$sliderNum); 4960 4961 } 4962 4963 //}); 4964 } 4965 4966 4967 function nectarSlideRotateInit(slider,interval,sliderNum){ 4968 4969 autoplay[sliderAutoplayCount] = { interval: setInterval(function(){ nectarSlideRotate(slider, sliderNum); } ,interval), nectarSliderNum: sliderNum, autoplayNum: sliderAutoplayCount, nectarSliderID: slider.attr('id') }; 4970 4971 $('#'+slider.attr('id')).attr('autoplay-id',sliderAutoplayCount); 4972 4973 //ar visualized style 4974 if( $('#'+slider.attr('id')).find('[data-bullet_style="see_through_ar_visualized"]').length > 0 ) { 4975 $('#'+slider.attr('id')).find('.slider-pagination svg circle.time').css('transition', 'stroke-dashoffset '+ (parseInt(interval) + 100) +'ms linear, stroke 0.2s ease'); 4976 } 4977 4978 var sliderClosure = slider; 4979 var sliderAutoplayCountClosure = sliderAutoplayCount; 4980 var intervalClosure = interval; 4981 var sliderNumClosure = sliderNum; 4982 4983 4984 $('#'+slider.attr('id') + ' a.slider-prev, #'+slider.attr('id') + ' a.slider-next, #' + slider.attr('id') + ' .slider-pagination span:not(.swiper-active-switch)').click(function(e){ 4985 4986 4987 nectarSlideRotateReset(sliderClosure, sliderAutoplayCountClosure, intervalClosure, sliderNumClosure); 4988 4989 //if(typeof e.clientY != 'undefined'){ 4990 // clearInterval(autoplay[$('#'+slider.attr('id')).attr('autoplay-id')]); 4991 4992 //class for directional 4993 // if( $('#'+slider.attr('id')).parent().hasClass('parallax_slider_outer') && $('#'+slider.attr('id')).attr('data-overall_style') == 'directional' ) { 4994 // $('#'+slider.attr('id')).parent().addClass('user-stopped'); 4995 // } 4996 //} 4997 }); 4998 4999 sliderAutoplayCount++; 5000 } 5001 5002 function nectarSlideRotateReset(slider, sliderAutoplayCount, interval,sliderNum){ 5003 5004 slider = (typeof slider.activeIndex === 'undefined') ? slider : $(slider.container).parent(); 5005 5006 sliderAutoplayCount = (typeof sliderAutoplayCount !== 'undefined' && typeof sliderAutoplayCount === 'number') ? sliderAutoplayCount : 'unknown'; 5007 5008 if( sliderAutoplayCount === 'unknown') { 5009 5010 $.each(autoplay,function(k,v){ 5011 5012 if( $('body').find('#' + v.nectarSliderID).length > 0 && v.nectarSliderID == $(slider).attr('id') ) { 5013 5014 sliderAutoplayCount = v.autoplayNum; 5015 interval = ($('body').find('#' + v.nectarSliderID).attr('data-autorotate').length > 0 && parseInt($('body').find('#' + v.nectarSliderID).attr('data-autorotate')) > 1000) ? $('body').find('#' + v.nectarSliderID).attr('data-autorotate') : 4000; 5016 sliderNum = v.nectarSliderNum; 5017 5018 } 5019 5020 }); 5021 } 5022 5023 5024 5025 //only reset and restart when slider was found and link was made 5026 if( sliderAutoplayCount !== 'unknown') { 5027 clearInterval(autoplay[$('#'+slider.attr('id')).attr('autoplay-id')].interval); 5028 autoplay[sliderAutoplayCount].interval = setInterval(function(){ nectarSlideRotate(slider, sliderNum); } ,interval); 5029 } 5030 5031 5032 } 5033 5034 5035 5036 var resetTouchIndex = 1; 5037 var resetTouchIndexLast = 'unknown'; 5038 5039 function nectarSlideRotateResetTouch(slider){ 5040 5041 5042 //if user has not dragged any significant distance 5043 if(Math.abs(slider.touches.diff) < 15) { return } 5044 5045 //first time run set last index 5046 if(resetTouchIndexLast == 'unknown' && $(slider.container).is('[data-loop="true"]')) { 5047 resetTouchIndexLast = 1; 5048 } else if(resetTouchIndexLast == 'unknown') { 5049 resetTouchIndexLast = 0; 5050 } 5051 5052 resetTouchIndex = slider.activeIndex; 5053 5054 nectarSlideRotateReset(slider); 5055 5056 //if going back to same slide on touch - reset visualization 5057 if($(slider.container).is('[data-bullets="true"][data-bullet_style="see_through_ar_visualized"]') && resetTouchIndex == resetTouchIndexLast) { 5058 var dotIndexStored = $(slider.container).find('.ar-vis').index(); 5059 5060 $(slider.container).find('.ar-vis').removeClass('ar-vis'); 5061 setTimeout(function(){ 5062 $(slider.container).find('.slider-pagination > span:nth-child('+ (dotIndexStored + 1) +')').addClass('ar-vis'); 5063 },50); 5064 5065 5066 } 5067 5068 resetTouchIndexLast = slider.activeIndex; 5069 5070 } 5071 5072 5073 5074 5075 function nectarSlideRotate(slider, sliderNum){ 5076 5077 if($('#nectar_fullscreen_rows').length > 0) { 5078 if($(slider).parents('.wpb_row.active').length == 0) { 5079 return true; 5080 } 5081 } 5082 //non looped 5083 if($nectarSliders[sliderNum].activeIndex + 1 < $(slider).find('.swiper-wrapper > div.swiper-slide').length){ 5084 5085 //btn with preview hover effect clear 5086 if($(slider).attr('data-button-styling') == 'btn_with_preview') { 5087 $(slider).find('.swiper-slide').removeClass('high-z-index').removeClass('prev-high-z-index'); 5088 $(slider).find('.swiper-slide').removeClass('next-move').removeClass('prev-move'); 5089 } 5090 5091 //classic style 5092 if($(slider).attr('data-overall_style') != 'directional') { 5093 $nectarSliders[sliderNum].swipeNext(); 5094 } else { 5095 //directional based 5096 $($nectarSliders[sliderNum].container).find('.slider-next').trigger('click'); 5097 } 5098 5099 } else { 5100 //looped sliders 5101 if($(slider).find('.swiper-container').is("[data-loop]") && $(slider).find('.swiper-container').attr('data-loop') == 'true') { 5102 5103 //classic style 5104 if($(slider).attr('data-overall_style') != 'directional') { 5105 $nectarSliders[sliderNum].swipeNext(); 5106 } else { 5107 //directional based 5108 $($nectarSliders[sliderNum].container).find('.slider-next').trigger('click'); 5109 } 5110 5111 } 5112 //regular sliders 5113 else { 5114 5115 if($(slider).attr('data-overall_style') != 'directional') { 5116 $nectarSliders[sliderNum].swipeTo(0,550); 5117 } else { 5118 $(slider).find('.swiper-container').addClass('directional-trans-prev'); 5119 $nectarSliders[sliderNum].swipeTo(0,550); 5120 //call the dark/light slide coloring half way through transition 5121 var $timeout2; 5122 clearTimeout($timeout2); 5123 $timeout2 = setTimeout(function(){ onChangeStart($nectarSliders[sliderNum]); } ,100); 5124 } 5125 5126 } 5127 } 5128 } 5129 5130 function clearAutoplay(e){ 5131 var $autoplayVal = $('#'+$(e.container).parent().attr('id')).attr('data-autorotate'); 5132 5133 if(typeof $autoplayVal !='undefined' && $autoplayVal.length != '0' && parseInt($autoplayVal)) { 5134 5135 clearInterval(autoplay[$('#'+$(e.container).parent().attr('id')).attr('autoplay-id')].interval); 5136 } 5137 } 5138 5139 5140 function onChangeStart(e){ 5141 //performance 5142 //$('.swiper-wrapper').css('will-change','transform'); 5143 5144 //cache slider obj 5145 var $obj = e; 5146 5147 $animating = true; 5148 5149 var $slideNum = $($obj.container).find('.swiper-wrapper > div').length; 5150 5151 //one for effects and one for basic slide arrow count 5152 $activeIndex = ($($obj.container).attr('data-loop') == 'true') ? $obj.activeIndex + 1: $obj.activeIndex+1; 5153 $activeIndex2 = ($($obj.container).attr('data-loop') == 'true') ? $obj.activeIndex: $obj.activeIndex+1; 5154 5155 //dark slide header 5156 if($($obj.container).parent().attr('data-overall_style') != 'directional') { 5157 if( $($obj.container).parents('.first-section').length > 0 && $($obj.container).find('.swiper-slide-active[data-color-scheme="dark"]').length > 0 || 5158 $('#nectar_fullscreen_rows').length > 0 && $($obj.container).find('.swiper-slide-active[data-color-scheme="dark"]').length > 0) { 5159 $('#header-outer').addClass('dark-slide'); 5160 } else if( $($obj.container).parents('.first-section').length > 0 || $('#nectar_fullscreen_rows').length > 0) { 5161 $('#header-outer').removeClass('dark-slide'); 5162 } 5163 } 5164 ////directional trans - will be called early so need to adjust the slide being looked for 5165 else { 5166 if($($obj.container).hasClass('directional-trans-next')) { 5167 5168 if($($obj.container).parents('.first-section').length > 0 && $($obj.container).find('.swiper-slide-active').next('.swiper-slide').is('[data-color-scheme="dark"]') ) { 5169 $('#header-outer').addClass('dark-slide'); 5170 //nav items animation 5171 if($('body.mobile').length == 0) { 5172 $('#header-outer nav > ul.sf-menu > li > a, #header-outer nav > ul.buttons > li#search-btn a, #header-outer nav > ul.buttons > li.slide-out-widget-area-toggle a > span, #header-outer .cart-icon-wrap, header#top #logo').each(function(){ 5173 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 5174 5175 $(this).find('span.dark').css('display','inline').transition({'margin-left': '0'},0).transition({ 'width' : $itemWidth }, 325, 'easeInOutQuart'); 5176 $(this).find('span.dark > span').transition({'margin-left': '0'},0); 5177 $(this).find('span.light').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 5178 $(this).find('span.light > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 5179 }); 5180 } 5181 } else { 5182 $('#header-outer').removeClass('dark-slide'); 5183 //nav items animation 5184 if($('body.mobile').length == 0) { 5185 $('#header-outer nav > ul.sf-menu > li > a, #header-outer nav > ul.buttons > li#search-btn a, #header-outer nav > ul.buttons > li.slide-out-widget-area-toggle a > span, #header-outer .cart-icon-wrap, header#top #logo').each(function(){ 5186 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 5187 5188 $(this).find('span.light').css('display','inline').transition({'margin-left': '0'},0).css('display','inline').transition({'width' : $itemWidth }, 325, 'easeInOutQuart'); 5189 $(this).find('span.light > span').transition({'margin-left': '0'},0); 5190 $(this).find('span.dark').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 5191 $(this).find('span.dark > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 5192 }); 5193 } 5194 } 5195 } 5196 5197 else if($($obj.container).hasClass('directional-trans-prev')) { 5198 if( $($obj.container).parents('.first-section').length > 0 && $($obj.container).find('.swiper-slide-active').prev('.swiper-slide').is('[data-color-scheme="dark"]') ) { 5199 $('#header-outer').addClass('dark-slide'); 5200 //nav items animation 5201 if($('body.mobile').length == 0) { 5202 $('#header-outer nav > ul.sf-menu > li > a, #header-outer nav > ul.buttons > li#search-btn a, #header-outer nav > ul.buttons > li.slide-out-widget-area-toggle a > span, #header-outer .cart-icon-wrap, header#top #logo').each(function(){ 5203 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 5204 5205 $(this).find('span.dark').css('display','inline').transition({'margin-left': '0'},0).transition({ 'width' : $itemWidth }, 325, 'easeInOutQuart'); 5206 $(this).find('span.dark > span').transition({'margin-left': '0'},0); 5207 $(this).find('span.light').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 5208 $(this).find('span.light > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 5209 }); 5210 } 5211 } else { 5212 $('#header-outer').removeClass('dark-slide'); 5213 //nav items animation 5214 if($('body.mobile').length == 0) { 5215 $('#header-outer nav > ul.sf-menu > li > a, #header-outer nav > ul.buttons > li#search-btn a, #header-outer nav > ul.buttons > li.slide-out-widget-area-toggle a > span, #header-outer .cart-icon-wrap, header#top #logo').each(function(){ 5216 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 5217 5218 $(this).find('span.light').css('display','inline').transition({'margin-left': '0'},0).transition({'width' : $itemWidth }, 325, 'easeInOutQuart'); 5219 $(this).find('span.light > span').transition({'margin-left': '0'},0); 5220 $(this).find('span.dark').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 5221 $(this).find('span.dark > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 5222 }); 5223 } 5224 } 5225 } 5226 5227 else if($($obj.container).hasClass('directional-trans-current')) { 5228 if( $($obj.container).parents('.first-section').length > 0 && $($obj.container).find('.swiper-slide-active').is('[data-color-scheme="dark"]') ) { 5229 $('#header-outer').addClass('dark-slide'); 5230 //nav items animation 5231 if($('body.mobile').length == 0) { 5232 $('#header-outer nav > ul.sf-menu > li > a, #header-outer nav > ul.buttons > li#search-btn a, #header-outer nav > ul.buttons > li.slide-out-widget-area-toggle a > span, #header-outer .cart-icon-wrap, header#top #logo').each(function(){ 5233 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 5234 5235 $(this).find('span.dark').css('display','inline').transition({'margin-left': '0'},0).transition({ 'width' : $itemWidth }, 325, 'easeInOutQuart'); 5236 $(this).find('span.dark > span').transition({'margin-left': '0'},0); 5237 $(this).find('span.light').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 5238 $(this).find('span.light > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 5239 }); 5240 } 5241 } else { 5242 $('#header-outer').removeClass('dark-slide'); 5243 //nav items animation 5244 if($('body.mobile').length == 0) { 5245 $('#header-outer nav > ul.sf-menu > li > a, #header-outer nav > ul.buttons > li#search-btn a, #header-outer nav > ul.buttons > li.slide-out-widget-area-toggle a > span, #header-outer .cart-icon-wrap, header#top #logo').each(function(){ 5246 var $itemWidth = parseI
5246nt($(this).find('span.original').attr('data-w')); 5247 5248 $(this).find('span.light').css('display','inline').transition({'margin-left': '0'},0).transition({'width' : $itemWidth }, 325, 'easeInOutQuart'); 5249 $(this).find('span.light > span').transition({'margin-left': '0'},0); 5250 $(this).find('span.dark').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 5251 $(this).find('span.dark > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 5252 }); 5253 } 5254 } 5255 } 5256 5257 5258 } 5259 5260 //light and dark controls 5261 if($($obj.container).parent().attr('data-overall_style') != 'directional') { 5262 if($($obj.container).find('.swiper-slide:nth-child('+ ($activeIndex) +')').attr('data-color-scheme') == 'dark') { 5263 $($obj.container).find('.slider-pagination').addClass('dark-cs'); 5264 $($obj.container).find('.slider-prev, .slider-next').addClass('dark-cs'); 5265 } else { 5266 $($obj.container).find('.slider-pagination').removeClass('dark-cs'); 5267 $($obj.container).find('.slider-prev, .slider-next').removeClass('dark-cs'); 5268 } 5269 } 5270 ////directional trans - will be called early so need to adjust the slide being looked for 5271 else { 5272 if($($obj.container).hasClass('directional-trans-next')) { 5273 if($($obj.container).find('.swiper-slide:nth-child('+ ($activeIndex+1) +')').attr('data-color-scheme') == 'dark') { 5274 $($obj.container).find('.slider-pagination').addClass('dark-cs'); 5275 $($obj.container).find('.slider-prev, .slider-next').addClass('dark-cs'); 5276 } else { 5277 $($obj.container).find('.slider-pagination').removeClass('dark-cs'); 5278 $($obj.container).find('.slider-prev, .slider-next').removeClass('dark-cs'); 5279 } 5280 } else if($($obj.container).hasClass('directional-trans-prev')) { 5281 if($($obj.container).find('.swiper-slide:nth-child('+ ($activeIndex-1) +')').attr('data-color-scheme') == 'dark') { 5282 $($obj.container).find('.slider-pagination').addClass('dark-cs'); 5283 $($obj.container).find('.slider-prev, .slider-next').addClass('dark-cs'); 5284 } else { 5285 $($obj.container).find('.slider-pagination').removeClass('dark-cs'); 5286 $($obj.container).find('.slider-prev, .slider-next').removeClass('dark-cs'); 5287 } 5288 5289 } else if($($obj.container).hasClass('directional-trans-current')) { 5290 if($($obj.container).find('.swiper-slide:nth-child('+ ($activeIndex) +')').attr('data-color-scheme') == 'dark') { 5291 $($obj.container).find('.slider-pagination').addClass('dark-cs'); 5292 $($obj.container).find('.slider-prev, .slider-next').addClass('dark-cs'); 5293 } else { 5294 $($obj.container).find('.slider-pagination').removeClass('dark-cs'); 5295 $($obj.container).find('.slider-prev, .slider-next').removeClass('dark-cs'); 5296 } 5297 5298 } 5299 } 5300 5301 5302 $($obj.container).find('.swiper-slide .video-texture').removeClass('no-trans').removeClass('light-overlay').removeClass('dark-overlay').removeClass('half-dark-overlay').removeClass('half-light-overlay'); 5303 5304 //add slide counts 5305 $($obj.container).find('.slider-prev .slide-count .slide-current').html( $activeIndex2 ); 5306 $($obj.container).find('.slider-next .slide-count .slide-current').html( $activeIndex2 ); 5307 5308 if($($obj.container).attr('data-loop') == 'true'){ 5309 //duplicate first slide 5310 if( $($obj.container).find('.swiper-slide-active').index()+1 == 1) { 5311 $($obj.container).find('.slider-next .slide-count .slide-current, .slider-prev .slide-count .slide-current').html( $slideNum - 2 ); 5312 } 5313 //duplicate last slide 5314 else if( $($obj.container).find('.swiper-slide-active').index()+1 == $slideNum) { 5315 $($obj.container).find('.slider-next .slide-count .slide-current, .slider-prev .slide-count .slide-current').html( 1 ); 5316 } 5317 } 5318 5319 if($obj.activeIndex >= 10) { $($obj.container).find('.slider-next .slide-count .slide-current').addClass('double-digits'); } else { 5320 $($obj.container).find('.slider-next .slide-count .slide-current').removeClass('double-digits'); 5321 } 5322 5323 5324 $($obj.container).find('.swiper-slide:not(".swiper-slide-active")').each(function(){ 5325 if($(this).find('.video-wrap video').length > 0) { 5326 5327 //if($(this).find('.video-wrap video').get(0).currentTime != 0 ) $(this).find('.video-wrap video').get(0).currentTime = 0; 5328 } 5329 }); 5330 5331 5332 //don't allow swiping on duplicate transition 5333 if($($obj.container).attr('data-loop') == 'true'){ 5334 if($obj.previousIndex == 1 && $obj.activeIndex == 0 || $obj.previousIndex == $slideNum - 2 && $obj.activeIndex == $slideNum - 1 ){ 5335 $('.swiper-slide').addClass('duplicate-transition'); 5336 } 5337 } 5338 5339 5340 //reset ken_burns 5341 5342 var sliderIndex = 0; 5343
5344 slideAnimationQueues.forEach(function(val,index) { 5345 if(typeof val === 'undefined') return; 5346 5347 if( val.sliderID == $($obj.container).parent().attr('id') ) { 5348 sliderIndex = index; 5349 } 5350 5351 }); 5352 5353 5354 if($($obj.container).parent().is('[data-bg-animation="ken_burns"]') && $($obj.container).parents('.nectar-slider-wrap[data-overall_style="directional"]').length == 0 ) { 5355 $($obj.container).find('.swiper-slide').addClass('ken-burns'); 5356 clearTimeout(slideAnimationQueues[sliderIndex].kenBurnsInterval); 5357 slideAnimationQueues[sliderIndex].kenBurnsInterval = setTimeout(function(){ 5358 $($obj.container).find('.swiper-slide:not(".swiper-slide-active")').removeClass('ken-burns'); 5359 },600); 5360 } 5361 5362 5363 var nsTimeout = ($($obj.container).parents('.nectar-slider-wrap[data-transition="fade"]').length > 0) ? 350 : 525; 5364 5365 clearTimeout(slideAnimationQueues[sliderIndex].captionInterval); 5366 if($($obj.container).parents('.nectar-slider-wrap[data-overall_style="directional"]').length == 0) { 5367 5368 slideAnimationQueues[sliderIndex].captionInterval = setTimeout(function(){ 5369 5370 $animating = false; 5371 5372 if( $($obj.container).attr('data-loop') == 'true' ) { 5373 $('.swiper-slide').removeClass('duplicate-transition'); 5374 5375 $.each($nectarSliders,function(k,v){ 5376 $nectarSliders[k].updateActiveSlide(); 5377 $nectarSliders[k].fixLoop(); 5378 }); 5379 } 5380 5381 captionTransition($obj); 5382 5383 },nsTimeout); 5384 5385 } 5386 5387 5388 } 5389 5390 5391 5392 5393 //functions to add or remove slider for webkit parallax fix 5394 function hideSlider() { 5395 5396 if( $(window).scrollTop()/($sliderHeight + portfolioHeaderHeight + 125) >= 1){ 5397 $('.parallax_slider_outer .nectar-slider-wrap, .project-title.parallax-effect').css('visibility','hidden').hide(); 5398 $('.parallax_slider_outer').removeClass('element-in-view').addClass('element-out-of-view'); 5399 5400 //directional slider autorotate clear 5401 if($('.parallax_slider_outer .nectar-slider-wrap[data-overall_style="directional"]').length > 0) { 5402 var $autoplayVal = $('.parallax_slider_outer .nectar-slider-wrap[data-overall_style="directional"]').attr('data-autorotate'); 5403 if(typeof $autoplayVal !='undefined' && $autoplayVal.length != '0' && parseInt($autoplayVal)) { 5404 clearInterval( autoplay[$('.parallax_slider_outer .nectar-slider-wrap').attr('autoplay-id')].interval ); 5405 } 5406 } 5407 5408 //$(window).on('scroll',showSlider); 5409 //$(window).off('scroll',hideSlider); 5410 } 5411 } 5412 5413 function showSlider() { 5414 if( $(window).scrollTop()/($sliderHeight + portfolioHeaderHeight + 125) <= 1){ 5415 5416 $('.parallax_slider_outer .nectar-slider-wrap, .project-title.parallax-effect').css('visibility','visible').show(); 5417 $('.parallax_slider_outer').addClass('element-in-view'); 5418 5419 //directional slider autorotate restart 5420 if($('.parallax_slider_outer .nectar-slider-wrap[data-overall_style="directional"]').length > 0 && $('.parallax_slider_outer.element-out-of-view').length > 0 && $('.parallax_slider_outer.user-stopped').length == 0) { 5421 var $autoplayVal = $('.parallax_slider_outer .nectar-slider-wrap[data-overall_style="directional"]').attr('data-autorotate'); 5422 if(typeof $autoplayVal !='undefined' && $autoplayVal.length != '0' && parseInt($autoplayVal)) { 5423 nectarSlideRotateInit($('.parallax_slider_outer .nectar-slider-wrap'),$autoplayVal,0); 5424 } 5425 } 5426 5427 $('.parallax_slider_outer').removeClass('element-out-of-view'); 5428 5429 //resize iframes incase user resized window when out of view 5430 $('.swiper-slide iframe[data-aspectRatio]').each(function() { 5431 var newWidth = $(this).parent().width(); 5432 var $el = $(this); 5433 if($(this).is(':visible')) $el.width(newWidth).height(newWidth * $el.attr('data-aspectRatio')); 5434 5435 }); 5436 5437
5438 nsSliderContentResize(); 5439 5440 //show content on current slide - could have been hidden from autorotate when slider was hidden 5441 if($('.parallax_slider_outer').length > 0) { 5442 var fromLeft = Math.abs(parseInt($('.parallax_slider_outer .nectar-slider-wrap .swiper-wrapper').css('left'))); 5443 var currentSlide = Math.round(fromLeft/$('.parallax_slider_outer .nectar-slider-wrap .swiper-slide').width()); 5444 5445 $('.parallax_slider_outer .swiper-wrapper .swiper-slide:eq(' + currentSlide + ')').find('.content').children().each(function(i){ 5446 $(this).stop(true,true).css({ 'opacity' : 1, 'transform' : 'translateY(0)' }); 5447 }); 5448 5449 $('.parallax_slider_outer .swiper-wrapper .swiper-slide:eq(' + currentSlide + ')').addClass('autorotate-shown'); 5450 } 5451 5452 //$(window).on('scroll',hideSlider); 5453 //$(window).off('scroll',showSlider); 5454 5455 } 5456 } 5457 5458 function sliderCorrectDisplayCheck() { 5459 if( $(window).scrollTop()/($sliderHeight + portfolioHeaderHeight + 125) >= 1){ 5460 hideSlider(); 5461 } 5462 //$(window).unbind('scroll',sliderCorrectDisplayCheck); 5463 } 5464 5465 5466 var $smoothActive = $('body').attr('data-smooth-scrolling'); 5467 5468 // Create cross browser requestAnimationFrame method: 5469 window.requestAnimationFrame = window.requestAnimationFrame 5470 || window.mozRequestAnimationFrame 5471 || window.webkitRequestAnimationFrame 5472 || window.msRequestAnimationFrame 5473 || function(f){setTimeout(f, 1000/60)} 5474 5475 5476 var lastPosition = -1; 5477 var $headerRemoveStickyness = ($('body[data-hhun="1"]').length > 0 && $('#header-outer[data-remove-fixed="1"]').length > 0) ? 1 : 0; 5478 5479 if($headerRemoveStickyness) { 5480 var $multiplier1 = 0.55; 5481 var $multiplier2 = 0.45; 5482 } else { 5483 var $multiplier1 = ($('body[data-hhun="1"]').length > 0) ? 0.45: 0.40; 5484 var $multiplier2 = ($('body[data-hhun="1"]').length > 0) ? 0.09: 0.19; 5485 } 5486 5487 5488 var $parallaxHeaderHUN = ($('#header-outer[data-transparency-option="1"]').length > 0) ? 0.49: 0.4; 5489 5490 var parallaxSliderEl = $('.parallax_slider_outer.first-section'); 5491 var nectarDisableForSafari = (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1); 5492 var $scrollTop = $(window).scrollTop(); 5493 var parallaxSliderStyle = (parallaxSliderEl.find('> .nectar-slider-wrap[data-parallax-style="bg_only"]').length > 0) ? 'bg-only' : 'both'; 5494 5495 function parallaxScroll(){ 5496 5497 $scrollTop = $(window).scrollTop(); 5498 //if on mobile, auto RAF 5499 if($onMobileBrowser){ 5500 $('.parallax_slider_outer .nectar-slider-wrap .slide-bg-wrap').css({ 'transform': 'translate3d(0, '+$scrollTop*0.25+'px, 0)' }); 5501 window.requestAnimationFrame(parallaxScroll); 5502 } 5503 5504 else if(parallaxSliderStyle == 'bg-only'){ 5505 $('.parallax_slider_outer .nectar-slider-wrap .slide-bg-wrap').css({ 'transform': 'translate3d(0, '+$scrollTop*0.25+'px, 0)' }); 5506 } 5507 5508 else { 5509 5510 // Avoid calculations if not needed 5511 if (lastPosition == $scrollTop || $('.parallax_slider_outer.element-in-view').length == 0 || $('.ocm-effect-wrap.material-ocm-open').length > 0 ) { 5512 // window.requestAnimationFrame(parallaxScroll); 5513 return false; 5514 } else lastPosition = $scrollTop; 5515 5516 if($smoothActive == 1 && nectarDisableForSafari) { return false; } 5517 5518 if( $('body[data-hhun="1"]').length > 0 && !$('#header-outer').hasClass('side-widget-open') && !$('#header-outer .slide-out-widget-area-toggle a').hasClass('animating') ) { 5519 5520 $('#header-outer.parallax-contained').css({ 'transform': 'translateY('+$scrollTop*-$parallaxHeaderHUN+'px)' }); 5521 } 5522 5523 $('.parallax_slider_outer.first-section .nectar-slider-wrap').css({ 'transform': 'translateY('+$scrollTop*-$multiplier1+'px)' }); 5524 5525 $('.parallax_slider_outer.first-section .swiper-slide:not(".static"):not(".caption-no-fade") .content, .nectar-slider-wrap .swiper-container .slider-next, .nectar-slider-wrap .swiper-container .slider-prev, .swiper-wrapper .slider-down-arrow').css({ 'transform': 'translateY('+$scrollTop*-$multiplier2+'px)' }); 5526 5527 if(!$headerRemoveStickyness) { 5528 $('.parallax_slider_outer.first-section .swiper-slide:not(".static"):not(".caption-no-fade") .content, .nectar-slider-wrap .swiper-container .slider-next, .nectar-slider-wrap .swiper-container .slider-prev, .swiper-wrapper .slider-down-arrow').css({ 'opacity': 1-($scrollTop/($sliderHeight-120)) }); 5529 } 5530 5531 $('#full_width_portfolio .project-title.parallax-effect').css({ 'transform': 'translateY('+ $scrollTop*-$multiplier1+'px)' }); 5532 5533 } 5534 5535 5536 } 5537 5538 function sliderParallaxUpdateHeight(){ 5539 $sliderHeight = parseInt($('.parallax_slider_outer.first-section .swiper-container').attr('data-height')); 5540 5541 /* 5542 $('.project-title').css({ 5543 'top': $headerNavSpace + $adminBarHeight + 'px', 5544 'width' : $('#ajax-content-wrap').width() 5545 }); */ 5546 } 5547 5548 5549 var $sliderHeight = parseInt($('.parallax_slider_outer.first-section .swiper-container').attr('data-height')); 5550 var $adminBarHeight = ($('#wpadminbar').length > 0) ? 28 : 0; 5551 var $headerNavSpace = ($('body[data-header-format="left-header"]').length > 0 && $(window).width() > 1000) ? 0 : $('#header-space').height(); 5552
5553 function sliderParallaxInit() { 5554 5555 5556 if($('#portfolio-extra').length > 0 && $('#full_width_portfolio').length == 0) { return false; } 5557 5558 //$(window).on('scroll.nsParallaxScroll',parallaxScroll); 5559 $('.parallax_slider_outer').addClass('element-in-view'); 5560 5561 /* 5562 if(!$onMobileBrowser) { 5563 window.addEventListener('scroll', function(){ 5564 window.requestAnimationFrame(parallaxScroll); 5565 }, false); 5566 } 5567 5568 parallaxScroll(); 5569 5570 5571 if($('.parallax_slider_outer > [data-parallax-style="bg_only"]').length > 0) { 5572 parallaxBGOnlySizing(); 5573 $(window).resize(parallaxBGOnlySizing); 5574 } 5575 5576 function parallaxBGOnlySizing() { 5577 var slideTopOffset = $('.parallax_slider_outer > [data-parallax-style="bg_only"] .swiper-slide').offset().top; 5578 5579 $('.parallax_slider_outer > [data-parallax-style="bg_only"] .swiper-slide .image-bg, .parallax_slider_outer > [data-parallax-style="bg_only"] .swiper-slide .slide-bg-overlay').css({'height':'calc(100% + ' + slideTopOffset/3 + 'px)', 'top': '-' + slideTopOffset/6 + 'px'}); 5580 $('.parallax_slider_outer > [data-parallax-style="bg_only"] .swiper-slide video').css({'top': '-' + slideTopOffset/6 + 'px'}); 5581 } 5582 */ 5583 5584 //hide slider to not mess up parallax section 5585 var portfolioHeaderHeight = ($('.project-title.parallax-effect').length > 0) ? 100 : 0; 5586 5587 function displayParallaxSliderInit() { 5588 if( $(window).scrollTop()/($sliderHeight + portfolioHeaderHeight + 90) >= 1){ 5589 //$(window).off('scroll.nsVisibilityHide'); 5590 //$(window).on('scroll.nsVisibilityHide', hideSlider); 5591 //$(window).on('scroll',showSlider); 5592 } else { 5593 //$(window).off('scroll.nsVisibilityShow'); 5594 //$(window).on('scroll.nsVisibilityShow', showSlider); 5595 //$(window).off('scroll', hideSlider); 5596 } 5597 } 5598 5599 if(!$onMobileBrowser) { 5600 5601 displayParallaxSliderInit(); 5602 5603 //$(window).off('scroll.nsCorrectDisplayCheck'); 5604 //$(window).on('scroll.nsCorrectDisplayCheck',sliderCorrectDisplayCheck); 5605 5606 5607 //$('body:not(".single") .page-header-no-bg, body:not(".single") #page-header-wrap, body:not(".single") #page-header-bg').remove(); 5608 5609 /*$('.project-title').addClass('parallax-effect').css({ 5610 'top': $headerNavSpace + $adminBarHeight + 'px', 5611 'width' : $('#ajax-content-wrap').width() 5612 });*/ 5613 5614 //caption alignment if portfolio fullwidth parallax 5615 if($('.project-title.parallax-effect').length > 0) { 5616 $('.parallax_slider_outer.first-section .swiper-slide .content, .nectar-slider-wrap.first-section .swiper-slide .content').css('margin-top','0px'); 5617 $('.swiper-container .slider-prev, .swiper-container .slider-next').css('margin-top','-28px'); 5618 } 5619 5620 //if using wooCommerce sitewide notice 5621 if($('.demo_store').length > 0) $('.project-title.parallax-effect').css('margin-top','-25px'); 5622 5623 if($('#full_width_portfolio').length > 0){ 5624 $('.parallax_slider_outer.first-section').css('margin-top','93px'); 5625 } 5626 5627 $(window).off('resize.nsHeightUpdate'); 5628 $(window).on('resize.nsHeightUpdate',sliderParallaxUpdateHeight); 5629 } 5630 5631 } 5632 5633 //parallax 5634 function parallaxCheck(){ 5635 5636 $(window).off('scroll.nsParallaxScroll'); 5637 5638 if($('.parallax_slider_outer').length > 0){ 5639 sliderParallaxInit(); 5640 if($('body[data-hhun="1"]').length > 0 && !$('#header-outer[data-remove-fixed="1"]').length > 0) $('#header-outer').addClass('parallax-contained'); 5641 5642 } else if($('.parallax_slider_outer').length > 0 && navigator.userAgent.match(/(Android|iPod|iPhone|iPad|IEMobile|Opera Mini)/)) { 5643 5644 /* 5645 $('.project-title').addClass('parallax-effect').css({ 5646 'top': $headerNavSpace + $adminBarHeight + 'px', 5647 'width' : $('#ajax-content-wrap').width() 5648 }); 5649 5650 $('body:not(".single") .page-header-no-bg, body:not(".single") #page-header-wrap, body:not(".single") #page-header-bg').remove(); 5651 */ 5652 } else { 5653 $('.project-title').css({'top':'0'}); 5654 } 5655 } 5656 parallaxCheck(); 5657 5658 function niceScrollInit(){ 5659 5660 if(!$().niceScroll) { return; } 5661 5662 $("html").niceScroll({ 5663 scrollspeed: 60, 5664 mousescrollstep: 40, 5665 cursorwidth: 15, 5666 cursorborder: 0, 5667 cursorcolor: '#303030',
5668 cursorborderradius: 6, 5669 autohidemode: false, 5670 horizrailenabled: false 5671 }); 5672 5673 if($('#boxed').length == 0){ 5674 $('body, body #header-outer, body #header-secondary-outer, body #search-outer').css('padding-right','16px'); 5675 } 5676 5677 $('html').addClass('no-overflow-y'); 5678 } 5679 5680 //pause video backgrounds if popup video player is started 5681 $('.portfolio-items a.pp:contains(Video), .swiper-container .buttons a.pp').click(function(){ 5682 $('.swiper-slide').each(function(){ 5683 if($(this).find('.video-wrap video').length > 0) { 5684 $(this).find('.video-wrap video').get(0).pause(); 5685 } 5686 }); 5687 }); 5688 5689 5690 //solid button hover effect 5691 $.cssHooks.backgroundColor = { 5692 get: function(elem) { 5693 if (elem.currentStyle) 5694 var bg = elem.currentStyle["backgroundColor"]; 5695 else if (window.getComputedStyle) 5696 var bg = document.defaultView.getComputedStyle(elem, 5697 null).getPropertyValue("background-color"); 5698 if (bg.search("rgb") == -1) 5699 return bg; 5700 else { 5701 bg = bg.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); 5702 function hex(x) { 5703 return ("0" + parseInt(x).toString(16)).slice(-2); 5704 } 5705 if(bg) { 5706 return "#" + hex(bg[1]) + hex(bg[2]) + hex(bg[3]); 5707 } 5708 } 5709 } 5710 } 5711 5712 function shadeColor(color, shade) { 5713 var colorInt = parseInt(color.substring(1),16); 5714 5715 var R = (colorInt & 0xFF0000) >> 16; 5716 var G = (colorInt & 0x00FF00) >> 8; 5717 var B = (colorInt & 0x0000FF) >> 0; 5718 5719 R = R + Math.floor((shade/255)*R); 5720 G = G + Math.floor((shade/255)*G); 5721 B = B + Math.floor((shade/255)*B); 5722 5723 var newColorInt = (R<<16) + (G<<8) + (B); 5724 var newColorStr = "#"+newColorInt.toString(16); 5725 5726 return newColorStr; 5727 } 5728 5729 function sliderbuttonHoverEffect() { 5730 $('body:not([data-button-style*="shadow"]) .swiper-slide').each(function(){ 5731 $(this).find('.solid_color').each(function(){ 5732 var $currentColor = $(this).find('a').css('background-color'); 5733 var $hoverColor = shadeColor($currentColor, -16); 5734 $(this).find('a').hover(function(){ 5735 $(this).attr('style','background-color:'+$hoverColor+'!important;'); 5736 },function(){ 5737 $(this).attr('style',''); 5738 });
5739 }); 5740 }); 5741 } 5742 sliderbuttonHoverEffect(); 5743 5744 5745 5746 5747 5748 5749 //slider down arrow 5750 var logoHeight = parseInt($('#header-outer').attr('data-logo-height')); 5751 //headerPadding/shinkNum moved up before fullscreen calcs 5752 5753 headerPadding = headerPadding - headerPadding/1.8; 5754 5755 $('body').on('click','.slider-down-arrow',function(){ 5756 5757 //within full page row 5758 if($(this).parents('#nectar_fullscreen_rows').length > 0) { 5759 if($('#fp-nav li .active').parent().next('li').length > 0) { 5760 $('#fp-nav li .active').parent().next('li').find('a').trigger('click'); 5761 } 5762 return; 5763 } 5764 5765 var $currentSlider = $(this).parents('.swiper-container'); 5766 var $topDistance = $currentSlider.attr('data-height'); 5767 var $offset = ($currentSlider.parents('.first-section').length == 0 || $('#header-outer[data-transparent-header="true"]').length == 0) ? $currentSlider.offset().top : 0; 5768 var materialSecondary = 0; 5769 5770 if($('body.material').length > 0 && $('#header-secondary-outer').length > 0) { materialSecondary = $('#header-secondary-outer').height(); } 5771 5772 if($('body[data-permanent-transparent="1"]').length == 0) { 5773 //regular 5774 if(!$('body').hasClass('mobile')){ 5775 5776 //hhun 5777 if($('body[data-hhun="1"]').length > 0) { 5778 $('body,html').stop().animate({ 5779 scrollTop: parseInt($topDistance) + $offset + 2 5780 },1000,'easeInOutCubic') 5781 } else { 5782 5783 5784 if( $('#header-outer[data-condense="true"]').length > 0) { 5785 5786 var $headerSpan9 = $('#header-outer[data-format="centered-menu-bottom-bar"] header#top .span_9'); 5787 var $secondaryHeaderHeight = ($('#header-secondary-outer').length > 0) ? $('#header-secondary-outer').height() : 0; 5788 5789 $headerNavSpace = $('#header-outer').height() - (parseInt($headerSpan9.position().top) - parseInt($('#header-outer #logo').css('margin-top')) ) - parseInt($secondaryHeaderHeight); 5790 5791 $('body,html').stop().animate({ 5792 scrollTop: parseInt($topDistance - $headerNavSpace) + 2 5793 },1000,'easeInOutCubic'); 5794 5795 } else { 5796 5797 $('body,html').stop().animate({ 5798 scrollTop: parseInt($topDistance - $('#header-space').height()) + parseInt(shrinkNum) + headerPadding*2 + $offset + 2 + materialSecondary 5799 },1000,'easeInOutCubic'); 5800 5801 } 5802 5803 5804 5805 } 5806 5807 } else { 5808 $scrollPos = ($('#header-outer[data-mobile-fixed="1"]').length > 0) ? parseInt($topDistance) - $('#header-space').height() + parseInt($currentSlider.offset().top) + 2 : parseInt($topDistance) + parseInt($currentSlider.offset().top) + 2; 5809 $('body,html').stop().animate({ 5810 scrollTop: $scrollPos 5811 },1000,'easeInOutCubic') 5812 } 5813 } else { 5814 //permanent transparent 5815 $('body,html').stop().animate({ 5816 scrollTop: parseInt($topDistance) + parseInt($currentSlider.offset().top) + 2 5817 },1000,'easeInOutCubic') 5818 } 5819 return false; 5820 }); 5821 5822 5823 5824 5825 function prettyPhotoInit(){ 5826 5827 var loading_animation = ($('body[data-loading-animation]').attr('data-loading-animation') != 'none') ? $('body').attr('data-loading-animation') : null ; 5828 var ascend_loader = ($('body').hasClass('ascend')) ? '<span class="default-loading-icon spin"></span>' : ''; 5829 var ascend_loader_class = ($('body').hasClass('ascend')) ? 'default_loader ' : ''; 5830 5831 $(".nectar-slider-wrap a[rel^='prettyPhoto']").prettyPhoto({ 5832 theme: 'dark_rounded', 5833 allow_resize: true, 5834 default_width: 690, 5835 opacity: 0.85, 5836 animation_speed: 'normal', 5837 default_height: 388, 5838 social_tools: '', 5839 markup: '<div class="pp_pic_holder"> \ 5840 <div class="ppt"> </div> \ 5841 <div class="pp_details"> \ 5842 <div class="pp_nav"> \ 5843 <a href="#" class="pp_arrow_previous"> <i class="icon-salient-left-arrow-thin icon-default-style"></i> </a> \ 5844 <a href="#" class="pp_arrow_next"> <i class="icon-salient-right-arrow-thin icon-default-style"></i> </a> \ 5845 <p class="currentTextHolder">0/0</p> \ 5846 </div> \ 5847 <a class="pp_close" href="#"><span class="icon-salient-x icon-default-style"></span></a> \ 5848 </div> \ 5849 <div class="pp_content_container"> \ 5850 <div class="pp_left"> \ 5851 <div class="pp_right"> \ 5852 <div class="pp_content"> \ 5853 <div class="pp_fade"> \ 5854 <div class="pp_hoverContainer"> \ 5855 </div> \ 5856 <div id="pp_full_res"></div> \ 5857 <p class="pp_description"></p> \ 5858 </div> \ 5859 </div> \ 5860 </div> \ 5861 </div> \ 5862 </div> \ 5863 </div> \ 5864 <div class="pp_loaderIcon ' + ascend_loader_class + loading_animation+'"> '+ascend_loader+' </div> \ 5865 <div class="pp_overlay"></div>' 5866 }); 5867 5868 } 5869 5870 5871 5872 5873}); 5874
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.