Ticket #198 (new enhancement)

Opened 2 years ago

Last modified 1 year ago

EventMap for Signal

Reported by: melkor@odyssey.com.uy Assigned to: somebody
Priority: normal Milestone: MochiKit 1.5
Component: component1 Version:
Severity: normal Keywords: MESSAGE
Cc: New, York

Description

Connect events to objects using a declarative object syntax. An example event map could be

var eventMap = [
  { name: 'anInputName', onkeyup:      doSomethingOnKeyUp },
  { tag:  'table',       onmouseover:  tablesOnMouseOver },
  { id:   'thisElement', onfocus:      thisElementOnFocus }
]

And to connect the events a call to connectEventMap(eventMap) suffices.

Attachments

EventMap.js (1.2 kB) - added by melkor@odyssey.com.uy on 10/12/06 04:21:22.

Change History

10/12/06 04:21:22 changed by melkor@odyssey.com.uy

  • attachment EventMap.js added.

(follow-up: ↓ 2 ) 10/12/06 06:09:18 changed by arnarbi@gmail.com

If the selector branch gets merged, you could add

var eventMap = [
  { selector: 'table#teams td.homeTeam', onclick:    showPlayers }
]

(in reply to: ↑ 1 ; follow-ups: ↓ 3 ↓ 4 ) 10/14/06 09:50:38 changed by anonymous

Replying to arnarbi@gmail.com:

That's something I was thinking. Maybe a better approach can be to give the connectEventMap an object with selectors, and select signal targets using the first matching property of each row in the event map.

A sample selector object could be like this:

var selectors = {
   css: function(selector) {
      ...
   },
   name: function(selector) {
      return document.getElementsByName(selector);
   },
   tag:  function(selector) {
      return getElementsByTagAndClassName(selector)
   }
}

connectEventMap(eventMap, parent, selectors);

We'd use the selectors object inside the connectEventMapItem().

That way you maintain a default mechanism, that's easy to read and extensible.

(in reply to: ↑ 2 ) 10/14/06 09:51:57 changed by melkor@odyssey.com.uy

Replying to anonymous: Oops that would be me (melkor@odyssey.com.uy), not anonymous...=)

(in reply to: ↑ 2 ) 10/16/06 02:46:39 changed by arnarbi@gmail.com

Replying to anonymous:

That's something I was thinking. Maybe a better approach can be to give the connectEventMap an object with selectors, and select signal targets using the first matching property of each row in the event map.

That sounds good. I'd suggest having this object stored somewhere globally but users would manipulate it via functions like "registerEventMapSelector" and "unregisterEventMapSelector" or such.

12/25/06 08:43:35 changed by felician

  • cc set to New, York.
  • keywords set to MESSAGE.

Thanks for the welcome Christmas Day falls on December 25. It is preceded by Christmas Eve on December 24, and in some countries is followed by Boxing Day on December 26. Some Eastern Orthodox Churches celebrate Christmas on January 7, which corresponds to December 25 on the Julian calendar. December 25 as a birthdate for Jesus is merely traditional, and is not thought to be his actual date of birth.Sincerely

05/14/07 17:46:57 changed by rsayre@mozilla.com

  • milestone set to MochiKit 1.5.

no activity since December. v1.5 if ever.