Update of /cvsroot/dynapi/dynapi3x/src/api
In directory sc8-pr-cvs1:/tmp/cvs-serv30194/src/api

Modified Files:
        dyndocument.js dynlayer_dom.js dynlayer_ie.js dynlayer_ns4.js 
        dynlayer_opera.js event.js 
Log Message:
uploaded by raymond (with changes made by Benoit)

Index: dyndocument.js
===================================================================
RCS file: /cvsroot/dynapi/dynapi3x/src/api/dyndocument.js,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** dyndocument.js      25 Feb 2003 21:45:16 -0000      1.3
--- dyndocument.js      5 Mar 2003 04:36:16 -0000       1.4
***************
*** 61,65 ****
  };
  p.insertChild = function(c) {
!       if (c.parent == this) {
                DynElement._flagEvent(c,'precreate');
                this.doc.write(c.getOuterHTML());
--- 61,65 ----
  };
  p.insertChild = function(c) {
!       if (c && !c.isInline && c.parent == this) {
                DynElement._flagEvent(c,'precreate');
                this.doc.write(c.getOuterHTML());
***************
*** 68,77 ****
  };
  p.insertAllChildren = function() {
!       var c,str =[''];
!       for (var i=0;i<this.children.length;i++) {
!               c = this.children[i];
!               DynElement._flagEvent(c,'precreate');
!               str[str.length]=c.getOuterHTML();
!               c._inserted = true;
        }
        this.doc.write(str.join('\n'));
--- 68,80 ----
  };
  p.insertAllChildren = function() {
!       var i,c,str =[''];
!       var ch=this.children;
!       for(i=0;i<ch.length;i++) {
!               c = ch[i];
!               if(!c.isInline){
!                       DynElement._flagEvent(c,'precreate');
!                       str[i]=c.getOuterHTML();
!                       c._inserted = true;
!               }
        }
        this.doc.write(str.join('\n'));
***************
*** 79,84 ****
  };
  p._create = function() {
        this._created = true;
!       if (dynapi.ua.ns4) {
                this.css = this.doc;
                this.elm = this.doc;
--- 82,88 ----
  };
  p._create = function() {
+       var ua=dynapi.ua;
        this._created = true;
!       if (ua.ns4) {
                this.css = this.doc;
                this.elm = this.doc;
***************
*** 87,91 ****
                this.elm = this.frame.document.body;
                this.css = this.frame.document.body.style;
!               if (dynapi.ua.ie) {
                        this._overflow = this.css.overflow || '';
                }
--- 91,95 ----
                this.elm = this.frame.document.body;
                this.css = this.frame.document.body.style;
!               if (ua.ie) {
                        this._overflow = this.css.overflow || '';
                }
***************
*** 95,108 ****
        this.doc._dynobj = this; // DynKeyEvent needs this!
        this.findDimensions();
!       for (var i=0;i<this.children.length;i++) {
!               if (this.children[i]._inserted) {
!                       DynLayer._assignElement(this.children[i]);
!                       DynElement._flagEvent(this.children[i],'create');
                }
-               else this.children[i]._create();
        }
        this._updateAnchors();  
  
!       if(dynapi.ua.ie && this._textSelectable==false) this.doc.onselectstart = 
dynapi.functions.Deny;
        
        if (this.captureMouseEvents) this.captureMouseEvents();
--- 99,126 ----
        this.doc._dynobj = this; // DynKeyEvent needs this!
        this.findDimensions();
! 
!       var divs;
!       // create divs object - speeds up DOM browsers on win32. Linux & Mac?
!       if (ua.win32 && (ua.ie||ua.dom)) {
!               divs={} 
!               var dv,all=(ua.ie||ua.opera)? document.all.tags('div') : 
document.getElementsByTagName('div');
!               var i=0,l=all.length; // very important!
!               while (i<l){
!                       dv=all[i];
!                       divs[dv.id]=dv;
!                       i++;
                }
        }
+       
+       var c,ch=this.children;
+       for(i=0;i<ch.length;i++){
+               c=ch[i];
+               if (c._inserted) c._createInserted(divs);
+               else if(c.isInline) c._createInline(divs);
+               else c._create();
+       };
        this._updateAnchors();  
  
!       if(ua.ie && this._textSelectable==false) this.doc.onselectstart = 
dynapi.functions.Deny;
        
        if (this.captureMouseEvents) this.captureMouseEvents();

Index: dynlayer_dom.js
===================================================================
RCS file: /cvsroot/dynapi/dynapi3x/src/api/dynlayer_dom.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** dynlayer_dom.js     25 Feb 2003 21:38:17 -0000      1.2
--- dynlayer_dom.js     5 Mar 2003 04:36:16 -0000       1.3
***************
*** 57,61 ****
                this.elm.outerHTML = ""; // ??
                this.elm = null;
!               this.releaseMouseEvents();
                if (this.releaseKeyEvents) this.releaseKeyEvents();
        }
--- 57,61 ----
                this.elm.outerHTML = ""; // ??
                this.elm = null;
!               if (this.releaseMouseEvents) this.releaseMouseEvents();
                if (this.releaseKeyEvents) this.releaseKeyEvents();
        }
***************
*** 85,90 ****
        }
  };
! DynLayer._assignElement = function(dlyr,elm) {
!       if (!elm) elm = dlyr.parent.doc.getElementById(dlyr.id);
        dlyr.elm = elm;
        dlyr.css = elm.style;
--- 85,95 ----
        }
  };
