1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
var INFO =
<plugin name="Statusline Toolbar" version="0.1"
href="http://github.com/vimpr/vimperator-plugins/raw/master/statusline-toolbar.js"
summary="Append Toolbar to Statusline"
xmlns="http://vimperator.org/namespaces/liberator">
<author email="teramako@gmail.com">teramako</author>
<license>MPL 1.1/GPL 2.0/LGPL 2.1</license>
<project name="Vimperator" minVersion="3.0"/>
<description>
<ul>
<li>Add toolbar to status-line</li>
<li>Move the status-bar to the toolbar.</li>
<li>Make the toolbarbuttons in the toolbar palette configurable
<ul>
<li>Can customize by command (ex. <ex>:set statuslinetoolbars=feed-button</ex>)</li>
<li>Also, can drop the toolbarbutton from Customize Toolbar window</li>
</ul>
</li>
</ul>
</description>
<item>
<tags>'slt' 'statuslinetoolbars'</tags>
<spec>'statuslinetoolbars' 'slt'</spec>
<type>stringlist</type>
<default></default>
<description>
<p>
Add/Remove toolbarbutton of the toolbar palette.
</p>
</description>
</item>
</plugin>
var updater = {
"star-button": [
null,
function rm(elm) {
$("urlbar-icons").insertBefore(elm, $("go-button"));
}
],
};
var css = <css><![CDATA[
#liberator-customize-toolbar {
border: none !important;
min-width: 5px !important;
max-height: 17px;
}
#liberator-customize-toolbar > :-moz-any(image, toolbarbutton) { max-height: 16px; }
#liberator-customize-toolbar .statusbar-resizerpanel { display: none; }
#liberator-customize-toolbar toolbarbutton { padding: 0 !important; }
#status-bar { background-color: transparent !important; }
]]></css>.toString() +
({
WINNT: <css></css>,
Linux: <css></css>,
Darwin: <css><![CDATA[
#liberator-customize-toolbar toolbarbutton {
background: transparent !important;
border: none !important;
margin: 0 !important;
padding: 0 !important;
}
]]></css>
})[Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS].toString();
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;
}
function customizeDone () {
window.BrowserToolboxCustomizeDone(true);
}
var gToolbox = gNavToolbox;
var id = "liberator-customize-toolbar";
if (!$(id)) {
init();
}
function init () {
styles.addSheet(true, "customize-toolbar", "chrome://*", css, 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(["statuslinetoolbars", "slt"], "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 = $(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 (gToolbox.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");
customizeDone();
return val;
},
completer: function (context) {
context.completions = [["none","-"]].concat(Array.map(gToolbox.palette.children, function(elm) {
return [ elm.id, elm.getAttribute("label") || "-" ];
}));
},
validator: function (ids) {
return ids.every(function(id) {
return ($(id) || gToolbox.palette.querySelector("#" + id));
});
},
});
customizeDone();
}
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 = $(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);
}
return toolbar;
}
// vim: sw=2 ts=2 et:
|