~ubuntu-branches/ubuntu/karmic/all-in-one-sidebar/karmic

« back to all changes in this revision

Viewing changes to chrome/aios.jar!/content/bm_hi.js

  • Committer: Bazaar Package Importer
  • Author(s): Sveinung Kvilhaugsvik
  • Date: 2009-08-04 19:25:10 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090804192510-u4bm1ehm9ve4zdne
Tags: 0.7.10-0ubuntu1
* new upstream release (LP: #398535)
* list firefox-3.5 as alternate dependency
* depend on ${misc:Depends} to fix lintian warning
* changed maintainer field do to change in rules
* merged all-in-one-sidebar 0.7.4-0ubuntu2
   + replace current watchfile with the one from it
   + add the change log entry from it
   + discard it's other changes
* bump standards-version to 3.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
var searchObj, clearObj;
3
 
var aios_checkElems = new Array( 'aios-enableAutoClose', 'aios-viewOpenClose', 'aios-viewClear', 'aios-EBS-toolbar-mitem' );
4
 
 
5
 
 
6
 
/*
7
 
        Initialisierung
8
 
                => Aufruf durch onload in bm_hi.xul
9
 
*/
10
 
function aios_initBmHi() {
11
 
        var popUp;
12
 
        aios_synchElements(aios_checkElems);
13
 
 
14
 
        // Tools-Buttton anzeigen?
15
 
        try {
16
 
                var enable_tools;
17
 
 
18
 
                if(document.getElementById('bookmarksPanel')) enable_tools = aios_gPrefBranch.getBoolPref("bm.tools");
19
 
                else enable_tools = aios_gPrefBranch.getBoolPref("hi.tools");
20
 
 
21
 
                document.getElementById('viewButton').hidden = !enable_tools;
22
 
        }
23
 
        catch(e){ }
24
 
        
25
 
        searchObj = document.getElementById("search-box");
26
 
        clearObj = document.getElementById("clearSearch");
27
 
 
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");');
34
 
        }
35
 
        
36
 
        // Chronik
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;
42
 
 
43
 
                popUp.appendChild(document.getElementById('aios-enableAutoClose'));
44
 
                popUp.appendChild(document.getElementById('aios-rememberFolder'));
45
 
                popUp.appendChild(document.getElementById('aios-scrollToFolder'));
46
 
 
47
 
                popUp.appendChild(document.getElementById('openClose-separator').cloneNode(true));
48
 
 
49
 
                popUp.appendChild(document.getElementById('aios-viewOpenClose'));
50
 
                popUp.appendChild(document.getElementById('aios-viewClear'));
51
 
        }
52
 
 
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;
58
 
 
59
 
                // alten <button> entfernen
60
 
                viewButton.parentNode.removeChild(viewButton);
61
 
 
62
 
                var new_viewButton = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "toolbarbutton");
63
 
 
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);
67
 
                }
68
 
 
69
 
                // neuen <toolbarbutton> einf�gen
70
 
                popUp.setAttribute('onpopupshowing', 'aios_checkOptions();');
71
 
                new_viewButton.appendChild(popUp);
72
 
                searchObj.parentNode.appendChild(new_viewButton);
73
 
        }
74
 
 
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'));
80
 
        }
81
 
 
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'));
87
 
        }
88
 
 
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'));
92
 
        }
93
 
        
94
 
        // Fix f�r Flock
95
 
        if(aios_appVendor == "Flock") {
96
 
                document.getElementById('openCloseFolder').hidden = true;
97
 
                document.getElementById('clearSearch').hidden = true;
98
 
                document.getElementById('viewButton').hidden = true;
99
 
        }
100
 
}
101
 
 
102
 
 
103
 
/*
104
 
        experimentelle Elemente aktivieren/deaktivieren
105
 
                => Aufruf durch onpopupshowing des Tools-Buttons
106
 
*/
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"));
110
 
}
111
 
 
112
 
 
113
 
/*
114
 
        Alle Ordner �ffnen (Linksklick) oder alle Ordner schlie�en (Rechtsklick)
115
 
                => Aufruf durch den Button #openCloseFolder in der bm_hi.xul
116
 
*/
117
 
function aios_openCloseFolder(event) {
118
 
        if(typeof event != "object") return;
119
 
 
120
 
        if(event.button == 1 || event.button == 2) aios_acbtf.closeAll();
121
 
        else aios_acbtf.openAll();
122
 
}
123
 
 
124
 
 
125
 
/*
126
 
"Suchbegriff" im Suchfeld anzeigen oder verbergen
127
 
                => Aufruf durch onfocus() und onblur() des Suchfeldes
128
 
*/
129
 
function aios_focusBlurText(mode) {
130
 
        var strings = document.getElementById("propSetStrings");
131
 
        var blurText = strings.getString('bm_hi.search.blur');
132
 
            
133
 
        if(mode == "focus" && searchObj.value == blurText) {
134
 
                searchObj.className = "";
135
 
                searchObj.value = "";
136
 
                clearObj.setAttribute('disabled', false);
137
 
        }
138
 
        else if(mode == "blur" && searchObj.value == "") {
139
 
            searchObj.className = "blur";
140
 
                searchObj.value = blurText;
141
 
                clearObj.setAttribute('disabled', true);
142
 
        }
143
 
}
144
 
 
145
 
 
146
 
/*
147
 
        Suche und Ansicht zur�cksetzen
148
 
                => Aufruf durch #clearSearch in bm_hi.xul und die Men�eintr�ge im "Extras"-Men�
149
 
*/
150
 
function aios_clearSearch() {
151
 
        searchObj.value = "";
152
 
        searchObj.focus();
153
 
 
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
158
 
        }
159
 
        else {
160
 
            searchHistory(searchObj.value);
161
 
        }
162
 
}
163
 
 
164
 
 
165
 
/*
166
 
        Autoclose Bookmark & History Folder by Ronny Perinke (mod by exxile, based on ac-btf_0_55_5.xpi)
167
 
*/
168
 
const aios_acbtf = {
169
 
        _BTree: null,
170
 
        _HTree: null,
171
 
        _Prefs:
172
 
        {
173
 
                //CloseSidebar: false, //mod by eXXile
174
 
                ScrollToRow: false,
175
 
                SelectLastUsedFolder: true,
176
 
                //ShowToolbar: true //mod by eXXile
177
 
        },
178
 
        get prefRoot()
179
 
        {
180
 
                return "extensions.aios.acbh."; //mod by eXXile
181
 
        },
182
 
        set prefRoot(aString){},
183
 
        get PrefsIFace()
184
 
        {
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; });
188
 
                return prefsIFace;
189
 
        },
190
 
        /*get StringBundle()*/ //function deleted by eXXile
191
 
        //#######################################
192
 
        //########      /private functions and properties       ########
193
 
        //########                                              ########
194
 
        //#######################################
195
 
        
196
 
        /**
197
 
                implement EventListener Interface
198
 
                only used for addEventListener()
199
 
        */
200
 
        handleEvent: function BMB_handleEvent(aEvent)
201
 
        {
202
 
                switch(aEvent.type)
203
 
                {
204
 
                        case "load":
205
 
                                this.init();
206
 
                                break;
207
 
                        
208
 
                        case "unload":
209
 
                                this.quit();
210
 
                                break;
211
 
                }
212
 
        },
213
 
        
214
 
        init: function()
215
 
        {
216
 
                
217
 
                try
218
 
                {
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
221
 
                }
222
 
                catch(e)
223
 
                {
224
 
                        //dump("ac-btf: could no get element \"bookmarks-view\"\nError Message:\n"+e+"\n");
225
 
                }
226
 
                
227
 
                try
228
 
                {
229
 
                        this._HTree = document.getElementById("historyTree");
230
 
                        this._HTree.setAttribute("onclick", 'aios_acbtf.onClick(event, "history")');            //�ndert den standard onclick-event //mod by eXXile
231
 
                }
232
 
                catch(e)
233
 
                {
234
 
                        //dump("ac-btf: could no get element \"historyTree\"\nError Message:\n"+e+"\n");
235
 
                }
236
 
                
237
 
                this.loadPrefs();
238
 
                
239
 
                this.PrefObserver.register(this.prefRoot);
240
 
                //this.showHideToolbar(); //mod by eXXile
241
 
                //this.addSettingsButton(); //mod by eXXile
242
 
                
243
 
                if (this._Prefs.SelectLastUsedFolder)
244
 
                {
245
 
                        var tbo, lastRowToSelect;
246
 
                        if (this._BTree && this.PrefsIFace.prefHasUserValue("lastBookmarkFolder"))
247
 
                        {
248
 
                                lastRowToSelect = this.PrefsIFace.getIntPref("lastBookmarkFolder");
249
 
                                tbo = this._BTree.treeBoxObject;
250
 
                                setTimeout(this.selectFolder, 10, lastRowToSelect, tbo);
251
 
                        }
252
 
                        
253
 
                        if (this._HTree && this.PrefsIFace.prefHasUserValue("lastHistoryFolder"))
254
 
                        {
255
 
                                lastRowToSelect = this.PrefsIFace.getIntPref("lastHistoryFolder");
256
 
                                tbo = this._HTree.treeBoxObject;
257
 
                                setTimeout(this.selectFolder, 10, lastRowToSelect, tbo);
258
 
                        }
259
 
                }
260
 
        },
