From: El Alemaño <victor@dom.de>
Subject: [PATCH] Allow to close modal with the escape key.

---
 js/modal.js | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/js/modal.js b/js/modal.js
index c757ef2..7155b8f 100644
--- a/js/modal.js
+++ b/js/modal.js
@@ -47,7 +47,8 @@
       },
       modalOptions: {
         opacity: .55,
-        background: '#fff'
+        background: '#fff',
+        backdropClose: false
       },
       modalClass: 'default'
     };
@@ -568,7 +569,15 @@
       }
     };

-    $(document).bind('keydown', modalEventEscapeCloseHandler);
+    $('body').bind('keydown', modalEventEscapeCloseHandler);
+      // Bind a click on backdrop for closing the modalContent
+      modalBackdropCloseHandler = function () {
+        if (Drupal.CTools.Modal.currentSettings.modalOptions.backdropClose) {
+        close();
+       return false;
+      }
+    };
+    $('#modalBackdrop').bind('click', modalBackdropCloseHandler);

     // Per WAI-ARIA 1.0 Authoring Practices, initial focus should be on the
     // close button, but we should save the original focus to restore it after
@@ -585,6 +594,7 @@
       $('body').unbind( 'keydown', modalTabTrapHandler );
       $('.close').unbind('click', modalContentClose);
       $('body').unbind('keypress', modalEventEscapeCloseHandler);
+      $('#modalBackdrop').unbind('click', modalBackdropCloseHandler);
       $(document).trigger('CToolsDetachBehaviors', $('#modalContent'));

       // Set our animation parameters and use them
--
2.3.2 (Apple Git-55)
