[mochikit] Re: EventMap for Signal?

2006-10-12 Thread Pablo Montilla

Done:
http://trac.mochikit.com/ticket/198

Regards,
Pablo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: EventMap for Signal?

2006-10-11 Thread Beau Hartshorne

On 11-Oct-06, at 3:20 AM, Pablo Montilla wrote:

> Well, its not beautiful but it works.
>
> It would be better if the selection of elements to be connected were
> done using a function as parameter (so its decoupled, and extensible):

I like the interface. Could you please submit a ticket, and attach  
your code so far?

Thanks!
Beau


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: EventMap for Signal?

2006-10-11 Thread Pablo Montilla


Jorge Godoy wrote:
> I'd like seeing your code. :-)  You could post it here to the list.
>
> Getting something like that with map() wouldn't be all that hard (but why
> reinventing the wheel if you have already done the hard part? ;-))...
>
> --
> Jorge Godoy  <[EMAIL PROTECTED]>

Well, its not beautiful but it works.

It would be better if the selection of elements to be connected were
done using a function as parameter (so its decoupled, and extensible):

function connectEventMap(eventMap, parent)
{
parent = parent || document.body;

forEach(eventMap, partial(connectEventMapItem, parent));
}

function connectEventMapItem(parent, eventSpec)
{
var items;
var selector;
if(eventSpec.name) {
items= base.filter(
partial(hasParent, parent),
document.getElementsByName(eventSpec.name)
);
selector = 'name';
}
else if(eventSpec.id) {
items= [getElement(eventSpec.id)];
selector = 'id';
}
else if(eventSpec.tag) {
items= getElementsByTagAndClassName(eventSpec.tag, null, 
parent);
selector = 'tag';
}

forEach(items, function(item) {
if(item) {
for(var eventName in eventSpec) {
if(eventName != selector) {
connect(item, eventName, 
eventSpec[eventName]);
}
}
}
})
}


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: EventMap for Signal?

2006-10-10 Thread Jorge Godoy

"Pablo Montilla" <[EMAIL PROTECTED]> writes:

> Hello, I've started using a declarative way for my event connections. I
> would create an array with objects that define the different events and
> its targets, and then call a generic connectEventMap() method that
> would do the plumbing for me. An example would be:
> var eventMap = [
>   { name: 'credit', onkeyup:  onValueKeyUp },
>   { name: 'debit',  onkeyup:  onValueKeyUp },
>   { name: 'creditNational', onkeyup: onNationalValueKeyUp, onchange:
> onInputChange },
>   { name: 'debitNational',  onkeyup: onNationalValueKeyUp, onchange:
> onInputChange },
>   { tag: 'input', onblur: onInputBlur }
> ]
>
> Could something like this be useful for MochiKit?

I'd like seeing your code. :-)  You could post it here to the list. 

Getting something like that with map() wouldn't be all that hard (but why
reinventing the wheel if you have already done the hard part? ;-))... 

-- 
Jorge Godoy  <[EMAIL PROTECTED]>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---