On Friday, February 28, 2003, at 12:02 PM, Raymond Irving wrote:

--- Benoit Marchant <[EMAIL PROTECTED]> wrote:
...I think we
should take a different approach: create your
dynlayers or widget
exactly as you usually do with their regular
constructors.
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.

Agree, but the user would have to add that line
manually (similar to the way we not do
insertAllChildren()):

<script>
dynapi.document.assignInlineElementToAllChildren()
</script>

You're right, I didn't see that now it's possible to avoid it.
So what about tweaking addChild(c,alias) method to addChild(c,alias,inline). Then you can specify inline as true, and we would default to no, which means it would be transparent to the current api. We can "override"
DynElement.prototype.addChild in the dynlayer_inline.js, t should work as long as you include that file, right ? or add that capacity to DynElement.

DynLayer.prototype.assignInlineElement = function () {
if (this.parent && !this.elm) {
//I'm not sure we want to call that as onprecreate was usually used to do setHTML which doesn't make sense here since the html already exists. Comments ?
//DynElement._flagEvent(this,'precreate');
DynLayer._assignElement(this);
DynLayer._updateValues(this);
DynElement._flagEvent(this,'create');
}
}

DynElement.prototype.addChild =
DynElement.prototype
.addInlineChild = function(c,alias,inline) {
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) {
if(!inline) c._create();
else {
c.assignInlineElement();
}
this.children[this.children.length] = c;
return c;
};

So what about that ?


That way you specifically say that you add a child that need to be mapped to an inline div.
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 ?

Very good! I like this approach. The only thing is
that the user would have to call setID() for each
layer, but that's not a problem.

var lyr=DynLayer()
lyr.setID('mydiv');

That's why I would be glad to see the id back in the constructor as the first argument ! It would save a line of code !
This would allow users to build complex inline widgets
and then have the system assign the elements to the
complex DynAPI structure. Briliant! The one problem
that I see is that inline wigdets will not be as
flexible as ordinary widgets, but they're great for
those who would want to automate the creation of
widgets/layers. Inline widgets for the most part will
have fixed parent-child relationships which is more
suitable for application specific widgets.

Benoit, I would suggest that you spear-head this new
implementation. You might also have to modify the docs
to indicate the importants of making sure
relationships are properly maintained when using
DynAPI Inline Widgets. All coding for this
implementation IMO should stored inside
dynlayer_inline.js

Keep up the good work!


Thanks

Benoit

--
Raymond Irving

Benoit



__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/


-------------------------------------------------------
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]/

Reply via email to