Dialog windows open conditionally

This usage of global scope makes this code hard to read/maintain. Let's pass in hasSelection, selection and selectedContainer.

Also, I would prefer to define the shouldOpen methods for dialog types in a global. No need to re-define them on every call. `WYMeditor.DIALOG_OPEN_TESTS` perhaps?

A good API would be a dialog registration system on editor initialization where you would pass in dialog title, content handler, submit handler, opening test and anything else they need. This is a good step towards that, at least.