Added 'tableize' feature, added strings for UI bugs 71743, 41547; fixed missing 'return' after dialog error close window, b=70619; editor portion of image dialog preview bug 78351. r=mjudge, sr=kin

This commit is contained in:
cmanske%netscape.com 2001-05-09 05:23:37 +00:00
parent 1a206de184
commit 5315f30030
27 changed files with 541 additions and 240 deletions

View File

@ -188,6 +188,8 @@ comm.jar:
content/editor/EditConflict.js (ui/dialogs/content/EditConflict.js)
content/editor/EditorSaveAsCharset.xul (ui/dialogs/content/EditorSaveAsCharset.xul)
content/editor/EditorSaveAsCharset.js (ui/dialogs/content/EditorSaveAsCharset.js)
content/editor/EdConvertToTable.xul (ui/dialogs/content/EdConvertToTable.xul)
content/editor/EdConvertToTable.js (ui/dialogs/content/EdConvertToTable.js)
en-US.jar:
locale/en-US/editor/contents.rdf (ui/composer/locale/en-US/contents.rdf)
@ -220,6 +222,7 @@ en-US.jar:
locale/en-US/editor/EditorImageMapHotSpot.dtd (ui/dialogs/locale/en-US/EditorImageMapHotSpot.dtd)
locale/en-US/editor/EditConflict.dtd (ui/dialogs/locale/en-US/EditConflict.dtd)
locale/en-US/editor/EditorSaveAsCharset.dtd (ui/dialogs/locale/en-US/EditorSaveAsCharset.dtd)
locale/en-US/editor/EdConvertToTable.dtd (ui/dialogs/locale/en-US/EdConvertToTable.dtd)
US.jar:
locale/US/editor-region/contents.rdf (ui/composer/locale/en-US/contents-region.rdf)

View File

@ -83,6 +83,7 @@ function SetupHTMLEditorCommands()
controller.registerCommand("cmd_CancelHTMLSource", nsCancelHTMLSource);
controller.registerCommand("cmd_smiley", nsSetSmiley);
controller.registerCommand("cmd_buildRecentPagesMenu", nsBuildRecentPagesMenu);
controller.registerCommand("cmd_ConvertToTable", nsConvertToTable);
}
function SetupTextEditorCommands()
@ -1459,3 +1460,38 @@ var nsBuildRecentPagesMenu =
BuildRecentMenu(true);
}
};
var nsConvertToTable =
{
isCommandEnabled: function(aCommand, dummy)
{
var selection = window.editorShell.editorSelection;
if (selection && !selection.isCollapsed)
{
// Don't allow if table or cell is the selection
var element = window.editorShell.GetSelectedElement("");
if (element && (element.nodeName == "td" ||
element.nodeName == "table"))
return false;
// Selection start and end must be in the same cell
// in same cell or both are NOT in a cell
if ( GetParentTableCell(selection.focusNode) !=
GetParentTableCell(selection.anchorNode) )
return false
return true;
}
return false;
},
doCommand: function(aCommand)
{
if (this.isCommandEnabled())
{
window.openDialog("chrome://editor/content/EdConvertToTable.xul","_blank", "chrome,close,titlebar,modal")
}
window._content.focus();
}
};

View File

