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