зеркало из https://github.com/mozilla/pjs.git
Convert from nsIEditorShell to nsIHTMLEditor/nsIEditor interfaces in dialogs. Work by cmanske and neil@parkwaycc.co.uk, b=158881, r=brade,andreww,neil@parkwaycc.co.uk; sr=dveditz,sfraser
This commit is contained in:
Родитель
270923b41b
Коммит
54020ecc8b
|
@ -20,6 +20,8 @@
|
|||
* Contributor(s):
|
||||
* Ben "Count XULula" Goodger
|
||||
* Daniel Glazman <glazman@netscape.com>
|
||||
* Charles Manske (cmanske@netscape.com)
|
||||
* Neil Rashbrook <neil@parkwaycc.co.uk>
|
||||
*/
|
||||
|
||||
// build attribute list in tree form from element attributes
|
||||
|
@ -28,8 +30,11 @@ function BuildCSSAttributeTable()
|
|||
// we can't trust DOM 2 ElementCSSInlineStyle because gElement can be
|
||||
// outside of the document's tree
|
||||
var styleAttr = gElement.getAttribute("style");
|
||||
var editor = editorShell.editor.QueryInterface(Components.interfaces.nsIHTMLEditor);
|
||||
var styleRule = editor.parseStyleAttrIntoCSSRule(styleAttr);
|
||||
var styleRule;
|
||||
try {
|
||||
var editor = GetCurrentEditor();
|
||||
styleRule = editor.parseStyleAttrIntoCSSRule(styleAttr);
|
||||
} catch(ex) {}
|
||||
|
||||
if (styleRule == undefined)
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ function BuildJSEAttributeNameList()
|
|||
}
|
||||
|
||||
for (i = 0; i < attNames.length; i++)
|
||||
AppendStringToMenulist(gDialog.AddJSEAttributeNameList, attNames[i]);
|
||||
gDialog.AddJSEAttributeNameList.appendItem(attNames[i], attNames[i]);
|
||||
|
||||
popup = gDialog.AddJSEAttributeNameList.firstChild;
|
||||
if (popup)
|
||||
|
@ -74,7 +74,7 @@ function BuildJSEAttributeNameList()
|
|||
popup.appendChild(sep);
|
||||
}
|
||||
else
|
||||
AppendStringToMenulist(gDialog.AddJSEAttributeNameList, gCoreJSEvents[i]);
|
||||
gDialog.AddJSEAttributeNameList.appendItem(gCoreJSEvents[i], gCoreJSEvents[i]);
|
||||
}
|
||||
|
||||
gDialog.AddJSEAttributeNameList.selectedIndex = 0;
|
||||
|
@ -133,21 +133,14 @@ function onSelectJSETreeItem()
|
|||
var tree = gDialog.AddJSEAttributeTree;
|
||||
if (tree && tree.treeBoxObject.selection.count)
|
||||
{
|
||||
var name = GetTreeItemAttributeStr(getSelectedItem(tree));
|
||||
|
||||
// Select attribute name in list
|
||||
if (gDialog.AddJSEAttributeNameList.firstChild)
|
||||
{
|
||||
var arr = gDialog.AddJSEAttributeNameList.firstChild.getElementsByAttribute('label', name);
|
||||
if (arr && arr.length)
|
||||
gDialog.AddJSEAttributeNameList.selectedItem = arr[0];
|
||||
gDialog.AddJSEAttributeNameList.value = GetTreeItemAttributeStr(getSelectedItem(tree));
|
||||
|
||||
// Set value input to that in tree (no need to update this in the tree)
|
||||
gUpdateTreeValue = false;
|
||||
gDialog.AddJSEAttributeValueInput.value = GetTreeItemValueStr(getSelectedItem(tree));
|
||||
gUpdateTreeValue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onInputJSEAttributeValue()
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Ben "Count XULula" Goodger
|
||||
* Charles Manske (cmanske@netscape.com)
|
||||
* Neil Rashbrook (neil@parkwaycc.co.uk)
|
||||
*/
|
||||
|
||||
/************** GLOBALS **************/
|
||||
|
@ -47,20 +49,19 @@ var gUpdateTreeValue = true;
|
|||
**/
|
||||
function Startup()
|
||||
{
|
||||
var editor = GetCurrentEditor();
|
||||
|
||||
// Element to edit is passed in
|
||||
if (!editor || !window.arguments[1])
|
||||
{
|
||||
dump("Advanced Edit: No editor or element to edit not supplied\n");
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
// This is the return value for the parent,
|
||||
// who only needs to know if OK was clicked
|
||||
window.opener.AdvancedEditOK = false;
|
||||
|
||||
if (!InitEditorShell())
|
||||
return;
|
||||
|
||||
// Element to edit is passed in
|
||||
if (!window.arguments[1])
|
||||
{
|
||||
dump("Advanced Edit: Element to edit not supplied\n");
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
// The actual element edited (not a copy!)
|
||||
gElement = window.arguments[1];
|
||||
|
||||
|
@ -106,14 +107,15 @@ function Startup()
|
|||
}
|
||||
|
||||
/**
|
||||
* function : bool onOK ( void );
|
||||
* function : bool onAccept ( void );
|
||||
* parameters : none
|
||||
* returns : boolean true to close the window
|
||||
* desc. : event handler for ok button
|
||||
**/
|
||||
function onAccept()
|
||||
{
|
||||
editorShell.BeginBatchChanges();
|
||||
var editor = GetCurrentEditor();
|
||||
editor.beginTransaction();
|
||||
try {
|
||||
// Update our gElement attributes
|
||||
UpdateHTMLAttributes();
|
||||
|
@ -122,7 +124,7 @@ function onAccept()
|
|||
} catch(ex) {
|
||||
dump(ex);
|
||||
}
|
||||
editorShell.EndBatchChanges();
|
||||
editor.endTransaction();
|
||||
|
||||
window.opener.AdvancedEditOK = true;
|
||||
SaveWindowLocation();
|
||||
|
@ -135,18 +137,24 @@ function onAccept()
|
|||
// (Temporary element from a property dialog won't have a parent node)
|
||||
function doRemoveAttribute(attrib)
|
||||
{
|
||||
try {
|
||||
var editor = GetCurrentEditor();
|
||||
if (gElement.parentNode)
|
||||
editorShell.RemoveAttribute(gElement, attrib);
|
||||
editor.removeAttribute(gElement, attrib);
|
||||
else
|
||||
gElement.removeAttribute(attrib);
|
||||
} catch(ex) {}
|
||||
}
|
||||
|
||||
function doSetAttribute(attrib, value)
|
||||
{
|
||||
try {
|
||||
var editor = GetCurrentEditor();
|
||||
if (gElement.parentNode)
|
||||
editorShell.SetAttribute(gElement, attrib, value);
|
||||
editor.setAttribute(gElement, attrib, value);
|
||||
else
|
||||
gElement.setAttribute(attrib, value);
|
||||
} catch(ex) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
<!-- HTML Attributes -->
|
||||
<!-- ============================================================== -->
|
||||
<vbox>
|
||||
<tree id="HTMLATree" class="AttributesTree"
|
||||
<tree id="HTMLATree" class="AttributesTree" flex="1"
|
||||
hidecolumnpicker="true" seltype="single"
|
||||
onselect="onSelectHTMLTreeItem();"
|
||||
onclick="onSelectHTMLTreeItem();"
|
||||
|
@ -118,13 +118,12 @@
|
|||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<spacer class="spacer" flex="1"/>
|
||||
</vbox>
|
||||
<!-- ============================================================== -->
|
||||
<!-- CSS Attributes -->
|
||||
<!-- ============================================================== -->
|
||||
<vbox>
|
||||
<tree id="CSSATree" class="AttributesTree"
|
||||
<tree id="CSSATree" class="AttributesTree" flex="1"
|
||||
hidecolumnpicker="true" seltype="single"
|
||||
onselect="onSelectCSSTreeItem();"
|
||||
onclick="onSelectCSSTreeItem();"
|
||||
|
@ -159,13 +158,12 @@
|
|||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<spacer class="spacer" flex="1"/>
|
||||
</vbox>
|
||||
<!-- ============================================================== -->
|
||||
<!-- JavaScript Event Handlers -->
|
||||
<!-- ============================================================== -->
|
||||
<vbox>
|
||||
<tree id="JSEATree" class="AttributesTree"
|
||||
<tree id="JSEATree" class="AttributesTree" flex="1"
|
||||
hidecolumnpicker="true" seltype="single"
|
||||
onselect="onSelectJSETreeItem();"
|
||||
onclick="onSelectJSETreeItem();"
|
||||
|
@ -194,13 +192,14 @@
|
|||
<row align="top" equalsize="always">
|
||||
<!-- List is built at runtime -->
|
||||
<menulist id="AddJSEAttributeNameList" flex="1"
|
||||
oncommand="onSelectJSEAttribute();"/>
|
||||
oncommand="onSelectJSEAttribute();">
|
||||
<menupopup/>
|
||||
</menulist>
|
||||
<textbox id="AddJSEAttributeValueInput" flex="1"
|
||||
oninput="onInputJSEAttributeValue();"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<spacer class="spacer" flex="1"/>
|
||||
</vbox>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
|
|
@ -41,8 +41,12 @@ var buttonElement;
|
|||
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
gDialog = {
|
||||
buttonType: document.getElementById("ButtonType"),
|
||||
|
@ -58,7 +62,7 @@ function Startup()
|
|||
|
||||
// Get a single selected button element
|
||||
var tagName = "button";
|
||||
buttonElement = editorShell.GetSelectedElement(tagName);
|
||||
buttonElement = editor.getSelectedElement(tagName);
|
||||
|
||||
if (buttonElement)
|
||||
// We found an element and don't need to insert one
|
||||
|
@ -70,7 +74,7 @@ function Startup()
|
|||
// We don't have an element selected,
|
||||
// so create one with default attributes
|
||||
|
||||
buttonElement = editorShell.CreateElementWithDefaults(tagName);
|
||||
buttonElement = editor.createElementWithDefaults(tagName);
|
||||
if (!buttonElement)
|
||||
{
|
||||
dump("Failed to get selected element or create a new one!\n");
|
||||
|
@ -78,7 +82,7 @@ function Startup()
|
|||
return;
|
||||
}
|
||||
// Hide button removing existing button
|
||||
gDialog.RemoveButton.setAttribute("hidden", "true");
|
||||
gDialog.RemoveButton.hidden = true;
|
||||
}
|
||||
|
||||
// Make a copy to use for AdvancedEdit
|
||||
|
@ -150,12 +154,14 @@ function onAccept()
|
|||
// element created to insert
|
||||
ValidateData();
|
||||
|
||||
editorShell.CloneAttributes(buttonElement, globalElement);
|
||||
var editor = GetCurrentEditor();
|
||||
|
||||
editor.cloneAttributes(buttonElement, globalElement);
|
||||
|
||||
if (insertNew && !InsertElementAroundSelection(buttonElement))
|
||||
{
|
||||
buttonElement.innerHTML = editorShell.GetContentsAs("text/html", 1); // OutputSelectionOnly (see nsIDocumentEncoder.h)
|
||||
editorShell.InsertElementAtSelection(buttonElement, true);
|
||||
buttonElement.innerHTML = editor.outputToString("text/html", 1); // OutputSelectionOnly (see nsIDocumentEncoder.h)
|
||||
editor.insertElementAtSelection(buttonElement, true);
|
||||
}
|
||||
|
||||
SaveWindowLocation();
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
//Cancel() is in EdDialogCommon.js
|
||||
|
||||
var BodyElement;
|
||||
var gBodyElement;
|
||||
var prefs;
|
||||
var gBackgroundImage;
|
||||
|
||||
|
@ -67,8 +67,12 @@ var gHaveDocumentUrl = false;
|
|||
// dialog initialization code
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
gDialog.ColorPreview = document.getElementById("ColorPreview");
|
||||
gDialog.NormalText = document.getElementById("NormalText");
|
||||
|
@ -80,15 +84,18 @@ function Startup()
|
|||
gDialog.CustomColorsRadio = document.getElementById("CustomColorsRadio");
|
||||
gDialog.BackgroundImageInput = document.getElementById("BackgroundImageInput");
|
||||
|
||||
BodyElement = editorShell.editorDocument.body;
|
||||
if (!BodyElement)
|
||||
try {
|
||||
gBodyElement = editor.rootElement;
|
||||
} catch (e) {}
|
||||
|
||||
if (!gBodyElement)
|
||||
{
|
||||
dump("Failed to get BODY element!\n");
|
||||
window.close();
|
||||
}
|
||||
|
||||
// Set element we will edit
|
||||
globalElement = BodyElement.cloneNode(false);
|
||||
globalElement = gBodyElement.cloneNode(false);
|
||||
|
||||
// Initialize default colors from browser prefs
|
||||
var browserColors = GetDefaultBrowserColors();
|
||||
|
@ -365,14 +372,16 @@ function ValidateAndPreviewImage(ShowErrorMessage)
|
|||
|
||||
function ValidateData()
|
||||
{
|
||||
var editor = GetCurrentEditor();
|
||||
try {
|
||||
// Colors values are updated as they are picked, no validation necessary
|
||||
if (gDialog.DefaultColorsRadio.selected)
|
||||
{
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, textStr, true);
|
||||
editor.removeAttributeOrEquivalent(globalElement, textStr, true);
|
||||
globalElement.removeAttribute(linkStr);
|
||||
globalElement.removeAttribute(vlinkStr);
|
||||
globalElement.removeAttribute(alinkStr);
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, bgcolorStr, true);
|
||||
editor.removeAttributeOrEquivalent(globalElement, bgcolorStr, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -383,13 +392,13 @@ function ValidateData()
|
|||
if (tmpColor != "windowtext")
|
||||
globalElement.setAttribute(textStr, customTextColor);
|
||||
else
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, textStr, true);
|
||||
editor.removeAttributeOrEquivalent(globalElement, textStr, true);
|
||||
|
||||
tmpColor = customBackgroundColor.toLowerCase();
|
||||
if (tmpColor != "window")
|
||||
globalElement.setAttribute(bgcolorStr, customBackgroundColor);
|
||||
else
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, bgcolorStr, true);
|
||||
editor.removeAttributeOrEquivalent(globalElement, bgcolorStr, true);
|
||||
|
||||
globalElement.setAttribute(linkStr, customLinkColor);
|
||||
globalElement.setAttribute(vlinkStr, customVisitedColor);
|
||||
|
@ -402,10 +411,11 @@ function ValidateData()
|
|||
if (gBackgroundImage)
|
||||
globalElement.setAttribute(backgroundStr, gBackgroundImage);
|
||||
else
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, backgroundStr, true);
|
||||
editor.removeAttributeOrEquivalent(globalElement, backgroundStr, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (e) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -414,7 +424,9 @@ function onAccept()
|
|||
if (ValidateData())
|
||||
{
|
||||
// Copy attributes to element we are changing
|
||||
editorShell.CloneAttributes(BodyElement, globalElement);
|
||||
try {
|
||||
GetCurrentEditor().cloneAttributes(gBodyElement, globalElement);
|
||||
} catch (e) {}
|
||||
|
||||
SaveWindowLocation();
|
||||
return true; // do close the window
|
||||
|
|
|
@ -20,12 +20,13 @@
|
|||
* Contributor(s):
|
||||
* Pete Collins
|
||||
* Brian King
|
||||
* Charles Manske (cmanske@netscape.com)
|
||||
* Neil Rashbrook (neil@parkwaycc.co.uk)
|
||||
*/
|
||||
|
||||
// Each editor window must include this file
|
||||
// Variables shared by all dialogs:
|
||||
var editorShell;
|
||||
var gEditor;
|
||||
|
||||
// Object to attach commonly-used widgets (all dialogs should use this)
|
||||
var gDialog = {};
|
||||
|
@ -53,6 +54,10 @@ var gLocation;
|
|||
// The element being edited - so AdvancedEdit can have access to it
|
||||
var globalElement;
|
||||
|
||||
//XXX THIS METHOD IS GOING AWAY SOON!
|
||||
// We are removing all editorShell calls
|
||||
// Use GetCurrentEditor() to get the nsIEditor/nsIHTMLEditor interface
|
||||
// Do not modify it or rely on it in any way!
|
||||
function InitEditorShell()
|
||||
{
|
||||
// get the editor shell from the parent window
|
||||
|
@ -70,7 +75,6 @@ function InitEditorShell()
|
|||
// Save as a property of the window so it can be used by child dialogs
|
||||
|
||||
window.editorShell = editorShell;
|
||||
gEditor = editorShell.editor.QueryInterface(Components.interfaces.nsIHTMLEditor);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -639,7 +643,7 @@ function SetMetaElementContent(metaElement, content, insertNew)
|
|||
if(!content || content == "")
|
||||
{
|
||||
if (!insertNew)
|
||||
editor.deleteElement(metaElement);
|
||||
editor.deleteNode(metaElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1074,7 +1078,7 @@ function FillLinkMenulist(linkMenulist, headingsArray)
|
|||
linkMenulist.appendItem(text);
|
||||
|
||||
// Save nodes in an array so we can create anchor node under it later
|
||||
headingsArray[NamedAnchorCount++] = heading;
|
||||
headingsArray[text] = heading;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
oncommand="MakeInputValueRelativeOrAbsolute(this);"
|
||||
tooltiptext="&makeUrlRelative.tooltip;"/>
|
||||
<spacer flex="1"/>
|
||||
<button label="&chooseButton.label;" accesskey="&chooseFile.accessKey;" oncommand="chooseLinkFile();"/>
|
||||
<button label="&chooseButton.label;" accesskey="&chooseFileLink.accessKey;" oncommand="chooseLinkFile();"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
|
|
|
@ -43,8 +43,12 @@ var legendElement;
|
|||
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
gDialog.editText = document.getElementById("EditText");
|
||||
gDialog.legendText = document.getElementById("LegendText");
|
||||
|
@ -53,11 +57,11 @@ function Startup()
|
|||
|
||||
// Get a single selected field set element
|
||||
var tagName = "fieldset";
|
||||
fieldsetElement = editorShell.GetSelectedElement(tagName);
|
||||
fieldsetElement = editor.getSelectedElement(tagName);
|
||||
if (!fieldsetElement)
|
||||
fieldsetElement = editorShell.GetElementOrParentByTagName(tagName, editorShell.editorSelection.anchorNode);
|
||||
fieldsetElement = editor.getElementOrParentByTagName(tagName, editor.selection.anchorNode);
|
||||
if (!fieldsetElement)
|
||||
fieldsetElement = editorShell.GetElementOrParentByTagName(tagName, editorShell.editorSelection.focusNode);
|
||||
fieldsetElement = editor.getElementOrParentByTagName(tagName, editor.selection.focusNode);
|
||||
|
||||
if (fieldsetElement)
|
||||
// We found an element and don't need to insert one
|
||||
|
@ -69,7 +73,7 @@ function Startup()
|
|||
// We don't have an element selected,
|
||||
// so create one with default attributes
|
||||
|
||||
fieldsetElement = editorShell.CreateElementWithDefaults(tagName);
|
||||
fieldsetElement = editor.createElementWithDefaults(tagName);
|
||||
if (!fieldsetElement)
|
||||
{
|
||||
dump("Failed to get selected element or create a new one!\n");
|
||||
|
@ -77,15 +81,17 @@ function Startup()
|
|||
return;
|
||||
}
|
||||
// Hide button removing existing fieldset
|
||||
gDialog.RemoveFieldSet.setAttribute("hidden", "true");
|
||||
gDialog.RemoveFieldSet.hidden = true;
|
||||
}
|
||||
|
||||
legendElement = fieldsetElement.firstChild;
|
||||
if (legendElement && legendElement.localName == "LEGEND")
|
||||
{
|
||||
newLegend = false;
|
||||
editorShell.SelectElement(legendElement);
|
||||
gDialog.legendText.value = GetSelectionAsText();
|
||||
var range = editor.document.createRange();
|
||||
range.setStart(legendElement, 0);
|
||||
range.setEnd(legendElement, legendElement.childNodes.length);
|
||||
gDialog.legendText.value = range.toString();
|
||||
if (/</.test(legendElement.innerHTML))
|
||||
{
|
||||
gDialog.editText.checked = false;
|
||||
|
@ -104,7 +110,7 @@ function Startup()
|
|||
// We don't have an element selected,
|
||||
// so create one with default attributes
|
||||
|
||||
legendElement = editorShell.CreateElementWithDefaults("legend");
|
||||
legendElement = editor.createElementWithDefaults("legend");
|
||||
if (!legendElement)
|
||||
{
|
||||
dump("Failed to get selected element or create a new one!\n");
|
||||
|
@ -135,15 +141,16 @@ function onEditText()
|
|||
|
||||
function RemoveFieldSet()
|
||||
{
|
||||
editorShell.BeginBatchChanges();
|
||||
var editor = GetCurrentEditor();
|
||||
editor.beginTransaction();
|
||||
try {
|
||||
if (!newLegend)
|
||||
editorShell.DeleteElement(legendElement);
|
||||
editor.DeleteNode(legendElement);
|
||||
// This really needs to call the C++ function RemoveBlockContainer
|
||||
// which inserts any <BR>s needed
|
||||
RemoveElementKeepingChildren(fieldsetElement);
|
||||
} finally {
|
||||
editorShell.EndBatchChanges();
|
||||
editorShell.endTransaction();
|
||||
}
|
||||
SaveWindowLocation();
|
||||
window.close();
|
||||
|
@ -163,33 +170,34 @@ function onAccept()
|
|||
// All values are valid - copy to actual element in doc
|
||||
ValidateData();
|
||||
|
||||
editorShell.BeginBatchChanges();
|
||||
var editor = GetCurrentEditor();
|
||||
|
||||
editor.beginTransaction();
|
||||
|
||||
try {
|
||||
if (gDialog.editText.checked)
|
||||
{
|
||||
if (gDialog.legendText.value)
|
||||
{
|
||||
var editor = editorShell.editor;
|
||||
if (newLegend)
|
||||
editorShell.InsertElement(legendElement, fieldsetElement, 0, true);
|
||||
editor.insertNode(legendElement, fieldsetElement, 0, true);
|
||||
else while (legendElement.firstChild)
|
||||
editor.deleteNode(legendElement.firstChild);
|
||||
editor.insertNode(editorShell.editorDocument.createTextNode(gDialog.legendText.value), legendElement, 0);
|
||||
editor.deleteNode(legendElement.lastChild);
|
||||
editor.insertNode(editor.document.createTextNode(gDialog.legendText.value), legendElement, 0);
|
||||
}
|
||||
else if (!newLegend)
|
||||
editorShell.DeleteElement(legendElement);
|
||||
editor.DeleteNode(legendElement);
|
||||
}
|
||||
|
||||
if (insertNew)
|
||||
InsertElementAroundSelection(fieldsetElement);
|
||||
else
|
||||
editorShell.SelectElement(fieldsetElement);
|
||||
editor.selectElement(fieldsetElement);
|
||||
|
||||
editorShell.CloneAttributes(legendElement, globalElement);
|
||||
editor.cloneAttributes(legendElement, globalElement);
|
||||
}
|
||||
finally {
|
||||
editorShell.EndBatchChanges();
|
||||
editor.endTransaction();
|
||||
}
|
||||
|
||||
SaveWindowLocation();
|
||||
|
|
|
@ -41,8 +41,12 @@ var formActionWarning;
|
|||
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
gForm = {
|
||||
Name: document.getElementById("FormName"),
|
||||
|
@ -57,11 +61,11 @@ function Startup()
|
|||
|
||||
// Get a single selected form element
|
||||
var tagName = "form";
|
||||
formElement = editorShell.GetSelectedElement(tagName);
|
||||
formElement = editor.getSelectedElement(tagName);
|
||||
if (!formElement)
|
||||
formElement = editorShell.GetElementOrParentByTagName(tagName, editorShell.editorSelection.anchorNode);
|
||||
formElement = editor.getElementOrParentByTagName(tagName, editor.selection.anchorNode);
|
||||
if (!formElement)
|
||||
formElement = editorShell.GetElementOrParentByTagName(tagName, editorShell.editorSelection.focusNode);
|
||||
formElement = editor.getElementOrParentByTagName(tagName, editor.selection.focusNode);
|
||||
|
||||
if (formElement)
|
||||
{
|
||||
|
@ -77,7 +81,7 @@ function Startup()
|
|||
// We don't have an element selected,
|
||||
// so create one with default attributes
|
||||
|
||||
formElement = editorShell.CreateElementWithDefaults(tagName);
|
||||
formElement = editor.createElementWithDefaults(tagName);
|
||||
if (!formElement)
|
||||
{
|
||||
dump("Failed to get selected element or create a new one!\n");
|
||||
|
@ -85,7 +89,7 @@ function Startup()
|
|||
return;
|
||||
}
|
||||
// Hide button removing existing form
|
||||
gDialog.RemoveForm.setAttribute("hidden", "true");
|
||||
gDialog.RemoveForm.hidden = true;
|
||||
}
|
||||
|
||||
// Make a copy to use for AdvancedEdit
|
||||
|
@ -138,7 +142,9 @@ function onAccept()
|
|||
// element created to insert
|
||||
ValidateData();
|
||||
|
||||
editorShell.CloneAttributes(formElement, globalElement);
|
||||
var editor = GetCurrentEditor();
|
||||
|
||||
editor.cloneAttributes(formElement, globalElement);
|
||||
|
||||
if (insertNew)
|
||||
InsertElementAroundSelection(formElement);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
|
||||
var tagName = "hr";
|
||||
var hLineElement;
|
||||
var gHLineElement;
|
||||
var width;
|
||||
var height;
|
||||
var align;
|
||||
|
@ -31,13 +31,18 @@ const gMaxHRSize = 1000; // This is hard-coded in nsHTMLHRElement::StringToAttri
|
|||
// dialog initialization code
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
|
||||
}
|
||||
try {
|
||||
// Get the selected horizontal line
|
||||
hLineElement = editorShell.GetSelectedElement(tagName);
|
||||
gHLineElement = editor.getSelectedElement(tagName);
|
||||
} catch (e) {}
|
||||
|
||||
if (!hLineElement) {
|
||||
if (!gHLineElement) {
|
||||
// We should never be here if not editing an existing HLine
|
||||
window.close();
|
||||
return;
|
||||
|
@ -52,7 +57,7 @@ function Startup()
|
|||
gDialog.pixelOrPercentMenulist = document.getElementById("pixelOrPercentMenulist");
|
||||
|
||||
// Make a copy to use for AdvancedEdit and onSaveDefault
|
||||
globalElement = hLineElement.cloneNode(false);
|
||||
globalElement = gHLineElement.cloneNode(false);
|
||||
|
||||
// Initialize control values based on existing attributes
|
||||
InitDialog()
|
||||
|
@ -86,7 +91,7 @@ function InitDialog()
|
|||
|
||||
// Get the width attribute of the element, stripping out "%"
|
||||
// This sets contents of menulist (adds pixel and percent menuitems elements)
|
||||
gDialog.widthInput.value = InitPixelOrPercentMenulist(globalElement, hLineElement, "width","pixelOrPercentMenulist");
|
||||
gDialog.widthInput.value = InitPixelOrPercentMenulist(globalElement, gHLineElement, "width","pixelOrPercentMenulist");
|
||||
|
||||
var marginLeft = GetHTMLOrCSSStyleValue(globalElement, "align", "margin-left").toLowerCase();
|
||||
var marginRight = GetHTMLOrCSSStyleValue(globalElement, "align", "margin-right").toLowerCase();
|
||||
|
@ -186,7 +191,9 @@ function ValidateData()
|
|||
if (align)
|
||||
globalElement.setAttribute("align", align);
|
||||
else
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "align", true);
|
||||
try {
|
||||
GetCurrentEditor().removeAttributeOrEquivalent(globalElement, "align", true);
|
||||
} catch (e) {}
|
||||
|
||||
if (gDialog.shading.checked) {
|
||||
shading = true;
|
||||
|
@ -203,7 +210,9 @@ function onAccept()
|
|||
if (ValidateData())
|
||||
{
|
||||
// Copy attributes from the globalElement to the document element
|
||||
editorShell.CloneAttributes(hLineElement, globalElement);
|
||||
try {
|
||||
GetCurrentEditor().cloneAttributes(gHLineElement, globalElement);
|
||||
} catch (e) {}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -232,8 +232,11 @@ function GetImageMap()
|
|||
{
|
||||
gCanRemoveImageMap = true;
|
||||
var mapname = usemap.substring(1, usemap.length);
|
||||
var mapCollection = editorShell.editorDocument.getElementsByName(mapname);
|
||||
if (mapCollection[0] != null)
|
||||
var mapCollection;
|
||||
try {
|
||||
mapCollection = GetCurrentEditor().document.getElementsByName(mapname);
|
||||
} catch (e) {}
|
||||
if (mapCollection && mapCollection[0] != null)
|
||||
{
|
||||
gInsertNewIMap = false;
|
||||
return mapCollection[0];
|
||||
|
@ -474,7 +477,11 @@ function editImageMap()
|
|||
{
|
||||
// Create an imagemap for image map editor
|
||||
if (gInsertNewIMap)
|
||||
gImageMap = editorShell.CreateElementWithDefaults("map");
|
||||
{
|
||||
try {
|
||||
gImageMap = GetCurrentEditor().createElementWithDefaults("map");
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Note: We no longer pass in a copy of the global ImageMap. ImageMap editor should create a copy and manage onOk and onCancel behavior
|
||||
window.openDialog("chrome://editor/content/EdImageMap.xul", "_blank", "chrome,close,titlebar,modal", globalElement, gImageMap);
|
||||
|
@ -497,6 +504,10 @@ function SwitchToValidatePanel()
|
|||
// accessible to AdvancedEdit() [in EdDialogCommon.js]
|
||||
function ValidateImage()
|
||||
{
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
return false;
|
||||
|
||||
gValidateTab = gDialog.tabLocation;
|
||||
if (!gDialog.srcInput.value)
|
||||
{
|
||||
|
@ -560,12 +571,12 @@ function ValidateImage()
|
|||
if (width)
|
||||
globalElement.setAttribute("width", width);
|
||||
else if (srcChanged)
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "width", true);
|
||||
editor.removeAttributeOrEquivalent(globalElement, "width", true);
|
||||
|
||||
if (height)
|
||||
globalElement.setAttribute("height", height);
|
||||
else if (srcChanged)
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "height", true);
|
||||
editor.removeAttributeOrEquivalent(globalElement, "height", true);
|
||||
|
||||
// spacing attributes
|
||||
gValidateTab = gDialog.tabBorder;
|
||||
|
@ -598,7 +609,9 @@ function ValidateImage()
|
|||
globalElement.setAttribute( "align", gDialog.alignTypeSelect.value );
|
||||
break;
|
||||
default:
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "align", true);
|
||||
try {
|
||||
editor.removeAttributeOrEquivalent(globalElement, "align", true);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -21,18 +21,24 @@
|
|||
* Pete Collins
|
||||
* Brian King
|
||||
* Ben Goodger
|
||||
* Charles Manske (cmanske@netscape.com)
|
||||
* Neil Rashbrook (neil@parkwaycc.co.uk)
|
||||
*/
|
||||
|
||||
var gAnchorElement = null;
|
||||
var gOriginalHref = "";
|
||||
var gHNodeArray = [];
|
||||
var gHNodeArray = {};
|
||||
|
||||
// dialog initialization code
|
||||
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
ImageStartup();
|
||||
gDialog.hrefInput = document.getElementById("hrefInput");
|
||||
|
@ -52,13 +58,17 @@ function Startup()
|
|||
else
|
||||
{
|
||||
// First check for <input type="image">
|
||||
imageElement = editorShell.GetSelectedElement("input");
|
||||
try {
|
||||
imageElement = editor.getSelectedElement("input");
|
||||
|
||||
if (!imageElement || imageElement.getAttribute("type") != "image") {
|
||||
// Get a single selected image element
|
||||
imageElement = editorShell.GetSelectedElement(tagName);
|
||||
imageElement = editor.getSelectedElement(tagName);
|
||||
if (imageElement)
|
||||
gAnchorElement = editorShell.GetElementOrParentByTagName("href", imageElement);
|
||||
gAnchorElement = editor.getElementOrParentByTagName("href", imageElement);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
}
|
||||
|
||||
if (imageElement)
|
||||
|
@ -77,15 +87,19 @@ function Startup()
|
|||
|
||||
// We don't have an element selected,
|
||||
// so create one with default attributes
|
||||
try {
|
||||
imageElement = editor.createElementWithDefaults(tagName);
|
||||
} catch(e) {}
|
||||
|
||||
imageElement = editorShell.CreateElementWithDefaults(tagName);
|
||||
if (!imageElement)
|
||||
{
|
||||
dump("Failed to get selected element or create a new one!\n");
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
gAnchorElement = editorShell.GetSelectedElement(tagName);
|
||||
try {
|
||||
gAnchorElement = editor.getSelectedElement("href");
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Make a copy to use for AdvancedEdit
|
||||
|
@ -178,7 +192,9 @@ function onAccept()
|
|||
return true;
|
||||
}
|
||||
|
||||
editorShell.BeginBatchChanges();
|
||||
var editor = GetCurrentEditor();
|
||||
|
||||
editor.beginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -187,13 +203,22 @@ function onAccept()
|
|||
globalElement.removeAttribute("usemap");
|
||||
if (gImageMap)
|
||||
{
|
||||
editorShell.DeleteElement(gImageMap);
|
||||
editor.deleteNode(gImageMap);
|
||||
gInsertNewIMap = true;
|
||||
gImageMap = null;
|
||||
}
|
||||
}
|
||||
else if (gImageMap)
|
||||
{
|
||||
// un-comment to see that inserting image maps does not work!
|
||||
gImageMap = editor.createElementWithDefaults("map");
|
||||
gImageMap.setAttribute("name", "testing");
|
||||
var testArea = editor.createElementWithDefaults("area");
|
||||
testArea.setAttribute("shape", "circle");
|
||||
testArea.setAttribute("coords", "86,102,52");
|
||||
testArea.setAttribute("href", "test");
|
||||
gImageMap.appendChild(testArea);
|
||||
|
||||
// Assign to map if there is one
|
||||
var mapName = gImageMap.getAttribute("name");
|
||||
if (mapName != "")
|
||||
|
@ -202,19 +227,13 @@ function onAccept()
|
|||
if (globalElement.getAttribute("border") == "")
|
||||
globalElement.setAttribute("border", 0);
|
||||
}
|
||||
|
||||
if (gInsertNewIMap)
|
||||
{
|
||||
editorShell.editorDocument.body.appendChild(gImageMap);
|
||||
//editorShell.InsertElementAtSelection(gImageMap, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Create or remove the link as appropriate
|
||||
var href = gDialog.hrefInput.value;
|
||||
if (href != gOriginalHref)
|
||||
{
|
||||
if (href)
|
||||
if (href && !gInsertNewImage)
|
||||
EditorSetTextProperty("a", "href", href);
|
||||
else
|
||||
EditorRemoveTextProperty("href", "");
|
||||
|
@ -233,48 +252,52 @@ function onAccept()
|
|||
globalElement.setAttribute("border", "0");
|
||||
}
|
||||
|
||||
// All values are valid - copy to actual element in doc or
|
||||
// element created to insert
|
||||
editorShell.CloneAttributes(imageElement, globalElement);
|
||||
if (gInsertNewImage)
|
||||
{
|
||||
if (href) {
|
||||
var linkElement = editor.createElementWithDefaults("a");
|
||||
linkElement.setAttribute("href", href);
|
||||
linkElement.appendChild(imageElement);
|
||||
editor.insertElementAtSelection(linkElement, true);
|
||||
}
|
||||
else
|
||||
// 'true' means delete the selection before inserting
|
||||
editorShell.InsertElementAtSelection(imageElement, true);
|
||||
// Also move the insertion point out of the link
|
||||
if (href)
|
||||
setTimeout(editorShell.RemoveTextProperty, 0, "href", "");
|
||||
editor.insertElementAtSelection(imageElement, true);
|
||||
}
|
||||
|
||||
// Check to see if the link was to a heading
|
||||
// Do this last because it moves the caret (BAD!)
|
||||
var index = gDialog.hrefInput.selectedIndex;
|
||||
if (index in gHNodeArray && gHNodeArray[index])
|
||||
if (href in gHNodeArray)
|
||||
{
|
||||
var anchorNode = editorShell.editorDocument.createElement("a");
|
||||
var anchorNode = editor.createElementWithDefaults("a");
|
||||
if (anchorNode)
|
||||
{
|
||||
anchorNode.name = href.substr(1);
|
||||
// Remember to use editorShell method so it is undoable!
|
||||
editorShell.InsertElement(anchorNode, gHNodeArray[index], 0, false);
|
||||
// Remember to use editor method so it is undoable!
|
||||
editor.insertNode(anchorNode, gHNodeArray[href], 0, false);
|
||||
}
|
||||
}
|
||||
// All values are valid - copy to actual element in doc or
|
||||
// element we just inserted
|
||||
editor.cloneAttributes(imageElement, globalElement);
|
||||
|
||||
// un-comment to see that inserting image maps does not work!
|
||||
/*test = editorShell.CreateElementWithDefaults("map");
|
||||
test.setAttribute("name", "testing");
|
||||
testArea = editorShell.CreateElementWithDefaults("area");
|
||||
testArea.setAttribute("shape", "circle");
|
||||
testArea.setAttribute("coords", "86,102,52");
|
||||
testArea.setAttribute("href", "test");
|
||||
test.appendChild(testArea);
|
||||
editorShell.InsertElementAtSelection(test, false);*/
|
||||
// If document is empty, the map element won't insert,
|
||||
// so always insert the image first
|
||||
if (gImageMap && gInsertNewIMap)
|
||||
{
|
||||
// Insert the ImageMap element at beginning of document
|
||||
var body = editor.rootElement;
|
||||
editor.setShouldTxnSetSelection(false);
|
||||
editor.insertNode(gImageMap, body, 0);
|
||||
editor.setShouldTxnSetSelection(true);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
dump(e);
|
||||
}
|
||||
|
||||
editorShell.EndBatchChanges();
|
||||
editor.endTransaction();
|
||||
|
||||
SaveWindowLocation();
|
||||
return true;
|
||||
|
|
|
@ -38,8 +38,12 @@
|
|||
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
gDialog = {
|
||||
inputName: document.getElementById( "InputName" ),
|
||||
|
@ -51,7 +55,9 @@ function Startup()
|
|||
|
||||
// Get a single selected input element
|
||||
var tagName = "input";
|
||||
imageElement = editorShell.GetSelectedElement(tagName);
|
||||
try {
|
||||
imageElement = editor.getSelectedElement(tagName);
|
||||
} catch (e) {}
|
||||
|
||||
if (imageElement)
|
||||
{
|
||||
|
@ -64,16 +70,21 @@ function Startup()
|
|||
|
||||
// We don't have an element selected,
|
||||
// so create one with default attributes
|
||||
try {
|
||||
imageElement = editor.createElementWithDefaults(tagName);
|
||||
} catch(e) {}
|
||||
|
||||
imageElement = editorShell.CreateElementWithDefaults(tagName);
|
||||
if( !imageElement )
|
||||
if (!imageElement )
|
||||
{
|
||||
dump("Failed to get selected element or create a new one!\n");
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
var imgElement;
|
||||
try {
|
||||
imgElement = editor.getSelectedElement("img");
|
||||
} catch(e) {}
|
||||
|
||||
var imgElement = editorShell.GetSelectedElement("img");
|
||||
if (imgElement)
|
||||
{
|
||||
// We found an image element, convert it to an input type="image"
|
||||
|
@ -143,14 +154,16 @@ function onAccept()
|
|||
if (ValidateData())
|
||||
{
|
||||
|
||||
editorShell.BeginBatchChanges();
|
||||
var editor = GetCurrentEditor();
|
||||
editor.beginTransaction();
|
||||
|
||||
try {
|
||||
if (gRemoveImageMap)
|
||||
{
|
||||
globalElement.removeAttribute("usemap");
|
||||
if (gImageMap)
|
||||
{
|
||||
editorShell.DeleteElement(gImageMap);
|
||||
editor.deleteNode(gImageMap);
|
||||
gInsertNewIMap = true;
|
||||
gImageMap = null;
|
||||
}
|
||||
|
@ -165,35 +178,29 @@ function onAccept()
|
|||
if (globalElement.getAttribute("border") == "")
|
||||
globalElement.setAttribute("border", 0);
|
||||
}
|
||||
|
||||
if (gInsertNewIMap)
|
||||
{
|
||||
try
|
||||
{
|
||||
editorShell.editorDocument.body.appendChild(gImageMap);
|
||||
//editorShell.InsertElementAtSelection(gImageMap, false);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
dump("Exception occured in InsertElementAtSelection\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editorShell.CloneAttributes(imageElement, globalElement);
|
||||
|
||||
if (gInsertNewImage)
|
||||
{
|
||||
try {
|
||||
// 'true' means delete the selection before inserting
|
||||
// in case were are converting an image to an input type="image"
|
||||
editorShell.InsertElementAtSelection(imageElement, true);
|
||||
} catch (e) {
|
||||
dump(e);
|
||||
}
|
||||
editor.insertElementAtSelection(imageElement, true);
|
||||
}
|
||||
editor.cloneAttributes(imageElement, globalElement);
|
||||
|
||||
editorShell.EndBatchChanges();
|
||||
// If document is empty, the map element won't insert,
|
||||
// so always insert the image element first
|
||||
if (gImageMap && gInsertNewIMap)
|
||||
{
|
||||
// Insert the ImageMap element at beginning of document
|
||||
var body = editor.rootElement;
|
||||
editor.setShouldTxnSetSelection(false);
|
||||
editor.insertNode(gImageMap, body, 0);
|
||||
editor.setShouldTxnSetSelection(true);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
editor.endTransaction();
|
||||
|
||||
SaveWindowLocation();
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Baki Bon <bakibon@yahoo.com> (original author)
|
||||
* Charles Manske (cmanske@netscape.com)
|
||||
* Neil Rashbrook (neil@parkwaycc.co.uk)
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -36,8 +38,11 @@ var NCount = VCount * TCount;
|
|||
// dialog initialization code
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
if (!GetCurrentEditor())
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
StartupLatin();
|
||||
|
||||
|
@ -65,9 +70,9 @@ function Startup()
|
|||
function onAccept()
|
||||
{
|
||||
// Insert the character
|
||||
// Note: Assiated parent window and editorShell
|
||||
// will be changed to whatever editor window has the focus
|
||||
window.editorShell.InsertText(LatinChar);
|
||||
try {
|
||||
GetCurrentEditor().insertText(LatinM.label);
|
||||
} catch(e) {}
|
||||
|
||||
// Set persistent attributes to save
|
||||
// which category, letter, and character modifier was used
|
||||
|
@ -101,7 +106,6 @@ var LatinL;
|
|||
var LatinM;
|
||||
var LatinL_Label;
|
||||
var LatinM_Label;
|
||||
var LatinChar;
|
||||
var indexL=0;
|
||||
var indexM=0;
|
||||
var indexM_AU=0;
|
||||
|
@ -217,22 +221,11 @@ function UpdateLatinL()
|
|||
if (category == "AccentUpper" || category == "AccentLower")
|
||||
{
|
||||
DisableLatinL(false);
|
||||
var basic;
|
||||
// No Q or q
|
||||
var alphabet = category == "AccentUpper" ? "ABCDEFGHIJKLMNOPRSTUVWXYZ" : "abcdefghijklmnoprstuvwxyz";
|
||||
for (var letter = 0; letter < alphabet.length; letter++)
|
||||
LatinL.appendItem(alphabet.charAt(letter));
|
||||
|
||||
// Fill the list
|
||||
if (category == "AccentUpper") // Uppercase Diacritical
|
||||
{
|
||||
for(basic=0; basic < 26; basic++)
|
||||
AppendStringToMenulist(LatinL , String.fromCharCode(0x41 + basic));
|
||||
}
|
||||
else // Lowercase Diacritical
|
||||
{
|
||||
for(basic=0; basic < 26; basic++)
|
||||
AppendStringToMenulist(LatinL , String.fromCharCode(0x61 + basic));
|
||||
}
|
||||
// Set the selected item
|
||||
if (indexL > 25)
|
||||
indexL = 25;
|
||||
LatinL.selectedIndex = indexL;
|
||||
}
|
||||
else
|
||||
|
@ -246,27 +239,27 @@ function UpdateLatinL()
|
|||
function UpdateLatinM()
|
||||
{
|
||||
ClearMenulist(LatinM);
|
||||
var i, basic;
|
||||
var i, accent;
|
||||
switch(category)
|
||||
{
|
||||
case "AccentUpper": // Uppercase Diacritical
|
||||
for(basic=0; basic < upper[indexL].length; basic++)
|
||||
AppendStringToMenulist(LatinM ,
|
||||
String.fromCharCode(upper[indexL][basic]));
|
||||
accent = upper[indexL];
|
||||
for(i=0; i < accent.length; i++)
|
||||
LatinM.appendItem(accent.charAt(i));
|
||||
|
||||
if(indexM_AU < upper[indexL].length)
|
||||
if(indexM_AU < accent.length)
|
||||
indexM = indexM_AU;
|
||||
else
|
||||
indexM = upper[indexL].length - 1;
|
||||
indexM = accent.length - 1;
|
||||
indexM_AU = indexM;
|
||||
break;
|
||||
|
||||
case "AccentLower": // Lowercase Diacritical
|
||||
for(basic=0; basic < lower[indexL].length; basic++)
|
||||
AppendStringToMenulist(LatinM ,
|
||||
String.fromCharCode(lower[indexL][basic]));
|
||||
accent = lower[indexL];
|
||||
for(i=0; i < accent.length; i++)
|
||||
LatinM.appendItem(accent.charAt(i));
|
||||
|
||||
if(indexM_AL < lower[indexL].length)
|
||||
if(indexM_AL < accent.length)
|
||||
indexM = indexM_AL;
|
||||
else
|
||||
indexM = lower[indexL].length - 1;
|
||||
|
@ -275,7 +268,7 @@ function UpdateLatinM()
|
|||
|
||||
case "Upper": // Uppercase w/o Diacritical
|
||||
for(i=0; i < otherupper.length; i++)
|
||||
AppendStringToMenulist(LatinM, String.fromCharCode(otherupper[i]));
|
||||
LatinM.appendItem(otherupper.charAt(i));
|
||||
|
||||
if(indexM_U < otherupper.length)
|
||||
indexM = indexM_U;
|
||||
|
@ -286,7 +279,7 @@ function UpdateLatinM()
|
|||
|
||||
case "Lower": // Lowercase w/o Diacritical
|
||||
for(i=0; i < otherlower.length; i++)
|
||||
AppendStringToMenulist(LatinM , String.fromCharCode(otherlower[i]));
|
||||
LatinM.appendItem(otherlower.charAt(i));
|
||||
|
||||
if(indexM_L < otherlower.length)
|
||||
indexM = indexM_L;
|
||||
|
@ -297,7 +290,7 @@ function UpdateLatinM()
|
|||
|
||||
case "Symbol": // Symbol
|
||||
for(i=0; i < symbol.length; i++)
|
||||
AppendStringToMenulist(LatinM , String.fromCharCode(symbol[i]));
|
||||
LatinM.appendItem(symbol.charAt(i));
|
||||
|
||||
if(indexM_S < symbol.length)
|
||||
indexM = indexM_S;
|
||||
|
@ -316,272 +309,135 @@ function UpdateCharacter()
|
|||
switch(category)
|
||||
{
|
||||
case "AccentUpper": // Uppercase Diacritical
|
||||
LatinChar = String.fromCharCode(upper[indexL][indexM]);
|
||||
indexM_AU = indexM;
|
||||
break;
|
||||
case "AccentLower": // Lowercase Diacritical
|
||||
LatinChar = String.fromCharCode(lower[indexL][indexM]);
|
||||
indexM_AL = indexM;
|
||||
break;
|
||||
case "Upper": // Uppercase w/o Diacritical
|
||||
LatinChar = String.fromCharCode(otherupper[indexM]);
|
||||
indexM_U = indexM;
|
||||
break;
|
||||
case "Lower": // Lowercase w/o Diacritical
|
||||
LatinChar = String.fromCharCode(otherlower[indexM]);
|
||||
indexM_L = indexM;
|
||||
break;
|
||||
case "Symbol":
|
||||
LatinChar = String.fromCharCode(symbol[indexM]);
|
||||
indexM_S = indexM;
|
||||
break;
|
||||
}
|
||||
//dump("Letter Index="+indexL+", Character Index="+indexM+", Character = "+LatinChar+"\n");
|
||||
//dump("Letter Index="+indexL+", Character Index="+indexM+", Character = "+LatinM.label+"\n");
|
||||
}
|
||||
|
||||
var upper=[
|
||||
[ // A
|
||||
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5,
|
||||
0x0100, 0x0102, 0x0104, 0x01cd, 0x01de, 0x01de, 0x01e0, 0x01fa,
|
||||
0x0200, 0x0202, 0x0226,
|
||||
0x1e00, 0x1ea0, 0x1ea2, 0x1ea4, 0x1ea6, 0x1ea8, 0x1eaa, 0x1eac,
|
||||
0x1eae, 0x1eb0, 0x1eb2, 0x1eb4, 0x1eb6
|
||||
], [ // B
|
||||
0x0181, 0x0182, 0x0184,
|
||||
0x1e02, 0x1e04, 0x1e06
|
||||
], [ // C
|
||||
0x00c7, 0x0106, 0x0108, 0x010a, 0x010c,
|
||||
0x0187,
|
||||
0x1e08
|
||||
], [ // D
|
||||
0x010e, 0x0110,
|
||||
0x0189,
|
||||
0x018a,
|
||||
0x1e0a, 0x1e0c, 0x1e0e, 0x1e10, 0x1e12
|
||||
], [ // E
|
||||
0x00C8, 0x00C9, 0x00CA, 0x00CB,
|
||||
0x0112, 0x0114, 0x0116, 0x0118, 0x011A,
|
||||
0x0204, 0x0206, 0x0228,
|
||||
0x1e14, 0x1e16, 0x1e18, 0x1e1a, 0x1e1c,
|
||||
0x1eb8, 0x1eba, 0x1ebc, 0x1ebe, 0x1ec0, 0x1ec2, 0x1ec4, 0x1ec6
|
||||
], [ // F
|
||||
0x1e1e
|
||||
], [ // G
|
||||
0x011c, 0x011E, 0x0120, 0x0122,
|
||||
0x01e4, 0x01e6, 0x01f4,
|
||||
0x1e20
|
||||
], [ // H
|
||||
0x0124, 0x0126,
|
||||
0x021e,
|
||||
0x1e22, 0x1e24, 0x1e26, 0x1e28, 0x1e2a
|
||||
], [ // I
|
||||
0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
||||
0x0128, 0x012a, 0x012C, 0x012e, 0x0130,
|
||||
0x0208, 0x020a,
|
||||
0x1e2c, 0x1e2e,
|
||||
0x1ec8, 0x1eca
|
||||
], [ // J
|
||||
0x0134,
|
||||
0x01f0
|
||||
], [ // K
|
||||
0x0136,
|
||||
0x0198, 0x01e8,
|
||||
0x1e30, 0x1e32, 0x1e34
|
||||
], [ // L
|
||||
0x0139, 0x013B, 0x013D, 0x013F, 0x0141,
|
||||
0x1e36, 0x1e38, 0x1e3a, 0x1e3c
|
||||
], [ // M
|
||||
0x1e3e, 0x1e40, 0x1e42
|
||||
], [ // N
|
||||
0x00D1,
|
||||
0x0143, 0x0145, 0x0147, 0x014A,
|
||||
0x01F8,
|
||||
0x1e44, 0x1e46, 0x1e48, 0x1e4a
|
||||
], [ // O
|
||||
0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6,
|
||||
0x014C, 0x014E, 0x0150,
|
||||
0x01ea, 0x01ec,
|
||||
0x020c, 0x020e, 0x022A, 0x022C, 0x022E, 0x0230,
|
||||
0x1e4c, 0x1e4e, 0x1e50, 0x1e52,
|
||||
0x1ecc, 0x1ece, 0x1ed0, 0x1ed2, 0x1ed4, 0x1ed6, 0x1ed8, 0x1eda, 0x1edc, 0x1ede,
|
||||
0x1ee0, 0x1ee2
|
||||
], [ // P
|
||||
0x1e54, 0x1e56
|
||||
], [ // Q
|
||||
0x0051
|
||||
], [ // R
|
||||
0x0154, 0x0156, 0x0158,
|
||||
0x0210, 0x0212,
|
||||
0x1e58, 0x1e5a, 0x1e5c, 0x1e5e
|
||||
], [ // S
|
||||
0x015A, 0x015C, 0x015E, 0x0160,
|
||||
0x0218,
|
||||
0x1e60, 0x1e62, 0x1e64, 0x1e66, 0x1e68
|
||||
], [ // T
|
||||
0x0162, 0x0164, 0x0166,
|
||||
0x021A,
|
||||
0x1e6a, 0x1e6c, 0x1e6e, 0x1e70
|
||||
], [ // U
|
||||
0x00D9, 0x00DA, 0x00DB, 0x00DC,
|
||||
0x0168, 0x016A, 0x016C, 0x016E, 0x0170, 0x0172,
|
||||
0x0214, 0x0216,
|
||||
0x1e72, 0x1e74, 0x1e76, 0x1e78, 0x1e7a,
|
||||
0x1ee4, 0x1ee6, 0x1ee8, 0x1eea, 0x1eec, 0x1eee, 0x1ef0
|
||||
], [ // V
|
||||
0x1e7c, 0x1e7e
|
||||
], [ // W
|
||||
0x0174,
|
||||
0x1e80, 0x1e82, 0x1e84, 0x1e86, 0x1e88
|
||||
], [ // X
|
||||
0x1e8a, 0x1e8c
|
||||
], [ // Y
|
||||
0x00DD,
|
||||
0x0176, 0x0178,
|
||||
0x0232,
|
||||
0x1e8e,
|
||||
0x1ef2, 0x1ef4, 0x1ef6, 0x1ef8
|
||||
], [ // Z
|
||||
0x0179, 0x017B, 0x017D,
|
||||
0x0224,
|
||||
0x1e90, 0x1e92, 0x1e94
|
||||
] ];
|
||||
var lower=[
|
||||
[ // a
|
||||
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5,
|
||||
0x0101, 0x0103, 0x0105,
|
||||
0x01ce, 0x01df, 0x01e1, 0x01fb,
|
||||
0x0201, 0x0203, 0x0227,
|
||||
0x1e01, 0x1e9a,
|
||||
0x1ea1, 0x1ea3, 0x1ea5, 0x1ea7, 0x1ea9, 0x1eab, 0x1ead, 0x1eaf,
|
||||
0x1eb1, 0x1eb3, 0x1eb5, 0x1eb7
|
||||
], [ // b
|
||||
0x0180, 0x0183, 0x0185,
|
||||
0x1e03, 0x1e05, 0x1e07
|
||||
], [ // c
|
||||
0x00e7,
|
||||
0x0107, 0x0109, 0x010b, 0x010d,
|
||||
0x0188,
|
||||
0x1e09
|
||||
], [ // d
|
||||
0x010f, 0x0111,
|
||||
0x1e0b, 0x1e0d, 0x1e0f, 0x1e11, 0x1e13
|
||||
], [ // e
|
||||
0x00e8, 0x00e9, 0x00ea, 0x00eb,
|
||||
0x0113, 0x0115, 0x0117, 0x0119, 0x011b,
|
||||
0x0205, 0x0207, 0x0229,
|
||||
0x1e15, 0x1e17, 0x1e19, 0x1e1b, 0x1e1d,
|
||||
0x1eb9, 0x1ebb, 0x1ebd, 0x1ebf,
|
||||
0x1ec1, 0x1ec3, 0x1ec5, 0x1ec7
|
||||
], [ // f
|
||||
0x1e1f
|
||||
], [ // g
|
||||
0x011d, 0x011f, 0x0121, 0x0123,
|
||||
0x01e5, 0x01e7, 0x01f5,
|
||||
0x1e21
|
||||
], [ // h
|
||||
0x0125, 0x0127,
|
||||
0x021f,
|
||||
0x1e23, 0x1e25, 0x1e27, 0x1e29, 0x1e2b, 0x1e96
|
||||
], [ // i
|
||||
0x00ec, 0x00ed, 0x00ee, 0x00ef,
|
||||
0x0129, 0x012b, 0x012d, 0x012f, 0x0131,
|
||||
0x01d0,
|
||||
0x0209, 0x020b,
|
||||
0x1e2d, 0x1e2f,
|
||||
0x1ec9, 0x1ecb
|
||||
], [ // j
|
||||
0x0135,
|
||||
], [ // k
|
||||
0x0137, 0x0138,
|
||||
0x01e9,
|
||||
0x1e31, 0x1e33, 0x1e35
|
||||
], [ // l
|
||||
0x013a, 0x013c, 0x013e, 0x0140, 0x0142,
|
||||
0x1e37, 0x1e39, 0x1e3b, 0x1e3d
|
||||
], [ // m
|
||||
0x1e3f, 0x1e41, 0x1e43
|
||||
], [ // n
|
||||
0x00f1,
|
||||
0x0144, 0x0146, 0x0148, 0x0149, 0x014b,
|
||||
0x01f9,
|
||||
0x1e45, 0x1e47, 0x1e49, 0x1e4b
|
||||
], [ // o
|
||||
0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6,
|
||||
0x014d, 0x014f, 0x0151,
|
||||
0x01d2, 0x01eb, 0x01ed,
|
||||
0x020d, 0x020e, 0x022b, 0x22d, 0x022f, 0x0231,
|
||||
0x1e4d, 0x1e4f, 0x1e51, 0x1e53,
|
||||
0x1ecd, 0x1ecf,
|
||||
0x1ed1, 0x1ed3, 0x1ed5, 0x1ed7, 0x1ed9, 0x1edb, 0x1edd, 0x1edf,
|
||||
0x1ee1, 0x1ee3
|
||||
], [ // p
|
||||
0x1e55, 0x1e57
|
||||
], [ // q
|
||||
0x0071
|
||||
], [ // r
|
||||
0x0155, 0x0157, 0x0159,
|
||||
0x0211, 0x0213,
|
||||
0x1e59, 0x1e5b, 0x1e5d, 0x1e5f
|
||||
], [ // s
|
||||
0x015b, 0x015d, 0x015f, 0x0161,
|
||||
0x0219,
|
||||
0x1e61, 0x1e63, 0x1e65, 0x1e67, 0x1e69
|
||||
], [ // t
|
||||
0x0162, 0x0163, 0x0165, 0x0167,
|
||||
0x021b,
|
||||
0x1e6b, 0x1e6d, 0x1e6f, 0x1e71,
|
||||
0x1e97
|
||||
], [ // u
|
||||
0x00f9, 0x00fa, 0x00fb, 0x00fc,
|
||||
0x0169, 0x016b, 0x016d, 0x016f, 0x0171, 0x0173,
|
||||
0x01d4, 0x01d6, 0x01d8, 0x01da, 0x01dc,
|
||||
0x0215, 0x0217,
|
||||
0x1e73, 0x1e75, 0x1e77, 0x1e79, 0x1e7b,
|
||||
0x1ee5, 0x1ee7, 0x1ee9, 0x1eeb, 0x1eed, 0x1eef,
|
||||
0x1ef1
|
||||
], [ // v
|
||||
0x1e7d, 0x1e7f
|
||||
], [ // w
|
||||
0x0175,
|
||||
0x1e81, 0x1e83, 0x1e85, 0x1e87, 0x1e89, 0x1e98,
|
||||
], [ // x
|
||||
0x1e8b, 0x1e8d
|
||||
], [ // y
|
||||
0x00fd, 0x00ff,
|
||||
0x0177,
|
||||
0x0233,
|
||||
0x1e8f, 0x1e99, 0x1ef3, 0x1ef5, 0x1ef7, 0x1ef9
|
||||
], [ // z
|
||||
0x017a, 0x017c, 0x017e,
|
||||
0x0225,
|
||||
0x1e91, 0x1e93, 0x1e95
|
||||
] ];
|
||||
|
||||
|
||||
var symbol = [
|
||||
0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x20ac, 0x00a6, 0x00a7,
|
||||
0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ae, 0x00af,
|
||||
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
|
||||
0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
|
||||
0x00d7, 0x00f7
|
||||
const upper=[
|
||||
// A
|
||||
"\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5\u0100\u0102\u0104\u01cd\u01de\u01de\u01e0\u01fa\u0200\u0202\u0226\u1e00\u1ea0\u1ea2\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6",
|
||||
// B
|
||||
"\u0181\u0182\u0184\u1e02\u1e04\u1e06",
|
||||
// C
|
||||
"\u00c7\u0106\u0108\u010a\u010c\u0187\u1e08",
|
||||
// D
|
||||
"\u010e\u0110\u0189\u018a\u1e0a\u1e0c\u1e0e\u1e10\u1e12",
|
||||
// E
|
||||
"\u00C8\u00C9\u00CA\u00CB\u0112\u0114\u0116\u0118\u011A\u0204\u0206\u0228\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1eb8\u1eba\u1ebc\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6",
|
||||
// F
|
||||
"\u1e1e",
|
||||
// G
|
||||
"\u011c\u011E\u0120\u0122\u01e4\u01e6\u01f4\u1e20",
|
||||
// H
|
||||
"\u0124\u0126\u021e\u1e22\u1e24\u1e26\u1e28\u1e2a",
|
||||
// I
|
||||
"\u00CC\u00CD\u00CE\u00CF\u0128\u012a\u012C\u012e\u0130\u0208\u020a\u1e2c\u1e2e\u1ec8\u1eca",
|
||||
// J
|
||||
"\u0134\u01f0",
|
||||
// K
|
||||
"\u0136\u0198\u01e8\u1e30\u1e32\u1e34",
|
||||
// L
|
||||
"\u0139\u013B\u013D\u013F\u0141\u1e36\u1e38\u1e3a\u1e3c",
|
||||
// M
|
||||
"\u1e3e\u1e40\u1e42",
|
||||
// N
|
||||
"\u00D1\u0143\u0145\u0147\u014A\u01F8\u1e44\u1e46\u1e48\u1e4a",
|
||||
// O
|
||||
"\u00D2\u00D3\u00D4\u00D5\u00D6\u014C\u014E\u0150\u01ea\u01ec\u020c\u020e\u022A\u022C\u022E\u0230\u1e4c\u1e4e\u1e50\u1e52\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede\u1ee0\u1ee2",
|
||||
// P
|
||||
"\u1e54\u1e56",
|
||||
// No Q
|
||||
// R
|
||||
"\u0154\u0156\u0158\u0210\u0212\u1e58\u1e5a\u1e5c\u1e5e",
|
||||
// S
|
||||
"\u015A\u015C\u015E\u0160\u0218\u1e60\u1e62\u1e64\u1e66\u1e68",
|
||||
// T
|
||||
"\u0162\u0164\u0166\u021A\u1e6a\u1e6c\u1e6e\u1e70",
|
||||
// U
|
||||
"\u00D9\u00DA\u00DB\u00DC\u0168\u016A\u016C\u016E\u0170\u0172\u0214\u0216\u1e72\u1e74\u1e76\u1e78\u1e7a\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0",
|
||||
// V
|
||||
"\u1e7c\u1e7e",
|
||||
// W
|
||||
"\u0174\u1e80\u1e82\u1e84\u1e86\u1e88",
|
||||
// X
|
||||
"\u1e8a\u1e8c",
|
||||
// Y
|
||||
"\u00DD\u0176\u0178\u0232\u1e8e\u1ef2\u1ef4\u1ef6\u1ef8",
|
||||
// Z
|
||||
"\u0179\u017B\u017D\u0224\u1e90\u1e92\u1e94"
|
||||
];
|
||||
|
||||
var otherupper = [
|
||||
0x00c6, 0x00d0, 0x00d8, 0x00de,
|
||||
0x0132,
|
||||
0x0152,
|
||||
0x0186,
|
||||
0x01c4, 0x01c5,
|
||||
0x01c7, 0x01c8,
|
||||
0x01ca, 0x01cb,
|
||||
0x01F1, 0x01f2
|
||||
];
|
||||
var otherlower = [
|
||||
0x00e6, 0x00f0, 0x00f8, 0x00fe, 0x00df,
|
||||
0x0133,
|
||||
0x0153,
|
||||
0x01c6,
|
||||
0x01c9,
|
||||
0x01cc,
|
||||
0x01f3
|
||||
const lower=[
|
||||
// a
|
||||
"\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5\u0101\u0103\u0105\u01ce\u01df\u01e1\u01fb\u0201\u0203\u0227\u1e01\u1e9a\u1ea1\u1ea3\u1ea5\u1ea7\u1ea9\u1eab\u1ead\u1eaf\u1eb1\u1eb3\u1eb5\u1eb7",
|
||||
// b
|
||||
"\u0180\u0183\u0185\u1e03\u1e05\u1e07",
|
||||
// c
|
||||
"\u00e7\u0107\u0109\u010b\u010d\u0188\u1e09",
|
||||
// d
|
||||
"\u010f\u0111\u1e0b\u1e0d\u1e0f\u1e11\u1e13",
|
||||
// e
|
||||
"\u00e8\u00e9\u00ea\u00eb\u0113\u0115\u0117\u0119\u011b\u0205\u0207\u0229\u1e15\u1e17\u1e19\u1e1b\u1e1d\u1eb9\u1ebb\u1ebd\u1ebf\u1ec1\u1ec3\u1ec5\u1ec7",
|
||||
// f
|
||||
"\u1e1f",
|
||||
// g
|
||||
"\u011d\u011f\u0121\u0123\u01e5\u01e7\u01f5\u1e21",
|
||||
// h
|
||||
"\u0125\u0127\u021f\u1e23\u1e25\u1e27\u1e29\u1e2b\u1e96",
|
||||
// i
|
||||
"\u00ec\u00ed\u00ee\u00ef\u0129\u012b\u012d\u012f\u0131\u01d0\u0209\u020b\u1e2d\u1e2f\u1ec9\u1ecb",
|
||||
// j
|
||||
"\u0135",
|
||||
// k
|
||||
"\u0137\u0138\u01e9\u1e31\u1e33\u1e35",
|
||||
// l
|
||||
"\u013a\u013c\u013e\u0140\u0142\u1e37\u1e39\u1e3b\u1e3d",
|
||||
// m
|
||||
"\u1e3f\u1e41\u1e43",
|
||||
// n
|
||||
"\u00f1\u0144\u0146\u0148\u0149\u014b\u01f9\u1e45\u1e47\u1e49\u1e4b",
|
||||
// o
|
||||
"\u00f2\u00f3\u00f4\u00f5\u00f6\u014d\u014f\u0151\u01d2\u01eb\u01ed\u020d\u020e\u022b\u22d\u022f\u0231\u1e4d\u1e4f\u1e51\u1e53\u1ecd\u1ecf\u1ed1\u1ed3\u1ed5\u1ed7\u1ed9\u1edb\u1edd\u1edf\u1ee1\u1ee3",
|
||||
// p
|
||||
"\u1e55\u1e57",
|
||||
// No q
|
||||
// r
|
||||
"\u0155\u0157\u0159\u0211\u0213\u1e59\u1e5b\u1e5d\u1e5f",
|
||||
// s
|
||||
"\u015b\u015d\u015f\u0161\u0219\u1e61\u1e63\u1e65\u1e67\u1e69",
|
||||
// t
|
||||
"\u0162\u0163\u0165\u0167\u021b\u1e6b\u1e6d\u1e6f\u1e71\u1e97",
|
||||
// u
|
||||
"\u00f9\u00fa\u00fb\u00fc\u0169\u016b\u016d\u016f\u0171\u0173\u01d4\u01d6\u01d8\u01da\u01dc\u0215\u0217\u1e73\u1e75\u1e77\u1e79\u1e7b\u1ee5\u1ee7\u1ee9\u1eeb\u1eed\u1eef\u1ef1",
|
||||
// v
|
||||
"\u1e7d\u1e7f",
|
||||
// w
|
||||
"\u0175\u1e81\u1e83\u1e85\u1e87\u1e89\u1e98",
|
||||
// x
|
||||
"\u1e8b\u1e8d",
|
||||
// y
|
||||
"\u00fd\u00ff\u0177\u0233\u1e8f\u1e99\u1ef3\u1ef5\u1ef7\u1ef9",
|
||||
// z
|
||||
"\u017a\u017c\u017e\u0225\u1e91\u1e93\u1e95"
|
||||
];
|
||||
|
||||
|
||||
const symbol = "\u00a1\u00a2\u00a3\u00a4\u00a5\u20ac\u00a6\u00a7\u00a8\u00a9\u00aa\u00ab\u00ac\u00ae\u00af\u00b0\u00b1\u00b2\u00b3\u00b4\u00b5\u00b6\u00b7\u00b8\u00b9\u00ba\u00bb\u00bc\u00bd\u00be\u00bf\u00d7\u00f7";
|
||||
|
||||
const otherupper = "\u00c6\u00d0\u00d8\u00de\u0132\u0152\u0186\u01c4\u01c5\u01c7\u01c8\u01ca\u01cb\u01F1\u01f2";
|
||||
|
||||
const otherlower = "\u00e6\u00f0\u00f8\u00fe\u00df\u0133\u0153\u01c6\u01c9\u01cc\u01f3";
|
||||
|
|
|
@ -56,15 +56,19 @@
|
|||
</radiogroup>
|
||||
<spacer class="spacer"/>
|
||||
</groupbox>
|
||||
<hbox>
|
||||
<hbox equalsize="always">
|
||||
<vbox flex="1">
|
||||
<!-- value is set in JS from editor.properties strings -->
|
||||
<label id="LatinL_Label" control="LatinL" value="&letter.label;" accesskey="&letter.accessKey;"/>
|
||||
<menulist class="larger" flex="1" id="LatinL" oncommand="SelectLatinLetter()"/>
|
||||
<menulist class="larger" flex="1" id="LatinL" oncommand="SelectLatinLetter()">
|
||||
<menupopup/>
|
||||
</menulist>
|
||||
</vbox>
|
||||
<vbox flex="1">
|
||||
<label id="LatinM_Label" control="LatinM" value="&character.label;" accesskey="&character.accessKey;"/>
|
||||
<menulist class="larger" flex="1" id="LatinM" oncommand="SelectLatinModifier()"/>
|
||||
<menulist class="larger" flex="1" id="LatinM" oncommand="SelectLatinModifier()">
|
||||
<menupopup/>
|
||||
</menulist>
|
||||
</vbox>
|
||||
</hbox>
|
||||
<separator class="groove"/>
|
||||
|
|
|
@ -21,22 +21,27 @@
|
|||
*/
|
||||
|
||||
//Cancel() is in EdDialogCommon.js
|
||||
var tagName = "table"
|
||||
var tableElement = null;
|
||||
var rowElement = null;
|
||||
var cellElement = null;
|
||||
var rows;
|
||||
var columns;
|
||||
var prefs = GetPrefs();
|
||||
var gTableElement = null;
|
||||
var gRows;
|
||||
var gColumns;
|
||||
var gActiveEditor;
|
||||
|
||||
// dialog initialization code
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
gActiveEditor = GetCurrentEditor();
|
||||
if (!gActiveEditor)
|
||||
{
|
||||
dump("Failed to get active editor!\n");
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
tableElement = editorShell.CreateElementWithDefaults(tagName);
|
||||
if(!tableElement)
|
||||
try {
|
||||
gTableElement = gActiveEditor.createElementWithDefaults("table");
|
||||
} catch (e) {}
|
||||
|
||||
if(!gTableElement)
|
||||
{
|
||||
dump("Failed to create a new table!\n");
|
||||
window.close();
|
||||
|
@ -50,11 +55,16 @@ function Startup()
|
|||
gDialog.OkButton = document.documentElement.getButton("accept");
|
||||
|
||||
// Make a copy to use for AdvancedEdit
|
||||
globalElement = tableElement.cloneNode(false);
|
||||
if (prefs.getBoolPref("editor.use_css") && (editorShell.editorType == "html")) {
|
||||
globalElement = gTableElement.cloneNode(false);
|
||||
try {
|
||||
if (GetPrefs().getBoolPref("editor.use_css") && isHTMLEditor()
|
||||
&& !(gActiveEditor.flags & Components.interfaces.nsIPlaintextEditor.eEditorMailMask))
|
||||
{
|
||||
// only for Composer and not for htmlmail
|
||||
globalElement.setAttribute("style", "text-align: left;");
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// Initialize all widgets with image attributes
|
||||
InitDialog();
|
||||
|
||||
|
@ -111,11 +121,11 @@ function ChangeRowOrColumn(id)
|
|||
// Set attributes on globalElement so they can be accessed by AdvancedEdit()
|
||||
function ValidateData()
|
||||
{
|
||||
rows = ValidateNumber(gDialog.rowsInput, null, 1, gMaxRows, null, null, true)
|
||||
gRows = ValidateNumber(gDialog.rowsInput, null, 1, gMaxRows, null, null, true)
|
||||
if (gValidationError)
|
||||
return false;
|
||||
|
||||
columns = ValidateNumber(gDialog.columnsInput, null, 1, gMaxColumns, null, null, true)
|
||||
gColumns = ValidateNumber(gDialog.columnsInput, null, 1, gMaxColumns, null, null, true)
|
||||
if (gValidationError)
|
||||
return false;
|
||||
|
||||
|
@ -137,25 +147,26 @@ function onAccept()
|
|||
{
|
||||
if (ValidateData())
|
||||
{
|
||||
editorShell.BeginBatchChanges();
|
||||
editorShell.CloneAttributes(tableElement, globalElement);
|
||||
gActiveEditor.beginTransaction();
|
||||
try {
|
||||
gActiveEditor.cloneAttributes(gTableElement, globalElement);
|
||||
|
||||
// Create necessary rows and cells for the table
|
||||
var tableBody = editorShell.CreateElementWithDefaults("tbody");
|
||||
var tableBody = gActiveEditor.createElementWithDefaults("tbody");
|
||||
if (tableBody)
|
||||
{
|
||||
tableElement.appendChild(tableBody);
|
||||
gTableElement.appendChild(tableBody);
|
||||
|
||||
// Create necessary rows and cells for the table
|
||||
for (var i = 0; i < rows; i++)
|
||||
for (var i = 0; i < gRows; i++)
|
||||
{
|
||||
var newRow = editorShell.CreateElementWithDefaults("tr");
|
||||
var newRow = gActiveEditor.createElementWithDefaults("tr");
|
||||
if (newRow)
|
||||
{
|
||||
tableBody.appendChild(newRow);
|
||||
for (var j = 0; j < columns; j++)
|
||||
for (var j = 0; j < gColumns; j++)
|
||||
{
|
||||
var newCell = editorShell.CreateElementWithDefaults("td");
|
||||
var newCell = gActiveEditor.createElementWithDefaults("td");
|
||||
if (newCell)
|
||||
{
|
||||
newRow.appendChild(newCell);
|
||||
|
@ -168,13 +179,13 @@ function onAccept()
|
|||
// Get number of cells selected
|
||||
var tagNameObj = { value: "" };
|
||||
var countObj = { value: 0 };
|
||||
var element = editorShell.GetSelectedOrParentTableElement(tagNameObj, countObj);
|
||||
var element = gActiveEditor.getSelectedOrParentTableElement(tagNameObj, countObj);
|
||||
var deletePlaceholder = false;
|
||||
|
||||
if (tagNameObj.value == "table")
|
||||
{
|
||||
//Replace entire selected table with new table, so delete the table
|
||||
editorShell.DeleteTable();
|
||||
gActiveEditor.deleteTable();
|
||||
}
|
||||
else if (tagNameObj.value == "td")
|
||||
{
|
||||
|
@ -185,41 +196,39 @@ function onAccept()
|
|||
// Assume user wants to replace a block of
|
||||
// contiguous cells with a table, so
|
||||
// join the selected cells
|
||||
editorShell.JoinTableCells(false);
|
||||
gActiveEditor.joinTableCells(false);
|
||||
|
||||
// Get the cell everything was merged into
|
||||
element = editorShell.GetFirstSelectedCell();
|
||||
element = gActiveEditor.getFirstSelectedCell();
|
||||
|
||||
// Collapse selection into just that cell
|
||||
editorShell.editorSelection.collapse(element,0);
|
||||
gActiveEditor.selection.collapse(element,0);
|
||||
}
|
||||
|
||||
if (element)
|
||||
{
|
||||
// Empty just the contents of the cell
|
||||
editorShell.DeleteTableCellContents();
|
||||
gActiveEditor.deleteTableCellContents();
|
||||
|
||||
// Collapse selection to start of empty cell...
|
||||
editorShell.editorSelection.collapse(element,0);
|
||||
gActiveEditor.selection.collapse(element,0);
|
||||
// ...but it will contain a <br> placeholder
|
||||
deletePlaceholder = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// true means delete selection when inserting
|
||||
editorShell.InsertElementAtSelection(tableElement, true);
|
||||
} catch (e) {
|
||||
dump("Exception occured in InsertElementAtSelection\n");
|
||||
}
|
||||
if (deletePlaceholder && tableElement && tableElement.nextSibling)
|
||||
gActiveEditor.insertElementAtSelection(gTableElement, true);
|
||||
|
||||
if (deletePlaceholder && gTableElement && gTableElement.nextSibling)
|
||||
{
|
||||
// Delete the placeholder <br>
|
||||
editorShell.DeleteElement(tableElement.nextSibling);
|
||||
gActiveEditor.deleteNode(gTableElement.nextSibling);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
editorShell.EndBatchChanges();
|
||||
gActiveEditor.endTransaction();
|
||||
|
||||
SaveWindowLocation();
|
||||
return true;
|
||||
|
|
|
@ -40,8 +40,12 @@ var labelElement;
|
|||
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
gDialog.editText = document.getElementById("EditText");
|
||||
gDialog.labelText = document.getElementById("LabelText");
|
||||
|
@ -55,7 +59,7 @@ function Startup()
|
|||
|
||||
InitDialog();
|
||||
|
||||
editorShell.SelectElement(labelElement);
|
||||
editor.selectElement(labelElement);
|
||||
gDialog.labelText.value = GetSelectionAsText();
|
||||
if (/</.test(labelElement.innerHTML))
|
||||
{
|
||||
|
@ -110,23 +114,25 @@ function onAccept()
|
|||
// All values are valid - copy to actual element in doc
|
||||
ValidateData();
|
||||
|
||||
editorShell.BeginBatchChanges();
|
||||
|
||||
editorShell.CloneAttributes(labelElement, globalElement);
|
||||
var editor = GetCurrentEditor();
|
||||
editor.beginTransaction();
|
||||
|
||||
try {
|
||||
if (gDialog.editText.checked)
|
||||
{
|
||||
var editor = editorShell.editor;
|
||||
while (labelElement.firstChild)
|
||||
editor.deleteNode(labelElement.firstChild);
|
||||
if (gDialog.labelText.value) {
|
||||
var textNode = editorShell.editorDocument.createTextNode(gDialog.labelText.value);
|
||||
var textNode = editor.document.createTextNode(gDialog.labelText.value);
|
||||
editor.insertNode(textNode, labelElement, 0);
|
||||
editorShell.SelectElement(labelElement);
|
||||
editor.selectElement(labelElement);
|
||||
}
|
||||
}
|
||||
|
||||
editorShell.EndBatchChanges();
|
||||
editor.cloneAttributes(labelElement, globalElement);
|
||||
} catch(e) {}
|
||||
|
||||
editor.endTransaction();
|
||||
|
||||
SaveWindowLocation();
|
||||
|
||||
|
|
|
@ -18,8 +18,11 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Charles Manske (cmanske@netscape.com)
|
||||
* Neil Rashbrook (neil@parkwaycc.co.uk)
|
||||
*/
|
||||
|
||||
var gActiveEditor;
|
||||
var anchorElement = null;
|
||||
var imageElement = null;
|
||||
var insertNew = false;
|
||||
|
@ -28,7 +31,7 @@ var insertLinkAtCaret;
|
|||
var needLinkText = false;
|
||||
var href;
|
||||
var newLinkText;
|
||||
var gHNodeArray = [];
|
||||
var gHNodeArray = {};
|
||||
var gHaveNamedAnchors = false;
|
||||
var gHaveHeadings = false;
|
||||
var gCanChangeHeadingSelected = true;
|
||||
|
@ -42,9 +45,13 @@ var tagName = "href";
|
|||
// dialog initialization code
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
gActiveEditor = GetCurrentEditor();
|
||||
if (!gActiveEditor)
|
||||
{
|
||||
dump("Failed to get active editor!\n");
|
||||
window.close();
|
||||
return;
|
||||
|
||||
}
|
||||
// Message was wrapped in a <label> or <div>, so actual text is a child text node
|
||||
gDialog.linkTextCaption = document.getElementById("linkTextCaption");
|
||||
gDialog.linkTextMessage = document.getElementById("linkTextMessage");
|
||||
|
@ -53,19 +60,13 @@ function Startup()
|
|||
gDialog.makeRelativeLink = document.getElementById("MakeRelativeLink");
|
||||
gDialog.AdvancedEditSection = document.getElementById("AdvancedEdit");
|
||||
|
||||
var selection = editorShell.editorSelection;
|
||||
if (selection)
|
||||
dump("There is a selection: collapsed = "+selection.isCollapsed+"\n");
|
||||
else
|
||||
dump("Failed to get selection\n");
|
||||
|
||||
// See if we have a single selected image
|
||||
imageElement = editorShell.GetSelectedElement("img");
|
||||
imageElement = gActiveEditor.getSelectedElement("img");
|
||||
|
||||
if (imageElement)
|
||||
{
|
||||
// Get the parent link if it exists -- more efficient than GetSelectedElement()
|
||||
anchorElement = editorShell.GetElementOrParentByTagName("href", imageElement);
|
||||
anchorElement = gActiveEditor.getElementOrParentByTagName("href", imageElement);
|
||||
if (anchorElement)
|
||||
{
|
||||
if (anchorElement.childNodes.length > 1)
|
||||
|
@ -83,13 +84,12 @@ function Startup()
|
|||
{
|
||||
// Get an anchor element if caret or
|
||||
// entire selection is within the link.
|
||||
anchorElement = editorShell.GetSelectedElement(tagName);
|
||||
anchorElement = gActiveEditor.getSelectedElement(tagName);
|
||||
|
||||
if (anchorElement)
|
||||
{
|
||||
// Select the entire link
|
||||
editorShell.SelectElement(anchorElement);
|
||||
selection = editorShell.editorSelection;
|
||||
gActiveEditor.selectElement(anchorElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -100,9 +100,9 @@ function Startup()
|
|||
// link and making 2 links.
|
||||
// Note that this isn't a problem with images, handled above
|
||||
|
||||
anchorElement = editorShell.GetElementOrParentByTagName("href", selection.anchorNode);
|
||||
anchorElement = gActiveEditor.getElementOrParentByTagName("href", gActiveEditor.selection.anchorNode);
|
||||
if (!anchorElement)
|
||||
anchorElement = editorShell.GetElementOrParentByTagName("href", selection.focusNode);
|
||||
anchorElement = gActiveEditor.getElementOrParentByTagName("href", gActiveEditor.selection.focusNode);
|
||||
|
||||
if (anchorElement)
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ function Startup()
|
|||
if(!anchorElement)
|
||||
{
|
||||
// No existing link -- create a new one
|
||||
anchorElement = editorShell.CreateElementWithDefaults(tagName);
|
||||
anchorElement = gActiveEditor.createElementWithDefaults(tagName);
|
||||
insertNew = true;
|
||||
// Hide message about removing existing link
|
||||
//document.getElementById("RemoveLinkMsg").setAttribute("hidden","true");
|
||||
|
@ -131,7 +131,7 @@ function Startup()
|
|||
}
|
||||
|
||||
// We insert at caret only when nothing is selected
|
||||
insertLinkAtCaret = selection.isCollapsed;
|
||||
insertLinkAtCaret = gActiveEditor.selection.isCollapsed;
|
||||
|
||||
var selectedText;
|
||||
if (insertLinkAtCaret)
|
||||
|
@ -251,7 +251,6 @@ function doEnabling()
|
|||
function ChangeLinkLocation()
|
||||
{
|
||||
SetRelativeCheckbox();
|
||||
|
||||
// Set OK button enable state
|
||||
doEnabling();
|
||||
}
|
||||
|
@ -307,21 +306,21 @@ function onAccept()
|
|||
if (href.length > 0)
|
||||
{
|
||||
// Copy attributes to element we are changing or inserting
|
||||
editorShell.CloneAttributes(anchorElement, globalElement);
|
||||
gActiveEditor.cloneAttributes(anchorElement, globalElement);
|
||||
|
||||
// Coalesce into one undo transaction
|
||||
editorShell.BeginBatchChanges();
|
||||
gActiveEditor.beginTransaction();
|
||||
|
||||
// Get text to use for a new link
|
||||
if (insertLinkAtCaret)
|
||||
{
|
||||
// Append the link text as the last child node
|
||||
// of the anchor node
|
||||
var textNode = editorShell.editorDocument.createTextNode(newLinkText);
|
||||
var textNode = gActiveEditor.document.createTextNode(newLinkText);
|
||||
if (textNode)
|
||||
anchorElement.appendChild(textNode);
|
||||
try {
|
||||
editorShell.InsertElementAtSelection(anchorElement, false);
|
||||
gActiveEditor.insertElementAtSelection(anchorElement, false);
|
||||
} catch (e) {
|
||||
dump("Exception occured in InsertElementAtSelection\n");
|
||||
return true;
|
||||
|
@ -332,33 +331,33 @@ function onAccept()
|
|||
// so insert a link node as parent of this
|
||||
// (may be text, image, or other inline content)
|
||||
try {
|
||||
editorShell.InsertLinkAroundSelection(anchorElement);
|
||||
gActiveEditor.insertLinkAroundSelection(anchorElement);
|
||||
} catch (e) {
|
||||
dump("Exception occured in InsertElementAtSelection\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Check if the link was to a heading
|
||||
if (href[0] == "#")
|
||||
if (href in gHNodeArray)
|
||||
{
|
||||
var index = gDialog.hrefInput.selectedIndex;
|
||||
if (index in gHNodeArray && gHNodeArray[index])
|
||||
{
|
||||
var anchorNode = editorShell.editorDocument.createElement("a");
|
||||
var anchorNode = gActiveEditor.createElementWithDefaults("a");
|
||||
if (anchorNode)
|
||||
{
|
||||
anchorNode.name = href.substr(1);
|
||||
// Remember to use editorShell method so it is undoable!
|
||||
editorShell.InsertElement(anchorNode, gHNodeArray[index], 0, false);
|
||||
|
||||
// Insert the anchor into the document,
|
||||
// but don't let the transaction change the selection
|
||||
gActiveEditor.setShouldTxnSetSelection(false);
|
||||
gActiveEditor.insertNode(anchorNode, gHNodeArray[href], 0);
|
||||
gActiveEditor.setShouldTxnSetSelection(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
editorShell.EndBatchChanges();
|
||||
gActiveEditor.endTransaction();
|
||||
}
|
||||
else if (!insertNew)
|
||||
{
|
||||
// We already had a link, but empty HREF means remove it
|
||||
editorShell.RemoveTextProperty("a", "");
|
||||
EditorRemoveTextProperty("href", "");
|
||||
}
|
||||
SaveWindowLocation();
|
||||
return true;
|
||||
|
|
|
@ -39,10 +39,16 @@ const gHundredsArray = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "C
|
|||
const gThousandsArray = ["", "M", "MM", "MMM", "MMMM", "MMMMM", "MMMMMM", "MMMMMMM", "MMMMMMMM", "MMMMMMMMM"];
|
||||
const gRomanDigits = {I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000};
|
||||
const A = "A".charCodeAt(0);
|
||||
const g_I = "I";
|
||||
const g_i = "i";
|
||||
const g_A = "A";
|
||||
const g_a = "a";
|
||||
const gArabic = "1";
|
||||
const gUpperRoman = "I";
|
||||
const gLowerRoman = "i";
|
||||
const gUpperLetters = "A";
|
||||
const gLowerLetters = "a";
|
||||
const gDecimalCSS = "decimal";
|
||||
const gUpperRomanCSS = "upper-roman";
|
||||
const gLowerRomanCSS = "lower-roman";
|
||||
const gUpperAlphaCSS = "upper-alpha";
|
||||
const gLowerAlphaCSS = "lower-alpha";
|
||||
|
||||
// dialog initialization code
|
||||
function Startup()
|
||||
|
@ -127,22 +133,23 @@ function InitDialog()
|
|||
}
|
||||
else if (gListType == "ol")
|
||||
{
|
||||
// Translate CSS property strings
|
||||
switch (type.toLowerCase())
|
||||
{
|
||||
case "decimal":
|
||||
type = "1";
|
||||
case gDecimalCSS:
|
||||
type = gArabic;
|
||||
break;
|
||||
case "upper-roman":
|
||||
type = g_I;
|
||||
case gUpperRomanCSS:
|
||||
type = gUpperRoman;
|
||||
break;
|
||||
case "lower-roman":
|
||||
type = g_i;
|
||||
case gLowerRomanCSS:
|
||||
type = gLowerRoman;
|
||||
break;
|
||||
case "upper-alpha":
|
||||
type = g_A;
|
||||
case gUpperAlphaCSS:
|
||||
type = gUpperLetters;
|
||||
break;
|
||||
case "lower-alpha":
|
||||
type = g_a;
|
||||
case gLowerAlphaCSS:
|
||||
type = gLowerLetters;
|
||||
break;
|
||||
}
|
||||
if (type)
|
||||
|
@ -163,16 +170,16 @@ function ConvertStartAttrToUserString(startAttr, type)
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case g_I:
|
||||
case gUpperRoman:
|
||||
startAttr = ConvertArabicToRoman(startAttr);
|
||||
break;
|
||||
case g_i:
|
||||
case gLowerRoman:
|
||||
startAttr = ConvertArabicToRoman(startAttr).toLowerCase();
|
||||
break;
|
||||
case g_A:
|
||||
case gUpperLetters:
|
||||
startAttr = ConvertArabicToLetters(startAttr);
|
||||
break;
|
||||
case g_a:
|
||||
case gLowerLetters:
|
||||
startAttr = ConvertArabicToLetters(startAttr).toLowerCase();
|
||||
break;
|
||||
}
|
||||
|
@ -209,11 +216,11 @@ function BuildBulletStyleList()
|
|||
label = GetString("NumberStyle");
|
||||
|
||||
gDialog.BulletStyleList.appendItem(GetString("Automatic"), "");
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_1"), "1");
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_I"), g_I);
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_i"), g_i);
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_A"), g_A);
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_a"), g_a);
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_1"), gArabic);
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_I"), gUpperRoman);
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_i"), gLowerRoman);
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_A"), gUpperLetters);
|
||||
gDialog.BulletStyleList.appendItem(GetString("Style_a"), gLowerLetters);
|
||||
|
||||
gDialog.BulletStyleList.value = gNumberStyleType;
|
||||
}
|
||||
|
@ -287,12 +294,15 @@ function ValidateData()
|
|||
|
||||
if (globalElement)
|
||||
{
|
||||
var editor = GetCurrentEditor();
|
||||
if (gListType == "ul")
|
||||
{
|
||||
if (gBulletStyleType && gDialog.ChangeAllRadio.selected)
|
||||
globalElement.setAttribute("type", gBulletStyleType);
|
||||
else
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "type", true);
|
||||
try {
|
||||
editor.removeAttributeOrEquivalent(globalElement, "type", true);
|
||||
} catch (e) {}
|
||||
|
||||
}
|
||||
else if (gListType == "ol")
|
||||
|
@ -300,7 +310,9 @@ function ValidateData()
|
|||
if (gBulletStyleType)
|
||||
globalElement.setAttribute("type", gBulletStyleType);
|
||||
else
|
||||
gEditor.removeAttributeOrEquivalent(globalElement, "type", true);
|
||||
try {
|
||||
editor.removeAttributeOrEquivalent(globalElement, "type", true);
|
||||
} catch (e) {}
|
||||
|
||||
var startingNumber = ConvertUserStringToStartAttr(gBulletStyleType);
|
||||
if (startingNumber)
|
||||
|
@ -318,14 +330,14 @@ function ConvertUserStringToStartAttr(type)
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case g_I:
|
||||
case g_i:
|
||||
case gUpperRoman:
|
||||
case gLowerRoman:
|
||||
// If the input isn't an integer, assume it's a roman numeral. Convert it.
|
||||
if (!Number(startingNumber))
|
||||
startingNumber = ConvertRomanToArabic(startingNumber);
|
||||
break;
|
||||
case g_A:
|
||||
case g_a:
|
||||
case gUpperLetters:
|
||||
case gLowerLetters:
|
||||
// Get the number equivalent of the letters
|
||||
if (!Number(startingNumber))
|
||||
startingNumber = ConvertLettersToArabic(startingNumber);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -41,8 +41,12 @@ var textareaElement;
|
|||
|
||||
function Startup()
|
||||
{
|
||||
if (!InitEditorShell())
|
||||
var editor = GetCurrentEditor();
|
||||
if (!editor)
|
||||
{
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
gDialog = {
|
||||
accept: document.documentElement.getButton("accept"),
|
||||
|
@ -61,7 +65,7 @@ function Startup()
|
|||
|
||||
// Get a single selected text area element
|
||||
var tagName = "textarea";
|
||||
textareaElement = editorShell.GetSelectedElement(tagName);
|
||||
textareaElement = editor.getSelectedElement(tagName);
|
||||
|
||||
if (textareaElement) {
|
||||
// We found an element and don't need to insert one
|
||||
|
@ -76,7 +80,7 @@ function Startup()
|
|||
// We don't have an element selected,
|
||||
// so create one with default attributes
|
||||
|
||||
textareaElement = editorShell.CreateElementWithDefaults(tagName);
|
||||
textareaElement = editor.createElementWithDefaults(tagName);
|
||||
if (!textareaElement)
|
||||
{
|
||||
dump("Failed to get selected element or create a new one!\n");
|
||||
|
@ -156,28 +160,30 @@ function onAccept()
|
|||
// element created to insert
|
||||
ValidateData();
|
||||
|
||||
editorShell.BeginBatchChanges();
|
||||
var editor = GetCurrentEditor();
|
||||
|
||||
editor.beginTransaction();
|
||||
|
||||
try {
|
||||
// undoably set value
|
||||
var initialText = gDialog.textareaValue.value;
|
||||
if (initialText != textareaElement.value) {
|
||||
while (textareaElement.hasChildNodes())
|
||||
editorShell.editor.deleteNode(textareaElement.firstChild);
|
||||
editor.deleteNode(textareaElement.lastChild);
|
||||
if (initialText) {
|
||||
var textNode = editorShell.editorDocument.createTextNode(initialText);
|
||||
editorShell.editor.insertNode(textNode, textareaElement, 0);
|
||||
var textNode = editor.document.createTextNode(initialText);
|
||||
editor.insertNode(textNode, textareaElement, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (insertNew)
|
||||
editorShell.InsertElementAtSelection(textareaElement, true);
|
||||
editor.insertElementAtSelection(textareaElement, true);
|
||||
else
|
||||
editorShell.SelectElement(textareaElement);
|
||||
editor.selectElement(textareaElement);
|
||||
|
||||
editorShell.CloneAttributes(textareaElement, globalElement);
|
||||
editor.cloneAttributes(textareaElement, globalElement);
|
||||
} finally {
|
||||
editorShell.EndBatchChanges();
|
||||
editor.endTransaction();
|
||||
}
|
||||
|
||||
SaveWindowLocation();
|
||||
|
|
Загрузка…
Ссылка в новой задаче