MDL-35674 Move logic for event application formslib to event handler

Rather than creating lots of events on individual form elements, apply
events to all elements with any dependency and test during the event
handler.