Author: hqm
Date: 2007-07-26 21:02:52 -0700 (Thu, 26 Jul 2007)
New Revision: 5823
Modified:
openlaszlo/branches/wafflecone/lps/components/utils/replicator/replicator.lzx
Log:
replicator needs to extend view, not node, for now...
Modified:
openlaszlo/branches/wafflecone/lps/components/utils/replicator/replicator.lzx
===================================================================
---
openlaszlo/branches/wafflecone/lps/components/utils/replicator/replicator.lzx
2007-07-27 02:56:43 UTC (rev 5822)
+++
openlaszlo/branches/wafflecone/lps/components/utils/replicator/replicator.lzx
2007-07-27 04:02:52 UTC (rev 5823)
@@ -114,8 +114,10 @@
<script when="immediate">
<![CDATA[
-class replicator extends LzNode {
+class replicator extends LzView {
+ static var tagname = 'replicator';
+
var pool = true;
// The size (width or height) in the replication axis of the view
@@ -125,7 +127,7 @@
// The axis in which to replicate
var axis = "y";
- // The list of elements controlled by this repliator
+ // The list of elements controlled by this replicator
var clones = null;
var nodes = null;
var _sizes = { x : 'width', y: 'height' };
@@ -162,9 +164,9 @@
function setNodes (n) {
this.nodes = n;
this.__adjustVisibleClones();
- setAttribute("replicatedsize", subviews.length == 0
+ this.setAttribute("replicatedsize", this.subviews.length == 0
? 0
- : subviews[subviews.length-1][_sizes[axis]]);
+ :
this.subviews[this.subviews.length-1][this._sizes[this.axis]]);
this.onnodes.sendEvent();
}
@@ -174,7 +176,7 @@
function insertNode (idx, n) {
this.nodes.splice(idx, 0, n);
this._cloneprops.splice(idx,0, undefined); // maintain cloneprops
indices
- __adjustVisibleClones();
+ this.__adjustVisibleClones();
}
// Called internally, but may be overriden. This is the method
@@ -230,8 +232,9 @@
// @keywords private
function getClone () {
- if ( _clonepool.length ) {
- v = _clonepool.pop();
+ var v;
+ if ( this._clonepool.length ) {
+ v = this._clonepool.pop();
v.setVisible( true );
} else {
v = this._makeClone();
@@ -241,6 +244,7 @@
// @keywords private
function _makeClone () {
+ var v = this.makeChild( this.replicated );
v.setAttribute( "clonenumber", null );
return v;
}
@@ -249,12 +253,12 @@
function poolClone (c) {
if ( c.clonenumber ) this.unbind( c );
c.setVisible( false );
- _clonepool.push( c );
+ this._clonepool.push( c );
}
// @keywords private
function getCloneIfVisible (n) {
- return clones[ n ];
+ return this.clones[ n ];
}
// Called internally, but may be overriden. This is the method is
@@ -265,18 +269,18 @@
// @param n: The node to which it is being set.
function setData (v, n) {
- v.setAttribute( "data" , nodes[ n ] );
- v.applyData(nodes[n]);
+ v.setAttribute( "data" , this.nodes[ n ] );
+ v.applyData(this.nodes[n]);
}
// @keywords private
function __adjustVisibleClones () {
- while( clones.length ) this.poolClone( clones.pop() );
- if (nodes != null) {
- for( var i = 0;i < nodes.length; i++ ){
+ while( this.clones.length ) this.poolClone( this.clones.pop() );
+ if (this.nodes != null) {
+ for( var i = 0;i < this.nodes.length; i++ ){
var cl = this.getClone( );
this.bind( cl, i );
- clones[ i ] = cl;
+ this.clones[ i ] = cl;
}
}
}
@@ -294,12 +298,12 @@
// @param Number n: The offset of the clone to scroll in view
function ensureInView (n) {
- var pos = n*replicatedsize;
- var ny = y;
+ var pos = n*this.replicatedsize;
+ var ny = this.y;
- if ( replicatedsize+pos >= mask.height -y) {
- ny = mask.height - pos-replicatedsize;
- } else if ( pos < -y ) ny = -pos;
+ if ( this.replicatedsize+pos >= mask.height -this.y) {
+ ny = mask.height - pos-this.replicatedsize;
+ } else if ( pos < -this.y ) ny = -pos;
if ( this.y != ny ) this.setY( ny );
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins