Update of /cvsroot/dynapi/dynapi/src/lib/dynapi/api In directory usw-pr-cvs1:/tmp/cvs-serv29769 Modified Files: events.js dynlayer.js Log Message: Yet a few more event+layer creation fixes. Index: events.js =================================================================== RCS file: /cvsroot/dynapi/dynapi/src/lib/dynapi/api/events.js,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** events.js 2001/01/11 19:23:59 1.11 --- events.js 2001/01/16 18:18:14 1.12 *************** *** 2,5 **** --- 2,6 ---- DynAPI Distribution Event Classes + Modified: 2000.11.05 The DynAPI Distribution is distributed under the terms of the GNU LGPL license. *************** *** 13,17 **** DynEvent.prototype.getSource=function() {return this.src;}; DynEvent.prototype.getTarget=function() {return this.target;}; - EventListener=function(target) {this.target=target;}; EventListener.prototype.handleEvent=function(type,e) { --- 14,17 ---- *************** *** 22,26 **** if (this["on"+type]) this["on"+type](e); }; - MouseEvent=function() {}; MouseEvent.prototype.getType=function() {return this.type;}; --- 22,25 ---- *************** *** 51,56 **** var m = e.modifiers; alt = (m==1 || m==3 || m==5 || m==7)?true:false; ! ctrl = (m==2 || m==3 || m==6 || m==7)?true:false; ! shft = (m==4 || m==5 || m==6 || m==7)?true:false; } else { } --- 50,55 ---- var m = e.modifiers; alt = (m==1 || m==3 || m==5 || m==7)?true:false; ! ctrl = (m==2 || m==3 || m==6 || m==7)?true:false; ! shft = (m==4 || m==5 || m==6 || m==7)?true:false; } else { } *************** *** 67,79 **** this.src.invokeEvent(this.type,this); this.bubbleEvent(); ! return; }; ! MouseEvent.prototype.getX=function() {return this.x;}; ! MouseEvent.prototype.getY=function() {return this.y;}; ! MouseEvent.prototype.getPageX=function() {return this.pageX;}; ! MouseEvent.prototype.getPageY=function() {return this.pageY;}; ! MouseEvent.prototype.setBubble=function(b) {this.bubble=b;}; ! MouseEvent.prototype.cancelBrowserEvent=function(b) {this.browserReturn=false;}; ! DynLayer.prototype.captureMouseEvents=function() { if (!this.eventListeners) this.eventListeners=[]; --- 66,77 ---- this.src.invokeEvent(this.type,this); this.bubbleEvent(); ! return }; ! MouseEvent.prototype.getX=function() {return this.x}; ! MouseEvent.prototype.getY=function() {return this.y}; ! MouseEvent.prototype.getPageX=function() {return this.pageX}; ! MouseEvent.prototype.getPageY=function() {return this.pageY}; ! MouseEvent.prototype.setBubble=function(b) {this.bubble=b}; ! MouseEvent.prototype.cancelBrowserEvent=function(b) {this.browserReturn=false}; DynLayer.prototype.captureMouseEvents=function() { if (!this.eventListeners) this.eventListeners=[]; *************** *** 82,92 **** var elm=this.elm; if (is.ns4) elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK | Event.DBLCLICK); ! elm.mousemove=elm.onmousedown=elm.onmouseup=elm.onmouseover=elm.onmouseout=elm.onclick=elm.ondblclick=DynLayer.prototype.EventMethod; ! if (is.ie5) elm.oncontextmenu=function() { ! return false; ! }; }; DynLayer.prototype.EventMethod = function(e) { - var dyndoc=this.lyrobj.dyndoc; if (is.ie) { --- 80,87 ---- var elm=this.elm; if (is.ns4) elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK | Event.DBLCLICK); ! elm.onmousedown=elm.onmouseup=elm.onmouseover=elm.onmouseout=elm.onclick=elm.ondblclick=DynLayer.prototype.EventMethod; ! if (is.ie5) this.elm.oncontextmenu=function() {return false}; }; DynLayer.prototype.EventMethod = function(e) { var dyndoc=this.lyrobj.dyndoc; if (is.ie) { *************** *** 94,121 **** e.cancelBubble=true; if (e.type=="click" && DynAPI.wasDragging) { - //e.cancelBubble=true; redundant DynAPI.wasDragging=false; return true; } ! //if (e.type!="mouseout" && e.type!="mouseover") e.cancelBubble=true; redundant ! if (e.type=="mouseout" && this.contains(e.toElement)) return true; ! if (e.type=="mouseover" && this.contains(e.fromElement)) return true; } ! ! var realsrc=is.ie?e.srcElement:e.target ! var which=(is.ie||is.ns5)?e.button:e.which ! /* Fix by ilMaestro: In IE, search for parent div, if any, because it will have a reference to the DynLayer */ for(;is.ie && !realsrc.lyrobj && realsrc.parentElement && realsrc.parentElement!=realsrc;realsrc=realsrc.parentElement); ! var src = realsrc.lyrobj||dyndoc ! //if (!src || src==dyndoc) {window.status=" --> "+realsrc.href; return true } ! var evt=dyndoc._e ! evt.setEvent(src,e) ! var type=evt.type ! //window.status = " ... "+src ! src.invokeEvent(type,evt) ! if (is.ns && (e.type=="mouseover" || e.type=="mouseout")) return false; evt.bubbleEvent(); return evt.browserReturn; --- 89,115 ---- e.cancelBubble=true; if (e.type=="click" && DynAPI.wasDragging) { DynAPI.wasDragging=false; return true; } ! if (e.type=="mouseout" && this.contains(e.toElement)) { return true }; ! if (e.type=="mouseover" && this.contains(e.fromElement)) { return true }; } ! var realsrc=is.ie?e.srcElement:e.target; /* Fix by ilMaestro: In IE, search for parent div, if any, because it will have a reference to the DynLayer */ for(;is.ie && !realsrc.lyrobj && realsrc.parentElement && realsrc.parentElement!=realsrc;realsrc=realsrc.parentElement); ! var which=(is.ie||is.ns5)?e.button:e.which; ! var src=realsrc.lyrobj||dyndoc; ! if (!src) return true; ! var evt=dyndoc._e; ! evt.setEvent(src,e); ! var type=evt.type; ! src.invokeEvent(type,evt); ! ! /* Fix by ilMaestro: more accurate event bubbling criteria. Some more bubbling check must be done ! inside invokeEvent (IE only) */ ! if(is.ns && (e.type=="mouseover" || e.type=="mouseout")) return false; ! evt.bubbleEvent(); return evt.browserReturn; *************** *** 137,142 **** DynLayer.prototype.invokeEvent=function(type,e) { if (!this.hasEventListeners) return; var orig=null; ! if (e && is.ns) { orig=e.orig; e.cancelBubble=false; --- 131,141 ---- DynLayer.prototype.invokeEvent=function(type,e) { if (!this.hasEventListeners) return; + + /* Fix by Ilmaestro: more accurate event Bubbling criteria */ + if (is.ie && type=='mouseover' && this.elm.contains(e.orig.fromElement)) +return; + if (is.ie && type=='mouseout' && this.elm.contains(e.orig.toElement)) return; + var orig=null; ! if (e && is.ns) { orig=e.orig; e.cancelBubble=false; *************** *** 157,169 **** this.eventListeners[i].handleEvent(type,e); } ! ! if (is.ns && e) { // DCP: added && e fix if (e.cancelBubble) return; if (orig && orig.target.handleEvent && orig.target!=this.elm) orig.target.handleEvent(type,orig); ! } if (is.ns4 && is.platform=="other" && type=="mouseup") this.invokeEvent("click",e); }; ! ! DynDocument.prototype._e=new MouseEvent(); DynDocument.prototype.captureMouseEvents=function() { if (this.mouseEventsCaptured) return; --- 156,171 ---- this.eventListeners[i].handleEvent(type,e); } ! if (is.ns && e) { if (e.cancelBubble) return; if (orig && orig.target.handleEvent && orig.target!=this.elm) orig.target.handleEvent(type,orig); ! } if (is.ns4 && is.platform=="other" && type=="mouseup") this.invokeEvent("click",e); + if (this.parentComponent) { + if (e) e.src=this.parentComponent; + else e=new DynEvent(type,this); + this.parentComponent.invokeEvent(type,e); + } }; ! DynDocument.prototype._e=new MouseEvent() DynDocument.prototype.captureMouseEvents=function() { if (this.mouseEventsCaptured) return; *************** *** 173,186 **** if (is.ns4) this.doc.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK | Event.DBLCLICK); this.doc.onmousemove=this.doc.onmousedown=this.doc.onmouseup=this.doc.onclick=this.doc.ondblclick=DynDocument.prototype.EventMethod; ! if (is.ie5) this.doc.oncontextmenu=function() { ! return false; ! } }; ! DynDocument.prototype.EventMethod=DynLayer.prototype.EventMethod; DynDocument.prototype.releaseMouseEvents = function() { this.mouseEventsCaptured = false; ! this.doc.onmousemove = this.doc.onmousedown = this.doc.onmouseup = this.doc.onclick = this.doc.ondblclick = function(e) { ! return false; ! }; }; DynDocument.prototype.addEventListener=DynLayer.prototype.addEventListener; --- 175,184 ---- if (is.ns4) this.doc.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK | Event.DBLCLICK); this.doc.onmousemove=this.doc.onmousedown=this.doc.onmouseup=this.doc.onclick=this.doc.ondblclick=DynDocument.prototype.EventMethod; ! if (is.ie5) this.doc.oncontextmenu=function(){ return false }; }; ! DynDocument.prototype.EventMethod=DynLayer.prototype.EventMethod DynDocument.prototype.releaseMouseEvents = function() { this.mouseEventsCaptured = false; ! this.doc.onmousemove = this.doc.onmousedown = this.doc.onmouseup = this.doc.onclick = this.doc.ondblclick = function(e) { return false }; }; DynDocument.prototype.addEventListener=DynLayer.prototype.addEventListener; *************** *** 190,194 **** if (!this.hasEventListeners) return; var orig=null; ! if (e && is.ns) { orig=e.orig; e.cancelBubble=false; --- 188,192 ---- if (!this.hasEventListeners) return; var orig=null; ! if (e && is.ns) { orig=e.orig; e.cancelBubble=false; *************** *** 209,218 **** this.eventListeners[i].handleEvent(type,e); } ! if (i!=0 || e) { if (is.ns) { if (e.cancelBubble) return; if (orig && orig.target.handleEvent && !orig.target.URL) orig.target.handleEvent(orig); } - } if (is.ns4 && is.platform=="other" && type=="mouseup") this.invokeEvent("click",e); ! }; --- 207,215 ---- this.eventListeners[i].handleEvent(type,e); } ! if (i!=0 || e) if (is.ns) { if (e.cancelBubble) return; if (orig && orig.target.handleEvent && !orig.target.URL) orig.target.handleEvent(orig); } if (is.ns4 && is.platform=="other" && type=="mouseup") this.invokeEvent("click",e); ! }; \ No newline at end of file Index: dynlayer.js =================================================================== RCS file: /cvsroot/dynapi/dynapi/src/lib/dynapi/api/dynlayer.js,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** dynlayer.js 2001/01/11 19:23:59 1.13 --- dynlayer.js 2001/01/16 18:18:14 1.14 *************** *** 80,84 **** } } ! 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); --- 80,84 ---- } } ! if (dlyr.z!=null) dlyr.css.zIndex=dlyr.z; dlyr.css.visibility=dlyr.visible? "inherit" : (is.ns4?"hide":"hidden"); if (dlyr.w!=null) dlyr.setWidth(dlyr.w, false); *************** *** 138,143 **** if (is.ns5) for (i in dlyr.doc.images) dlyr.doc.images[i].lyrobj=dlyr.elm; ! /* ilmaestro: not neded anymore ! if (is.ie) for (i in dlyr.elm.all.tags("img")) dlyr.elm.all.tags("img")[i].lyrobj=dlyr; */ }; DynLayer.assignChildren=function(dlyr) { --- 138,143 ---- if (is.ns5) for (i in dlyr.doc.images) dlyr.doc.images[i].lyrobj=dlyr.elm; ! /* ilmaestro: not neded anymore */ ! //if (is.ie) for (i in dlyr.elm.all.tags("img")) dlyr.elm.all.tags("img")[i].lyrobj=dlyr; }; DynLayer.assignChildren=function(dlyr) { *************** *** 155,162 **** } child.invokeEvent("resize"); - - if (child.hasEventListeners && is.ns4) dlyr.captureMouseEvents(); - child.created=true; child.invokeEvent('create'); } --- 155,163 ---- } child.invokeEvent("resize"); child.created=true; + if (child.hasEventListeners) child.captureMouseEvents(); + // zIndex not working by placing the tag in the getOuterHTML method, +therefore... + if (child.z!=null) child.css.zIndex=child.z; + child.invokeEvent('create'); } *************** *** 211,215 **** 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; --- 212,216 ---- 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; *************** *** 277,281 **** else if (dlyr.w!=null && dlyr.h!=null); s+=' clip="0,0,'+dlyr.w+','+dlyr.h+'"'; ! if (dlyr.z) s+=' zIndex='+dlyr.z; if (dlyr.bgImage!=null) s+=' background="'+dlyr.bgImage+'"'; if (dlyr.bgColor!=null) s+=' bgcolor="'+dlyr.bgColor+'"'; --- 278,283 ---- else if (dlyr.w!=null && dlyr.h!=null); s+=' clip="0,0,'+dlyr.w+','+dlyr.h+'"'; ! // not working. See assignChildren() ! // if (dlyr.z) s+=' z-Index='+dlyr.z; if (dlyr.bgImage!=null) s+=' background="'+dlyr.bgImage+'"'; if (dlyr.bgColor!=null) s+=' bgcolor="'+dlyr.bgColor+'"'; *************** *** 297,303 **** else if (dlyr.w!=null && dlyr.h!=null); s+=' clip:rect(0px '+dlyr.w+'px '+dlyr.h+'px 0px);'; ! if (dlyr.z) s+=' zIndex='+dlyr.z; if (dlyr.bgImage!=null) s+=' background-image:url('+dlyr.bgImage+');' // DCP : This works :) ! if (dlyr.bgColor!=null) s+=' background-color:'+dlyr.bgColor+';' if (is.ie55 && dlyr.bgImage==null && dlyr.html==null) s+=' background-image:url(javascript:null);' // DCP : Fixes IE5.5 specific event problem s+=' position:absolute;">'; --- 299,306 ---- else if (dlyr.w!=null && dlyr.h!=null); s+=' clip:rect(0px '+dlyr.w+'px '+dlyr.h+'px 0px);'; ! // not working. See assignChildren() ! //if (dlyr.z) s+=' zindex='+dlyr.z; if (dlyr.bgImage!=null) s+=' background-image:url('+dlyr.bgImage+');' // DCP : This works :) ! if (dlyr.bgColor!=null) s+=' background:'+dlyr.bgColor+';' if (is.ie55 && dlyr.bgImage==null && dlyr.html==null) s+=' background-image:url(javascript:null);' // DCP : Fixes IE5.5 specific event problem s+=' position:absolute;">'; *************** *** 435,443 **** this.elm.appendChild(df); for (var i in this.doc.images) this.doc.images[i].lyrobj=this.elm; } - /* else { // ilMaestro: not needed anymore - for (var i in this.elm.all.tags("img")) - this.elm.all.tags("img")[i].lyrobj=this; - } */ if (noevt!=false) this.invokeEvent("load"); }; --- 438,445 ---- this.elm.appendChild(df); for (var i in this.doc.images) this.doc.images[i].lyrobj=this.elm; + } + else { + //for (var i in this.elm.all.tags("img")) +this.elm.all.tags("img")[i].lyrobj=this; } if (noevt!=false) this.invokeEvent("load"); }; _______________________________________________ Dynapi-CVS mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/dynapi-cvs