Guest User

Untitled

a guest
Jan 6th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. var Class = (function() {
  2.  
  3. function init() {
  4. return function() {
  5. if (this.initialize) {
  6. this.initialize.apply(this, arguments);
  7. }
  8. };
  9. }
  10.  
  11. function extend(protoProps, staticProps) {
  12. var parent = this;
  13.  
  14. var child = init();
  15.  
  16. window.$.extend(child, parent, staticProps);
  17.  
  18. var proto = Object.create(parent.prototype);
  19. proto.constructor = child;
  20. child.prototype = proto;
  21.  
  22. window.$.extend(child.prototype, protoProps);
  23.  
  24. child.superClass = parent.prototype;
  25.  
  26. return child;
  27. }
  28.  
  29. var Class = function(protoProps) {
  30. var cls = init();
  31.  
  32. window.$.extend(cls.prototype, protoProps);
  33.  
  34. cls.extend = extend;
  35.  
  36. return cls;
  37. };
  38.  
  39. Class.extend = extend;
  40.  
  41. return Class;
  42.  
  43. })();
  44.  
  45. export default Class
  46.  
  47.  
  48. // WEBPACK FOOTER //
  49. // ./src/utility/class.js
Add Comment
Please, Sign In to add comment