Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser for Prototype 1.7 #11

Open
victor-homyakov opened this issue Jul 19, 2012 · 3 comments
Open

Parser for Prototype 1.7 #11

victor-homyakov opened this issue Jul 19, 2012 · 3 comments

Comments

@victor-homyakov
Copy link
Contributor

Current Prototype events parser is working only for versions 1.6.X. In Prototype 1.7 event registry was changed, so I wrote new parser:

(function(window, document, $, VisualEvent) {

  function dumpListeners(event) {
    var listeners = [];

    for (var eventType in event) {
      var handlers = event[eventType];

      for (var i = 0, len = handlers.length; i < len; i++) {
        listeners.push({
          "type": eventType,
          "func": handlers[i].handler.toString(),
          "removed": false,
          "source": 'Prototype 1.7+'
        });
      }
    }

    return listeners;
  }

  VisualEvent.parsers.push(function() {
    if (typeof Prototype == 'undefined') {
      return [];
    }

    var elements = [], event;

    for (var e in Event.cache) {
      event = Event.cache[e];
      elements.push({
        "node": event.element,
        "listeners": dumpListeners(event)
      });
    }

    return elements;
  });

})(window, document, jQuery, VisualEvent);
@DataTables
Copy link
Collaborator

Fantastic - I'll add a file for that - unless you already have a merge ready pull request? :-)

@victor-homyakov
Copy link
Contributor Author

I've made it from browser, and there is no possibility to add new files to project from browser.

@victor-homyakov
Copy link
Contributor Author

I've committed it in my fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant