Omitting Drupal's admin overlay from selectors

I had an issue recently, where I was using a selector to add menu tabs to the edge of the content area. Getting them to appear wasn't the issue. Getting them NOT to appear on admin overlays was.
The body class on which my selector was based didn't change when an admin overlay covered the page. It was still .front. So, how to do the equivalent of the following pseudo-code?
if body class = front but not an admin overlay?
What DOES change in the markup is the html tag. It has the class
overlay-open
when the admin overlay is present. So, given that, how do we select the body from
<html>
  <body class="front">
  <body>
<html>
but not
<html class="overlay-open">
  <body class="front">
  <body>
<html>
'not' is the answer. Or, more precisely, '.not'. There are, of course, many ways to finagle the desired selection in jQuery. In this case, we can use .not to tell jQuery what we don't want along with what we do.
$('html').not('.overlay-open').find('body.front')
will return the body, unless the admin overlay is present, in which case it will return nothing.

Add new comment

Markdown

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Missing filter. All text is removed
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.