!function(){var moduleFactory=function($){var module=this,jQuery=$,exports=function(){!function(window,$){"use strict";var resizeTimeout,$event=$.event;$event.special.smartresize={setup:function(){$(this).bind("resize",$event.special.smartresize.handler)},teardown:function(){$(this).unbind("resize",$event.special.smartresize.handler)},handler:function(event,execAsap){var context=this,args=arguments;event.type="smartresize",resizeTimeout&&clearTimeout(resizeTimeout),resizeTimeout=setTimeout(function(){jQuery.event.handle.apply(context,args)
},"execAsap"===execAsap?0:100)}},$.fn.smartresize=function(fn){return fn?this.bind("smartresize",fn):this.trigger("smartresize",["execAsap"])},$.Mason=function(options,element){this.element=$(element),this._create(options),this._init()},$.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1,containerStyle:{position:"relative"}},$.Mason.prototype={_filterFindBricks:function($elems){var selector=this.options.itemSelector;return selector?$elems.filter(selector).add($elems.find(selector)):$elems
},_getBricks:function($elems){var $bricks=this._filterFindBricks($elems).css({position:"absolute"}).addClass("masonry-brick");return $bricks},_create:function(options){this.options=$.extend(!0,{},$.Mason.settings,options),this.styleQueue=[];var elemStyle=this.element[0].style;this.originalStyle={height:elemStyle.height||""};var containerStyle=this.options.containerStyle;for(var prop in containerStyle)this.originalStyle[prop]=elemStyle[prop]||"";this.element.css(containerStyle),this.horizontalDirection=this.options.isRTL?"right":"left",this.offset={x:parseInt(this.element.css("padding-"+this.horizontalDirection),10),y:parseInt(this.element.css("padding-top"),10)},this.isFluid=this.options.columnWidth&&"function"==typeof this.options.columnWidth;
var instance=this;setTimeout(function(){instance.element.addClass("masonry")},0),this.options.isResizable&&$(window).bind("smartresize.masonry",function(){instance.resize()}),this.reloadItems()},_init:function(callback){this._getColumns(),this._reLayout(callback)},option:function(key){$.isPlainObject(key)&&(this.options=$.extend(!0,this.options,key))},layout:function($bricks,callback){for(var i=0,len=$bricks.length;len>i;i++)this._placeBrick($bricks[i]);var containerSize={};if(containerSize.height=Math.max.apply(Math,this.colYs),this.options.isFitWidth){var unusedCols=0;
for(i=this.cols;--i&&0===this.colYs[i];)unusedCols++;containerSize.width=(this.cols-unusedCols)*this.columnWidth-this.options.gutterWidth}this.styleQueue.push({$el:this.element,style:containerSize});var obj,styleFn=this.isLaidOut?this.options.isAnimated?"animate":"css":"css",animOpts=this.options.animationOptions;for(i=0,len=this.styleQueue.length;len>i;i++)obj=this.styleQueue[i],obj.$el[styleFn](obj.style,animOpts);this.styleQueue=[],callback&&callback.call($bricks),this.isLaidOut=!0},_getColumns:function(){var container=this.options.isFitWidth?this.element.parent():this.element,containerWidth=container.width();
this.columnWidth=this.isFluid?this.options.columnWidth(containerWidth):this.options.columnWidth||this.$bricks.outerWidth(!0)||containerWidth,this.columnWidth+=this.options.gutterWidth,this.cols=Math.floor((containerWidth+this.options.gutterWidth)/this.columnWidth),this.cols=Math.max(this.cols,1)},_placeBrick:function(brick){var colSpan,groupCount,groupY,groupColY,j,$brick=$(brick);if(colSpan=Math.ceil($brick.outerWidth(!0)/(this.columnWidth+this.options.gutterWidth)),colSpan=Math.min(colSpan,this.cols),1===colSpan)groupY=this.colYs;
else for(groupCount=this.cols+1-colSpan,groupY=[],j=0;groupCount>j;j++)groupColY=this.colYs.slice(j,j+colSpan),groupY[j]=Math.max.apply(Math,groupColY);for(var minimumY=Math.min.apply(Math,groupY),shortCol=0,i=0,len=groupY.length;len>i;i++)if(groupY[i]===minimumY){shortCol=i;break}var position={top:minimumY+this.offset.y};position[this.horizontalDirection]=this.columnWidth*shortCol+this.offset.x,this.styleQueue.push({$el:$brick,style:position});var setHeight=minimumY+$brick.outerHeight(!0),setSpan=this.cols+1-len;
for(i=0;setSpan>i;i++)this.colYs[shortCol+i]=setHeight},resize:function(){var prevColCount=this.cols;this._getColumns(),(this.isFluid||this.cols!==prevColCount)&&this._reLayout()},_reLayout:function(callback){var i=this.cols;for(this.colYs=[];i--;)this.colYs.push(0);this.layout(this.$bricks,callback)},reloadItems:function(){this.$bricks=this._getBricks(this.element.children())},reload:function(callback){this.reloadItems(),this._init(callback)},appended:function($content,isAnimatedFromBottom,callback){if(isAnimatedFromBottom){this._filterFindBricks($content).css({top:this.element.height()});
var instance=this;setTimeout(function(){instance._appended($content,callback)},1)}else this._appended($content,callback)},_appended:function($content,callback){var $newBricks=this._getBricks($content);this.$bricks=this.$bricks.add($newBricks),this.layout($newBricks,callback)},remove:function($content){this.$bricks=this.$bricks.not($content),$content.remove()},destroy:function(){this.$bricks.removeClass("masonry-brick").each(function(){this.style.position="",this.style.top="",this.style.left=""});var elemStyle=this.element[0].style;
for(var prop in this.originalStyle)elemStyle[prop]=this.originalStyle[prop];this.element.unbind(".masonry").removeClass("masonry").removeData("masonry"),$(window).unbind(".masonry")}},$.fn.imagesLoaded=function(callback){function triggerCallback(){callback.call($this,$images)}function imgLoaded(event){var img=event.target;img.src!==blank&&-1===$.inArray(img,loaded)&&(loaded.push(img),--len<=0&&(setTimeout(triggerCallback),$images.unbind(".imagesLoaded",imgLoaded)))}var $this=this,$images=$this.find("img").add($this.filter("img")),len=$images.length,blank="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",loaded=[];
return len||triggerCallback(),$images.bind("load.imagesLoaded error.imagesLoaded",imgLoaded).each(function(){var src=this.src;this.src=blank,this.src=src}),$this};var logError=function(message){window.console&&window.console.error(message)};$.fn.masonry=function(options){if("string"==typeof options){var args=Array.prototype.slice.call(arguments,1);this.each(function(){var instance=$.data(this,"masonry");return instance?$.isFunction(instance[options])&&"_"!==options.charAt(0)?(instance[options].apply(instance,args),void 0):(logError("no such method '"+options+"' for masonry instance"),void 0):(logError("cannot call methods on masonry prior to initialization; attempted to call method '"+options+"'"),void 0)
})}else this.each(function(){var instance=$.data(this,"masonry");instance?(instance.option(options||{}),instance._init()):$.data(this,"masonry",new $.Mason(options,this))});return this}}(window,jQuery)};exports(),module.resolveWith(exports)};dispatch("masonry").containing(moduleFactory).to("Foundry/2.1 Modules")}();