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