summaryrefslogtreecommitdiff
path: root/modules/overlay
diff options
context:
space:
mode:
Diffstat (limited to 'modules/overlay')
-rw-r--r--modules/overlay/overlay-child.js10
-rw-r--r--modules/overlay/overlay-parent.js20
-rw-r--r--modules/overlay/overlay.module34
3 files changed, 52 insertions, 12 deletions
diff --git a/modules/overlay/overlay-child.js b/modules/overlay/overlay-child.js
index f89645b97..d0e4b8df8 100644
--- a/modules/overlay/overlay-child.js
+++ b/modules/overlay/overlay-child.js
@@ -20,8 +20,14 @@ Drupal.behaviors.overlayChild = {
var settings = settings.overlayChild || {};
+ // If the entire parent window should be refreshed when the overlay is
+ // closed, pass that information to the parent window.
+ if (settings.refreshPage) {
+ parent.Drupal.overlay.refreshPage = true;
+ }
+
// If a form has been submitted successfully, then the server side script
- // may have decided to tell us the parent window to close the popup dialog.
+ // may have decided to tell the parent window to close the popup dialog.
if (settings.closeOverlay) {
parent.Drupal.overlay.bindChild(window, true);
// Use setTimeout to close the child window from a separate thread,
@@ -38,7 +44,7 @@ Drupal.behaviors.overlayChild = {
}
// If one of the regions displaying outside the overlay needs to be
- // reloaded, let the parent window know.
+ // reloaded immediately, let the parent window know.
if (settings.refreshRegions) {
parent.Drupal.overlay.refreshRegions(settings.refreshRegions);
}
diff --git a/modules/overlay/overlay-parent.js b/modules/overlay/overlay-parent.js
index 3007fe088..b0cd7be74 100644
--- a/modules/overlay/overlay-parent.js
+++ b/modules/overlay/overlay-parent.js
@@ -116,6 +116,7 @@ Drupal.overlay.create = function () {
.bind('drupalOverlayLoad' + eventClass, $.proxy(this, 'eventhandlerOuterResize'))
.bind('drupalOverlayReady' + eventClass +
' drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerSyncURLFragment'))
+ .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRefreshPage'))
.bind('drupalOverlayBeforeClose' + eventClass +
' drupalOverlayBeforeLoad' + eventClass +
' drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerDispatchEvent'))
@@ -458,7 +459,7 @@ Drupal.overlay.eventhandlerOverrideLink = function (event) {
// Close the overlay when the link contains the overlay-close class.
if ($target.hasClass('overlay-close')) {
// Clearing the overlay URL fragment will close the overlay.
- $.bbq.pushState();
+ $.bbq.removeState('overlay');
return;
}
@@ -587,7 +588,22 @@ Drupal.overlay.eventhandlerSyncURLFragment = function (event) {
}
}
else {
- $.bbq.pushState();
+ $.bbq.removeState('overlay');
+ }
+};
+
+/**
+ * Event handler: if the child window suggested that the parent refresh on
+ * close, force a page refresh.
+ *
+ * @param event
+ * Event being triggered, with the following restrictions:
+ * - event.type: drupalOverlayClose
+ * - event.currentTarget: document
+ */
+Drupal.overlay.eventhandlerRefreshPage = function (event) {
+ if (Drupal.overlay.refreshPage) {
+ window.location.reload(true);
}
};
diff --git a/modules/overlay/overlay.module b/modules/overlay/overlay.module
index fa5e76af0..2650e8168 100644
--- a/modules/overlay/overlay.module
+++ b/modules/overlay/overlay.module
@@ -551,18 +551,21 @@ function overlay_overlay_parent_initialize() {
function overlay_overlay_child_initialize() {
// Check if the parent window needs to refresh any page regions on this page
// request.
- overlay_trigger_regions_to_refresh();
+ overlay_trigger_refresh();
// If this is a POST request, or a GET request with a token parameter, we
// have an indication that something in the supplemental regions of the
// overlay might change during the current page request. We therefore store
// the initial rendered content of those regions here, so that we can compare
// it to the same content rendered in overlay_exit(), at the end of the page
// request. This allows us to check if anything actually did change, and, if
- // so, trigger an AJAX refresh of the parent window.
+ // so, trigger an immediate AJAX refresh of the parent window.
if (!empty($_POST) || isset($_GET['token'])) {
foreach (overlay_supplemental_regions() as $region) {
overlay_store_rendered_content($region, overlay_render_region($region));
}
+ // In addition, notify the parent window that when the overlay closes,
+ // the entire parent window should be refreshed.
+ overlay_request_page_refresh();
}
// Indicate that when the main page rendering occurs later in the page
// request, only the regions that appear within the overlay should be
@@ -797,7 +800,7 @@ function overlay_store_rendered_content($id = NULL, $content = NULL) {
* The name of the page region to refresh. The parent window will trigger a
* refresh of this region on the next page load.
*
- * @see overlay_trigger_regions_to_refresh()
+ * @see overlay_trigger_refresh()
* @see Drupal.overlay.refreshRegions()
*/
function overlay_request_refresh($region) {
@@ -806,16 +809,27 @@ function overlay_request_refresh($region) {
}
/**
- * Check if the parent window needs to refresh any regions on this page load.
+ * Request that the entire parent window be reloaded when the overlay closes.
*
- * If the previous page load requested that any page regions be refreshed, pass
- * that request via JavaScript to the child window, so it can in turn pass the
- * request to the parent window.
+ * @see overlay_trigger_refresh()
+ */
+function overlay_request_page_refresh() {
+ $_SESSION['overlay_refresh_parent'] = TRUE;
+}
+
+/**
+ * Check if the parent window needs to be refreshed on this page load.
+ *
+ * If the previous page load requested that any page regions be refreshed, or
+ * if it requested that the entire page be refreshed when the overlay closes,
+ * pass that request via JavaScript to the child window, so it can in turn pass
+ * the request to the parent window.
*
* @see overlay_request_refresh()
+ * @see overlay_request_page_refresh()
* @see Drupal.overlay.refreshRegions()
*/
-function overlay_trigger_regions_to_refresh() {
+function overlay_trigger_refresh() {
if (!empty($_SESSION['overlay_regions_to_refresh'])) {
$settings = array(
'overlayChild' => array(
@@ -825,6 +839,10 @@ function overlay_trigger_regions_to_refresh() {
drupal_add_js($settings, array('type' => 'setting'));
unset($_SESSION['overlay_regions_to_refresh']);
}
+ if (!empty($_SESSION['overlay_refresh_parent'])) {
+ drupal_add_js(array('overlayChild' => array('refreshPage' => TRUE)), array('type' => 'setting'));
+ unset($_SESSION['overlay_refresh_parent']);
+ }
}
/**