2001-09-20 04:02:59 +04:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Netscape Public
|
1999-11-13 19:37:58 +03:00
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
2001-09-20 04:02:59 +04:00
|
|
|
* the License at http://www.mozilla.org/NPL/
|
|
|
|
*
|
1999-11-13 19:37:58 +03:00
|
|
|
* 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.
|
2001-09-20 04:02:59 +04:00
|
|
|
*
|
|
|
|
* 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
|
1999-11-13 19:37:58 +03:00
|
|
|
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
2001-09-20 04:02:59 +04:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*/
|
1999-11-13 19:37:58 +03:00
|
|
|
|
2000-10-05 19:01:23 +04:00
|
|
|
var newTitle = "";
|
2000-02-15 18:54:05 +03:00
|
|
|
var author = "";
|
|
|
|
var description = "";
|
|
|
|
var authorElement;
|
|
|
|
var descriptionElement;
|
|
|
|
var insertNewAuthor = false;
|
|
|
|
var insertNewDescription = false;
|
2000-04-28 09:59:16 +04:00
|
|
|
var titleWasEdited = false;
|
|
|
|
var authorWasEdited = false;
|
|
|
|
var descWasEdited = false;
|
1999-11-13 19:37:58 +03:00
|
|
|
|
|
|
|
//Cancel() is in EdDialogCommon.js
|
|
|
|
// dialog initialization code
|
|
|
|
function Startup()
|
|
|
|
{
|
|
|
|
if (!InitEditorShell())
|
|
|
|
return;
|
|
|
|
|
2001-10-11 00:07:06 +04:00
|
|
|
gDialog.PageLocation = document.getElementById("PageLocation");
|
|
|
|
gDialog.TitleInput = document.getElementById("TitleInput");
|
|
|
|
gDialog.AuthorInput = document.getElementById("AuthorInput");
|
|
|
|
gDialog.DescriptionInput = document.getElementById("DescriptionInput");
|
2000-02-15 18:54:05 +03:00
|
|
|
|
|
|
|
// Default string for new page is set from DTD string in XUL,
|
|
|
|
// so set only if not new doc URL
|
|
|
|
var location = editorShell.editorDocument.location;
|
2000-09-02 02:01:44 +04:00
|
|
|
var lastmodString = GetString("Unknown");
|
2001-08-03 02:00:59 +04:00
|
|
|
|
2001-11-15 18:28:24 +03:00
|
|
|
if (!IsUrlAboutBlank(location))
|
2000-04-29 03:35:36 +04:00
|
|
|
{
|
2001-10-11 00:07:06 +04:00
|
|
|
gDialog.PageLocation.setAttribute("value", editorShell.editorDocument.location);
|
2000-06-16 18:22:12 +04:00
|
|
|
|
2000-04-29 03:35:36 +04:00
|
|
|
// Get last-modified file date+time
|
|
|
|
// TODO: Convert this to local time?
|
2000-06-16 18:22:12 +04:00
|
|
|
var lastmod = editorShell.editorDocument.lastModified; // get string of last modified date
|
|
|
|
|
2001-11-30 02:49:02 +03:00
|
|
|
// Convert modified string to date (0 = unknown date or January 1, 1970 GMT)
|
|
|
|
if (Date.parse(lastmod))
|
|
|
|
lastmodString = lastmod;
|
2000-04-29 03:35:36 +04:00
|
|
|
}
|
2000-09-02 02:01:44 +04:00
|
|
|
document.getElementById("PageModDate").setAttribute("value", lastmodString);
|
2000-02-15 18:54:05 +03:00
|
|
|
|
|
|
|
authorElement = GetMetaElement("author");
|
|
|
|
if (!authorElement)
|
2000-02-03 05:06:10 +03:00
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
authorElement = CreateMetaElement("author");
|
|
|
|
if (!authorElement)
|
2001-05-09 09:23:37 +04:00
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
window.close();
|
2001-05-09 09:23:37 +04:00
|
|
|
return;
|
|
|
|
}
|
2000-02-15 18:54:05 +03:00
|
|
|
insertNewAuthor = true;
|
2000-02-03 05:06:10 +03:00
|
|
|
}
|
|
|
|
|
2000-02-15 18:54:05 +03:00
|
|
|
descriptionElement = GetMetaElement("description");
|
|
|
|
if (!descriptionElement)
|
2000-02-03 05:06:10 +03:00
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
descriptionElement = CreateMetaElement("description");
|
|
|
|
if (!descriptionElement)
|
|
|
|
window.close();
|
2000-02-03 05:06:10 +03:00
|
|
|
|
2000-02-15 18:54:05 +03:00
|
|
|
insertNewDescription = true;
|
|
|
|
}
|
2000-04-28 09:59:16 +04:00
|
|
|
|
2000-02-03 05:06:10 +03:00
|
|
|
InitDialog();
|
|
|
|
|
2001-10-11 00:07:06 +04:00
|
|
|
SetTextboxFocus(gDialog.TitleInput);
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
|
|
|
|
SetWindowLocation();
|
1999-11-13 19:37:58 +03:00
|
|
|
}
|
|
|
|
|
1999-12-02 01:20:50 +03:00
|
|
|
function InitDialog()
|
|
|
|
{
|
2001-10-11 00:07:06 +04:00
|
|
|
gDialog.TitleInput.value = editorShell.GetDocumentTitle();
|
2001-10-26 22:51:37 +04:00
|
|
|
var author = TrimString(authorElement.getAttribute("content"));
|
2000-08-11 07:20:47 +04:00
|
|
|
if (author.length == 0)
|
|
|
|
{
|
|
|
|
// Fill in with value from editor prefs
|
|
|
|
var prefs = GetPrefs();
|
|
|
|
if (prefs)
|
2001-10-27 09:39:25 +04:00
|
|
|
author = prefs.getCharPref("editor.author");
|
2000-08-11 07:20:47 +04:00
|
|
|
}
|
2001-10-11 00:07:06 +04:00
|
|
|
gDialog.AuthorInput.value = author;
|
|
|
|
gDialog.DescriptionInput.value = descriptionElement.getAttribute("content");
|
1999-12-02 01:20:50 +03:00
|
|
|
}
|
|
|
|
|
2001-03-22 03:15:47 +03:00
|
|
|
function TextboxChanged(ID)
|
2000-04-28 09:59:16 +04:00
|
|
|
{
|
|
|
|
switch(ID)
|
|
|
|
{
|
|
|
|
case "TitleInput":
|
|
|
|
titleWasEdited = true;
|
|
|
|
break;
|
|
|
|
case "AuthorInput":
|
|
|
|
authorWasEdited = true;
|
|
|
|
break;
|
|
|
|
case "DescriptionInput":
|
|
|
|
descWasEdited = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-15 18:54:05 +03:00
|
|
|
function ValidateData()
|
|
|
|
{
|
2001-10-26 22:51:37 +04:00
|
|
|
newTitle = TrimString(gDialog.TitleInput.value);
|
|
|
|
author = TrimString(gDialog.AuthorInput.value);
|
|
|
|
description = TrimString(gDialog.DescriptionInput.value);
|
2000-02-15 18:54:05 +03:00
|
|
|
return true;
|
2000-02-03 05:06:10 +03:00
|
|
|
}
|
|
|
|
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2001-11-03 07:06:54 +03:00
|
|
|
function onAccept()
|
1999-11-13 19:37:58 +03:00
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
if (ValidateData())
|
|
|
|
{
|
2001-02-27 00:51:44 +03:00
|
|
|
editorShell.BeginBatchChanges();
|
2000-04-28 09:59:16 +04:00
|
|
|
if (titleWasEdited)
|
|
|
|
{
|
|
|
|
// Set title contents even if string is empty
|
|
|
|
// because TITLE is a required HTML element
|
2000-10-05 19:01:23 +04:00
|
|
|
editorShell.SetDocumentTitle(newTitle);
|
2000-04-28 09:59:16 +04:00
|
|
|
}
|
2000-02-15 18:54:05 +03:00
|
|
|
|
2000-04-28 09:59:16 +04:00
|
|
|
if (authorWasEdited)
|
|
|
|
SetMetaElementContent(authorElement, author, insertNewAuthor);
|
|
|
|
if (descWasEdited)
|
|
|
|
SetMetaElementContent(descriptionElement, description, insertNewDescription);
|
2000-02-15 18:54:05 +03:00
|
|
|
|
2001-02-27 00:51:44 +03:00
|
|
|
editorShell.EndBatchChanges();
|
|
|
|
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
SaveWindowLocation();
|
2000-02-15 18:54:05 +03:00
|
|
|
return true; // do close the window
|
|
|
|
}
|
|
|
|
return false;
|
1999-11-13 19:37:58 +03:00
|
|
|
}
|
2000-02-15 18:54:05 +03:00
|
|
|
|