1(function ($) { 2 3 'use strict'; 4 5 function Lightbox(element, options) { 6 this.el = element; 7 this.$element = $(element); 8 this.$body = $('body'); 9 this.objects = {}; 10 this.lightboxModul = {}; 11 this.$item = ''; 12 this.$cont = ''; 13 14 this.$items = this.$element.children().find('a:not(.title_url)'); 15 this.settings = $.extend({}, this.constructor.defaults, options); 16 17 this.init(); 18 19 return this; 20 } 21 22 Lightbox.defaults = { 23 slideAnimationType: 'effect_1', 24 arrows: 'arrows_1', 25 speed: 600, 26 width: '50%', 27 height: '70%', 28 videoMaxWidth: '790', 29 overlayDuration: 100, 30 preload: 10, 31 openCloseType: { 32 0: 'open_1', 33 1: 'close_1' 34 } 35 }; 36 37 Lightbox.prototype.init = function () { 38 var $object = this, $openCloseType; 39 40 switch(this.settings.openCloseType){ 41 case 'none': 42 $openCloseType = { 43 0: 'open_0', 44 1: 'close_0' 45 }; 46 break; 47 case 'unfold': 48 $openCloseType = { 49 0: 'open_1', 50 1: 'close_1' 51 }; 52 break; 53 case 'unfold_r': 54 $openCloseType = { 55 0: 'open_1_r', 56 1: 'close_1_r' 57 }; 58 break; 59 case 'blowup': 60 $openCloseType = { 61 0: 'open_2', 62 1: 'close_2' 63 }; 64 break; 65 case 'blowup_r': 66 $openCloseType = { 67 0: 'open_2_r', 68 1: 'close_2_r' 69 }; 70 break; 71 case 'roadrunner': 72 $openCloseType = { 73 0: 'open_3', 74 1: 'close_3' 75 }; 76 break; 77 case 'roadrunner_r': 78 $openCloseType = { 79 0: 'open_3_r', 80 1: 'close_3_r' 81 }; 82 break; 83 case 'runner': 84 $openCloseType = { 85 0: 'open_4', 86 1: 'close_4' 87 }; 88 break; 89 case 'runner_r': 90 $openCloseType = { 91 0: 'open_4_r', 92 1: 'close_4_r' 93 }; 94 break; 95 case 'rotate': 96 $openCloseType = { 97 0: 'open_5', 98 1: 'close_5' 99 }; 100 break; 101 case 'rotate_r': 102 $openCloseType = { 103 0: 'open_5_r', 104 1: 'close_5_r' 105 }; 106 break; 107 } 108 109 this.settings.openCloseType = $openCloseType; 110 111 (($object.settings.preload > $object.$items.length) && ($object.settings.preload = $object.$items.length)); 112 113 $object.$items.on('click.rwdcustom', function (event) { 114 if(!$('.rwd-SlideWrapper').hasClass('lightboxOff')){ 115 if(!$('.rwd-SlideWrapper').hasClass('rwd-fullscreen-on')){ 116 var $disabled = jQuery('.lSAction a').hasClass('disabled'); 117 118 if($disabled){ 119 return false; 120 } 121 122 event = event || window.event; 123 event.preventDefault ? event.preventDefault() : (event.returnValue = false); 124 125 $object.index = $object.$items.index(this); 126 127 if (!$object.$body.hasClass('rwd-on')) { 128 $object.build($object.index); 129 $object.$body.addClass('rwd-on'); 130 } 131 } else { 132 event.preventDefault(); 133 } 134 } 135 }); 136 137 $object.$body.on('click', function () { 138 $object.$_y_ = window.pageYOffset; 139 }); 140 }; 141 142 Lightbox.prototype.build = function (index) { 143 144 var $object = this; 145 146 $object.structure(index); 147 148 $object.lightboxModul['modul'] = new $.fn.lightbox.lightboxModul['modul']($object.el); 149 150 $object.slide(index, false, false); 151 152 $object.addKeyEvents(); 153 154 if ($object.$items.length > 1) { 155 $object.arrow(); 156 } 157 158 $object.closeGallery(); 159 160 $object.$cont.on('click.rwd-container', function () { 161 $object.$cont.removeClass('rwd-hide-items'); 162 }); 163 164 $object.calculateDimensions(index); 165 }; 166 167 Lightbox.prototype.structure = function (index) { 168 169 var $object = this, list = '', controls = '', i, 170 subHtmlCont = '', close = '', template; 171 172 this.$body.append(
173 this.objects.overlay = $('<div class="rwd-overlay"></div>') 174 ); 175 this.objects.overlay.css('transition-duration', this.settings.overlayDuration + 'ms'); 176 177 for (i = 0; i < this.$items.length; i++) { 178 list += '<div class="rwd-item"></div>'; 179 } 180 181 close = '<span class="rwd-close rwd-icon ' + this.settings.arrows + '"></span>'; 182 183 if (this.$items.length > 1) { 184 controls = '<div class="rwd-arrows ' + this.settings.arrows + '">' + 185 '<div class="rwd-prev rwd-icon"></div>' + 186 '<div class="rwd-next rwd-icon"></div>' + 187 '</div>'; 188 } 189 190 template = '<div class="rwd-cont ">' + 191 '<div class="rwd-container">' + 192 '<div class="cont-inner">' + list + '</div>' + 193 '<div class="rwd-toolbar group">' + 194 close + 195 '</div>' + 196 controls + 197 '</div>' + 198 '</div>'; 199 200 201 switch($object.settings.openCloseType[0]){ 202 case 'open_1': 203 case 'open_2': 204 case 'open_3': 205 case 'open_4': 206 case 'open_5': 207 case 'open_1_r': 208 case 'open_2_r': 209 case 'open_3_r': 210 case 'open_4_r': 211 case 'open_5_r': 212 setTimeout(function(){ 213 $object.$cont.addClass('rwd-visible'); 214 $('.rwd-container').addClass($object.settings.openCloseType[0]); 215 }, 500); 216 break; 217 default: 218 $('.rwd-container').addClass($object.settings.openCloseType[0]); 219 setTimeout(function () { 220 $object.$cont.addClass('rwd-visible'); 221 }, this.settings.overlayDuration); 222 break; 223 } 224 225 226 227 this.$body.append(template); 228 this.$cont = $('.rwd-cont'); 229 this.$item = this.$cont.find('.rwd-item'); 230 this.$cont.addClass('rwd-use'); 231 232 $object.calculateDimensions(index); 233 234 this.$item.eq(this.index).addClass('rwd-current'); 235 236 if (this.effectsSupport()) { 237 this.$cont.addClass('rwd-support'); 238 } else { 239 this.$cont.addClass('rwd-noSupport'); 240 this.settings.speed = 0; 241 } 242 243 this.$cont.addClass('slider_' + this.settings.slideAnimationType); 244 245 this.$cont.addClass('rwd-show-after-load'); 246 247 if (this.effectsSupport()) { 248 var $inner = this.$cont.find('.cont-inner'); 249 $inner.css('transition-timing-function', 'ease'); 250 $inner.css('transition-duration', this.settings.speed + 'ms'); 251 } 252 253 $object.objects.overlay.addClass('in'); 254 255 this.prevScrollTop = $(window).scrollTop(); 256 257 $object.objects.content = $('.rwd-container'); 258 259 if(jQuery(window).width() < 768){ 260 $object.objects.content.css({ 261 'width': '90%', 262 'height': '90%' 263 }); 264 } else { 265 $object.objects.content.css({ 266 'width': $object.settings.width, 267 'height': $object.settings.height 268 }); 269 } 270 271 jQuery(window).on('resize', function(){ 272 if(jQuery(window).width() < 768){ 273 $object.objects.content.css({ 274 'width': '90%', 275 'height': '90%' 276 }); 277 } else { 278 $object.objects.content.css({ 279 'width': $object.settings.width, 280 'height': $object.settings.height 281 }); 282 } 283 }); 284 }; 285 286 Lightbox.prototype.calculateDimensions = function (index) { 287 var $object = this, $width, $container; 288 289 $width = $('.rwd-current').height() * 16 / 9; 290 291 if ($width > $object.settings.videoMaxWidth) { 292 $width = $object.settings.videoMaxWidth; 293 } 294 295 $('.rwd-video-cont ').css({ 296 'max-width': $width + 'px' 297 }); 298 299 $container = $('.rwd-container'); 300 301 var $left, $top, $prev, $next; 302 303 switch(this.settings.arrows){ 304 case 'arrows_1': 305 case 'arrows_2': 306 case 'arrows_3': 307 $left = ($container.width() + $object.$item.eq(index).find('.rwd-object').width()) / 2 - 9; 308 $top = ($container.height() - $object.$item.eq(index).find('.rwd-object').height()) / 2 - 16; 309 $prev = ($container.width() - $object.$item.eq(index).find('.rwd-object').width()) / 2; 310 $next = ($container.width() + $object.$item.eq(index).find('.rwd-object').width()) / 2 - 46; 311 break; 312 case 'arrows_4': 313 $left = ($container.width() + $object.$item.eq(index).find('.rwd-object').width()) / 2 - 20; 314 $top = ($container.height() - $object.$item.eq(index).find('.rwd-object').height()) / 2 - 10.5; 315 $prev = ($container.width() - $object.$item.eq(index).find('.rwd-object').width()) / 2 - 30; 316 $next = ($container.width() + $object.$item.eq(index).find('.rwd-object').width()) / 2 - 16; 317 break; 318 case 'arrows_5': 319 $left = ($container.width() + $object.$item.eq(index).find('.rwd-object').width()) / 2 - 5; 320 $top = ($container.height() - $object.$item.eq(index).find('.rwd-object').height()) / 2 - 23.5; 321 $prev = ($container.width() - $object.$item.eq(index).find('.rwd-object').width()) / 2 - 28; 322 $next = ($container.width() + $object.$item.eq(index).find('.rwd-object').width()) / 2 - 20; 323 break; 324 case 'arrows_6': 325 $left = ($container.width() + $object.$item.eq(index).find('.rwd-object').width()) / 2 - 24; 326 $top = ($container.height() - $object.$item.eq(index).find('.rwd-object').height()) / 2 - 11.5; 327 $prev = ($container.width() - $object.$item.eq(index).find('.rwd-object').width()) / 2 - 30; 328 $next = ($container.width() + $object.$item.eq(index).find('.rwd-object').width()) / 2 - 17; 329 break; 330 } 331 332 $('.rwd-toolbar').css({ 333 'top': $top 334 }); 335 336 $('.rwd-close').css({ 337 'position': 'absolute', 338 'left': $left 339 }); 340 341 $('.rwd-prev').css({ 342 'top': '50%', 343 'transform': 'translateY(-15px)', 344 'left': $prev 345 }); 346 347 $('.rwd-next').css({ 348 'top': '50%', 349 'transform': 'translateY(-15px)', 350 'left': $next 351 }); 352 353 $object.$element.on('onBeforeSlide.rwd-container', function (event, prevIndex, index) { 354 $('.rwd-close, .rwd-prev, .rwd-next').css({ 355 'visibility': 'hidden', 356 'opacity': '0', 357 'transition': 'visibility 0s, opacity 0.5s linear' 358 }); 359 }); 360 361 $object.$element.on('onAfterSlide.rwd-container', function (event, prevIndex) { 362 setTimeout(function(){ 363 $('.rwd-close, .rwd-prev, .rwd-next').css({ 364 'visibility': 'visible', 365 'opacity': '1' 366 }); 367 }, 700); 368 }); 369 370 }; 371 372 Lightbox.prototype.effectsSupport = function () { 373 var transition, root, support; 374 support = function () { 375 transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition']; 376 root = document.documentElement; 377 for (var i = 0; i < transition.length; i++) { 378 if (transition[i] in root.style) { 379 return transition[i] in root.style; 380 } 381 } 382 }; 383 384 return support(); 385 }; 386 387 Lightbox.prototype.isVideo = function (src, index) { 388 var youtube, vimeo; 389 390 if(src !== undefined){ 391 if(src.indexOf('youtu') !== -1){ 392 youtube = src.match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/); 393 } 394 395 if(src.indexOf('vimeo') !== -1){ 396 vimeo = src.match(/(videos|video|channels|\.com)\/([\d]+)/); 397 } 398 } 399 400 if (youtube) { 401 return { 402 youtube: youtube 403 }; 404 } else if (vimeo) { 405 return { 406 vimeo: vimeo 407 }; 408 } 409 }; 410 411 Lightbox.prototype.preload = function (index) { 412 for (var i = 1; i <= this.settings.preload; i++) { 413 if (i >= this.$items.length - index) { 414 break; 415 } 416 417 this.loadContent(index + i, false, 0); 418 } 419 420 for (var j = 1; j <= this.settings.preload; j++) { 421 if (index - j < 0) { 422 break; 423 } 424 425 this.loadContent(index - j, false, 0); 426 } 427 }; 428 429 Lightbox.prototype.loadContent = function (index, rec, delay) { 430 431 var $object, src, isVideo; 432 433 $object = this; 434 435 function isImg() { 436 src = $object.$items.eq(index).attr('href'); 437 return src.match(/\.(jpg|png|gif)\b/); 438 } 439 440 src = $object.$items.eq(index).attr('href'); 441 442 isVideo = $object.isVideo(src, index); 443 if (!$object.$item.eq(index).hasClass('rwd-loaded')) { 444 if (isVideo) { 445 $object.$item.eq(index).prepend('<div class="rwd-video-cont "><div class="rwd-video"></div></div>'); 446 $object.$element.trigger('hasVideo.rwd-container', [index, src]); 447 } else { 448 $object.$item.eq(index).prepend('<div class="rwd-img-wrap"><img class="rwd-object rwd-image" src="' + src + '" /></div>'); 449 } 450 451 $object.$element.trigger('onAferAppendSlide.rwd-container', [index]); 452 453 $object.$item.eq(index).addClass('rwd-loaded'); 454 } 455 456 $object.$item.eq(index).find('.rwd-object').on('load.rwd-container error.rwd-container', function () { 457 458 var speed = 0; 459 if (delay) { 460 speed = delay; 461 } 462 463 setTimeout(function () { 464 $object.$item.eq(index).addClass('rwd-complete'); 465 }, speed); 466 467 }); 468 469 if (rec === true) { 470 471 if (!$object.$item.eq(index).hasClass('rwd-complete')) { 472 $object.$item.eq(index).find('.rwd-object').on('load.rwd-container error.rwd-container', function () { 473 $object.preload(index); 474 }); 475 } else { 476 $object.preload(index); 477 } 478 } 479 }; 480 481 Lightbox.prototype.slide = function (index, fromSlide, fromThumb) { 482 var $object, prevIndex; 483 484 $object = this; 485 prevIndex = this.$cont.find('.rwd-current').index(); 486 487 var length = this.$item.length, 488 next = false, 489 prev = false; 490 491 this.$element.trigger('onBeforeSlide.rwd-container', [prevIndex, index, fromSlide, fromThumb]); 492 493 $object.$cont.addClass('rwd-no-trans'); 494 495 this.$item.removeClass('rwd-prev-slide rwd-next-slide'); 496 if (!fromSlide) { 497 498 if (index < prevIndex) { 499 prev = true; 500 if ((index === 0) && (prevIndex === length - 1) && !fromThumb) { 501 prev = false; 502 next = true; 503 } 504 } else if (index > prevIndex) { 505 next = true; 506 if ((index === length - 1) && (prevIndex === 0) && !fromThumb) { 507 prev = true; 508 next = false; 509 } 510 } 511 512 if (prev) { 513 this.$item.eq(index).addClass('rwd-prev-slide'); 514 this.$item.eq(prevIndex).addClass('rwd-next-slide'); 515 } else if (next) { 516 this.$item.eq(index).addClass('rwd-next-slide'); 517 this.$item.eq(prevIndex).addClass('rwd-prev-slide'); 518 } 519 520 setTimeout(function () { 521 $object.$item.removeClass('rwd-current'); 522 523 $object.$item.eq(index).addClass('rwd-current'); 524 525 $object.$cont.removeClass('rwd-no-trans'); 526 }, 50); 527 } else { 528 529 var slidePrev = index - 1; 530 var slideNext = index + 1; 531 532 if ((index === 0) && (prevIndex === length - 1)) { 533 534 slideNext = 0; 535 slidePrev = length - 1; 536 } else if ((index === length - 1) && (prevIndex === 0)) { 537 538 slideNext = 0; 539 slidePrev = length - 1; 540 } 541 542 this.$item.removeClass('rwd-prev-slide rwd-current rwd-next-slide'); 543 $object.$item.eq(slidePrev).addClass('rwd-prev-slide'); 544 $object.$item.eq(slideNext).addClass('rwd-next-slide'); 545 $object.$item.eq(index).addClass('rwd-current'); 546 } 547 548 $object.loadContent(index, true, $object.settings.overlayDuration); 549 550 $object.$element.trigger('onAfterSlide.rwd-container', [prevIndex, index, fromSlide, fromThumb]); 551 552 $object.calculateDimensions(index); 553 554 $(window).on('resize.rwd-container', function () { 555 $object.calculateDimensions(index); 556 }); 557 }; 558 559 Lightbox.prototype.goToNextSlide = function (fromSlide) { 560 var $object = this; 561 if (($object.index + 1) < $object.$item.length) { 562 $object.index++; 563 $object.slide($object.index, fromSlide, false); 564 } else { 565 $object.index = 0; 566 $object.slide($object.index, fromSlide, false); 567 } 568 }; 569 570 Lightbox.prototype.goToPrevSlide = function (fromSlide) { 571 var $object = this; 572 573 if ($object.index > 0) { 574 $object.index--; 575 $object.slide($object.index, fromSlide, false); 576 } else { 577 $object.index = $object.$items.length - 1; 578 $object.slide($object.index, fromSlide, false); 579 } 580 }; 581 582 Lightbox.prototype.addKeyEvents = function () { 583 var $object = this; 584 585 if (this.$items.length > 1) { 586 $(window).on('keyup.rwd-container', function (e) { 587 if ($object.$items.length > 1) { 588 if (e.keyCode === 37) { 589 e.preventDefault(); 590 $object.goToPrevSlide(); 591 } 592 593 if (e.keyCode === 39) { 594 e.preventDefault(); 595 $object.goToNextSlide(); 596 } 597 } 598 }); 599 } 600 601 $(window).on('keydown.rwd-container', function (e) { 602 if (e.keyCode === 27) { 603 e.preventDefault(); 604 $object.destroy(); 605 } 606 }); 607 }; 608 609 Lightbox.prototype.arrow = function () { 610 var $object = this; 611 this.$cont.find('.rwd-prev').on('click.rwd-container', function () { 612 $object.goToPrevSlide(); 613 }); 614 615 this.$cont.find('.rwd-next').on('click.rwd-container', function () { 616 $object.goToNextSlide(); 617 }); 618 }; 619 620 Lightbox.prototype.closeGallery = function () { 621 var $object = this, mousedown = false; 622 623 this.$cont.find('.rwd-close').on('click.rwd-container', function () { 624 $object.destroy(); 625 }); 626 627 $object.$cont.on('mousedown.rwd-container', function (e) { 628 629 mousedown = ($(e.target).is('.rwd-cont') || $(e.target).is('.rwd-item ') || $(e.target).is('.rwd-img-wrap')); 630 631 }); 632 633 $object.$cont.on('mouseup.rwd-container', function (e) { 634 635 if ($(e.target).is('.contInner') || $(e.target).is('.rwd-cont') || $(e.target).is('.rwd-item ') || $(e.target).is('.rwd-img-wrap') && mousedown) { 636 if (!$object.$cont.hasClass('rwd-dragEvent')) { 637 $object.destroy(); 638 } 639 } 640 641 }); 642 }; 643 644 Lightbo
644x.prototype.destroy = function (d) { 645 646 var $object = this, $time; 647 648 $('.rwd-container').removeClass(this.settings.openCloseType[0]).addClass(this.settings.openCloseType[1]); 649 650 switch(this.settings.openCloseType[1]){ 651 case 'close_1': 652 case 'close_1_r': 653 $time = 1000; 654 break; 655 case 'close_2': 656 case 'close_2_r': 657 $time = 300; 658 break; 659 case 'close_3': 660 case 'close_4': 661 case 'close_3_r': 662 case 'close_4_r': 663 $time = 340; 664 break; 665 case 'close_5': 666 case 'close_5_r': 667 $time = 250; 668 break; 669 } 670 671 setTimeout(function(){ 672 clearInterval($object.interval); 673 674 $object.$body.removeClass('rwd-on'); 675 676 $(window).scrollTop($object.prevScrollTop); 677 678 if (d) { 679 $.removeData($object.el, 'lightbox'); 680 } 681 682 ($object.settings.socialSharing && (window.location.hash = '')); 683 684 if ($object.$cont) { 685 $object.$cont.removeClass('rwd-visible'); 686 } 687 688 $object.objects.overlay.removeClass('in'); 689 690 setTimeout(function () { 691 if ($object.$cont) { 692 $object.$cont.remove(); 693 } 694 695 $object.objects.overlay.remove(); 696 697 }, $object.settings.overlayDuration + 50); 698 699 window.scrollTo(0, $object.$_y_); 700 }, $time); 701 }; 702 703 $.fn.lightbox = function (options) { 704 return this.each(function () { 705 if (!$.data(this, 'lightbox')) { 706 $.data(this, 'lightbox', new Lightbox(this, options)); 707 } 708 }); 709 }; 710 711 $.fn.lightbox.lightboxModul = {}; 712 713 714 var Modul = function (element) { 715 716 this.dataL = $(element).data('lightbox'); 717 this.$element = $(element); 718 this.init(); 719 720 this.$el = $(element); 721 722 return this; 723 }; 724 725 Modul.prototype.init = function () { 726 var $object = this; 727 728 $object.dataL.$element.one('hasVideo.rwd-container', function (event, index, src) { 729 $object.dataL.$item.eq(index).find('.rwd-video').append($object.loadVideo(src, 'rwd-object', index)); 730 }); 731 732 $object.dataL.$element.on('onAferAppendSlide.rwd-container', function (event, index) { 733 $object.dataL.$item.eq(index).find('.rwd-video-cont').css({ 734 'max-width': '790px' 735 }); 736 }); 737 738 $object.dataL.$element.on('onBeforeSlide.rwd-container', function (event, prevIndex, index) { 739 740 var $videoSlide = $object.dataL.$item.eq(prevIndex), 741 youtubePlayer = $videoSlide.find('.rwd-youtube').get(0), 742 vimeoPlayer = $videoSlide.find('.rwd-vimeo').get(0); 743 744 if (youtubePlayer) { 745 youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); 746 } else if (vimeoPlayer) { 747 try { 748 $f(vimeoPlayer).api('pause'); 749 } catch (e) { 750 console.error('Make sure you have included froogaloop2 js'); 751 } 752 } 753 754 var src; 755 src = $object.dataL.$items.eq(index).attr('href'); 756 757 var isVideo = $object.dataL.isVideo(src, index) || {}; 758 }); 759 760 $object.dataL.$element.on('onAfterSlide.rwd-container', function (event, prevIndex) { 761 $object.dataL.$item.eq(prevIndex).removeClass('rwd-video-playing'); 762 }); 763 }; 764 765 Modul.prototype.loadVideo = function (src, addClass, index) { 766 var video = '', 767 autoplay = 0, 768 a = '', 769 isVideo = this.dataL.isVideo(src, index) || {}; 770 771 if (isVideo.youtube) { 772 773 a = '?wmode=opaque&autoplay=' + autoplay + '&enablejsapi=1'; 774 775 video = '<iframe class="rwd-video-object rwd-youtube ' + addClass + '" width="560" height="315" src="//www.youtube.com/embed/' + isVideo.youtube[7] + a + '" frameborder="0" allowfullscreen></iframe>'; 776 777 } else if (isVideo.vimeo) { 778 779 a = '?autoplay=' + autoplay + '&api=1'; 780 781 video = '<iframe class="rwd-video-object rwd-vimeo ' + addClass + '" width="560" height="315" src="//player.vimeo.com/video/' + isVideo.vimeo[2] + a + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; 782 783 } 784 785 return video; 786 }; 787 788 $.fn.lightbox.lightboxModul.modul = Modul; 789 790})(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.