jQuery LavaLamp - auto default start location tests

jQuery LavaLamp Demos Page

LavaLamp's priority order for default starting location:
  1. by startItem value
  2. by class="selectedLava"
  3. by homeTop/homeLeft if returnHome is true
  4. by browser location match with one of the LavaLamp links
  5. first element in list

1. startItem test

$('ul#manualtest').lavaLamp({startItem: 3});

2. selectedLava (& noLava) class tests

<li class="selectedLava"><a href="/projects/lavalamp/urltest/">trailing slash</a></li>

3. home element test

$('ul#hometest').lavaLamp({homeTop:100, homeLeft:100, returnHome:true});

4. URI Matching::

- absolute path tests:

LavaLamp defaults to the longest href found that matches the full window.location path+query+hash reference. In the test above, the first absolute with trailing slash link always highlights even when clicking the no trailing slash link because the browser always delivers a trailing slash on path only links, making the longer a href match the winner in any case.

- relative path tests:

Notice when you click the 3rd or 4th link above, the similar absolute links are also highlighted in the previous absolute tests menu. A menu with similar mixed absolute and relative a href links will always default to the longest a href match.

- mixed absolute and relative path tests:

While obviously the last two links offer more detail than the first, because the first link is the longest a href and matches within the full path delivered by window.location it wins for default. Yes, code could be added to attempt a full mixed match, but to keep LavaLamp as lean as possible I am leaving it this way for now.
Some tips for using automatic start location:

jQuery LavaLamp Demos Page

copyright (c) 2008-2010 Nixbox Designs

feel free to reuse this code anyway you see fit in your own projects, understanding you assume all responsibility of such usage.

 

 

 

protocol: | port: | host: | hostname:

href: | pathname:

hash: | search: