Requires

Provides

Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks.

License:
MIT-style license.
  1. 18
  2. 19
  3. 20
  4. 21
  5. 22
  6. 23
  7. 24
  8. 25
  9. 26
  10. 27
  11. 28
  12. 29
  13. 30
  14. 31
  15. 32
  16. 33
  17. 34
  18. 35
  19. 36
  20. 37
  21. 38
  22. 39
  23. 40
  24. 41
  25. 42
  26. 43
  27. 44
  28. 45
  29. 46
  30. 47
  31. 48
  32. 49
  33. 50
  34. 51
(function(){ this.Chain = new Class({ $chain: [], chain: function(){ this.$chain.append(Array.flatten(arguments)); return this; }, callChain: function(){ return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false; }, clearChain: function(){ this.$chain.empty(); return this; } }); var removeOn = function(string){ return string.replace(/^on([A-Z])/, function(full, first){ return first.toLowerCase(); }); }; this.Events = new Class({ $events: {}, addEvent: function(type, fn, internal){ type = removeOn(type);

<1.2compat>

  1. 54
if (fn == $empty) return this;

</1.2compat>

  1. 57
  2. 58
  3. 59
  4. 60
  5. 61
  6. 62
  7. 63
  8. 64
  9. 65
  10. 66
  11. 67
  12. 68
  13. 69
  14. 70
  15. 71
  16. 72
  17. 73
  18. 74
  19. 75
  20. 76
  21. 77
  22. 78
  23. 79
  24. 80
  25. 81
  26. 82
  27. 83
  28. 84
  29. 85
  30. 86
  31. 87
  32. 88
  33. 89
  34. 90
  35. 91
  36. 92
  37. 93
  38. 94
  39. 95
  40. 96
  41. 97
  42. 98
  43. 99
  44. 100
  45. 101
  46. 102
  47. 103
  48. 104
  49. 105
  50. 106
  51. 107
  52. 108
  53. 109
  54. 110
  55. 111
  56. 112
  57. 113
  58. 114
  59. 115
  60. 116
  61. 117
  62. 118
  63. 119
  64. 120
  65. 121
  66. 122
this.$events[type] = (this.$events[type] || []).include(fn); if (internal) fn.internal = true; return this; }, addEvents: function(events){ for (var type in events) this.addEvent(type, events[type]); return this; }, fireEvent: function(type, args, delay){ type = removeOn(type); var events = this.$events[type]; if (!events) return this; args = Array.from(args); events.each(function(fn){ if (delay) fn.delay(delay, this, args); else fn.apply(this, args); }, this); return this; }, removeEvent: function(type, fn){ type = removeOn(type); var events = this.$events[type]; if (events && !fn.internal){ var index = events.indexOf(fn); if (index != -1) delete events[index]; } return this; }, removeEvents: function(events){ var type; if (typeOf(events) == 'object'){ for (type in events) this.removeEvent(type, events[type]); return this; } if (events) events = removeOn(events); for (type in this.$events){ if (events && events != type) continue; var fns = this.$events[type]; for (var i = fns.length; i--;) if (i in fns){ this.removeEvent(type, fns[i]); } } return this; } }); this.Options = new Class({ setOptions: function(){ var options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments)); if (this.addEvent) for (var option in options){ if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue; this.addEvent(option, options[option]); delete options[option]; } return this; } }); })();