1.1.1
by Sveinung Kvilhaugsvik
Import upstream version 0.7.6 |
1 |
var aios_xulUrl = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
2 |
//var aios_remMinWidth, aios_remDefWidth, aios_remMaxWidth;
|
|
3 |
||
4 |
||
5 |
/*
|
|
6 |
Liste der zur Verfügung stehenden Sidebars erstellen
|
|
7 |
=> Aufruf durch aios_initPane()
|
|
8 |
*/
|
|
9 |
function aios_genSidebarList() { |
|
10 |
||
11 |
if(!document.getElementById('sidebarInitPopup') || !document.getElementById('panelInitPopup')) return false; |
|
12 |
||
13 |
var strings = document.getElementById("aiosStrings"); |
|
14 |
//if(!confirm(strings.getString('prefs.confirm'))) return false;
|
|
15 |
||
16 |
var sidebarInit = document.getElementById('sidebarInitPopup'); |
|
17 |
var panelInit = document.getElementById('panelInitPopup'); |
|
18 |
var allSidebars = aios_WIN.document.getElementsByAttribute('group', 'sidebar'); |
|
19 |
||
20 |
var cnt = 0; |
|
21 |
var initID = null; |
|
22 |
var sidebarPrefInit = ""; |
|
23 |
var panelPrefInit = ""; |
|
24 |
try { |
|
25 |
sidebarPrefInit = aios_gPrefBranch.getCharPref("gen.init"); |
|
26 |
panelPrefInit = aios_gPrefBranch.getCharPref("gen.open.init"); |
|
27 |
} catch(e) { } |
|
28 |
||
29 |
for(var i = 0; i < allSidebars.length; i++) { |
|
30 |
var xulElem = null; |
|
31 |
||
32 |
// muß eine ID haben, darf keinen observer haben (Menüeinträge usw.) und muss eine Sidebar-URL haben
|
|
33 |
if(allSidebars[i].id && !allSidebars[i].getAttribute('observes') && allSidebars[i].getAttribute('sidebarurl')) { |
|
34 |
||
35 |
var separator = document.createElementNS(aios_xulUrl, "menuseparator"); |
|
36 |
if(cnt == 0) { |
|
37 |
sidebarInit.appendChild(separator); |
|
38 |
panelInit.appendChild(separator.cloneNode(true)); |
|
39 |
}
|
|
40 |
||
41 |
if(allSidebars[i].id != "extensionsEMbSidebar" && allSidebars[i].id != "themesEMbSidebar") { |
|
42 |
xulElem = document.createElementNS(aios_xulUrl, "menuitem"); |
|
43 |
xulElem.setAttribute('label', strings.getString('prefs.openpanel') + " " + allSidebars[i].getAttribute('label')); |
|
44 |
xulElem.setAttribute('value', allSidebars[i].id); |
|
45 |
||
46 |
if(allSidebars[i].getAttribute('tooltiptext')) |
|
47 |
xulElem.setAttribute('tooltiptext', allSidebars[i].getAttribute('tooltiptext')); |
|
48 |
||
49 |
sidebarInit.appendChild(xulElem); |
|
50 |
panelInit.appendChild(xulElem.cloneNode(true)); |
|
51 |
}
|
|
52 |
||
53 |
cnt++; |
|
54 |
}
|
|
55 |
}
|
|
56 |
||
57 |
sidebarInit.parentNode.value = sidebarPrefInit; |
|
58 |
panelInit.parentNode.value = panelPrefInit; |
|
59 |
return true; |
|
60 |
}
|
|
61 |
||
62 |
||
63 |
/*
|
|
64 |
Werte der aktuellen Sidebarbreite einsetzen
|
|
65 |
=> Aufruf durch oncommand() der drei <toolbarbutton>
|
|
66 |
*/
|
|
67 |
function aios_setWidthVal(mode) { |
|
68 |
var browserWidth = aios_getBrowserWidth(); |
|
69 |
var widthSidebar = browserWidth[0]; |
|
70 |
var widthContent = browserWidth[1] + browserWidth[2]; |
|
71 |
var compWidth = browserWidth[3]; |
|
72 |
||
73 |
var percent = parseInt(Math.round((widthSidebar * 100) / compWidth)); |
|
74 |
var theUnit = document.getElementById('obj-' + mode + 'WidthUnit').value; |
|
75 |
||
76 |
if(theUnit == "px") { |
|
77 |
document.getElementById('obj-' + mode + 'WidthVal').value = widthSidebar; |
|
78 |
document.getElementById(mode + 'WidthVal').value = widthSidebar; |
|
79 |
}
|
|
80 |
else if(theUnit == "%") { |
|
81 |
document.getElementById('obj-' + mode + 'WidthVal').value = percent; |
|
82 |
document.getElementById(mode + 'WidthVal').value = percent; |
|
83 |
}
|
|
84 |
}
|
|
85 |
||
86 |
||
87 |
/*
|
|
88 |
Breitenangaben bei Änderung der Maßeinheit umrechnen und ausgeben
|
|
89 |
=> Aufruf durch ValueChange-Listener, initiert in aios_initPrefs()
|
|
90 |
*/
|
|
91 |
function aios_changeWidthUnit(mode) { |
|
92 |
var elem = document.getElementById('obj-' + mode + 'WidthVal'); |
|
93 |
var theUnit = document.getElementById('obj-' + mode + 'WidthUnit').value; |
|
94 |
||
95 |
var browserWidth = aios_getBrowserWidth(); |
|
96 |
var compWidth = browserWidth[3]; |
|
97 |
||
98 |
if(theUnit == "px") elem.value = parseInt((parseInt(elem.value) * compWidth) / 100); |
|
99 |
else elem.value = parseInt((parseInt(elem.value) * 100) / compWidth); |
|
100 |
||
101 |
// Kontrolle
|
|
102 |
aios_checkWidthVal(mode); |
|
103 |
}
|
|
104 |
||
105 |
||
106 |
/*
|
|
107 |
Angaben zur Sidebarbreite prüfen
|
|
108 |
=> Aufruf durch onBlur() der drei Textfelder, aios_changeWidthUnit(), aios_setConfSidebarWidth()
|
|
109 |
*/
|
|
110 |
function aios_checkWidthVal(mode) { |
|
111 |
var elem = document.getElementById('obj-' + mode + 'WidthVal'); |
|
112 |
var theUnit = document.getElementById('obj-' + mode + 'WidthUnit').value; |
|
113 |
||
114 |
elem.value = parseInt(elem.value); |
|
115 |
||
116 |
// Kontrolle
|
|
117 |
if(mode == "max") { |
|
118 |
if(theUnit == "px" && elem.value < 100) elem.value = 100; |
|
119 |
else if(theUnit == "%" && elem.value < 10) elem.value = 10; |
|
120 |
}
|
|
121 |
}
|
|
122 |
||
123 |
||
124 |
/*
|
|
125 |
stellt die Größe der Sidebar ein
|
|
126 |
=> Aufruf durch aios_savePrefs() in prefs.js
|
|
127 |
*/
|
|
128 |
function aios_setConfSidebarWidth() { |
|
129 |
var elem, theUnit, theValue; |
|
130 |
var widthStyle = ""; |
|
131 |
var modes = new Array('min', 'def', 'max'); |
|
132 |
||
133 |
var browserWidth = aios_getBrowserWidth(); |
|
134 |
var compWidth = browserWidth[3]; |
|
135 |
||
136 |
for(var i = 0; i < modes.length; i++) { |
|
137 |
elem = document.getElementById('obj-' + modes[i] + 'WidthVal'); |
|
138 |
theUnit = document.getElementById('obj-' + modes[i] + 'WidthUnit').value; |
|
139 |
||
140 |
// Kontrolle
|
|
141 |
aios_checkWidthVal(modes[i]); |
|
142 |
||
143 |
theValue = elem.value; |
|
144 |
||
145 |
// Prozente in Px umrechnen (Angaben in % funktionieren hier nicht??)
|
|
146 |
if(theUnit == "%") theValue = parseInt((compWidth * theValue) / 100); |
|
147 |
||
148 |
switch(modes[i]) { |
|
149 |
case "min": widthStyle+= 'min-width: ' + theValue + 'px !important; '; break; |
|
150 |
case "def": widthStyle+= 'width: ' + theValue + 'px !important; '; break; |
|
151 |
case "max": widthStyle+= 'max-width: ' + theValue + 'px !important; '; break; |
|
152 |
}
|
|
153 |
}
|
|
154 |
||
155 |
aios_WIN.document.getElementById('sidebar').setAttribute('style', widthStyle); |
|
156 |
aios_WIN.document.persist('sidebar', 'style'); |
|
157 |
}
|
|
158 |