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