! p._createInserted = function(divs){
!       DynLayer._assignElement(this,null,divs);
!       DynElement._flagEvent(this,'create');
! };
! DynLayer._assignElement = function(dlyr,elm,divs) {
!       if (!elm ) elm = (divs)? divs[dlyr.id] : 
dlyr.parent.doc.getElementById(dlyr.id);
!       //if (!elm) elm = dlyr.parent.doc.getElementById(dlyr.id);
        dlyr.elm = elm;
        dlyr.css = elm.style;

Index: dynlayer_ie.js
===================================================================
RCS file: /cvsroot/dynapi/dynapi3x/src/api/dynlayer_ie.js,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** dynlayer_ie.js      25 Feb 2003 21:38:18 -0000      1.3
--- dynlayer_ie.js      5 Mar 2003 04:36:16 -0000       1.4
***************
*** 27,31 ****
        
        if (html!=null) this.setHTML(html);
!               
  };
  var p = dynapi.setPrototype('DynLayer','DynElement');
--- 27,31 ----
        
        if (html!=null) this.setHTML(html);
!  
  };
  var p = dynapi.setPrototype('DynLayer','DynElement');
***************
*** 59,63 ****
                this.elm.outerHTML = "";
                this.elm = null;
!               this.releaseMouseEvents();
                if (this.releaseKeyEvents) this.releaseKeyEvents();
        }
--- 59,63 ----
                this.elm.outerHTML = "";
                this.elm = null;
!               if (this.releaseMouseEvents) this.releaseMouseEvents();
                if (this.releaseKeyEvents) this.releaseKeyEvents();
        }
***************
*** 84,89 ****
        }
  };
! DynLayer._assignElement = function(dlyr,elm) {
!       if (!elm) elm = dlyr.parent.elm.all[dlyr.id];
        dlyr.elm = elm;
        dlyr.css = elm.style;
--- 84,93 ----
        }
  };
! p._createInserted = function(divs){
!       DynLayer._assignElement(this,null,divs);
!       DynElement._flagEvent(this,'create');
! };
! DynLayer._assignElement = function(dlyr,elm,divs) {
!       if (!elm ) elm = (divs)? divs[dlyr.id] : dlyr.parent.elm.all[dlyr.id];
        dlyr.elm = elm;
        dlyr.css = elm.style;
***************
*** 99,104 ****
        }
  
!       for (var i=0; i<dlyr.children.length; i++) {
!               DynLayer._assignElement(dlyr.children[i]);
        }
  
--- 103,110 ----
        }
  
!       var i=0,ch=dlyr.children; 
!       while (i<ch.length) {
!               DynLayer._assignElement(ch[i]);
!               i++;
        }
  
***************
*** 241,247 ****
  
  p.getInnerHTML=function() {
!       var i,s = '';
        if (this.html!=null) s+=this.html;
!       for (i=0;i<this.children.length;i++) s+=this.children[i].getOuterHTML();
        return s;
  };
--- 247,257 ----
  
  p.getInnerHTML=function() {
!       var s = '';
!       var ch=this.children,i=0;
        if (this.html!=null) s+=this.html;
!       while (i<ch.length) {
!               s+=ch[i].getOuterHTML();
!               i++;
!       };
        return s;
  };

