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