Event-driven widget classes for javascript