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

Proposed by Jonathan Jacobs
Status: Merged
Approved by: Jonathan Jacobs
Approved revision: 196
Merged at revision: 196
Proposed branch: lp:~methanal-developers/methanal/1081191-modaldialog-close-notification
Merge into: lp:methanal
Diff against target: 67 lines (+16/-3)
2 files modified
methanal/js/Methanal/Widgets.js (+15/-2)
methanal/themes/methanal-base/methanal-modal-dialog.html (+1/-1)
To merge this branch: bzr merge lp:~methanal-developers/methanal/1081191-modaldialog-close-notification
Reviewer Review Type Date Requested Status
Tristan Seligmann Needs Fixing
Jonathan Jacobs Approve
Review via email: mp+135191@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jonathan Jacobs (jjacobs) :
review: Approve
Revision history for this message
Tristan Seligmann (mithrandi) wrote :

I think it might be better if this had a notifyOnDisconnect()-type API where you get a new Deferred returned every time you call it.

review: Needs Fixing

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-07-18 15:03:32 +0000
3+++ methanal/js/Methanal/Widgets.js 2012-11-20 16:14:22 +0000
4@@ -1403,6 +1403,9 @@
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@@ -1411,13 +1414,22 @@
15 self.node.ownerDocument.body, 'printing');
16 Methanal.Util.addElementClass(
17 self.node, 'print-target');
18+ self.onClose = Divmod.Defer.Deferred();
19+ },
20+
21+
22+ /**
23+ * Cancel the dialog.
24+ */
25+ function cancel(self, node) {
26+ return self.close(node, true);
27 },
28
29
30 /**
31 * Dismiss the dialog.
32 */
33- function close(self) {
34+ function close(self, node, cancelled) {
35 Methanal.Util.removeElementClass(
36 self.node.ownerDocument.body, 'printing');
37 Methanal.Util.removeElementClass(
38@@ -1426,6 +1438,7 @@
39 self.detach();
40 self.node.parentNode.removeChild(self.node);
41 Methanal.Util.setModalOverlay(false);
42+ self.onClose.callback(!!cancelled);
43 });
44
45
46@@ -1488,7 +1501,7 @@
47 * Dismiss the dialog.
48 */
49 function cancel(self) {
50- self.widgetParent.close();
51+ self.widgetParent.cancel();
52 return false;
53 });
54
55
56=== modified file 'methanal/themes/methanal-base/methanal-modal-dialog.html'
57--- methanal/themes/methanal-base/methanal-modal-dialog.html 2011-02-16 23:10:30 +0000
58+++ methanal/themes/methanal-base/methanal-modal-dialog.html 2012-11-20 16:14:22 +0000
59@@ -2,7 +2,7 @@
60 <div class="modal-dialog-middle">
61 <div class="modal-dialog-inner">
62 <a href="#" class="modal-dialog-close" title="Close">
63- <athena:handler event="onclick" handler="close" />
64+ <athena:handler event="onclick" handler="cancel" />
65 </a>
66 <h1 nevow:render="dialogTitle" />
67 <div class="modal-dialog-content" nevow:render="dialogContent" />

Subscribers

People subscribed via source and target branches

to all changes: