mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-24 08:07:30 +09:00
palemoon#975: Customizable toolbars - backward compatible (but unidirectional)
This commit is contained in:
parent
f1f2d4d77e
commit
7da20021ff
2 changed files with 41 additions and 11 deletions
|
|
@ -180,8 +180,8 @@ function persistCurrentSets()
|
||||||
// Persist custom toolbar info on the <toolbarset/>
|
// Persist custom toolbar info on the <toolbarset/>
|
||||||
// Attributes:
|
// Attributes:
|
||||||
// Names: "toolbarX" (X - the number of the toolbar)
|
// Names: "toolbarX" (X - the number of the toolbar)
|
||||||
// Values: "Name:HidingAttributeName-HidingAttributeValue:CurrentSet"
|
// Values: "Name|HidingAttributeName-HidingAttributeValue|CurrentSet"
|
||||||
gToolbox.toolbarset.setAttribute("toolbar"+(++customCount),
|
gToolbox.toolbarset.setAttribute("toolbar" + (++customCount),
|
||||||
toolbar.toolbarName
|
toolbar.toolbarName
|
||||||
+ gToolbarInfoSeparators[0]
|
+ gToolbarInfoSeparators[0]
|
||||||
+ hidingAttribute
|
+ hidingAttribute
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
<field name="externalToolbars">
|
<field name="externalToolbars">
|
||||||
[]
|
[]
|
||||||
</field>
|
</field>
|
||||||
|
|
||||||
<!-- Set by customizeToolbar.js -->
|
<!-- Set by customizeToolbar.js -->
|
||||||
|
|
@ -50,22 +50,52 @@
|
||||||
<constructor>
|
<constructor>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
this.toolbarInfoSeparators = ["|", "-"];
|
this.toolbarInfoSeparators = ["|", "-"];
|
||||||
|
this.toolbarInfoLegacySeparator = ":";
|
||||||
// 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") {
|
||||||
this.toolbarset = toolbarset.nextSibling;
|
this.toolbarset = toolbarset.nextSibling;
|
||||||
|
}
|
||||||
|
|
||||||
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 (this.toolbarset.hasAttribute("toolbar" + (++index))) {
|
while (this.toolbarset.hasAttribute("toolbar" + (++index))) {
|
||||||
var toolbarInfo = this.toolbarset.getAttribute("toolbar"+index);
|
let hiddingAttribute =
|
||||||
var infoSplit = toolbarInfo.split(this.toolbarInfoSeparators[0]);
|
this.toolbarset.getAttribute("type") == "menubar"
|
||||||
var infoName = infoSplit[0];
|
? "autohide" : "collapsed";
|
||||||
var infoHidingAttribute = infoSplit[1].split(this.toolbarInfoSeparators[1]);
|
let toolbarInfo = this.toolbarset.getAttribute("toolbar" + index);
|
||||||
var infoCurrentSet = infoSplit[2];
|
let infoSplit = toolbarInfo.split(this.toolbarInfoSeparators[0]);
|
||||||
|
if (infoSplit.length == 1) {
|
||||||
this.appendCustomToolbar(infoName, infoCurrentSet, infoHidingAttribute);
|
infoSplit = toolbarInfo.split(this.toolbarInfoLegacySeparator);
|
||||||
|
}
|
||||||
|
let infoName = infoSplit[0];
|
||||||
|
let infoHidingAttribute = [null, null];
|
||||||
|
let infoCurrentSet = "";
|
||||||
|
let infoSplitLen = infoSplit.length;
|
||||||
|
switch (infoSplitLen) {
|
||||||
|
case 3:
|
||||||
|
// Pale Moon 27.2+
|
||||||
|
infoHidingAttribute = infoSplit[1]
|
||||||
|
.split(this.toolbarInfoSeparators[1]);
|
||||||
|
infoCurrentSet = infoSplit[2];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
// Legacy:
|
||||||
|
// - toolbars from Pale Moon 27.0 - 27.1.x
|
||||||
|
// - Basilisk
|
||||||
|
// The previous value (hiddingAttribute) isn't stored.
|
||||||
|
infoHidingAttribute = [hiddingAttribute, "false"];
|
||||||
|
infoCurrentSet = infoSplit[1];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Components.utils.reportError(
|
||||||
|
"Customizable toolbars - an invalid value:" + "\n"
|
||||||
|
+ '"toolbar' + index + '" = "' + toolbarInfo + '"');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.appendCustomToolbar(
|
||||||
|
infoName, infoCurrentSet, infoHidingAttribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]]>
|
]]>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue