Javascript framework for encapsulating logic for DOM nodes