1/* 2 * jQuery OwlCarousel v1.3.2 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("owl-originalStyles", base.$elem.attr("style")) 69 .data("owl-originalClasses", base.$elem.attr("class")); 70 71 base.$elem.css({opacity: 0}); 72 base.orignalItems = base.options.items; 73 base.checkBrowser(); 74 base.wrapperWidth = 0; 75 base.checkVisible = null; 76 base.setVars(); 77 }, 78 79 setVars : function () { 80 var base = this; 81 if (base.$elem.children().length === 0) {return false; } 82 base.baseClass(); 83 base.eventTypes(); 84 base.$userItems = base.$elem.children(); 85 base.itemsAmount = base.$userItems.length; 86 base.wrapItems(); 87 base.$owlItems = base.$elem.find(".owl-item"); 88 base.$owlWrapper = base.$elem.find(".owl-wrapper"); 89 base.playDirection = "next"; 90 base.prevItem = 0; 91 base.prevArr = [0]; 92 base.currentItem = 0; 93 base.customEvents(); 94 base.onStartup(); 95 }, 96 97 onStartup : function () { 98 var base = this; 99 base.updateItems(); 100 base.calculateAll(); 101 base.buildControls(); 102 base.updateControls(); 103 base.response(); 104 base.moveEvents(); 105 base.stopOnHover(); 106 base.owlStatus(); 107 108 if (base.options.transitionStyle !== false) { 109 base.transitionTypes(base.options.transitionStyle); 110 } 111 if (base.options.autoPlay === true) { 112 base.options.autoPlay = 5000; 113 } 114 base.play(); 115 116 base.$elem.find(".owl-wrapper").css("display", "block"); 117 118 if (!base.$elem.is(":visible")) { 119 base.watchVisibility(); 120 } else { 121 base.$elem.css("opacity", 1); 122 } 123 base.onstartup = false; 124 base.eachMoveUpdate(); 125 if (typeof base.options.afterInit === "function") { 126 base.options.afterInit.apply(this, [base.$elem]); 127 } 128 }, 129 130 eachMoveUpdate : function () { 131 var base = this; 132 133 if (base.options.lazyLoad === true) { 134 base.lazyLoad(); 135 } 136 if (base.options.autoHeight === true) { 137 base.autoHeight(); 138 } 139 base.onVisibleItems(); 140 141 if (typeof base.options.afterAction === "function") { 142 base.options.afterAction.apply(this, [base.$elem]); 143 } 144 }, 145
146 updateVars : function () { 147 var base = this; 148 if (typeof base.options.beforeUpdate === "function") { 149 base.options.beforeUpdate.apply(this, [base.$elem]); 150 } 151 base.watchVisibility(); 152 base.updateItems(); 153 base.calculateAll(); 154 base.updatePosition(); 155 base.updateControls(); 156 base.eachMoveUpdate(); 157 if (typeof base.options.afterUpdate === "function") { 158 base.options.afterUpdate.apply(this, [base.$elem]); 159 } 160 }, 161 162 reload : function () { 163 var base = this; 164 window.setTimeout(function () { 165 base.updateVars(); 166 }, 0); 167 }, 168 169 watchVisibility : function () { 170 var base = this; 171 172 if (base.$elem.is(":visible") === false) { 173 base.$elem.css({opacity: 0}); 174 window.clearInterval(base.autoPlayInterval); 175 window.clearInterval(base.checkVisible); 176 } else { 177 return false; 178 } 179 base.checkVisible = window.setInterval(function () { 180 if (base.$elem.is(":visible")) { 181 base.reload(); 182 base.$elem.animate({opacity: 1}, 200); 183 window.clearInterval(base.checkVisible); 184 } 185 }, 500); 186 }, 187 188 wrapItems : function () { 189 var base = this; 190 base.$userItems.wrapAll("<div class=\"owl-wrapper\">").wrap("<div class=\"owl-item\"></div>"); 191 base.$elem.find(".owl-wrapper").wrap("<div class=\"owl-wrapper-outer\">"); 192 base.wrapperOuter = base.$elem.find(".owl-wrapper-outer"); 193 base.$elem.css("display", "block"); 194 }, 195 196 baseClass : function () { 197 var base = this, 198 hasBaseClass = base.$elem.hasClass(base.options.baseClass), 199 hasThemeClass = base.$elem.hasClass(base.options.theme); 200 201 if (!hasBaseClass) { 202 base.$elem.addClass(base.options.baseClass); 203 } 204 205 if (!hasThemeClass) { 206 base.$elem.addClass(base.options.theme); 207 } 208 }, 209 210 updateItems : function () { 211 var base = this, width, i; 212 213 if (base.options.responsive === false) { 214 return false; 215 } 216 if (base.options.singleItem === true) { 217 base.options.items = base.orignalItems = 1; 218 base.options.itemsCustom = false; 219 base.options.itemsDesktop = false; 220 base.options.itemsDesktopSmall = false; 221 base.options.itemsTablet = false; 222 base.options.itemsTabletSmall = false; 223 base.options.itemsMobile = false; 224 return false; 225 } 226 227 width = $(base.options.responsiveBaseWidth).width(); 228 229 if (width > (base.options.itemsDesktop[0] || base.orignalItems)) { 230 base.options.items = base.orignalItems; 231 } 232 if (base.options.itemsCustom !== false) { 233 //Reorder array by screen size 234 base.options.itemsCustom.sort(function (a, b) {return a[0] - b[0]; }); 235 236 for (i = 0; i < base.options.itemsCustom.length; i += 1) { 237 if (base.options.itemsCustom[i][0] <= width) { 238 base.options.items = base.options.itemsCustom[i][1]; 239 } 240 } 241 242 } else { 243 244 if (width <= base.options.itemsDesktop[0] && base.options.itemsDesktop !== false) { 245 base.options.items = base.options.itemsDesktop[1]; 246 } 247 248 if (width <= base.options.itemsDesktopSmall[0] && base.options.itemsDesktopSmall !== false) { 249 base.options.items = base.options.itemsDesktopSmall[1]; 250 } 251 252 if (width <= base.options.itemsTablet[0] && base.options.itemsTablet !== false) { 253 base.options.items = base.options.itemsTablet[1]; 254 } 255 256 if (width <= base.options.itemsTabletSmall[0] && base.options.itemsTabletSmall !== false) { 257 base.options.items = base.options.itemsTabletSmall[1]; 258 } 259 260 if (width <= base.options.itemsMobile[0] && base.options.itemsMobile !== false) { 261 base.options.items = base.options.itemsMobile[1]; 262 } 263 } 264 265 //if number of items is less than declared 266 if (base.options.items > base.itemsAmount && base.options.itemsScaleUp === true) { 267 base.options.items = base.itemsAmount; 268 } 269 }, 270 271 response : function () { 272 var base = this, 273 smallDelay, 274 lastWindowWidth; 275 276 if (base.options.responsive !== true) { 277 return false;
278 } 279 lastWindowWidth = $(window).width(); 280 281 base.resizer = function () { 282 if ($(window).width() !== lastWindowWidth) { 283 if (base.options.autoPlay !== false) { 284 window.clearInterval(base.autoPlayInterval); 285 } 286 window.clearTimeout(smallDelay); 287 smallDelay = window.setTimeout(function () { 288 lastWindowWidth = $(window).width(); 289 base.updateVars(); 290 }, base.options.responsiveRefreshRate); 291 } 292 }; 293 $(window).resize(base.resizer); 294 }, 295 296 updatePosition : function () { 297 var base = this; 298 base.jumpTo(base.currentItem); 299 if (base.options.autoPlay !== false) { 300 base.checkAp(); 301 } 302 }, 303 304 appendItemsSizes : function () { 305 var base = this, 306 roundPages = 0, 307 lastItem = base.itemsAmount - base.options.items; 308 309 base.$owlItems.each(function (index) { 310 var $this = $(this); 311 $this 312 .css({"width": base.itemWidth}) 313 .data("owl-item", Number(index)); 314 315 if (index % base.options.items === 0 || index === lastItem) { 316 if (!(index > lastItem)) { 317 roundPages += 1; 318 } 319 } 320 $this.data("owl-roundPages", roundPages); 321 }); 322 }, 323 324 appendWrapperSizes : function () { 325 var base = this, 326 width = base.$owlItems.length * base.itemWidth; 327 328 base.$owlWrapper.css({ 329 "width": width * 2, 330 "left": 0 331 }); 332 base.appendItemsSizes(); 333 }, 334 335 calculateAll : function () { 336 var base = this; 337 base.calculateWidth(); 338 base.appendWrapperSizes(); 339 base.loops(); 340 base.max(); 341 }, 342 343 calculateWidth : function () { 344 var base = this; 345 base.itemWidth = Math.round(base.$elem.width() / base.options.items); 346 }, 347 348 max : function () { 349 var base = this, 350 maximum = ((base.itemsAmount * base.itemWidth) - base.options.items * base.itemWidth) * -1; 351 if (base.options.items > base.itemsAmount) { 352 base.maximumItem = 0; 353 maximum = 0; 354 base.maximumPixels = 0; 355 } else { 356 base.maximumItem = base.itemsAmount - base.options.items; 357 base.maximumPixels = maximum; 358 } 359 return maximum; 360 }, 361 362 min : function () { 363 return 0; 364 }, 365 366 loops : function () { 367 var base = this, 368 prev = 0, 369 elWidth = 0, 370 i, 371 item, 372 roundPageNum; 373 374 base.positionsInArray = [0]; 375 base.pagesInArray = []; 376 377 for (i = 0; i < base.itemsAmount; i += 1) { 378 elWidth += base.itemWidth; 379 base.positionsInArray.push(-elWidth); 380 381 if (base.options.scrollPerPage === true) { 382 item = $(base.$owlItems[i]); 383 roundPageNum = item.data("owl-roundPages"); 384 if (roundPageNum !== prev) { 385 base.pagesInArray[prev] = base.positionsInArray[i]; 386 prev = roundPageNum; 387 } 388 } 389 } 390 }, 391 392 buildControls : function () { 393 var base = this; 394 if (base.options.navigation === true || base.options.pagination === true) { 395 base.owlControls = $("<div class=\"owl-controls\"/>").toggleClass("clickable", !base.browser.isTouch).appendTo(base.$elem); 396 } 397 if (base.options.pagination === true) { 398 base.buildPagination(); 399 } 400 if (base.options.navigation === true) { 401 base.buildButtons(); 402 } 403 }, 404 405 buildButtons : function () { 406 var base = this, 407 buttonsWrapper = $("<div class=\"owl-buttons\"/>"); 408 base.owlControls.append(buttonsWrapper); 409 410 base.buttonPrev = $("<div/>", { 411 "class" : "owl-prev", 412 "html" : base.options.navigationText[0] || "" 413 }); 414 415 base.buttonNext = $("<div/>", { 416 "class" : "owl-next", 417 "html" : base.options.navigationText[1] || "" 418 }); 419 420 buttonsWrapper 421 .append(base.buttonPrev) 422 .append(base.buttonNext); 423 424 buttonsWrapper.on("touchstart.owlControls mousedown.owlControls", "div[class^=\"owl\"]", function (event) { 425 event.preventDefault(); 426 }); 427 428 buttonsWrapper.on("touchend.owlControls mouseup.owlControls", "div[class^=\"owl\"]", function (event) { 429 event.preventDefault(); 430 if ($(this).hasClass("owl-next")) { 431 base.next(); 432 } else { 433 base.prev(); 434 } 435 }); 436 }, 437 438 buildPagination : function () { 439 var base = this; 440 441 base.paginationWrapper = $("<div class=\"owl-pagination\"/>"); 442 base.owlControls.append(base.paginationWrapper); 443 444 base.paginationWrapper.on("touchend.owlControls mouseup.owlControls", ".owl-page", function (event) { 445 event.preventDefault(); 446 if (Number($(this).data("owl-page")) !== base.currentItem) { 447 base.goTo(Number($(this).data("owl-page")), true); 448 } 449 }); 450 }, 451 452 updatePagination : function () { 453 var base = this, 454 counter, 455 lastPage, 456 lastItem, 457 i, 458 paginationButton, 459 paginationButtonInner; 460 461 if (base.options.pagination === false) { 462 return false;
463 } 464 465 base.paginationWrapper.html(""); 466 467 counter = 0; 468 lastPage = base.itemsAmount - base.itemsAmount % base.options.items; 469 470 for (i = 0; i < base.itemsAmount; i += 1) { 471 if (i % base.options.items === 0) { 472 counter += 1; 473 if (lastPage === i) { 474 lastItem = base.itemsAmount - base.options.items; 475 } 476 paginationButton = $("<div/>", { 477 "class" : "owl-page" 478 }); 479 paginationButtonInner = $("<span></span>", { 480 "text": base.options.paginationNumbers === true ? counter : "", 481 "class": base.options.paginationNumbers === true ? "owl-numbers" : "" 482 }); 483 paginationButton.append(paginationButtonInner); 484 485 paginationButton.data("owl-page", lastPage === i ? lastItem : i); 486 paginationButton.data("owl-roundPages", counter); 487 488 base.paginationWrapper.append(paginationButton); 489 } 490 } 491 base.checkPagination(); 492 }, 493 checkPagination : function () { 494 var base = this; 495 if (base.options.pagination === false) { 496 return false; 497 } 498 base.paginationWrapper.find(".owl-page").each(function () { 499 if ($(this).data("owl-roundPages") === $(base.$owlItems[base.currentItem]).data("owl-roundPages")) { 500 base.paginationWrapper 501 .find(".owl-page") 502 .removeClass("active"); 503 $(this).addClass("active"); 504 } 505 }); 506 }, 507 508 checkNavigation : function () { 509 var base = this; 510 511 if (base.options.navigation === false) { 512 return false; 513 } 514 if (base.options.rewindNav === false) { 515 if (base.currentItem === 0 && base.maximumItem === 0) { 516 base.buttonPrev.addClass("disabled"); 517 base.buttonNext.addClass("disabled"); 518 } else if (base.currentItem === 0 && base.maximumItem !== 0) { 519 base.buttonPrev.addClass("disabled"); 520 base.buttonNext.removeClass("disabled"); 521 } else if (base.currentItem === base.maximumItem) { 522 base.buttonPrev.removeClass("disabled"); 523 base.buttonNext.addClass("disabled"); 524 } else if (base.currentItem !== 0 && base.currentItem !== base.maximumItem) { 525 base.buttonPrev.removeClass("disabled"); 526 base.buttonNext.removeClass("disabled"); 527 } 528 } 529 }, 530 531 updateControls : function () { 532 var base = this; 533 base.updatePagination(); 534 base.checkNavigation(); 535 if (base.owlControls) { 536 if (base.options.items >= base.itemsAmount) { 537 base.owlControls.hide(); 538 } else { 539 base.owlControls.show(); 540 } 541 } 542 }, 543 544 destroyControls : function () { 545 var base = this; 546 if (base.owlControls) { 547 base.owlControls.remove(); 548 } 549 }, 550 551 next : function (speed) { 552 var base = this; 553 554 if (base.isTransition) { 555 return false; 556 } 557 558 base.currentItem += base.options.scrollPerPage === true ? base.options.items : 1; 559 if (base.currentItem > base.maximumItem + (base.options.scrollPerPage === true ? (base.options.items - 1) : 0)) { 560 if (base.options.rewindNav === true) { 561 base.currentItem = 0; 562 speed = "rewind"; 563 } else { 564 base.currentItem = base.maximumItem; 565 return false; 566 } 567 } 568 base.goTo(base.currentItem, speed); 569 }, 570 571 prev : function (speed) { 572 var base = this; 573 574 if (base.isTransition) { 575 return false;
576 } 577 578 if (base.options.scrollPerPage === true && base.currentItem > 0 && base.currentItem < base.options.items) { 579 base.currentItem = 0; 580 } else { 581 base.currentItem -= base.options.scrollPerPage === true ? base.options.items : 1; 582 } 583 if (base.currentItem < 0) { 584 if (base.options.rewindNav === true) { 585 base.currentItem = base.maximumItem; 586 speed = "rewind"; 587 } else { 588 base.currentItem = 0; 589 return false; 590 } 591 } 592 base.goTo(base.currentItem, speed); 593 }, 594 595 goTo : function (position, speed, drag) { 596 var base = this, 597 goToPixel; 598 599 if (base.isTransition) { 600 return false; 601 } 602 if (typeof base.options.beforeMove === "function") { 603 base.options.beforeMove.apply(this, [base.$elem]); 604 } 605 if (position >= base.maximumItem) { 606 position = base.maximumItem; 607 } else if (position <= 0) { 608 position = 0; 609 } 610 611 base.currentItem = base.owl.currentItem = position; 612 if (base.options.transitionStyle !== false && drag !== "drag" && base.options.items === 1 && base.browser.support3d === true) { 613 base.swapSpeed(0); 614 if (base.browser.support3d === true) { 615 base.transition3d(base.positionsInArray[position]); 616 } else { 617 base.css2slide(base.positionsInArray[position], 1); 618 } 619 base.afterGo(); 620 base.singleItemTransition(); 621 return false; 622 } 623 goToPixel = base.positionsInArray[position]; 624 625 if (base.browser.support3d === true) { 626 base.isCss3Finish = false; 627 628 if (speed === true) { 629 base.swapSpeed("paginationSpeed"); 630 window.setTimeout(function () { 631 base.isCss3Finish = true; 632 }, base.options.paginationSpeed); 633 634 } else if (speed === "rewind") { 635 base.swapSpeed(base.options.rewindSpeed); 636 window.setTimeout(function () { 637 base.isCss3Finish = true; 638 }, base.options.rewindSpeed); 639 640 } else { 641 base.swapSpeed("slideSpeed"); 642 window.setTimeout(function () { 643 base.isCss3Finish = true; 644 }, base.options.slideSpeed); 645 } 646 base.transition3d(goToPixel); 647 } else { 648 if (speed === true) { 649 base.css2slide(goToPixel, base.options.paginationSpeed); 650 } else if (speed === "rewind") { 651 base.css2slide(goToPixel, base.options.rewindSpeed); 652 } else { 653 base.css2slide(goToPixel, base.options.slideSpeed); 654 } 655 } 656 base.afterGo(); 657 }, 658 659 jumpTo : function (position) { 660 var base = this; 661 if (typeof base.options.beforeMove === "function") { 662 base.options.beforeMove.apply(this, [base.$elem]); 663 } 664 if (position >= base.maximumItem || position === -1) { 665 position = base.maximumItem; 666 } else if (position <= 0) { 667 position = 0; 668 } 669 base.swapSpeed(0); 670 if (base.browser.support3d === true) { 671 base.transition3d(base.positionsInArray[position]); 672 } else { 673 base.css2slide(base.positionsInArray[position], 1); 674 } 675 base.currentItem = base.owl.currentItem = position; 676 base.afterGo(); 677 }, 678 679 afterGo : function () { 680 var base = this; 681 682 base.prevArr.push(base.currentItem); 683 base.prevItem = base.owl.prevItem = base.prevArr[base.prevArr.length - 2]; 684 base.prevArr.shift(0); 685 686 if (base.prevItem !== base.currentItem) { 687 base.checkPagination(); 688 base.checkNavigation(); 689 base.eachMoveUpdate(); 690 691 if (base.options.autoPlay !== false) { 692 base.checkAp(); 693 } 694 } 695 if (typeof base.options.afterMove === "function" && base.prevItem !== base.currentItem) { 696 base.options.afterMove.apply(this, [base.$elem]); 697 } 698 }, 699 700 stop : function () { 701 var base = this; 702 base.apStatus = "stop"; 703 window.clearInterval(base.autoPlayInterval); 704 }, 705 706 checkAp : function () { 707 var base = this; 708 if (base.apStatus !== "stop") { 709 base.play(); 710 } 711 }, 712 713 play : function () { 714 var base = this; 715 base.apStatus = "play"; 716 if (base.options.autoPlay === false) { 717 return false;
718 } 719 window.clearInterval(base.autoPlayInterval); 720 base.autoPlayInterval = window.setInterval(function () { 721 base.next(true); 722 }, base.options.autoPlay); 723 }, 724 725 swapSpeed : function (action) { 726 var base = this; 727 if (action === "slideSpeed") { 728 base.$owlWrapper.css(base.addCssSpeed(base.options.slideSpeed)); 729 } else if (action === "paginationSpeed") { 730 base.$owlWrapper.css(base.addCssSpeed(base.options.paginationSpeed)); 731 } else if (typeof action !== "string") { 732 base.$owlWrapper.css(base.addCssSpeed(action)); 733 } 734 }, 735 736 addCssSpeed : function (speed) { 737 return { 738 "-webkit-transition": "all " + speed + "ms ease", 739 "-moz-transition": "all " + speed + "ms ease", 740 "-o-transition": "all " + speed + "ms ease", 741 "transition": "all " + speed + "ms ease" 742 }; 743 }, 744 745 removeTransition : function () { 746 return { 747 "-webkit-transition": "", 748 "-moz-transition": "", 749 "-o-transition": "", 750 "transition": "" 751 }; 752 }, 753 754 doTranslate : function (pixels) { 755 return { 756 "-webkit-transform": "translate3d(" + pixels + "px, 0px, 0px)", 757 "-moz-transform": "translate3d(" + pixels + "px, 0px, 0px)", 758 "-o-transform": "translate3d(" + pixels + "px, 0px, 0px)", 759 "-ms-transform": "translate3d(" + pixels + "px, 0px, 0px)", 760 "transform": "translate3d(" + pixels + "px, 0px,0px)" 761 }; 762 }, 763 764 transition3d : function (value) { 765 var base = this; 766 base.$owlWrapper.css(base.doTranslate(value)); 767 }, 768 769 css2move : function (value) { 770 var base = this; 771 base.$owlWrapper.css({"left" : value}); 772 }, 773 774 css2slide : function (value, speed) { 775 var base = this; 776 777 base.isCssFinish = false; 778 base.$owlWrapper.stop(true, true).animate({ 779 "left" : value 780 }, { 781 duration : speed || base.options.slideSpeed, 782 complete : function () { 783 base.isCssFinish = true; 784 } 785 }); 786 }, 787 788 checkBrowser : function () { 789 var base = this, 790 translate3D = "translate3d(0px, 0px, 0px)", 791 tempElem = document.createElement("div"), 792 regex, 793 asSupport, 794 support3d, 795 isTouch; 796 797 tempElem.style.cssText = " -moz-transform:" + translate3D + 798 "; -ms-transform:" + translate3D + 799 "; -o-transform:" + translate3D + 800 "; -webkit-transform:" + translate3D + 801 "; transform:" + translate3D; 802 regex = /translate3d\(0px, 0px, 0px\)/g; 803 asSupport = tempElem.style.cssText.match(regex); 804 support3d = (asSupport !== null && asSupport.length === 1); 805 806 isTouch = "ontouchstart" in window || window.navigator.msMaxTouchPoints; 807 808 base.browser = { 809 "support3d" : support3d, 810 "isTouch" : isTouch 811 }; 812 }, 813 814 moveEvents : function () { 815 var base = this; 816 if (base.options.mouseDrag !== false || base.options.touchDrag !== false) { 817 base.gestures(); 818 base.disabledEvents(); 819 } 820 }, 821 822 eventTypes : function () { 823 var base = this, 824 types = ["s", "e", "x"]; 825 826 base.ev_types = {}; 827 828 if (base.options.mouseDrag === true && base.options.touchDrag === true) { 829 types = [ 830 "touchstart.owl mousedown.owl", 831 "touchmove.owl mousemove.owl", 832 "touchend.owl touchcancel.owl mouseup.owl" 833 ]; 834 } else if (base.options.mouseDrag === false && base.options.touchDrag === true) { 835 types = [ 836 "touchstart.owl", 837 "touchmove.owl", 838 "touchend.owl touchcancel.owl" 839 ]; 840 } else if (base.options.mouseDrag === true && base.options.touchDrag === false) { 841 types = [ 842 "mousedown.owl", 843 "mousemove.owl", 844 "mouseup.owl" 845 ]; 846 } 847 848 base.ev_types.start = types[0]; 849 base.ev_types.move = types[1]; 850 base.ev_types.end = types[2]; 851 }, 852 853 disabledEvents : function () { 854 var base = this; 855 base.$elem.on("dragstart.owl", function (event) { event.preventDefault(); }); 856 base.$elem.on("mousedown.disableTextSelect", function (e) { 857 return $(e.target).is('input, textarea, select, option'); 858 }); 859 }, 860 861 gestures : function () { 862 /*jslint unparam: true*/ 863 var base = this, 864 locals = { 865 offsetX : 0, 866 offsetY : 0, 867 baseElWidth : 0, 868 relativePos : 0, 869 position: null, 870 minSwipe : null, 871 maxSwipe: null, 872 sliding : null, 873 dargging: null, 874 targetElement : null 875 }; 876 877 base.isCssFinish = true; 878 879 function getTouches(event) { 880 if (event.touches !== undefined) { 881 return { 882 x : event.touches[0].pageX, 883 y : event.touches[0].pageY 884 }; 885 } 886 887 if (event.touches === undefined) { 888 if (event.pageX !== undefined) { 889 return { 890 x : event.pageX, 891 y : event.pageY 892 }; 893 } 894 if (event.pageX === undefined) { 895 return { 896 x : event.clientX, 897 y : event.clientY 898 }; 899 } 900 } 901 } 902 903 function swapEvents(type) { 904 if (type === "on") { 905 $(document).on(base.ev_types.move, dragMove); 906 $(document).on(base.ev_types.end, dragEnd); 907 } else if (type === "off") { 908 $(document).off(base.ev_types.move); 909 $(document).off(base.ev_types.end); 910 } 911 } 912 913 function dragStart(event) { 914 var ev = event.originalEvent || event || window.event, 915 position; 916 917 if (ev.which === 3) { 918 return false;
919 } 920 if (base.itemsAmount <= base.options.items) { 921 return; 922 } 923 if (base.isCssFinish === false && !base.options.dragBeforeAnimFinish) { 924 return false; 925 } 926 if (base.isCss3Finish === false && !base.options.dragBeforeAnimFinish) { 927 return false; 928 } 929 930 if (base.options.autoPlay !== false) { 931 window.clearInterval(base.autoPlayInterval); 932 } 933 934 if (base.browser.isTouch !== true && !base.$owlWrapper.hasClass("grabbing")) { 935 base.$owlWrapper.addClass("grabbing"); 936 } 937 938 base.newPosX = 0; 939 base.newRelativeX = 0; 940 941 $(this).css(base.removeTransition()); 942 943 position = $(this).position(); 944 locals.relativePos = position.left; 945 946 locals.offsetX = getTouches(ev).x - position.left; 947 locals.offsetY = getTouches(ev).y - position.top; 948 949 swapEvents("on"); 950 951 locals.sliding = false; 952 locals.targetElement = ev.target || ev.srcElement; 953 } 954 955 function dragMove(event) { 956 var ev = event.originalEvent || event || window.event, 957 minSwipe, 958 maxSwipe; 959 960 base.newPosX = getTouches(ev).x - locals.offsetX; 961 base.newPosY = getTouches(ev).y - locals.offsetY; 962 base.newRelativeX = base.newPosX - locals.relativePos; 963 964 if (typeof base.options.startDragging === "function" && locals.dragging !== true && base.newRelativeX !== 0) { 965 locals.dragging = true; 966 base.options.startDragging.apply(base, [base.$elem]); 967 } 968 969 if ((base.newRelativeX > 8 || base.newRelativeX < -8) && (base.browser.isTouch === true)) { 970 if (ev.preventDefault !== undefined) { 971 ev.preventDefault(); 972 } else { 973 ev.returnValue = false; 974 } 975 locals.sliding = true; 976 } 977 978 if ((base.newPosY > 10 || base.newPosY < -10) && locals.sliding === false) { 979 $(document).off("touchmove.owl"); 980 } 981 982 minSwipe = function () { 983 return base.newRelativeX / 5; 984 }; 985 986 maxSwipe = function () { 987 return base.maximumPixels + base.newRelativeX / 5; 988 }; 989 990 base.newPosX = Math.max(Math.min(base.newPosX, minSwipe()), maxSwipe()); 991 if (base.browser.support3d === true) { 992 base.transition3d(base.newPosX); 993 } else { 994 base.css2move(base.newPosX); 995 } 996 } 997 998 function dragEnd(event) { 999 var ev = event.originalEvent || event || window.event, 1000 newPosition, 1001 handlers, 1002 owlStopEvent; 1003 1004 ev.target = ev.target || ev.srcElement; 1005 1006 locals.dragging = false; 1007 1008 if (base.browser.isTouch !== true) { 1009 base.$owlWrapper.removeClass("grabbing"); 1010 } 1011 1012 if (base.newRelativeX < 0) { 1013 base.dragDirection = base.owl.dragDirection = "left"; 1014 } else { 1015 base.dragDirection = base.owl.dragDirection = "right"; 1016 } 1017 1018 if (base.newRelativeX !== 0) { 1019 newPosition = base.getNewPosition(); 1020 base.goTo(newPosition, false, "drag"); 1021 if (locals.targetElement === ev.target && base.browser.isTouch !== true) { 1022 $(ev.target).on("click.disable", function (ev) { 1023 ev.stopImmediatePropagation(); 1024 ev.stopPropagation(); 1025 ev.preventDefault(); 1026 $(ev.target).off("click.disable"); 1027 }); 1028 handlers = $._data(ev.target, "events").click; 1029 owlStopEvent = handlers.pop(); 1030 handlers.splice(0, 0, owlStopEvent); 1031 } 1032 } 1033 swapEvents("off"); 1034 } 1035 base.$elem.on(base.ev_types.start, ".owl-wrapper", dragStart); 1036 }, 1037 1038 getNewPosition : function () { 1039 var base = this, 1040 newPosition = base.closestItem(); 1041 1042 if (newPosition > base.maximumItem) { 1043 base.currentItem = base.maximumItem; 1044 newPosition = base.maximumItem; 1045 } else if (base.newPosX >= 0) { 1046 newPosition = 0; 1047 base.currentItem = 0; 1048 } 1049 return newPosition; 1050 }, 1051 closestItem : function () { 1052 var base = this, 1053 array = base.options.scrollPerPage === true ? base.pagesInArray : base.positionsInArray, 1054 goal = base.newPosX, 1055 closest = null; 1056 1057 $.each(array, function (i, v) { 1058 if (goal - (base.itemWidth / 20) > array[i + 1] && goal - (base.itemWidth / 20) < v && base.moveDirection() === "left") { 1059 closest = v; 1060 if (base.options.scrollPerPage === true) { 1061 base.currentItem = $.inArray(closest, base.positionsInArray); 1062 } else { 1063 base.currentItem = i; 1064 } 1065 } else if (goal + (base.itemWidth / 20) < v && goal + (base.itemWidth / 20) > (array[i + 1] || array[i] - base.itemWidth) && base.moveDirection() === "right") { 1066 if (base.options.scrollPerPage === true) { 1067 closest = array[i + 1] || array[array.length - 1]; 1068 base.currentItem = $.inArray(closest, base.positionsInArray); 1069 } else { 1070 closest = array[i + 1]; 1071 base.currentItem = i + 1; 1072 } 1073 } 1074 }); 1075 return base.currentItem; 1076 }, 1077 1078 moveDirection : function () { 1079 var base = this, 1080 direction; 1081 if (base.newRelativeX < 0) { 1082 direction = "right"; 1083 base.playDirection = "next"; 1084 } else { 1085 direction = "left"; 1086 base.playDirection = "prev"; 1087 } 1088 return direction; 1089 }, 1090 1091 customEvents : function () { 1092 /*jslint unparam: true*/ 1093 var base = this; 1094 base.$elem.on("owl.next", function () { 1095 base.next(); 1096 }); 1097 base.$elem.on("owl.prev", function () { 1098 base.prev(); 1099 }); 1100 base.$elem.on("owl.play", function (event, speed) { 1101 base.options.autoPlay = speed; 1102 base.play(); 1103 base.hoverStatus = "play"; 1104 }); 1105 base.$elem.on("owl.stop", function () { 1106 base.stop(); 1107 base.hoverStatus = "stop"; 1108 }); 1109 base.$elem.on("owl.goTo", function (event, item) { 1110 base.goTo(item); 1111 }); 1112 base.$elem.on("owl.jumpTo", function (event, item) { 1113 base.jumpTo(item); 1114 }); 1115 }, 1116 1117 stopOnHover : function () { 1118 var base = this; 1119 if (base.options.stopOnHover === true && base.browser.isTouch !== true && base.options.autoPlay !== false) { 1120 base.$elem.on("mouseover", function () { 1121 base.stop(); 1122 }); 1123 base.$elem.on("mouseout", function () { 1124 if (base.hoverStatus !== "stop") { 1125 base.play(); 1126 } 1127 }); 1128 } 1129 }, 1130 1131 lazyLoad : function () { 1132 var base = this, 1133 i, 1134 $item, 1135 itemNumber, 1136 $lazyImg, 1137 follow; 1138 1139 if (base.options.lazyLoad === false) { 1140 return false;
1141 } 1142 for (i = 0; i < base.itemsAmount; i += 1) { 1143 $item = $(base.$owlItems[i]); 1144 1145 if ($item.data("owl-loaded") === "loaded") { 1146 continue; 1147 } 1148 1149 itemNumber = $item.data("owl-item"); 1150 $lazyImg = $item.find(".lazyOwl"); 1151 1152 if (typeof $lazyImg.data("src") !== "string") { 1153 $item.data("owl-loaded", "loaded"); 1154 continue; 1155 } 1156 if ($item.data("owl-loaded") === undefined) { 1157 $lazyImg.hide(); 1158 $item.addClass("loading").data("owl-loaded", "checked"); 1159 } 1160 if (base.options.lazyFollow === true) { 1161 follow = itemNumber >= base.currentItem; 1162 } else { 1163 follow = true; 1164 } 1165 if (follow && itemNumber < base.currentItem + base.options.items && $lazyImg.length) { 1166 base.lazyPreload($item, $lazyImg); 1167 } 1168 } 1169 }, 1170 1171 lazyPreload : function ($item, $lazyImg) { 1172 var base = this, 1173 iterations = 0, 1174 isBackgroundImg; 1175 1176 if ($lazyImg.prop("tagName") === "DIV") { 1177 $lazyImg.css("background-image", "url(" + $lazyImg.data("src") + ")"); 1178 isBackgroundImg = true; 1179 } else { 1180 $lazyImg[0].src = $lazyImg.data("src"); 1181 } 1182 1183 function showImage() { 1184 $item.data("owl-loaded", "loaded").removeClass("loading"); 1185 $lazyImg.removeAttr("data-src"); 1186 if (base.options.lazyEffect === "fade") { 1187 $lazyImg.fadeIn(400); 1188 } else { 1189 $lazyImg.show(); 1190 } 1191 if (typeof base.options.afterLazyLoad === "function") { 1192 base.options.afterLazyLoad.apply(this, [base.$elem]); 1193 } 1194 } 1195 1196 function checkLazyImage() { 1197 iterations += 1; 1198 if (base.completeImg($lazyImg.get(0)) || isBackgroundImg === true) { 1199 showImage(); 1200 } else if (iterations <= 100) {//if image loads in less than 10 seconds 1201 window.setTimeout(checkLazyImage, 100); 1202 } else { 1203 showImage(); 1204 } 1205 } 1206 1207 checkLazyImage(); 1208 }, 1209 1210 autoHeight : function () { 1211 var base = this, 1212 $currentimg = $(base.$owlItems[base.currentItem]).find("img"), 1213 iterations; 1214 1215 function addHeight() { 1216 var $currentItem = $(base.$owlItems[base.currentItem]).height(); 1217 base.wrapperOuter.css("height", $currentItem + "px"); 1218 if (!base.wrapperOuter.hasClass("autoHeight")) { 1219 window.setTimeout(function () { 1220 base.wrapperOuter.addClass("autoHeight"); 1221 }, 0); 1222 } 1223 } 1224 1225 function checkImage() { 1226 iterations += 1; 1227 if (base.completeImg($currentimg.get(0))) { 1228 addHeight(); 1229 } else if (iterations <= 100) { //if image loads in less than 10 seconds 1230 window.setTimeout(checkImage, 100); 1231 } else { 1232 base.wrapperOuter.css("height", ""); //Else remove height attribute 1233 } 1234 } 1235 1236 if ($currentimg.get(0) !== undefined) { 1237 iterations = 0; 1238 checkImage(); 1239 } else { 1240 addHeight(); 1241 } 1242 }, 1243 1244 completeImg : function (img) { 1245 var naturalWidthType; 1246 1247 if (!img.complete) { 1248 return false; 1249 } 1250 naturalWidthType = typeof img.naturalWidth;
1251 if (naturalWidthType !== "undefined" && img.naturalWidth === 0) { 1252 return false; 1253 } 1254 return true; 1255 }, 1256 1257 onVisibleItems : function () { 1258 var base = this, 1259 i; 1260 1261 if (base.options.addClassActive === true) { 1262 base.$owlItems.removeClass("active"); 1263 } 1264 base.visibleItems = []; 1265 for (i = base.currentItem; i < base.currentItem + base.options.items; i += 1) { 1266 base.visibleItems.push(i); 1267 1268 if (base.options.addClassActive === true) { 1269 $(base.$owlItems[i]).addClass("active"); 1270 } 1271 } 1272 base.owl.visibleItems = base.visibleItems; 1273 }, 1274 1275 transitionTypes : function (className) { 1276 var base = this; 1277 //Currently available: "fade", "backSlide", "goDown", "fadeUp" 1278 base.outClass = "owl-" + className + "-out"; 1279 base.inClass = "owl-" + className + "-in"; 1280 }, 1281 1282 singleItemTransition : function () { 1283 var base = this, 1284 outClass = base.outClass, 1285 inClass = base.inClass, 1286 $currentItem = base.$owlItems.eq(base.currentItem), 1287 $prevItem = base.$owlItems.eq(base.prevItem), 1288 prevPos = Math.abs(base.positionsInArray[base.currentItem]) + base.positionsInArray[base.prevItem], 1289 origin = Math.abs(base.positionsInArray[base.currentItem]) + base.itemWidth / 2, 1290 animEnd = 'webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend'; 1291 1292 base.isTransition = true; 1293 1294 base.$owlWrapper 1295 .addClass('owl-origin') 1296 .css({ 1297 "-webkit-transform-origin" : origin + "px", 1298 "-moz-perspective-origin" : origin + "px", 1299 "perspective-origin" : origin + "px" 1300 }); 1301 function transStyles(prevPos) { 1302 return { 1303 "position" : "relative", 1304 "left" : prevPos + "px" 1305 }; 1306 } 1307 1308 $prevItem 1309 .css(transStyles(prevPos, 10)) 1310 .addClass(outClass) 1311 .on(animEnd, function () { 1312 base.endPrev = true; 1313 $prevItem.off(animEnd); 1314 base.clearTransStyle($prevItem, outClass); 1315 }); 1316 1317 $currentItem 1318 .addClass(inClass) 1319 .on(animEnd, function () { 1320 base.endCurrent = true; 1321 $currentItem.off(animEnd); 1322 base.clearTransStyle($currentItem, inClass); 1323 }); 1324 }, 1325 1326 clearTransStyle : function (item, classToRemove) { 1327 var base = this; 1328 item.css({ 1329 "position" : "", 1330 "left" : "" 1331 }).removeClass(classToRemove); 1332 1333 if (base.endPrev && base.endCurrent) { 1334 base.$owlWrapper.removeClass('owl-origin'); 1335 base.endPrev = false; 1336 base.endCurrent = false; 1337 base.isTransition = false; 1338 } 1339 }, 1340 1341 owlStatus : function () { 1342 var base = this; 1343 base.owl = { 1344 "userOptions" : base.userOptions, 1345 "baseElement" : base.$elem, 1346 "userItems" : base.$userItems, 1347 "owlItems" : base.$owlItems, 1348 "currentItem" : base.currentItem, 1349 "prevItem" : base.prevItem, 1350 "visibleItems" : base.visibleItems, 1351 "isTouch" : base.browser.isTouch, 1352 "browser" : base.browser, 1353 "dragDirection" : base.dragDirection 1354 }; 1355 }, 1356 1357 clearEvents : function () { 1358 var base = this; 1359 base.$elem.off(".owl owl mousedown.disableTextSelect"); 1360 $(document).off(".owl owl"); 1361 $(window).off("resize", base.resizer); 1362 }, 1363 1364 unWrap : function () { 1365 var base = this; 1366 if (base.$elem.children().length !== 0) { 1367 base.$owlWrapper.unwrap(); 1368 base.$userItems.unwrap().unwrap(); 1369 if (base.owlControls) { 1370 base.owlControls.remove(); 1371 } 1372 } 1373 base.clearEvents(); 1374 base.$elem 1375 .attr("style", base.$elem.data("owl-originalStyles") || "") 1376 .attr("class", base.$elem.data("owl-originalClasses")); 1377 }, 1378 1379 destroy : function () { 1380 var base = this; 1381 base.stop(); 1382 window.clearInterval(base.checkVisible); 1383 base.unWrap(); 1384 base.$elem.removeData(); 1385 }, 1386 1387 reinit : function (newOptions) { 1388 var base = this, 1389 options = $.extend({}, base.userOptions, newOptions); 1390 base.unWrap(); 1391 base.init(options, base.$elem); 1392 }, 1393 1394 addItem : function (htmlString, targetPosition) { 1395 var base = this, 1396 position; 1397 1398 if (!htmlString) {return false; } 1399 1400 if (base.$elem.children().length === 0) { 1401 base.$elem.append(htmlString); 1402 base.setVars(); 1403 return false;
1404 } 1405 base.unWrap(); 1406 if (targetPosition === undefined || targetPosition === -1) { 1407 position = -1; 1408 } else { 1409 position = targetPosition; 1410 } 1411 if (position >= base.$userItems.length || position === -1) { 1412 base.$userItems.eq(-1).after(htmlString); 1413 } else { 1414 base.$userItems.eq(position).before(htmlString); 1415 } 1416 1417 base.setVars(); 1418 }, 1419 1420 removeItem : function (targetPosition) { 1421 var base = this, 1422 position; 1423 1424 if (base.$elem.children().length === 0) { 1425 return false; 1426 } 1427 if (targetPosition === undefined || targetPosition === -1) { 1428 position = -1; 1429 } else { 1430 position = targetPosition; 1431 } 1432 1433 base.unWrap(); 1434 base.$userItems.eq(position).remove(); 1435 base.setVars(); 1436 } 1437 1438 }; 1439 1440 $.fn.owlCarousel = function (options) { 1441 return this.each(function () { 1442 if ($(this).data("owl-init") === true) { 1443 return false; 1444 } 1445 $(this).data("owl-init", true); 1446 var carousel = Object.create(Carousel); 1447 carousel.init(options, this); 1448 $.data(this, "owlCarousel", carousel); 1449 }); 1450 }; 1451 1452 $.fn.owlCarousel.options = { 1453 1454 items : 5, 1455 itemsCustom : false, 1456 itemsDesktop : [1199, 4], 1457 itemsDesktopSmall : [979, 3], 1458 itemsTablet : [768, 2], 1459 itemsTabletSmall : false, 1460 itemsMobile : [479, 1], 1461 singleItem : false, 1462 itemsScaleUp : false, 1463 1464 slideSpeed : 200, 1465 paginationSpeed : 800, 1466 rewindSpeed : 1000, 1467 1468 autoPlay : false, 1469 stopOnHover : false, 1470 1471 navigation : false, 1472 navigationText : ["prev", "next"], 1473 rewindNav : true, 1474 scrollPerPage : false, 1475 1476 pagination : true, 1477 paginationNumbers : false, 1478 1479 responsive : true, 1480 responsiveRefreshRate : 200, 1481 responsiveBaseWidth : window, 1482 1483 baseClass : "owl-carousel", 1484 theme : "owl-theme", 1485 1486 lazyLoad : false, 1487 lazyFollow : true, 1488 lazyEffect : "fade", 1489 1490 autoHeight : false, 1491 1492 jsonPath : false, 1493 jsonSuccess : false, 1494 1495 dragBeforeAnimFinish : true, 1496 mouseDrag : true, 1497 touchDrag : true, 1498 1499 addClassActive : false, 1500 transitionStyle : false, 1501 1502 beforeUpdate : false, 1503 afterUpdate : false, 1504 beforeInit : false, 1505 afterInit : false, 1506 beforeMove : false, 1507 afterMove : false, 1508 afterAction : false, 1509 startDragging : false, 1510 afterLazyLoad: false 1511 }; 1512}(jQuery, window, document)); 1513 1514/** 1515 * Galeries Krea3 1516 */ 1517(function($) { 1518 // Declaration de notre plugin 1519 $.plusGallery = function(element, options) { 1520 // Mise en place des options par défaut 1521 var defaults = { 1522 imagePath : 'images/plusgallery', 1523 imageData : null, 1524 imageSize : 'thumbnail', 1525 galleryID : '', 1526 phototheque: 0, 1527 /* don't touch */ 1528 imgArray : [], 1529 titleArray : [], 1530 t : '', // timer 1531 idx : 0, 1532 imgCount : 0, 1533 imgTotal : [], 1534 winWidth : 1024, // resets 1535 touch : false, 1536 titleText : '', 1537 fermer: "Fermer",
1538 fermer_title: "Fermer la galerie photo", 1539 suivant: "Suivant", 1540 precedent: "Précédent", 1541 suivant_title: "Photo suivante", 1542 precedent_title: "Photo précédente", 1543 zoomIdx: null, //the zoom index 1544 zoomImagesLoaded: [], 1545 zoomScrollDir: null, 1546 zoomScrollLeft: 0, 1547 }; 1548 1549 // Pour éviter la confusion avec $(this) on declare plugin comme varible pour l'instance de notre plugin 1550 var plugin = this; 1551 // On crée un objet vide qui contiendra les options de notre plugin 1552 plugin.options = {} 1553 // reference a l'objet jQuery que le plugin affecte 1554 var $element = $(element); 1555 // reference a l'element HTML que le plugin affecte 1556 var element = element; 1557 1558 // La méthode dite "constructeur" qui sera appelée lorsque l'objet sera crée 1559 plugin.init = function() { 1560 // on stocke les options dans un objet en fusionnant les options par defaut et celle ajoutée en parametre 1561 plugin.options = $.extend({}, defaults, options); 1562 // On déclare toutes les méthodes utiles à la construction du plugin 1563 setplusGallery(); 1564 setEvents(); 1565 } 1566 1567 /** 1568 * Méthode privée pour insérer dans le dom la galerie à l'élément affecté par le plugin 1569 */ 1570 var setplusGallery = function(){ 1571 plugin.options.imageData = JSON.parse( $element.attr("data-image-data") ); 1572 $element.append('<div id="pgthumbview' + plugin.options.galleryID + '">' + '<ul id="pgthumbs' + plugin.options.galleryID + '" class="clearfix"></ul>' + '</div>'); 1573 $element.addClass('pg'); 1574 } 1575 1576 var parseData = function() { 1577 var obPath, imgTitle, imgSrc, imgTh, imgBg = '', thumbsLoaded = 0, zoomWidth, flickrImgExt; 1578 1579 $('.crumbtitle').remove(); 1580 $('#pgthumbs' + plugin.options.galleryID).empty(); 1581 1582 1583 objPath = plugin.options.imageData.images; 1584 1585 plugin.options.imgTotal = objPath.length; 1586 1587 if (plugin.options.imgTotal === 0) { 1588 alert("Veuillez vérifier le contenu de votre page car aucunes photos n'ont été détectées dans une ou plusieurs galeries de votre page."); 1589 } 1590 1591 if (plugin.options.winWidth > 1100) { 1592 zoomWidth = 1024; 1593 } else if (plugin.options.winWidth > 620) { 1594 zoomWidth = 768; 1595 } else { 1596 zoomWidth = 540; 1597 } 1598 1599 plugin.options.imgArray = []; 1600 plugin.options.titleArray = []; 1601 //console.log( plugin.options.imageSize); 1602 1603 $.each(objPath, function(i, obj) { 1604 1605 imgTitle = ''; 1606 if (obj.caption !== null) { 1607 imgTitle = obj.caption; 1608 } 1609 imgSrc = obj.src; 1610 imgTh = obj.th; 1611 1612 id = obj.id; 1613 plugin.options.imgArray[i] = imgSrc; 1614 plugin.options.titleArray[i] = imgTitle; 1615 1616 var dim_vignette, target, span_phototheque, span_titre, onclick = taxos = title_telecharger = ""; 1617 1618 if ( typeof(obj.taxos) != 'undefined') { 1619 taxos = obj.taxos; 1620 } 1621 1622 if( plugin.options.phototheque == 0){ 1623 dim_vignette = "pgthumb"; 1624 target = ""; 1625 span_phototheque = ""; 1626 span_titre = ''; 1627 title_telecharger = imgTitle; 1628 onclick = ""; 1629 } 1630 else{ 1631 dim_vignette = "pgthumb_phototheque"; 1632 target = ' target="_blank" '; 1633 span_phototheque = '<span class="titre_phototheque">'+ telecharger_photo +'</span>'; 1634 span_titre = '<span class="item-a-title">'+imgTitle+'</span>'; 1635 title_telecharger = titre_telecharger + " " + imgTitle; 1636 onclick = " onclick='incrementer_photo("+id+")' "; 1637 } 1638 1639 span_phototheque = ""; 1640 1641 if (plugin.options.imageSize == "vignette-annuaire-large"){ 1642 dim_vignette = dim_vignette + " large"; 1643 }else if(plugin.options.imageSize == "large"){ 1644 dim_vignette = dim_vignette + " full"; 1645 } 1646 1647 if( plugin.options.phototheque == 1 ){ 1648 dim_vignette = dim_vignette + " large"; 1649 } 1650 1651 $('#pgthumbs' + plugin.options.galleryID).append( 1652 '<li class="' + dim_vignette + ' ' + taxos + ' " id="' + plugin.options.galleryID + "-" + i + '" ><a href="' + imgSrc 1653 + '" rel="' + id + '" ' + target + onclick + '><img itemprop="image" src="' + imgTh 1654 + '" id="pgthumbimg' + plugin.options.galleryID 1655 + i + '" class="pgthumbimg" alt="' 1656 + imgTitle + '" title="' + title_telecharger + '"' + imgBg + '>' + span_titre + span_phototheque + '</a></li>' 1657 ); 1658 1659 // check to make sure all the images are loaded and if 1660 // so show the thumbs 1661 $('#pgthumbimg' + plugin.options.galleryID + i).load(function() { 1662 thumbsLoaded++; 1663 if (thumbsLoaded == plugin.options.imgTotal) { 1664 $('#pgthumbview'+ plugin.options.galleryID).show(); 1665 } 1666 }); 1667 }); // end each 1668 1669 } 1670 1671 /** 1672 * Méthode privée pour mettre en place les évènements sur les galeries 1673 */ 1674 var setEvents = function(){ 1675 var _doc = $(document); 1676 // check for touch device 1677 if ("ontouchstart" in document.documentElement) { 1678 window.scrollTo(0, 1); 1679 plugin.options.touch = true; 1680 } 1681 1682 var touchClass; 1683 1684 if (plugin.options.touch) { 1685 touchClass = 'touch'; 1686 $element.addClass('touch'); 1687 } else { 1688 touchClass = 'no-touch'; 1689 $element.addClass('no-touch'); 1690 } 1691 1692 plugin.options.winWidth = $(window).width(); 1693 1694 // reset some shit in case there is another copy that was loaded. 1695 $('#pgzoomview').remove(); 1696 // Unbind everything first? 1697 _doc.off("click",".pgthumb, .pgzoomarrow, .pgzoomclose, #pgzoomview, #pgzoomslide, .pgzoomslide, .pgzoomimg"); 1698 1699 1700 $('body').prepend('<div id="pgzoomview" class="pg ' + touchClass + '">' 1701 + '<a href="#" rel="previous" id="pgzoomclose" title="'+plugin.options.fermer_title+'">'+plugin.options.fermer+'</a>' 1702 + '<a href="#" rel="previous" id="pgprevious" class="pgzoomarrow" title="'+plugin.options.precedent+'">'+plugin.options.precedent_title+'</a>' 1703 + '<a href="#" rel="next" id="pgnext" class="pgzoomarrow" title="'+plugin.options.suivant+'">'+plugin.options.suivant_title+'</a>' 1704 + '<div id="pgzoomscroll">' + '<ul id="pgzoom"></ul>' + '</div>' + '</div>'); 1705 1706 parseData(); 1707 1708 $element.addClass('loaded'); 1709 1710 // attach links load detail image 1711 _doc.on('click', '.pgthumb', function(e) { 1712 e.preventDefault(); 1713 1714 //var idx = $('.pgthumb').index(this); 1715 1716 //var galerie = $(this).parent().parent().attr("id"); 1717 //var galerie = this.id.replace("pgthumbimg","").replace("-"+idx,""); 1718 1719 var s = this.id.split("-"); 1720 var galerie = s[0]; 1721 var idx = $('img',this).attr("id").replace("pgthumbimg"+galerie, ""); 1722 1723 plugin.options.galleryID = galerie; 1724 1725 $element = $("#plusgallery-"+plugin.options.galleryID); 1726 1727 plugin.options.imageSize = $element.attr("data-image-size"); 1728 plugin.options.imageData = JSON.parse( $element.attr("data-image-data") ); 1729 parseData(); 1730 1731 1732 plugin.loadZoom(idx); 1733 return false;
1734 }); 1735 1736 /* zoom events */ 1737 _doc.on('click', '.pgzoomarrow', function(e) { 1738 e.preventDefault(); 1739 var dir = this.rel; 1740 prevNext(dir); 1741 return false; 1742 }); 1743 1744 _doc.on('click', '.pgzoomclose', function(e) { 1745 e.preventDefault(); 1746 unloadZoom(); 1747 }); 1748 _doc.on("click", "#pgzoomview", function(e) { 1749 e.preventDefault(); 1750 unloadZoom(); 1751 }); 1752 1753 _doc.on("click", "#pgzoomslide", function() { 1754 unloadZoom(); 1755 }); 1756 1757 _doc.on("click", ".pgzoomimg", function() { 1758 if ($(this).attr('id').replace('pgzoomimg'+plugin.options.galleryID,'') < plugin.options.imgTotal - 1) { 1759 prevNext('next'); 1760 } 1761 return false; 1762 }); 1763 1764 clearTimeout(plugin.options.t); 1765 } 1766 1767 plugin.loadZoom = function(idx) { 1768 plugin.options.zoomIdx = idx; 1769 plugin.options.winWidth = $(window).width(); 1770 var pgZoomView = $('#pgzoomview'), pgZoomScroll = $('#pgzoomscroll'), pgPrevious = $('#pgprevious'), 1771 pgNext = $('#pgnext'), pgZoom = $('#pgzoom'), pgZoomHTML = '', 1772 totalImages = plugin.options.imgArray.length; 1773 1774 pgZoomView.addClass('fixed'); 1775 1776 // show/hide the prev/next links 1777 if ( idx === 0 ) { 1778 pgPrevious.hide(); 1779 } 1780 1781 if (idx == totalImages - 1) { 1782 pgNext.hide(); 1783 } 1784 1785 1786 var pgzoomWidth = plugin.options.imgArray.length * plugin.options.winWidth; 1787 $('#pgzoom').width(pgzoomWidth); 1788 1789 var scrollLeftInt = parseInt(idx * plugin.options.winWidth); 1790 1791 pgZoomView.fadeIn(function() { 1792 1793 // this has gotta come in after the fade or iOS blows up. 1794 $(window).on('resize', resizeZoom); 1795 1796 $.each(plugin.options.imgArray,function(i) { 1797 /* 1798 pgZoomHTML = pgZoomHTML 1799 + '<li class="pgzoomslide loading" id="pgzoomslide' + i + '" style="width: ' + plugin.options.winWidth 1800 + 'px;"><img src="' + plugin.options.imagePath + '/square.gif" class="pgzoomspacer" alt="zoomspacer"><span class="pgzoomcaption">' 1801 + plugin.options.titleArray[i] + '</span></li>'; 1802 */ 1803 1804 pgZoomHTML = pgZoomHTML 1805 + '<li class="pgzoomslide loading" id="pgzoomslide' + i + '" style="background-image:none;width: ' + plugin.options.winWidth 1806 + 'px;"><figure role="group" class="pgzoomslide loading" style="width: ' + plugin.options.winWidth + 'px;"><img src="' + plugin.options.imagePath + '/square.gif" class="pgzoomspacer" alt="zoomspacer"><figcaption class="pgzoomcaption">' 1807 + plugin.options.titleArray[i] + '</figcaption></figure></li>'; 1808 1809 1810 totalImages = plugin.options.imgArray.length; 1811 1812 1813 if (i + 1 == totalImages) { 1814 // at the end of the loop 1815 $('#pgzoom').html(pgZoomHTML); 1816 zoomKeyPress(); 1817 $('#pgzoomscroll').scrollLeft(scrollLeftInt); 1818 zoomScrollLeft = scrollLeftInt; 1819 loadZoomImg(idx); 1820 zoomScroll(); 1821 1822 // load siblings 1823 if ( (idx - 1) >= 0) { 1824 loadZoomImg(idx - 1); 1825 1826 } 1827 1828 if ((idx + 1) < plugin.options.imgArray.length) { 1829 loadZoomImg(idx + 1); 1830 } 1831 } 1832 1833 }); 1834 }); 1835 } 1836 1837 var loadZoomImg = function(idx) { 1838 if ($('#pgzoomimg' + idx).length === 0) { 1839 $('#pgzoomslide' + idx + ' .pgzoomspacer') 1840 .after( 1841 '<img src="' + plugin.options.imgArray[idx] 1842 + '" data-src="' + plugin.options.imgArray[idx] 1843 + '" title="' + plugin.options.titleArray[idx] 1844 + '" alt="' + plugin.options.titleArray[idx] 1845 + '" id="pgzoomimg' + idx 1846 + '" class="pgzoomimg">'); 1847 $('#pgzoomimg' + idx).load(function() { 1848 $(this).addClass('active'); 1849 }); 1850 } 1851 } 1852 1853 var zoomScroll = function() { 1854 var pgPrevious = $('#pgprevious'), pgNext = $('#pgnext'), scrollTimeout, canLoadZoom = true; 1855 1856 $('#pgzoomscroll') 1857 .on( 1858 'scroll', 1859 function() { 1860 currentScrollLeft = $(this).scrollLeft(); 1861 if (canLoadZoom === true) { 1862 canLoadZoom = false;
1863 scrollTimeout = setTimeout( 1864 function() { 1865 if (currentScrollLeft === 0) { 1866 pgPrevious.fadeOut(); 1867 } else { 1868 pgPrevious.fadeIn(); 1869 } 1870 1871 if (currentScrollLeft >= (plugin.options.imgTotal - 1) 1872 * plugin.options.winWidth) { 1873 pgNext.fadeOut(); 1874 } else { 1875 pgNext.fadeIn(); 1876 } 1877 1878 /* 1879 * Check if we have scrolled 1880 * left and if so load up 1881 * the zoom image 1882 */ 1883 if (currentScrollLeft 1884 % plugin.options.zoomScrollLeft > 20 1885 || (currentScrollLeft > 0 && plugin.options.zoomScrollLeft === 0)) { 1886 plugin.options.zoomScrollLeft = currentScrollLeft; 1887 var currentIdx = plugin.options.zoomScrollLeft 1888 / plugin.options.winWidth; 1889 1890 var currentIdxCeil = Math 1891 .ceil(currentIdx); 1892 var currentIdxFloor = Math 1893 .floor(currentIdx); 1894 1895 // Lazy load siblings on 1896 // scroll. 1897 if (!plugin.options.zoomImagesLoaded[currentIdxCeil]) { 1898 loadZoomImg(currentIdxCeil); 1899 } 1900 if (!plugin.options.zoomImagesLoaded[currentIdxFloor]) { 1901 loadZoomImg(currentIdxFloor); 1902 } 1903 } 1904 canLoadZoom = true; 1905 }, 200); 1906 } 1907 }); 1908 } 1909 1910 zoomKeyPress = function() { 1911 $(document).on('keyup', 'body', function(e) { 1912 if (e.which == 27) { 1913 unloadZoom(); 1914 } else if (e.which == 37) { 1915 prevNext('previous'); 1916 } else if (e.which == 39) { 1917 prevNext('next'); 1918 } 1919 }); 1920 } 1921 1922 unloadZoom = function(){ 1923 $(document).off('keyup','body'); 1924 $(window).off('resize', resizeZoom); 1925 $('#pgzoomscroll').off('scroll'); 1926 $('#pgzoomview').fadeOut(function(){ 1927 $('#pgzoom').empty(); 1928 $('#pgzoomview').off('keyup'); 1929 $('#pgzoomview').removeClass('fixed'); 1930 }); 1931 1932 /* AJOUT POUR LES FILTRES TAXONOMIES */ 1933 if( $('#plusgallery-'+plugin.options.galleryID).hasClass("boxes") ){ 1934 var $filters = $(".filter a"), $boxes = $(".boxes li"); 1935 var $filterColor = $(".filter a.active").attr("data-filter"); 1936 if ($filterColor == "all") { 1937 $boxes.removeClass("is-animated").fadeOut().promise().done(function() { 1938 $boxes.addClass("is-animated").fadeIn(); 1939 }); 1940 }else{ 1941 $boxes.removeClass("is-animated").fadeOut().promise().done(function() { 1942 $(".boxes li."+$filterColor).addClass("is-animated").fadeIn(); 1943 }); 1944 } 1945 } 1946 1947 } 1948 1949 resizeZoom = function() { 1950 plugin.options.winWidth = $(window).width(); 1951 var pgzoomWidth = plugin.options.imgArray.length * plugin.options.winWidth; 1952 $('#pgzoom').width(pgzoomWidth); 1953 $('.pgzoomslide').width(plugin.options.winWidth); 1954 var scrollLeftInt = parseInt(plugin.options.zoomIdx * plugin.options.winWidth); 1955 $('#pgzoomscroll').scrollLeft(scrollLeftInt); 1956 } 1957 1958 prevNext = function(dir){ 1959 var currentIdx = $('#pgzoomscroll').scrollLeft() / plugin.options.winWidth; 1960 1961 if(dir == "previous"){ 1962 plugin.options.zoomIdx = Math.round(currentIdx) - 1; 1963 } 1964 else { 1965 plugin.options.zoomIdx = Math.round(currentIdx) + 1; 1966 } 1967 //console.log("prevnext: plugin.options.zoomIdx = "+plugin.options.zoomIdx); 1968 var newScrollLeft = plugin.options.zoomIdx * plugin.options.winWidth; 1969 1970 $('#pgzoomscroll').stop().animate({scrollLeft:newScrollLeft}); 1971 } 1972 1973 // On appele la méthode publique init qui va se charger de mettre en place 1974 // toutes les méthodes de notre plugin pour qu'il fonctionne 1975 plugin.init(); 1976 1977 }; 1978 1979 // On ajoute le plugin à l'objet jQuery $.fn 1980 $.fn.plusGallery = function(options) { 1981 // Pour chacuns des éléments du dom à qui on a assigné le plugin 1982 return this.each(function() { 1983 // Si le plugin n'as pas deja été assigné à l'élément 1984 //if (undefined == $(this).data('plusGallery-'+ options.gallerID)) { 1985 if (undefined == $(this).data('plusGallery-'+options.galleryID)) { 1986 // On crée une instance du plugin avec les options renseigées 1987 var plugin = new $.plusGallery(this, options); 1988 // on stocke une référence de notre plugin pour pouvoir accéder à ses méthode publiques 1989 $(this).data('plusGallery-'+options.galleryID, plugin); 1990 } 1991 }); 1992 }; 1993 1994})(jQuery); 1995 1996/** 1997 * https://github.com/chriscoyier/Fluid-Width-Video
1998 * http://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php 1999 */ 2000jQuery(function($) { 2001 2002 var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com'], iframe[src^='https://www.youtube.com'], iframe[src^='//www.youtube.com'], object, embed"), 2003 $fluidEl = $("figure.krea3video"); 2004 2005 $allVideos.each(function() { 2006 2007 $(this) 2008 // jQuery .data does not work on object/embed elements 2009 .attr('data-aspectRatio', this.height / this.width) 2010 .removeAttr('height') 2011 .removeAttr('width'); 2012 2013 }); 2014 2015 $(window).resize(function() { 2016 2017 var newWidth = $fluidEl.width(); 2018 $allVideos.each(function() { 2019 2020 var $el = $(this); 2021 $el 2022 .width(newWidth) 2023 .height(newWidth * $el.attr('data-aspectRatio')); 2024 2025 }); 2026 2027 }).resize(); 2028 2029}); 2030 2031// ================================================== 2032// youCover v.alpha 2033// 2034// Licensed GPLv3 for open source use 2035// 2036// ================================================== 2037 2038(function ( $ ) { 2039 var youCover = function(el,attributes){ 2040 var smallScreen = (window.matchMedia('(max-width: 767px)').matches); 2041 var is_mobile = (/Android|webOS|iPhone|iPad|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(navigator.userAgent)); 2042 var $el = $(el), data = $el.data(); 2043 var coverUrl = "https://i3.ytimg.com/vi/%yid%/maxresdefault.jpg"; 2044 var $wrapper = $("<a id='youcover-lien' href='#'></a>"); 2045 var $iframe = $("<iframe />"); 2046 var $cover = $("<img />"); 2047 2048 2049 //merge attributes and keep only iframe attributes 2050 attributes = $.extend( {},attributes,data); 2051 $wrapper.addClass(attributes.wrapperclass); 2052 2053 delete attributes.wrapperclass; 2054 delete attributes.youcover; 2055 delete attributes.fancybox; 2056 delete attributes.rel; 2057 2058 if(data.id){ 2059 data.src = "https://www.youtube.com/embed/" + data.id + "?rel=0&autoplay=1"; 2060 attributes.src = data.src; 2061 } 2062 2063 var yId = data.id || youtube_parser(attributes.src); 2064 var url = coverUrl.replace("%yid%",yId); 2065 var coverImage = data.image || url; 2066 //put autoplay param 2067 var aP = attributes.src.indexOf('autoplay'); 2068 if(aP && !is_mobile) if(aP==-1) attributes.src += "&autoplay=1"; else attributes.src = attributes.src.replace("autoplay=0","autoplay=1"); 2069 2070 if(undefined != data.fancybox && $.fn.fancybox){ 2071 $wrapper.attr('data-fancybox',data.rel || false) 2072 .attr('href',attributes.src) 2073 .attr('rel',data.rel); 2074 $cover.attr('src',coverImage); 2075 $wrapper.append($cover); 2076 $el.replaceWith($wrapper); 2077 $wrapper.addClass('loaded'); 2078 return $wrapper; 2079 } 2080 2081 //apply iframe attributes 2082 $(attributes).each(function(idx,attr){ 2083 for(var key in attr){ 2084 $iframe.attr(key,attr[key]); 2085 } 2086 }); 2087 2088 2089 //check mobile and use default iframe and remove autoplay options if instantiated 2090 if(is_mobile){ 2091 //remove autoplay and update src with new src value 2092 $iframe.attr('src', $iframe.attr('src') + "&autoplay=1" ); 2093 $iframe.attr('allow', "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"); 2094 } 2095 2096 $cover.attr('src',coverImage); 2097 $wrapper.append($cover); 2098 $el.replaceWith($wrapper); 2099 $wrapper.addClass('loaded'); 2100 2101 $wrapper.click(function(e){ 2102 // $('a.youcover-lien').click(function(e){ 2103 e.preventDefault(); 2104 $(this).addClass('active-iframe').addClass('loaded'); 2105 $(this).append($iframe); 2106 }); 2107 2108 return $wrapper; 2109 }; 2110 2111 function youtube_parser(url){ 2112 var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; 2113 var match = url.match(regExp); 2114 return (match&&match[7].length==11)? match[7] : false; 2115 } 2116 2117 /** 2118 * replace the default Youtube iframe player<iframe> 2119 * 2120 * @example 2121 2122 * 2123 * @param {Object} [opcional] Opcional attributes 2124 * @returns {Number} 2125 */ 2126 $.fn.youCover = function(attributes) { 2127 attributes = $.extend( {}, $.fn.youCover.attributes, attributes ); 2128 2129 return $(this).each(function(){ 2130 if($(this).hasClass('loaded')) return this; 2131 return new youCover(this,attributes); 2132 }); 2133 }; 2134 2135 $.fn.youCover.attributes = {wrapperclass:'youCover'}; 2136 2137 //auto detect 2138 $("[data-youcover]").youCover(); 2139 2140 if($.fn.fancybox){ 2141 var $galleryes = $("[data-fancybox][rel]"); 2142 2143 $galleryes.fancybox({ 2144 beforeShow:function(){ 2145 $galleryes.removeClass('fancybox-active'); 2146 }, 2147 afterShow: function( instance, slide ) { 2148 var a = $.fancybox.getInstance().current.opts.$orig; 2149 $(a).addClass('fancybox-active'); 2150 }, 2151 afterClose:function(){ 2152 $galleryes.removeClass('fancybox-active'); 2153 } 2154 }); 2155 } 2156 2157 2158}( jQuery ));
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.