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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
const EXPORTED_SYMBOLS = ["S4EToolbars"];
const CI = Components.interfaces;
const CU = Components.utils;
CU.import("resource://gre/modules/Services.jsm");
function S4EToolbars(window, gBrowser, toolbox, service, getters)
{
this._window = window;
this._toolbox = toolbox;
this._service = service;
this._getters = getters;
this._handler = new ClassicS4EToolbars(this._window, this._toolbox);
}
S4EToolbars.prototype =
{
_window: null,
_toolbox: null,
_service: null,
_getters: null,
_handler: null,
setup: function()
{
this.updateSplitters(false);
this.updateWindowGripper(false);
this._handler.setup(this._service.firstRun);
},
destroy: function()
{
this._handler.destroy();
["_window", "_toolbox", "_service", "_getters", "_handler"].forEach(function(prop)
{
delete this[prop];
}, this);
},
updateSplitters: function(action)
{
let document = this._window.document;
let splitter_before = document.getElementById("status4evar-status-splitter-before");
if(splitter_before)
{
splitter_before.parentNode.removeChild(splitter_before);
}
let splitter_after = document.getElementById("status4evar-status-splitter-after");
if(splitter_after)
{
splitter_after.parentNode.removeChild(splitter_after);
}
let status = this._getters.statusWidget;
if(!action || !status)
{
return;
}
let urlbar = document.getElementById("urlbar-container");
let stop = document.getElementById("stop-button");
let fullscreenflex = document.getElementById("fullscreenflex");
let nextSibling = status.nextSibling;
let previousSibling = status.previousSibling;
function getSplitter(splitter, suffix)
{
if(!splitter)
{
splitter = document.createElement("splitter");
splitter.id = "status4evar-status-splitter-" + suffix;
splitter.setAttribute("resizebefore", "flex");
splitter.setAttribute("resizeafter", "flex");
splitter.className = "chromeclass-toolbar-additional status4evar-status-splitter";
}
return splitter;
}
if((previousSibling && previousSibling.flex > 0)
|| (urlbar && stop && urlbar.getAttribute("combined") && stop == previousSibling))
{
status.parentNode.insertBefore(getSplitter(splitter_before, "before"), status);
}
if(nextSibling && nextSibling.flex > 0 && nextSibling != fullscreenflex)
{
status.parentNode.insertBefore(getSplitter(splitter_after, "after"), nextSibling);
}
},
updateWindowGripper: function(action)
{
let document = this._window.document;
let gripper = document.getElementById("status4evar-window-gripper");
let toolbar = this._getters.statusBar || this._getters.addonbar;
if(!action || !toolbar || !this._service.addonbarWindowGripper
|| this._window.windowState != CI.nsIDOMChromeWindow.STATE_NORMAL || toolbar.toolbox.customizing)
{
if(gripper)
{
gripper.parentNode.removeChild(gripper);
}
return;
}
gripper = this._handler.buildGripper(toolbar, gripper, "status4evar-window-gripper");
toolbar.appendChild(gripper);
}
};
function ClassicS4EToolbars(window, toolbox)
{
this._window = window;
this._toolbox = toolbox;
}
ClassicS4EToolbars.prototype =
{
_window: null,
_toolbox: null,
setup: function(firstRun)
{
let document = this._window.document;
let addon_bar = document.getElementById("addon-bar");
if(addon_bar)
{
let baseSet = "addonbar-closebutton"
+ ",status4evar-status-widget"
+ ",status4evar-progress-widget";
// Update the defaultSet
let defaultSet = baseSet;
let defaultSetIgnore = ["addonbar-closebutton", "spring", "status-bar"];
addon_bar.getAttribute("defaultset").split(",").forEach(function(item)
{
if(defaultSetIgnore.indexOf(item) == -1)
{
defaultSet += "," + item;
}
});
defaultSet += ",status-bar"
addon_bar.setAttribute("defaultset", defaultSet);
// Update the currentSet
if(firstRun)
{
let isCustomizableToolbar = function(aElt)
{
return aElt.localName == "toolbar" && aElt.getAttribute("customizable") == "true";
}
let isCustomizedAlready = false;
let toolbars = Array.filter(this._toolbox.childNodes, isCustomizableToolbar).concat(
Array.filter(this._toolbox.externalToolbars, isCustomizableToolbar));
toolbars.forEach(function(toolbar)
{
if(toolbar.currentSet.indexOf("status4evar") > -1)
{
isCustomizedAlready = true;
}
});
if(!isCustomizedAlready)
{
let currentSet = baseSet;
let currentSetIgnore = ["addonbar-closebutton", "spring"];
addon_bar.currentSet.split(",").forEach(function(item)
{
if(currentSetIgnore.indexOf(item) == -1)
{
currentSet += "," + item;
}
});
addon_bar.currentSet = currentSet;
addon_bar.setAttribute("currentset", currentSet);
document.persist(addon_bar.id, "currentset");
this._window.setToolbarVisibility(addon_bar, true);
}
}
}
},
destroy: function()
{
["_window", "_toolbox"].forEach(function(prop)
{
delete this[prop];
}, this);
},
buildGripper: function(toolbar, gripper, id)
{
if(!gripper)
{
let document = this._window.document;
gripper = document.createElement("resizer");
gripper.id = id;
gripper.dir = "bottomend";
}
return gripper;
}
};
|