Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(typeof Class == 'undefined') { var Class = function(){}; }
- if(!Class.def) {
- Class.def = function(def, stopConstruct) {
- if(!stopConstruct) { stopConstruct = false; }
- var obj = new def();
- var tmp = function(){};
- tmp.prototype = obj.definition;
- var Class = new tmp();
- if(typeof Class.init == 'function' && stopConstruct == false) {
- Class.init();
- }
- return Class;
- };
- Class.create = function(def) {
- var tmp = function(){
- this.definition = def;
- };
- return tmp;
- };
- Class.extends = function(parent, def) {
- var obj = this.def(parent, true);
- if(obj['init']) {
- obj._parent = { init: obj.init };
- }
- for(var x in def) {
- obj[x] = def[x];
- }
- return this.create(obj);
- };
- }
Add Comment
Please, Sign In to add comment