From a16c40cda3420a67bbdf5ac61d53e94a11a226e9 Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Thu, 16 Sep 1999 04:36:16 +0000 Subject: [PATCH] Editor UI work. Integrated Brendan's JS improvements. Trying to get popups to work in dialogs. Add Ben Goodger's table properties dialog work. git-svn-id: svn://10.0.0.236/trunk@47733 18797224-902f-48f8-a5cc-f745e15eee43 --- .../ui/dialogs/content/EdDialogCommon.js | 137 ++----- .../ui/dialogs/content/EdDialogOverlay.xul | 10 +- .../ui/dialogs/content/EdHLineProps.xul | 20 +- .../ui/dialogs/content/EdImageProps.xul | 10 - .../ui/dialogs/content/EdInsertTable.js | 4 +- .../ui/dialogs/content/EdInsertTable.xul | 3 +- .../editor/ui/dialogs/content/EdLinkProps.js | 6 +- .../editor/ui/dialogs/content/EdMessage.js | 18 +- .../ui/dialogs/content/EdTableProps.xul | 379 ++++++++++++++++-- .../dialogs/locale/en-US/EdDialogOverlay.dtd | 2 + .../locale/en-US/EditorHLineProperties.dtd | 1 - .../locale/en-US/EditorTableProperties.dtd | 51 ++- .../editor/ui/dialogs/skin/EditorDialog.css | 158 ++------ 13 files changed, 497 insertions(+), 302 deletions(-) diff --git a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js index b0827401356..0932a0f8da9 100644 --- a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js +++ b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js @@ -123,8 +123,7 @@ function ValidateNumberString(value, minValue, maxValue) { // Get the number version (strip out non-numbers) - var pat = /\D/g; - value = value.replace(pat, ""); + value = value.replace(/\D+/g, ""); number = value - 0; if ((value+"") != "") { if (number && number >= minValue && number <= maxValue ){ @@ -154,45 +153,30 @@ function GetString(name) function TrimStringLeft(string) { - if(!StringExists(string)) - return ""; - if( IsWhitespace(string.charAt(0))) - string = string.replace(/\s+/, ""); - return string; + if(!string) return ""; + return string.replace(/^\s+/, ""); } function TrimStringRight(string) { - if(!StringExists(string)) - return ""; - var lastCharIndex = string.length-1; - var result; - var done = false; - while (!done && lastCharIndex >= 0) { - - // Find the last non-whitespace char - - if (!IsWhitespace(string.charAt(lastCharIndex))) break; - lastCharIndex--; - } - if (lastCharIndex < 0) { - string = ""; - } else { - string = string.slice(0, lastCharIndex+1); - } - return string; + if (!string) return ""; + return string.replace(/\s+$/, ''); } // Remove whitespace from both ends of a string - function TrimString(string) { - return TrimStringRight(TrimStringLeft(string)); + if (!string) return ""; + return string.replace(/(^\s+)|(\s+$)/g, '') +} + +String.prototype.trimString = function() { + return this.replace(/(^\s+)|(\s+$)/g, '') } function IsWhitespace(character) { - var result = character.match(/\s/); + var result = character.match(/\s/); if (result == null) return false; return true; @@ -200,77 +184,30 @@ function IsWhitespace(character) function TruncateStringAtWordEnd(string, maxLength, addEllipses) { - // We assume they probably don't want whitespace at the beginning + // Return empty if string is null, undefined, or the empty string + if (!string) + return ""; - var string = TrimStringLeft(string); + // We assume they probably don't want whitespace at the beginning + string = string.replace(/^\s+/, ''); + if (string.length <= maxLength) + return string; - var len = string.length; - if (len > maxLength) { + // We need to truncate the string to maxLength or fewer chars + if (addEllipses) + maxLength -= 3; + string = string.replace(RegExp("(.{0," + maxLength + "})\\s.*"), "$1") - // We need to truncate the string - - var max; - if (addEllipses) { - // Make room for ellipses - max = maxLength - 3; - } else { - max = maxLength; - } - var lastCharIndex = 0; - - // Start search just past max if there's enough characters - - if (len >= (max+1)) { - lastCharIndex = max; - } else { - lastCharIndex = len-1; - } - dump("Len="+len+" lastCharIndex="+lastCharIndex+" max="+max+"\n"); - - // Find the last whitespace char from the end - - dump("Skip to first whitspace from end: "); - - while (lastCharIndex > 0) { - var lastChar = string.charAt(lastCharIndex); - dump(lastChar); - if (IsWhitespace(lastChar)) break; - lastCharIndex = lastCharIndex -1; - } - dump("[space found]\nlastCharIndex="+lastCharIndex+"\nSkip over whitespace:"); - - while (lastCharIndex > 0) { - - // Find the last non-whitespace char - - lastChar = string.charAt(lastCharIndex); - dump(lastChar); - if (!IsWhitespace(lastChar)) break; - lastCharIndex = lastCharIndex -1; - } - dump("[non-space found]\nlastCharIndex="+lastCharIndex+"\n"); - - string = string.slice(0, lastCharIndex+1); - if (addEllipses) { - string = string+"..."; - dump(string+"\n"); - } - } - return string; + if (addEllipses) + string += "..."; + return string; } // Replace all whitespace characters with supplied character // E.g.: Use charReplace = " ", to "unwrap" the string by removing line-end chars // Use charReplace = "_" when you don't want spaces (like in a URL) function ReplaceWhitespace(string, charReplace) { - if (string.length > 0 ) - { - string = TrimString(string); - // This replaces a run of whitespace with just one character - string = string.replace(/\s+/g, charReplace); - } - dump(string+"\n"); - return string; + return string.replace(/(^\s+)|(\s+$)/g,'').replace(/\s+/g,charReplace) } // this function takes an elementID and a flag @@ -383,20 +320,18 @@ sysBeep = sysBeep.QueryInterface(Components.interfaces.nsISound); function forceInteger(elementID) { - editfield = document.getElementById( elementID ); - if ( !editfield ) + var editField = document.getElementById( elementID ); + if ( !editField ) return; - - var stringIn = editfield.value; - var pat = /\D/g; - - result = stringIn.match(pat, ""); - if (result) { - editfield.value = stringIn.replace(pat,""); - // hopefully we can remove the following line for blur() once xp widgets land + var stringIn = editField.value; + var pat = /\D+/g; + if (pat.test(stringIn)) { + editField.value = stringIn.replace(pat,""); - editfield.blur(); + // we hope to remove the following line for blur() once xp widgets land + // cmanske (9/15) testing this now that GFX ender widget is active + //editField.blur(); sysBeep.Beep(); } } diff --git a/mozilla/editor/ui/dialogs/content/EdDialogOverlay.xul b/mozilla/editor/ui/dialogs/content/EdDialogOverlay.xul index e3a941d4481..8fcf5bc490b 100644 --- a/mozilla/editor/ui/dialogs/content/EdDialogOverlay.xul +++ b/mozilla/editor/ui/dialogs/content/EdDialogOverlay.xul @@ -28,11 +28,11 @@ xmlns:html="http://www.w3.org/TR/REC-html40" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - - - - + + + + + diff --git a/mozilla/editor/ui/dialogs/content/EdHLineProps.xul b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul index 4d2cce860f4..83e8151f3b7 100644 --- a/mozilla/editor/ui/dialogs/content/EdHLineProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul @@ -68,8 +68,15 @@ onkeypress="forceInteger('width')" /> - + @@ -98,13 +105,4 @@ - - - - - - - - - diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.xul b/mozilla/editor/ui/dialogs/content/EdImageProps.xul index 7ce1ab0b254..bdce290994a 100644 --- a/mozilla/editor/ui/dialogs/content/EdImageProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdImageProps.xul @@ -609,17 +609,13 @@ - - + diff --git a/mozilla/editor/ui/dialogs/content/EdLinkProps.js b/mozilla/editor/ui/dialogs/content/EdLinkProps.js index 09e4815a3d6..6f9e186a6ea 100644 --- a/mozilla/editor/ui/dialogs/content/EdLinkProps.js +++ b/mozilla/editor/ui/dialogs/content/EdLinkProps.js @@ -179,7 +179,7 @@ function ChooseFile() { // Get a local file, converted into URL format fileName = editorShell.GetLocalFileURL(window, "html"); - if (StringExists(fileName)) { + if (fileName) { hrefInput.value = fileName; } // Put focus into the input field @@ -196,11 +196,12 @@ function RemoveLink() // Set attributes on globalElement so they can be accessed by AdvancedEdit() function ValidateData() { - href = TrimString(hrefInput.value); + href = hrefInput.value.trimString(); if (href.length > 0) { // Set the HREF directly on the editor document's anchor node // or on the newly-created node if insertNew is true globalElement.setAttribute("href",href); + dump("HREF:"+href+"|\n"); } else if (insertNew) { // We must have a URL to insert a new link //NOTE: WE ACCEPT AN EMPTY HREF TO ALLOW REMOVING AN EXISTING LINK, @@ -217,6 +218,7 @@ function ValidateData() return false; } } + window.sizeToContent(); return true; } diff --git a/mozilla/editor/ui/dialogs/content/EdMessage.js b/mozilla/editor/ui/dialogs/content/EdMessage.js index b44c48d8f6d..1c06b65e3d2 100644 --- a/mozilla/editor/ui/dialogs/content/EdMessage.js +++ b/mozilla/editor/ui/dialogs/content/EdMessage.js @@ -33,9 +33,11 @@ function Startup() // Message is wrapped in a
// We will add child text node(s) var messageParent = (document.getElementById("message")); - var messageText = String(window.arguments[1]); + var messageText = ""; + if(window.arguments[1]) + messageText = String(window.arguments[1]); - if (StringExists(messageText)) { + if (messageText != "") { var messageFragment; // Let the caller use "\n" to cause breaks @@ -75,7 +77,7 @@ function Startup() } titleText = String(window.arguments[2]); - if (StringExists(titleText)) { + if (titleText) { dump(titleText+" is the message dialog title\n"); window.title = titleText; } @@ -93,14 +95,14 @@ function Startup() function InitButton(argIndex, buttonID, useOK) { var button = document.getElementById(buttonID); - var text = String(window.arguments[argIndex]); - var exists = StringExists(text); - if (!exists && useOK) { + var text = ""; + if(window.arguments[argIndex]) + text = String(window.arguments[argIndex]); + if (text == "" && useOK) { text = "OK"; - exists = true; } - if (exists) + if (text != "") { dump(text+"\n"); button.setAttribute("value", text); diff --git a/mozilla/editor/ui/dialogs/content/EdTableProps.xul b/mozilla/editor/ui/dialogs/content/EdTableProps.xul index 7d73f04bab6..f059fda152f 100644 --- a/mozilla/editor/ui/dialogs/content/EdTableProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdTableProps.xul @@ -33,44 +33,357 @@ - - - - + + - - - &tableTab.label; - &cellTab.label; - - - - - - - WORK IN PROGRESS: This is the TABLE Tab - - - - - - - - WORK IN PROGRESS: This is the CELL Tab - - - - - - - - - + + + &tableTab.label; + &cellTab.label; + + + + + + + &tableSize.label; + + + + &tableRows.label; + + + + + + + + + &tableHeight.label; + + + + + + + &tablePixels.label; + &tablePercent.label; + + + + + + &tableColumns.label; + + + + + + + + + &tableWidth.label; + + + + + + + &tablePixels.label; + &tablePercent.label; + + + + + + + + &tableBorderSpacing.label; + + + + + + + &tableBorderWidth.label; + + + + + + &tablePixels.label; + + + + + + + &tableSpacing.label; + + + + + + &tablePxBetwCells.label; + + + + + &tablePadding.label; + + + + + + &tablePxBetwBrdrCellContent.label; + + + + + + + + + + &tableAlignment.label; + + + + &tableAlignLeft.label; + &tableAlignCenter.label; + &tableAlignRight.label; + + + + + + + &tableCaption.label; + + + + &tableCaptionNone.label; + &tableCaptionAbove.label; + &tableCaptionBelow.label; + + + + + + + + + &tableBackground.label; + + + + &tableColor.label; + + + + + + + + + + &tableImage.label; + + + + + + + + + + + &tableLeaveImageAtLocation.label; + + + + + + + + + + &cellSelection.label; + + + + + &cellSelectionCell.label; + &cellSelectionRow.label; + &cellSelectionColumn.label; + + + + + + + + + + + + + + &tableSize.label; + + + + + + + &tableHeight.label; + + + + + + + &tablePixels.label; + &tablePercent.label; + + + + &cellSpans.label; + + + + + + &cellSpanRows.label; + + + + + + + + &tableWidth.label; + + + + + + + &tablePixels.label; + &tablePercent.label; + + + + + + + + &cellSpanCells.label; + + + + + + + &cellContentAlignment.label; + + + + &cellHorizontal.label; + + + + &tableAlignLeft.label; + &tableAlignCenter.label; + &tableAlignRight.label; + + + + + + &cellVertical.label; + + + + &cellAlignTop.label; + &cellAlignCenter.label; + &cellAlignBottom.label; + + + + + + + + &cellTextStyle.label; + + + + + + + &cellHeader.label; + + + + + + &cellNonbreaking.label; + + + + + + + + + + &tableBackground.label; + + + + &tableColor.label; + + + + + + + + + + &tableImage.label; + + + + + + + + + + + &tableLeaveImageAtLocation.label; + + + + + + + + + + + + + + diff --git a/mozilla/editor/ui/dialogs/locale/en-US/EdDialogOverlay.dtd b/mozilla/editor/ui/dialogs/locale/en-US/EdDialogOverlay.dtd index 66faa5a9c31..56941a7e911 100644 --- a/mozilla/editor/ui/dialogs/locale/en-US/EdDialogOverlay.dtd +++ b/mozilla/editor/ui/dialogs/locale/en-US/EdDialogOverlay.dtd @@ -21,3 +21,5 @@ --> + + diff --git a/mozilla/editor/ui/dialogs/locale/en-US/EditorHLineProperties.dtd b/mozilla/editor/ui/dialogs/locale/en-US/EditorHLineProperties.dtd index d4025980b7c..eca92fee3b7 100644 --- a/mozilla/editor/ui/dialogs/locale/en-US/EditorHLineProperties.dtd +++ b/mozilla/editor/ui/dialogs/locale/en-US/EditorHLineProperties.dtd @@ -29,7 +29,6 @@ - diff --git a/mozilla/editor/ui/dialogs/locale/en-US/EditorTableProperties.dtd b/mozilla/editor/ui/dialogs/locale/en-US/EditorTableProperties.dtd index 100619ffe73..4ecfbb89ab9 100644 --- a/mozilla/editor/ui/dialogs/locale/en-US/EditorTableProperties.dtd +++ b/mozilla/editor/ui/dialogs/locale/en-US/EditorTableProperties.dtd @@ -20,6 +20,51 @@ - Contributor(s): --> - - - + + + + + + + + + + + + + + + + and cell content"> + + + + + +Alignment:"> + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mozilla/editor/ui/dialogs/skin/EditorDialog.css b/mozilla/editor/ui/dialogs/skin/EditorDialog.css index 46a08e3015c..0c4d797ae28 100644 --- a/mozilla/editor/ui/dialogs/skin/EditorDialog.css +++ b/mozilla/editor/ui/dialogs/skin/EditorDialog.css @@ -36,126 +36,7 @@ window{ } -titledbutton.popup { - - list-style-image: url(resource:/res/toolbar/TB_popup.gif); - width: auto; - display: inline; - text-decoration: none; - color: black; - padding: 0px; - margin: 0px; - border: 1px outset white; - font: inherit; -} - -titledbutton.popup:hover { - background-color: inherit; - background-image: inherit; - border: 1px outset white; - padding: 0px; - margin: 0px; - color: black; - text-decoration: none; -} - - -titledbutton.popup:active { - - text-decoration: none; - border: 1px outset white; - color: none; - color: black; /* why is color set twice? */ - padding: 0px; - margin: 0px; - -} - - -titledbutton.popup[disabled="true"] { - - background-color: inherit; - background-image: inherit; - border : 1px solid #999999; - padding: 0px; - margin: 0px; - color: #999999; - text-decoration: none; - image-opacity: 25%; -} - -titledbutton.popup[disabled="true"]:hover { - - background-color: inherit; - background-image: inherit; - border : 1px solid #999999; - padding: 0px; - margin: 0px; - color: #999999; - text-decoration: none; -} - -titledbutton.popup[disabled="true"]:active { - - background-color: inherit; - background-image: inherit; - padding: 0px; - margin: 0px; - border : 1px solid #999999; - color: #999999; - text-decoration: none; -} - -titledbutton.dropdown { - - width: 100%; - display: inline; - text-decoration: none; - color: black; - padding: 0px; - margin: 0px; - border: none; - font: inherit; - background-repeat: no-repeat; - background-color: inherit; - color: black; - - -} - -titledbutton.dropdown:hover { - - width: 100%; - display: inline; - text-decoration: none; - color: black; - padding: 0px; - margin: 0px; - border: none; - font: inherit; - background-repeat: no-repeat; - background-color: #666699; - color: white; - - -} - -titledbutton.dropdown:active { - - width: 100%; - display: inline; - text-decoration: none; - color: white; - padding: 0px; - margin: 0px; - border: none; - font: inherit; - background-repeat: no-repeat; - background-color: #666699; - - -} - +/* THIS SHOULD BE KILLED. NO SPECIAL TITLED BUTTONS SHOULD BE USED! */ titledbutton.select { width: 100%; @@ -206,7 +87,7 @@ titledbutton.select:active { } - +/* Subtle changes, like a little more space, is OK */ /* Don't mess with top and bottom margin! */ titledbutton[class=~spaced] { @@ -214,8 +95,6 @@ titledbutton[class=~spaced] { margin-right: 5px; } -/* This assumes 1px is shifted to the border - @@ -327,7 +206,7 @@ select.combobox { select.SpellCheckList, select.SpellCheckLanguage, input.SpellCheckWord { width: 20em; - border-style: inset; + /* border-style: inset; */ background-color: #CCCCCC; /* not working on Macintosh */ } @@ -623,6 +502,7 @@ spring.bigspacer { height: 10px; } +/* From Ben Goodger (originally EdAdvancedEdit.css) */ div.spacer [align~=horizontal] { border : 1px inset white; height : 2px; @@ -716,3 +596,33 @@ input.AttributesCell:active { input.AttributesCell:hover { border: 1px white inset; } + +/* From Ben Goodger (originally EdTableProps.css) */ +box.header { +/* background-color: #7777A4;*/ + padding: 2px; +} + +box.header > div { + color: #000000; + font-size: 16px; + font-weight: bold; + margin-left: 5px; +} + +box.panel { + border: 1px outset white; + width: 350px; +} + +fieldset.holder { + width: 350px; + +/* Always use the arrow cursor, except in input widget */ +*,p,div,legend,box {cursor: pointer;} +button { cursor: crosshair; } + +input[type=text], input[type=textarea] { + cursor: text; +} +