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