On Thursday, February 27, 2003, at 07:58 PM, Raymond Irving wrote:
I see what you're trying to do. You're trying to construct a widget from an inline div, correct?
Exactly !
Which is fine to me as I'm looking at it considering I would have a server side that generates both the inline div, and the javascript instruction, so they would be in sync.So you would like the option to be able to pass paraments to the widget from an the getInline() function? What I think you're forgetting is the section of getInline() that calls DynLayer._updateValues(). The DynLayer._updateValues() function will overwrite your x,y,w,h,bgcolor,bgimage and html properties that you would have set from the widget/layer.
True, but if it's automated, then you're much safer, otherwise, that's true, it's a risk. However could that be checked to make sure that this.elm.parent == this.parent.elm
Secondly if you were to construct a widget from an inline layer then you will have to remeber that the widget's parent will become that of the inline layer. This could really mess up parant/child relationship if it's not used properly.
That would work. But I thought about it yesterday night, and I think we should take a different approach: create your dynlayers or widget exactly as you usually do with their regular constructors.
In any event I would suggest that you try doing something like this:
DynLayer.getInline = function (id, p, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) { var elm; var pobj; if (!p) pobj = dynapi.document; else if (p.isClass && p.isClass('DynElement')) pobj = p; if (pobj) { if (dynapi.ua.ns4) elm = pobj.doc.layers[id]; else if (dynapi.ua.ns6) elm = pobj.doc.getElementsByID(id); else if (dynapi.ua.ie) elm = pobj.doc.all[id]; } if (!elm) return alert("DynLayer_inline Error: did not find element "+id);
var className=this.prototype._className; //get class name var dlyr = eval('new '+className+'(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)'); dlyr.setID(id); dlyr.parent = pobj; dlyr.elm = elm; if (dynapi.ua.ns4) dlyr.doc = elm.document; DynLayer._updateValues(dlyr); DynLayer._assignElement(dlyr,elm); DynElement._flagEvent(dlyr,'create'); return dlyr; }
function MyWidget(a,b,c){ // code here; }
MyWidget.getInline=DynLayer.getInline;
Best regards,
-- Raymond Irving
Now, if you already have the html in the page representing the divs of the objects you created, you would call an equivallent to document.insertAllChildren() which would be assignInlineElementToAllChildren() in the onload. This method would crawl the tree of dynlayers, and call on each one:
DynLayer.prototype.assignInlineElement = function { var p = this.parent;
if (!p) pobj = dynapi.document; else if (p.isClass && p.isClass('DynElement')) pobj = p; if (pobj) { if (dynapi.ua.ns4) elm = pobj.doc.layers[id]; else if (dynapi.ua.ns6) elm = pobj.doc.getElementsByID(id); else if (dynapi.ua.ie) elm = pobj.doc.all[id]; } if (!elm) return alert("DynLayer_inline Error: did not find element "+id);
this.elm = elm; if (dynapi.ua.ns4) dlyr.doc = elm.document; DynLayer._updateValues(this); DynLayer._assignElement(this,elm); DynElement._flagEvent(this,'create');
}
That way I think it's a much cleaner design that scales better. What do you think ?
Benoit
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://www.mail-archive.com/[EMAIL PROTECTED]/