diff --git a/mozilla/editor/jar.mn b/mozilla/editor/jar.mn
index 7b89e08bdd9..6c2a367806b 100644
--- a/mozilla/editor/jar.mn
+++ b/mozilla/editor/jar.mn
@@ -4,6 +4,9 @@ comm.jar:
content/editor/editor.xul (ui/composer/content/editor.xul)
content/editor/TextEditorAppShell.xul (ui/composer/content/TextEditorAppShell.xul)
content/editor/editor.js (ui/composer/content/editor.js)
+ content/editor/publish.js (ui/composer/content/publish.js)
+ content/editor/PublishPrefs.js (ui/composer/content/PublishPrefs.js)
+ content/editor/editorUtilities.js (ui/composer/content/editorUtilities.js)
content/editor/ComposerCommands.js (ui/composer/content/ComposerCommands.js)
content/editor/EditorCommandsDebug.js (ui/composer/content/EditorCommandsDebug.js)
content/editor/EditorContextMenu.js (ui/composer/content/EditorContextMenu.js)
@@ -14,7 +17,7 @@ comm.jar:
content/editor/EditorAllTags.css (ui/composer/content/EditorAllTags.css)
content/editor/EditorOverride.css (ui/composer/content/EditorOverride.css)
content/editor/EditorParagraphMarks.css (ui/composer/content/EditorParagraphMarks.css)
- content/editor/EditorContent.css (ui/composer/content/EditorContent.css)
+ content/editor/EditorContent.css (ui/composer/content/EditorContent.css)
content/editor/sidebar-editor.rdf (ui/composer/content/sidebar-editor.rdf)
content/editor/sidebar-editor.xul (ui/composer/content/sidebar-editor.xul)
content/editor/sb-bookmarks-panel.xul (ui/composer/content/sb-bookmarks-panel.xul)
@@ -194,6 +197,11 @@ comm.jar:
content/editor/EditorSaveAsCharset.js (ui/dialogs/content/EditorSaveAsCharset.js)
content/editor/EdConvertToTable.xul (ui/dialogs/content/EdConvertToTable.xul)
content/editor/EdConvertToTable.js (ui/dialogs/content/EdConvertToTable.js)
+ content/editor/EditorPublish.xul (ui/dialogs/content/EditorPublish.xul)
+ content/editor/EditorPublish.js (ui/dialogs/content/EditorPublish.js)
+ content/editor/EditorPublishSettings.xul (ui/dialogs/content/EditorPublishSettings.xul)
+ content/editor/EditorPublishSettings.js (ui/dialogs/content/EditorPublishSettings.js)
+ content/editor/EditorPublishOverlay.xul (ui/dialogs/content/EditorPublishOverlay.xul)
en-US.jar:
locale/en-US/editor/contents.rdf (ui/composer/locale/en-US/contents.rdf)
@@ -228,6 +236,7 @@ en-US.jar:
locale/en-US/editor/EditConflict.dtd (ui/dialogs/locale/en-US/EditConflict.dtd)
locale/en-US/editor/EditorSaveAsCharset.dtd (ui/dialogs/locale/en-US/EditorSaveAsCharset.dtd)
locale/en-US/editor/EdConvertToTable.dtd (ui/dialogs/locale/en-US/EdConvertToTable.dtd)
+ locale/en-US/editor/EditorPublish.dtd (ui/dialogs/locale/en-US/EditorPublish.dtd)
US.jar:
locale/US/editor-region/contents.rdf (ui/composer/locale/en-US/contents-region.rdf)
diff --git a/mozilla/editor/ui/composer/content/ComposerCommands.js b/mozilla/editor/ui/composer/content/ComposerCommands.js
index 9dc7d9c2057..19b29f20129 100644
--- a/mozilla/editor/ui/composer/content/ComposerCommands.js
+++ b/mozilla/editor/ui/composer/content/ComposerCommands.js
@@ -169,6 +169,9 @@ function SetupComposerWindowCommands()
commandManager.registerCommand("cmd_saveAs", nsSaveAsCommand);
commandManager.registerCommand("cmd_exportToText", nsExportToTextCommand);
commandManager.registerCommand("cmd_saveAsCharset", nsSaveAsCharsetCommand);
+ commandManager.registerCommand("cmd_publish", nsPublishCommand);
+ commandManager.registerCommand("cmd_publishAs", nsPublishAsCommand);
+ commandManager.registerCommand("cmd_publishSettings",nsPublishSettingsCommand);
commandManager.registerCommand("cmd_revert", nsRevertCommand);
commandManager.registerCommand("cmd_openRemote", nsOpenRemoteCommand);
commandManager.registerCommand("cmd_preview", nsPreviewCommand);
@@ -324,7 +327,7 @@ var nsSaveCommand =
{
return window.editorShell &&
(window.editorShell.documentModified ||
- window.editorShell.editorDocument.location == "about:blank" ||
+ IsUrlAboutBlank(window.editorShell.editorDocument.location) ||
window.gHTMLSourceChanged);
},
@@ -333,7 +336,7 @@ var nsSaveCommand =
if (window.editorShell)
{
FinishHTMLSource(); // In editor.js
- var doSaveAs = window.editorShell.editorDocument.location == "about:blank";
+ var doSaveAs = IsUrlAboutBlank(window.editorShell.editorDocument.location);
var result = window.editorShell.saveDocument(doSaveAs, false, editorShell.contentsMIMEType);
window._content.focus();
return result;
@@ -419,6 +422,95 @@ var nsSaveAsCharsetCommand =
}
};
+//-----------------------------------------------------------------------------------
+var nsPublishCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return window.editorShell &&
+ (window.editorShell.documentModified ||
+ IsUrlAboutBlank(window.editorShell.editorDocument.location) ||
+ window.gHTMLSourceChanged);
+ },
+
+ doCommand: function(aCommand)
+ {
+ if (window.editorShell)
+ {
+ FinishHTMLSource(); // In editor.js
+
+ // If new page, we must use the publish dialog
+ if (IsUrlAboutBlank(window.editorShell.editorDocument.location))
+ goDoCommand("cmd_publishAs");
+
+ // TODO: ADD ONE-BUTTON-PUBLISH HERE!
+ // (Get current location, build URI and go!)
+
+ window._content.focus();
+ return true;
+ }
+ return false;
+ }
+}
+
+var nsPublishAsCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable);
+ },
+
+ doCommand: function(aCommand)
+ {
+ if (window.editorShell)
+ {
+ FinishHTMLSource();
+
+ // Launch Publish dialog
+ // Object to pass back data from dialog
+ var publishData = {
+ SiteName : "",
+ UserName : "",
+ Password : "",
+ Filename : "",
+ DestinationDir : "",
+ BrowseDir : "",
+ RelatedDocs : {}
+ }
+
+ window.ok = window.openDialog("chrome://editor/content/EditorPublish.xul","_blank", "chrome,close,titlebar,modal", "", publishData);
+ if (window.ok)
+ {
+dump(" * Publishing info: UserName="+publishData.UserName+", Password="+publishData.Password+", Filename="+publishData.Filename+"\n Destination="+publishData.DestinationDir+", Browse dir="+publishData.BrowseDir+"\n");
+ }
+ window._content.focus();
+ return window.ok;
+ }
+ return false;
+ }
+}
+
+var nsPublishSettingsCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell && window.editorShell.documentEditable);
+ },
+
+ doCommand: function(aCommand)
+ {
+ if (window.editorShell)
+ {
+ // Launch Publish Settings dialog
+
+ window.ok = window.openDialog("chrome://editor/content/EditorPublishSettings.xul","_blank", "chrome,close,titlebar,modal", "");
+ window._content.focus();
+ return window.ok;
+ }
+ return false;
+ }
+}
+
//-----------------------------------------------------------------------------------
var nsRevertCommand =
{
@@ -426,7 +518,7 @@ var nsRevertCommand =
{
return (window.editorShell &&
window.editorShell.documentModified &&
- window.editorShell.editorDocument.location != "about:blank");
+ !IsUrlAboutBlank(window.editorShell.editorDocument.location));
},
doCommand: function(aCommand)
diff --git a/mozilla/editor/ui/composer/content/EditorContextMenu.js b/mozilla/editor/ui/composer/content/EditorContextMenu.js
index b7fb391d2ff..1100c44e17f 100644
--- a/mozilla/editor/ui/composer/content/EditorContextMenu.js
+++ b/mozilla/editor/ui/composer/content/EditorContextMenu.js
@@ -31,6 +31,7 @@ function EditorFillContextMenu(event, contextMenuNode)
goUpdateCommand("cmd_copy");
goUpdateCommand("cmd_paste");
goUpdateCommand("cmd_delete");
+ goUpdateCommand("cmd_link");
// Setup object property menuitem
var objectName = InitObjectPropertiesMenuitem("objectProperties_cm");
diff --git a/mozilla/editor/ui/composer/content/MANIFEST b/mozilla/editor/ui/composer/content/MANIFEST
index 2afee7ab5a3..37840b848da 100644
--- a/mozilla/editor/ui/composer/content/MANIFEST
+++ b/mozilla/editor/ui/composer/content/MANIFEST
@@ -26,6 +26,7 @@ editor.xul
TextEditorAppShell.xul
editor.js
publish.js
+PublishPrefs.js
ComposerCommands.js
EditorCommandsDebug.js
EditorContextMenu.js
@@ -52,6 +53,7 @@ pref-composer.xul
pref-publish.xul
pref-editing.xul
editorPrefsOverlay.xul
+editorUtilities.js
images:tag-anchor.gif
images:tag-abr.gif
images:tag-acr.gif
diff --git a/mozilla/editor/ui/composer/content/editor.js b/mozilla/editor/ui/composer/content/editor.js
index ce3a277cee0..26aa192deee 100644
--- a/mozilla/editor/ui/composer/content/editor.js
+++ b/mozilla/editor/ui/composer/content/editor.js
@@ -63,26 +63,12 @@ var gFormatToolbar;
var gFormatToolbarHidden = false;
var gFormatToolbarCollapsed;
var gEditModeBar;
-// Bummer! Can't get at enums from nsIDocumentEncoder.h
-var gOutputSelectionOnly = 1;
-var gOutputFormatted = 2;
-//var gOutputNoDoctype = 4; // OutputNoDoctype has been obsoleted
-var gOutputBodyOnly = 8;
-var gOutputPreformatted = 16;
-var gOutputWrap = 32;
-var gOutputFormatFlowed = 64;
-var gOutputAbsoluteLinks = 128;
-var gOutputEncodeEntities = 256;
var gNormalModeButton;
var gTagModeButton;
var gSourceModeButton;
var gPreviewModeButton;
-var gIsWindows;
-var gIsMac;
-var gIsUNIX;
var gIsHTMLEditor = false;
var gColorObj = new Object();
-var gPrefs;
var gDefaultTextColor = "";
var gDefaultBackgroundColor = "";
@@ -287,20 +273,15 @@ function EditorSharedStartup()
editorShell.contentsMIMEType = "text/plain";
break;
}
-
- gIsWindows = navigator.appVersion.indexOf("Win") != -1;
- gIsUNIX = (navigator.appVersion.indexOf("X11") ||
- navigator.appVersion.indexOf("nux")) != -1;
- gIsMac = !gIsWindows && !gIsUNIX;
- //dump("IsWin="+gIsWindows+", IsUNIX="+gIsUNIX+", IsMac="+gIsMac+"\n");
+ var isMac = (GetOS() == gMac);
// Set platform-specific hints for how to select cells
// Mac uses "Cmd", all others use "Ctrl"
- var tableKey = GetString(gIsMac ? "XulKeyMac" : "TableSelectKey");
+ var tableKey = GetString(isMac ? "XulKeyMac" : "TableSelectKey");
var dragStr = tableKey+GetString("Drag");
var clickStr = tableKey+GetString("Click");
- var delStr = GetString(gIsMac ? "Clear" : "Del");
+ var delStr = GetString(isMac ? "Clear" : "Del");
SafeSetAttribute("menu_SelectCell", "acceltext", clickStr);
SafeSetAttribute("menu_SelectRow", "acceltext", dragStr);
@@ -314,9 +295,8 @@ function EditorSharedStartup()
// hide UI that we don't have components for
RemoveInapplicableUIElements();
- // Use global prefs if EditorStartup already run,
- // else get service for other editor users
- if (!gPrefs) GetPrefsService();
+ // gPrefs and GetPrefsService() are in editorUtilities.js
+ gPrefs = GetPrefsService();
// Use browser colors as initial values for editor's default colors
var BrowserColors = GetDefaultBrowserColors();
@@ -331,38 +311,6 @@ function EditorSharedStartup()
gColorObj.LastBackgroundColor = "";
}
-// Get these to use for initial default text and background,
-// and also pass to prefs and color dialogs
-function GetDefaultBrowserColors()
-{
- var colors = new Object();
- if (!colors) return null;
- //Initialize to avoid JS warnings
- colors.TextColor = "";
- colors.BackgroundColor = "";
-
- var useSysColors = false;
- try { useSysColors = gPrefs.getBoolPref("browser.display.use_system_colors"); } catch (e) {}
-
- if (!useSysColors)
- {
- try { colors.TextColor = gPrefs.getCharPref("browser.display.foreground_color"); } catch (e) {}
-
- try { colors.BackgroundColor = gPrefs.getCharPref("browser.display.background_color"); } catch (e) {}
- }
- // Use OS colors for text and background if explicitly asked or pref is not set
- if (!colors.TextColor)
- colors.TextColor = "windowtext";
-
- if (!colors.BackgroundColor)
- colors.BackgroundColor = "window";
-
- try { colors.LinkColor = gPrefs.getCharPref("browser.anchor_color"); } catch (e) {}
- try { colors.VisitedLinkColor = gPrefs.getCharPref("browser.visited_color"); } catch (e) {}
-
- return colors;
-}
-
function _EditorNotImplemented()
{
dump("Function not implemented\n");
@@ -380,12 +328,6 @@ function SafeSetAttribute(nodeID, attributeName, attributeValue)
theNode.setAttribute(attributeName, attributeValue);
}
-// We use this alot!
-function GetString(id)
-{
- return editorShell.GetString(id);
-}
-
function FindAndSelectEditorWindowWithURL(urlToMatch)
{
if (!urlToMatch || urlToMatch.length == 0)
@@ -404,19 +346,21 @@ function FindAndSelectEditorWindowWithURL(urlToMatch)
var enumerator = windowManagerInterface.getEnumerator( "composer:html" );
if ( !enumerator )
return false;
-
- while ( enumerator.hasMoreElements() )
- {
- var window = windowManagerInterface.convertISupportsToDOMWindow( enumerator.getNext() );
- if ( window )
+ try {
+ while ( enumerator.hasMoreElements() )
{
- if (editorShell.checkOpenWindowForURLMatch(urlToMatch, window))
+ var window = windowManagerInterface.convertISupportsToDOMWindow( enumerator.getNext() );
+ if ( window )
{
- window.focus();
- return true;
+ if (editorShell.checkOpenWindowForURLMatch(urlToMatch, window))
+ {
+ window.focus();
+ return true;
+ }
}
}
}
+ catch (ex) {}
// not found
return false;
@@ -431,7 +375,7 @@ function DocumentHasBeenSaved()
return false;
}
- if (fileurl == "" || fileurl == "about:blank")
+ if (fileurl == "" || IsUrlAboutBlank(fileurl))
return false;
// We have a file URL already
@@ -547,7 +491,7 @@ function EditorSetDocumentCharacterSet(aCharset)
if(editorShell)
{
editorShell.SetDocumentCharacterSet(aCharset);
- if( editorShell.editorDocument.location != "about:blank")
+ if( !IsUrlAboutBlank(editorShell.editorDocument.location))
{
// reloading the document will reverse any changes to the META charset,
// we need to put them back in, which is achieved by a dedicated listener
@@ -565,7 +509,7 @@ function updateCharsetPopupMenu(menuPopup)
for (var i = 0; i < menuPopup.childNodes.length; i++)
{
var menuItem = menuPopup.childNodes[i];
- menuItem.setAttribute('disabled', 'true');
+ menuItem.setAttribute('disabled', 'true');
}
}
}
@@ -1298,16 +1242,6 @@ function CollapseItem(id, collapse)
}
}
-function DisableItem(id, disable)
-{
- var item = document.getElementById(id);
- if (item)
- {
- if(disable != (item.getAttribute("disabled") == "true"))
- item.setAttribute("disabled", disable ? "true" : "");
- }
-}
-
function SetDisplayMode(mode)
{
if (gIsHTMLEditor)
@@ -1469,7 +1403,6 @@ function BuildRecentMenu(savePrefs)
// but we don't include it in the menu.
var curTitle = window.editorShell.editorDocument.title;
var curUrl = window.editorShell.editorDocument.location;
- var newDoc = (curUrl == "about:blank");
var historyCount = 10;
try { historyCount = gPrefs.getIntPref("editor.history.url_maximum"); } catch(e) {}
var titleArray = new Array(historyCount);
@@ -1479,7 +1412,7 @@ function BuildRecentMenu(savePrefs)
var i;
var disableMenu = true;
- if(!newDoc)
+ if(!IsUrlAboutBlank(curUrl))
{
// Always put latest-opened URL at start of array
titleArray[0] = curTitle;
@@ -1818,8 +1751,7 @@ function EditorSetDefaultPrefsAndDoctype()
}
/* only set default prefs for new documents */
- var newDoc = window.editorShell.editorDocument.location == "about:blank";
- if (!newDoc)
+ if (!IsUrlAboutBlank(window.editorShell.editorDocument.location))
return;
// search for author meta tag.
@@ -2036,8 +1968,11 @@ function onButtonUpdate(button, commmandID)
{
var commandNode = document.getElementById(commmandID);
var state = commandNode.getAttribute("state");
-
button.checked = state == "true";
+
+ // XXX why doesn't button.checked make the right thing happen here?
+ // Did it ever?
+ button.setAttribute("checked", state);
}
//--------------------------------------------------------------------
@@ -2047,32 +1982,13 @@ function onStateButtonUpdate(button, commmandID, onState)
var state = commandNode.getAttribute("state");
button.checked = state == onState;
-}
+ // XXX why doesn't button.checked make the right thing happen here?
+ // Did it ever?
+ button.setAttribute("checked", state == onState);
+}
// --------------------------- Status calls ---------------------------
-function onStyleChange(theStyle)
-{
- //dump("in onStyleChange with " + theStyle + "\n");
-
- var broadcaster = document.getElementById("cmd_" + theStyle);
- var isOn = broadcaster.getAttribute("state");
-
- // PrintObject(broadcaster);
-
- var theButton = document.getElementById(theStyle + "Button");
- if (theButton)
- {
- theButton.checked = isOn == "true";
- }
-
- var theMenuItem = document.getElementById(theStyle + "MenuItem");
- if (theMenuItem)
- {
- theMenuItem.setAttribute("checked", isOn);
- }
-}
-
function getColorAndSetColorWell(ColorPickerID, ColorWellID)
{
var colorWell;
@@ -2158,22 +2074,6 @@ function RemoveItem(id)
item.parentNode.removeChild(item);
}
-function GetPrefsService()
-{
- // Store the prefs object
- try {
- var prefsService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- gPrefs = prefsService.getBranch(null);
- if (!gPrefs)
- dump("failed to get prefs service!\n");
- }
- catch(ex)
- {
- dump("failed to get prefs service!\n");
- }
-}
-
// Command Updating Strategy:
// Don't update on on selection change, only when menu is displayed,
// with this "oncreate" hander:
diff --git a/mozilla/editor/ui/composer/content/editor.xul b/mozilla/editor/ui/composer/content/editor.xul
index 6eca8751e8b..df16e00732e 100644
--- a/mozilla/editor/ui/composer/content/editor.xul
+++ b/mozilla/editor/ui/composer/content/editor.xul
@@ -63,10 +63,6 @@
persist="screenX screenY width height sizemode">
-
diff --git a/mozilla/editor/ui/composer/content/editorOverlay.xul b/mozilla/editor/ui/composer/content/editorOverlay.xul
index a7a58817fb1..145fa12a5c7 100644
--- a/mozilla/editor/ui/composer/content/editorOverlay.xul
+++ b/mozilla/editor/ui/composer/content/editorOverlay.xul
@@ -27,6 +27,7 @@
+
@@ -78,13 +79,11 @@
-
-
@@ -104,7 +103,7 @@
-
+
@@ -113,6 +112,8 @@
+
+
@@ -128,6 +129,8 @@
+
+
-
+
@@ -290,18 +293,24 @@
-
-
+
+
+
+
-
+
+ where "position" is assumed to be just after 'previewInBrowser' -->
@@ -341,7 +350,8 @@
-
+
+
diff --git a/mozilla/editor/ui/composer/content/editorUtilities.js b/mozilla/editor/ui/composer/content/editorUtilities.js
new file mode 100644
index 00000000000..137e9c80e4f
--- /dev/null
+++ b/mozilla/editor/ui/composer/content/editorUtilities.js
@@ -0,0 +1,590 @@
+/*
+ * 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):
+ * Pete Collins
+ * Brian King
+ */
+/*
+ if we ever need to use a different string bundle, use srGetStrBundle
+ by including
+
+ e.g.:
+ var bundle = srGetStrBundle("chrome://global/locale/filepicker.properties");
+*/
+
+/**** NAMESPACES ****/
+const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
+
+// Each editor window must include this file
+// Variables shared by all dialogs:
+var editorShell;
+
+// Object to attach commonly-used widgets (all dialogs should use this)
+var gDialog = {};
+
+// Bummer! Can't get at enums from nsIDocumentEncoder.h
+const gOutputSelectionOnly = 1;
+const gOutputFormatted = 2;
+const gOutputBodyOnly = 8;
+const gOutputPreformatted = 16;
+const gOutputWrap = 32;
+const gOutputFormatFlowed = 64;
+const gOutputAbsoluteLinks = 128;
+const gOutputEncodeEntities = 256;
+var gStringBundle;
+var gIOService;
+var gPrefsService;
+
+var gOS = "";
+const gWin = "Win";
+const gUNIX = "UNIX";
+const gMac = "Mac";
+
+/************* Message dialogs ***************/
+
+function AlertWithTitle(title, message)
+{
+ var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
+ promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
+
+ if (promptService)
+ {
+ if (!title)
+ title = GetString("Alert");
+
+ // "window" is the calling dialog window
+ promptService.alert(window, title, message);
+ }
+}
+
+// Optional: Caller may supply text to substitue for "Ok" and/or "Cancel"
+function ConfirmWithTitle(title, message, okButtonText, cancelButtonText)
+{
+ var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
+ promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
+
+ if (promptService)
+ {
+ var result = {value:0};
+ var okFlag = okButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_OK;
+ var cancelFlag = cancelButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_CANCEL;
+
+ promptService.confirmEx(window, title, message,
+ (okFlag * promptService.BUTTON_POS_0) +
+ (cancelFlag * promptService.BUTTON_POS_1),
+ okButtonText, cancelButtonText, null, null, {value:0}, result);
+ return (result.value == 0);
+ }
+ return false;
+}
+
+/************* String Utilities ***************/
+
+function GetString(name)
+{
+ if (editorShell)
+ {
+ return editorShell.GetString(name);
+ }
+ else
+ {
+ // Non-editors (like prefs) may use these methods
+ if (!gStringBundle)
+ {
+ gStringBundle = srGetStrBundle("chrome://editor/locale/editor.properties");
+ if (!gStringBundle)
+ return null;
+ }
+ return gStringBundle.GetStringFromName(name);
+ }
+ return null;
+}
+
+function TrimStringLeft(string)
+{
+ if(!string) return "";
+ return string.replace(/^\s+/, "");
+}
+
+function TrimStringRight(string)
+{
+ if (!string) return "";
+ return string.replace(/\s+$/, '');
+}
+
+// Remove whitespace from both ends of a string
+function TrimString(string)
+{
+ if (!string) return "";
+ return string.replace(/(^\s+)|(\s+$)/g, '')
+}
+
+function IsWhitespace(string)
+{
+ return /^\s/.test(string);
+}
+
+function TruncateStringAtWordEnd(string, maxLength, addEllipses)
+{
+ // Return empty if string is null, undefined, or the empty string
+ if (!string)
+ return "";
+
+ // We assume they probably don't want whitespace at the beginning
+ string = string.replace(/^\s+/, '');
+ if (string.length <= maxLength)
+ return string;
+
+ // We need to truncate the string to maxLength or fewer chars
+ if (addEllipses)
+ maxLength -= 3;
+ string = string.replace(RegExp("(.{0," + maxLength + "})\\s.*"), "$1")
+
+ if (string.length > maxLength)
+ string = string.slice(0, maxLength);
+
+ if (addEllipses)
+ string += "...";
+ return string;
+}
+
+// Replace all whitespace characters with supplied character
+// E.g.: Use charReplace = " ", to "unwrap" the string by removing line-end chars
+// Use charReplace = "_" when you don't want spaces (like in a URL)
+function ReplaceWhitespace(string, charReplace)
+{
+ return string.replace(/(^\s+)|(\s+$)/g,'').replace(/\s+/g,charReplace)
+}
+
+// Replace whitespace with "_" and allow only HTML CDATA
+// characters: "a"-"z","A"-"Z","0"-"9", "_", ":", "-", ".",
+// and characters above ASCII 127
+function ConvertToCDATAString(string)
+{
+ return string.replace(/\s+/g,"_").replace(/[^a-zA-Z0-9_\.\-\:\u0080-\uFFFF]+/g,'');
+}
+
+function GetSelectionAsText()
+{
+ return editorShell.GetContentsAs("text/plain", gOutputSelectionOnly);
+}
+
+
+/************* Element enbabling/disabling ***************/
+
+// this function takes an elementID and a flag
+// if the element can be found by ID, then it is either enabled (by removing "disabled" attr)
+// or disabled (setAttribute) as specified in the "doEnable" parameter
+function SetElementEnabledById(elementID, doEnable)
+{
+ SetElementEnabled(document.getElementById(elementID), doEnable);
+}
+
+function SetElementEnabled(element, doEnable)
+{
+ if ( element )
+ {
+ if ( doEnable )
+ {
+ element.removeAttribute( "disabled" );
+ }
+ else
+ {
+ element.setAttribute( "disabled", "true" );
+ }
+ }
+ else
+ {
+ dump("Element not found in SetElementEnabled\n");
+ }
+}
+
+function DisableItem(id, disable)
+{
+ var item = document.getElementById(id);
+ if (item)
+ {
+ if (disable != (item.getAttribute("disabled") == "true"))
+ item.setAttribute("disabled", disable ? "true" : "");
+ }
+}
+
+
+/************* Services / Prefs ***************/
+
+function GetIOService()
+{
+ if (gIOService)
+ return gIOService;
+
+ var CID = Components.classes["@mozilla.org/network/io-service;1"];
+ gIOService = CID.getService(Components.interfaces.nsIIOService);
+ return gIOService;
+}
+
+function GetPrefsService()
+{
+ if (gPrefsService)
+ return gPrefsService;
+
+ try {
+ gPrefsService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
+
+ if (!gPrefsService)
+ dump("failed to get prefs service!\n");
+ }
+ catch(ex)
+ {
+ dump("failed to get prefs service!\n");
+ }
+
+ return gPrefsService;
+}
+
+function GetPrefs()
+{
+ try {
+ var prefService = GetPrefsService();
+ var prefs = prefService.getBranch(null);
+ if (prefs)
+ return prefs;
+ else
+ dump("failed to get root prefs!\n");
+
+ }
+ catch(ex)
+ {
+ dump("failed to get root prefs!\n");
+ }
+ return null;
+}
+
+function GetDefaultBrowserColors()
+{
+ var prefs = GetPrefs();
+ var colors = new Object();
+ var useSysColors = false;
+ colors.TextColor = 0;
+ colors.BackgroundColor = 0;
+ try { useSysColors = prefs.getBoolPref("browser.display.use_system_colors"); } catch (e) {}
+
+ if (!useSysColors)
+ {
+ try { colors.TextColor = prefs.getCharPref("browser.display.foreground_color"); } catch (e) {}
+
+ try { colors.BackgroundColor = prefs.getCharPref("browser.display.background_color"); } catch (e) {}
+ }
+ // Use OS colors for text and background if explicitly asked or pref is not set
+ if (!colors.TextColor)
+ colors.TextColor = "windowtext";
+
+ if (!colors.BackgroundColor)
+ colors.BackgroundColor = "window";
+
+ colors.LinkColor = prefs.getCharPref("browser.anchor_color");
+ colors.VisitedLinkColor = prefs.getCharPref("browser.visited_color");
+
+ return colors;
+}
+
+/************* URL handling ***************/
+
+function TextIsURI(selectedText)
+{
+ if (selectedText)
+ {
+ var text = selectedText.toLowerCase();
+ return text.match(/^http:\/\/|^https:\/\/|^file:\/\/|^ftp:\/\/|\
+ ^about:|^mailto:|^news:|^snews:|^telnet:|\
+ ^ldap:|^ldaps:|^gopher:|^finger:|^javascript:/);
+ }
+ return false;
+}
+
+function IsUrlAboutBlank(urlString)
+{
+ return (urlString == "about:blank");
+}
+
+function MakeRelativeUrl(url)
+{
+ var inputUrl = TrimString(url);
+ if (!inputUrl)
+ return inputUrl;
+
+ // Get the filespec relative to current document's location
+ // NOTE: Can't do this if file isn't saved yet!
+ var docUrl = GetDocumentBaseUrl();
+ var docScheme = GetScheme(docUrl);
+
+ // Can't relativize if no doc scheme (page hasn't been saved)
+ if (!docScheme)
+ return inputUrl;
+
+ var urlScheme = GetScheme(inputUrl);
+
+ // Do nothing if not the same scheme or url is already relativized
+ if (docScheme != urlScheme)
+ return inputUrl;
+
+ var IOService = GetIOService();
+ if (!IOService)
+ return inputUrl;
+
+ // Host must be the same
+ var docHost = GetHost(docUrl);
+ var urlHost = GetHost(inputUrl);
+ if (docHost != urlHost)
+ return inputUrl;
+
+ // Get just the file path part of the urls
+ var docPath = IOService.extractUrlPart(docUrl, IOService.url_Path, {start:0}, {end:0});
+ var urlPath = IOService.extractUrlPart(inputUrl, IOService.url_Path, {start:0}, {end:0});
+
+ // We only return "urlPath", so we can convert
+ // the entire docPath for case-insensitive comparisons
+ var os = GetOS();
+ var doCaseInsensitive = (docScheme.toLowerCase() == "file" && os == gWin);
+ if (doCaseInsensitive)
+ docPath = docPath.toLowerCase();
+
+ // Get document filename before we start chopping up the docPath
+ var docFilename = GetFilename(docPath);
+
+ // Both url and doc paths now begin with "/"
+ // Look for shared dirs starting after that
+ urlPath = urlPath.slice(1);
+ docPath = docPath.slice(1);
+
+ var firstDirTest = true;
+ var nextDocSlash = 0;
+ var done = false;
+
+ // Remove all matching subdirs common to both doc and input urls
+ do {
+ nextDocSlash = docPath.indexOf("\/");
+ var nextUrlSlash = urlPath.indexOf("\/");
+
+ if (nextUrlSlash == -1)
+ {
+ // We're done matching and all dirs in url
+ // what's left is the filename
+ done = true;
+
+ // Remove filename for named anchors in the same file
+ if (nextDocSlash == -1 && docFilename)
+ {
+ var anchorIndex = urlPath.indexOf("#");
+ if (anchorIndex > 0)
+ {
+ var urlFilename = doCaseInsensitive ? urlPath.toLowerCase() : urlPath;
+
+ if (urlFilename.indexOf(docFilename) == 0)
+ urlPath = urlPath.slice(anchorIndex);
+ }
+ }
+ }
+ else if (nextDocSlash >= 0)
+ {
+ // Test for matching subdir
+ var docDir = docPath.slice(0, nextDocSlash);
+ var urlDir = urlPath.slice(0, nextUrlSlash);
+ if (doCaseInsensitive)
+ urlDir = urlDir.toLowerCase();
+
+ if (urlDir == docDir)
+ {
+
+ // Remove matching dir+"/" from each path
+ // and continue to next dir
+ docPath = docPath.slice(nextDocSlash+1);
+ urlPath = urlPath.slice(nextUrlSlash+1);
+ }
+ else
+ {
+ // No match, we're done
+ done = true;
+
+ // Be sure we are on the same local drive or volume
+ // (the first "dir" in the path) because we can't
+ // relativize to different drives/volumes.
+ // UNIX doesn't have volumes, so we must not do this else
+ // the first directory will be misinterpreted as a volume name
+ if (firstDirTest && docScheme == "file" && os != gUNIX)
+ return inputUrl;
+ }
+ }
+ else // No more doc dirs left, we're done
+ done = true;
+
+ firstDirTest = false;
+ }
+ while (!done);
+
+ // Add "../" for each dir left in docPath
+ while (nextDocSlash > 0)
+ {
+ urlPath = "../" + urlPath;
+ nextDocSlash = docPath.indexOf("\/", nextDocSlash+1);
+ }
+ return urlPath;
+}
+
+function MakeAbsoluteUrl(url)
+{
+ var resultUrl = TrimString(url);
+ if (!resultUrl)
+ return resultUrl;
+
+ // Check if URL is already absolute, i.e., it has a scheme
+ var urlScheme = GetScheme(resultUrl);
+
+ if (urlScheme)
+ return resultUrl;
+
+ var docUrl = GetDocumentBaseUrl();
+ var docScheme = GetScheme(docUrl);
+
+ // Can't relativize if no doc scheme (page hasn't been saved)
+ if (!docScheme)
+ return resultUrl;
+
+ var IOService = GetIOService();
+ if (!IOService)
+ return resultUrl;
+
+ // Make a URI object to use its "resolve" method
+ var absoluteUrl = resultUrl;
+ var docUri = IOService.newURI(docUrl, null);
+
+ try {
+ absoluteUrl = docUri.resolve(resultUrl);
+ // This is deprecated and buggy!
+ // If used, we must make it a path for the parent directory (remove filename)
+ //absoluteUrl = IOService.resolveRelativePath(resultUrl, docUrl);
+ } catch (e) {}
+
+ return absoluteUrl;
+}
+
+// Get the HREF of the page's tag or the document location
+// returns empty string if no base href and document hasn't been saved yet
+function GetDocumentBaseUrl()
+{
+ if (window.editorShell)
+ {
+ var docUrl;
+
+ // if document supplies a tag, use that URL instead
+ var baseList = editorShell.editorDocument.getElementsByTagName("base");
+ if (baseList)
+ {
+ var base = baseList.item(0);
+ if (base)
+ docUrl = base.getAttribute("href");
+ }
+ if (!docUrl)
+ docUrl = editorShell.editorDocument.location.href;
+
+ if (!IsUrlAboutBlank(docUrl))
+ return docUrl;
+ }
+ return "";
+}
+
+// Extract the scheme (e.g., 'file', 'http') from a URL string
+function GetScheme(url)
+{
+ var resultUrl = TrimString(url);
+ // Unsaved document URL has no acceptable scheme yet
+ if (!resultUrl || IsUrlAboutBlank(resultUrl))
+ return "";
+
+ var IOService = GetIOService();
+ if (!IOService)
+ return "";
+
+ var scheme = "";
+ try {
+ // This fails if there's no scheme
+ scheme = IOService.extractScheme(resultUrl, {schemeStartPos:0}, {schemeEndPos:0});
+ } catch (e) {}
+
+ return scheme ? scheme : "";
+}
+
+function GetHost(url)
+{
+ var IOService = GetIOService();
+ if (!IOService)
+ return "";
+
+ var host = "";
+ if (url)
+ {
+ try {
+ host = IOService.extractUrlPart(url, IOService.url_Host, {start:0}, {end:0});
+ } catch (e) {}
+ }
+ return host;
+}
+
+function GetFilename(url)
+{
+ var IOService = GetIOService();
+ if (!IOService)
+ return "";
+
+ var filename;
+
+ if (url)
+ {
+ try {
+ filename = IOService.extractUrlPart(url, IOService.url_FileBaseName, {start:0}, {end:0});
+ if (filename)
+ {
+ var ext = IOService.extractUrlPart(url, IOService.url_FileExtension, {start:0}, {end:0});
+ if (ext)
+ filename += "."+ext;
+ }
+ } catch (e) {}
+ }
+ return filename ? filename : "";
+}
+
+function GetOS()
+{
+ if (gOS)
+ return gOS;
+
+ var platform = navigator.platform.toLowerCase();
+
+ if (platform.indexOf("win") != -1)
+ gOS = gWin;
+ else if (platform.indexOf("mac") != -1)
+ gOS = gMac;
+ else if (platform.indexOf("unix") != -1 || platform.indexOf("linux") != -1 || platform.indexOf("sun") != -1)
+ gOS = gUNIX;
+ else
+ gOS = "";
+ // Add other tests?
+
+ return gOS;
+}
diff --git a/mozilla/editor/ui/composer/content/makefile.win b/mozilla/editor/ui/composer/content/makefile.win
index 4b76d74f85a..5d488c64f47 100644
--- a/mozilla/editor/ui/composer/content/makefile.win
+++ b/mozilla/editor/ui/composer/content/makefile.win
@@ -30,6 +30,7 @@ CHROME_CONTENT = \
.\TextEditorAppShell.xul \
.\editor.js \
.\publish.js \
+ .\PublishPrefs.js \
.\ComposerCommands.js \
.\EditorCommandsDebug.js \
.\EditorContextMenu.js \
@@ -56,6 +57,7 @@ CHROME_CONTENT = \
.\pref-composer.js \
.\pref-composer.xul \
.\editorPrefsOverlay.xul \
+ .\editorUtilities.js \
$(NULL)
CHROME_MISC = \
diff --git a/mozilla/editor/ui/composer/content/pref-composer.js b/mozilla/editor/ui/composer/content/pref-composer.js
index 82e41eb4827..afad399548f 100644
--- a/mozilla/editor/ui/composer/content/pref-composer.js
+++ b/mozilla/editor/ui/composer/content/pref-composer.js
@@ -1,7 +1,25 @@
+/*
+ * 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):
+ */
// This is mostly a modified version of code in EdColorProps.xul
-// TODO: Factor out common code to reduce code size
-// and make a new utility.js to eliminate duplication
-// in editor.js and EdDialogCommon.js
// Initialize in case we can't get them from prefs???
var defaultTextColor="#000000";
diff --git a/mozilla/editor/ui/composer/content/pref-editing.xul b/mozilla/editor/ui/composer/content/pref-editing.xul
index 7ec6dc614ec..08dc631d1f3 100644
--- a/mozilla/editor/ui/composer/content/pref-editing.xul
+++ b/mozilla/editor/ui/composer/content/pref-editing.xul
@@ -37,6 +37,7 @@
+
diff --git a/mozilla/editor/ui/composer/content/publishprefs.js b/mozilla/editor/ui/composer/content/publishprefs.js
new file mode 100644
index 00000000000..12a201ef1c2
--- /dev/null
+++ b/mozilla/editor/ui/composer/content/publishprefs.js
@@ -0,0 +1,226 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: NPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2001
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the NPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the NPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// Number of items in each site profile array
+const gSiteDataLength = 4;
+// Index to each profile item:
+const gNameIndex = 0;
+const gUrlIndex = 1;
+const gBrowseIndex = 2;
+const gUserNameIndex = 3;
+const gDefaultDirIndex = 4;
+const gDirListIndex = 5;
+
+function GetPublishPrefsBranch()
+{
+ var prefsService = GetPrefsService();
+ if (!prefsService) return;
+
+ return prefsService.getBranch("editor.publish.");
+}
+
+// Build an array of publish site data obtained from prefs
+function GetPublishSiteData()
+{
+ var publishBranch = GetPublishPrefsBranch();
+ if (!publishBranch)
+ return null;
+
+ var prefCount = {value:0};
+ var nameArray = publishBranch.getChildList("site_name.", prefCount);
+dump(" *** GetPublishSiteData: nameArray="+nameArray+", count ="+prefCount.value+"\n");
+
+ if (!nameArray || prefCount.value == 0)
+ return null;
+
+ // Array of all site data
+ var siteArray = new Array();
+
+ var index = 0;
+ var i;
+
+ for (i = 0; i < prefCount.value; i++)
+ {
+ var name = GetPublishCharPref(publishBranch, nameArray[i]);
+ if (name)
+ {
+ // Associated data uses site name as key
+ var prefPrefix = "site_data." + name + ".";
+
+ // We must at least have a publish url, else we ignore this site
+ // (siteData and siteNames for sites with incomplete data
+ // will get deleted by SavePublishSiteDataToPrefs)
+ var publishUrl = GetPublishCharPref(publishBranch, prefPrefix+"url");
+ if (publishUrl)
+ {
+ siteArray[index] = new Array(gSiteDataLength);
+ siteArray[index][gNameIndex] = name;
+ siteArray[index][gUrlIndex] = publishUrl;
+ siteArray[index][gBrowseIndex] = GetPublishCharPref(publishBranch, prefPrefix+"browse_url");
+ siteArray[index][gUserNameIndex] = GetPublishCharPref(publishBranch, prefPrefix+"username");
+ siteArray[index][gDefaultDirIndex] = GetPublishCharPref(publishBranch, prefPrefix+"default_dir");
+
+ // Get the list of directories within each site
+ var dirCount = {value:0};
+ var dirArray = publishBranch.getChildList(prefPrefix+"dir_name.", dirCount);
+ if (dirArray && dirCount.value > 0)
+ {
+ siteArray[index][gDirListIndex] = new Array();
+ for (var j = 0; j < dirCount.value; j++)
+ {
+ var dirName = GetPublishCharPref(publishBranch, prefPrefix+dirArray[j]);
+dump(" DirName="+dirName+"\n");
+ if (dirName)
+ siteArray[index][gDirListIndex][j] = dirName;
+ }
+ }
+ index++;
+ }
+dump(" Name="+name+", URL="+publishUrl+"\n");
+ }
+ }
+ if (index == 0) // No Valid pref records found!
+ return null;
+
+ if (index > 1)
+ {
+ // NOTE: This is an ASCII sort (not locale-aware)
+ siteArray.sort();
+ }
+ return siteArray;
+}
+
+function SavePublishSiteDataToPrefs(siteArray, defaultName)
+{
+ var publishBranch = GetPublishPrefsBranch();
+dump(" *** Saving Publish Data: publishBranch="+publishBranch+"\n");
+ if (!publishBranch)
+ return;
+
+ // Clear existing names and data -- rebuild all site prefs
+ publishBranch.deleteBranch("site_name.");
+ publishBranch.deleteBranch("site_data.");
+
+// ***** DEBUG ONLY
+ var prefCount = {value:0};
+ var pubArray = publishBranch.getChildList("", prefCount);
+dump(" *** editor.publish child array ="+pubArray+", prefCount.value ="+prefCount.value+"\n");
+
+// ***** DEBUG ONLY
+
+ var i;
+ if (siteArray)
+ {
+ for (i = 0; i < siteArray.length; i++)
+ {
+dump(" Saving prefs for "+siteArray[i][gNameIndex]+"\n");
+ var prefPrefix = "site_data." + siteArray[i][gNameIndex] + "."
+ publishBranch.setCharPref("site_name."+i, siteArray[i][gNameIndex]);
+ publishBranch.setCharPref(prefPrefix+"url", siteArray[i][gUrlIndex]);
+ publishBranch.setCharPref(prefPrefix+"browse_url", siteArray[i][gBrowseIndex]);
+ publishBranch.setCharPref(prefPrefix+"username", siteArray[i][gUserNameIndex]);
+ }
+ }
+
+ // Save default site name
+ publishBranch.setCharPref("default_site", defaultName);
+
+ // Force saving to file so next file opened finds these values
+ if (gPrefsService)
+ gPrefsService.savePrefFile(null);
+}
+
+// This doesn't force saving prefs file
+// Call "SavePublishSiteDataToPrefs(null, defaultName)" to force saving file
+function SetDefaultSiteName(name)
+{
+ if (name)
+ {
+ var publishBranch = GetPublishPrefsBranch();
+ if (publishBranch)
+ publishBranch.setCharPref("default_site", name);
+ }
+}
+
+function GetDefaultPublishSiteName()
+{
+ var publishBranch = GetPublishPrefsBranch();
+ var name = "";
+ if (publishBranch)
+ try {
+ name = GetPublishCharPref(publishBranch, "default_site");
+ } catch (ex) {}
+
+ return name;
+}
+
+function GetDefaultPublishSiteData()
+{
+ var publishBranch = GetPublishPrefsBranch();
+ if (!publishBranch)
+ return null;
+
+ var name = GetPublishCharPref(publishBranch, "default_site");
+ if (!name)
+ return null;
+
+ var prefPrefix = "site_data." + name + ".";
+
+ var publishData = {
+ SiteName : name,
+ UserName : GetPublishCharPref(publishBranch, prefPrefix+"username"),
+ Password : "",
+ Filename : "",
+ DestinationDir : GetPublishCharPref(publishBranch, prefPrefix+"url"),
+ BrowseDir : GetPublishCharPref(publishBranch, prefPrefix+"browse_url"),
+ RelatedDocs : {}
+ }
+
+ return publishData;
+}
+
+// Prefs that don't exist will through an exception,
+// so just return empty string for those cases
+function GetPublishCharPref(prefBranch, name)
+{
+ var prefStr = "";
+ try {
+ prefStr = prefBranch.getCharPref(name);
+ } catch (ex) {}
+
+ return prefStr;
+}
diff --git a/mozilla/editor/ui/composer/locale/en-US/editor.properties b/mozilla/editor/ui/composer/locale/en-US/editor.properties
index 3cda479a0ef..765c0096af2 100644
--- a/mozilla/editor/ui/composer/locale/en-US/editor.properties
+++ b/mozilla/editor/ui/composer/locale/en-US/editor.properties
@@ -28,6 +28,7 @@ SaveDocumentAs=Save Page As
ExportToText=Export to Text
EditMode=Edit Mode
Preview=Preview
+Publish=Publish
CorrectSpelling=(correct spelling)
NoSuggestedWords=(no suggested words)
NoMisspelledWord=No misspelled words
@@ -55,21 +56,24 @@ SendPageReason=before sending this page
## LOCALIZATION NOTE (AbandonChanges): Don't translate %title%
AbandonChanges=Abandon unsaved changes to %title% and reload page?
DocumentTitle=Page Title
-NeedDocTitle=Enter a title for the current page.
+NeedDocTitle=Please enter a title for the current page.
DocTitleHelp=This identifies the page in the window title and bookmarks.
AttributesFor=Current attributes for:
MissingImageError=Please enter or choose an image of type gif, jpg, or png.
-EmptyHREFError=You must enter or choose a location to create a new link.
+InputNameError=Please enter a name for this form field.
+InputValueError=Please enter a name and value for this form field.
+TextAreaError=Please enter a name and size for this text area.
+EmptyHREFError=Please choose a location to create a new link.
LinkText=Link Text
LinkImage=Link Image
MixedSelection=[Mixed selection]
Mixed=(mixed)
EnterLinkText=Enter text to display for the link:
-EmptyLinkTextError=You must enter some text for this link.
+EmptyLinkTextError=Please enter some text for this link.
#LOCALIZATION NOTE (ValidateNumber):Don't translate: %n% %min% %max%
ValidateRangeMsg=The number you entered (%n%) is outside of the allowed range.
ValidateNumberMsg=Please enter a number between %min% and %max%.
-MissingAnchorNameError=You must enter a name for this anchor.
+MissingAnchorNameError=Please enter a name for this anchor.
#LOCALIZATION NOTE (DuplicateAnchorNameError): Don't translate %name%
DuplicateAnchorNameError="%name%" already exists in this page. Please enter a different name.
BulletStyle=Bullet Style
@@ -116,6 +120,10 @@ NamedAnchor=Named Anchor
List=List
ListItem=List Item
Tag=Tag
+MissingSiteNameError=Please enter a name for this publishing site.
+MissingPublishUrlError=Please enter a location for publishing this page.
+MissingPublishFilename=Please enter a filename for the current page.
+MissingPublishSiteError=No publishing site information given. Switching to Settings panel so you can supply publishing information.
AdvancedProperties=Advanced Properties...
# LOCALIZATION NOTE (ObjectProperties):Don't translate "%obj%" it will be replaced with one of above object nouns
ObjectProperties=%obj% Properties...
diff --git a/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd b/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd
index 86850e903c8..d0e6fe41ec9 100644
--- a/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd
+++ b/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd
@@ -47,8 +47,13 @@
+
+
+
+
+
-
+
@@ -75,6 +80,8 @@
+
+
diff --git a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul
index bba9b4ed411..a2c8a78e2eb 100644
--- a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul
+++ b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul
@@ -44,6 +44,7 @@
+
diff --git a/mozilla/editor/ui/dialogs/content/EdColorPicker.xul b/mozilla/editor/ui/dialogs/content/EdColorPicker.xul
index 4342c098027..9928f404121 100644
--- a/mozilla/editor/ui/dialogs/content/EdColorPicker.xul
+++ b/mozilla/editor/ui/dialogs/content/EdColorPicker.xul
@@ -34,6 +34,7 @@
onunload="onCancel()"
>
+
diff --git a/mozilla/editor/ui/dialogs/content/EdColorProps.xul b/mozilla/editor/ui/dialogs/content/EdColorProps.xul
index 057645b8132..7d6dfe8d7f6 100644
--- a/mozilla/editor/ui/dialogs/content/EdColorProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdColorProps.xul
@@ -37,6 +37,7 @@
onload="Startup()"
onunload="onCancel()">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdConvertToTable.xul b/mozilla/editor/ui/dialogs/content/EdConvertToTable.xul
index 1372c881025..bf13f2b36e5 100644
--- a/mozilla/editor/ui/dialogs/content/EdConvertToTable.xul
+++ b/mozilla/editor/ui/dialogs/content/EdConvertToTable.xul
@@ -39,6 +39,7 @@
style="min-width:20em">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js
index 12b67e6d921..77898ae7715 100644
--- a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js
+++ b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js
@@ -29,9 +29,6 @@
var bundle = srGetStrBundle("chrome://global/locale/filepicker.properties");
*/
-/**** NAMESPACES ****/
-const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-
// Each editor window must include this file
// Variables shared by all dialogs:
var editorShell;
@@ -39,23 +36,7 @@ var editorShell;
// Object to attach commonly-used widgets (all dialogs should use this)
var gDialog = {};
-// Bummer! Can't get at enums from nsIDocumentEncoder.h
-var gOutputSelectionOnly = 1;
-var gOutputFormatted = 2;
-var gOutputNoDoctype = 4;
-var gOutputBodyOnly = 8;
-var gOutputPreformatted = 16;
-var gOutputWrap = 32;
-var gOutputFormatFlowed = 64;
-var gOutputAbsoluteLinks = 128;
-var gOutputEncodeEntities = 256;
-var gStringBundle;
var gValidationError = false;
-var gIOService;
-var gOS = "";
-const gWin = "Win";
-const gUNIX = "UNIX";
-const gMac = "Mac";
// Use for 'defaultIndex' param in InitPixelOrPercentMenulist
var gPixel = 0;
@@ -93,14 +74,6 @@ function InitEditorShell()
return true;
}
-function StringExists(string)
-{
- if (string != null && string != "undefined" && string.length > 0)
- return true;
-
- return false;
-}
-
/* Validate contents of an input field
*
* inputWidget The 'textbox' XUL element for text input of the attribute's value
@@ -259,175 +232,6 @@ function ShowInputErrorMessage(message)
window.focus();
}
-function AlertWithTitle(title, message)
-{
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
- promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
-
- if (promptService)
- {
- if (!title)
- title = GetString("Alert");
-
- // "window" is the calling dialog window
- promptService.alert(window, title, message);
- }
-}
-
-// Optional: Caller may supply text to substitue for "Ok" and/or "Cancel"
-function ConfirmWithTitle(title, message, okButtonText, cancelButtonText)
-{
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
- promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
-
- if (promptService)
- {
- var result = {value:0};
- var okFlag = okButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_OK;
- var cancelFlag = cancelButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_CANCEL;
-
- promptService.confirmEx(window, title, message,
- (okFlag * promptService.BUTTON_POS_0) +
- (cancelFlag * promptService.BUTTON_POS_1),
- okButtonText, cancelButtonText, null, null, {value:0}, result);
- return (result.value == 0);
- }
- return false;
-}
-
-function GetString(name)
-{
- if (editorShell)
- {
- return editorShell.GetString(name);
- }
- else
- {
- // Non-editors (like prefs) may use these methods
- if (!gStringBundle)
- {
- gStringBundle = srGetStrBundle("chrome://editor/locale/editor.properties");
- if (!gStringBundle)
- return null;
- }
- return gStringBundle.GetStringFromName(name);
- }
- return null;
-}
-
-function TrimStringLeft(string)
-{
- if(!string) return "";
- return string.replace(/^\s+/, "");
-}
-
-function TrimStringRight(string)
-{
- if (!string) return "";
- return string.replace(/\s+$/, '');
-}
-
-// Remove whitespace from both ends of a string
-function TrimString(string)
-{
- if (!string) return "";
- return string.replace(/(^\s+)|(\s+$)/g, '')
-}
-
-function IsWhitespace(string)
-{
- return /^\s/.test(string);
-}
-
-function TruncateStringAtWordEnd(string, maxLength, addEllipses)
-{
- // Return empty if string is null, undefined, or the empty string
- if (!string)
- return "";
-
- // We assume they probably don't want whitespace at the beginning
- string = string.replace(/^\s+/, '');
- if (string.length <= maxLength)
- return string;
-
- // We need to truncate the string to maxLength or fewer chars
- if (addEllipses)
- maxLength -= 3;
- string = string.replace(RegExp("(.{0," + maxLength + "})\\s.*"), "$1")
-
- if (string.length > maxLength)
- string = string.slice(0, maxLength);
-
- if (addEllipses)
- string += "...";
- return string;
-}
-
-// Replace all whitespace characters with supplied character
-// E.g.: Use charReplace = " ", to "unwrap" the string by removing line-end chars
-// Use charReplace = "_" when you don't want spaces (like in a URL)
-function ReplaceWhitespace(string, charReplace)
-{
- return string.replace(/(^\s+)|(\s+$)/g,'').replace(/\s+/g,charReplace)
-}
-
-// Replace whitespace with "_" and allow only HTML CDATA
-// characters: "a"-"z","A"-"Z","0"-"9", "_", ":", "-", ".",
-// and characters above ASCII 127
-function ConvertToCDATAString(string)
-{
- return string.replace(/\s+/g,"_").replace(/[^a-zA-Z0-9_\.\-\:\u0080-\uFFFF]+/g,'');
-}
-
-// this function takes an elementID and a flag
-// if the element can be found by ID, then it is either enabled (by removing "disabled" attr)
-// or disabled (setAttribute) as specified in the "doEnable" parameter
-function SetElementEnabledById( elementID, doEnable )
-{
- var element = document.getElementById(elementID);
- if ( element )
- {
- if ( doEnable )
- {
- element.removeAttribute( "disabled" );
- }
- else
- {
- element.setAttribute( "disabled", "true" );
- }
- }
- else
- {
- dump("Element "+elementID+" not found in SetElementEnabledById\n");
- }
-}
-
-// This function relies on css classes for enabling and disabling
-// This function takes an ID for a label and a flag
-// if an element can be found by its ID, then it is either enabled or disabled
-// The class is set to either "enabled" or "disabled" depending on the flag passed in.
-// This function relies on css having a special appearance for these two classes.
-
-function SetClassEnabledById( elementID, doEnable )
-{
- element = document.getElementById(elementID);
- if ( element )
- {
- if ( doEnable )
- {
- element.setAttribute( "class", "enabled" );
- }
- else
- {
- element.setAttribute( "class", "disabled" );
- }
- }
- else
- {
- dump( "not changing element "+elementID+"\n" );
- }
-}
-
// Get the text appropriate to parent container
// to determine what a "%" value is refering to.
// elementForAtt is element we are actually setting attributes on
@@ -446,47 +250,6 @@ function GetAppropriatePercentString(elementForAtt, elementInDoc)
return GetString("PercentOfWindow");
}
-function InitPixelOrPercentMenulist(elementForAtt, elementInDoc, attribute, menulistID, defaultIndex)
-{
- if (!defaultIndex) defaultIndex = gPixel;
-
- var size = elementForAtt.getAttribute(attribute);
- var menulist = document.getElementById(menulistID);
- var pixelItem;
- var percentItem;
-
- if (!menulist)
- {
- dump("NO MENULIST found for ID="+menulistID+"\n");
- return size;
- }
-
- ClearMenulist(menulist);
- pixelItem = AppendStringToMenulist(menulist, GetString("Pixels"));
-
- if (!pixelItem) return 0;
-
- percentItem = AppendStringToMenulist(menulist, GetAppropriatePercentString(elementForAtt, elementInDoc));
- if (size && size.length > 0)
- {
- // Search for a "%" character
- var percentIndex = size.search(/%/);
- if (percentIndex > 0)
- {
- // Strip out the %
- size = size.substr(0, percentIndex);
- if (percentItem)
- menulist.selectedItem = percentItem;
- }
- else
- menulist.selectedItem = pixelItem;
- }
- else
- menulist.selectedIndex = defaultIndex;
-
- return size;
-}
-
function AppendStringToMenulistById(menulist, stringID)
{
return AppendStringToMenulist(menulist, editorShell.GetString(stringID));
@@ -752,6 +515,46 @@ function LimitStringLength(elementID, length)
editField.value = stringIn.slice(0,length);
}
+function InitPixelOrPercentMenulist(elementForAtt, elementInDoc, attribute, menulistID, defaultIndex)
+{
+ if (!defaultIndex) defaultIndex = gPixel;
+
+ var size = elementForAtt.getAttribute(attribute);
+ var menulist = document.getElementById(menulistID);
+ var pixelItem;
+ var percentItem;
+
+ if (!menulist)
+ {
+ dump("NO MENULIST found for ID="+menulistID+"\n");
+ return size;
+ }
+
+ ClearMenulist(menulist);
+ pixelItem = AppendStringToMenulist(menulist, GetString("Pixels"));
+
+ if (!pixelItem) return 0;
+
+ percentItem = AppendStringToMenulist(menulist, GetAppropriatePercentString(elementForAtt, elementInDoc));
+ if (size && size.length > 0)
+ {
+ // Search for a "%" character
+ var percentIndex = size.search(/%/);
+ if (percentIndex > 0)
+ {
+ // Strip out the %
+ size = size.substr(0, percentIndex);
+ if (percentItem)
+ menulist.selectedItem = percentItem;
+ }
+ else
+ menulist.selectedItem = pixelItem;
+ }
+ else
+ menulist.selectedIndex = defaultIndex;
+
+ return size;
+}
function onAdvancedEdit()
{
@@ -772,47 +575,6 @@ function onAdvancedEdit()
}
}
-function GetSelectionAsText()
-{
- return editorShell.GetContentsAs("text/plain", gOutputSelectionOnly);
-}
-
-
-// ** getSelection ()
-// ** This function checks for existence of table around the focus node
-// ** Brian King - XML Workshop
-
-function getContainer ()
-{
- tagName = "img";
- selImage = editorShell.GetSelectedElement(tagName);
- if (selImage) // existing image
- {
- oneup = selImage.parentNode;
- return oneup;
- }
- else if (!selImage) // new image insertion
- {
- dump("Not an image element -- Trying for caret selection\n");
- var selection = window.editorShell.editorSelection;
- if (selection)
- {
- var focusN = selection.focusNode;
- if (focusN.nodeName.toLowerCase == "td")
- return focusN
- else
- {
- oneup = focusN.parentNode;
- return oneup;
- }
- }
- else
- return null;
- }
- else
- return null;
-}
-
function getColor(ColorPickerID)
{
var colorPicker = document.getElementById(ColorPickerID);
@@ -930,25 +692,6 @@ function SwitchToValidatePanel()
// Only EdTableProps.js currently implements this
}
-function GetPrefs()
-{
- try {
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- var prefs = prefService.getBranch(null);
- if (prefs)
- return prefs;
- else
- dump("failed to get prefs service!\n");
-
- }
- catch(ex)
- {
- dump("failed to get prefs service!\n");
- }
- return null;
-}
-
const nsIFilePicker = Components.interfaces.nsIFilePicker;
function GetLocalFileURL(filterType)
@@ -1153,46 +896,6 @@ function onCancel()
return true;
}
-function GetDefaultBrowserColors()
-{
- var prefs = GetPrefs();
- var colors = new Object();
- var useSysColors = false;
- colors.TextColor = 0;
- colors.BackgroundColor = 0;
- try { useSysColors = prefs.getBoolPref("browser.display.use_system_colors"); } catch (e) {}
-
- if (!useSysColors)
- {
- try { colors.TextColor = prefs.getCharPref("browser.display.foreground_color"); } catch (e) {}
-
- try { colors.BackgroundColor = prefs.getCharPref("browser.display.background_color"); } catch (e) {}
- }
- // Use OS colors for text and background if explicitly asked or pref is not set
- if (!colors.TextColor)
- colors.TextColor = "windowtext";
-
- if (!colors.BackgroundColor)
- colors.BackgroundColor = "window";
-
- colors.LinkColor = prefs.getCharPref("browser.anchor_color");
- colors.VisitedLinkColor = prefs.getCharPref("browser.visited_color");
-
- return colors;
-}
-
-function TextIsURI(selectedText)
-{
- if (selectedText)
- {
- var text = selectedText.toLowerCase();
- return text.match(/^http:\/\/|^https:\/\/|^file:\/\/|^ftp:\/\/|\
- ^about:|^mailto:|^news:|^snews:|^telnet:|\
- ^ldap:|^ldaps:|^gopher:|^finger:|^javascript:/);
- }
- return false;
-}
-
function SetRelativeCheckbox()
{
var checkbox = document.getElementById("MakeRelativeCheckbox");
@@ -1288,273 +991,3 @@ function MakeInputValueRelativeOrAbsolute()
}
}
-function MakeRelativeUrl(url)
-{
- var inputUrl = TrimString(url);
- if (!inputUrl)
- return inputUrl;
-
- // Get the filespec relative to current document's location
- // NOTE: Can't do this if file isn't saved yet!
- var docUrl = GetDocumentBaseUrl();
- var docScheme = GetScheme(docUrl);
-
- // Can't relativize if no doc scheme (page hasn't been saved)
- if (!docScheme)
- return inputUrl;
-
- var urlScheme = GetScheme(inputUrl);
-
- // Do nothing if not the same scheme or url is already relativized
- if (docScheme != urlScheme)
- return inputUrl;
-
- var IOService = GetIOService();
- if (!IOService)
- return inputUrl;
-
- // Host must be the same
- var docHost = GetHost(docUrl);
- var urlHost = GetHost(inputUrl);
- if (docHost != urlHost)
- return inputUrl;
-
- // Get just the file path part of the urls
- var docPath = IOService.extractUrlPart(docUrl, IOService.url_Path, {start:0}, {end:0});
- var urlPath = IOService.extractUrlPart(inputUrl, IOService.url_Path, {start:0}, {end:0});
-
- // We only return "urlPath", so we can convert
- // the entire docPath for case-insensitive comparisons
- var os = GetOS();
- var doCaseInsensitive = (docScheme.toLowerCase() == "file" && os == gWin);
- if (doCaseInsensitive)
- docPath = docPath.toLowerCase();
-
- // Get document filename before we start chopping up the docPath
- var docFilename = GetFilename(docPath);
-
- // Both url and doc paths now begin with "/"
- // Look for shared dirs starting after that
- urlPath = urlPath.slice(1);
- docPath = docPath.slice(1);
-
- var firstDirTest = true;
- var nextDocSlash = 0;
- var done = false;
-
- // Remove all matching subdirs common to both doc and input urls
- do {
- nextDocSlash = docPath.indexOf("\/");
- var nextUrlSlash = urlPath.indexOf("\/");
-
- if (nextUrlSlash == -1)
- {
- // We're done matching and all dirs in url
- // what's left is the filename
- done = true;
-
- // Remove filename for named anchors in the same file
- if (nextDocSlash == -1 && docFilename)
- {
- var anchorIndex = urlPath.indexOf("#");
- if (anchorIndex > 0)
- {
- var urlFilename = doCaseInsensitive ? urlPath.toLowerCase() : urlPath;
-
- if (urlFilename.indexOf(docFilename) == 0)
- urlPath = urlPath.slice(anchorIndex);
- }
- }
- }
- else if (nextDocSlash >= 0)
- {
- // Test for matching subdir
- var docDir = docPath.slice(0, nextDocSlash);
- var urlDir = urlPath.slice(0, nextUrlSlash);
- if (doCaseInsensitive)
- urlDir = urlDir.toLowerCase();
-
- if (urlDir == docDir)
- {
-
- // Remove matching dir+"/" from each path
- // and continue to next dir
- docPath = docPath.slice(nextDocSlash+1);
- urlPath = urlPath.slice(nextUrlSlash+1);
- }
- else
- {
- // No match, we're done
- done = true;
-
- // Be sure we are on the same local drive or volume
- // (the first "dir" in the path) because we can't
- // relativize to different drives/volumes.
- // UNIX doesn't have volumes, so we must not do this else
- // the first directory will be misinterpreted as a volume name
- if (firstDirTest && docScheme == "file" && os != gUNIX)
- return inputUrl;
- }
- }
- else // No more doc dirs left, we're done
- done = true;
-
- firstDirTest = false;
- }
- while (!done);
-
- // Add "../" for each dir left in docPath
- while (nextDocSlash > 0)
- {
- urlPath = "../" + urlPath;
- nextDocSlash = docPath.indexOf("\/", nextDocSlash+1);
- }
- return urlPath;
-}
-
-function MakeAbsoluteUrl(url)
-{
- var resultUrl = TrimString(url);
- if (!resultUrl)
- return resultUrl;
-
- // Check if URL is already absolute, i.e., it has a scheme
- var urlScheme = GetScheme(resultUrl);
-
- if (urlScheme)
- return resultUrl;
-
- var docUrl = GetDocumentBaseUrl();
- var docScheme = GetScheme(docUrl);
-
- // Can't relativize if no doc scheme (page hasn't been saved)
- if (!docScheme)
- return resultUrl;
-
- var IOService = GetIOService();
- if (!IOService)
- return resultUrl;
-
- // Make a URI object to use its "resolve" method
- var absoluteUrl = resultUrl;
- var docUri = IOService.newURI(docUrl, null);
-
- try {
- absoluteUrl = docUri.resolve(resultUrl);
- // This is deprecated and buggy!
- // If used, we must make it a path for the parent directory (remove filename)
- //absoluteUrl = IOService.resolveRelativePath(resultUrl, docUrl);
- } catch (e) {}
-
- return absoluteUrl;
-}
-
-// Get the HREF of the page's tag or the document location
-// returns empty string if no base href and document hasn't been saved yet
-function GetDocumentBaseUrl()
-{
- if (window.editorShell)
- {
- var docUrl;
-
- // if document supplies a tag, use that URL instead
- var baseList = editorShell.editorDocument.getElementsByTagName("base");
- if (baseList)
- {
- var base = baseList.item(0);
- if (base)
- docUrl = base.getAttribute("href");
- }
- if (!docUrl)
- docUrl = editorShell.editorDocument.location.href;
-
- if (docUrl != "about:blank")
- return docUrl;
- }
- return "";
-}
-
-function GetIOService()
-{
- if (gIOService)
- return gIOService;
-
- var CID = Components.classes["@mozilla.org/network/io-service;1"];
- gIOService = CID.getService(Components.interfaces.nsIIOService);
- return gIOService;
-}
-
-// Extract the scheme (e.g., 'file', 'http') from a URL string
-function GetScheme(url)
-{
- var resultUrl = TrimString(url);
- // Unsaved document URL has no acceptable scheme yet
- if (!resultUrl || resultUrl == "about:blank")
- return "";
-
- var IOService = GetIOService();
- if (!IOService)
- return "";
-
- var scheme = "";
- try {
- // This fails if there's no scheme
- scheme = IOService.extractScheme(resultUrl, {schemeStartPos:0}, {schemeEndPos:0});
- } catch (e) {}
-
- return scheme ? scheme : "";
-}
-
-function GetHost(url)
-{
- var IOService = GetIOService();
- if (!IOService)
- return "";
-
- var host = "";
- if (url)
- {
- try {
- host = IOService.extractUrlPart(url, IOService.url_Host, {start:0}, {end:0});
- } catch (e) {}
- }
- return host;
-}
-
-function GetFilename(url)
-{
- var IOService = GetIOService();
- if (!IOService)
- return "";
-
- var filename;
-
- if (url)
- {
- try {
- filename = IOService.extractUrlPart(url, IOService.url_FileBaseName, {start:0}, {end:0});
- if (filename)
- {
- var ext = IOService.extractUrlPart(url, IOService.url_FileExtension, {start:0}, {end:0});
- if (ext)
- filename += "."+ext;
- }
- } catch (e) {}
- }
- return filename ? filename : "";
-}
-
-function GetOS()
-{
- if (gOS)
- return gOS;
-
- if (navigator.platform.toLowerCase().indexOf("win") >= 0)
- gOS = gWin;
- else if (navigator.platform.toLowerCase().indexOf("mac") >=0)
- gOS = gMac;
- else
- gOS = gUNIX;
-
- return gOS;
-}
diff --git a/mozilla/editor/ui/dialogs/content/EdDialogTemplate.xul b/mozilla/editor/ui/dialogs/content/EdDialogTemplate.xul
index f42a931305b..c1daaef2771 100644
--- a/mozilla/editor/ui/dialogs/content/EdDialogTemplate.xul
+++ b/mozilla/editor/ui/dialogs/content/EdDialogTemplate.xul
@@ -38,6 +38,7 @@
orient="vertical">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdDictionary.xul b/mozilla/editor/ui/dialogs/content/EdDictionary.xul
index 47e55c42899..595026e1089 100644
--- a/mozilla/editor/ui/dialogs/content/EdDictionary.xul
+++ b/mozilla/editor/ui/dialogs/content/EdDictionary.xul
@@ -30,6 +30,7 @@
onunload="Close()">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdHLineProps.xul b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul
index 007eef9c9f0..11556d76f10 100644
--- a/mozilla/editor/ui/dialogs/content/EdHLineProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul
@@ -38,6 +38,7 @@
ondialogcancel="return onCancel();">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdImageMap.js b/mozilla/editor/ui/dialogs/content/EdImageMap.js
index dc4cc4cf8f2..018c7c687e2 100644
--- a/mozilla/editor/ui/dialogs/content/EdImageMap.js
+++ b/mozilla/editor/ui/dialogs/content/EdImageMap.js
@@ -66,7 +66,7 @@ function initDialog(){
//check for relative url
if (!((srcInput.value.indexOf("http://") != -1) || (srcInput.value.indexOf("file://") != -1))){
- if (editorShell.editorDocument.location == "about:blank"){
+ if (IsUrlAboutBlank(editorShell.editorDocument.location)){
alert(GetString("SaveToUseRelativeUrl"));
window.close();
//TODO: add option to save document now
diff --git a/mozilla/editor/ui/dialogs/content/EdImageMap.xul b/mozilla/editor/ui/dialogs/content/EdImageMap.xul
index 7d3ad2d830f..bad069040ba 100644
--- a/mozilla/editor/ui/dialogs/content/EdImageMap.xul
+++ b/mozilla/editor/ui/dialogs/content/EdImageMap.xul
@@ -25,6 +25,7 @@
+
@@ -44,6 +45,7 @@
width="640" height="480">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdImageMapHotSpot.xul b/mozilla/editor/ui/dialogs/content/EdImageMapHotSpot.xul
index 4db3012b8e9..0108736d055 100644
--- a/mozilla/editor/ui/dialogs/content/EdImageMapHotSpot.xul
+++ b/mozilla/editor/ui/dialogs/content/EdImageMapHotSpot.xul
@@ -36,6 +36,7 @@
>
+
diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.js b/mozilla/editor/ui/dialogs/content/EdImageProps.js
index ad648aa8822..f52c51119da 100644
--- a/mozilla/editor/ui/dialogs/content/EdImageProps.js
+++ b/mozilla/editor/ui/dialogs/content/EdImageProps.js
@@ -48,6 +48,7 @@ var gHaveDocumentUrl = false;
var gPreviewImageWidth = 80;
var gPreviewImageHeight = 50;
var StartupCalled = false;
+var gOkButton;
// dialog initialization code
@@ -86,6 +87,7 @@ function Startup()
gDialog.PreviewHeight = document.getElementById( "PreviewHeight" );
gDialog.PreviewSize = document.getElementById( "PreviewSize" );
gDialog.PreviewImage = null;
+ gDialog.OkButton = document.documentElement.getButton("accept");
// Get a single selected image element
var tagName = "img"
@@ -150,7 +152,6 @@ function Startup()
function InitDialog()
{
// Set the controls to the image's attributes
-
gDialog.srcInput.value = globalElement.getAttribute("src");
// Set "Relativize" checkbox according to current URL state
@@ -400,9 +401,7 @@ function doOverallEnabling()
wasEnableAll = canEnableOk;
- // anon. content, so can't use SetElementEnabledById here
- var dialogNode = document.getElementById("imageDlg");
- dialogNode.getButton("accept").disabled = !canEnableOk;
+ SetElementEnabled(gDialog.OkButton, canEnableOk);
SetElementEnabledById("AdvancedEditButton1", canEnableOk );
SetElementEnabledById( "imagemapLabel", canEnableOk );
@@ -427,16 +426,16 @@ function ToggleConstrain()
function constrainProportions( srcID, destID )
{
- var srcElement = document.getElementById ( srcID );
- if ( !srcElement )
+ var srcElement = document.getElementById(srcID);
+ if (!srcElement)
return;
- var destElement = document.getElementById( destID );
- if ( !destElement )
+ var destElement = document.getElementById(destID);
+ if (!destElement)
return;
// always force an integer (whether we are constraining or not)
- forceInteger( srcID );
+ forceInteger(srcID);
if (!actualWidth || !actualHeight ||
!(gDialog.constrainCheckbox.checked && !gDialog.constrainCheckbox.disabled))
diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.xul b/mozilla/editor/ui/dialogs/content/EdImageProps.xul
index 9207b57c114..862050a9285 100644
--- a/mozilla/editor/ui/dialogs/content/EdImageProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdImageProps.xul
@@ -42,6 +42,7 @@
ondialogcancel="return onCancel();"
ondialoghelp="return doHelpButton();">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdInsSrc.xul b/mozilla/editor/ui/dialogs/content/EdInsSrc.xul
index 24f06bf414e..edadb8e2990 100644
--- a/mozilla/editor/ui/dialogs/content/EdInsSrc.xul
+++ b/mozilla/editor/ui/dialogs/content/EdInsSrc.xul
@@ -36,6 +36,7 @@
onunload="onCancel()">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdInsertChars.xul b/mozilla/editor/ui/dialogs/content/EdInsertChars.xul
index 97600382ef8..3d7eabd331b 100644
--- a/mozilla/editor/ui/dialogs/content/EdInsertChars.xul
+++ b/mozilla/editor/ui/dialogs/content/EdInsertChars.xul
@@ -38,6 +38,7 @@
ondialogcancel = "return onClose();">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdInsertTable.xul b/mozilla/editor/ui/dialogs/content/EdInsertTable.xul
index 9f4cc5ab231..3e7538c11ec 100644
--- a/mozilla/editor/ui/dialogs/content/EdInsertTable.xul
+++ b/mozilla/editor/ui/dialogs/content/EdInsertTable.xul
@@ -39,6 +39,7 @@
persist="screenX screenY">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdLinkProps.xul b/mozilla/editor/ui/dialogs/content/EdLinkProps.xul
index c6f85d7e91b..cd98984151b 100644
--- a/mozilla/editor/ui/dialogs/content/EdLinkProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdLinkProps.xul
@@ -38,6 +38,7 @@
ondialogcancel="return onCancel();"
ondialoghelp="return doHelpButton();">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdListProps.xul b/mozilla/editor/ui/dialogs/content/EdListProps.xul
index afd461dd369..bf6635f8fbf 100644
--- a/mozilla/editor/ui/dialogs/content/EdListProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdListProps.xul
@@ -34,6 +34,7 @@
onunload="onCancel()">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdNamedAnchorProps.xul b/mozilla/editor/ui/dialogs/content/EdNamedAnchorProps.xul
index b3497fbff45..11c45a16753 100644
--- a/mozilla/editor/ui/dialogs/content/EdNamedAnchorProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdNamedAnchorProps.xul
@@ -38,6 +38,7 @@
onunload="onCancel()">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdPageProps.js b/mozilla/editor/ui/dialogs/content/EdPageProps.js
index 3df09fc2fe7..4c98870bf47 100644
--- a/mozilla/editor/ui/dialogs/content/EdPageProps.js
+++ b/mozilla/editor/ui/dialogs/content/EdPageProps.js
@@ -48,7 +48,7 @@ function Startup()
var location = editorShell.editorDocument.location;
var lastmodString = GetString("Unknown");
- if (location != "about:blank")
+ if (!IsUrlAboutBlank(location))
{
gDialog.PageLocation.setAttribute("value", editorShell.editorDocument.location);
diff --git a/mozilla/editor/ui/dialogs/content/EdPageProps.xul b/mozilla/editor/ui/dialogs/content/EdPageProps.xul
index a9f3450b407..50e703de3c2 100644
--- a/mozilla/editor/ui/dialogs/content/EdPageProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdPageProps.xul
@@ -36,6 +36,7 @@
ondialogcancel="return onCancel();">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdSpellCheck.xul b/mozilla/editor/ui/dialogs/content/EdSpellCheck.xul
index bbf4a62b397..1422aaf2b57 100644
--- a/mozilla/editor/ui/dialogs/content/EdSpellCheck.xul
+++ b/mozilla/editor/ui/dialogs/content/EdSpellCheck.xul
@@ -32,6 +32,7 @@
onload = "Startup()"
onunload = "onClose()">
+
diff --git a/mozilla/editor/ui/dialogs/content/EdTableProps.xul b/mozilla/editor/ui/dialogs/content/EdTableProps.xul
index 98f1841d74f..76fd819e643 100644
--- a/mozilla/editor/ui/dialogs/content/EdTableProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdTableProps.xul
@@ -37,6 +37,7 @@
onunload="onCancel()">
+
diff --git a/mozilla/editor/ui/dialogs/content/EditConflict.xul b/mozilla/editor/ui/dialogs/content/EditConflict.xul
index b635961bb82..d90c8ffb11f 100644
--- a/mozilla/editor/ui/dialogs/content/EditConflict.xul
+++ b/mozilla/editor/ui/dialogs/content/EditConflict.xul
@@ -36,6 +36,7 @@
onunload="PreventCancel()">
+
diff --git a/mozilla/editor/ui/dialogs/content/EditorPublish.js b/mozilla/editor/ui/dialogs/content/EditorPublish.js
new file mode 100644
index 00000000000..93b4c04ddb7
--- /dev/null
+++ b/mozilla/editor/ui/dialogs/content/EditorPublish.js
@@ -0,0 +1,572 @@
+/*
+ * 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) 2001 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ */
+
+var gPublishPanel = 0;
+var gSettingsPanel = 1;
+var gCurrentPanel = gPublishPanel;
+var gPublishSiteData;
+var gReturnData;
+var gPublishDataChanged = false;
+var gDefaultSiteIndex = -1;
+var gDefaultSiteName;
+var gPreviousDefaultSite;
+var gPreviousDefaultDir;
+var gPreviousTitle;
+var gSettingsChanged = false;
+
+// Dialog initialization code
+function Startup()
+{
+ if (!InitEditorShell()) return;
+
+ // Element to edit is passed in
+ if (!window.arguments[1])
+ {
+ dump("Publish: Return data object not supplied\n");
+ window.close();
+ return;
+ }
+ gReturnData = window.arguments[gUrlIndex];
+
+ gDialog.TabPanels = document.getElementById("TabPanels");
+ gDialog.PublishTab = document.getElementById("PublishTab");
+ gDialog.SettingsTab = document.getElementById("SettingsTab");
+
+ // Publish panel
+ gDialog.PageTitleInput = document.getElementById("PageTitleInput");
+ gDialog.FilenameInput = document.getElementById("FilenameInput");
+ gDialog.SiteList = document.getElementById("SiteList");
+ gDialog.DirList = document.getElementById("DirList");
+
+ gDialog.MoreSection = document.getElementById("MoreSection");
+ gDialog.MoreFewerButton = document.getElementById("MoreFewerButton");
+
+ // Settings Panel
+ gDialog.SettingsPanel = document.getElementById("SettingsPanel");
+ gDialog.ServerSettingsBox = document.getElementById("ServerSettingsBox");
+ gDialog.SiteNameInput = document.getElementById("SiteNameInput");
+ gDialog.PublishUrlInput = document.getElementById("PublishUrlInput");
+ gDialog.BrowseUrlInput = document.getElementById("BrowseUrlInput");
+ gDialog.UserNameInput = document.getElementById("UserNameInput");
+
+ gDialog.PublishButton = document.documentElement.getButton("accept");
+
+ // Change 'Ok' button to 'Publish'
+ gDialog.PublishButton.setAttribute("label", GetString("Publish"));
+
+ gPublishSiteData = GetPublishSiteData();
+ gDefaultSiteName = GetDefaultPublishSiteName();
+ gPreviousDefaultSite = gDefaultSiteName;
+
+ InitDialog();
+
+ SeeMore = (gDialog.MoreFewerButton.getAttribute("more") != "1");
+ onMoreFewerPublish();
+
+ // If there's no current site data, start a new item in the Settings panel
+ if (!gPublishSiteData)
+ AddNewSite();
+ else
+ SetTextboxFocus(gDialog.PageTitleInput);
+
+ // This sets enable states on buttons
+ doEnabling();
+
+ SetWindowLocation();
+}
+
+function InitDialog()
+{
+ gPreviousTitle = editorShell.GetDocumentTitle();
+
+ var selectedSiteIndex = -1;
+ if (gPublishSiteData)
+ FillSiteList();
+
+ var docUrl = editorShell.editorDocument.location.href;
+ var scheme = GetScheme(docUrl);
+ var filename = "";
+ if (scheme)
+ {
+ filename = GetFilename(docUrl);
+
+ if (scheme.toLowerCase() != "file:")
+ {
+ // Editing a remote URL.
+ // Attempt to find doc URL in Site Data
+ if (gPublishSiteData)
+ {
+ // Remove filename from docUrl
+ var lastSlash = docUrl.lastIndexOf("\/");
+ var destinationDir = docUrl.slice(0, lastSlash);
+ selectedSiteIndex = FindDestinationUrlInPublishData(destinationDir);
+ }
+ }
+ }
+
+ // We didn't find a site -- use default
+ if (selectedSiteIndex == -1)
+ gDialog.SiteList.selectedIndex = gDefaultSiteIndex;
+
+ gDialog.PageTitleInput.value = gPreviousTitle;
+ gDialog.FilenameInput.value = filename;
+
+ // Settings panel widgets are filled in by InitSiteSettings() when we switch to that panel
+}
+
+function FindDestinationUrlInPublishData(url)
+{
+ if (!url)
+ return -1;
+ var siteIndex = -1;
+ var siteUrlLen = 0;
+ var urlLen = url.length;
+
+ if (gPublishSiteData)
+ {
+ for (var i = 0; i < gPublishSiteData.length; i++)
+ {
+ // Site url needs to be contained in document URL,
+ // but that may also have a directory after the site base URL
+ // So we must examine all records to find the site URL that best
+ // matches the document URL
+ if (url.indexOf(gPublishSiteData[i][gUrlIndex]) == 0)
+ {
+ var len = gPublishSiteData[i][gUrlIndex].length;
+ if (len > siteUrlLen)
+ {
+ siteIndex = i;
+ siteUrlLen = len;
+ // We must be done if doc exactly matches the site URL
+ if (len = urlLen)
+ break;
+ }
+ }
+ }
+ if (siteIndex >= 0)
+ {
+ // Select the site we found
+ gDialog.SiteList.selectedIndex = siteIndex;
+
+ // Set extra directory name from the end of url
+ if (urlLen > siteUrlLen)
+ gDialog.DirList.value = url.slice(siteUrlLen);
+ }
+ }
+ return siteIndex;
+}
+
+function FillSiteList()
+{
+ ClearMenulist(gDialog.SiteList);
+ gDefaultSiteIndex = -1;
+
+ // Fill the site lists
+ var count = gPublishSiteData.length;
+ var i;
+
+ for (i = 0; i < count; i++)
+ {
+ var name = gPublishSiteData[i][gNameIndex];
+ var menuitem = AppendStringToMenulist(gDialog.SiteList, name);
+ // Show checkmark in front of default site
+ if (name == gDefaultSiteName)
+ {
+ gDefaultSiteIndex = i;
+ if (menuitem)
+ {
+ menuitem.setAttribute("class", "menuitem-highlight-1");
+ menuitem.setAttribute("default", "true");
+ }
+ }
+ }
+}
+
+function doEnabling()
+{
+
+}
+
+function SelectSiteList()
+{
+dump(" *** SelectSiteList called\n");
+ // Fill the Directory list
+ if (!gPublishSiteData)
+ return;
+
+ var selectedSiteIndex = gDialog.SiteList.selectedIndex;
+ if (selectedSiteIndex == -1)
+ return;
+
+ var dirArray = gPublishSiteData[selectedSiteIndex][gDirListIndex];
+ for (var i = 0; i < dirArray.length; i++)
+ AppendStringToMenulist(gDialog.DirList, dirArray[i]);
+
+ gDialog.DirList.value = gPublishSiteData[selectedSiteIndex][gDefaultDirIndex];
+}
+
+function SetDefault()
+{
+ if (!gPublishSiteData)
+ return;
+
+ var index = gDialog.SiteList.selectedIndex;
+ if (index >= 0)
+ {
+ gDefaultSiteIndex = index;
+ gDefaultSiteName = gPublishSiteData[index][gNameIndex];
+ gSettingsChanged = false;
+ }
+}
+
+function onMoreFewerPublish()
+{
+ if (SeeMore)
+ {
+ gDialog.MoreSection.setAttribute("collapsed","true");
+ gDialog.ServerSettingsBox.setAttribute("collapsed","true");
+ window.sizeToContent();
+
+ gDialog.MoreFewerButton.setAttribute("more","0");
+ gDialog.MoreFewerButton.setAttribute("label",GetString("More"));
+ SeeMore = false;
+ }
+ else
+ {
+ gDialog.MoreSection.removeAttribute("collapsed");
+ gDialog.ServerSettingsBox.removeAttribute("collapsed");
+ window.sizeToContent();
+
+ gDialog.MoreFewerButton.setAttribute("more","1");
+ gDialog.MoreFewerButton.setAttribute("label",GetString("Less"));
+ SeeMore = true;
+ }
+}
+
+function AddNewSite()
+{
+ // Button in Publish panel allows user
+ // to automatically switch to "Settings" panel
+ // to enter data for new site
+ SwitchPanel(gSettingsPanel);
+
+ // Initialize Setting widgets to none of the selected sites
+ InitSiteSettings(-1);
+ SetTextboxFocus(gDialog.SiteNameInput);
+}
+
+function SelectPublishTab()
+{
+ if (gSettingsChanged)
+ {
+ gCurrentPanel = gPublishPanel;
+ if (!SaveSettingsData())
+ return;
+
+ gCurrentPanel = gSettingsPanel;
+ }
+
+ SwitchPanel(gPublishPanel);
+ SetTextboxFocus(gDialog.PageTitleInput);
+}
+
+function SelectSettingsTab()
+{
+ // Initialize Setting widgets based on Selectd Site from Publish panel
+ var index = gDialog.SiteList.selectedIndex;
+ if (index >= 0)
+ InitSiteSettings(index);
+
+ SwitchPanel(gSettingsPanel);
+ SetTextboxFocus(gDialog.SiteNameInput);
+}
+
+function InitSiteSettings(selectedSiteIndex)
+{
+ var siteName = "";
+ var publishUrl = "";
+ var browseUrl = "";
+ var username = "";
+ var password = "";
+ var savePassord = false;
+
+ if (gPublishSiteData && selectedSiteIndex >= 0)
+ {
+ siteName = gPublishSiteData[selectedSiteIndex][gNameIndex];
+ publishUrl = gPublishSiteData[selectedSiteIndex][gUrlIndex];
+ browseUrl = gPublishSiteData[selectedSiteIndex][gBrowseIndex];
+ username = gPublishSiteData[selectedSiteIndex][gUserNameIndex];
+ // TODO: HOW TO GET PASSWORD???
+ }
+
+ gDialog.SiteNameInput.value = siteName;
+ gDialog.PublishUrlInput.value = publishUrl;
+ gDialog.BrowseUrlInput.value = browseUrl;
+ gDialog.UserNameInput.value = username;
+ gDialog.SiteList.selectedIndex = selectedSiteIndex;
+
+ gSettingsChanged = false;
+}
+
+function SwitchPanel(panel)
+{
+ if (gCurrentPanel != panel)
+ {
+ // Set index for starting panel on the element
+ gDialog.TabPanels.setAttribute("selectedIndex", panel);
+ if (panel == gSettingsPanel)
+ {
+ // Trigger setting of style for the tab widgets
+ gDialog.SettingsTab.setAttribute("selected", "true");
+ gDialog.PublishTab.removeAttribute("selected");
+
+ // We collapse part of the Settings panel so the Publish Panel can be more compact
+ if (gDialog.ServerSettingsBox.getAttribute("collapsed"))
+ {
+ gDialog.ServerSettingsBox.removeAttribute("collapsed");
+ window.sizeToContent();
+ }
+ } else {
+ gDialog.PublishTab.setAttribute("selected", "true");
+ gDialog.SettingsTab.removeAttribute("selected");
+
+ if (!SeeMore)
+ {
+ gDialog.ServerSettingsBox.setAttribute("collapsed","true");
+ window.sizeToContent();
+ }
+ }
+ gCurrentPanel = panel;
+ }
+}
+
+function onInputSettings()
+{
+ // TODO: Save current data during SelectSite and compare here
+ // to detect if real change has occured?
+ gSettingsChanged = true;
+}
+
+function ShowErrorInPanel(panelId, errorMsgId, widgetWithError)
+{
+ SwitchPanel(panelId);
+ ShowInputErrorMessage(GetString(errorMsgId));
+ if (widgetWithError)
+ SetTextboxFocus(widgetWithError);
+}
+
+function ValidatePublishData()
+{
+ var selectedSiteIndex = gDialog.SiteList.selectedIndex;
+
+ if (selectedSiteIndex == -1)
+ {
+ if (gPublishSiteData)
+ selectedSiteIndex = gDefaultSiteIndex;
+ else
+ {
+ // No site selected!
+ ShowErrorInPanel(gPublishPanel, "MissingPublishSiteError", null);
+ AddNewSite();
+ }
+ }
+
+ var title = TrimString(gDialog.PageTitleInput.value);
+ var filename = TrimString(gDialog.FilenameInput.value);
+ if (!filename)
+ {
+ ShowErrorInPanel(gPublishPanel, "MissingPublishFilename", gDialog.FilenameInput);
+ return false;
+ }
+ gReturnData.Filename = filename;
+
+ if (selectedSiteIndex >=0 )
+ {
+ // Get rest of the data from the Site database
+ gReturnData.DestinationDir = gPublishSiteData[selectedSiteIndex][gUrlIndex];
+ gReturnData.BrowseDir = gPublishSiteData[selectedSiteIndex][gBrowseIndex];
+ gReturnData.UserName = gPublishSiteData[selectedSiteIndex][gUserNameIndex];
+ // TODO: HOW TO GET PASSWORD?
+ gReturnData.Password = "";
+ }
+ else
+ {
+ gReturnData.DestinationDir = "";
+ gReturnData.BrowseDir = "";
+ gReturnData.UserName = "";
+ gReturnData.Password = "";
+ }
+ // TODO; RELATED DOCS (IMAGES)
+
+ return true;
+}
+
+function ValidateSettingsData()
+{
+ if (gSettingsChanged)
+ return SaveSettingsData();
+
+ return true;
+}
+
+
+function SaveSettingsData()
+{
+ // Validate and add new site
+ var newName = TrimString(gDialog.SiteNameInput.value);
+ if (!newName)
+ {
+ ShowErrorInPanel(gSettingsPanel, "MissingSiteNameError", gDialog.SiteNameInput);
+ return false;
+ }
+ var newUrl = TrimString(gDialog.PublishUrlInput.value);
+ if (!newUrl)
+ {
+ ShowErrorInPanel(gSettingsPanel, "MissingPublishUrlError", gDialog.PublishUrlInput);
+ return false;
+ }
+
+ var siteIndex = -1;
+ if (!gPublishSiteData)
+ {
+dump(" * Create new gPublishSiteData\n");
+ // Create the first site profile
+ gPublishSiteData = new Array(1);
+ siteIndex = 0;
+ }
+ else
+ {
+ // Update existing site profile
+ siteIndex = gDialog.SiteList.selectedIndex;
+dump(" * Updating site data for list index = "+siteIndex+"\n");
+ if (siteIndex == -1)
+ {
+ // No site is selected -- add new data at the end
+ siteIndex = gPublishSiteData.length;
+ }
+ }
+dump(" * SaveSettingsData: NEW DATA AT index="+siteIndex+", gPublishSiteData.length="+gPublishSiteData.length+"\n");
+
+ gPublishSiteData[siteIndex] = new Array(gSiteDataLength);
+ gPublishSiteData[siteIndex][gNameIndex] = newName;
+ gPublishSiteData[siteIndex][gUrlIndex] = newUrl;
+ gPublishSiteData[siteIndex][gBrowseIndex] = TrimString(gDialog.BrowseUrlInput.value);
+ gPublishSiteData[siteIndex][gUserNameIndex] = TrimString(gDialog.UserNameInput.value);
+
+ if (siteIndex == gDefaultSiteIndex)
+ gDefaultSiteName = newName;
+
+dump(" Default SiteName = "+gDefaultSiteName+", Index="+gDefaultSiteIndex+"\n");
+
+dump("New Site Array: data="+gPublishSiteData[siteIndex][gNameIndex]+","+gPublishSiteData[siteIndex][gUrlIndex]+","+gPublishSiteData[siteIndex][gBrowseIndex]+","+gPublishSiteData[siteIndex][gUserNameIndex]+"\n");
+
+ var publishSiteName = gPublishSiteData[siteIndex][gNameIndex];
+
+ var count = gPublishSiteData.length;
+ if (count > 1)
+ {
+ // XXX Ascii sort, not locale-aware
+ gPublishSiteData.sort();
+
+ // Find previously-selected item in sorted list
+ for (var i = 0; i < count; i++)
+ {
+ dump(" Name #"+i+" = "+gPublishSiteData[i][gNameIndex]+"\n");
+
+ if (gPublishSiteData[i][gNameIndex] == publishSiteName)
+ {
+ siteIndex = i;
+ break;
+ }
+ }
+ }
+
+ // When adding the very first site, assume that's the default
+ if (count == 1 && !gDefaultSiteName)
+ {
+ gDefaultSiteName = gPublishSiteData[0][gNameIndex];
+ gDefaultSiteIndex = 0;
+ }
+
+ FillSiteList();
+ gDialog.SiteList.selectedIndex = siteIndex;
+
+ // Get the directory name -- add to database if not already there
+ // Because of the autoselect behavior in editable menulists,
+ // selectedIndex = -1 means value in input field is not already in the list
+ var dirIndex = gDialog.DirList.selectedIndex;
+ var dirName = TrimString(gDialog.DirList.value);
+ if (dirName && dirIndex == -1)
+ {
+ var dirListLen = gPublishSiteData[siteIndex][gDirListIndex].length;
+dump(" *** Current directory list length = "+dirListLen+"\n");
+ gPublishSiteData[siteIndex][gDirListIndex][dirListLen] = dirName;
+ }
+ gPublishSiteData[siteIndex][gDefaultDirIndex] = dirName;
+
+
+ gSettingsChanged = false;
+
+ SavePublishSiteDataToPrefs(gPublishSiteData, gDefaultSiteName);
+
+ return true;
+}
+
+function ValidateData()
+{
+ var result = true;;
+ var savePanel = gCurrentPanel;
+
+ // Validate current panel first
+ if (gCurrentPanel == gPublishPanel)
+ {
+ result = ValidatePublishData();
+ if (result)
+ result = ValidateSettingsData();
+
+ } else {
+ result = ValidateSettingsData();
+ if (result)
+ result = ValidatePublishData();
+ }
+ return result;
+}
+
+function doHelpButton()
+{
+ openHelp("chrome://help/content/help.xul?publish");
+}
+
+function onAccept()
+{
+ if (ValidateData())
+ {
+ var title = TrimString(gDialog.PageTitleInput.value);
+ if (title != gPreviousTitle)
+ editorShell.SetDocumentTitle(title);
+
+ SaveWindowLocation();
+ return true;
+ }
+
+ return false;
+}
diff --git a/mozilla/editor/ui/dialogs/content/EditorPublish.xul b/mozilla/editor/ui/dialogs/content/EditorPublish.xul
new file mode 100644
index 00000000000..f5ce05af2da
--- /dev/null
+++ b/mozilla/editor/ui/dialogs/content/EditorPublish.xul
@@ -0,0 +1,131 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mozilla/editor/ui/dialogs/content/EditorPublishOverlay.xul b/mozilla/editor/ui/dialogs/content/EditorPublishOverlay.xul
new file mode 100644
index 00000000000..abda1ca548b
--- /dev/null
+++ b/mozilla/editor/ui/dialogs/content/EditorPublishOverlay.xul
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mozilla/editor/ui/dialogs/content/EditorPublishSettings.js b/mozilla/editor/ui/dialogs/content/EditorPublishSettings.js
new file mode 100644
index 00000000000..ea4745d5985
--- /dev/null
+++ b/mozilla/editor/ui/dialogs/content/EditorPublishSettings.js
@@ -0,0 +1,324 @@
+/*
+ * 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) 2001 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ */
+
+var gPublishSiteData;
+var gPublishDataChanged = false;
+var gDefaultSiteIndex = -1;
+var gDefaultSiteName;
+var gPreviousDefaultSite;
+var gPreviousTitle;
+var gSettingsChanged = false;
+var gSiteDataChanged = false;
+
+// Dialog initialization code
+function Startup()
+{
+ if (!InitEditorShell()) return;
+
+ gDialog.SiteList = document.getElementById("SiteList");
+ gDialog.SiteNameInput = document.getElementById("SiteNameInput");
+ gDialog.PublishUrlInput = document.getElementById("PublishUrlInput");
+ gDialog.BrowseUrlInput = document.getElementById("BrowseUrlInput");
+ gDialog.UserNameInput = document.getElementById("UserNameInput");
+ gDialog.OkButton = document.documentElement.getButton("accept");
+
+ gPublishSiteData = GetPublishSiteData();
+ gDefaultSiteName = GetDefaultPublishSiteName();
+ gPreviousDefaultSite = gDefaultSiteName;
+
+ InitDialog();
+
+ SetWindowLocation();
+}
+
+function InitDialog()
+{
+ // If there's no current site data, start a new item in the Settings panel
+ if (!gPublishSiteData)
+ {
+ AddNewSite();
+ }
+ else
+ {
+ FillSiteList();
+ InitSiteSettings(gDefaultSiteIndex);
+ SetTextboxFocus(gDialog.SiteNameInput);
+ }
+}
+
+function FillSiteList()
+{
+ ClearTreelist(gDialog.SiteList);
+ gDefaultSiteIndex = -1;
+
+ // Fill the site lists
+ var count = gPublishSiteData.length;
+ var i;
+
+ for (i = 0; i < count; i++)
+ {
+ var name = gPublishSiteData[i][gNameIndex];
+ var menuitem = AppendStringToTreelist(gDialog.SiteList, name);
+
+ // Add a cell before the text to display a check for default site
+ if (menuitem)
+ {
+ var checkCell = document.createElementNS(XUL_NS, "treecell");
+ checkCell.setAttribute("class", "treecell-check");
+
+ // Insert tree cell before the one created by AppendStringToTreelist():
+ // (menuitem=treeitem) -> treerow -> treecell
+ menuitem.firstChild.insertBefore(checkCell, menuitem.firstChild.firstChild);
+
+ // Show checkmark in front of default site
+ if (name == gDefaultSiteName)
+ {
+ gDefaultSiteIndex = i;
+dump(" *** Setting checked style on tree item\n");
+ checkCell.setAttribute("checked", "true");
+ menuitem.setAttribute("checked", "true");
+ }
+ }
+ }
+}
+
+function AddNewSite()
+{
+ // Save any pending changes locally first
+ if (gSettingsChanged && !UpdateSettings())
+ return;
+
+ // Initialize Setting widgets to none of the selected sites
+ InitSiteSettings(-1);
+ SetTextboxFocus(gDialog.SiteNameInput);
+}
+
+function RemoveSite()
+{
+ if (!gPublishSiteData)
+ return;
+
+ var count = gPublishSiteData.length;
+ var index = gDialog.SiteList.selectedIndex;
+ var item;
+ if (index >= 0)
+ item = gDialog.SiteList.selectedItems[0];
+
+dump(" **** Before remove: count = "+count+"\n");
+
+ // Remove one item from site array
+ gPublishSiteData.splice(index, 1);
+
+dump(" **** After remove: count = "+gPublishSiteData.length+"\n");
+ count--;
+
+ if (index >= count)
+ index--;
+
+ // Remove item from site list
+ if (item)
+ item.parentNode.removeChild(item);
+
+ InitSiteSettings(index);
+
+ gSiteDataChanged = true;
+}
+
+function SetDefault()
+{
+ if (!gPublishSiteData)
+ return;
+
+ var index = gDialog.SiteList.selectedIndex;
+ if (index >= 0)
+ {
+ gDefaultSiteIndex = index;
+ gDefaultSiteName = gPublishSiteData[index][gNameIndex];
+ }
+}
+
+// Recursion prevention: InitSiteSettings() changes selected item
+var gIsSelecting = false;
+
+function SelectSiteList()
+{
+ if (gIsSelecting)
+ return;
+
+ gIsSelecting = true;
+
+ // Save any pending changes locally first
+ if (gSettingsChanged && !UpdateSettings())
+ return;
+
+ InitSiteSettings(gDialog.SiteList.selectedIndex);
+
+ gIsSelecting = false;
+}
+
+function InitSiteSettings(selectedSiteIndex)
+{
+ var siteName = "";
+ var publishUrl = "";
+ var browseUrl = "";
+ var username = "";
+ var password = "";
+ var savePassord = false;
+
+ if (gPublishSiteData && selectedSiteIndex >= 0)
+ {
+ siteName = gPublishSiteData[selectedSiteIndex][gNameIndex];
+ publishUrl = gPublishSiteData[selectedSiteIndex][gUrlIndex];
+ browseUrl = gPublishSiteData[selectedSiteIndex][gBrowseIndex];
+ username = gPublishSiteData[selectedSiteIndex][gUserNameIndex];
+ // TODO: HOW TO GET PASSWORD???
+ }
+
+ gDialog.SiteList.selectedIndex = selectedSiteIndex;
+ gDialog.SiteNameInput.value = siteName;
+ gDialog.PublishUrlInput.value = publishUrl;
+ gDialog.BrowseUrlInput.value = browseUrl;
+ gDialog.UserNameInput.value = username;
+
+ gSettingsChanged = false;
+}
+
+function onInputSettings()
+{
+dump(" * onInputSettings\n");
+ // TODO: Save current data during SelectSite1 and compare here
+ // to detect if real change has occurred?
+ gSettingsChanged = true;
+}
+
+function UpdateSettings()
+{
+ // Validate and add new site
+ var newName = TrimString(gDialog.SiteNameInput.value);
+ if (!newName)
+ {
+ ShowInputErrorMessage(GetString("MissingSiteNameError"), gDialog.SiteNameInput);
+ return false;
+ }
+ var newUrl = TrimString(gDialog.PublishUrlInput.value);
+ if (!newUrl)
+ {
+ ShowInputErrorMessage(GetString("MissingPublishUrlError"), gDialog.PublishUrlInput);
+ return false;
+ }
+
+ var siteIndex = -1;
+ if (!gPublishSiteData)
+ {
+dump(" * Create new gPublishSiteData\n");
+ // Create the first site profile
+ gPublishSiteData = new Array(1);
+ siteIndex = 0;
+ }
+ else
+ {
+ // Update existing site profile
+ siteIndex = gDialog.SiteList.selectedIndex;
+ if (siteIndex == -1)
+ {
+ // But if none selected, add new data at the end
+ siteIndex = gPublishSiteData.length;
+ }
+ }
+dump(" * UpdateSettings: NEW DATA AT index="+siteIndex+", gPublishSiteData.length="+gPublishSiteData.length+"\n");
+
+ gPublishSiteData[siteIndex] = new Array(gSiteDataLength);
+ gPublishSiteData[siteIndex][gNameIndex] = newName;
+ gPublishSiteData[siteIndex][gUrlIndex] = newUrl;
+ gPublishSiteData[siteIndex][gBrowseIndex] = TrimString(gDialog.BrowseUrlInput.value);
+ gPublishSiteData[siteIndex][gUserNameIndex] = TrimString(gDialog.UserNameInput.value);
+
+ if (siteIndex == gDefaultSiteIndex)
+ gDefaultSiteName = newName;
+
+dump(" Default SiteName = "+gDefaultSiteName+", Index="+gDefaultSiteIndex+"\n");
+
+dump("New Site Array: data="+gPublishSiteData[siteIndex][gNameIndex]+","+gPublishSiteData[siteIndex][gUrlIndex]+","+gPublishSiteData[siteIndex][gBrowseIndex]+","+gPublishSiteData[siteIndex][gUserNameIndex]+"\n");
+
+ var count = gPublishSiteData.length;
+ if (count > 1)
+ {
+ // XXX Ascii sort, not locale-aware
+ gPublishSiteData.sort();
+
+ //Find previous items in sorted list
+ for (var i = 0; i < count; i++)
+ {
+ dump(" Name #"+i+" = "+gPublishSiteData[i][gNameIndex]+"\n");
+
+ if (gPublishSiteData[i][gNameIndex] == newName)
+ {
+ siteIndex = i;
+ break;
+ }
+ }
+ }
+
+ // When adding the very first site, assume that's the default
+ if (count == 1 && !gDefaultSiteName)
+ {
+ gDefaultSiteName = gPublishSiteData[0][gNameIndex];
+ gDefaultSiteIndex = 0;
+ }
+
+ FillSiteList();
+
+ gDialog.SiteList.selectedIndex = siteIndex;
+
+ gSettingsChanged = false;
+
+ gSiteDataChanged = true;
+
+ return true;
+}
+
+function doHelpButton()
+{
+ openHelp("chrome://help/content/help.xul?publishSettings");
+}
+
+function onAccept()
+{
+ // Save any pending changes locally first
+ if (gSettingsChanged && !UpdateSettings())
+ return false;
+
+ if (gSiteDataChanged)
+ {
+ // Save all local data to prefs
+ SavePublishSiteDataToPrefs(gPublishSiteData, gDefaultSiteName);
+ }
+ else if (gPreviousDefaultSite != gDefaultSiteName)
+ {
+ // only the default site was changed
+ SavePublishSiteDataToPrefs(null, gDefaultSiteName);
+ }
+
+ SaveWindowLocation();
+
+ return true;
+}
diff --git a/mozilla/editor/ui/dialogs/content/EditorPublishSettings.xul b/mozilla/editor/ui/dialogs/content/EditorPublishSettings.xul
new file mode 100644
index 00000000000..6ce92a17d35
--- /dev/null
+++ b/mozilla/editor/ui/dialogs/content/EditorPublishSettings.xul
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mozilla/editor/ui/dialogs/content/EditorSaveAsCharset.xul b/mozilla/editor/ui/dialogs/content/EditorSaveAsCharset.xul
index 1e1afe02de4..022e18dda04 100644
--- a/mozilla/editor/ui/dialogs/content/EditorSaveAsCharset.xul
+++ b/mozilla/editor/ui/dialogs/content/EditorSaveAsCharset.xul
@@ -39,6 +39,7 @@
style="width: 32em;">
+
diff --git a/mozilla/editor/ui/dialogs/content/MANIFEST b/mozilla/editor/ui/dialogs/content/MANIFEST
index 82200a60509..6458d30ff94 100644
--- a/mozilla/editor/ui/dialogs/content/MANIFEST
+++ b/mozilla/editor/ui/dialogs/content/MANIFEST
@@ -70,3 +70,8 @@ EditorSaveAsCharset.xul
EditorSaveAsCharset.js
EdConvertToTable.xul
EdConvertToTable.js
+EditorPublish.js
+EditorPublish.xul
+EditorPublishSettings.js
+EditorPublishSettings.xul
+EditorPublishOverlay.xul
diff --git a/mozilla/editor/ui/dialogs/content/makefile.win b/mozilla/editor/ui/dialogs/content/makefile.win
index 5e7fefd7870..7db98d64f11 100644
--- a/mozilla/editor/ui/dialogs/content/makefile.win
+++ b/mozilla/editor/ui/dialogs/content/makefile.win
@@ -73,6 +73,11 @@ CHROME_CONTENT = \
.\EditorSaveAsCharset.js \
.\EdConvertToTable.xul \
.\EdConvertToTable.js \
+ .\EditorPublish.xul \
+ .\EditorPublish.js \
+ .\EditorPublishSettings.xul \
+ .\EditorPublishSettings.js \
+ .\EditorPublishOverlay.xul \
$(NULL)
include <$(DEPTH)\config\rules.mak>
diff --git a/mozilla/editor/ui/dialogs/locale/en-US/EditorPublish.dtd b/mozilla/editor/ui/dialogs/locale/en-US/EditorPublish.dtd
new file mode 100644
index 00000000000..a84fbc0bb5c
--- /dev/null
+++ b/mozilla/editor/ui/dialogs/locale/en-US/EditorPublish.dtd
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mozilla/editor/ui/dialogs/locale/en-US/MANIFEST b/mozilla/editor/ui/dialogs/locale/en-US/MANIFEST
index ffeafce97a8..2b34f0274a2 100644
--- a/mozilla/editor/ui/dialogs/locale/en-US/MANIFEST
+++ b/mozilla/editor/ui/dialogs/locale/en-US/MANIFEST
@@ -44,3 +44,4 @@ EditorInsertChars.dtd
EditConflict.dtd
EditorSaveAsCharset.dtd
EditorConvertToTable.dtd
+EditorPublish.dtd
diff --git a/mozilla/editor/ui/dialogs/locale/en-US/makefile.win b/mozilla/editor/ui/dialogs/locale/en-US/makefile.win
index d46a4837b49..149ab6e5380 100644
--- a/mozilla/editor/ui/dialogs/locale/en-US/makefile.win
+++ b/mozilla/editor/ui/dialogs/locale/en-US/makefile.win
@@ -46,6 +46,7 @@ CHROME_L10N = \
.\EditorSaveAsCharset.dtd \
.\EdColorPicker.dtd \
.\EdConvertToTable.dtd \
+ .\EditorPublish.dtd \
$(NULL)
include <$(DEPTH)\config\rules.mak>