From fb1a0cda2f4edf20651627464d9b2a5b364c0056 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Thu, 16 Dec 2010 23:46:14 -0500 Subject: [PATCH] js : add cellByRowResize --- src/jquery.molequul.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/jquery.molequul.js b/src/jquery.molequul.js index a92551d..dd6a878 100755 --- a/src/jquery.molequul.js +++ b/src/jquery.molequul.js @@ -459,8 +459,6 @@ this[ namespace ].cols = Math.floor( this.width / this[ namespace ].columnWidth ) ; this[ namespace ].cols = Math.max( this[ namespace ].cols, 1 ); - console.log( 'cols for ' + namespace, this[ namespace ].cols ) - return this; } @@ -627,20 +625,30 @@ this.cellsByRow.atomsLen = $elems.length; $elems.each( function( i ){ var $this = $(this), - x = ( i % instance.cellsByRow.cols ) * instance.cellsByRow.columnWidth + instance.posLeft, - y = ~~( i / instance.cellsByRow.cols ) * instance.cellsByRow.rowHeight + instance.posTop; - console.log( x, y ) - + x = ( i % instance.cellsByRow.cols ) * instance.cellsByRow.columnWidth + + instance.posLeft, + y = ~~( i / instance.cellsByRow.cols ) * instance.cellsByRow.rowHeight + + instance.posTop; instance._pushPosition( $this, x, y ); - }); + return this; }; $.Molequul.prototype._cellsByRowGetContainerSize = function() { - console.log( Math.ceil( this.cellsByRow.atomsLen / this.cellsByRow.cols ) ) return { height : Math.ceil( this.cellsByRow.atomsLen / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.posTop }; }; + $.Molequul.prototype._cellsByRowResize = function() { + var prevCols = this.cellsByRow.cols; + this._getCols('cellsByRow'); + + // if column count has changed, do a new column cound + if ( this.cellsByRow.cols !== prevCols ) { + this.reLayout(); + } + return this; + }; + })( jQuery ); \ No newline at end of file