|
From: Pascal B. <pa...@dy...> - 2000-10-30 18:40:35
|
Ok, here are a few possible fixes for the latest release:
in: DynLayer.prototype.removeChild()
change this: DynLayer.unassigned[DynLayer.unAssigned.length]=child
into this: DynLayer.unassigned[DynLayer.unassigned.length]=child
error was: the unAssigned array is not with a capital A ;)
deleteElement contains a MAJOR bug:
DynLayer.prototype.deleteElement=function() {
this.created=false
/*
DONT DO THE FOLLOWING!
It's already being done by the functions that call deleteElement, so don't
do it here again - major problems!
DynAPI.removeFromArray(this.dyndoc.all,this,true)
delete this.dyndoc.allID[this.id]
DynLayer.unassigned[DynLayer.unassigned.length]=this
DynLayer.unassignedID[this.id]=this
*/
if (is.ns4) {
this.elm.releaseEvents(Event.LOAD)
this.elm.visibility="hide"
} else {
this.elm.style.visibility="hidden"
this.elm.innerHTML=""
this.elm.outerHTML=""
// + following line won't work on IE4, so check for IE5
if (is.ie5 && this.elm.children.length>0) this.elm.removeNode(true)
}
this.elm={}
this.doc={}
this.css={}
this.deleteChildElements()
}
Also the inline code is totally broken, I've got a working version
but it depends on the children array still "alive". I don't know why
the children[] is removed (or atleast not an array at the beginning) this
makes coding a tricky thing (always having to check for the children array
being an array)
the widget modifications posted a few days ago should make the children[]
problems solved,
so that the array can always be an array, so that checks don't have to be
done maybe saving
a few code-breaking situations, speed and file-sizes..
anyway, here's the correct inline code (might need a children[] fix as
mentioned, or preferably
restore the children array to an array) :
/*
Core DynAPI Distribution
AddOn extensions
*/
DynAPI.findLayers=function(dyndoc,or) {
var divs=[]
or=or||dyndoc
if (is.ns4) divs=dyndoc.doc.layers
if (is.ns5) divs=dyndoc.doc.getElementsByTagName("DIV")
if (is.ie) divs=dyndoc.doc.all.tags("DIV")
for (var i=0; i<divs.length; i++) {
if(DynAPI.isDirectChildOf(divs[i],dyndoc.elm)) {
var id=is.ns4? divs[i].name : divs[i].id
var dlyr=new DynLayer(id)
dlyr.parent=dyndoc
dlyr.assignElement(divs[i])
dlyr.dyndoc=or
// new line here, not sure why I did it, but it fixed a few things
// for events I think.
if (dyndoc.getClass()!=DynDocument) dlyr.isChild=true
if (or.getClass()!=DynDocument) dlyr.isChild=true
else {
// this part was needing some fixing for Scott's new code:
DynAPI.removeFromArray(DynLayer.unassigned, dlyr, true)
delete DynLayer.unassignedID[dlyr.id]
or.all[or.all.length]=dlyr
or.all[dlyr.id]=dlyr
or.allID[dlyr.id]=dlyr
}
dyndoc.children[dyndoc.children.length]=dlyr
var index=id.indexOf("Div")
if (index>0) dyndoc.doc.window[id.substr(0,index)] = dyndoc.all[id]
if (is.ns4) {for (ict in dlyr.doc.images)
dlyr.doc.images[ict].lyrobj=dlyr}
else if (is.ns5) {for (ict in dlyr.doc.images)
dlyr.doc.images[ict].lyrobj=dlyr.elm}
else {for (ict in dlyr.elm.all.tags("img"))
dlyr.elm.all.tags("img")[ict].lyrobj=dlyr}
if (dlyr.updateValues) dlyr.updateValues()
DynAPI.findLayers(dlyr,or)
}
}
}
DynLayer.prototype.updateValues=function() {
if (is.ns) {
this.x=parseInt(this.css.left)
this.y=parseInt(this.css.top)
this.w=is.ns4? this.css.clip.width : parseInt(this.css.width)
this.h=is.ns4? this.css.clip.height : parseInt(this.css.height)
if (is.ns4)
this.clip=[this.css.clip.top,this.css.clip.right,this.css.clip.bottom,this.c
ss.clip.left]
this.bgColor = this.doc.bgColor!="this.doc.bgColor"?this.doc.bgColor:null
this.bgImage = this.elm.background.src!=""?this.elm.background.src:null
this.html = this.innerHTML = this.elm.innerHTML = ""
}
else if (is.ie) {
this.x=this.elm.offsetLeft
this.y=this.elm.offsetTop
this.w=is.ie4? this.css.pixelWidth : this.elm.offsetWidth
this.h=is.ie4? this.css.pixelHeight : this.elm.offsetHeight
this.bgImage = this.css.backgroundImage
this.bgColor = this.css.backgroundColor
this.html = this.innerHTML = this.elm.innerHTML
}
this.z = this.css.zIndex
var b = this.css.visibility
this.visible = (b=="inherit"||b=="show"||b=="visible"||b=="")
}
DynAPI.getModel=function() {
dom='DYNAPI OBJECT MODEL:\n\n+DynAPI\n'
for (var i=0; i<DynAPI.documents.length; i++) {
dom+=' +'+DynAPI.documents[i].toString()+'\n'
for (var j=0; j<DynAPI.documents[i].all.length; j++)
dom+='+'+DynAPI.documents[i].all[j].toString()+'\n'
}
alert(dom)
}
DynAPI.isDirectChildOf = function(l, parent) {
if(is.ns) return (l.parentLayer == parent)
for(var p=l.parentElement;p;p=p.parentElement)
if(p.tagName.toLowerCase()=='div') return p==parent
return !parent.tagName
}
Some doubts about the event code in the current release, there is some code
for the
old rtmouseup and rtmousedown events.. don't think they are needed (at least
not in that
state) I've got the following solution working:
Use all of Scott's this.button changes, and change the handleEvent()
method into this:
EventListener.prototype.handleEvent=function(type,e)
if (type=='mousedown' || type=='mouseup') {
if (e.button==2) type='md'+type
if (e.button==3) type='rt'+type
}
if (this["on"+type]) this["on"+type](e)
}
should do correct event bubbling, and still make different events for
rtmouseup/rtmousedown
and mdmouseup/mdmousedown (middle button)
that's it for now.. have fun :)
Pascal Bestebroer
pa...@dy...
http://www.dynamic-core.net
|