Bug 540838 Toolbar elements losing the command attribute r+a=gavin

This commit is contained in:
Neil Rashbrook 2010-08-05 13:33:00 +01:00
Родитель 0bfa166121
Коммит 070761ff0d
1 изменённых файлов: 24 добавлений и 15 удалений

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

@ -239,21 +239,7 @@ function unwrapToolbarItems()
var paletteItem;
while ((paletteItem = paletteItems.item(0)) != null) {
var toolbarItem = paletteItem.firstChild;
if (paletteItem.hasAttribute("itemdisabled"))
toolbarItem.disabled = true;
if (paletteItem.hasAttribute("itemchecked"))
toolbarItem.checked = true;
if (paletteItem.hasAttribute("itemcommand")) {
let commandID = paletteItem.getAttribute("itemcommand");
toolbarItem.setAttribute("command", commandID);
//XXX Bug 309953 - toolbarbuttons aren't in sync with their commands after customizing
toolbarItem.disabled = gToolboxDocument.getElementById(commandID).disabled;
}
restoreItemForToolbar(toolbarItem, paletteItem);
paletteItem.parentNode.replaceChild(toolbarItem, paletteItem);
}
}
@ -505,6 +491,28 @@ function cleanupItemForToolbar(aItem, aWrapper)
}
}
/**
* Restore all the properties that we stripped off above.
*/
function restoreItemForToolbar(aItem, aWrapper)
{
if (aWrapper.hasAttribute("itemdisabled"))
aItem.disabled = true;
if (aWrapper.hasAttribute("itemchecked"))
aItem.checked = true;
if (aWrapper.hasAttribute("itemcommand")) {
let commandID = aWrapper.getAttribute("itemcommand");
aItem.setAttribute("command", commandID);
//XXX Bug 309953 - toolbarbuttons aren't in sync with their commands after customizing
let command = gToolboxDocument.getElementById(commandID);
if (command && command.hasAttribute("disabled"))
aItem.setAttribute("disabled", command.getAttribute("disabled"));
}
}
function setWrapperType(aItem, aWrapper)
{
if (aItem.localName == "toolbarseparator") {
@ -904,6 +912,7 @@ function onPaletteDrop(aEvent)
if (wrapperType != "separator" &&
wrapperType != "spacer" &&
wrapperType != "spring") {
restoreItemForToolbar(wrapper.firstChild, wrapper);
appendPaletteItem(document.importNode(wrapper.firstChild, true));
gToolbox.palette.appendChild(wrapper.firstChild);
}