261
 
        quit: function()
262
 
        {
263
 
                this.PrefObserver.unregister();
264
 
                /*this.removeSettingsButton();
265
 
                
266
 
                if (this._Prefs.CloseSidebar)
267
 
                {
268
 
                        var sb_box = window.top.document.getElementById("sidebar-box");
269
 
                        sb_box.setAttribute("sidebarcommand", "");
270
 
                        window.top.document.persist("sidebar-box", "sidebarcommand");
271
 
                }*/ //mod by eXXile
272
 
        },
273
 
        
274
 
        loadPrefs: function()
275
 
        {
276
 
                this.PrefsIFace = this.prefRoot;        // reset PrefBranch to default value
277
 
                //load user settings
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
282
 
        },
283
 
        
284
 
        /*showHideToolbar: function()
285
 
        addToolbar: function()
286
 
        removeToolbar: function()
287
 
        updateTBButtons: function(aEvent)
288
 
        addSettingsButton: function()
289
 
        removeSettingsButton: function()*/ //functions deleted by eXXile
290
 
        
291
 
        selectFolder: function(index, tbo)
292
 
        {
293
 
                if (tbo.view.rowCount >= index)
294
 
                {
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);
299
 
                }
300
 
        },
301
 
        
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'))
305
 
                {
306
 
                        return;
307
 
                }
308
 
                
309
 
                // don't do anything if it was a right-click
310
 
                if (aEvent.button == 2)
311
 
                {
312
 
                        return;
313
 
                }
314
 
                
315
 
                var dotoggle = (aEvent.button != 0)?false:true; //wenn es kein links-klick war, dann f�hre nur die standardaktion aus
316
 
                
317
 
                const tree = (aios_acbtf._BTree)?aios_acbtf._BTree:aios_acbtf._HTree;   //mod by eXXile
318
 
                
319
 
                var tbo = tree.treeBoxObject;
320
 
                
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")
325
 
                {
326
 
                        return;
327
 
                }
328
 
                
329
 
                var mouseInGutter = false;
330
 
                if (sidebarType == 'history')
331
 
                {
332
 
                      var x = { }, y = { }, w = { }, h = { };
333
 
                      tbo.getCoordsForCellItem(row.value, col.value, "image", x, y, w, h);
334
 
                      mouseInGutter = aEvent.clientX < x.value;
335
 
                }
336
 
                
337
 
                var tboView = tbo.view
338
 
                var modifKey = aEvent.shiftKey || aEvent.ctrlKey || aEvent.altKey || aEvent.metaKey  || aEvent.button == 1;
339
 
                row = row.value;
340
 
                if (dotoggle && tboView.isContainer(row) && !modifKey)
