Advertisement
Guest User

Packery minified

a guest
Aug 8th, 2013
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(e){function c(d){if(d){if("string"===typeof a[d])return d;d=d.charAt(0).toUpperCase()+d.slice(1);for(var g,f=0,c=b.length;f<c;f++)if(g=b[f]+d,"string"===typeof a[g])return g}}var b=["Webkit","Moz","ms","Ms","O"],a=document.documentElement.style;"function"===typeof define&&define.amd?define(function(){return c}):e.getStyleProperty=c})(window);
  2. (function(e,c){function b(a){var d=parseFloat(a);return-1===a.indexOf("%")&&!isNaN(d)&&d}function a(a){var d=a("boxSizing"),c;(function(){if(d){var a=document.createElement("div");a.style.width="200px";a.style.padding="1px 2px 3px 4px";a.style.borderStyle="solid";a.style.borderWidth="1px 2px 3px 4px";a.style[d]="border-box";var f=document.body||document.documentElement;f.appendChild(a);var h=g(a);c=200===b(h.width);f.removeChild(a)}})();return function(a){"string"===typeof a&&(a=document.querySelector(a));
  3. if(a&&"object"===typeof a&&a.nodeType){var h=g(a);if("none"===h.display){var e={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},h=0;for(a=f.length;h<a;h++)e[f[h]]=0;return e}e={};e.width=a.offsetWidth;e.height=a.offsetHeight;a=e.isBorderBox=!(!d||!h[d]||"border-box"!==h[d]);for(var m=0,p=f.length;m<p;m++){var r=f[m],s=parseFloat(h[r]);e[r]=isNaN(s)?0:s}var m=e.paddingLeft+e.paddingRight,p=e.paddingTop+e.paddingBottom,r=e.marginLeft+e.marginRight,s=e.marginTop+e.marginBottom,
  4. w=e.borderLeftWidth+e.borderRightWidth,v=e.borderTopWidth+e.borderBottomWidth;a=a&&c;var n=b(h.width);!1!==n&&(e.width=n+(a?0:m+w));h=b(h.height);!1!==h&&(e.height=h+(a?0:p+v));e.innerWidth=e.width-(m+w);e.innerHeight=e.height-(p+v);e.outerWidth=e.width+r;e.outerHeight=e.height+s;return e}}}var d=document.defaultView,g=d&&d.getComputedStyle?function(a){return d.getComputedStyle(a,null)}:function(a){return a.currentStyle},f="paddingLeft paddingRight paddingTop paddingBottom marginLeft marginRight marginTop marginBottom borderLeftWidth borderRightWidth borderTopWidth borderBottomWidth".split(" ");
  5. "function"===typeof define&&define.amd?define(["get-style-property/get-style-property"],a):e.getSize=a(e.getStyleProperty)})(window);
  6. (function(e,c){function b(a,d){return a[g](d)}function a(a,d){a.parentNode||document.createDocumentFragment().appendChild(a);for(var f=a.parentNode.querySelectorAll(d),g=0,c=f.length;g<c;g++)if(f[g]===a)return!0;return!1}function d(a,d){a.parentNode||document.createDocumentFragment().appendChild(a);return b(a,d)}var g=function(){if(c.matchesSelector)return"matchesSelector";for(var a=["webkit","moz","ms","o"],d=0,f=a.length;d<f;d++){var g=a[d]+"MatchesSelector";if(c[g])return g}}(),f;if(g){var h=document.createElement("div");
  7. f=b(h,"div")?b:d}else f=a;"function"===typeof define&&define.amd?define(function(){return f}):window.matchesSelector=f})(this,Element.prototype);
  8. (function(){function e(){}function c(a,d){for(var g=a.length;g--;)if(a[g].listener===d)return g;return-1}var b=e.prototype;b.getListeners=function(a){var d=this._getEvents(),g,f;if("object"===typeof a)for(f in g={},d)d.hasOwnProperty(f)&&a.test(f)&&(g[f]=d[f]);else g=d[a]||(d[a]=[]);return g};b.flattenListeners=function(a){var d=[],g;for(g=0;g<a.length;g+=1)d.push(a[g].listener);return d};b.getListenersAsObject=function(a){var d=this.getListeners(a),g;d instanceof Array&&(g={},g[a]=d);return g||d};
  9. b.addListener=function(a,d){var g=this.getListenersAsObject(a),f="object"===typeof d,b;for(b in g)g.hasOwnProperty(b)&&-1===c(g[b],d)&&g[b].push(f?d:{listener:d,once:!1});return this};b.on=b.addListener;b.addOnceListener=function(a,d){return this.addListener(a,{listener:d,once:!0})};b.once=b.addOnceListener;b.defineEvent=function(a){this.getListeners(a);return this};b.defineEvents=function(a){for(var d=0;d<a.length;d+=1)this.defineEvent(a[d]);return this};b.removeListener=function(a,d){var g=this.getListenersAsObject(a),
  10. f,b;for(b in g)g.hasOwnProperty(b)&&(f=c(g[b],d),-1!==f&&g[b].splice(f,1));return this};b.off=b.removeListener;b.addListeners=function(a,d){return this.manipulateListeners(!1,a,d)};b.removeListeners=function(a,d){return this.manipulateListeners(!0,a,d)};b.manipulateListeners=function(a,d,g){var f,b,c=a?this.removeListener:this.addListener;a=a?this.removeListeners:this.addListeners;if("object"!==typeof d||d instanceof RegExp)for(f=g.length;f--;)c.call(this,d,g[f]);else for(f in d)d.hasOwnProperty(f)&&
  11. (b=d[f])&&("function"===typeof b?c.call(this,f,b):a.call(this,f,b));return this};b.removeEvent=function(a){var d=typeof a,b=this._getEvents(),f;if("string"===d)delete b[a];else if("object"===d)for(f in b)b.hasOwnProperty(f)&&a.test(f)&&delete b[f];else delete this._events;return this};b.emitEvent=function(a,d){var b=this.getListenersAsObject(a),f,c,e,l;for(e in b)if(b.hasOwnProperty(e))for(c=b[e].length;c--;)f=b[e][c],l=f.listener.apply(this,d||[]),l!==this._getOnceReturnValue()&&!0!==f.once||this.removeListener(a,
  12. f.listener);return this};b.trigger=b.emitEvent;b.emit=function(a){var d=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,d)};b.setOnceReturnValue=function(a){this._onceReturnValue=a;return this};b._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0};b._getEvents=function(){return this._events||(this._events={})};"function"===typeof define&&define.amd?define(function(){return e}):"undefined"!==typeof module&&module.exports?module.exports=
  13. e:this.EventEmitter=e}).call(this);
  14. (function(e){var c=document.documentElement,b=function(){};c.addEventListener?b=function(a,b,f){a.addEventListener(b,f,!1)}:c.attachEvent&&(b=function(a,b,f){a[b+f]=f.handleEvent?function(){var a=e.event;a.target=a.target||a.srcElement;f.handleEvent.call(f,a)}:function(){var b=e.event;b.target=b.target||b.srcElement;f.call(a,b)};a.attachEvent("on"+b,a[b+f])});var a=function(){};c.removeEventListener?a=function(a,b,f){a.removeEventListener(b,f,!1)}:c.detachEvent&&(a=function(a,b,f){a.detachEvent("on"+
  15. b,a[b+f]);try{delete a[b+f]}catch(c){a[b+f]=void 0}});c={bind:b,unbind:a};"function"===typeof define&&define.amd?define(c):e.eventie=c})(this);
  16. (function(e){function c(a){"function"===typeof a&&(c.isReady?a():g.push(a))}function b(a){a="readystatechange"===a.type&&"complete"!==d.readyState;if(!c.isReady&&!a){c.isReady=!0;a=0;for(var b=g.length;a<b;a++)(0,g[a])()}}function a(a){a.bind(d,"DOMContentLoaded",b);a.bind(d,"readystatechange",b);a.bind(e,"load",b);return c}var d=e.document,g=[];c.isReady=!1;"function"===typeof define&&define.amd?(c.isReady="function"===typeof requirejs,define(["eventie/eventie"],a)):e.docReady=a(e.eventie)})(this);
  17. (function(e){function c(c,e){(b(c,e)?d:a)(c,e)}var b,a,d;"classList"in document.documentElement?(b=function(a,b){return a.classList.contains(b)},a=function(a,b){a.classList.add(b)},d=function(a,b){a.classList.remove(b)}):(b=function(a,b){return RegExp("(^|\\s+)"+b+"(\\s+|$)").test(a.className)},a=function(a,d){b(a,d)||(a.className=a.className+" "+d)},d=function(a,b){a.className=a.className.replace(RegExp("(^|\\s+)"+b+"(\\s+|$)")," ")});var g={hasClass:b,addClass:a,removeClass:d,toggleClass:c,has:b,
  18. add:a,remove:d,toggle:c};"function"===typeof define&&define.amd?define(g):e.classie=g})(window);
  19. (function(e){function c(b){for(var a in c.defaults)this[a]=c.defaults[a];for(a in b)this[a]=b[a]}(e.Packery=function(){}).Rect=c;c.defaults={x:0,y:0,width:0,height:0};c.prototype.contains=function(b){var a=b.width||0,d=b.height||0;return this.x<=b.x&&this.y<=b.y&&this.x+this.width>=b.x+a&&this.y+this.height>=b.y+d};c.prototype.overlaps=function(b){var a=this.x+this.width,d=this.y+this.height,c=b.y+b.height;return this.x<b.x+b.width&&a>b.x&&this.y<c&&d>b.y};c.prototype.getMaximalFreeRects=function(b){if(!this.overlaps(b))return!1;
  20. var a=[],d,e=this.x+this.width,f=this.y+this.height,h=b.x+b.width,k=b.y+b.height;this.y<b.y&&(d=new c({x:this.x,y:this.y,width:this.width,height:b.y-this.y}),a.push(d));e>h&&(d=new c({x:h,y:this.y,width:e-h,height:this.height}),a.push(d));f>k&&(d=new c({x:this.x,y:k,width:this.width,height:f-k}),a.push(d));this.x<b.x&&(d=new c({x:this.x,y:this.y,width:b.x-this.x,height:this.height}),a.push(d));return a};c.prototype.canFit=function(b){return this.width>=b.width&&this.height>=b.height}})(window);
  21. (function(e){function c(a,b){this.width=a||0;this.height=b||0;this.reset()}e=e.Packery;var b=e.Rect;c.prototype.reset=function(){this.spaces=[];this.newSpaces=[];var a=new b({x:0,y:0,width:this.width,height:this.height});this.spaces.push(a)};c.prototype.pack=function(a,b){for(var c=0,e=this.spaces.length;c<e;c++){var h=this.spaces[c];if(h.canFit(a)){this.placeInSpace(a,h,b);break}}};c.prototype.placeInSpace=function(a,b,c){a.x=b.x;a.y=b.y;this.placed(a,c)};c.prototype.placed=function(a,b){for(var e=
  22. [],f=0,h=this.spaces.length;f<h;f++){var k=this.spaces[f],l=k.getMaximalFreeRects(a);l?e.push.apply(e,l):e.push(k)}this.spaces=e;c.mergeRects(this.spaces);"horizontal"==b?this.spaces.sort(c.spaceSorterLeftTop):this.spaces.sort(c.spaceSorterTopLeft)};c.mergeRects=function(a){for(var b=0,c=a.length;b<c;b++){var e=a[b];if(e){var h=a.slice(0);h.splice(b,1);for(var k=0,l=0,q=h.length;l<q;l++){var t=b>l?0:1;e.contains(h[l])&&(a.splice(l+t-k,1),k++)}}}return a};c.spaceSorterTopLeft=function(a,b){return a.y-
  23. b.y||a.x-b.x};c.spaceSorterLeftTop=function(a,b){return a.x-b.x||a.y-b.y};e.Packer=c})(window);
  24. (function(e){function c(b,c){this.element=b;this.packery=c;this.position={x:0,y:0};this.rect=new a;this.placeRect=new a;this.element.style.position="absolute"}var b=e.Packery,a=b.Rect,d=e.getSize,g=e.getStyleProperty;e=e.EventEmitter;var f=document.defaultView,h=f&&f.getComputedStyle?function(a){return f.getComputedStyle(a,null)}:function(a){return a.currentStyle},k=g("transition"),l=g("transform"),q=k&&l,g=!!g("perspective"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",
  25. OTransition:"otransitionend",transition:"transitionend"}[k],u={WebkitTransform:"-webkit-transform",MozTransform:"-moz-transform",OTransform:"-o-transform",transform:"transform"}[l];(function(a,b){for(var c in b)a[c]=b[c];return a})(c.prototype,e.prototype);c.prototype.handleEvent=function(a){var b="on"+a.type;if(this[b])this[b](a)};c.prototype.getSize=function(){this.size=d(this.element)};c.prototype.css=function(a){var b=this.element.style,c;for(c in a)b[c]=a[c]};c.prototype.getPosition=function(){var a=
  26. h(this.element),b=parseInt(a.left,10),a=parseInt(a.top,10),b=isNaN(b)?0:b,a=isNaN(a)?0:a,c=this.packery.elementSize,b=b-c.paddingLeft,a=a-c.paddingTop;this.position.x=b;this.position.y=a};var m=g?function(a,b){return"translate3d( "+a+"px, "+b+"px, 0)"}:function(a,b){return"translate( "+a+"px, "+b+"px)"};c.prototype._transitionTo=function(a,b){this.getPosition();var c=this.position.x,d=this.position.y,e=parseInt(a,10),n=parseInt(b,10),e=e===this.position.x&&n===this.position.y;this.setPosition(a,b);
  27. e&&!this.isTransitioning?this.layoutPosition():(e={},e[u]=m(a-c,b-d),this.transition(e,this.layoutPosition))};c.prototype.goTo=function(a,b){this.setPosition(a,b);this.layoutPosition()};c.prototype.moveTo=q?c.prototype._transitionTo:c.prototype.goTo;c.prototype.setPosition=function(a,b){this.position.x=parseInt(a,10);this.position.y=parseInt(b,10)};c.prototype.layoutPosition=function(){var a=this.packery.elementSize;this.css({left:this.position.x+a.paddingLeft+"px",top:this.position.y+a.paddingTop+
  28. "px"});this.emitEvent("layout",[this])};c.prototype._nonTransition=function(a,b){this.css(a);b&&b.call(this)};c.prototype._transition=function(a,b){this.transitionStyle=a;var c=[],d;for(d in a)c.push(d);d={};d[k+"Property"]=c.join(",");d[k+"Duration"]=this.packery.options.transitionDuration;this.element.addEventListener(t,this,!1);if(b)this.on("transitionEnd",function(a){b.call(a);return!0});this.css(d);this.css(a);this.isTransitioning=!0};c.prototype.transition=c.prototype[k?"_transition":"_nonTransition"];
  29. c.prototype.onwebkitTransitionEnd=function(a){this.ontransitionend(a)};c.prototype.onotransitionend=function(a){this.ontransitionend(a)};c.prototype.ontransitionend=function(a){if(a.target===this.element){this.onTransitionEnd&&(this.onTransitionEnd(),delete this.onTransitionEnd);this.removeTransitionStyles();a={};for(var b in this.transitionStyle)a[b]="";this.css(a);this.element.removeEventListener(t,this,!1);delete this.transitionStyle;this.isTransitioning=!1;this.emitEvent("transitionEnd",[this])}};
  30. c.prototype.removeTransitionStyles=function(){var a={};a[k+"Property"]="";a[k+"Duration"]="";this.css(a)};c.prototype.remove=function(){var a={opacity:0};a[u]="scale(0.001)";this.transition(a,this.removeElem)};c.prototype.removeElem=function(){this.element.parentNode.removeChild(this.element);this.emitEvent("remove",[this])};c.prototype.reveal=k?function(){var a={opacity:0};a[u]="scale(0.001)";this.css(a);a={opacity:1};a[u]="scale(1)";this.transition(a)}:function(){};c.prototype.destroy=function(){this.css({position:"",
  31. left:"",top:""})};c.prototype.dragStart=function(){this.getPosition();this.removeTransitionStyles();this.isTransitioning&&l&&(this.element.style[l]="none");this.getSize();this.isPlacing=!0;this.needsPositioning=!1;this.positionPlaceRect(this.position.x,this.position.y);this.didDrag=this.isTransitioning=!1};c.prototype.dragMove=function(a,b){this.didDrag=!0;var c=this.packery.elementSize;a-=c.paddingLeft;b-=c.paddingTop;this.positionPlaceRect(a,b)};c.prototype.dragStop=function(){this.getPosition();
  32. var a=this.position.y!==this.placeRect.y;this.needsPositioning=this.position.x!==this.placeRect.x||a;this.didDrag=!1};c.prototype.positionPlaceRect=function(a,b,c){this.placeRect.x=this.getPlaceRectCoord(a,!0);this.placeRect.y=this.getPlaceRectCoord(b,!1,c)};c.prototype.getPlaceRectCoord=function(a,b,c){var d=b?"Width":"Height",e=this.size["outer"+d],n=this.packery[b?"columnWidth":"rowHeight"],d=this.packery.elementSize["inner"+d];b||(d=Math.max(d,this.packery.maxY),this.packery.rowHeight||(d-=this.packery.gutter));
  33. n?(n+=this.packery.gutter,d+=b?this.packery.gutter:0,a=Math.round(a/n),b=Math[b?"floor":"ceil"](d/n),e=b-=Math.ceil(e/n)):e=d-e;a=c?a:Math.min(a,e);return Math.max(0,a*(n||1))};c.prototype.copyPlaceRectPosition=function(){this.rect.x=this.placeRect.x;this.rect.y=this.placeRect.y};b.Item=c})(window);
  34. (function(e){function c(a,b){for(var c in b)a[c]=b[c];return a}function b(a){var b=[];if("number"===typeof a.length)for(var c=0,d=a.length;c<d;c++)b.push(a[c]);else b.push(a);return b}function a(a,b){if(a&&r(a)){this.element=a;this.options=c({},this.options);c(this.options,b);var d=++w;this.element.packeryGUID=d;v[d]=this;this._create();this.options.isInitLayout&&this.layout()}else m&&m.error("bad Packery element: "+a)}var d=e.Packery,g=d.Rect,f=d.Packer,h=d.Item,k=e.classie,d=e.docReady,l=e.eventie,
  35. q=e.getSize,t=e.matchesSelector,u=e.document,m=e.console,p=e.jQuery,r="object"===typeof HTMLElement?function(a){return a instanceof HTMLElement}:function(a){return a&&"object"===typeof a&&1===a.nodeType&&"string"===typeof a.nodeName},s=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},w=0,v={};c(a.prototype,e.EventEmitter.prototype);a.prototype.options={containerStyle:{position:"relative"},layoutMode:"vertical",isInitLayout:!0,
  36. isResizeBound:!0,transitionDuration:"0.4s"};a.prototype._create=function(){this.packer=new f;this.reloadItems();this.stampedElements=[];this.stamp(this.options.stamped);c(this.element.style,this.options.containerStyle);this.options.isResizeBound&&this.bindResize();var a=this;this.handleDraggabilly={dragStart:function(b){a.itemDragStart(b.element)},dragMove:function(b){a.itemDragMove(b.element,b.position.x,b.position.y)},dragEnd:function(b){a.itemDragEnd(b.element)}};this.handleUIDraggable={start:function(b){a.itemDragStart(b.currentTarget)},
  37. drag:function(b,c){a.itemDragMove(b.currentTarget,c.position.left,c.position.top)},stop:function(b){a.itemDragEnd(b.currentTarget)}}};a.prototype.reloadItems=function(){this.items=this._getItems(this.element.children)};a.prototype._getItems=function(a){a=this._filterFindItemElements(a);for(var b=[],c=0,d=a.length;c<d;c++){var e=new h(a[c],this);b.push(e)}return b};a.prototype._filterFindItemElements=function(a){a=b(a);var c=this.options.itemSelector;if(!c)return a;for(var d=[],e=0,f=a.length;e<f;e++){var g=
  38. a[e];t(g,c)&&d.push(g);for(var g=g.querySelectorAll(c),h=0,k=g.length;h<k;h++)d.push(g[h])}return d};a.prototype.getItemElements=function(){for(var a=[],b=0,c=this.items.length;b<c;b++)a.push(this.items[b].element);return a};a.prototype.layout=function(){this._prelayout();this.layoutItems(this.items,void 0!==this.options.isLayoutInstant?this.options.isLayoutInstant:!this._isLayoutInited);this._isLayoutInited=!0};a.prototype._init=a.prototype.layout;a.prototype._prelayout=function(){this.elementSize=
  39. q(this.element);this._getMeasurements();"horizontal"==this.options.layoutMode?(this.packer.width=Number.POSITIVE_INFINITY,this.packer.height=this.elementSize.innerHeight+this.gutter):(this.packer.width=this.elementSize.innerWidth+this.gutter,this.packer.height=Number.POSITIVE_INFINITY);this.packer.reset();this.maxY=this.maxX=0;this.placeStampedElements()};a.prototype._getMeasurements=function(){this._getMeasurement("columnWidth","width");this._getMeasurement("rowHeight","height");this._getMeasurement("gutter",
  40. "width")};a.prototype._getMeasurement=function(a,b){var c=this.options[a],d;c?("string"===typeof c?d=this.element.querySelector(c):r(c)&&(d=c),this[a]=d?q(d)[b]:c):this[a]=0};a.prototype.layoutItems=function(a,b){var c=this._getLayoutItems(a);if(c&&c.length){this._itemsOn(c,"layout",function(){this.emitEvent("layoutComplete",[this,c])});for(var d=0,e=c.length;d<e;d++){var f=c[d];this._packItem(f);this._layoutItem(f,b)}}else this.emitEvent("layoutComplete",[this,[]]);this._setContainerSize()};a.prototype._setContainerSize=
  41. function(){var a=this.elementSize;if("horizontal"==this.options.layoutMode){var b=this.maxX-this.gutter;a.isBorderBox&&(b+=a.paddingLeft+a.paddingRight+a.borderRightWidth+a.borderLeftWidth);b=Math.max(b,0);this.element.style.width=b+"px"}else b=this.maxY-this.gutter,a.isBorderBox&&(b+=a.paddingBottom+a.paddingTop+a.borderTopWidth+a.borderBottomWidth),b=Math.max(b,0),this.element.style.height=b+"px"};a.prototype._getLayoutItems=function(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c];e.isIgnored||
  42. b.push(e)}return b};a.prototype._packItem=function(a){this._setRectSize(a.element,a.rect);this.packer.pack(a.rect,this.options.layoutMode);"horizontal"==this.options.layoutMode?this._setMaxX(a.rect):this._setMaxY(a.rect)};a.prototype._setMaxX=function(a){this.maxX=Math.max(a.x+a.width,this.maxX)};a.prototype._setMaxY=function(a){this.maxY=Math.max(a.y+a.height,this.maxY)};a.prototype._setRectSize=function(a,b){var c=q(a),d=c.outerWidth,c=c.outerHeight,e=this.columnWidth+this.gutter,f=this.rowHeight+
  43. this.gutter,d=this.columnWidth?Math.ceil(d/e)*e:d+this.gutter,c=this.rowHeight?Math.ceil(c/f)*f:c+this.gutter;"horizontal"==this.options.layoutMode?(b.width=d,b.height=Math.min(c,this.packer.height)):(b.width=Math.min(d,this.packer.width),b.height=c)};a.prototype._layoutItem=function(a,b){var c=a.rect;b?a.goTo(c.x,c.y):a.moveTo(c.x,c.y)};a.prototype._itemsOn=function(a,b,c){function d(){e++;e===f&&c.call(g);return!0}for(var e=0,f=a.length,g=this,h=0,k=a.length;h<k;h++)a[h].on(b,d)};a.prototype.stamp=
  44. function(a){if(a){"string"===typeof a&&(a=this.element.querySelectorAll(a));a=b(a);this.stampedElements.push.apply(this.stampedElements,a);for(var c=0,d=a.length;c<d;c++)this.ignore(a[c])}};a.prototype.unstamp=function(a){if(a){a=b(a);for(var c=0,d=a.length;c<d;c++){var e=a[c],f=s(this.stampedElements,e);-1!==f&&this.stampedElements.splice(f,1);this.unignore(e)}}};a.prototype.placeStampedElements=function(){if(this.stampedElements&&this.stampedElements.length){this._getBounds();for(var a=0,b=this.stampedElements.length;a<
  45. b;a++)this.placeStamp(this.stampedElements[a])}};a.prototype._getBounds=function(){var a=this.element.getBoundingClientRect();this._boundingLeft=a.left+this.elementSize.paddingLeft;this._boundingTop=a.top+this.elementSize.paddingTop};a.prototype.placeStamp=function(a){var b=this.getItem(a),c;c=b&&b.isPlacing?b.placeRect:this._getElementOffsetRect(a);this._setRectSize(a,c);this.packer.placed(c,this.options.layoutMode);"horizontal"==this.options.layoutMode?this._setMaxX(b.rect):this._setMaxY(b.rect)};
  46. a.prototype._getElementOffsetRect=function(a){a=a.getBoundingClientRect();a=new g({x:a.left-this._boundingLeft,y:a.top-this._boundingTop});a.x-=this.elementSize.borderLeftWidth;a.y-=this.elementSize.borderTopWidth;return a};a.prototype.handleEvent=function(a){var b="on"+a.type;if(this[b])this[b](a)};a.prototype.bindResize=function(){this.isResizeBound||(l.bind(e,"resize",this),this.isResizeBound=!0)};a.prototype.unbindResize=function(){l.unbind(e,"resize",this);this.isResizeBound=!1};a.prototype.onresize=
  47. function(){this.resizeTimeout&&clearTimeout(this.resizeTimeout);var a=this;this.resizeTimeout=setTimeout(function(){a.resize()},100)};a.prototype.resize=function(){var a=q(this.element);this.elementSize&&a&&a.innerWidth===this.elementSize.innerWidth||(this.layout(),delete this.resizeTimeout)};a.prototype.addItems=function(a){a=this._getItems(a);if(a.length)return this.items.push.apply(this.items,a),a};a.prototype.appended=function(a){a=this.addItems(a);a.length&&(this.layoutItems(a,!0),this.reveal(a))};
  48. a.prototype.prepended=function(a){a=this._getItems(a);if(a.length){var b=this.items.slice(0);this.items=a.concat(b);this._prelayout();this.layoutItems(a,!0);this.reveal(a);this.layoutItems(b)}};a.prototype.reveal=function(a){if(a&&a.length)for(var b=0,c=a.length;b<c;b++)a[b].reveal()};a.prototype.getItem=function(a){for(var b=0,c=this.items.length;b<c;b++){var d=this.items[b];if(d.element===a)return d}};a.prototype.getItems=function(a){if(a&&a.length){for(var b=[],c=0,d=a.length;c<d;c++){var e=this.getItem(a[c]);
  49. e&&b.push(e)}return b}};a.prototype.remove=function(a){a=b(a);var c=this.getItems(a);this._itemsOn(c,"remove",function(){this.emitEvent("removeComplete",[this,c])});a=0;for(var d=c.length;a<d;a++){var e=c[a];e.remove();e=s(this.items,e);this.items.splice(e,1)}};a.prototype.ignore=function(a){if(a=this.getItem(a))a.isIgnored=!0};a.prototype.unignore=function(a){(a=this.getItem(a))&&delete a.isIgnored};a.prototype.sortItemsByPosition=function(){this.items.sort(function(a,b){return a.position.y-b.position.y||
  50. a.position.x-b.position.x})};a.prototype.fit=function(a,b,c){function d(){g++;2===g&&f.emitEvent("fitComplete",[f,e])}var e=this.getItem(a);if(e){this._getMeasurements();this.stamp(e.element);e.getSize();e.isPlacing=!0;b=void 0===b?e.rect.x:b;c=void 0===c?e.rect.y:c;e.positionPlaceRect(b,c,!0);var f=this,g=0;e.on("layout",function(){d();return!0});this.on("layoutComplete",function(){d();return!0});e.moveTo(e.placeRect.x,e.placeRect.y);this.layout();this.unstamp(e.element);this.sortItemsByPosition();
  51. e.isPlacing=!1;e.copyPlaceRectPosition()}};a.prototype.itemDragStart=function(a){this.stamp(a);(a=this.getItem(a))&&a.dragStart()};a.prototype.itemDragMove=function(a,b,c){(a=this.getItem(a))&&a.dragMove(b,c);var d=this;this.clearDragTimeout();this.dragTimeout=setTimeout(function(){d.layout();delete d.dragTimeout},40)};a.prototype.clearDragTimeout=function(){this.dragTimeout&&clearTimeout(this.dragTimeout)};a.prototype.itemDragEnd=function(a){function b(){g++;if(g!==f)return!0;c&&(k.remove(c.element,
  52. "is-positioning-post-drag"),c.isPlacing=!1,c.copyPlaceRectPosition());h.unstamp(a);h.sortItemsByPosition();c&&e&&h.emitEvent("dragItemPositioned",[h,c]);return!0}var c=this.getItem(a),d;c&&(d=c.didDrag,c.dragStop());if(c&&(d||c.needsPositioning)){k.add(c.element,"is-positioning-post-drag");var e=c.needsPositioning,f=e?2:1,g=0,h=this;e?(c.on("layout",b),c.moveTo(c.placeRect.x,c.placeRect.y)):c&&c.copyPlaceRectPosition();this.clearDragTimeout();this.on("layoutComplete",b);this.layout()}else this.unstamp(a)};
  53. a.prototype.bindDraggabillyEvents=function(a){a.on("dragStart",this.handleDraggabilly.dragStart);a.on("dragMove",this.handleDraggabilly.dragMove);a.on("dragEnd",this.handleDraggabilly.dragEnd)};a.prototype.bindUIDraggableEvents=function(a){a.on("dragstart",this.handleUIDraggable.start).on("drag",this.handleUIDraggable.drag).on("dragstop",this.handleUIDraggable.stop)};a.prototype.destroy=function(){this.element.style.position="";this.element.style.height="";delete this.element.packeryGUID;for(var a=
  54. 0,b=this.items.length;a<b;a++)this.items[a].destroy();this.unbindResize()};a.data=function(a){return(a=a.packeryGUID)&&v[a]};d(function(){for(var b=u.querySelectorAll(".js-packery"),c=0,d=b.length;c<d;c++){var e=b[c],f=e.getAttribute("data-packery-options"),g;try{g=f&&JSON.parse(f)}catch(h){m&&m.error("Error parsing data-packery-options on "+e.nodeName.toLowerCase()+(e.id?"#"+e.id:"")+": "+h);continue}f=new a(e,g);p&&p.data(e,"packery",f)}});p&&p.bridget&&p.bridget("packery",a);a.Rect=g;a.Packer=
  55. f;a.Item=h;e.Packery=a})(window);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement