diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/suite/editor/components/prefs | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/suite/editor/components/prefs')
6 files changed, 519 insertions, 0 deletions
diff --git a/comm/suite/editor/components/prefs/content/editorPrefsOverlay.xhtml b/comm/suite/editor/components/prefs/content/editorPrefsOverlay.xhtml new file mode 100644 index 0000000000..41112036ca --- /dev/null +++ b/comm/suite/editor/components/prefs/content/editorPrefsOverlay.xhtml @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<!-- 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/. --> + + +<!DOCTYPE overlay [ +<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" > +%brandDTD; +<!ENTITY % editorPrefsOverlayDTD SYSTEM "chrome://editor/locale/editorPrefsOverlay.dtd" > +%editorPrefsOverlayDTD; +]> + +<overlay id="editorPrefsOverlay" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> + + <preferences id="appearance_preferences"> + <preference id="general.startup.editor" + name="general.startup.editor" + type="bool"/> + </preferences> + + <!-- editor startup toggle --> + <groupbox id="generalStartupPreferences"> + <checkbox id="generalStartupEditor" + insertafter="generalStartupMail,generalStartupBrowser" + label="&editorCheck.label;" + accesskey="&editorCheck.accesskey;" + preference="general.startup.editor"/> + </groupbox> + <!-- category tree entries for editor --> + <treechildren id="prefsPanelChildren"> + <treeitem container="true" + id="composerItem" + insertbefore="securityItem" + label="&compose.label;" + prefpane="composer_pane" + url="chrome://editor/content/pref-composer.xhtml" + helpTopic="composer_prefs_general"> + <treechildren id="composerChildren"> + <treeitem id="editingItem" + label="&editing.label;" + prefpane="editing_pane" + url="chrome://editor/content/pref-editing.xhtml" + helpTopic="composer_prefs_newpage"/> + </treechildren> + </treeitem> + </treechildren> + +</overlay> diff --git a/comm/suite/editor/components/prefs/content/pref-composer.xhtml b/comm/suite/editor/components/prefs/content/pref-composer.xhtml new file mode 100644 index 0000000000..79b4a1514c --- /dev/null +++ b/comm/suite/editor/components/prefs/content/pref-composer.xhtml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<!-- 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/. --> + +<!DOCTYPE overlay SYSTEM "chrome://editor/locale/pref-composer.dtd"> + +<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> + <prefpane id="composer_pane" label="&pref.composer.title;"> + + <preferences id="composer_preferences"> + <preference id="editor.history.url_maximum" + name="editor.history.url_maximum" + type="int"/> + <preference id="editor.prettyprint" + name="editor.prettyprint" + type="bool" + inverted="true"/> + <preference id="editor.save_associated_files" + name="editor.save_associated_files" + type="bool"/> + <preference id="editor.always_show_publish_dialog" + name="editor.always_show_publish_dialog" + type="bool"/> + <preference id="editor.table.maintain_structure" + name="editor.table.maintain_structure" + type="bool"/> + <preference id="editor.use_css" + name="editor.use_css" + type="bool"/> + <preference id="editor.CR_creates_new_p" + name="editor.CR_creates_new_p" + type="bool"/> + </preferences> + + <!-- Recent files menu --> + <groupbox> + <label class="header">&recentFiles.title;</label> + <hbox align="center"> + <label value="&documentsInMenu.label;" + accesskey="&documentsInMenu.accesskey;" + control="recentFiles"/> + <html:input id="recentFiles" type="number" class="size3" + min="0" max="99" value="10" + preference="editor.history.url_maximum"/> + </hbox> + </groupbox> + + <!-- HTML formatting on output --> + <groupbox> + <label class="header">&savingFiles.title;</label> + <checkbox id="preserveFormatting" + label="&preserveExisting.label;" + accesskey="&preserveExisting.accesskey;" + tooltiptext="&preserveExisting.tooltip;" + preference="editor.prettyprint"/> + <checkbox id="saveAssociatedFiles" + label="&saveAssociatedFiles.label;" + accesskey="&saveAssociatedFiles.accesskey;" + preference="editor.save_associated_files"/> + <checkbox id="showPublishDialog" + label="&showPublishDialog.label;" + accesskey="&showPublishDialog.accesskey;" + preference="editor.always_show_publish_dialog"/> + </groupbox> + + <groupbox align="start"> + <label class="header">&composerEditing.label;</label> + <checkbox id="maintainTableStructure" + label="&maintainStructure.label;" + accesskey="&maintainStructure.accesskey;" + tooltiptext="&maintainStructure.tooltip;" + preference="editor.table.maintain_structure"/> + <checkbox id="useCSS" + label="&useCSS.label;" + accesskey="&useCSS.accesskey;" + preference="editor.use_css"/> + <checkbox id="crInPCreatesNewP" + label="&crInPCreatesNewP.label;" + accesskey="&crInPCreatesNewP.accesskey;" + preference="editor.CR_creates_new_p"/> + </groupbox> + </prefpane> +</overlay> diff --git a/comm/suite/editor/components/prefs/content/pref-editing.js b/comm/suite/editor/components/prefs/content/pref-editing.js new file mode 100644 index 0000000000..61f4c1edef --- /dev/null +++ b/comm/suite/editor/components/prefs/content/pref-editing.js @@ -0,0 +1,187 @@ +/* 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/. */ + +const browserPrefsObserver = +{ + observe: function(aSubject, aTopic, aData) + { + if (aTopic != "nsPref:changed" || document.getElementById("editor.use_custom_colors").value) + return; + + switch (aData) + { + case "browser.anchor_color": + SetColorPreview("linkText", Services.prefs.getCharPref(aData)); + break; + case "browser.active_color": + SetColorPreview("activeLinkText", Services.prefs.getCharPref(aData)); + break; + case "browser.visited_color": + SetColorPreview("visitedLinkText", Services.prefs.getCharPref(aData)); + break; + default: + SetBgAndFgColors(Services.prefs.getBoolPref("browser.display.use_system_colors")) + } + } +}; + +function Startup() +{ + // Add browser prefs observers + Services.prefs.addObserver("browser.display.use_system_colors", browserPrefsObserver); + Services.prefs.addObserver("browser.display.foreground_color", browserPrefsObserver); + Services.prefs.addObserver("browser.display.background_color", browserPrefsObserver); + Services.prefs.addObserver("browser.anchor_color", browserPrefsObserver); + Services.prefs.addObserver("browser.active_color", browserPrefsObserver); + Services.prefs.addObserver("browser.visited_color", browserPrefsObserver); + + // Add event listener so we can remove our observers + window.addEventListener("unload", WindowOnUnload, {capture: false, once: true}); + UpdateDependent(document.getElementById("editor.use_custom_colors").value); +} + +function GetColorAndUpdatePref(aType, aButtonID) +{ + // Don't allow a blank color, i.e., using the "default" + var colorObj = { NoDefault:true, Type:"", TextColor:0, PageColor:0, Cancel:false }; + var preference = document.getElementById("editor." + aButtonID + "_color"); + + if (aButtonID == "background") + colorObj.PageColor = preference.value; + else + colorObj.TextColor = preference.value; + + colorObj.Type = aType; + + window.openDialog("chrome://editor/content/EdColorPicker.xhtml", "_blank", "chrome,close,titlebar,modal", "", colorObj); + + // User canceled the dialog + if (colorObj.Cancel) + return; + + // Update preference with picked color + if (aType == "Page") + preference.value = colorObj.BackgroundColor; + else + preference.value = colorObj.TextColor; +} + +function UpdateDependent(aCustomEnabled) +{ + ToggleElements(aCustomEnabled); + + if (aCustomEnabled) + { // Set current editor colors on preview and buttons + SetColors("textCW", "normalText", document.getElementById("editor.text_color").value); + SetColors("linkCW", "linkText", document.getElementById("editor.link_color").value); + SetColors("activeCW", "activeLinkText", document.getElementById("editor.active_link_color").value); + SetColors("visitedCW", "visitedLinkText", document.getElementById("editor.followed_link_color").value); + SetColors("backgroundCW", "ColorPreview", document.getElementById("editor.background_color").value); + } + else + { // Set current browser colors on preview + SetBgAndFgColors(Services.prefs.getBoolPref("browser.display.use_system_colors")); + SetColorPreview("linkText", Services.prefs.getCharPref("browser.anchor_color")); + SetColorPreview("activeLinkText", Services.prefs.getCharPref("browser.active_color")); + SetColorPreview("visitedLinkText", Services.prefs.getCharPref("browser.visited_color")); + } +} + +function ToggleElements(aCustomEnabled) +{ + var buttons = document.getElementById("color-rows").getElementsByTagName("button"); + + for (var i = 0; i < buttons.length; i++) + { + let isLocked = CheckLocked(buttons[i].id); + buttons[i].disabled = !aCustomEnabled || isLocked; + buttons[i].previousSibling.disabled = !aCustomEnabled || isLocked; + buttons[i].firstChild.setAttribute("default", !aCustomEnabled || isLocked); + } +} + +function CheckLocked(aButtonID) +{ + return document.getElementById("editor." + aButtonID + "_color").locked; +} + +// Updates preview and button color when a editor color pref change +function UpdateColors(aColorWellID, aPreviewID, aColor) +{ + // Only show editor colors from prefs if we're in custom mode + if (!document.getElementById("editor.use_custom_colors").value) + return; + + SetColors(aColorWellID, aPreviewID, aColor) +} + +function SetColors(aColorWellID, aPreviewID, aColor) +{ + SetColorWell(aColorWellID, aColor); + SetColorPreview(aPreviewID, aColor); +} + +function SetColorWell(aColorWellID, aColor) +{ + document.getElementById(aColorWellID).style.backgroundColor = aColor; +} + +function SetColorPreview(aPreviewID, aColor) +{ + if (aPreviewID == "ColorPreview") + document.getElementById(aPreviewID).style.backgroundColor = aColor; + else + document.getElementById(aPreviewID).style.color = aColor; +} + +function UpdateBgImagePreview(aImage) +{ + var colorPreview = document.getElementById("ColorPreview"); + colorPreview.style.backgroundImage = aImage && "url(" + aImage + ")"; +} + +// Sets browser background/foreground colors +function SetBgAndFgColors(aSysPrefEnabled) +{ + if (aSysPrefEnabled) + { // Use system colors + SetColorPreview("normalText", "windowtext"); + SetColorPreview("ColorPreview", "window"); + } + else + { + SetColorPreview("normalText", Services.prefs.getCharPref("browser.display.foreground_color")); + SetColorPreview("ColorPreview", Services.prefs.getCharPref("browser.display.background_color")); + } +} + +function ChooseImageFile() +{ + const nsIFilePicker = Ci.nsIFilePicker; + var fp = Cc["@mozilla.org/filepicker;1"] + .createInstance(nsIFilePicker); + var editorBundle = document.getElementById("bundle_editor"); + var title = editorBundle.getString("SelectImageFile"); + fp.init(window, title, nsIFilePicker.modeOpen); + fp.appendFilters(nsIFilePicker.filterImages); + fp.open(rv => { + if (rv != nsIFilePicker.returnOK || !fp.file) { + return; + } + document.getElementById("editor.default_background_image").value = fp.fileURL.spec; + let textbox = document.getElementById("backgroundImageInput"); + textbox.focus(); + textbox.select(); + }); +} + +function WindowOnUnload() +{ + Services.prefs.removeObserver("browser.display.use_system_colors", browserPrefsObserver, false); + Services.prefs.removeObserver("browser.display.foreground_color", browserPrefsObserver, false); + Services.prefs.removeObserver("browser.display.background_color", browserPrefsObserver, false); + Services.prefs.removeObserver("browser.anchor_color", browserPrefsObserver, false); + Services.prefs.removeObserver("browser.active_color", browserPrefsObserver, false); + Services.prefs.removeObserver("browser.visited_color", browserPrefsObserver, false); +} diff --git a/comm/suite/editor/components/prefs/content/pref-editing.xhtml b/comm/suite/editor/components/prefs/content/pref-editing.xhtml new file mode 100644 index 0000000000..140ff320ce --- /dev/null +++ b/comm/suite/editor/components/prefs/content/pref-editing.xhtml @@ -0,0 +1,181 @@ +<?xml version="1.0"?> +<!-- 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/. --> + +<?xml-stylesheet href="chrome://editor/skin/EditorDialog.css" type="text/css"?> + +<!DOCTYPE overlay SYSTEM "chrome://editor/locale/pref-editing.dtd"> + +<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> + <prefpane id="editing_pane" + label="&pref.editing.title;" + script="chrome://editor/content/pref-editing.js"> + + <preferences id="editing_preferences"> + <preference id="editor.author" + name="editor.author" + type="string"/> + <preference id="editor.use_custom_colors" + name="editor.use_custom_colors" + type="bool" + onchange="UpdateDependent(this.value);"/> + <preference id="editor.text_color" + name="editor.text_color" + type="string" + onchange="UpdateColors('textCW', 'normalText', this.value);"/> + <preference id="editor.link_color" + name="editor.link_color" + type="string" + onchange="UpdateColors('linkCW', 'linkText', this.value);"/> + <preference id="editor.active_link_color" + name="editor.active_link_color" + type="string" + onchange="UpdateColors('activeCW', 'activeLinkText', this.value);"/> + <preference id="editor.followed_link_color" + name="editor.followed_link_color" + type="string" + onchange="UpdateColors('visitedCW', 'visitedLinkText', this.value);"/> + <preference id="editor.background_color" + name="editor.background_color" + type="string" + onchange="UpdateColors('backgroundCW', 'ColorPreview', this.value);"/> + <preference id="editor.default_background_image" + name="editor.default_background_image" + type="string" + onchange="UpdateBgImagePreview(this.value);"/> + </preferences> + + <stringbundle id="bundle_editor" + src="chrome://editor/locale/editor.properties"/> + + <vbox> + <label value="&authorName.label;" + accesskey="&authorName.accesskey;" + control="editorAuthor"> + </label> + <hbox> + <textbox id="editorAuthor" + flex="1" + preference="editor.author"/> + <spacer flex="1"/> + </hbox> + </vbox> + <spacer class="smallspacer"/> + <groupbox align="start"> + <label class="header">&pageColorHeader;</label> + <radiogroup id="useCustomColors" + preference="editor.use_custom_colors"> + <radio id="defaultColorsRadio" + value="false" + label="&defaultColors.label;" + accesskey="&defaultColors.accesskey;"/> + <radio id="customColorsRadio" + value="true" + label="&customColors.label;" + accesskey="&customColors.accesskey;"/> + </radiogroup> + <hbox class="indent"> + <grid> + <columns><column/><column/></columns> + <rows id="color-rows"> + <row align="center"> + <label id="textLabel" + value="&normalText.label;&colon.character;" + accesskey="&normalText.accesskey;" + control="text"/> + <button id="text" + class="color-button" + oncommand="GetColorAndUpdatePref('Text', 'text');"> + <spacer id="textCW" class="color-well"/> + </button> + </row> + <row align="center"> + <label id="linkLabel" + value="&linkText.label;&colon.character;" + accesskey="&linkText.accesskey;" + control="link"/> + <button id="link" + class="color-button" + oncommand="GetColorAndUpdatePref('Link', 'link');"> + <spacer id="linkCW" class="color-well"/> + </button> + </row> + <row align="center"> + <label id="activeLinkLabel" + value="&activeLinkText.label;&colon.character;" + accesskey="&activeLinkText.accesskey;" + control="active_link"/> + <button id="active_link" + class="color-button" + oncommand="GetColorAndUpdatePref('ActiveLink', 'active_link');"> + <spacer id="activeCW" class="color-well"/> + </button> + </row> + <row align="center"> + <label id="visitedLinkLabel" + value ="&visitedLinkText.label;&colon.character;" + accesskey="&visitedLinkText.accesskey;" + control="followed_link"/> + <button id="followed_link" + class="color-button" + oncommand="GetColorAndUpdatePref('VisitedLink', 'followed_link');"> + <spacer id="visitedCW" class="color-well"/> + </button> + </row> + <row align="center"> + <label id="backgroundLabel" + value="&background.label;" + accesskey="&background.accesskey;" + control="background"/> + <button id="background" + class="color-button" + oncommand="GetColorAndUpdatePref('Page', 'background');"> + <spacer id="backgroundCW" class="color-well"/> + </button> + </row> + </rows> + </grid> + <vbox id="ColorPreview" + flex="1"> + <spacer flex="1"/> + <label id="normalText" + class="larger" + value="&normalText.label;"/> + <spacer flex="1"/> + <label id="linkText" + class="larger" + value="&linkText.label;"/> + <spacer flex="1"/> + <label id="activeLinkText" + class="larger" + value="&activeLinkText.label;"/> + <spacer flex="1"/> + <label id="visitedLinkText" + class="larger" + value="&visitedLinkText.label;"/> + <spacer flex="1"/> + </vbox> + <spacer flex="1"/> + </hbox> + <spacer class="spacer"/> + <label id="backgroundImageLabel" + value="&backgroundImage.label;" + accesskey="&backgroundImage.accesskey;" + control="backgroundImageInput"> + </label> + <hbox align="center"> + <textbox id="backgroundImageInput" + class="uri-element" + preference="editor.default_background_image" + style="min-width: 23em;" + flex="1"/> + <button label="&chooseFile.label;" + accesskey="&chooseFile.accesskey;" + oncommand="ChooseImageFile();"> + <observes element="backgroundImageInput" attribute="disabled"/> + </button> + </hbox> + </groupbox> + </prefpane> +</overlay> diff --git a/comm/suite/editor/components/prefs/jar.mn b/comm/suite/editor/components/prefs/jar.mn new file mode 100644 index 0000000000..308da7340c --- /dev/null +++ b/comm/suite/editor/components/prefs/jar.mn @@ -0,0 +1,11 @@ +# 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/. + +comm.jar: +% overlay chrome://communicator/content/pref/preferences.xhtml chrome://editor/content/editorPrefsOverlay.xhtml +% overlay chrome://communicator/content/pref/pref-appearance.xhtml chrome://editor/content/editorPrefsOverlay.xhtml + content/editor/editorPrefsOverlay.xhtml (content/editorPrefsOverlay.xhtml) + content/editor/pref-composer.xhtml (content/pref-composer.xhtml) + content/editor/pref-editing.js (content/pref-editing.js) + content/editor/pref-editing.xhtml (content/pref-editing.xhtml) diff --git a/comm/suite/editor/components/prefs/moz.build b/comm/suite/editor/components/prefs/moz.build new file mode 100644 index 0000000000..de5cd1bf81 --- /dev/null +++ b/comm/suite/editor/components/prefs/moz.build @@ -0,0 +1,6 @@ +# vim: set filetype=python: +# 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/. + +JAR_MANIFESTS += ["jar.mn"] |