341
 
                {
342
 
                        tboView.toggleOpenState(row);   //�ffnet oder schliesst den ordner; Standardvorgang bei Ordnern
343
 
                        
344
 
                        // mod by eXXile => nur die anderen schlie�en, wenn auch aktiviert
345
 
                        if(!aios_getBoolean("aios-enableAutoClose", "checked")) return;
346
 
                        
347
 
                        //jetzt der teil, der die anderen offenen ordner schliesst
348
 
                        var parents = new Array();
349
 
                        //nun werden alle ober-ordner des aktuellen gesucht
350
 
                        while (row != -1)
351
 
                        {
352
 
                                parents.push(row);
353
 
                                row = tboView.getParentIndex(row);
354
 
                        }
355
 
                        parents.reverse();      //dreht reihenfolge im array um
356
 
                        
357
 
                        for (var i = tboView.rowCount-1; i>=0; i--)     //geht einfach jede zeile durch und testet ...
358
 
                        {
359
 
                                if (parents.length > 0 && parents[parents.length-1] == i)
360
 
                                {       //bei den ober-ordnern soll sich nix tun, sollen also offen bleiben
361
 
                                        parents.pop();
362
 
                                }
363
 
                                else
364
 
                                {
365
 
                                        if (tboView.isContainer(i) && tboView.isContainerOpen(i))
366
 
                                        {
367
 
                                                //andere elemente, die ordner sind, sollen geschlossen werden
368
 
                                                tboView.toggleOpenState(i);
369
 
                                        }
370
 
                                }
371
 
                        }
372
 
                        
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
374
 
                        {
375
 
                                tbo.scrollToRow(tree.currentIndex);
376
 
                        }
377
 
                        tbo.ensureRowIsVisible(tree.currentIndex);      // scrollt zum index nur wenn n�tig.
378
 
                        
379
 
                        if (aios_acbtf._Prefs.SelectLastUsedFolder) // mod by eXXile
380
 
                        {
381
 
                                switch(sidebarType)
382
 
                                {
383
 
                                        case 'bookmarks':
384
 
                                                aios_acbtf.PrefsIFace.setIntPref("lastBookmarkFolder", tree.currentIndex); // mod by eXXile
385
 
                                                break;
386
 
                                                
387
 
                                        case 'history':
388
 
                                                aios_acbtf.PrefsIFace.setIntPref("lastHistoryFolder", tree.currentIndex); // mod by eXXile
389
 
                                                break;
390
 
                                }
391
 
                        }
392
 
                        return;
393
 
                }
394
 
                
395
 
                // open item
396
 
                if (!mouseInGutter && aEvent.originalTarget.localName == "treechildren" && (aEvent.button == 0 || aEvent.button == 1))
397
 
                {
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")
403
 
                        {
404
 
                                PlacesUIUtils.openNodeWithEvent(tree.selectedNode, aEvent);
405
 
                                return;
406
 
                        }
407
 
                        if (typeof(PlacesUtils) == "object" && typeof(PlacesUtils.openNodeWithEvent) == "function")
408
 
                        {
409
 
                                PlacesUtils.openNodeWithEvent(tree.selectedNode, aEvent);
410
 
                                return;
411
 
                        }
412
 
                        if (tree.controller && typeof(tree.controller.openSelectedNodeWithEvent) == "function")
413
 
                        {
414
 
                                tree.controller.openSelectedNodeWithEvent(aEvent);
415
 
                                return;
416
 
                        }
417
 
                        if (sidebarType == 'bookmarks' && typeof(tree.openItemClick) == "function")
418
 
                        {
419
 
                                tree.openItemClick(aEvent, 1);
420
 
                                return;
421
 
                        }
422
 
                        if (sidebarType == 'history' && typeof(openURL) == "function")
423
 
                        {
424
 
                                openURL(aEvent);
425
 
                                return;
426
 
                        }
427
 
                }
428
 
        },
429
 
        
430
 
        closeAll: function()
431
 
        {
432
 
                var aView;
433
 
                if (aios_acbtf._BTree) // mod by eXXile
434
 
                {
435
 
                        aView = aios_acbtf._BTree.treeBoxObject.view; // mod by eXXile
436
 
                        try
437
 
                        {
438
 
                                this.PrefsIFace.clearUserPref("lastBookmarkFolder");
439
 
                        }
440
 
                        catch(e)
441
 
                        {}
442
 
                }
443
 
                
444
 
                if (aios_acbtf._HTree) // mod by eXXile
445
 
                {
446
 
                        aView = aios_acbtf._HTree.treeBoxObject.view; // mod by eXXile
447
 
                        try
448
 
                        {
449
 
                                this.PrefsIFace.clearUserPref("lastHistoryFolder");
450
 
                        }
451
 
                        catch(e)
452
 
                        {}
453
 
                }
454
 
                
455
 
                if (aView)
456
 
                {
457
 
                        for (var i = aView.rowCount-1; i>=0; i--)
458
 
                        {
459
 
                                if (aView.isContainer(i) && aView.isContainerOpen(i))
460
 
                                {
461
 
                                        aView.toggleOpenState(i);
462
 
                                }
463
 
                        }
464
 
                }
465
 
        },
466
 
        openAll: function()
