Editor JS utilities reorg (b=106374, r=kin, sr=hewitt) and first draft of new Publishing UI (b=88208, r=brade, sr=hewitt)

This commit is contained in:
cmanske%netscape.com 2001-11-15 15:28:24 +00:00
Родитель ab875e9236
Коммит 06512a771e
49 изменённых файлов: 2325 добавлений и 771 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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)

Просмотреть файл

@ -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");

Просмотреть файл

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

Просмотреть файл

@ -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:

Просмотреть файл

@ -63,10 +63,6 @@
persist="screenX screenY width height sizemode">
<script type="application/x-javascript" src="chrome://editor/content/editor.js"/>
<!--
Loaded by editorOverlay.js
<script type="application/x-javascript" src="chrome://editor/content/ComposerCommands.js"/>
-->
<script type="application/x-javascript" src="chrome://editor/content/EditorCommandsDebug.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EditorContextMenu.js"/>
<script type="application/x-javascript" src="chrome://global/content/strres.js"/>

Просмотреть файл

@ -27,6 +27,7 @@
<overlay id="editorOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/editorOverlay.js"/>
<script type="application/x-javascript" src="chrome://editor/content/ComposerCommands.js"/>
@ -78,13 +79,11 @@
<command id="cmd_open" oncommand="goDoCommand('cmd_open')"/>
<command id="cmd_openRemote" label="&openremoteCmd.label;" oncommand="goDoCommand('cmd_openRemote')"/>
<command id="cmd_close" label="&closeCmd.label;" oncommand="goDoCommand('cmd_close')"/>
<command id="cmd_printSetup" label="&printSetupCmd.label;" oncommand="goDoCommand('cmd_printSetup')"/>
<!--
<command id="cmd_printPreview" label="&printPreviewCmd.label;" oncommand="goDoCommand('cmd_printPreview')"/>
-->
<command id="cmd_print" oncommand="goDoCommand('cmd_print')"/>
<command id="cmd_quit" oncommand="goDoCommand('cmd_quit')"/>
</commandset>
@ -104,7 +103,7 @@
<command id="cmd_hline" oncommand="goDoCommand('cmd_hline')"/>
<command id="cmd_table" oncommand="goDoCommand('cmd_table')"/>
<command id="cmd_objectProperties" oncommand="goDoCommand('cmd_objectProperties')"/>
<command id="cmd_insertChars" oncommand="goDoCommand('cmd_insertChars')" label="&insertCharsCmd.label;"/>
<command id="cmd_insertChars" oncommand="goDoCommand('cmd_insertChars')" label="&insertCharsCmd.label;"/>
<command id="cmd_insertHTML" oncommand="goDoCommand('cmd_insertHTML')" label="&insertHTMLCmd.label;"/>
<command id="cmd_insertBreak" oncommand="goDoCommand('cmd_insertBreak')"/>
@ -113,6 +112,8 @@
<command id="cmd_AllTagsMode" oncommand="goDoCommand('cmd_AllTagsMode')" label="&AllTagsMode.label;"/>
<command id="cmd_HTMLSourceMode" oncommand="goDoCommand('cmd_HTMLSourceMode')"/>
<command id="cmd_PreviewMode" oncommand="goDoCommand('cmd_PreviewMode')" label="&PreviewMode.label;"/>
<!-- only used in context popup menu -->
<command id="cmd_editLink" oncommand="goDoCommand('cmd_editLink')"/>
<!-- dummy command used just to disable things in non-HTML modes -->
@ -128,6 +129,8 @@
<command id="cmd_saveAs" label="&saveAsCmd.label;" oncommand="goDoCommand('cmd_saveAs')"/>
<command id="cmd_exportToText" label="&exportToTextCmd.label;" oncommand="goDoCommand('cmd_exportToText')"/>
<command id="cmd_saveAsCharset" label="&saveAsCharsetCmd.label;" oncommand="goDoCommand('cmd_saveAsCharset')"/>
<command id="cmd_publish" oncommand="goDoCommand('cmd_publish')"/>
<command id="cmd_publishAs" oncommand="goDoCommand('cmd_publishAs')"/>
<command id="cmd_revert" label="&fileRevert.label;" oncommand="goDoCommand('cmd_revert')"/>
<command id="cmd_preview" oncommand="goDoCommand('cmd_preview')"/>
<command id="cmd_editSendPage" label="&sendPageCmd.label;"
@ -157,7 +160,7 @@
<command id="cmd_validate" oncommand="goDoCommand('cmd_validate')"/>
<command id="cmd_checkLinks" oncommand="goDoCommand('cmd_checkLinks')"/>
<command id="cmd_pasteQuote" oncommand="goDoCommand('cmd_pasteQuote')" label="&pasteAsQuotationCmd.label;"/>
<command id="cmd_publishSettings" oncommand="goDoCommand('cmd_publishSettings')"/>
</commandset>
<!-- style related commands that update on creation, and on selection change -->
@ -290,18 +293,24 @@
<menupopup id="menupopup_RecentFiles"/>
<!-- menuitems appended at runtime -->
</menu>
<menuseparator/>
<menuitem accesskey="&fileclose.accesskey;" key="closekb" observes="cmd_close"/>
<menuseparator/>
<menuitem accesskey="&filesave.accesskey;" key="savekb" observes="cmd_save"/>
<menuitem accesskey="&filesaveas.accesskey;" observes="cmd_saveAs"/>
<menuitem accesskey="&filesaveascharset.accesskey;" observes="cmd_saveAsCharset"/>
<menu label="&publish.label;" accesskey="&publishmenu.accesskey;">
<menupopup>
<menuitem label="&publish.label;" accesskey="&publishcmd.accesskey;" observes="cmd_publish"/>
</menupopup>
</menu>
<menuitem label="&publishAsCmd.label;" accesskey="&publishas.accesskey;" observes="cmd_publishAs"/>
<menuseparator/>
<menuitem accesskey="&fileexporttotext.accesskey;" observes="cmd_exportToText" id="fileExportToText"/>
<menuitem accesskey="&filerevert.accesskey;" observes="cmd_revert"/>
<menuseparator/>
<menuitem label="&previewCmd.label;" accesskey="&filepreview.accesskey;" observes="cmd_preview"/>
<menuitem id="previewInBrowser" label="&previewCmd.label;" accesskey="&filepreview.accesskey;" observes="cmd_preview"/>
<!-- menuitem id="menu_SendPage" is merged here from mailEditorOverlay.xul,
where "position" is assumed to be 14. Change that label if menu position changes. -->
where "position" is assumed to be just after 'previewInBrowser' -->
<!--Page setup gets overlaid here from platformGlobalOverlay.xul / -->
<menuitem id="printMenuItem" accesskey="&fileprint.accesskey;" key="printkb" observes="cmd_print" label="&printCmd.label;"/>
<!-- The Exit/Quit item is merged from platformGlobalOverlay.xul -->
@ -341,7 +350,8 @@
<menuitem id="menu_validate" observes="cmd_validate"
label="&validateCmd.label;"/>
<menuseparator id="menu_PrefsSeparator"/>
<menuitem id="menu_preferences" observes="cmd_preferences"/>
<menuitem id="menu_publishSettings" label="&publishSettings.label;" accesskey="&publishSettings.accesskey;" observes="cmd_publishSettings"/>
<menuitem id="menu_preferences" observes="cmd_preferences"/>
</menupopup>
</menu>

