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