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); 805 806 isTouch = "ontouchstart" in window || window.navigator.msMaxTouchPoints; 807 808 base.browser = { 809 "support3d" : support3d, 810 "isTouch" : isTouch 811 }; 812 }, 813 814 moveEvents : function () { 815 var base = this; 816 if (base.options.mouseDrag !== false || base.options.touchDrag !== false) { 817 base.gestures(); 818 base.disabledEvents(); 819 } 820 }, 821 822 eventTypes : function () { 823 var base = this, 824 types = ["s", "e", "x"]; 825 826 base.ev_types = {}; 827 828 if (base.options.mouseDrag === true && base.options.touchDrag === true) { 829 types = [ 830 "touchstart.owl mousedown.owl", 831 "touchmove.owl mousemove.owl", 832 "touchend.owl touchcancel.owl mouseup.owl" 833 ]; 834 } else if (base.options.mouseDrag === false && base.options.touchDrag === true) { 835 types = [ 836 "touchstart.owl", 837 "touchmove.owl", 838 "touchend.owl touchcancel.owl" 839 ]; 840 } else if (base.options.mouseDrag === true && base.options.touchDrag === false) { 841 types = [ 842 "mousedown.owl", 843 "mousemove.owl", 844 "mouseup.owl" 845 ]; 846 } 847 848 base.ev_types.start = types[0]; 849 base.ev_types.move = types[1]; 850 base.ev_types.end = types[2]; 851 }, 852 853 disabledEvents : function () { 854 var base = this; 855 base.$elem.on("dragstart.owl", function (event) { event.preventDefault(); }); 856 base.$elem.on("mousedown.disableTextSelect", function (e) { 857 return $(e.target).is('input, textarea, select, option'); 858 }); 859 }, 860 861 gestures : function () { 862 /*jslint unparam: true*/ 863 var base = this, 864 locals = { 865 offsetX : 0, 866 offsetY : 0, 867 baseElWidth : 0, 868 relativePos : 0, 869 position: null, 870 minSwipe : null, 871 maxSwipe: null, 872 sliding : null, 873 dargging: null, 874 targetElement : null 875 }; 876 877 base.isCssFinish = true; 878 879 function getTouches(event) { 880 if (event.touches !== undefined) { 881 return { 882 x : event.touches[0].pageX, 883 y : event.touches[0].pageY 884 }; 885 } 886 887 if (event.touches === undefined) { 888 if (event.pageX !== undefined) { 889 return { 890 x : event.pageX, 891 y : event.pageY 892 }; 893 } 894 if (event.pageX === undefined) { 895 return { 896 x : event.clientX, 897 y : event.clientY 898 }; 899 } 900 } 901 } 902 903 function swapEvents(type) { 904 if (type === "on") { 905 $(document).on(base.ev_types.move, dragMove); 906 $(document).on(base.ev_types.end, dragEnd); 907 } else if (type === "off") { 908 $(document).off(base.ev_types.move); 909 $(document).off(base.ev_types.end); 910 } 911 } 912 913 function dragStart(event) { 914 var ev = event.originalEvent || event || window.event, 915 position; 916 917 if (ev.which === 3) { 918 return false; 919 } 920 if (base.itemsAmount <= base.options.items) { 921 return; 922 } 923 if (base.isCssFinish === false && !base.options.dragBeforeAnimFinish) { 924 return false; 925 } 926 if (base.isCss3Finish === false && !base.options.dragBeforeAnimFinish) { 927 return false; 928 } 929 930 if (base.options.autoPlay !== false) { 931 window.clearInterval(base.autoPlayInterval); 932 } 933 934 if (base.browser.isTouch !== true && !base.$owlWrapper.hasClass("grabbing")) { 935 base.$owlWrapper.addClass("grabbing"); 936 } 937 938 base.newPosX = 0; 939 base.newRelativeX = 0; 940 941 $(this).css(base.removeTransition()); 942 943 position = $(this).position(); 944 locals.relativePos = position.left; 945 946 locals.offsetX = getTouches(ev).x - position.left; 947 locals.offsetY = getTouches(ev).y - position.top; 948 949 swapEvents("on"); 950 951 locals.sliding = false; 952 locals.targetElement = ev.target || ev.srcElement; 953 } 954 955 function dragMove(event) { 956 var ev = event.originalEvent || event || window.event, 957 minSwipe, 958 maxSwipe; 959 960 base.newPosX = getTouches(ev).x - locals.offsetX; 961 base.newPosY = getTouches(ev).y - locals.offsetY; 962 base.newRelativeX = base.newPosX - locals.relativePos; 963 964 if (typeof base.options.startDragging === "function" && locals.dragging !== true && base.newRelativeX !== 0) { 965 locals.dragging = true; 966 base.options.startDragging.apply(base, [base.$elem]); 967 } 968 969 if ((base.newRelativeX > 8 || base.newRelativeX < -8) && (base.browser.isTouch === true)) { 970 if (ev.preventDefault !== undefined) { 971 ev.preventDefault(); 972 } else { 973 ev.returnValue = false; 974 } 975 locals.sliding = true; 976 } 977 978 if ((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false) { 979 $(document).off("touchmove.owl"); 980 } 981 982 minSwipe = function () { 983 return base.newRelativeX / 5; 984 }; 985 986 maxSwipe = function () { 987 return base.maximumPixels + base.newRelativeX / 5; 988 }; 989 990 base.newPosX = Math.max(Math.min(base.newPosX, minSwipe()), maxSwipe()); 991 if (base.browser.support3d === true) { 992 base.transition3d(base.newPosX); 993 } else { 994 base.css2move(base.newPosX); 995 } 996 } 997 998 function dragEnd(event) { 999 var ev = event.originalEvent || event || window.event, 1000 newPosition, 1001 handlers, 1002 owlStopEvent; 1003 1004 ev.target = ev.target || ev.srcElement; 1005 1006 locals.dragging = false; 1007 1008 if (base.browser.isTouch !== true) { 1009 base.$owlWrapper.removeClass("grabbing"); 1010 } 1011 1012 if (base.newRelativeX < 0) { 1013 base.dragDirection = base.owl.dragDirection = "left"; 1014 } else { 1015 base.dragDirection = base.owl.dragDirection = "right"; 1016 } 1017 1018 if (base.newRelativeX !== 0) { 1019 newPosition = base.getNewPosition(); 1020 base.goTo(newPosition, false, "drag"); 1021 if (locals.targetElement === ev.target && base.browser.isTouch !== true) { 1022 $(ev.target).on("click.disable", function (ev) { 1023 ev.stopImmediatePropagation(); 1024 ev.stopPropagation(); 1025 ev.preventDefault(); 1026 $(ev.target).off("click.disable"); 1027 }); 1028 handlers = $._data(ev.target, "events").click; 1029 owlStopEvent = handlers.pop(); 1030 handlers.splice(0, 0, owlStopEvent); 1031 } 1032 } 1033 swapEvents("off"); 1034 } 1035 base.$elem.on(base.ev_types.start, ".owl-wrapper", dragStart); 1036 }, 1037 1038 getNewPosition : function () { 1039 var base = this, 1040 newPosition = base.closestItem(); 1041 1042 if (newPosition > base.maximumItem) { 1043 base.currentItem = base.maximumItem; 1044 newPosition = base.maximumItem; 1045 } else if (base.newPosX >= 0) { 1046 newPosition = 0; 1047 base.currentItem = 0; 1048 } 1049 return newPosition; 1050 }, 1051 closestItem : function () { 1052 var base = this, 1053 array = base.options.scrollPerPage === true ? base.pagesInArray : base.positionsInArray, 1054 goal = base.newPosX, 1055 closest = null; 1056 1057 $.each(array, function (i, v) { 1058 if (goal - (base.itemWidth / 20) > array[i + 1] && goal - (base.itemWidth / 20) < v && base.moveDirection() === "left") { 1059 closest = v; 1060 if (base.options.scrollPerPage === true) { 1061 base.currentItem = $.inArray(closest, base.positionsInArray);
1062 } else { 1063 base.currentItem = i; 1064 } 1065 } else if (goal + (base.itemWidth / 20) < v && goal + (base.itemWidth / 20) > (array[i + 1] || array[i] - base.itemWidth) && base.moveDirection() === "right") { 1066 if (base.options.scrollPerPage === true) { 1067 closest = array[i + 1] || array[array.length - 1]; 1068 base.currentItem = $.inArray(closest, base.positionsInArray); 1069 } else { 1070 closest = array[i + 1]; 1071 base.currentItem = i + 1; 1072 } 1073 } 1074 }); 1075 return base.currentItem; 1076 }, 1077 1078 moveDirection : function () { 1079 var base = this, 1080 direction; 1081 if (base.newRelativeX < 0) { 1082 direction = "right"; 1083 base.playDirection = "next"; 1084 } else { 1085 direction = "left"; 1086 base.playDirection = "prev"; 1087 } 1088 return direction; 1089 }, 1090 1091 customEvents : function () { 1092 /*jslint unparam: true*/ 1093 var base = this; 1094 base.$elem.on("owl.next", function () { 1095 base.next(); 1096 }); 1097 base.$elem.on("owl.prev", function () { 1098 base.prev(); 1099 }); 1100 base.$elem.on("owl.play", function (event, speed) { 1101 base.options.autoPlay = speed; 1102 base.play(); 1103 base.hoverStatus = "play"; 1104 }); 1105 base.$elem.on("owl.stop", function () { 1106 base.stop(); 1107 base.hoverStatus = "stop"; 1108 }); 1109 base.$elem.on("owl.goTo", function (event, item) { 1110 base.goTo(item); 1111 }); 1112 base.$elem.on("owl.jumpTo", function (event, item) { 1113 base.jumpTo(item); 1114 }); 1115 }, 1116 1117 stopOnHover : function () { 1118 var base = this; 1119 if (base.options.stopOnHover === true && base.browser.isTouch !== true && base.options.autoPlay !== false) { 1120 base.$elem.on("mouseover", function () { 1121 base.stop(); 1122 }); 1123 base.$elem.on("mouseout", function () { 1124 if (base.hoverStatus !== "stop") { 1125 base.play(); 1126 } 1127 }); 1128 } 1129 }, 1130 1131 lazyLoad : function () { 1132 var base = this, 1133 i, 1134 $item, 1135 itemNumber, 1136 $lazyImg, 1137 follow; 1138 1139 if (base.options.lazyLoad === false) { 1140 return false; 1141 } 1142 for (i = 0; i < base.itemsAmount; i += 1) { 1143 $item = $(base.$owlItems[i]); 1144 1145 if ($item.data("owl-loaded") === "loaded") { 1146 continue; 1147 } 1148 1149 itemNumber = $item.data("owl-item"); 1150 $lazyImg = $item.find(".lazyOwl"); 1151 1152 if (typeof $lazyImg.data("src") !== "string") { 1153 $item.data("owl-loaded", "loaded"); 1154 continue; 1155 } 1156 if ($item.data("owl-loaded") === undefined) { 1157 $lazyImg.hide(); 1158 $item.addClass("loading").data("owl-loaded", "checked"); 1159 } 1160 if (base.options.lazyFollow === true) { 1161 follow = itemNumber >= base.currentItem; 1162 } else { 1163 follow = true; 1164 } 1165 if (follow && itemNumber < base.currentItem + base.options.items && $lazyImg.length) { 1166 base.lazyPreload($item, $lazyImg); 1167 } 1168 } 1169 }, 1170 1171 lazyPreload : function ($item, $lazyImg) { 1172 var base = this, 1173 iterations = 0,
1174 isBackgroundImg; 1175 1176 if ($lazyImg.prop("tagName") === "DIV") { 1177 $lazyImg.css("background-image", "url(" + $lazyImg.data("src") + ")"); 1178 isBackgroundImg = true; 1179 } else { 1180 $lazyImg[0].src = $lazyImg.data("src"); 1181 } 1182 1183 function showImage() { 1184 $item.data("owl-loaded", "loaded").removeClass("loading"); 1185 $lazyImg.removeAttr("data-src"); 1186 if (base.options.lazyEffect === "fade") { 1187 $lazyImg.fadeIn(400); 1188 } else { 1189 $lazyImg.show(); 1190 } 1191 if (typeof base.options.afterLazyLoad === "function") { 1192 base.options.afterLazyLoad.apply(this, [base.$elem]); 1193 } 1194 } 1195 1196 function checkLazyImage() { 1197 iterations += 1; 1198 if (base.completeImg($lazyImg.get(0)) || isBackgroundImg === true) { 1199 showImage(); 1200 } else if (iterations <= 100) {//if image loads in less than 10 seconds 1201 window.setTimeout(checkLazyImage, 100); 1202 } else { 1203 showImage(); 1204 } 1205 } 1206 1207 checkLazyImage(); 1208 }, 1209 1210 autoHeight : function () { 1211 var base = this, 1212 $currentimg = $(base.$owlItems[base.currentItem]).find("img"), 1213 iterations; 1214 1215 function addHeight() { 1216 var $currentItem = $(base.$owlItems[base.currentItem]).height(); 1217 base.wrapperOuter.css("height", $currentItem + "px"); 1218 if (!base.wrapperOuter.hasClass("autoHeight")) { 1219 window.setTimeout(function () { 1220 base.wrapperOuter.addClass("autoHeight"); 1221 }, 0); 1222 } 1223 } 1224 1225 function checkImage() { 1226 iterations += 1; 1227 if (base.completeImg($currentimg.get(0))) { 1228 addHeight(); 1229 } else if (iterations <= 100) { //if image loads in less than 10 seconds 1230 window.setTimeout(checkImage, 100); 1231 } else { 1232 base.wrapperOuter.css("height", ""); //Else remove height attribute 1233 } 1234 } 1235 1236 if ($currentimg.get(0) !== undefined) { 1237 iterations = 0; 1238 checkImage(); 1239 } else { 1240 addHeight(); 1241 } 1242 }, 1243 1244 completeImg : function (img) { 1245 var naturalWidthType; 1246 1247 if (!img.complete) { 1248 return false; 1249 } 1250 naturalWidthType = typeof img.naturalWidth;
1251 if (naturalWidthType !== "undefined" && img.naturalWidth === 0) { 1252 return false; 1253 } 1254 return true; 1255 }, 1256 1257 onVisibleItems : function () { 1258 var base = this, 1259 i; 1260 1261 if (base.options.addClassActive === true) { 1262 base.$owlItems.removeClass("active"); 1263 } 1264 base.visibleItems = []; 1265 for (i = base.currentItem; i < base.currentItem + base.options.items; i += 1) { 1266 base.visibleItems.push(i); 1267 1268 if (base.options.addClassActive === true) { 1269 $(base.$owlItems[i]).addClass("active"); 1270 } 1271 } 1272 base.owl.visibleItems = base.visibleItems; 1273 }, 1274 1275 transitionTypes : function (className) { 1276 var base = this; 1277 //Currently available: "fade", "backSlide", "goDown", "fadeUp" 1278 base.outClass = "owl-" + className + "-out"; 1279 base.inClass = "owl-" + className + "-in"; 1280 }, 1281 1282 singleItemTransition : function () { 1283 var base = this, 1284 outClass = base.outClass, 1285 inClass = base.inClass, 1286 $currentItem = base.$owlItems.eq(base.currentItem), 1287 $prevItem = base.$owlItems.eq(base.prevItem), 1288 prevPos = Math.abs(base.positionsInArray[base.currentItem]) + base.positionsInArray[base.prevItem], 1289 origin = Math.abs(base.positionsInArray[base.currentItem]) + base.itemWidth / 2, 1290 animEnd = 'webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend'; 1291 1292 base.isTransition = true; 1293 1294 base.$owlWrapper 1295 .addClass('owl-origin') 1296 .css({ 1297 "-webkit-transform-origin" : origin + "px", 1298 "-moz-perspective-origin" : origin + "px", 1299 "perspective-origin" : origin + "px" 1300 }); 1301 function transStyles(prevPos) { 1302 return { 1303 "position" : "relative", 1304 "left" : prevPos + "px" 1305 }; 1306 } 1307 1308 $prevItem 1309 .css(transStyles(prevPos, 10)) 1310 .addClass(outClass) 1311 .on(animEnd, function () { 1312 base.endPrev = true; 1313 $prevItem.off(animEnd); 1314 base.clearTransStyle($prevItem, outClass); 1315 }); 1316 1317 $currentItem 1318 .addClass(inClass) 1319 .on(animEnd, function () { 1320 base.endCurrent = true; 1321 $currentItem.off(animEnd); 1322 base.clearTransStyle($currentItem, inClass); 1323 }); 1324 }, 1325 1326 clearTransStyle : function (item, classToRemove) { 1327 var base = this; 1328 item.css({ 1329 "position" : "", 1330 "left" : "" 1331 }).removeClass(classToRemove); 1332 1333 if (base.endPrev && base.endCurrent) { 1334 base.$owlWrapper.removeClass('owl-origin'); 1335 base.endPrev = false; 1336 base.endCurrent = false; 1337 base.isTransition = false; 1338 } 1339 }, 1340 1341 owlStatus : function () { 1342 var base = this; 1343 base.owl = { 1344 "userOptions" : base.userOptions, 1345 "baseElement" : base.$elem, 1346 "userItems" : base.$userItems, 1347 "owlItems" : base.$owlItems, 1348 "currentItem" : base.currentItem, 1349 "prevItem" : base.prevItem, 1350 "visibleItems" : base.visibleItems, 1351 "isTouch" : base.browser.isTouch, 1352 "browser" : base.browser, 1353 "dragDirection" : base.dragDirection 1354 }; 1355 }, 1356 1357 clearEvents : function () { 1358 var base = this; 1359 base.$elem.off(".owl owl mousedown.disableTextSelect"); 1360 $(document).off(".owl owl"); 1361 $(window).off("resize", base.resizer); 1362 }, 1363 1364 unWrap : function () { 1365 var base = this; 1366 if (base.$elem.children().length !== 0) { 1367 base.$owlWrapper.unwrap(); 1368 base.$userItems.unwrap().unwrap(); 1369 if (base.owlControls) { 1370 base.owlControls.remove(); 1371 } 1372 } 1373 base.clearEvents(); 1374 base.$elem 1375 .attr("style", base.$elem.data("owl-originalStyles") || "") 1376 .attr("class", base.$elem.data("owl-originalClasses")); 1377 }, 1378 1379 destroy : function () { 1380 var base = this; 1381 base.stop(); 1382 window.clearInterval(base.checkVisible); 1383 base.unWrap(); 1384 base.$elem.removeData(); 1385 }, 1386 1387 reinit : function (newOptions) { 1388 var base = this, 1389 options = $.extend({}, base.userOptions, newOptions); 1390 base.unWrap(); 1391 base.init(options, base.$elem); 1392 }, 1393 1394 addItem : function (htmlString, targetPosition) { 1395 var base = this, 1396 position; 1397 1398 if (!htmlString) {return false; } 1399 1400 if (base.$elem.children().length === 0) { 1401 base.$elem.append(htmlString); 1402 base.setVars();
1403 return false; 1404 } 1405 base.unWrap(); 1406 if (targetPosition === undefined || targetPosition === -1) { 1407 position = -1; 1408 } else { 1409 position = targetPosition; 1410 } 1411 if (position >= base.$userItems.length || position === -1) { 1412 base.$userItems.eq(-1).after(htmlString); 1413 } else { 1414 base.$userItems.eq(position).before(htmlString); 1415 } 1416 1417 base.setVars(); 1418 }, 1419 1420 removeItem : function (targetPosition) { 1421 var base = this, 1422 position; 1423 1424 if (base.$elem.children().length === 0) { 1425 return false; 1426 } 1427 if (targetPosition === undefined || targetPosition === -1) { 1428 position = -1; 1429 } else { 1430 position = targetPosition; 1431 } 1432 1433 base.unWrap(); 1434 base.$userItems.eq(position).remove(); 1435 base.setVars(); 1436 } 1437 1438 }; 1439 1440 $.fn.owlCarousel = function (options) { 1441 return this.each(function () { 1442 if ($(this).data("owl-init") === true) { 1443 return false; 1444 } 1445 $(this).data("owl-init", true); 1446 var carousel = Object.create(Carousel); 1447 carousel.init(options, this); 1448 $.data(this, "owlCarousel", carousel); 1449 }); 1450 }; 1451 1452 $.fn.owlCarousel.options = { 1453 1454 items : 5, 1455 itemsCustom : false, 1456 itemsDesktop : [1199, 4], 1457 itemsDesktopSmall : [979, 3], 1458 itemsTablet : [768, 2], 1459 itemsTabletSmall : false, 1460 itemsMobile : [479, 1], 1461 singleItem : false, 1462 itemsScaleUp : false, 1463 1464 slideSpeed : 200, 1465 paginationSpeed : 800, 1466 rewindSpeed : 1000, 1467 1468 autoPlay : false, 1469 stopOnHover : false, 1470 1471 navigation : false, 1472 navigationText : ["prev", "next"], 1473 rewindNav : true, 1474 scrollPerPage : false, 1475 1476 pagination : true, 1477 paginationNumbers : false, 1478 1479 responsive : true, 1480 responsiveRefreshRate : 200, 1481 responsiveBaseWidth : window, 1482 1483 baseClass : "owl-carousel", 1484 theme : "owl-theme", 1485 1486 lazyLoad : false, 1487 lazyFollow : true, 1488 lazyEffect : "fade", 1489 1490 autoHeight : false, 1491 1492 jsonPath : false, 1493 jsonSuccess : false, 1494 1495 dragBeforeAnimFinish : true, 1496 mouseDrag : true, 1497 touchDrag : true, 1498 1499 addClassActive : false, 1500 transitionStyle : false, 1501 1502 beforeUpdate : false, 1503 afterUpdate : false, 1504 beforeInit : false, 1505 afterInit : false, 1506 beforeMove : false, 1507 afterMove : false, 1508 afterAction : false, 1509 startDragging : false, 1510 afterLazyLoad: false 1511 }; 1512}(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.