Requires

Provides

Adds the functionallity to add pseudo events

License:
MIT-style license
Authors:
Arian Stolwijk
  1. 20
  2. 21
  3. 22
  4. 23
  5. 24
  6. 25
  7. 26
  8. 27
  9. 28
  10. 29
  11. 30
  12. 31
  13. 32
  14. 33
  15. 34
  16. 35
  17. 36
  18. 37
  19. 38
  20. 39
  21. 40
  22. 41
  23. 42
  24. 43
  25. 44
  26. 45
  27. 46
  28. 47
  29. 48
  30. 49
  31. 50
  32. 51
  33. 52
  34. 53
  35. 54
  36. 55
  37. 56
  38. 57
  39. 58
  40. 59
  41. 60
  42. 61
  43. 62
  44. 63
  45. 64
  46. 65
  47. 66
  48. 67
  49. 68
  50. 69
  51. 70
  52. 71
  53. 72
  54. 73
  55. 74
  56. 75
  57. 76
  58. 77
  59. 78
  60. 79
  61. 80
  62. 81
  63. 82
  64. 83
  65. 84
  66. 85
  67. 86
  68. 87
  69. 88
  70. 89
  71. 90
  72. 91
  73. 92
  74. 93
  75. 94
  76. 95
  77. 96
  78. 97
  79. 98
  80. 99
  81. 100
  82. 101
  83. 102
  84. 103
  85. 104
  86. 105
  87. 106
  88. 107
  89. 108
  90. 109
  91. 110
  92. 111
  93. 112
  94. 113
  95. 114
  96. 115
  97. 116
Events.Pseudos = function(pseudos, addEvent, removeEvent){ var storeKey = 'monitorEvents:'; var getStorage = function(object){ return { store: object.store ? function(key, value){ object.store(storeKey + key, value); } : function(key, value){ (object.$monitorEvents || (object.$monitorEvents = {}))[key] = value; }, retrieve: object.retrieve ? function(key, dflt){ return object.retrieve(storeKey + key, dflt); } : function(key, dflt){ if (!object.$monitorEvents) return dflt; return object.$monitorEvents[key] || dflt; } }; }; var splitType = function(type){ if (type.indexOf(':') == -1) return null; var parsed = Slick.parse(type).expressions[0][0], parsedPseudos = parsed.pseudos; return (pseudos && pseudos[parsedPseudos[0].key]) ? { event: parsed.tag, value: parsedPseudos[0].value, pseudo: parsedPseudos[0].key, original: type } : null; }; return { addEvent: function(type, fn, internal){ var split = splitType(type); if (!split) return addEvent.call(this, type, fn, internal); var storage = getStorage(this); var events = storage.retrieve(type, []); var self = this; var monitor = function(){ pseudos[split.pseudo].call(self, split, fn, arguments); }; events.include({event: fn, monitor: monitor}); storage.store(type, events); return addEvent.call(this, split.event, monitor, internal); }, removeEvent: function(type, fn){ var split = splitType(type); if (!split) return removeEvent.call(this, type, fn); var storage = getStorage(this); var events = storage.retrieve(type); if (!events) return this; events.each(function(monitor, i){ if (!fn || monitor.event == fn) removeEvent.call(this, split.event, monitor.monitor); delete events[i]; }, this); storage.store(type, events); return this; } }; }; (function(){ var pseudos = { once: function(split, fn, args){ fn.apply(this, args) this.removeEvent(split.original, fn); } }; Events.definePseudo = function(key, fn){ pseudos[key] = fn; }; Events.implement(Events.Pseudos(pseudos, Events.prototype.addEvent, Events.prototype.removeEvent)); })();