It's great to have such good advices. Please continue :)
j) same issue as i). I started like that, but ended up writing all the
blabla.prototype for each
method because of my doc tool :(
> I agree with most of what Satyam says except this:
> YAHOO.widget.Element, should be YAHOO.util.Element
> You should use this namespace call:
> YAHOO.namespace('inputEx');
> Then your namespace will be:
> YAHOO.inputEx..
> You want to stay away from putting things under the widget namespace,
> that's where YUI puts it's widgets ;)
> Dav
> On May 11, 2:09 pm, Deva Satyam <DevaSat...@gmail.com> wrote:
> > First of all, this looks great! I like it, otherwise I wouldn't have
> > bothered to check the source nor to write this message. I am a QA guy
> > (quality assurance) so I always looks for bugs, nothing personal, Ok?
> > a) Define your own namespace. Something like:
> > YAHOO.namespace('Neyric.inputEx');
> > or
> > YAHOO.namespace('widget.inputEx');
> > b) Use more of YAHOO.lang. Instead of
> > typeof something == 'function'
> > use
> > YAHOO.lang.isFunction(something)
> > c) make field extend YAHOO.widget.Element. All new YAHOO.widgets
> > inherit from Element so they all provide a standard base API. Only
> > the widgets prior to Element don't, and I am sure that will change in
> > the future.
> > Element already has some of the functionality you provide plus:
> > - It inherits from AttributeProvider, which gives you better
> > handling of configuration attributes
> > - AttributeProvider itself inherits from EventProvider which makes
> > it easier to declare and fire events.
> > d) Include the version number in your distribution folder, just as
> > YUI does so two versions of the library can coexists and you can
> > switch a page at a time.
> > e) Field options should be handled through AttributeProvider
> > Perhaps I should explain this better. AttributeProvider assembles a
> > list of Attribute objects. Look at the properties of
> > YAHOO.util.Attribute. You can set a validator for the attribute, set
> > read-only or wirte-once options and, most important, set a method
> > which will be called when the value is changed so that it can
> > immediately do something to the object. You cannot do with pasive
> > object properties since JavaScript does not provide getter and setter
> > methods. AttributeProvider is what allows, for example, in the
> > DataTable, if you do:
> > myDataTable.set('caption','this is the caption');
> > The datatable, already drawn in the browser, will suddenly show a
> > caption, because there is an Attribute method associated with that
> > property which is immediately triggered. Thus, setToolTipMessage,
> > could be converted into a toolTipMessage configuration attribute and
> > you could put the current code as the method property for that one
> > which would have immediate effect.
> > f) to be skinnable, your CSS file should have all selectors preceeded
> > by a skin name, like in yui-skin-sam. That allows any page to change
> > skins on-the-fly just by changing the className of the top-most
> > skinnable element, instead of having to load a different style sheet.
> > g) this is more like an idea: in a group, the optional property, if
> > the value is a string, all those with the same string value should be
> > grouped under that name in the screen so instead of just one optional
> > set of fields, you can several optional groups. If the value for
> > optional is boolean then you would do as now, making it backward
> > compatible.
> > h) If groups were enclosed in a fieldset element, a legend property
> > could be added.
> > i) enclose each object definition in an anonymous function so as to
> > define shortcuts inside
> > (function () {
> > var Dom = YAHOO.util.Dom, lang = YAHOO.lang
> > })();
> > That will shorten your code and will allow the YUI compressor to
> > minimize it even more since it can't minimize global variables but can
> > play freely with local variables.
> > j) This will allow the YUI Compressor to make even shorter code:
> > inputEx.Group.prototype = {
> > initEvents: function() {
> > YAHOO.util.Event.addListener(this.optionsLabel, "click",
> > this.onClickOptionsLabel, this, true);
> > },
> > /**
> > * Handle the click on the "Options" label
> > */
> > onClickOptionsLabel: function .....
> > The YUI compressor cannot compact references like
> > inputEx.Group.prototype.initEvents since they are public and need to
> > be accessible by that name from external code.
> > You can also use YAHOO.lang.augmentObject pretty much in the same way.
> > k) add a YAHOO.register call at the end so it can registers properly
> > and it can be used with the YUI Loader.
> > l) Use more shortcuts within your methods. Instead of:
> > if(this.options.ajax) {
> > this.options.ajax.method = this.options.ajax.method || 'POST';
> > this.options.ajax.uri = this.options.ajax.uri || 'default.php';
> > this.options.ajax.callback = this.options.ajax.callback || {};
> > this.options.ajax.callback.scope =
> > this.options.ajax.callback.scope || this;
> > }
> > };
> > do:
> > var ajax = this.options.ajax;
> > and then use that shortcut all over.
> > Anyway, if you use Element, this would be:
> > var ajax = this.get('ajax');
> > m) use CSS floats instead of tables to order elements
> > n) make classNames out of field names so users can tailor fields/
> > groups/forms.
> > o) not yet, I'll get to the o eventually ;-) Actually, I just looked
> > at the examples and browsed the code. I'll try the library tomorrow.
> > I liked it so far. After all, notice that all this suggestions are to
> > make it more YUI-like. The library works fine as it is.
> > Satyam