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