From 1b897a579bf4cca96195c18b8ac23c6b851d9ee7 Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Fri, 17 Aug 2001 22:41:52 +0000 Subject: [PATCH] Fixed Advanced Editor dialog bugs (fixed warnings, user input filter rules, dynamic value menulist for particular attributes): bugs 86710, 86712, 86713, 86934, 88878, 88888, 88917, 88923, 88930, 88935, 89445, 92554 (includes help from stephend), r=brade (86713=rcassin, 92554=glazman), sr=kin; fix to 95085 by neil@parkwayscc.co.uk, r=cmanske, sr=kin --- .../composer/locale/en-US/editor.properties | 2 +- editor/ui/dialogs/content/EdAEAttributes.js | 106 +++++++++++++++--- .../ui/dialogs/content/EdAEHTMLAttributes.js | 45 ++++++-- .../ui/dialogs/content/EdAEJSEAttributes.js | 45 +++++--- editor/ui/dialogs/content/EdAdvancedEdit.js | 2 +- editor/ui/dialogs/content/EdAdvancedEdit.xul | 6 +- .../dialogs/locale/en-US/EdAdvancedEdit.dtd | 2 + 7 files changed, 164 insertions(+), 44 deletions(-) diff --git a/editor/ui/composer/locale/en-US/editor.properties b/editor/ui/composer/locale/en-US/editor.properties index 0fb88c46aeb..f39722b735c 100644 --- a/editor/ui/composer/locale/en-US/editor.properties +++ b/editor/ui/composer/locale/en-US/editor.properties @@ -93,7 +93,7 @@ ShowToolbar=Show Toolbar HideToolbar=Hide Toolbar ImapError=Unable to load image ImapCheck=\nPlease select a new location (URL) and try again. -ImapRelative=Relative URLs can only be used on documents which have been saved +SaveToUseRelativeUrl=Relative URLs can only be used on pages which have been saved NoNamedAnchors=(No named anchors in this page) NoHeadings=(No headings without anchors) TextColor=Text Color diff --git a/editor/ui/dialogs/content/EdAEAttributes.js b/editor/ui/dialogs/content/EdAEAttributes.js index 83da18e560b..c5a0c8631e4 100644 --- a/editor/ui/dialogs/content/EdAEAttributes.js +++ b/editor/ui/dialogs/content/EdAEAttributes.js @@ -21,7 +21,6 @@ * Beth Epperson */ - // HTML Attributes object for "Name" menulist var gHTMLAttr = {}; @@ -33,13 +32,15 @@ var gJSAttr = {}; // This is appended to Name menulist when "_core" is attribute name var gCoreHTMLAttr = [ - "id", + "id", "class", "title" ]; // Core event attribute values // // This is appended to all JS menulists +// except those elements having "noJSEvents" +// as a value in their gJSAttr array. var gCoreJSEvents = [ "onclick", @@ -111,6 +112,34 @@ var gVAlignTable = ]; // ================ HTML Attributes ================ // +/* For each element, there is an array of attributes, + whose name is the element name, + used to fill the "Attribute Name" menulist. + For each of those attributes, if they have a specific + set of values, those are listed in an array named: + "elementName_attName". + + In each values string, the following characters + are signal to do input filtering: + "#" Allow only integer values + "%" Allow integer values or a number ending in "%" + "!" Allow only one character + "$" is an attribute required by HTML DTD +*/ + +/* + Most elements have the "dir" attribute, + so we use this value array + for all elements instead of specifying + separately for each element +*/ +gHTMLAttr.all_dir = +[ + "ltr", + "rtl" +]; + + gHTMLAttr.a = [ "charset", @@ -211,11 +240,11 @@ gHTMLAttr.applet = "object", "alt", "name", - "$width", - "$height", + "%$width", + "%$height", "align", - "hspace", - "vspace", + "#hspace", + "#vspace", "-", "_core" ]; @@ -286,6 +315,8 @@ gHTMLAttr.basefont_color = gHTMLColors; gHTMLAttr.bdo = [ + "_core", + "-", "lang", "$dir" ]; @@ -329,8 +360,6 @@ gHTMLAttr.body = "dir" ]; -gHTMLAttr.body_background = gHTMLColors; - gHTMLAttr.body_bgcolor = gHTMLColors; gHTMLAttr.body_text = gHTMLColors; @@ -500,7 +529,11 @@ gHTMLAttr.dd = gHTMLAttr.del = [ "cite", - "datetime" + "datetime", + "_core", + "-", + "lang", + "dir" ]; gHTMLAttr.dfn = @@ -582,7 +615,7 @@ gHTMLAttr.fieldset = // this is deprecated // gHTMLAttr.font = [ - "size", + "#size", "color", "face", "-", @@ -621,6 +654,13 @@ gHTMLAttr.form_enctype = "application/x-www-form-urlencoded" ]; +gHTMLAttr.form_target = +[ + "blank", + "self", + "parent", + "top" +]; gHTMLAttr.frame = [ @@ -808,6 +848,15 @@ gHTMLAttr.iframe_scrolling = "no" ]; +gHTMLAttr.iframe_align = +[ + "top", + "middle", + "bottom", + "left", + "right" +]; + gHTMLAttr.img = [ "$src", @@ -819,9 +868,9 @@ gHTMLAttr.img = "usemap", "ismap", "align", - "border", - "hspace", - "vspace", + "#border", + "#hspace", + "#vspace", "-", "_core", "-", @@ -1119,9 +1168,9 @@ gHTMLAttr.object = "name", "#tabindex", "align", - "border", - "hspace", - "vspace", + "#border", + "#hspace", + "#vspace", "-", "_core", "-", @@ -1677,7 +1726,9 @@ gHTMLAttr._var = // ================ JS Attributes ================ // // These are element specif even handlers. -// All elements use gCoreJSEvents +/* Most all elements use gCoreJSEvents, so those + are assumed except for those listed here with "noEvents" +*/ gJSAttr.a = [ @@ -1744,3 +1795,24 @@ gJSAttr.textarea = "onchange" ]; +// Elements that don't have JSEvents: +gJSAttr.font = +[ + "noJSEvents" +]; + +gJSAttr.applet = +[ + "noJSEvents" +]; + +gJSAttr.isindex = +[ + "noJSEvents" +]; + +gJSAttr.iframe = +[ + "noJSEvents" +]; + diff --git a/editor/ui/dialogs/content/EdAEHTMLAttributes.js b/editor/ui/dialogs/content/EdAEHTMLAttributes.js index f5b6b63263a..1fe821fb475 100644 --- a/editor/ui/dialogs/content/EdAEHTMLAttributes.js +++ b/editor/ui/dialogs/content/EdAEHTMLAttributes.js @@ -50,7 +50,7 @@ function BuildHTMLAttributeNameList() var popup = dialog.AddHTMLAttributeNameInput.firstChild; if (popup) { - sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"); + var sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"); if (sep) popup.appendChild(sep); } @@ -60,7 +60,7 @@ function BuildHTMLAttributeNameList() // Get information about value filtering forceOneChar = name.indexOf("!") >= 0; forceInteger = name.indexOf("#") >= 0; - forceIntOrPercent = name.indexOf("%") >= 0; + var forceIntOrPercent = name.indexOf("%") >= 0; //var required = name.indexOf("$") >= 0; // Strip flag characters ("_" is used when attribute name is reserved JS word) @@ -176,14 +176,31 @@ function onInputHTMLAttributeName() if (attName) { // Get value list for current attribute name - var valueList = gHTMLAttr[gElement.localName.toLowerCase() + "_" + attName]; + var valueListName; + + // Most elements have the "dir" attribute, + // so we have just one array for the allowed values instead + // requiring duplicate entries for each element in EdAEAttributes.js + if (attName == "dir") + valueListName = "all_dir"; + else + valueListName = gElement.localName.toLowerCase() + "_" + attName; + + // Strip off leading "_" we sometimes use (when element name is reserved word) + if (valueListName[0] == "_") + valueListName = valueListName.slice(1); - // Index to which widget we were using to edit the value - var deckIndex = dialog.AddHTMLAttributeValueDeck.getAttribute("index"); var newValue = ""; var listLen = 0; - if (valueList) + var deckIndex = 0; + + if (valueListName in gHTMLAttr) { + var valueList = gHTMLAttr[valueListName]; + + // Index to which widget we were using to edit the value + deckIndex = dialog.AddHTMLAttributeValueDeck.getAttribute("index"); + listLen = valueList.length; if (listLen > 0) newValue = valueList[0]; @@ -202,7 +219,21 @@ function onInputHTMLAttributeName() } // Rebuild the list for (var i = 0; i < listLen; i++) - AppendStringToMenulist(dialog.AddHTMLAttributeValueMenulist, valueList[i]); + { + if (valueList[i] == "-") + { + // Signal for separator + var popup = dialog.AddHTMLAttributeValueInput.firstChild; + if (popup) + { + var sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"); + if (sep) + popup.appendChild(sep); + } + } else { + AppendStringToMenulist(dialog.AddHTMLAttributeValueMenulist, valueList[i]); + } + } } } diff --git a/editor/ui/dialogs/content/EdAEJSEAttributes.js b/editor/ui/dialogs/content/EdAEJSEAttributes.js index 0204241a07f..aaac7af0a23 100644 --- a/editor/ui/dialogs/content/EdAEJSEAttributes.js +++ b/editor/ui/dialogs/content/EdAEJSEAttributes.js @@ -26,26 +26,41 @@ function BuildJSEAttributeNameList() ClearMenulist(dialog.AddJSEAttributeNameList); // Get events specific to current element - var attNames = gJSAttr[gElement.localName.toLowerCase()]; - var i; - var popup; - var sep; - - if (attNames && attNames.length) + var elementName = gElement.localName.toLowerCase(); + if (elementName in gJSAttr) { - for (i = 0; i < attNames.length; i++) - AppendStringToMenulist(dialog.AddJSEAttributeNameList, attNames[i]); + var attNames = gJSAttr[elementName]; + var i; + var popup; + var sep; - popup = dialog.AddJSEAttributeNameList.firstChild; - if (popup) + if (attNames && attNames.length) { - sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"); - if (sep) - popup.appendChild(sep); - } + // Since we don't allow user-editable JS events yet (but we will soon) + // simply remove the JS tab to not allow adding JS events + if (attNames[0] == "noJSEvents") + { + var tab = document.getElementById("tabJSE"); + if (tab) + tab.parentNode.removeChild(tab); + + return; + } + + for (i = 0; i < attNames.length; i++) + AppendStringToMenulist(dialog.AddJSEAttributeNameList, attNames[i]); + + popup = dialog.AddJSEAttributeNameList.firstChild; + if (popup) + { + sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"); + if (sep) + popup.appendChild(sep); + } + } } - // Always add core JS events + // Always add core JS events unless we aborted above for (i = 0; i < gCoreJSEvents.length; i++) { if (gCoreJSEvents[i] == "-") diff --git a/editor/ui/dialogs/content/EdAdvancedEdit.js b/editor/ui/dialogs/content/EdAdvancedEdit.js index d9bda9752e5..bee01f27262 100644 --- a/editor/ui/dialogs/content/EdAdvancedEdit.js +++ b/editor/ui/dialogs/content/EdAdvancedEdit.js @@ -162,7 +162,7 @@ function UpdateExistingAttribute( attName, attValue, treeChildrenId ) { var treeChildren = document.getElementById(treeChildrenId); if (!treeChildren) - return; + return false; var name; var i; diff --git a/editor/ui/dialogs/content/EdAdvancedEdit.xul b/editor/ui/dialogs/content/EdAdvancedEdit.xul index a20a898a1e0..adf277a234f 100644 --- a/editor/ui/dialogs/content/EdAdvancedEdit.xul +++ b/editor/ui/dialogs/content/EdAdvancedEdit.xul @@ -70,7 +70,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -157,7 +157,7 @@ - + diff --git a/editor/ui/dialogs/locale/en-US/EdAdvancedEdit.dtd b/editor/ui/dialogs/locale/en-US/EdAdvancedEdit.dtd index 6d611769665..04cba112c0f 100644 --- a/editor/ui/dialogs/locale/en-US/EdAdvancedEdit.dtd +++ b/editor/ui/dialogs/locale/en-US/EdAdvancedEdit.dtd @@ -24,8 +24,10 @@ + +