0.1.6 • Published 10 years ago

strapjs v0.1.6

Weekly downloads
11
License
MIT
Repository
github
Last release
10 years ago

strap.js

Documentation

Browser compatibility

This library is designed to be used in all modern browsers and Node.js.

Known issues

  • phantomjs not fully supported! At the moment some unit tests are failing (namespace loader) due to some strange errors with qunit and phantomjs

HelloWorld the simple way

// define the class
var Hello = class_({

    // constructor
    initialize: function(name) {
        this.name = name;
    },

    // method with your own logic
    output: function() {
        alert("Hello " + this.name + "!");
    }

});

// create instances of the the class
var instance1 = new Hello("World");
var instance2 = new Hello("strap.js");

// work with the instances
instance1.output(); // --> "Hello World!"
instance2.output(); // --> "Hello strap.js!"

// overwrite instance
instance1 = new Hello("Ninja");
instance1.output(); // --> "Hello Ninja!"

HelloWorld with namespaces

Class definition:

namespace_('strapjs.examples.helloworld', {

    HelloWorld: class_({

        // constructor
        initialize : function(name) {
            this.name = name;
        },

        // method with your own logic
        output : function() {
            alert("Hello " + this.name + "!");
        }

    })
});

Class usage:

// register the namespaces to use
var used = use_('strapjs.examples.helloworld');

// create an instance using the loader
var tst1 = used.create('HelloWorld', ['World!']);

// create an instance using the load with callback
var tst2 = used.create('HelloWorld', ['Dude!'], function(wrld2) {
    alert('callback ' + wrld2.name);
}); // --> "callback Dude!"

// create an instance without the loader but the whole namespace
var tst3 = new strapjs.examples.helloworld.HelloWorld('Ninja!');

// work with the instances
tst1.output(); // --> "Hello World!"
tst2.output(); // --> "Hello Dude!"
tst3.output(); // --> "Hello Ninja!"
0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago