Wednesday, February 13, 2008

New Additions and Functionality



Resizing Gripper

With the help of The University of Pennsylvania Libraries Toolbar I was able to correct and add a resizing gripper to the toolbar. The gripper behavior is a bit non-intuitive as to how it works but I was able to correct the behavior by locking down each component by setting their flex values. The gripper resizes the box to the immediate left of it and nothing else. If the values were not set then resizing the toolbar would be destructive and when you pulled the bar to the left and let go of the element it would leave everything scrunched together (like my previous post).

So each XUL element needs to have locked size settings and a setting for flex:
width="value"
minwidth="value"
flex = "0" (or 1) (0 means that it is not flexible, 1 means you can resize it).

Tabbing Controls



One of my faculty asked me to standardize the searching method that is built into the toolbar to load each new search into a pop-up menu. I have added the option to pick whether or not the user wants to load searches in new windows or to load them in the current window they are working in. The following XUL script will add in a tabbing section to a menu. The function that follows controls whether or not tabbing is used.

XML:
<menupopup id="EToolbar Settings">
<menuitem label="Tabbing On" oncommand="engrTabSet(true)" tooltiptext="Turn Tabbing On" />
<menuitem label="Tabbing Off" oncommand="engrTabSet(false)" tooliptext="Turn Tabbing Off" />
</menupopup>

Javascript Functions:

//engrTabSet(Boolean) - Sets whether tabbing is on or off.

function engrTabSet(engrtabval)
{
if(engrtabval)
{
engrpops=true;
}
else
{
engrpops=false;
}
}

//engrTab(String) takes the string that is given to it and either loads it into a new tab (if tabbing is on) or loads it into the same window otherwise.

function engrTab(engrlink)
{
if(engrpops)
{
var newTab=getBrowser().addTab(engrlink);
getBrowser().selectedTab=newTab;
newTab.selected='true';
}
else
{
window._content.document.location=engrlink;
}
};

I have gone through the code that I used for the toolbar and cleaned up syntax and formatting. I also standardized several of the functions so there would be no conflicts with other applications.

No comments: