зеркало из https://github.com/mozilla/gecko-dev.git
Update on insert Form widgets dialogs, b=45495, fixes by neil/cmanske, r=neil/cmanske, sr=hewitt
This commit is contained in:
Родитель
6240221fb1
Коммит
e479265635
|
@ -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,10 +99,14 @@
|
|||
<checkbox id="InputReadOnly" label="&InputReadOnly.label;"/>
|
||||
</deck>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<hbox>
|
||||
<button id="MoreFewerButton" oncommand="onMoreFewer();" persist="more"/>
|
||||
</hbox>
|
||||
<rows id="MoreSection">
|
||||
<grid id="MoreSection" align="start">
|
||||
<columns><column/><column/></columns>
|
||||
<rows>
|
||||
<row>
|
||||
<spacer/>
|
||||
<checkbox id="InputDisabled" label="&InputDisabled.label;"/>
|
||||
|
@ -136,7 +140,6 @@
|
|||
<textbox id="InputAccept"/>
|
||||
</row>
|
||||
</rows>
|
||||
</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();
|
||||
|
||||
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,11 +88,14 @@
|
|||
<textbox id="TextAreaCols" class="narrow" oninput="forceInteger(this.id);onInput();"/>
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<hbox>
|
||||
<button id="MoreFewerButton" oncommand="onMoreFewer();" persist="more"/>
|
||||
</hbox>
|
||||
<rows id="MoreSection">
|
||||
<row id="wrap" collapsed="true" align="center">
|
||||
<grid id="MoreSection"><columns><column/><column/></columns>
|
||||
<rows>
|
||||
<row align="center">
|
||||
<label value="&TextAreaWrap.label;" accesskey="&TextAreaWrap.accessKey;"/>
|
||||
<menulist id="TextAreaWrap">
|
||||
<menupopup>
|
||||
|
@ -104,6 +107,10 @@
|
|||
<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>
|
||||
|
@ -132,7 +139,6 @@
|
|||
</row>
|
||||
<textbox id="TextAreaValue" flex="1" multiline="true" rows="5"/>
|
||||
</rows>
|
||||
</rows>
|
||||
</grid>
|
||||
</groupbox>
|
||||
|
||||
|
|
|
@ -531,6 +531,10 @@ dump(" *** Current directory list length = "+dirListLen+"\n");
|
|||
return true;
|
||||
}
|
||||
|
||||
function ChooseDir()
|
||||
{
|
||||
}
|
||||
|
||||
function ValidateData()
|
||||
{
|
||||
var result = true;;
|
||||
|
|
Загрузка…
Ссылка в новой задаче