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">