Requires

Provides

Class.Includes.js

Multiple inheritance in mootools, chained Extend basically.

License:
MIT-style license.
  1. 21
  2. 22
  3. 23
  4. 24
  5. 25
  6. 26
  7. 27
  8. 28
  9. 29
  10. 30
  11. 31
  12. 32
  13. 33
  14. 34
  15. 35
  16. 36
  17. 37
  18. 38
  19. 39
  20. 40
  21. 41
  22. 42
  23. 43
  24. 44
  25. 45
  26. 46
  27. 47
  28. 48
  29. 49
  30. 50
  31. 51
  32. 52
  33. 53
  34. 54
  35. 55
  36. 56
  37. 57
  38. 58
  39. 59
  40. 60
  41. 61
  42. 62
  43. 63
  44. 64
  45. 65
  46. 66
  47. 67
  48. 68
  49. 69
  50. 70
(function() { var getInstance = function(klass){ klass.$prototyping = true; var proto = new klass; delete klass.$prototyping; return proto; }; Class.include = function(klass, klasses) { return new Class({ Includes: Array.from(arguments).flatten() }); }; Class.flatten = function(items) { return Array.from(items).clean().map(function(item, i) { if (item.parent) { return [Class.flatten(item.parent), item]; } else { return item; } }).flatten(); }; Class.Mutators.Includes = function(items) { items = Array.from(items); var instance = this.parent ? this.parent : items.shift(); Class.flatten(items).each(function(parent){ var baked = new Class; if (instance) { baked.parent = instance; baked.prototype = getInstance(instance); } var proto = Object.append({}, parent.prototype); delete proto.$caller; delete proto.$constructor; delete proto.parent; delete proto.caller; for (var i in proto) { var fn = proto[i]; if (fn && fn.$owner && (fn.$owner != parent) && fn.$owner.parent) delete proto[i]; } baked.implement(proto); instance = baked; }, this); this.parent = instance; this.prototype = getInstance(instance); }; })();