summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-04-21 07:23:10 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-04-21 07:23:10 +0000
commitb6eb2533cb91f8cf620a00762375d3f6f02b0b1b (patch)
tree4af775d5fb0777f15cb07ee9625415616d9237f0 /modules
parent6b108a3b67e8bf6151185b82f26c92d52722e560 (diff)
downloadbrdo-b6eb2533cb91f8cf620a00762375d3f6f02b0b1b.tar.gz
brdo-b6eb2533cb91f8cf620a00762375d3f6f02b0b1b.tar.bz2
#662856 by David_Rothstein, ksenzee: Fixed submitting a form that closes the overlay causes the form to flash on the screen again before it closes.
Diffstat (limited to 'modules')
-rw-r--r--modules/overlay/overlay.module60
1 files changed, 55 insertions, 5 deletions
diff --git a/modules/overlay/overlay.module b/modules/overlay/overlay.module
index b5ec993b8..1959be5e2 100644
--- a/modules/overlay/overlay.module
+++ b/modules/overlay/overlay.module
@@ -340,11 +340,14 @@ function overlay_form_after_build($form, &$form_state) {
* perform any redirection once the submitted form has been processed.
*
* When $form_state['redirect'] is set to FALSE, then Form API will simply
- * re-render the form with the values still in its fields. And this is all
- * we need to output the JavaScript that will tell the parent window to close
- * the child dialog.
+ * re-render the current page. This is all we need in order to output the
+ * JavaScript that will tell the parent window to close the child dialog, so
+ * we store a variable which will cause the page to be rendered by a delivery
+ * callback function that does not actually print visible HTML, thereby
+ * allowing the dialog to be closed faster and with less interruption.
*
* @see overlay_get_mode()
+ * @see overlay_page_delivery_callback_alter()
* @ingroup forms
*/
function overlay_form_submit($form, &$form_state) {
@@ -394,13 +397,60 @@ function overlay_form_submit($form, &$form_state) {
}
drupal_add_js($settings, array('type' => 'setting'));
}
- // Tell FAPI to redraw the form without redirection after all submit
- // callbacks have been processed.
+ // Request that an empty page be displayed.
+ overlay_display_empty_page(TRUE);
+ // Tell FAPI to stay on the same page after all submit callbacks have been
+ // processed.
$form_state['redirect'] = FALSE;
}
}
/**
+ * Callback to request that the overlay display an empty page.
+ *
+ * This is used to prevent a submitted form which closes the overlay from being
+ * fully re-rendered before the overlay is closed.
+ *
+ * @param $value
+ * By default, an empty page will not be displayed. Set to TRUE to request
+ * an empty page display, or FALSE to disable the empty page display (if it
+ * was previously enabled on this page request).
+ *
+ * @return
+ * TRUE if the current behavior is to display an empty page, or FALSE if not.
+ */
+function overlay_display_empty_page($value = NULL) {
+ $display_empty_page = &drupal_static(__FUNCTION__, FALSE);
+ if (isset($value)) {
+ $display_empty_page = $value;
+ }
+ return $display_empty_page;
+}
+
+/**
+ * Implements hook_page_delivery_callback_alter().
+ */
+function overlay_page_delivery_callback_alter(&$callback) {
+ if (overlay_display_empty_page()) {
+ $callback = 'overlay_deliver_empty_page';
+ }
+}
+
+/**
+ * Delivery callback to display an empty page.
+ *
+ * This function is used to print out a bare minimum empty page which still has
+ * the scripts and styles necessary in order to trigger the overlay to close.
+ *
+ * @see overlay_form_submit()
+ */
+function overlay_deliver_empty_page() {
+ $empty_page = '<html><head><title></title>' . drupal_get_css() . drupal_get_js() . '</head><body class="overlay"></body></html>';
+ print $empty_page;
+ drupal_exit();
+}
+
+/**
* Get the current overlay mode.
*
* @see overlay_set_mode()