Index: dynlayer_ns4.js
===================================================================
RCS file: /cvsroot/dynapi/dynapi3x/src/api/dynlayer_ns4.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** dynlayer_ns4.js     25 Feb 2003 21:38:18 -0000      1.2
--- dynlayer_ns4.js     5 Mar 2003 04:36:16 -0000       1.3
***************
*** 56,60 ****
                this.elm.visibility="hide";
                this.elm = null;
!               this.releaseMouseEvents();
                if (this.releaseKeyEvents) this.releaseKeyEvents();
        }
--- 56,60 ----
                this.elm.visibility="hide";
                this.elm = null;
!               if (this.releaseMouseEvents) this.releaseMouseEvents();
                if (this.releaseKeyEvents) this.releaseKeyEvents();
        }
***************
*** 95,98 ****
--- 95,102 ----
                DynElement._flagEvent(this,'create');
        }
+ };
+ p._createInserted = function(){
+       DynLayer._assignElement(this,null);
+       DynElement._flagEvent(this,'create');
  };
  DynLayer._assignElement = function(dlyr,elm) {

Index: dynlayer_opera.js
===================================================================
RCS file: /cvsroot/dynapi/dynapi3x/src/api/dynlayer_opera.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** dynlayer_opera.js   25 Feb 2003 21:38:19 -0000      1.2
--- dynlayer_opera.js   5 Mar 2003 04:36:16 -0000       1.3
***************
*** 60,64 ****
                this.elm.outerHTML = "";
                this.elm = null;
!               this.releaseMouseEvents();
                if (this.releaseKeyEvents) this.releaseKeyEvents();
        }
--- 60,64 ----
                this.elm.outerHTML = "";
                this.elm = null;
!               if (this.releaseMouseEvents) this.releaseMouseEvents();
                if (this.releaseKeyEvents) this.releaseKeyEvents();
        }
***************
*** 85,90 ****
        }
  };
! DynLayer._assignElement = function(dlyr,elm) {
!       if (!elm) elm = dlyr.parent.elm.all[dlyr.id];
        dlyr.elm = elm;
        dlyr.css = elm.style;
--- 85,95 ----
        }
  };
