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