From: Raymond I. <xw...@us...> - 2003-03-09 22:21:56
|
Update of /cvsroot/dynapi/dynapi3x/src/api In directory sc8-pr-cvs1:/tmp/cvs-serv12044/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 Index: dyndocument.js =================================================================== RCS file: /cvsroot/dynapi/dynapi3x/src/api/dyndocument.js,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** dyndocument.js 5 Mar 2003 04:36:16 -0000 1.4 --- dyndocument.js 9 Mar 2003 22:21:46 -0000 1.5 *************** *** 100,105 **** this.findDimensions(); var divs; ! // create divs object - speeds up DOM browsers on win32. Linux & Mac? if (ua.win32 && (ua.ie||ua.dom)) { divs={} --- 100,106 ---- this.findDimensions(); + var divs; ! // create divs object - speeds up DOM browsers on Win32. Linux & Mac? if (ua.win32 && (ua.ie||ua.dom)) { divs={} Index: dynlayer_dom.js =================================================================== RCS file: /cvsroot/dynapi/dynapi3x/src/api/dynlayer_dom.js,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** dynlayer_dom.js 5 Mar 2003 04:36:16 -0000 1.3 --- dynlayer_dom.js 9 Mar 2003 22:21:46 -0000 1.4 *************** *** 11,16 **** this.DynElement = DynElement; this.DynElement(); ! if (html!=null) this.setHTML(html); ! else this.html = null; this.x = x; this.y = y; --- 11,37 ---- this.DynElement = DynElement; this.DynElement(); ! ! if (html && html.constructor==Object){ ! var args=html; // dictionary input ! html=args.html; ! x = args.x; ! y = args.y; ! w = args.w; ! h = args.h; ! color = args.color; ! this.visible = (args.visible||true); ! this.z = (args.zIndex||1); ! this._saveAnchor = args.anchor; ! this._textSelectable = (args.textSelectable||true); ! if (args.id) this.setID(args.id,true); ! } ! else { ! this.visible = true; ! this.z = 1; ! this._saveAnchor = false; ! this._textSelectable = true; ! } ! ! this.html = html; this.x = x; this.y = y; *************** *** 18,28 **** this.h = h; this.bgColor = color; - this.visible = true; - this.z = 1; this.elm = null; this.doc = null; this.css = null; - this._saveAnchor = false; - this._textSelectable = true; }; var p = dynapi.setPrototype('DynLayer','DynElement'); --- 39,45 ---- *************** *** 76,79 **** --- 93,98 ---- var elm, parentElement; parentElement = this.parent.elm; + + // this method seems faster for most dom browsers var r = parentElement.ownerDocument.createRange(); r.setStartBefore(parentElement); *************** *** 81,84 **** --- 100,104 ---- parentElement.appendChild(ptxt); elm = parentElement.lastChild; + DynLayer._assignElement(this,elm); DynElement._flagEvent(this,'create'); *************** *** 95,99 **** dlyr.css = elm.style; dlyr.doc = dlyr.parent.doc; - //dlyr.elm.lyrobj = dlyr; //to be removed dlyr.elm._dynobj = dlyr; dlyr._dyndoc = dlyr.parent._dyndoc; --- 115,118 ---- *************** *** 107,117 **** } ! for (var i=0; i<dlyr.children.length; i++) { ! DynLayer._assignElement(dlyr.children[i]); ! } if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); // if (dlyr.assignKeyEvents) dlyr.assignKeyEvents(); if (dlyr._hasKeyEvents) dlyr.captureKeyEvents(); }; p.getOuterHTML=function() { --- 126,136 ---- } ! var i,ch=dlyr.children; ! for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null,divs); if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); // if (dlyr.assignKeyEvents) dlyr.assignKeyEvents(); if (dlyr._hasKeyEvents) dlyr.captureKeyEvents(); + }; p.getOuterHTML=function() { *************** *** 122,126 **** s=[ '<div id="'+this.id+'" style="', - ((this.visible==false)? ' visibility:hidden;':' visibility:inherit;'), ' left:',(this.x!=null? this.x : 0),'px;', ' top:',(this.y!=null? this.y : 0),'px;', --- 141,144 ---- *************** *** 131,139 **** ((this._overflow!=null)? ' overflow:hidden;':''), ((this.bgColor!=null)? ' background-color:'+this.bgColor+';':''), ! bgimage,clip,' position:absolute;">', ! this.getInnerHTML(),'</div>' ]; return s.join(''); }; p.setLocation=function(x,y) { var cx = (x!=null && x!=this.x); --- 149,169 ---- ((this._overflow!=null)? ' overflow:hidden;':''), ((this.bgColor!=null)? ' background-color:'+this.bgColor+';':''), ! ((this.visible==false)? ' visibility:hidden;':' visibility:inherit;'), ! bgimage, ! clip, ! ' position:absolute;">', ! this.getInnerHTML(), ! '</div>\n' ]; return s.join(''); }; + p.getInnerHTML=function() { + var s = ''; + var i,ch=this.children; + if (this.html!=null) s+=this.html; + for (i=0;i<ch.length;i++) s+=ch[i].getOuterHTML(); + return s; + }; + p.setLocation=function(x,y) { var cx = (x!=null && x!=this.x); *************** *** 242,253 **** }; p.getZIndex=function() {return this.z}; - - 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; - }; - p.getHTML = function() {return this.html}; p.setWidth=function(w) {this.setSize(w,null)}; --- 272,275 ---- Index: dynlayer_ie.js =================================================================== RCS file: /cvsroot/dynapi/dynapi3x/src/api/dynlayer_ie.js,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** dynlayer_ie.js 5 Mar 2003 04:36:16 -0000 1.4 --- dynlayer_ie.js 9 Mar 2003 22:21:46 -0000 1.5 *************** *** 12,16 **** this.DynElement(); ! this.html = null; this.x = x; this.y = y; --- 12,37 ---- this.DynElement(); ! if (html && html.constructor==Object){ ! var args=html; // dictionary input ! html=args.html; ! x = args.x; ! y = args.y; ! w = args.w; ! h = args.h; ! color = args.color; ! this.visible = (args.visible||true); ! this.z = (args.zIndex||1); ! this._saveAnchor = args.anchor; ! this._textSelectable = (args.textSelectable||true); ! if (args.id) this.setID(args.id,true); ! } ! else { ! this.visible = true; ! this.z = 1; ! this._saveAnchor = false; ! this._textSelectable = true; ! } ! ! this.html = html; this.x = x; this.y = y; *************** *** 18,31 **** this.h = h; this.bgColor = color; - this.visible = true; - this.z = 1; this.elm = null; this.doc = null; ! this.css = null; ! this._saveAnchor = false; ! this._textSelectable = true; ! ! if (html!=null) this.setHTML(html); ! }; var p = dynapi.setPrototype('DynLayer','DynElement'); --- 39,45 ---- this.h = h; this.bgColor = color; this.elm = null; this.doc = null; ! this.css = null; }; var p = dynapi.setPrototype('DynLayer','DynElement'); *************** *** 78,83 **** var elm, parentElement; parentElement = this.parent.elm; ! parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML()); ! elm = parentElement.children[parentElement.children.length-1]; DynLayer._assignElement(this,elm); DynElement._flagEvent(this,'create'); --- 92,120 ---- var elm, parentElement; parentElement = this.parent.elm; ! if(dynapi.ua.v<5){ ! parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML()); ! elm = parentElement.children[parentElement.children.length-1]; ! } ! else { ! // this method is more efficent for ie5+. any comment? ! elm=document.createElement('DIV'); ! elm.id=this.id; ! elm.style.position='absolute'; ! elm.style.pixelLeft=(this.x||0); ! elm.style.pixelTop=(this.y||0); ! elm.style.width=(this.w||'auto'); ! elm.style.height=(this.h||'auto'); ! elm.style.backgroundColor=(this.bgColor||'transparent'); ! elm.style.zIndex=(this.z||1); ! elm.style.cursor=(this._cursor||'auto') ! elm.style.overflow=(this._overflow!=null)? 'hidden':''; ! if(this.bgImage!=null) elm.style.backgroundImage='url('+this.bgImage+')'; ! if (this.bgImage==null && this.html==null) elm.style.backgroundImage='none'; ! if (this.clip) elm.style.clip='rect('+this.clip[0]+'px '+this.clip[1]+'px '+this.clip[2]+'px '+this.clip[3]+'px)'; ! else if (this.w!=null && this.h!=null) elm.style.clip='rect(0px '+this.w+'px '+this.h+'px 0px)'; ! elm.style.visibility=(this.visible==false)? 'hidden':'inherit'; ! elm.innerHTML=this.getInnerHTML(); ! parentElement.appendChild(elm); ! } DynLayer._assignElement(this,elm); DynElement._flagEvent(this,'create'); *************** *** 93,97 **** dlyr.css = elm.style; dlyr.doc = dlyr.parent.doc; - //dlyr.elm.lyrobj = dlyr; // to be removed dlyr.elm._dynobj = dlyr; dlyr._dyndoc = dlyr.parent._dyndoc; --- 130,133 ---- *************** *** 102,111 **** dlyr.setSize(cw,ch); } ! ! var i=0,ch=dlyr.children; ! while (i<ch.length) { ! DynLayer._assignElement(ch[i]); ! i++; ! } if (dlyr._textSelectable==false) elm.onselectstart = dynapi.functions.Deny; --- 138,144 ---- dlyr.setSize(cw,ch); } ! ! var i,ch=dlyr.children; ! for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null,divs); if (dlyr._textSelectable==false) elm.onselectstart = dynapi.functions.Deny; *************** *** 115,120 **** if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); ! // if (dlyr.assignKeyEvents) dlyr.assignKeyEvents(); if (dlyr._hasKeyEvents) dlyr.captureKeyEvents(); }; p.getOuterHTML=function() { --- 148,154 ---- if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); ! // if (dlyr.assignKeyEvents) dlyr.assignKeyEvents(); if (dlyr._hasKeyEvents) dlyr.captureKeyEvents(); + }; p.getOuterHTML=function() { *************** *** 124,132 **** if (this.clip) clip=' clip:rect('+this.clip[0]+'px '+this.clip[1]+'px '+this.clip[2]+'px '+this.clip[3]+'px);'; else if (this.w!=null && this.h!=null) clip=' clip:rect(0px '+this.w+'px '+this.h+'px 0px);'; ! s=[ '<div id="'+this.id+'" style="', - ((this.visible==false)? ' visibility:hidden;':' visibility:inherit;'), ' left:',(this.x!=null? this.x : 0),'px;', ! ' top:',(this.y!=null? this.y : 0),'px;', ((this.w!=null)? ' width:'+this.w+'px;':''), ((this.h!=null)? ' height:'+this.h+'px;':''), --- 158,165 ---- if (this.clip) clip=' clip:rect('+this.clip[0]+'px '+this.clip[1]+'px '+this.clip[2]+'px '+this.clip[3]+'px);'; else if (this.w!=null && this.h!=null) clip=' clip:rect(0px '+this.w+'px '+this.h+'px 0px);'; ! return [ '<div id="'+this.id+'" style="', ' left:',(this.x!=null? this.x : 0),'px;', ! ' top:',(this.y!=null? this.y : 0),'px;', ((this.w!=null)? ' width:'+this.w+'px;':''), ((this.h!=null)? ' height:'+this.h+'px;':''), *************** *** 135,144 **** ((this._overflow!=null)? ' overflow:hidden;':''), ((this.bgColor!=null)? ' background-color:'+this.bgColor+';':''), ! bgimage,clip,' position:absolute;">', ! this.getInnerHTML(),'</div>' ! ]; ! return s.join(''); }; - p.setLocation=function(x,y) { var cx = (x!=null && x!=this.x); --- 168,186 ---- ((this._overflow!=null)? ' overflow:hidden;':''), ((this.bgColor!=null)? ' background-color:'+this.bgColor+';':''), ! ((this.visible==false)? ' visibility:hidden;':' visibility:inherit;'), ! bgimage, ! clip, ! ' position:absolute;">', ! this.getInnerHTML(), ! '</div>\n' ! ].join(''); ! }; ! p.getInnerHTML=function() { ! var s = ''; ! var i,ch=this.children; ! if (this.html!=null) s+=this.html; ! for (i=0;i<ch.length;i++) s+=ch[i].getOuterHTML(); ! return s; }; p.setLocation=function(x,y) { var cx = (x!=null && x!=this.x); *************** *** 245,259 **** }; p.getZIndex=function() {return this.z}; - - 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; - }; p.getHTML = function() {return this.html}; --- 287,290 ---- Index: dynlayer_ns4.js =================================================================== RCS file: /cvsroot/dynapi/dynapi3x/src/api/dynlayer_ns4.js,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** dynlayer_ns4.js 5 Mar 2003 04:36:16 -0000 1.3 --- dynlayer_ns4.js 9 Mar 2003 22:21:46 -0000 1.4 *************** *** 11,16 **** this.DynElement = DynElement; this.DynElement(); ! if (html!=null) this.setHTML(html); ! else this.html = null; this.x = x; this.y = y; --- 11,37 ---- this.DynElement = DynElement; this.DynElement(); ! ! if (html && html.constructor==Object){ ! var args=html; // dictionary input ! html=args.html; ! x = args.x; ! y = args.y; ! w = args.w; ! h = args.h; ! color = args.color; ! this.visible = (args.visible||true); ! this.z = (args.zIndex||1); ! this._saveAnchor = args.anchor; ! this._textSelectable = (args.textSelectable||true); ! if (args.id) this.setID(args.id,true); ! } ! else { ! this.visible = true; ! this.z = 1; ! this._saveAnchor = false; ! this._textSelectable = true; ! } ! ! this.html = html; this.x = x; this.y = y; *************** *** 18,28 **** this.h = h; this.bgColor = color; - this.visible = true; - this.z = 1; this.elm = null; this.doc = null; this.css = null; - this._saveAnchor = false; - this._textSelectable = true; }; var p = dynapi.setPrototype('DynLayer','DynElement'); --- 39,45 ---- *************** *** 115,121 **** if (dlyr.bgImage!=null) dlyr.setBgImage(dlyr.bgImage); ! for (var i=0; i<dlyr.children.length; i++) { ! DynLayer._assignElement(dlyr.children[i]); ! } if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); // if (dlyr.assignKeyEvents) dlyr.assignKeyEvents(); --- 132,138 ---- if (dlyr.bgImage!=null) dlyr.setBgImage(dlyr.bgImage); ! var i,ch=dlyr.children; ! for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null); ! if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); // if (dlyr.assignKeyEvents) dlyr.assignKeyEvents(); *************** *** 123,127 **** }; p.getOuterHTML=function() { ! var s,clip; if (this.clip) clip=' clip="'+this.clip[3]+','+this.clip[0]+','+this.clip[1]+','+this.clip[2]+'"'; else clip=' clip="0,0,'+((this.w>=0)?this.w:0)+','+((this.h>=0)?this.h:0)+'"'; --- 140,144 ---- }; p.getOuterHTML=function() { ! var s,clip=''; if (this.clip) clip=' clip="'+this.clip[3]+','+this.clip[0]+','+this.clip[1]+','+this.clip[2]+'"'; else clip=' clip="0,0,'+((this.w>=0)?this.w:0)+','+((this.h>=0)?this.h:0)+'"'; *************** *** 133,137 **** ((this.w!=null)? ' width='+this.w:''), ((this.h!=null)? ' height='+this.h:''), ! ((this.z)? ' z-index:'+this.z:''), ((this.bgColor!=null)? ' bgcolor="'+this.bgColor+'"':'')+'>', this.getInnerHTML(),'</layer>' --- 150,154 ---- ((this.w!=null)? ' width='+this.w:''), ((this.h!=null)? ' height='+this.h:''), ! ((this.z)? ' z-index:'+this.z:''), clip, ((this.bgColor!=null)? ' bgcolor="'+this.bgColor+'"':'')+'>', this.getInnerHTML(),'</layer>' *************** *** 139,142 **** --- 156,168 ---- return s.join(''); }; + p.getInnerHTML=function() { + var i,s = ''; + if (this.html!=null) { + if (this.w==null) s += '<nobr>'+this.html+'</nobr>'; + else s+=this.html; + } + for (i=0;i<this.children.length;i++) s+=this.children[i].getOuterHTML(); + return s; + }; p.setLocation = function(x,y) { var cx = (x!=null && x!=this.x); *************** *** 260,272 **** }; p.getZIndex=function() {return this.z}; - p.getInnerHTML=function() { - var i,s = ''; - if (this.html!=null) { - if (this.w==null) s += '<nobr>'+this.html+'</nobr>'; - else s+=this.html; - } - for (i=0;i<this.children.length;i++) s+=this.children[i].getOuterHTML(); - return s; - }; p.getHTML = function() {return this.html}; p.setWidth=function(w) {this.setSize(w,null)}; --- 286,289 ---- Index: dynlayer_opera.js =================================================================== RCS file: /cvsroot/dynapi/dynapi3x/src/api/dynlayer_opera.js,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** dynlayer_opera.js 5 Mar 2003 04:36:16 -0000 1.3 --- dynlayer_opera.js 9 Mar 2003 22:21:46 -0000 1.4 *************** *** 8,20 **** */ ! // Note this is a copy of the dynlayer_ie.js file ! // this file should be modified to use opera/DOM specific code so that // performance can be gained function DynLayer(html,x,y,w,h,color) { this.DynElement = DynElement; this.DynElement(); ! if (html!=null) this.setHTML(html); ! else this.html = null; this.x = x; this.y = y; --- 8,45 ---- */ ! // Note: this is a copy of the dynlayer_ie.js file ! // it file should be modified to use opera/DOM specific code so that // performance can be gained + // Warning: Avoid using document.all collection as it has been reported + // that on some platforms when opera is set to an identity other than IE + // the all[] collection is not available + function DynLayer(html,x,y,w,h,color) { this.DynElement = DynElement; this.DynElement(); ! ! if (html && html.constructor==Object){ ! var args=html; // dictionary input ! html=args.html; ! x = args.x; ! y = args.y; ! w = args.w; ! h = args.h; ! color = args.color; ! this.visible = (args.visible||true); ! this.z = (args.zIndex||1); ! this._saveAnchor = args.anchor; ! this._textSelectable = (args.textSelectable||true); ! if (args.id) this.setID(args.id,true); ! } ! else { ! this.visible = true; ! this.z = 1; ! this._saveAnchor = false; ! this._textSelectable = true; ! } ! ! this.html = html; this.x = x; this.y = y; *************** *** 22,32 **** this.h = h; this.bgColor = color; - this.visible = true; - this.z = 1; this.elm = null; this.doc = null; this.css = null; - this._saveAnchor = false; - this._textSelectable = true; }; var p = dynapi.setPrototype('DynLayer','DynElement'); --- 47,53 ---- *************** *** 79,84 **** --- 100,108 ---- var elm, parentElement; parentElement = this.parent.elm; + + // this method is more efficient for opera7+ parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML()); elm = parentElement.children[parentElement.children.length-1]; + DynLayer._assignElement(this,elm); DynElement._flagEvent(this,'create'); *************** *** 90,99 **** }; 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; dlyr.doc = dlyr.parent.doc; - //dlyr.elm.lyrobj = dlyr; //to be removed dlyr.elm._dynobj = dlyr; dlyr._dyndoc = dlyr.parent._dyndoc; --- 114,122 ---- }; DynLayer._assignElement = function(dlyr,elm,divs) { ! if (!elm ) elm = (divs)? divs[dlyr.id] : dlyr.parent.doc.getElementById(dlyr.id); // if (!elm) elm = dlyr.parent.elm.all[dlyr.id]; dlyr.elm = elm; dlyr.css = elm.style; dlyr.doc = dlyr.parent.doc; dlyr.elm._dynobj = dlyr; dlyr._dyndoc = dlyr.parent._dyndoc; *************** *** 105,116 **** } ! for (var i=0; i<dlyr.children.length; i++) { ! DynLayer._assignElement(dlyr.children[i]); ! } if (this._textSelectable==false) elm.onselectstart = dynapi.functions.Disallow; - //if (elm.all.tags("img").length) elm.ondragstart = dynapi.functions.False; - if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); // if (dlyr.assignKeyEvents) dlyr.assignKeyEvents(); --- 128,136 ---- } ! var i,ch=dlyr.children; ! for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null,divs); if (this._textSelectable==false) elm.onselectstart = dynapi.functions.Disallow; if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); // if (dlyr.assignKeyEvents) dlyr.assignKeyEvents(); *************** *** 134,142 **** ((this._overflow!=null)? ' overflow:hidden;':''), ((this.bgColor!=null)? ' background-color:'+this.bgColor+';':''), ! bgimage,clip,' position:absolute;">', ! this.getInnerHTML(),'</div>' ]; return s.join(''); }; p.setLocation=function(x,y) { var cx = (x!=null && x!=this.x); --- 154,171 ---- ((this._overflow!=null)? ' overflow:hidden;':''), ((this.bgColor!=null)? ' background-color:'+this.bgColor+';':''), ! bgimage, ! clip, ! ' position:absolute;">', ! this.getInnerHTML(), ! '</div>' ]; return s.join(''); }; + 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; + }; p.setLocation=function(x,y) { var cx = (x!=null && x!=this.x); *************** *** 243,254 **** }; p.getZIndex=function() {return this.z}; - - 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; - }; - p.getHTML = function() {return this.html}; p.setWidth=function(w) {this.setSize(w,null)}; --- 272,275 ---- Index: event.js =================================================================== RCS file: /cvsroot/dynapi/dynapi3x/src/api/event.js,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** event.js 5 Mar 2003 04:36:16 -0000 1.3 --- event.js 9 Mar 2003 22:21:46 -0000 1.4 *************** *** 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 --- 1,322 ---- ! /* ! 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; ! }; ! 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; ! // use onCreate() and onPrecreate() instead ! //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) { ! if (type=="create") c._created = true; ! if (type=='precreate'||type=='create') { ! // Raise onCreate/onPreCreate callback Flag ! if (c._hasPCreateFn||c._hasCreateFn) c._flagCreateEvent(type); ! }else{ ! // Raise other events; ! c.invokeEvent(type); ! } ! var ch=c.children; ! for (var i=0; i<ch.length; i++) { ! DynElement._flagEvent(ch[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; |