Writing Friendly Code 11. Alll the Options | WebReference

Writing Friendly Code 11. Alll the Options

home / web / dev / friendly

Writing Friendly Code

11. All the Options

The parameter that is sent to this function is the "this.value" from the button clicked, which sets the appropriate control's visibility and toggles the button's text (which becomes the new value). I love that "this." The next time the button is clicked, the new this.value is sent, and "Show Tabs" becomes "Hide Tabs", for instance. You have to burrow through the layers to access the form controls in Navigator, while IE uses it's "all". The style property is not used here, the value of a control seems to really be the value of the thing....

There are in all four button containers, each of which is a positioned div container with a form containing some input buttons. The page tab class across the top and a pair of navigation buttons ("back" and "next") at the lower right are made visible when the page opens. Also visible on startup is a button at the right of the page numbers, called "Options." 

If the user clicks the Options button, the button disappears and another bar is made visible near the bottom of the screen. The options bar has the buttons for the Forum and Resources pages, among other features. 


function shoOpts(wotOpt){ 
   if(wotOpt=="Options"){ 
     setVis("toolBox","visible");
     setVis("optins","hidden"); 
   }
   if(wotOpt=="Hide"){
     setVis("toolBox","hidden");
     setVis("optins","visible"); 
   }
   if(wotOpt=="Show Tabs"){
     setVis("tabBar","visible");
     if (brid=="IE") document.all.optbtn1.value="Hide Tabs";
     if (brid=="NS") document.toolBox.document.forms[0].optbtn1.value="Hide Tabs";
   }
   if(wotOpt=="Hide Tabs"){
     setVis("tabBar","hidden");
     if (brid=="IE") document.all.optbtn1.value="Show Tabs";
     if (brid=="NS") document.toolBox.document.forms[0].optbtn1.value="Show Tabs";
   }
}


1.n. inform

inform is called from various places with a parameter (wotis) for the index of the tip in the infos array. Navigator likes to destroy the old layer and build a new one, Microsoft prefers to convert the heathen and change its existing content. 

IE does an inner HTML to produce the tip. Ordinarily the popup will appear in front of the page you are viewing, but the iframes seem to stay on top no matter what. To make the popup visible from the iframe pages I temporarily hide the iframe page. When you close the popup it runs "turnpg(pg)" and reopens the page you were just on in a blink. 


function inform(wotis){
var tmpg="page"+pg;
   if(brid=="IE"){
     if(pg>=n2 ) setVis(tmpg,"hidden"); 
     document.all.info.style.visibility="visible";
     document.all.info.innerHTML=infos[wotis]; 
   }

Navigator does it wholesale. Writes a new page to a layer nested in the info layer. If you write to the top layer you overwrite the whole page. The first tip is integrated with the watermark, but the watermark has to be hidden if the tip is one of the others. There is one case where the message for Navigator is not the same as the one that is appropriate for IE, although the same event sends the same parameter to the function. Here we check to see if we are looking for number 4 and simply replace it with number 5.  

The thing that took me forever was getting the click event of the button that is written to the tips page to click. I'd get the button to show, but no Event. I wrote a ton of Event handlers, but, as usual, the solution was easy. I had to make the parent layer visible to pass the click event through. Since the parent layer (info) had no visible content it didn't cause a display problem. And the click event went right to inform().


   if(brid=="NS"){
     if(wotis==4)wotis=5; 
     (wotis>0) ? setVis("watermark","hidden") : setVis("watermark","visible") 
     document.info.document.moInfo.document.write(infos[wotis])
     document.info.document.moInfo.document.close(); 
     setVis(tmpg,"hidden"); 
     document.info.visibility="show";
     document.info.document.moInfo.visibility="show";
   }
} 

Finishing Up 

Comments are welcome

 


Created: Dec. 2, 1999
Revised: Dec. 7, 1999

URL: http://webreference.com/dev/friendly/