Well, I wrote an solution that would be simple to use but with
inheritance that is in my opinion is nice to have in larger projects.

Simple use:

$.plugin("simple_plugin", {
    options: {
        className: "simple_plugin",
        opt1: false
    },
    init: function( options ) {
        $(this.node).addClass(options.className);
        if ( options.opt1 ) {
            //...
        }
    }
});

To have an alternative simple_plugin but with some different default
options we can simply:

$.plugin("simple_plugin_2", {
    base: $.simple_plugin,
    options: {
        opt1: true
    }
});

Later, we can change some default options to simple_plugin that will
also apply to simple_plugin_2 if not overrided.

$.simple_plugin.setOptions({
    className: "sim_plugin"
});

$.simple_plugin_2.options.className == "sim_plugin"; // TRUE!


JQuery UI would inherit $.plugin.base to define $.widget:

$.widget = $.plugin.base.extended({
    init: function( options ) {
        //$.plugin.base.fn.init.call(this, options);
        this.call($.plugin.base, 'init', options);
        //...
    },
    fn: {
        enable: function() {
            //...
        }
        //...
    }
});

$.plugin("tabs", {
    base: $.widget
    //...
});


$.base is an generic base "class" (not plugin).

"class" in my implementation is an object (not function) to provide
static property inheritance too. Instead of the "new" operator, you
will use "$" static method to create an instance...

Hope this short intro will make my solution more clear to understand.


On May 5, 3:30 am, John Resig <[email protected]> wrote:
> It's not completely clear what your code does or how it would be used, from
> looking at it - do you have any examples?
>
> --John
>
> On Mon, May 4, 2009 at 7:43 PM, Robert Katić <[email protected]> wrote:
>
> > After some readings on the "A Modest Proposal: jQuery Enterprise"
> > discussion at
> >http://groups.google.com/group/jquery-dev/browse_frm/thread/1ec4dca6e...
> > ,
> > it is clear that jQuery needs an own widget system that will expose an
> > standard way to write widgets/plugins. This need is more evident on
> > larger projects. JQuery UI implements an own.
>
> > Some ideas:
> > jQuery UI:http://jquery-ui.googlecode.com/svn/trunk/ui/ui.core.js
> > John:http://dev.jquery.com/~john/plugins/widget/widget.js<http://dev.jquery.com/%7Ejohn/plugins/widget/widget.js>
> > my try with 
> > inheritance:http://bender.fesb.hr/~robert/jquery.plugin.js<http://bender.fesb.hr/%7Erobert/jquery.plugin.js>
>
> > Thoughts?
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to