1/* 2 * jQuery OwlCarousel v1.29 3 * 4 * Copyright (c) 2013 Bartosz Wojciechowski 5 * http://www.owlgraphic.com/owlcarousel/ 6 * 7 * Licensed under MIT 8 * 9 */ 10 11if ( typeof Object.create !== "function" ) { 12 Object.create = function( obj ) { 13 function F() {}; 14 F.prototype = obj; 15 return new F(); 16 }; 17} 18(function( $, window, document, undefined ) { 19 20 var Carousel = { 21 init :function(options, el){ 22 var base = this; 23 24 base.$elem = $(el); 25 26 // options passed via js override options passed via data attributes 27 base.options = $.extend({}, $.fn.owlCarousel.options, base.$elem.data(), options); 28 29 base.userOptions = options; 30 base.loadContent(); 31 }, 32 33 loadContent : function(){ 34 var base = this; 35 36 if (typeof base.options.beforeInit === "function") { 37 base.options.beforeInit.apply(this,[base.$elem]); 38 } 39 40 if (typeof base.options.jsonPath === "string") { 41 var url = base.options.jsonPath; 42 43 function getData(data) { 44 if (typeof base.options.jsonSuccess === "function") { 45 base.options.jsonSuccess.apply(this,[data]); 46 } else { 47 var content = ""; 48 for(var i in data["owl"]){ 49 content += data["owl"][i]["item"]; 50 } 51 base.$elem.html(content); 52 } 53 base.logIn(); 54 } 55 $.getJSON(url,getData); 56 } else { 57 base.logIn(); 58 } 59 }, 60 61 logIn : function(action){ 62 var base = this; 63 64 base.$elem.css({opacity: 0}); 65 base.orignalItems = base.options.items; 66 base.checkBrowser(); 67 base.wrapperWidth = 0; 68 base.checkVisible; 69 base.setVars(); 70 }, 71 72 setVars : function(){ 73 var base = this; 74 if(base.$elem.children().length === 0){return false;} 75 base.baseClass(); 76 base.eventTypes(); 77 base.$userItems = base.$elem.children(); 78 base.itemsAmount = base.$userItems.length; 79 base.wrapItems(); 80 base.$owlItems = base.$elem.find(".owl-item"); 81 base.$owlWrapper = base.$elem.find(".owl-wrapper"); 82 base.playDirection = "next"; 83 base.prevItem = 0;//base.options.startPosition; 84 base.currentItem = 0; //Starting Position 85 base.customEvents(); 86 base.onStartup(); 87 }, 88 89 onStartup : function(){ 90 var base = this; 91 base.updateItems(); 92 base.calculateAll(); 93 base.buildControls(); 94 base.updateControls(); 95 base.response(); 96 base.moveEvents(); 97 base.stopOnHover(); 98 base.owlStatus(); 99 100 if(base.options.transitionStyle !== false){ 101 base.transitionTypes(base.options.transitionStyle); 102 } 103 if(base.options.autoPlay === true){ 104 base.options.autoPlay = 5000; 105 } 106 base.play(); 107 108 base.$elem.find(".owl-wrapper").css("display","block"); 109 110 if(!base.$elem.is(":visible")){ 111 base.watchVisibility(); 112 } else { 113 base.$elem.css("opacity",1); 114 } 115 base.onstartup = false; 116 base.eachMoveUpdate(); 117 if (typeof base.options.afterInit === "function") { 118 base.options.afterInit.apply(this,[base.$elem]); 119 } 120 }, 121 122 eachMoveUpdate : function(){ 123 var base = this; 124 125 if(base.options.lazyLoad === true){ 126 base.lazyLoad(); 127 } 128 if(base.options.autoHeight === true){ 129 base.autoHeight(); 130 } 131 132 base.onVisibleItems(); 133 134 if (typeof base.options.afterAction === "function") { 135 base.options.afterAction.apply(this,[base.$elem]); 136 } 137 }, 138 139 updateVars : function(){ 140 var base = this; 141 if(typeof base.options.beforeUpdate === "function") { 142 base.options.beforeUpdate.apply(this,[base.$elem]); 143 } 144 base.watchVisibility(); 145 base.updateItems(); 146 base.calculateAll(); 147 base.updatePosition(); 148 base.updateControls(); 149 base.eachMoveUpdate(); 150 if(typeof base.options.afterUpdate === "function") { 151 base.options.afterUpdate.apply(this,[base.$elem]); 152 } 153 }, 154 155 reload : function(elements){ 156 var base = this; 157 setTimeout(function(){ 158 base.updateVars(); 159 },0); 160 }, 161 162 watchVisibility : function(){ 163 var base = this; 164 165 if(base.$elem.is(":visible") === false){ 166 base.$elem.css({opacity: 0}); 167 clearInterval(base.autoPlayInterval); 168 clearInterval(base.checkVisible); 169 } else { 170 return false; 171 } 172 base.checkVisible = setInterval(function(){ 173 if (base.$elem.is(":visible")) { 174 base.reload(); 175 base.$elem.animate({opacity: 1},200); 176 clearInterval(base.checkVisible); 177 } 178 }, 500); 179 }, 180 181 wrapItems : function(){ 182 var base = this; 183 base.$userItems.wrapAll("<div class=\"owl-wrapper\">").wrap("<div class=\"owl-item\"></div>"); 184 base.$elem.find(".owl-wrapper").wrap("<div class=\"owl-wrapper-outer\">"); 185 base.wrapperOuter = base.$elem.find(".owl-wrapper-outer"); 186 base.$elem.css("display","block"); 187 }, 188 189 baseClass : function(){ 190 var base = this; 191 var hasBaseClass = base.$elem.hasClass(base.options.baseClass); 192 var hasThemeClass = base.$elem.hasClass(base.options.theme); 193 base.$elem.data("owl-originalStyles", base.$elem.attr("style")) 194 .data("owl-originalClasses", base.$elem.attr("class")); 195 196 if(!hasBaseClass){ 197 base.$elem.addClass(base.options.baseClass); 198 } 199 200 if(!hasThemeClass){ 201 base.$elem.addClass(base.options.theme); 202 } 203 }, 204 205 updateItems : function(){ 206 var base = this; 207 208 if(base.options.responsive === false){ 209 return false;
210 } 211 if(base.options.singleItem === true){ 212 base.options.items = base.orignalItems = 1; 213 base.options.itemsDesktop = false; 214 base.options.itemsDesktopSmall = false; 215 base.options.itemsTablet = false; 216 base.options.itemsTabletSmall = false; 217 base.options.itemsMobile = false; 218 return false; 219 } 220 221 var width = $(base.options.responsiveBaseWidth).width(); 222 223 if(width > (base.options.itemsDesktop[0] || base.orignalItems) ){ 224 base.options.items = base.orignalItems; 225 } 226 227 if(width <= base.options.itemsDesktop[0] && base.options.itemsDesktop !== false){ 228 base.options.items = base.options.itemsDesktop[1]; 229 } 230 231 if(width <= base.options.itemsDesktopSmall[0] && base.options.itemsDesktopSmall !== false){ 232 base.options.items = base.options.itemsDesktopSmall[1]; 233 } 234 235 if(width <= base.options.itemsTablet[0] && base.options.itemsTablet !== false){ 236 base.options.items = base.options.itemsTablet[1]; 237 } 238 239 if(width <= base.options.itemsTabletSmall[0] && base.options.itemsTabletSmall !== false){ 240 base.options.items = base.options.itemsTabletSmall[1]; 241 } 242 243 if(width <= base.options.itemsMobile[0] && base.options.itemsMobile !== false){ 244 base.options.items = base.options.itemsMobile[1]; 245 } 246 247 //if number of items is less than declared 248 if(base.options.items > base.itemsAmount && base.options.itemsScaleUp === true){ 249 base.options.items = base.itemsAmount; 250 } 251 }, 252 253 response : function(){ 254 var base = this, 255 smallDelay; 256 if(base.options.responsive !== true){ 257 return false; 258 } 259 var lastWindowWidth = $(window).width(); 260 261 base.resizer = function(){ 262 if($(window).width() !== lastWindowWidth){ 263 if(base.options.autoPlay !== false){ 264 clearInterval(base.autoPlayInterval); 265 } 266 clearTimeout(smallDelay); 267 smallDelay = setTimeout(function(){ 268 lastWindowWidth = $(window).width(); 269 base.updateVars(); 270 },base.options.responsiveRefreshRate); 271 } 272 }; 273 $(window).resize(base.resizer); 274 }, 275 276 updatePosition : function(){ 277 var base = this; 278 279 if(base.browser.support3d === true){ 280 if(base.positionsInArray[base.currentItem] > base.maximumPixels){ 281 base.transition3d(base.positionsInArray[base.currentItem]); 282 } else { 283 base.transition3d(0); 284 base.currentItem = 0; 285 } 286 } else{ 287 if(base.positionsInArray[base.currentItem] > base.maximumPixels){ 288 base.css2slide(base.positionsInArray[base.currentItem]); 289 } else { 290 base.css2slide(0); 291 base.currentItem = 0; 292 } 293 } 294 if(base.options.autoPlay !== false){ 295 base.checkAp(); 296 } 297 }, 298 299 appendItemsSizes : function(){ 300 var base = this; 301 302 var roundPages = 0; 303 var lastItem = base.itemsAmount - base.options.items; 304 305 base.$owlItems.each(function(index){ 306 var $this = $(this); 307 $this 308 .css({"width": base.itemWidth}) 309 .data("owl-item",Number(index)); 310 311 if(index % base.options.items === 0 || index === lastItem){ 312 if(!(index > lastItem)){ 313 roundPages +=1; 314 } 315 } 316 $this.data("owl-roundPages",roundPages); 317 }); 318 }, 319 320 appendWrapperSizes : function(){ 321 var base = this; 322 var width = 0; 323 324 var width = base.$owlItems.length * base.itemWidth; 325 326 base.$owlWrapper.css({ 327 "width": width*2, 328 "left": 0 329 }); 330 base.appendItemsSizes(); 331 }, 332 333 calculateAll : function(){ 334 var base = this; 335 base.calculateWidth(); 336 base.appendWrapperSizes(); 337 base.loops(); 338 base.max(); 339 }, 340 341 calculateWidth : function(){ 342 var base = this; 343 base.itemWidth = Math.round(base.$elem.width()/base.options.items); 344 }, 345 346 max : function(){ 347 var base = this; 348 var maximum = ((base.itemsAmount * base.itemWidth) - base.options.items * base.itemWidth) * -1; 349 if(base.options.items > base.itemsAmount){ 350 base.maximumItem = 0; 351 maximum = 0; 352 base.maximumPixels = 0; 353 } else { 354 base.maximumItem = base.itemsAmount - base.options.items; 355 base.maximumPixels = maximum; 356 } 357 return maximum; 358 }, 359 360 min : function(){ 361 return 0; 362 }, 363 364 loops : function(){ 365 var base = this; 366 367 base.positionsInArray = [0]; 368 var elWidth = 0; 369 370 for(var i = 0; i<base.itemsAmount; i++){ 371 elWidth += base.itemWidth; 372 base.positionsInArray.push(-elWidth); 373 } 374 }, 375 376 buildControls : function(){ 377 var base = this; 378 if(base.options.navigation === true || base.options.pagination === true){
379 base.owlControls = $("<div class=\"owl-controls\"/>").toggleClass("clickable", !base.browser.isTouch).appendTo(base.$elem); 380 } 381 if(base.options.pagination === true){ 382 base.buildPagination(); 383 } 384 if(base.options.navigation === true){ 385 base.buildButtons(); 386 } 387 }, 388 389 buildButtons : function(){ 390 var base = this; 391 var buttonsWrapper = $("<div class=\"owl-buttons\"/>"); 392 base.owlControls.append(buttonsWrapper); 393 394 base.buttonPrev = $("<div/>",{ 395 "class" : "owl-prev", 396 "html" : base.options.navigationText[0] || "" 397 }); 398 399 base.buttonNext = $("<div/>",{ 400 "class" : "owl-next", 401 "html" : base.options.navigationText[1] || "" 402 }); 403 404 buttonsWrapper 405 .append(base.buttonPrev) 406 .append(base.buttonNext); 407 408 buttonsWrapper.on("touchstart.owlControls mousedown.owlControls", "div[class^=\"owl\"]", function(event){ 409 event.preventDefault(); 410 }); 411 412 buttonsWrapper.on("touchend.owlControls mouseup.owlControls", "div[class^=\"owl\"]", function(event){ 413 event.preventDefault(); 414 if($(this).hasClass("owl-next")){ 415 base.next(); 416 } else{ 417 base.prev(); 418 } 419 }); 420 }, 421 422 buildPagination : function(){ 423 var base = this; 424 425 base.paginationWrapper = $("<div class=\"owl-pagination\"/>"); 426 base.owlControls.append(base.paginationWrapper); 427 428 base.paginationWrapper.on("touchend.owlControls mouseup.owlControls", ".owl-page", function(event){ 429 event.preventDefault(); 430 if(Number($(this).data("owl-page")) !== base.currentItem){ 431 base.goTo( Number($(this).data("owl-page")), true); 432 } 433 }); 434 }, 435 436 updatePagination : function(){ 437 var base = this; 438 if(base.options.pagination === false){ 439 return false; 440 } 441 442 base.paginationWrapper.html(""); 443 444 var counter = 0; 445 var lastPage = base.itemsAmount - base.itemsAmount % base.options.items; 446 447 for(var i = 0; i<base.itemsAmount; i++){ 448 if(i % base.options.items === 0){ 449 counter +=1; 450 if(lastPage === i){ 451 var lastItem = base.itemsAmount - base.options.items; 452 } 453 var paginationButton = $("<div/>",{ 454 "class" : "owl-page" 455 }); 456 var paginationButtonInner = $("<span></span>",{ 457 "text": base.options.paginationNumbers === true ? counter : "", 458 "class": base.options.paginationNumbers === true ? "owl-numbers" : "" 459 }); 460 paginationButton.append(paginationButtonInner); 461 462 paginationButton.data("owl-page",lastPage === i ? lastItem : i); 463 paginationButton.data("owl-roundPages",counter); 464 465 base.paginationWrapper.append(paginationButton); 466 } 467 } 468 base.checkPagination(); 469 }, 470 checkPagination : function(){ 471 var base = this; 472 if(base.options.pagination === false){ 473 return false; 474 } 475 base.paginationWrapper.find(".owl-page").each(function(i,v){ 476 if($(this).data("owl-roundPages") === $(base.$owlItems[base.currentItem]).data("owl-roundPages") ){ 477 base.paginationWrapper 478 .find(".owl-page") 479 .removeClass("active"); 480 $(this).addClass("active"); 481 } 482 }); 483 }, 484 485 checkNavigation : function(){ 486 var base = this; 487 488 if(base.options.navigation === false){ 489 return false; 490 } 491 if(base.options.rewindNav === false){ 492 if(base.currentItem === 0 && base.maximumItem === 0){ 493 base.buttonPrev.addClass("disabled"); 494 base.buttonNext.addClass("disabled"); 495 } else if(base.currentItem === 0 && base.maximumItem !== 0){ 496 base.buttonPrev.addClass("disabled"); 497 base.buttonNext.removeClass("disabled"); 498 } else if (base.currentItem === base.maximumItem){ 499 base.buttonPrev.removeClass("disabled"); 500 base.buttonNext.addClass("disabled"); 501 } else if(base.currentItem !== 0 && base.currentItem !== base.maximumItem){ 502 base.buttonPrev.removeClass("disabled"); 503 base.buttonNext.removeClass("disabled"); 504 } 505 } 506 }, 507 508 updateControls : function(){ 509 var base = this; 510 base.updatePagination(); 511 base.checkNavigation(); 512 if(base.owlControls){ 513 if(base.options.items >= base.itemsAmount){ 514 base.owlControls.hide(); 515 } else { 516 base.owlControls.show(); 517 } 518 } 519 }, 520 521 destroyControls : function(){ 522 var base = this; 523 if(base.owlControls){ 524 base.owlControls.remove(); 525 } 526 }, 527 528 next : function(speed){ 529 var base = this; 530 531 if(base.isTransition){ 532 return false;
533 } 534 535 base.storePrevItem = base.currentItem; 536 537 base.currentItem += base.options.scrollPerPage === true ? base.options.items : 1; 538 if(base.currentItem > base.maximumItem + (base.options.scrollPerPage == true ? (base.options.items - 1) : 0)){ 539 if(base.options.rewindNav === true){ 540 base.currentItem = 0; 541 speed = "rewind"; 542 } else { 543 base.currentItem = base.maximumItem; 544 return false; 545 } 546 } 547 base.goTo(base.currentItem,speed); 548 }, 549 550 prev : function(speed){ 551 var base = this; 552 553 if(base.isTransition){ 554 return false; 555 } 556 557 base.storePrevItem = base.currentItem; 558 559 if(base.options.scrollPerPage === true && base.currentItem > 0 && base.currentItem < base.options.items){ 560 base.currentItem = 0; 561 } else { 562 base.currentItem -= base.options.scrollPerPage === true ? base.options.items : 1; 563 } 564 if(base.currentItem < 0){ 565 if(base.options.rewindNav === true){ 566 base.currentItem = base.maximumItem; 567 speed = "rewind"; 568 } else { 569 base.currentItem =0; 570 return false; 571 } 572 } 573 base.goTo(base.currentItem,speed); 574 }, 575 576 goTo : function(position,speed,drag){ 577 var base = this; 578 579 if(base.isTransition){ 580 return false; 581 } 582 base.getPrevItem(); 583 if(typeof base.options.beforeMove === "function") { 584 base.options.beforeMove.apply(this,[base.$elem]); 585 } 586 if(position >= base.maximumItem){ 587 position = base.maximumItem; 588 } 589 else if( position <= 0 ){ 590 position = 0; 591 } 592 593 base.currentItem = base.owl.currentItem = position; 594 if( base.options.transitionStyle !== false && drag !== "drag" && base.options.items === 1 && base.browser.support3d === true){ 595 base.swapSpeed(0); 596 if(base.browser.support3d === true){ 597 base.transition3d(base.positionsInArray[position]); 598 } else { 599 base.css2slide(base.positionsInArray[position],1); 600 } 601 base.singleItemTransition(); 602 base.afterGo(); 603 return false; 604 } 605 var goToPixel = base.positionsInArray[position]; 606 607 if(base.browser.support3d === true){ 608 base.isCss3Finish = false; 609 610 if(speed === true){ 611 base.swapSpeed("paginationSpeed"); 612 setTimeout(function() { 613 base.isCss3Finish = true; 614 }, base.options.paginationSpeed); 615 616 } else if(speed === "rewind" ){ 617 base.swapSpeed(base.options.rewindSpeed); 618 setTimeout(function() { 619 base.isCss3Finish = true; 620 }, base.options.rewindSpeed); 621 622 } else { 623 base.swapSpeed("slideSpeed"); 624 setTimeout(function() { 625 base.isCss3Finish = true; 626 }, base.options.slideSpeed); 627 } 628 base.transition3d(goToPixel); 629 } else { 630 if(speed === true){ 631 base.css2slide(goToPixel, base.options.paginationSpeed); 632 } else if(speed === "rewind" ){ 633 base.css2slide(goToPixel, base.options.rewindSpeed); 634 } else { 635 base.css2slide(goToPixel, base.options.slideSpeed); 636 } 637 } 638 base.afterGo(); 639 }, 640 641 getPrevItem : function(){ 642 var base = this; 643 base.prevItem = base.owl.prevItem = base.storePrevItem === undefined ? base.currentItem : base.storePrevItem; 644 base.storePrevItem = undefined; 645 }, 646 647 jumpTo : function(position){ 648 var base = this; 649 base.getPrevItem(); 650 if(typeof base.options.beforeMove === "function") { 651 base.options.beforeMove.apply(this,[base.$elem]); 652 } 653 if(position >= base.maximumItem || position === -1){ 654 position = base.maximumItem; 655 } 656 else if( position <= 0 ){ 657 position = 0; 658 } 659 base.swapSpeed(0); 660 if(base.browser.support3d === true){ 661 base.transition3d(base.positionsInArray[position]); 662 } else { 663 base.css2slide(base.positionsInArray[position],1); 664 } 665 base.currentItem = base.owl.currentItem = position; 666 base.afterGo(); 667 }, 668 669 afterGo : function(){ 670 var base = this; 671 base.checkPagination(); 672 base.checkNavigation(); 673 base.eachMoveUpdate(); 674 675 if(typeof base.options.afterMove === "function") { 676 base.options.afterMove.apply(this,[base.$elem]); 677 } 678 if(base.options.autoPlay !== false){ 679 base.checkAp(); 680 } 681 }, 682 683 stop : function(){ 684 var base = this; 685 base.apStatus = "stop"; 686 clearInterval(base.autoPlayInterval); 687 }, 688 689 checkAp : function(){ 690 var base = this; 691 if(base.apStatus !== "stop"){ 692 base.play(); 693 } 694 }, 695 696 play : function(){ 697 var base = this; 698 base.apStatus = "play"; 699 if(base.options.autoPlay === false){ 700 return false;
701 } 702 clearInterval(base.autoPlayInterval); 703 base.autoPlayInterval = setInterval(function(){ 704 base.next(true); 705 },base.options.autoPlay); 706 }, 707 708 swapSpeed : function(action){ 709 var base = this; 710 if(action === "slideSpeed"){ 711 base.$owlWrapper.css(base.addCssSpeed(base.options.slideSpeed)); 712 } else if(action === "paginationSpeed" ){ 713 base.$owlWrapper.css(base.addCssSpeed(base.options.paginationSpeed)); 714 } else if(typeof action !== "string"){ 715 base.$owlWrapper.css(base.addCssSpeed(action)); 716 } 717 }, 718 719 addCssSpeed : function(speed){ 720 var base = this; 721 return { 722 "-webkit-transition": "all "+ speed +"ms ease", 723 "-moz-transition": "all "+ speed +"ms ease", 724 "-o-transition": "all "+ speed +"ms ease", 725 "transition": "all "+ speed +"ms ease" 726 }; 727 }, 728 729 removeTransition : function(){ 730 return { 731 "-webkit-transition": "", 732 "-moz-transition": "", 733 "-o-transition": "", 734 "transition": "" 735 }; 736 }, 737 738 doTranslate : function(pixels){ 739 return { 740 "-webkit-transform": "translate3d("+pixels+"px, 0px, 0px)", 741 "-moz-transform": "translate3d("+pixels+"px, 0px, 0px)", 742 "-o-transform": "translate3d("+pixels+"px, 0px, 0px)", 743 "-ms-transform": "translate3d("+pixels+"px, 0px, 0px)", 744 "transform": "translate3d("+pixels+"px, 0px,0px)" 745 }; 746 }, 747 748 transition3d : function(value){ 749 var base = this; 750 base.$owlWrapper.css(base.doTranslate(value)); 751 }, 752 753 css2move : function(value){ 754 var base = this; 755 base.$owlWrapper.css({"left" : value}); 756 }, 757 758 css2slide : function(value,speed){ 759 var base = this; 760 761 base.isCssFinish = false; 762 base.$owlWrapper.stop(true,true).animate({ 763 "left" : value 764 }, { 765 duration : speed || base.options.slideSpeed , 766 complete : function(){ 767 base.isCssFinish = true; 768 } 769 }); 770 }, 771 772 checkBrowser : function(){ 773 var base = this; 774 775 //Check 3d support 776 var translate3D = "translate3d(0px, 0px, 0px)", 777 tempElem = document.createElement("div"); 778 779 tempElem.style.cssText= " -moz-transform:" + translate3D + 780 "; -ms-transform:" + translate3D + 781 "; -o-transform:" + translate3D + 782 "; -webkit-transform:" + translate3D + 783 "; transform:" + translate3D; 784 var regex = /translate3d\(0px, 0px, 0px\)/g, 785 asSupport = tempElem.style.cssText.match(regex), 786 support3d = (asSupport !== null && asSupport.length === 1); 787 788 var isTouch = "ontouchstart" in window || navigator.msMaxTouchPoints; 789 790 base.browser = { 791 "support3d" : support3d, 792 "isTouch" : isTouch 793 }; 794 }, 795 796 moveEvents : function(){ 797 var base = this; 798 if(base.options.mouseDrag !== false || base.options.touchDrag !== false){ 799 base.gestures(); 800 base.disabledEvents(); 801 } 802 }, 803 804 eventTypes : function(){ 805 var base = this; 806 var types = ["s","e","x"]; 807 808 base.ev_types = {}; 809 810 if(base.options.mouseDrag === true && base.options.touchDrag === true){ 811 types = [ 812 "touchstart.owl mousedown.owl", 813 "touchmove.owl mousemove.owl", 814 "touchend.owl touchcancel.owl mouseup.owl" 815 ]; 816 } else if(base.options.mouseDrag === false && base.options.touchDrag === true){ 817 types = [ 818 "touchstart.owl", 819 "touchmove.owl", 820 "touchend.owl touchcancel.owl" 821 ]; 822 } else if(base.options.mouseDrag === true && base.options.touchDrag === false){ 823 types = [ 824 "mousedown.owl", 825 "mousemove.owl", 826 "mouseup.owl" 827 ]; 828 } 829 830 base.ev_types["start"] = types[0]; 831 base.ev_types["move"] = types[1]; 832 base.ev_types["end"] = types[2]; 833 }, 834 835 disabledEvents : function(){ 836 var base = this; 837 base.$elem.on("dragstart.owl", function(event) { event.preventDefault();}); 838 base.$elem.on("mousedown.disableTextSelect", function(e) { 839 return $(e.target).is('input, textarea, select, option'); 840 }); 841 }, 842 843 gestures : function(){ 844 var base = this; 845 846 var locals = { 847 offsetX : 0, 848 offsetY : 0, 849 baseElWidth : 0, 850 relativePos : 0, 851 position: null, 852 minSwipe : null, 853 maxSwipe: null, 854 sliding : null, 855 dargging: null, 856 targetElement : null 857 }; 858 859 base.isCssFinish = true; 860 861 function getTouches(event){ 862 if(event.touches){ 863 return { 864 x : event.touches[0].pageX, 865 y : event.touches[0].pageY 866 }; 867 } else { 868 if(event.pageX !== undefined){ 869 return { 870 x : event.pageX, 871 y : event.pageY 872 }; 873 } else { 874 return { 875 x : event.clientX, 876 y : event.clientY 877 }; 878 } 879 } 880 } 881 882 function swapEvents(type){ 883 if(type === "on"){ 884 $(document).on(base.ev_types["move"], dragMove); 885 $(document).on(base.ev_types["end"], dragEnd); 886 } else if(type === "off"){ 887 $(document).off(base.ev_types["move"]); 888 $(document).off(base.ev_types["end"]); 889 } 890 } 891 892 function dragStart(event) { 893 var event = event.originalEvent || event || window.event; 894 895 if (event.which === 3) { 896 return false;
897 } 898 if(base.isCssFinish === false && !base.options.dragBeforeAnimFinish ){ 899 return false; 900 } 901 if(base.isCss3Finish === false && !base.options.dragBeforeAnimFinish ){ 902 return false; 903 } 904 905 if(base.options.autoPlay !== false){ 906 clearInterval(base.autoPlayInterval); 907 } 908 909 if(base.browser.isTouch !== true && !base.$owlWrapper.hasClass("grabbing")){ 910 base.$owlWrapper.addClass("grabbing"); 911 } 912 913 base.newPosX = 0; 914 base.newRelativeX = 0; 915 916 $(this).css(base.removeTransition()); 917 918 var position = $(this).position(); 919 locals.relativePos = position.left; 920 921 locals.offsetX = getTouches(event).x - position.left; 922 locals.offsetY = getTouches(event).y - position.top; 923 924 swapEvents("on"); 925 926 locals.sliding = false; 927 locals.targetElement = event.target || event.srcElement; 928 } 929 930 function dragMove(event){ 931 var event = event.originalEvent || event || window.event; 932 933 base.newPosX = getTouches(event).x- locals.offsetX; 934 base.newPosY = getTouches(event).y - locals.offsetY; 935 base.newRelativeX = base.newPosX - locals.relativePos; 936 937 if (typeof base.options.startDragging === "function" && locals.dragging !== true && base.newRelativeX !== 0) { 938 locals.dragging = true; 939 base.options.startDragging.apply(this); 940 } 941 942 if(base.newRelativeX > 8 || base.newRelativeX < -8 && base.browser.isTouch === true){ 943 event.preventDefault ? event.preventDefault() : event.returnValue = false; 944 locals.sliding = true; 945 } 946 947 if((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false){ 948 $(document).off("touchmove.owl"); 949 } 950 951 var minSwipe = function(){ 952 return base.newRelativeX / 5; 953 }; 954 var maxSwipe = function(){ 955 return base.maximumPixels + base.newRelativeX / 5; 956 }; 957 958 base.newPosX = Math.max(Math.min( base.newPosX, minSwipe() ), maxSwipe() ); 959 if(base.browser.support3d === true){ 960 base.transition3d(base.newPosX); 961 } else { 962 base.css2move(base.newPosX); 963 } 964 } 965 966 function dragEnd(event){ 967 var event = event.originalEvent || event || window.event; 968 event.target = event.target || event.srcElement; 969 970 locals.dragging = false; 971 972 if(base.browser.isTouch !== true){ 973 base.$owlWrapper.removeClass("grabbing"); 974 } 975 976 if(base.newRelativeX !== 0){ 977 var newPosition = base.getNewPosition(); 978 base.goTo(newPosition,false,"drag"); 979 if(locals.targetElement === event.target && base.browser.isTouch !== true){ 980 $(event.target).on("click.disable", function(ev){ 981 ev.stopImmediatePropagation(); 982 ev.stopPropagation(); 983 ev.preventDefault(); 984 $(event.target).off("click.disable"); 985 }); 986 var handlers = $._data(event.target, "events")["click"]; 987 var owlStopEvent = handlers.pop(); 988 handlers.splice(0, 0, owlStopEvent); 989 } 990 } 991 swapEvents("off"); 992 } 993 base.$elem.on(base.ev_types["start"], ".owl-wrapper", dragStart); 994 }, 995 996 getNewPosition : function(){ 997 var base = this, 998 newPosition; 999 1000 var newPosition = base.improveClosest(); 1001 if(newPosition > base.maximumItem){ 1002 base.currentItem = base.maximumItem; 1003 newPosition = base.maximumItem; 1004 } else if( base.newPosX >=0 ){ 1005 newPosition = 0; 1006 base.currentItem = 0; 1007 } 1008 return newPosition; 1009 }, 1010 1011 improveClosest : function(){ 1012 var base = this; 1013 var array = base.positionsInArray; 1014 var goal = base.newPosX; 1015 var closest = null; 1016 $.each(array, function(i,v){ 1017 if( goal - (base.itemWidth/20) > array[i+1] && goal - (base.itemWidth/20)< v && base.moveDirection() === "left") { 1018 closest = v; 1019 base.currentItem = i; 1020 } 1021 else if (goal + (base.itemWidth/20) < v && goal + (base.itemWidth/20) > array[i+1] && base.moveDirection() === "right"){ 1022 closest = array[i+1]; 1023 base.currentItem = i+1; 1024 } 1025 }); 1026 return base.currentItem; 1027 }, 1028 1029 moveDirection : function(){ 1030 var base = this, 1031 direction; 1032 if(base.newRelativeX < 0 ){ 1033 direction = "right"; 1034 base.playDirection = "next"; 1035 } else { 1036 direction = "left"; 1037 base.playDirection = "prev"; 1038 } 1039 return direction; 1040 }, 1041 1042 customEvents : function(){ 1043 var base = this; 1044 base.$elem.on("owl.next",function(){ 1045 base.next(); 1046 }); 1047 base.$elem.on("owl.prev",function(){ 1048 base.prev(); 1049 }); 1050 base.$elem.on("owl.play",function(event,speed){ 1051 base.options.autoPlay = speed; 1052 base.play(); 1053 base.hoverStatus = "play"; 1054 }); 1055 base.$elem.on("owl.stop",function(){ 1056 base.stop(); 1057 base.hoverStatus = "stop"; 1058 });
1059 base.$elem.on("owl.goTo",function(event,item){ 1060 base.goTo(item); 1061 }); 1062 base.$elem.on("owl.jumpTo",function(event,item){ 1063 base.jumpTo(item); 1064 }); 1065 }, 1066 1067 stopOnHover : function(){ 1068 var base = this; 1069 if(base.options.stopOnHover === true && base.browser.isTouch !== true && base.options.autoPlay !== false){ 1070 base.$elem.on("mouseover", function(){ 1071 base.stop(); 1072 }); 1073 base.$elem.on("mouseout", function(){ 1074 if(base.hoverStatus !== "stop"){ 1075 base.play(); 1076 } 1077 }); 1078 } 1079 }, 1080 1081 lazyLoad : function(){ 1082 var base = this; 1083 1084 if(base.options.lazyLoad === false){ 1085 return false; 1086 } 1087 for(var i=0; i<base.itemsAmount; i++){ 1088 var $item = $(base.$owlItems[i]); 1089 1090 if($item.data("owl-loaded") === "loaded"){ 1091 continue; 1092 } 1093 1094 var itemNumber = $item.data("owl-item"), 1095 $lazyImg = $item.find(".lazyOwl"), 1096 follow; 1097 1098 if( typeof $lazyImg.data("src") !== "string"){ 1099 $item.data("owl-loaded","loaded"); 1100 continue; 1101 } 1102 if($item.data("owl-loaded") === undefined){ 1103 $lazyImg.hide(); 1104 $item.addClass("loading").data("owl-loaded","checked"); 1105 } 1106 if(base.options.lazyFollow === true){ 1107 follow = itemNumber >= base.currentItem; 1108 } else { 1109 follow = true; 1110 } 1111 if(follow && itemNumber < base.currentItem + base.options.items && $lazyImg.length){ 1112 base.lazyPreload($item,$lazyImg); 1113 } 1114 } 1115 }, 1116 1117 lazyPreload : function($item,$lazyImg){ 1118 var base = this, 1119 iterations = 0; 1120 $lazyImg[0].src = $lazyImg.data("src"); 1121 checkLazyImage(); 1122 1123 function checkLazyImage(){ 1124 iterations += 1; 1125 if (base.completeImg( $lazyImg.get(0) )) { 1126 showImage(); 1127 } else if(iterations <= 100){//if image loads in less than 10 seconds 1128 setTimeout(checkLazyImage,100); 1129 } else { 1130 showImage(); 1131 } 1132 } 1133 function showImage(){ 1134 $item.data("owl-loaded", "loaded").removeClass("loading"); 1135 $lazyImg.removeAttr("data-src"); 1136 base.options.lazyEffect === "fade" ? $lazyImg.fadeIn(400) : $lazyImg.show(); 1137 } 1138 }, 1139 1140 autoHeight : function(){ 1141 var base = this; 1142 var $currentimg = $(base.$owlItems[base.currentItem]).find("img"); 1143 1144 if($currentimg.get(0) !== undefined ){ 1145 var iterations = 0; 1146 checkImage(); 1147 } else { 1148 addHeight(); 1149 } 1150 function checkImage(){ 1151 iterations += 1; 1152 if ( base.completeImg($currentimg.get(0)) ) { 1153 addHeight(); 1154 } else if(iterations <= 100){ //if image loads in less than 10 seconds 1155 setTimeout(checkImage,100); 1156 } else { 1157 base.wrapperOuter.css("height", ""); //Else remove height attribute 1158 } 1159 } 1160 1161 function addHeight(){ 1162 var $currentItem = $(base.$owlItems[base.currentItem]).height(); 1163 base.wrapperOuter.css("height",$currentItem+"px"); 1164 if(!base.wrapperOuter.hasClass("autoHeight")){ 1165 setTimeout(function(){ 1166 base.wrapperOuter.addClass("autoHeight"); 1167 },0); 1168 } 1169 } 1170 }, 1171 1172 completeImg : function(img) { 1173 if (!img.complete) { 1174 return false; 1175 } 1176 if (typeof img.naturalWidth !== "undefined" && img.naturalWidth == 0) { 1177 return false; 1178 } 1179 return true; 1180 }, 1181 1182 onVisibleItems : function(){ 1183 var base = this; 1184 1185 if(base.options.addClassActive === true){ 1186 base.$owlItems.removeClass("active"); 1187 } 1188 base.visibleItems = []; 1189 for(var i=base.currentItem; i<base.currentItem + base.options.items; i++){ 1190 base.visibleItems.push(i); 1191 1192 if(base.options.addClassActive === true){ 1193 $(base.$owlItems[i]).addClass("active"); 1194 } 1195 } 1196 base.owl.visibleItems = base.visibleItems; 1197 }, 1198 1199 transitionTypes : function(className){ 1200 var base = this; 1201 //Currently available: "fade","backSlide","goDown","fadeUp" 1202 base.outClass = "owl-"+className+"-out"; 1203 base.inClass = "owl-"+className+"-in"; 1204 }, 1205 1206 singleItemTransition : function(){ 1207 var base = this; 1208 base.isTransition = true; 1209 1210 var outClass = base.outClass, 1211 inClass = base.inClass, 1212 $currentItem = base.$owlItems.eq(base.currentItem), 1213 $prevItem = base.$owlItems.eq(base.prevItem), 1214 prevPos = Math.abs(base.positionsInArray[base.currentItem]) + base.positionsInArray[base.prevItem], 1215 origin = Math.abs(base.positionsInArray[base.currentItem])+base.itemWidth/2; 1216 1217 base.$owlWrapper 1218 .addClass('owl-origin') 1219 .css({ 1220 "-webkit-transform-origin" : origin+"px", 1221 "-moz-perspective-origin" : origin+"px", 1222 "perspective-origin" : origin+"px" 1223 }); 1224 function transStyles(prevPos,zindex){ 1225 return { 1226 "position" : "relative", 1227 "left" : prevPos+"px" 1228 }; 1229 } 1230 1231 var animEnd = 'webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend'; 1232 1233 $prevItem 1234 .css(transStyles(prevPos,10)) 1235 .addClass(outClass) 1236 .on(animEnd, function() { 1237 base.endPrev = true; 1238 $prevItem.off(animEnd); 1239 base.clearTransStyle($prevItem,outClass); 1240 }); 1241 1242 $currentItem 1243 .addClass(inClass) 1244 .on(animEnd, function() { 1245 base.endCurrent = true; 1246 $currentItem.off(animEnd); 1247 base.clearTransStyle($currentItem,inClass); 1248 }); 1249 }, 1250 1251 clearTransStyle : function(item,classToRemove){ 1252 var base = this; 1253 item.css({ 1254 "position" : "", 1255 "left" : "" 1256 }) 1257 .removeClass(classToRemove); 1258 if(base.endPrev && base.endCurrent){ 1259 base.$owlWrapper.removeClass('owl-origin'); 1260 base.endPrev = false;
1261 base.endCurrent = false; 1262 base.isTransition = false; 1263 } 1264 }, 1265 1266 owlStatus : function(){ 1267 var base = this; 1268 base.owl = { 1269 "userOptions" : base.userOptions, 1270 "baseElement" : base.$elem, 1271 "userItems" : base.$userItems, 1272 "owlItems" : base.$owlItems, 1273 "currentItem" : base.currentItem, 1274 "prevItem" : base.prevItem, 1275 "visibleItems" : base.visibleItems, 1276 "isTouch" : base.browser.isTouch, 1277 "browser" : base.browser 1278 }; 1279 }, 1280 1281 clearEvents : function(){ 1282 var base = this; 1283 base.$elem.off(".owl owl mousedown.disableTextSelect"); 1284 $(document).off(".owl owl"); 1285 $(window).off("resize", base.resizer); 1286 }, 1287 1288 unWrap : function(){ 1289 var base = this; 1290 if(base.$elem.children().length !== 0){ 1291 base.$owlWrapper.unwrap(); 1292 base.$userItems.unwrap().unwrap(); 1293 if(base.owlControls){ 1294 base.owlControls.remove(); 1295 } 1296 } 1297 base.clearEvents(); 1298 base.$elem 1299 .attr("style", base.$elem.data("owl-originalStyles") || "") 1300 .attr("class", base.$elem.data("owl-originalClasses")); 1301 }, 1302 1303 destroy : function(){ 1304 var base = this; 1305 base.stop(); 1306 clearInterval(base.checkVisible); 1307 base.unWrap(); 1308 base.$elem.removeData(); 1309 }, 1310 1311 reinit : function(newOptions){ 1312 var base = this; 1313 var options = $.extend({}, base.userOptions, newOptions); 1314 base.unWrap(); 1315 base.init(options,base.$elem); 1316 }, 1317 1318 addItem : function(htmlString,targetPosition){ 1319 var base = this, 1320 position; 1321 1322 if(!htmlString){return false;} 1323 1324 if(base.$elem.children().length === 0){ 1325 base.$elem.append(htmlString); 1326 base.setVars(); 1327 return false; 1328 } 1329 base.unWrap(); 1330 if(targetPosition === undefined || targetPosition === -1){ 1331 position = -1; 1332 } else { 1333 position = targetPosition; 1334 } 1335 if(position >= base.$userItems.length || position === -1){ 1336 base.$userItems.eq(-1).after(htmlString); 1337 } else { 1338 base.$userItems.eq(position).before(htmlString); 1339 } 1340 1341 base.setVars(); 1342 }, 1343 1344 removeItem : function(targetPosition){ 1345 var base = this, 1346 position; 1347 1348 if(base.$elem.children().length === 0){return false;} 1349 1350 if(targetPosition === undefined || targetPosition === -1){ 1351 position = -1; 1352 } else { 1353 position = targetPosition; 1354 } 1355 1356 base.unWrap(); 1357 base.$userItems.eq(position).remove(); 1358 base.setVars(); 1359 } 1360 1361 }; 1362 1363 $.fn.owlCarousel = function( options ){ 1364 return this.each(function() { 1365 if($(this).data("owl-init") === true){ 1366 return false; 1367 } 1368 $(this).data("owl-init", true); 1369 var carousel = Object.create( Carousel ); 1370 carousel.init( options, this ); 1371 $.data( this, "owlCarousel", carousel ); 1372 }); 1373 }; 1374 1375 $.fn.owlCarousel.options = { 1376 1377 items : 5, 1378 itemsDesktop : [1199,4], 1379 itemsDesktopSmall : [979,3], 1380 itemsTablet : [768,2], 1381 itemsTabletSmall : false, 1382 itemsMobile : [479,1], 1383 singleItem : false, 1384 itemsScaleUp : false, 1385 1386 slideSpeed : 200, 1387 paginationSpeed : 800, 1388 rewindSpeed : 1000, 1389 1390 autoPlay : false, 1391 stopOnHover : false, 1392 1393 navigation : false, 1394 navigationText : ["prev","next"], 1395 rewindNav : true, 1396 scrollPerPage : false, 1397 1398 pagination : true, 1399 paginationNumbers : false, 1400 1401 responsive : true, 1402 responsiveRefreshRate : 200, 1403 responsiveBaseWidth : window, 1404 1405 1406 baseClass : "owl-carousel", 1407 theme : "owl-theme", 1408 1409 lazyLoad : false, 1410 lazyFollow : true, 1411 lazyEffect : "fade", 1412 1413 autoHeight : false, 1414 1415 jsonPath : false, 1416 jsonSuccess : false, 1417 1418 dragBeforeAnimFinish : true, 1419 mouseDrag : true, 1420 touchDrag : true, 1421 1422 addClassActive : false, 1423 transitionStyle : false, 1424 1425 beforeUpdate : false, 1426 afterUpdate : false, 1427 beforeInit : false, 1428 afterInit : false, 1429 beforeMove : false, 1430 afterMove : false, 1431 afterAction : false, 1432 startDragging : false 1433 1434 }; 1435})( jQuery, window, document );
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.