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