Requires

Provides

Type.js

A base class for all class pools

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin
  1. 27
  2. 28
  3. 29
  4. 30
  5. 31
  6. 32
  7. 33
  8. 34
  9. 35
  10. 36
  11. 37
  12. 38
  13. 39
  14. 40
  15. 41
  16. 42
  17. 43
  18. 44
  19. 45
  20. 46
  21. 47
  22. 48
  23. 49
  24. 50
  25. 51
  26. 52
  27. 53
  28. 54
  29. 55
  30. 56
  31. 57
  32. 58
  33. 59
  34. 60
  35. 61
  36. 62
  37. 63
LSD.Type = function(name, namespace) { this.name = name; this.count = 0; this.namespace = namespace || 'LSD'; var holder = Object.getFromPath(window, this.namespace); if (this.storage = holder[name]) { for (var key in this) this.storage[key] = (this[key].call) ? this[key].bind(this) : this[key]; } else this.storage = (holder[name] = this); this.pool = [this.storage]; this.queries = {}; }; LSD.Type.prototype = { each: function(callback, bind) { for (var name in this.storage) { var value = this.storage[name]; if (value && value.$family && value.$family() == 'class') callback.call(bind || this, value, name) } }, find: function(name) { if (!this.queries) this.queries = {}; else if (this.queries[name] != null) return this.queries[name]; name = LSD.toClassName(name); for (var i = 0, storage; storage = this.pool[i++];) { var result = Object.getFromPath(storage, name); if (result) return (this.queries[name] = result); } return (this.queries[name] = false); }, create: function(name, a, b, c, d) { var widget = this.find(name); if (!widget) throw 'Class named LSD.' + LSD.toClassName(this.name) + '.' + LSD.toClassName(name) + ' was not found'; this.count++; return new widget(a, b, c, d); } }

must-have stuff for all widgets

  1. 65
new LSD.Type('Module');

some widgets may use those

  1. 67
new LSD.Type('Trait');

these may be applied in runtime

  1. 69
new LSD.Type('Mixin');

these may be applied in runtime

  1. 71
new LSD.Type('Element');