Bug 207221 Autocomplete URL in [Image/]Link Properties dialog r=brade sr=rbs

This commit is contained in:
neil%parkwaycc.co.uk 2003-09-11 09:10:22 +00:00
Родитель c5fb998558
Коммит db6f1d5abb
2 изменённых файлов: 21 добавлений и 7 удалений

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

@ -974,6 +974,7 @@ function RemoveContainer(element)
function FillLinkMenulist(linkMenulist, headingsArray) function FillLinkMenulist(linkMenulist, headingsArray)
{ {
var menupopup = linkMenulist.firstChild;
var editor = GetCurrentEditor(); var editor = GetCurrentEditor();
try { try {
var NamedAnchorNodeList = editor.document.anchors; var NamedAnchorNodeList = editor.document.anchors;
@ -981,7 +982,7 @@ function FillLinkMenulist(linkMenulist, headingsArray)
if (NamedAnchorCount > 0) if (NamedAnchorCount > 0)
{ {
for (var i = 0; i < NamedAnchorCount; i++) for (var i = 0; i < NamedAnchorCount; i++)
linkMenulist.appendItem("#" + NamedAnchorNodeList.item(i).name); createMenuItem(menupopup, "#" + NamedAnchorNodeList.item(i).name);
} }
for (var j = 1; j <= 6; j++) for (var j = 1; j <= 6; j++)
{ {
@ -1010,21 +1011,29 @@ function FillLinkMenulist(linkMenulist, headingsArray)
// Append "_" to any name already in the list // Append "_" to any name already in the list
while (linkMenulist.getElementsByAttribute("label", text).length) while (linkMenulist.getElementsByAttribute("label", text).length)
text += "_"; text += "_";
linkMenulist.appendItem(text); createMenuItem(menupopup, text);
// Save nodes in an array so we can create anchor node under it later // Save nodes in an array so we can create anchor node under it later
headingsArray[text] = heading; headingsArray[text] = heading;
} }
} }
} }
if (!linkMenulist.firstChild.hasChildNodes()) if (!menupopup.hasChildNodes())
{ {
var item = linkMenulist.appendItem(GetString("NoNamedAnchorsOrHeadings")); var item = createMenuItem(menupopup, GetString("NoNamedAnchorsOrHeadings"));
item.setAttribute("disabled", "true"); item.setAttribute("disabled", "true");
} }
} catch (e) {} } catch (e) {}
} }
function createMenuItem(aMenuPopup, aLabel)
{
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", aLabel);
aMenuPopup.appendChild(menuitem);
return menuitem;
}
// Shared by Image and Link dialogs for the "Choose" button for links // Shared by Image and Link dialogs for the "Choose" button for links
function chooseLinkFile() function chooseLinkFile()
{ {

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

@ -70,9 +70,14 @@
<vbox id="LinkLocationBox"> <vbox id="LinkLocationBox">
<label control="hrefInput" accesskey="&LinkURLEditField.accessKey;" width="1">&LinkURLEditField.label;</label> <label control="hrefInput" accesskey="&LinkURLEditField.accessKey;" width="1">&LinkURLEditField.label;</label>
<menulist editable="true" id="hrefInput" style="min-width: 30em" class="uri-element" oninput="ChangeLinkLocation();"> <textbox id="hrefInput" type="autocomplete"
<menupopup/> searchSessions="history" timeout="50" maxrows="6"
</menulist> disablehistory="false" class="uri-element"
oninput="ChangeLinkLocation();">
<menupopup class="autocomplete-history-popup"
popupalign="topleft" popupanchor="bottomleft"
oncommand="this.parentNode.value = event.target.getAttribute('label');"/>
</textbox>
<hbox align="center"> <hbox align="center">
<!-- from EdDialogOverlay.xul 'for' identifies the textfield to get URL from --> <!-- from EdDialogOverlay.xul 'for' identifies the textfield to get URL from -->
<checkbox id="MakeRelativeLink" <checkbox id="MakeRelativeLink"