/* * nivo lightbox v1.0 * http://dev7studios.com/nivo-lightbox * * copyright 2013, dev7studios * free to use and abuse under the mit license. * http://www.opensource.org/licenses/mit-license.php */ (function(e,t,n,r){function o(t,n){this.el=t;this.$el=e(this.el);this.options=e.extend({},s,n);this._defaults=s;this._name=i;this.init()}var i="nivolightbox",s={effect:"fade",theme:"default",keyboardnav:true,oninit:function(){},beforeshowlightbox:function(){},aftershowlightbox:function(e){},beforehidelightbox:function(){},afterhidelightbox:function(){},onprev:function(e){},onnext:function(e){},errormessage:"the requested content cannot be loaded. please try again later."};o.prototype={init:function(){var t=this;this.$el.on("click",function(e){e.preventdefault();t.showlightbox()});if(this.options.keyboardnav){e("body").off("keyup").on("keyup",function(n){var r=n.keycode?n.keycode:n.which;if(r==27)t.destructlightbox();if(r==37)e(".nivo-lightbox-prev").trigger("click");if(r==39)e(".nivo-lightbox-next").trigger("click")})}this.options.oninit.call(this)},showlightbox:function(){var t=this;this.options.beforeshowlightbox.call(this);var n=this.constructlightbox();if(!n)return;var r=n.find(".nivo-lightbox-content");if(!r)return;var i=this.$el;e("body").addclass("nivo-lightbox-body-effect-"+this.options.effect);this.processcontent(r,i);if(this.$el.attr("data-lightbox-gallery")){var t=this,s=e('[data-lightbox-gallery="'+this.$el.attr("data-lightbox-gallery")+'"]');e(".nivo-lightbox-nav").show();e(".nivo-lightbox-prev").off("click").on("click",function(n){n.preventdefault();var o=s.index(i);i=s.eq(o-1);if(!e(i).length)i=s.last();t.processcontent(r,i);t.options.onprev.call(this,[i])});e(".nivo-lightbox-next").off("click").on("click",function(n){n.preventdefault();var o=s.index(i);i=s.eq(o+1);if(!e(i).length)i=s.first();t.processcontent(r,i);t.options.onnext.call(this,[i])})}settimeout(function(){n.addclass("nivo-lightbox-open");t.options.aftershowlightbox.call(this,[n])},1)},processcontent:function(n,r){var i=this;var s=r.attr("href");n.html("").addclass("nivo-lightbox-loading");if(this.ishidpi()&&r.attr("data-lightbox-hidpi")){s=r.attr("data-lightbox-hidpi")}if(s.match(/\.(jpeg|jpg|gif|png)$/)!=null){var o=e("",{src:s});o.one("load",function(){var r=e('
');r.append(o);n.html(r).removeclass("nivo-lightbox-loading");r.css({"line-height":e(".nivo-lightbox-content").height()+"px",height:e(".nivo-lightbox-content").height()+"px"});e(t).resize(function(){r.css({"line-height":e(".nivo-lightbox-content").height()+"px",height:e(".nivo-lightbox-content").height()+"px"})})}).each(function(){if(this.complete)e(this).load()});o.error(function(){var t=e(''+i.options.errormessage+"