a zip code crypto-currency system good for red ONLY

customevents.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function() {
  2. var CustomEvents;
  3. CustomEvents = {
  4. bind: function(element, eventName, handler) {
  5. if (element.addEventListener) {
  6. return element.addEventListener(eventName, handler, false);
  7. } else if (element.attachEvent) {
  8. element[eventName] = 1;
  9. return element.attachEvent('onpropertychange', function(event) {
  10. if (event.propertyName === eventName) {
  11. return handler();
  12. }
  13. });
  14. } else {
  15. throw new Error("Attempt to attach custom event " + eventName + " to something which isn't a DOMElement");
  16. }
  17. },
  18. fire: function(element, eventName) {
  19. var event;
  20. if (element.addEventListener) {
  21. event = document.createEvent('HTMLEvents');
  22. event.initEvent(eventName, true, true);
  23. return document.dispatchEvent(event);
  24. } else if (element.attachEvent) {
  25. if (element[eventName]) {
  26. return element[eventName]++;
  27. }
  28. } else {
  29. throw new Error("Attempt to fire custom event " + eventName + " on something which isn't a DOMElement");
  30. }
  31. }
  32. };
  33. exports.bind = CustomEvents.bind;
  34. exports.fire = CustomEvents.fire;
  35. }).call(this);