@@ -1265,6 +1265,7 @@ var Gmail_ = function(localJQuery) {
1265
1265
handler : function ( match , callback ) {
1266
1266
// console.log('reply_forward handler called', match, callback);
1267
1267
1268
+ var originalMatch = match ;
1268
1269
// look back up the DOM tree for M9 (the main reply/forward node)
1269
1270
match = match . closest ( 'div.M9' ) ;
1270
1271
if ( ! match . length ) return ;
@@ -1274,6 +1275,16 @@ var Gmail_ = function(localJQuery) {
1274
1275
type = match . find ( 'input[name=subject]' ) . val ( ) . indexOf ( 'Fw' ) == 0 ? 'forward' : 'reply' ;
1275
1276
} else {
1276
1277
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
+
1277
1288
}
1278
1289
callback ( match , type ) ;
1279
1290
}
@@ -1394,7 +1405,12 @@ var Gmail_ = function(localJQuery) {
1394
1405
return true ;
1395
1406
1396
1407
// 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' ) {
1398
1414
1399
1415
// wait until the gmail interface has finished loading and then
1400
1416
// execute the passed handler. If interface is already loaded,
0 commit comments