1/* 2 * jQuery OwlCarousel v1.23 3 * 4 * Copyright (c) 2013 Bartosz Wojciechowski 5 * http://www.owlgraphic.com/owlcarousel/ 6 * 7 * Licensed under MIT 8 * 9 */ 10 11// Object.create function 12if ( typeof Object.create !== "function" ) { 13 Object.create = function( obj ) { 14 function F() {}; 15 F.prototype = obj; 16 return new F(); 17 }; 18} 19(function( $, window, document, undefined ) { 20 21 var Carousel = { 22 init :function(options, el){ 23 var base = this; 24 base.options = base.userOptions = $.extend({}, $.fn.owlCarousel.options, options); 25 var elem = el; 26 var $elem = $(el); 27 base.$elem = $elem; 28 base.loadContent(); 29 30 console.log(base.options); 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(){ 62 var base = this; 63 64 base.baseClass(); 65 66 base.$elem 67 .css({opacity: 0}); 68 69 base.eventTypes(); 70 base.checkBrowser(); 71 72 base.wrapperWidth = 0; 73 base.currentItem = 0; //Starting Position 74 75 base.$userItems = base.$elem.children(); 76 base.itemsAmount = base.$userItems.length; 77 base.wrapItems(); 78 79 base.owlItems = base.$elem.find(".owl-item"); 80 base.$owlItems = $(base.owlItems); 81 base.owlWrapper = base.$elem.find(".owl-wrapper"); 82 83 base.orignalItems = base.options.items; 84 base.playDirection = "next"; 85 base.prevItem = 0;//base.options.startPosition; 86 base.checkVisible; 87 88 base.customEvents(); 89 base.onStartup(); 90 }, 91 92 onStartup : function(){ 93 var base = this; 94 base.updateItems(); 95 base.calculateAll(); 96 base.buildControls(); 97 base.updateControls(); 98 base.response(); 99 base.moveEvents(); 100 base.stopOnHover(); 101 base.owlStatus(); 102 103 if(base.options.transitionStyle !== false){ 104 base.transitionTypes(base.options.transitionStyle); 105 } 106 if(base.options.autoPlay === true){ 107 base.options.autoPlay = 5000; 108 } 109 110 base.play(); 111 base.$elem.find(".owl-wrapper").css("display","block") 112 113 if(!base.$elem.is(":visible")){ 114 base.watchVisibility(); 115 } else { 116 setTimeout(function(){ 117 base.$elem.animate({opacity: 1},200); 118 },10); 119 } 120 base.onstartup = false; 121 base.eachMoveUpdate(); 122 if (typeof base.options.afterInit === "function") { 123 base.options.afterInit.apply(this,[base.$elem]); 124 } 125 }, 126 127 eachMoveUpdate : function(){ 128 var base = this; 129 130 if(base.options.lazyLoad === true){ 131 base.lazyLoad(); 132 } 133 if(base.options.autoHeight === true){ 134 base.autoHeight(); 135 } 136 if(base.options.addClassActive === true){ 137 base.addClassActive(); 138 } 139 if (typeof base.options.afterAction === "function") { 140 base.options.afterAction.apply(this,[base.$elem]); 141 } 142 }, 143 144 updateVars : function(){ 145 var base = this; 146 base.watchVisibility(); 147 base.updateItems(); 148 base.calculateAll(); 149 base.updatePosition(); 150 base.updateControls(); 151 base.eachMoveUpdate(); 152 }, 153 154 reload : function(elements){ 155 var base = this; 156 setTimeout(function(){ 157 base.updateVars(); 158 },0) 159 }, 160 161 watchVisibility : function(){ 162 var base = this; 163 164 if(base.$elem.is(":visible") === false){ 165 base.$elem.css({opacity: 0}); 166 clearInterval(base.autoPlayInterval); 167 clearInterval(base.checkVisible); 168 } else { 169 return false; 170 } 171 base.checkVisible = setInterval(function(){ 172 if (base.$elem.is(":visible")) { 173 base.reload(); 174 base.$elem.animate({opacity: 1},200); 175 clearInterval(base.checkVisible); 176 } 177 }, 500); 178 }, 179 180 wrapItems : function(){ 181 var base = this; 182 base.$userItems.wrapAll("<div class=\"owl-wrapper\">").wrap("<div class=\"owl-item\"></div>"); 183 base.$elem.find(".owl-wrapper").wrap("<div class=\"owl-wrapper-outer\">"); 184 base.wrapperOuter = base.$elem.find(".owl-wrapper-outer"); 185 base.$elem.css("display","block"); 186 }, 187 188 baseClass : function(){ 189 var base = this; 190 var hasBaseClass = base.$elem.hasClass(base.options.baseClass); 191 var hasThemeClass = base.$elem.hasClass(base.options.theme); 192 193 if(!hasBaseClass){ 194 base.$elem.addClass(base.options.baseClass); 195 } 196 197 if(!hasThemeClass){ 198 base.$elem.addClass(base.options.theme); 199 } 200 }, 201 202 updateItems : function(){ 203 var base = this; 204 205 if(base.options.responsive === false){ 206 return false;
207 } 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 $(window).resize(function(){ 259 if($(window).width() !== lastWindowWidth){ 260 if(base.options.autoPlay !== false){ 261 clearInterval(base.autoPlayInterval); 262 } 263 clearTimeout(smallDelay); 264 smallDelay = setTimeout(function(){ 265 lastWindowWidth = $(window).width(); 266 base.updateVars(); 267 },base.options.responsiveRefreshRate); 268 } 269 }) 270 }, 271 272 updatePosition : function(){ 273 var base = this; 274 275 if(base.browser.support3d === true){ 276 if(base.positionsInArray[base.currentItem] > base.maximumPixels){ 277 base.transition3d(base.positionsInArray[base.currentItem]); 278 } else { 279 base.transition3d(0); 280 base.currentItem = 0; 281 } 282 } else{ 283 if(base.positionsInArray[base.currentItem] > base.maximumPixels){ 284 base.css2slide(base.positionsInArray[base.currentItem]); 285 } else { 286 base.css2slide(0); 287 base.currentItem = 0; 288 } 289 } 290 if(base.options.autoPlay !== false){ 291 base.checkAp(); 292 } 293 }, 294 295 appendItemsSizes : function(){ 296 var base = this; 297 298 var roundPages = 0; 299 var lastItem = base.itemsAmount - base.options.items; 300 301 base.owlItems.each(function(index){ 302 var $this = $(this); 303 $this 304 .css({"width": base.itemWidth}) 305 .data("owl-item",Number(index)); 306 307 if(index % base.options.items === 0 || index === lastItem){ 308 if(!(index > lastItem)){ 309 roundPages +=1; 310 } 311 } 312 $this 313 .data("owl-roundPages",roundPages) 314 .data("owl-originalStyles", $this.attr("style")); 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){ 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","img", function(event) { event.preventDefault();}); 827 base.$elem.bind("mousedown.disableTextSelect", function() {return false;}); 828 }, 829 830 gestures : function(){ 831 var base = this; 832 833 var locals = { 834 offsetX : 0, 835 offsetY : 0, 836 baseElWidth : 0, 837 relativePos : 0, 838 position: null, 839 minSwipe : null, 840 maxSwipe: null, 841 sliding : null, 842 dargging: null, 843 targetElement : null 844 } 845 846 base.isCssFinish = true; 847 848 function getTouches(event){ 849 if(event.touches){ 850 return { 851 x : event.touches[0].pageX, 852 y : event.touches[0].pageY 853 } 854 } else { 855 if(event.pageX !== undefined){ 856 return { 857 x : event.pageX, 858 y : event.pageY 859 } 860 } else { 861 return { 862 x : event.clientX, 863 y : event.clientY 864 } 865 } 866 } 867 } 868 869 function swapEvents(type){ 870 if(type === "on"){ 871 $(document).on(base.ev_types["move"], dragMove); 872 $(document).on(base.ev_types["end"], dragEnd); 873 } else if(type === "off"){ 874 $(document).off(base.ev_types["move"]); 875 $(document).off(base.ev_types["end"]); 876 } 877 } 878 function dragStart(event) { 879 var event = event.originalEvent || event || window.event; 880 881 if(base.isCssFinish === false){ 882 return false;
883 } 884 if(base.isCss3Finish === false){ 885 return false; 886 } 887 888 if(base.options.autoPlay !== false){ 889 clearInterval(base.autoPlayInterval); 890 } 891 892 if(base.browser.isTouch !== true && !base.owlWrapper.hasClass("grabbing")){ 893 base.owlWrapper.addClass("grabbing") 894 } 895 896 base.newPosX = 0; 897 base.newRelativeX = 0; 898 899 $(this).css(base.removeTransition()); 900 901 var position = $(this).position(); 902 locals.relativePos = position.left; 903 904 locals.offsetX = getTouches(event).x - position.left; 905 locals.offsetY = getTouches(event).y - position.top; 906 907 swapEvents("on"); 908 909 locals.sliding = false; 910 locals.targetElement = event.target || event.srcElement; 911 } 912 913 function dragMove(event){ 914 var event = event.originalEvent || event || window.event; 915 916 base.newPosX = getTouches(event).x- locals.offsetX; 917 base.newPosY = getTouches(event).y - locals.offsetY; 918 base.newRelativeX = base.newPosX - locals.relativePos; 919 920 if (typeof base.options.startDragging === "function" && locals.dragging !== true && base.newPosX !== 0) { 921 locals.dragging = true; 922 base.options.startDragging.apply(this); 923 } 924 925 if(base.newRelativeX > 8 || base.newRelativeX < -8 && base.browser.isTouch === true){ 926 event.preventDefault ? event.preventDefault() : event.returnValue = false; 927 locals.sliding = true; 928 } 929 930 if((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false){ 931 $(document).off("touchmove.owl"); 932 } 933 934 var minSwipe = function(){ 935 return base.newRelativeX / 5; 936 } 937 var maxSwipe = function(){ 938 return base.maximumPixels + base.newRelativeX / 5; 939 } 940 941 base.newPosX = Math.max(Math.min( base.newPosX, minSwipe() ), maxSwipe() ); 942 if(base.browser.support3d === true){ 943 base.transition3d(base.newPosX); 944 } else { 945 base.css2move(base.newPosX); 946 } 947 } 948 949 function dragEnd(event){ 950 var event = event.originalEvent || event || window.event; 951 event.target = event.target || event.srcElement; 952 953 locals.dragging = false; 954 955 if(base.browser.isTouch !== true){ 956 base.owlWrapper.removeClass("grabbing"); 957 } 958 959 if(base.newPosX !== 0){ 960 var newPosition = base.getNewPosition(); 961 base.goTo(newPosition,false,"drag"); 962 if(locals.targetElement === event.target && base.browser.isTouch !== true){ 963 $(event.target).on("click.disable", function(ev){ 964 ev.stopImmediatePropagation(); 965 ev.stopPropagation(); 966 ev.preventDefault(); 967 $(event.target).off("click.disable"); 968 }); 969 var handlers = $._data(event.target, "events")["click"]; 970 var owlStopEvent = handlers.pop(); 971 handlers.splice(0, 0, owlStopEvent); 972 } 973 } 974 swapEvents("off"); 975 } 976 base.$elem.on(base.ev_types["start"], ".owl-wrapper", dragStart); 977 }, 978 979 clearEvents : function(){ 980 var base = this; 981 base.$elem.off(".owl"); 982 $(document).off(".owl"); 983 }, 984 985 getNewPosition : function(){ 986 var base = this, 987 newPosition; 988 989 var newPosition = base.improveClosest(); 990 if(newPosition>base.maximumItem){ 991 base.currentItem = base.maximumItem; 992 newPosition = base.maximumItem; 993 } else if( base.newPosX >=0 ){ 994 newPosition = 0; 995 base.currentItem = 0; 996 } 997 return newPosition; 998 }, 999 1000 improveClosest : function(){ 1001 var base = this; 1002 var array = base.positionsInArray; 1003 var goal = base.newPosX; 1004 var closest = null; 1005 $.each(array, function(i,v){ 1006 if( goal - (base.itemWidth/20) > array[i+1] && goal - (base.itemWidth/20)< v && base.moveDirection() === "left") { 1007 closest = v; 1008 base.currentItem = i; 1009 } 1010 else if (goal + (base.itemWidth/20) < v && goal + (base.itemWidth/20) > array[i+1] && base.moveDirection() === "right"){ 1011 closest = array[i+1]; 1012 base.currentItem = i+1; 1013 } 1014 }); 1015 return base.currentItem; 1016 }, 1017 1018 moveDirection : function(){ 1019 var base = this, 1020 direction; 1021 if(base.newRelativeX < 0 ){ 1022 direction = "right" 1023 base.playDirection = "next" 1024 } else { 1025 direction = "left" 1026 base.playDirection = "prev" 1027 } 1028 return direction 1029 }, 1030 1031 customEvents : function(){ 1032 var base = this; 1033 base.$elem.on("owl.next",function(){ 1034 base.next(); 1035 }); 1036 base.$elem.on("owl.prev",function(){ 1037 base.prev(); 1038 }); 1039 base.$elem.on("owl.play",function(event,speed){ 1040 base.options.autoPlay = speed; 1041 base.play(); 1042 base.hoverStatus = "play"; 1043 }); 1044 base.$elem.on("owl.stop",function(){ 1045 base.stop(); 1046 base.hoverStatus = "stop"; 1047 });
1048 base.$elem.on("owl.goTo",function(event,item){ 1049 base.goTo(item) 1050 }); 1051 base.$elem.on("owl.jumpTo",function(event,item){ 1052 base.jumpTo(item) 1053 }); 1054 }, 1055 1056 stopOnHover : function(){ 1057 var base = this; 1058 if(base.options.stopOnHover === true && base.browser.isTouch !== true && base.options.autoPlay !== false){ 1059 base.$elem.on("mouseover", function(){ 1060 base.stop(); 1061 }); 1062 base.$elem.on("mouseout", function(){ 1063 if(base.hoverStatus !== "stop"){ 1064 base.play(); 1065 } 1066 }); 1067 } 1068 }, 1069 1070 lazyLoad : function(){ 1071 var base = this; 1072 1073 if(base.options.lazyLoad === false){ 1074 return false; 1075 } 1076 1077 for(var i=0; i<base.itemsAmount; i++){ 1078 var item = $(base.owlItems[i]), 1079 itemNumber = item.data("owl-item"), 1080 lazyImg = item.find(".lazyOwl"), 1081 follow; 1082 1083 if(item.data("owl-loaded") === undefined){ 1084 lazyImg.hide(); 1085 item.addClass("loading").data("owl-loaded","checked"); 1086 } else if(item.data("owl-loaded") === "loaded"){ 1087 continue; 1088 } 1089 1090 if(base.options.lazyFollow === true){ 1091 follow = itemNumber >= base.currentItem; 1092 }else { 1093 follow = true; 1094 } 1095 1096 if(follow && itemNumber < base.currentItem + base.options.items){ 1097 item.data("owl-loaded", "loaded"); 1098 1099 var link = lazyImg.data("src"); 1100 if(link){ 1101 lazyImg[0].src = link; 1102 lazyImg.removeAttr("data-src"); 1103 } 1104 lazyImg.fadeIn(200); 1105 item.removeClass("loading"); 1106 } 1107 } 1108 }, 1109 1110 autoHeight : function(){ 1111 var base = this; 1112 var $currentimg = $(base.owlItems[base.currentItem]).find("img"); 1113 1114 if($currentimg.get(0) !== undefined ){ 1115 var iterations = 0; 1116 checkImage(); 1117 } else { 1118 addHeight(); 1119 } 1120 function checkImage(){ 1121 iterations += 1; 1122 if ($currentimg.get(0).complete) { 1123 addHeight(); 1124 } else if(iterations <= 50){ //if image loads in less than 10 seconds 1125 setTimeout(checkImage,200); 1126 } else { 1127 base.wrapperOuter.css("height", ""); //Else remove height attribute 1128 } 1129 } 1130 1131 function addHeight(){ 1132 var $currentItem = $(base.owlItems[base.currentItem]).height(); 1133 base.wrapperOuter.css("height",$currentItem+"px"); 1134 if(!base.wrapperOuter.hasClass("autoHeight")){ 1135 setTimeout(function(){ 1136 base.wrapperOuter.addClass("autoHeight"); 1137 },0); 1138 } 1139 } 1140 }, 1141 1142 addClassActive : function(){ 1143 var base = this; 1144 $(base.owlItems).removeClass("active"); 1145 for(var i=base.currentItem; i<base.currentItem + base.options.items; i++){ 1146 $(base.owlItems[i]).addClass("active"); 1147 } 1148 }, 1149 1150 transitionTypes : function(className){ 1151 var base = this; 1152 //Currently available: "fade","backSlide","goDown","fadeUp" 1153 base.outClass = "owl-"+className+"-out"; 1154 base.inClass = "owl-"+className+"-in"; 1155 }, 1156 1157 singleItemTransition : function(){ 1158 var base = this; 1159 base.isTransition = true; 1160 1161 var outClass = base.outClass, 1162 inClass = base.inClass, 1163 $currentItem = base.$owlItems.eq(base.currentItem), 1164 $prevItem = base.$owlItems.eq(base.prevItem), 1165 prevPos = Math.abs(base.positionsInArray[base.currentItem]) + base.positionsInArray[base.prevItem], 1166 origin = Math.abs(base.positionsInArray[base.currentItem])+base.itemWidth/2; 1167 1168 base.owlWrapper 1169 .addClass('owl-origin') 1170 .css({ 1171 "-webkit-transform-origin" : origin+"px", 1172 "-moz-perspective-origin" : origin+"px", 1173 "perspective-origin" : origin+"px" 1174 }); 1175 function transStyles(prevPos,zindex){ 1176 return { 1177 "position" : "relative", 1178 "left" : prevPos+"px" 1179 }; 1180 } 1181 1182 var animEnd = 'webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend'; 1183 1184 $prevItem 1185 .css(transStyles(prevPos,10)) 1186 .addClass(outClass) 1187 .on(animEnd, function() { 1188 base.endPrev = true; 1189 $prevItem.off(animEnd); 1190 base.clearTransStyle($prevItem,outClass); 1191 }); 1192 1193 $currentItem 1194 .addClass(inClass) 1195 .on(animEnd, function() { 1196 base.endCurrent = true; 1197 $currentItem.off(animEnd); 1198 base.clearTransStyle($currentItem,inClass); 1199 }); 1200 }, 1201 1202 clearTransStyle : function(item,classToRemove){ 1203 var base = this; 1204 item.attr("style", item.data("owl-originalStyles")) 1205 .removeClass(classToRemove); 1206 if(base.endPrev && base.endCurrent){ 1207 base.owlWrapper.removeClass('owl-origin'); 1208 base.endPrev = false;
1209 base.endCurrent = false; 1210 base.isTransition = false; 1211 } 1212 }, 1213 1214 owlStatus : function(){ 1215 var base = this; 1216 base.owl = { 1217 "userOptions" : base.userOptions, 1218 "baseElement" : base.$elem, 1219 "userItems" : base.$userItems, 1220 "owlItems" : base.$owlItems, 1221 "currentItem" : base.currentItem, 1222 "prevItem" : base.prevItem, 1223 "isTouch" : base.browser.isTouch, 1224 "browser" : base.browser 1225 } 1226 } 1227 }; 1228 1229 $.fn.owlCarousel = function( options ){ 1230 return this.each(function() { 1231 var carousel = Object.create( Carousel ); 1232 carousel.init( options, this ); 1233 $.data( this, "owlCarousel", carousel ); 1234 }); 1235 }; 1236 1237 $.fn.owlCarousel.options = { 1238 1239 items : 5, 1240 itemsDesktop : [1199,4], 1241 itemsDesktopSmall : [979,3], 1242 itemsTablet: [768,2], 1243 itemsTabletSmall: false, 1244 itemsMobile : [479,1], 1245 singleItem:false, 1246 1247 slideSpeed : 200, 1248 paginationSpeed : 800, 1249 rewindSpeed : 1000, 1250 1251 autoPlay : false, 1252 stopOnHover : false, 1253 1254 navigation : false, 1255 navigationText : ["prev","next"], 1256 rewindNav : true, 1257 scrollPerPage : false, 1258 1259 pagination : true, 1260 paginationNumbers: false, 1261 1262 responsive: true, 1263 responsiveRefreshRate : 200, 1264 responsiveBaseWidth: window, 1265 1266 baseClass : "owl-carousel", 1267 theme : "owl-theme", 1268 1269 lazyLoad : false, 1270 lazyFollow : true, 1271 1272 autoHeight : false, 1273 1274 jsonPath : false, 1275 jsonSuccess : false, 1276 1277 mouseDrag : true, 1278 touchDrag : true, 1279 1280 addClassActive : false, 1281 transitionStyle : false, 1282 1283 beforeInit : false, 1284 afterInit : false, 1285 beforeMove: false, 1286 afterMove: false, 1287 afterAction : false, 1288 startDragging : false 1289 1290 1291 }; 1292})( 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.