Guest User

Untitled

a guest
Jul 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. if(typeof Class == 'undefined') { var Class = function(){}; }
  2. if(!Class.def) {
  3. Class.def = function(def, stopConstruct) {
  4. if(!stopConstruct) { stopConstruct = false; }
  5. var obj = new def();
  6. var tmp = function(){};
  7. tmp.prototype = obj.definition;
  8. var Class = new tmp();
  9. if(typeof Class.init == 'function' && stopConstruct == false) {
  10. Class.init();
  11. }
  12. return Class;
  13. };
  14.  
  15. Class.create = function(def) {
  16. var tmp = function(){
  17. this.definition = def;
  18. };
  19. return tmp;
  20. };
  21.  
  22. Class.extends = function(parent, def) {
  23. var obj = this.def(parent, true);
  24. if(obj['init']) {
  25. obj._parent = { init: obj.init };
  26. }
  27. for(var x in def) {
  28. obj[x] = def[x];
  29. }
  30. return this.create(obj);
  31. };
  32. }
Add Comment
Please, Sign In to add comment