@ -120,10 +120,12 @@ var DocumentStateListener =
EditorInitToolbars();
BuildRecentMenu(true); // Build the recent files menu and save to prefs
window._content.focus();
// Just for convenience
gContentWindow = window._content;
gContentWindow.focus();
// udpate menu items now that we have an editor to play with
// Note: This must be AFTER window._content.focus();
// Note: This must be AFTER gContentWindow.focus();
window.updateCommands("create");
if (!("InsertCharWindow" in window))
@ -141,7 +143,7 @@ var DocumentStateListener =
// hack! Should not need this updateCommands, but there is some controller
// bug that this works around. ??
// comment out the following line because it cause 41573 IME problem on Mac
//window._content.focus();
//gContentWindow.focus();
window.updateCommands("create");
window.updateCommands("save");
}
@ -199,6 +201,9 @@ function EditorStartup(editorType, editorElement)
// This is the only method also called by Message Composer
function EditorSharedStartup()
{
// Just for convenience
gContentWindow = window._content;
// set up JS-implemented commands for Text or HTML editing
switch (editorShell.editorType)
{
@ -219,9 +224,6 @@ function EditorSharedStartup()
break;
}
// Just for convenience
gContentWindow = window._content;
gIsWindows = navigator.appVersion.indexOf("Win") != -1;
gIsUNIX = (navigator.appVersion.indexOf("X11") ||
navigator.appVersion.indexOf("nux")) != -1;
@ -540,7 +542,7 @@ function doStatefulCommand(commandID, newState)
var commandNode = document.getElementById(commandID);
if (commandNode)
commandNode.setAttribute("state", newState);
window._content.focus(); // needed for command dispatch to work
gContentWindow.focus(); // needed for command dispatch to work
goDoCommand(commandID);
}
@ -834,7 +836,7 @@ function SetSmiley(smileyText)
{
editorShell.InsertText(smileyText);
window._content.focus();
gContentWindow.focus();
}
function EditorSelectColor(colorType, mouseEvent)
@ -952,7 +954,7 @@ function EditorSelectColor(colorType, mouseEvent)
goUpdateCommand("cmd_backgroundColor");
}
window._content.focus();
gContentWindow.focus();
}
function GetParentTable(element)
@ -960,7 +962,20 @@ function GetParentTable(element)
var node = element;
while (node)
{
if (node.tagName.toLowerCase() == "table")
if (node.nodeName.toLowerCase() == "table")
return node;
node = node.parentNode;
}
return node;
}
function GetParentTableCell(element)
{
var node = element;
while (node)
{
if (node.nodeName.toLowerCase() == "td" || node.nodeName.toLowerCase() == "th")
return node;
node = node.parentNode;
@ -1111,7 +1126,7 @@ function SetEditMode(mode)
if (bodyNode)
editorShell.editorSelection.collapse(bodyNode, 0);
window._content.focus();
gContentWindow.focus();
}
ResetWindowTitleWithFilename();
}
@ -1216,7 +1231,7 @@ function SetDisplayMode(mode)
gFormatToolbar.setAttribute("hidden", gFormatToolbarHidden);
}
window._content.focus();
gContentWindow.focus();
}
// We must set check on menu item since toolbar may have been used
@ -1310,17 +1325,16 @@ function EditorToggleParagraphMarks()
}
}
function EditorInitEditMenu()
function InitPasteAsMenu()
{
/*
// Fake the keybinding hint for the "Clear" item
// (Don't bother for Mac?)
if (!gIsMac)
document.getElementById("menu_clear").setAttribute("acceltext", GetString("Del"));
*/
//TODO: We should modify the Paste menuitem to build a submenu
// with multiple paste format types
var menuItem = document.getElementById("menu_pasteTable")
if(menuItem)
{
menuItem.IsInTable
menuItem.setAttribute("label", GetString(IsInTable() ? "NestedTable" : "Table"));
// menuItem.setAttribute("accesskey",GetString("ObjectPropertiesAccessKey"));
}
// TODO: Do enabling based on what is in the clipboard
}
function EditorOpenUrl(url)
@ -2183,7 +2197,8 @@ function goUpdateTableMenuItems(commandset)
{
if (commandID == "cmd_InsertTable" ||
commandID == "cmd_JoinTableCells" ||
commandID == "cmd_SplitTableCell")
commandID == "cmd_SplitTableCell" ||
commandID == "cmd_ConvertToTable")
{
// Call the update method in the command class
goUpdateCommand(commandID);
@ -2246,9 +2261,14 @@ function EditorInsertOrEditTable(insertAllowed)
if (IsInTable()) {
// Edit properties of existing table
window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "","TablePanel");
window._content.focus();
gContentWindow.focus();
} else if(insertAllowed) {
EditorInsertTable();
if (editorShell.editorSelection.isCollapsed)
// If we have a caret, insert a blank table...
EditorInsertTable();
else
// else convert the selection into a table
goDoCommand("cmd_ConvertToTable");
}
}
@ -2256,7 +2276,7 @@ function EditorInsertTable()
{
// Insert a new table
window.openDialog("chrome://editor/content/EdInsertTable.xul", "_blank", "chrome,close,titlebar,modal", "");
window._content.focus();
gContentWindow.focus();
}
function EditorTableCellProperties()
@ -2265,7 +2285,7 @@ function EditorTableCellProperties()
if (cell) {
// Start Table Properties dialog on the "Cell" panel
window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "", "CellPanel");
window._content.focus();
gContentWindow.focus();
}
}

View File

@ -241,6 +241,7 @@
<command id="cmd_NormalizeTable" oncommand="goDoCommand('cmd_NormalizeTable')"/>
<command id="cmd_JoinTableCells" oncommand="goDoCommand('cmd_JoinTableCells')"/>
<command id="cmd_SplitTableCell" oncommand="goDoCommand('cmd_SplitTableCell')"/>
<command id="cmd_ConvertToTable" oncommand="goDoCommand('cmd_ConvertToTable')"/>
<command id="cmd_TableOrCellColor" oncommand="goDoCommand('cmd_TableOrCellColor')"/>
<command id="cmd_editTable" oncommand="goDoCommand('cmd_editTable')"/>
</commandset>
@ -301,7 +302,7 @@
</menu>
<menu id="editMenu" label="&editMenu.label;" accesskey="&editmenu.accesskey;">
<menupopup id="edEditMenuPopup" oncreate="EditorInitEditMenu()">
<menupopup id="edEditMenuPopup">
<!-- from utilityOverlay.xul -->
<menuitem id="menu_undo"/>
<menuitem id="menu_redo"/>
@ -309,6 +310,17 @@
<menuitem id="menu_cut"/>
<menuitem id="menu_copy"/>
<menuitem id="menu_paste"/>
<menu id="menu_pasteAs" label="&pasteAs.label;" accesskey="&pasteAs.accesskey;">
<menupopup oncreate="InitPasteAsMenu();">
<menuitem id="menu_pasteText" label="&pasteTextCmd.label;" accesskey="&pasteText.accesskey;"/>
<menuitem id="menu_pasteImage" label="&pasteImageCmd.label;" accesskey="&pasteImage.accesskey;"/>
<menuseparator/>
<menuitem id="menu_pasteRows" label="&pasteRowsCmd.label;" accesskey="&pasteRows.accesskey;"/>
<menuitem id="menu_pasteColumns" label="&pasteColumnsCmd.label;" accesskey="&pasteColumns.accesskey;"/>
<!-- label set in InitPasteAsMenu depending on context -->
<menuitem id="menu_pasteTable" accesskey="&pasteTable.accesskey;"/>
</menupopup>
</menu>
<menuitem id="menu_delete"/>
<menuseparator id="edEditMenuSep2" />
<menuitem id="menu_selectAll"/>
@ -551,6 +563,7 @@
<!-- menu label is set in InitTableMenu -->
<menuitem id="menu_JoinTableCells" label="&tableJoinCells.label;" accesskey="&tablejoincells.accesskey;" observes="cmd_JoinTableCells"/>
<menuitem id="menu_SlitTableCell" label="&tableSplitCell.label;" accesskey="&tablesplitcell.accesskey;" observes="cmd_SplitTableCell"/>
<menuitem id="menu_ConvertToTable" label="&convertToTable.label;" accesskey="&converttotable.accesskey;" observes="cmd_ConvertToTable"/>
<menuseparator />
<menuitem id="menu_TableOrCellColor" label="&tableOrCellColor.label;" accesskey="&tableOrCellColor.accesskey;" observes="cmd_TableOrCellColor"/>
<menuitem id="menu_tableProperties" label="&tableProperties.label;" accesskey="&tableProperties.accesskey;" observes="cmd_editTable"/>

View File

@ -107,6 +107,7 @@ Color=Color
NoColorError=Click on a color or enter a valid HTML color string
Table=Table
TableCell=Table Cell
NestedTable=Nested Table
HLine=Horizontal Line
Link=Link
Image=Image
@ -162,3 +163,4 @@ NoAlignChar=No alignment character supplied.\nEnter a single character or\nselec
SaveImageAs=Save Image (%NAME%)...
Add=Add
Set=Set
NoSeparatorCharacter=Please enter a single character to use for separating into columns

View File

@ -73,17 +73,29 @@
<!-- Edit menu items -->
<!ENTITY editMenu.label "Edit">
<!ENTITY editmenu.accesskey "e">
<!ENTITY pasteAs.label "Paste As">
<!ENTITY pasteAs.accesskey "a">
<!-- For a "Paste" submenu when more than 1
clipboard formats are available -->
<!ENTITY pasteHTMLCmd.label "HTML">
<!ENTITY pasteHTML.accesskey "h">
<!ENTITY pasteTextCmd.label "Text">
<!ENTITY editpastetext.accesskey "t">
<!ENTITY pasteText.accesskey "t">
<!ENTITY pasteImageCmd.label "Image">
<!ENTITY editpasteimage.accesskey "i">
<!ENTITY pasteImage.accesskey "i">
<!ENTITY pasteRowsCmd.label "Rows">
<!ENTITY pasteRows.accesskey "r">
<!ENTITY pasteColumnsCmd.label "Columns">
<!ENTITY pasteColumns.accesskey "c">
<!-- LOCALIZATION NOTE: Text for menu item is in editor.properties
Set to: "Table" or "Nested Table" depending on context
This accesskey must be in both strings -->
<!ENTITY pasteTable.accesskey "a">
<!ENTITY pasteLinkCmd.label "Link">
<!ENTITY editpastelink.accesskey "l">
<!ENTITY pasteHTMLCmd.label "HTML">
<!ENTITY editpastehtml.accesskey "h">
<!ENTITY pasteAsQuotationCmd.label "Paste As Quotation">
<!ENTITY editpastequotation.accesskey "q">
<!ENTITY editpastequotation.keybinding "v">
@ -510,6 +522,8 @@
<!ENTITY tablejoincells.accesskey "j">
<!ENTITY tableSplitCell.label "Split Cell">
<!ENTITY tablesplitcell.accesskey "c">
<!ENTITY convertToTable.label "Create Table from Selection">
<!ENTITY converttotable.accesskey "r">
<!ENTITY tableProperties.label "Table Properties...">
<!ENTITY tableProperties.accesskey "o">

View File

@ -0,0 +1,165 @@
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
var dialog;
var gIndex;
var gCommaIndex = "0";
var gSpaceIndex = "1";
var gOtherIndex = "2";
// dialog initialization code
function Startup()
{
if (!InitEditorShell())
return;
doSetOKCancel(onOK, onCancel);
// Create dialog object to store controls for easy access
dialog = new Object;
dialog.sepRadioGroup = document.getElementById("SepRadioGroup");
dialog.sepCharacterInput = document.getElementById("SepCharacterInput");
dialog.deleteSepCharacter = document.getElementById("DeleteSepCharacter");
// We persist the user's separator character
dialog.sepCharacterInput.value = dialog.sepRadioGroup.getAttribute("character");
// Always default to deleting the separator character
dialog.deleteSepCharacter.checked = true;
gIndex = dialog.sepRadioGroup.getAttribute("index");
dump("***** Previous index of radio group in EdConvertToTable="+gIndex+"\n");
switch (gIndex)
{
case gCommaIndex:
default:
document.getElementById("comma").checked = true;
break;
case gSpaceIndex:
document.getElementById("space").checked = true;
break;
case gOtherIndex:
document.getElementById("other").checked = true;
break;
}
// Set initial enable state on character input
SelectCharacter(gIndex);
SetTextboxFocus(dialog.sepRadioGroup);
SetWindowLocation();
}
function SelectCharacter(radioGroupIndex)
{
gIndex = radioGroupIndex;
dump("***** SelectCharacter index of radio group ="+gIndex+"\n");
SetElementEnabledById("SepCharacterInput", gIndex == gOtherIndex);
}
function onOK()
{
// 1 = OutputSelectionOnly, 1024 = OutputLFLineBreak
// 256 = OutputEncodeEntities
var str = editorShell.GetContentsAs("text/html", 1+1024);
// Replace nbsp with spaces:
str = str.replace(/\u00a0/g, " ");
// Trim trailing <p> or <br>
str = str.replace(/\s*<br>\s*$/, "");
str = str.replace(/\s*<p>\s*$/, "");
// Trim leading and trailing spaces
str = str.replace(/^\s+/, "");
str = str.replace(/\s+$/, "");
// Trim whitespace adjacent to <p> and <br> tags
str = str.replace(/\s+<p>\s+/g, "<br>");
str = str.replace(/\s+<br>\s+/g, "<br>");
var sepCharacter = "";
switch ( gIndex )
{
case gCommaIndex:
sepCharacter = ",";
break;
case gSpaceIndex:
sepCharacter = " ";
break;
case gOtherIndex:
sepCharacter = dialog.sepCharacterInput.value.slice(0,1);
break;
}
if (sepCharacter.length == 0)
{
ShowInputErrorMessage(editorShell.GetString("NoSeparatorCharacter"));
SetTextboxFocus(dialog.sepCharacterInput);
return false;
}
// Replace separator characters with table cells
var replaceString;
if (dialog.deleteSepCharacter.checked)
{
replaceString = "";
// Replace one or more adjacent spaces
if (sepCharacter == " ")
sepCharacter += "+";
}
else
{
// Don't delete separator character,
// so include it at start of string to replace
replaceString = sepCharacter;
}
replaceString += " <td>";
var pattern = new RegExp("\\" + sepCharacter, "g");
//pattern.global = true;
str = str.replace(pattern, replaceString);
// End table row and start another for each br or p
str = str.replace(/\s*<br>\s*/g, "</tr>\n<tr><td>");
// Add the table tags and the opening and closing tr/td tags
str = "<table border=\"1\">\n<tr><td>" + str + "</tr>\n</table>\n";
editorShell.BeginBatchChanges();
editorShell.InsertSource(str);
// Get the table just inserted
var selection = editorShell.editorSelection;
editorShell.NormalizeTable(null);
editorShell.EndBatchChanges();
// Save persisted attributes
dialog.sepRadioGroup.setAttribute("index", gIndex);
if (gIndex == gOtherIndex)
dialog.sepRadioGroup.setAttribute("character", sepCharacter);
SaveWindowLocation();
return true;
}