! p._createInserted = function(divs){
!       DynLayer._assignElement(this,null,divs);
!       DynElement._flagEvent(this,'create');
! };
! DynLayer._assignElement = function(dlyr,elm,divs) {
!       if (!elm ) elm = (divs)? divs[dlyr.id] : dlyr.parent.elm.all[dlyr.id];
! //    if (!elm) elm = dlyr.parent.elm.all[dlyr.id];
        dlyr.elm = elm;
        dlyr.css = elm.style;

Index: event.js
===================================================================
RCS file: /cvsroot/dynapi/dynapi3x/src/api/event.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** event.js    25 Feb 2003 21:38:19 -0000      1.2
--- event.js    5 Mar 2003 04:36:16 -0000       1.3
***************
*** 1 ****
! /*
        DynAPI Distribution
        DynEvent, EventObject, DynElement Classes

        The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/

function DynEvent(type,src) {
        this.DynObject = DynObject;
        this.DynObject();
        this.type = type;
        this.src = src;
        this.origin = src;
        this.propagate = true;
        this.bubble = false;
        this.bubbleChild = null;
        this.defaultValue = true;

        this._trapAlerts=null;  
};
var p = dynapi.setPrototype('DynEvent','DynObject');

p.getType = function() {return this.type};
p.getSource = function() {return this.src};
p.getOrigin=function() {return this.origin};
p.stopPropagation = function() {this.propagate = false};
p.preventBubble = function() {this.bubble = false};
p.preventDefault = function() {this.defaultValue = false};
p.getBubbleChild = function() {return this.bubbleChild};

function EventObject() {
        this.DynObject = DynObject;
        this.DynObject();
        this._listeners = [];
}
EventObject._SubClass={};

p = dynapi.setPrototype('EventObject','DynObject');
p.addEventListener = function(el) {
        if (el) {
                for (var i=0;i<this._listeners.length;i++) if (this._listeners[i]==el) 
return;
                this._listeners[this._listeners.length] = el;           
                this._hasCreateEvent=(el['oncreate'])? true:this._hasCreateEvent;
                this._hasPrecreateEvent=(el['onprecreate'])? 
true:this._hasPrecreateEvent;              
                this._hasDragEvents=(el['ondragstart']||el['ondragmove']||
                                                        
el['ondragend']||el['ondragdrop']||
                                                        
el['ondragover']||el['ondragout'])? true:this._hasDragEvents;                          
                                 

                if (this.captureMouseEvents) {
                        if (this._created && !this._hasMouseEvents && (el.onmousedown 
|| el.onmouseup || el.onmouseover || el.onmouseout || el.onclick || el.ondblclick)) {
                                this.captureMouseEvents();
                        }
                        else this._hasMouseEvents = true;
                }
                if (this.captureKeyEvents) {
                        if (this._created && !this._hasKeyEvents && (el.onkeydown || 
el.onkeyup || el.keypress)) {
                                this.captureKeyEvents();
                        }
                        else this._hasKeyEvents = true;
                }
        }
};
p.removeEventListener = function(el) {
        if (el) {
                DynAPI.functions.removeFromArray(this._listeners, el, false);
                if (!this._listeners.length && this.releaseMouseEvents && 
this.getClassName()!='DynDocument') this.releaseMouseEvents();
                if (!this._listeners.length && this.releaseKeyEvents && 
this.getClassName()!='DynDocument') this.releaseKeyEvents();
        }
};
p.removeAllEventListeners = function() {
        this._listeners = [];
};
p.invokeEvent = function(type,e,args) {
        if (!e) e = new DynEvent(type,this);
        e.src = this;
        e.type = type;
        
        // Check for subclassing
        var clsFn=EventObject._SubClass[this+'_'+type];
        if(clsFn) {
                if (clsFn(e,args)==false) return;
        };
        
        if (this._listeners.length) for (var i=0;i<this._listeners.length;i++) {
                if (this._listeners[i]["on"+type]) 
this._listeners[i]["on"+type](e,args);
                if (!e.propagate) break;
        }
        if (this["on"+type]) this["on"+type](e,args);
        if (e.bubble && this.parent) {
                //if ((type=="mouseover" || type=="mouseout") && 
e._relative==this.parent) return;
                e.x += this.x;
                e.y += this.y;
                e.bubbleChild = this;
                this.parent.invokeEvent(type,e,args);
        }
};

// Add subClassEvent() function to dynapi.functions
dynapi.functions.subClassEvent = function(type,eobj,fn){
        var ek=eobj+'_'+type;
        var cls=EventObject._SubClass;
        if(typeof(fn)=='function') cls[ek]=fn;
        else if(!fn && cls[ek]) delete(cls[ek])
};

function DynElement() {
        this.EventObject = EventObject;
        this.EventObject();
        this.isChild = false;
        this._created = false;
        this.parent = null;
        this._dyndoc = null;
        this.children = [];
        this._childAnchors = [];
};
DynElement._flagEvent = function(c,type) {
        var ok=false;
        if (type=="create") c._created = true;
        // Raise onCreate/onPreCreate callback Flag
        if((c._hasPCreateFn||c._hasCreateFn) && (type=='precreate'||type=='create')) {
                ok=true; 
                c._flagCreateEvent(type);       
        }
        if(!ok){
                //to speed up creation skip invokeEvent if precreate or create events 
where not registered
                if(type=='precreate' && (c._hasPrecreateEvent || c['onprecreate'])) 
ok=true;
                else if(type=='create' && (c._hasCreateEvent || c['oncreate'])) 
ok=true;
                else if(type!='create' && type!='precreate') ok=true;
                if(ok) c.invokeEvent(type);
        }
        for (var i=0; i<c.children.length; i++) {
                DynElement._flagEvent(c.children[i],type);
        }
};
p = dynapi.setPrototype('DynElement','EventObject');
p.addChild = function(c,alias) {
        if (!c) return dynapi.debug.print("Error: no object sent to 
[DynLayer].addChild()");
        if (c.isChild) c.removeFromParent();
        c.isChild = true;
        c.parent = this;
        if (c._saveAnchor) {
                c.setAnchor(c._saveAnchor);
                delete c._saveAnchor;
        }
        if(alias) this[alias]=c;
        if (this._created) c._create();
        this.children[this.children.length] = c;
        return c;
};
p.removeChild = function(c) {
        var l = this.children.length;
        for (var i=0;i<l && this.children[i]!=c;i++);
        if (i!=l) {
                c._remove();
                c._created = false;
                c.isChild = false;
                c.parent = null;
                c.dyndoc = null;
                this.children[i] = this.children[l-1];
                this.children[l-1] = null;
                this.children.length--;
        }
};
p.deleteChild = function(c) {
        c.removeFromParent();
        c._delete();
};
p.deleteAllChildren = function() {
        var l = this.children.length;
        for(var i=0;i<l;i++) {
                this.children[i].del();
                delete this.children[i];
        }
        this.children = [];
};
p.deleteFromParent = function () {
        if (this.parent) this.parent.deleteChild(this);
};
p.removeFromParent = function () {
        if (this.parent) this.parent.removeChild(this);
};
p._create = p._remove = p._delete = p._destroy = dynapi.functions.Null;

p.getChildren = function() {return this.children}
p.getAllChildren = function() {
        var ret = [];
        var temp;
        var l = this.children.length;
        for(var i=0;i<l;i++) {
                ret[this.children[i].id] = this.children[i];
                temp = this.children[i].getAll();
                for(var j in temp) ret[j] = temp[j];
        }
        return ret
};
p.getParents = function(l) {
        if (l==null) l = [];
        if (this.parent) {
                l[l.length] = this.parent;
                l = this.parent.getParents(l);
        }
        return l;
};
p.isParentOf = function(c) {
        if (c) {
                var p = c.getParents();
                for (var i=0;i<p.length;i++) {
                        if (p[i]==this) return true;
                }
        }
        return false;
};
p.isChildOf = function(p) {
        if (!p) return false;
        return p.isParentOf(this);
};
// New onPreCreate() and onCreate() callback functions
p.onCreate = function(fn){
        if(!this._cfn){this._fn=0;this._cfn={};}
        var s='create'+this._fn++;
        this._cfn[s]='create';
        this._hasCreateFn=true;
        this[s]=fn;
};
p.onPreCreate = function(fn){
        if(!this._cfn){this._fn=0;this._cfn={};}
        var s='precreate'+this._fn++;
        this._cfn[s]='precreate';
        this._hasPCreateFn=true;
        this[s]=fn;
};
p._flagCreateEvent = function(s){
        for(var i in this._cfn){ 
                if(this._cfn[i]==s) this[i]();
        };
};

p.updateAnchor = function() {
        this.parent._updateAnchor(this.id);
};
p._updateAnchor = function(id) {
        if (!id) return;
        var dlyr = DynObject.all[id];
        var a = this._childAnchors[id];
        var tw = this.w;
        var th = this.h;
        if (tw==null && th==null) return;
        
        // anchoring/docking
        var fn=dynapi.functions;
        var padX=0,padY=0;
        if(a.topA) {
                anc=fn.getAnchorLocation(a.topA,this);
                if(anc){padY=anc.y; th=th-padY;}
        }
        if(a.leftA) {
                anc=(a.leftA==a.topA && anc)? anc:fn.getAnchorLocation(a.leftA,this);
                if(anc) {padX=anc.x; tw=tw-padX;}
        }
        if(a.bottomA) {
                anc=fn.getAnchorLocation(a.bottomA,this);
                th=th-(this.h-anc.y);
        }
        if(a.rightA) {
                anc=(a.bottomA==a.rightA && anc)? 
anc:fn.getAnchorLocation(a.rightA,this);
                if(anc) tw=tw-(this.w-anc.x);                           
        }
        
        var aleft=(tw>0 && a.left && typeof(a.left)=='string')? 
tw*(parseInt(a.left)/100):a.left;
        var aright=(tw>0 && a.right && typeof(a.right)=='string')? 
tw*(parseInt(a.right)/100):a.right;
        var atop=(th>0 && a.top && typeof(a.top)=='string')? 
th*(parseInt(a.top)/100):a.top;
        var abottom=(th>0 && a.bottom && typeof(a.bottom)=='string')? 
th*(parseInt(a.bottom)/100):a.bottom;
        var x = aleft;
        var y = atop;
        var w = null;
        var h = null;
        var dlyrWidth=dlyr.getWidth();
        var dlyrHeight=dlyr.getHeight();
        if (a.stretchH!=null) {
                if(typeof(a.stretchH)!='string') w=a.stretchH;
                else {
                        if(a.stretchH=='*') w = tw - ((aleft!=null)? aleft:0);
                        else w = tw*(parseInt(a.stretchH)/100);
                }
                dlyrWidth=w;
        }
        if (a.centerH!=nu
ll) {
                x = Math.ceil(tw/2 - dlyrWidth/2 + a.centerH);
        }else if (aright!=null) {
                if (aleft!=null) w = (tw - aright) - aleft;
                else x = (tw - dlyrWidth) - aright;
                if(tw<=0 && x<0) x=null; // ns4 needs x>=0
        }       
        if (a.stretchV!=null) {
                if(typeof(a.stretchV)!='string') h=a.stretchV;
                else {
                        if(a.stretchV=='*') h = th - ((atop!=null)? atop:0);
                        else h = th*(parseInt(a.stretchV)/100);
                }
                dlyrHeight=h;
        }       
        if (a.centerV!=null) {
                y = Math.ceil(th/2 - dlyrHeight/2 + a.centerV);
        }else if (abottom!=null) {
                if (atop!=null) h = (th - abottom) - atop;
                else y = (th - dlyrHeight) - abottom;
                if(th<=0 && y<0) y=null; // ns4 needs y>=0
        }
        if(padX) {x=(x)? x:0;x+=padX}
        if(padY) {y=(y)? y:0;y+=padY}
        if(x!=null||y!=null) dlyr.setLocation(x,y);
        if(w!=null||h!=null) dlyr.setSize(w,h);
};
p._updateAnchors = function() {
        var tw = this.w;
        var th = this.h;
        if (tw==null && th==null) return;
        for (id in this._childAnchors) this._updateAnchor(id);
};


// bandwidth timer stop
var ua=dynapi.ua; ua._bwe=new Date;
ua.broadband=((ua._bwe-ua._bws)<=1500)? true:false;
\ No newline at end of file
--- 1 ----
! /*
        DynAPI Distribution
        DynEvent, EventObject, DynElement Classes

        The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
*/

function DynEvent(type,src) {
        this.DynObject = DynObject;
        this.DynObject();
        this.type = type;
        this.src = src;
        this.origin = src;
        this.propagate = true;
        this.bubble = false;
        this.bubbleChild = null;
        this.defaultValue = true;

        this._trapAlerts=null;  
};
var p = dynapi.setPrototype('DynEvent','DynObject');

p.getType = function() {return this.type};
p.getSource = function() {return this.src};
p.getOrigin=function() {return this.origin};
p.stopPropagation = function() {this.propagate = false};
p.preventBubble = function() {this.bubble = false};
p.preventDefault = function() {this.defaultValue = false};
p.getBubbleChild = function() {return this.bubbleChild};

function EventObject() {
        this.DynObject = DynObject;
        this.DynObject();
        this._listeners = [];
}
EventObject._SubClass={};

p = dynapi.setPrototype('EventObject','DynObject');
p.addEventListener = function(el) {
        if (el) {
                for (var i=0;i<this._listeners.length;i++) if (this._listeners[i]==el) 
return;
                this._listeners[this._listeners.length] = el;           
                this._hasCreateEvent=(el['oncreate'])? true:this._hasCreateEvent;
                this._hasPrecreateEvent=(el['onprecreate'])? 
true:this._hasPrecreateEvent;              
                this._hasDragEvents=(el['ondragstart']||el['ondragmove']||
                                                        
el['ondragend']||el['ondragdrop']||
                                                        
el['ondragover']||el['ondragout'])? true:this._hasDragEvents;                          
                                 

                if (this.captureMouseEvents) {
                        if (this._created && !this._hasMouseEvents && (el.onmousedown 
|| el.onmouseup || el.onmouseover || el.onmouseout || el.onclick || el.ondblclick)) {
                                this.captureMouseEvents();
                        }
                        else this._hasMouseEvents = true;
                }
                if (this.captureKeyEvents) {
                        if (this._created && !this._hasKeyEvents && (el.onkeydown || 
el.onkeyup || el.keypress)) {
                                this.captureKeyEvents();
                        }
                        else this._hasKeyEvents = true;
                }
        }
};
p.removeEventListener = function(el) {
        if (el) {
                DynAPI.functions.removeFromArray(this._listeners, el, false);
                if (!this._listeners.length && this.releaseMouseEvents && 
this.getClassName()!='DynDocument') this.releaseMouseEvents();
                if (!this._listeners.length && this.releaseKeyEvents && 
this.getClassName()!='DynDocument') this.releaseKeyEvents();
        }
};
p.removeAllEventListeners = function() {
        this._listeners = [];
};
p.invokeEvent = function(type,e,args) {
        if (!e) e = new DynEvent(type,this);
        e.src = this;
        e.type = type;
        
        // Check for subclassing
        var clsFn=EventObject._SubClass[this+'_'+type];
        if(clsFn) {
                if (clsFn(e,args)==false) return;
        };
        
        if (this._listeners.length) for (var i=0;i<this._listeners.length;i++) {
                if (this._listeners[i]["on"+type]) 
this._listeners[i]["on"+type](e,args);
                if (!e.propagate) break;
        }
        if (this["on"+type]) this["on"+type](e,args);
        if (e.bubble && this.parent) {
                //if ((type=="mouseover" || type=="mouseout") && 
e._relative==this.parent) return;
                e.x += this.x;
                e.y += this.y;
                e.bubbleChild = this;
                this.parent.invokeEvent(type,e,args);
        }
};

