Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
With margin-top applied, we can use Javascript to adjust absolute positioned elements, as well as the <body>
background.
Needless to say, it requires that you have Apply top margin option enabled.
Comment | File | Size | Author |
---|---|---|---|
#46 | admin_menu-auto_height_bind_plus_fixed_top-428844-#38-D7.patch | 2.27 KB | StrVL |
#7 | admin_menu-428844-04.patch | 3.42 KB | AmrMostafa |
#7 | admin_menu-428844-04-D5.patch | 3.08 KB | AmrMostafa |
#5 | admin_menu-428844-03.patch | 3.42 KB | AmrMostafa |
#3 | admin_menu_D5-428844-03.patch | 2 KB | AmrMostafa |
Comments
Comment #1
AmrMostafa CreditAttribution: AmrMostafa commented... and since I originally developed this on D5 since my theme which needed the fix was there, here is a D5 patch as well.
Comment #2
AmrMostafa CreditAttribution: AmrMostafa commentedFix for a bug where the
:absolute
selector was including#admin-menu
's sub-menus in the processing which obviously misplaces them.Updated patches included, HEAD and D5.
Comment #3
AmrMostafa CreditAttribution: AmrMostafa commentedThe D5 versions of the patch above required jquery_update module (i.e. a recent version of jQuery) to work. But with this patch this is no longer required, stock 5.x jQuery will work fine.
Comment #4
sun#427048: Sticky table headers hidden when keep menu at top of page is true seems to slightly overlap with this patch.
In general, that other issue made me finally think again about this approach here and I think I basically agree. However, I don't think we really need to add a new jQuery :absolute selector...?
Thoughts?
That aside, there are some indentation errors in this patch. It should also use single quotes where possible. And shouldn't the last hunk only run if $("body").css("background-position") results in anything?
Comment #5
AmrMostafa CreditAttribution: AmrMostafa commentedGreat, I've extended this patch to cover 'fixed' positioned elements, which includes #427048: Sticky table headers hidden when keep menu at top of page is true. However, since tableheader.js is included after us, this won't work yet. If you want to test it, you will have to open
admin_menu.module
and replace the'module'
bit with'theme'
for thedrupal_add_js('admin_menu.js', ...)
soadmin_menu.js
is included aftertableheader.js
. We will probably want to think about how to do this right.Can you elaborate, why not? It appears to me to be the most optimal way to do this with jQuery. Otherwise, we would end up looping on the elements ourselves and no matter how good we can do it I doubt we can beat jQuery to it. We are getting all/any jQuery/Sizzle optimizations this way.
Fixed the quotes, but I can't seem to find the indentation issues (I assumed you mean hard tabs instead of spaces).
No, because even if the background-position is
0% 0%
(the default, even if not set explicitly) we still want to adjust it.Lastly, shouldn't we merge
repositionLayout
intoadminMenuMarginTop
?Comment #6
AmrMostafa CreditAttribution: AmrMostafa commentedComment #7
AmrMostafa CreditAttribution: AmrMostafa commentedUse
$adminMenu
instead of#admin-menu
in some place, and a D5 version.Comment #8
TravisCarden CreditAttribution: TravisCarden commentedSubscribe
Comment #9
sunIn 3.x, admin_menu can have a variable size/height, due to optional, enhancing widgets and themes/designs that can be enabled. So we badly need this.
For 5.x-3.x, I'm fine with adding a dependency on jquery_update, btw. No need to special-case that, especially, because I want all 3.x code to be as comparable as possible, and many sites need jquery_update anyway.
What's left to continue here?
Comment #10
hass CreditAttribution: hass commented+
Comment #11
sun"@todo" is the proper directive. If a @todo spans over multiple lines, the following lines should be indented with extra 2 spaces.
Also, typo in "came".
uh oh - I thought the purpose of this patch is to fix all positioning issues like table headers?
If this only applies to fixed positioning, then we need another solution for the absolute positioning case (which is the default, but still leads to issues when widgets start to span over "multiple lines").
Always use "10" as extra argument to parseInt() if you want to get decimal numbers.
Use double quotes only where technically required, please.
This JSDoc is missing a summary (what's there can be left as description).
Missing period (full-stop).
This review is powered by Dreditor.
Comment #12
tim.plunketthas the patch been rerolled since sun's critique?
Comment #13
ñull CreditAttribution: ñull commented+ Very needed for sticky headers that disappear behind the menu
Comment #14
ñull CreditAttribution: ñull commentedbump
Comment #15
bensey CreditAttribution: bensey commentedHi,
I really need this issue fixed also, but as a rank amateur who has trouble with patching in windows, I came up with a temporary solution until someone clever comes up with a better one, lol.
I often use conditional statements to define styles based on roles, and just threw the following into the head tag in page.tpl.php defining a style that adjusts the sticky header top margin for the role that the admin menu is displayed... (example is 30px as I set admin menu to 30px with larger font for accessibility)
Simple, but it works for me as a short-term fix.
Comment #16
Senpai CreditAttribution: Senpai commentedThe latest patch from #7 fails at hunk 1, line 113 against admin_menu-6.x-3.x-dev on Drupal-6-16.
Rejects file pasted below for reference:
Comment #17
boabjohn CreditAttribution: boabjohn commented+ ... sort of nice, sort of essential. Any progress for alpha4? Sorry no code/css chops here: anything else you guys need? Ie, boxes of beer, three rousing cheers, ??
Comment #18
casey CreditAttribution: casey commentedUsing #787940: Generic approach for position:fixed elements like Toolbar, tableHeader admin menu would only need the class "displace-top", rest will be done automaticly.
In this patch I also see background-position repositioning... is it an idea to merge that into #787940: Generic approach for position:fixed elements like Toolbar, tableHeader?
Comment #19
casey CreditAttribution: casey commentedI opened a seperate issue about using misc/displace.js: #801526: Use misc/displace.js to position admin_menu.
Comment #20
scott859 CreditAttribution: scott859 commentedsubscribing
Comment #21
sun@AmrMostafa, TravisCarden, Senpai, bensey + others: Drupal 7 core may introduce a functionality along the lines of this issue/patch, as proposed by @casey. It would be great if all of you would help to review + validate the approach taken over in #787940: Generic approach for position:fixed elements like Toolbar, tableHeader
Comment #22
pillarsdotnet CreditAttribution: pillarsdotnet commentedUntil the 7.x solution gets back-ported to 6.x, I have implemented the following hack on my site. This also fixes the problem of table captions triggering the header-scroll too early. I'm just sharing in case somebody else needs an immediate work-around:
Also, I have the following CSS to prevent the table body from showing through the header, as if it were transparent:
Comment #23
BrightBoldThanks @pillarsdotnet - awesome patch. This problem has been driving me crazy.
Comment #24
Aurochs CreditAttribution: Aurochs commentedignore this
Comment #25
podarok@pillarsdotnet
#22 If You make this like a patch file for testing bot we can got it into code someday
Comment #26
pillarsdotnet CreditAttribution: pillarsdotnet commented@podarok: I sincerely doubt that drupal core will ever accept a patch that explicitly recognizes admin_menu.
Perhaps admin_menu can replace/override misc/tableheader.js with it's own version? I'd have to look through the code in jquery_update to see how they do it.
Comment #27
Todd Zebert CreditAttribution: Todd Zebert commented#22 works great, thanks!!!!
Comment #28
pillarsdotnet CreditAttribution: pillarsdotnet commentedComment #29
pillarsdotnet CreditAttribution: pillarsdotnet commentedSee #520368: Admin toolbar breaks sticky table headers
and #1210844: Admin menu covers sticky headers
Comment #30
sunComment #31
taocode CreditAttribution: taocode as a volunteer commentedPatch breaks javascript. Please ignore.
Comment #32
taocode CreditAttribution: taocode as a volunteer commentedMy first patch submission. This broke javascript on some locations. Hopefully the patch below (comment #36) will help.
Comment #33
taocode CreditAttribution: taocode as a volunteer commentedComment #34
taocode CreditAttribution: taocode as a volunteer commenteddoesn't work. Please ignore.
Comment #35
taocode CreditAttribution: taocode as a volunteer commentedwrong again. Sorry.
Comment #36
taocode CreditAttribution: taocode as a volunteer commentedThis patch automatically adjusts the margin-top and absolute/fixed headers (with css class hook) according to current admin_menu height. Add 'hook-admin-menu-top' class to all your fixed/absolute positioned template elements to be re-positioned below the admin_menu.
Uses jQuery.bind to recalculate the admin menu height on load and resize, keeping the menu from overlapping the content no matter how tall it gets in a narrow browser.
Comment #37
mikeytown2 CreditAttribution: mikeytown2 commentedPatch applies, setting issue to needs review.
Comment #46
StrVL CreditAttribution: StrVL as a volunteer and at DrupalJedi commentedPatch #36 works, but it attaches more that one pair of load+resize events. After every attachBehaviors() call it adds new unnecessary events pair. There is a fix.
Comment #47
Chris Matthews CreditAttribution: Chris Matthews commentedThe patch in #46 applied cleanly on 7.x-3.x-dev to admin_menu.css; admin_menu.js and admin_menu_toolbar.css works for me and appears to be ready to RTBC.
Comment #48
Chris Matthews CreditAttribution: Chris Matthews commentedComment #49
thallesCan you send screens before and after the patch?
On apply:
warning: admin_menu.js has type 100644, expected 100755