ESC key support + 'cancel' event, autofocus, form[type=dialog]

- encapsulated entire code
- added ```ESC``` key support to cancel modal dialog
- fires ```cancel``` event before ```close``` on canceling modal dialog
- autofucus
- form[type=dialog]