- Split up the initial setup portion of the script into two parts: one sets up the page for use with the navigation script (hide navigation sections, add click event for every link to aid in navigation); the second determines which section needs to be shown.
- The new second part of the function determines whether or not an anchor is included in the URL. If none is present then the first section is made visible. If one is present and it matches one of the navigation sections then that section is made visible. If it matches an anchor other than one of the navigation sections it climbs the DOM tree to see if that anchor is contained in one of the navigation sections, which is then made visible.
- The new click event for links was necessary to allow anchor navigation within a document. Since an anchor may be in a hidden section it was necessary to find a way to determine when such a link was clicked so that the correct section could be shown. The function loads the new URL and then reloads the page, causing the load event to fire which then displays the correct navigation section and jumps to the anchor point.
- Split the function that shows/hides the navigation section into two different functions. The first determines (based on the click event) which navigational link was click and so which section needs to be shown. The second performs the actual work of showing the correct section. I split this up so that I could do the show/hide work outside of the original flow (the navigation click). This was necessary for the creation of the added functionality described in the previous bullets. It also allows someone to create a link to perform this function.
Friday, March 18, 2005
Component Prototype
I made some major modifications to the show/hide navigation script I wrote for inclusion in the prototype that FM is working on. Some of the modifications may make their way back into the script, but for now I'll be keeping them separate. Here's a breakdown of the changes: