Bug 500665 - Should be able to lock the mode and icon size of a toolbar. r=neil

This commit is contained in:
Dão Gottwald 2009-09-16 16:14:37 +02:00
parent fa35f26204
commit 72ac7fb392
2 changed files with 30 additions and 47 deletions

View File

@ -642,13 +642,8 @@ function restoreDefaultSet()
}
// Restore the default icon size and mode.
var defaultMode = gToolbox.getAttribute("defaultmode");
var defaultIconsSmall = gToolbox.getAttribute("defaulticonsize") == "small";
updateIconSize(defaultIconsSmall, true);
document.getElementById("smallicons").checked = defaultIconsSmall;
updateToolbarMode(defaultMode, true);
document.getElementById("modelist").value = defaultMode;
document.getElementById("smallicons").checked = (updateIconSize() == "small");
document.getElementById("modelist").value = updateToolbarMode();
// Now rebuild the palette.
buildPalette();
@ -659,52 +654,40 @@ function restoreDefaultSet()
toolboxChanged("reset");
}
function updateIconSize(aUseSmallIcons, localDefault)
{
gToolboxIconSize = aUseSmallIcons ? "small" : "large";
setAttribute(gToolbox, "iconsize", gToolboxIconSize);
gToolboxDocument.persist(gToolbox.id, "iconsize");
for (var i = 0; i < gToolbox.childNodes.length; ++i) {
var toolbar = getToolbarAt(i);
if (isCustomizableToolbar(toolbar)) {
var toolbarIconSize = (localDefault && toolbar.hasAttribute("defaulticonsize")) ?
toolbar.getAttribute("defaulticonsize") :
gToolboxIconSize;
setAttribute(toolbar, "iconsize", toolbarIconSize);
gToolboxDocument.persist(toolbar.id, "iconsize");
}
}
function updateIconSize(aSize) {
return updateToolboxProperty("iconsize", aSize);
}
function updateToolbarMode(aModeValue, localDefault)
{
setAttribute(gToolbox, "mode", aModeValue);
gToolboxDocument.persist(gToolbox.id, "mode");
for (var i = 0; i < gToolbox.childNodes.length; ++i) {
var toolbar = getToolbarAt(i);
if (isCustomizableToolbar(toolbar)) {
var toolbarMode = (localDefault && toolbar.hasAttribute("defaultmode")) ?
toolbar.getAttribute("defaultmode") :
aModeValue;
setAttribute(toolbar, "mode", toolbarMode);
gToolboxDocument.persist(toolbar.id, "mode");
}
}
function updateToolbarMode(aModeValue) {
var mode = updateToolboxProperty("mode", aModeValue);
var iconSizeCheckbox = document.getElementById("smallicons");
iconSizeCheckbox.disabled = aModeValue == "text";
iconSizeCheckbox.disabled = mode == "text";
return mode;
}
function updateToolboxProperty(aProp, aValue) {
var toolboxDefault = gToolbox.getAttribute("default" + aProp);
function setAttribute(aElt, aAttr, aVal)
{
if (aVal)
aElt.setAttribute(aAttr, aVal);
else
aElt.removeAttribute(aAttr);
gToolbox.setAttribute(aProp, aValue || toolboxDefault);
gToolboxDocument.persist(gToolbox.id, aProp);
Array.forEach(gToolbox.childNodes, function (toolbar) {
if (!isCustomizableToolbar(toolbar))
return;
var toolbarDefault = toolbar.getAttribute("default" + aProp) ||
toolboxDefault;
if (toolbar.getAttribute("lock" + aProp) == "true" &&
toolbar.getAttribute(aProp) == toolbarDefault)
return;
toolbar.setAttribute(aProp, aValue || toolbarDefault);
gToolboxDocument.persist(toolbar.id, aProp);
});
return aValue;
}
function isCustomizableToolbar(aElt)

View File

@ -86,7 +86,7 @@
</menupopup>
</menulist>
<checkbox id="smallicons" oncommand="updateIconSize(this.checked);" label="&useSmallIcons.label;"/>
<checkbox id="smallicons" oncommand="updateIconSize(this.checked ? 'small' : 'large');" label="&useSmallIcons.label;"/>
<button label="&addNewToolbar.label;" oncommand="addNewToolbar();" icon="add"/>
<button label="&restoreDefaultSet.label;" oncommand="restoreDefaultSet();" icon="revert"/>