467
 
        {
468
 
                var aView, viewbutton;
469
 
                if (aios_acbtf._BTree) // mod by eXXile
470
 
                {
471
 
                        aView = aios_acbtf._BTree.treeBoxObject.view; // mod by eXXile
472
 
                        try
473
 
                        {
474
 
                                this.PrefsIFace.clearUserPref("lastBookmarkFolder");
475
 
                        }
476
 
                        catch(e)
477
 
                        {}
478
 
                }
479
 
                
480
 
                if (aios_acbtf._HTree) // mod by eXXile
481
 
                {
482
 
                        aView = aios_acbtf._HTree.treeBoxObject.view; // mod by eXXile
483
 
                        viewbutton = document.getElementById("viewButton");
484
 
                        try
485
 
                        {
486
 
                                this.PrefsIFace.clearUserPref("lastHistoryFolder");
487
 
                        }
488
 
                        catch(e)
489
 
                        {}
490
 
                }
491
 
                
492
 
                var doOnce = (viewbutton)?(viewbutton.getAttribute("selectedsort") == "day"):false;
493
 
                
494
 
                if (aView)
495
 
                {
496
 
                        var oldrows = -1;
497
 
                        var rows = aView.rowCount;
498
 
                        do
499
 
                        {
500
 
                                for (var i = rows-1; i>=0; i--)
501
 
                                {
502
 
                                        if (aView.isContainer(i) && !aView.isContainerOpen(i))
503
 
                                        {
504
 
                                                aView.toggleOpenState(i);
505
 
                                        }
506
 
                                }
507
 
                                
508
 
                                oldrows = rows;
509
 
                                rows = aView.rowCount;
510
 
                        }
511
 
                        while(rows != oldrows && !doOnce);
512
 
                }
513
 
        },
514
 
        
515
 
        PrefObserver:
516
 
        {               
517
 
                get CI()
518
 
                {
519
 
                        return Components.interfaces;
520
 
                },
521
 
                set Ci(){},     // make it kind of a constant ;-)
522
 
                // http://kb.mozillazine.org/Dev_:_Using_preferences#Using_preferences_observers
523
 
                _branch: null,
524
 
                _registered: false,
525
 
                register: function(aPrefRoot)
526
 
                {
527
 
                        if (this._registered)
528
 
                        {
529
 
                                return;
530
 
                        }
531
 
                        
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);
535
 
                        
536
 
                        this._branch = prefService.getBranch(aPrefRoot);
537
 
                        this._branch.QueryInterface(eval("this.CI."+prefBranch));
538
 
                        this._branch.addObserver("", this, false);
539
 
                        this._registered = true;
540
 
                },
541
 
                
542
 
                unregister: function()
543
 
                {
544
 
                        if (!this._registered)
545
 
                        {
546
 
                                return;
547
 
                        }
548
 
                        
549
 
                        //dump("aios_acbtf.PrefObserver: removing observer ...\n"); // mod by eXXile
550
 
                        this._branch.removeObserver("", this);
551
 
                        this._registered = false;
552
 
                },
553
 
                
554
 
                QueryInterface: function(aIID)
555
 
                {
556
 
                        if (!aIID.equals(this.CI.nsISupports) && !aIID.equals(this.CI.nsIObserver))
557
 
                        {
558
 
                                throw Components.results.NS_ERROR_NO_INTERFACE;
559
 
                        }
560
 
                        return this;
561
 
                },
562
 
                
563
 
                observe: function(aSubject, aTopic, aData)
564
 
                {
565
 
                        //dump("aios_acbtf.PrefObserver: observe() called ...\n"); // mod by eXXile
566
 
                        if (typeof(aios_acbtf) == "undefined") // mod by eXXile
567
 
                        {
568
 
                                //dump("aios_acbtf.PrefObserver: aios_acbtf is undefined!\n"); // mod by eXXile
569
 
                                return;
570
 
                        }
571
 
                        if (aTopic != "nsPref:changed")
572
 
                        {
573
 
                                //dump("aios_acbtf.PrefObserver: " + aTopic + " is not the right topic for me.\n"); // mod by eXXile
574
 
                                return;
575
 
                        }
576
 
                        
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
581
 
                        /*switch (aData)
582
 
                        {
583
 
                                case "ShowToolbar":
584
 
                                        aios_acbtf.showHideToolbar();
585
 
                                        break;
586
 
                        }*/ // mod by eXXile
587
 
                }
588
 
        }
589
 
}
590
 
 
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'