Index: jar.mn
===================================================================
RCS file: /cvsroot/mozilla/editor/jar.mn,v
retrieving revision 1.18
diff -u -r1.18 jar.mn
--- jar.mn 2001/11/15 16:39:59 1.18
+++ jar.mn 2001/12/06 14:21:41
@@ -154,6 +154,8 @@
content/editor/EdLinkProps.js (ui/dialogs/content/EdLinkProps.js)
content/editor/EdImageProps.xul (ui/dialogs/content/EdImageProps.xul)
content/editor/EdImageProps.js (ui/dialogs/content/EdImageProps.js)
+ content/editor/EdImageOverlay.xul (ui/dialogs/content/EdImageOverlay.xul)
+ content/editor/EdImageOverlay.js (ui/dialogs/content/EdImageOverlay.js)
content/editor/EdHLineProps.xul (ui/dialogs/content/EdHLineProps.xul)
content/editor/EdHLineProps.js (ui/dialogs/content/EdHLineProps.js)
content/editor/EdSpellCheck.xul (ui/dialogs/content/EdSpellCheck.xul)
@@ -166,6 +168,22 @@
content/editor/EdInsertTable.js (ui/dialogs/content/EdInsertTable.js)
content/editor/EdTableProps.xul (ui/dialogs/content/EdTableProps.xul)
content/editor/EdTableProps.js (ui/dialogs/content/EdTableProps.js)
+ content/editor/EdFormProps.xul (ui/dialogs/content/EdFormProps.xul)
+ content/editor/EdFormProps.js (ui/dialogs/content/EdFormProps.js)
+ content/editor/EdInputProps.xul (ui/dialogs/content/EdInputProps.xul)
+ content/editor/EdInputProps.js (ui/dialogs/content/EdInputProps.js)
+ content/editor/EdInputImage.xul (ui/dialogs/content/EdInputImage.xul)
+ content/editor/EdInputImage.js (ui/dialogs/content/EdInputImage.js)
+ content/editor/EdTextAreaProps.xul (ui/dialogs/content/EdTextAreaProps.xul)
+ content/editor/EdTextAreaProps.js (ui/dialogs/content/EdTextAreaProps.js)
+ content/editor/EdSelectProps.xul (ui/dialogs/content/EdSelectProps.xul)
+ content/editor/EdSelectProps.js (ui/dialogs/content/EdSelectProps.js)
+ content/editor/EdButtonProps.xul (ui/dialogs/content/EdButtonProps.xul)
+ content/editor/EdButtonProps.js (ui/dialogs/content/EdButtonProps.js)
+ content/editor/EdLabelProps.xul (ui/dialogs/content/EdLabelProps.xul)
+ content/editor/EdLabelProps.js (ui/dialogs/content/EdLabelProps.js)
+ content/editor/EdFieldSetProps.xul (ui/dialogs/content/EdFieldSetProps.xul)
+ content/editor/EdFieldSetProps.js (ui/dialogs/content/EdFieldSetProps.js)
content/editor/EdInsSrc.xul (ui/dialogs/content/EdInsSrc.xul)
content/editor/EdInsSrc.js (ui/dialogs/content/EdInsSrc.js)
content/editor/EdInsertChars.xul (ui/dialogs/content/EdInsertChars.xul)
@@ -228,6 +246,13 @@
locale/en-US/editor/EditorPersonalDictionary.dtd (ui/dialogs/locale/en-US/EditorPersonalDictionary.dtd)
locale/en-US/editor/EditorSpellCheck.dtd (ui/dialogs/locale/en-US/EditorSpellCheck.dtd)
locale/en-US/editor/EditorTableProperties.dtd (ui/dialogs/locale/en-US/EditorTableProperties.dtd)
+ locale/en-US/editor/EditorFormProperties.dtd (ui/dialogs/locale/en-US/EditorFormProperties.dtd)
+ locale/en-US/editor/EditorInputProperties.dtd (ui/dialogs/locale/en-US/EditorInputProperties.dtd)
+ locale/en-US/editor/EditorTextAreaProperties.dtd (ui/dialogs/locale/en-US/EditorTextAreaProperties.dtd)
+ locale/en-US/editor/EditorSelectProperties.dtd (ui/dialogs/locale/en-US/EditorSelectProperties.dtd)
+ locale/en-US/editor/EditorButtonProperties.dtd (ui/dialogs/locale/en-US/EditorButtonProperties.dtd)
+ locale/en-US/editor/EditorLabelProperties.dtd (ui/dialogs/locale/en-US/EditorLabelProperties.dtd)
+ locale/en-US/editor/EditorFieldSetProperties.dtd (ui/dialogs/locale/en-US/EditorFieldSetProperties.dtd)
locale/en-US/editor/EdNamedAnchorProperties.dtd (ui/dialogs/locale/en-US/EdNamedAnchorProperties.dtd)
locale/en-US/editor/EdDialogOverlay.dtd (ui/dialogs/locale/en-US/EdDialogOverlay.dtd)
locale/en-US/editor/EdAdvancedEdit.dtd (ui/dialogs/locale/en-US/EdAdvancedEdit.dtd)
Index: ui/dialogs/content/makefile.win
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/content/makefile.win,v
retrieving revision 1.32
diff -u -r1.32 makefile.win
--- ui/dialogs/content/makefile.win 2001/11/15 15:28:20 1.32
+++ ui/dialogs/content/makefile.win 2001/12/06 14:21:42
@@ -30,6 +30,8 @@
.\EdLinkProps.js \
.\EdImageProps.xul \
.\EdImageProps.js \
+ .\EdImageOverlay.xul \
+ .\EdImageOverlay.js \
.\EdHLineProps.xul \
.\EdHLineProps.js \
.\EdSpellCheck.xul \
@@ -42,6 +44,22 @@
.\EdInsertTable.js \
.\EdTableProps.xul \
.\EdTableProps.js \
+ .\EdFormProps.xul \
+ .\EdFormProps.js \
+ .\EdInputProps.xul \
+ .\EdInputProps.js \
+ .\EdInputImage.xul \
+ .\EdInputImage.js \
+ .\EdTextAreaProps.xul \
+ .\EdTextAreaProps.js \
+ .\EdSelectProps.xul \
+ .\EdSelectProps.js \
+ .\EdButtonProps.xul \
+ .\EdButtonProps.js \
+ .\EdLabelProps.xul \
+ .\EdLabelProps.js \
+ .\EdFieldSetProps.xul \
+ .\EdFieldSetProps.js \
.\EdInsSrc.xul \
.\EdInsSrc.js \
.\EdInsertChars.xul \
Index: ui/dialogs/content/MANIFEST
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/content/MANIFEST,v
retrieving revision 1.27
diff -u -r1.27 MANIFEST
--- ui/dialogs/content/MANIFEST 2001/11/15 15:28:20 1.27
+++ ui/dialogs/content/MANIFEST 2001/12/06 14:21:42
@@ -29,6 +29,8 @@
EdHLineProps.js
EdImageProps.xul
EdImageProps.js
+EdImageOverlay.xul
+EdImageOverlay.js
EdLinkProps.xul
EdLinkProps.js
EdSpellCheck.xul
@@ -41,6 +43,22 @@
EdInsertTable.js
EdTableProps.js
EdTableProps.xul
+EdFormProps.js
+EdFormProps.xul
+EdInputProps.js
+EdInputProps.xul
+EdInputImage.js
+EdInputImage.xul
+EdTextAreaProps.js
+EdTextAreaProps.xul
+EdSelectProps.js
+EdSelectProps.xul
+EdButtonProps.js
+EdButtonProps.xul
+EdLabelProps.js
+EdLabelProps.xul
+EdFieldSetProps.js
+EdFieldSetProps.xul
EdInsSrc.xul
EdInsSrc.js
EdDialogOverlay.xul
Index: ui/dialogs/content/EdDialogCommon.js
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/content/EdDialogCommon.js,v
retrieving revision 1.113
diff -u -r1.113 EdDialogCommon.js
--- ui/dialogs/content/EdDialogCommon.js 2001/11/29 23:49:01 1.113
+++ ui/dialogs/content/EdDialogCommon.js 2001/12/06 14:21:44
@@ -958,3 +958,223 @@
}
}
+var IsBlockParent = {
+ APPLET: true,
+ BLOCKQUOTE: true,
+ BODY: true,
+ CENTER: true,
+ DD: true,
+ DIV: true,
+ FORM: true,
+ LI: true,
+ NOSCRIPT: true,
+ OBJECT: true,
+ TD: true,
+ TH: true
+};
+
+var NotAnInlineParent = {
+ COL: true,
+ COLGROUP: true,
+ DL: true,
+ DIR: true,
+ MENU: true,
+ OL: true,
+ TABLE: true,
+ TBODY: true,
+ TFOOT: true,
+ THEAD: true,
+ TR: true,
+ UL: true
+};
+
+function nodeDepth(node)
+{
+ for (var depth = 0; node != null; depth++)
+ node = node.parentNode;
+ return depth;
+}
+
+function nthParent(node, n)
+{
+ for (; n > 0; n--)
+ node = node.parentNode;
+ return node;
+}
+
+function nodeIsBlock(node)
+{
+ // HR doesn't count because it's not a container
+ return !node || (node.localName != 'HR' && editorShell.NodeIsBlock(node));
+}
+
+/* Ugly code alert! If only I could do this:
+ * var range = editorShell.editorSelection;
+ * range = editorShell.FlattenRange(range); // ensure anchorNode == parentNode
+ * if (editorShell.IsInlineRange(range) && editorShell.NodeIsBlock(node)) return false;
+ * while (!editorShell.ContainmentAllowed(range.anchorNode, element))
+ * range = editorShell.ParentRangeOf(range);
+ * editorShell.InsertElementAtRange(element, range);
+ * return true;
+ */
+function InsertElementAroundSelection(element)
+{
+ // We need to find a suitable container for the element.
+ // First get the selection
+ var anchorParent = editorShell.editorSelection.anchorNode;
+ if (!anchorParent.localName)
+ var anchorSelected = true;
+ else if (editorShell.editorSelection.anchorOffset < anchorParent.childNodes.length)
+ var anchor = anchorParent.childNodes[editorShell.editorSelection.anchorOffset];
+ var focusParent = editorShell.editorSelection.focusNode;
+ if (!focusParent.localName)
+ var focusSelected = true;
+ else if (editorShell.editorSelection.focusOffset < focusParent.childNodes.length)
+ var focus = focusParent.childNodes[editorShell.editorSelection.focusOffset];
+
+ // Find the common ancestor
+ var anchorDepth = nodeDepth(anchorParent);
+ var focusDepth = nodeDepth(focusParent);
+ if (anchorDepth > focusDepth)
+ {
+ anchor = nthParent(anchorParent, anchorDepth - focusDepth - 1);
+ anchorParent = anchor.parentNode;
+ anchorSelected = true;
+ }
+ else if (anchorDepth < focusDepth)
+ {
+ focus = nthParent(focusParent, focusDepth - anchorDepth - 1);
+ focusParent = focus.parentNode;
+ focusSelected = true;
+ }
+ var ordered = false;
+ while (anchorParent != focusParent)
+ {
+ anchor = anchorParent;
+ anchorParent = anchor.parentNode;
+ focus = focusParent;
+ focusParent = focus.parentNode;
+ anchorSelected = focusSelected = true;
+ }
+
+ // The common ancestor may not be suitable, so find a suitable one.
+ if (editorShell.NodeIsBlock(element))
+ {
+ // Block element parent must be a valid block
+ while (!(anchorParent.localName in IsBlockParent))
+ {
+ anchor = focus = anchorParent;
+ anchorSelected = focusSelected = true;
+ anchorParent = anchor.parentNode;
+ ordered = true;
+ }
+ }
+ else
+ {
+ // Inline element parent must not be an invalid block
+ while (anchorParent.localName in NotAnInlineParent)
+ {
+ anchor = focus = anchorParent;
+ anchorSelected = focusSelected = true;
+ anchorParent = anchor.parentNode;
+ ordered = true;
+ }
+ }
+
+ // We now have an ancestor to hold the element
+ // and a range of child nodes to move into the element
+ if (anchor != focus)
+ {
+ if (!ordered)
+ {
+ // Ensure anchor <= focus
+ for (var node = anchorParent.firstChild; node != anchor; node = node.nextSibling)
+ {
+ if (node == focus)
+ {
+ focus = anchor;
+ anchor = node;
+ focusSelected = anchorSelected;
+ break;
+ }
+ }
+ }
+ if (focus && !focusSelected)
+ focus = focus.previousSibling;
+ }
+ if (!editorShell.NodeIsBlock(element))
+ {
+ // Fail if we're not inserting a block
+ if (!anchor) return false;
+ for (node = anchor; ; node = node.nextSibling)
+ if (!node)
+ return false;
+ else if (nodeIsBlock(node))
+ break;
+ else if (node == focus)
+ return false;
+ }
+
+ // The range may be contained by body text, which should all be selected.
+ if (!nodeIsBlock(anchor))
+ while (!nodeIsBlock(anchor.previousSibling))
+ anchor = anchor.previousSibling;
+ if (!nodeIsBlock(focus))
+ while (!nodeIsBlock(focus.nextSibling))
+ focus = focus.nextSibling;
+
+ editorShell.BeginBatchChanges();
+ try {
+ var anchorOffset = 0;
+ // Calculate the insertion point for the undoable InsertElement method
+ if (!anchor)
+ anchor = anchorParent.firstChild;
+ else
+ for (node = anchorParent.firstChild; node != anchor; node = node.nextSibling)
+ anchorOffset++;
+ editorShell.InsertElement(element, anchorParent, anchorOffset, true);
+ // Move all the old child nodes to the element
+ // Use editor methods in case of text nodes
+ var editor = editorShell.editor;
+ while (anchor)
+ {
+ node = anchor.nextSibling;
+ editor.DeleteNode(anchor);
+ editor.InsertNode(anchor, element, element.childNodes.length);
+ if (anchor == focus) break;
+ anchor = node;
+ }
+ }
+ finally {
+ editorShell.EndBatchChanges();
+ }
+ return true;
+}
+
+// Should I set the selection to the element, then insert HTML the element's innerHTML?
+// I would prefer to say editorShell.DeleteElement(element, FLAG_TO_KEEP_CHILD_NODES);
+function RemoveElementKeepingChildren(element)
+{
+ editorShell.BeginBatchChanges();
+ try {
+ if (element.firstChild)
+ {
+ // Use editor methods in case of text nodes
+ var editor = editorShell.editor;
+ var parent = element.parentNode;
+ var offset = 0;
+ for (var node = parent.firstChild; node != element; node = node.nextSibling)
+ offset++;
+ while ((node = element.firstChild))
+ {
+ editor.DeleteNode(node);
+ editor.InsertNode(node, parent, offset++);
+ }
+ }
+ editorShell.DeleteElement(element);
+ }
+ finally {
+ editorShell.EndBatchChanges();
+ }
+}
+
Index: ui/dialogs/content/EdImageProps.js
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/content/EdImageProps.js,v
retrieving revision 1.91
diff -u -r1.91 EdImageProps.js
--- ui/dialogs/content/EdImageProps.js 2001/11/29 23:49:02 1.91
+++ ui/dialogs/content/EdImageProps.js 2001/12/06 14:21:45
@@ -25,30 +25,10 @@
var gInsertNewImage = true;
var gInsertNewIMap = true;
-var constrainOn = false;
-// Note used in current version, but these are set correctly
-// and could be used to reset width and height used for constrain ratio
-var constrainWidth = 0;
-var constrainHeight = 0;
-var imageElement;
var gImageMap = 0;
-var gCanRemoveImageMap = false;
var gRemoveImageMap = false;
var gImageMapDisabled = false;
-var firstTimeOkUsed = true;
-var doAltTextError = false;
-var actualWidth = "";
-var gOriginalSrc = "";
-var actualHeight = "";
-var gHaveDocumentUrl = false;
-var gTimerID;
-
-// These must correspond to values in EditorDialog.css for each theme
-// (unfortunately, setting "style" attribute here doesn't work!)
-var gPreviewImageWidth = 80;
-var gPreviewImageHeight = 50;
var StartupCalled = false;
-var gOkButton;
// dialog initialization code
@@ -67,38 +47,37 @@
if (!InitEditorShell())
return;
- gDialog.srcInput = document.getElementById( "srcInput" );
- gDialog.altTextInput = document.getElementById( "altTextInput" );
- gDialog.MoreFewerButton = document.getElementById( "MoreFewerButton" );
- gDialog.MoreSection = document.getElementById( "MoreSection" );
- gDialog.customSizeRadio = document.getElementById( "customSizeRadio" );
- gDialog.actualSizeRadio = document.getElementById( "actualSizeRadio" );
- gDialog.constrainCheckbox = document.getElementById( "constrainCheckbox" );
- gDialog.widthInput = document.getElementById( "widthInput" );
- gDialog.heightInput = document.getElementById( "heightInput" );
- gDialog.widthUnitsMenulist = document.getElementById( "widthUnitsMenulist" );
- gDialog.heightUnitsMenulist = document.getElementById( "heightUnitsMenulist" );
- gDialog.imagelrInput = document.getElementById( "imageleftrightInput" );
- gDialog.imagetbInput = document.getElementById( "imagetopbottomInput" );
- gDialog.border = document.getElementById( "border" );
- gDialog.alignTypeSelect = document.getElementById( "alignTypeSelect" );
- gDialog.ImageHolder = document.getElementById( "preview-image-holder" );
- gDialog.PreviewWidth = document.getElementById( "PreviewWidth" );
- gDialog.PreviewHeight = document.getElementById( "PreviewHeight" );
- gDialog.PreviewSize = document.getElementById( "PreviewSize" );
- gDialog.PreviewImage = null;
- gDialog.OkButton = document.documentElement.getButton("accept");
+ gDialog = {
+ MoreFewerButton: document.getElementById( "MoreFewerButton" ),
+ MoreSection: document.getElementById( "MoreSection" )
+ };
+ ImageStartup();
+
// Get a single selected image element
- var tagName = "img"
- imageElement = editorShell.GetSelectedElement(tagName);
+ var tagName = "img";
+ if ("arguments" in window && window.arguments[0])
+ {
+ imageElement = window.arguments[0];
+ }
+ else
+ {
+ // First check for
+ imageElement = editorShell.GetSelectedElement("input");
+ if (!imageElement || imageElement.getAttribute("type") != "image")
+ // Get a single selected image element
+ imageElement = editorShell.GetSelectedElement(tagName);
+ }
if (imageElement)
{
// We found an element and don't need to insert one
- gInsertNewImage = false;
- actualWidth = imageElement.naturalWidth;
- actualHeight = imageElement.naturalHeight;
+ if (imageElement.hasAttribute("src"))
+ {
+ gInsertNewImage = false;
+ actualWidth = imageElement.naturalWidth;
+ actualHeight = imageElement.naturalHeight;
+ }
}
else
{
@@ -151,66 +130,10 @@
// by AdvancedEdit(), which is shared by all property dialogs
function InitDialog()
{
- // Set the controls to the image's attributes
- gDialog.srcInput.value = globalElement.getAttribute("src");
-
- // Set "Relativize" checkbox according to current URL state
- SetRelativeCheckbox();
-
- // Force loading of image from its source and show preview image
- LoadPreviewImage();
-
- gDialog.altTextInput.value = globalElement.getAttribute("alt");
-
- // setup the height and width widgets
- var width = InitPixelOrPercentMenulist(globalElement,
- gInsertNewImage ? null : imageElement,
- "width", "widthUnitsMenulist", gPixel);
- var height = InitPixelOrPercentMenulist(globalElement,
- gInsertNewImage ? null : imageElement,
- "height", "heightUnitsMenulist", gPixel);
-
- var rg = gDialog.actualSizeRadio.radioGroup;
- // Set actual radio button if both set values are the same as actual
- if (actualWidth && actualHeight) {
- if ((width == actualWidth && height == actualHeight) || !(width || height))
- rg.selectedItem = gDialog.actualSizeRadio;
- }
- if (!gDialog.actualSizeRadio.selected)
- rg.selectedItem = gDialog.customSizeRadio;
-
- gDialog.widthInput.value = constrainWidth = width ? width : (actualWidth ? actualWidth : "");
- gDialog.heightInput.value = constrainHeight = height ? height : (actualHeight ? actualHeight : "");
-
- // set spacing editfields
- gDialog.imagelrInput.value = globalElement.getAttribute("hspace");
- gDialog.imagetbInput.value = globalElement.getAttribute("vspace");
- gDialog.border.value = globalElement.getAttribute("border");
-
- // Get alignment setting
- var align = globalElement.getAttribute("align");
- if (align) {
- align = align.toLowerCase();
- }
- var imgClass;
- var textID;
- switch ( align )
- {
- case "top":
- case "middle":
- case "right":
- case "left":
- gDialog.alignTypeSelect.value = align;
- break;
- default: // Default or "bottom"
- gDialog.alignTypeSelect.value = "bottom";
- }
-
// Get image map for image
gImageMap = GetImageMap();
- doOverallEnabling();
- doDimensionEnabling();
+ InitImage();
}
function GetImageMap()
@@ -231,164 +154,12 @@
{
gCanRemoveImageMap = false;
}
+ SetElementEnabledById( "removeImageMap", gCanRemoveImageMap);
gInsertNewIMap = true;
return null;
}
-function chooseFile()
-{
- // Get a local file, converted into URL format
- var fileName = GetLocalFileURL("img");
- if (fileName)
- {
- // Always try to relativize local file URLs
- if (gHaveDocumentUrl)
- fileName = MakeRelativeUrl(fileName);
-
- gDialog.srcInput.value = fileName;
-
- SetRelativeCheckbox();
- doOverallEnabling();
- }
- LoadPreviewImage();
-
- // Put focus into the input field
- SetTextboxFocus(gDialog.srcInput);
-}
-
-function PreviewImageLoaded()
-{
- if (gDialog.PreviewImage)
- {
- // Image loading has completed -- we can get actual width
- actualWidth = gDialog.PreviewImage.naturalWidth;
- actualHeight = gDialog.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 > gPreviewImageWidth)
- {
- width = gPreviewImageWidth;
- height = actualHeight * (gPreviewImageWidth / actualWidth);
- }
- if (height > gPreviewImageHeight)
- {
- height = gPreviewImageHeight;
- width = actualWidth * (gPreviewImageHeight / actualHeight);
- }
- gDialog.PreviewImage.width = width;
- gDialog.PreviewImage.height = height;
-
- gDialog.PreviewWidth.setAttribute("value", actualWidth);
- gDialog.PreviewHeight.setAttribute("value", actualHeight);
-
- gDialog.PreviewSize.setAttribute("collapsed", "false");
- gDialog.ImageHolder.setAttribute("collapsed", "false");
-
- // Use values as start for constrain proportions
- }
-
- if (gDialog.actualSizeRadio.selected)
- SetActualSize();
- }
-}
-
-function LoadPreviewImage()
-{
- gDialog.PreviewSize.setAttribute("collapsed", "true");
-
- var imageSrc = TrimString(gDialog.srcInput.value);
- if (!imageSrc)
- return;
-
- try {
- // Remove the image URL from image cache so it loads fresh
- // (if we don't do this, loads after the first will always use image cache
- // and we won't see image edit changes or be able to get actual width and height)
-
- var IOService = GetIOService();
- if (IOService)
- {
- // We must have an absolute URL to preview it or remove it from the cache
- imageSrc = MakeAbsoluteUrl(imageSrc);
-
- if (GetScheme(imageSrc))
- {
- var uri = IOService.newURI(imageSrc, null);
- if (uri)
- {
- var imgCacheService = Components.classes["@mozilla.org/image/cache;1"].getService();
- var imgCache = imgCacheService.QueryInterface(Components.interfaces.imgICache);
-
- // This returns error if image wasn't in the cache; ignore that
- imgCache.removeEntry(uri);
- }
- }
- }
- } catch(e) {}
-
- if (gDialog.PreviewImage)
- removeEventListener("load", PreviewImageLoaded, true);
-
- if (gDialog.ImageHolder.firstChild)
- gDialog.ImageHolder.removeChild(gDialog.ImageHolder.firstChild);
-
- gDialog.PreviewImage = document.createElementNS("http://www.w3.org/1999/xhtml", "html:img");
- if (gDialog.PreviewImage)
- {
- gDialog.ImageHolder.appendChild(gDialog.PreviewImage);
- gDialog.PreviewImage.addEventListener("load", PreviewImageLoaded, true);
- gDialog.PreviewImage.src = imageSrc;
- }
-}
-
-function SetActualSize()
-{
- gDialog.widthInput.value = actualWidth ? actualWidth : "";
- gDialog.widthUnitsMenulist.selectedIndex = 0;
- gDialog.heightInput.value = actualHeight ? actualHeight : "";
- gDialog.heightUnitsMenulist.selectedIndex = 0;
- doDimensionEnabling();
-}
-
-function ChangeImageSrc()
-{
- if (gTimerID)
- clearTimeout(gTimerID);
-
- gTimerID = setTimeout("LoadPreviewImage()", 800);
-
- SetRelativeCheckbox();
- doOverallEnabling();
-}
-
-function doDimensionEnabling()
-{
- // Enabled only if "Custom" is selected
- var enable = (gDialog.customSizeRadio.selected);
-
- // BUG 74145: After input field is disabled,
- // setting it enabled causes blinking caret to appear
- // even though focus isn't set to it.
- SetElementEnabledById( "heightInput", enable );
- SetElementEnabledById( "heightLabel", enable );
- SetElementEnabledById( "heightUnitsMenulist", enable );
-
- SetElementEnabledById( "widthInput", enable );
- SetElementEnabledById( "widthLabel", enable);
- SetElementEnabledById( "widthUnitsMenulist", enable );
-
- var constrainEnable = enable
- && ( gDialog.widthUnitsMenulist.selectedIndex == 0 )
- && ( gDialog.heightUnitsMenulist.selectedIndex == 0 );
-
- SetElementEnabledById( "constrainCheckbox", constrainEnable );
-}
-
function doOverallEnabling()
{
var enabled = TrimString(gDialog.srcInput.value) != "";
@@ -402,60 +173,6 @@
SetElementEnabledById("removeImageMap", gCanRemoveImageMap);
}
-function ToggleConstrain()
-{
- // If just turned on, save the current width and height as basis for constrain ratio
- // Thus clicking on/off lets user say "Use these values as aspect ration"
- if (gDialog.constrainCheckbox.checked && !gDialog.constrainCheckbox.disabled
- && (gDialog.widthUnitsMenulist.selectedIndex == 0)
- && (gDialog.heightUnitsMenulist.selectedIndex == 0))
- {
- constrainWidth = Number(TrimString(gDialog.widthInput.value));
- constrainHeight = Number(TrimString(gDialog.heightInput.value));
- }
-}
-
-function constrainProportions( srcID, destID )
-{
- var srcElement = document.getElementById(srcID);
- if (!srcElement)
- return;
-
- var destElement = document.getElementById(destID);
- if (!destElement)
- return;
-
- // always force an integer (whether we are constraining or not)
- forceInteger(srcID);
-
- if (!actualWidth || !actualHeight ||
- !(gDialog.constrainCheckbox.checked && !gDialog.constrainCheckbox.disabled))
- return;
-
- // double-check that neither width nor height is in percent mode; bail if so!
- if ( (gDialog.widthUnitsMenulist.selectedIndex != 0)
- || (gDialog.heightUnitsMenulist.selectedIndex != 0) )
- return;
-
- // This always uses the actual width and height ratios
- // which is kind of funky if you change one number without the constrain
- // and then turn constrain on and change a number
- // I prefer the old strategy (below) but I can see some merit to this solution
- if (srcID == "widthInput")
- destElement.value = Math.round( srcElement.value * actualHeight / actualWidth );
- else
- destElement.value = Math.round( srcElement.value * actualWidth / actualHeight );
-
-/*
- // With this strategy, the width and height ratio
- // can be reset to whatever the user entered.
- if (srcID == "widthInput")
- destElement.value = Math.round( srcElement.value * constrainHeight / constrainWidth );
- else
- destElement.value = Math.round( srcElement.value * constrainWidth / constrainHeight );
-*/
-}
-
function editImageMap()
{
// Create an imagemap for image map editor
@@ -477,96 +194,7 @@
// accessible to AdvancedEdit() [in EdDialogCommon.js]
function ValidateData()
{
- //TODO: WE NEED TO DO SOME URL VALIDATION HERE, E.G.:
- // We must convert to "file:///" or "http://" format else image doesn't load!
- var src = TrimString(gDialog.srcInput.value);
- globalElement.setAttribute("src", src);
-
- // Note: allow typing spaces,
- // Warn user if empty string just once per dialog session
- // but don't consider this a failure
- var alt = gDialog.altTextInput.value;
- if (doAltTextError && !alt)
- {
- AlertWithTitle(null, GetString("NoAltText"));
- SetTextboxFocus(gDialog.altTextInput);
- doAltTextError = false;
- return false;
- }
- globalElement.setAttribute("alt", alt);
-
- var width = "";
- var height = "";
-
- if (!gDialog.actualSizeRadio.selected)
- {
- // Get user values for width and height
- width = ValidateNumber(gDialog.widthInput, gDialog.widthUnitsMenulist, 1, maxPixels,
- globalElement, "width", false, true);
- if (gValidationError)
- return false;
-
- height = ValidateNumber(gDialog.heightInput, gDialog.heightUnitsMenulist, 1, maxPixels,
- globalElement, "height", false, true);
- if (gValidationError)
- return false;
- }
-
- // We always set the width and height attributes, even if same as actual.
- // This speeds up layout of pages since sizes are known before image is loaded
- if (!width)
- width = actualWidth;
- if (!height)
- height = actualHeight;
-
- // Remove existing width and height only if source changed
- // and we couldn't obtain actual dimensions
- var srcChanged = (src != gOriginalSrc);
- if (width)
- globalElement.setAttribute("width", width);
- else if (srcChanged)
- globalElement.removeAttribute("width");
-
- if (height)
- globalElement.setAttribute("height", height);
- else if (srcChanged)
- globalElement.removeAttribute("height");
-
- // spacing attributes
-
- ValidateNumber(gDialog.imagelrInput, null, 0, maxPixels,
- globalElement, "hspace", false, true, true);
- if (gValidationError)
- return false;
-
- ValidateNumber(gDialog.imagetbInput, null, 0, maxPixels,
- globalElement, "vspace", false, true);
- if (gValidationError)
- return false;
-
- // note this is deprecated and should be converted to stylesheets
- ValidateNumber(gDialog.border, null, 0, maxPixels,
- globalElement, "border", false, true);
- if (gValidationError)
- return false;
-
- // Default or setting "bottom" means don't set the attribute
- // Note that the attributes "left" and "right" are opposite
- // of what we use in the UI, which describes where the TEXT wraps,
- // not the image location (which is what the HTML describes)
- switch ( gDialog.alignTypeSelect.value )
- {
- case "top":
- case "middle":
- case "right":
- case "left":
- globalElement.setAttribute( "align", gDialog.alignTypeSelect.value );
- break;
- default:
- globalElement.removeAttribute( "align" );
- }
-
- return true;
+ return ValidateImage();
}
function doHelpButton()
@@ -586,6 +214,12 @@
if (ValidateData())
{
+ if ("arguments" in window && window.arguments[0])
+ {
+ SaveWindowLocation();
+ return true;
+ }
+
editorShell.BeginBatchChanges();
if (gRemoveImageMap)
Index: ui/dialogs/content/EdImageProps.xul
===================================================================
RCS file: /cvsroot/mozilla/editor/ui/dialogs/content/EdImageProps.xul,v
retrieving revision 1.96
diff -u -r1.96 EdImageProps.xul
--- ui/dialogs/content/EdImageProps.xul 2001/12/04 22:38:40 1.96
+++ ui/dialogs/content/EdImageProps.xul 2001/12/06 14:21:45
@@ -26,6 +26,7 @@
+
@@ -51,38 +52,7 @@