View File

@ -0,0 +1,64 @@
<?xml version="1.0"?>
<!--
- The contents of this file are subject to the Netscape Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/NPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The Original Code is Mozilla Communicator client code, released
- March 31, 1998.
-
- The Initial Developer of the Original Code is Netscape
- Communications Corporation. Portions created by Netscape are
- Copyright (C) 1998-1999 Netscape Communications Corporation. All
- Rights Reserved.
-
- Contributor(s):
-->
<?xml-stylesheet href="chrome://editor/skin/editor.css" type="text/css"?>
<?xml-stylesheet href="chrome://editor/skin/EditorDialog.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<?xul-overlay href="chrome://editor/content/EdDialogOverlay.xul"?>
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://editor/locale/EdConvertToTable.dtd">
<window class="dialog" title="&windowTitle.label;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
onload = "Startup()"
orient="vertical">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />
<!--- Element-specific methods -->
<script type="application/x-javascript" src="chrome://editor/content/EdConvertToTable.js"/>
<spring id="location" offsetY="50" persist="offsetX offsetY"/>
<keyset id="dialogKeys"/>
<popupset id="aTooltipSet"/>
<html flex="1">&instructions.label;</html>
<radiogroup id="SepRadioGroup" orient="vertical" persist="index character" index="0" character="">
<radio group="SepRadioGroup" id="comma" label="&commaRadio.label;" oncommand="SelectCharacter('0');"/>
<radio group="SepRadioGroup" id="space" label="&spaceRadio.label;" oncommand="SelectCharacter('1');"/>
<box autostretch="never">
<radio group="SepRadioGroup" id="other" label="&otherRadio.label;" oncommand="SelectCharacter('2');"/>
<textbox class="narrow" id="SepCharacterInput" oninput="LimitStringLength(this.id, 1)"/>
</box>
</radiogroup>
<spring class="spacer"/>
<checkbox id="DeleteSepCharacter" label="&deleteCharCheck.label;" oncommand="SelectCharacter('1');"/>
<separator class="groove"/>
<!-- from global dialogOverlay -->
<box id="okCancelButtons"/>
</window>

View File

