candy-chat/candy — pull request #303 by strix-technica (2014-09-22 18:57:58+00:00)
Title: Feature/domain selector

Adds to the login form an optional selection box containing a fixed list of domains. When core option `domains` is set (a list), the login form will present this box and, when the user clicks 'login', will first strip any user-provided domain and append the selected domain before handing over to Strophe to log in.

Only the first space-delineated word of the selected domain is used, which means the Candy admin can append a small amount of extra information to the domain if desired (eg ['foo.com (staff only)', 'users.foo.com (everybody else)'])

The most obvious problem with the patch as it currently stands is that I've had to widen the login form to accommodate the extra field (thereby widening all modal dialogue boxes), and I haven't yet figured how to write CSS that widened just the login form (because there didn't appear to be any class login-specific class on div.chat-modal to attach it to). I'm guessing that some modification needs to be made to the thing that generates div.chat-modal to do that, but I'm not sure how to go about that, or even if that's a sensible idea.

Alternatively, I could modify the base CSS directly from within Candy.View.Pane.showLoginForm() — but I'm unsure what prevailing practices in this respect are, and fiddling with CSS from JS somehow doesn't quite seem right.

The other objection might be that Candy.View.Pane.showLoginForm() fetches its domain list by calling Candy.Core.getOptions() rather than having the list passed as an argument — probably not 'best practice'.