1
0
Fork 0
This repository has been archived on 2024-12-30. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
pelican-alchemy/alchemy/static/js/jquery.fluidbox.min.js

1 line
6.2 KiB
JavaScript
Raw Normal View History

function whichTransitionEvent(){var a,b=document.createElement("fakeelement"),c={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(a in c)if(void 0!==b.style[a])return c[a]}!function(a,b){var c=function(a,b,c){var d;return function(){function g(){c||a.apply(e,f),d=null}var e=this,f=arguments;d?clearTimeout(d):c&&a.apply(e,f),d=setTimeout(g,b||100)}};jQuery.fn[b]=function(a){return a?this.bind("resize",c(a)):this.trigger(b)}}(jQuery,"smartresize");var customTransitionEnd=whichTransitionEvent();!function(a){var b=0;a.fn.fluidbox=function(c){var d=a.extend(!0,{viewportFill:.95,debounceResize:!0,stackIndex:1e3,stackIndexDelta:10,closeTrigger:[{selector:".fluidbox-overlay",event:"click"},{selector:"document",event:"keyup",keyCode:27}],immediateOpen:!1},c),e=["keyup","keydown","keypress"];d.stackIndex<d.stackIndexDelta&&(d.stackIndexDelta=d.stackIndex),$fbOverlay=a("<div />",{"class":"fluidbox-overlay",css:{"z-index":d.stackIndex}});var h,f=this,g=a(window),i=function(b){a(b+".fluidbox-opened").trigger("click")},j=function(b,c){var e=b.find("img"),f=b.find(".fluidbox-ghost"),i=b.find(".fluidbox-wrap"),j=b.data(),k=0,l=0;e.data().imgRatio=j.natWidth/j.natHeight;var m,n,o;h>e.data().imgRatio?(k=j.natHeight<g.height()*d.viewportFill?j.natHeight:g.height()*d.viewportFill,j.imgScale=k/e.height(),j.imgScaleY=j.imgScale,m=e.height()*j.imgScaleY,n=m/j.natHeight,o=j.natWidth*n/e.width(),j.imgScaleX=o):(l=j.natWidth<g.width()*d.viewportFill?j.natWidth:g.width()*d.viewportFill,j.imgScale=l/e.width(),j.imgScaleX=j.imgScale,newWidth=e.width()*j.imgScaleX,n=newWidth/j.natWidth,o=j.natHeight*n/e.height(),j.imgScaleY=o);var p=g.scrollTop()-e.offset().top+.5*e.data("imgHeight")*(e.data("imgScale")-1)+.5*(g.height()-e.data("imgHeight")*e.data("imgScale")),q=.5*e.data("imgWidth")*(e.data("imgScale")-1)+.5*(g.width()-e.data("imgWidth")*e.data("imgScale"))-e.offset().left,r=parseInt(1e3*j.imgScaleX)/1e3+","+parseInt(1e3*j.imgScaleY)/1e3;f.css({transform:"translate("+parseInt(10*q)/10+"px,"+parseInt(10*p)/10+"px) scale("+r+")",top:e.offset().top-i.offset().top,left:e.offset().left-i.offset().left}).one(customTransitionEnd,function(){a.each(c,function(a,c){b.trigger(c)})})},k=function(a){function i(){f.imgWidth=b.width(),f.imgHeight=b.height(),f.imgRatio=b.width()/b.height(),c.css({width:b.width(),height:b.height(),top:b.offset().top-e.offset().top+parseInt(b.css("borderTopWidth"))+parseInt(b.css("paddingTop")),left:b.offset().left-e.offset().left+parseInt(b.css("borderLeftWidth"))+parseInt(b.css("paddingLeft"))}),f.imgScale=h>f.imgRatio?g.height()*d.viewportFill/b.height():g.width()*d.viewportFill/b.width()}if(h=g.width()/g.height(),a.hasClass("fluidbox")){var b=a.find("img"),c=a.find(".fluidbox-ghost"),e=a.find(".fluidbox-wrap"),f=b.data();i(),b.load(i)}},l=function(b){if(a(this).hasClass("fluidbox")){var c=a(this),e=a(this).find("img"),f=a(this).find(".fluidbox-ghost"),g=a(this).find(".fluidbox-wrap"),h={},i=function(){c.trigger("openstart"),c.append($fbOverlay).data("fluidbox-state",1).removeClass("fluidbox-closed").addClass("fluidbox-opened"),h.close&&window.clearTimeout(h.close),h.open=window.setTimeout(function(){a(".fluidbox-overlay").css({opacity:1})},10),a(".fluidbox-wrap").css({zIndex:d.stackIndex-d.stackIndexDelta-1}),g.css({"z-index":d.stackIndex+d.stackIndexDelta})},k=function(){c.trigger("closestart"),c.data("fluidbox-state",0).removeClass("fluidbox-opened fluidbox-loaded fluidbox-loading").addClass("fluidbox-closed"),h.open&&window.clearTimeout(h.open),h.close=window.setTimeout(function(){a(".fluidbox-overlay").remove(),g.css({"z-index":d.stackIndex-d.stackIndexDelta})},10),a(".fluidbox-overlay").css({opacity:0}),f.css({transform:"translate(0,0) scale(1)",opacity:0,top:e.offset().top-g.offset().top+parseInt(e.css("borderTopWidth"))+parseInt(e.css("paddingTop")),left:e.offset().left-g.offset().left+parseInt(e.css("borderLeftWidth"))+parseInt(e.css("paddingLeft"))}).one(customTransitionEnd,function(){c.trigger("closeend")}),e.css({opacity:1})};0!==a(this).