Refactor message group selector

* Store references to dom nodes in member variables to avoid querying
  them over and over again
* Refactor some code into separate functions for clarity
* Consistency and style improvements:
** New line after dom node creation
** groupSelector = this
** use $.proxy when possible
** use .then() to transform return values in promises
* Fixes a bug where filter was not applied if user was typing before
  groups were loaded
* Use 'one' for the event to close the menu to avoid extra processing

Change-Id: I8175a78e1becb3276550b360d6dbbd41b800de64