Просмотреть файл

@ -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
<script type="application/x-javascript" src="chrome://global/content/strres.js"/>
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 <base> 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 <base> 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;
}

Просмотреть файл

@ -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 = \

Просмотреть файл

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

Просмотреть файл

@ -37,6 +37,7 @@
</script>
<script type="application/x-javascript" src="chrome://editor/content/pref-composer.js"/>
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://global/content/strres.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;
}

Просмотреть файл

@ -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...

Просмотреть файл

@ -47,8 +47,13 @@
<!ENTITY filesave.keybinding "s">
<!ENTITY saveAsCmd.label "Save As...">
<!ENTITY filesaveas.accesskey "A">
<!ENTITY publish.label "Publish">
<!ENTITY publishmenu.accesskey "b">
<!ENTITY publishcmd.accesskey "P">
<!ENTITY publishAsCmd.label "Publish As...">
<!ENTITY publishas.accesskey "i">
<!ENTITY exportToTextCmd.label "Export to Text...">
<!ENTITY fileexporttotext.accesskey "t">
<!ENTITY fileexporttotext.accesskey "T">
<!ENTITY saveAsCharsetCmd.label "Save As Charset...">
<!ENTITY filesaveascharset.accesskey "h">
<!ENTITY previewCmd.label "Browse Page">
@ -75,6 +80,8 @@
<!ENTITY editmenu.accesskey "e">
<!ENTITY pasteAs.label "Paste As">
<!ENTITY pasteAs.accesskey "a">
<!ENTITY publishSettings.label "Publishing Site Settings...">
<!ENTITY publishSettings.accesskey "b">
<!-- For a "Paste" submenu when more than 1
clipboard formats are available -->

