diff options
Diffstat (limited to 'modules/overlay')
-rw-r--r-- | modules/overlay/images/background.png | bin | 76 -> 0 bytes | |||
-rw-r--r-- | modules/overlay/images/close-rtl.png | bin | 368 -> 0 bytes | |||
-rw-r--r-- | modules/overlay/images/close.png | bin | 344 -> 0 bytes | |||
-rw-r--r-- | modules/overlay/overlay-child-rtl.css | 35 | ||||
-rw-r--r-- | modules/overlay/overlay-child.css | 158 | ||||
-rw-r--r-- | modules/overlay/overlay-child.js | 192 | ||||
-rw-r--r-- | modules/overlay/overlay-parent.css | 50 | ||||
-rw-r--r-- | modules/overlay/overlay-parent.js | 991 | ||||
-rw-r--r-- | modules/overlay/overlay.api.php | 40 | ||||
-rw-r--r-- | modules/overlay/overlay.info | 5 | ||||
-rw-r--r-- | modules/overlay/overlay.install | 19 | ||||
-rw-r--r-- | modules/overlay/overlay.module | 975 | ||||
-rw-r--r-- | modules/overlay/overlay.tpl.php | 37 |
13 files changed, 0 insertions, 2502 deletions
diff --git a/modules/overlay/images/background.png b/modules/overlay/images/background.png Binary files differdeleted file mode 100644 index 9be21936e15..00000000000 --- a/modules/overlay/images/background.png +++ /dev/null diff --git a/modules/overlay/images/close-rtl.png b/modules/overlay/images/close-rtl.png Binary files differdeleted file mode 100644 index ae05d11140b..00000000000 --- a/modules/overlay/images/close-rtl.png +++ /dev/null diff --git a/modules/overlay/images/close.png b/modules/overlay/images/close.png Binary files differdeleted file mode 100644 index 436985e226f..00000000000 --- a/modules/overlay/images/close.png +++ /dev/null diff --git a/modules/overlay/overlay-child-rtl.css b/modules/overlay/overlay-child-rtl.css deleted file mode 100644 index 8d90fab2af5..00000000000 --- a/modules/overlay/overlay-child-rtl.css +++ /dev/null @@ -1,35 +0,0 @@ - -html { - direction: rtl; -} - -#overlay-title { - float: right; - left: auto; -} -#overlay { - padding: 0.2em; - padding-left: 26px; -} -#overlay-close-wrapper { - left: 0; - right: auto; -} -#overlay-close, -#overlay-close:hover { - background: transparent url(images/close-rtl.png) no-repeat; - -moz-border-radius-topright: 0; - -webkit-border-top-right-radius: 0; - border-top-right-radius: 0; -} - -/** - * Tabs on the overlay. - */ -#overlay-tabs { - left: 20px; - right: auto; -} -#overlay-tabs li { - margin: 0 -3px 0 O; -} diff --git a/modules/overlay/overlay-child.css b/modules/overlay/overlay-child.css deleted file mode 100644 index d047535415d..00000000000 --- a/modules/overlay/overlay-child.css +++ /dev/null @@ -1,158 +0,0 @@ - -html.js { - background: transparent !important; - overflow-y: scroll; -} -html.js body { - background: transparent !important; - margin-left: 0; - margin-right: 0; - padding: 20px 0; -} - -#overlay { - display: table; - margin: 0 auto; - min-height: 100px; - min-width: 700px; - position: relative; - padding: .2em; - padding-bottom: 2em; - padding-right: 26px; /* LTR */ - width: 88%; -} -#overlay-titlebar { - padding: 0 20px; - position: relative; - white-space: nowrap; - z-index: 100; -} -#overlay-content { - background: #fff; - clear: both; - color: #000; - padding: .5em 1em; - position: relative; -} - -#overlay-title-wrapper { - overflow: hidden; -} -#overlay-title { - color: #fff; - float: left; /* LTR */ - font-size: 20px; - margin: 0; - padding: 0.3em 0; -} -#overlay-title:active, -#overlay-title:focus { - outline: 0; -} - -.overlay #skip-link { - margin-top: -20px; -} -.overlay #skip-link a { - color: #fff; /* This is white to contrast with the dark background behind it. */ -} - -#overlay-close-wrapper { - position: absolute; - right: 0; /* LTR */ -} -#overlay-close, -#overlay-close:hover { - background: transparent url(images/close.png) no-repeat; /* LTR */ - -moz-border-radius-topleft: 0; /* LTR */ - -webkit-border-top-left-radius: 0; /* LTR */ - border-top-left-radius: 0; /* LTR */ - display: block; - height: 26px; - margin: 0; - padding: 0; - /* Replace with position:fixed to get a scrolling close button. */ - position: absolute; - width: 26px; -} - -/** - * Tabs on the overlay. - */ -#overlay-tabs { - line-height: 27px; - margin: -28px 0 0 0; - position: absolute; - right: 20px; /* LTR */ - text-transform: uppercase; -} -#overlay-tabs li { - display: inline; - list-style: none; - margin: 0 0 0 -3px; /* LTR */ - padding: 0; -} -#overlay-tabs li a, -#overlay-tabs li a:active, -#overlay-tabs li a:visited, -#overlay-tabs li a:hover { - background-color: #a6a7a2; - -moz-border-radius: 8px 8px 0 0; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - border-radius: 8px 8px 0 0; - color: #000; - display: inline-block; - font-size: 11px; - font-weight: bold; - margin: 0 0 2px 0; - outline: 0; - padding: 0 14px; - text-decoration: none; -} -#overlay-tabs li.active a, -#overlay-tabs li.active a.active, -#overlay-tabs li.active a:active, -#overlay-tabs li.active a:visited { - background-color: #fff; - margin: 0; - padding-bottom: 2px; -} -#overlay-tabs li a:focus, -#overlay-tabs li a:hover { - color: #fff; -} -#overlay-tabs li.active a:focus, -#overlay-tabs li.active a:hover { - color: #000; -} - -/** - * Add to shortcuts link - */ -#overlay-titlebar .add-or-remove-shortcuts { - padding-top: 0.9em; -} - -/** - * Disable message. - */ -#overlay-disable-message { - background-color: #fff; - margin: -20px auto 20px; - width: 80%; - -moz-border-radius: 0 0 8px 8px; - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - border-radius: 0 0 8px 8px; -} -.overlay-disable-message-focused { - padding: 0.5em; -} -.overlay-disable-message-focused a { - display: block; - float: left; -} -.overlay-disable-message-focused #overlay-dismiss-message { - float: right; -} diff --git a/modules/overlay/overlay-child.js b/modules/overlay/overlay-child.js deleted file mode 100644 index e78e3831c91..00000000000 --- a/modules/overlay/overlay-child.js +++ /dev/null @@ -1,192 +0,0 @@ - -(function ($) { - -/** - * Attach the child dialog behavior to new content. - */ -Drupal.behaviors.overlayChild = { - attach: function (context, settings) { - // Make sure this behavior is not processed more than once. - if (this.processed) { - return; - } - this.processed = true; - - // If we cannot reach the parent window, break out of the overlay. - if (!parent.Drupal || !parent.Drupal.overlay) { - window.location = window.location.href.replace(/([?&]?)render=overlay&?/g, '$1').replace(/\?$/, ''); - } - - 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 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, - // because the current one is busy processing Drupal behaviors. - setTimeout(function () { - if (typeof settings.redirect == 'string') { - parent.Drupal.overlay.redirect(settings.redirect); - } - else { - parent.Drupal.overlay.close(); - } - }, 1); - return; - } - - // If one of the regions displaying outside the overlay needs to be - // reloaded immediately, let the parent window know. - if (settings.refreshRegions) { - parent.Drupal.overlay.refreshRegions(settings.refreshRegions); - } - - // Ok, now we can tell the parent window we're ready. - parent.Drupal.overlay.bindChild(window); - - // IE8 crashes on certain pages if this isn't called; reason unknown. - window.scrollTo(window.scrollX, window.scrollY); - - // Attach child related behaviors to the iframe document. - Drupal.overlayChild.attachBehaviors(context, settings); - - // There are two links within the message that informs people about the - // overlay and how to disable it. Make sure both links are visible when - // either one has focus and add a class to the wrapper for styling purposes. - $('#overlay-disable-message', context) - .focusin(function () { - $(this).addClass('overlay-disable-message-focused'); - $('a.element-focusable', this).removeClass('element-invisible'); - }) - .focusout(function () { - $(this).removeClass('overlay-disable-message-focused'); - $('a.element-focusable', this).addClass('element-invisible'); - }); - } -}; - -/** - * Overlay object for child windows. - */ -Drupal.overlayChild = Drupal.overlayChild || { - behaviors: {} -}; - -Drupal.overlayChild.prototype = {}; - -/** - * Attach child related behaviors to the iframe document. - */ -Drupal.overlayChild.attachBehaviors = function (context, settings) { - $.each(this.behaviors, function () { - this(context, settings); - }); -}; - -/** - * Capture and handle clicks. - * - * Instead of binding a click event handler to every link we bind one to the - * document and handle events that bubble up. This also allows other scripts - * to bind their own handlers to links and also to prevent overlay's handling. - */ -Drupal.overlayChild.behaviors.addClickHandler = function (context, settings) { - $(document).bind('click.drupal-overlay mouseup.drupal-overlay', $.proxy(parent.Drupal.overlay, 'eventhandlerOverrideLink')); -}; - -/** - * Modify forms depending on their relation to the overlay. - * - * By default, forms are assumed to keep the flow in the overlay. Thus their - * action attribute get a ?render=overlay suffix. - */ -Drupal.overlayChild.behaviors.parseForms = function (context, settings) { - $('form', context).once('overlay', function () { - // Obtain the action attribute of the form. - var action = $(this).attr('action'); - // 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'); - } - }); -}; - -/** - * Replace the overlay title with a message while loading another page. - */ -Drupal.overlayChild.behaviors.loading = function (context, settings) { - var $title; - var text = Drupal.t('Loading'); - var dots = ''; - - $(document).bind('drupalOverlayBeforeLoad.drupal-overlay.drupal-overlay-child-loading', function () { - $title = $('#overlay-title').text(text); - var id = setInterval(function () { - dots = (dots.length > 10) ? '' : dots + '.'; - $title.text(text + dots); - }, 500); - }); -}; - -/** - * Switch active tab immediately. - */ -Drupal.overlayChild.behaviors.tabs = function (context, settings) { - var $tabsLinks = $('#overlay-tabs > li > a'); - - $('#overlay-tabs > li > a').bind('click.drupal-overlay', function () { - var active_tab = Drupal.t('(active tab)'); - $tabsLinks.parent().siblings().removeClass('active').find('element-invisible:contains(' + active_tab + ')').appendTo(this); - $(this).parent().addClass('active'); - }); -}; - -/** - * If the shortcut add/delete button exists, move it to the overlay titlebar. - */ -Drupal.overlayChild.behaviors.shortcutAddLink = function (context, settings) { - // Remove any existing shortcut button markup from the titlebar. - $('#overlay-titlebar').find('.add-or-remove-shortcuts').remove(); - // If the shortcut add/delete button exists, move it to the titlebar. - var $addToShortcuts = $('.add-or-remove-shortcuts'); - if ($addToShortcuts.length) { - $addToShortcuts.insertAfter('#overlay-title'); - } - - $(document).bind('drupalOverlayBeforeLoad.drupal-overlay.drupal-overlay-child-loading', function () { - $('#overlay-titlebar').find('.add-or-remove-shortcuts').remove(); - }); -}; - -/** - * Use displacement from parent window. - */ -Drupal.overlayChild.behaviors.alterTableHeaderOffset = function (context, settings) { - if (Drupal.settings.tableHeaderOffset) { - Drupal.overlayChild.prevTableHeaderOffset = Drupal.settings.tableHeaderOffset; - } - Drupal.settings.tableHeaderOffset = 'Drupal.overlayChild.tableHeaderOffset'; -}; - -/** - * Callback for Drupal.settings.tableHeaderOffset. - */ -Drupal.overlayChild.tableHeaderOffset = function () { - var topOffset = Drupal.overlayChild.prevTableHeaderOffset ? eval(Drupal.overlayChild.prevTableHeaderOffset + '()') : 0; - - return topOffset + parseInt($(document.body).css('marginTop')); -}; - -})(jQuery); diff --git a/modules/overlay/overlay-parent.css b/modules/overlay/overlay-parent.css deleted file mode 100644 index dad6d5575b5..00000000000 --- a/modules/overlay/overlay-parent.css +++ /dev/null @@ -1,50 +0,0 @@ - -html.overlay-open, -html.overlay-open body { - height: 100%; - overflow: hidden; -} - -#overlay-container, -.overlay-modal-background, -.overlay-element { - height: 100%; - left: 0; - position: absolute; - top: 0; - width: 100%; - z-index: 500; -} - -.overlay-modal-background { - /* Using a transparent png renders faster than using opacity */ - background: transparent url(images/background.png) repeat; -} - -.overlay-element { - background: transparent; - left: -200%; - z-index: 501; -} -.overlay-element.overlay-active { - left: 0; -} - -html.overlay-open .displace-top, -html.overlay-open .displace-bottom { - z-index: 600; -} - -/** - * Within the overlay parent, the message about disabling the overlay is for - * screen-reader users only. It is always kept invisible with the - * element-invisible class, and removed from the tab order. Overlay-child.css - * contains styling for the same message appearing within the overlay, and - * intended for sighted users. - */ -#overlay-disable-message { - display: none; -} -html.overlay-open #overlay-disable-message { - display: block; -} diff --git a/modules/overlay/overlay-parent.js b/modules/overlay/overlay-parent.js deleted file mode 100644 index 135320fe603..00000000000 --- a/modules/overlay/overlay-parent.js +++ /dev/null @@ -1,991 +0,0 @@ - -(function ($) { - -/** - * Open the overlay, or load content into it, when an admin link is clicked. - */ -Drupal.behaviors.overlayParent = { - attach: function (context, settings) { - if (Drupal.overlay.isOpen) { - Drupal.overlay.makeDocumentUntabbable(context); - } - - if (this.processed) { - return; - } - this.processed = true; - - $(window) - // When the hash (URL fragment) changes, open the overlay if needed. - .bind('hashchange.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOperateByURLFragment')) - // Trigger the hashchange handler once, after the page is loaded, so that - // permalinks open the overlay. - .triggerHandler('hashchange.drupal-overlay'); - - $(document) - // Instead of binding a click event handler to every link we bind one to - // the document and only handle events that bubble up. This allows other - // scripts to bind their own handlers to links and also to prevent - // overlay's handling. - .bind('click.drupal-overlay mouseup.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOverrideLink')); - } -}; - -/** - * Overlay object for parent windows. - * - * Events - * Overlay triggers a number of events that can be used by other scripts. - * - drupalOverlayOpen: This event is triggered when the overlay is opened. - * - drupalOverlayBeforeClose: This event is triggered when the overlay attempts - * to close. If an event handler returns false, the close will be prevented. - * - drupalOverlayClose: This event is triggered when the overlay is closed. - * - drupalOverlayBeforeLoad: This event is triggered right before a new URL - * is loaded into the overlay. - * - drupalOverlayReady: This event is triggered when the DOM of the overlay - * child document is fully loaded. - * - drupalOverlayLoad: This event is triggered when the overlay is finished - * loading. - * - drupalOverlayResize: This event is triggered when the overlay is being - * resized to match the parent window. - */ -Drupal.overlay = Drupal.overlay || { - isOpen: false, - isOpening: false, - isClosing: false, - isLoading: false -}; - -Drupal.overlay.prototype = {}; - -/** - * Open the overlay. - * - * @param url - * The URL of the page to open in the overlay. - * - * @return - * TRUE if the overlay was opened, FALSE otherwise. - */ -Drupal.overlay.open = function (url) { - // Just one overlay is allowed. - if (this.isOpen || this.isOpening) { - return this.load(url); - } - this.isOpening = true; - // Store the original document title. - this.originalTitle = document.title; - - // Create the dialog and related DOM elements. - this.create(); - - this.isOpening = false; - this.isOpen = true; - $(document.documentElement).addClass('overlay-open'); - this.makeDocumentUntabbable(); - - // Allow other scripts to respond to this event. - $(document).trigger('drupalOverlayOpen'); - - return this.load(url); -}; - -/** - * Create the underlying markup and behaviors for the overlay. - */ -Drupal.overlay.create = function () { - this.$container = $(Drupal.theme('overlayContainer')) - .appendTo(document.body); - - // Overlay uses transparent iframes that cover the full parent window. - // When the overlay is open the scrollbar of the parent window is hidden. - // Because some browsers show a white iframe background for a short moment - // while loading a page into an iframe, overlay uses two iframes. By loading - // the page in a hidden (inactive) iframe the user doesn't see the white - // background. When the page is loaded the active and inactive iframes - // are switched. - this.activeFrame = this.$iframeA = $(Drupal.theme('overlayElement')) - .appendTo(this.$container); - - this.inactiveFrame = this.$iframeB = $(Drupal.theme('overlayElement')) - .appendTo(this.$container); - - this.$iframeA.bind('load.drupal-overlay', { self: this.$iframeA[0], sibling: this.$iframeB }, $.proxy(this, 'loadChild')); - this.$iframeB.bind('load.drupal-overlay', { self: this.$iframeB[0], sibling: this.$iframeA }, $.proxy(this, 'loadChild')); - - // Add a second class "drupal-overlay-open" to indicate these event handlers - // should only be bound when the overlay is open. - var eventClass = '.drupal-overlay.drupal-overlay-open'; - $(window) - .bind('resize' + eventClass, $.proxy(this, 'eventhandlerOuterResize')); - $(document) - .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')); - - if ($('.overlay-displace-top, .overlay-displace-bottom').length) { - $(document) - .bind('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements')) - .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements')); - } -}; - -/** - * Load the given URL into the overlay iframe. - * - * Use this method to change the URL being loaded in the overlay if it is - * already open. - * - * @return - * TRUE if URL is loaded into the overlay, FALSE otherwise. - */ -Drupal.overlay.load = function (url) { - if (!this.isOpen) { - return false; - } - - // Allow other scripts to respond to this event. - $(document).trigger('drupalOverlayBeforeLoad'); - - $(document.documentElement).addClass('overlay-loading'); - - // The contentDocument property is not supported in IE until IE8. - var iframeDocument = this.inactiveFrame[0].contentDocument || this.inactiveFrame[0].contentWindow.document; - - // location.replace doesn't create a history entry. location.href does. - // In this case, we want location.replace, as we're creating the history - // entry using URL fragments. - iframeDocument.location.replace(url); - - return true; -}; - -/** - * Close the overlay and remove markup related to it from the document. - * - * @return - * TRUE if the overlay was closed, FALSE otherwise. - */ -Drupal.overlay.close = function () { - // Prevent double execution when close is requested more than once. - if (!this.isOpen || this.isClosing) { - return false; - } - - // Allow other scripts to respond to this event. - var event = $.Event('drupalOverlayBeforeClose'); - $(document).trigger(event); - // If a handler returned false, the close will be prevented. - if (event.isDefaultPrevented()) { - return false; - } - - this.isClosing = true; - this.isOpen = false; - $(document.documentElement).removeClass('overlay-open'); - // Restore the original document title. - document.title = this.originalTitle; - this.makeDocumentTabbable(); - - // Allow other scripts to respond to this event. - $(document).trigger('drupalOverlayClose'); - - // When the iframe is still loading don't destroy it immediately but after - // the content is loaded (see Drupal.overlay.loadChild). - if (!this.isLoading) { - this.destroy(); - this.isClosing = false; - } - return true; -}; - -/** - * Destroy the overlay. - */ -Drupal.overlay.destroy = function () { - $([document, window]).unbind('.drupal-overlay-open'); - this.$container.remove(); - - this.$container = null; - this.$iframeA = null; - this.$iframeB = null; - - this.iframeWindow = null; -}; - -/** - * Redirect the overlay parent window to the given URL. - * - * @param url - * Can be an absolute URL or a relative link to the domain root. - */ -Drupal.overlay.redirect = function (url) { - // Create a native Link object, so we can use its object methods. - var link = $(url.link(url)).get(0); - - // If the link is already open, force the hashchange event to simulate reload. - if (window.location.href == link.href) { - $(window).triggerHandler('hashchange.drupal-overlay'); - } - - window.location.href = link.href; - return true; -}; - -/** - * Bind the child window. - * - * Note that this function is fired earlier than Drupal.overlay.loadChild. - */ -Drupal.overlay.bindChild = function (iframeWindow, isClosing) { - this.iframeWindow = iframeWindow; - - // We are done if the child window is closing. - if (isClosing || this.isClosing || !this.isOpen) { - return; - } - - // Allow other scripts to respond to this event. - $(document).trigger('drupalOverlayReady'); -}; - -/** - * Event handler: load event handler for the overlay iframe. - * - * @param event - * Event being triggered, with the following restrictions: - * - event.type: load - * - event.currentTarget: iframe - */ -Drupal.overlay.loadChild = function (event) { - var iframe = event.data.self; - var iframeDocument = iframe.contentDocument || iframe.contentWindow.document; - var iframeWindow = iframeDocument.defaultView || iframeDocument.parentWindow; - if (iframeWindow.location == 'about:blank') { - return; - } - - this.isLoading = false; - $(document.documentElement).removeClass('overlay-loading'); - event.data.sibling.removeClass('overlay-active').attr({ 'tabindex': -1 }); - - // Only continue when overlay is still open and not closing. - if (this.isOpen && !this.isClosing) { - // And child document is an actual overlayChild. - if (iframeWindow.Drupal && iframeWindow.Drupal.overlayChild) { - // Replace the document title with title of iframe. - document.title = iframeWindow.document.title; - - this.activeFrame = $(iframe) - .addClass('overlay-active') - // Add a title attribute to the iframe for accessibility. - .attr('title', Drupal.t('@title dialog', { '@title': iframeWindow.jQuery('#overlay-title').text() })).removeAttr('tabindex'); - this.inactiveFrame = event.data.sibling; - - // Load an empty document into the inactive iframe. - (this.inactiveFrame[0].contentDocument || this.inactiveFrame[0].contentWindow.document).location.replace('about:blank'); - - // Move the focus to just before the "skip to main content" link inside - // the overlay. - this.activeFrame.focus(); - var skipLink = iframeWindow.jQuery('a:first'); - Drupal.overlay.setFocusBefore(skipLink, iframeWindow.document); - - // Allow other scripts to respond to this event. - $(document).trigger('drupalOverlayLoad'); - } - else { - window.location = iframeWindow.location.href.replace(/([?&]?)render=overlay&?/g, '$1').replace(/\?$/, ''); - } - } - else { - this.destroy(); - } -}; - -/** - * Creates a placeholder element to receive document focus. - * - * Setting the document focus to a link will make it visible, even if it's a - * "skip to main content" link that should normally be visible only when the - * user tabs to it. This function can be used to set the document focus to - * just before such an invisible link. - * - * @param $element - * The jQuery element that should receive focus on the next tab press. - * @param document - * The iframe window element to which the placeholder should be added. The - * placeholder element has to be created inside the same iframe as the element - * it precedes, to keep IE happy. (http://bugs.jquery.com/ticket/4059) - */ -Drupal.overlay.setFocusBefore = function ($element, document) { - // Create an anchor inside the placeholder document. - var placeholder = document.createElement('a'); - var $placeholder = $(placeholder).addClass('element-invisible').attr('href', '#'); - // Put the placeholder where it belongs, and set the document focus to it. - $placeholder.insertBefore($element); - $placeholder.focus(); - // Make the placeholder disappear as soon as it loses focus, so that it - // doesn't appear in the tab order again. - $placeholder.one('blur', function () { - $(this).remove(); - }); -} - -/** - * Check if the given link is in the administrative section of the site. - * - * @param url - * The url to be tested. - * - * @return boolean - * TRUE if the URL represents an administrative link, FALSE otherwise. - */ -Drupal.overlay.isAdminLink = function (url) { - if (Drupal.overlay.isExternalLink(url)) { - return false; - } - - var path = this.getPath(url); - - // Turn the list of administrative paths into a regular expression. - if (!this.adminPathRegExp) { - var regExpPrefix = '^' + Drupal.settings.pathPrefix + '('; - var adminPaths = regExpPrefix + Drupal.settings.overlay.paths.admin.replace(/\s+/g, ')$|' + regExpPrefix) + ')$'; - var nonAdminPaths = regExpPrefix + Drupal.settings.overlay.paths.non_admin.replace(/\s+/g, ')$|'+ regExpPrefix) + ')$'; - adminPaths = adminPaths.replace(/\*/g, '.*'); - nonAdminPaths = nonAdminPaths.replace(/\*/g, '.*'); - this.adminPathRegExp = new RegExp(adminPaths); - this.nonAdminPathRegExp = new RegExp(nonAdminPaths); - } - - return this.adminPathRegExp.exec(path) && !this.nonAdminPathRegExp.exec(path); -}; - -/** - * Determine whether a link is external to the site. - * - * @param url - * The url to be tested. - * - * @return boolean - * TRUE if the URL is external to the site, FALSE otherwise. - */ -Drupal.overlay.isExternalLink = function (url) { - var re = RegExp('^((f|ht)tps?:)?//(?!' + window.location.host + ')'); - return re.test(url); -}; - -/** - * Event handler: resizes overlay according to the size of the parent window. - * - * @param event - * Event being triggered, with the following restrictions: - * - event.type: any - * - event.currentTarget: any - */ -Drupal.overlay.eventhandlerOuterResize = function (event) { - // Proceed only if the overlay still exists. - if (!(this.isOpen || this.isOpening) || this.isClosing || !this.iframeWindow) { - return; - } - - // IE6 uses position:absolute instead of position:fixed. - if (typeof document.body.style.maxHeight != 'string') { - this.activeFrame.height($(window).height()); - } - - // Allow other scripts to respond to this event. - $(document).trigger('drupalOverlayResize'); -}; - -/** - * Event handler: resizes displaced elements so they won't overlap the scrollbar - * of overlay's iframe. - * - * @param event - * Event being triggered, with the following restrictions: - * - event.type: any - * - event.currentTarget: any - */ -Drupal.overlay.eventhandlerAlterDisplacedElements = function (event) { - // Proceed only if the overlay still exists. - if (!(this.isOpen || this.isOpening) || this.isClosing || !this.iframeWindow) { - return; - } - - $(this.iframeWindow.document.body).css({ - marginTop: Drupal.overlay.getDisplacement('top'), - marginBottom: Drupal.overlay.getDisplacement('bottom') - }) - // IE7 isn't reflowing the document immediately. - // @todo This might be fixed in a cleaner way. - .addClass('overlay-trigger-reflow').removeClass('overlay-trigger-reflow'); - - var documentHeight = this.iframeWindow.document.body.clientHeight; - var documentWidth = this.iframeWindow.document.body.clientWidth; - // IE6 doesn't support maxWidth, use width instead. - var maxWidthName = 'maxWidth'; - - if (Drupal.overlay.leftSidedScrollbarOffset === undefined && $(document.documentElement).attr('dir') === 'rtl') { - // We can't use element.clientLeft to detect whether scrollbars are placed - // on the left side of the element when direction is set to "rtl" as most - // browsers dont't support it correctly. - // http://www.gtalbot.org/BugzillaSection/DocumentAllDHTMLproperties.html - // There seems to be absolutely no way to detect whether the scrollbar - // is on the left side in Opera; always expect scrollbar to be on the left. - if ($.browser.opera) { - Drupal.overlay.leftSidedScrollbarOffset = document.documentElement.clientWidth - this.iframeWindow.document.documentElement.clientWidth + this.iframeWindow.document.documentElement.clientLeft; - } - else if (this.iframeWindow.document.documentElement.clientLeft) { - Drupal.overlay.leftSidedScrollbarOffset = this.iframeWindow.document.documentElement.clientLeft; - } - else { - var el1 = $('<div style="direction: rtl; overflow: scroll;"></div>').appendTo(document.body); - var el2 = $('<div></div>').appendTo(el1); - Drupal.overlay.leftSidedScrollbarOffset = parseInt(el2[0].offsetLeft - el1[0].offsetLeft); - el1.remove(); - } - } - - // Consider any element that should be visible above the overlay (such as - // a toolbar). - $('.overlay-displace-top, .overlay-displace-bottom').each(function () { - var data = $(this).data(); - var maxWidth = documentWidth; - // In IE, Shadow filter makes element to overlap the scrollbar with 1px. - if (this.filters && this.filters.length && this.filters.item('DXImageTransform.Microsoft.Shadow')) { - maxWidth -= 1; - } - - if (Drupal.overlay.leftSidedScrollbarOffset) { - $(this).css('left', Drupal.overlay.leftSidedScrollbarOffset); - } - - // Prevent displaced elements overlapping window's scrollbar. - var currentMaxWidth = parseInt($(this).css(maxWidthName)); - if ((data.drupalOverlay && data.drupalOverlay.maxWidth) || isNaN(currentMaxWidth) || currentMaxWidth > maxWidth || currentMaxWidth <= 0) { - $(this).css(maxWidthName, maxWidth); - (data.drupalOverlay = data.drupalOverlay || {}).maxWidth = true; - } - - // Use a more rigorous approach if the displaced element still overlaps - // window's scrollbar; clip the element on the right. - var offset = $(this).offset(); - var offsetRight = offset.left + $(this).outerWidth(); - if ((data.drupalOverlay && data.drupalOverlay.clip) || offsetRight > maxWidth) { - if (Drupal.overlay.leftSidedScrollbarOffset) { - $(this).css('clip', 'rect(auto, auto, ' + (documentHeight - offset.top) + 'px, ' + (Drupal.overlay.leftSidedScrollbarOffset + 2) + 'px)'); - } - else { - $(this).css('clip', 'rect(auto, ' + (maxWidth - offset.left) + 'px, ' + (documentHeight - offset.top) + 'px, auto)'); - } - (data.drupalOverlay = data.drupalOverlay || {}).clip = true; - } - }); -}; - -/** - * Event handler: restores size of displaced elements as they were before - * overlay was opened. - * - * @param event - * Event being triggered, with the following restrictions: - * - event.type: any - * - event.currentTarget: any - */ -Drupal.overlay.eventhandlerRestoreDisplacedElements = function (event) { - var $displacedElements = $('.overlay-displace-top, .overlay-displace-bottom'); - try { - $displacedElements.css({ maxWidth: '', clip: '' }); - } - // IE bug that doesn't allow unsetting style.clip (http://dev.jquery.com/ticket/6512). - catch (err) { - $displacedElements.attr('style', function (index, attr) { - return attr.replace(/clip\s*:\s*rect\([^)]+\);?/i, ''); - }); - } -}; - -/** - * Event handler: overrides href of administrative links to be opened in - * the overlay. - * - * This click event handler should be bound to any document (for example the - * overlay iframe) of which you want links to open in the overlay. - * - * @param event - * Event being triggered, with the following restrictions: - * - event.type: click, mouseup - * - event.currentTarget: document - * - * @see Drupal.overlayChild.behaviors.addClickHandler - */ -Drupal.overlay.eventhandlerOverrideLink = function (event) { - // In some browsers the click event isn't fired for right-clicks. Use the - // mouseup event for right-clicks and the click event for everything else. - if ((event.type == 'click' && event.button == 2) || (event.type == 'mouseup' && event.button != 2)) { - return; - } - - var $target = $(event.target); - - // Only continue if clicked target (or one of its parents) is a link. - if (!$target.is('a')) { - $target = $target.closest('a'); - if (!$target.length) { - return; - } - } - - // Never open links in the overlay that contain the overlay-exclude class. - if ($target.hasClass('overlay-exclude')) { - return; - } - - // 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.removeState('overlay'); - return; - } - - var target = $target[0]; - var href = target.href; - // Only handle links that have an href attribute and use the http(s) protocol. - if (href != undefined && href != '' && target.protocol.match(/^https?\:/)) { - var anchor = href.replace(target.ownerDocument.location.href, ''); - // Skip anchor links. - if (anchor.length == 0 || anchor.charAt(0) == '#') { - return; - } - // Open admin links in the overlay. - else if (this.isAdminLink(href)) { - // If the link contains the overlay-restore class and the overlay-context - // state is set, also update the parent window's location. - var parentLocation = ($target.hasClass('overlay-restore') && typeof $.bbq.getState('overlay-context') == 'string') - ? Drupal.settings.basePath + $.bbq.getState('overlay-context') - : null; - href = this.fragmentizeLink($target.get(0), parentLocation); - // Only override default behavior when left-clicking and user is not - // pressing the ALT, CTRL, META (Command key on the Macintosh keyboard) - // or SHIFT key. - if (event.button == 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) { - // Redirect to a fragmentized href. This will trigger a hashchange event. - this.redirect(href); - // Prevent default action and further propagation of the event. - return false; - } - // Otherwise alter clicked link's href. This is being picked up by - // the default action handler. - else { - $target - // Restore link's href attribute on blur or next click. - .one('blur mousedown', { target: target, href: target.href }, function (event) { $(event.data.target).attr('href', event.data.href); }) - .attr('href', href); - } - } - // Non-admin links should close the overlay and open in the main window, - // which is the default action for a link. We only need to handle them - // if the overlay is open and the clicked link is inside the overlay iframe. - else if (this.isOpen && target.ownerDocument === this.iframeWindow.document) { - // Open external links in the immediate parent of the frame, unless the - // link already has a different target. - if (target.hostname != window.location.hostname) { - if (!$target.attr('target')) { - $target.attr('target', '_parent'); - } - } - else { - // Add the overlay-context state to the link, so "overlay-restore" links - // can restore the context. - $target.attr('href', $.param.fragment(href, { 'overlay-context': this.getPath(window.location) + window.location.search })); - - // When the link has a destination query parameter and that destination - // is an admin link we need to fragmentize it. This will make it reopen - // in the overlay. - var params = $.deparam.querystring(href); - if (params.destination && this.isAdminLink(params.destination)) { - var fragmentizedDestination = $.param.fragment(this.getPath(window.location), { overlay: params.destination }); - $target.attr('href', $.param.querystring(href, { destination: fragmentizedDestination })); - } - - // Make the link open in the immediate parent of the frame. - $target.attr('target', '_parent'); - } - } - } -}; - -/** - * Event handler: opens or closes the overlay based on the current URL fragment. - * - * @param event - * Event being triggered, with the following restrictions: - * - event.type: hashchange - * - event.currentTarget: document - */ -Drupal.overlay.eventhandlerOperateByURLFragment = function (event) { - // If we changed the hash to reflect an internal redirect in the overlay, - // its location has already been changed, so don't do anything. - if ($.data(window.location, window.location.href) === 'redirect') { - $.data(window.location, window.location.href, null); - return; - } - - // Get the overlay URL from the current URL fragment. - var state = $.bbq.getState('overlay'); - if (state) { - // Append render variable, so the server side can choose the right - // rendering and add child frame code to the page if needed. - var url = $.param.querystring(Drupal.settings.basePath + state, { render: 'overlay' }); - - this.open(url); - this.resetActiveClass(this.getPath(Drupal.settings.basePath + state)); - } - // If there is no overlay URL in the fragment and the overlay is (still) - // open, close the overlay. - else if (this.isOpen && !this.isClosing) { - this.close(); - this.resetActiveClass(this.getPath(window.location)); - } -}; - -/** - * Event handler: makes sure the internal overlay URL is reflected in the parent - * URL fragment. - * - * Normally the parent URL fragment determines the overlay location. However, if - * the overlay redirects internally, the parent doesn't get informed, and the - * parent URL fragment will be out of date. This is a sanity check to make - * sure we're in the right place. - * - * The parent URL fragment is also not updated automatically when overlay's - * open, close or load functions are used directly (instead of through - * eventhandlerOperateByURLFragment). - * - * @param event - * Event being triggered, with the following restrictions: - * - event.type: drupalOverlayReady, drupalOverlayClose - * - event.currentTarget: document - */ -Drupal.overlay.eventhandlerSyncURLFragment = function (event) { - if (this.isOpen) { - var expected = $.bbq.getState('overlay'); - // This is just a sanity check, so we're comparing paths, not query strings. - if (this.getPath(Drupal.settings.basePath + expected) != this.getPath(this.iframeWindow.document.location)) { - // There may have been a redirect inside the child overlay window that the - // parent wasn't aware of. Update the parent URL fragment appropriately. - var newLocation = Drupal.overlay.fragmentizeLink(this.iframeWindow.document.location); - // Set a 'redirect' flag on the new location so the hashchange event handler - // knows not to change the overlay's content. - $.data(window.location, newLocation, 'redirect'); - // Use location.replace() so we don't create an extra history entry. - window.location.replace(newLocation); - } - } - else { - $.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); - } -}; - -/** - * Event handler: dispatches events to the overlay document. - * - * @param event - * Event being triggered, with the following restrictions: - * - event.type: any - * - event.currentTarget: any - */ -Drupal.overlay.eventhandlerDispatchEvent = function (event) { - if (this.iframeWindow && this.iframeWindow.document) { - this.iframeWindow.jQuery(this.iframeWindow.document).trigger(event); - } -}; - -/** - * Make a regular admin link into a URL that will trigger the overlay to open. - * - * @param link - * A JavaScript Link object (i.e. an <a> element). - * @param parentLocation - * (optional) URL to override the parent window's location with. - * - * @return - * A URL that will trigger the overlay (in the form - * /node/1#overlay=admin/config). - */ -Drupal.overlay.fragmentizeLink = function (link, parentLocation) { - // Don't operate on links that are already overlay-ready. - var params = $.deparam.fragment(link.href); - if (params.overlay) { - return link.href; - } - - // Determine the link's original destination. Set ignorePathFromQueryString to - // true to prevent transforming this link into a clean URL while clean URLs - // may be disabled. - var path = this.getPath(link, true); - // Preserve existing query and fragment parameters in the URL, except for - // "render=overlay" which is re-added in Drupal.overlay.eventhandlerOperateByURLFragment. - var destination = path + link.search.replace(/&?render=overlay/, '').replace(/\?$/, '') + link.hash; - - // Assemble and return the overlay-ready link. - return $.param.fragment(parentLocation || window.location.href, { overlay: destination }); -}; - -/** - * Refresh any regions of the page that are displayed outside the overlay. - * - * @param data - * An array of objects with information on the page regions to be refreshed. - * For each object, the key is a CSS class identifying the region to be - * refreshed, and the value represents the section of the Drupal $page array - * corresponding to this region. - */ -Drupal.overlay.refreshRegions = function (data) { - $.each(data, function () { - var region_info = this; - $.each(region_info, function (regionClass) { - var regionName = region_info[regionClass]; - var regionSelector = '.' + regionClass; - // Allow special behaviors to detach. - Drupal.detachBehaviors($(regionSelector)); - $.get(Drupal.settings.basePath + Drupal.settings.overlay.ajaxCallback + '/' + regionName, function (newElement) { - $(regionSelector).replaceWith($(newElement)); - Drupal.attachBehaviors($(regionSelector), Drupal.settings); - }); - }); - }); -}; - -/** - * Reset the active class on links in displaced elements according to - * given path. - * - * @param activePath - * Path to match links against. - */ -Drupal.overlay.resetActiveClass = function(activePath) { - var self = this; - var windowDomain = window.location.protocol + window.location.hostname; - - $('.overlay-displace-top, .overlay-displace-bottom') - .find('a[href]') - // Remove active class from all links in displaced elements. - .removeClass('active') - // Add active class to links that match activePath. - .each(function () { - var linkDomain = this.protocol + this.hostname; - var linkPath = self.getPath(this); - - // A link matches if it is part of the active trail of activePath, except - // for frontpage links. - if (linkDomain == windowDomain && (activePath + '/').indexOf(linkPath + '/') === 0 && (linkPath !== '' || activePath === '')) { - $(this).addClass('active'); - } - }); -}; - -/** - * Helper function to get the (corrected) Drupal path of a link. - * - * @param link - * Link object or string to get the Drupal path from. - * @param ignorePathFromQueryString - * Boolean whether to ignore path from query string if path appears empty. - * - * @return - * The Drupal path. - */ -Drupal.overlay.getPath = function (link, ignorePathFromQueryString) { - if (typeof link == 'string') { - // Create a native Link object, so we can use its object methods. - link = $(link.link(link)).get(0); - } - - var path = link.pathname; - // Ensure a leading slash on the path, omitted in some browsers. - if (path.charAt(0) != '/') { - path = '/' + path; - } - path = path.replace(new RegExp(Drupal.settings.basePath + '(?:index.php)?'), ''); - if (path == '' && !ignorePathFromQueryString) { - // If the path appears empty, it might mean the path is represented in the - // query string (clean URLs are not used). - var match = new RegExp('([?&])q=(.+)([&#]|$)').exec(link.search); - if (match && match.length == 4) { - path = match[2]; - } - } - - return path; -}; - -/** - * Get the total displacement of given region. - * - * @param region - * Region name. Either "top" or "bottom". - * - * @return - * The total displacement of given region in pixels. - */ -Drupal.overlay.getDisplacement = function (region) { - var displacement = 0; - var lastDisplaced = $('.overlay-displace-' + region + ':last'); - if (lastDisplaced.length) { - displacement = lastDisplaced.offset().top + lastDisplaced.outerHeight(); - - // Remove height added by IE Shadow filter. - if (lastDisplaced[0].filters && lastDisplaced[0].filters.length && lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow')) { - displacement -= lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow').strength; - displacement = Math.max(0, displacement); - } - } - return displacement; -}; - -/** - * Makes elements outside the overlay unreachable via the tab key. - * - * @param context - * The part of the DOM that should have its tabindexes changed. Defaults to - * the entire page. - */ -Drupal.overlay.makeDocumentUntabbable = function (context) { - // Manipulating tabindexes for the entire document is unacceptably slow in IE6 - // and IE7, so in those browsers, the underlying page will still be reachable - // via the tab key. However, we still make the links within the Disable - // message unreachable, because the same message also exists within the - // child document. The duplicate copy in the underlying document is only for - // assisting screen-reader users navigating the document with reading commands - // that follow markup order rather than tab order. - if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8) { - $('#overlay-disable-message a', context).attr('tabindex', -1); - return; - } - - context = context || document.body; - var $overlay, $tabbable, $hasTabindex; - - // Determine which elements on the page already have a tabindex. - $hasTabindex = $('[tabindex] :not(.overlay-element)', context); - // Record the tabindex for each element, so we can restore it later. - $hasTabindex.each(Drupal.overlay._recordTabindex); - // Add the tabbable elements from the current context to any that we might - // have previously recorded. - Drupal.overlay._hasTabindex = $hasTabindex.add(Drupal.overlay._hasTabindex); - - // Set tabindex to -1 on everything outside the overlay and toolbars, so that - // the underlying page is unreachable. - - // By default, browsers make a, area, button, input, object, select, textarea, - // and iframe elements reachable via the tab key. - $tabbable = $('a, area, button, input, object, select, textarea, iframe'); - // If another element (like a div) has a tabindex, it's also tabbable. - $tabbable = $tabbable.add($hasTabindex); - // Leave links inside the overlay and toolbars alone. - $overlay = $('.overlay-element, #overlay-container, .overlay-displace-top, .overlay-displace-bottom').find('*'); - $tabbable = $tabbable.not($overlay); - // We now have a list of everything in the underlying document that could - // possibly be reachable via the tab key. Make it all unreachable. - $tabbable.attr('tabindex', -1); -}; - -/** - * Restores the original tabindex value of a group of elements. - * - * @param context - * The part of the DOM that should have its tabindexes restored. Defaults to - * the entire page. - */ -Drupal.overlay.makeDocumentTabbable = function (context) { - // Manipulating tabindexes is unacceptably slow in IE6 and IE7. In those - // browsers, the underlying page was never made unreachable via tab, so - // there is no work to be done here. - if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8) { - return; - } - - var $needsTabindex; - context = context || document.body; - - // Make the underlying document tabbable again by removing all existing - // tabindex attributes. - var $tabindex = $('[tabindex]', context); - if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8) { - // removeAttr('tabindex') is broken in IE6-7, but the DOM function - // removeAttribute works. - var i; - var length = $tabindex.length; - for (i = 0; i < length; i++) { - $tabindex[i].removeAttribute('tabIndex'); - } - } - else { - $tabindex.removeAttr('tabindex'); - } - - // Restore the tabindex attributes that existed before the overlay was opened. - $needsTabindex = $(Drupal.overlay._hasTabindex, context); - $needsTabindex.each(Drupal.overlay._restoreTabindex); - Drupal.overlay._hasTabindex = Drupal.overlay._hasTabindex.not($needsTabindex); -}; - -/** - * Record the tabindex for an element, using $.data. - * - * Meant to be used as a jQuery.fn.each callback. - */ -Drupal.overlay._recordTabindex = function () { - var $element = $(this); - var tabindex = $(this).attr('tabindex'); - $element.data('drupalOverlayOriginalTabIndex', tabindex); -} - -/** - * Restore an element's original tabindex. - * - * Meant to be used as a jQuery.fn.each callback. - */ -Drupal.overlay._restoreTabindex = function () { - var $element = $(this); - var tabindex = $element.data('drupalOverlayOriginalTabIndex'); - $element.attr('tabindex', tabindex); -}; - -/** - * Theme function to create the overlay iframe element. - */ -Drupal.theme.prototype.overlayContainer = function () { - return '<div id="overlay-container"><div class="overlay-modal-background"></div></div>'; -}; - -/** - * Theme function to create an overlay iframe element. - */ -Drupal.theme.prototype.overlayElement = function (url) { - return '<iframe class="overlay-element" frameborder="0" scrolling="auto" allowtransparency="true"></iframe>'; -}; - -})(jQuery); diff --git a/modules/overlay/overlay.api.php b/modules/overlay/overlay.api.php deleted file mode 100644 index bc23546df7e..00000000000 --- a/modules/overlay/overlay.api.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -/** - * @file - * Hooks provided by Overlay module. - */ - -/** - * @addtogroup hooks - * @{ - */ - -/** - * Allow modules to act when an overlay parent window is initialized. - * - * The parent window is initialized when a page is displayed in which the - * overlay might be required to be displayed, so modules can act here if they - * need to take action to accommodate the possibility of the overlay appearing - * within a Drupal page. - */ -function hook_overlay_parent_initialize() { - // Add our custom JavaScript. - drupal_add_js(drupal_get_path('module', 'hook') . '/hook-overlay.js'); -} - -/** - * Allow modules to act when an overlay child window is initialized. - * - * The child window is initialized when a page is displayed from within the - * overlay, so modules can act here if they need to take action to work from - * within the confines of the overlay. - */ -function hook_overlay_child_initialize() { - // Add our custom JavaScript. - drupal_add_js(drupal_get_path('module', 'hook') . '/hook-overlay-child.js'); -} - -/** - * @} End of "addtogroup hooks". - */ diff --git a/modules/overlay/overlay.info b/modules/overlay/overlay.info deleted file mode 100644 index a78279206b0..00000000000 --- a/modules/overlay/overlay.info +++ /dev/null @@ -1,5 +0,0 @@ -name = Overlay -description = Displays the Drupal administration interface in an overlay. -package = Core -version = VERSION -core = 8.x diff --git a/modules/overlay/overlay.install b/modules/overlay/overlay.install deleted file mode 100644 index 2fa7c84bc65..00000000000 --- a/modules/overlay/overlay.install +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -/** - * @file - * Install, update and uninstall functions for the overlay module. - */ - -/** - * Implements hook_enable(). - * - * If the module is being enabled through the admin UI, and not from an - * install profile, reopen the modules page in an overlay. - */ -function overlay_enable() { - if (strpos(current_path(), 'admin/modules') === 0) { - // Flag for a redirect to <front>#overlay=admin/modules on hook_init(). - $_SESSION['overlay_enable_redirect'] = 1; - } -} diff --git a/modules/overlay/overlay.module b/modules/overlay/overlay.module deleted file mode 100644 index 6e137b74873..00000000000 --- a/modules/overlay/overlay.module +++ /dev/null @@ -1,975 +0,0 @@ -<?php - -/** - * @file - * Displays the Drupal administration interface in an overlay. - */ - -/** - * Implements hook_help(). - */ -function overlay_help($path, $arg) { - switch ($path) { - case 'admin/help#overlay': - $output = ''; - $output .= '<h3>' . t('About') . '</h3>'; - $output .= '<p>' . t('The Overlay module makes the administration pages on your site display in a JavaScript overlay of the page you were viewing when you clicked the administrative link, instead of replacing the page in your browser window. Use the close link on the overlay to return to the page you were viewing when you clicked the link. For more information, see the online handbook entry for <a href="@overlay">Overlay module</a>.', array('@overlay' => 'http://drupal.org/handbook/modules/overlay')) . '</p>'; - return $output; - } -} - -/** - * Implements hook_menu(). - */ -function overlay_menu() { - $items['overlay-ajax/%'] = array( - 'title' => '', - 'page callback' => 'overlay_ajax_render_region', - 'page arguments' => array(1), - 'access arguments' => array('access overlay'), - 'type' => MENU_CALLBACK, - ); - $items['overlay/dismiss-message'] = array( - 'title' => '', - 'page callback' => 'overlay_user_dismiss_message', - 'access arguments' => array('access overlay'), - 'type' => MENU_CALLBACK, - ); - return $items; -} - -/** - * Implements hook_admin_paths(). - */ -function overlay_admin_paths() { - $paths = array( - // This is marked as an administrative path so that if it is visited from - // within the overlay, the user will stay within the overlay while the - // callback is being processed. - 'overlay/dismiss-message' => TRUE, - ); - return $paths; -} - -/** - * Implements hook_permission(). - */ -function overlay_permission() { - return array( - 'access overlay' => array( - 'title' => t('Access the administrative overlay'), - 'description' => t('View administrative pages in the overlay.'), - ), - ); -} - -/** - * Implements hook_theme(). - */ -function overlay_theme() { - return array( - 'overlay' => array( - 'render element' => 'page', - 'template' => 'overlay', - ), - 'overlay_disable_message' => array( - 'render element' => 'element', - ), - ); -} - -/** - * Implements hook_form_FORM_ID_alter(). - */ -function overlay_form_user_profile_form_alter(&$form, &$form_state) { - if ($form['#user_category'] == 'account') { - $account = $form['#user']; - if (user_access('access overlay', $account)) { - $form['overlay_control'] = array( - '#type' => 'fieldset', - '#title' => t('Administrative overlay'), - '#weight' => 4, - '#collapsible' => TRUE, - ); - - $form['overlay_control']['overlay'] = array( - '#type' => 'checkbox', - '#title' => t('Use the overlay for administrative pages.'), - '#description' => t('Show administrative pages on top of the page you started from.'), - '#default_value' => isset($account->data['overlay']) ? $account->data['overlay'] : 1, - ); - } - } -} - -/** - * Implements hook_user_presave(). - */ -function overlay_user_presave(&$edit, $account, $category) { - if (isset($edit['overlay'])) { - $edit['data']['overlay'] = $edit['overlay']; - } -} - -/** - * Implements hook_init(). - * - * Determine whether the current page request is destined to appear in the - * parent window or in the overlay window, and format the page accordingly. - * - * @see overlay_set_mode() - */ -function overlay_init() { - global $user; - - $mode = overlay_get_mode(); - - // Only act if the user has access to the overlay and a mode was not already - // set. Other modules can also enable the overlay directly for other uses. - $use_overlay = !isset($user->data['overlay']) || $user->data['overlay']; - if (empty($mode) && user_access('access overlay') && $use_overlay) { - $current_path = current_path(); - // After overlay is enabled on the modules page, redirect to - // <front>#overlay=admin/modules to actually enable the overlay. - if (isset($_SESSION['overlay_enable_redirect']) && $_SESSION['overlay_enable_redirect']) { - unset($_SESSION['overlay_enable_redirect']); - drupal_goto('<front>', array('fragment' => 'overlay=' . $current_path)); - } - - if (isset($_GET['render']) && $_GET['render'] == 'overlay') { - // If a previous page requested that we close the overlay, close it and - // redirect to the final destination. - if (isset($_SESSION['overlay_close_dialog'])) { - call_user_func_array('overlay_close_dialog', $_SESSION['overlay_close_dialog']); - unset($_SESSION['overlay_close_dialog']); - } - // If this page shouldn't be rendered inside the overlay, redirect to the - // parent. - elseif (!path_is_admin($current_path)) { - overlay_close_dialog($current_path); - } - - // Indicate that we are viewing an overlay child page. - overlay_set_mode('child'); - - // Unset the render parameter to avoid it being included in URLs on the page. - unset($_GET['render']); - } - // Do not enable the overlay if we already are on an admin page. - elseif (!path_is_admin($current_path)) { - // Otherwise add overlay parent code and our behavior. - overlay_set_mode('parent'); - } - } -} - -/** - * Implements hook_exit(). - * - * When viewing an overlay child page, check if we need to trigger a refresh of - * the supplemental regions of the overlay on the next page request. - */ -function overlay_exit() { - // Check that we are in an overlay child page. Note that this should never - // return TRUE on a cached page view, since the child mode is not set until - // overlay_init() is called. - if (overlay_get_mode() == 'child') { - // Load any markup that was stored earlier in the page request, via calls - // to overlay_store_rendered_content(). If none was stored, this is not a - // page request where we expect any changes to the overlay supplemental - // regions to have occurred, so we do not need to proceed any further. - $original_markup = overlay_get_rendered_content(); - if (!empty($original_markup)) { - // Compare the original markup to the current markup that we get from - // rendering each overlay supplemental region now. If they don't match, - // something must have changed, so we request a refresh of that region - // within the parent window on the next page request. - foreach (overlay_supplemental_regions() as $region) { - if (!isset($original_markup[$region]) || $original_markup[$region] != overlay_render_region($region)) { - overlay_request_refresh($region); - } - } - } - } -} - -/** - * Implements hook_library_info(). - */ -function overlay_library_info() { - $module_path = drupal_get_path('module', 'overlay'); - - // Overlay parent. - $libraries['parent'] = array( - 'title' => 'Overlay: Parent', - 'website' => 'http://drupal.org/handbook/modules/overlay', - 'version' => '1.0', - 'js' => array( - $module_path . '/overlay-parent.js' => array(), - ), - 'css' => array( - $module_path . '/overlay-parent.css' => array(), - ), - 'dependencies' => array( - array('system', 'ui'), - array('system', 'jquery.bbq'), - ), - ); - // Overlay child. - $libraries['child'] = array( - 'title' => 'Overlay: Child', - 'website' => 'http://drupal.org/handbook/modules/overlay', - 'version' => '1.0', - 'js' => array( - $module_path . '/overlay-child.js' => array(), - ), - 'css' => array( - $module_path . '/overlay-child.css' => array(), - ), - ); - - return $libraries; -} - -/** - * Implements hook_drupal_goto_alter(). - */ -function overlay_drupal_goto_alter(&$path, &$options, &$http_response_code) { - if (overlay_get_mode() == 'child') { - // The authorize.php script bootstraps Drupal to a very low level, where - // the PHP code that is necessary to close the overlay properly will not be - // loaded. Therefore, if we are redirecting to authorize.php inside the - // overlay, instead redirect back to the current page with instructions to - // close the overlay there before redirecting to the final destination; see - // overlay_init(). - if ($path == system_authorized_get_url() || $path == system_authorized_batch_processing_url()) { - $_SESSION['overlay_close_dialog'] = array($path, $options); - $path = current_path(); - $options = drupal_get_query_parameters(); - } - - // If the current page request is inside the overlay, add ?render=overlay - // to the new path, so that it appears correctly inside the overlay. - if (isset($options['query'])) { - $options['query'] += array('render' => 'overlay'); - } - else { - $options['query'] = array('render' => 'overlay'); - } - } -} - -/** - * Implements hook_batch_alter(). - * - * If the current page request is inside the overlay, add ?render=overlay to - * the success callback URL, so that it appears correctly within the overlay. - * - * @see overlay_get_mode() - */ -function overlay_batch_alter(&$batch) { - if (overlay_get_mode() == 'child') { - if (isset($batch['url_options']['query'])) { - $batch['url_options']['query']['render'] = 'overlay'; - } - else { - $batch['url_options']['query'] = array('render' => 'overlay'); - } - } -} - -/** - * Implements hook_page_alter(). - */ -function overlay_page_alter(&$page) { - // If we are limiting rendering to a subset of page regions, deny access to - // all other regions so that they will not be processed. - if ($regions_to_render = overlay_get_regions_to_render()) { - $skipped_regions = array_diff(element_children($page), $regions_to_render); - foreach ($skipped_regions as $skipped_region) { - $page[$skipped_region]['#access'] = FALSE; - } - } - - $mode = overlay_get_mode(); - if ($mode == 'child') { - // Add the overlay wrapper before the html wrapper. - array_unshift($page['#theme_wrappers'], 'overlay'); - } - elseif ($mode == 'parent' && ($message = overlay_disable_message())) { - $page['page_top']['disable_overlay'] = $message; - } -} - -/** - * Menu callback; dismisses the overlay accessibility message for this user. - */ -function overlay_user_dismiss_message() { - global $user; - // It's unlikely, but possible that "access overlay" permission is granted to - // the anonymous role. In this case, we do not display the message to disable - // the overlay, so there is nothing to dismiss. Also, protect against - // cross-site request forgeries by validating a token. - if (empty($user->uid) || !isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'overlay')) { - return MENU_ACCESS_DENIED; - } - else { - user_save(user_load($user->uid), array('data' => array('overlay_message_dismissed' => 1))); - drupal_set_message(t('The message has been dismissed. You can change your overlay settings at any time by visiting your profile page.')); - // Destination is normally given. Go to the user profile as a fallback. - drupal_goto('user/' . $user->uid . '/edit'); - } -} - -/** - * Returns a renderable array representing a message for disabling the overlay. - * - * If the current user can access the overlay and has not previously indicated - * that this message should be dismissed, this function returns a message - * containing a link to disable the overlay. Nothing is returned for anonymous - * users, because the links control per-user settings. Therefore, because some - * screen readers are unable to properly read overlay contents, site builders - * are discouraged from granting the "access overlay" permission to the - * anonymous role. See http://drupal.org/node/890284. - */ -function overlay_disable_message() { - global $user; - - if (!empty($user->uid) && empty($user->data['overlay_message_dismissed']) && (!isset($user->data['overlay']) || $user->data['overlay']) && user_access('access overlay')) { - $build = array( - '#theme' => 'overlay_disable_message', - '#weight' => -99, - // Link to the user's profile page, where the overlay can be disabled. - 'profile_link' => array( - '#type' => 'link', - '#title' => t('If you have problems accessing administrative pages on this site, disable the overlay on your profile page.'), - '#href' => 'user/' . $user->uid . '/edit', - '#options' => array( - 'query' => drupal_get_destination(), - 'fragment' => 'edit-overlay-control', - 'attributes' => array( - 'id' => 'overlay-profile-link', - // Prevent the target page from being opened in the overlay. - 'class' => array('overlay-exclude'), - ), - ), - ), - // Link to a menu callback that allows this message to be permanently - // dismissed for the current user. - 'dismiss_message_link' => array( - '#type' => 'link', - '#title' => t('Dismiss this message.'), - '#href' => 'overlay/dismiss-message', - '#options' => array( - 'query' => drupal_get_destination() + array( - // Add a token to protect against cross-site request forgeries. - 'token' => drupal_get_token('overlay'), - ), - 'attributes' => array( - 'id' => 'overlay-dismiss-message', - // If this message is being displayed outside the overlay, prevent - // this link from opening the overlay. - 'class' => (overlay_get_mode() == 'parent') ? array('overlay-exclude') : array(), - ), - ), - ) - ); - } - else { - $build = array(); - } - - return $build; -} - -/** - * Returns the HTML for the message about how to disable the overlay. - * - * @see overlay_disable_message() - */ -function theme_overlay_disable_message($variables) { - $element = $variables['element']; - - // Add CSS classes to hide the links from most sighted users, while keeping - // them accessible to screen-reader users and keyboard-only users. To assist - // screen-reader users, this message appears in both the parent and child - // documents, but only the one in the child document is part of the tab order. - foreach (array('profile_link', 'dismiss_message_link') as $key) { - $element[$key]['#options']['attributes']['class'][] = 'element-invisible'; - if (overlay_get_mode() == 'child') { - $element[$key]['#options']['attributes']['class'][] = 'element-focusable'; - } - } - - // Render the links. - $output = drupal_render($element['profile_link']) . ' ' . drupal_render($element['dismiss_message_link']); - - // Add a heading for screen-reader users. The heading doesn't need to be seen - // by sighted users. - $output = '<h3 class="element-invisible">' . t('Options for the administrative overlay') . '</h3>' . $output; - - // Wrap in a container for styling. - $output = '<div id="overlay-disable-message" class="clearfix">' . $output . '</div>'; - - return $output; -} - -/** - * Implements hook_block_list_alter(). - */ -function overlay_block_list_alter(&$blocks) { - // If we are limiting rendering to a subset of page regions, hide all blocks - // which appear in regions not on that list. Note that overlay_page_alter() - // does a more comprehensive job of preventing unwanted regions from being - // displayed (regardless of whether they contain blocks or not), but the - // reason for duplicating effort here is performance; we do not even want - // these blocks to be built if they are not going to be displayed. - if ($regions_to_render = overlay_get_regions_to_render()) { - foreach ($blocks as $bid => $block) { - if (!in_array($block->region, $regions_to_render)) { - unset($blocks[$bid]); - } - } - } -} - -/** - * Implements hook_system_info_alter(). - * - * Add default regions for the overlay. - */ -function overlay_system_info_alter(&$info, $file, $type) { - if ($type == 'theme') { - $info['overlay_regions'][] = 'content'; - $info['overlay_regions'][] = 'help'; - } -} - -/** - * Implements hook_preprocess_html(). - * - * If the current page request is inside the overlay, add appropriate classes - * to the <body> element, and simplify the page title. - * - * @see overlay_get_mode() - */ -function overlay_preprocess_html(&$variables) { - if (overlay_get_mode() == 'child') { - // Add overlay class, so themes can react to being displayed in the overlay. - $variables['classes_array'][] = 'overlay'; - } -} - -/** - * Implements hook_preprocess_maintenance_page(). - * - * If the current page request is inside the overlay, add appropriate classes - * to the <body> element, and simplify the page title. - * - * @see overlay_preprocess_maintenance_page() - */ -function overlay_preprocess_maintenance_page(&$variables) { - overlay_preprocess_html($variables); -} - -/** - * Preprocesses template variables for overlay.tpl.php - * - * @see overlay.tpl.php - */ -function template_preprocess_overlay(&$variables) { - $variables['tabs'] = menu_primary_local_tasks(); - $variables['title'] = drupal_get_title(); - $variables['disable_overlay'] = overlay_disable_message(); - $variables['content_attributes_array']['class'][] = 'clearfix'; -} - -/** - * Processes variables for overlay.tpl.php - * - * @see template_preprocess_overlay() - * @see overlay.tpl.php - */ -function template_process_overlay(&$variables) { - // Place the rendered HTML for the page body into a top level variable. - $variables['page'] = $variables['page']['#children']; -} - -/** - * Implements hook_preprocess_page(). - * - * Hide tabs inside the overlay. - * - * @see overlay_get_mode() - */ -function overlay_preprocess_page(&$variables) { - if (overlay_get_mode() == 'child') { - unset($variables['tabs']['#primary']); - } -} - -/** - * Callback to request that the overlay display an empty page. - * - * This is used to prevent a page request which closes the overlay (for - * example, a form submission) from being fully re-rendered before the overlay - * is closed. Instead, we store a variable which will cause the page to be - * rendered by a delivery callback function that does not actually print - * visible HTML (but rather only the bare minimum scripts and styles necessary - * to trigger the overlay to close), thereby allowing the dialog to be closed - * faster and with less interruption, and also allowing the display of messages - * to be deferred to the parent window (rather than displaying them in the - * child window, which will close before the user has had a chance to read - * them). - * - * @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. - * - * @see overlay_page_delivery_callback_alter() - */ -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. - */ -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() - */ -function overlay_get_mode() { - return overlay_set_mode(NULL); -} - -/** - * Sets the overlay mode and adds proper JavaScript and styles to the page. - * - * Note that since setting the overlay mode triggers a variety of behaviors - * (including hooks being invoked), it can only be done once per page request. - * Therefore, the first call to this function which passes along a value of the - * $mode parameter controls the overlay mode that will be used. - * - * @param $mode - * To set the mode, pass in one of the following values: - * - 'parent': This is used in the context of a parent window (a regular - * browser window). If set, JavaScript is added so that administrative - * links in the parent window will open in an overlay. - * - 'child': This is used in the context of the child overlay window (the - * page actually appearing within the overlay iframe). If set, JavaScript - * and CSS are added so that Drupal behaves nicely from within the overlay. - * - 'none': This is used to avoid adding any overlay-related code to the - * page at all. Modules can set this to explicitly prevent the overlay from - * being used. For example, since the overlay module itself sets the mode - * to 'parent' or 'child' in overlay_init() when certain conditions are - * met, other modules which want to override that behavior can do so by - * setting the mode to 'none' earlier in the page request - e.g., in their - * own hook_init() implementations, if they have a lower weight. - * This parameter is optional, and if omitted, the current mode will be - * returned with no action taken. - * - * @return - * The current mode, if any has been set, or NULL if no mode has been set. - * - * @ingroup overlay_api - * @see overlay_init() - */ -function overlay_set_mode($mode = NULL) { - global $base_path; - $overlay_mode = &drupal_static(__FUNCTION__); - - // Make sure external resources are not included more than once. Also return - // the current mode, if no mode was specified. - if (isset($overlay_mode) || !isset($mode)) { - return $overlay_mode; - } - $overlay_mode = $mode; - - switch ($overlay_mode) { - case 'parent': - drupal_add_library('overlay', 'parent'); - - // Allow modules to act upon overlay events. - module_invoke_all('overlay_parent_initialize'); - break; - - case 'child': - drupal_add_library('overlay', 'child'); - - // Allow modules to act upon overlay events. - module_invoke_all('overlay_child_initialize'); - break; - } - return $overlay_mode; -} - -/** - * Implements hook_overlay_parent_initialize(). - */ -function overlay_overlay_parent_initialize() { - // Let the client side know which paths are administrative. - $paths = path_get_admin_paths(); - foreach ($paths as &$type) { - $type = str_replace('<front>', variable_get('site_frontpage', 'node'), $type); - } - drupal_add_js(array('overlay' => array('paths' => $paths)), 'setting'); - // Pass along the Ajax callback for rerendering sections of the parent window. - drupal_add_js(array('overlay' => array('ajaxCallback' => 'overlay-ajax')), 'setting'); -} - -/** - * Implements hook_overlay_child_initialize(). - */ -function overlay_overlay_child_initialize() { - // Check if the parent window needs to refresh any page regions on this page - // request. - 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 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 - // rendered. - overlay_set_regions_to_render(overlay_regions()); -} - -/** - * Callback to request that the overlay close as soon as the page is displayed. - * - * @param $redirect - * (optional) The path that should open in the parent window after the - * overlay closes. If not set, no redirect will be performed on the parent - * window. - * @param $redirect_options - * (optional) An associative array of options to use when generating the - * redirect URL. - */ -function overlay_close_dialog($redirect = NULL, $redirect_options = array()) { - $settings = array( - 'overlayChild' => array( - 'closeOverlay' => TRUE, - ), - ); - - // Tell the child window to perform the redirection when requested to. - if (isset($redirect)) { - $settings['overlayChild']['redirect'] = url($redirect, $redirect_options); - } - - drupal_add_js($settings, array('type' => 'setting')); - - // Since we are closing the overlay as soon as the page is displayed, we do - // not want to show any of the page's actual content. - overlay_display_empty_page(TRUE); -} - -/** - * Returns a list of page regions that appear in the overlay. - * - * Overlay regions correspond to the entire contents of the overlay child - * window and are refreshed each time a new page request is made within the - * overlay. - * - * @return - * An array of region names that correspond to those which appear in the - * overlay, within the theme that is being used to display the current page. - * - * @see overlay_supplemental_regions() - */ -function overlay_regions() { - return _overlay_region_list('overlay_regions'); -} - -/** - * Returns a list of supplemental page regions for the overlay. - * - * Supplemental overlay regions are those which are technically part of the - * parent window, but appear to the user as being related to the overlay - * (usually because they are displayed next to, rather than underneath, the - * main overlay regions) and therefore need to be dynamically refreshed if any - * administrative actions taken within the overlay change their contents. - * - * An example of a typical overlay supplemental region would be the 'page_top' - * region, in the case where a toolbar is being displayed there. - * - * @return - * An array of region names that correspond to supplemental overlay regions, - * within the theme that is being used to display the current page. - * - * @see overlay_regions() - */ -function overlay_supplemental_regions() { - return _overlay_region_list('overlay_supplemental_regions'); -} - -/** - * Helper function for returning a list of page regions related to the overlay. - * - * @param $type - * The type of regions to return. This can either be 'overlay_regions' or - * 'overlay_supplemental_regions'. - * - * @return - * An array of region names of the given type, within the theme that is being - * used to display the current page. - * - * @see overlay_regions() - * @see overlay_supplemental_regions() - */ -function _overlay_region_list($type) { - // Obtain the current theme. We need to first make sure the theme system is - // initialized, since this function can be called early in the page request. - drupal_theme_initialize(); - $themes = list_themes(); - $theme = $themes[$GLOBALS['theme']]; - // Return the list of regions stored within the theme's info array, or an - // empty array if no regions of the appropriate type are defined. - return !empty($theme->info[$type]) ? $theme->info[$type] : array(); -} - -/** - * Returns a list of page regions that rendering should be limited to. - * - * @return - * An array containing the names of the regions that will be rendered when - * drupal_render_page() is called. If empty, then no limits will be imposed, - * and all regions of the page will be rendered. - * - * @see overlay_page_alter() - * @see overlay_block_list_alter() - * @see overlay_set_regions_to_render() - */ -function overlay_get_regions_to_render() { - return overlay_set_regions_to_render(); -} - -/** - * Sets the regions of the page that rendering will be limited to. - * - * @param $regions - * (Optional) An array containing the names of the regions that should be - * rendered when drupal_render_page() is called. Pass in an empty array to - * remove all limits and cause drupal_render_page() to render all page - * regions (the default behavior). If this parameter is omitted, no change - * will be made to the current list of regions to render. - * - * @return - * The current list of regions to render, or an empty array if the regions - * are not being limited. - * - * @see overlay_page_alter() - * @see overlay_block_list_alter() - * @see overlay_get_regions_to_render() - */ -function overlay_set_regions_to_render($regions = NULL) { - $regions_to_render = &drupal_static(__FUNCTION__, array()); - if (isset($regions)) { - $regions_to_render = $regions; - } - return $regions_to_render; -} - -/** - * Renders an individual page region. - * - * This function is primarily intended to be used for checking the content of - * supplemental overlay regions (e.g., a region containing a toolbar). Passing - * in a region that is intended to display the main page content is not - * supported; the region will be rendered by this function, but the main page - * content will not appear in it. In addition, although this function returns - * the rendered HTML for the provided region, it does not place it on the final - * page, nor add any of its associated JavaScript or CSS to the page. - * - * @param $region - * The name of the page region that should be rendered. - * - * @return - * The rendered HTML of the provided region. - */ -function overlay_render_region($region) { - // Indicate the region that we will be rendering, so that other regions will - // be hidden by overlay_page_alter() and overlay_block_list_alter(). - overlay_set_regions_to_render(array($region)); - // Do what is necessary to force drupal_render_page() to only display HTML - // from the requested region. Specifically, declare that the main page - // content does not need to automatically be added to the page, and pass in - // a page array that has all theme functions removed (so that overall HTML - // for the page will not be added either). - $system_main_content_added = &drupal_static('system_main_content_added'); - $system_main_content_added = TRUE; - $page = array( - '#type' => 'page', - '#theme' => NULL, - '#theme_wrappers' => array(), - ); - // Render the region, but do not cache any JavaScript or CSS associated with - // it. This region might not be included the next time drupal_render_page() - // is called, and we do not want its JavaScript or CSS to erroneously appear - // on the final rendered page. - $original_js = drupal_add_js(); - $original_css = drupal_add_css(); - $original_libraries = drupal_static('drupal_add_library'); - $js = &drupal_static('drupal_add_js'); - $css = &drupal_static('drupal_add_css'); - $libraries = &drupal_static('drupal_add_library'); - $markup = drupal_render_page($page); - $js = $original_js; - $css = $original_css; - $libraries = $original_libraries; - // Indicate that the main page content has not, in fact, been displayed, so - // that future calls to drupal_render_page() will be able to render it - // correctly. - $system_main_content_added = FALSE; - // Restore the original behavior of rendering all regions for the next time - // drupal_render_page() is called. - overlay_set_regions_to_render(array()); - return $markup; -} - -/** - * Returns any rendered content that was stored earlier in the page request. - * - * @return - * An array of all rendered HTML that was stored earlier in the page request, - * keyed by the identifier with which it was stored. If no content was - * stored, an empty array is returned. - * - * @see overlay_store_rendered_content() - */ -function overlay_get_rendered_content() { - return overlay_store_rendered_content(); -} - -/** - * Stores strings representing rendered HTML content. - * - * This function is used to keep a static cache of rendered content that can be - * referred to later in the page request. - * - * @param $id - * (Optional) An identifier for the content which is being stored, which will - * be used as an array key in the returned array. If omitted, no change will - * be made to the current stored data. - * @param $content - * (Optional) A string representing the rendered data to store. This only has - * an effect if $id is also provided. - * - * @return - * An array representing all data that is currently being stored, or an empty - * array if there is none. - * - * @see overlay_get_rendered_content() - */ -function overlay_store_rendered_content($id = NULL, $content = NULL) { - $rendered_content = &drupal_static(__FUNCTION__, array()); - if (isset($id)) { - $rendered_content[$id] = $content; - } - return $rendered_content; -} - -/** - * Request that the parent window refresh a particular page region. - * - * @param $region - * 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_refresh() - * @see Drupal.overlay.refreshRegions() - */ -function overlay_request_refresh($region) { - $class = drupal_region_class($region); - $_SESSION['overlay_regions_to_refresh'][] = array($class => $region); -} - -/** - * Request that the entire parent window be reloaded when the overlay closes. - * - * @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_refresh() { - if (!empty($_SESSION['overlay_regions_to_refresh'])) { - $settings = array( - 'overlayChild' => array( - 'refreshRegions' => $_SESSION['overlay_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']); - } -} - -/** - * Prints the markup obtained by rendering a single region of the page. - * - * This function is intended to be called via Ajax. - * - * @param $region - * The name of the page region to render. - * - * @see Drupal.overlay.refreshRegions() - */ -function overlay_ajax_render_region($region) { - print overlay_render_region($region); -} diff --git a/modules/overlay/overlay.tpl.php b/modules/overlay/overlay.tpl.php deleted file mode 100644 index 54b10af1f1c..00000000000 --- a/modules/overlay/overlay.tpl.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/** - * @file - * Default theme implementation to display a page in the overlay. - * - * Available variables: - * - $title: the (sanitized) title of the page. - * - $page: The rendered page content. - * - $tabs (array): Tabs linking to any sub-pages beneath the current page - * (e.g., the view and edit tabs when displaying a node). - * - * Helper variables: - * - $classes_array: Array of html class attribute values. It is flattened - * into a string within the variable $classes. - * - * @see template_preprocess() - * @see template_preprocess_overlay() - * @see template_process() - */ -?> - -<?php print render($disable_overlay); ?> -<div id="overlay" <?php print $attributes; ?>> - <div id="overlay-titlebar" class="clearfix"> - <div id="overlay-title-wrapper" class="clearfix"> - <h1 id="overlay-title"<?php print $title_attributes; ?>><?php print $title; ?></h1> - </div> - <div id="overlay-close-wrapper"> - <a id="overlay-close" href="#" class="overlay-close"><span class="element-invisible"><?php print t('Close overlay'); ?></span></a> - </div> - <?php if ($tabs): ?><h2 class="element-invisible"><?php print t('Primary tabs'); ?></h2><ul id="overlay-tabs"><?php print render($tabs); ?></ul><?php endif; ?> - </div> - <div id="overlay-content"<?php print $content_attributes; ?>> - <?php print $page; ?> - </div> -</div> |