reverted: --- modules/node/node.admin.inc 15 Oct 2009 13:11:03 -0000 +++ modules/node/node.admin.inc 11 Oct 2009 03:07:18 -0000 1.71 @@ -445,12 +445,7 @@ $destination = drupal_get_destination(); $nodes = array(); foreach ($result as $node) { + $l_options = empty($node->language) ? array() : array('language' => $languages[$node->language]); - // Set a class to flag to the overlay, if present, not to open the link in - // the overlay. - $l_options = array('attributes' => array('class' => 'overlay-escape')); - if (!empty($node->language)) { - $l_options['language'] = $languages[$node->language]; - } $options[$node->nid] = array( 'title' => l($node->title, 'node/' . $node->nid, $l_options) . ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))), 'type' => check_plain(node_type_get_name($node)), diff -u modules/overlay/overlay-child.js modules/overlay/overlay-child.js --- modules/overlay/overlay-child.js 15 Oct 2009 13:11:03 -0000 +++ modules/overlay/overlay-child.js @@ -12,6 +12,7 @@ */ Drupal.behaviors.overlayChild = { attach: function(context, settings) { + console.log("I'm a child!", location.href); var self = Drupal.overlayChild; var settings = settings.overlayChild || {}; @@ -68,6 +69,11 @@ Drupal.overlayChild.isObject = parent.Drupal.overlay.isObject; /** + * Add the isAdminLink() method to the overlayChild object for convenience. + */ +Drupal.overlayChild.isAdminLink = parent.Drupal.overlay.isAdminLink; + +/** * Add the addOverlayParam() method to the overlayChild object for convenience. */ Drupal.overlayChild.addOverlayParam = parent.Drupal.overlay.addOverlayParam; @@ -96,16 +102,17 @@ * * By default, forms and links are assumed to keep the flow in the overlay. * Thus their action and href attributes respectively get a ?render=overlay - * suffix. Links having the .overlay-escape class should however close the - * overlay and redirect the parent page to the given link. Such are links - * in a content listing, where administration options are mixed with links - * to the actual content to be shown on the site out of the overlay. + * suffix. Non-administrative links should however close the overlay and + * redirect the parent page to the given link. This would include links in a + * content listing, where administration options are mixed with links to the + * actual content to be shown on the site out of the overlay. + * + * @see Drupal.overlay.isAdminLink() */ Drupal.overlayChild.behaviors.parseLinks = function(context, settings) { - $('a:not(.overlay-exclude)', context).once('overlay').each(function() { - // Links that have the class "overlay-escape" should close the overlay and - // open in the main window. - if ($(this).hasClass('overlay-escape')) { + $('a:not(.overlay-exclude)', context).once('overlay').each(function () { + // Non-admin links should close the overlay and open in the main window. + if (!Drupal.overlayChild.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. diff -u modules/overlay/overlay-parent.js modules/overlay/overlay-parent.js --- modules/overlay/overlay-parent.js 15 Oct 2009 13:11:03 -0000 +++ modules/overlay/overlay-parent.js @@ -7,8 +7,12 @@ */ Drupal.behaviors.overlayParent = { attach: function(context, settings) { - // Attach on the .to-overlay class. - $('a.to-overlay:not(.overlay-exclude)').once('overlay').click(function() { + // Attach on all admin links without the 'overlay-exclude' class. + $('a:not(.overlay-exclude)').filter(function (){ + return Drupal.overlay.isAdminLink(this.href); + }) + // Respond to their click event. + .once('overlay').click(function() { // Append render variable, so the server side can choose the right // rendering and add child modal frame code to the page if needed. @@ -523,6 +527,72 @@ }; /** + * Check if the given link is an admin link and should be opened in the overlay. + * + * Modules and themes can override the default behavior by adding an array of + * links and/or regular expressions to + * Drupal.settings.overlay.admin[modulename], for links that should be displayed + * inside the overlay, or Drupal.settings.overlay.nonAdmin[modulename], for + * links that should be displayed as normal in the parent window. + */ +Drupal.overlay.isAdminLink = function (url) { + // Create a native Link object, so we can use its object methods. + var link = $(url.link(url)).get(0); + var path = link.pathname.replace(new RegExp(Drupal.settings.basePath), ''); + // debug + Drupal.settings.overlay = {'links':{'nonAdmin': {'node': {}}}}; + Drupal.settings.overlay.links.nonAdmin.node = ['node/70/edit', new RegExp('node/[0-2]/edit')]; + // Test the link against module/theme-provided non-admin links. + for (module in Drupal.settings.overlay.links.nonAdmin) { + var list = Drupal.settings.overlay.links.nonAdmin[module]; + if ((typeof module == 'string') && list.length) { + var i; + for (i = 0; i < list.length; i++) { + var item = list[i]; + switch (typeof item) { + case 'string': + if (path.indexOf(item) === 0) { + return false; + } + default: + if (path.match(item)) { + return false; + } + } + } + } + } + if (path.indexOf('admin') === 0) { + return true; + } + var re = new RegExp("node/[0-9]+/edit"); + if (path.match(re)) { + return true; + } + // Test the link against module/theme-provided admin links. + for (module in Drupal.settings.overlay.links.admin) { + list = Drupal.settings.overlay.links.admin[module]; + if ((typeof module == 'string') && list.length) { + i; + for (i = 0; i < list.length; i++) { + item = list[i]; + switch (typeof item) { + case 'string': + if (path.indexOf(item) === 0) { + return true; + } + default: + if (path.match(item)) { + return true; + } + } + } + } + } + return false; +} + +/** * Sanitize dialog size. * * Do not let the overlay go over the 0.78x of the width of the screen and set