2
var searchObj, clearObj;
3
var aios_checkElems = new Array( 'aios-enableAutoClose', 'aios-viewOpenClose', 'aios-viewClear', 'aios-EBS-toolbar-mitem' );
8
=> Aufruf durch onload in bm_hi.xul
10
function aios_initBmHi() {
12
aios_synchElements(aios_checkElems);
14
// Tools-Buttton anzeigen?
18
if(document.getElementById('bookmarksPanel')) enable_tools = aios_gPrefBranch.getBoolPref("bm.tools");
19
else enable_tools = aios_gPrefBranch.getBoolPref("hi.tools");
21
document.getElementById('viewButton').hidden = !enable_tools;
25
searchObj = document.getElementById("search-box");
26
clearObj = document.getElementById("clearSearch");
28
// Tooltip, focus- und blur-Funktionen hinzuf�gen
29
// => erst hier bei init(), weil es sonst Skript-Fehler geben w�rde
30
// => nicht aktivieren in Verbindung mit Bookmark Duplicate Detector
31
if(typeof Bookmarkdd != "object") {
32
searchObj.setAttribute('onfocus', 'aios_focusBlurText("focus");');
33
searchObj.setAttribute('onblur', 'aios_focusBlurText("blur");');
37
// => dem "Extras"-Men� den Separator und die drei Men�punkte hinzuf�gen
38
popUp = document.getElementById("viewButton").firstChild;
39
if(document.getElementById("bylastvisited")) {
40
popUp.appendChild(document.getElementById('openClose-separator'));
41
document.getElementById('openClose-separator').hidden = false;
43
popUp.appendChild(document.getElementById('aios-enableAutoClose'));
44
popUp.appendChild(document.getElementById('aios-rememberFolder'));
45
popUp.appendChild(document.getElementById('aios-scrollToFolder'));
47
popUp.appendChild(document.getElementById('openClose-separator').cloneNode(true));
49
popUp.appendChild(document.getElementById('aios-viewOpenClose'));
50
popUp.appendChild(document.getElementById('aios-viewClear'));
53
// falls der "Tools"-Button ein <button> ist (FF >= 1.5), diesen durch einen <toolbarbutton> ersetzen
54
if(document.getElementById("viewButton").localName == "button") {
55
var viewButton = document.getElementById("viewButton");
56
popUp = viewButton.firstChild.cloneNode(true);
57
var attr = viewButton.attributes;
59
// alten <button> entfernen
60
viewButton.parentNode.removeChild(viewButton);
62
var new_viewButton = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "toolbarbutton");
64
// alle Attribute des alten Buttons �bernehmen
65
for(var i = 0; i < attr.length; i++) {
66
new_viewButton.setAttribute(attr[i].name, attr[i].value);
69
// neuen <toolbarbutton> einf�gen
70
popUp.setAttribute('onpopupshowing', 'aios_checkOptions();');
71
new_viewButton.appendChild(popUp);
72
searchObj.parentNode.appendChild(new_viewButton);
75
// Fix f�r Enhanced Bookmarks Search (Elemente entfernen, wenn EBS nicht verf�gbar ist)
76
if(typeof ebsBMPanelInit != "function" && document.getElementById('viewPopUp')) {
77
document.getElementById('viewPopUp').removeChild(document.getElementById('aios-EBS-separator'));
78
document.getElementById('viewPopUp').removeChild(document.getElementById('aios-EBS-toolbar-mitem'));
79
document.getElementById('viewPopUp').removeChild(document.getElementById('aios-EBS-mitem'));
82
// Fix f�r Advanced Bookmarks Search (Elemente entfernen, wenn ABS nicht verf�gbar ist)
83
if(!document.getElementById('abs-button') && document.getElementById('viewPopUp')) {
84
document.getElementById('viewPopUp').removeChild(document.getElementById('aios-ABS-separator'));
85
document.getElementById('viewPopUp').removeChild(document.getElementById('aios-ABS-toolbar-mitem'));
86
document.getElementById('viewPopUp').removeChild(document.getElementById('aios-ABS-mitem'));
89
if(typeof ebsBMPanelInit == "function" && document.getElementById('abs-button') && document.getElementById('viewPopUp')) {
90
document.getElementById('viewPopUp').removeChild(document.getElementById('aios-ABS-separator'));
91
document.getElementById('viewPopUp').removeChild(document.getElementById('aios-ABS-toolbar-mitem'));
95
if(aios_appVendor == "Flock") {
96
document.getElementById('openCloseFolder').hidden = true;
97
document.getElementById('clearSearch').hidden = true;
98
document.getElementById('viewButton').hidden = true;
104
experimentelle Elemente aktivieren/deaktivieren
105
=> Aufruf durch onpopupshowing des Tools-Buttons
107
function aios_checkOptions() {
108
document.getElementById('aios-rememberFolder').setAttribute('disabled', !aios_getBoolean("aios-enableAutoClose", "checked"));
109
document.getElementById('aios-scrollToFolder').setAttribute('disabled', !aios_getBoolean("aios-enableAutoClose", "checked"));
114
Alle Ordner �ffnen (Linksklick) oder alle Ordner schlie�en (Rechtsklick)
115
=> Aufruf durch den Button #openCloseFolder in der bm_hi.xul
117
function aios_openCloseFolder(event) {
118
if(typeof event != "object") return;
120
if(event.button == 1 || event.button == 2) aios_acbtf.closeAll();
121
else aios_acbtf.openAll();
126
"Suchbegriff" im Suchfeld anzeigen oder verbergen
127
=> Aufruf durch onfocus() und onblur() des Suchfeldes
129
function aios_focusBlurText(mode) {
130
var strings = document.getElementById("propSetStrings");
131
var blurText = strings.getString('bm_hi.search.blur');
133
if(mode == "focus" && searchObj.value == blurText) {
134
searchObj.className = "";
135
searchObj.value = "";
136
clearObj.setAttribute('disabled', false);
138
else if(mode == "blur" && searchObj.value == "") {
139
searchObj.className = "blur";
140
searchObj.value = blurText;
141
clearObj.setAttribute('disabled', true);
147
Suche und Ansicht zur�cksetzen
148
=> Aufruf durch #clearSearch in bm_hi.xul und die Men�eintr�ge im "Extras"-Men�
150
function aios_clearSearch() {
151
searchObj.value = "";
154
// Ansicht aktualisieren
155
if(document.getElementById('bookmarks-view')) {
156
if(typeof searchBookmarks == "function") searchBookmarks(searchObj.value); // Fx 3
157
else document.getElementById('bookmarks-view').searchBookmarks(searchObj.value); // Fx <= 2
160
searchHistory(searchObj.value);
166
Autoclose Bookmark & History Folder by Ronny Perinke (mod by exxile, based on ac-btf_0_55_5.xpi)
173
//CloseSidebar: false, //mod by eXXile
175
SelectLastUsedFolder: true,
176
//ShowToolbar: true //mod by eXXile
180
return "extensions.aios.acbh."; //mod by eXXile
182
set prefRoot(aString){},
185
var prefsIFace = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPref);
186
var prefsIFace = prefsIFace.getBranch(this.prefRoot);
187
this.__defineGetter__("PrefsIFace", function() { return prefsIFace; });
190
/*get StringBundle()*/ //function deleted by eXXile
191
//#######################################
192
//######## /private functions and properties ########
194
//#######################################
197
implement EventListener Interface
198
only used for addEventListener()
200
handleEvent: function BMB_handleEvent(aEvent)
219
this._BTree = document.getElementById("bookmarks-view");
220
this._BTree.setAttribute("onclick", 'aios_acbtf.onClick(event, "bookmarks")'); //�ndert den standard onclick-event //mod by eXXile
224
//dump("ac-btf: could no get element \"bookmarks-view\"\nError Message:\n"+e+"\n");
229
this._HTree = document.getElementById("historyTree");
230
this._HTree.setAttribute("onclick", 'aios_acbtf.onClick(event, "history")'); //�ndert den standard onclick-event //mod by eXXile
234
//dump("ac-btf: could no get element \"historyTree\"\nError Message:\n"+e+"\n");
239
this.PrefObserver.register(this.prefRoot);
240
//this.showHideToolbar(); //mod by eXXile
241
//this.addSettingsButton(); //mod by eXXile
243
if (this._Prefs.SelectLastUsedFolder)
245
var tbo, lastRowToSelect;
246
if (this._BTree && this.PrefsIFace.prefHasUserValue("lastBookmarkFolder"))
248
lastRowToSelect = this.PrefsIFace.getIntPref("lastBookmarkFolder");
249
tbo = this._BTree.treeBoxObject;
250
setTimeout(this.selectFolder, 10, lastRowToSelect, tbo);
253
if (this._HTree && this.PrefsIFace.prefHasUserValue("lastHistoryFolder"))
255
lastRowToSelect = this.PrefsIFace.getIntPref("lastHistoryFolder");
256
tbo = this._HTree.treeBoxObject;
257
setTimeout(this.selectFolder, 10, lastRowToSelect, tbo);
263
this.PrefObserver.unregister();
264
/*this.removeSettingsButton();
266
if (this._Prefs.CloseSidebar)
268
var sb_box = window.top.document.getElementById("sidebar-box");
269
sb_box.setAttribute("sidebarcommand", "");
270
window.top.document.persist("sidebar-box", "sidebarcommand");
274
loadPrefs: function()
276
this.PrefsIFace = this.prefRoot; // reset PrefBranch to default value
278
//this._Prefs.CloseSidebar = this.PrefsIFace.getBoolPref("CloseSidebar"); //mod by eXXile
279
this._Prefs.SelectLastUsedFolder = aios_getBoolean("aios-rememberFolder", "checked"); //mod by eXXile
280
this._Prefs.ScrollToRow = aios_getBoolean("aios-scrollToFolder", "checked"); //mod by eXXile
281
//this._Prefs.ShowToolbar = this.PrefsIFace.getBoolPref("ShowToolbar"); //mod by eXXile
284
/*showHideToolbar: function()
285
addToolbar: function()
286
removeToolbar: function()
287
updateTBButtons: function(aEvent)
288
addSettingsButton: function()
289
removeSettingsButton: function()*/ //functions deleted by eXXile
291
selectFolder: function(index, tbo)
293
if (tbo.view.rowCount >= index)
295
tbo.view.selection.select(index);
296
if (tbo.view.rowCount > tbo.getPageLength()) // check if we really need to scroll
297
tbo.scrollToRow(index);
298
tbo.ensureRowIsVisible(index);
302
onClick: function(aEvent, sidebarType)
303
{ aios_acbtf.loadPrefs(); //mod by eXXile - falls die Einstellungen ge�ndert wurden, w�hrend die Sidebar offen ist
304
if (!aEvent || !sidebarType || (sidebarType != 'history' && sidebarType != 'bookmarks'))
309
// don't do anything if it was a right-click
310
if (aEvent.button == 2)
315
var dotoggle = (aEvent.button != 0)?false:true; //wenn es kein links-klick war, dann f�hre nur die standardaktion aus
317
const tree = (aios_acbtf._BTree)?aios_acbtf._BTree:aios_acbtf._HTree; //mod by eXXile
319
var tbo = tree.treeBoxObject;
321
//wenn man auf das + zeichen vor dem ordner klickt, dann soll er einfach nur aufgehen und die anderen nicht geschlossen werden
322
var row = {}, col = {}, obj = {};
323
tbo.getCellAt(aEvent.clientX, aEvent.clientY, row, col, obj);
324
if (row.value == -1 || obj.value == "twisty")
329
var mouseInGutter = false;
330
if (sidebarType == 'history')
332
var x = { }, y = { }, w = { }, h = { };
333
tbo.getCoordsForCellItem(row.value, col.value, "image", x, y, w, h);
334
mouseInGutter = aEvent.clientX < x.value;
337
var tboView = tbo.view
338
var modifKey = aEvent.shiftKey || aEvent.ctrlKey || aEvent.altKey || aEvent.metaKey || aEvent.button == 1;
340
if (dotoggle && tboView.isContainer(row) && !modifKey)
342
tboView.toggleOpenState(row); //�ffnet oder schliesst den ordner; Standardvorgang bei Ordnern
344
// mod by eXXile => nur die anderen schlie�en, wenn auch aktiviert
345
if(!aios_getBoolean("aios-enableAutoClose", "checked")) return;
347
//jetzt der teil, der die anderen offenen ordner schliesst
348
var parents = new Array();
349
//nun werden alle ober-ordner des aktuellen gesucht
353
row = tboView.getParentIndex(row);
355
parents.reverse(); //dreht reihenfolge im array um
357
for (var i = tboView.rowCount-1; i>=0; i--) //geht einfach jede zeile durch und testet ...
359
if (parents.length > 0 && parents[parents.length-1] == i)
360
{ //bei den ober-ordnern soll sich nix tun, sollen also offen bleiben
365
if (tboView.isContainer(i) && tboView.isContainerOpen(i))
367
//andere elemente, die ordner sind, sollen geschlossen werden
368
tboView.toggleOpenState(i);
373
if (aios_acbtf._Prefs.ScrollToRow && (tboView.rowCount > tbo.getPageLength())) //falls gescrollt werden soll, aber nur wenn das auch wirklich n�tig ist // mod by eXXile
375
tbo.scrollToRow(tree.currentIndex);
377
tbo.ensureRowIsVisible(tree.currentIndex); // scrollt zum index nur wenn n�tig.
379
if (aios_acbtf._Prefs.SelectLastUsedFolder) // mod by eXXile
384
aios_acbtf.PrefsIFace.setIntPref("lastBookmarkFolder", tree.currentIndex); // mod by eXXile
388
aios_acbtf.PrefsIFace.setIntPref("lastHistoryFolder", tree.currentIndex); // mod by eXXile
396
if (!mouseInGutter && aEvent.originalTarget.localName == "treechildren" && (aEvent.button == 0 || aEvent.button == 1))
398
// Clear all other selection since we're loading a link now. We must
399
// do this *before* attempting to load the link since openURL uses
400
// selection as an indication of which link to load.
401
tboView.selection.select(row);
402
if (typeof(PlacesUIUtils) == "object" && typeof(PlacesUIUtils.openNodeWithEvent) == "function")
404
PlacesUIUtils.openNodeWithEvent(tree.selectedNode, aEvent);
407
if (typeof(PlacesUtils) == "object" && typeof(PlacesUtils.openNodeWithEvent) == "function")
409
PlacesUtils.openNodeWithEvent(tree.selectedNode, aEvent);
412
if (tree.controller && typeof(tree.controller.openSelectedNodeWithEvent) == "function")
414
tree.controller.openSelectedNodeWithEvent(aEvent);
417
if (sidebarType == 'bookmarks' && typeof(tree.openItemClick) == "function")
419
tree.openItemClick(aEvent, 1);
422
if (sidebarType == 'history' && typeof(openURL) == "function")
433
if (aios_acbtf._BTree) // mod by eXXile
435
aView = aios_acbtf._BTree.treeBoxObject.view; // mod by eXXile
438
this.PrefsIFace.clearUserPref("lastBookmarkFolder");
444
if (aios_acbtf._HTree) // mod by eXXile
446
aView = aios_acbtf._HTree.treeBoxObject.view; // mod by eXXile
449
this.PrefsIFace.clearUserPref("lastHistoryFolder");
457
for (var i = aView.rowCount-1; i>=0; i--)
459
if (aView.isContainer(i) && aView.isContainerOpen(i))
461
aView.toggleOpenState(i);
468
var aView, viewbutton;
469
if (aios_acbtf._BTree) // mod by eXXile
471
aView = aios_acbtf._BTree.treeBoxObject.view; // mod by eXXile
474
this.PrefsIFace.clearUserPref("lastBookmarkFolder");
480
if (aios_acbtf._HTree) // mod by eXXile
482
aView = aios_acbtf._HTree.treeBoxObject.view; // mod by eXXile
483
viewbutton = document.getElementById("viewButton");
486
this.PrefsIFace.clearUserPref("lastHistoryFolder");
492
var doOnce = (viewbutton)?(viewbutton.getAttribute("selectedsort") == "day"):false;
497
var rows = aView.rowCount;
500
for (var i = rows-1; i>=0; i--)
502
if (aView.isContainer(i) && !aView.isContainerOpen(i))
504
aView.toggleOpenState(i);
509
rows = aView.rowCount;
511
while(rows != oldrows && !doOnce);
519
return Components.interfaces;
521
set Ci(){}, // make it kind of a constant ;-)
522
// http://kb.mozillazine.org/Dev_:_Using_preferences#Using_preferences_observers
525
register: function(aPrefRoot)
527
if (this._registered)
532
//dump("aios_acbtf.PrefObserver: adding observer ...\n"); // mod by eXXile
533
const prefBranch = (typeof(this.CI.nsIPrefBranch2) == "object")?"nsIPrefBranch2":"nsIPrefBranchInternal";
534
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(this.CI.nsIPrefService);
536
this._branch = prefService.getBranch(aPrefRoot);
537
this._branch.QueryInterface(eval("this.CI."+prefBranch));
538
this._branch.addObserver("", this, false);
539
this._registered = true;
542
unregister: function()
544
if (!this._registered)
549
//dump("aios_acbtf.PrefObserver: removing observer ...\n"); // mod by eXXile
550
this._branch.removeObserver("", this);
551
this._registered = false;
554
QueryInterface: function(aIID)
556
if (!aIID.equals(this.CI.nsISupports) && !aIID.equals(this.CI.nsIObserver))
558
throw Components.results.NS_ERROR_NO_INTERFACE;
563
observe: function(aSubject, aTopic, aData)
565
//dump("aios_acbtf.PrefObserver: observe() called ...\n"); // mod by eXXile
566
if (typeof(aios_acbtf) == "undefined") // mod by eXXile
568
//dump("aios_acbtf.PrefObserver: aios_acbtf is undefined!\n"); // mod by eXXile
571
if (aTopic != "nsPref:changed")
573
//dump("aios_acbtf.PrefObserver: " + aTopic + " is not the right topic for me.\n"); // mod by eXXile
577
// aSubject is the nsIPrefBranch we're observing (after appropriate QI)
578
// aData is the name of the pref that's been changed (relative to aSubject)
579
//dump("aios_acbtf.PrefObserver: name of the pref which was changed: " + aData +"\n"); // mod by eXXile
580
aios_acbtf.loadPrefs(); // mod by eXXile
584
aios_acbtf.showHideToolbar();
591
window.addEventListener('load', aios_acbtf, false); // mod by eXXile
592
window.addEventListener('unload', aios_acbtf, false); // mod by eXXile
b'\\ No newline at end of file'