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