Просмотреть файл

@ -44,6 +44,7 @@
<popupset id="aTooltipSet" />
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<!-- element page functions -->
<script type="application/x-javascript" src="chrome://editor/content/EdAEHTMLAttributes.js"/>

Просмотреть файл

@ -34,6 +34,7 @@
onunload="onCancel()"
>
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdColorPicker.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />

Просмотреть файл

@ -37,6 +37,7 @@
onload="Startup()"
onunload="onCancel()">
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdColorProps.js"/>

Просмотреть файл

@ -39,6 +39,7 @@
style="min-width:20em">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />
<!--- Element-specific methods -->

Просмотреть файл

@ -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 <base> 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 <base> 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;
}

Просмотреть файл

@ -38,6 +38,7 @@
orient="vertical">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/Ed?????.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />

Просмотреть файл

@ -30,6 +30,7 @@
onunload="Close()">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDictionary.js"/>

Просмотреть файл

@ -38,6 +38,7 @@
ondialogcancel="return onCancel();">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<!--- Element-specific methods -->
<script type="application/x-javascript" src="chrome://editor/content/EdHLineProps.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

Просмотреть файл

@ -25,6 +25,7 @@
<?xml-stylesheet href="chrome://editor/skin/EdImageMap.css" type="text/css"?>
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<?xml-stylesheet href="chrome://editor/skin/" type="text/css"?>
@ -44,6 +45,7 @@
width="640" height="480">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js" />
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />
<script type="application/x-javascript" src="chrome://help/content/help.js"/>

Просмотреть файл

@ -36,6 +36,7 @@
>
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.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))

Просмотреть файл

@ -42,6 +42,7 @@
ondialogcancel="return onCancel();"
ondialoghelp="return doHelpButton();">
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdImageProps.js"/>
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>

Просмотреть файл

@ -36,6 +36,7 @@
onunload="onCancel()">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdInsSrc.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />

Просмотреть файл

@ -38,6 +38,7 @@
ondialogcancel = "return onClose();">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdInsertChars.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />

Просмотреть файл

@ -39,6 +39,7 @@
persist="screenX screenY">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdInsertTable.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js"/>

Просмотреть файл

@ -38,6 +38,7 @@
ondialogcancel="return onCancel();"
ondialoghelp="return doHelpButton();">
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdLinkProps.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />

Просмотреть файл

@ -34,6 +34,7 @@
onunload="onCancel()">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdListProps.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />

Просмотреть файл

@ -38,6 +38,7 @@
onunload="onCancel()">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdNamedAnchorProps.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.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);

Просмотреть файл

@ -36,6 +36,7 @@
ondialogcancel="return onCancel();">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdPageProps.js"/>

Просмотреть файл

@ -32,6 +32,7 @@
onload = "Startup()"
onunload = "onClose()">
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/utilityOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/builtinURLs.js"/>

Просмотреть файл

@ -37,6 +37,7 @@
onunload="onCancel()">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdTableProps.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />

Просмотреть файл

@ -36,6 +36,7 @@
onunload="PreventCancel()">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EditConflict.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.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 <tabpanels> 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;
}

Просмотреть файл

