summaryrefslogtreecommitdiff
path: root/modules/overlay/overlay-child.js
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-12-23 21:33:52 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-12-23 21:33:52 +0000
commit7e7181a42054fb124d589044867044907dd3f378 (patch)
tree0fc66be1c1ef9d6e52b5bbf9de76d90c236a6481 /modules/overlay/overlay-child.js
parenteae4c336a1e7d59d7f62b61bb85996d97b3831f0 (diff)
downloadbrdo-7e7181a42054fb124d589044867044907dd3f378.tar.gz
brdo-7e7181a42054fb124d589044867044907dd3f378.tar.bz2
#615130 by casey, Kiphaas7, David_Rothstein, ksenzee, seutje, and meatsack: Dramatically improve performance of the Overlay module.
Diffstat (limited to 'modules/overlay/overlay-child.js')
-rw-r--r--modules/overlay/overlay-child.js62
1 files changed, 35 insertions, 27 deletions
diff --git a/modules/overlay/overlay-child.js b/modules/overlay/overlay-child.js
index 5a81de20f..e3e1cb933 100644
--- a/modules/overlay/overlay-child.js
+++ b/modules/overlay/overlay-child.js
@@ -99,43 +99,51 @@ Drupal.overlayChild.behaviors.scrollToTop = function (context, settings) {
* @see Drupal.overlay.isAdminLink()
*/
Drupal.overlayChild.behaviors.parseLinks = function (context, settings) {
- $('a:not(.overlay-exclude)', context).once('overlay').each(function () {
- // Non-admin links should close the overlay and open in the main window.
- if (!parent.Drupal.overlay.isAdminLink(this.href)) {
- $(this).click(function () {
- // We need to store the parent variable locally because it will
- // disappear as soon as we close the iframe.
- var parentWindow = parent;
- if (parentWindow.Drupal.overlay.close(false)) {
- parentWindow.Drupal.overlay.redirect($(this).attr('href'));
- }
- return false;
- });
+ var closeAndRedirectOnClick = function (event) {
+ // We need to store the parent variable locally because it will
+ // disappear as soon as we close the iframe.
+ var parentWindow = parent;
+ if (parentWindow.Drupal.overlay.close(false)) {
+ parentWindow.Drupal.overlay.redirect($(this).attr('href'));
+ }
+ return false;
+ };
+ var redirectOnClick = function (event) {
+ parent.Drupal.overlay.redirect($(this).attr('href'));
+ return false;
+ };
+
+ $('a:not(.overlay-exclude)', context).once('overlay', function () {
+ var href = $(this).attr('href');
+ // Skip links that don't have an href attribute.
+ if (href == undefined) {
return;
}
+ // Non-admin links should close the overlay and open in the main window.
+ else if (!parent.Drupal.overlay.isAdminLink(href)) {
+ $(this).click(closeAndRedirectOnClick);
+ }
+ // Open external links in a new window.
+ else if (href.indexOf('http') > 0 || href.indexOf('https') > 0) {
+ $(this).attr('target', '_new');
+ }
+ // Open admin links in the overlay.
else {
- var href = $(this).attr('href');
- if (href.indexOf('http') > 0 || href.indexOf('https') > 0) {
- $(this).attr('target', '_new');
- }
- else {
- $(this).each(function(){
- this.href = parent.Drupal.overlay.fragmentizeLink(this);
- }).click(function () {
- parent.window.location.href = this.href;
- return false;
- });
- }
+ $(this)
+ .attr('href', parent.Drupal.overlay.fragmentizeLink(this))
+ .click(redirectOnClick);
}
});
- $('form:not(.overlay-processed)', context).addClass('overlay-processed').each(function () {
+
+ $('form', context).once('overlay', function () {
// Obtain the action attribute of the form.
var action = $(this).attr('action');
- if (action.indexOf('http') != 0 && action.indexOf('https') != 0) {
- // Keep internal forms in the overlay.
+ // Keep internal forms in the overlay.
+ if (action == undefined || (action.indexOf('http') != 0 && action.indexOf('https') != 0)) {
action += (action.indexOf('?') > -1 ? '&' : '?') + 'render=overlay';
$(this).attr('action', action);
}
+ // Submit external forms into a new window.
else {
$(this).attr('target', '_new');
}