(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 }; 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("
").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); o = f.scrolltop() + f.height() / 10; n = f.scrollleft(); this.$lightbox.css({ top: o + 'px', left: n + '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.$outercontainer.addclass('animating'); c = new image(); c.onload = function() { var m, g, h, i, j, k, l; d.attr('src', e.album[f].link); m = b(c); d.width(c.width); d.height(c.height); if (e.options.fitimagesinviewport) { l = b(window).width(); k = b(window).height(); j = l - e.containerleftpadding - e.containerrightpadding - 20; i = k - e.containertoppadding - e.containerbottompadding - 110; if ((c.width > j) || (c.height > i)) { if ((c.width / j) > (c.height / i)) { h = j; g = parseint(c.height / (c.width / h), 10); d.width(h); d.height(g) } else { g = i; h = parseint(c.width / (c.height / g), 10); d.width(h); d.height(g) } } } return e.sizecontainer(d.width(), d.height()) }; c.src = this.album[f].link; this.currentimageindex = f }; c.prototype.sizeoverlay = function() { return b('#lightboxoverlay').width(b(document).width()).height(b(document).height()) }; c.prototype.sizecontainer = function(f, g) { var b, d, e, h, c = this; h = this.$outercontainer.outerwidth(); e = this.$outercontainer.outerheight(); d = f + this.containerleftpadding + this.containerrightpadding; b = g + this.containertoppadding + this.containerbottompadding; this.$outercontainer.animate({ width: d, height: b }, this.options.resizeduration, 'swing'); settimeout(function() { c.$lightbox.find('.lb-datacontainer').width(d); c.$lightbox.find('.lb-prevlink').height(b); c.$lightbox.find('.lb-nextlink').height(b); c.showimage() }, this.options.resizeduration) }; c.prototype.showimage = function() { this.$lightbox.find('.lb-loader').hide(); this.$lightbox.find('.lb-image').fadein('slow'); this.updatenav(); this.updatedetails(); this.preloadneighboringimages(); this.enablekeyboardnav() }; c.prototype.updatenav = function() { this.$lightbox.find('.lb-nav').show(); if (this.album.length > 1) { if (this.options.wraparound) { this.$lightbox.find('.lb-prev, .lb-next').show() } else { if (this.currentimageindex > 0) { this.$lightbox.find('.lb-prev').show() } if (this.currentimageindex < this.album.length - 1) { this.$lightbox.find('.lb-next').show() } } } }; c.prototype.updatedetails = function() { var b = this; if (typeof this.album[this.currentimageindex].title !== 'undefined' && this.album[this.currentimageindex].title !== "") { this.$lightbox.find('.lb-caption').html(this.album[this.currentimageindex].title).fadein('fast') } if (this.album.length > 1 && this.options.showimagenumberlabel) { this.$lightbox.find('.lb-number').text(this.options.albumlabel(this.currentimageindex + 1, this.album.length)).fadein('fast') } else { this.$lightbox.find('.lb-number').hide() } this.$outercontainer.removeclass('animating'); this.$lightbox.find('.lb-datacontainer').fadein(this.resizeduration, function() { return b.sizeoverlay() }) }; c.prototype.preloadneighboringimages = function() { var c, b; if (this.album.length > this.currentimageindex + 1) { c = new image(); c.src = this.album[this.currentimageindex + 1].link } if (this.currentimageindex > 0) { b = new image(); b.src = this.album[this.currentimageindex - 1].link } }; c.prototype.enablekeyboardnav = function() { b(document).on('keyup.keyboard', b.proxy(this.keyboardaction, this)) }; c.prototype.disablekeyboardnav = function() { b(document).off('.keyboard') }; c.prototype.keyboardaction = function(g) { var d, e, f, c, b; d = 27; e = 37; f = 39; b = g.keycode; c = string.fromcharcode(b).tolowercase(); if (b === d || c.match(/x|o|c/)) { this.end() } else if (c === 'p' || b === e) { if (this.currentimageindex !== 0) { this.changeimage(this.currentimageindex - 1) } } else if (c === 'n' || b === f) { if (this.currentimageindex !== this.album.length - 1) { this.changeimage(this.currentimageindex + 1) } } }; c.prototype.end = function() { this.disablekeyboardnav(); b(window).off("resize", this.sizeoverlay); this.$lightbox.fadeout(this.options.fadeduration); this.$overlay.fadeout(this.options.fadeduration); return b('select, object, embed').css({ visibility: "visible" }) }; return c })(); b(function() { var e, b; b = new c(); return e = new d(b) }) }).call(this);