1999-11-13 19:37:58 +03:00
|
|
|
/*
|
|
|
|
* 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):
|
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
|
2000-02-15 18:54:05 +03:00
|
|
|
dialog = new Object;
|
|
|
|
if (!dialog)
|
2000-02-03 05:06:10 +03:00
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
dump("Failed to create dialog object!!!\n");
|
2000-02-03 05:06:10 +03:00
|
|
|
window.close();
|
|
|
|
}
|
2000-02-15 18:54:05 +03:00
|
|
|
dialog.PageLocation = document.getElementById("PageLocation");
|
|
|
|
dialog.TitleInput = document.getElementById("TitleInput");
|
|
|
|
dialog.AuthorInput = document.getElementById("AuthorInput");
|
|
|
|
dialog.DescriptionInput = document.getElementById("DescriptionInput");
|
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
|
|
|
doSetOKCancel(onOK, onCancel);
|
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");
|
|
|
|
dump("location="+location);
|
2000-02-15 18:54:05 +03:00
|
|
|
if (location != "about:blank")
|
2000-04-29 03:35:36 +04:00
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
dialog.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
|
|
|
|
var lastmoddate = Date.parse(lastmod); // convert modified string to date
|
2000-09-02 02:01:44 +04:00
|
|
|
if(lastmoddate != 0) // unknown date (or January 1, 1970 GMT)
|
|
|
|
lastmodString = lastmoddate;
|
2000-06-16 18:22:12 +04:00
|
|
|
|
2000-04-29 03:35:36 +04:00
|
|
|
}
|
2000-09-02 02:01:44 +04:00
|
|
|
dump(", lastmod date="+lastmoddate+"\n");
|
|
|
|
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)
|
|
|
|
window.close();
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
Big UI fix! bugs=47898, 26843, 26871, 37152, 38944, 41545, 42246, 42343, 43089, 45463, 45904, 46001, 47644, 47314, 47510, 47515, 47622, 47650, 47653, 47699, 47700, 46179, 47696, 47693. r=sfraser
2000-08-10 06:10:17 +04:00
|
|
|
SetTextfieldFocus(dialog.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()
|
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
dialog.TitleInput.value = editorShell.GetDocumentTitle();
|
2000-08-11 07:20:47 +04:00
|
|
|
var author = authorElement.getAttribute("content").trimString();
|
|
|
|
if (author.length == 0)
|
|
|
|
{
|
|
|
|
// Fill in with value from editor prefs
|
|
|
|
var prefs = GetPrefs();
|
|
|
|
if (prefs)
|
|
|
|
author = prefs.CopyCharPref("editor.author");
|
|
|
|
}
|
|
|
|
dialog.AuthorInput.value = author;
|
2000-02-15 18:54:05 +03:00
|
|
|
dialog.DescriptionInput.value = descriptionElement.getAttribute("content");
|
1999-12-02 01:20:50 +03:00
|
|
|
}
|
|
|
|
|
2000-04-28 09:59:16 +04:00
|
|
|
function TextfieldChanged(ID)
|
|
|
|
{
|
|
|
|
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()
|
|
|
|
{
|
2000-10-05 19:01:23 +04:00
|
|
|
newTitle = dialog.TitleInput.value.trimString();
|
2000-02-15 18:54:05 +03:00
|
|
|
author = dialog.AuthorInput.value.trimString();
|
|
|
|
description = dialog.DescriptionInput.value.trimString();
|
|
|
|
return true;
|
2000-02-03 05:06:10 +03:00
|
|
|
}
|
|
|
|
|
1999-11-13 19:37:58 +03:00
|
|
|
function onOK()
|
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
if (ValidateData())
|
|
|
|
{
|
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
|
|
|
|
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
|
|
|
|