Index: modalframe.module
===================================================================
--- modalframe.module (revision 363)
+++ modalframe.module (working copy)
@@ -187,6 +187,9 @@
  * @ingroup forms
  */
 function modalframe_form_submit($form, &$form_state) {
+  if (module_exists('modalframe_ext') && isset($form_state['redirect']) && _modalframe_ext_close()) {
+    modalframe_close_dialog();
+  }
   if (!empty($GLOBALS['modalframe_close_dialog'])) {
     $form_state['redirect'] = FALSE;
   }
Index: modules/modalframe_ext/README.txt
===================================================================
--- modules/modalframe_ext/README.txt (revision 0)
+++ modules/modalframe_ext/README.txt (revision 0)
@@ -0,0 +1,28 @@
+Example use of hook provided
+
+all options except for last are described in main README.txt for modalframe.
+
+Last option is new,
+
+  'allow_redirect' is a convenient way to automatically close a frame if the form attempts to redirect 
+  
+  An example would be the node form.  When you submit the form, and it completes with 0 errors, it attempts to redirect you to the node page.
+  This would be awkward if the frame was loaded by click on the edit link from the node view page, as in the example below.
+
+function hook_modalframe() {
+  return array(
+    'node/*' => array(
+      'a[href$="/edit"]' => array(
+        'draggable' => FALSE,
+        'width' => 1200, //must be integer
+        'height' => 700, //must be integer
+        'autoFit' => FALSE,
+        'autoResize' => TRUE,
+        //'draggable' => FALSE,
+        //'onSubmit' => 'example',
+        'allow_redirect' => FALSE,
+      ),
+    ),
+  );
+}
+
Index: modules/modalframe_ext/modalframe_ext.info
===================================================================
--- modules/modalframe_ext/modalframe_ext.info  (revision 0)
+++ modules/modalframe_ext/modalframe_ext.info  (revision 0)
@@ -0,0 +1,6 @@
+; $Id: 
+name = Modal Frame Extensions
+description = Provies additional useful functionality for module developers to incorporate Modal Frames.
+package = User interface
+dependencies[] = modalframe
+core = 6.x
Index: modules/modalframe_ext/modalframe_ext.js
===================================================================
--- modules/modalframe_ext/modalframe_ext.js  (revision 0)
+++ modules/modalframe_ext/modalframe_ext.js  (revision 0)
@@ -0,0 +1,23 @@
+// $Id: 
+
+jQuery(function ($) {
+  
+  $.each(Drupal.settings.modalframe.frames, function (i, val) {
+    $(i).click(function () {
+      var a =  document.createElement('a');
+      a.href = this.href;
+      a.search += '&render=overlay&modalframe_ext_selector='+ Drupal.encodeURIComponent(i) +'&modalframe_ext_q=' + window.location.pathname;
+      Drupal.modalFrame.open({
+        url: a.href,
+        width: val.width,
+        height: val.height,
+        autoFit: val.autoFit,
+        autoResize: val.autoResize,
+        draggable: val.draggable,
+        onSubmit: val.onSubmit,
+      });
+      return false;
+    });
+  });
+  
+});
Index: modules/modalframe_ext/modalframe_ext.module
===================================================================
--- modules/modalframe_ext/modalframe_ext.module  (revision 0)
+++ modules/modalframe_ext/modalframe_ext.module  (revision 0)
@@ -0,0 +1,48 @@
+<?php
+// $Id: modalframe_example.module,v 1.1.2.3 2009/06/17 12:55:55 markuspetrux Exp $
+
+/**
+ * @file
+ * Example for the Modal Frame module.
+ */
+
+function modalframe_ext_init() {
+  $settings = _modalframe_ext_settings();
+  
+  $frames = array();
+  
+  foreach ($settings as $path => $frame) {
+    if (drupal_match_path($_GET['q'], $path)) {
+      modalframe_parent_js();
+      drupal_add_js(drupal_get_path('module', 'modalframe_ext') .'/modalframe_ext.js');
+      $frames += $frame;
+    }
+  }
+  
+  drupal_add_js(array('modalframe' => array('frames' => $frames)), 'setting');
+  
+  if ($_GET['render'] == 'overlay') {
+    modalframe_child_js();
+  }
+  
+} 
+
+function _modalframe_ext_close() {
+  if (isset($_GET['modalframe_ext_selector']) && isset($_GET['modalframe_ext_q'])) {
+    $settings = _modalframe_ext_settings();
+    foreach ($settings as $path => $frame) {
+      if (drupal_match_path(parse_url(trim($_GET['modalframe_ext_q'], '/'), PHP_URL_PATH), $path) && isset($frame[$_GET['modalframe_ext_selector']]['allow_redirect'])) {
+        return !$frame[$_GET['modalframe_ext_selector']]['allow_redirect'];
+      }
+    }
+  }
+}
+
+function _modalframe_ext_settings() {
+  static $settings = array();
+  if (empty($settings)) {
+    $settings = module_invoke_all('modalframe');
+  }
+  return $settings;
+}
+
