home *** CD-ROM | disk | FTP | other *** search
- var buttonSlopX = 5;
- var buttonSlopY = 2;
- var firstButtonX = 5;
-
- var prev = "";
- var current;
-
- function Point (x, y) {
- this.x = x;
- this.y = y;
- }
-
-
- function ButtonSetup(name, value, tip, clickAction)
- {
- this.name = name;
- this.value = value;
- this.tip = tip;
- this.clickAction = clickAction;
- }
-
-
- function buttonHilite()
- {
- var hilite = window.document.layers['topHilite'];
- var bottomHilite = window.document.layers['bottomHilite'];
-
- hilite.left = this.left-buttonSlopX;
- hilite.top = this.top-buttonSlopY;
- hilite.clip.width=this.clip.width + (2 * buttonSlopX) -1;
- hilite.clip.height=this.clip.height+buttonSlopY;
- hilite.visibility="show";
-
- bottomHilite.left = this.left + hilite.clip.width + 1 - buttonSlopX - bottomHilite.document.width;
- bottomHilite.top = this.top + hilite.clip.height - bottomHilite.document.height;
- bottomHilite.clip.left = bottomHilite.document.width - hilite.clip.width;
- bottomHilite.clip.top = bottomHilite.document.height - hilite.clip.height;
- bottomHilite.visibility="show";
-
- return;
- }
-
- function buttonDim()
- {
- window.document.layers['topHilite'].visibility="hidden";
- window.document.layers['bottomHilite'].visibility="hidden";
- return;
- }
-
- function buttonCreate()
- {
- var buttonLayer;
-
- buttonLayer = new Layer(this.width + 2);
- buttonLayer.visibility = "hide";
- buttonLayer.document.open();
- var outputString = "";
- outputString += "<layer top=0 left=0 clip=50,30><a href='gencon.htm'";
- outputString += " onclick=\"self.buttonClick('";
- outputString += this.value;
- outputString += "'); return false;\">";
- outputString += "<img src=\"images/blank.gif\" border=0 width=50 height=30 alt=\"";
- outputString += this.tooltip;
- outputString += "\"></a></layer>";
- outputString += "<font face = \"" + this.fontFace + "\" point-size = " + this.fontSize + ">";
- outputString += this.text;
- outputString += "</font>";
- buttonLayer.document.write(outputString);
-
- buttonLayer.document.close();
-
- buttonLayer.left = this.xPos;
- buttonLayer.top = this.yPos;
- buttonLayer.clip.width = this.width;
- buttonLayer.clip.height = this.height;
- buttonLayer.onMouseOver = this.hilite;
- buttonLayer.onMouseOut = this.dim;
-
- return buttonLayer;
- }
-
- function TextButton(parent, value, text, tooltip, width, height, xPos, yPos, font, size)
- {
- this.value = value;
- this.text = text;
- this.tooltip = tooltip;
- this.height= height;
- this.width = width;
- this.xPos = xPos;
- this.yPos = yPos;
- this.fontFace = font;
- this.fontSize = size.toString();
- this.parent = parent;
-
- this.createButton = buttonCreate;
- this.hilite = buttonHilite;
- this.dim = buttonDim;
- this.click = '"' + buttonClick + '"';
- }
-
- function measureText(text, font, fontSize)
- {
- outputString = "";
-
- document.layers['measure'].document.clear();
- document.layers['measure'].document.open();
- outputString += "<font face = \"" + font + "\" point-size = \"" + fontSize + "\">";
- outputString += text;
- outputString += "</font>";
- document.layers['measure'].document.write(outputString);
- document.layers['measure'].document.close();
-
- var size = new Point(document.layers['measure'].clip.width, document.layers['measure'].clip.height);
-
- return size;
- }
-
-
- function layoutButtons (specArray)
- {
- var size = 0 ;
- var rowWidth = 0;
- var rowNum = 0;
- var maxHeight =0 ;
- var font = specArray.fontFace;
- var fontSize = specArray.fontSize;
- var startHeight = specArray.startHeight;
-
- var rows = new Array();
- var buttons = new Array();
-
- var name;
- var button, row;
- var spaceWidth;
- var xPos = firstButtonX + buttonSlopX;
- var i;
- var retryCount = 0;
-
- for (i=0; i< specArray.length; i++) {
- name = specArray[i].name;
- size = measureText(name, font, fontSize);
-
- if (size.y > maxHeight)
- maxHeight = size.y;
-
- if (rowWidth + size.x > 190) {
- if (retryCount >= 1) {
- // exceeded the width of the row, and we've already tried to re-layout
- // the buttons. We'll just have to do drop to another line.
-
- buttons.rowWidth = rowWidth;
- rows[rowNum++] = buttons;
- buttons = new Array();
- startHeight = 3;
- rowWidth = 0;
- } else {
- // exceeded the width of our space. Let's try it by dropping the
- // font size by a bit and try to relayout.
-
- fontSize -=2;
- retryCount ++;
-
- i=-1;
-
- size = 0 ;
- rowWidth = 0;
- rowNum = 0;
- maxHeight =0 ;
-
- buttons.length = 0;
- continue;
- }
- }
-
- rowWidth += size.x;
- buttons[buttons.length] = new TextButton(null, specArray[i].value, name, specArray[i].tip, size.x, size.y, -1, -1, font, fontSize);
- }
-
- buttons.rowWidth = rowWidth;
- rows[rowNum] = buttons;
-
- rowNum=0;
- for (row in rows) {
- rowWidth = rows[row].rowWidth;
- spacerWidth = (180 - rowWidth) / (rows[row].length - 1);
- buttons = rows[row];
- for (i=0; i < buttons.length; i++) {
- button = buttons[i];
- button.xPos = xPos;
- button.yPos = startHeight + (rowNum * maxHeight);
- xPos += button.width + spacerWidth;
- }
-
- xPos = firstButtonX + buttonSlopX;
- rowNum++;
- }
-
- rows.totalHeight = rowNum * maxHeight;
- return rows;
- }
-
- function MakeButtons(buttons)
- {
- var rows;
- var rowButtons;
- var button;
- var visButton;
- rows = layoutButtons(buttons);
-
- for (var row in rows) {
- rowButtons = rows[row];
- for (i=0; i < rowButtons.length; i++) {
- button = rowButtons[i];
-
- visButton = button.createButton();
- visButton.visibility="show";
- }
- }
- }
-
- function buttonClick(button)
- {
- switch (button) {
- case "New":
- HandleAdd();
- break;
- case "Options":
- HandleEdit();
- break;
- case "Help":
- HandleHelp("");
- break;
- case "Exit":
- HandleExit();
- break;
- }
-
- }
-
- var buttons = new Array(4);
-
- buttons[0] = new ButtonSetup(top.getLocalString("New"), "New", top.getLocalString("Add a new item to Netcaster"), "");
- buttons[1] = new ButtonSetup(top.getLocalString("Options"), "Options", top.getLocalString("Configure Netcaster"), "");
- buttons[2] = new ButtonSetup(top.getLocalString("Help"), "Help", top.getLocalString("Get Help"), "");
- buttons[3] = new ButtonSetup(top.getLocalString("Exit"), "Exit", top.getLocalString("Close Netcaster"), "");
-
- buttons.startHeight = 7;
- if (depth.isWindows()) {
- buttons.fontFace = "Arial";
- } else {
- buttons.fontFace = "Helvetica";
- }
- buttons.fontSize = "10";
-
- function onLoad() {
- MakeButtons(buttons);
- }
-
- compromisePrincipals();
-
- void(0);