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 addPaginationEvents(); 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 autorotateInit(); 2739 parallaxCheck(); 2740 sliderbuttonHoverEffect(); 2741 },150); 2742 2743 2744 } 2745 2746 }); //pronto render 2747 2748 function parallaxSliderPos(){ 2749 if(parallaxSlider.parent().attr('class') == 'wpb_wrapper') { 2750 2751 //give the slider the custom row ID if assigned 2752 if(parallaxSlider.parents('.wpb_row').length > 0) { 2753 if(parallaxSlider.parents('.wpb_row').not('[id^="fws_"]').length > 0) parallaxSlider.attr('id',parallaxSlider.parents('.wpb_row').attr('id')); 2754 } 2755 //remove the row 2756 parallaxSlider.parents('.wpb_row').remove(); 2757 } 2758 //alter the DOM pos 2759 parallaxSlider.insertBefore('.container-wrap'); 2760 2761 } 2762 2763 ////remove parallax if using page header on projects/posts 2764 if($('body.single #page-header-bg').length > 0) $('.parallax_slider_outer').removeClass('parallax_slider_outer').addClass('no-left-margin'); 2765 2766 parallaxSliderPos(); 2767 2768 //initial cals 2769 var $smoothSrollWidth = ($('body').attr('data-smooth-scrolling') == '1') ? 0 : 0; 2770 2771 2772 2773 2774 /*========================= 2775 Begin Nectar Slider Main Construction 2776 ===========================*/ 2777 var $nectarSliders = []; 2778 2779 function nectarSliderMainInit() { 2780 2781 $nectarSliders = []; 2782 2783 //remove boxed full width attr when not needed 2784 $('.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') }); 2785 2786 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){ 2787 $('.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'; 2788 $('.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()); 2789 } 2790 else if( $('.nectar-slider-wrap[data-full-width="true"]').parent().attr('id') == 'portfolio-extra' && $('#full_width_portfolio').length != 0){ 2791 $('.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'; 2792 $('.nectar-slider-wrap[data-full-width="true"] .swiper-container, .nectar-slider-wrap[data-full-width="true"], .parallax_slider_outer.first-section .swiper-container, .parallax_slider_outer.first-section .nectar-slider-wrap').css('width',$(window).width()); 2793 } 2794 else { 2795 var $container = ($('body > #boxed').length == 0) ? '#post-area' : '.container-wrap';
2796 //backup incase only slider is used with nothing else in boxed mode 2797 if($($container).width() == '0' && $('body > #boxed').length > 0) $container = '#boxed'; 2798 $('.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()); 2799 } 2800 2801 //show slider once full width calcs have taken place 2802 $('.nectar-slider-wrap').show(); 2803 2804 //set bg colors / textures after js has made the slider fullwidth 2805 $('.swiper-container, .swiper-slide').css('background-color','#000'); 2806 $('.video-texture').css('opacity','1'); 2807 2808 2809 2810 $('.nectar-slider-wrap').each(function(i){ 2811 var $arrows = $(this).find('.swiper-container').attr('data-arrows'); 2812 var $bullets = $(this).find('.swiper-container').attr('data-bullets'); 2813 var $swipe = $(this).find('.swiper-container').attr('data-desktop-swipe'); 2814 var $loop = $(this).find('.swiper-container').attr('data-loop'); 2815 2816 //swipe 2817 if($swipe == 'true' && $('#'+$(this).attr('id') +' .swiper-wrapper > div').length > 1 && $(this).attr('data-overall_style') != 'directional' ){ 2818 var $grab = 1; 2819 var $desktopSwipe = 1; 2820 } else { 2821 var $grab = 0; 2822 var $desktopSwipe = 0; 2823 } 2824 2825 ////set swipe as true for mobile 2826 if($('body').hasClass('mobile') && $(this).attr('data-overall_style') != 'directional') $desktopSwipe = 1; 2827 2828 //bullets 2829 if($bullets == 'true' && $(this).find('.swiper-wrapper > div').length > 1 && $(this).attr('data-overall_style') != 'directional' ){ 2830 $bullets = '#'+$(this).attr('id')+' .slider-pagination'; 2831 } else { 2832 $bullets = null; 2833 } 2834 2835 //loop 2836 $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; 2837 if($useLoop == false) $(this).find('.swiper-container').attr('data-loop','false'); 2838 2839 //obj config 2840 2841 if($(this).attr('data-transition') == 'fade' && $(this).attr('data-overall_style') != 'directional'){ 2842 2843 var progressVar = true; 2844 var touchRatio = 1.3; 2845 2846 $sliderOptions = { 2847 loop: $useLoop, 2848 grabCursor: $grab, 2849 touchRatio: touchRatio, 2850 speed: 900, 2851 pagination : $bullets, 2852 simulateTouch: $desktopSwipe, 2853 onSlideChangeEnd: captionTransition, 2854 onTouchEnd: captionTransition, 2855 onSlideChangeStart: onChangeStart, 2856 onTouchMove: clearAutoplay, 2857 onFirstInit: nectarInit, 2858 progress: progressVar, 2859 onProgressChange: function(swiper){ 2860 for (var i = 0; i < swiper.slides.length; i++){ 2861 var slide = swiper.slides[i]; 2862 var progress = slide.progress; 2863 var translate = progress*swiper.width; 2864 var opacity = 1 - Math.min(Math.abs(progress),1); 2865 slide.style.opacity = opacity; 2866 swiper.setTransform(slide,'translate3d('+translate+'px,0,0)'); 2867 } 2868 }, 2869 onTouchStart: function(swiper){ 2870 for (var i = 0; i < swiper.slides.length; i++){ 2871 swiper.setTransition(swiper.slides[i], 0); 2872 } 2873 }, 2874 onSetWrapperTransition: function(swiper, speed) { 2875 for (var i = 0; i < swiper.slides.length; i++){ 2876 swiper.setTransition(swiper.slides[i], speed); 2877 } 2878 } 2879 } 2880 2881 2882 } else { 2883 2884 var touchRatio = 0.6; 2885 2886 $sliderOptions = { 2887 loop: $useLoop, 2888 grabCursor: $grab, 2889 touchRatio: touchRatio, 2890 speed: 550, 2891 useCSS3Transforms: false, 2892 pagination : $bullets, 2893 simulateTouch: $desktopSwipe, 2894 onSlideChangeEnd: captionTransition, 2895 onSlideChangeStart: onChangeStart, 2896 onTouchMove: clearAutoplay, 2897 onFirstInit: nectarInit 2898 2899 } 2900 } 2901 2902 2903 $nectarSliders[i] = new Swiper('#'+$(this).attr('id')+' .swiper-container', $sliderOptions); 2904 $nectarSliders[i].swipeReset(); 2905 2906 2907 2908 //webkit looped slider first video fix 2909 if(navigator.userAgent.indexOf('Chrome') > 0) { 2910 if( jQuery(this).find('.swiper-slide:nth-child(2) video').length > 0 && jQuery(this).find('.swiper-container').attr('data-loop') == 'true') { 2911 2912 var webmSource = jQuery(this).find('.swiper-slide:nth-child(2) video source[type="video/webm"]').attr('src') + "?id="+Math.ceil(Math.random()*10000); 2913 var firstVideo = jQuery(this).find('.swiper-slide:nth-child(2) video').get(0); 2914 firstVideo.src = webmSource; 2915 firstVideo.load(); 2916 2917 var webmSource2 = jQuery(this).find('.swiper-slide:last-child video source[type="video/webm"]').attr('src') + "?id="+Math.ceil(Math.random()*10000); 2918 var lastVideo = jQuery(this).find('.swiper-slide:last-child video').get(0); 2919 lastVideo.src = webmSource2; 2920 lastVideo.load(); 2921 } 2922 2923 if( jQuery(this).find('.swiper-slide:eq(-2) video').length > 0 && jQuery(this).find('.swiper-container').attr('data-loop') == 'true') { 2924 2925 var webmSource = jQuery(this).find('.swiper-slide:eq(-2) video source[type="video/webm"]').attr('src') + "?id="+Math.ceil(Math.random()*10000); 2926 var firstVideo = jQuery(this).find('.swiper-slide:eq(-2) video').get(0); 2927 firstVideo.src = webmSource; 2928 firstVideo.load(); 2929 2930 var webmSource2 = jQuery(this).find('.swiper-slide:nth-child(1) video source[type="video/webm"]').attr('src') + "?id="+Math.ceil(Math.random()*10000); 2931 var lastVideo = jQuery(this).find('.swiper-slide:nth-child(1) video').get(0); 2932 lastVideo.src = webmSource2; 2933 lastVideo.load(); 2934 } 2935 } 2936 2937 2938 2939 //Navigation arrows 2940 2941 ////default arrows 2942 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 ){ 2943 2944 $('.slide-count i').transition({ scale: 0.5, opacity: 0 }); 2945 2946 //hover event 2947 $('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(){ 2948 2949 $(this).find('.slide-count i').clearQueue().stop(true,true).delay(110).transition({ scale: 1, opacity: 1 },200); 2950 2951 $(this).stop(true,true).animate({ 2952 'width' : '100px' 2953 },300,'easeOutCubic'); 2954 $(this).find('.slide-count span').clearQueue().stop().delay(100).animate({ 2955 'opacity' : '1' 2956 },225,'easeOutCubic'); 2957 }); 2958 2959 $('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(){ 2960 2961 $('.slide-count i').stop(true,true).transition({ scale: 0, opacity: 0 },200); 2962 2963 $(this).stop().delay(150).animate({ 2964 'width' : '50px' 2965 },300,'easeOutCubic'); 2966 $(this).find('.slide-count span').stop(true,true).animate({ 2967 'opacity' : '0' 2968 },200,'easeOutCubic'); 2969 }); 2970 2971 //add slide counts 2972 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; 2973 2974 //ie8 2975 if($('html').hasClass('no-video')) $slideCount = $('#'+$(this).attr('id') + ' .swiper-wrapper > div').length; 2976 2977 $('#'+$(this).attr('id')+' .slider-prev .slide-count .slide-total').html( $slideCount ); 2978 $('#'+$(this).attr('id')+' .slider-next .slide-count .slide-total').html( $slideCount ); 2979 2980 //prev 2981 2982 function prevArrowAnimation(e) { 2983 2984 if($(this).hasClass('inactive')) return false;
2985 2986 var $that = $(this); 2987 2988 //non looped slider 2989 if($(this).parents('.swiper-container').attr('data-loop') != 'true') { 2990 2991 2992 if( $(this).parents('.swiper-container').find('.swiper-slide-active').index()+1 == 1 && !$('html').hasClass('no-video')){ 2993 2994 //make sure the animation is complete 2995 var $timeout; 2996 2997 clearTimeout($timeout); 2998 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,700); 2999 3000 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') != 'fade') { 3001 3002 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','none').animate({ 3003 'left' : parseInt($(this).parents('.swiper-container').find('.swiper-wrapper').css('left')) + 20 3004 },200,function(){ 3005 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','left,top'); 3006 $nectarSliders[i].swipeReset(); 3007 }); 3008 } 3009 3010 $(this).addClass('inactive'); 3011 3012 } 3013 3014 } 3015 3016 e.preventDefault(); 3017 $nectarSliders[i].swipePrev(); 3018 3019 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') == 'fade') { 3020 var $timeout; 3021 3022 clearTimeout($timeout); 3023 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,800); 3024 3025 $(this).addClass('inactive'); 3026 } 3027 } 3028 3029 $('body').off('click','#'+$(this).attr('id')+' .slider-prev',prevArrowAnimation); 3030 $('body').on('click','#'+$(this).attr('id')+' .slider-prev',prevArrowAnimation); 3031 3032 3033 function nextArrowAnimation(e) { 3034 3035 if($(this).hasClass('inactive')) return false; 3036 3037 var $that = $(this); 3038 var $slideNum = $(this).parents('.swiper-container').find('.swiper-wrapper > div').length; 3039 3040 //non looped slider 3041 if($(this).parents('.swiper-container').attr('data-loop') != 'true') { 3042 3043 if( $(this).parents('.swiper-container').find('.swiper-slide-active').index()+1 == $slideNum && !$('html').hasClass('no-video')) { 3044 3045 //make sure the animation is complete 3046 var $timeout; 3047 3048 clearTimeout($timeout); 3049 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,700); 3050 3051 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') != 'fade') { 3052 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','none').animate({ 3053 'left' : parseInt($(this).parents('.swiper-container').find('.swiper-wrapper').css('left')) - 20 3054 },200,function(){ 3055 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','left,top'); 3056 $nectarSliders[i].swipeReset(); 3057 }); 3058 } 3059 $(this).addClass('inactive'); 3060 } 3061 } 3062 3063 3064 e.preventDefault(); 3065 $nectarSliders[i].swipeNext(); 3066 3067 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') == 'fade') { 3068 var $timeout; 3069 3070 clearTimeout($timeout); 3071 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,800); 3072 3073 $(this).addClass('inactive'); 3074 } 3075 3076 } 3077 3078 //next 3079 $('body').off('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimation); 3080 $('body').on('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimation); 3081 3082 3083 3084 } 3085 ////button with preview on hover 3086 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){ 3087 3088 3089 function prevArrowAnimationWithPreview(e) { 3090 if($(this).hasClass('inactive')) return false;
3091 var $that = $(this); 3092 3093 //make sure the animation is complete 3094 var $timeout; 3095 3096 clearTimeout($timeout); 3097 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,1000); 3098 3099 var $timeout2; 3100 3101 clearTimeout($timeout2); 3102 $timeout2 = setTimeout(function(){ $that.removeClass('stophover'); } ,500); 3103 3104 $(this).addClass('inactive').addClass('stophover'); 3105 3106 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').prev('.swiper-slide').removeClass('prev-high-z-index'); 3107 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().removeClass('prev-move'); 3108 3109 e.preventDefault(); 3110 $nectarSliders[i].swipePrev(); 3111 } 3112 3113 function nextArrowAnimationWithPreview(e) { 3114 if($(this).hasClass('inactive')) return false; 3115 var $that = $(this); 3116 3117 //make sure the animation is complete 3118 var $timeout; 3119 3120 clearTimeout($timeout); 3121 $timeout = setTimeout(function(){ $that.removeClass('inactive'); } ,1000); 3122 3123 var $timeout2; 3124 3125 clearTimeout($timeout2); 3126 $timeout2 = setTimeout(function(){ $that.removeClass('stophover'); } ,500); 3127 3128 $(this).addClass('inactive').addClass('stophover'); 3129 3130 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').next('.swiper-slide').removeClass('high-z-index'); 3131 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().removeClass('next-move'); 3132 3133 e.preventDefault(); 3134 $nectarSliders[i].swipeNext(); 3135 } 3136 3137 function darkSlideNextMouseOver(currentSlider, activeIndex) { 3138 var $indexAdd = ($(currentSlider).find('.swiper-container').attr('data-loop') == 'true') ? 2 : 1; 3139 3140 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + 1) +')').attr('data-color-scheme') == 'dark') { 3141 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +')').attr('data-color-scheme') == 'dark') { 3142 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +') .video-texture').addClass('half-light-overlay').addClass('no-trans'); 3143 } 3144 else { 3145 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +') .video-texture').addClass('light-overlay').addClass('no-trans'); 3146 } 3147 } else { 3148 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +')').attr('data-color-scheme') == 'light') { 3149 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +') .video-texture').addClass('half-dark-overlay').addClass('no-trans'); 3150 } else { 3151 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + $indexAdd) +') .video-texture').addClass('dark-overlay').addClass('no-trans'); 3152 } 3153 } 3154 } 3155 function darkSlidePrevMouseOver(currentSlider, activeIndex) { 3156 var $indexAdd = ($(currentSlider).find('.swiper-container').attr('data-loop') == 'true') ? 0 : 0; 3157 3158 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex + 1) +')').attr('data-color-scheme') == 'dark') { 3159 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +')').attr('data-color-scheme') == 'dark') { 3160 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +') .video-texture').addClass('half-light-overlay').addClass('no-trans'); 3161 } else { 3162 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +') .video-texture').addClass('light-overlay').addClass('no-trans'); 3163 } 3164 } else { 3165 if($(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +')').attr('data-color-scheme') == 'light') { 3166 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +') .video-texture').addClass('half-dark-overlay').addClass('no-trans'); 3167 } else { 3168 $(currentSlider).find('.swiper-slide:nth-child('+ (activeIndex - $indexAdd) +') .video-texture').addClass('dark-overlay').addClass('no-trans'); 3169 } 3170 } 3171 } 3172 3173 3174 $('body').off('click','#'+$(this).attr('id')+' .slider-prev',prevArrowAnimationWithPreview); 3175 $('body').on('click','#'+$(this).attr('id')+' .slider-prev',prevArrowAnimationWithPreview); 3176 3177 //next 3178 $('body').off('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimationWithPreview); 3179 $('body').on('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimationWithPreview); 3180 3181 //hover event 3182 $('body').on('mouseenter','.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-next:not(.stophover)',function(){ 3183 3184 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').next('.swiper-slide').addClass('high-z-index'); 3185 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().addClass('next-move'); 3186 $(this).stop().addClass('next-arrow-move'); 3187 darkSlideNextMouseOver($(this).parents('.nectar-slider-wrap'), $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').index()); 3188 3189 }); 3190 3191 $('body').on('mouseleave','.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-next',function(){ 3192 3193 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').next('.swiper-slide').removeClass('high-z-index'); 3194 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().removeClass('next-move'); 3195 $(this).stop().removeClass('next-arrow-move'); 3196 }); 3197 3198 3199 $('body').on('mouseenter','.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-prev:not(.stophover)',function(){ 3200 3201 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').prev('.swiper-slide').addClass('prev-high-z-index'); 3202 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().addClass('prev-move'); 3203 $(this).stop().addClass('prev-arrow-move'); 3204 darkSlidePrevMouseOver($(this).parents('.nectar-slider-wrap'), $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').index()); 3205 }); 3206 3207 $('body').on('mouseleave','.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-prev',function(){ 3208 3209 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').prev('.swiper-slide').removeClass('prev-high-z-index'); 3210 $(this).parents('.nectar-slider-wrap').find('.swiper-slide-active').stop().removeClass('prev-move'); 3211 $(this).stop().removeClass('prev-arrow-move'); 3212 3213 }); 3214 3215 } else if($('#'+$(this).attr('id') + '.nectar-slider-wrap[data-overall_style="directional"]').length == 1) { 3216 3217 function prevArrowAnimationDirectional(e) { 3218 if($(this).hasClass('inactive') || $(this).parents('.swiper-container').find('.slider-next').hasClass('inactive')) return false;
3219 var $that = $(this); 3220 3221 //cache the widths 3222 if($('#header-outer.transparent').length > 0){ 3223 $('#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(){ 3224 var $extraWidth = ($(this).find('.original .sf-sub-indicator').length > 0) ? 14: 1; 3225 $(this).find('.original').attr('data-w',$(this).find('span.original').width()+$extraWidth); 3226 }); 3227 } 3228 3229 //make sure the animation is complete 3230 var $timeout; 3231 3232 clearTimeout($timeout); 3233 $timeout = setTimeout(function(){ 3234 3235 $that.parents('.swiper-container').removeClass('directional-trans-prev'); 3236 $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); 3237 setTimeout(function(){ 3238 $nectarSliders[i].updateActiveSlide(); 3239 $nectarSliders[i].fixLoop(); 3240 $that.removeClass('inactive'); 3241 },50); 3242 3243 resetContentPos(); 3244 3245 } ,1100); 3246 3247 //call the dark/light slide coloring half way through transition 3248 var $timeout2; 3249 3250 clearTimeout($timeout2); 3251 $timeout2 = setTimeout(function(){ 3252 3253 if($that.parents('.swiper-container').attr('data-loop') != 'true') { 3254 if( $that.parents('.swiper-container').find('.swiper-slide-active').index()+1 != 1) { 3255 onChangeStart($nectarSliders[i]); 3256 } 3257 } 3258 3259 else { 3260 onChangeStart($nectarSliders[i]); 3261 } 3262 3263 } ,100); 3264 3265 //non looped slider 3266 if($(this).parents('.swiper-container').attr('data-loop') != 'true') { 3267 3268 3269 if( $(this).parents('.swiper-container').find('.swiper-slide-active').index()+1 == 1 && !$('html').hasClass('no-video')){ 3270 3271 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') != 'fade') { 3272 3273 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','none').animate({ 3274 'left' : parseInt($(this).parents('.swiper-container').find('.swiper-wrapper').css('left')) + 20 3275 },200,function(){ 3276 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','left,top'); 3277 $nectarSliders[i].swipeReset(); 3278 }); 3279 } 3280 } else { 3281 3282 $(this).parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active .content').children().each(function(i){ 3283 $(this).stop().delay(i*50).transition({ 3284 'x': $that.parents('.swiper-container').width()/2.5 + "px" 3285 }, 950,'easeInOutQuart'); 3286 }); 3287 } 3288 3289 } 3290 3291 $(this).addClass('inactive'); 3292 3293 //move the slide with eaising 3294 $(this).parents('.swiper-container').find('.swiper-wrapper').transition({ 'x': $(this).parents('.swiper-container').width() + "px"},1100,'easeInOutQuart'); 3295 3296 if($(this).parents('.swiper-container').attr('data-loop') == 'true') { 3297 $(this).parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active .content > *').each(function(i){ 3298 $(this).stop().delay(i*50).transition({ 3299 'x': $that.parents('.swiper-container').width()/2.5 + "px" 3300 }, 950,'easeInOutQuart'); 3301 }); 3302 } 3303 3304 $that.parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active').prev('.swiper-slide').find('.content > *').transition({ 3305 'x': '-' + $that.parents('.swiper-container').width() + "px" 3306 }, 0); 3307 3308 setTimeout(function(){ 3309 $that.parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active').prev('.swiper-slide').find('.content > *').each(function(i){ 3310 3311 $(this).stop().delay(i*50).transition({ 3312 'x': "0px" 3313 }, 750,'easeInOutQuart'); 3314 }); 3315 },200); 3316 3317 $that.parents('.swiper-container').addClass('directional-trans-prev'); 3318 3319 e.preventDefault(); 3320 3321 } 3322 3323 function nextArrowAnimationDirectional(e) { 3324 if($(this).hasClass('inactive') || $(this).parents('.swiper-container').find('.slider-prev').hasClass('inactive')) return false;
3325 var $that = $(this); 3326 3327 //cache the widths 3328 if($('#header-outer.transparent').length > 0){ 3329 $('#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(){ 3330 var $extraWidth = ($(this).find('.original .sf-sub-indicator').length > 0) ? 14: 1; 3331 $(this).find('.original').attr('data-w',$(this).find('span.original').width()+$extraWidth); 3332 }); 3333 } 3334 3335 //make sure the animation is complete 3336 var $timeout; 3337 3338 clearTimeout($timeout); 3339 $timeout = setTimeout(function(){ 3340 3341 $that.parents('.swiper-container').removeClass('directional-trans-next'); 3342 $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); 3343 setTimeout(function(){ 3344 $nectarSliders[i].updateActiveSlide(); 3345 $nectarSliders[i].fixLoop(); 3346 $that.removeClass('inactive'); 3347 },50); 3348 resetContentPos(); 3349 3350 } ,1100); 3351 3352 //call the dark/light slide coloring half way through transition 3353 var $timeout2; 3354 3355 clearTimeout($timeout2); 3356 $timeout2 = setTimeout(function(){ 3357 3358 if($that.parents('.swiper-container').attr('data-loop') != 'true') { 3359 if( $that.parents('.swiper-container').find('.swiper-slide-active').index()+1 != $slideNum) { 3360 onChangeStart($nectarSliders[i]); 3361 } 3362 } 3363 3364 else { 3365 onChangeStart($nectarSliders[i]); 3366 } 3367 3368 } ,100); 3369 3370 3371 3372 var $slideNum = $(this).parents('.swiper-container').find('.swiper-wrapper > div').length; 3373 3374 //non looped slider 3375 if($(this).parents('.swiper-container').attr('data-loop') != 'true') { 3376 3377 if( $(this).parents('.swiper-container').find('.swiper-slide-active').index()+1 == $slideNum && !$('html').hasClass('no-video')) { 3378 3379 if( $(this).parents('.nectar-slider-wrap ').attr('data-transition') != 'fade') { 3380 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','none').animate({ 3381 'left' : parseInt($(this).parents('.swiper-container').find('.swiper-wrapper').css('left')) - 20 3382 },200,function(){ 3383 $(this).parents('.swiper-container').find('.swiper-wrapper').stop(true,false).css('transition','left,top'); 3384 $nectarSliders[i].swipeReset(); 3385 }); 3386 } 3387 } else { 3388 $(this).parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active .content > *').each(function(i){ 3389 $(this).stop().delay(i*50).transition({ 3390 'x': '-' + $that.parents('.swiper-container').width()/2.5 + "px" 3391 }, 950,'easeInOutQuart'); 3392 }); 3393 } 3394 } 3395 3396 $(this).addClass('inactive'); 3397 3398 3399 //move the slide with eaising 3400 $(this).parents('.swiper-container').find('.swiper-wrapper').transition({ 'x': - $(this).parents('.swiper-container').width() + "px"},1100,'easeInOutQuart'); 3401 3402 if($(this).parents('.swiper-container').attr('data-loop') == 'true') { 3403 $(this).parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active .content > *').each(function(i){ 3404 $(this).stop().delay(i*50).transition({ 3405 'x': '-' + $that.parents('.swiper-container').width()/2.5 + "px" 3406 }, 950,'easeInOutQuart'); 3407 }); 3408 } 3409 3410 3411 $that.parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active').next('.swiper-slide').find('.content > *').transition({ 3412 'x': $that.parents('.swiper-container').width() + "px" 3413 }, 0); 3414 3415 setTimeout(function(){ 3416 $that.parents('.swiper-container').find('.swiper-wrapper').find('.swiper-slide-active').next('.swiper-slide').find('.content > *').each(function(i){ 3417 3418 $(this).stop().delay(i*50).transition({ 3419 'x': "0px" 3420 }, 750,'easeInOutQuart'); 3421 }); 3422 },200); 3423 3424 3425 $that.parents('.swiper-container').addClass('directional-trans-next'); 3426 3427 e.preventDefault(); 3428 3429 3430 } 3431 3432 3433 //prev 3434 $('body').off('click','#'+$(this).attr('id')+' .slider-prev', prevArrowAnimationDirectional); 3435 $('body').on('click','#'+$(this).attr('id')+' .slider-prev', prevArrowAnimationDirectional); 3436 3437 //next 3438 $('body').off('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimationDirectional); 3439 $('body').on('click','#'+$(this).attr('id')+' .slider-next', nextArrowAnimationDirectional); 3440 3441 function resetContentPos() { 3442 $($nectarSliders[i].container).find('.swiper-slide .content > *').transition({ 'x': '0px' }, 0); 3443 } 3444 3445 } 3446 3447 3448 //Clickable pagination 3449 if($bullets != null && $('#'+$(this).attr('id') +' .swiper-wrapper > div').length > 1 ){ 3450 $('#'+$(this).attr('id')+' .slider-pagination .swiper-pagination-switch').click(function(){ 3451 $nectarSliders[i].swipeTo($(this).index()); 3452 }); 3453 } 3454 }); 3455 3456 3457 3458 } 3459 3460 nectarSliderMainInit(); 3461 3462 3463 3464 function darkFirstSlide(slider){ 3465 if( slider.parents('.parallax_slider_outer').length > 0 && slider.find('.swiper-slide-active[data-color-scheme="dark"]').length > 0 ) { 3466 $('#header-outer').addClass('dark-slide'); 3467 } else { 3468 $('#header-outer').removeClass('dark-slide'); 3469 } 3470 } 3471 3472 function directionalNavColorInit(slider) { 3473 3474 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) { 3475 3476 if( slider.parents('.parallax_slider_outer').length > 0 || slider.parents('.first-section').length > 0 ) { 3477 3478 $('#header-outer').addClass('directional-nav-effect'); 3479 3480 $('#header-outer nav > ul.sf-menu > li > a, #header-outer nav > ul.buttons > li.slide-out-widget-area-toggle a span, #header-outer nav > ul.buttons > li#search-btn a').each(function(){ 3481 var $text = $(this).html(); 3482 $(this).html(' '); 3483 $(this).append('<span class="dark"><span>'+ $text + '</span></span>'); 3484 $(this).append('<span class="light"><span>'+ $text + '</span></span>'); 3485 $(this).append('<span class="original"><span>'+ $text + '</span></span>'); 3486 }); 3487 3488 $('#header-outer .cart-outer .cart-icon-wrap').each(function(){ 3489 $(this).find('> i').remove(); 3490 $(this).append('<span class="dark"><span><i class="icon-salient-cart"></i></span></span>'); 3491 $(this).append('<span class="light"><span><i class="icon-salient-cart"></i></span></span>'); 3492 $(this).append('<span class="original"><span><i class="icon-salient-cart"></i></span></span>'); 3493 }); 3494 setTimeout(function(){ 3495 $('#header-outer .cart-outer .cart-icon-wrap').each(function(){ 3496 $(this).find('> i, > span').remove(); 3497 $(this).append('<span class="dark"><span><i class="icon-salient-cart"></i></span></span>'); 3498 $(this).append('<span class="light"><span><i class="icon-salient-cart"></i></span></span>'); 3499 $(this).append('<span class="original"><span><i class="icon-salient-cart"></i></span></span>'); 3500 }); 3501 },1000); 3502 3503 //logo 3504 if($('header#top #logo img').length > 0) { 3505 $('header#top #logo').append('<span class="dark"><span></span></span>'); 3506 $('header#top #logo').append('<span class="light"><span></span></span>'); 3507 $('header#top #logo').append('<span class="original"><span></span></span>'); 3508 $('header#top #logo img:first').clone().appendTo($('header#top #logo .original span')); 3509 if($('header#top #logo img.starting-logo').length > 0) $('header#top #logo img.starting-logo:not(.dark-version)').clone().appendTo($('header#top #logo .light span')); 3510 if($('header#top #logo img.starting-logo.retina.logo').length > 0) $('header#top #logo img.starting-logo.retina-logo:not(.dark-version)').clone().appendTo($('header#top #logo .light span')); 3511 if($('header#top #logo img.starting-logo.dark-version').length > 0) $('header#top #logo img.starting-logo.dark-version').clone().appendTo($('header#top #logo .dark span')); 3512 if($('header#top #logo img.starting-logo.dark-version.retina.logo').length > 0) $('header#top #logo img.starting-logo.dark-version.retina-logo').clone().appendTo($('header#top #logo .dark span')); 3513 $('header#top #logo > img').remove(); 3514 3515 } else { 3516 var $logoText = $('header#top #logo').text(); 3517 $('header#top #logo').html(' '); 3518 $('header#top #logo').append('<span class="dark"><span>'+$logoText+'</span></span>'); 3519 $('header#top #logo').append('<span class="light"><span>'+$logoText+'</span></span>'); 3520 $('header#top #logo').append('<span class="original"><span>'+$logoText+'</span></span>'); 3521 } 3522 3523 //cache the widths 3524 $('#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(){ 3525 var $extraWidth = ($(this).find('.original .sf-sub-indicator').length > 0) ? 14: 1; 3526 $(this).find('.original').attr('data-w',$(this).find('span.original').width()+$extraWidth); 3527 }); 3528 3529 3530 } 3531 } 3532 } 3533 3534 //initial slide load 3535 var $animating = false;
3536 3537 //responsive slider 3538 var $sliderHeights = []; 3539 var $existingSliders = []; 3540 3541 3542 function initialSlideLoad() { 3543 3544 $animating = false; 3545 3546 $sliderHeights = []; 3547 $existingSliders = []; 3548 3549 //add class to first video slide 3550 $('.swiper-wrapper').each(function(){ 3551 if($(this).find('.swiper-slide:nth-child(2) video').length > 0) $(this).find('.swiper-slide:nth-child(2)').addClass('first_video_slide'); 3552 }); 3553 3554 3555 $('.nectar-slider-wrap').each(function(i){ 3556 3557 3558 var $sliderWrapCount = $('.nectar-slider-wrap').length; 3559 var $that = $(this); 3560 3561 if($(this).find('.swiper-slide-active video').length > 0){ 3562 3563 if(!$('html').hasClass('no-video')){ 3564 $(this).find('.swiper-slide-active:first video').get(0).load(); 3565 $(this).find('.swiper-slide-active:first video').get(0).addEventListener('loadeddata',function(){ 3566 3567 showSliderControls(); 3568 resizeToCover(); 3569 slideContentPos(); 3570 sliderLoadIn($that); 3571 captionTransition($nectarSliders[i]); 3572 darkFirstSlide($that); 3573 3574 }); 3575 3576 } 3577 //ie8 3578 else { 3579 showSliderControls(); 3580 resizeToCover(); 3581 slideContentPos(); 3582 sliderLoadIn($that); 3583 captionTransition($nectarSliders[i]); 3584 darkFirstSlide($that); 3585 } 3586 } 3587 else { 3588 3589 var $firstBg = $(this).find('.swiper-slide-active').attr('style'); 3590 var pattern = /url\(["']?([^'")]+)['"]?\)/; 3591 var match = pattern.exec($firstBg); 3592 3593 if (match) { 3594 3595 var slideImg = new Image(); 3596 slideImg.src = match[1]; 3597 3598 $(slideImg).load(function(){ 3599 showSliderControls(); 3600 resizeToCover(); 3601 slideContentPos(); 3602 sliderLoadIn($that); 3603 captionTransition($nectarSliders[i]); 3604 darkFirstSlide($that); 3605 }); 3606 } 3607 } 3608 3609 //mobile check 3610 if(navigator.userAgent.match(/(Android|iPod|iPhone|iPad|IEMobile|Opera Mini)/)){ 3611 captionTransition($nectarSliders[i]); 3612 showSliderControls(); 3613 resizeToCover(); 3614 slideContentPos(); 3615 darkFirstSlide($that); 3616 3617 setTimeout(function(){ resizeToCover(); slideContentPos(); },400); 3618 3619 $('.nectar-slider-wrap').find('.nectar-slider-loading').fadeOut(800,'easeInOutExpo'); 3620 $('body #header-outer[data-transparent-header="true"] .ns-loading-cover').fadeOut(800,'easeInOutExpo',function(){ 3621 $(this).remove(); 3622 $('.nectar-slider-wrap.first-section .swiper-container .swiper-wrapper .swiper-slide').removeClass('not-loaded'); 3623 }); 3624 3625 $('.nectar-slider-wrap .mobile-video-image').show(); 3626 $('.nectar-slider-wrap .video-wrap').remove(); 3627 } 3628 3629 3630 if($('header#top #logo img').length > 0) { 3631 var logoImg = new Image(); 3632 logoImg.src = $('header#top #logo img:first').attr('src'); 3633 3634 $(logoImg).load(function(){ 3635 directionalNavColorInit($that); 3636 if($that.attr('data-overall_style') == 'directional') { 3637 $that.find('.swiper-container').addClass('directional-trans-current'); 3638 onChangeStart($nectarSliders[i]); 3639 } 3640 }); 3641 } else { 3642 directionalNavColorInit($that); 3643 if($that.attr('data-overall_style') == 'directional') { 3644 $that.find('.swiper-container').addClass('directional-trans-current'); 3645 onChangeStart($nectarSliders[i]); 3646 } 3647 } 3648 3649 }); 3650 3651 3652 ////get slider heights 3653 $('.swiper-container').each(function(i){ 3654 $sliderHeights[i] = parseInt($(this).attr('data-height')); 3655 $existingSliders[i] = $(this).parent().attr('id'); 3656 }); 3657 3658 3659 } 3660 3661 3662 3663 3664 function nectarInit(){ 3665 if(doneVideoInit == true) return; 3666 3667 //videos 3668 /*$('.swiper-slide .slider-video').mediaelementplayer({ 3669 enableKeyboard: false, 3670 iPadUseNativeControls: false, 3671 pauseOtherPlayers: false, 3672 // force iPhone's native controls 3673 iPhoneUseNativeControls: false, 3674 // force Android's native controls 3675 AndroidUseNativeControls: false 3676 });*/ 3677 3678 //if using pp - init it after slide loads 3679 if($().prettyPhoto) prettyPhotoInit(); 3680 3681 3682 doneVideoInit = true; 3683 } 3684 3685 3686 3687 initialSlideLoad(); 3688 3689 3690 3691 3692 3693 //dynamic height sliders 3694 dynamicHeightSliders(); 3695 function dynamicHeightSliders(){ 3696 3697 var $adminBarHeight = ($('#wpadminbar').length > 0) ? 28 : 0 ; 3698 3699 $('.nectar-slider-wrap').each(function(){ 3700
3701 var $heightCalc; 3702 var $minHeight = $('.swiper-container').attr('data-min-height'); 3703 3704 //fullscreen 3705 if($(this).attr('data-fullscreen') == 'true' && $(this).attr('data-full-width') == 'true') { 3706 3707 //first slider on page 3708 if($(this).hasClass('first-section') && $(this).index() == 0){ 3709 3710 //min height 3711 $heightCal = ( ($(window).height() - $(this).offset().top + 2) <= $minHeight ) ? $minHeight : $(window).height() - $(this).offset().top + 2; 3712 $(this).find('.swiper-container').attr('data-height',$heightCal); 3713 3714 } 3715 //first parallax slider on page 3716 else if($(this).parents('.parallax_slider_outer').length > 0 && $(this).parents('#full_width_portfolio').length == 0){ 3717 3718 //min height 3719 $heightCal = ( ($(window).height() - $(this).parent().offset().top + 2) <= $minHeight ) ? $minHeight : $(window).height() - $(this).parent().offset().top + 2; 3720 $(this).find('.swiper-container').attr('data-height',$heightCal); 3721 3722 } 3723 //first portfolio slider on page 3724 else if($(this).parents('#full_width_portfolio').length > 0 && $(this).attr('data-parallax') != 'true' && $(this).index() == 0){ 3725 3726 //min height 3727 $heightCal = ( ($(window).height() - $(this).offset().top + 2) <= $minHeight ) ? $minHeight : $(window).height() - $(this).offset().top + 2; 3728 $(this).find('.swiper-container').attr('data-height',$heightCal); 3729 3730 } 3731 //first portfolio parallax slider on page 3732 else if($(this).parents('#full_width_portfolio').length > 0 && $(this).attr('data-parallax') == 'true'){ 3733 3734 //min height 3735 $heightCal = ( ($(window).height() - $(this).offset().top + 2) <= $minHeight ) ? $minHeight : $(window).height() - $(this).offset().top + 2; 3736 $(this).find('.swiper-container').attr('data-height',$heightCal); 3737 } 3738 //all others 3739 else { 3740 3741 //min height 3742 $heightCal = ( $(window).height() <= $minHeight ) ? $minHeight : $(window).height(); 3743 $(this).find('.swiper-container').attr('data-height',$heightCal); 3744 } 3745 3746 //transparent header loading icon center 3747 if($('#header-outer[data-remove-border="true"]').length == 0) { 3748 if($('body #header-outer[data-transparent-header="true"]').length > 0 3749 && $('.first-section .nectar-slider-wrap[data-fullscreen="true"]').length > 0 3750 && $('#page-header-bg').length == 0) { 3751 3752 $('.first-section .nectar-slider-loading').css({ 3753 'background-image': $loading_bg_storage, 3754 'background-position' : 'center ' + ((($(window).height() /2) + 15) - $('#header-space').height()) +'px' 3755 }); 3756 3757 $('.first-section .nectar-slider-wrap .nectar-slider-loading .loading-icon').css({ 3758 'opacity' : '1', 3759 'height' : $(window).height() - $('#header-space').height() + 'px' 3760 }); 3761 } 3762 } 3763 3764 } 3765 3766 //flexible height 3767 if($(this).attr('data-flexible-height') == 'true' && $(this).attr('data-fullscreen') != 'true') { 3768 3769 //escape if not placed in a flexible ready position 3770 if($(this).parents('.wpb_row.full-width-content').length == 0 && $(this).attr('data-full-width') == 'false') { $(this).attr('data-flexible-height','false'); return false; } 3771 3772 var $minHeight = $('.swiper-container').attr('data-min-height'); 3773 3774 var currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 3775 var $windowWidth = $(window).width(); 3776 var $definedHeight = $sliderHeights[currentKey]; 3777 3778 var dif = $(window).width() / 1600; 3779 3780 if( window.innerWidth > 1000 && $('#boxed').length == 0) { 3781 $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*dif)); 3782 } else { 3783 3784 //column sliders 3785 var $parentCol = ($(this).parents('.wpb_column').length > 0) ? $(this).parents('.wpb_column') : $(this).parents('.col') ; 3786 if($parentCol.length == 0) $parentCol = $('.main-content'); 3787 3788 if(!$parentCol.hasClass('vc_span12') && !$parentCol.hasClass('main-content') && !$parentCol.hasClass('span_12') ) { 3789 3790 var $parentColWidth = sliderColumnDesktopWidth($parentCol); 3791 var $parentColRatio = 1100/$parentColWidth; 3792 3793 //min height 3794 if( $definedHeight*dif <= $minHeight ){ 3795 $(this).find('.swiper-container').attr('data-height',$minHeight); 3796 } else { 3797 $(this).find('.swiper-container').attr('data-height',Math.
3797ceil($parentColRatio*$definedHeight*dif)); 3798 } 3799 3800 } 3801 3802 3803 //boxed 3804 else if($('#boxed').length > 0){ 3805 3806 var dif = $('#boxed').width() / 1600; 3807 3808 if( window.innerWidth > 1300 ) { 3809 3810 if($('body[data-ext-responsive="true"]').length > 0){ 3811 3812 if($(this).has('[data-full-width="boxed-full-width"]')) { 3813 ($('#boxed').width() < 1400) ? $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*dif)) : $(this).find('.swiper-container').attr('data-height',$definedHeight*(1400/1600)); 3814 } 3815 3816 } else { 3817 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*(1200/1600))); 3818 } 3819 3820 } else if( window.innerWidth <= 1300 && window.innerWidth >= 1000 ) { 3821 3822 if($('body[data-ext-responsive="true"]').length > 0){ 3823 $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*dif)); 3824 } else { 3825 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*(980/1600))); 3826 } 3827 3828 } else if( window.innerWidth < 1000 && window.innerWidth > 690 ) { 3829 3830 var $heightCalc = ( $definedHeight*(679/1600) <= $minHeight ) ? $minHeight : $definedHeight*(679/1600); 3831 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height',$minHeight); 3832 3833 } else if( window.innerWidth <= 690 && window.innerWidth >= 470 ) { 3834 3835 var $heightCalc = ( $definedHeight*(410/1600) <= $minHeight ) ? $minHeight : $definedHeight*(410/1600); 3836 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height', $height
3836Calc); 3837 3838 } else if( window.innerWidth < 470 ) { 3839 3840 var $heightCalc = ( $definedHeight*(318/1600) <= $minHeight ) ? $minHeight : $definedHeight*(318/1600); 3841 if($(this).has('[data-full-width="boxed-full-width"]')) $(this).find('.swiper-container').attr('data-height', $heightCalc); 3842 3843 } 3844 3845 } 3846 3847 3848 //regular 3849 else { 3850 3851 //min height 3852 if( $definedHeight*dif <= $minHeight ){ 3853 $(this).find('.swiper-container').attr('data-height',$minHeight); 3854 } else { 3855 $(this).find('.swiper-container').attr('data-height',Math.ceil($definedHeight*dif)); 3856 } 3857 3858 } 3859 3860 } 3861 3862 3863 //transparent header loading icon center 3864 if($('body #header-outer[data-transparent-header="true"]').length > 0 && 3865 $('.first-section .nectar-slider-wrap[data-flexible-height="true"]').length > 0) { 3866 3867 $('.first-section .nectar-slider-loading').css({ 3868 'background-image': $loading_bg_storage, 3869 'background-position' : 'center ' + (((($definedHeight*dif)/2) + 15) - $('#header-space').height()) +'px' 3870 }); 3871 3872 $('.first-section .nectar-slider-wrap .nectar-slider-loading .loading-icon').css({ 3873 'opacity' : '1', 3874 'height' : $definedHeight*dif - $('#header-space').height() + 'px' 3875 }); 3876 } 3877 3878 } 3879 }); 3880 } 3881 3882 if(window.innerWidth > 690){ 3883 $(window).on('resize.dynamicHeights',dynamicHeightSliders); 3884 } else { 3885 3886 //stop mobile browsers from firing the resize event on scroll (when toolbar hides) 3887 var $windowWidth = $(window).width(), $windowHeight = $(window).height(); 3888 var $orientationChange = 0; 3889 3890 window.addEventListener("orientationchange", function() { 3891 $orientationChange = 1; 3892 }); 3893 3894 $(window).resize(function(){ 3895 if( ($(window).width() != $windowWidth && $(window).height != $windowHeight) || $orientationChange == 1){ 3896 dynamicHeightSliders(); 3897 $orientationChange = 0; 3898 } 3899 }); 3900 } 3901 3902 3903 3904 ////helper function 3905 function sliderColumnDesktopWidth(parentCol) { 3906 3907 var $parentColWidth = 1100; 3908 var $columnNumberParsed = $(parentCol).attr('class').match(/\d+/); 3909 3910 if($columnNumberParsed == '2') { $parentColWidth = 170 } 3911 else if($columnNumberParsed == '3') { $parentColWidth = 260 } 3912 else if($columnNumberParsed == '4') { $parentColWidth = 340 } 3913 else if($columnNumberParsed == '6') { $parentColWidth = 530 } 3914 else if($columnNumberParsed == '8') { $parentColWidth = 700 } 3915 else if($columnNumberParsed == '9') { $parentColWidth = 805 } 3916 else if($columnNumberParsed == '10') { $parentColWidth = 916.3 } 3917 else if($columnNumberParsed == '12') { $parentColWidth = 1100 } 3918 3919 return $parentColWidth; 3920 } 3921 3922 3923 sliderSize(); 3924 $(window).resize(sliderSize); 3925 3926 function sliderSize(){ 3927 3928 3929 //check for mobile first 3930 if( window.innerWidth < 1000 && window.innerWidth > 690 ) { 3931 3932 //fullwidth sliders 3933 $('.nectar-slider-wrap[data-full-width="true"]:not([data-fullscreen="true"],[data-flexible-height="true"])').each(function(i){ 3934 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 3935 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/1.4 ) 3936 }); 3937 3938 //column sliders 3939 $('.nectar-slider-wrap[data-full-width="false"]:not([data-flexible-height="true"])').each(function(i){ 3940 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 3941 3942 var $currentSliderHeight = $sliderHeights[currentKey]; 3943 var $parentCol = ($(this).parents('.wpb_column').length > 0) ? $(this).parents('.wpb_column') : $(this).parents('.col'); 3944 3945 //fullwidth but inside the span_9 post area 3946 if($(this).parents('#post-area').length > 0 && $(this).parents('.vc_span12').length > 0) $parentCol = $(this).parents('#post-area'); 3947 3948 //last resort 3949 if($parentCol.length == 0) $parentCol = $('.main-content'); 3950 3951 var $parentColWidth = sliderColumnDesktopWidth($parentCol); 3952 3953 var $aspectRatio = $currentSliderHeight/$parentColWidth; 3954 3955 $(this).find('.swiper-container').attr('data-height',$aspectRatio*$parentCol.width()); 3956 }); 3957 3958 //boxed sliders
3959 $('.nectar-slider-wrap[data-full-width="boxed-full-width"]:not([data-flexible-height="true"])').each(function(i){ 3960 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 3961 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/1.9 ) 3962 }); 3963 } 3964 3965 else if( window.innerWidth <= 690 ) { 3966 3967 //fullwidth sliders 3968 $('.nectar-slider-wrap[data-full-width="true"]:not([data-fullscreen="true"],[data-flexible-height="true"])').each(function(i){ 3969 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 3970 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/2.7 ) 3971 }); 3972 3973 //column sliders 3974 $('.nectar-slider-wrap[data-full-width="false"]:not([data-flexible-height="true"])').each(function(i){ 3975 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 3976 3977 var $currentSliderHeight = $sliderHeights[currentKey]; 3978 var $parentCol = ($(this).parents('.wpb_column').length > 0) ? $(this).parents('.wpb_column') : $(this).parents('.col'); 3979 3980 //fullwidth but inside the span_9 post area 3981 if($(this).parents('#post-area').length > 0 && $(this).parents('.vc_span12').length > 0) $parentCol = $(this).parents('#post-area'); 3982 3983 //last resort 3984 if($parentCol.length == 0) $parentCol = $('.main-content'); 3985 3986 var $parentColWidth = sliderColumnDesktopWidth($parentCol); 3987 3988 var $aspectRatio = $currentSliderHeight/$parentColWidth; 3989 3990 $(this).find('.swiper-container').attr('data-height',$aspectRatio*$parentCol.width()); 3991 }); 3992 3993 //boxed sliders 3994 $('.nectar-slider-wrap[data-full-width="boxed-full-width"]:not([data-flexible-height="true"])').each(function(i){ 3995 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 3996 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/2.9 ) 3997 }); 3998 3999 } 4000 4001 else if( window.innerWidth < 1300 && window.innerWidth >= 1000 ) { 4002 4003 //fullwidth sliders 4004 $('.nectar-slider-wrap[data-full-width="true"]:not([data-fullscreen="true"],[data-flexible-height="true"])').each(function(i){ 4005 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4006 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/1.2 ) 4007 }); 4008 4009 //column sliders 4010 $('.nectar-slider-wrap[data-full-width="false"]:not([data-flexible-height="true"])').each(function(i){ 4011 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4012 4013 var $currentSliderHeight = $sliderHeights[currentKey]; 4014 var $parentCol = ($(this).parents('.wpb_column').length > 0) ? $(this).parents('.wpb_column') : $(this).parents('.col') ; 4015 4016 //fullwidth but inside the span_9 post area 4017 if($(this).parents('#post-area').length > 0 && $(this).parents('.vc_span12').length > 0) $parentCol = $(this).parents('#post-area'); 4018 4019 //last resort 4020 if($parentCol.length == 0) $parentCol = $('.main-content'); 4021 4022 var $parentColWidth = sliderColumnDesktopWidth($parentCol); 4023 4024 var $aspectRatio = $currentSliderHeight/$parentColWidth; 4025 4026 $(this).find('.swiper-container').attr('data-height',$aspectRatio*$parentCol.width()); 4027 4028 }); 4029 4030 //boxed sliders 4031 $('.nectar-slider-wrap[data-full-width="boxed-full-width"]:not([data-flexible-height="true"])').each(function(i){ 4032 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4033 $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]/1.2 ) 4034 }); 4035 4036 } 4037 4038 else { 4039 4040 //fullwidth sliders 4041 $('.nectar-slider-wrap[data-full-width="true"]:not([data-fullscreen="true"],[data-flexible-height="true"])').each(function(i){ 4042 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4043 if($(this).attr('data-flexible-height') != 'true') $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey]) 4044 }); 4045 4046 //boxed sliders 4047 $('.nectar-slider-wrap[data-full-width="false"], .nectar-slider-wrap[data-full-width="boxed-full-width"]:not([data-flexible-height="true"])').each(function(i){ 4048 currentKey = $existingSliders.getKeyByValue($(this).attr('id')); 4049 if($(this).attr('data-flexible-height') != 'true') $(this).find('.swiper-container').attr('data-height',$sliderHeights[currentKey] ) 4050 }); 4051 } 4052 4053 } 4054 4055 4056 //remove transform if single slide 4057 $('.nectar-slider-wrap').each(function(){ 4058 if($(this).find('.swiper-wrapper .swiper-slide').length == 1) { 4059 $(this).find('.swiper-slide').addClass('no-transform'); 4060 $(this).find('.swiper-wrapper').addClass('no-transform'); 4061 } 4062 }); 4063 4064 4065 4066 //slider height 4067 4068 var min_w = 1500; // minimum video width allowed 4069 var vid_w_orig; // original video dimensions 4070 var vid_h_orig; 4071 4072 vid_w_orig = 1280; 4073 vid_h_orig = 720; 4074 var $headerHeight = $('header').height()-1; 4075 4076 function nsSliderContentResize(e){ 4077 resizeToCover(); slideContentPos(); 4078 4079 for(var i=0;
4079 i < $nectarSliders.length; i++){ 4080 4081 //make sure the parent is not hidden 4082 if($($nectarSliders[i].container).parent().attr('data-transition') && $($nectarSliders[i].container).parent().attr('data-transition') == 'fade') { 4083 4084 for(var k=0; k < $nectarSliders[i].slides.length; k++){ 4085 $nectarSliders[i].setTransition($nectarSliders[i].slides[k], 0); 4086 } 4087 4088 $('.swiper-wrapper').stop(true,true).css('transition-duration','0s'); 4089 4090 if($('.nectar-slider-loading').css('display') == 'none') { 4091 $('.swiper-wrapper .swiper-slide.swiper-slide-active .content > *').css({ 4092 'opacity': 1, 4093 'padding-top' : 0 4094 }); 4095 } 4096 } 4097 4098 $nectarSliders[i].reInit(); 4099 $nectarSliders[i].resizeFix(); 4100 4101 } 4102 4103 } 4104 4105 // $(window).off('resize.nsSliderContent'); 4106 $(window).on('resize.nsSliderContent',nsSliderContentResize); 4107 if(!$('body').hasClass('ajax-loaded')) $(window).trigger('resize'); 4108 4109 function resizeToCover() { 4110 $('.nectar-slider-wrap').each(function(i){ 4111 4112 4113 if( $(this).css('visibility') != 'hidden') { 4114 4115 //width resize 4116 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){ 4117 $('.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'; 4118 $('.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()); 4119 } 4120 else if( $('.nectar-slider-wrap[data-full-width="true"]').parent().attr('id') == 'portfolio-extra' && $('#full_width_portfolio').length != 0){ 4121 $('.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'; 4122 $('.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()); 4123 } 4124 else { 4125 var $container = ($('body > #boxed').length == 0) ? '#post-area' : '.container-wrap'; 4126 //backup incase only slider is used with nothing else in boxed mode 4127 if($($container).width() == '0' && $('body > #boxed').length > 0) $container = '#boxed'; 4128 $('.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()); 4129 } 4130 4131 var $sliderHeight = parseInt($(this).find('.swiper-container').attr('data-height')); 4132 var isFullWidthCompatible = ($(this).attr('data-full-width') == 'true') ? 'true' : 'false'; 4133 4134 if($(this).parent().attr('id') == 'portfolio-extra' && $('#full_width_portfolio').length == 0 || $(this).parents('#post-area').length > 0) { isFullWidthCompatible = 'false'; }; 4135 4136 var $sliderWidth = (isFullWidthCompatible == 'true') ? $(window).width()-$smoothSrollWidth : $(this).width(); 4137 4138 $(this).parents('.parallax_slider_outer').css('height',$sliderHeight); 4139 $(this).css('height',$sliderHeight); 4140 $(this).find('.swiper-container, .swiper-slide').css({'height':$sliderHeight+2, 'top':'-1px'}); 4141 $(this).find('.swiper-container').css('width', $sliderWidth); 4142 //$(this).find('.swiper-slide').css('width', $sliderWidth); 4143 4144 // set the video viewport to the window size 4145 $(this).find('.video-wrap').width($sliderWidth+2); 4146 $(this).find('.video-wrap').height($sliderHeight+2); 4147 4148 // use largest scale factor of horizontal/vertical 4149 var scale_h = $sliderWidth / vid_w_orig; 4150 var scale_v = ($sliderHeight - $headerHeight) / vid_h_orig; 4151 var scale = scale_h > scale_v ? scale_h : scale_v; 4152 4153 //update minium width to never allow excess space 4154 min_w = 1280/720 * ($sliderHeight+20); 4155 4156 // don't allow scaled width < minimum video width
4157 if (scale * vid_w_orig < min_w) {scale = min_w / vid_w_orig;} 4158 4159 // now scale the video 4160 $(this).find('video, .mejs-overlay, .mejs-poster').width(Math.ceil(scale * vid_w_orig +2)); 4161 $(this).find('video, .mejs-overlay, .mejs-poster').height(Math.ceil(scale * vid_h_orig +2)); 4162 4163 // and center it by scrolling the video viewport 4164 $(this).find('.video-wrap').scrollLeft(($(this).find('video').width() - $sliderWidth) / 2); 4165 4166 $(this).find('.swiper-slide').each(function(){ 4167 4168 //video alignment 4169 if($(this).find('.video-wrap').length > 0){ 4170 //align middle 4171 if($(this).attr('data-bg-alignment') == 'center'){ 4172 $(this).find('.video-wrap, .mejs-overlay, .mejs-poster').scrollTop(($(this).find('video').height() - ($sliderHeight)) / 2); 4173 } 4174 //align bottom 4175 else if($(this).attr('data-bg-alignment') == 'bottom'){ 4176 $(this).find('.video-wrap').scrollTop(($(this).find('video').height() - ($sliderHeight+2))); 4177 } 4178 //align top 4179 else { 4180 $(this).find('.video-wrap').scrollTop(0); 4181 } 4182 } 4183 4184 }); 4185 4186 } //if visible 4187 4188 }); 4189 }; 4190 4191 ////initial call 4192 resizeToCover(); 4193 4194 4195 //caption transitions 4196 function captionTransition(obj){ 4197 4198 resizeToCover(); 4199 4200 var $containerClass; 4201 4202 (typeof obj == 'undefined') ? $containerClass = 'div[id^=ns-id-]' : $containerClass = '#'+$(obj.container).parents('.nectar-slider-wrap').attr('id'); ; 4203 4204 4205 var fromLeft = Math.abs(parseInt($($containerClass+' .swiper-wrapper').css('left'))); 4206 var currentSlide = Math.round(fromLeft/$($containerClass+' .swiper-slide').width()); 4207 var $slideNum = $($containerClass+':first .swiper-wrapper > div').length; 4208 4209 if($($containerClass).attr('data-transition') == 'fade') currentSlide = $($containerClass + ' .swiper-slide-active').index(); 4210 4211 if(isNaN(currentSlide)) currentSlide = 0; 4212 4213 //make sure user isn't going back to same slide 4214 if( $($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').find('.content *').length > 0 ) { 4215 if($($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').find('.content *').css('opacity') != '0' && !$('html').hasClass('no-video')) { 4216 //play video if there's one 4217 playVideoBG(currentSlide + 1, $containerClass); 4218 4219 if(!$($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').hasClass('autorotate-shown')) { 4220 return false; 4221 } else { 4222 $($containerClass+' .swiper-slide').removeClass('autorotate-shown'); 4223 } 4224 4225 } 4226 } 4227 4228 //hide all 4229 if(!$('html').hasClass('no-video')) { 4230 $($containerClass+' .swiper-slide .content p, '+$containerClass+' .swiper-slide .content h2, '+$containerClass+' .swiper-slide .content .buttons').stop(true,true).animate({'opacity':0, 'padding-top': 25},1); 4231 } 4232 4233 //pause video if there's one 4234 $($containerClass+' .swiper-slide').each(function(){ 4235 if($(this).find('.video-wrap video').length > 0 && !$('html').hasClass('no-video')) { $(this).find('.video-wrap video').get(0).pause(); } 4236 }); 4237 $($containerClass+' .swiper-slide:not(".swiper-slide-active")').each(function(){ 4238 if($(this).find('.video-wrap video').length > 0) { 4239 4240 if($(this).find('.video-wrap video').get(0).currentTime != 0 ) $(this).find('.video-wrap video').get(0).currentTime = 0; 4241 } 4242 }); 4243 4244 4245 4246 if($($containerClass +' .swiper-container').attr('data-loop') == 'true') { 4247 4248 4249 //webkit video fix 4250 if( $($containerClass+' .swiper-slide-active').index()+1 == 2 && $($containerClass+' .swiper-slide-active video').length > 0 && !$('html').hasClass('no-video')) { 4251 4252 $($containerClass+' .swiper-slide:last-child').find('.video-wrap video').get(0).play(); 4253 $($containerClass+' .swiper-slide:last-child').find('.video-wrap video').get(0).pause(); 4254 } 4255 if( $($containerClass+' .swiper-slide-active').index()+1 == $slideNum-1 && $($containerClass+' .swiper-slide-active video').length > 0 && !$('html').hasClass('no-video')) { 4256 4257 $($containerClass+' .swiper-slide:first-child').find('.video-wrap video').get(0).play(); 4258 $($containerClass+' .swiper-slide:first-child').find('.video-wrap video').get(0).pause(); 4259 } 4260 if($($containerClass+' .swiper-slide-active').index()+1 != 2 && $($containerClass+' .swiper-slide:nth-child(2) video').length > 0 && !$('html').hasClass('no-video')) { 4261 4262 $($containerClass+' .swiper-slide:last-child').find('.video-wrap video').get(0).play(); 4263 $($containerClass+' .swiper-slide:last-child').find('.video-wrap video').get(0).pause(); 4264 4265 $($containerClass+' .swiper-slide:nth-child(2) video').get(0).pause(); 4266 if($($containerClass+' .swiper-slide:nth-child(2) video').get(0).currentTime != 0 ) $($containerClass+' .swiper-slide:nth-child(2) video').get(0).currentTime = 0; 4267 } 4268 4269 4270 //also show duplicate slide if applicable 4271 if($($containerClass).attr('data-overall_style') != 'directional') { 4272 ////first 4273 if( $($containerClass+' .swiper-slide-active').index()+1 == $slideNum-1 ){ 4274 4275 $($containerClass+' .swiper-slide:nth-child(1)').find('.content').children().each(function(i){ 4276 4277 $(this).stop().delay(i*90).animate({ 4278 'opacity' : 1, 4279 'padding-top' : 0 4280 },{ duration: 400, easing: 'easeOutQuad'}); 4281 }); 4282 4283 } 4284 4285 ////last 4286 if( $($containerClass+' .swiper-slide-active').index()+1 == 2 ){ 4287 $($containerClass+' .swiper-slide:nth-child('+ ($slideNum) + ')').find('.content').children().each(function(i){ 4288 $(this).stop().delay(i*90).animate({ 4289 'opacity' : 1, 4290 'padding-top' : 0 4291 },{ duration: 400, easing: 'easeOutQuad'}); 4292 }); 4293 4294 } 4295 4296 4297 //looped last going to first 4298 if( $($containerClass+' .swiper-slide-active').index()+1 == $slideNum ){ 4299 4300 $($containerClass+' .swiper-slide:nth-child(2)').find('.content').children().each(function(i){ 4301 4302 $(this).stop().delay(i*90).animate({ 4303 'opacity' : 1, 4304 'padding-top' : 0 4305 },{ duration: 400, easing: 'easeOutQuad'}); 4306 }); 4307 } 4308 4309 //looped first going to last 4310 if( $($containerClass+' .swiper-slide-active').index()+1 == 1 ){ 4311 4312 $($containerClass+' .swiper-slide:eq(-2)').find('.content').children().each(function(i){ 4313 4314 $(this).stop().delay(i*90).animate({ 4315 'opacity' : 1, 4316 'padding-top' : 0 4317 },{ duration: 400, easing: 'easeOutQuad'}); 4318 }); 4319 } 4320 } 4321 4322 4323 }//if using loop 4324 4325 //play video if there's one 4326 playVideoBG(currentSlide + 1, $containerClass); 4327 4328 4329 //fadeIn active slide 4330 if($($containerClass).attr('data-overall_style') != 'directional') { 4331 $($containerClass+' .swiper-slide:nth-child('+ (currentSlide + 1) +')').find('.content').children().each(function(i){ 4332 4333 $(this).stop().delay(i*90).animate({ 4334 'opacity' : 1, 4335 'padding-top' : 0 4336 },{ duration: 400, easing: 'easeOutQuad'}); 4337 }); 4338 } 4339 4340 4341 4342 4343 4344 4345 $captionTrans++;
4346 if($captionTrans == $('.swiper-wrapper').length) { $('div.first_video_slide').addClass('nulled') } 4347 4348 4349 //slider arrows with preview effect 4350 setTimeout(function(){ 4351 4352 if($('.slider-next').hasClass('next-arrow-move')) { 4353 $('.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-next').trigger('mouseenter'); 4354 } else if($('.slider-prev').hasClass('prev-arrow-move')) { 4355 $('.nectar-slider-wrap[data-button-styling="btn_with_preview"] .swiper-container .slider-prev').trigger('mouseenter'); 4356 } 4357 4358 4359 if($($containerClass).attr('data-button-styling') == 'btn_with_preview') { 4360 $($containerClass+' .swiper-slide').addClass('prev-high-z-index-static'); 4361 $($containerClass+' .swiper-slide.swiper-slide-active').removeClass('prev-high-z-index-static'); 4362 } 4363 4364 },175); 4365 4366 4367 4368 4369 } 4370 4371 //used in caption transition 4372 function playVideoBG(nthChild, containerClass){ 4373 4374 if($(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.video-wrap video').length > 0){ 4375 4376 if(!$('html').hasClass('no-video')) $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.video-wrap video').get(0).play(); 4377 4378 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'); } 4379 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'); 4380 4381 var $that = $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-overlay.mejs-overlay-play'); 4382 var $that2 = $(containerClass+' .swiper-slide:nth-child('+ (nthChild) +')').find('.mejs-poster'); 4383 4384 if($that.hasClass('playing') && $that.hasClass('mobile-played')) { 4385 setTimeout(function(){ $that.addClass('behind-buttons'); $that2.addClass('behind-buttons');},200); 4386 } else { 4387 $that.removeClass('behind-buttons'); $that2.removeClass('behind-buttons'); 4388 } 4389 } 4390 4391 } 4392 4393 4394 var $startingSlide = null; 4395 4396 4397 4398 function slideContentPos(){ 4399 4400 $('.swiper-wrapper').each(function(){ 4401 4402 //etxra space if first slider in section 4403 var $extraHeight = ($(this).parents('.nectar-slider-wrap').hasClass('first-section') || $(this).parents('.parallax_slider_outer').hasClass('first-section')) ? 30 : 0; 4404 4405 var $sliderHeight = parseInt($(this).parents('.swiper-container').attr('data-height')); 4406 4407 var $transparentHeader = ($('#header-outer[data-transparent-header="true"]').length > 0) ? $('#header-space').height() : 0 ; 4408 if($(this).parents('.first-section').length == 0 || window.innerWidth < 1000) { 4409 $transparentHeader = null; 4410 } else if($transparentHeader != 0 && $('#header-outer[data-remove-border="true"]').length > 0){ 4411 $transparentHeader = $transparentHeader/2 4412 } 4413 4414 $(this).find('.swiper-slide').each(function(){ 4415 4416 var $contentHeight = $(this).find('.content').height(); 4417 var $contentItems = $(this).find('.content > *').length; 4418 4419 $contentHeight2 = 0; 4420 $(this).find('.content > *').each(function(){ 4421 $contentHeight2 += $(this).height() + parseInt($(this).css('margin-bottom')) + parseInt($(this).css('padding-bottom')); 4422 }); 4423 4424 if($(this).find('.content > *').css('padding-top') == '25px') $contentHeight = $contentHeight - 25*$contentItems; 4425 4426 if($(this).attr('data-y-pos') == 'top'){ 4427 var $topHeight = ($contentHeight2/2) < ((($sliderHeight+ $transparentHeader)/4) - 30) ? ((($sliderHeight+ $transparentHeader)/4) - ($contentHeight2/2)) + 20 : ($sliderHeight+ $transparentHeader)/8; 4428 $(this).find('.content').css('top', $topHeight + 'px'); 4429 } 4430 else if($(this).attr('data-y-pos') == 'middle') { 4431 $(this).find('.content').css('top', ((($sliderHeight + $transparentHeader)/2) - ($contentHeight2/2)) + 'px'); 4432 } 4433 else { 4434 if($contentHeight2 > 180) { 4435 $(this).find('.content').css('top', ((($sliderHeight + $transparentHeader)/2) - ($contentHeight2/10)) +'px'); 4436 } else { 4437 $(this).find('.content').css('top', ((($sliderHeight + $transparentHeader)/2) + ($contentHeight2/9)) + 'px'); 4438 } 4439 } 4440 }); 4441 }); 4442 } 4443 4444 4445 4446 function showSliderControls() { 4447 $('.swiper-container .slider-prev, .swiper-container .slider-next, .slider-pagination').animate({'opacity':1},550,'easeOutSine'); 4448 } 4449 4450 4451 var sliderLength = $('.swiper-container').length; 4452 var sliderLoadedLength = 0; 4453 4454 function sliderLoadIn(slider) { 4455 4456 slider.find('.nectar-slider-loading').fadeOut(800,'easeInOutExpo'); 4457 $('body #header-outer[data-transparent-header="true"] .ns-loading-cover').fadeOut(800,'easeInOutExpo',function(){ 4458 $(this).remove(); 4459 $('.nectar-slider-wrap.first-section .swiper-container .swiper-wrapper .swiper-slide').removeClass('not-loaded'); 4460 }); 4461 4462 slider.find('span.ie-fix').remove(); 4463 4464 ///make sure to init smooth scrolling after slider height exists 4465 var $smoothActive = $('body').attr('data-smooth-scrolling'); 4466 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(); } 4467 4468 //check for sliders in tabbed 4469 sliderLoadedLength++; 4470 if($('.tabbed').find('.swiper-container').length > 0 && sliderLoadedLength == sliderLength) { 4471 setTimeout(function(){ $('.tabbed > ul li:first-child a').click(); }, 200); 4472 } 4473 4474 } 4475 4476 4477 //play video user is hovering over 4478 $('body').on('mouseover','.swiper-slide', function(){ 4479 if($(this).find('video').length > 0 && $(this).find('video').get(0).paused == true && $animating == false){ 4480 $(this).find('video').get(0).play(); 4481 } 4482 }); 4483 4484 4485 //mobile play event 4486 $('body').on('click', '.mejs-overlay.mejs-overlay-play',function(){ 4487 $(this).toggleClass('playing'); 4488 $(this).addClass('mobile-played'); 4489 4490 $(this).parent().find('.mejs-poster').toggleClass('playing'); 4491 $(this).parent().find('.mejs-poster').addClass('mobile-played'); 4492 4493 var $that = $(this); 4494 var $that2 = $(this).parent().find('.mejs-poster'); 4495 4496 if($(this).hasClass('playing') && $(this).hasClass('mobile-played')) { 4497 4498 setTimeout(function(){ $that.addClass('behind-buttons'); $that2.addClass('behind-buttons'); },200); 4499 } else { 4500 setTimeout(function(){ $that.removeClass('behind-buttons'); $that2.removeClass('behind-buttons'); },1); 4501 } 4502 }); 4503 4504 4505 //autoplay 4506 var autoplay = []; 4507 var sliderAutoplayCount = -1; 4508 var $sliderHeight = parseInt($(this).find('.swiper-container').attr('data-height')); 4509 var portfolioHeaderHeight = ($('.project-title.parallax-effect').length > 0) ? 100 : 0; 4510 4511 function autorotateInit() { 4512 $('.nectar-slider-wrap').each(function(i){ 4513 var $autoplayVal = $(this).attr('data-autorotate'); 4514 var $that = $(this); 4515 var $sliderNum = i; 4516 4517 if(typeof $autoplayVal !='undefined' && $autoplayVal.length != '0' && parseInt($autoplayVal)) { 4518 nectarSlideRotateInit($that,$autoplayVal,$sliderNum); 4519 } 4520 4521 }); 4522 } 4523 autorotateInit(); 4524 4525 function nectarSlideRotateInit(slider,interval,sliderNum){ 4526 4527 autoplay[sliderAutoplayCount] = setInterval(function(){ nectarSlideRotate(slider, sliderNum); } ,interval); 4528 4529 $('#'+slider.attr('id')).attr('autoplay-id',sliderAutoplayCount); 4530 4531 $('#'+slider.attr('id') + ' a.slider-prev, #'+slider.attr('id') + ' a.slider-next, #' + slider.attr('id') + ' .slider-pagination span').click(function(e){ 4532 if(typeof e.clientY != 'undefined'){ 4533 clearInterval(autoplay[$('#'+slider.attr('id')).attr('autoplay-id')]); 4534 4535 //class for directional 4536 if( $('#'+slider.attr('id')).parent().hasClass('parallax_slider_outer') && $('#'+slider.attr('id')).attr('data-overall_style') == 'directional' ) { 4537 $('#'+slider.attr('id')).parent().addClass('user-stopped'); 4538 } 4539 } 4540 }); 4541 4542 sliderAutoplayCount++; 4543 } 4544 4545 function nectarSlideRotate(slider, sliderNum){ 4546 4547 //non looped 4548 if($nectarSliders[sliderNum].activeIndex + 1 < $(slider).find('.swiper-wrapper > div.swiper-slide').length){ 4549 4550 //btn with preview hover effect clear 4551 if($(slider).attr('data-button-styling') == 'btn_with_preview') { 4552 $(slider).find('.swiper-slide').removeClass('high-z-index').removeClass('prev-high-z-index'); 4553 $(slider).find('.swiper-slide').removeClass('next-move').removeClass('prev-move'); 4554 } 4555 4556 //classic style 4557 if($(slider).attr('data-overall_style') != 'directional') { 4558 $nectarSliders[sliderNum].swipeNext(); 4559 } else { 4560 //directional based 4561 $($nectarSliders[sliderNum].container).find('.slider-next').trigger('click'); 4562 } 4563 4564 } else { 4565 //looped sliders 4566 if($(slider).find('.swiper-container').is("[data-loop]") && $(slider).find('.swiper-container').attr('data-loop') == 'true') { 4567 4568 //classic style 4569 if($(slider).attr('data-overall_style') != 'directional') { 4570 $nectarSliders[sliderNum].swipeNext(); 4571 } else { 4572 //directional based 4573 $($nectarSliders[sliderNum].container).find('.slider-next').trigger('click'); 4574 } 4575 4576 } 4577 //regular sliders 4578 else { 4579 4580 if($(slider).attr('data-overall_style') != 'directional') { 4581 $nectarSliders[sliderNum].swipeTo(0,800); 4582 } else { 4583 $(slider).find('.swiper-container').addClass('directional-trans-prev'); 4584 $nectarSliders[sliderNum].swipeTo(0,800); 4585 //call the dark/light slide coloring half way through transition 4586 var $timeout2; 4587 clearTimeout($timeout2); 4588 $timeout2 = setTimeout(function(){ onChangeStart($nectarSliders[sliderNum]); } ,100); 4589 } 4590 4591 } 4592 } 4593 } 4594 4595 function clearAutoplay(e){ 4596 var $autoplayVal = $('#'+$(e.container).parent().attr('id')).attr('data-autorotate'); 4597 4598 if(typeof $autoplayVal !='undefined' && $autoplayVal.length != '0' && parseInt($autoplayVal)) { 4599 4600 clearInterval(autoplay[$('#'+$(e.container).parent().attr('id')).attr('autoplay-id')]); 4601 } 4602 } 4603 4604 var animationQueue = null; 4605 4606 function onChangeStart(e){ 4607 4608 //cache slider obj 4609 var $obj = e; 4610 4611 $animating = true; 4612 4613 var $slideNum = $($obj.container).find('.swiper-wrapper > div').length; 4614 4615 //one for effects and one for basic slide arrow count 4616 $activeIndex = ($($obj.container).attr('data-loop') == 'true') ? $obj.activeIndex + 1: $obj.activeIndex+1; 4617 $activeIndex2 = ($($obj.container).attr('data-loop') == 'true') ? $obj.activeIndex: $obj.activeIndex+1; 4618 4619 //dark slide header 4620 if($($obj.container).parent().attr('data-overall_style') != 'directional') { 4621 if( $($obj.container).parents('.parallax_slider_outer').length > 0 && $($obj.container).find('.swiper-slide-active[data-color-scheme="dark"]').length > 0 || 4622 $($obj.container).parents('.first-section').length > 0 && $($obj.container).find('.swiper-slide-active[data-color-scheme="dark"]').length > 0) { 4623 $('#header-outer').addClass('dark-slide'); 4624 } else { 4625 $('#header-outer').removeClass('dark-slide'); 4626 } 4627 } 4628 ////directional trans - will be called early so need to adjust the slide being looked for 4629 else { 4630 if($($obj.container).hasClass('directional-trans-next')) { 4631 4632 if( $($obj.container).parents('.parallax_slider_outer').length > 0 && $($obj.container).find('.swiper-slide-active').next('.swiper-slide').is('[data-color-scheme="dark"]') || 4633 $($obj.container).parents('.first-section').length > 0 && $($obj.container).find('.swiper-slide-active').next('.swiper-slide').is('[data-color-scheme="dark"]') ) { 4634 $('#header-outer').addClass('dark-slide'); 4635 //nav items animation 4636 if($('body.mobile').length == 0) { 4637 $('#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(){ 4638 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 4639 4640 $(this).find('span.dark').css('display','inline').transition({'margin-left': '0'},0).transition({ 'width' : $itemWidth }, 325, 'easeInOutQuart'); 4641 $(this).find('span.dark > span').transition({'margin-left': '0'},0); 4642 $(this).find('span.light').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 4643 $(this).find('span.light > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 4644 }); 4645 } 4646 } else { 4647 $('#header-outer').removeClass('dark-slide'); 4648 //nav items animation 4649 if($('body.mobile').length == 0) { 4650 $('#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(){ 4651 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 4652 4653 $(this).find('span.light').css('display','inline').transition({'margin-left': '0'},0).css('display','inline').transition({'width' : $itemWidth }, 325, 'easeInOutQuart'); 4654 $(this).find('span.light > span').transition({'margin-left': '0'},0); 4655 $(this).find('span.dark').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 4656 $(this).find('span.dark > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 4657 }); 4658 } 4659 } 4660 } 4661 4662 else if($($obj.container).hasClass('directional-trans-prev')) { 4663 if( $($obj.container).parents('.parallax_slider_outer').length > 0 && $($obj.container).find('.swiper-slide-active').prev('.swiper-slide').is('[data-color-scheme="dark"]') || 4664 $($obj.container).parents('.first-section').length > 0 && $($obj.container).find('.swiper-slide-active').prev('.swiper-slide').is('[data-color-scheme="dark"]') ) { 4665 $('#header-outer').addClass('dark-slide'); 4666 //nav items animation 4667 if($('body.mobile').length == 0) { 4668 $('#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(){ 4669 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 4670 4671 $(this).find('span.dark').css('display','inline').transition({'margin-left': '0'},0).transition({ 'width' : $itemWidth }, 325, 'easeInOutQuart'); 4672 $(this).find('span.dark > span').transition({'margin-left': '0'},0); 4673 $(this).f
4673ind('span.light').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 4674 $(this).find('span.light > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 4675 }); 4676 } 4677 } else { 4678 $('#header-outer').removeClass('dark-slide'); 4679 //nav items animation 4680 if($('body.mobile').length == 0) { 4681 $('#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(){ 4682 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 4683 4684 $(this).find('span.light').css('display','inline').transition({'margin-left': '0'},0).transition({'width' : $itemWidth }, 325, 'easeInOutQuart'); 4685 $(this).find('span.light > span').transition({'margin-left': '0'},0); 4686 $(this).find('span.dark').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 4687 $(this).find('span.dark > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 4688 }); 4689 } 4690 } 4691 } 4692 4693 else if($($obj.container).hasClass('directional-trans-current')) { 4694 if( $($obj.container).parents('.parallax_slider_outer').length > 0 && $($obj.container).find('.swiper-slide-active').is('[data-color-scheme="dark"]') || 4695 $($obj.container).parents('.first-section').length > 0 && $($obj.container).find('.swiper-slide-active').is('[data-color-scheme="dark"]') ) { 4696 $('#header-outer').addClass('dark-slide'); 4697 //nav items animation 4698 if($('body.mobile').length == 0) { 4699 $('#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(){ 4700 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 4701 4702 $(this).find('span.dark').css('display','inline').transition({'margin-left': '0'},0).transition({ 'width' : $itemWidth }, 325, 'easeInOutQuart'); 4703 $(this).find('span.dark > span').transition({'margin-left': '0'},0); 4704 $(this).find('span.light').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 4705 $(this).find('span.light > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 4706 }); 4707 } 4708 } else { 4709 $('#header-outer').removeClass('dark-slide'); 4710 //nav items animation 4711 if($('body.mobile').length == 0) { 4712 $('#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(){ 4713 var $itemWidth = parseInt($(this).find('span.original').attr('data-w')); 4714 4715 $(this).find('span.light').css('display','inline').transition({'margin-left': '0'},0).transition({'width' : $itemWidth }, 325, 'easeInOutQuart'); 4716 $(this).find('span.light > span').transition({'margin-left': '0'},0); 4717 $(this).find('span.dark').css('display','inline-block').transition({'margin-left': $itemWidth, 'width' : '0' }, 325, 'easeInOutQuart'); 4718 $(this).find('span.dark > span').transition({'margin-left': '-' + ($itemWidth) + 'px', 'width' : $itemWidth }, 325, 'easeInOutQuart'); 4719 }); 4720 } 4721 } 4722 } 4723 4724 4725 } 4726 4727 //light and dark controls 4728 if($($obj.container).parent().attr('data-overall_style') != 'directional') { 4729 if($($obj.container).find('.swiper-slide:nth-child('+ ($activeIndex) +')').attr('data-color-scheme') == 'dar
4729k') { 4730 $($obj.container).find('.slider-pagination').addClass('dark-cs'); 4731 $($obj.container).find('.slider-prev, .slider-next').addClass('dark-cs'); 4732 } else { 4733 $($obj.container).find('.slider-pagination').removeClass('dark-cs'); 4734 $($obj.container).find('.slider-prev, .slider-next').removeClass('dark-cs'); 4735 } 4736 } 4737 ////directional trans - will be called early so need to adjust the slide being looked for 4738 else { 4739 if($($obj.container).hasClass('directional-trans-next')) { 4740 if($($obj.container).find('.swiper-slide:nth-child('+ ($activeIndex+1) +')').attr('data-color-scheme') == 'dark') { 4741 $($obj.container).find('.slider-pagination').addClass('dark-cs'); 4742 $($obj.container).find('.slider-prev, .slider-next').addClass('dark-cs'); 4743 } else { 4744 $($obj.container).find('.slider-pagination').removeClass('dark-cs'); 4745 $($obj.container).find('.slider-prev, .slider-next').removeClass('dark-cs'); 4746 } 4747 } else if($($obj.container).hasClass('directional-trans-prev')) { 4748 if($($obj.container).find('.swiper-slide:nth-child('+ ($activeIndex-1) +')').attr('data-color-scheme') == 'dark') { 4749 $($obj.container).find('.slider-pagination').addClass('dark-cs'); 4750 $($obj.container).find('.slider-prev, .slider-next').addClass('dark-cs'); 4751 } else { 4752 $($obj.container).find('.slider-pagination').removeClass('dark-cs'); 4753 $($obj.container).find('.slider-prev, .slider-next').removeClass('dark-cs'); 4754 } 4755 4756 } else if($($obj.container).hasClass('directional-trans-current')) { 4757 if($($obj.container).find('.swiper-slide:nth-child('+ ($activeIndex) +')').attr('data-color-scheme') == 'dark') { 4758 $($obj.container).find('.slider-pagination').addClass('dark-cs'); 4759 $($obj.container).find('.slider-prev, .slider-next').addClass('dark-cs'); 4760 } else { 4761 $($obj.container).find('.slider-pagination').removeClass('dark-cs'); 4762 $($obj.container).find('.slider-prev, .slider-next').removeClass('dark-cs'); 4763 } 4764 4765 } 4766 } 4767 4768 4769 $($obj.container).find('.swiper-slide .video-texture').removeClass('no-trans').removeClass('light-overlay').removeClass('dark-overlay').removeClass('half-dark-overlay').removeClass('half-light-overlay'); 4770 4771 //add slide counts 4772 $($obj.container).find('.slider-prev .slide-count .slide-current').html( $activeIndex2 ); 4773 $($obj.container).find('.slider-next .slide-count .slide-current').html( $activeIndex2 ); 4774 4775 if($($obj.container).attr('data-loop') == 'true'){ 4776 //duplicate first slide 4777 if( $($obj.container).find('.swiper-slide-active').index()+1 == 1) { 4778 $($obj.container).find('.slider-next .slide-count .slide-current, .slider-prev .slide-count .slide-current').html( $slideNum - 2 ); 4779 } 4780 //duplicate last slide 4781 else if( $($obj.container).find('.swiper-slide-active').index()+1 == $slideNum) { 4782 $($obj.container).find('.slider-next .slide-count .slide-current, .slider-prev .slide-count .slide-current').html( 1 ); 4783 } 4784 } 4785 4786 if($obj.activeIndex >= 10) { $($obj.container).find('.slider-next .slide-count .slide-current').addClass('double-digits'); } else { 4787 $($obj.container).find('.slider-next .slide-count .slide-current').removeClass('double-digits'); 4788 } 4789 4790 4791 $($obj.container).find('.swiper-slide:not(".swiper-slide-active")').each(function(){ 4792 if($(this).find('.video-wrap video').length > 0) { 4793 4794 //if($(this).find('.video-wrap video').get(0).currentTime != 0 ) $(this).find('.video-wrap video').get(0).currentTime = 0; 4795 } 4796 }); 4797 4798 4799 //don't allow swiping on duplicate transition 4800 if($($obj.container).attr('data-loop') == 'true'){ 4801 if($obj.previousIndex == 1 && $obj.activeIndex == 0 || $obj.previousIndex == $slideNum - 2 && $obj.activeIndex == $slideNum - 1 ){ 4802 $('.swiper-slide').addClass('duplicate-transition'); 4803 } 4804 } 4805 4806 4807 clearTimeout(animationQueue); 4808 animationQueue = setTimeout(function(){ $animating = false; $('.swiper-slide').removeClass('duplicate-transition'); },800); 4809 4810 4811 4812 } 4813 4814 4815 4816 4817 //functions to add or remove slider for webkit parallax fix 4818 function hideSlider() { 4819 if( $(window).scrollTop()/($sliderHeight + portfolioHeaderHeight + 125) >= 1){ 4820 $('.parallax_slider_outer .nectar-slider-wrap, .project-title.parallax-effect').css('visibility','hidden').hide(); 4821 $('.parallax_slider_outer').removeClass('element-in-view').addClass('element-out-of-view'); 4822 4823 //directional slider autorotate clear 4824 if($('.parallax_slider_outer .nectar-slider-wrap[data-overall_style="directional"]').length > 0) { 4825 var $autoplayVal = $('.parallax_slider_outer .nectar-slider-wrap[data-overall_style="directional"]').attr('data-autorotate'); 4826 if(typeof $autoplayVal !='undefined' && $autoplayVal.length != '0' && parseInt($autoplayVal)) { 4827 clearInterval( autoplay[$('.parallax_slider_outer .nectar-slider-wrap').attr('autoplay-id')] ); 4828 } 4829 } 4830 4831 $(window).on('scroll',showSlider); 4832 $(window).off('scroll',hideSlider); 4833 } 4834 } 4835 4836 function showSlider() { 4837 if( $(window).scrollTop()/($sliderHeight + portfolioHeaderHeight + 125) <= 1){ 4838 4839 $('.parallax_slider_outer .nectar-slider-wrap, .project-title.parallax-effect').css('visibility','visible').show(); 4840 $('.parallax_slider_outer').addClass('element-in-view'); 4841 4842 //directional slider autorotate restart 4843 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) { 4844 var $autoplayVal = $('.parallax_slider_outer .nectar-slider-wrap[data-overall_style="directional"]').attr('data-autorotate'); 4845 if(typeof $autoplayVal !='undefined' && $autoplayVal.length != '0' && parseInt($autoplayVal)) { 4846 nectarSlideRotateInit($('.parallax_slider_outer .nectar-slider-wrap'),$autoplayVal,0); 4847 } 4848 } 4849 4850 $('.parallax_slider_outer').removeClass('element-out-of-view'); 4851
4852 //resize iframes incase user resized window when out of view 4853 $('.swiper-slide iframe[data-aspectRatio]').each(function() { 4854 var newWidth = $(this).parent().width(); 4855 var $el = $(this); 4856 if($(this).is(':visible')) $el.width(newWidth).height(newWidth * $el.attr('data-aspectRatio')); 4857 4858 }); 4859 4860 4861 nsSliderContentResize(); 4862 4863 //show content on current slide - could have been hidden from autorotate when slider was hidden 4864 if($('.parallax_slider_outer').length > 0) { 4865 var fromLeft = Math.abs(parseInt($('.parallax_slider_outer .nectar-slider-wrap .swiper-wrapper').css('left'))); 4866 var currentSlide = Math.round(fromLeft/$('.parallax_slider_outer .nectar-slider-wrap .swiper-slide').width()); 4867 4868 $('.parallax_slider_outer .swiper-wrapper .swiper-slide:eq(' + currentSlide + ')').find('.content').children().each(function(i){ 4869 $(this).stop(true,true).css({ 'opacity' : 1, 'padding-top' : 0 }); 4870 }); 4871 4872 $('.parallax_slider_outer .swiper-wrapper .swiper-slide:eq(' + currentSlide + ')').addClass('autorotate-shown'); 4873 } 4874 4875 $(window).on('scroll',hideSlider); 4876 $(window).off('scroll',showSlider); 4877 4878 } 4879 } 4880 4881 function sliderCorrectDisplayCheck() { 4882 if( $(window).scrollTop()/($sliderHeight + portfolioHeaderHeight + 125) >= 1){ 4883 hideSlider(); 4884 } 4885 $(window).unbind('scroll',sliderCorrectDisplayCheck); 4886 } 4887 4888 4889 var $smoothActive = $('body').attr('data-smooth-scrolling'); 4890 4891 // Create cross browser requestAnimationFrame method: 4892 window.requestAnimationFrame = window.requestAnimationFrame 4893 || window.mozRequestAnimationFrame 4894 || window.webkitRequestAnimationFrame 4895 || window.msRequestAnimationFrame 4896 || function(f){setTimeout(f, 1000/60)} 4897 4898 function parallaxScroll(){ 4899 4900 if($('.parallax_slider_outer.element-in-view').length == 0) return false; 4901 4902 if($smoothActive == 1 && navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { return false; } 4903 4904 $('.parallax_slider_outer.first-section .nectar-slider-wrap[data-parallax="true"]').stop(true,true).transition({ y: $(window).scrollTop()*-.2 },0); 4905 $('.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').stop(true,true).transition({ y: $(window).scrollTop()*-.14 },0); 4906 4907 $('#full_width_portfolio .project-title.parallax-effect').transition({ y: $(window).scrollTop()*-.2 },0); 4908 4909 $('.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-($(window).scrollTop()/($sliderHeight-120)) ); 4910 4911 } 4912 4913 function sliderParallaxUpdateHeight(){ 4914 $sliderHeight = parseInt($('.parallax_slider_outer.first-section .swiper-container').attr('data-height')); 4915 4916 $('.project-title').css({ 4917 'top': $('#header-space').outerHeight() + $adminBarHeight + 'px' 4918 }); 4919 } 4920 4921 4922 var $sliderHeight = parseInt($('.parallax_slider_outer.first-section .swiper-container').attr('data-height')); 4923 var $adminBarHeight = ($('#wpadminbar').length > 0) ? 28 : 0; 4924 4925 function sliderParallaxInit() { 4926 4927 4928 if($('#portfolio-extra').length > 0 && $('#full_width_portfolio').length == 0) { return false; } 4929 4930 //$(window).on('scroll.nsParallaxScroll',parallaxScroll); 4931 $('.parallax_slider_outer').addClass('element-in-view'); 4932 4933 window.addEventListener('scroll', function(){ 4934 requestAnimationFrame(parallaxScroll) 4935 }, false) 4936 4937 //hide slider to not mess up parallax section 4938 var portfolioHeaderHeight = ($('.project-title.parallax-effect').length > 0) ? 100 : 0; 4939 4940 function displayParallaxSliderInit() { 4941 if( $(window).scrollTop()/($sliderHeight + portfolioHeaderHeight + 90) >= 1){ 4942 $(window).off('scroll.nsVisibilityHide'); 4943 $(window).on('scroll.nsVisibilityHide', hideSlider); 4944 $(window).on('scroll',showSlider); 4945 } else { 4946 $(window).off('scroll.nsVisibilityShow'); 4947 $(window).on('scroll.nsVisibilityShow', showSlider); 4948 $(window).off('scroll', hideSlider); 4949 } 4950 } 4951 4952 displayParallaxSliderInit(); 4953 4954 $(window).off('scroll.nsCorrectDisplayCheck'); 4955 $(window).on('scroll.nsCorrectDisplayCheck',sliderCorrectDisplayCheck); 4956 4957 4958 $('body:not(".single") .page-header-no-bg, body:not(".single") #page-header-wrap, body:not(".single") #page-header-bg').remove(); 4959 4960 $('.project-title').addClass('parallax-effect').css({ 4961 'top': $('#header-space').outerHeight() + $adminBarHeight + 'px' 4962 }); 4963 4964 //caption alignment if portfolio fullwidth parallax 4965 if($('.project-title.parallax-effect').length > 0) { 4966 $('.parallax_slider_outer.first-section .swiper-slide .content, .nectar-slider-wrap.first-section .swiper-slide .content').css('margin-top','0px'); 4967 $('.swiper-container .slider-prev, .swiper-container .slider-next').css('margin-top','-28px'); 4968 } 4969 4970 //if using wooCommerce sitewide notice 4971 if($('.demo_store').length > 0) $('.project-title.parallax-effect').css('margin-top','-25px'); 4972 4973 if($('#full_width_portfolio').length > 0){ 4974 $('.parallax_slider_outer.first-section').css('margin-top','93px'); 4975 } 4976 4977 $(window).off('resize.nsHeightUpdate'); 4978 $(window).on('resize.nsHeightUpdate',sliderParallaxUpdateHeight); 4979 4980 } 4981 4982 //parallax 4983 function parallaxCheck(){ 4984 4985 $(window).off('scroll.nsParallaxScroll'); 4986 4987 if($('.parallax_slider_outer').length > 0 && !navigator.userAgent.match(/(Android|iPod|iPhone|iPad|IEMobile|Opera Mini)/)){
4988 sliderParallaxInit(); 4989 4990 } else if($('.parallax_slider_outer').length > 0 && navigator.userAgent.match(/(Android|iPod|iPhone|iPad|IEMobile|Opera Mini)/)) { 4991 4992 $('.project-title').addClass('parallax-effect').css({ 4993 'top': $('#header-space').outerHeight() + $adminBarHeight + 'px' 4994 }); 4995 4996 $('body:not(".single") .page-header-no-bg, body:not(".single") #page-header-wrap, body:not(".single") #page-header-bg').remove(); 4997 } else { 4998 $('.project-title').css({'top':'0'}); 4999 } 5000 } 5001 parallaxCheck(); 5002 5003 function niceScrollInit(){ 5004 $("html").niceScroll({ 5005 scrollspeed: 60, 5006 mousescrollstep: 40, 5007 cursorwidth: 15, 5008 cursorborder: 0, 5009 cursorcolor: '#303030', 5010 cursorborderradius: 6, 5011 autohidemode: false, 5012 horizrailenabled: false 5013 }); 5014 5015 if($('#boxed').length == 0){ 5016 $('body, body #header-outer, body #header-secondary-outer, body #search-outer').css('padding-right','16px'); 5017 } 5018 5019 $('html').addClass('no-overflow-y'); 5020 } 5021 5022 //pause video backgrounds if popup video player is started 5023 $('.portfolio-items a.pp:contains(Video), .swiper-container .buttons a.pp').click(function(){ 5024 $('.swiper-slide').each(function(){ 5025 if($(this).find('.video-wrap video').length > 0) { 5026 $(this).find('.video-wrap video').get(0).pause(); 5027 } 5028 }); 5029 }); 5030 5031 5032 //solid button hover effect 5033 $.cssHooks.backgroundColor = { 5034 get: function(elem) { 5035 if (elem.currentStyle) 5036 var bg = elem.currentStyle["backgroundColor"]; 5037 else if (window.getComputedStyle) 5038 var bg = document.defaultView.getComputedStyle(elem, 5039 null).getPropertyValue("background-color"); 5040 if (bg.search("rgb") == -1) 5041 return bg; 5042 else { 5043 bg = bg.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); 5044 function hex(x) { 5045 return ("0" + parseInt(x).toString(16)).slice(-2); 5046 } 5047 if(bg) { 5048 return "#" + hex(bg[1]) + hex(bg[2]) + hex(bg[3]); 5049 } 5050 } 5051 } 5052 } 5053 5054 function shadeColor(color, shade) { 5055 var colorInt = parseInt(color.substring(1),16); 5056 5057 var R = (colorInt & 0xFF0000) >> 16; 5058 var G = (colorInt & 0x00FF00) >> 8; 5059 var B = (colorInt & 0x0000FF) >> 0; 5060 5061 R = R + Math.floor((shade/255)*R); 5062 G = G + Math.floor((shade/255)*G); 5063 B = B + Math.floor((shade/255)*B); 5064 5065 var newColorInt = (R<<16) + (G<<8) + (B); 5066 var newColorStr = "#"+newColorInt.toString(16); 5067 5068 return newColorStr; 5069 } 5070 5071 function sliderbuttonHoverEffect() { 5072 $('.swiper-slide').each(function(){ 5073 $(this).find('.solid_color').each(function(){ 5074 var $currentColor = $(this).find('a').css('background-color'); 5075 var $hoverColor = shadeColor($currentColor, -16); 5076 $(this).find('a').hover(function(){ 5077 $(this).attr('style','background-color:'+$hoverColor+'!important;'); 5078 },function(){ 5079 $(this).attr('style',''); 5080 }); 5081 }); 5082 }); 5083 } 5084 sliderbuttonHoverEffect(); 5085 5086 //slider down arrow 5087 var logoHeight = parseInt($('#header-outer').attr('data-logo-height')); 5088 var headerPadding = parseInt($('#header-outer').attr('data-padding')); 5089 var shrinkNum = 8; 5090 5091 if($('#header-outer[data-shrink-num]').length > 0 ) shrinkNum = $('#header-outer').attr('data-shrink-num'); 5092 5093 headerPadding = headerPadding - headerPadding/1.8; 5094 5095 $('body').on('click','.slider-down-arrow',function(){ 5096 5097 var $currentSlider = $(this).parents('.swiper-container'); 5098 var $topDistance = $currentSlider.attr('data-height'); 5099 var $offset = ($currentSlider.parents('.first-section').length == 0 || $('body[data-transparent-header="false"]').length > 0) ? $currentSlider.offset().top : 0; 5100 5101 if(!$('body').hasClass('mobile')){ 5102 $('body,html').stop().animate({ 5103 scrollTop: parseInt($topDistance - $('#header-space').height()) + parseInt(shrinkNum) + headerPadding*2 + $offset + 2 5104 },1000,'easeInOutCubic') 5105 } else { 5106 $('body,html').stop().animate({ 5107 scrollTop: parseInt($topDistance) + parseInt($currentSlider.offset().top) + 2 5108 },1000,'easeInOutCubic') 5109 } 5110 return false;
5111 }); 5112 5113 function prettyPhotoInit(){ 5114 5115 var loading_animation = ($('body[data-loading-animation]').attr('data-loading-animation') != 'none') ? $('body').attr('data-loading-animation') : null ; 5116 var ascend_loader = ($('body').hasClass('ascend')) ? '<span class="default-loading-icon spin"></span>' : ''; 5117 var ascend_loader_class = ($('body').hasClass('ascend')) ? 'default_loader ' : ''; 5118 5119 $(".nectar-slider-wrap a[rel^='prettyPhoto']").prettyPhoto({ 5120 theme: 'dark_rounded', 5121 allow_resize: true, 5122 default_width: 690, 5123 opacity: 0.85, 5124 animation_speed: 'normal', 5125 default_height: 388, 5126 social_tools: '', 5127 markup: '<div class="pp_pic_holder"> \ 5128 <div class="ppt"> </div> \ 5129 <div class="pp_details"> \ 5130 <div class="pp_nav"> \ 5131 <a href="#" class="pp_arrow_previous"> <i class="icon-salient-left-arrow-thin icon-default-style"></i> </a> \ 5132 <a href="#" class="pp_arrow_next"> <i class="icon-salient-right-arrow-thin icon-default-style"></i> </a> \ 5133 <p class="currentTextHolder">0/0</p> \ 5134 </div> \ 5135 <a class="pp_close" href="#"><span class="icon-salient-x icon-default-style"></span></a> \ 5136 </div> \ 5137 <div class="pp_content_container"> \ 5138 <div class="pp_left"> \ 5139 <div class="pp_right"> \ 5140 <div class="pp_content"> \ 5141 <div class="pp_fade"> \ 5142 <div class="pp_hoverContainer"> \ 5143 </div> \ 5144 <div id="pp_full_res"></div> \ 5145 <p class="pp_description"></p> \ 5146 </div> \ 5147 </div> \ 5148 </div> \ 5149 </div> \ 5150 </div> \ 5151 </div> \ 5152 <div class="pp_loaderIcon ' + ascend_loader_class + loading_animation+'"> '+ascend_loader+' </div> \ 5153 <div class="pp_overlay"></div>' 5154 }); 5155 5156 } 5157 5158 5159 $('.section-options select[name=layout-style]').change(function(){ 5160 if($(this).val() == 'boxed') { 5161 5162 //nectar slider stuff 5163 $('.nectar-slider-wrap[data-full-width="true"] .swiper-slide').css({'width':$('#boxed').width()}); 5164 $('.nectar-slider-wrap[data-full-width="true"]').attr('data-full-width','boxed-full-width').css({'width':'auto','left':'auto'}).transition({ y: 0 },0); 5165 slideContentPos(); 5166 sliderSize(); 5167 resizeToCover(); 5168 for(var i=0; i < $nectarSliders.length; i++){ 5169 $nectarSliders[i].reInit(); 5170 5171 } 5172 $(window).trigger('resize'); 5173 5174 $('.slider-nav .right, .slider-nav .left').css('opacity','1'); 5175 } else { 5176 5177 //nectar slider stuff 5178 $('.nectar-slider-wrap[data-full-width="boxed-full-width"]').attr('data-full-width','true'); 5179 sliderSize(); 5180 resizeToCover(); 5181 slideContentPos(); 5182 5183 for(var i=0; i < $nectarSliders.length; i++){ 5184 $nectarSliders[i].reInit(); 5185 5186 } 5187 5188 $(window).trigger('resize'); 5189 5190 } 5191 }); 5192 5193 5194 5195 5196 5197}); 5198
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.