var INFO = teramako MPL 1.1/GPL 2.0/LGPL 2.1
  • Add toolbar to status-line
  • Move the status-bar to the toolbar.
  • Make the toolbarbuttons in the toolbar palette configurable
    • Can customize by command (ex. :set statustoolbars=feed-button)
    • Also, can drop the toolbarbutton from Customize Toolbar window
'statustoolbars' 'statustoolbars' stringlist

Add/Remove toolbarbutton of the toolbar palette.

var updater = { "noscript-tbb": [ function add(id) { noscriptOverlay.initPopups(); }, ], "star-button": [ null, function rm(elm) { $("urlbar-icons").insertBefore(elm, $("go-button")); } ], }; function $(id) document.getElementById(id); function createElement (name, attrs) { var elm = document.createElement("toolbar"); for (let [name, value] in Iterator(attrs)) { elm.setAttribute(name, value); } return elm; } var id = "liberator-customize-toolbar"; if (!$(id)) { init(); } function init () { styles.addSheet(true, "customize-toolbar", "chrome://*", :-moz-any(image, toolbarbutton) { max-height: 16px; } #liberator-customize-toolbar .statusbar-resizerpanel { display: none; } ]]>.toString(), false); var t = createToolbar(); t.appendChild($("status-bar")); $("liberator-bottombar").appendChild(t); updateSets(t, t.currentSet.split(","), []); config.toolbars.statuslinetoolbar = [[id], "Statusline Toolbar"]; options.add(["statustoolbars"], "Statusline Toolbar Sets", "stringlist", "", { toolbar: t, getter: function () { return this.toolbar.currentSet.split(",").filter(function(id) id != "status-bar").join(",") || "none"; }, setter: function (val) { if (val == "none") val = ""; let newSets = [], removeSets = this.toolbar.currentSet.split(",").filter(function(id) id != "status-bar"), index; for (let [, id] in Iterator(this.parseValues(val))) { let i = removeSets.indexOf(id); if (i != -1) { newSets.push(id); removeSets.splice(i, 1); continue; } let elm = document.getElementById(id); if (elm) { if (elm.parentNode !== t) { t.appendChild(elm); if (updater[id] && typeof updater[id][0] == "function") updater[id][0](elm); } newSets.push(id); } else if (gNavToolbox.palette.querySelector("#" + id)) { newSets.push(id); } } t.currentSet = newSets.join(","); t.setAttribute("currentset", newSets.join(",")); updateSets(this.toolbar, newSets, removeSets); document.persist(this.toolbar.id, "currentset"); return val; }, completer: function (context) { context.completions = [["none","-"]].concat(Array.map(gNavToolbox.palette.children, function(elm) { return [ elm.id, elm.getAttribute("label") || "-" ]; })); }, validator: function (val) { return true; }, }); } function updateSets (toolbar, newSets, removeSets) { for (let [, id] in Iterator(newSets)) { if (updater[id] && typeof updater[id][0] == "function") { updater[id][0](id); } } for (let [, id] in Iterator(removeSets)) { let elm = document.getElementById(id); if (!elm) continue; toolbar.removeChild(elm); if (updater[id] && typeof updater[id][1] == "function") { updater[id][1](elm); } } } function createToolbar () { var toolbar = createElement("toolbar", { id: id, toolbarname: "Liberator Statusline Toolbar", toolboxid: "navigator-toolbox", mode: "icons", iconsize: "small", defaulticonsize: "small", lockiconsize: "small", customizable: "true", context: "toolbar-context-menu", }); toolbar.setAttributeNS(NS.uri, "highlight", "ModeMsg"); var RDF = services.get("rdf"); var localStore = RDF.GetDataSource("rdf:local-store"); var currentSet = localStore.GetTarget( RDF.GetResource(document.baseURI + "#" + toolbar.id), RDF.GetResource("currentset"), true); if (currentSet) { currentSet = currentSet.QueryInterface(Ci.nsIRDFLiteral).Value; toolbar.setAttribute("currentset", currentSet); toolbar.appendChild(document.getElementById("star-button")); } return toolbar; } // vim: sw=2 ts=2 et: