Guest User

Untitled

a guest
Jan 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. var Class = function(){
  2. var klass = function(){
  3. this.init.apply(this, arguments);
  4. };
  5.  
  6. klass.prototype.init = function(){};
  7.  
  8. // Shortcut to access prototype
  9. klass.fn = klass.prototype;
  10.  
  11. // Shortcut to access class
  12. klass.fn.parent = klass;
  13.  
  14. // Adding class properties
  15. klass.extend = function(obj){
  16. var extended = obj.extended;
  17. for(var i in obj) {
  18. klass[i] = obj[i];
  19. }
  20. if (extended) extended(obj)
  21. };
  22.  
  23. // Adding instance properties
  24. klass.include = function(obj) {
  25. var included = obj.included;
  26. for (var i in obj) {
  27. klass.fn[i] = obj[i];
  28. }
  29. if (included) included(klass)
  30. };
  31.  
  32. return klass;
  33. };
Add Comment
Please, Sign In to add comment