Guest User

Untitled

a guest
Apr 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. // provide a shorter version to listen for events (like jQuery) but with a $-prefix
  2. // so it won't conflict with the builtin click() submit() etc.
  3. // $(element).$click(function() { ... });
  4.  
  5. (function() {
  6.  
  7. // Alias events to work directly as methods on elments
  8. var methods = {};
  9.  
  10. $w("blur focus load resize scroll unload click dblclick ready" +
  11. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  12. "change select submit keydown keypress keyup error").each(function(eventName) {
  13. methods['$' + eventName] = function(element, handler) {
  14. return Event.observe(element, eventName, handler);
  15. }
  16. });
  17.  
  18. Element.addMethods(methods);
  19.  
  20. // alias $(document).ready for dom:loaded: $(document).ready(function() { ... });
  21. Object.extend(document, {
  22. ready: Event.observe.curry(document, 'dom:loaded')
  23. });
  24. })();
Add Comment
Please, Sign In to add comment