@ -692,6 +692,17 @@ function forceInteger(elementID)
}
}
function LimitStringLength(elementID, length)
{
var editField = document.getElementById( elementID );
if ( !editField )
return;
var stringIn = editField.value;
if (stringIn && stringIn.length > length)
editField.value = stringIn.slice(0,length);
}
function onAdvancedEdit()
{
@ -901,7 +912,7 @@ function GetLocalFileURL(filterType)
fp.init(window, GetString("SelectImageFile"), nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterImages);
}
else (filterType == "html")
else if (filterType == "html")
{
fp.init(window, GetString("OpenHTMLFile"), nsIFilePicker.modeOpen);

View File

@ -44,7 +44,10 @@ function initDialog(){
//Get image element from parent
imageElement = window.arguments[0];
if (!imageElement) //If not an image close window
{
window.close();
return;
}
//Get image map from parent
imageMap = window.arguments[1];

View File

@ -40,7 +40,7 @@ var globalMap;
var doAltTextError = true;
var actualWidth = "";
var actualHeight = "";
var previewImage;
var gPreviewImage;
var timeoutId = -1;
// msec between attempts to load image
var interval = 200;
@ -50,8 +50,8 @@ var intervalLimit = 60000;
// These must correspond to values in EditorDialog.css for each theme
// (unfortunately, setting "style" attribute here doesn't work!)
var previewImageWidth = 80;
var previewImageHeight = 50;
var gPreviewImageWidth = 80;
var gPreviewImageHeight = 50;
var StartupCalled = false;
// dialog initialization code
@ -126,6 +126,7 @@ function Startup()
{
dump("Failed to get selected element or create a new one!\n");
window.close();
return;
}
}
@ -260,6 +261,50 @@ function chooseFile()
SetTextboxFocus(dialog.srcInput);
}
function PreviewImageLoaded()
{
if (gPreviewImage)
{
// Image loading has completed -- we can get actual width
actualWidth = gPreviewImage.naturalWidth;
actualHeight = gPreviewImage.naturalHeight;
//dump("*** actualWidth = "+actualWidth+", actualHeight = "+actualHeight+"\n");
if (actualWidth && actualHeight)
{
// Use actual size or scale to fit preview if either dimension is too large
var width = actualWidth;
var height = actualHeight;
if (actualWidth > gPreviewImageWidth)
{
width = gPreviewImageWidth;
height = actualHeight * (gPreviewImageWidth / actualWidth);
}
if (height > gPreviewImageHeight)
{
height = gPreviewImageHeight;
width = actualWidth * (gPreviewImageHeight / actualHeight);
}
if (actualWidth > gPreviewImageWidth || actualHeight > gPreviewImageHeight)
{
// Resize image to fit preview frame
gPreviewImage.setAttribute("width", width);
gPreviewImage.setAttribute("height", height);
}
dialog.PreviewWidth.setAttribute("value", actualWidth);
dialog.PreviewHeight.setAttribute("value", actualHeight);
dialog.PreviewSize.setAttribute("collapsed", "false");
dialog.ImageHolder.setAttribute("collapsed", "false");
// Use values as start for constrain proportions
}
if (dialog.actualSizeRadio.checked)
SetActualSize();
}
}
function GetImageFromURL()
{
dialog.PreviewSize.setAttribute("collapsed", "true");
@ -269,8 +314,6 @@ function GetImageFromURL()
// once we fail to load, further setting of src fail)
if (dialog.ImageHolder.firstChild)
{
//previewImage.setAttribute("width", 0);
//previewImage.setAttribute("height", 0);
dialog.ImageHolder.removeChild(dialog.ImageHolder.firstChild);
}
@ -283,86 +326,16 @@ function GetImageFromURL()
{
// Append an image to the dialog to trigger image loading
// and also serves as a preview
previewImage = editorShell.CreateElementWithDefaults("img");
if (!previewImage) return;
dialog.ImageHolder.appendChild(previewImage);
gPreviewImage = editorShell.CreateElementWithDefaults("img");
if (!gPreviewImage) return;
dialog.ImageHolder.appendChild(gPreviewImage);
gPreviewImage.onload = "PreviewImageLoaded();";
gPreviewImage.src = imageSrc;
}
previewImage.src = imageSrc;
// Get the origin width from the image or setup timer to get later
if (previewImage.complete)
GetActualSize();
else
{
// Start timer to poll until image is loaded
//dump("*** Starting timer to get natural image size...\n");
timeoutId = window.setInterval("GetActualSize()", interval);
intervalSum = 0;
}
}
}
function GetActualSize()
{
if (intervalSum > intervalLimit)
{
dump(" Timeout trying to load preview image\n");
CancelTimer();
return;
}
if (!previewImage)
{
CancelTimer();
}
else
{
if (previewImage.complete)
{
// Image loading has completed -- we can get actual width
CancelTimer();
actualWidth = previewImage.naturalWidth;
actualHeight = previewImage.naturalHeight;
if (actualWidth && actualHeight)
{
// Use actual size or scale to fit preview if either dimension is too large
var width = actualWidth;
var height = actualHeight;
if (actualWidth > previewImageWidth)
{
width = previewImageWidth;
height = actualHeight * (previewImageWidth / actualWidth);
}
if (height > previewImageHeight)
{
height = previewImageHeight;
width = actualWidth * (previewImageHeight / actualHeight);
}
if (actualWidth > previewImageWidth || actualHeight > previewImageHeight)
{
// Resize image to fit preview frame
previewImage.setAttribute("width", width);
previewImage.setAttribute("height", height);
}
dialog.PreviewWidth.setAttribute("value", actualWidth);
dialog.PreviewHeight.setAttribute("value", actualHeight);
dialog.PreviewSize.setAttribute("collapsed", "false");
dialog.ImageHolder.setAttribute("collapsed", "false");
// Use values as start for constrain proportions
}
if (dialog.actualSizeRadio.checked)
SetActualSize();
}
else
{
//dump("*** Waiting for image loading...\n");
// Accumulate time so we don't do try this forever
intervalSum += interval;
}
}
}
@ -488,7 +461,6 @@ function constrainProportions( srcID, destID )
// always force an integer (whether we are constraining or not)
forceInteger( srcID );
// if (!constrainWidth || !constrainHeight ||
if (!actualWidth || !actualHeight ||
!(dialog.constrainCheckbox.checked && !dialog.constrainCheckbox.disabled))
return;

View File

@ -67,9 +67,7 @@
/>
<textbox
id = "srcInput"
oninput = "doOverallEnabling()"
onmouseup = "doOverallEnabling()"
onchange = "ChangeImageSrc()"
oninput = "ChangeImageSrc()"
style = "min-width : 20em"/>
<!-- from EdDialogOverlay.xul -->
<button id="ChooseFile"/>

View File

