Merge lp:~methanal-developers/methanal/1081191-modaldialog-close-notification-2 into lp:methanal

Proposed by Jonathan Jacobs
Status: Merged
Approved by: Tristan Seligmann
Approved revision: 198
Merged at revision: 197
Proposed branch: lp:~methanal-developers/methanal/1081191-modaldialog-close-notification-2
Merge into: lp:methanal
Diff against target: 46 lines (+19/-5)
1 file modified
methanal/js/Methanal/Widgets.js (+19/-5)
To merge this branch: bzr merge lp:~methanal-developers/methanal/1081191-modaldialog-close-notification-2
Reviewer Review Type Date Requested Status
Tristan Seligmann Approve
Review via email: mp+135319@code.launchpad.net
To post a comment you must log in.
198. By Jonathan Jacobs

Remove old Deferred.

Revision history for this message
Tristan Seligmann (mithrandi) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'methanal/js/Methanal/Widgets.js'
2--- methanal/js/Methanal/Widgets.js 2012-11-20 16:12:15 +0000
3+++ methanal/js/Methanal/Widgets.js 2012-11-21 06:21:17 +0000
4@@ -1403,9 +1403,6 @@
5
6 /**
7 * Modal dialog widget.
8- *
9- * @ivar onClose: L{Deferred} that is fired with a L{Boolean}, indicating if
10- * the dialog was cancelled, when the dialog is closed.
11 */
12 Nevow.Athena.Widget.subclass(Methanal.Widgets, 'ModalDialog').methods(
13 function nodeInserted(self) {
14@@ -1414,7 +1411,22 @@
15 self.node.ownerDocument.body, 'printing');
16 Methanal.Util.addElementClass(
17 self.node, 'print-target');
18- self.onClose = Divmod.Defer.Deferred();
19+ self._notifyOnClose = [];
20+ },
21+
22+
23+ /**
24+ * Get a L{Deferred} that is fired when this dialog is closed.
25+ *
26+ * The L{Deferred} is fired with a boolean indicating whether the dialog
27+ * was cancelled.
28+ *
29+ * @rtype: L{Deferred}
30+ */
31+ function notifyOnClose(self) {
32+ var d = Divmod.Defer.Deferred();
33+ self._notifyOnClose.push(d);
34+ return d;
35 },
36
37
38@@ -1438,7 +1450,9 @@
39 self.detach();
40 self.node.parentNode.removeChild(self.node);
41 Methanal.Util.setModalOverlay(false);
42- self.onClose.callback(!!cancelled);
43+ for (var i = 0; i < self._notifyOnClose.length; ++i) {
44+ self._notifyOnClose[i].callback(!!cancelled);
45+ }
46 });
47
48

Subscribers

People subscribed via source and target branches

to all changes: