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