Browse Source

js : Use $.extend for cellByRow layout

pull/14/head
David DeSandro 14 years ago
parent
commit
b801948bb0
  1. 67
      src/jquery.molequul.js

67
src/jquery.molequul.js

@ -613,42 +613,47 @@
// ====================== cellsByRow ====================== // ====================== cellsByRow ======================
$.Molequul.prototype._cellsByRowReset = function() { $.extend( $.Molequul.prototype, {
this.cellsByRow = {};
this._getCols('cellsByRow');
this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true);
return this;
};
$.Molequul.prototype._cellsByRowLayout = function( $elems ) { _cellsByRowReset : function() {
var instance = this, this.cellsByRow = {};
cols = this.cellsByRow.cols; this._getCols('cellsByRow');
this.cellsByRow.atomsLen = $elems.length; this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true);
$elems.each( function( i ){ return this;
var $this = $(this), },
x = ( i % cols + 0.5 ) * instance.cellsByRow.columnWidth
- $this.outerWidth(true) / 2 + instance.posLeft,
y = ( ~~( i / cols ) + 0.5 ) * instance.cellsByRow.rowHeight
- $this.outerHeight(true) / 2 + instance.posTop;
instance._pushPosition( $this, x, y );
});
return this;
};
$.Molequul.prototype._cellsByRowGetContainerSize = function() { _cellsByRowLayout : function( $elems ) {
return { height : Math.ceil( this.cellsByRow.atomsLen / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.posTop }; var instance = this,
}; cols = this.cellsByRow.cols;
this.cellsByRow.atomsLen = $elems.length;
$elems.each( function( i ){
var $this = $(this),
x = ( i % cols + 0.5 ) * instance.cellsByRow.columnWidth
- $this.outerWidth(true) / 2 + instance.posLeft,
y = ( ~~( i / cols ) + 0.5 ) * instance.cellsByRow.rowHeight
- $this.outerHeight(true) / 2 + instance.posTop;
instance._pushPosition( $this, x, y );
});
return this;
},
_cellsByRowGetContainerSize : function() {
return { height : Math.ceil( this.cellsByRow.atomsLen / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.posTop };
},
$.Molequul.prototype._cellsByRowResize = function() { _cellsByRowResize : function() {
var prevCols = this.cellsByRow.cols; var prevCols = this.cellsByRow.cols;
this._getCols('cellsByRow'); this._getCols('cellsByRow');
// if column count has changed, do a new column cound // if column count has changed, do a new column cound
if ( this.cellsByRow.cols !== prevCols ) { if ( this.cellsByRow.cols !== prevCols ) {
this.reLayout(); this.reLayout();
}
return this;
} }
return this; });
};

Loading…
Cancel
Save