@ -45,6 +45,7 @@ function Startup()
{
dump("Failed to create a new table!\n");
window.close();
return;
}
// Create dialog object to store controls for easy access
dialog = new Object;
@ -78,7 +79,7 @@ function Startup()
// Resize window
window.sizeToContent();
SetTextboxFocus(dialog.rowsInput);
SetTextboxFocusById("rowsInput");
SetWindowLocation();
}
@ -142,7 +143,6 @@ function onOK()
editorShell.CloneAttributes(tableElement, globalElement);
// Create necessary rows and cells for the table
// AFTER BUG 30378 IS FIXED, DON'T INSERT TBODY!
var tableBody = editorShell.CreateElementWithDefaults("tbody");
if (tableBody)
{
@ -186,7 +186,7 @@ function onOK()
if (countObj.value > 1)
{
// Assume user wants to replace a block of
// contiguous cells with a tabl, so
// contiguous cells with a table, so
// join the selected cells
editorShell.JoinTableCells(false);

View File

@ -36,9 +36,10 @@ function Startup()
if (!InitEditorShell())
return;
dialog = new Object;
if (!dialog)
if (!dialog) {
window.close();
return;
}
doSetOKCancel(onOK, onCancel);
dialog.ListTypeList = document.getElementById("ListType");

View File

@ -70,6 +70,7 @@ function Startup()
{
dump("Failed to get selected element or create a new one!\n");
window.close();
return;
}
InitDialog();

View File

@ -43,6 +43,7 @@ function Startup()
{
dump("Failed to create dialog object!!!\n");
window.close();
return;
}
dialog.PageLocation = document.getElementById("PageLocation");
dialog.TitleInput = document.getElementById("TitleInput");
@ -75,8 +76,10 @@ dump(", lastmod date="+lastmoddate+"\n");
{
authorElement = CreateMetaElement("author");
if (!authorElement)
{
window.close();
return;
}
insertNewAuthor = true;
}

View File

@ -37,6 +37,7 @@ function Startup()
if (!spellChecker) {
dump("SpellChecker not found!!!\n");
window.close();
return;
}
// Start the spell checker module.
@ -50,6 +51,7 @@ function Startup()
catch(ex) {
dump("*** Exception error: InitSpellChecker\n");
window.close();
return;
}
// Create dialog object to store controls for easy access

View File

@ -94,8 +94,10 @@ function Startup()
dialog = new Object;
if (!dialog)
{
window.close();
return;
}
// Get dialog widgets - Table Panel
dialog.TableRowsInput = document.getElementById("TableRowsInput");
dialog.TableColumnsInput = document.getElementById("TableColumnsInput");
@ -121,8 +123,6 @@ function Startup()
dialog.CellHeightUnits = document.getElementById("CellHeightUnits");
dialog.CellWidthInput = document.getElementById("CellWidthInput");
dialog.CellWidthUnits = document.getElementById("CellWidthUnits");
dialog.RowSpanInput = document.getElementById("RowSpanInput");
dialog.ColSpanInput = document.getElementById("ColSpanInput");
dialog.CellHAlignList = document.getElementById("CellHAlignList");
dialog.CellVAlignList = document.getElementById("CellVAlignList");
dialog.CellInheritColor = document.getElementById("CellInheritColor");
@ -134,8 +134,6 @@ function Startup()
// and that's probably not what they expect!
dialog.CellHeightCheckbox = document.getElementById("CellHeightCheckbox");
dialog.CellWidthCheckbox = document.getElementById("CellWidthCheckbox");
dialog.RowSpanCheckbox = document.getElementById("RowSpanCheckbox");
dialog.ColSpanCheckbox = document.getElementById("ColSpanCheckbox");
dialog.CellHAlignCheckbox = document.getElementById("CellHAlignCheckbox");
dialog.CellVAlignCheckbox = document.getElementById("CellVAlignCheckbox");
dialog.CellStyleCheckbox = document.getElementById("CellStyleCheckbox");
@ -151,6 +149,7 @@ function Startup()
{
dump("Failed to get table element!\n");
window.close();
return;
}
globalTableElement = TableElement.cloneNode(false);
@ -167,7 +166,6 @@ function Startup()
// Tells us whether cell, row, or column is selected
SelectedCellsType = editorShell.GetSelectedCellsType(TableElement);
SetSpanEnable();
// Ignore types except Cell, Row, and Column
if (SelectedCellsType < SELECT_CELL || SelectedCellsType > SELECT_COLUMN)
@ -311,14 +309,6 @@ function InitCellPanel()
dialog.CellWidthInput.value = InitPixelOrPercentMenulist(globalCellElement, CellElement, "width", "CellWidthUnits", gPixel);
dialog.CellWidthCheckbox.checked = AdvancedEditUsed && previousValue != dialog.CellWidthInput.value;
previousValue = dialog.RowSpanInput.value;
dialog.RowSpanInput.value = globalCellElement.getAttribute("rowspan");
dialog.RowSpanCheckbox.checked = AdvancedEditUsed && previousValue != dialog.RowSpanInput.value;
previousValue = dialog.ColSpanInput.value;
dialog.ColSpanInput.value = globalCellElement.getAttribute("colspan");
dialog.ColSpanCheckbox.checked = AdvancedEditUsed && previousValue != dialog.ColSpanInput.value;
var previousIndex = dialog.CellVAlignList.selectedIndex;
var valign = globalCellElement.vAlign.toLowerCase();
if (valign == topStr)
@ -758,21 +748,6 @@ function DisableSelectionButtons( disable )
dialog.NextButton.setAttribute("disabled", disable ? "true" : "false");
}
function SetSpanEnable()
{
// If entire row is selected, don't allow changing colspan...
if ( SelectedCellsType == SELECT_COLUMN )
dialog.RowSpanInput.setAttribute("disabled", "true");
else
dialog.RowSpanInput.removeAttribute("disabled");
// ...and similarly:
if ( SelectedCellsType == SELECT_ROW )
dialog.ColSpanInput.setAttribute("disabled", "true");
else
dialog.ColSpanInput.removeAttribute("disabled");
}
function SwitchToValidatePanel()
{
if (currentPanel != validatePanel)
@ -850,20 +825,6 @@ function ValidateCellData()
if (gValidationError) return false;
}
if (dialog.RowSpanCheckbox.checked && dialog.RowSpanCheckbox.disabled != "true")
{
// Note that span = 0 is allowed and means "span entire row/col"
ValidateNumber(dialog.RowSpanInput, null,
0, rowCount, globalCellElement, "rowspan");
if (gValidationError) return false;
}
if (dialog.ColSpanCheckbox.checked && dialog.ColSpanCheckbox.getAttribute("disabled") != "true")
{
ValidateNumber(dialog.ColSpanInput, null,
0, colCount, globalCellElement, "colspan");
if (gValidationError) return false;
}
if (dialog.CellHAlignCheckbox.checked)
{
var hAlign = dialog.CellHAlignList.selectedItem.value;
@ -1223,12 +1184,6 @@ function ApplyAttributesToOneCell(destElement)
if (dialog.CellWidthCheckbox.checked)
CloneAttribute(destElement, globalCellElement, "width");
if (dialog.RowSpanCheckbox.checked && dialog.RowSpanCheckbox.getAttribute("disabled") != "true")
CloneAttribute(destElement, globalCellElement, "rowspan");
if (dialog.ColSpanCheckbox.checked && dialog.ColSpanCheckbox.getAttribute("disabled") != "true")
CloneAttribute(destElement, globalCellElement, "colspan");
if (dialog.CellHAlignCheckbox.checked)
{
CloneAttribute(destElement, globalCellElement, "align");
@ -1283,7 +1238,7 @@ function Apply()
{
ApplyCellAttributes();
// Be sure user didn't mess up table by setting incorrect span values
editorShell.NormalizeTable(TableElement);
// editorShell.NormalizeTable(TableElement);
}
editorShell.EndBatchChanges();

View File

@ -170,66 +170,58 @@
<text class="label" value="&applyBeforeChange2.label;"/>
</box>
</titledbox>
<!-- cell size titledbox -->
<titledbox><label align="left" value="&size.label;"/>
<grid>
<columns><column/><column/><column/></columns>
<rows>
<row valign="middle" autostretch="never">
<checkbox id="CellHeightCheckbox" label="&tableHeight.label;"/>
<textbox class="narrow" id="CellHeightInput"
oninput="ChangeIntTextbox(this.id,'CellHeightCheckbox');"/>
<menulist id="CellHeightUnits" oncommand="SetCheckbox('CellHeightCheckbox');"/>
</row>
<row valign="middle" autostretch="never">
<checkbox id="CellWidthCheckbox" label="&tableWidth.label;"/>
<textbox class="narrow" id="CellWidthInput"
oninput="ChangeIntTextbox(this.id,'CellWidthCheckbox');"/>
<menulist id="CellWidthUnits" oncommand="SetCheckbox('CellWidthCheckbox');"/>
</row>
</rows>
</grid>
<spring class="bigspacer"/>
<grid>
<columns><column/><column/></columns>
<rows>
<row valign="middle" autostretch="never">
<checkbox id="RowSpanCheckbox" label="&cellRowSpan.label;"/>
<textbox class="narrow" id="RowSpanInput"
oninput="ChangeIntTextbox(this.id,'RowSpanCheckbox');"/>
</row>
<row valign="middle" autostretch="never">
<checkbox id="ColSpanCheckbox" label="&cellColSpan.label;"/>
<textbox class="narrow" id="ColSpanInput"
oninput="ChangeIntTextbox(this.id,'ColSpanCheckbox');"/>
</row>
</rows>
</grid>
</titledbox>
<!-- Alignment -->
<titledbox valign="middle" autostretch="never">
<label value="&cellContentAlignment.label;"/>
<checkbox id="CellHAlignCheckbox" label="&cellHorizontal.label;"/>
<menulist id="CellHAlignList" oncommand="SelectCellHAlign()">
<menupopup>
<menuitem label="&AlignLeft.label;" value="left"/>
<menuitem label="&AlignCenter.label;" value="center"/>
<menuitem label="&AlignRight.label;" value="right"/>
<menuitem label="&cellAlignJustify.label;" value="justify"/>
</menupopup>
</menulist>
<spring class="spacer"/>
<checkbox id="CellVAlignCheckbox" label="&cellVertical.label;"/>
<menulist id="CellVAlignList" oncommand="SetCheckbox('CellVAlignCheckbox');">
<menupopup>
<menuitem label="&cellAlignTop.label;" value="top"/>
<menuitem label="&cellAlignMiddle.label;" value="middle"/>
<menuitem label="&cellAlignBottom.label;" value="bottom"/>
</menupopup>
</menulist>
</titledbox>
<box autostretch="never">
<!-- cell size titledbox -->
<titledbox><label align="left" value="&size.label;"/>
<grid>
<columns><column/><column/><column/></columns>
<rows>
<row valign="middle" autostretch="never">
<checkbox id="CellHeightCheckbox" label="&tableHeight.label;"/>
<textbox class="narrow" id="CellHeightInput"
oninput="ChangeIntTextbox(this.id,'CellHeightCheckbox');"/>
<menulist id="CellHeightUnits" oncommand="SetCheckbox('CellHeightCheckbox');"/>
</row>
<row valign="middle" autostretch="never">
<checkbox id="CellWidthCheckbox" label="&tableWidth.label;"/>
<textbox class="narrow" id="CellWidthInput"
oninput="ChangeIntTextbox(this.id,'CellWidthCheckbox');"/>
<menulist id="CellWidthUnits" oncommand="SetCheckbox('CellWidthCheckbox');"/>
</row>
</rows>
</grid>
<spring class="bigspacer"/>
</titledbox>
<!-- Alignment -->
<titledbox><label value="&cellContentAlignment.label;"/>
<grid>
<columns><column/><column/><column/></columns>
<rows>
<row valign="middle" autostretch="never">
<checkbox id="CellVAlignCheckbox" label="&cellVertical.label;"/>
<menulist id="CellVAlignList" oncommand="SetCheckbox('CellVAlignCheckbox');">
<menupopup>
<menuitem label="&cellAlignTop.label;" value="top"/>
<menuitem label="&cellAlignMiddle.label;" value="middle"/>
<menuitem label="&cellAlignBottom.label;" value="bottom"/>
</menupopup>
</menulist>
</row>
<row valign="middle" autostretch="never">
<checkbox id="CellHAlignCheckbox" label="&cellHorizontal.label;"/>
<menulist id="CellHAlignList" oncommand="SelectCellHAlign()">
<menupopup>
<menuitem label="&AlignLeft.label;" value="left"/>
<menuitem label="&AlignCenter.label;" value="center"/>
<menuitem label="&AlignRight.label;" value="right"/>
<menuitem label="&cellAlignJustify.label;" value="justify"/>
</menupopup>
</menulist>
</row>
</rows>
</grid>
</titledbox>
</box>
<spring class="spacer"/>
<box valign="middle" autostretch="never">
<checkbox id="CellStyleCheckbox" label="&cellStyle.label;"/>

View File

@ -37,6 +37,7 @@ dump("KeepCurrentPage\n");
//TODO: Should we force saving of the current page?
SaveWindowLocation();
window.close();
return;
}
function UseOtherPage()

View File

@ -54,7 +54,10 @@ function Startup()
{
contenttypeElement = CreateHTTPEquivMetaElement("content-type");
if( ! contenttypeElement )
{
window.close();
return;
}
insertNewContentType = true;
}

View File

@ -67,3 +67,5 @@ EditConflict.xul
EditConflict.js
EditorSaveAsCharset.xul
EditorSaveAsCharset.js
EdConvertToTable.xul
EdConvertToTable.js

View File

@ -70,6 +70,8 @@ CHROME_CONTENT = \
.\EditConflict.js \
.\EditorSaveAsCharset.xul \
.\EditorSaveAsCharset.js \
.\EdConvertToTable.xul \
.\EdConvertToTable.js \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@ -24,7 +24,6 @@
<!ENTITY WindowTitle.label "Advanced Property Editor">
<!ENTITY AttName.label "Name: ">
<!ENTITY AttValue.label "Value: ">
<!ENTITY AddAttributeButton.label "Add">
<!ENTITY currentattributesfor.label "Current attributes for: ">
<!ENTITY tree.attributeHeader.label "Attribute">
<!ENTITY tree.valueHeader.label "Value">
@ -32,10 +31,13 @@
<!ENTITY tabCSS.label "Inline Style">
<!ENTITY tabJSE.label "JavaScript Events">
<!ENTITY AddJSEAttributeLabel.label "Add a JavaScript Event Handler">
<!ENTITY AddHTMLAttributeLabel.label "Add an HTML Attribute">
<!ENTITY AddCSSAttributeLabel.label "Add a Style Attribute">
<!-- REMOVE THIS AFTER NEW ADVANCED EDIT DIALOG IS FINISHED -->
<!ENTITY AddAttributeButton.label "Add">
<!ENTITY AddJSEAttributeLabel.label "Edit or Add a JavaScript Event Handler">
<!ENTITY AddHTMLAttributeLabel.label "Edit or Add an HTML Attribute">
<!ENTITY AddCSSAttributeLabel.label "Edit or Add a Style Attribute">
<!ENTITY editAttribute.label "Click on an item to edit its value">
<!ENTITY removeAttribute.label "Remove Attribute">
<!ENTITY newButton.label "New">

View File

@ -0,0 +1,34 @@
<!--
- The contents of this file are subject to the Netscape Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/NPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The Original Code is Mozilla Communicator client code, released
- March 31, 1998.
-
- The Initial Developer of the Original Code is Netscape
- Communications Corporation. Portions created by Netscape are
- Copyright (C) 1998-1999 Netscape Communications Corporation. All
- Rights Reserved.
-
- Contributor(s):
-->
<!-- Window title -->
<!ENTITY windowTitle.label "Convert To Table">
<!--LOCALIZATION NOTE Don't translate <html:br/> Place where needed to control linebreaks in message -->
<!ENTITY instructions.label "Composer creates a new table row<html:br/>for each paragraph in the selection.<html:br/><html:br/>Choose the character used<html:br/>to separate the selection into columns:">
<!ENTITY commaRadio.label "Comma">
<!ENTITY spaceRadio.label "Space">
<!ENTITY otherRadio.label "Other Character:">
<!ENTITY deleteCharCheck.label "Delete separator character">

View File

@ -43,3 +43,4 @@ EditorImageMapHotSpot.dtd
EditorInsertChars.dtd
EditConflict.dtd
EditorSaveAsCharset.dtd
EditorConvertToTable.dtd

View File

@ -45,6 +45,7 @@ CHROME_L10N = \
.\EditConflict.dtd \
.\EditorSaveAsCharset.dtd \
.\EdColorPicker.dtd \
.\EdConvertToTable.dtd \
$(NULL)
include <$(DEPTH)\config\rules.mak>