Update of /cvsroot/dynapi/dynapi/src/lib/dynapi/api
In directory usw-pr-cvs1:/tmp/cvs-serv30686

Modified Files:
        dynlayer.js dyndocument.js 
Log Message:
Static methods update

Index: dynlayer.js
===================================================================
RCS file: /cvsroot/dynapi/dynapi/src/lib/dynapi/api/dynlayer.js,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** dynlayer.js 2001/01/06 20:48:26     1.7
--- dynlayer.js 2001/01/08 04:50:57     1.8
***************
*** 26,31 ****
        this.bgImage=null;
        
!       // these stay null until created
!       // within the dynlayer most checks for this.created have been replace with 
this.elm!=null
        this.elm=null;
        this.doc=null;
--- 26,30 ----
        this.bgImage=null;
        
!       // these stay null until created - checks for this.created have been replace 
with this.elm!=null
        this.elm=null;
        this.doc=null;
***************
*** 34,54 ****
        DynLayer.unassigned[this.id]=this;
  }
  DynLayer.unassigned=[];
  DynLayer.nullCount=0;
! DynLayer.prototype.isDynLayer = true;
  
! /*    no longer used
! DynLayer.prototype.getComponent=function () {
!       return this;
  };
! DynLayer.prototype.setParentComponent=function (par) {
!       this.parentComponent=par;
  };
! DynLayer.prototype.getParentComponent=function () {
!       return this.parentComponent;
  };
! */
  
! DynLayer.prototype.getClass=function() {      // should maybe set a string in each 
class .className ?
        return this.constructor;
  };
--- 33,177 ----
        DynLayer.unassigned[this.id]=this;
  }
+ 
+ // Static Properties/Methods
  DynLayer.unassigned=[];
  DynLayer.nullCount=0;
