jQuery-class

jQuery Class


Project maintained by EyeCode

Welcome to jQuery Class Component.

Simple and easy jquery class builder with namespacing

Perequisite:

Basic Exemple:

$.Class({
    required: ["Foo.Bar"],// (array) optional..
    namespace: "Foo",

    consts: {
        someConstant: "constant"
    },

    someFunction: function: () {
        // some code..
    }
});
$.Class({
    namespace: "Foo.Bar"
    // ...
});
                

Foo and Bar are initially individual plugin, combining it with namespace is where the fun start..

Doing thing like this, you building an App containing foo and bar where bar is in foo!

And much more, you can provide required classes, that way, all namespace provided to the "required" params (as array) need to be loaded before initializing current plugin, that's provide a kind of loading priority where you don't have to bother with the way you are calling your source files

One more thing, functions declaration beginning with "init...", will automatically be called after the complete load of the class.

To access bar from foo you simply do

this.Bar.anyFunctionOrVar()

or

Foo.Bar.anyFunctionOrVar()

To access foo from bar you simply do

Foo.anyFunctionOrVar()

consts are used as a constant holder where sub variable are simply a getter. If used like the exemple above, this give something like

Foo.someConstant() // >> return "constant"

Inheritance Exemple:

$.Class({
    namespace: "Foo",

    consts: {
        someConstant: "constant"
    },

    someFunction: function: () {
        // some code..
    }
});

$.Class([Foo], {
    namespace: "Bar"
    // ...
});
                

Now bar inherit from foo and have same properties/functions, so you can use it like this:

Bar.someConstant() // >> return "constant"

You can also check for an instanceof like this

Bar.instanceOf(Foo) // >> return true or false if not

# Todo :

Authors and Contributors

2016 EyeCode