// Add subClassEvent() function to dynapi.functions
dynapi.functions.subClassEvent = function(type,eobj,fn){
        var ek=eobj+'_'+type;
        var cls=EventObject._SubClass;
        if(typeof(fn)=='function') cls[ek]=fn;
        else if(!fn && cls[ek]) delete(cls[ek])
};

function DynElement() {
        this.EventObject = EventObject;
        this.EventObject();
        this.isChild = false;
        this._created = false;
        this.parent = null;
        this._dyndoc = null;
        this.children = [];
        this._childAnchors = [];
};
DynElement._flagEvent = function(c,type) {
        var ok=false;
        if (type=="create") c._created = true;
        // Raise onCreate/onPreCreate callback Flag
        if((c._hasPCreateFn||c._hasCreateFn) && (type=='precreate'||type=='create')) {
                ok=true; 
                c._flagCreateEvent(type);       
        }
        if(!ok){
                //to speed up creation skip invokeEvent if precreate or create events 
where not registered
                if(type=='precreate' && (c._hasPrecreateEvent || c['onprecreate'])) 
ok=true;
                else if(type=='create' && (c._hasCreateEvent || c['oncreate'])) 
ok=true;
                else if(type!='create' && type!='precreate') ok=true;
                if(ok) c.invokeEvent(type);
        }
        for (var i=0; i<c.children.length; i++) {
                DynElement._flagEvent(c.children[i],type);
        }
};
p = dynapi.setPrototype('DynElement','EventObject');
p.addChild = function(c,alias,inlineID) {
        if (!c) return dynapi.debug.print("Error: no object sent to 
[DynLayer].addChild()");
        if (c.isChild) c.removeFromParent();
        c.isChild = true;
        c.parent = this;
        if (c._saveAnchor) {
                c.setAnchor(c._saveAnchor);
                delete c._saveAnchor;
        }
        if(alias) this[alias]=c;
        if(inlineID) c.setID(inlineID,true);
        if (this._created)      {
                if (c.isInline) c._createInline();
                else c._create();
        }
        this.children[this.children.length] = c;
        return c;
};
p.removeChild = function(c) {
        var l = this.children.length;
        for (var i=0;i<l && this.children[i]!=c;i++);
        if (i!=l) {
                c._remove();
                c._created = false;
                c.isChild = false;
                c.parent = null;
                c.dyndoc = null;
                this.children[i] = this.children[l-1];
                this.children[l-1] = null;
                this.children.length--;
        }
};
p.deleteChild = function(c) {
        c.removeFromParent();
        c._delete();
};
p.deleteAllChildren = function() {
        var l = this.children.length;
        for(var i=0;i<l;i++) {
                this.children[i].del();
                delete this.children[i];
        }
        this.children = [];
};
p.deleteFromParent = function () {
        if (this.parent) this.parent.deleteChild(this);
};
p.removeFromParent = function () {
        if (this.parent) this.parent.removeChild(this);
};
p._create = p._createInLine = p._createInserted = p._remove = p._delete = p._destroy = 
dynapi.functions.Null;

p.getChildren = function() {return this.children}
p.getAllChildren = function() {
        var ret = [];
        var temp;
        var l = this.children.length;
        for(var i=0;i<l;i++) {
                ret[this.children[i].id] = this.children[i];
                temp = this.children[i].getAll();
                for(var j in temp) ret[j] = temp[j];
        }
        return ret
};
p.getParents = function(l) {
        if (l==null) l = [];
        if (this.parent) {
                l[l.length] = this.parent;
                l = this.parent.getParents(l);
        }
        return l;
};
p.isParentOf = function(c) {
        if (c) {
                var p = c.getParents();
                for (var i=0;i<p.length;i++) {
                        if (p[i]==this) return true;
                }
        }
        return false;
};
p.isChildOf = function(p) {
        if (!p) return false;
        return p.isParentOf(this);
};
// New onPreCreate() and onCreate() callback functions
p.onCreate = function(fn){
        if(!this._cfn){this._fn=0;this._cfn={};}
        var s='create'+this._fn++;
        this._cfn[s]='create';
        this._hasCreateFn=true;
        this[s]=fn;
};
p.onPreCreate = function(fn){
        if(!this._cfn){this._fn=0;this._cfn={};}
        var s='precreate'+this._fn++;
        this._cfn[s]='precreate';
        this._hasPCreateFn=true;
        this[s]=fn;
};
p._flagCreateEvent = function(s){
        for(var i in this._cfn){ 
                if(this._cfn[i]==s) this[i]();
        };
};

p.updateAnchor = function() {
        this.parent._updateAnchor(this.id);
};
p._updateAnchor = function(id) {
        if (!id) return;
        var dlyr = DynObject.all[id];
        var a = this._childAnchors[id];
        var tw = this.w;
        var th = this.h;
        if (tw==null && th==null) return;
        
        // anchoring/docking
        var fn=dynapi.functions;
        var padX=0,padY=0;
        if(a.topA) {
                anc=fn.getAnchorLocation(a.topA,this);
                if(anc){padY=anc.y; th=th-padY;}
        }
        if(a.leftA) {
                anc=(a.leftA==a.topA && anc)? anc:fn.getAnchorLocation(a.leftA,this);
                if(anc) {padX=anc.x; tw=tw-padX;}
        }
        if(a.bottomA) {
                anc=fn.getAnchorLocation(a.bottomA,this);
                th=th-(this.h-anc.y);
        }
        if(a.rightA) {
                anc=(a.bottomA==a.rightA && anc)? 
anc:fn.getAnchorLocation(a.rightA,this);
                if(anc) tw=tw-(this.w-anc.x);                           
        }
        
        var aleft=(tw>0 && a.left && typeof(a.left)=='string')? 
tw*(parseInt(a.left)/100):a.left;
        var aright=(tw>0 && a.right && typeof(a.right)=='string')? 
tw*(parseInt(a.right)/100):a.right;
        var atop=(th>0 && a.top && typeof(a.top)=='string')? 
th*(parseInt(a.top)/100):a.top;
        var abottom=(th>0 && a.bottom && typeof(a.bottom)=='string')? 
th*(parseInt(a.bottom)/100):a.bottom;
        var x = aleft;
        var y = atop;
        var w = null;
        var h = null;
        var dlyrWidth=dlyr.getWidth();
        var dlyrHeight=dlyr.getHeight();
        if (a.stretchH!=null) {
                if(typeof(a.stretchH)!='string') w=a.stretchH;
                else {
                        if(a
.stretchH=='*') w = tw - ((aleft!=null)? aleft:0);
                        else w = tw*(parseInt(a.stretchH)/100);
                }
                dlyrWidth=w;
        }
        if (a.centerH!=null) {
                x = Math.ceil(tw/2 - dlyrWidth/2 + a.centerH);
        }else if (aright!=null) {
                if (aleft!=null) w = (tw - aright) - aleft;
                else x = (tw - dlyrWidth) - aright;
                if(tw<=0 && x<0) x=null; // ns4 needs x>=0
        }       
        if (a.stretchV!=null) {
                if(typeof(a.stretchV)!='string') h=a.stretchV;
                else {
                        if(a.stretchV=='*') h = th - ((atop!=null)? atop:0);
                        else h = th*(parseInt(a.stretchV)/100);
                }
                dlyrHeight=h;
        }       
        if (a.centerV!=null) {
                y = Math.ceil(th/2 - dlyrHeight/2 + a.centerV);
        }else if (abottom!=null) {
                if (atop!=null) h = (th - abottom) - atop;
                else y = (th - dlyrHeight) - abottom;
                if(th<=0 && y<0) y=null; // ns4 needs y>=0
        }
        if(padX) {x=(x)? x:0;x+=padX}
        if(padY) {y=(y)? y:0;y+=padY}
        if(x!=null||y!=null) dlyr.setLocation(x,y);
        if(w!=null||h!=null) dlyr.setSize(w,h);
};
p._updateAnchors = function() {
        var tw = this.w;
        var th = this.h;
        if (tw==null && th==null) return;
        for (id in this._childAnchors) this._updateAnchor(id);
};


// bandwidth timer stop
var ua=dynapi.ua; ua._bwe=new Date;
ua.broadband=((ua._bwe-ua._bws)<=1500)? true:false;
\ No newline at end of file



-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
Dynapi-CVS mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dynapi-cvs

Reply via email to