Skip to content

Commit a4952bd

Browse files
yellowandyjosteink
authored andcommitted
adding ability to listen for compose close events
1 parent 59a6961 commit a4952bd

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/gmail.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,7 @@ var Gmail_ = function(localJQuery) {
12651265
handler: function(match, callback) {
12661266
// console.log('reply_forward handler called', match, callback);
12671267

1268+
var originalMatch = match;
12681269
// look back up the DOM tree for M9 (the main reply/forward node)
12691270
match = match.closest('div.M9');
12701271
if (!match.length) return;
@@ -1274,6 +1275,16 @@ var Gmail_ = function(localJQuery) {
12741275
type = match.find('input[name=subject]').val().indexOf('Fw') == 0 ? 'forward' : 'reply';
12751276
} else {
12761277
type = 'compose';
1278+
1279+
//Find the close button and set an event listener so we can forward the compose_cancelled event.
1280+
var composeWindow = originalMatch.closest('div.AD');
1281+
composeWindow.find('.Ha').mouseup(function() {
1282+
if(api.tracker.composeCancelledCallback) {
1283+
api.tracker.composeCancelledCallback(match);
1284+
}
1285+
return true;
1286+
});
1287+
12771288
}
12781289
callback(match,type);
12791290
}
@@ -1394,7 +1405,12 @@ var Gmail_ = function(localJQuery) {
13941405
return true;
13951406

13961407
// support for gmail interface load event
1397-
} else if(action == 'load') {
1408+
}
1409+
else if(action == 'compose_cancelled') {
1410+
console.log('set compose cancelled callback');
1411+
api.tracker.composeCancelledCallback = callback;
1412+
}
1413+
else if(action == 'load') {
13981414

13991415
// wait until the gmail interface has finished loading and then
14001416
// execute the passed handler. If interface is already loaded,

0 commit comments

Comments
 (0)