/*!
* Arenite JavaScript Library v2.1.2
* https://github.com/lcavadas/arenite
*
* Copyright 2014, Luís Serralheiro
*/
/* global Arenite:true */
/*!
* Arenite JavaScript Library v2.1.2
* https://github.com/lcavadas/arenite
*
* Copyright 2014, Luís Serralheiro
*/
/* global Arenite:true */
Arenite is an implementation of the Sandbox and Module patterns. It was designed to, unlike most of the existing module libraries, not affect your code making it dependant on the module library itself.
Base of the arenite sandbox object. Creates the base services in the arenite sandbox object.
Using the Namespace and MVP (or MVC) patterns is strongly recommended but not mandatory.
You can create further extensions to the sandbox by providing new services or overriding already imported ones.
There are a few extensions included in this repository and you can read more about them here.
For more information about the mentioned patterns consult the book “Javascript Patterns” by Stoyan Stefanov from O’Reilly Media which discusses these patterns in detail.
The documentation for the configuration is presented in the website.
Arenite = function (config) {
Instance of the Sandbox is started with the Arenite.Object module witch gives us access to the extend
function used.
var arenite = Arenite.Object();
Add the object and array helper methods to their respective prototypes
arenite.object.forEach(arenite.object, function (func, name) {
if (!Object.prototype[name]) {
Object.defineProperty(Object.prototype, name, {
writable: true,
enumerable: false,
value: function () {
return func.apply(this, [this].concat([].slice.call(arguments)));
}
});
}
});
arenite.object.forEach(arenite.array, function (func, name) {
if (!Array.prototype[name]) {
Object.defineProperty(Array.prototype, name, {
writable: true,
enumerable: false,
value: function () {
return func.apply(this, [this].concat([].slice.call(arguments)));
}
});
}
});
arenite.fuseWith(Arenite.Html(arenite));
Extend the instance with the Arenite.Async extension providing the asynchronous tools (Latch Pattern) used by the Loader extension.
arenite.fuseWith(Arenite.Async(arenite));
Extend the instance with the Arenite.Url extension which provides functions for analysis of query parameters.
arenite.fuseWith(Arenite.Url(arenite));
Extend the instance with the Arenite.DI extension which provides the injector functionality.
arenite.fuseWith(Arenite.DI(arenite));
Extend the instance with the Arenite.AnnotationProcessor extension which provides the parsing and hanlding of annotations.
arenite.fuseWith(Arenite.AnnotationProcessor(arenite));
Extend the instance with the Arenite.Context extension which provides the context to manage the instances.
arenite.fuseWith(Arenite.Context(arenite));
Extend the instance with the Arenite.Loader extension which provides the script and resource loading functionality to the sandbox.
arenite.fuseWith(Arenite.Loader(arenite));
arenite.fuseWith(Arenite.Bus(arenite));
Initialize the injector by having it read the configuration object passed into this constructor.
arenite.di.init(config);
return arenite;
};