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 // THANHNT fix height at decimal value 349 base.itemWidth = Math.round((base.$elem.width() / base.options.items) * 100) / 100 350 // base.itemWidth = Math.round(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// if($(e.target).parents('div:eq(0)').hasClass('wishlist')){ 866// return true; 867// } 868// return $(e.target).is('input, textarea, select, option'); 869 }); 870 }, 871 872 gestures : function () { 873 /*jslint unparam: true*/ 874 var base = this, 875 locals = { 876 offsetX : 0, 877 offsetY : 0, 878 baseElWidth : 0, 879 relativePos : 0, 880 position: null, 881 minSwipe : null, 882 maxSwipe: null, 883 sliding : null, 884 dargging: null, 885 targetElement : null 886 }; 887 888 base.isCssFinish = true; 889 890 function getTouches(event) { 891 if (event.touches !== undefined) { 892 return { 893 x : event.touches[0].pageX, 894 y : event.touches[0].pageY 895 }; 896 } 897 898 if (event.touches === undefined) { 899 if (event.pageX !== undefined) { 900 return { 901 x : event.pageX, 902 y : event.pageY 903 }; 904 } 905 if (event.pageX === undefined) { 906 return { 907 x : event.clientX, 908 y : event.clientY 909 }; 910 } 911 } 912 } 913 914 function swapEvents(type) { 915 if (type === "on") { 916 $(document).on(base.ev_types.move, dragMove); 917 $(document).on(base.ev_types.end, dragEnd); 918 } else if (type === "off") { 919 $(document).off(base.ev_types.move); 920 $(document).off(base.ev_types.end); 921 } 922 } 923 924 function dragStart(event) { 925 var ev = event.originalEvent || event || window.event, 926 position; 927 928 if (ev.which === 3) { 929 return false;
930 } 931 if (base.itemsAmount <= base.options.items) { 932 return; 933 } 934 if (base.isCssFinish === false && !base.options.dragBeforeAnimFinish) { 935 return false; 936 } 937 if (base.isCss3Finish === false && !base.options.dragBeforeAnimFinish) { 938 return false; 939 } 940 941 if (base.options.autoPlay !== false) { 942 window.clearInterval(base.autoPlayInterval); 943 } 944 945 if (base.browser.isTouch !== true && !base.$owlWrapper.hasClass("grabbing")) { 946 base.$owlWrapper.addClass("grabbing"); 947 } 948 949 base.newPosX = 0; 950 base.newRelativeX = 0; 951 952 $(this).css(base.removeTransition()); 953 954 position = $(this).position(); 955 if(base.options['direction']=="rtl") { 956 positionRight = base.$owlItems.eq(0).width()*base.currentItem; 957 locals.relativePos = positionRight; 958 locals.offsetX = -getTouches(ev).x + positionRight; 959 } 960 else { 961 locals.relativePos = position.left; 962 locals.offsetX = getTouches(ev).x - position.left; 963 } 964 locals.offsetY = getTouches(ev).y - position.top; 965 966 swapEvents("on"); 967 968 locals.sliding = false; 969 locals.targetElement = ev.target || ev.srcElement; 970 } 971 972 function dragMove(event) { 973 var ev = event.originalEvent || event || window.event, 974 minSwipe; 975 if(base.options['direction']=="rtl") { 976 base.newPosX = -getTouches(ev).x - locals.offsetX; 977 base.newPosY = getTouches(ev).y - locals.offsetY; 978 base.newRelativeX = base.newPosX + locals.relativePos; 979 } 980 else { 981 base.newPosX = getTouches(ev).x - locals.offsetX; 982 base.newPosY = getTouches(ev).y - locals.offsetY; 983 base.newRelativeX = base.newPosX - locals.relativePos; 984 } 985 if (typeof base.options.startDragging === "function" && locals.dragging !== true && base.newRelativeX !== 0) { 986 locals.dragging = true; 987 base.options.startDragging.apply(base, [base.$elem]); 988 } 989 990 if ((base.newRelativeX > 8 || base.newRelativeX < -8) && (base.browser.isTouch === true)) { 991 if (ev.preventDefault !== undefined) { 992 ev.preventDefault(); 993 } else { 994 ev.returnValue = false; 995 } 996 locals.sliding = true; 997 } 998 999 if ((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false) { 1000 $(document).off("touchmove.owl"); 1001 } 1002 1003 minSwipe = function () { 1004 return base.newRelativeX / 5; 1005 }; 1006 1007 maxSwipe = function () { 1008 return base.maximumPixels + base.newRelativeX / 5; 1009 }; 1010 1011 base.newPosX = Math.max(Math.min(base.newPosX, minSwipe()), maxSwipe()); 1012 if (base.browser.support3d === true) { 1013 base.transition3d(base.newPosX); 1014 } else { 1015 base.css2move(base.newPosX); 1016 } 1017 } 1018 1019 function dragEnd(event) { 1020 var ev = event.originalEvent || event || window.event, 1021 newPosition, 1022 handlers, 1023 owlStopEvent; 1024 1025 ev.target = ev.target || ev.srcElement; 1026 1027 locals.dragging = false; 1028 1029 if (base.browser.isTouch !== true) { 1030 base.$owlWrapper.removeClass("grabbing"); 1031 } 1032 1033 if(base.options['direction']=="rtl") { 1034 if (base.newRelativeX < 0) { base.dragDirection = base.owl.dragDirection = "right"; } 1035 else { base.dragDirection = base.owl.dragDirection = "left"; } 1036 } 1037 else { 1038 if (base.newRelativeX < 0) { base.dragDirection = base.owl.dragDirection = "left"; } 1039 else { base.dragDirection = base.owl.dragDirection = "right"; } 1040 } 1041 1042 if (base.newRelativeX !== 0) { 1043 newPosition = base.getNewPosition(); 1044 base.goTo(newPosition, false, "drag"); 1045 if (locals.targetElement === ev.target && base.browser.isTouch !== true) { 1046 $(ev.target).on("click.disable", function (ev) { 1047 ev.stopImmediatePropagation(); 1048 ev.stopPropagation(); 1049 ev.preventDefault(); 1050 $(ev.target).off("click.disable"); 1051 }); 1052 handlers = $._data(ev.target, "events").click; 1053 owlStopEvent = handlers.pop(); 1054 handlers.splice(0, 0, owlStopEvent); 1055 } 1056 } 1057 swapEvents("off"); 1058 } 1059 base.$elem.on(base.ev_types.start, ".owl-wrapper", dragStart); 1060 }, 1061 1062 getNewPosition : function () { 1063 var base = this, 1064 newPosition = base.closestItem(); 1065 1066 if (newPosition > base.maximumItem) { 1067 base.currentItem = base.maximumItem; 1068 newPosition = base.maximumItem; 1069 } else if (base.newPosX >= 0) { 1070 newPosition = 0; 1071 base.currentItem = 0; 1072 } 1073 return newPosition; 1074 }, 1075 closestItem : function () { 1076 var base = this, 1077 array = base.options.scrollPerPage === true ? base.pagesInArray : base.positionsInArray, 1078 goal = base.newPosX, 1079 closest = null; 1080 1081 $.each(array, function (i, v) { 1082 if (goal - (base.itemWidth / 20) > array[i + 1] && goal - (base.itemWidth / 20) < v && base.moveDirection() === "left") { 1083 closest = v; 1084 if (base.options.scrollPerPage === true) { 1085 base.currentItem = $.inArray(closest, base.positionsInArray); 1086 } else { 1087 base.currentItem = i; 1088 } 1089 } else if (goal + (base.itemWidth / 20) < v && goal + (base.itemWidth / 20) > (array[i + 1] || array[i] - base.itemWidth) && base.moveDirection() === "right") { 1090 if (base.options.scrollPerPage === true) { 1091 closest = array[i + 1] || array[array.length - 1]; 1092 base.currentItem = $.inArray(closest, base.positionsInArray); 1093 } else { 1094 closest = array[i + 1]; 1095 base.currentItem = i + 1; 1096 } 1097 } 1098 }); 1099 return base.currentItem; 1100 }, 1101 1102 moveDirection : function () { 1103 var base = this, 1104 direction; 1105 if (base.newRelativeX < 0) { 1106 direction = "right"; 1107 base.playDirection = "next"; 1108 } else { 1109 direction = "left"; 1110 base.playDirection = "prev"; 1111 } 1112 return direction; 1113 }, 1114 1115 customEvents : function () { 1116 /*jslint unparam: true*/ 1117 var base = this; 1118 base.$elem.on("owl.next", function () { 1119 base.next(); 1120 }); 1121 base.$elem.on("owl.prev", function () { 1122 base.prev(); 1123 }); 1124 base.$elem.on("owl.play", function (event, speed) { 1125 base.options.autoPlay = speed; 1126 base.play(); 1127 base.hoverStatus = "play"; 1128 }); 1129 base.$elem.on("owl.stop", function () { 1130 base.stop(); 1131 base.hoverStatus = "stop"; 1132 }); 1133 base.$elem.on("owl.goTo", function (event, item) { 1134 base.goTo(item); 1135 }); 1136 base.$elem.on("owl.jumpTo", function (event, item) { 1137 base.jumpTo(item); 1138 }); 1139 }, 1140 1141 stopOnHover : function () { 1142 var base = this; 1143 if (base.options.stopOnHover === true && base.browser.isTouch !== true && base.options.autoPlay !== false) { 1144 base.$elem.on("mouseover", function () { 1145 base.stop(); 1146 }); 1147 base.$elem.on("mouseout", function () { 1148 if (base.hoverStatus !== "stop") { 1149 base.play(); 1150 } 1151 }); 1152 } 1153 }, 1154 1155 lazyLoad : function () { 1156 var base = this, 1157 i, 1158 $item, 1159 itemNumber, 1160 $lazyImg, 1161 follow; 1162 1163 if (base.options.lazyLoad === false) { 1164 return false;
1165 } 1166 for (i = 0; i < base.itemsAmount; i += 1) { 1167 $item = $(base.$owlItems[i]); 1168 1169 if ($item.data("owl-loaded") === "loaded") { 1170 continue; 1171 } 1172 1173 itemNumber = $item.data("owl-item"); 1174 $lazyImg = $item.find(".lazyOwl"); 1175 1176 if (typeof $lazyImg.data("src") !== "string") { 1177 $item.data("owl-loaded", "loaded"); 1178 continue; 1179 } 1180 if ($item.data("owl-loaded") === undefined) { 1181 $lazyImg.hide(); 1182 $item.addClass("loading").data("owl-loaded", "checked"); 1183 } 1184 if (base.options.lazyFollow === true) { 1185 follow = itemNumber >= base.currentItem; 1186 } else { 1187 follow = true; 1188 } 1189 if (follow && itemNumber < base.currentItem + base.options.items && $lazyImg.length) { 1190 $lazyImg.each(function() { 1191 base.lazyPreload($item, $(this)); 1192 }); 1193 } 1194 } 1195 }, 1196 1197 lazyPreload : function ($item, $lazyImg) { 1198 var base = this, 1199 iterations = 0, 1200 isBackgroundImg; 1201 1202 if ($lazyImg.prop("tagName") === "DIV") { 1203 $lazyImg.css("background-image", "url(" + $lazyImg.data("src") + ")"); 1204 isBackgroundImg = true; 1205 } else { 1206 $lazyImg[0].src = $lazyImg.data("src"); 1207 } 1208 1209 function showImage() { 1210 $item.data("owl-loaded", "loaded").removeClass("loading"); 1211 $lazyImg.removeAttr("data-src"); 1212 if (base.options.lazyEffect === "fade") { 1213 $lazyImg.fadeIn(400); 1214 } else { 1215 $lazyImg.show(); 1216 } 1217 if (typeof base.options.afterLazyLoad === "function") { 1218 base.options.afterLazyLoad.apply(this, [base.$elem]); 1219 } 1220 } 1221 1222 function checkLazyImage() { 1223 iterations += 1; 1224 if (base.completeImg($lazyImg.get(0)) || isBackgroundImg === true) { 1225 showImage(); 1226 } else if (iterations <= 100) {//if image loads in less than 10 seconds 1227 window.setTimeout(checkLazyImage, 100); 1228 } else { 1229 showImage(); 1230 } 1231 } 1232 1233 checkLazyImage(); 1234 }, 1235 1236 autoHeight : function () { 1237 var base = this, 1238 $currentimg = $(base.$owlItems[base.currentItem]).find("img"), 1239 iterations; 1240 1241 function addHeight() { 1242 var $currentItem = $(base.$owlItems[base.currentItem]).height(); 1243 base.wrapperOuter.css("height", $currentItem + "px"); 1244 if (!base.wrapperOuter.hasClass("autoHeight")) { 1245 window.setTimeout(function () { 1246 base.wrapperOuter.addClass("autoHeight"); 1247 }, 0); 1248 } 1249 } 1250 1251 function checkImage() { 1252 iterations += 1; 1253 if (base.completeImg($currentimg.get(0))) { 1254 addHeight(); 1255 } else if (iterations <= 100) { //if image loads in less than 10 seconds 1256 window.setTimeout(checkImage, 100); 1257 } else { 1258 base.wrapperOuter.css("height", ""); //Else remove height attribute 1259 } 1260 } 1261 1262 if ($currentimg.get(0) !== undefined) { 1263 iterations = 0; 1264 checkImage(); 1265 } else { 1266 addHeight(); 1267 } 1268 }, 1269 1270 completeImg : function (img) { 1271 var naturalWidthType; 1272 1273 if (!img.complete) { 1274 return false; 1275 } 1276 naturalWidthType = typeof img.naturalWidth;
1277 if (naturalWidthType !== "undefined" && img.naturalWidth === 0) { 1278 return false; 1279 } 1280 return true; 1281 }, 1282 1283 onVisibleItems : function () { 1284 var base = this, 1285 i; 1286 1287 if (base.options.addClassActive === true) { 1288 base.$owlItems.removeClass("active"); 1289 } 1290 base.visibleItems = []; 1291 for (i = base.currentItem; i < base.currentItem + base.options.items; i += 1) { 1292 base.visibleItems.push(i); 1293 1294 if (base.options.addClassActive === true) { 1295 $(base.$owlItems[i]).addClass("active"); 1296 } 1297 } 1298 base.owl.visibleItems = base.visibleItems; 1299 }, 1300 1301 transitionTypes : function (className) { 1302 var base = this; 1303 //Currently available: "fade", "backSlide", "goDown", "fadeUp" 1304 base.outClass = "owl-" + className + "-out"; 1305 base.inClass = "owl-" + className + "-in"; 1306 }, 1307 1308 singleItemTransition : function () { 1309 var base = this, 1310 outClass = base.outClass, 1311 inClass = base.inClass, 1312 $currentItem = base.$owlItems.eq(base.currentItem), 1313 $prevItem = base.$owlItems.eq(base.prevItem), 1314 prevPos = Math.abs(base.positionsInArray[base.currentItem]) + base.positionsInArray[base.prevItem], 1315 origin = Math.abs(base.positionsInArray[base.currentItem]) + base.itemWidth / 2, 1316 animEnd = 'webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend'; 1317 1318 base.isTransition = true; 1319 1320 base.$owlWrapper 1321 .addClass('owl-origin') 1322 .css({ 1323 "-webkit-transform-origin" : origin + "px", 1324 "-moz-perspective-origin" : origin + "px", 1325 "perspective-origin" : origin + "px" 1326 }); 1327 function transStyles(prevPos) { 1328 return { 1329 "position" : "relative", 1330 "left" : prevPos + "px" 1331 }; 1332 } 1333 1334 $prevItem 1335 .css(transStyles(prevPos, 10)) 1336 .addClass(outClass) 1337 .on(animEnd, function () { 1338 base.endPrev = true; 1339 $prevItem.off(animEnd); 1340 base.clearTransStyle($prevItem, outClass); 1341 }); 1342 1343 $currentItem 1344 .addClass(inClass) 1345 .on(animEnd, function () { 1346 base.endCurrent = true; 1347 $currentItem.off(animEnd); 1348 base.clearTransStyle($currentItem, inClass); 1349 }); 1350 }, 1351 1352 clearTransStyle : function (item, classToRemove) { 1353 var base = this; 1354 item.css({ 1355 "position" : "", 1356 "left" : "" 1357 }).removeClass(classToRemove); 1358 1359 if (base.endPrev && base.endCurrent) { 1360 base.$owlWrapper.removeClass('owl-origin'); 1361 base.endPrev = false; 1362 base.endCurrent = false; 1363 base.isTransition = false; 1364 } 1365 }, 1366 1367 owlStatus : function () { 1368 var base = this; 1369 base.owl = { 1370 "userOptions" : base.userOptions, 1371 "baseElement" : base.$elem, 1372 "userItems" : base.$userItems, 1373 "owlItems" : base.$owlItems, 1374 "currentItem" : base.currentItem, 1375 "prevItem" : base.prevItem, 1376 "visibleItems" : base.visibleItems, 1377 "isTouch" : base.browser.isTouch, 1378 "browser" : base.browser, 1379 "dragDirection" : base.dragDirection 1380 }; 1381 }, 1382 1383 clearEvents : function () { 1384 var base = this; 1385 base.$elem.off(".owl owl mousedown.disableTextSelect"); 1386 $(document).off(".owl owl"); 1387 $(window).off("resize", base.resizer); 1388 }, 1389 1390 unWrap : function () { 1391 var base = this; 1392 if (base.$elem.children().length !== 0) { 1393 base.$owlWrapper.unwrap(); 1394 base.$userItems.unwrap().unwrap(); 1395 if (base.owlControls) { 1396 base.owlControls.remove(); 1397 } 1398 } 1399 base.clearEvents(); 1400 base.$elem.attr({ 1401 style: base.$elem.data("owl-originalStyles") || "", 1402 class: base.$elem.data("owl-originalClasses") 1403 }); 1404 }, 1405 1406 destroy : function () { 1407 var base = this; 1408 base.stop(); 1409 window.clearInterval(base.checkVisible); 1410 base.unWrap(); 1411 base.$elem.removeData(); 1412 }, 1413 1414 reinit : function (newOptions) { 1415 var base = this, 1416 options = $.extend({}, base.userOptions, newOptions); 1417 base.unWrap(); 1418 base.init(options, base.$elem); 1419 }, 1420 1421 addItem : function (htmlString, targetPosition) { 1422 var base = this, 1423 position; 1424 1425 if (!htmlString) {return false; } 1426 1427 if (base.$elem.children().length === 0) { 1428 base.$elem.append(htmlString); 1429 base.setVars(); 1430 return false;
1431 } 1432 base.unWrap(); 1433 if (targetPosition === undefined || targetPosition === -1) { 1434 position = -1; 1435 } else { 1436 position = targetPosition; 1437 } 1438 if (position >= base.$userItems.length || position === -1) { 1439 base.$userItems.eq(-1).after(htmlString); 1440 } else { 1441 base.$userItems.eq(position).before(htmlString); 1442 } 1443 1444 base.setVars(); 1445 }, 1446 1447 removeItem : function (targetPosition) { 1448 var base = this, 1449 position; 1450 1451 if (base.$elem.children().length === 0) { 1452 return false; 1453 } 1454 if (targetPosition === undefined || targetPosition === -1) { 1455 position = -1; 1456 } else { 1457 position = targetPosition; 1458 } 1459 1460 base.unWrap(); 1461 base.$userItems.eq(position).remove(); 1462 base.setVars(); 1463 } 1464 1465 }; 1466 1467 $.fn.owlCarousel = function (options) { 1468 return this.each(function () { 1469 if ($(this).data("owl-init") === true) { 1470 return false; 1471 } 1472 $(this).data("owl-init", true); 1473 var carousel = Object.create(Carousel); 1474 carousel.init(options, this); 1475 $.data(this, "owlCarousel", carousel); 1476 }); 1477 }; 1478 1479 $.fn.owlCarousel.options = { 1480 direction:'ltr', 1481 1482 items : 5, 1483 itemsCustom : false, 1484 itemsDesktop : [1199, 4], 1485 itemsDesktopSmall : [979, 3], 1486 itemsTablet : [768, 2], 1487 itemsTabletSmall : false, 1488 itemsMobile : [479, 1], 1489 singleItem : false, 1490 itemsScaleUp : false, 1491 1492 slideSpeed : 200, 1493 paginationSpeed : 800, 1494 rewindSpeed : 1000, 1495 1496 autoPlay : false, 1497 stopOnHover : false, 1498 1499 navigation : false, 1500 navigationText : ["prev", "next"], 1501 rewindNav : true, 1502 scrollPerPage : false, 1503 1504 pagination : true, 1505 paginationNumbers : false, 1506 1507 responsive : true, 1508 responsiveRefreshRate : 200, 1509 responsiveBaseWidth : window, 1510 1511 baseClass : "owl-carousel", 1512 theme : "owl-theme", 1513 1514 lazyLoad : false, 1515 lazyFollow : true, 1516 lazyEffect : "fade", 1517 1518 autoHeight : false, 1519 1520 jsonPath : false, 1521 jsonSuccess : false, 1522 1523 dragBeforeAnimFinish : true, 1524 mouseDrag : true, 1525 touchDrag : true, 1526 1527 addClassActive : false, 1528 transitionStyle : false, 1529 1530 beforeUpdate : false, 1531 afterUpdate : false, 1532 beforeInit : false, 1533 afterInit : false, 1534 beforeMove : false, 1535 afterMove : false, 1536 afterAction : false, 1537 startDragging : false, 1538 afterLazyLoad: false 1539 }; 1540}(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.