Update on insert Form widgets dialogs, b=45495, fixes by neil/cmanske, r=neil/cmanske, sr=hewitt

This commit is contained in:
cmanske%netscape.com 2002-01-24 22:01:10 +00:00
Родитель 6240221fb1
Коммит e479265635
13 изменённых файлов: 149 добавлений и 163 удалений

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

@ -358,10 +358,7 @@ function UpdateHTMLAttributes()
{
var name = HTMLRAttrs[i];
// We can't use getAttribute to figure out if attribute already
// exists for attributes that don't require a value
// This gets the attribute NODE from the attributes NamedNodeMap
if (gElement.attributes.getNamedItem(name))
if (gElement.hasAttribute(name))
doRemoveAttribute(name);
}

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

@ -217,6 +217,8 @@ function SelectLastPickedColor()
if ( onAccept() )
//window.close();
return true;
return false;
}
function SetCurrentColor(color)

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

@ -659,7 +659,6 @@ function onMoreFewer()
gDialog.MoreFewerButton.setAttribute("more","0");
gDialog.MoreFewerButton.setAttribute("label",GetString("MoreProperties"));
SeeMore = false;
// window.sizeToContent();
}
else
{

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

@ -86,7 +86,7 @@ function Startup()
newLegend = false;
editorShell.SelectElement(legendElement);
gDialog.legendText.value = GetSelectionAsText();
if (legendElement.innerHTML.match(/</))
if (/</.test(legendElement.innerHTML))
{
gDialog.editText.checked = false;
gDialog.editText.disabled = false;
@ -124,7 +124,7 @@ function Startup()
function InitDialog()
{
gDialog.legendAlign.value = globalElement.getAttribute("align");
gDialog.legendAlign.value = GetHTMLOrCSSStyleValue(globalElement, "align", "caption-side");
}
function onEditText()
@ -135,11 +135,12 @@ function onEditText()
function RemoveFieldSet()
{
// RemoveTextProperty might work becuase the field set element was selected above
editorShell.BeginBatchChanges();
try {
if (!newLegend)
editorShell.DeleteElement(legendElement);
// This really needs to call the C++ function RemoveBlockContainer
// which inserts any <BR>s needed
RemoveElementKeepingChildren(fieldsetElement);
} finally {
editorShell.EndBatchChanges();
@ -160,16 +161,11 @@ function ValidateData()
function onAccept()
{
// All values are valid - copy to actual element in doc
// ValidateData();
ValidateData();
editorShell.BeginBatchChanges();
try {
editorShell.CloneAttributes(legendElement, globalElement);
if (insertNew)
InsertElementAroundSelection(fieldsetElement);
if (gDialog.editText.checked)
{
if (gDialog.legendText.value)
@ -179,11 +175,18 @@ function onAccept()
editorShell.InsertElement(legendElement, fieldsetElement, 0, true);
else while (legendElement.firstChild)
editor.DeleteNode(legendElement.firstChild);
editor.InsertNode(document.createTextNode(gDialog.legendText.value), legendElement, 0);
editor.InsertNode(editorShell.editorDocument.createTextNode(gDialog.legendText.value), legendElement, 0);
}
else if (!newLegend)
editorShell.DeleteElement(legendElement);
}
if (insertNew)
InsertElementAroundSelection(fieldsetElement);
else
editorShell.SelectElement(fieldsetElement);
editorShell.CloneAttributes(legendElement, globalElement);
}
finally {
editorShell.EndBatchChanges();

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

@ -103,14 +103,7 @@ function InitDialog()
gDialog.alignGroup.selectedItem = gDialog.leftAlign;
}
// This is tricky! Since the "noshade" attribute doesn't always have a value,
// we can't use getAttribute to figure out if it's set!
// This gets the attribute NODE from the attributes NamedNodeMap
if (globalElement.attributes.getNamedItem("noshade"))
gDialog.shading.checked = false;
else
gDialog.shading.checked = true;
gDialog.shading.checked = globalElement.hasAttribute("noshade");
}
function onSaveDefault()

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

@ -61,8 +61,8 @@
</tabs>
<tabpanels>
<!-- panels overlayed from EdImageOverlay.xul -->
<groupbox id="imageLocation"/>
<groupbox id="imageDimensions"/>
<vbox id="imageLocation"/>
<vbox id="imageDimensions"/>
<hbox id="imageAppearance"/>
</tabpanels>

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

@ -88,8 +88,8 @@
</groupbox>
<!-- panels overlayed from EdImageOverlay.xul -->
<groupbox id="imageLocation"/>
<groupbox id="imageDimensions"/>
<vbox id="imageLocation"/>
<vbox id="imageDimensions"/>
<hbox id="imageAppearance"/>
</tabpanels>

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

@ -243,32 +243,6 @@ function doImageProperties()
function ValidateData()
{
var index = gDialog.inputType.selectedIndex;
switch (index)
{
case 4:
case 5:
break;
case 8:
if (!globalElement.hasAttribute("src"))
{
doImageProperties();
if (!globalElement.hasAttribute("src"))
return false;
}
break;
case 3:
default:
if (!gDialog.inputName.value || !gDialog.inputValue.value)
{
AlertWithTitle(GetString("Alert"), GetString("FormInputError"));
if (!gDialog.inputName.value)
gDialog.inputName.focus();
else
gDialog.inputValue.focus();
return false;
}
}
var attributes = {
type: "",
name: gDialog.inputName.value,
@ -279,6 +253,7 @@ function ValidateData()
maxlength: "",
accept: ""
};
var index = gDialog.inputType.selectedIndex;
var flags = {
checked: false,
readonly: false,

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

@ -99,43 +99,46 @@
<checkbox id="InputReadOnly" label="&InputReadOnly.label;"/>
</deck>
</row>
<hbox>
<button id="MoreFewerButton" oncommand="onMoreFewer();" persist="more"/>
</hbox>
<rows id="MoreSection">
<row>
<spacer/>
<checkbox id="InputDisabled" label="&InputDisabled.label;"/>
</row>
<row align="center">
<label value="&tabIndex.label;"/>
<hbox>
<textbox id="InputTabIndex" class="narrow" oninput="forceInteger(this.id);"/>
</hbox>
</row>
<row align="center">
<label value="&AccessKey.label;"/>
<hbox>
<textbox id="InputAccessKey" class="narrow"/>
</hbox>
</row>
<row align="center">
<label value="&TextSize.label;"/>
<hbox>
<textbox id="InputSize" class="narrow" oninput="forceInteger(this.id);"/>
</hbox>
</row>
<row align="center">
<label value="&TextLength.label;"/>
<hbox>
<textbox id="InputMaxLength" class="narrow" oninput="forceInteger(this.id);"/>
</hbox>
</row>
<row align="center">
<label value="&Accept.label;"/>
<textbox id="InputAccept"/>
</row>
</rows>
</rows>
</grid>
<hbox>
<button id="MoreFewerButton" oncommand="onMoreFewer();" persist="more"/>
</hbox>
<grid id="MoreSection" align="start">
<columns><column/><column/></columns>
<rows>
<row>
<spacer/>
<checkbox id="InputDisabled" label="&InputDisabled.label;"/>
</row>
<row align="center">
<label value="&tabIndex.label;"/>
<hbox>
<textbox id="InputTabIndex" class="narrow" oninput="forceInteger(this.id);"/>
</hbox>
</row>
<row align="center">
<label value="&AccessKey.label;"/>
<hbox>
<textbox id="InputAccessKey" class="narrow"/>
</hbox>
</row>
<row align="center">
<label value="&TextSize.label;"/>
<hbox>
<textbox id="InputSize" class="narrow" oninput="forceInteger(this.id);"/>
</hbox>
</row>
<row align="center">
<label value="&TextLength.label;"/>
<hbox>
<textbox id="InputMaxLength" class="narrow" oninput="forceInteger(this.id);"/>
</hbox>
</row>
<row align="center">
<label value="&Accept.label;"/>
<textbox id="InputAccept"/>
</row>
</rows>
</grid>
</groupbox>

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

@ -119,8 +119,11 @@ function onAccept()
var editor = editorShell.editor;
while (labelElement.firstChild)
editor.DeleteNode(labelElement.firstChild);
if (gDialog.labelText.value)
editor.InsertNode(document.createTextNode(gDialog.labelText.value), labelElement, 0);
if (gDialog.labelText.value) {
var textNode = editorShell.editorDocument.createTextNode(gDialog.labelText.value);
editor.InsertNode(textNode, labelElement, 0);
editorShell.SelectElement(labelElement);
}
}
editorShell.EndBatchChanges();

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

@ -63,9 +63,12 @@ function Startup()
var tagName = "textarea";
textareaElement = editorShell.GetSelectedElement(tagName);
if (textareaElement)
if (textareaElement) {
// We found an element and don't need to insert one
insertNew = false;
gDialog.textareaValue.value = textareaElement.value;
}
else
{
insertNew = true;
@ -81,7 +84,7 @@ function Startup()
return;
}
else
textareaElement.value = GetSelectionAsText();
gDialog.textareaValue.value = GetSelectionAsText();
}
// Make a copy to use for AdvancedEdit
@ -91,13 +94,6 @@ function Startup()
InitMoreFewer();
if ("@mozilla.org/preferences;1" in Components.classes) try {
var pref = Components.classes["@mozilla.org/preferences;1"];
pref = pref.getService(Components.interfaces.nsIPref);
var wrap = document.getElementById("wrap");
wrap.setAttribute("collapsed", pref.GetBoolPref("editor.dtd.strict"));
} catch (e) {}
SetTextboxFocus(gDialog.textareaName);
SetWindowLocation();
@ -108,12 +104,11 @@ function InitDialog()
gDialog.textareaName.value = globalElement.getAttribute("name");
gDialog.textareaRows.value = globalElement.getAttribute("rows");
gDialog.textareaCols.value = globalElement.getAttribute("cols");
gDialog.textareaWrap.value = globalElement.getAttribute("wrap");
gDialog.textareaWrap.value = GetHTMLOrCSSStyleValue(globalElement, "wrap", "white-space");
gDialog.textareaReadOnly.checked = globalElement.hasAttribute("readonly");
gDialog.textareaDisabled.checked = globalElement.hasAttribute("disabled");
gDialog.textareaTabIndex.value = globalElement.getAttribute("tabindex");
gDialog.textareaAccessKey.value = globalElement.getAttribute("accesskey");
gDialog.textareaValue.value = globalElement.value;
onInput();
}
@ -152,32 +147,38 @@ function ValidateData()
else
globalElement.removeAttribute(f);
}
globalElement.value = gDialog.textareaValue.value;
return true;
}
function onAccept()
{
editorShell.BeginBatchChanges();
if (insertNew)
{
try {
// 'true' means delete the selection before inserting
// in case were are converting text to a text area
editorShell.InsertElementAtSelection(textareaElement, true);
} catch (e) {
dump(e);
}
}
// All values are valid - copy to actual element in doc or
// element created to insert
ValidateData();
editorShell.CloneAttributes(textareaElement, globalElement);
editorShell.BeginBatchChanges();
editorShell.EndBatchChanges();
try {
// undoably set value
var initialText = gDialog.textareaValue.value;
if (initialText != textareaElement.value) {
while (textareaElement.hasChildNodes())
editorShell.editor.DeleteNode(textareaElement.firstChild);
if (initialText) {
var textNode = editorShell.editorDocument.createTextNode(initialText);
editorShell.editor.InsertNode(textNode, textareaElement, 0);
}
}
if (insertNew)
editorShell.InsertElementAtSelection(textareaElement, true);
else
editorShell.SelectElement(textareaElement);
editorShell.CloneAttributes(textareaElement, globalElement);
} finally {
editorShell.EndBatchChanges();
}
SaveWindowLocation();

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

@ -88,50 +88,56 @@
<textbox id="TextAreaCols" class="narrow" oninput="forceInteger(this.id);onInput();"/>
</hbox>
</row>
<hbox>
<button id="MoreFewerButton" oncommand="onMoreFewer();" persist="more"/>
</hbox>
<rows id="MoreSection">
<row id="wrap" collapsed="true" align="center">
<label value="&TextAreaWrap.label;" accesskey="&TextAreaWrap.accessKey;"/>
<menulist id="TextAreaWrap">
<menupopup>
<menuitem label="&WrapDefault.value;"/>
<menuitem label="&WrapOff.value;" value="off"/>
<menuseparator/>
<menuitem label="&WrapSoft.value;" value="soft"/>
<menuitem label="&WrapHard.value;" value="hard"/>
<menuseparator/>
<menuitem label="&WrapPhysical.value;" value="physical"/>
<menuitem label="&WrapVirtual.value;" value="virtual"/>
</menupopup>
</menulist>
</row>
<row>
<spacer/>
<checkbox id="TextAreaReadOnly" label="&TextAreaReadOnly.label;" accesskey="&TextAreaReadOnly.accessKey;"/>
</row>
<row>
<spacer/>
<checkbox id="TextAreaDisabled" label="&TextAreaDisabled.label;" accesskey="&TextAreaDisabled.accessKey;"/>
</row>
<row align="center">
<label value="&TextAreaTabIndex.label;" accesskey="&TextAreaTabIndex.accessKey;"/>
<hbox>
<textbox id="TextAreaTabIndex" class="narrow" oninput="forceInteger(this.id);"/>
</hbox>
</row>
<row align="center">
<label value="&TextAreaAccessKey.label;" accesskey="&TextAreaAccessKey.accessKey;"/>
<hbox>
<textbox id="TextAreaAccessKey" class="narrow" maxlength="1"/>
</hbox>
</row>
<row>
<label value="&InitialText.label;" accesskey="&InitialText.accessKey;"/>
</row>
<textbox id="TextAreaValue" flex="1" multiline="true" rows="5"/>
</rows>
</rows>
</grid>
<hbox>
<button id="MoreFewerButton" oncommand="onMoreFewer();" persist="more"/>
</hbox>
<grid id="MoreSection"><columns><column/><column/></columns>
<rows>
<row align="center">
<label value="&TextAreaWrap.label;" accesskey="&TextAreaWrap.accessKey;"/>
<menulist id="TextAreaWrap">
<menupopup>
<menuitem label="&WrapDefault.value;"/>
<menuitem label="&WrapOff.value;" value="off"/>
<menuseparator/>
<menuitem label="&WrapSoft.value;" value="soft"/>
<menuitem label="&WrapHard.value;" value="hard"/>
<menuseparator/>
<menuitem label="&WrapPhysical.value;" value="physical"/>
<menuitem label="&WrapVirtual.value;" value="virtual"/>
<menuseparator/>
<menuitem label="normal" value="normal"/>
<menuitem label="nowrap" value="nowrap"/>
<menuitem label="pre" value="pre"/>
</menupopup>
</menulist>
</row>
<row>
<spacer/>
<checkbox id="TextAreaReadOnly" label="&TextAreaReadOnly.label;" accesskey="&TextAreaReadOnly.accessKey;"/>
</row>
<row>
<spacer/>
<checkbox id="TextAreaDisabled" label="&TextAreaDisabled.label;" accesskey="&TextAreaDisabled.accessKey;"/>
</row>
<row align="center">
<label value="&TextAreaTabIndex.label;" accesskey="&TextAreaTabIndex.accessKey;"/>
<hbox>
<textbox id="TextAreaTabIndex" class="narrow" oninput="forceInteger(this.id);"/>
</hbox>
</row>
<row align="center">
<label value="&TextAreaAccessKey.label;" accesskey="&TextAreaAccessKey.accessKey;"/>
<hbox>
<textbox id="TextAreaAccessKey" class="narrow" maxlength="1"/>
</hbox>
</row>
<row>
<label value="&InitialText.label;" accesskey="&InitialText.accessKey;"/>
</row>
<textbox id="TextAreaValue" flex="1" multiline="true" rows="5"/>
</rows>
</grid>
</groupbox>

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

@ -531,6 +531,10 @@ dump(" *** Current directory list length = "+dirListLen+"\n");
return true;
}
function ChooseDir()
{
}
function ValidateData()
{
var result = true;;