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 23(function ($, window, document) { 24 25 var Carousel = { 26 init : function (options, el) { 27 var base = this; 28 29 base.$elem = $(el); 30 base.options = $.extend({}, $.fn.owlCarousel.options, base.$elem.data(), options); 31 32 base.userOptions = options; 33 base.loadContent(); 34 }, 35 36 loadContent : function () { 37 var base = this, url; 38 39 function getData(data) { 40 var i, content = ""; 41 if (typeof base.options.jsonSuccess === "function") { 42 base.options.jsonSuccess.apply(this, [data]); 43 } else { 44 for (i in data.owl) { 45 if (data.owl.hasOwnProperty(i)) { 46 content += data.owl[i].item; 47 } 48 } 49 base.$elem.html(content); 50 } 51 base.logIn(); 52 } 53 54 if (typeof base.options.beforeInit === "function") { 55 base.options.beforeInit.apply(this, [base.$elem]); 56 } 57 58 if (typeof base.options.jsonPath === "string") { 59 url = base.options.jsonPath; 60 $.getJSON(url, getData); 61 } else { 62 base.logIn(); 63 } 64 }, 65 66 logIn : function () { 67 var base = this; 68 69 base.$elem.data("owl-originalStyles", base.$elem.attr("style")); 70 base.$elem.data("owl-originalClasses", base.$elem.attr("class")); 71 72 base.$elem.css({opacity: 0}); 73 base.orignalItems = base.options.items; 74 base.checkBrowser(); 75 base.wrapperWidth = 0; 76 base.checkVisible = null; 77 base.setVars(); 78 }, 79 80 setVars : function () { 81 var base = this; 82 if (base.$elem.children().length === 0) {return false; } 83 base.baseClass(); 84 base.eventTypes(); 85 base.$userItems = base.$elem.children(); 86 base.itemsAmount = base.$userItems.length; 87 base.wrapItems(); 88 base.$owlItems = base.$elem.find(".owl-item"); 89 base.$owlWrapper = base.$elem.find(".owl-wrapper"); 90 base.playDirection = "next"; 91 base.prevItem = 0; 92 base.prevArr = [0]; 93 base.currentItem = 0; 94 base.customEvents(); 95 base.onStartup(); 96 }, 97 98 onStartup : function () { 99 var base = this; 100 base.updateItems(); 101 base.calculateAll(); 102 base.buildControls(); 103 base.updateControls(); 104 base.response(); 105 base.moveEvents(); 106 base.stopOnHover(); 107 base.owlStatus(); 108 109 if (base.options.transitionStyle !== false) { 110 base.transitionTypes(base.options.transitionStyle); 111 } 112 if (base.options.autoPlay === true) { 113 base.options.autoPlay = 5000; 114 } 115 base.play(); 116 117 base.$elem.find(".owl-wrapper").css("display", "block"); 118 119 if (!base.$elem.is(":visible")) { 120 base.watchVisibility(); 121 } else { 122 base.$elem.css("opacity", 1); 123 } 124 base.onstartup = false; 125 base.eachMoveUpdate(); 126 if (typeof base.options.afterInit === "function") { 127 base.options.afterInit.apply(this, [base.$elem]); 128 } 129 }, 130 131 eachMoveUpdate : function () { 132 var base = this; 133 134 if (base.options.lazyLoad === true) { 135 base.lazyLoad(); 136 } 137 if (base.options.autoHeight === true) { 138 base.autoHeight(); 139 } 140 base.onVisibleItems(); 141 142 if (typeof base.options.afterAction === "function") { 143 base.options.afterAction.apply(this, [base.$elem]); 144 } 145 }, 146
147 updateVars : function () { 148 var base = this; 149 if (typeof base.options.beforeUpdate === "function") { 150 base.options.beforeUpdate.apply(this, [base.$elem]); 151 } 152 base.watchVisibility(); 153 base.updateItems(); 154 base.calculateAll(); 155 base.updatePosition(); 156 base.updateControls(); 157 base.eachMoveUpdate(); 158 if (typeof base.options.afterUpdate === "function") { 159 base.options.afterUpdate.apply(this, [base.$elem]); 160 } 161 }, 162 163 reload : function () { 164 var base = this; 165 window.setTimeout(function () { 166 base.updateVars(); 167 }, 0); 168 }, 169 170 watchVisibility : function () { 171 var base = this; 172 173 if (base.$elem.is(":visible") === false) { 174 base.$elem.css({opacity: 0}); 175 window.clearInterval(base.autoPlayInterval); 176 window.clearInterval(base.checkVisible); 177 } else { 178 return false; 179 } 180 base.checkVisible = window.setInterval(function () { 181 if (base.$elem.is(":visible")) { 182 base.reload(); 183 base.$elem.animate({opacity: 1}, 200); 184 window.clearInterval(base.checkVisible); 185 } 186 }, 500); 187 }, 188 189 wrapItems : function () { 190 var base = this; 191 base.$userItems.wrapAll("<div class=\"owl-wrapper\"></div>").wrap("<div class=\"owl-item\"></div>"); 192 base.$elem.find(".owl-wrapper").wrap("<div class=\"owl-wrapper-outer\"></div>"); 193 base.wrapperOuter = base.$elem.find(".owl-wrapper-outer"); 194 base.$elem.css("display", "block"); 195 }, 196 197 baseClass : function () { 198 var base = this, 199 hasBaseClass = base.$elem.hasClass(base.options.baseClass), 200 hasThemeClass = base.$elem.hasClass(base.options.theme); 201 202 if (!hasBaseClass) { 203 base.$elem.addClass(base.options.baseClass); 204 } 205 206 if (!hasThemeClass) { 207 base.$elem.addClass(base.options.theme); 208 } 209 }, 210 211 updateItems : function () { 212 var base = this, width, i; 213 214 if (base.options.responsive === false) { 215 return false; 216 } 217 if (base.options.singleItem === true) { 218 base.options.items = base.orignalItems = 1; 219 base.options.itemsCustom = false; 220 base.options.itemsDesktop = false; 221 base.options.itemsDesktopSmall = false; 222 base.options.itemsTablet = false; 223 base.options.itemsTabletSmall = false; 224 base.options.itemsMobile = false; 225 return false; 226 } 227 228 width = $(base.options.responsiveBaseWidth).width(); 229 230 if (width > (base.options.itemsDesktop[0] || base.orignalItems)) { 231 base.options.items = base.orignalItems; 232 } 233 if (base.options.itemsCustom !== false) { 234 //Reorder array by screen size 235 base.options.itemsCustom.sort(function (a, b) {return a[0] - b[0]; }); 236 237 for (i = 0; i < base.options.itemsCustom.length; i += 1) { 238 if (base.options.itemsCustom[i][0] <= width) { 239 base.options.items = base.options.itemsCustom[i][1]; 240 } 241 } 242 243 } else { 244 245 if (width <= base.options.itemsDesktop[0] && base.options.itemsDesktop !== false) { 246 base.options.items = base.options.itemsDesktop[1]; 247 } 248 249 if (width <= base.options.itemsDesktopSmall[0] && base.options.itemsDesktopSmall !== false) { 250 base.options.items = base.options.itemsDesktopSmall[1]; 251 } 252 253 if (width <= base.options.itemsTablet[0] && base.options.itemsTablet !== false) { 254 base.options.items = base.options.itemsTablet[1]; 255 } 256 257 if (width <= base.options.itemsTabletSmall[0] && base.options.itemsTabletSmall !== false) { 258 base.options.items = base.options.itemsTabletSmall[1]; 259 } 260 261 if (width <= base.options.itemsMobile[0] && base.options.itemsMobile !== false) { 262 base.options.items = base.options.itemsMobile[1]; 263 } 264 } 265 266 //if number of items is less than declared 267 if (base.options.items > base.itemsAmount && base.options.itemsScaleUp === true) { 268 base.options.items = base.itemsAmount; 269 } 270 }, 271 272 response : function () { 273 var base = this, 274 smallDelay, 275 lastWindowWidth; 276 277 if (base.options.responsive !== true) { 278 return false;
279 } 280 lastWindowWidth = $(window).width(); 281 282 base.resizer = function () { 283 if ($(window).width() !== lastWindowWidth) { 284 if (base.options.autoPlay !== false) { 285 window.clearInterval(base.autoPlayInterval); 286 } 287 window.clearTimeout(smallDelay); 288 smallDelay = window.setTimeout(function () { 289 lastWindowWidth = $(window).width(); 290 base.updateVars(); 291 }, base.options.responsiveRefreshRate); 292 } 293 }; 294 $(window).resize(base.resizer); 295 }, 296 297 updatePosition : function () { 298 var base = this; 299 base.jumpTo(base.currentItem); 300 if (base.options.autoPlay !== false) { 301 base.checkAp(); 302 } 303 }, 304 305 appendItemsSizes : function () { 306 var base = this, 307 roundPages = 0, 308 lastItem = base.itemsAmount - base.options.items; 309 310 base.$owlItems.each(function (index) { 311 var $this = $(this); 312 $this 313 .css({"width": base.itemWidth}) 314 .data("owl-item", Number(index)); 315 316 if (index % base.options.items === 0 || index === lastItem) { 317 if (!(index > lastItem)) { 318 roundPages += 1; 319 } 320 } 321 $this.data("owl-roundPages", roundPages); 322 }); 323 }, 324 325 appendWrapperSizes : function () { 326 var base = this, 327 width = base.$owlItems.length * base.itemWidth; 328 329 base.$owlWrapper.css({ 330 "width": width * 2, 331 "left": 0 332 }); 333 base.appendItemsSizes(); 334 }, 335 336 calculateAll : function () { 337 var base = this; 338 base.calculateWidth(); 339 base.appendWrapperSizes(); 340 base.loops(); 341 base.max(); 342 }, 343 344 calculateWidth : function () { 345 var base = this; 346 base.itemWidth = Math.round(base.$elem.width() / base.options.items); 347 }, 348 349 max : function () { 350 var base = this, 351 maximum = ((base.itemsAmount * base.itemWidth) - base.options.items * base.itemWidth) * -1; 352 if (base.options.items > base.itemsAmount) { 353 base.maximumItem = 0; 354 maximum = 0; 355 base.maximumPixels = 0; 356 } else { 357 base.maximumItem = base.itemsAmount - base.options.items; 358 base.maximumPixels = maximum; 359 } 360 return maximum; 361 }, 362 363 min : function () { 364 return 0; 365 }, 366 367 loops : function () { 368 var base = this, 369 prev = 0, 370 elWidth = 0, 371 i, 372 item, 373 roundPageNum; 374 375 base.positionsInArray = [0]; 376 base.pagesInArray = []; 377 378 for (i = 0; i < base.itemsAmount; i += 1) { 379 elWidth += base.itemWidth; 380 base.positionsInArray.push(-elWidth); 381 382 if (base.options.scrollPerPage === true) { 383 item = $(base.$owlItems[i]); 384 roundPageNum = item.data("owl-roundPages"); 385 if (roundPageNum !== prev) { 386 base.pagesInArray[prev] = base.positionsInArray[i]; 387 prev = roundPageNum; 388 } 389 } 390 } 391 }, 392 393 buildControls : function () { 394 var base = this; 395 if (base.options.navigation === true || base.options.pagination === true) { 396 base.owlControls = $("<div class=\"owl-controls\"/>").toggleClass("clickable", !base.browser.isTouch).appendTo(base.$elem); 397 } 398 if (base.options.pagination === true) { 399 base.buildPagination(); 400 } 401 if (base.options.navigation === true) { 402 base.buildButtons(); 403 } 404 }, 405 406 buildButtons : function () { 407 var base = this, 408 buttonsWrapper = $("<div class=\"owl-buttons\"/>"); 409 base.owlControls.append(buttonsWrapper); 410 411 base.buttonPrev = $("<div/>", { 412 "class" : "owl-prev", 413 "html" : base.options.navigationText[0] || "" 414 }); 415 416 base.buttonNext = $("<div/>", { 417 "class" : "owl-next", 418 "html" : base.options.navigationText[1] || "" 419 }); 420 421 buttonsWrapper 422 .append(base.buttonPrev) 423 .append(base.buttonNext); 424 425 buttonsWrapper.on("touchstart.owlControls mousedown.owlControls", "div[class^=\"owl\"]", function (event) { 426 event.preventDefault(); 427 }); 428 429 buttonsWrapper.on("touchend.owlControls mouseup.owlControls", "div[class^=\"owl\"]", function (event) { 430 event.preventDefault(); 431 if ($(this).hasClass("owl-next")) { 432 base.next(); 433 } else { 434 base.prev(); 435 } 436 }); 437 }, 438 439 buildPagination : function () { 440 var base = this; 441 442 base.paginationWrapper = $("<div class=\"owl-pagination\"/>"); 443 base.owlControls.append(base.paginationWrapper); 444 445 base.paginationWrapper.on("touchend.owlControls mouseup.owlControls", ".owl-page", function (event) { 446 event.preventDefault(); 447 if (Number($(this).data("owl-page")) !== base.currentItem) { 448 base.goTo(Number($(this).data("owl-page")), true); 449 } 450 }); 451 }, 452 453 updatePagination : function () { 454 var base = this, 455 counter, 456 lastPage, 457 lastItem, 458 i, 459 paginationButton, 460 paginationButtonInner; 461 462 if (base.options.pagination === false) { 463 return false;
464 } 465 466 base.paginationWrapper.html(""); 467 468 counter = 0; 469 lastPage = base.itemsAmount - base.itemsAmount % base.options.items; 470 471 for (i = 0; i < base.itemsAmount; i += 1) { 472 if (i % base.options.items === 0) { 473 counter += 1; 474 if (lastPage === i) { 475 lastItem = base.itemsAmount - base.options.items; 476 } 477 paginationButton = $("<div/>", { 478 "class" : "owl-page" 479 }); 480 paginationButtonInner = $("<span></span>", { 481 "text": base.options.paginationNumbers === true ? counter : "", 482 "class": base.options.paginationNumbers === true ? "owl-numbers" : "" 483 }); 484 paginationButton.append(paginationButtonInner); 485 486 paginationButton.data("owl-page", lastPage === i ? lastItem : i); 487 paginationButton.data("owl-roundPages", counter); 488 489 base.paginationWrapper.append(paginationButton); 490 } 491 } 492 base.checkPagination(); 493 }, 494 checkPagination : function () { 495 var base = this; 496 if (base.options.pagination === false) { 497 return false; 498 } 499 base.paginationWrapper.find(".owl-page").each(function () { 500 if ($(this).data("owl-roundPages") === $(base.$owlItems[base.currentItem]).data("owl-roundPages")) { 501 base.paginationWrapper 502 .find(".owl-page") 503 .removeClass("active"); 504 $(this).addClass("active"); 505 } 506 }); 507 }, 508 509 checkNavigation : function () { 510 var base = this; 511 512 if (base.options.navigation === false) { 513 return false; 514 } 515 if (base.options.rewindNav === false) { 516 if (base.currentItem === 0 && base.maximumItem === 0) { 517 base.buttonPrev.addClass("disabled"); 518 base.buttonNext.addClass("disabled"); 519 } else if (base.currentItem === 0 && base.maximumItem !== 0) { 520 base.buttonPrev.addClass("disabled"); 521 base.buttonNext.removeClass("disabled"); 522 } else if (base.currentItem === base.maximumItem) { 523 base.buttonPrev.removeClass("disabled"); 524 base.buttonNext.addClass("disabled"); 525 } else if (base.currentItem !== 0 && base.currentItem !== base.maximumItem) { 526 base.buttonPrev.removeClass("disabled"); 527 base.buttonNext.removeClass("disabled"); 528 } 529 } 530 }, 531 532 updateControls : function () { 533 var base = this; 534 base.updatePagination(); 535 base.checkNavigation(); 536 if (base.owlControls) { 537 if (base.options.items >= base.itemsAmount) { 538 base.owlControls.hide(); 539 } else { 540 base.owlControls.show(); 541 } 542 } 543 }, 544 545 destroyControls : function () { 546 var base = this; 547 if (base.owlControls) { 548 base.owlControls.remove(); 549 } 550 }, 551 552 next : function (speed) { 553 var base = this; 554 555 if (base.isTransition) { 556 return false; 557 } 558 559 base.currentItem += base.options.scrollPerPage === true ? base.options.items : 1; 560 if (base.currentItem > base.maximumItem + (base.options.scrollPerPage === true ? (base.options.items - 1) : 0)) { 561 if (base.options.rewindNav === true) { 562 base.currentItem = 0; 563 speed = "rewind"; 564 } else { 565 base.currentItem = base.maximumItem; 566 return false; 567 } 568 } 569 base.goTo(base.currentItem, speed); 570 }, 571 572 prev : function (speed) { 573 var base = this; 574 575 if (base.isTransition) { 576 return false;
577 } 578 579 if (base.options.scrollPerPage === true && base.currentItem > 0 && base.currentItem < base.options.items) { 580 base.currentItem = 0; 581 } else { 582 base.currentItem -= base.options.scrollPerPage === true ? base.options.items : 1; 583 } 584 if (base.currentItem < 0) { 585 if (base.options.rewindNav === true) { 586 base.currentItem = base.maximumItem; 587 speed = "rewind"; 588 } else { 589 base.currentItem = 0; 590 return false; 591 } 592 } 593 base.goTo(base.currentItem, speed); 594 }, 595 596 goTo : function (position, speed, drag) { 597 var base = this, 598 goToPixel; 599 600 if (base.isTransition) { 601 return false; 602 } 603 if (typeof base.options.beforeMove === "function") { 604 base.options.beforeMove.apply(this, [base.$elem]); 605 } 606 if (position >= base.maximumItem) { 607 position = base.maximumItem; 608 } else if (position <= 0) { 609 position = 0; 610 } 611 612 base.currentItem = base.owl.currentItem = position; 613 if (base.options.transitionStyle !== false && drag !== "drag" && base.options.items === 1 && base.browser.support3d === true) { 614 base.swapSpeed(0); 615 if (base.browser.support3d === true) { 616 base.transition3d(base.positionsInArray[position]); 617 } else { 618 base.css2slide(base.positionsInArray[position], 1); 619 } 620 base.afterGo(); 621 base.singleItemTransition(); 622 return false; 623 } 624 goToPixel = base.positionsInArray[position]; 625 626 if (base.browser.support3d === true) { 627 base.isCss3Finish = false; 628 629 if (speed === true) { 630 base.swapSpeed("paginationSpeed"); 631 window.setTimeout(function () { 632 base.isCss3Finish = true; 633 }, base.options.paginationSpeed); 634 635 } else if (speed === "rewind") { 636 base.swapSpeed(base.options.rewindSpeed); 637 window.setTimeout(function () { 638 base.isCss3Finish = true; 639 }, base.options.rewindSpeed); 640 641 } else { 642 base.swapSpeed("slideSpeed"); 643 window.setTimeout(function () { 644 base.isCss3Finish = true; 645 }, base.options.slideSpeed); 646 } 647 base.transition3d(goToPixel); 648 } else { 649 if (speed === true) { 650 base.css2slide(goToPixel, base.options.paginationSpeed); 651 } else if (speed === "rewind") { 652 base.css2slide(goToPixel, base.options.rewindSpeed); 653 } else { 654 base.css2slide(goToPixel, base.options.slideSpeed); 655 } 656 } 657 base.afterGo(); 658 }, 659 660 jumpTo : function (position) { 661 var base = this; 662 if (typeof base.options.beforeMove === "function") { 663 base.options.beforeMove.apply(this, [base.$elem]); 664 } 665 if (position >= base.maximumItem || position === -1) { 666 position = base.maximumItem; 667 } else if (position <= 0) { 668 position = 0; 669 } 670 base.swapSpeed(0); 671 if (base.browser.support3d === true) { 672 base.transition3d(base.positionsInArray[position]); 673 } else { 674 base.css2slide(base.positionsInArray[position], 1); 675 } 676 base.currentItem = base.owl.currentItem = position; 677 base.afterGo(); 678 }, 679 680 afterGo : function () { 681 var base = this; 682 683 base.prevArr.push(base.currentItem); 684 base.prevItem = base.owl.prevItem = base.prevArr[base.prevArr.length - 2]; 685 base.prevArr.shift(0); 686 687 if (base.prevItem !== base.currentItem) { 688 base.checkPagination(); 689 base.checkNavigation(); 690 base.eachMoveUpdate(); 691 692 if (base.options.autoPlay !== false) { 693 base.checkAp(); 694 } 695 } 696 if (typeof base.options.afterMove === "function" && base.prevItem !== base.currentItem) { 697 base.options.afterMove.apply(this, [base.$elem]); 698 } 699 }, 700 701 stop : function () { 702 var base = this; 703 base.apStatus = "stop"; 704 window.clearInterval(base.autoPlayInterval); 705 }, 706 707 checkAp : function () { 708 var base = this; 709 if (base.apStatus !== "stop") { 710 base.play(); 711 } 712 }, 713 714 play : function () { 715 var base = this; 716 base.apStatus = "play"; 717 if (base.options.autoPlay === false) { 718 return false;
719 } 720 window.clearInterval(base.autoPlayInterval); 721 base.autoPlayInterval = window.setInterval(function () { 722 base.next(true); 723 }, base.options.autoPlay); 724 }, 725 726 swapSpeed : function (action) { 727 var base = this; 728 if (action === "slideSpeed") { 729 base.$owlWrapper.css(base.addCssSpeed(base.options.slideSpeed)); 730 } else if (action === "paginationSpeed") { 731 base.$owlWrapper.css(base.addCssSpeed(base.options.paginationSpeed)); 732 } else if (typeof action !== "string") { 733 base.$owlWrapper.css(base.addCssSpeed(action)); 734 } 735 }, 736 737 addCssSpeed : function (speed) { 738 return { 739 "-webkit-transition": "all " + speed + "ms ease", 740 "-moz-transition": "all " + speed + "ms ease", 741 "-o-transition": "all " + speed + "ms ease", 742 "transition": "all " + speed + "ms ease" 743 }; 744 }, 745 746 removeTransition : function () { 747 return { 748 "-webkit-transition": "", 749 "-moz-transition": "", 750 "-o-transition": "", 751 "transition": "" 752 }; 753 }, 754 755 doTranslate : function (pixels) { 756 return { 757 "-webkit-transform": "translate3d(" + pixels + "px, 0px, 0px)", 758 "-moz-transform": "translate3d(" + pixels + "px, 0px, 0px)", 759 "-o-transform": "translate3d(" + pixels + "px, 0px, 0px)", 760 "-ms-transform": "translate3d(" + pixels + "px, 0px, 0px)", 761 "transform": "translate3d(" + pixels + "px, 0px,0px)" 762 }; 763 }, 764 765 transition3d : function (value) { 766 var base = this; 767 base.$owlWrapper.css(base.doTranslate(value)); 768 }, 769 770 css2move : function (value) { 771 var base = this; 772 base.$owlWrapper.css({"left" : value}); 773 }, 774 775 css2slide : function (value, speed) { 776 var base = this; 777 778 base.isCssFinish = false; 779 base.$owlWrapper.stop(true, true).animate({ 780 "left" : value 781 }, { 782 duration : speed || base.options.slideSpeed, 783 complete : function () { 784 base.isCssFinish = true; 785 } 786 }); 787 }, 788 789 checkBrowser : function () { 790 var base = this, 791 translate3D = "translate3d(0px, 0px, 0px)", 792 tempElem = document.createElement("div"), 793 regex, 794 asSupport, 795 support3d, 796 isTouch; 797 798 tempElem.style.cssText = " -moz-transform:" + translate3D + 799 "; -ms-transform:" + translate3D + 800 "; -o-transform:" + translate3D + 801 "; -webkit-transform:" + translate3D + 802 "; transform:" + translate3D; 803 regex = /translate3d\(0px, 0px, 0px\)/g; 804 asSupport = tempElem.style.cssText.match(regex); 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.