From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../components/dialogs/content/EdAEAttributes.js | 973 +++++++++++++ .../dialogs/content/EdAECSSAttributes.js | 146 ++ .../dialogs/content/EdAEHTMLAttributes.js | 367 +++++ .../dialogs/content/EdAEJSEAttributes.js | 200 +++ .../components/dialogs/content/EdAdvancedEdit.js | 342 +++++ .../dialogs/content/EdAdvancedEdit.xhtml | 182 +++ .../components/dialogs/content/EdButtonProps.js | 146 ++ .../components/dialogs/content/EdButtonProps.xhtml | 92 ++ .../components/dialogs/content/EdColorPicker.js | 297 ++++ .../components/dialogs/content/EdColorPicker.xhtml | 56 + .../components/dialogs/content/EdColorProps.js | 476 +++++++ .../components/dialogs/content/EdColorProps.xhtml | 134 ++ .../components/dialogs/content/EdConvertToTable.js | 326 +++++ .../dialogs/content/EdConvertToTable.xhtml | 43 + .../components/dialogs/content/EdDialogCommon.js | 1038 ++++++++++++++ .../components/dialogs/content/EdDialogTemplate.js | 45 + .../dialogs/content/EdDialogTemplate.xhtml | 23 + .../components/dialogs/content/EdDictionary.js | 164 +++ .../components/dialogs/content/EdDictionary.xhtml | 59 + .../components/dialogs/content/EdFieldSetProps.js | 196 +++ .../dialogs/content/EdFieldSetProps.xhtml | 67 + .../components/dialogs/content/EdFormProps.js | 136 ++ .../components/dialogs/content/EdFormProps.xhtml | 98 ++ .../components/dialogs/content/EdHLineProps.js | 227 +++ .../components/dialogs/content/EdHLineProps.xhtml | 80 ++ .../components/dialogs/content/EdImageDialog.js | 661 +++++++++ .../dialogs/content/EdImageLinkLoader.js | 145 ++ .../components/dialogs/content/EdImageProps.js | 293 ++++ .../components/dialogs/content/EdImageProps.xhtml | 116 ++ .../components/dialogs/content/EdInputImage.js | 189 +++ .../components/dialogs/content/EdInputImage.xhtml | 104 ++ .../components/dialogs/content/EdInputProps.js | 345 +++++ .../components/dialogs/content/EdInputProps.xhtml | 135 ++ .../editor/components/dialogs/content/EdInsSrc.js | 160 +++ .../components/dialogs/content/EdInsSrc.xhtml | 42 + .../components/dialogs/content/EdInsertChars.js | 409 ++++++ .../components/dialogs/content/EdInsertChars.xhtml | 55 + .../components/dialogs/content/EdInsertMath.js | 330 +++++ .../components/dialogs/content/EdInsertMath.xhtml | 60 + .../components/dialogs/content/EdInsertTOC.js | 378 +++++ .../components/dialogs/content/EdInsertTOC.xhtml | 225 +++ .../components/dialogs/content/EdInsertTable.js | 254 ++++ .../components/dialogs/content/EdInsertTable.xhtml | 82 ++ .../components/dialogs/content/EdLabelProps.js | 118 ++ .../components/dialogs/content/EdLabelProps.xhtml | 66 + .../components/dialogs/content/EdLinkProps.js | 331 +++++ .../components/dialogs/content/EdLinkProps.xhtml | 79 ++ .../components/dialogs/content/EdListProps.js | 455 +++++++ .../components/dialogs/content/EdListProps.xhtml | 73 + .../dialogs/content/EdNamedAnchorProps.js | 159 +++ .../dialogs/content/EdNamedAnchorProps.xhtml | 43 + .../components/dialogs/content/EdPageProps.js | 159 +++ .../components/dialogs/content/EdPageProps.xhtml | 50 + .../editor/components/dialogs/content/EdReplace.js | 382 ++++++ .../components/dialogs/content/EdReplace.xhtml | 65 + .../components/dialogs/content/EdSelectProps.js | 770 +++++++++++ .../components/dialogs/content/EdSelectProps.xhtml | 143 ++ .../components/dialogs/content/EdSnapToGrid.js | 62 + .../components/dialogs/content/EdSnapToGrid.xhtml | 47 + .../components/dialogs/content/EdSpellCheck.js | 495 +++++++ .../components/dialogs/content/EdSpellCheck.xhtml | 113 ++ .../components/dialogs/content/EdTableProps.js | 1439 ++++++++++++++++++++ .../components/dialogs/content/EdTableProps.xhtml | 287 ++++ .../components/dialogs/content/EdTextAreaProps.js | 171 +++ .../dialogs/content/EdTextAreaProps.xhtml | 115 ++ .../components/dialogs/content/EditConflict.js | 42 + .../components/dialogs/content/EditConflict.xhtml | 40 + .../components/dialogs/content/EditorPublish.js | 558 ++++++++ .../components/dialogs/content/EditorPublish.xhtml | 132 ++ .../dialogs/content/EditorPublishOverlay.xhtml | 66 + .../dialogs/content/EditorPublishProgress.js | 391 ++++++ .../dialogs/content/EditorPublishProgress.xhtml | 66 + .../dialogs/content/EditorPublishSettings.js | 343 +++++ .../dialogs/content/EditorPublishSettings.xhtml | 50 + .../dialogs/content/EditorSaveAsCharset.js | 155 +++ .../dialogs/content/EditorSaveAsCharset.xhtml | 46 + .../components/dialogs/content/edImage.inc.xhtml | 248 ++++ comm/suite/editor/components/dialogs/jar.mn | 82 ++ comm/suite/editor/components/dialogs/moz.build | 6 + comm/suite/editor/components/moz.build | 10 + .../prefs/content/editorPrefsOverlay.xhtml | 50 + .../components/prefs/content/pref-composer.xhtml | 84 ++ .../components/prefs/content/pref-editing.js | 187 +++ .../components/prefs/content/pref-editing.xhtml | 181 +++ comm/suite/editor/components/prefs/jar.mn | 11 + comm/suite/editor/components/prefs/moz.build | 6 + .../editor/components/texzilla/content/TeXZilla.js | 339 +++++ comm/suite/editor/components/texzilla/jar.mn | 6 + comm/suite/editor/components/texzilla/moz.build | 6 + 89 files changed, 18623 insertions(+) create mode 100644 comm/suite/editor/components/dialogs/content/EdAEAttributes.js create mode 100644 comm/suite/editor/components/dialogs/content/EdAECSSAttributes.js create mode 100644 comm/suite/editor/components/dialogs/content/EdAEHTMLAttributes.js create mode 100644 comm/suite/editor/components/dialogs/content/EdAEJSEAttributes.js create mode 100644 comm/suite/editor/components/dialogs/content/EdAdvancedEdit.js create mode 100644 comm/suite/editor/components/dialogs/content/EdAdvancedEdit.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdButtonProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdButtonProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdColorPicker.js create mode 100644 comm/suite/editor/components/dialogs/content/EdColorPicker.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdColorProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdColorProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdConvertToTable.js create mode 100644 comm/suite/editor/components/dialogs/content/EdConvertToTable.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdDialogCommon.js create mode 100644 comm/suite/editor/components/dialogs/content/EdDialogTemplate.js create mode 100644 comm/suite/editor/components/dialogs/content/EdDialogTemplate.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdDictionary.js create mode 100644 comm/suite/editor/components/dialogs/content/EdDictionary.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdFieldSetProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdFieldSetProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdFormProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdFormProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdHLineProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdHLineProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdImageDialog.js create mode 100755 comm/suite/editor/components/dialogs/content/EdImageLinkLoader.js create mode 100644 comm/suite/editor/components/dialogs/content/EdImageProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdImageProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdInputImage.js create mode 100644 comm/suite/editor/components/dialogs/content/EdInputImage.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdInputProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdInputProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdInsSrc.js create mode 100644 comm/suite/editor/components/dialogs/content/EdInsSrc.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdInsertChars.js create mode 100644 comm/suite/editor/components/dialogs/content/EdInsertChars.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdInsertMath.js create mode 100644 comm/suite/editor/components/dialogs/content/EdInsertMath.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdInsertTOC.js create mode 100644 comm/suite/editor/components/dialogs/content/EdInsertTOC.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdInsertTable.js create mode 100644 comm/suite/editor/components/dialogs/content/EdInsertTable.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdLabelProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdLabelProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdLinkProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdLinkProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdListProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdListProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdNamedAnchorProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdNamedAnchorProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdPageProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdPageProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdReplace.js create mode 100644 comm/suite/editor/components/dialogs/content/EdReplace.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdSelectProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdSelectProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdSnapToGrid.js create mode 100644 comm/suite/editor/components/dialogs/content/EdSnapToGrid.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdSpellCheck.js create mode 100644 comm/suite/editor/components/dialogs/content/EdSpellCheck.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdTableProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdTableProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EdTextAreaProps.js create mode 100644 comm/suite/editor/components/dialogs/content/EdTextAreaProps.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EditConflict.js create mode 100644 comm/suite/editor/components/dialogs/content/EditConflict.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EditorPublish.js create mode 100644 comm/suite/editor/components/dialogs/content/EditorPublish.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EditorPublishOverlay.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EditorPublishProgress.js create mode 100644 comm/suite/editor/components/dialogs/content/EditorPublishProgress.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EditorPublishSettings.js create mode 100644 comm/suite/editor/components/dialogs/content/EditorPublishSettings.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/EditorSaveAsCharset.js create mode 100644 comm/suite/editor/components/dialogs/content/EditorSaveAsCharset.xhtml create mode 100644 comm/suite/editor/components/dialogs/content/edImage.inc.xhtml create mode 100644 comm/suite/editor/components/dialogs/jar.mn create mode 100644 comm/suite/editor/components/dialogs/moz.build create mode 100644 comm/suite/editor/components/moz.build create mode 100644 comm/suite/editor/components/prefs/content/editorPrefsOverlay.xhtml create mode 100644 comm/suite/editor/components/prefs/content/pref-composer.xhtml create mode 100644 comm/suite/editor/components/prefs/content/pref-editing.js create mode 100644 comm/suite/editor/components/prefs/content/pref-editing.xhtml create mode 100644 comm/suite/editor/components/prefs/jar.mn create mode 100644 comm/suite/editor/components/prefs/moz.build create mode 100644 comm/suite/editor/components/texzilla/content/TeXZilla.js create mode 100644 comm/suite/editor/components/texzilla/jar.mn create mode 100644 comm/suite/editor/components/texzilla/moz.build (limited to 'comm/suite/editor/components') diff --git a/comm/suite/editor/components/dialogs/content/EdAEAttributes.js b/comm/suite/editor/components/dialogs/content/EdAEAttributes.js new file mode 100644 index 0000000000..52b7e30fac --- /dev/null +++ b/comm/suite/editor/components/dialogs/content/EdAEAttributes.js @@ -0,0 +1,973 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// HTML Attributes object for "Name" menulist +var gHTMLAttr = {}; + +// JS Events Attributes object for "Name" menulist +var gJSAttr = {}; + +// Core HTML attribute values // +// This is appended to Name menulist when "_core" is attribute name +var gCoreHTMLAttr = ["^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", + "ondblclick", + "onmousedown", + "onmouseup", + "onmouseover", + "onmousemove", + "onmouseout", + "-", + "onkeypress", + "onkeydown", + "onkeyup", +]; + +// Following are commonly-used strings + +// Also accept: sRGB: #RRGGBB // +var gHTMLColors = [ + "Aqua", + "Black", + "Blue", + "Fuchsia", + "Gray", + "Green", + "Lime", + "Maroon", + "Navy", + "Olive", + "Purple", + "Red", + "Silver", + "Teal", + "White", + "Yellow", +]; + +var gHAlign = ["left", "center", "right"]; + +var gHAlignJustify = ["left", "center", "right", "justify"]; + +var gHAlignTableContent = ["left", "center", "right", "justify", "char"]; + +var gVAlignTable = ["top", "middle", "bottom", "baseline"]; + +var gTarget = ["_blank", "_self", "_parent", "_top"]; + +// ================ 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 integer values and allow "+" or "-" as first character + "!" Allow only one character + "^" The first character can be only be A-Z, a-z, hyphen, underscore, colon or period + "$" 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", + "type", + "name", + "href", + "^hreflang", + "target", + "rel", + "rev", + "!accesskey", + "shape", // with imagemap // + "coords", // with imagemap // + "#tabindex", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.a_target = gTarget; + +gHTMLAttr.a_rel = [ + "alternate", + "stylesheet", + "start", + "next", + "prev", + "contents", + "index", + "glossary", + "copyright", + "chapter", + "section", + "subsection", + "appendix", + "help", + "bookmark", +]; + +gHTMLAttr.a_rev = [ + "alternate", + "stylesheet", + "start", + "next", + "prev", + "contents", + "index", + "glossary", + "copyright", + "chapter", + "section", + "subsection", + "appendix", + "help", + "bookmark", +]; + +gHTMLAttr.a_shape = ["rect", "circle", "poly", "default"]; + +gHTMLAttr.abbr = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.acronym = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.address = ["_core", "-", "^lang", "dir"]; + +// this is deprecated // +gHTMLAttr.applet = [ + "codebase", + "archive", + "code", + "object", + "alt", + "name", + "%$width", + "%$height", + "align", + "#hspace", + "#vspace", + "-", + "_core", +]; + +gHTMLAttr.applet_align = ["top", "middle", "bottom", "left", "right"]; + +gHTMLAttr.area = [ + "shape", + "coords", + "href", + "nohref", + "target", + "$alt", + "#tabindex", + "!accesskey", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.area_target = gTarget; + +gHTMLAttr.area_shape = ["rect", "circle", "poly", "default"]; + +gHTMLAttr.area_nohref = ["nohref"]; + +gHTMLAttr.b = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.base = ["href", "target"]; + +gHTMLAttr.base_target = gTarget; + +// this is deprecated // +gHTMLAttr.basefont = ["^id", "$size", "color", "face"]; + +gHTMLAttr.basefont_color = gHTMLColors; + +gHTMLAttr.bdo = ["_core", "-", "^lang", "$dir"]; + +gHTMLAttr.bdo_dir = ["ltr", "rtl"]; + +gHTMLAttr.big = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.blockquote = ["cite", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.body = [ + "background", + "bgcolor", + "text", + "link", + "vlink", + "alink", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.body_bgcolor = gHTMLColors; + +gHTMLAttr.body_text = gHTMLColors; + +gHTMLAttr.body_link = gHTMLColors; + +gHTMLAttr.body_vlink = gHTMLColors; + +gHTMLAttr.body_alink = gHTMLColors; + +gHTMLAttr.br = ["clear", "-", "_core"]; + +gHTMLAttr.br_clear = ["none", "left", "all", "right"]; + +gHTMLAttr.button = [ + "name", + "value", + "$type", + "disabled", + "#tabindex", + "!accesskey", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.button_type = ["submit", "button", "reset"]; + +gHTMLAttr.button_disabled = ["disabled"]; + +gHTMLAttr.caption = ["align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.caption_align = ["top", "bottom", "left", "right"]; + +// this is deprecated // +gHTMLAttr.center = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.cite = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.code = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.col = [ + "#$span", + "%width", + "align", + "!char", + "#charoff", + "valign", + "char", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.col_span = [ + "1", // default +]; + +gHTMLAttr.col_align = gHAlignTableContent; + +gHTMLAttr.col_valign = ["top", "middle", "bottom", "baseline"]; + +gHTMLAttr.colgroup = [ + "#$span", + "%width", + "align", + "!char", + "#charoff", + "valign", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.colgroup_span = [ + "1", // default +]; + +gHTMLAttr.colgroup_align = gHAlignTableContent; + +gHTMLAttr.colgroup_valign = ["top", "middle", "bottom", "baseline"]; + +gHTMLAttr.dd = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.del = ["cite", "datetime", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.dfn = ["_core", "-", "^lang", "dir"]; + +// this is deprecated // +gHTMLAttr.dir = ["compact", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.dir_compact = ["compact"]; + +gHTMLAttr.div = ["align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.div_align = gHAlignJustify; + +gHTMLAttr.dl = ["compact", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.dl_compact = ["compact"]; + +gHTMLAttr.dt = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.em = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.fieldset = ["_core", "-", "^lang", "dir"]; + +// this is deprecated // +gHTMLAttr.font = ["+size", "color", "face", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.font_color = gHTMLColors; + +gHTMLAttr.form = [ + "$action", + "$method", + "enctype", + "accept", + "name", + "accept-charset", + "target", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.form_method = ["get", "post"]; + +gHTMLAttr.form_enctype = ["application/x-www-form-urlencoded"]; + +gHTMLAttr.form_target = gTarget; + +gHTMLAttr.frame = [ + "longdesc", + "name", + "src", + "#frameborder", + "#marginwidth", + "#marginheight", + "noresize", + "$scrolling", +]; + +gHTMLAttr.frame_frameborder = ["1", "0"]; + +gHTMLAttr.frame_noresize = ["noresize"]; + +gHTMLAttr.frame_scrolling = ["auto", "yes", "no"]; + +gHTMLAttr.frameset = ["rows", "cols", "-", "_core"]; + +gHTMLAttr.h1 = ["align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.h1_align = gHAlignJustify; + +gHTMLAttr.h2 = ["align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.h2_align = gHAlignJustify; + +gHTMLAttr.h3 = ["align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.h3_align = gHAlignJustify; + +gHTMLAttr.h4 = ["align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.h4_align = gHAlignJustify; + +gHTMLAttr.h5 = ["align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.h5_align = gHAlignJustify; + +gHTMLAttr.h6 = ["align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.h6_align = gHAlignJustify; + +gHTMLAttr.head = ["profile", "-", "^lang", "dir"]; + +gHTMLAttr.hr = [ + "align", + "noshade", + "#size", + "%width", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.hr_align = gHAlign; + +gHTMLAttr.hr_noshade = ["noshade"]; + +gHTMLAttr.html = ["version", "-", "^lang", "dir"]; + +gHTMLAttr.i = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.iframe = [ + "longdesc", + "name", + "src", + "$frameborder", + "marginwidth", + "marginheight", + "$scrolling", + "align", + "%height", + "%width", + "-", + "_core", +]; + +gHTMLAttr.iframe_frameborder = ["1", "0"]; + +gHTMLAttr.iframe_scrolling = ["auto", "yes", "no"]; + +gHTMLAttr.iframe_align = ["top", "middle", "bottom", "left", "right"]; + +gHTMLAttr.img = [ + "$src", + "$alt", + "longdesc", + "name", + "%height", + "%width", + "usemap", + "ismap", + "align", + "#border", + "#hspace", + "#vspace", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.img_ismap = ["ismap"]; + +gHTMLAttr.img_align = ["top", "middle", "bottom", "left", "right"]; + +gHTMLAttr.input = [ + "$type", + "name", + "value", + "checked", + "disabled", + "readonly", + "#size", + "#maxlength", + "src", + "alt", + "usemap", + "ismap", + "#tabindex", + "!accesskey", + "accept", + "align", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.input_type = [ + "text", + "password", + "checkbox", + "radio", + "submit", + "reset", + "file", + "hidden", + "image", + "button", +]; + +gHTMLAttr.input_checked = ["checked"]; + +gHTMLAttr.input_disabled = ["disabled"]; + +gHTMLAttr.input_readonly = ["readonly"]; + +gHTMLAttr.input_ismap = ["ismap"]; + +gHTMLAttr.input_align = ["top", "middle", "bottom", "left", "right"]; + +gHTMLAttr.ins = ["cite", "datetime", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.isindex = ["prompt", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.kbd = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.label = ["for", "!accesskey", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.legend = ["!accesskey", "align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.legend_align = ["top", "bottom", "left", "right"]; + +gHTMLAttr.li = ["type", "#value", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.li_type = ["disc", "square", "circle", "-", "1", "a", "A", "i", "I"]; + +gHTMLAttr.link = [ + "charset", + "href", + "^hreflang", + "type", + "rel", + "rev", + "media", + "target", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.link_target = gTarget; + +gHTMLAttr.link_rel = [ + "alternate", + "stylesheet", + "start", + "next", + "prev", + "contents", + "index", + "glossary", + "copyright", + "chapter", + "section", + "subsection", + "appendix", + "help", + "bookmark", +]; + +gHTMLAttr.link_rev = [ + "alternate", + "stylesheet", + "start", + "next", + "prev", + "contents", + "index", + "glossary", + "copyright", + "chapter", + "section", + "subsection", + "appendix", + "help", + "bookmark", +]; + +gHTMLAttr.map = ["$name", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.menu = ["compact", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.menu_compact = ["compact"]; + +gHTMLAttr.meta = [ + "http-equiv", + "name", + "$content", + "scheme", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.noframes = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.noscript = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.object = [ + "declare", + "classid", + "codebase", + "data", + "type", + "codetype", + "archive", + "standby", + "%height", + "%width", + "usemap", + "name", + "#tabindex", + "align", + "#border", + "#hspace", + "#vspace", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.object_declare = ["declare"]; + +gHTMLAttr.object_align = ["top", "middle", "bottom", "left", "right"]; + +gHTMLAttr.ol = ["type", "compact", "#start", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.ol_type = ["1", "a", "A", "i", "I"]; + +gHTMLAttr.ol_compact = ["compact"]; + +gHTMLAttr.optgroup = ["disabled", "$label", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.optgroup_disabled = ["disabled"]; + +gHTMLAttr.option = [ + "selected", + "disabled", + "label", + "value", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.option_selected = ["selected"]; + +gHTMLAttr.option_disabled = ["disabled"]; + +gHTMLAttr.p = ["align", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.p_align = gHAlignJustify; + +gHTMLAttr.param = ["^id", "$name", "value", "$valuetype", "type"]; + +gHTMLAttr.param_valuetype = ["data", "ref", "object"]; + +gHTMLAttr.pre = ["%width", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.q = ["cite", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.s = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.samp = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.script = ["charset", "$type", "language", "src", "defer"]; + +gHTMLAttr.script_defer = ["defer"]; + +gHTMLAttr.select = [ + "name", + "#size", + "multiple", + "disabled", + "#tabindex", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.select_multiple = ["multiple"]; + +gHTMLAttr.select_disabled = ["disabled"]; + +gHTMLAttr.small = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.span = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.strike = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.strong = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.style = ["$type", "media", "title", "-", "^lang", "dir"]; + +gHTMLAttr.sub = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.sup = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.table = [ + "summary", + "%width", + "#border", + "frame", + "rules", + "#cellspacing", + "#cellpadding", + "align", + "bgcolor", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.table_frame = [ + "void", + "above", + "below", + "hsides", + "lhs", + "rhs", + "vsides", + "box", + "border", +]; + +gHTMLAttr.table_rules = ["none", "groups", "rows", "cols", "all"]; + +// Note; This is alignment of the table, +// not table contents, like all other table child elements +gHTMLAttr.table_align = gHAlign; + +gHTMLAttr.table_bgcolor = gHTMLColors; + +gHTMLAttr.tbody = [ + "align", + "!char", + "#charoff", + "valign", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.tbody_align = gHAlignTableContent; + +gHTMLAttr.tbody_valign = gVAlignTable; + +gHTMLAttr.td = [ + "abbr", + "axis", + "headers", + "scope", + "$#rowspan", + "$#colspan", + "align", + "!char", + "#charoff", + "valign", + "nowrap", + "bgcolor", + "%width", + "%height", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.td_scope = ["row", "col", "rowgroup", "colgroup"]; + +gHTMLAttr.td_rowspan = [ + "1", // default +]; + +gHTMLAttr.td_colspan = [ + "1", // default +]; + +gHTMLAttr.td_align = gHAlignTableContent; + +gHTMLAttr.td_valign = gVAlignTable; + +gHTMLAttr.td_nowrap = ["nowrap"]; + +gHTMLAttr.td_bgcolor = gHTMLColors; + +gHTMLAttr.textarea = [ + "name", + "$#rows", + "$#cols", + "disabled", + "readonly", + "#tabindex", + "!accesskey", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.textarea_disabled = ["disabled"]; + +gHTMLAttr.textarea_readonly = ["readonly"]; + +gHTMLAttr.tfoot = [ + "align", + "!char", + "#charoff", + "valign", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.tfoot_align = gHAlignTableContent; + +gHTMLAttr.tfoot_valign = gVAlignTable; + +gHTMLAttr.th = [ + "abbr", + "axis", + "headers", + "scope", + "$#rowspan", + "$#colspan", + "align", + "!char", + "#charoff", + "valign", + "nowrap", + "bgcolor", + "%width", + "%height", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.th_scope = ["row", "col", "rowgroup", "colgroup"]; + +gHTMLAttr.th_rowspan = [ + "1", // default +]; + +gHTMLAttr.th_colspan = [ + "1", // default +]; + +gHTMLAttr.th_align = gHAlignTableContent; + +gHTMLAttr.th_valign = gVAlignTable; + +gHTMLAttr.th_nowrap = ["nowrap"]; + +gHTMLAttr.th_bgcolor = gHTMLColors; + +gHTMLAttr.thead = [ + "align", + "!char", + "#charoff", + "valign", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.thead_align = gHAlignTableContent; + +gHTMLAttr.thead_valign = gVAlignTable; + +gHTMLAttr.title = ["^lang", "dir"]; + +gHTMLAttr.tr = [ + "align", + "!char", + "#charoff", + "valign", + "bgcolor", + "-", + "_core", + "-", + "^lang", + "dir", +]; + +gHTMLAttr.tr_align = gHAlignTableContent; + +gHTMLAttr.tr_valign = gVAlignTable; + +gHTMLAttr.tr_bgcolor = gHTMLColors; + +gHTMLAttr.tt = ["_core", "-", "^lang", "dir"]; + +gHTMLAttr.u = ["_core", "-", "^lang", "dir"]; +gHTMLAttr.ul = ["type", "compact", "-", "_core", "-", "^lang", "dir"]; + +gHTMLAttr.ul_type = ["disc", "square", "circle"]; + +gHTMLAttr.ul_compact = ["compact"]; + +// Prefix with "_" since this is reserved (it's stripped out) +gHTMLAttr._var = ["_core", "-", "^lang", "dir"]; + +// ================ JS Attributes ================ // +// These are element specific even handlers. +/* Most all elements use gCoreJSEvents, so those + are assumed except for those listed here with "noEvents" +*/ + +gJSAttr.a = ["onfocus", "onblur"]; + +gJSAttr.area = ["onfocus", "onblur"]; + +gJSAttr.body = ["onload", "onupload"]; + +gJSAttr.button = ["onfocus", "onblur"]; + +gJSAttr.form = ["onsubmit", "onreset"]; + +gJSAttr.frameset = ["onload", "onunload"]; + +gJSAttr.input = ["onfocus", "onblur", "onselect", "onchange"]; + +gJSAttr.label = ["onfocus", "onblur"]; + +gJSAttr.select = ["onfocus", "onblur", "onchange"]; + +gJSAttr.textarea = ["onfocus", "onblur", "onselect", "onchange"]; + +// Elements that don't have JSEvents: +gJSAttr.font = ["noJSEvents"]; + +gJSAttr.applet = ["noJSEvents"]; + +gJSAttr.isindex = ["noJSEvents"]; + +gJSAttr.iframe = ["noJSEvents"]; diff --git a/comm/suite/editor/components/dialogs/content/EdAECSSAttributes.js b/comm/suite/editor/components/dialogs/content/EdAECSSAttributes.js new file mode 100644 index 0000000000..977068bd70 --- /dev/null +++ b/comm/suite/editor/components/dialogs/content/EdAECSSAttributes.js @@ -0,0 +1,146 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* import-globals-from ../../composer/content/editorUtilities.js */ +/* import-globals-from EdAdvancedEdit.js */ +/* import-globals-from EdDialogCommon.js */ + +// build attribute list in tree form from element attributes +function BuildCSSAttributeTable() { + var style = gElement.style; + if (style == undefined) { + dump("Inline styles undefined\n"); + return; + } + + var declLength = style.length; + + if (declLength == undefined || declLength == 0) { + if (declLength == undefined) { + dump("Failed to query the number of inline style declarations\n"); + } + + return; + } + + if (declLength > 0) { + for (var i = 0; i < declLength; ++i) { + var name = style.item(i); + var value = style.getPropertyValue(name); + AddTreeItem(name, value, "CSSAList", CSSAttrs); + } + } + + ClearCSSInputWidgets(); +} + +function onChangeCSSAttribute() { + var name = TrimString(gDialog.AddCSSAttributeNameInput.value); + if (!name) { + return; + } + + var value = TrimString(gDialog.AddCSSAttributeValueInput.value); + + // First try to update existing attribute + // If not found, add new attribute + if (!UpdateExistingAttribute(name, value, "CSSAList") && value) { + AddTreeItem(name, value, "CSSAList", CSSAttrs); + } +} + +function ClearCSSInputWidgets() { + gDialog.AddCSSAttributeTree.view.selection.clearSelection(); + gDialog.AddCSSAttributeNameInput.value = ""; + gDialog.AddCSSAttributeValueInput.value = ""; + SetTextboxFocus(gDialog.AddCSSAttributeNameInput); +} + +function onSelectCSSTreeItem() { + if (!gDoOnSelectTree) { + return; + } + + var tree = gDialog.AddCSSAttributeTree; + if (tree && tree.view.selection.count) { + gDialog.AddCSSAttributeNameInput.value = GetTreeItemAttributeStr( + getSelectedItem(tree) + ); + gDialog.AddCSSAttributeValueInput.value = GetTreeItemValueStr( + getSelectedItem(tree) + ); + } +} + +function onInputCSSAttributeName() { + var attName = TrimString( + gDialog.AddCSSAttributeNameInput.value + ).toLowerCase(); + var newValue = ""; + + var existingValue = GetAndSelectExistingAttributeValue(attName, "CSSAList"); + if (existingValue) { + newValue = existingValue; + } + + gDialog.AddCSSAttributeValueInput.value = newValue; +} + +function editCSSAttributeValue(targetCell) { + if (IsNotTreeHeader(targetCell)) { + gDialog.AddCSSAttributeValueInput.inputField.select(); + } +} + +function UpdateCSSAttributes() { + var CSSAList = document.getElementById("CSSAList"); + var styleString = ""; + for (var i = 0; i < CSSAList.childNodes.length; i++) { + var item = CSSAList.childNodes[i]; + var name = GetTreeItemAttributeStr(item); + var value = GetTreeItemValueStr(item); + // this code allows users to be sloppy in typing in values, and enter + // things like "foo: " and "bar;". This will trim off everything after the + // respective character. + if (name.includes(":")) { + name = name.substring(0, name.lastIndexOf(":")); + } + if (value.includes(";")) { + value = value.substring(0, value.lastIndexOf(";")); + } + if (i == CSSAList.childNodes.length - 1) { + // Last property. + styleString += name + ": " + value + ";"; + } else { + styleString += name + ": " + value + "; "; + } + } + if (styleString) { + // Use editor transactions if modifying the element directly in the document + doRemoveAttribute("style"); + doSetAttribute("style", styleString); // NOTE BUG 18894!!! + } else if (gElement.getAttribute("style")) { + doRemoveAttribute("style"); + } +} + +function RemoveCSSAttribute() { + // We only allow 1 selected item + if (gDialog.AddCSSAttributeTree.view.selection.count) { + // Remove the item from the tree + // We always rebuild complete "style" string, + // so no list of "removed" items + getSelectedItem(gDialog.AddCSSAttributeTree).remove(); + + ClearCSSInputWidgets(); + } +} + +function SelectCSSTree(index) { + gDoOnSelectTree = false; + try { + gDialog.AddCSSAttributeTree.selectedIndex = index; + } catch (e) {} + gDoOnSelectTree = true; +} diff --git a/comm/suite/editor/components/dialogs/content/EdAEHTMLAttributes.js b/comm/suite/editor/components/dialogs/content/EdAEHTMLAttributes.js new file mode 100644 index 0000000000..1f96762754 --- /dev/null +++ b/comm/suite/editor/components/dialogs/content/EdAEHTMLAttributes.js @@ -0,0 +1,367 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* import-globals-from ../../composer/content/editorUtilities.js */ +/* import-globals-from EdAdvancedEdit.js */ +/* import-globals-from EdDialogCommon.js */ + +function BuildHTMLAttributeNameList() { + gDialog.AddHTMLAttributeNameInput.removeAllItems(); + + var elementName = gElement.localName; + var attNames = gHTMLAttr[elementName]; + + if (attNames && attNames.length) { + var menuitem; + + for (var i = 0; i < attNames.length; i++) { + var name = attNames[i]; + + if (name == "_core") { + // Signal to append the common 'core' attributes. + for (var j = 0; j < gCoreHTMLAttr.length; j++) { + name = gCoreHTMLAttr[j]; + + // only filtering rule used for core attributes as of 8-20-01 + // Add more rules if necessary. + if (name.includes("^")) { + name = name.replace(/\^/g, ""); + menuitem = gDialog.AddHTMLAttributeNameInput.appendItem(name, name); + menuitem.setAttribute("limitFirstChar", "true"); + } else { + gDialog.AddHTMLAttributeNameInput.appendItem(name, name); + } + } + } else if (name == "-") { + // Signal for separator + var popup = gDialog.AddHTMLAttributeNameInput.menupopup; + if (popup) { + var sep = document.createXULElement("menuseparator"); + if (sep) { + popup.appendChild(sep); + } + } + } else { + // Get information about value filtering + let forceOneChar = name.includes("!"); + let forceInteger = name.includes("#"); + let forceSignedInteger = name.includes("+"); + let forceIntOrPercent = name.includes("%"); + let limitFirstChar = name.includes("^"); + // let required = name.includes("$"); + + // Strip flag characters + name = name.replace(/[!^#%$+]/g, ""); + + menuitem = gDialog.AddHTMLAttributeNameInput.appendItem(name, name); + if (menuitem) { + // Signify "required" attributes by special style + // TODO: Don't do this until next version, when we add + // explanatory text and an 'Autofill Required Attributes' button + // if (required) + // menuitem.setAttribute("class", "menuitem-highlight-1"); + + // Set flags to filter value input + if (forceOneChar) { + menuitem.setAttribute("forceOneChar", "true"); + } + if (limitFirstChar) { + menuitem.setAttribute("limitFirstChar", "true"); + } + if (forceInteger) { + menuitem.setAttribute("forceInteger", "true"); + } + if (forceSignedInteger) { + menuitem.setAttribute("forceSignedInteger", "true"); + } + if (forceIntOrPercent) { + menuitem.setAttribute("forceIntOrPercent", "true"); + } + } + } + } + } +} + +// build attribute list in tree form from element attributes +function BuildHTMLAttributeTable() { + var nodeMap = gElement.attributes; + var i; + if (nodeMap.length > 0) { + var added = false; + for (i = 0; i < nodeMap.length; i++) { + let name = nodeMap[i].name.trim().toLowerCase(); + if ( + CheckAttributeNameSimilarity(nodeMap[i].nodeName, HTMLAttrs) || + name.startsWith("on") || + name == "style" + ) { + continue; // repeated or non-HTML attribute, ignore this one and go to next + } + if ( + !name.startsWith("_moz") && + AddTreeItem(name, nodeMap[i].value, "HTMLAList", HTMLAttrs) + ) { + added = true; + } + } + + if (added) { + SelectHTMLTree(0); + } + } +} + +function ClearHTMLInputWidgets() { + gDialog.AddHTMLAttributeTree.view.selection.clearSelection(); + gDialog.AddHTMLAttributeNameInput.value = ""; + gDialog.AddHTMLAttributeValueInput.value = ""; + SetTextboxFocus(gDialog.AddHTMLAttributeNameInput); +} + +function onSelectHTMLTreeItem() { + if (!gDoOnSelectTree) { + return; + } + + var tree = gDialog.AddHTMLAttributeTree; + if (tree && tree.view.selection.count) { + var inputName = TrimString( + gDialog.AddHTMLAttributeNameInput.value + ).toLowerCase(); + var selectedItem = getSelectedItem(tree); + var selectedName = selectedItem.firstChild.firstChild.getAttribute("label"); + + if (inputName == selectedName) { + // Already editing selected name - just update the value input + gDialog.AddHTMLAttributeValueInput.value = GetTreeItemValueStr( + selectedItem + ); + } else { + gDialog.AddHTMLAttributeNameInput.value = selectedName; + + // Change value input based on new selected name + onInputHTMLAttributeName(); + } + } +} + +function onInputHTMLAttributeName() { + let attName = gDialog.AddHTMLAttributeNameInput.value.toLowerCase().trim(); + + // Clear value widget, but prevent triggering update in tree + gUpdateTreeValue = false; + gDialog.AddHTMLAttributeValueInput.value = ""; + gUpdateTreeValue = true; + + if (attName) { + // Get value list for current attribute name + 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 + "_" + attName; + } + + // Strip off leading "_" we sometimes use (when element name is reserved word) + if (valueListName.startsWith("_")) { + valueListName = valueListName.slice(1); + } + + var newValue = ""; + var listLen = 0; + + // Index to which widget we were using to edit the value + var deckIndex = gDialog.AddHTMLAttributeValueDeck.getAttribute( + "selectedIndex" + ); + + if (valueListName in gHTMLAttr) { + var valueList = gHTMLAttr[valueListName]; + + listLen = valueList.length; + if (listLen == 1) { + newValue = valueList[0]; + } + + // Note: For case where "value list" is actually just + // one (default) item, don't use menulist for that + if (listLen > 1) { + gDialog.AddHTMLAttributeValueMenulist.removeAllItems(); + + if (deckIndex != "1") { + // Switch to using editable menulist + gDialog.AddHTMLAttributeValueInput = + gDialog.AddHTMLAttributeValueMenulist; + gDialog.AddHTMLAttributeValueDeck.setAttribute("selectedIndex", "1"); + } + // Rebuild the list + for (var i = 0; i < listLen; i++) { + if (valueList[i] == "-") { + // Signal for separator + var popup = gDialog.AddHTMLAttributeValueInput.menupopup; + if (popup) { + var sep = document.createXULElement("menuseparator"); + if (sep) { + popup.appendChild(sep); + } + } + } else { + gDialog.AddHTMLAttributeValueMenulist.appendItem( + valueList[i], + valueList[i] + ); + } + } + } + } + + if (listLen <= 1 && deckIndex != "0") { + // No list: Use textbox for input instead + gDialog.AddHTMLAttributeValueInput = gDialog.AddHTMLAttributeValueTextbox; + gDialog.AddHTMLAttributeValueDeck.setAttribute("selectedIndex", "0"); + } + + // If attribute already exists in tree, use associated value, + // else use default found above + var existingValue = GetAndSelectExistingAttributeValue( + attName, + "HTMLAList" + ); + if (existingValue) { + newValue = existingValue; + } + + gDialog.AddHTMLAttributeValueInput.value = newValue; + + if (!existingValue) { + onInputHTMLAttributeValue(); + } + } +} + +function onInputHTMLAttributeValue() { + if (!gUpdateTreeValue) { + return; + } + + var name = TrimString(gDialog.AddHTMLAttributeNameInput.value); + if (!name) { + return; + } + + // Trim spaces only from left since we must allow spaces within the string + // (we always reset the input field's value below) + var value = TrimStringLeft(gDialog.AddHTMLAttributeValueInput.value); + if (value) { + // Do value filtering based on type of attribute + // (Do not use "forceInteger()" to avoid multiple + // resetting of input's value and flickering) + var selectedItem = gDialog.AddHTMLAttributeNameInput.selectedItem; + + if (selectedItem) { + if ( + selectedItem.getAttribute("forceOneChar") == "true" && + value.length > 1 + ) { + value = value.slice(0, 1); + } + + if (selectedItem.getAttribute("forceIntOrPercent") == "true") { + // Allow integer with optional "%" as last character + var percent = TrimStringRight(value).slice(-1); + value = value.replace(/\D+/g, ""); + if (percent == "%") { + value += percent; + } + } else if (selectedItem.getAttribute("forceInteger") == "true") { + value = value.replace(/\D+/g, ""); + } else if (selectedItem.getAttribute("forceSignedInteger") == "true") { + // Allow integer with optional "+" or "-" as first character + var sign = value[0]; + value = value.replace(/\D+/g, ""); + if (sign == "+" || sign == "-") { + value = sign + value; + } + } + + // Special case attributes + if (selectedItem.getAttribute("limitFirstChar") == "true") { + // Limit first character to letter, and all others to + // letters, numbers, and a few others + value = value + .replace(/^[^a-zA-Z\u0080-\uFFFF]/, "") + .replace(/[^a-zA-Z0-9_\.\-\:\u0080-\uFFFF]+/g, ""); + } + + // Update once only if it changed + if (value != gDialog.AddHTMLAttributeValueInput.value) { + gDialog.AddHTMLAttributeValueInput.value = value; + } + } + } + + // Update value in the tree list + // If not found, add new attribute + if (!UpdateExistingAttribute(name, value, "HTMLAList") && value) { + AddTreeItem(name, value, "HTMLAList", HTMLAttrs); + } +} + +function editHTMLAttributeValue(targetCell) { + if (IsNotTreeHeader(targetCell)) { + gDialog.AddHTMLAttributeValueInput.select(); + } +} + +// update the object with added and removed attributes +function UpdateHTMLAttributes() { + var HTMLAList = document.getElementById("HTMLAList"); + var i; + + // remove removed attributes + for (i = 0; i < HTMLRAttrs.length; i++) { + var name = HTMLRAttrs[i]; + + if (gElement.hasAttribute(name)) { + doRemoveAttribute(name); + } + } + + // Set added or changed attributes + for (i = 0; i < HTMLAList.childNodes.length; i++) { + var item = HTMLAList.childNodes[i]; + doSetAttribute(GetTreeItemAttributeStr(item), GetTreeItemValueStr(item)); + } +} + +function RemoveHTMLAttribute() { + // We only allow 1 selected item + if (gDialog.AddHTMLAttributeTree.view.selection.count) { + var item = getSelectedItem(gDialog.AddHTMLAttributeTree); + var attr = GetTreeItemAttributeStr(item); + + // remove the item from the attribute array + HTMLRAttrs[HTMLRAttrs.length] = attr; + RemoveNameFromAttArray(attr, HTMLAttrs); + + // Remove the item from the tree + item.remove(); + + // Clear inputs and selected item in tree + ClearHTMLInputWidgets(); + } +} + +function SelectHTMLTree(index) { + gDoOnSelectTree = false; + try { + gDialog.AddHTMLAttributeTree.selectedIndex = index; + } catch (e) {} + gDoOnSelectTree = true; +} diff --git a/comm/suite/editor/components/dialogs/content/EdAEJSEAttributes.js b/comm/suite/editor/components/dialogs/content/EdAEJSEAttributes.js new file mode 100644 index 0000000000..c15c938b3e --- /dev/null +++ b/comm/suite/editor/components/dialogs/content/EdAEJSEAttributes.js @@ -0,0 +1,200 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* import-globals-from ../../composer/content/editorUtilities.js */ +/* import-globals-from EdAdvancedEdit.js */ +/* import-globals-from EdDialogCommon.js */ + +function BuildJSEAttributeNameList() { + gDialog.AddJSEAttributeNameList.removeAllItems(); + + // Get events specific to current element + var elementName = gElement.localName; + if (elementName in gJSAttr) { + var attNames = gJSAttr[elementName]; + var i; + var popup; + var sep; + + if (attNames && attNames.length) { + // 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.remove(); + } + + return; + } + + for (i = 0; i < attNames.length; i++) { + gDialog.AddJSEAttributeNameList.appendItem(attNames[i], attNames[i]); + } + + popup = gDialog.AddJSEAttributeNameList.firstChild; + if (popup) { + sep = document.createXULElement("menuseparator"); + if (sep) { + popup.appendChild(sep); + } + } + } + } + + // Always add core JS events unless we aborted above + for (i = 0; i < gCoreJSEvents.length; i++) { + if (gCoreJSEvents[i] == "-") { + if (!popup) { + popup = gDialog.AddJSEAttributeNameList.firstChild; + } + + sep = document.createXULElement("menuseparator"); + + if (popup && sep) { + popup.appendChild(sep); + } + } else { + gDialog.AddJSEAttributeNameList.appendItem( + gCoreJSEvents[i], + gCoreJSEvents[i] + ); + } + } + + gDialog.AddJSEAttributeNameList.selectedIndex = 0; + + // Use current name and value of first tree item if it exists + onSelectJSETreeItem(); +} + +// build attribute list in tree form from element attributes +function BuildJSEAttributeTable() { + var nodeMap = gElement.attributes; + if (nodeMap.length > 0) { + var added = false; + for (var i = 0; i < nodeMap.length; i++) { + let name = nodeMap[i].nodeName.toLowerCase(); + if (CheckAttributeNameSimilarity(nodeMap[i].nodeName, JSEAttrs)) { + // Repeated or non-JS handler, ignore this one and go to next. + continue; + } + if (!name.startsWith("on")) { + // Attribute isn't an event handler. + continue; + } + var value = gElement.getAttribute(nodeMap[i].nodeName); + if (AddTreeItem(name, value, "JSEAList", JSEAttrs)) { + // add item to tree + added = true; + } + } + + // Select first item + if (added) { + gDialog.AddJSEAttributeTree.selectedIndex = 0; + } + } +} + +function onSelectJSEAttribute() { + if (!gDoOnSelectTree) { + return; + } + + gDialog.AddJSEAttributeValueInput.value = GetAndSelectExistingAttributeValue( + gDialog.AddJSEAttributeNameList.label, + "JSEAList" + ); +} + +function onSelectJSETreeItem() { + var tree = gDialog.AddJSEAttributeTree; + if (tree && tree.view.selection.count) { + // Select attribute name in list + gDialog.AddJSEAttributeNameList.value = GetTreeItemAttributeStr( + getSelectedItem(tree) + ); + + // Set value input to that in tree (no need to update this in the tree) + gUpdateTreeValue = false; + gDialog.AddJSEAttributeValueInput.value = GetTreeItemValueStr( + getSelectedItem(tree) + ); + gUpdateTreeValue = true; + } +} + +function onInputJSEAttributeValue() { + if (gUpdateTreeValue) { + var name = TrimString(gDialog.AddJSEAttributeNameList.label); + var value = TrimString(gDialog.AddJSEAttributeValueInput.value); + + // Update value in the tree list + // Since we have a non-editable menulist, + // we MUST automatically add the event attribute if it doesn't exist + if (!UpdateExistingAttribute(name, value, "JSEAList") && value) { + AddTreeItem(name, value, "JSEAList", JSEAttrs); + } + } +} + +function editJSEAttributeValue(targetCell) { + if (IsNotTreeHeader(targetCell)) { + gDialog.AddJSEAttributeValueInput.inputField.select(); + } +} + +function UpdateJSEAttributes() { + var JSEAList = document.getElementById("JSEAList"); + var i; + + // remove removed attributes + for (i = 0; i < JSERAttrs.length; i++) { + var name = JSERAttrs[i]; + + if (gElement.hasAttribute(name)) { + doRemoveAttribute(name); + } + } + + // Add events + for (i = 0; i < JSEAList.childNodes.length; i++) { + var item = JSEAList.childNodes[i]; + + // set the event handler + doSetAttribute(GetTreeItemAttributeStr(item), GetTreeItemValueStr(item)); + } +} + +function RemoveJSEAttribute() { + // This differs from HTML and CSS panels: + // We reselect after removing, because there is not + // editable attribute name input, so we can't clear that + // like we do in other panels + var newIndex = gDialog.AddJSEAttributeTree.selectedIndex; + + // We only allow 1 selected item + if (gDialog.AddJSEAttributeTree.view.selection.count) { + var item = getSelectedItem(gDialog.AddJSEAttributeTree); + + // Name is the text of the treecell + var attr = GetTreeItemAttributeStr(item); + + // remove the item from the attribute array + if (newIndex >= JSEAttrs.length - 1) { + newIndex--; + } + + // remove the item from the attribute array + JSERAttrs[JSERAttrs.length] = attr; + RemoveNameFromAttArray(attr, JSEAttrs); + + // Remove the item from the tree + item.remove(); + + // Reselect an item + gDialog.AddJSEAttributeTree.selectedIndex = newIndex; + } +} diff --git a/comm/suite/editor/components/dialogs/content/EdAdvancedEdit.js b/comm/suite/editor/components/dialogs/content/EdAdvancedEdit.js new file mode 100644 index 0000000000..60e9009905 --- /dev/null +++ b/comm/suite/editor/components/dialogs/content/EdAdvancedEdit.js @@ -0,0 +1,342 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* import-globals-from ../../composer/content/editorUtilities.js */ +/* import-globals-from EdAEAttributes.js */ +/* import-globals-from EdAECSSAttributes.js */ +/* import-globals-from EdAEHTMLAttributes.js */ +/* import-globals-from EdAEJSEAttributes.js */ +/* import-globals-from EdDialogCommon.js */ + +/** ************ GLOBALS **************/ +var gElement = null; // handle to actual element edited + +var HTMLAttrs = []; // html attributes +var CSSAttrs = []; // css attributes +var JSEAttrs = []; // js events + +var HTMLRAttrs = []; // removed html attributes +var JSERAttrs = []; // removed js events + +/* Set false to allow changing selection in tree + without doing "onselect" handler actions +*/ +var gDoOnSelectTree = true; +var gUpdateTreeValue = true; + +/** ************ INITIALISATION && SETUP **************/ + +document.addEventListener("dialogaccept", onAccept); +document.addEventListener("dialogcancel", onCancel); + +/** + * function : void Startup(); + * parameters : none + * returns : none + * desc. : startup and initialisation, prepares dialog. + **/ +function Startup() { + var editor = GetCurrentEditor(); + + // Element to edit is passed in + if (!editor || !window.arguments[1]) { + dump("Advanced Edit: No editor or element to edit not supplied\n"); + window.close(); + return; + } + // This is the return value for the parent, + // who only needs to know if OK was clicked + window.opener.AdvancedEditOK = false; + + // The actual element edited (not a copy!) + gElement = window.arguments[1]; + + // place the tag name in the header + var tagLabel = document.getElementById("tagLabel"); + tagLabel.setAttribute("value", "<" + gElement.localName + ">"); + + // Create dialog object to store controls for easy access + gDialog.AddHTMLAttributeNameInput = document.getElementById( + "AddHTMLAttributeNameInput" + ); + + // We use a to switch between editable menulist and textbox + gDialog.AddHTMLAttributeValueDeck = document.getElementById( + "AddHTMLAttributeValueDeck" + ); + gDialog.AddHTMLAttributeValueMenulist = document.getElementById( + "AddHTMLAttributeValueMenulist" + ); + gDialog.AddHTMLAttributeValueTextbox = document.getElementById( + "AddHTMLAttributeValueTextbox" + ); + gDialog.AddHTMLAttributeValueInput = gDialog.AddHTMLAttributeValueTextbox; + + gDialog.AddHTMLAttributeTree = document.getElementById("HTMLATree"); + gDialog.AddCSSAttributeNameInput = document.getElementById( + "AddCSSAttributeNameInput" + ); + gDialog.AddCSSAttributeValueInput = document.getElementById( + "AddCSSAttributeValueInput" + ); + gDialog.AddCSSAttributeTree = document.getElementById("CSSATree"); + gDialog.AddJSEAttributeNameList = document.getElementById( + "AddJSEAttributeNameList" + ); + gDialog.AddJSEAttributeValueInput = document.getElementById( + "AddJSEAttributeValueInput" + ); + gDialog.AddJSEAttributeTree = document.getElementById("JSEATree"); + gDialog.okButton = document.documentElement.getButton("accept"); + + // build the attribute trees + BuildHTMLAttributeTable(); + BuildCSSAttributeTable(); + BuildJSEAttributeTable(); + + // Build attribute name arrays for menulists + BuildJSEAttributeNameList(); + BuildHTMLAttributeNameList(); + // No menulists for CSS panel (yet) + + // Set focus to Name editable menulist in HTML panel + SetTextboxFocus(gDialog.AddHTMLAttributeNameInput); + + // size the dialog properly + window.sizeToContent(); + + SetWindowLocation(); +} + +/** + * function : bool onAccept ( void ); + * parameters : none + * returns : boolean true to close the window + * desc. : event handler for ok button + **/ +function onAccept() { + var editor = GetCurrentEditor(); + editor.beginTransaction(); + try { + // Update our gElement attributes + UpdateHTMLAttributes(); + UpdateCSSAttributes(); + UpdateJSEAttributes(); + } catch (ex) { + dump(ex); + } + editor.endTransaction(); + + window.opener.AdvancedEditOK = true; + SaveWindowLocation(); +} + +// Helpers for removing and setting attributes +// Use editor transactions if modifying the element already in the document +// (Temporary element from a property dialog won't have a parent node) +function doRemoveAttribute(attrib) { + try { + var editor = GetCurrentEditor(); + if (gElement.parentNode) { + editor.removeAttribute(gElement, attrib); + } else { + gElement.removeAttribute(attrib); + } + } catch (ex) {} +} + +function doSetAttribute(attrib, value) { + try { + var editor = GetCurrentEditor(); + if (gElement.parentNode) { + editor.setAttribute(gElement, attrib, value); + } else { + gElement.setAttribute(attrib, value); + } + } catch (ex) {} +} + +/** + * function : bool CheckAttributeNameSimilarity ( string attName, array attArray ); + * parameters : attribute to look for, array of current attributes + * returns : true if attribute already exists, false if it does not + * desc. : checks to see if any other attributes by the same name as the arg supplied + * already exist. + **/ +function CheckAttributeNameSimilarity(attName, attArray) { + for (var i = 0; i < attArray.length; i++) { + if (attName.toLowerCase() == attArray[i].toLowerCase()) { + return true; + } + } + return false; +} + +/** + * function : bool UpdateExistingAttribute ( string attName, string attValue, string treeChildrenId ); + * parameters : attribute to look for, new value, ID of node in XUL tree + * returns : true if attribute already exists in tree, false if it does not + * desc. : checks to see if any other attributes by the same name as the arg supplied + * already exist while setting the associated value if different from current value + **/ +function UpdateExistingAttribute(attName, attValue, treeChildrenId) { + var treeChildren = document.getElementById(treeChildrenId); + if (!treeChildren) { + return false; + } + + var name; + var i; + attName = TrimString(attName).toLowerCase(); + attValue = TrimString(attValue); + + for (i = 0; i < treeChildren.childNodes.length; i++) { + var item = treeChildren.childNodes[i]; + name = GetTreeItemAttributeStr(item); + if (name.toLowerCase() == attName) { + // Set the text in the "value' column treecell + SetTreeItemValueStr(item, attValue); + + // Select item just changed, + // but don't trigger the tree's onSelect handler + gDoOnSelectTree = false; + try { + selectTreeItem(treeChildren, item); + } catch (e) {} + gDoOnSelectTree = true; + + return true; + } + } + return false; +} + +/** + * function : string GetAndSelectExistingAttributeValue ( string attName, string treeChildrenId ); + * parameters : attribute to look for, ID of node in XUL tree + * returns : value in from the tree or empty string if name not found + **/ +function GetAndSelectExistingAttributeValue(attName, treeChildrenId) { + if (!attName) { + return ""; + } + + var treeChildren = document.getElementById(treeChildrenId); + var name; + var i; + + for (i = 0; i < treeChildren.childNodes.length; i++) { + var item = treeChildren.childNodes[i]; + name = GetTreeItemAttributeStr(item); + if (name.toLowerCase() == attName.toLowerCase()) { + // Select item in the tree + // but don't trigger the tree's onSelect handler + gDoOnSelectTree = false; + try { + selectTreeItem(treeChildren, item); + } catch (e) {} + gDoOnSelectTree = true; + + // Get the text in the "value' column treecell + return GetTreeItemValueStr(item); + } + } + + // Attribute doesn't exist in tree, so remove selection + gDoOnSelectTree = false; + try { + treeChildren.parentNode.view.selection.clearSelection(); + } catch (e) {} + gDoOnSelectTree = true; + + return ""; +} + +/* Tree structure: + + + // Name Cell + + + + + + + + + + + + + + + +