! DynLayer.createElement=function(dlyr) {
!       if (dlyr.created||!dlyr.parent||dlyr.elm!=null) return;
!       if (dlyr.parent.isDocument) dlyr.dyndoc=dlyr.parent;
!     else dlyr.dyndoc=dlyr.parent.dyndoc;
!       var lyr;
!       if (is.ns4) {
!               var recycled=dlyr.parent.doc.recycled;
!               if (recycled && recycled.length>0) {
!               lyr=recycled[0];
!                       DynAPI.removeFromArray(recycled,recycled[0]);
!               } else {
!                       lyr=new Layer(dlyr.w,dlyr.parent.elm);
!                       lyr.captureEvents(Event.LOAD);
!                       lyr.onload=function() {};
!               }
!       } else var 
parentElement=(dlyr.parent.isDynLayer)?dlyr.parent.elm:dlyr.parent.doc.body;
!       if (is.ie4) {
!               var code='<DIV id="'+dlyr.id+'" style="position:absolute; left:0px; 
top:0px; width:'+dlyr.w+'px;"></DIV>';
!               parentElement.insertAdjacentHTML("beforeEnd", code);
!               lyr=parentElement.children[parentElement.children.length-1];
!       } else if (is.ie5 || is.ns5) {
!               lyr=dlyr.dyndoc.doc.createElement("DIV");
!               lyr.style.position="absolute";
!               lyr.id=dlyr.id;
!               parentElement.appendChild(lyr);
!       }
!       DynLayer.flagPrecreate(dlyr);
!       DynLayer.assignElement(dlyr,lyr);
!       if (is.ns4) dlyr.elm.moveTo(dlyr.x,dlyr.y);
!       else {
!               dlyr.css.left=dlyr.x;
!               dlyr.css.top=dlyr.y;
!       }
!       if (dlyr.bgColor!=null) dlyr.setBgColor(dlyr.bgColor);
!       if (dlyr.bgImage!=null) dlyr.setBgImage(dlyr.bgImage)
!       else if (is.ie55 && dlyr.bgImage==null && dlyr.html==null) 
dlyr.setBgImage('javascript:null');
!       if (dlyr.clip!=null) {
!               if (is.ns4) {
!                       var c=dlyr.elm.clip;
!                       c.top=clip[0], c.right=clip[1], c.bottom=clip[2], 
c.left=clip[3];
!               } else {
!                       dlyr.setClip(dlyr.clip);
!               }
!       }
!       if (dlyr.z) dlyr.css.zIndex=dlyr.z;
!       dlyr.css.visibility=dlyr.visible? "inherit" : (is.ns4?"hide":"hidden");
!       if (dlyr.w!=null) dlyr.setWidth(dlyr.w, false);
!       if (dlyr.h!=null) dlyr.setHeight(dlyr.h, false);
!       if (dlyr.children.length>0) {
!               if (is.ns4) {
!                       dlyr.doc.write(dlyr.getInnerHTML());
!                       dlyr.doc.close();
!               } else if (is.ie || is.dom) {
!                       dlyr.setHTML(dlyr.getInnerHTML());
!               }
!               DynLayer.assignChildren(dlyr);
!       }
!       if (dlyr.html!=null && (dlyr.w==null || dlyr.h==null)) {
!               if (dlyr.w==null && dlyr.getContentWidth()>0) 
dlyr.setWidth(dlyr.getContentWidth(), false);
!               if (dlyr.h==null && dlyr.getContentHeight()>0) 
dlyr.setHeight(dlyr.getContentHeight(), false);
!       }
!       if (dlyr.hasEventListeners) dlyr.captureMouseEvents();
!       dlyr.created=true;
!       dlyr.invokeEvent("resize");
!       dlyr.invokeEvent('create');
! };
! DynLayer.deleteElement = function(dlyr) {
!       DynLayer.flagDeleteChildren(dlyr);
!       if (dlyr.elm) {
!               if (is.ns4) {
!                       dlyr.elm.visibility = "hide";
!                       dlyr.elm.releaseEvents(Event.LOAD);
!               } else {
!                       dlyr.elm.style.visibility = "hidden";
!                       dlyr.elm.innerHTML = "";
!                       dlyr.elm.outerHTML = "";
!                       if (is.ie5 && is.platform=="win32" && 
dlyr.elm.children.length>0) dlyr.elm.removeNode(true);
!               }
!       }
!       dlyr.elm = null;
!       dlyr.doc = null;
!       dlyr.css = null;
!       dlyr.created = false;
! };
! DynLayer.assignElement=function(dlyr,elm) {
!       dlyr.elm=elm;
!       if (is.ns4) {                   
!               dlyr.css=elm;
!               dlyr.doc=elm.document;
!               dlyr.doc.lyrobj=dlyr;
!       }
!       else if (is.ie || is.dom) {
!               dlyr.css=dlyr.elm.style;
!               dlyr.doc=dlyr.parent.doc;
!       }
!       dlyr.elm.lyrobj=dlyr;
  
!       if (is.ns4) for (i in dlyr.doc.images) dlyr.doc.images[i].lyrobj=dlyr;
!       if (is.ns5) for (i in dlyr.doc.images) dlyr.doc.images[i].lyrobj=dlyr.elm;
!       if (is.ie) for (i in dlyr.elm.all.tags("img")) 
dlyr.elm.all.tags("img")[i].lyrobj=dlyr;
  };
! DynLayer.assignChildren=function(dlyr) {
!       for (var i=0; i<dlyr.children.length; i++) {
!               var child=dlyr.children[i];
!               if (is.ns4) var elm=dlyr.doc.layers[child.id];
!               else if (is.ns5) var elm=dlyr.doc.getElementById(child.id);
!               else if (is.ie) var elm=dlyr.elm.all[child.id];
!               DynLayer.assignElement(child,elm);
!               DynLayer.assignChildren(child);
! 
!               if (child.html!=null && (child.w==null || child.h==null)) {
!                       if (child.w==null && child.getContentWidth()>0) 
child.setWidth(child.getContentWidth(),false);
!                       if (child.h==null && child.getContentHeight()>0) 
child.setHeight(child.getContentHeight(),false);
!               }
!               child.invokeEvent("resize");
! 
!               if (child.hasEventListeners && is.ns4) dlyr.captureMouseEvents();
!               
!               child.created=true;
!               child.invokeEvent('create');
!       }
  };
! DynLayer.flagPrecreate=function(dlyr) {
!       for (var i=0; i<dlyr.children.length;  i++) {
!               DynLayer.flagPrecreate(dlyr.children[i]);
!       }
!       dlyr.invokeEvent('precreate');
! }
! DynLayer.flagDeleteChildren=function(dlyr) { 
!       for (var i=0; i<dlyr.children.length; i++) {
!               if (dlyr.children[i].created) 
DynLayer.flagDeleteChildren(dlyr.children[i]);
!       }
  };
