cv-online/js/lightbox-2.6.min.js

1 line
7.9 KiB
JavaScript
Raw Normal View History

2018-05-15 23:18:54 +00:00
(function() { var b, d, c; b = jQuery; c = (function() { function b() { this.fadeDuration = 500; this.fitImagesInViewport = true; this.resizeDuration = 700; this.showImageNumberLabel = true; this.wrapAround = false } b.prototype.albumLabel = function(b, c) { return"Image " + b + " sur " + c }; return b })(); d = (function() { function c(b) { this.options = b; this.album = []; this.currentImageIndex = void 0; this.init() } c.prototype.init = function() { this.enable(); return this.build() }; c.prototype.enable = function() { var c = this; return b('body').on('click', 'a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]', function(d) { c.start(b(d.currentTarget)); return false }) }; c.prototype.build = function() { var c = this; b("<div id='lightboxOverlay' class='lightboxOverlay'></div><div id='lightbox' class='lightbox'><div class='lb-outerContainer'><div class='lb-container'><img class='lb-image' src='' /><div class='lb-nav'><a class='lb-prev' href='' ></a><a class='lb-next' href='' ></a></div><div class='lb-loader'><a class='lb-cancel'></a></div></div></div><div class='lb-dataContainer'><div class='lb-data'><div class='lb-details'><span class='lb-caption'></span><span class='lb-number'></span></div><div class='lb-closeContainer'><a class='lb-close'></a></div></div></div></div>").appendTo(b('body')); this.$lightbox = b('#lightbox'); this.$overlay = b('#lightboxOverlay'); this.$outerContainer = this.$lightbox.find('.lb-outerContainer'); this.$container = this.$lightbox.find('.lb-container'); this.containerTopPadding = parseInt(this.$container.css('padding-top'), 10); this.containerRightPadding = parseInt(this.$container.css('padding-right'), 10); this.containerBottomPadding = parseInt(this.$container.css('padding-bottom'), 10); this.containerLeftPadding = parseInt(this.$container.css('padding-left'), 10); this.$overlay.hide().on('click', function() { c.end(); return false }); this.$lightbox.hide().on('click', function(d) { if (b(d.target).attr('id') === 'lightbox') { c.end() } return false }); this.$outerContainer.on('click', function(d) { if (b(d.target).attr('id') === 'lightbox') { c.end() } return false }); this.$lightbox.find('.lb-prev').on('click', function() { if (c.currentImageIndex === 0) { c.changeImage(c.album.length - 1) } else { c.changeImage(c.currentImageIndex - 1) } return false }); this.$lightbox.find('.lb-next').on('click', function() { if (c.currentImageIndex === c.album.length - 1) { c.changeImage(0) } else { c.changeImage(c.currentImageIndex + 1) } return false }); return this.$lightbox.find('.lb-loader, .lb-close').on('click', function() { c.end(); return false }) }; c.prototype.start = function(c) { var f, e, j, d, g, n, o, k, l, m, p, h, i; b(window).on("resize", this.sizeOverlay); b('select, object, embed').css({visibility: "hidden"}); this.$overlay.width(b(document).width()).height(b(document).height()).fadeIn(this.options.fadeDuration); this.album = []; g = 0; j = c.attr('data-lightbox'); if (j) { h = b(c.prop("tagName") + '[data-lightbox="' + j + '"]'); for (d = k = 0, m = h.length; k < m; d = ++k) { e = h[d]; this.album.push({link: b(e).attr('href'), title: b(e).attr('title')}); if (b(e).attr('href') === c.attr('href')) { g = d } } } else { if (c.attr('rel') === 'lightbox') { this.album.push({link: c.attr('href'), title: c.attr('title')}) } else { i = b(c.prop("tagName") + '[rel="' + c.attr('rel') + '"]'); for (d = l = 0, p = i.length; l < p; d = ++l) { e = i[d]; this.album.push({link: b(e).attr('href'), title: b(e).attr('title')}); if (b(e).attr('href') === c.attr('href')) { g = d } } } } f = b(window); this.$lightbox.css({top: (f.height()/10) + 'px', left: 0 + 'px'}).fadeIn(this.options.fadeDuration); this.changeImage(g) }; c.prototype.changeImage = function(f) { var d, c, e = this; this.disableKeyboardNav(); d = this.$lightbox.find('.lb-image'); this.sizeOverlay(); this.$overlay.fadeIn(this.options.fadeDuration); b('.lb-loader').fadeIn('slow'); this.$lightbox.find('.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption').hide(); this.$o