text: 
  (function(a){a.fn.viewbox=function(e){if(typeof(e)==="undefined"){e={}}e=a.extend({template:'<div class="viewbox-container"><div class="viewbox-body"><div class="viewbox-header"></div><div class="viewbox-content"></div><div class="viewbox-footer"></div></div></div>',loader:'<div class="loader"><div class="spinner"><div class="double-bounce1"></div><div class="double-bounce2"></div></div></div>',setTitle:true,margin:20,resizeDuration:400,openDuration:200,closeDuration:200,closeButton:true,navButtons:true,closeOnSideClick:true,nextOnContentClick:false,useGestures:true},e);var p=a(this),q=a(e.template),o=a(e.loader),f=false,w=false,d,i=[];if(!a("#viewbox-sprite").length){a("body").get(0).insertAdjacentHTML("afterbegin",'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="viewbox-sprite" style="display:none"><symbol id="viewbox-close-icon" viewBox="0 0 50 50"><path d="M37.304 11.282l1.414 1.414-26.022 26.02-1.414-1.413z"/><path d="M12.696 11.282l26.022 26.02-1.414 1.415-26.022-26.02z"/></symbol><symbol id="viewbox-prev-icon" viewBox="0 0 50 50"><path d="M27.3 34.7L17.6 25l9.7-9.7 1.4 1.4-8.3 8.3 8.3 8.3z"/></symbol><symbol id="viewbox-next-icon" viewBox="0 0 50 50"><path d="M22.7 34.7l-1.4-1.4 8.3-8.3-8.3-8.3 1.4-1.4 9.7 9.7z"/></symbol></svg>')}q.bind("viewbox.open",function(x,y){if(Number.isInteger(y)&&p.length){u(p.eq(y>=0&&y<p.length?y:0))}else{if(y&&y.tagName){u(a(y))}else{if(p.length){u(p.eq(0))}}}});q.bind("viewbox.next",function(y){if(p.length<=1){return}var x=h()+1;if(x>=p.length){x=0}u(p.eq(x))});q.bind("viewbox.prev",function(y){if(p.length<=1){return}var x=h()-1;if(x<0){x=p.length-1}u(p.eq(x))});q.bind("viewbox.close",function(x){if(f){q.fadeOut(e.closeDuration,function(){f=false})}});function u(z){if(w){return}m();var y=z.attr("href"),x=e.setTitle&&z.attr("title")?z.attr("title"):"";if(!y){d=z;k(z,x)}else{if(r(y)){d=z;c(y,x)}else{if(s(y)){d=z;k(y,x)}}}}function v(B,x){var C=t("body"),z=t("content"),y,A;if(B){z.width(B)}if(x){z.height(x)}if(!f){f=true;a("body").append(q);q.show();y=C.width();A=C.height();q.hide();q.fadeIn(e.openDuration)}else{y=C.width();A=C.height()}C.css({"margin-left":-y/2,"margin-top":-A/2})}function t(x){return q.find(".viewbox-"+x)}function l(x,y){t(x).html(y)}function h(){var x=-1;if(d){p.each(function(y){if(d.is(this)){x=y;return false}})}return x}function r(x){return x.match(/(png|jpg|jpeg|gif)$/i)}function s(x){return x.match(/^#.+$/i)&&a(x).length}function b(x){return x.get(0).complete}function j(x){if(x){o.appendTo(t("body"))}else{o.detach()}}function n(z){var y=a('<div class="viewbox-button-default viewbox-button-'+z+'"></div>'),x=window.location.pathname+window.location.search+"#viewbox-"+z+"-icon";y.appendTo(q).get(0).insertAdjacentHTML("afterbegin",'<svg><use xlink:href="'+x+'"/></svg>');return y}function k(z,y){var A=a(z),x=a('<div class="viewbox-content-placeholder"></div>');A.before(x);if(f){q.trigger("viewbox.close")}l("content","");l("header",y);t("content").append(A);v("auto","auto");i.push({placeholder:x,content:A})}function m(){var x;while(i.length){x=i.shift();x.placeholder.before(x.content);x.placeholder.detach()}}function c(A,z){var C=a('<img class="viewbox-image" alt="">').attr("src",A);if(!b(C)){j(true)}l("content","");l("header",z);v();var D=t("body"),y=0,B=t("content"),x=window.setInterval(function(){if(!b(C)&&y<1000){y++;return}window.clearInterval(x);j(false);a("body").append(C);var F=D.width()-B.width()+e.margin*2,I=D.height()-B.height()+e.margin*2,G=a(window).width()-F,J=a(window).height()-I,E=C.width(),H=C.height();C.detach();if(E>G){H=H*G/E;E=G}if(H>J){E=E*J/H;H=J}w=true;D.animate({"margin-left":-(E+F)/2+e.margin,"margin-top":-(H+I)/2+e.margin},e.resizeDuration);B.animate({width:E,height:H},e.resizeDuration,function(){B.append(C);w=false})},b(C)?0:200)}function g(z,D){if(typeof(D)!="function"){return}var y,B,x=150,C=100,A=300;z.on("touchstart",function(E){var F=E.originalEvent.changedTouches[0];y={x:F.pageX,y:F.pageY};B=new Date().getTime()});z.on("touchend",function(H){var J=H.originalEvent.changedTouches[0],E="none",F=new Date().getTime()-B,G={x:J.pageX,y:J.pageY},I={x:G.x-y.x,y:G.y-y.y};if(F<=A){if(Math.abs(I.x)>=x&&Math.abs(I.y)<=C){E=I.x<0?"left":"right"}else{if(Math.abs(I.y)>=x&&Math.abs(I.x)<=C){E=I.y<0?"up":"down"}}}D.call(this,E)})}p.filter("a").click(function(){q.trigger("viewbox.open",[this]);return false});t("body").click(function(x){x.stopPropagation();if(e.nextOnContentClick){q.trigger("viewbox.next")}});if(e.closeButton){n("close").click(function(x){x.stopPropagation();q.trigger("viewbox.close")})}if(e.navButtons&&p.length>1){n("next").click(function(x){x.stopPropagation();q.trigger("viewbox.next")});n("prev").click(function(x){x.stopPropagation();q.trigger("viewbox.prev")})}if(e.closeOnSideClick){q.click(function(){q.trigger("viewbox.close")})}if(e.useGestures&&"ontouchstart" in document.documentElement){g(q,function(x){switch(x){case"left":q.trigger("viewbox.next");break;case"right":q.trigger("viewbox.prev");break}})}return q}}(jQuery));