Moved common logic to global coffeescript functions, as much as possible.

Event handlers now are very semantic, calling functions with descriptive names. Event handlers themselves have as little CSS and DOM manipulation as possible; this way if the specifics of the markup and CSS change, the code modifications needed are confined to the auxiliary functions, and the logic in the event handlers themselve can remain untouched.

This finishes DRYing efforts on coffeescript code, for now at least.