Browse Source

js : Use $.extend for cellByRow layout

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

75
src/jquery.molequul.js

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

Loading…
Cancel
Save