Jörn,

Thanks for all of your feedback! Those are excellent pointers and will help
greatly in the refactor! Thanks again!

-Jonathan


On 2/2/07, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:

Jonathan Sharp schrieb:
> I'm just starting on a refactor of this code and am making several
> improvements including accepting settings when initializing, handling
> events through delegation, replacing the iframe code with bgiframe and
> supporting vertical menus.
>
> So before I undergo this refactor. There have been several approaches
> to structuring plugin's and I wanted to ask which approach is
> "standard" or closest to "standard" for how plugin's should be
> developed. A few things to note is the use of the wrapper function
> passing in jQuery, internal functions not bound directly to the jQuery
> object. So any feedback is much appreciated!
>
> Source Reference:
> http://jdsharp.us/code/jQuery/plugins/jdMenu/jquery.jdMenu.js
See http://docs.jquery.com/Core#.24.28_fn_.29 for a little trick to make
the ready event not rely on the $ alias. In your case:

jQuery(function($){
        $('ul.jd_menu').jdMenu();
        $(document).bind('click', function() {
                $('ul.jd_menu ul:visible').jdMenuHide();
        });
});

In addition, you could optimize the above by saving the 'ul.jd_menu'
selection.

When defining multiple variables, I like to write "var" only once, and
adding a tab in front of the others, in my editor, they are still nicely
aligned then.

var xxx,
    yzs;

removeEvent() is used only once, so you don't really need an extra
function for that.

It's nice for readability to avoid one-character variable names. If you
use them, add a comment that explains what the variable is used for.
Considerung compressed file size: You save the amount of bytes used for
the variable name only once, it doesn't matter how often it is used.

css() automatically adds "px" to values passed as a number, where
appropiate (it excludes eg. opacity and z-index), so you don't need to
add that in your code.

There are a few very similar lines of code in the hoverXXX functions,
that could be refactored.

A few more comments here and there help the reader, and you wouldn't ask
for a code review if you wouldn't care about the reader :-)

Mhmm, I'm really nitpicking here, good job!

--
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to