! // End Static Properties/Methods
  
! DynLayer.prototype.isDynLayer = true;
! DynLayer.prototype.getClass=function() {
        return this.constructor;
  };
***************
*** 58,62 ****
  DynLayer.prototype.addChildID=function() {
        for (var a=0;a<arguments.length;a++) {
!               var child=arguments[a];         //.getComponent();
                child.dyndoc=this.dyndoc;
                if (this.dyndoc.all[child.id]) {
--- 181,185 ----
  DynLayer.prototype.addChildID=function() {
        for (var a=0;a<arguments.length;a++) {
!               var child=arguments[a];
                child.dyndoc=this.dyndoc;
                if (this.dyndoc.all[child.id]) {
***************
*** 71,75 ****
  DynLayer.prototype.addChild=function() {
      for (var a=0;a<arguments.length;a++) {
!         var child=arguments[a];               //.getComponent();
          if (child.created) child.removeFromParent();
          child.parent=this;
--- 194,198 ----
  DynLayer.prototype.addChild=function() {
      for (var a=0;a<arguments.length;a++) {
!         var child=arguments[a];
          if (child.created) child.removeFromParent();
          child.parent=this;
***************
*** 77,81 ****
          if (this.dyndoc) this.addChildID(child);
          this.children[this.children.length]=child;
!         if (this.created) child.createElement(); //DynLayer_createElement(child);
      }
      return arguments[arguments.length-1];
--- 200,204 ----
          if (this.dyndoc) this.addChildID(child);
          this.children[this.children.length]=child;
!         if (this.created) DynLayer.createElement(child); 
      }
      return arguments[arguments.length-1];
***************
*** 83,92 ****
  DynLayer.prototype.removeChild=function() {
      for (var a=0;a<arguments.length;a++) {
!         var child=arguments[a];               //.getComponent();
          if (child.parent==this) {
                        DynAPI.removeFromArray(this.children,child);
              DynAPI.removeFromArray(this.dyndoc.all,child,true);
              DynLayer.unassigned[child.id]=child;
!             child.deleteElement();
              child.parent=null;
              child.isChild=false;
--- 206,215 ----
  DynLayer.prototype.removeChild=function() {
      for (var a=0;a<arguments.length;a++) {
!         var child=arguments[a];       
          if (child.parent==this) {
                        DynAPI.removeFromArray(this.children,child);
              DynAPI.removeFromArray(this.dyndoc.all,child,true);
              DynLayer.unassigned[child.id]=child;
!             DynLayer.deleteElement(child);
              child.parent=null;
              child.isChild=false;
***************
*** 100,104 ****
  DynLayer.prototype.deleteChild=function() {
      for (var a=0;a<arguments.length;a++) {
!         var child=arguments[a];               //.getComponent();
          if (child.parent == this) {
                        child.deleteAllChildren();
--- 223,227 ----
  DynLayer.prototype.deleteChild=function() {
      for (var a=0;a<arguments.length;a++) {
!         var child=arguments[a];       
          if (child.parent == this) {
                        child.deleteAllChildren();
***************
*** 110,114 ****
                  this.doc.recycled[this.doc.recycled.length]=child.elm;
              }
!             child.deleteElement();
              child.parent=null;
              child.isChild=false;
--- 233,237 ----
                  this.doc.recycled[this.doc.recycled.length]=child.elm;
              }
!             DynLayer.deleteElement(child);
              child.parent=null;
              child.isChild=false;
***************
*** 125,129 ****
                        
this.doc.recycled[this.doc.recycled.length]=this.children[i].elm;
                }
!         this.children[i].deleteElement();
                this.children[i].parent=null;
                this.children[i].isChild=false;
--- 248,252 ----
                        
this.doc.recycled[this.doc.recycled.length]=this.children[i].elm;
                }
!         DynLayer.deleteElement(this.children[i]);
                this.children[i].parent=null;
                this.children[i].isChild=false;
***************
*** 131,251 ****
      this.children=[];
  };
- 
  DynLayer.prototype.deleteFromParent=function() {
        this.parent.deleteChild(this)
  };
- 
- // DCP: Totall replacement of old code with precreation code, working in IE and NS 
and Mozilla
- 
- DynLayer.prototype.createElement=function() {
-       if (this.created||!this.parent||this.elm!=null) return;
-       if (this.parent.isDocument) this.dyndoc=this.parent;
-       else this.dyndoc=this.parent.dyndoc;
- 
-       var lyr;
-       if (is.ns4) {
-               var recycled=this.parent.doc.recycled;
-               if (recycled && recycled.length>0) {
-                       var lyr=recycled[0];
-                       DynAPI.removeFromArray(recycled,recycled[0]);
-               } else {
-                       lyr=new Layer(this.w,this.parent.elm);
-                       lyr.captureEvents(Event.LOAD);
-                       lyr.onload=function() {};
-               }
-       } else var 
parentElement=(this.parent.isDynLayer)?this.parent.elm:this.parent.doc.body;
-       if (is.ie4) {
-               var code='<DIV id="'+this.id+'" style="position:absolute; left:0px; 
top:0px; width:'+this.w+'px;"></DIV>';
-               parentElement.insertAdjacentHTML("beforeEnd", code);
-               lyr=parentElement.children[parentElement.children.length-1];
-       } else if (is.ie5 || is.ns5) {
-               lyr=this.dyndoc.doc.createElement("DIV");
-               lyr.style.position="absolute";
-               lyr.id=this.id;
-               parentElement.appendChild(lyr);
-       }
- 
-       for (var i=0; i<this.children.length; i++) 
this.children[i].invokeEvent('precreate');
-       this.invokeEvent('precreate');
-       this.assignElement(lyr);
-       
-       if (is.ns4) this.elm.moveTo(this.x,this.y);
-       else {
-               this.css.left=this.x;
-               this.css.top=this.y;
-       }
-       if (this.bgColor!=null) this.setBgColor(this.bgColor);
-       if (this.bgImage!=null) this.setBgImage(this.bgImage)
-       else if (is.ie55 && this.bgImage==null && this.html==null) 
this.setBgImage('javascript:null');
-       if (this.clip!=null) {
-               if (is.ns4) {
-                       var c=this.elm.clip;
-                       c.top=clip[0], c.right=clip[1], c.bottom=clip[2], 
c.left=clip[3];
-               } else {
-                       this.setClip(this.clip);
-               }
-       }
-       
-       if (this.z) this.css.zIndex=this.z;
-       this.css.visibility=this.visible? "inherit" : (is.ns4?"hide":"hidden");
-       if (this.w!=null) this.setWidth(this.w, false);
-       if (this.h!=null) this.setHeight(this.h, false);
-       if (is.ns4) {
-               this.doc.write(this.getInnerHTML());
-               this.doc.close();
-       } else if (is.ie || is.dom) {
-               this.setHTML(this.getInnerHTML());
-       }
-       this.assignChildren();
- 
-       if (this.html!=null && (this.w==null || this.h==null)) {
-               if (this.w==null && this.getContentWidth()>0) 
this.setWidth(this.getContentWidth(), false);
-               if (this.h==null && this.getContentHeight()>0) 
this.setHeight(this.getContentHeight(), false);
-       }
-       
-       if (this.hasEventListeners) this.captureMouseEvents();
- 
-       this.created=true;
-       this.invokeEvent("resize");
-       this.invokeEvent('create');
- }
- DynLayer.prototype.assignElement=function(elm) {
-       this.elm=elm;
-       if (is.ns4) {                   
-               this.css=elm;
-               this.doc=elm.document;
-               this.doc.lyrobj=this;
-       }
-       else if (is.ie || is.dom) {
-               this.css=this.elm.style;
-               this.doc=this.parent.doc;
-       }
-       this.elm.lyrobj=this;
- 
-       if (is.ns4) for (i in this.doc.images) this.doc.images[i].lyrobj=this;
-       if (is.ns5) for (i in this.doc.images) this.doc.images[i].lyrobj=this.elm;
-       if (is.ie) for (i in this.elm.all.tags("img")) 
this.elm.all.tags("img")[i].lyrobj=this;
- }
- DynLayer.prototype.assignChildren=function() {
-       for (var i=0; i<this.children.length; i++) {
-               var child=this.children[i];
-               if (is.ns4) var elm=this.doc.layers[child.id];
-               else if (is.ns5) var elm=this.doc.getElementById(child.id);
-               else if (is.ie) var elm=this.elm.all[child.id];
-               child.assignElement(elm);
-               child.assignChildren();
- 
-               if (child.html!=null && (child.w==null || child.h==null)) {
-                       if (child.w==null && child.getContentWidth()>0) 
child.setWidth(child.getContentWidth(),false);
-                       if (child.h==null && child.getContentHeight()>0) 
child.setHeight(child.getContentHeight(),false);
-               }
-               child.invokeEvent("resize");
- 
-               if (child.hasEventListeners && is.ns4) this.captureMouseEvents();
-               
-               child.created=true;
-               child.invokeEvent('create');
-       }
- }
  DynLayer.prototype.getInnerHTML=function() {
        var s="";
--- 254,260 ----
***************
*** 253,257 ****
        for (var i=0; i<this.children.length;  i++) 
s+=this.getOuterHTML(this.children[i]);
        return s;
! }
  if (is.ns4) {
        DynLayer.prototype.getOuterHTML=function(dlyr) {
--- 262,266 ----
        for (var i=0; i<this.children.length;  i++) 
s+=this.getOuterHTML(this.children[i]);
        return s;
! };
  if (is.ns4) {
        DynLayer.prototype.getOuterHTML=function(dlyr) {
***************
*** 273,277 ****
                s+='</layer>';
                return s;
!       }
  } else {
        DynLayer.prototype.getOuterHTML=function(dlyr) {
--- 282,286 ----
                s+='</layer>';
                return s;
!       };
  } else {
        DynLayer.prototype.getOuterHTML=function(dlyr) {
***************
*** 293,323 ****
                s+='</div>';
                return s;
!       }
! }
! 
! DynLayer.prototype.deleteElement = function() {
!       DynLayer_flagDeleteChildren(this);
!       if (this.elm) {
!               if (is.ns4) {
!                       this.elm.visibility = "hide";
!                       this.elm.releaseEvents(Event.LOAD);
!               } else {
!                       this.elm.style.visibility = "hidden";
!                       this.elm.innerHTML = "";
!                       this.elm.outerHTML = "";
!                       if (is.ie5 && is.platform=="win32" && 
this.elm.children.length>0) this.elm.removeNode(true);
!               }
!       }
!       this.elm = null;
!       this.doc = null;
!       this.css = null;
!       this.created = false;
  };
- function DynLayer_flagDeleteChildren(dlyr) { 
-       for (var i=0; i<dlyr.children.length; i++) {
-               if (dlyr.children[i].created) 
DynLayer_flagDeleteChildren(dlyr.children[i]);
-       }
- };
- 
  DynLayer.prototype.setStyle=function (s) {
        var 
id=s.id,x=s.left,y=s.top,w=s.width,h=s.height,i=s.backgroundImage,c=s.backgroundColor,v=s.visibility,z=s.zIndex;
--- 302,307 ----
                s+='</div>';
                return s;
!       };
  };
  DynLayer.prototype.setStyle=function (s) {
        var 
id=s.id,x=s.left,y=s.top,w=s.width,h=s.height,i=s.backgroundImage,c=s.backgroundColor,v=s.visibility,z=s.zIndex;

Index: dyndocument.js
===================================================================
RCS file: /cvsroot/dynapi/dynapi/src/lib/dynapi/api/dyndocument.js,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** dyndocument.js      2001/01/07 00:18:08     1.5
--- dyndocument.js      2001/01/08 04:50:57     1.6
***************
*** 35,39 ****
  };
  DynDocument.prototype.getClass = DynLayer.prototype.getClass;
- //DynDocument.prototype.getComponent = DynLayer.prototype.getComponent;
  DynDocument.prototype.addChild = DynLayer.prototype.addChild;
  DynDocument.prototype.removeChild = DynLayer.prototype.removeChild;
--- 35,38 ----
***************
*** 50,55 ****
        }
      for (var i=0; i<this.children.length; i++) { 
!         this.children[i].deleteElement();
!         this.children[i].createElement();
      }
  };
--- 49,54 ----
        }
      for (var i=0; i<this.children.length; i++) { 
!         DynLayer.deleteElement(this.children[i]);
!         DynLayer.createElement(this.children[i]);
      }
  };


_______________________________________________
Dynapi-CVS mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-cvs

Reply via email to