[MAGNOLIA-2438] Add "first" to li class on first element, "last" to li class on last element of level Created: 17/Oct/08  Updated: 23/Jan/13  Resolved: 19/Jan/09

Status: Closed
Project: Magnolia
Component/s: taglibs
Affects Version/s: 3.6.3
Fix Version/s: 4.0

Type: Improvement Priority: Minor
Reporter: Will Scheidegger Assignee: Magnolia International
Resolution: Fixed Votes: 0
Labels: css, simpleNavigation
Remaining Estimate: 0.5h
Time Spent: Not Specified
Original Estimate: 0.5h

Attachments: Text File SimpleNavigationTag.patch    
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

Often one would like to have the first or last nav element of a level display differently, e.g. an additional border. The proposed modification adds a "first" to the css class of the first element and a "last" to the last nav element of each level, i.e. to the <li> tag.

For instance this:
<ul class="level3">
<li class="leaf"><a href="/magnoliaAuthor/page1.html">Link 1</a></li>
<li class="leaf"><a href="/magnoliaAuthor/page2.html">Link 2</a></li>
<li class="leaf"><a href="/magnoliaAuthor/page3.html">Link 3</a></li>
<li class="leaf"><a href="/magnoliaAuthor/page4.html">Link 4</a></li>
</ul>

will be turned into this:
<ul class="level3">
<li class="leaf first"><a href="/magnoliaAuthor/page1.html">Link 1</a></li>
<li class="leaf"><a href="/magnoliaAuthor/page2.html">Link 2</a></li>
<li class="leaf"><a href="/magnoliaAuthor/page3.html">Link 3</a></li>
<li class="leaf last"><a href="/magnoliaAuthor/page4.html">Link 4</a></li>
</ul>

Note: I did create the patch file as described in http://wiki.magnolia-cms.com/display/WIKI/Developer+information but the patch file looks strange with many many lines to be removed. Therefore I also added the complete, modified Java file.



 Comments   
Comment by Magnolia International [ 17/Oct/08 ]

The patch looks "strange" only because your ide went ahead and reformatted the code without being asked to do it

Actually if you code redo it without the code style change it'd be great, we'd see where the actual changes are.

Comment by Ryan Gardner [ 17/Oct/08 ]

I would suggest that this not be on by default. This "first" and "last" thing is already provided in CSS2 selectors.

http://www.quirksmode.org/css/firstchild.html

Sure, older versions of IE don't support it - but there is the "ie7" script which can be loaded in ie7 which makes adds back in the support:

http://dean.edwards.name/IE7/

I don't have a problem adding it in - but I think it'd be better to have it as an option which you have to turn on in order to enable it. (just my 2 cents)

Comment by Will Scheidegger [ 19/Oct/08 ]

I modified the patch so that one has to turn it on specifically by setting the markFirstAndLastElement attribute to true.... and I fixed the patch file so that it only reflects the real changes, not the code "cleanup" by NetBeans.

-> I don't think that having this "on" by default is bad. The two additional classes will not have any impact on the HTML code.
-> Still more than 50% of the users us IE which is not a CSS2 browser

But then again having to turn the feature on with a flag is not that bad either.

Comment by Magnolia International [ 19/Jan/09 ]

Patch applied, thanks !

Generated at Mon Feb 12 03:36:43 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.