Merge branch 'jonathan-fielding/master'

This commit is contained in:
Kegan Myers 2015-08-27 14:24:58 -05:00
commit d13d7c8bb7
4 changed files with 19 additions and 7 deletions

View file

@ -1,6 +1,6 @@
{
"name": "tile-flooring",
"version": "0.0.2",
"version": "0.0.3",
"homepage": "https://terribleplan.com/TileFlooring.js/",
"authors": [
"Kegan Myers <kegan@keganmyers.com>"

View file

@ -1,6 +1,6 @@
{
"name": "tile-flooring",
"version": "0.0.2",
"version": "0.0.3",
"description": "TileFlooring.js - You want a masonry-style layout? You got it.",
"main": "tile.js",
"scripts": {

18
tile.js
View file

@ -1,6 +1,18 @@
/*! TileFlooring.js 0.0.1 | (c) 2015 Kegan Myers | https://terribleplan.com/TileFlooring.js/LICENSE.md */
/*! TileFlooring.js 0.0.3 | (c) 2015 Kegan Myers | https://terribleplan.com/TileFlooring.js/LICENSE.md */
var TileFloor = (function() {
(function (window, document, undefined, factory) {
if (typeof define === 'function' && define.amd) {
define(function() {
return factory(window, document, undefined);
});
}
else if (typeof exports === 'object') {
module.exports = factory;
}
else {
window.TileFloor = factory(window, document, undefined);
}
})(window, document, undefined, function (window, document, undefined) {
function elementSuicide(element) {
if (element.parentElement !== null) {
element.parentElement.removeChild(element);
@ -131,4 +143,4 @@ var TileFloor = (function() {
};
return Tile;
})();
});

4
tile.min.js vendored
View file

@ -1,2 +1,2 @@
/*! TileFlooring.js 0.0.1 | (c) 2015 Kegan Myers | https://terribleplan.com/TileFlooring.js/LICENSE.md */
var TileFloor=function(){function a(a){null!==a.parentElement&&a.parentElement.removeChild(a)}function b(a){this.element=a,this.originalParent=a.parent}function c(a){this.element=a}function d(a,c){if(!a.tagName||"function"!=typeof a.querySelectorAll)throw new Error("The first argument must be a DOM Element");if(!c.hasOwnProperty("elementSelector"))throw new Error("You must define an element selector");if(!c.hasOwnProperty("columns"))throw new Error("The only display mode is `columns`");if(!c.columns.hasOwnProperty("maxWidth"))throw new Error("You must define a max width for your columns");c.columns.hasOwnProperty("maxCount")||(c.columns.maxCount=1/0),this.masterElement=a,this.destroyed=!1,this.options=c,this.elements=Array.prototype.map.call(a.querySelectorAll(c.elementSelector),function(a){return new b(a)}),this.containers=[],this.containerElement=null;var d="-generated-tf"+Math.floor(1e4*Math.random());this.clearfixClassName="clearfix"+d,this.columnClassName="responsive-column"+d,this.clearfixStylesheet=document.createElement("style"),document.head.appendChild(this.clearfixStylesheet),this.clearfixStylesheet.sheet.insertRule("."+this.clearfixClassName+':after{content:"";display:table;clear:both}',0),this.clearfixStylesheet.sheet.insertRule("."+this.columnClassName+"{float:left;max-width:"+c.columns.maxWidth+"px}",0),this.flow();var e=this;this.onResize=function(){var a=e.determineColumns();return e.containers.length!==a?e.flow():void 0},window.addEventListener("resize",this.onResize,!1)}function e(a){a.removeSelf()}function f(){return document.createElement("div")}function g(a){var b=0,c=1/0;return a.forEach(function(a,d){var e=a.height();c>e&&(b=d,c=e)}),a[b]}if("function"!=typeof document.querySelectorAll)throw new Error("TileFloor is only compatible with HTML5 browsers");return b.prototype.removeSelf=function(){a(this.element)},c.prototype.removeSelf=b.prototype.removeSelf,c.prototype.height=function(){return this.element.offsetHeight},c.prototype.addChild=function(a){return this.element.appendChild(a)},d.prototype.flow=function(){var b=this;null!==this.containerElement&&a(this.containerElement),this.elements.forEach(e),this.containers.forEach(e);var d=this.determineColumns();if(0===d)throw new Error("Cowardly refusing to flow elements into 0 columns");this.containerElement=f(),this.containerElement.className=this.clearfixClassName,this.containers=new Array(d);for(var g=0;d>g;g++){var h=f();h.className=b.columnClassName,h.style.width=100/d+"%",b.containerElement.appendChild(h),this.containers[g]=new c(h)}this.masterElement.appendChild(this.containerElement),this.elements.forEach(function(a){b.pushElement(a)})},d.prototype.pushElement=function(a){var c=a instanceof b?a:new b(a);c.removeSelf(),g(this.containers).addChild(c.element)},d.prototype.determineColumns=function(){return Math.min(Math.ceil(this.masterElement.offsetWidth/this.options.columns.maxWidth),this.options.columns.maxCount)},d}();
/*! TileFlooring.js 0.0.3 | (c) 2015 Kegan Myers | https://terribleplan.com/TileFlooring.js/LICENSE.md */
!function(a,b,c,d){"function"==typeof define&&define.amd?define(function(){return d(a,b,c)}):"object"==typeof exports?module.exports=d:a.TileFloor=d(a,b,c)}(window,document,void 0,function(a,b,c){function d(a){null!==a.parentElement&&a.parentElement.removeChild(a)}function e(a){this.element=a,this.originalParent=a.parent}function f(a){this.element=a}function g(c,d){if(!c.tagName||"function"!=typeof c.querySelectorAll)throw new Error("The first argument must be a DOM Element");if(!d.hasOwnProperty("elementSelector"))throw new Error("You must define an element selector");if(!d.hasOwnProperty("columns"))throw new Error("The only display mode is `columns`");if(!d.columns.hasOwnProperty("maxWidth"))throw new Error("You must define a max width for your columns");d.columns.hasOwnProperty("maxCount")||(d.columns.maxCount=1/0),this.masterElement=c,this.destroyed=!1,this.options=d,this.elements=Array.prototype.map.call(c.querySelectorAll(d.elementSelector),function(a){return new e(a)}),this.containers=[],this.containerElement=null;var f="-generated-tf"+Math.floor(1e4*Math.random());this.clearfixClassName="clearfix"+f,this.columnClassName="responsive-column"+f,this.clearfixStylesheet=b.createElement("style"),b.head.appendChild(this.clearfixStylesheet),this.clearfixStylesheet.sheet.insertRule("."+this.clearfixClassName+':after{content:"";display:table;clear:both}',0),this.clearfixStylesheet.sheet.insertRule("."+this.columnClassName+"{float:left;max-width:"+d.columns.maxWidth+"px}",0),this.flow();var g=this;this.onResize=function(){var a=g.determineColumns();return g.containers.length!==a?g.flow():void 0},a.addEventListener("resize",this.onResize,!1)}function h(a){a.removeSelf()}function i(){return b.createElement("div")}function j(a){var b=0,c=1/0;return a.forEach(function(a,d){var e=a.height();c>e&&(b=d,c=e)}),a[b]}if("function"!=typeof b.querySelectorAll)throw new Error("TileFloor is only compatible with HTML5 browsers");return e.prototype.removeSelf=function(){d(this.element)},f.prototype.removeSelf=e.prototype.removeSelf,f.prototype.height=function(){return this.element.offsetHeight},f.prototype.addChild=function(a){return this.element.appendChild(a)},g.prototype.flow=function(){var a=this;null!==this.containerElement&&d(this.containerElement),this.elements.forEach(h),this.containers.forEach(h);var b=this.determineColumns();if(0===b)throw new Error("Cowardly refusing to flow elements into 0 columns");this.containerElement=i(),this.containerElement.className=this.clearfixClassName,this.containers=new Array(b);for(var c=0;b>c;c++){var e=i();e.className=a.columnClassName,e.style.width=100/b+"%",a.containerElement.appendChild(e),this.containers[c]=new f(e)}this.masterElement.appendChild(this.containerElement),this.elements.forEach(function(b){a.pushElement(b)})},g.prototype.pushElement=function(a){var b=a instanceof e?a:new e(a);b.removeSelf(),j(this.containers).addChild(b.element)},g.prototype.determineColumns=function(){return Math.min(Math.ceil(this.masterElement.offsetWidth/this.options.columns.maxWidth),this.options.columns.maxCount)},g});