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