mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-21 06:37:30 +09:00
palemoon#903: Customizable toolbars - persist the attribute "collapsed"
https://github.com/MoonchildProductions/Pale-Moon/pull/903
This commit is contained in:
parent
71ad12a654
commit
f1f2d4d77e
3 changed files with 35 additions and 6 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
const gToolbarInfoSeparators = ["|", "-"];
|
||||||
|
|
||||||
var gToolboxDocument = null;
|
var gToolboxDocument = null;
|
||||||
var gToolbox = null;
|
var gToolbox = null;
|
||||||
var gCurrentDragOverItem = null;
|
var gCurrentDragOverItem = null;
|
||||||
|
|
@ -173,9 +175,20 @@ function persistCurrentSets()
|
||||||
// Remove custom toolbars whose contents have been removed.
|
// Remove custom toolbars whose contents have been removed.
|
||||||
gToolbox.removeChild(toolbar);
|
gToolbox.removeChild(toolbar);
|
||||||
} else if (gToolbox.toolbarset) {
|
} else if (gToolbox.toolbarset) {
|
||||||
|
var hidingAttribute = toolbar.getAttribute("type") == "menubar" ?
|
||||||
|
"autohide" : "collapsed";
|
||||||
// Persist custom toolbar info on the <toolbarset/>
|
// Persist custom toolbar info on the <toolbarset/>
|
||||||
|
// Attributes:
|
||||||
|
// Names: "toolbarX" (X - the number of the toolbar)
|
||||||
|
// Values: "Name:HidingAttributeName-HidingAttributeValue:CurrentSet"
|
||||||
gToolbox.toolbarset.setAttribute("toolbar"+(++customCount),
|
gToolbox.toolbarset.setAttribute("toolbar"+(++customCount),
|
||||||
toolbar.toolbarName + ":" + currentSet);
|
toolbar.toolbarName
|
||||||
|
+ gToolbarInfoSeparators[0]
|
||||||
|
+ hidingAttribute
|
||||||
|
+ gToolbarInfoSeparators[1]
|
||||||
|
+ toolbar.getAttribute(hidingAttribute)
|
||||||
|
+ gToolbarInfoSeparators[0]
|
||||||
|
+ currentSet);
|
||||||
gToolboxDocument.persist(gToolbox.toolbarset.id, "toolbar"+customCount);
|
gToolboxDocument.persist(gToolbox.toolbarset.id, "toolbar"+customCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -485,6 +498,11 @@ function addNewToolbar()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (name.value.includes(gToolbarInfoSeparators[0])) {
|
||||||
|
message = stringBundle.getFormattedString("enterToolbarIllegalChars", [name.value]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var dupeFound = false;
|
var dupeFound = false;
|
||||||
|
|
||||||
// Check for an existing toolbar with the same display name
|
// Check for an existing toolbar with the same display name
|
||||||
|
|
@ -506,7 +524,7 @@ function addNewToolbar()
|
||||||
message = stringBundle.getFormattedString("enterToolbarDup", [name.value]);
|
message = stringBundle.getFormattedString("enterToolbarDup", [name.value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
gToolbox.appendCustomToolbar(name.value, "");
|
gToolbox.appendCustomToolbar(name.value, "", [null, null]);
|
||||||
|
|
||||||
toolboxChanged();
|
toolboxChanged();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@
|
||||||
|
|
||||||
<constructor>
|
<constructor>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
this.toolbarInfoSeparators = ["|", "-"];
|
||||||
// Look to see if there is a toolbarset.
|
// Look to see if there is a toolbarset.
|
||||||
this.toolbarset = this.firstChild;
|
this.toolbarset = this.firstChild;
|
||||||
while (this.toolbarset && this.toolbarset.localName != "toolbarset")
|
while (this.toolbarset && this.toolbarset.localName != "toolbarset")
|
||||||
|
|
@ -57,10 +58,14 @@
|
||||||
if (this.toolbarset) {
|
if (this.toolbarset) {
|
||||||
// Create each toolbar described by the toolbarset.
|
// Create each toolbar described by the toolbarset.
|
||||||
var index = 0;
|
var index = 0;
|
||||||
while (toolbarset.hasAttribute("toolbar"+(++index))) {
|
while (this.toolbarset.hasAttribute("toolbar" + (++index))) {
|
||||||
var toolbarInfo = toolbarset.getAttribute("toolbar"+index);
|
var toolbarInfo = this.toolbarset.getAttribute("toolbar"+index);
|
||||||
var infoSplit = toolbarInfo.split(":");
|
var infoSplit = toolbarInfo.split(this.toolbarInfoSeparators[0]);
|
||||||
this.appendCustomToolbar(infoSplit[0], infoSplit[1]);
|
var infoName = infoSplit[0];
|
||||||
|
var infoHidingAttribute = infoSplit[1].split(this.toolbarInfoSeparators[1]);
|
||||||
|
var infoCurrentSet = infoSplit[2];
|
||||||
|
|
||||||
|
this.appendCustomToolbar(infoName, infoCurrentSet, infoHidingAttribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]]>
|
]]>
|
||||||
|
|
@ -69,6 +74,7 @@
|
||||||
<method name="appendCustomToolbar">
|
<method name="appendCustomToolbar">
|
||||||
<parameter name="aName"/>
|
<parameter name="aName"/>
|
||||||
<parameter name="aCurrentSet"/>
|
<parameter name="aCurrentSet"/>
|
||||||
|
<parameter name="aHidingAttribute"/>
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
if (!this.toolbarset)
|
if (!this.toolbarset)
|
||||||
|
|
@ -84,6 +90,10 @@
|
||||||
toolbar.setAttribute("iconsize", this.getAttribute("iconsize"));
|
toolbar.setAttribute("iconsize", this.getAttribute("iconsize"));
|
||||||
toolbar.setAttribute("context", this.toolbarset.getAttribute("context"));
|
toolbar.setAttribute("context", this.toolbarset.getAttribute("context"));
|
||||||
toolbar.setAttribute("class", "chromeclass-toolbar");
|
toolbar.setAttribute("class", "chromeclass-toolbar");
|
||||||
|
// Restore persist the hiding attribute.
|
||||||
|
if (aHidingAttribute[0]) {
|
||||||
|
toolbar.setAttribute(aHidingAttribute[0], aHidingAttribute[1]);
|
||||||
|
}
|
||||||
|
|
||||||
this.insertBefore(toolbar, this.toolbarset);
|
this.insertBefore(toolbar, this.toolbarset);
|
||||||
return toolbar;
|
return toolbar;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
enterToolbarTitle=New Toolbar
|
enterToolbarTitle=New Toolbar
|
||||||
enterToolbarName=Enter a name for this toolbar:
|
enterToolbarName=Enter a name for this toolbar:
|
||||||
enterToolbarDup=There is already a toolbar with the name “%S”. Please enter a different name.
|
enterToolbarDup=There is already a toolbar with the name “%S”. Please enter a different name.
|
||||||
|
enterToolbarIllegalChars=The name contains illegal character "|". Please enter a different name.
|
||||||
enterToolbarBlank=You must enter a name to create a new toolbar.
|
enterToolbarBlank=You must enter a name to create a new toolbar.
|
||||||
separatorTitle=Separator
|
separatorTitle=Separator
|
||||||
springTitle=Flexible Space
|
springTitle=Flexible Space
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue