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