Fixed Tab code in Composer dialogs, b=157778, r=neil@parkwaycc.co.uk, sr=alecf, a=asa/drivers

This commit is contained in:
cmanske%netscape.com 2002-07-25 17:32:12 +00:00
parent bc188ef763
commit 56fba4830f
4 changed files with 44 additions and 111 deletions

View File

@ -28,10 +28,7 @@ var CellElement;
var TableCaptionElement;
var globalCellElement;
var globalTableElement
const TablePanel = 0;
const CellPanel = 1;
var currentPanel = TablePanel;
var validatePanel;
var gValidateTab;
const defHAlign = "left";
const centerStr = "center"; //Index=1
const rightStr = "right"; // 2
@ -115,6 +112,7 @@ function Startup()
gDialog.TableAlignList = document.getElementById("TableAlignList");
gDialog.TableCaptionList = document.getElementById("TableCaptionList");
gDialog.TableInheritColor = document.getElementById("TableInheritColor");
gDialog.TabBox = document.getElementById("TabBox");
// Cell Panel
gDialog.SelectionList = document.getElementById("SelectionList");
@ -147,7 +145,6 @@ function Startup()
gDialog.CellColorCheckbox = document.getElementById("CellColorCheckbox");
gDialog.TableTab = document.getElementById("TableTab");
gDialog.CellTab = document.getElementById("CellTab");
gDialog.TabPanels = document.getElementById("TabPanels");
TableElement = editorShell.GetElementOrParentByTagName("table", null);
if(!TableElement)
@ -192,33 +189,18 @@ function Startup()
// Starting TabPanel name is passed in
if (window.arguments[1] == "CellPanel")
{
currentPanel = CellPanel;
//Set index for starting panel on the <tabpanels> element
gDialog.TabPanels.selectedIndex = CellPanel; // setAttribute("selectedIndex", CellPanel);
// Trigger setting of style for the tab widgets
gDialog.CellTab.selected = "true";
gDialog.TableTab.selected = null;
// Use cell element for Advanced Edit dialog
globalElement = globalCellElement;
}
gDialog.TabBox.selectedTab = gDialog.CellTab;
}
if (currentPanel == TablePanel)
if (gDialog.TabBox.selectedTab == gDialog.TableTab)
{
// Use table element for Advanced Edit dialog
globalElement = globalTableElement;
// We may call this with table selected, but no cell,
// so disable the Cell Properties tab
if(!CellElement)
{
// XXX: Disabling of tabs is currently broken, so for
// now we'll just remove the tab completely.
//CellTab.setAttribute("disabled", "true");
//gDialog.CellTab.disabled = true;
gDialog.CellTab.parentNode.removeChild(gDialog.CellTab);
}
}
@ -253,7 +235,7 @@ function Startup()
// If first initializing, we really aren't changing anything
CellDataChanged = false;
if (currentPanel == CellPanel)
if (gDialog.TabBox.selectedTab == gDialog.CellTab)
setTimeout("gDialog.SelectionList.focus()", 0);
else
SetTextboxFocus(gDialog.TableRowsInput);
@ -434,18 +416,6 @@ function GetCellData(rowIndex, colIndex)
return true;
}
function SelectTableTab()
{
globalElement = globalTableElement;
currentPanel = TablePanel;
}
function SelectCellTab()
{
globalElement = globalCellElement;
currentPanel = CellPanel;
}
function SelectCellHAlign()
{
SetCheckbox("CellHAlignCheckbox");
@ -538,7 +508,6 @@ function ChangeSelectionToFirstCell()
}
CellElement = cellData.cell;
globalCellElement = CellElement;
globalElement = CellElement;
curRowIndex = 0;
curColIndex = 0;
@ -699,7 +668,6 @@ function MoveSelection(forward)
// Copy for new global cell
globalCellElement = CellElement.cloneNode(false);
globalElement = globalCellElement;
// Change the selection
DoCellSelection();
@ -780,21 +748,8 @@ function DisableSelectionButtons( disable )
function SwitchToValidatePanel()
{
if (currentPanel != validatePanel)
{
//Set index for starting panel on the <tabpanels> element
gDialog.TabPanels.selectedIndex = validatePanel; //setAttribute("selectedIndex", validatePanel);
if (validatePanel == CellPanel)
{
// Trigger setting of style for the tab widgets
gDialog.CellTab.selected = "true";
gDialog.TableTab.selected = null;
} else {
gDialog.TableTab.selected = "true";
gDialog.CellTab.selected = null;
}
currentPanel = validatePanel;
}
if (gDialog.TabBox.selectedTab != gValidateTab)
gDialog.TabBox.selectedTab = gValidateTab;
}
function SetAlign(listID, defaultValue, element, attName)
@ -808,7 +763,7 @@ function SetAlign(listID, defaultValue, element, attName)
function ValidateTableData()
{
validatePanel = TablePanel;
gValidateTab = gDialog.TableTab;
newRowCount = Number(ValidateNumber(gDialog.TableRowsInput, null, 1, maxRows, null, true, true));
if (gValidationError) return false;
@ -863,7 +818,7 @@ function ValidateTableData()
function ValidateCellData()
{
validatePanel = CellPanel;
gValidateTab = gDialog.CellTab;
if (gDialog.CellHeightCheckbox.checked)
{
@ -918,10 +873,9 @@ function ValidateCellData()
function ValidateData()
{
var result;
var savePanel = currentPanel;
// Validate current panel first
if (currentPanel == TablePanel)
if (gDialog.TabBox.selectedTab == gDialog.TableTab)
{
result = ValidateTableData();
if (result)
@ -933,11 +887,8 @@ function ValidateData()
}
if(!result) return false;
// If we passed, restore former currentPanel
currentPanel = savePanel;
// Set global element for AdvancedEdit
if(currentPanel == TablePanel)
if(gDialog.TabBox.selectedTab == gDialog.TableTab)
globalElement = globalTableElement;
else
globalElement = globalCellElement;
@ -950,7 +901,7 @@ function ChangeCellTextbox(textboxID)
// Filter input for just integers
forceInteger(textboxID);
if (currentPanel == CellPanel)
if (gDialog.TabBox.selectedTab == gDialog.CellTab)
CellDataChanged = true;
}

View File

@ -50,15 +50,15 @@
<spacer id="location" offsetY="50" persist="offsetX offsetY"/>
<broadcaster id="args" value=""/>
<tabbox>
<tabbox id="TabBox">
<tabs flex="1">
<tab id="TableTab" oncommand="SelectTableTab()" label="&tableTab.label;"/>
<tab id="CellTab" oncommand="SelectCellTab()" label="&cellTab.label;"/>
<tab id="TableTab" label="&tableTab.label;"/>
<tab id="CellTab" label="&cellTab.label;"/>
</tabs>
<tabpanels id="TabPanels">
<tabpanels>
<!-- TABLE PANEL -->
<vbox id="TablePanel">
<vbox>
<groupbox orient="horizontal"><caption label="&size.label;"/>
<grid>
<columns><column/><column/><column/><column/><column/></columns>
@ -155,7 +155,7 @@
</vbox><!-- Table Panel -->
<!-- CELL PANEL -->
<vbox id="CellPanel">
<vbox>
<groupbox orient="horizontal" align="center">
<caption label="&cellSelection.label;"/>
<vbox>

View File

@ -22,9 +22,6 @@
* Ryan Cassin (rcassin@supernova.org)
*/
var gPublishPanel = 0;
var gSettingsPanel = 1;
var gCurrentPanel = gPublishPanel;
var gPublishSiteData;
var gReturnData;
var gDefaultSiteIndex = -1;
@ -52,7 +49,7 @@ function Startup()
return;
}
gDialog.TabPanels = document.getElementById("TabPanels");
gDialog.TabBox = document.getElementById("TabBox");
gDialog.PublishTab = document.getElementById("PublishTab");
gDialog.SettingsTab = document.getElementById("SettingsTab");
@ -68,7 +65,6 @@ function Startup()
gDialog.OtherDirList = document.getElementById("OtherDirList");
// Settings Panel
gDialog.SettingsPanel = document.getElementById("SettingsPanel");
gDialog.SiteNameInput = document.getElementById("SiteNameInput");
gDialog.PublishUrlInput = document.getElementById("PublishUrlInput");
gDialog.BrowseUrlInput = document.getElementById("BrowseUrlInput");
@ -291,7 +287,7 @@ function AddNewSite()
// Button in Publish panel allows user
// to automatically switch to "Settings" panel
// to enter data for new site
SwitchPanel(gSettingsPanel);
SwitchPanel(gDialog.SettingsTab);
gDialog.SiteList.selectedIndex = -1;
@ -304,42 +300,23 @@ function AddNewSite()
function SelectPublishTab()
{
if (gSettingsChanged)
{
gCurrentPanel = gPublishPanel;
if (!ValidateSettings())
return;
if (gSettingsChanged && !ValidateSettings())
return;
gCurrentPanel = gSettingsPanel;
}
SwitchPanel(gPublishPanel);
SwitchPanel(gDialog.PublishTab);
SetTextboxFocus(gDialog.PageTitleInput);
}
function SelectSettingsTab()
{
SwitchPanel(gSettingsPanel);
SwitchPanel(gDialog.SettingsTab);
SetTextboxFocus(gDialog.SiteNameInput);
}
function SwitchPanel(panel)
function SwitchPanel(tab)
{
if (gCurrentPanel != panel)
{
// Set index for starting panel on the <tabpanels> element
gDialog.TabPanels.selectedIndex = panel;
if (panel == gSettingsPanel)
{
// Trigger setting of style for the tab widgets
gDialog.SettingsTab.selected = "true";
gDialog.PublishTab.selected = null;
} else {
gDialog.PublishTab.selected = "true";
gDialog.SettingsTab.selected = null;
}
gCurrentPanel = panel;
}
if (gDialog.TabBox.selectedTab != tab)
gDialog.TabBox.selectedTab = tab;
}
function onInputSettings()
@ -384,12 +361,12 @@ function ValidateSettings()
var siteName = TrimString(gDialog.SiteNameInput.value);
if (!siteName)
{
ShowErrorInPanel(gSettingsPanel, "MissingSiteNameError", gDialog.SiteNameInput);
ShowErrorInPanel(gDialog.SettingsTab, "MissingSiteNameError", gDialog.SiteNameInput);
return false;
}
if (PublishSiteNameExists(siteName, gPublishSiteData, gDialog.SiteList.selectedIndex))
{
SwitchPanel(gSettingsPanel);
SwitchPanel(gDialog.SettingsTab);
ShowInputErrorMessage(GetString("DuplicateSiteNameError").replace(/%name%/, siteName));
SetTextboxFocus(gDialog.SiteNameInput);
return false;
@ -402,14 +379,19 @@ function ValidateSettings()
if (publishUrl)
{
publishUrl = FormatUrlForPublishing(publishUrl);
// Assume scheme = "ftp://" if missing
// This compensates when user enters hostname w/o scheme (as most ISPs provide)
if (!GetScheme(publishUrl))
publishUrl = "ftp://" + publishUrl;
gDialog.PublishUrlInput.value = publishUrl;
}
else
{
ShowErrorInPanel(gSettingsPanel, "MissingPublishUrlError", gDialog.PublishUrlInput);
ShowErrorInPanel(gDialog.SettingsTab, "MissingPublishUrlError", gDialog.PublishUrlInput);
return false;
}
var browseUrl = GetBrowseUrlInput();
var username = TrimString(gDialog.UsernameInput.value);
@ -551,7 +533,7 @@ function ValidateData()
var filename = TrimString(gDialog.FilenameInput.value);
if (!filename)
{
ShowErrorInPanel(gPublishPanel, "MissingPublishFilename", gDialog.FilenameInput);
ShowErrorInPanel(gDialog.PublishTab, "MissingPublishFilename", gDialog.FilenameInput);
return false;
}
gReturnData.filename = filename;
@ -559,9 +541,9 @@ function ValidateData()
return true;
}
function ShowErrorInPanel(panelId, errorMsgId, widgetWithError)
function ShowErrorInPanel(tab, errorMsgId, widgetWithError)
{
SwitchPanel(panelId);
SwitchPanel(tab);
ShowInputErrorMessage(GetString(errorMsgId));
if (widgetWithError)
SetTextboxFocus(widgetWithError);
@ -569,7 +551,7 @@ function ShowErrorInPanel(panelId, errorMsgId, widgetWithError)
function doHelpButton()
{
if (gCurrentPanel == gPublishPanel)
if (gDialog.TabBox.selectedTab == gDialog.PublishTab)
openHelp("comp-doc-publish-publishtab");
else
openHelp("comp-doc-publish-settingstab");

View File

@ -49,14 +49,14 @@
<spacer id="location" offsetY="50" persist="offsetX offsetY"/>
<broadcaster id="args" value=""/>
<tabbox>
<tabbox id="TabBox">
<tabs flex="1">
<tab id="PublishTab" oncommand="SelectPublishTab()" label="&publishTab.label;"/>
<tab id="SettingsTab" oncommand="SelectSettingsTab()" label="&settingsTab.label;"/>
</tabs>
<tabpanels id="TabPanels">
<tabpanels>
<!-- PUBLISH PANEL -->
<vbox id="TablePanel">
<vbox>
<spacer class="spacer"/>
<grid pack="start">
<columns><column/><column/><column/></columns>