@ -0,0 +1,131 @@
<?xml version="1.0"?>
<!--
- 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):
-->
<?xml-stylesheet href="chrome://editor/skin/editor.css" type="text/css"?>
<?xml-stylesheet href="chrome://editor/skin/EditorDialog.css" type="text/css"?>
<?xul-overlay href="chrome://editor/content/EdDialogOverlay.xul"?>
<?xul-overlay href="chrome://editor/content/EditorPublishOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://editor/locale/EditorPublish.dtd">
<dialog title="&windowTitle.label;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Startup()"
buttons="accept,cancel,help"
ondialogaccept="return onAccept();"
ondialogcancel="return onCancel();"
ondialoghelp="return doHelpButton();">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EditorPublish.js"/>
<script type="application/x-javascript" src="chrome://editor/content/PublishPrefs.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />
<script type="application/x-javascript" src="chrome://help/content/help.js"/>
<spacer id="location" offsetY="50" persist="offsetX offsetY"/>
<broadcaster id="args" value=""/>
<tabbox>
<tabs flex="1">
<tab id="PublishTab" oncommand="SelectPublishTab()" label="&publishTab.label;"/>
<tab id="SettingsTab" oncommand="SelectSettingsTab()" label="&settingsTab.label;"/>
</tabs>
<tabpanels id="TabPanels">
<!-- PUBLISH PANEL -->
<vbox id="TablePanel">
<spacer class="spacer"/>
<grid pack="start">
<columns><column/><column/><column/></columns>
<rows>
<row align="center">
<label value="&siteList.label;"/>
<!-- Contents filled in at runtime -->
<menulist id="SiteList" class="minWidth15" onSelect="SelectSiteList();"/>
<hbox>
<button label="&newSiteButton.label;" oncommand="AddNewSite();"/>
<spacer flex="1"/>
</hbox>
</row>
<row>
<spacer class="spacer"/>
<spacer class="spacer"/>
<spacer class="spacer"/>
</row>
<row align="center">
<label value="&pageTitle.label;"/>
<textbox id="PageTitleInput" class="minWidth15"/>
<label value="&pageTitleExample.label;"/>
</row>
<row align="center">
<label value="&filename.label;"/>
<textbox id="FilenameInput" class="minWidth15"/>
<label value="&filenameExample.label;"/>
</row>
</rows>
</grid>
<spacer class="spacer"/>
<hbox>
<button id="MoreFewerButton" oncommand="onMoreFewerPublish()"
persist="more" style="min-width:6em !important"/>
<spacer flex="1"/>
</hbox>
<vbox id="MoreSection">
<groupbox>
<caption label="&siteDirector.label;"/>
<label value="&siteDirList.label;"/>
<hbox flex="1">
<!-- Contents filled in at runtime -->
<menulist id="DirList" class="minWidth20" editable="true" flex="1"/>
<button label="&chooseDirButton.label;" oncommand="ChooseDir();"/>
<spacer flex="1"/>
</hbox>
<!--
<hbox>
<button id="SetDefaultSiteAndDirButton" label="&setDefSiteAndDir.label;" oncommand="SetDefault();"/>
<spacer flex="1"/>
</hbox>
-->
</groupbox>
<groupbox>
<caption label="&relatedDocs.label;"/>
<tree rows="6" class="list" id="RelatedDocsList" flex="1">
<treecolgroup>
<treecol flex="1"/>
</treecolgroup>
</tree>
</groupbox>
</vbox>
</vbox><!-- Publish Panel -->
<!-- SETTINGS PANEL -->
<hbox id="SettingsPanel">
<!-- from EditorPublishOverlay.xul -->
<vbox id="PublishSettingsInputs"/>
</hbox><!-- Settings Panel -->
</tabpanels>
</tabbox>
</dialog>

Просмотреть файл

@ -0,0 +1,69 @@
<?xml version="1.0"?>
<!--
- 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):
-->
<?xml-stylesheet href="chrome://editor/skin/editor.css" type="text/css"?>
<?xml-stylesheet href="chrome://editor/skin/EditorDialog.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://editor/locale/EditorPublish.dtd">
<overlay id="EditorPublishOverlay"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox id="PublishSettingsInputs">
<groupbox id="ServerSettingsBox" orient="vertical">
<caption label="&serverInfo.label;"/>
<hbox align="center">
<label value="&siteName.label;"/>
<textbox id="SiteNameInput" class="MinWidth10em" oninput="onInputSettings();"/>
</hbox>
<spacer class="spacer"/>
<label value="&siteUrl.label;"/>
<textbox id="PublishUrlInput" class="MinWidth20em" oninput="onInputSettings();"/>
<spacer class="spacer"/>
<label value="&browseUrl.label;"/>
<textbox id="BrowseUrlInput" class="MinWidth20em" oninput="onInputSettings();"/>
</groupbox>
<groupbox id="LoginSettingsBox" orient="vertical">
<caption label="&loginInfo.label;"/>
<grid>
<columns><column flex="1"/><column flex="3"/></columns>
<rows>
<row align="center">
<label value="&userName.label;"/>
<textbox id="UserNameInput" class="MinWidth10em" flex="1" oninput="onInputSettings();"/>
</row>
<row align="center">
<label value="&password.label;"/>
<hbox>
<textbox id="PasswordInput" type="password" class="MinWidth5em"/>
<checkbox id="SavePassword" label="&savePassword.label;"/>
</hbox>
</row>
</rows>
</grid>
</groupbox>
</vbox>
</overlay>

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -0,0 +1,76 @@
<?xml version="1.0"?>
<!--
- 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):
-->
<?xml-stylesheet href="chrome://editor/skin/editor.css" type="text/css"?>
<?xml-stylesheet href="chrome://editor/skin/EditorDialog.css" type="text/css"?>
<?xul-overlay href="chrome://editor/content/EdDialogOverlay.xul"?>
<?xul-overlay href="chrome://editor/content/EditorPublishOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://editor/locale/EditorPublish.dtd">
<dialog title="&windowTitle.label;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Startup()"
buttons="accept,cancel,help"
ondialogaccept="return onAccept();"
ondialogcancel="return onCancel();"
ondialoghelp="return doHelpButton();">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EditorPublishSettings.js"/>
<script type="application/x-javascript" src="chrome://editor/content/PublishPrefs.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />
<script type="application/x-javascript" src="chrome://help/content/help.js"/>
<spacer id="location" offsetY="50" persist="offsetX offsetY"/>
<broadcaster id="args" value=""/>
<hbox id="SettingsPanel">
<groupbox align="center">
<caption label="&publishSites.label;"/>
<!-- XXX: If tree isn't wrapped in vbox, it appears BELOW next vbox -->
<vbox flex="1">
<tree rows="4" class="list" id="SiteList" flex="1" onselect="SelectSiteList();">
<treecolgroup>
<treecol/>
<treecol flex="1"/>
</treecolgroup>
</tree>
</vbox>
<hbox pack="center">
<vbox>
<button id="NewSiteButton" label="&newSiteButton.label;" oncommand="AddNewSite();"/>
<button id="SetDefaultButton" label="&setDefaultButton.label;" oncommand="SetDefault();"/>
<button id="RemoveSiteButton" label="&removeButton.label;" oncommand="RemoveSite();"/>
</vbox>
</hbox>
</groupbox>
<!-- from EditorPublishOverlay.xul -->
<vbox id="PublishSettingsInputs"/>
</hbox>
<spacer class="spacer"/>
</dialog>

