adobe/brackets — pull request #4087 by iwehrman (2013-06-04 19:45:01+00:00)
Title: Dialog.done should return itself for chaining

With the the recent modal dialog changes, `Dialogs.showModalDialogUsingTemplate()` returns a `Dialog` object that encapsulates a jQuery object representing the displayed dialog and a dismissal promise. For convenience and some measure of compatibility with the previous implementation, the `Dialog` object directly exposes the `done()` method of its promise.

This is great, but it would be even better if the `Dialog.done()` returned itself to support the following idiom:
```
var dlg = Dialogs.showModalDialogUsingTemplate(template).done(function () {
// do something when the dialog closes
});

$otherThing.on("click", function () {
// do something else and close the dialog
dlg.close()
});
```
I like this because it reminds me of the promise chaining idiom that `Dialog.done()` mimicks.

This pull request just adds `return this;` to the definition of `Dialog.prototype.done` to accomplish this.

CC @TomMalbran