function Class (ns) {
this.toString = function () { return ns; };
}
Class.def = function (ns, ctx) {
var c = window;
var ns = ns.split('.');
for (var i = 0, ix = ns.length - 1; i < ix; i++)
c = c[ns[i]] instanceof Object ? c[ns[i]] : c[ns[i]] = {};
if (!(ctx.init instanceof Function)) ctx.init = function () {};
c = c[ns[i]] = function () { this.constructor.apply(this, arguments); };
c.prototype = new Class(ns.join('.'));
c.prototype.constructor = ctx.init;
for (var key in ctx) if (ctx.hasOwnProperty(key)) {
if (key != 'init') c.prototype[key] = ctx[key];
}
return c;
};
Class (instanceof Class)
Category: Uncategorized |
Tags: js
Leave a Reply
You must be logged in to post a comment.