Просмотреть файл

@ -39,6 +39,7 @@
style="width: 32em;">
<!-- Methods common to all editor dialogs -->
<script type="application/x-javascript" src="chrome://editor/content/editorUtilities.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EdDialogCommon.js"/>
<script type="application/x-javascript" src="chrome://editor/content/EditorSaveAsCharset.js"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js" />

Просмотреть файл

@ -70,3 +70,8 @@ EditorSaveAsCharset.xul
EditorSaveAsCharset.js
EdConvertToTable.xul
EdConvertToTable.js
EditorPublish.js
EditorPublish.xul
EditorPublishSettings.js
EditorPublishSettings.xul
EditorPublishOverlay.xul

Просмотреть файл

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

Просмотреть файл

@ -0,0 +1,54 @@
<!--
- 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):
-->
<!-- Window title -->
<!ENTITY windowTitle.label "Publish Page">
<!ENTITY publishTab.label "Publish">
<!ENTITY settingsTab.label "Settings">
<!-- Publish Tab Panel -->
<!ENTITY siteList.label "Site Name:">
<!ENTITY newSiteButton.label "New Site">
<!ENTITY siteDirList.label "Select or type a directory name in your publishing site:">
<!ENTITY siteDirector.label "Directory for HTML file">
<!ENTITY chooseDirButton.label "Choose...">
<!ENTITY pageTitle.label "Page Title:">
<!ENTITY pageTitleExample.label "e.g.: &quot;My Web Page&quot;">
<!ENTITY filename.label "Filename:">
<!ENTITY filenameExample.label "e.g,: &quot;mypage.html&quot;">
<!ENTITY relatedDocs.label "Other files to publish">
<!ENTITY setDefaultButton.label "Set as Default">
<!ENTITY setDefSiteAndDir.label "Set as Default Site and Directory">
<!ENTITY removeButton.label "Remove Site">
<!-- Settings Tab Panel -->
<!ENTITY publishSites.label "Publishing Sites">
<!ENTITY serverInfo.label "Server Information">
<!ENTITY loginInfo.label "Login Information">
<!ENTITY siteName.label "Site Name:">
<!ENTITY siteUrl.label "Publishing Location (provided by your ISP or Sys Admin.):">
<!ENTITY browseUrl.label "Home Page Location (if different from above):">
<!ENTITY userName.label "User Name:">
<!ENTITY password.label "Password:">
<!ENTITY savePassword.label "Save Password">

Просмотреть файл

@ -44,3 +44,4 @@ EditorInsertChars.dtd
EditConflict.dtd
EditorSaveAsCharset.dtd
EditorConvertToTable.dtd
EditorPublish.dtd

Просмотреть файл

@ -46,6 +46,7 @@ CHROME_L10N = \
.\EditorSaveAsCharset.dtd \
.\EdColorPicker.dtd \
.\EdConvertToTable.dtd \
.\EditorPublish.dtd \
$(NULL)
include <$(DEPTH)\config\rules.mak>