From 9899a865e9664e880aa7a99a268fe5aa8aafd24b Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Wed, 13 Jun 2001 01:04:39 +0000 Subject: [PATCH] New Advanced Properties Editor UI. Fixes bugs 71743, 71973, 71027, 73167. Fix is shown on 71743, r=brade, sr=kin, a=asa-drivers git-svn-id: svn://10.0.0.236/trunk@97019 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/jar.mn | 1 + .../composer/locale/en-US/editor.properties | 3 - .../ui/dialogs/content/EdAEAttributes.js | 1746 +++++++++++++++++ .../ui/dialogs/content/EdAECSSAttributes.js | 172 +- .../ui/dialogs/content/EdAEHTMLAttributes.js | 339 +++- .../ui/dialogs/content/EdAEJSEAttributes.js | 213 +- .../ui/dialogs/content/EdAdvancedEdit.js | 385 ++-- .../ui/dialogs/content/EdAdvancedEdit.xul | 125 +- .../ui/dialogs/content/EdDialogCommon.js | 18 +- mozilla/editor/ui/dialogs/content/MANIFEST | 1 + .../editor/ui/dialogs/content/makefile.win | 1 + .../dialogs/locale/en-US/EdAdvancedEdit.dtd | 12 +- 12 files changed, 2603 insertions(+), 413 deletions(-) create mode 100644 mozilla/editor/ui/dialogs/content/EdAEAttributes.js diff --git a/mozilla/editor/jar.mn b/mozilla/editor/jar.mn index fa1192ebdbb..b5ef5244f92 100644 --- a/mozilla/editor/jar.mn +++ b/mozilla/editor/jar.mn @@ -178,6 +178,7 @@ comm.jar: content/editor/EdAECSSAttributes.js (ui/dialogs/content/EdAECSSAttributes.js) content/editor/EdAEHTMLAttributes.js (ui/dialogs/content/EdAEHTMLAttributes.js) content/editor/EdAEJSEAttributes.js (ui/dialogs/content/EdAEJSEAttributes.js) + content/editor/EdAEAttributes.js (ui/dialogs/content/EdAEAttributes.js) content/editor/EdImageMap.js (ui/dialogs/content/EdImageMap.js) content/editor/EdImageMap.xul (ui/dialogs/content/EdImageMap.xul) content/editor/EdImageMapHotSpot.js (ui/dialogs/content/EdImageMapHotSpot.js) diff --git a/mozilla/editor/ui/composer/locale/en-US/editor.properties b/mozilla/editor/ui/composer/locale/en-US/editor.properties index 4b5acfd8f8d..c0e97f08368 100644 --- a/mozilla/editor/ui/composer/locale/en-US/editor.properties +++ b/mozilla/editor/ui/composer/locale/en-US/editor.properties @@ -159,8 +159,5 @@ RemoveLinks=Remove Links StopLinks=Discontinue Link # NoAltText=It is recommended that you supply alternate text that will appear in text-only browsers, and that will appear in other browsers when an image is loading or when image loading is disabled. -NoAlignChar=No alignment character supplied.\nEnter a single character or\nselect a different alignment style. SaveImageAs=Save Image (%NAME%)... -Add=Add -Set=Set NoSeparatorCharacter=Please enter a single character to use for separating into columns diff --git a/mozilla/editor/ui/dialogs/content/EdAEAttributes.js b/mozilla/editor/ui/dialogs/content/EdAEAttributes.js new file mode 100644 index 00000000000..83da18e560b --- /dev/null +++ b/mozilla/editor/ui/dialogs/content/EdAEAttributes.js @@ -0,0 +1,1746 @@ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998-2001 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Beth Epperson + */ + + +// 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 +var gCoreJSEvents = +[ + "onclick", + "ondblclick", + "onmousedown", + "onmouseup", + "onmouseover", + "onmousemove", + "onmouseout", + "-", + "onkeypress", + "onkeydown", + "onkeyup" +]; + +// Following are commonly-used strings + +// Alse accept: sRGB: #RRGGBB // +var gHTMLColors = +[ + "Black", + "Green", + "Silver", + "Lime", + "Gray", + "Olive", + "White", + "Yellow", + "Maroon", + "Navy", + "Red", + "Blue", + "Purple", + "Teal", + "Fuchsia", + "Aqua" +]; + +var gHAlign = +[ + "left", + "center", + "right" +]; + +var gHAlignJustify = +[ + "left", + "center", + "right", + "justify" +]; + +var gHAlignTableContent = +[ + "left", + "center", + "right", + "justify", + "char" +]; + +var gVAlignTable = +[ + "top", + "middle", + "bottom", + "baseline" +]; + +// ================ HTML Attributes ================ // +gHTMLAttr.a = +[ + "charset", + "type", + "name", + "href", + "hreflang", + "target", + "rel", + "rev", + "!accesskey", + "shape", // with imagemap // + "coords", // with imagemap // + "#tabindex", + "-", + "_core", + "-", + "lang", + "dir" +]; + +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_shape = +[ + "rect", + "circle", + "poly", + "default" +]; + +gHTMLAttr.area_nohref = +[ + "nohref" +]; + +gHTMLAttr.b = +[ + "_core", + "-", + "lang", + "dir" +]; + +gHTMLAttr.base = +[ + "href", + "target" +]; + +// this is deprecated // +gHTMLAttr.basefont = +[ + "id", + "$size", + "color", + "face" +]; + +gHTMLAttr.basefont_color = gHTMLColors; + +gHTMLAttr.bdo = +[ + "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_background = gHTMLColors; + +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" +]; + +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.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.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_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 specif even handlers. +// All elements use gCoreJSEvents + +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" +]; + diff --git a/mozilla/editor/ui/dialogs/content/EdAECSSAttributes.js b/mozilla/editor/ui/dialogs/content/EdAECSSAttributes.js index 3f5795388c0..c641a4370dd 100644 --- a/mozilla/editor/ui/dialogs/content/EdAECSSAttributes.js +++ b/mozilla/editor/ui/dialogs/content/EdAECSSAttributes.js @@ -1,21 +1,40 @@ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998-1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Ben "Count XULula" Goodger + */ // build attribute list in tree form from element attributes function BuildCSSAttributeTable() { - // dump("populating CSS Attributes tree\n"); - // dump(" style=\"" + element.getAttribute("style") + "\"\n"); - // get the CSS declaration from DOM 2 ElementCSSInlineStyle - var style = element.style; + var style = gElement.style; - if(style == undefined) + if (style == undefined) { dump("Inline styles undefined\n"); return; } var l = style.length; - if(l == undefined || l == 0) + if (l == undefined || l == 0) { if (l == undefined) { dump("Failed to query the number of inline style declarations\n"); @@ -23,76 +42,135 @@ function BuildCSSAttributeTable() return; } - for (i = 0; i < l; i++) { - name = style.item(i); - value = style.getPropertyValue(name); - // dump(" adding property '" + name + "' with value '" + value +"'\n"); - if ( !AddTreeItem( name, value, "CSSAList", CSSAttrs ) ) - dump("Failed to add CSS attribute: " + i + "\n"); + if (l > 0) + { + var added = false; + for (i = 0; i < l; i++) + { + name = style.item(i); + value = style.getPropertyValue(name); + AddTreeItem( name, value, "CSSAList", CSSAttrs ); + } } - return; + + ClearCSSInputWidgets(); } -// add an attribute to the tree widget -function onAddCSSAttribute() +// add or select attribute in the tree widget +function onChangeCSSAttribute() { - var which = document.getElementById("AddCSSAttribute"); - if(!which || which.getAttribute ( "disabled" ) ) + var name = TrimString(dialog.AddCSSAttributeNameInput.value); + if ( !name ) return; - var name = dialog.AddCSSAttributeNameInput.value; var value = TrimString(dialog.AddCSSAttributeValueInput.value); - if(!name || !CheckAttributeNameSimilarity( name, CSSAttrs ) ) - return; - - if ( AddTreeItem ( name, value, "CSSAList", CSSAttrs ) ) { - dialog.AddCSSAttributeNameInput.value = ""; - dialog.AddCSSAttributeValueInput.value = ""; - } - dialog.AddCSSAttributeNameInput.focus(); - doCSSEnabling(); + // First try to update existing attribute + // If not found, add new attribute + if ( !UpdateExistingAttribute( name, value, "CSSAList" ) ) + AddTreeItem( name, value, "CSSAList", CSSAttrs ); } -// does enabling based on any user input. -function doCSSEnabling() +function ClearCSSInputWidgets() { - var name = TrimString(dialog.AddCSSAttributeNameInput.value).toLowerCase(); - if( !name || !CheckAttributeNameSimilarity(name,CSSAttrs)) - dialog.AddCSSAttribute.setAttribute("disabled","true"); - else - dialog.AddCSSAttribute.removeAttribute("disabled"); + dialog.AddCSSAttributeTree.clearItemSelection(); + dialog.AddCSSAttributeNameInput.value =""; + dialog.AddCSSAttributeValueInput.value = ""; + dialog.AddCSSAttributeNameInput.inputField.focus(); +} + +function onSelectCSSTreeItem() +{ + if (!gDoOnSelectTree) + return; + + var tree = dialog.AddCSSAttributeTree; + if (tree && tree.selectedItems && tree.selectedItems.length) + { + dialog.AddCSSAttributeNameInput.value = GetTreeItemAttributeStr(tree.selectedItems[0]); + dialog.AddCSSAttributeValueInput.value = GetTreeItemValueStr(tree.selectedItems[0]); + } +} + +function onInputCSSAttributeName() +{ + var attName = TrimString(dialog.AddCSSAttributeNameInput.value).toLowerCase(); + var newValue = ""; + + var existingValue = GetAndSelectExistingAttributeValue(attName, "CSSAList"); + if (existingValue) + newValue = existingValue; + + dialog.AddCSSAttributeValueInput.value = newValue; +} + +function onInputCSSAttributeValue() +{ + // Update value in the tree list + UpdateExistingAttribute( dialog.AddCSSAttributeNameInput.value, + dialog.AddCSSAttributeValueInput.value, + "CSSAList" ); +} + +function editCSSAttributeValue(targetCell) +{ + if (IsNotTreeHeader(targetCell)) + dialog.AddCSSAttributeValueInput.inputField.select(); } function UpdateCSSAttributes() { - dump("===============[ Setting and Updating STYLE ]===============\n"); var CSSAList = document.getElementById("CSSAList"); var styleString = ""; for(var i = 0; i < CSSAList.childNodes.length; i++) { var item = CSSAList.childNodes[i]; - var name = TrimString(item.firstChild.firstChild.getAttribute("label")); - var value = TrimString(item.firstChild.lastChild.firstChild.value); + 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.indexOf(":") != -1) + if (name.indexOf(":") != -1) name = name.substring(0,name.lastIndexOf(":")); - if(value.indexOf(";") != -1) + if (value.indexOf(";") != -1) value = value.substring(0,value.lastIndexOf(";")); - if(i == (CSSAList.childNodes.length - 1)) + if (i == (CSSAList.childNodes.length - 1)) styleString += name + ": " + value + ";"; // last property else styleString += name + ": " + value + "; "; } - dump("stylestring: ||" + styleString + "||\n"); - if(styleString.length > 0) { - element.removeAttribute("style"); - element.setAttribute("style",styleString); // NOTE BUG 18894!!! - } else { - if(element.getAttribute("style")) - element.removeAttribute("style"); + if (styleString.length > 0) + { + gElement.removeAttribute("style"); + gElement.setAttribute("style",styleString); // NOTE BUG 18894!!! + } + else if (gElement.getAttribute("style")) + gElement.removeAttribute("style"); +} + +function RemoveCSSAttribute() +{ + var treechildren = dialog.AddCSSAttributeTree.lastChild; + + // We only allow 1 selected item + if (dialog.AddCSSAttributeTree.selectedItems.length) + { + var item = dialog.AddCSSAttributeTree.selectedItems[0]; + + // Remove the item from the tree + // We always rebuild complete "style" string, + // so no list of "removed" items + treechildren.removeChild (item); + + ClearCSSInputWidgets(); } } +function SelectCSSTree( index ) +{ + gDoOnSelectTree = false; + try { + dialog.AddCSSAttributeTree.selectedIndex = index; + } catch (e) {} + gDoOnSelectTree = true; +} diff --git a/mozilla/editor/ui/dialogs/content/EdAEHTMLAttributes.js b/mozilla/editor/ui/dialogs/content/EdAEHTMLAttributes.js index 5ef0adc0837..f5b6b63263a 100644 --- a/mozilla/editor/ui/dialogs/content/EdAEHTMLAttributes.js +++ b/mozilla/editor/ui/dialogs/content/EdAEHTMLAttributes.js @@ -1,83 +1,332 @@ -/** EdAEHTMLAttributes.js - * - this file applies to the Editor Advanced Edit dialog box. - * - contains functions for creating the HTML Attributes list - **/ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998-1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Ben "Count XULula" Goodger + */ + +function BuildHTMLAttributeNameList() +{ + ClearMenulist(dialog.AddHTMLAttributeNameInput); + + var elementName = gElement.localName.toLowerCase(); + var attNames = gHTMLAttr[elementName]; + + if (attNames && attNames.length) + { + var forceOneChar = false; + var forceInteger = false; + + for (var i = 0; i < attNames.length; i++) + { + var name = attNames[i]; + if (name == "_core") + { + // Signal to append the common 'core' attributes. + // Note: These currently don't have any filtering + for (var j = 0; j < gCoreHTMLAttr.length; j++) + AppendStringToMenulist(dialog.AddHTMLAttributeNameInput, gCoreHTMLAttr[j]); + + } + else if (name == "-") + { + // Signal for separator + var popup = dialog.AddHTMLAttributeNameInput.firstChild; + if (popup) + { + sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"); + if (sep) + popup.appendChild(sep); + } + } + else + { + // Get information about value filtering + forceOneChar = name.indexOf("!") >= 0; + forceInteger = name.indexOf("#") >= 0; + forceIntOrPercent = name.indexOf("%") >= 0; + //var required = name.indexOf("$") >= 0; + + // Strip flag characters ("_" is used when attribute name is reserved JS word) + name = name.replace(/[!#%$_]/g, ""); + + var menuitem = AppendStringToMenulist(dialog.AddHTMLAttributeNameInput, 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 + menuitem.setAttribute("forceOneChar", forceOneChar ? "true" : ""); + menuitem.setAttribute("forceInteger", forceInteger ? "true" : ""); + menuitem.setAttribute("forceIntOrPercent", forceIntOrPercent ? "true" : ""); + } + } + } + } + + // Always start with empty input fields + ClearHTMLInputWidgets(); +} // build attribute list in tree form from element attributes function BuildHTMLAttributeTable() { - var nodeMap = element.attributes; + var nodeMap = gElement.attributes; var i; - if(nodeMap.length > 0) { + if (nodeMap.length > 0) + { + var added = false; for(i = 0; i < nodeMap.length; i++) { - if ( !CheckAttributeNameSimilarity( nodeMap[i].nodeName, JSEAttrs ) || + if ( CheckAttributeNameSimilarity( nodeMap[i].nodeName, HTMLAttrs ) || IsEventHandler( nodeMap[i].nodeName ) || TrimString( nodeMap[i].nodeName.toLowerCase() ) == "style" ) { continue; // repeated or non-HTML attribute, ignore this one and go to next } var name = nodeMap[i].nodeName.toLowerCase(); - var value = element.getAttribute ( nodeMap[i].nodeName ); - if (name.indexOf("_moz") != 0) - AddTreeItem ( name, value, "HTMLAList", HTMLAttrs ); + var value = gElement.getAttribute ( nodeMap[i].nodeName ); + if ( name.indexOf("_moz") != 0 && + AddTreeItem(name, value, "HTMLAList", HTMLAttrs) ) + added = true; + } + + if (added) + SelectHTMLTree(0); + } +} + +// add or select an attribute in the tree widget +function onChangeHTMLAttribute() +{ + var name = TrimString(dialog.AddHTMLAttributeNameInput.value); + if (!name) + return; + + var value = TrimString(dialog.AddHTMLAttributeValueInput.value); + + // First try to update existing attribute + // If not found, add new attribute + if ( !UpdateExistingAttribute( name, value, "HTMLAList" ) ) + AddTreeItem ( name, value, "HTMLAList", HTMLAttrs ); +} + +function ClearHTMLInputWidgets() +{ + dialog.AddHTMLAttributeTree.clearItemSelection(); + dialog.AddHTMLAttributeNameInput.value =""; + dialog.AddHTMLAttributeValueInput.value = ""; + dialog.AddHTMLAttributeNameInput.inputField.focus(); +} + +function onSelectHTMLTreeItem() +{ + if (!gDoOnSelectTree) + return; + + var tree = dialog.AddHTMLAttributeTree; + if (tree && tree.selectedItems && tree.selectedItems.length) + { + var inputName = TrimString(dialog.AddHTMLAttributeNameInput.value).toLowerCase(); + var selectedName = tree.selectedItems[0].firstChild.firstChild.getAttribute("label"); + + if (inputName == selectedName) + { + // Already editing selected name - just update the value input + dialog.AddHTMLAttributeValueInput.value = GetTreeItemValueStr(tree.selectedItems[0]); + } + else + { + dialog.AddHTMLAttributeNameInput.value = selectedName; + + // Change value input based on new selected name + onInputHTMLAttributeName(); } } } -// add an attribute to the tree widget -function onAddHTMLAttribute() +function onInputHTMLAttributeName() { - var which = document.getElementById('AddHTMLAttribute'); - if(!which || which.getAttribute ( "disabled" ) ) - return; + var attName = TrimString(dialog.AddHTMLAttributeNameInput.value).toLowerCase(); - var name = dialog.AddHTMLAttributeNameInput.value; - var value = TrimString(dialog.AddHTMLAttributeValueInput.value); - if(!name || !CheckAttributeNameSimilarity( name, CSSAttrs ) ) - return; + // Clear value widget, but prevent triggering update in tree + gUpdateTreeValue = false; + dialog.AddHTMLAttributeValueInput.value = ""; + gUpdateTreeValue = true; - if ( AddTreeItem ( name, value, "HTMLAList", HTMLAttrs ) ) { - dialog.AddHTMLAttributeNameInput.value = ""; - dialog.AddHTMLAttributeValueInput.value = ""; - } - dialog.AddHTMLAttributeNameInput.focus(); - doHTMLEnabling(); -} + if (attName) + { + // Get value list for current attribute name + var valueList = gHTMLAttr[gElement.localName.toLowerCase() + "_" + attName]; -// does enabling based on any user input. -function doHTMLEnabling() -{ - var name = TrimString(dialog.AddHTMLAttributeNameInput.value).toLowerCase(); - if( !name || !CheckAttributeNameSimilarity(name,HTMLAttrs)) { - dialog.AddHTMLAttribute.setAttribute("disabled","true"); - } else { - dialog.AddHTMLAttribute.removeAttribute("disabled"); + // Index to which widget we were using to edit the value + var deckIndex = dialog.AddHTMLAttributeValueDeck.getAttribute("index"); + var newValue = ""; + var listLen = 0; + if (valueList) + { + listLen = valueList.length; + if (listLen > 0) + newValue = valueList[0]; + + // Note: For case where "value list" is actually just + // one (default) item, don't use menulist for that + if (listLen > 1) + { + ClearMenulist(dialog.AddHTMLAttributeValueMenulist); + + if (deckIndex != "1") + { + // Switch to using editable menulist + dialog.AddHTMLAttributeValueInput = dialog.AddHTMLAttributeValueMenulist; + dialog.AddHTMLAttributeValueDeck.setAttribute("index", "1"); + } + // Rebuild the list + for (var i = 0; i < listLen; i++) + AppendStringToMenulist(dialog.AddHTMLAttributeValueMenulist, valueList[i]); + } + } + + if (listLen <= 1 && deckIndex != "0") + { + // No list: Use textbox for input instead + dialog.AddHTMLAttributeValueInput = dialog.AddHTMLAttributeValueTextbox; + dialog.AddHTMLAttributeValueDeck.setAttribute("index", "0"); + } + + // If attribute already exists in tree, use associated value, + // else use default found above + var existingValue = GetAndSelectExistingAttributeValue(attName, "HTMLAList"); + if (existingValue) + newValue = existingValue; + + dialog.AddHTMLAttributeValueInput.value = newValue; } } +function onInputHTMLAttributeValue() +{ + if (!gUpdateTreeValue) + 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(dialog.AddHTMLAttributeValueInput.value); + if (value) + { + // Do value filtering based on type of attribute + // (Do not use "LimitStringLength()" and "forceInteger()" + // to avoid multiple reseting of input's value and flickering) + var selectedItem = dialog.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,""); + } + + // Update once only if it changed + if ( value != dialog.AddHTMLAttributeValueInput.value ) + dialog.AddHTMLAttributeValueInput.value = value; + } + } + + // Always update value in the tree list + UpdateExistingAttribute( dialog.AddHTMLAttributeNameInput.value, value, "HTMLAList" ); +} + +function editHTMLAttributeValue(targetCell) +{ + if (IsNotTreeHeader(targetCell)) + dialog.AddHTMLAttributeValueInput.inputField.select(); +} + + // update the object with added and removed attributes function UpdateHTMLAttributes() { - dump("===============[ Setting and Updating HTML ]===============\n"); var HTMLAList = document.getElementById("HTMLAList"); - var name; var i; // remove removed attributes for( i = 0; i < HTMLRAttrs.length; i++ ) { - name = HTMLRAttrs[i]; - if(element.getAttribute(name)) - element.removeAttribute(name); - else continue; // doesn't exist, so don't bother removing it. + var name = HTMLRAttrs[i]; + + // We can't use getAttribute to figure out if attribute already + // exists for attributes that don't require a value + // This gets the attribute NODE from the attributes NamedNodeMap + if (gElement.attributes.getNamedItem(name)) + gElement.removeAttribute(name); } - // Set added attributes + + // Set added or changed attributes for( i = 0; i < HTMLAList.childNodes.length; i++) { var item = HTMLAList.childNodes[i]; - name = TrimString(item.firstChild.firstChild.getAttribute("label")); - var value = TrimString(item.firstChild.lastChild.firstChild.value); - // set the attribute - element.setAttribute(name,value); + gElement.setAttribute( GetTreeItemAttributeStr(item), GetTreeItemValueStr(item) ); } } + +function RemoveHTMLAttribute() +{ + var treechildren = dialog.AddHTMLAttributeTree.lastChild; + + // We only allow 1 selected item + if (dialog.AddHTMLAttributeTree.selectedItems.length) + { + var item = dialog.AddHTMLAttributeTree.selectedItems[0]; + var attr = GetTreeItemAttributeStr(item); + + // remove the item from the attribute array + HTMLRAttrs[HTMLRAttrs.length] = attr; + RemoveNameFromAttArray(attr, HTMLAttrs); + + // Remove the item from the tree + treechildren.removeChild(item); + + // Clear inputs and selected item in tree + ClearHTMLInputWidgets(); + } +} + +function SelectHTMLTree( index ) +{ + + gDoOnSelectTree = false; + try { + dialog.AddHTMLAttributeTree.selectedIndex = index; + } catch (e) {} + gDoOnSelectTree = true; +} diff --git a/mozilla/editor/ui/dialogs/content/EdAEJSEAttributes.js b/mozilla/editor/ui/dialogs/content/EdAEJSEAttributes.js index f60000da324..0204241a07f 100644 --- a/mozilla/editor/ui/dialogs/content/EdAEJSEAttributes.js +++ b/mozilla/editor/ui/dialogs/content/EdAEJSEAttributes.js @@ -1,19 +1,97 @@ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998-1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Ben "Count XULula" Goodger + */ + +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) + { + 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 + for (i = 0; i < gCoreJSEvents.length; i++) + { + if (gCoreJSEvents[i] == "-") + { + if (!popup) + popup = dialog.AddJSEAttributeNameList.firstChild; + + sep = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"); + + if (popup && sep) + popup.appendChild(sep); + } + else + AppendStringToMenulist(dialog.AddJSEAttributeNameList, gCoreJSEvents[i]); + } + + dialog.AddJSEAttributeNameList.selectedIndex = 0; + + // Use current name and value of first tree item if it exists + onSelectJSETreeItem(); + + dialog.AddJSEAttributeNameList.focus(); +} // build attribute list in tree form from element attributes function BuildJSEAttributeTable() { - var nodeMap = element.attributes; - if(nodeMap.length > 0) { - for(var i = 0; i < nodeMap.length; i++) + var nodeMap = gElement.attributes; + if (nodeMap.length > 0) + { + var added = false; + for (var i = 0; i < nodeMap.length; i++) { - if( !CheckAttributeNameSimilarity( nodeMap[i].nodeName, JSEAttrs ) ) + if( CheckAttributeNameSimilarity( nodeMap[i].nodeName, JSEAttrs ) ) continue; // repeated or non-JS handler, ignore this one and go to next if( !IsEventHandler( nodeMap[i].nodeName ) ) continue; // attribute isn't an event handler. var name = nodeMap[i].nodeName.toLowerCase(); - var value = element.getAttribute(nodeMap[i].nodeName); - AddTreeItem( name, value, "JSEAList", JSEAttrs ); // add item to tree + var value = gElement.getAttribute(nodeMap[i].nodeName); + if (AddTreeItem( name, value, "JSEAList", JSEAttrs )) // add item to tree + added = true; } + + // Select first item + if (added) + dialog.AddJSEAttributeTree.selectedIndex = 0; } } @@ -22,71 +100,118 @@ function IsEventHandler( which ) { var handlerName = which.toLowerCase(); var firstTwo = handlerName.substring(0,2); - if(firstTwo == "on") + if (firstTwo == "on") return true; else return false; } -// add an attribute to the tree widget -function onAddJSEAttribute() +function onSelectJSEAttribute() { - var which = document.getElementById("AddJSEAttribute"); - if(!which || which.getAttribute ( "disabled" ) ) + if(!gDoOnSelectTree) return; - var name = dialog.AddJSEAttributeNameInput.value; - var value = TrimString(dialog.AddJSEAttributeValueInput.value); - if( !name ) - return; - - if ( name.substring(0,2).toLowerCase() != "on" ) - name = "on" + name; // user has entered event without "on" prefix, add it - - if ( AddTreeItem( name, value, "JSEAList", JSEAttrs ) ) { - dialog.AddJSEAttributeNameInput.value = ""; - dialog.AddJSEAttributeValueInput.value = ""; - } - dialog.AddJSEAttributeNameInput.focus(); - doJSEEnabling(); + dialog.AddJSEAttributeValueInput.value = + GetAndSelectExistingAttributeValue(dialog.AddJSEAttributeNameList.label, "JSEAList"); } -// does enabling based on any user input. -function doJSEEnabling() +function onSelectJSETreeItem() { - var name = TrimString(dialog.AddJSEAttributeNameInput.value).toLowerCase(); + var tree = dialog.AddJSEAttributeTree; + if (tree && tree.selectedItems && tree.selectedItems.length) + { + var name = GetTreeItemAttributeStr(tree.selectedItems[0]); - if ( name.substring(0,2) != "on" ) - name = "on" + name; // user has entered event without "on" prefix, add it + // Select attribute name in list + if (dialog.AddJSEAttributeNameList.firstChild) + { + var arr = dialog.AddJSEAttributeNameList.firstChild.getElementsByAttribute('label', name); + if (arr && arr.length) + dialog.AddJSEAttributeNameList.selectedItem = arr[0]; - if( name == "on" || !CheckAttributeNameSimilarity(name, JSEAttrs)) - dialog.AddJSEAttribute.setAttribute("disabled","true"); - else - dialog.AddJSEAttribute.removeAttribute("disabled"); + // Set value input to that in tree (no need to update this in the tree) + gUpdateTreeValue = false; + dialog.AddJSEAttributeValueInput.value = GetTreeItemValueStr(tree.selectedItems[0]); + gUpdateTreeValue = true; + } + } +} + +function onInputJSEAttributeValue() +{ + if (gUpdateTreeValue) + { + + var name = TrimString(dialog.AddJSEAttributeNameList.label); + var value = TrimString(dialog.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" )) + AddTreeItem( name, value, "JSEAList", JSEAttrs ); + } +} + +function editJSEAttributeValue(targetCell) +{ + if (IsNotTreeHeader(targetCell)) + dialog.AddJSEAttributeValueInput.inputField.select(); } function UpdateJSEAttributes() { - dump("===============[ Setting and Updating JSE ]===============\n"); var JSEAList = document.getElementById("JSEAList"); var i; + // remove removed attributes - for( i = 0; i < JSERAttrs.length; i++ ) + for (i = 0; i < JSERAttrs.length; i++) { - var name = JSERAttrs[i]; - if(element.getAttribute(name)) - element.removeAttribute(name); - else continue; // doesn't exist, so don't bother removing it. + name = JSERAttrs[i]; + if (gElement.getAttribute(name)) + gElement.removeAttribute(name); } // Add events - for( i = 0; i < JSEAList.childNodes.length; i++) + for (i = 0; i < JSEAList.childNodes.length; i++) { var item = JSEAList.childNodes[i]; - name = TrimString(item.firstChild.firstChild.getAttribute("label")); - value = TrimString(item.firstChild.lastChild.firstChild.value); // set the event handler - element.setAttribute(name,value); + gElement.setAttribute( GetTreeItemAttributeStr(item), GetTreeItemValueStr(item) ); + } +} + +function RemoveJSEAttribute() +{ + var treechildren = dialog.AddJSEAttributeTree.lastChild; + + // 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 = dialog.AddJSEAttributeTree.selectedIndex; + + // We only allow 1 selected item + if (dialog.AddJSEAttributeTree.selectedItems.length) + { + var item = dialog.AddJSEAttributeTree.selectedItems[0]; + + // 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 + treechildren.removeChild (item); + + // Reselect an item + dialog.AddJSEAttributeTree.selectedIndex = newIndex; } } diff --git a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js index ee4caeb2c82..d60b805b2ed 100644 --- a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js +++ b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js @@ -21,27 +21,25 @@ * Ben "Count XULula" Goodger */ -/************** FOR NOW **************/ -const TEXT_WIDGETS_DONT_SUCK = false; -const PERFORMANCE_BOOSTS = false; - /************** NAMESPACES ***************/ const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; /************** GLOBALS **************/ - -var tagname = null; // element.nodeName; -var element = null; // handle for the actual element +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 CSSRAttrs = []; // removed css attributes var JSERAttrs = []; // removed js events -var gSelecting = false; // To prevent recursive selection +/* Set false to allow changing selection in tree + without doing "onselect" handler actions +*/ +var gDoOnSelectTree = true; +var gUpdateTreeValue = true; + var dialog; /************** INITIALISATION && SETUP **************/ @@ -65,32 +63,51 @@ function Startup() doSetOKCancel(onOK, onCancel); // Element to edit is passed in - element = window.arguments[1]; - if (!element || element == undefined) { + if (!window.arguments[1]) + { dump("Advanced Edit: Element to edit not supplied\n"); window.close(); + return; } + // 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", ("<" + element.localName + ">")); + tagLabel.setAttribute("value", ("<" + gElement.localName + ">")); // Create dialog object to store controls for easy access dialog = {}; dialog.AddHTMLAttributeNameInput = document.getElementById("AddHTMLAttributeNameInput"); - dialog.AddHTMLAttributeValueInput = document.getElementById("AddHTMLAttributeValueInput"); - dialog.AddHTMLAttribute = document.getElementById("AddHTMLAttribute"); - dialog.AddCSSAttributeNameInput = document.getElementById("AddCSSAttributeNameInput"); - dialog.AddCSSAttributeValueInput = document.getElementById("AddCSSAttributeValueInput"); - dialog.AddCSSAttribute = document.getElementById("AddCSSAttribute"); - dialog.AddJSEAttributeNameInput = document.getElementById("AddJSEAttributeNameInput"); - dialog.AddJSEAttributeValueInput = document.getElementById("AddJSEAttributeValueInput"); - dialog.AddJSEAttribute = document.getElementById("AddJSEAttribute"); + + // We use a to switch between editable menulist and textbox + dialog.AddHTMLAttributeValueDeck = document.getElementById("AddHTMLAttributeValueDeck"); + dialog.AddHTMLAttributeValueMenulist = document.getElementById("AddHTMLAttributeValueMenulist"); + dialog.AddHTMLAttributeValueTextbox = document.getElementById("AddHTMLAttributeValueTextbox"); + dialog.AddHTMLAttributeValueInput = dialog.AddHTMLAttributeValueTextbox; + + dialog.AddHTMLAttributeTree = document.getElementById("HTMLATree"); + dialog.AddCSSAttributeNameInput = document.getElementById("AddCSSAttributeNameInput"); + dialog.AddCSSAttributeValueInput = document.getElementById("AddCSSAttributeValueInput"); + dialog.AddCSSAttributeTree = document.getElementById("CSSATree"); + dialog.AddJSEAttributeNameList = document.getElementById("AddJSEAttributeNameList"); + dialog.AddJSEAttributeValueInput = document.getElementById("AddJSEAttributeValueInput"); + dialog.AddJSEAttributeTree = document.getElementById("JSEATree"); + dialog.okButton = document.getElementById("ok"); // build the attribute trees BuildHTMLAttributeTable(); BuildCSSAttributeTable(); BuildJSEAttributeTable(); + + // Build attribute name arrays for menulists + BuildJSEAttributeNameList(); + + // No menulists for CSS panel (yet), so just clear input fields + ClearCSSInputWidgets(); + + // Do this last -- sets focus to HTML Name menulist + BuildHTMLAttributeNameList(); // size the dialog properly window.sizeToContent(); @@ -106,120 +123,159 @@ function Startup() **/ function onOK() { - UpdateObject(); // call UpdateObject fn to update element in document - window.opener.AdvancedEditOK = true; - window.opener.globalElement = element; + // Update our gElement attributes + UpdateHTMLAttributes(); + UpdateCSSAttributes(); + UpdateJSEAttributes(); + window.opener.AdvancedEditOK = true; SaveWindowLocation(); return true; // do close the window } -/** - * function : void UpdateObject ( void ); - * parameters : none - * returns : none - * desc. : Updates the copy of the page object with the data set in this dialog. - **/ -function UpdateObject() -{ - UpdateHTMLAttributes(); - UpdateCSSAttributes(); - UpdateJSEAttributes(); -} - /** * function : bool CheckAttributeNameSimilarity ( string attName, array attArray ); * parameters : attribute to look for, array of current attributes - * returns : false if attribute already exists, true if it does not + * 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++) + for (var i = 0; i < attArray.length; i++) { - if(attName.toLowerCase() == attArray[i].toLowerCase()) - return false; + if (attName.toLowerCase() == attArray[i].toLowerCase()) + return true; } - return true; + return false; } /** - * function : bool CheckAttributeNotRemoved ( string attName, array attArray ); - * parameters : attribute to look for, array of deleted attributes - * returns : false if attribute already exists, true if it does not - * desc. : check to see if the attribute is in the array marked for removal - * before updating the final object + * 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 CheckAttributeNotRemoved( attName, attArray ) +function UpdateExistingAttribute( attName, attValue, treeChildrenId ) { - for( var i = 0; i < attArray.length; i++ ) + var treeChildren = document.getElementById(treeChildrenId); + if (!treeChildren) + return; + + var name; + var i; + attName = TrimString(attName).toLowerCase(); + attValue = TrimString(attValue); + + for (i = 0; i < treeChildren.childNodes.length; i++) { - if(attName.toLowerCase() == attArray[i].toLowerCase()) - return false; - } - return true; -} + var item = treeChildren.childNodes[i]; + name = GetTreeItemAttributeStr(item); + if (name.toLowerCase() == attName) + { + // Set the text in the "value' column treecell + SetTreeItemValueStr(item, attValue); -/** - * function : void doRemoveAttribute( DOMElement which); - * parameters : DOMElement that was context-clicked. - * returns : nothing - * desc. : removes an attribute or attributes from the tree - **/ -function RemoveAttribute( treeId ) -{ - var tree = document.getElementById(treeId); - if (!tree) return; + // Select item just changed, + // but don't trigger the tree's onSelect handler + gDoOnSelectTree = false; + try { + treeChildren.parentNode.selectItem(item); + } catch (e) {} + gDoOnSelectTree = true; - var kids = tree.lastChild; // treechildren element of tree - var newIndex = tree.selectedIndex; - - // We only allow 1 selected item - if (tree.selectedItems.length) - { - var item = tree.selectedItems[0]; - // Name is the value of the treecell - var attr = TrimString(item.firstChild.firstChild.getAttribute("value")); - - // remove the item from the attribute arrary - switch ( tree.id ) { - case "HTMLATree": - HTMLRAttrs[HTMLRAttrs.length] = attr; - if (newIndex >= (HTMLAttrs.length-1)) - newIndex--; - RemoveNameFromAttArray(attr, HTMLAttrs); - break; - case "CSSATree": - // We write a completely new "style" string, so we don't need "remove" array - //CSSRAttrs[CSSRAttrs.length] = attr; - if (newIndex >= (CSSAttrs.length-1)) - newIndex--; - RemoveNameFromAttArray(attr, CSSAttrs); - break; - case "JSEATree": - JSERAttrs[JSERAttrs.length] = attr; - if (newIndex >= (JSEAttrs.length-1)) - newIndex--; - RemoveNameFromAttArray(attr, JSEAttrs); - break; - default: break; + return true; } - - // Remove the item from the tree - kids.removeChild (item); - - // Reselect an item - tree.selectedIndex = newIndex; - SelectTreeItem(tree); } + 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 { + treeChildren.parentNode.selectItem(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.clearItemSelection(); + } catch (e) {} + gDoOnSelectTree = true; + + return ""; +} + +/* Tree structure: + + + // Name Cell +