1/* 2 * Boxer [Formstone Library] 3 * @author Ben Plum 4 * @version 1.8.6 5 * 6 * Copyright © 2013 Ben Plum <[email protected]> 7 * Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 8 */ 9 10if(jQuery)(function(c){function F(a){m.formatter=G;return c(this).on("click.boxer",c.extend({},m,a||{}),v)}function v(b){b.preventDefault();b.stopPropagation();var d=c(this),e=b.data.$object,f=d[0].attributes?d.attr("href")||"":"",h=f.toLowerCase().split("."),h=h[h.length-1],g=d.data("type")||"",k="image"==g||"jpeg"==h||"jpg"==h||"gif"==h||"png"==h||"data:image"==f.substr(0,10),l=-1<f.indexOf("youtube.com/embed")||-1<f.indexOf("player.vimeo.com/video"),p="url"==g||!k&&!l&&"http"==f.substr(0,4),q="element"== g||!k&&!l&&!p&&"#"==f.substr(0,1),n="undefined"!==typeof e;if(1>c("#boxer").length&&(k||l||p||q||n)){a={$target:d,$object:e,visible:!1,resizeTimer:null,touchTimer:null,gallery:{active:!1},options:b.data,isMobile:(H||b.data.mobile)&&!q&&!n};a.type=k?"image":l?"video":"element";if(k||l)b=a.$target.attr("rel"),"undefined"!==typeof b&&!1!==b&&(a.gallery.active=!0,a.gallery.rel=b,a.gallery.$items=c("a[rel= "+a.gallery.rel+"]"),a.gallery.index=a.gallery.$items.index(a.$target),a.gallery.total=a.gallery.$items.length- 1);b="";a.isMobile||(b+='<div id="boxer-overlay" class="'+a.options.customClass+'" style="opacity: 0"></div>');b+='<div id="boxer" class="loading '+a.options.customClass;a.isMobile&&(b+=" mobile");p&&(b+=" iframe");if(q||n)b+=" inline";b+='" style="opacity: 0;';!0===a.options.fixed&&(b+=" position: fixed;");b+='"><span class="boxer-close">Close</span>';b+='<div class="boxer-container" style="';b=a.isMobile?b+"height: 100%; width: 100%":b+("height: "+a.options.height+"px; width: "+a.options.width+ "px");b+='">';b+='<div class="boxer-content" style="opacity: 0;">';if(k||l)b+='<div class="boxer-meta">',a.gallery.active?(b+='<div class="boxer-arrow previous">Previous</div>',b+='<div class="boxer-arrow next">Next</div>',b+='<p class="boxer-position"',1>a.gallery.total&&(b+=' style="display: none;"'),b+=">",b+='<span class="current">'+(a.gallery.index+1)+'</span> of <span class="total">'+(a.gallery.total+1)+"</span>",b+="</p>",b+='<div class="boxer-caption gallery">'):b+='<div class="boxer-caption">', b+=a.options.formatter.apply(c("body"),[a.$target]),b+="</div></div>";b+="</div></div></div>";c("body").append(b);a.$overlay=c("#boxer-overlay");a.$boxer=c("#boxer");a.$container=a.$boxer.find(".boxer-container");a.$content=a.$boxer.find(".boxer-content");a.$meta=a.$boxer.find(".boxer-meta");a.$position=a.$boxer.find(".boxer-position");a.$caption=a.$boxer.find(".boxer-caption");a.$arrows=a.$boxer.find(".boxer-arrow");a.$animatables=c("#boxer-overlay, #boxer, .boxer-container");a.padding=2*parseInt(a.$boxer.css("paddingTop"), 10);I();a.gallery.active&&w();c(window).on("resize.boxer",J).on("keydown.boxer",K);c("body").on("click.boxer","#boxer-overlay, #boxer .boxer-close",x);if(a.gallery.active)a.$boxer.on("click.boxer",".boxer-arrow",L);a.$overlay.stop().animate({opacity:a.options.opacity},a.options.duration);a.$boxer.stop().animate({opacity:1},a.options.duration,function(){if(k)y(f);else if(l)z(f);else if(p){var b=f,b=b+(-1<b.indexOf("?")?"&"+m.requestKey+"=true":"?"+m.requestKey+"=true"),b=c('<iframe class="boxer-iframe" src="'+ b+'" />');r(b)}else q?(b=c(f).find(">:first-child").clone(),r(b)):n?r(a.$object):c.error("BOXER: '"+f+"' is not valid.")})}if(n)return a.$boxer}function s(){if(a.isMobile)var b=0,d=0;else{var b=(c(window).width()-a.contentWidth-a.padding)/2,d=0>=a.options.top?(c(window).height()-a.contentHeight-a.padding)/2:a.options.top,e=a.$arrows.outerHeight();!0!==a.options.fixed&&(d+=c(window).scrollTop());a.$arrows.css({marginTop:(a.contentHeight-a.metaHeight-e)/2})}e=a.isMobile?0:a.options.duration;if(!a.visible&& a.isMobile&&(c("html, body").css({height:"100%",overflow:"hidden",width:"100%"}),"image"==a.type&&a.gallery.active))a.$content.on("touchstart.boxer",".boxer-image",M);a.$boxer.stop().animate({left:b,top:d},e);a.$container.show().stop().animate({height:a.contentHeight,width:a.contentWidth},e,function(b){a.$content.stop().animate({opacity:1},a.options.duration);a.$boxer.removeClass("loading").find(".boxer-close").stop().animate({opacity:1},a.options.duration);a.options.callback.apply(a.$boxer);a.visible= !0})}function x(b){b.preventDefault&&(b.preventDefault(),b.stopPropagation());"undefined"!==typeof a.$animatables&&(a.$animatables.stop().animate({opacity:0}
10,a.options.duration,function(){c(this).remove()}),g(a.resizeTimer),c(window).off(".boxer"),c("body").off(".boxer"),a.gallery.active&&a.$boxer.off(".boxer"),a.isMobile&&(c("html, body").css({height:"",overflow:"",width:""}),"image"==a.type&&a.gallery.active&&a.$container.off(".boxer")),a={})}function J(){t.resize()}function I(){if(a.isMobile)var b= 0,d=0;else b=(c(window).width()-a.$boxer.width()-a.padding)/2,d=0>=a.options.top?(c(window).height()-a.$boxer.height()-a.padding)/2:a.options.top,!0!==a.options.fixed&&(d+=c(window).scrollTop());a.$boxer.css({left:b,top:d})}function y(b){a.$image=c("<img />");a.$image.one("load.boxer",function(){var b;b=a.$image[0];var c=new Image;"undefined"!=typeof b.naturalHeight?b={naturalHeight:b.naturalHeight,naturalWidth:b.naturalWidth}:"img"===b.tagName.toLowerCase()?(c.src=b.src,b={naturalHeight:c.height, naturalWidth:c.width}):b=!1;a.naturalHeight=b.naturalHeight;a.naturalWidth=b.naturalWidth;a.options.retina&&(a.naturalHeight/=2,a.naturalWidth/=2);a.$content.prepend(a.$image);""==a.$caption.html()?a.$caption.hide():a.$caption.show();u(0)&&s()}).attr("src",b).addClass("boxer-image");(a.$image[0].complete||4===a.$image[0].readyState)&&a.$image.trigger("load")}function z(b){a.$videoWrapper=c('<div class="boxer-video-wrapper" />');a.$video=c('<iframe class="boxer-video" />');a.$video.attr("src",b).addClass("boxer-video").prependTo(a.$videoWrapper); a.$content.prepend(a.$videoWrapper);A();s()}function G(a){a=a.attr("title");return""!=a&&void 0!==a?'<p class="caption">'+a+"</p>":""}function u(b){a.windowHeight=a.viewportHeight=0==b?c(window).height():a.windowHeight;a.windowWidth=a.viewportWidth=0==b?c(window).width():a.windowWidth;a.imageHeight=0==b?a.naturalHeight:a.$image.outerHeight();a.imageWidth=0==b?a.naturalWidth:a.$image.outerWidth();a.metaHeight=0==b?0:a.metaHeight;0==b&&(a.ratioHorizontal=a.imageHeight/a.imageWidth,a.ratioVertical=a.imageWidth/ a.imageHeight,a.isWide=a.imageWidth>a.imageHeight);a.imageHeight<a.options.minHeight&&(a.options.minHeight=a.imageHeight);a.imageWidth<a.options.minWidth&&(a.options.minWidth=a.imageWidth);a.isMobile?(a.viewportHeight-=a.padding,a.viewportWidth-=a.padding,a.contentHeight=a.viewportHeight,a.contentWidth=a.viewportWidth,a=B(a),a.imageMarginTop=(a.contentHeight-a.targetImageHeight)/2,a.imageMarginLeft=(a.contentWidth-a.targetImageWidth)/2):(a.viewportHeight-=a.options.margin+a.padding+a.metaHeight,a.viewportWidth-= a.options.margin+a.padding,a=B(a),a.contentHeight=a.targetImageHeight,a.contentWidth=a.targetImageWidth,a.imageMarginTop=0,a.imageMarginLeft=0);a.$content.css({height:a.isMobile?a.contentHeight:"auto",width:a.contentWidth});a.$meta.css({width:a.contentWidth});a.$image.css({height:a.targetImageHeight,width:a.targetImageWidth,marginTop:a.imageMarginTop,marginLeft:a.imageMarginLeft});return!a.isMobile&&(a.metaHeight=a.$meta.outerHeight(!0),a.contentHeight+=a.metaHeight,a.contentHeight>a.viewportHeight&& 2>b)?u(b+1):!0}function B(a){a.isWide?(a.targetImageWidth=a.viewportWidth,a.targetImageHeight=a.targetImageWidth*a.ratioHorizontal,a.targetImageHeight>a.viewportHeight&&(a.targetImageHeight=a.viewportHeight,a.targetImageWidth=a.targetImageHeight*a.ratioVertical)):(a.targetImageHeight=a.viewportHeight,a.targetImageWidth=a.targetImageHeight*a.ratioVertical,a.targetImageWidth>a.viewportWidth&&(a.targetImageWidth=a.viewportWidth,a.targetImageHeight=a.targetImageWidth*a.ratioHorizontal));if(a.targetImageWidth> a.imageWidth||a.targetImageHeight>a.imageHeight)a.targetImageWidth=a.imageWidth,a.targetImageHeight=a.imageHeight;if(a.targetImageWidth<a.options.minWidth||a.targetImageHeight<a.options.minHeight)a.targetImageWidth<a.options.minWidth?(a.targetImageWidth=a.options.minWidth,a.targetImageHeight=a.targetImageWidth*a.ratioHorizontal):(a.targetImageHeight=a.options.minHeight,a.targetImageWidth=a.targetImageHeight*a.ratioVertical);return a}function A(){a.windowHeight=c(window).height()-a.padding;a.windowWidth= c(window).width()-a.padding;a.videoMarginTop=0;a.videoMarginLeft=0;a.isMobile?(a.$meta.css({width:a.windowWidth}),a.metaHeight=a.$meta.outerHeight(!0),a.contentHeight=a.windowHeight,a.contentWidth=a.windowWidth,a.videoWidth=a.windowWidth,a.videoHeight=a.videoWidth*a.options.videoRatio,a.videoHeight>a.windowHeight-a.metaHeight&&(a.videoHeight=a.windowHeight-a.metaHeight,a.videoWidth=a.videoHeight*a.options.videoRatio),a.videoMarginTop=(a.contentHeight-a.videoHeight)/2,a.videoMarginLeft=(a.contentWidth- a.videoWidth)/2):(a.windowHeight-=a.options.margin,a.windowWidth-=a.options.margin,a.videoWidth=a.options.videoWidth>a.windowWidth?a.windowWidth:a.options.videoWidth,a.videoHeight=a.videoWidth*a.options.videoRatio,a.contentHeight=a.videoHeight,a.contentWidth=a.videoWidth);a.$content.css({height:a.isMobile?a.contentHeight:"auto",width:a.contentWidth}
10);a.$meta.css({width:a.contentWidth});a.$videoWrapper.css({height:a.videoHeight,width:a.videoWidth,marginTop:a.videoMarginTop,marginLeft:a.videoMarginLeft}); a.isMobile||(a.metaHeight=a.$meta.outerHeight(!0),a.contentHeight=a.videoHeight+a.metaHeight);a.contentWidth=a.videoWidth}function L(b){b.preventDefault();b.stopPropagation();b=c(this);b.hasClass("disabled")||(a.$boxer.addClass("loading"),a.gallery.index+=b.hasClass("next")?1:-1,a.gallery.index>a.gallery.total&&(a.gallery.index=a.gallery.total),0>a.gallery.index&&(a.gallery.index=0),a.$content.stop().animate({opacity:0},a.options.duration,function(){"undefined"!==typeof a.$image&&a.$image.remove(); "undefined"!==typeof a.$videoWrapper&&a.$videoWrapper.remove();a.$target=a.gallery.$items.eq(a.gallery.index);a.$caption.html(a.options.formatter.apply(c("body"),[a.$target]));a.$position.find(".current").html(a.gallery.index+1);var b=a.$target.attr("href");-1<b.indexOf("youtube.com/embed")||-1<b.indexOf("player.vimeo.com/video")?z(b):y(b);w()}))}function w(){a.$arrows.removeClass("disabled");0==a.gallery.index&&a.$arrows.filter(".previous").addClass("disabled");a.gallery.index==a.gallery.total&& a.$arrows.filter(".next").addClass("disabled")}function K(b){!a.gallery.active||37!=b.keyCode&&39!=b.keyCode?27==b.keyCode&&a.$boxer.find(".boxer-close").trigger("click"):(b.preventDefault(),b.stopPropagation(),a.$arrows.filter(37==b.keyCode?".previous":".next").trigger("click"))}function r(b){a.$content.append(b);C(b);s()}function C(b){a.objectHeight=b.outerHeight(!0);a.objectWidth=b.outerWidth(!0);a.windowHeight=c(window).height()-a.padding;a.windowWidth=c(window).width()-a.padding;a.dataHeight= a.$target.data("height");a.dataWidth=a.$target.data("width");a.maxHeight=0>a.windowHeight?m.minHeight:a.windowHeight;a.isIframe=b.is("iframe");a.objectMarginTop=0;a.objectMarginLeft=0;a.isMobile||(a.windowHeight-=a.options.margin,a.windowWidth-=a.options.margin);a.contentHeight=void 0!=a.dataHeight?a.dataHeight:a.isIframe?a.windowHeight:a.objectHeight;a.contentWidth=void 0!=a.dataWidth?a.dataWidth:a.isIframe?a.windowWidth:a.objectWidth;a.isIframe&&a.isMobile&&(a.contentHeight=a.windowHeight,a.contentWidth= a.windowWidth);a.isIframe||(a.contentHeight>a.maxHeight?(a.contentHeight=a.maxHeight,a.$content.css({overflowY:"scroll"})):a.$content.css({overflowY:"auto"}));a.$content.css({height:a.contentHeight,width:a.contentWidth})}function M(b){b.preventDefault();b.stopPropagation();g(a.touchTimer);if(!a.isAnimating){var d="undefined"!==typeof b.originalEvent.targetTouches?b.originalEvent.targetTouches[0]:null;a.xStart=d?d.pageX:b.clientX;a.leftPosition=0;a.touchMax=Infinity;a.touchMin=-Infinity;a.edge=0.25* a.contentWidth;0==a.gallery.index&&(a.touchMax=0);a.gallery.index==a.gallery.total&&(a.touchMin=0);c(window).on("touchmove.boxer",N).one("touchend.boxer",D)}}function N(b){var c="undefined"!==typeof b.originalEvent.targetTouches?b.originalEvent.targetTouches[0]:null;a.delta=a.xStart-(c?c.pageX:b.clientX);20<a.delta&&(b.preventDefault(),b.stopPropagation());a.canSwipe=!0;c=-a.delta;c<a.touchMin&&(c=a.touchMin,a.canSwipe=!1);c>a.touchMax&&(c=a.touchMax,a.canSwipe=!1);a.$image.css({transform:"translate3D("+ c+"px,0,0)"});a.touchTimer=E(a.touchTimer,300,function(){D(b)})}function D(b){b.preventDefault();b.stopPropagation();g(a.touchTimer);c(window).off("touchmove.boxer").off("touchend.boxer");a.delta&&(a.$boxer.addClass("animated"),a.swipe=!1,a.canSwipe&&(a.delta>a.edge||a.delta<-a.edge)?(a.swipe=!0,a.delta<=a.leftPosition?a.$image.css({transform:"translate3D("+a.contentWidth+"px,0,0)"}):a.$image.css({transform:"translate3D("+-a.contentWidth+"px,0,0)"})):a.$image.css({transform:"translate3D(0,0,0)"}), a.swipe&&a.$arrows.filter(a.delta<=a.leftPosition?".previous":".next").trigger("click"),E(a.resetTimer,a.options.duration,function(){a.$boxer.removeClass("animated")}))}function E(a,c,e){g(a);return setTimeout(e,c)}function g(a){a&&clearTimeout(a)}var m={callback:c.noop,customClass:"",duration:250,fixed:!1,formatter:c.noop,height:100,margin:100,minHeight:100,minWidth:100,mobile:!1,opacity:0.75,retina:!1,requestKey:"boxer",top:0,videoRatio:0.5625,videoWidth:600,width:100},a={},H=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent|| navigator.vendor||window.opera),t={destroy:function(){x();return c(this).off(".boxer")},resize:function(b){if("undefined"!=typeof a.$boxer&&("element"==a.type?C(a.$content.find(">:first-child")):"image"==a.type?u(0):"video"==a.type&&A(),b=!1,a.visible)){if(a.isMobile)var d=0,e=0;else{var d=(c(window).width()-a.contentWidth-a.padding)/2,e=0>=a.options.top?(c(window).height()-a.contentHeight-a.padding)/2:a.options.top,f=a.$arrows.outerHeight();!0!==a.options.fixed&&(e+=c(window).scrollTop());a.$arrows.css({marginTop:(a.contentHeight- a.metaHeight-f)/2})}b?(a.$boxer.stop().animate({left:d,top:e},a.options.duration),a.$container.show().stop().animate({height:a.contentHeight,width:a.contentWidth}
10)):(a.$boxer.css({left:d,top:e}),a.$container.css({height:a.contentHeight,width:a.contentWidth}))}return c(this)}};c.fn.boxer=function(a){return t[a]?t[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!==typeof a&&a?this:F.apply(this,arguments)};c.boxer=function(a,d){return v(c.Event("click",{data:c.extend({$object:a},m,d|| {})}))}})(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.