2007-10-16 13:22:28 -04:00
|
|
|
|
var TreeStyleTabService = {
|
2007-10-23 02:05:44 -04:00
|
|
|
|
kID : 'treestyletab-id',
|
|
|
|
|
kCHILDREN : 'treestyletab-children',
|
|
|
|
|
kPARENT : 'treestyletab-parent',
|
2007-11-26 16:17:46 -05:00
|
|
|
|
kANCESTOR : 'treestyletab-ancestors',
|
2007-10-23 02:05:44 -04:00
|
|
|
|
kINSERT_BEFORE : 'treestyletab-insert-before',
|
|
|
|
|
kSUBTREE_COLLAPSED : 'treestyletab-subtree-collapsed',
|
|
|
|
|
kCOLLAPSED : 'treestyletab-collapsed',
|
2007-11-30 14:22:34 -05:00
|
|
|
|
kTWISTY_HOVER : 'treestyletab-twisty-hover',
|
2007-10-23 02:05:44 -04:00
|
|
|
|
kNEST : 'treestyletab-nest',
|
|
|
|
|
kDROP_POSITION : 'treestyletab-drop-position',
|
|
|
|
|
kTABBAR_POSITION : 'treestyletab-tabbar-position',
|
2007-10-26 08:56:04 -04:00
|
|
|
|
kMODE : 'treestyletab-mode',
|
2007-10-23 02:05:44 -04:00
|
|
|
|
kUI_INVERTED : 'treestyletab-appearance-inverted',
|
|
|
|
|
kSCROLLBAR_INVERTED : 'treestyletab-scrollbar-inverted',
|
2007-10-25 18:59:34 -04:00
|
|
|
|
kALLOW_COLLAPSE : 'treestyletab-allow-subtree-collapse',
|
2007-11-09 00:48:39 -05:00
|
|
|
|
kHIDE_ALLTABS : 'treestyletab-hide-alltabs-button',
|
2007-10-23 02:05:44 -04:00
|
|
|
|
kSTYLE : 'treestyletab-style',
|
2008-02-28 07:12:02 -05:00
|
|
|
|
kTWISTY_STYLE : 'treestyletab-twisty-style',
|
2007-10-23 02:05:44 -04:00
|
|
|
|
kFIRSTTAB_BORDER : 'treestyletab-firsttab-border',
|
2007-11-08 08:21:13 -05:00
|
|
|
|
kAUTOHIDE : 'treestyletab-tabbar-autohide',
|
2008-02-22 12:55:35 -05:00
|
|
|
|
kFIXED : 'treestyletab-tabbar-fixed',
|
2008-03-09 23:51:21 -04:00
|
|
|
|
kRESIZING : 'treestyletab-tabbar-resizing',
|
|
|
|
|
kTRANSPARENT : 'treestyletab-tabbar-transparent',
|
2007-10-18 13:11:03 -04:00
|
|
|
|
|
2007-10-20 02:12:22 -04:00
|
|
|
|
kTWISTY : 'treestyletab-twisty',
|
|
|
|
|
kTWISTY_CONTAINER : 'treestyletab-twisty-container',
|
|
|
|
|
kDROP_MARKER : 'treestyletab-drop-marker',
|
|
|
|
|
kDROP_MARKER_CONTAINER : 'treestyletab-drop-marker-container',
|
|
|
|
|
kCOUNTER : 'treestyletab-counter',
|
|
|
|
|
kCOUNTER_CONTAINER : 'treestyletab-counter-container',
|
2007-10-20 07:29:42 -04:00
|
|
|
|
kSPLITTER : 'treestyletab-splitter',
|
2007-11-30 14:22:34 -05:00
|
|
|
|
kSTRINGBUNDLE : 'treestyletab-stringbundle',
|
2007-10-16 13:22:28 -04:00
|
|
|
|
|
2007-10-19 22:44:14 -04:00
|
|
|
|
kMENUITEM_REMOVESUBTREE_SELECTION : 'multipletab-selection-item-removeTabSubTree',
|
2007-10-19 01:27:06 -04:00
|
|
|
|
|
2007-10-18 23:05:36 -04:00
|
|
|
|
kFOCUS_ALL : 0,
|
|
|
|
|
kFOCUS_VISIBLE : 1,
|
|
|
|
|
|
2007-10-19 22:44:14 -04:00
|
|
|
|
kDROP_BEFORE : -1,
|
|
|
|
|
kDROP_ON : 0,
|
|
|
|
|
kDROP_AFTER : 1,
|
|
|
|
|
|
|
|
|
|
kACTION_MOVE : 1,
|
|
|
|
|
kACTION_ATTACH : 2,
|
|
|
|
|
kACTION_PART : 4,
|
2008-02-22 18:31:22 -05:00
|
|
|
|
kACTION_DUPLICATE : 8,
|
2008-02-24 03:11:17 -05:00
|
|
|
|
kACTION_MOVE_FROM_OTHER_WINDOW : 16,
|
2007-10-19 22:44:14 -04:00
|
|
|
|
|
2007-10-20 06:24:36 -04:00
|
|
|
|
kTABBAR_TOP : 1,
|
|
|
|
|
kTABBAR_BOTTOM : 2,
|
|
|
|
|
kTABBAR_LEFT : 4,
|
|
|
|
|
kTABBAR_RIGHT : 8,
|
|
|
|
|
|
|
|
|
|
kTABBAR_HORIZONTAL : 3,
|
|
|
|
|
kTABBAR_VERTICAL : 12,
|
|
|
|
|
|
2008-06-17 02:22:49 -04:00
|
|
|
|
kAUTOHIDE_MODE_DISABLED : 0,
|
|
|
|
|
kAUTOHIDE_MODE_HIDE : 1,
|
|
|
|
|
kAUTOHIDE_MODE_SHRINK : 2,
|
2008-06-17 06:16:57 -04:00
|
|
|
|
get autoHideMode()
|
|
|
|
|
{
|
|
|
|
|
if (this._autoHideMode == this.kAUTOHIDE_MODE_SHRINK &&
|
|
|
|
|
this.getTreePref('tabbar.position') != 'left' &&
|
|
|
|
|
this.getTreePref('tabbar.position') != 'right')
|
|
|
|
|
return this.kAUTOHIDE_MODE_HIDE;
|
|
|
|
|
return this._autoHideMode;
|
|
|
|
|
},
|
|
|
|
|
set autoHideMode(aValue)
|
|
|
|
|
{
|
|
|
|
|
this._autoHideMode = aValue;
|
|
|
|
|
return aValue;
|
|
|
|
|
},
|
|
|
|
|
_autoHideMode : 0,
|
2008-06-17 02:22:49 -04:00
|
|
|
|
|
2008-03-08 03:57:17 -05:00
|
|
|
|
kSHOWN_BY_UNKNOWN : 0,
|
|
|
|
|
kSHOWN_BY_SHORTCUT : 1,
|
|
|
|
|
kSHOWN_BY_MOUSEMOVE : 2,
|
2008-03-09 01:36:52 -05:00
|
|
|
|
kSHOWN_BY_FEEDBACK : 3,
|
2008-09-26 10:13:29 -04:00
|
|
|
|
|
|
|
|
|
kTRANSPARENT_NONE : 0,
|
|
|
|
|
kTRANSPARENT_PART : 1,
|
|
|
|
|
kTRANSPARENT_FULL : 2,
|
|
|
|
|
kTRANSPARENT_STYLE : ['none', 'part', 'full'],
|
2008-03-08 03:57:17 -05:00
|
|
|
|
|
2007-10-30 20:38:37 -04:00
|
|
|
|
kINSERT_FISRT : 0,
|
|
|
|
|
kINSERT_LAST : 1,
|
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
baseLebelMargin : 12,
|
2007-11-08 22:10:10 -05:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
NSResolver : {
|
|
|
|
|
lookupNamespaceURI : function(aPrefix)
|
|
|
|
|
{
|
|
|
|
|
switch (aPrefix)
|
|
|
|
|
{
|
|
|
|
|
case 'xul':
|
|
|
|
|
return 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
|
|
|
|
|
case 'html':
|
|
|
|
|
case 'xhtml':
|
|
|
|
|
return 'http://www.w3.org/1999/xhtml';
|
|
|
|
|
case 'xlink':
|
|
|
|
|
return 'http://www.w3.org/1999/xlink';
|
|
|
|
|
default:
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
get SessionStore() {
|
|
|
|
|
if (!this._SessionStore) {
|
2008-02-22 00:01:35 -05:00
|
|
|
|
this._SessionStore = Components
|
|
|
|
|
.classes['@mozilla.org/browser/sessionstore;1']
|
|
|
|
|
.getService(Components.interfaces.nsISessionStore);
|
2007-10-16 13:22:28 -04:00
|
|
|
|
}
|
|
|
|
|
return this._SessionStore;
|
|
|
|
|
},
|
|
|
|
|
_SessionStore : null,
|
2007-10-20 04:22:42 -04:00
|
|
|
|
|
|
|
|
|
get ObserverService() {
|
|
|
|
|
if (!this._ObserverService) {
|
2008-02-22 00:01:35 -05:00
|
|
|
|
this._ObserverService = Components
|
|
|
|
|
.classes['@mozilla.org/observer-service;1']
|
|
|
|
|
.getService(Components.interfaces.nsIObserverService);
|
2007-10-20 04:22:42 -04:00
|
|
|
|
}
|
|
|
|
|
return this._ObserverService;
|
|
|
|
|
},
|
|
|
|
|
_ObserverService : null,
|
2007-10-22 05:59:43 -04:00
|
|
|
|
|
|
|
|
|
get IOService() {
|
|
|
|
|
if (!this._IOService) {
|
2008-02-22 00:01:35 -05:00
|
|
|
|
this._IOService = Components
|
|
|
|
|
.classes['@mozilla.org/network/io-service;1']
|
|
|
|
|
.getService(Components.interfaces.nsIIOService);
|
2007-10-22 05:59:43 -04:00
|
|
|
|
}
|
|
|
|
|
return this._IOService;
|
|
|
|
|
},
|
|
|
|
|
_IOService : null,
|
2007-11-09 00:20:32 -05:00
|
|
|
|
|
2008-02-22 00:01:35 -05:00
|
|
|
|
get WindowMediator() {
|
|
|
|
|
if (!this._WindowMediator) {
|
|
|
|
|
this._WindowMediator = Components
|
|
|
|
|
.classes['@mozilla.org/appshell/window-mediator;1']
|
|
|
|
|
.getService(Components.interfaces.nsIWindowMediator);
|
|
|
|
|
}
|
|
|
|
|
return this._WindowMediator;
|
|
|
|
|
},
|
|
|
|
|
_WindowMediator : null,
|
|
|
|
|
|
2007-11-09 00:20:32 -05:00
|
|
|
|
get isGecko18() {
|
|
|
|
|
var version = this.XULAppInfo.platformVersion.split('.');
|
|
|
|
|
return parseInt(version[0]) <= 1 && parseInt(version[1]) <= 8;
|
|
|
|
|
},
|
2008-05-22 23:30:49 -04:00
|
|
|
|
get isGecko19() {
|
|
|
|
|
var version = this.XULAppInfo.platformVersion.split('.');
|
|
|
|
|
return parseInt(version[0]) >= 2 || parseInt(version[1]) >= 9;
|
|
|
|
|
},
|
2007-11-09 00:20:32 -05:00
|
|
|
|
|
|
|
|
|
get XULAppInfo() {
|
|
|
|
|
if (!this._XULAppInfo) {
|
|
|
|
|
this._XULAppInfo = Components.classes['@mozilla.org/xre/app-info;1'].getService(Components.interfaces.nsIXULAppInfo);
|
|
|
|
|
}
|
|
|
|
|
return this._XULAppInfo;
|
|
|
|
|
},
|
|
|
|
|
_XULAppInfo : null,
|
2007-11-30 14:22:34 -05:00
|
|
|
|
|
|
|
|
|
get stringbundle() {
|
|
|
|
|
if (!this._stringbundle) {
|
|
|
|
|
this._stringbundle = document.getElementById(this.kSTRINGBUNDLE);
|
|
|
|
|
}
|
|
|
|
|
return this._stringbundle;
|
|
|
|
|
},
|
|
|
|
|
_stringbundle : null,
|
2007-11-17 00:20:26 -05:00
|
|
|
|
|
2007-10-21 04:16:10 -04:00
|
|
|
|
/* API */
|
2007-11-08 08:21:13 -05:00
|
|
|
|
|
2007-10-29 10:52:52 -04:00
|
|
|
|
readyToOpenChildTab : function(aFrameOrTabBrowser, aMultiple, aInsertBefore)
|
2007-10-21 04:16:10 -04:00
|
|
|
|
{
|
2008-02-27 19:07:51 -05:00
|
|
|
|
if (!this.getTreePref('autoAttachNewTabsAsChildren')) return;
|
|
|
|
|
|
2007-10-21 04:16:10 -04:00
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
|
|
|
|
if (!frame) return;
|
|
|
|
|
|
2007-10-23 00:33:46 -04:00
|
|
|
|
var ownerBrowser = this.getTabBrowserFromFrame(frame);
|
2007-11-14 14:34:36 -05:00
|
|
|
|
ownerBrowser.treeStyleTab.readyToAttachNewTab = true;
|
|
|
|
|
ownerBrowser.treeStyleTab.readyToAttachMultiple = aMultiple || false ;
|
|
|
|
|
ownerBrowser.treeStyleTab.multipleCount = 0;
|
|
|
|
|
ownerBrowser.treeStyleTab.parentTab = this.getTabFromFrame(frame, ownerBrowser).getAttribute(this.kID);
|
|
|
|
|
ownerBrowser.treeStyleTab.insertBefore = aInsertBefore ? aInsertBefore.getAttribute(this.kID) : null ;
|
2007-10-21 04:16:10 -04:00
|
|
|
|
},
|
|
|
|
|
|
2007-10-21 20:40:04 -04:00
|
|
|
|
readyToOpenNewTabGroup : function(aFrameOrTabBrowser)
|
|
|
|
|
{
|
2008-02-27 19:07:51 -05:00
|
|
|
|
if (!this.getTreePref('autoAttachNewTabsAsChildren')) return;
|
|
|
|
|
|
2007-10-21 20:40:04 -04:00
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
|
|
|
|
if (!frame) return;
|
|
|
|
|
|
|
|
|
|
this.stopToOpenChildTab(frame);
|
|
|
|
|
|
2007-10-23 00:33:46 -04:00
|
|
|
|
var ownerBrowser = this.getTabBrowserFromFrame(frame);
|
2007-11-14 14:34:36 -05:00
|
|
|
|
ownerBrowser.treeStyleTab.readyToAttachNewTabGroup = true;
|
|
|
|
|
ownerBrowser.treeStyleTab.readyToAttachMultiple = true;
|
|
|
|
|
ownerBrowser.treeStyleTab.multipleCount = 0;
|
2007-10-21 20:40:04 -04:00
|
|
|
|
},
|
|
|
|
|
|
2007-10-21 04:16:10 -04:00
|
|
|
|
stopToOpenChildTab : function(aFrameOrTabBrowser)
|
|
|
|
|
{
|
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
|
|
|
|
if (!frame) return;
|
|
|
|
|
|
2007-10-23 00:33:46 -04:00
|
|
|
|
var ownerBrowser = this.getTabBrowserFromFrame(frame);
|
2007-11-14 14:34:36 -05:00
|
|
|
|
ownerBrowser.treeStyleTab.readyToAttachNewTab = false;
|
|
|
|
|
ownerBrowser.treeStyleTab.readyToAttachNewTabGroup = false;
|
|
|
|
|
ownerBrowser.treeStyleTab.readyToAttachMultiple = false;
|
|
|
|
|
ownerBrowser.treeStyleTab.multipleCount = 0;
|
|
|
|
|
ownerBrowser.treeStyleTab.parentTab = null;
|
|
|
|
|
ownerBrowser.treeStyleTab.insertBefore = null;
|
2007-10-21 04:16:10 -04:00
|
|
|
|
},
|
|
|
|
|
|
2007-10-21 04:17:59 -04:00
|
|
|
|
checkToOpenChildTab : function(aFrameOrTabBrowser)
|
2007-10-21 04:16:10 -04:00
|
|
|
|
{
|
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
|
|
|
|
|
if (!frame) return false;
|
|
|
|
|
|
2007-10-23 00:33:46 -04:00
|
|
|
|
var ownerBrowser = this.getTabBrowserFromFrame(frame);
|
2007-11-14 14:34:36 -05:00
|
|
|
|
return ownerBrowser.treeStyleTab.readyToAttachNewTab || ownerBrowser.treeStyleTab.readyToAttachNewTabGroup ? true : false ;
|
2007-10-21 04:16:10 -04:00
|
|
|
|
},
|
2007-10-28 12:07:10 -04:00
|
|
|
|
|
2007-10-29 11:49:00 -04:00
|
|
|
|
checkReadyToOpenNewTab : function(aInfo)
|
2007-10-28 12:07:10 -04:00
|
|
|
|
{
|
2007-10-29 10:52:52 -04:00
|
|
|
|
/*
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̐<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
<EFBFBD>E<EFBFBD><EFBFBD><EFBFBD>݂̃T<EFBFBD>C<EFBFBD>g<EFBFBD>ƈقȂ<EFBFBD><EFBFBD>T<EFBFBD>C<EFBFBD>g<EFBFBD><EFBFBD><EFBFBD>ǂݍ<EFBFBD><EFBFBD>ޏꍇ<EFBFBD>Ƀ^<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>F
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɉ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD>B<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>^<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD>q<EFBFBD>^<EFBFBD>u<EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꍇ<EFBFBD>͕ʓr
|
|
|
|
|
readyToOpenChildTab<EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
|
|
|
|
|
<EFBFBD>E<EFBFBD><EFBFBD><EFBFBD>݂̃T<EFBFBD>C<EFBFBD>g<EFBFBD>Ɠ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD>C<EFBFBD>g<EFBFBD>̃y<EFBFBD>[<EFBFBD>W<EFBFBD><EFBFBD><EFBFBD>ǂݍ<EFBFBD><EFBFBD>ޏꍇ<EFBFBD>Ƀ^<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>F
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>e<EFBFBD>̃^<EFBFBD>u<EFBFBD>͓<EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD>C<EFBFBD>g<EFBFBD><EFBFBD><EFBFBD>H
|
|
|
|
|
No <EFBFBD>F<EFBFBD>q<EFBFBD>^<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD>
|
|
|
|
|
Yes<EFBFBD>F<EFBFBD>Z<EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><EFBFBD>ă^<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><EFBFBD><EFBFBD>B<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>̃^<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̃^<EFBFBD>u<EFBFBD>͂<EFBFBD><EFBFBD>ׂ<EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>݂̃^<EFBFBD>u<EFBFBD>Ǝ<EFBFBD><EFBFBD>̌Z<EFBFBD><EFBFBD><EFBFBD>^<EFBFBD>u<EFBFBD>Ƃ̊ԂɊJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>z<EFBFBD>T<EFBFBD>u<EFBFBD>c<EFBFBD><EFBFBD><EFBFBD>[<EFBFBD>ƂȂ<EFBFBD><EFBFBD>B
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>݂̃^<EFBFBD>u<EFBFBD>Ɂu__treestyletab__next<EFBFBD>v<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>邩<EFBFBD>H
|
|
|
|
|
Yes<EFBFBD>F__treestyletab__next<EFBFBD>Ŏ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ<EFBFBD>^<EFBFBD>u<EFBFBD>̒<EFBFBD><EFBFBD>O<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD><EFBFBD><EFBFBD>^<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD>}<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
No <EFBFBD>F<EFBFBD><EFBFBD><EFBFBD>݂̃^<EFBFBD>u<EFBFBD>̎<EFBFBD><EFBFBD>̌Z<EFBFBD><EFBFBD><EFBFBD>^<EFBFBD>u<EFBFBD><EFBFBD>ID<EFBFBD><EFBFBD>__treestyletab__next
|
|
|
|
|
<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>ɕێ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>z<EFBFBD>̎q<EFBFBD>^<EFBFBD>u<EFBFBD><EFBFBD><EFBFBD>}<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʒu<EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD>Ƃ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
*/
|
|
|
|
|
|
2007-10-28 14:03:24 -04:00
|
|
|
|
var info = aInfo || { uri : '' };
|
|
|
|
|
if (/^javascript:/.test(info.uri)) return false;
|
|
|
|
|
|
2007-10-29 11:22:50 -04:00
|
|
|
|
var frame = this.getFrameFromTabBrowserElements(info.target);
|
|
|
|
|
if (!frame) return false;
|
|
|
|
|
|
2007-10-28 13:16:48 -04:00
|
|
|
|
var external = info.external || {};
|
|
|
|
|
var internal = info.internal || {};
|
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
var b = this.getTabBrowserFromFrame(frame);
|
|
|
|
|
var nextTab = b.treeStyleTab.getNextSiblingTab(currentTab);
|
|
|
|
|
|
2007-10-28 13:16:48 -04:00
|
|
|
|
var targetHost = /^\w+:\/\/([^:\/]+)(\/|$)/.test(info.uri) ? RegExp.$1 : null ;
|
2007-10-29 10:52:52 -04:00
|
|
|
|
var currentTab = this.getTabFromFrame(frame);
|
2007-10-28 12:07:10 -04:00
|
|
|
|
var currentURI = frame.location.href;
|
|
|
|
|
var currentHost = currentURI.match(/^\w+:\/\/([^:\/]+)(\/|$)/) ? RegExp.$1 : null ;
|
2007-11-14 14:34:36 -05:00
|
|
|
|
var parentTab = b.treeStyleTab.getParentTab(currentTab);
|
2007-10-28 12:07:10 -04:00
|
|
|
|
var parentURI = parentTab ? parentTab.linkedBrowser.currentURI : null ;
|
|
|
|
|
var parentHost = parentURI && parentURI.spec.match(/^\w+:\/\/([^:\/]+)(\/|$)/) ? RegExp.$1 : null ;
|
|
|
|
|
|
2007-10-29 11:49:00 -04:00
|
|
|
|
var openTab = false;
|
|
|
|
|
var parent = null;
|
|
|
|
|
var insertBefore = null;
|
|
|
|
|
|
|
|
|
|
if (info.modifier) openTab = true;
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
internal.newTab &&
|
|
|
|
|
currentHost == targetHost &&
|
|
|
|
|
currentURI != 'about:blank' &&
|
|
|
|
|
currentURI.split('#')[0] != info.uri.split('#')[0]
|
|
|
|
|
) {
|
|
|
|
|
openTab = info.modifier && info.invert ? !openTab : true ;
|
|
|
|
|
parent = parentHost == targetHost && !internal.forceChild ? parentTab : frame ;
|
2007-10-30 20:38:37 -04:00
|
|
|
|
insertBefore = parentHost == targetHost && !internal.forceChild &&
|
|
|
|
|
(this.getTreePref('insertNewChildAt') == this.kINSERT_FIRST ?
|
|
|
|
|
nextTab :
|
|
|
|
|
(
|
2007-11-14 14:34:36 -05:00
|
|
|
|
b.treeStyleTab.getTabById(currentTab.__treestyletab__next) ||
|
2007-10-30 20:38:37 -04:00
|
|
|
|
(nextTab ? (currentTab.__treestyletab__next = nextTab.getAttribute(this.kID), nextTab) : null )
|
|
|
|
|
)
|
|
|
|
|
);
|
2007-10-29 11:49:00 -04:00
|
|
|
|
}
|
|
|
|
|
else if (
|
|
|
|
|
external.newTab &&
|
|
|
|
|
currentHost != targetHost &&
|
|
|
|
|
currentURI != 'about:blank'
|
|
|
|
|
) {
|
|
|
|
|
openTab = info.modifier && info.invert ? !openTab : true ;
|
|
|
|
|
if (external.forceChild) {
|
|
|
|
|
parent = frame;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (openTab && parent) {
|
|
|
|
|
this.readyToOpenChildTab(parent, false, insertBefore);
|
|
|
|
|
}
|
|
|
|
|
return openTab;
|
2007-10-28 12:07:10 -04:00
|
|
|
|
},
|
2008-09-26 10:13:29 -04:00
|
|
|
|
checkReadyToOpenNewTabOnLocationBar : function(aURI, aModifier)
|
|
|
|
|
{
|
|
|
|
|
return this.checkReadyToOpenNewTab({
|
|
|
|
|
uri : aURI,
|
|
|
|
|
external : {
|
|
|
|
|
newTab : this.getTreePref('urlbar.loadDifferentDomainToNewTab'),
|
|
|
|
|
forceChild : this.getTreePref('urlbar.loadDifferentDomainToNewTab.asChild')
|
|
|
|
|
},
|
|
|
|
|
internal : { newTab : this.getTreePref('urlbar.loadSameDomainToNewChildTab') },
|
|
|
|
|
modifier : aModifier,
|
|
|
|
|
invert : this.getTreePref('urlbar.invertDefaultBehavior')
|
|
|
|
|
});
|
|
|
|
|
},
|
2007-10-30 08:58:09 -04:00
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
/* backward compatibility */
|
|
|
|
|
getTempTreeStyleTab : function(aTabBrowser)
|
|
|
|
|
{
|
|
|
|
|
return aTabBrowser.treeStyleTab || new TreeStyleTabBrowser(aTabBrowser);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
initTabAttributes : function(aTab, aTabBrowser)
|
|
|
|
|
{
|
2007-11-17 08:32:41 -05:00
|
|
|
|
var b = aTabBrowser || this.getTabBrowserFromChild(aTab);
|
2007-11-14 14:34:36 -05:00
|
|
|
|
this.getTempTreeStyleTab(b).initTabAttributes(aTab);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
initTabContents : function(aTab, aTabBrowser)
|
|
|
|
|
{
|
2007-11-17 08:32:41 -05:00
|
|
|
|
var b = aTabBrowser || this.getTabBrowserFromChild(aTab);
|
2007-11-14 14:34:36 -05:00
|
|
|
|
this.getTempTreeStyleTab(b).initTabContents(aTab);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
initTabContentsOrder : function(aTab, aTabBrowser)
|
|
|
|
|
{
|
2007-11-17 08:32:41 -05:00
|
|
|
|
var b = aTabBrowser || this.getTabBrowserFromChild(aTab);
|
2007-11-14 14:34:36 -05:00
|
|
|
|
this.getTempTreeStyleTab(b).initTabContentsOrder(aTab);
|
|
|
|
|
},
|
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
/* Utilities */
|
2008-03-09 01:36:52 -05:00
|
|
|
|
|
2007-10-26 05:36:45 -04:00
|
|
|
|
isEventFiredOnTwisty : function(aEvent)
|
2007-10-16 13:22:28 -04:00
|
|
|
|
{
|
|
|
|
|
var tab = this.getTabFromEvent(aEvent);
|
|
|
|
|
if (!tab) return false;
|
|
|
|
|
|
2008-04-29 14:17:44 -04:00
|
|
|
|
return this.hasChildTabs(tab) && this.evaluateXPath(
|
2007-11-14 07:34:36 -05:00
|
|
|
|
'ancestor-or-self::*[@class="'+this.kTWISTY+'" or (ancestor::xul:tabbrowser[@'+this.kMODE+'="vertical"] and @class="tab-icon")]',
|
2007-10-26 05:36:45 -04:00
|
|
|
|
aEvent.originalTarget || aEvent.target,
|
|
|
|
|
XPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
|
).singleNodeValue ? true : false ;
|
2007-10-18 13:11:03 -04:00
|
|
|
|
},
|
2007-10-18 14:20:54 -04:00
|
|
|
|
|
2008-02-22 00:01:35 -05:00
|
|
|
|
get browserWindow()
|
|
|
|
|
{
|
|
|
|
|
return this.WindowMediator.getMostRecentWindow('navigator:browser');
|
|
|
|
|
},
|
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
get browser()
|
|
|
|
|
{
|
2008-02-22 00:01:35 -05:00
|
|
|
|
var w = this.browserWindow;
|
|
|
|
|
return !w ? null :
|
2008-02-22 00:04:35 -05:00
|
|
|
|
'SplitBrowser' in w ? w.SplitBrowser.activeBrowser :
|
2008-02-22 00:01:35 -05:00
|
|
|
|
w.gBrowser ;
|
2007-10-16 13:22:28 -04:00
|
|
|
|
},
|
|
|
|
|
|
2007-10-18 23:05:36 -04:00
|
|
|
|
evaluateXPath : function(aExpression, aContext, aType)
|
|
|
|
|
{
|
|
|
|
|
if (!aType) aType = XPathResult.ORDERED_NODE_SNAPSHOT_TYPE;
|
|
|
|
|
try {
|
|
|
|
|
var xpathResult = document.evaluate(
|
|
|
|
|
aExpression,
|
|
|
|
|
aContext,
|
|
|
|
|
this.NSResolver,
|
|
|
|
|
aType,
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
return {
|
|
|
|
|
singleNodeValue : null,
|
|
|
|
|
snapshotLength : 0,
|
|
|
|
|
snapshotItem : function() {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return xpathResult;
|
|
|
|
|
},
|
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
getArrayFromXPathResult : function(aXPathResult)
|
|
|
|
|
{
|
|
|
|
|
var max = aXPathResult.snapshotLength;
|
|
|
|
|
var array = new Array(max);
|
|
|
|
|
if (!max) return array;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < max; i++)
|
|
|
|
|
{
|
|
|
|
|
array[i] = aXPathResult.snapshotItem(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return array;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getTabFromEvent : function(aEvent)
|
|
|
|
|
{
|
2007-10-26 05:36:45 -04:00
|
|
|
|
return this.evaluateXPath(
|
|
|
|
|
'ancestor-or-self::xul:tab',
|
|
|
|
|
aEvent.originalTarget || aEvent.target, XPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
|
).singleNodeValue;
|
2007-10-16 13:22:28 -04:00
|
|
|
|
},
|
|
|
|
|
|
2007-10-17 12:07:43 -04:00
|
|
|
|
getTabFromFrame : function(aFrame, aTabBrowser)
|
|
|
|
|
{
|
|
|
|
|
var b = aTabBrowser || this.browser;
|
|
|
|
|
var docShell = aFrame.top
|
|
|
|
|
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
|
|
|
|
.getInterface(Components.interfaces.nsIWebNavigation)
|
|
|
|
|
.QueryInterface(Components.interfaces.nsIDocShell);
|
|
|
|
|
var tabs = b.mTabContainer.childNodes;
|
|
|
|
|
for (var i = 0, maxi = tabs.length; i < maxi; i++)
|
|
|
|
|
{
|
|
|
|
|
if (tabs[i].linkedBrowser.docShell == docShell)
|
|
|
|
|
return tabs[i];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
|
2007-11-17 08:32:41 -05:00
|
|
|
|
getTabBrowserFromChild : function(aTab)
|
2007-10-16 13:22:28 -04:00
|
|
|
|
{
|
2007-10-17 12:07:43 -04:00
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
if (aTab.__treestyletab__linkedTabBrowser)
|
|
|
|
|
return aTab.__treestyletab__linkedTabBrowser;
|
|
|
|
|
|
2007-10-26 06:25:59 -04:00
|
|
|
|
return this.evaluateXPath(
|
|
|
|
|
'ancestor-or-self::xul:tabbrowser',
|
|
|
|
|
aTab,
|
|
|
|
|
XPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
|
).singleNodeValue;
|
2007-10-16 13:22:28 -04:00
|
|
|
|
},
|
|
|
|
|
|
2007-10-23 00:33:46 -04:00
|
|
|
|
getTabBrowserFromFrame : function(aFrame)
|
|
|
|
|
{
|
2008-02-22 00:01:35 -05:00
|
|
|
|
var w = this.browserWindow;
|
|
|
|
|
return !w ? null :
|
|
|
|
|
('SplitBrowser' in w) ? this.getTabBrowserFromChild(w.SplitBrowser.getSubBrowserAndBrowserFromFrame(aFrame.top).browser) :
|
|
|
|
|
this.browser ;
|
2007-10-23 00:33:46 -04:00
|
|
|
|
},
|
2007-10-23 04:19:32 -04:00
|
|
|
|
|
2007-10-21 04:16:10 -04:00
|
|
|
|
getFrameFromTabBrowserElements : function(aFrameOrTabBrowser)
|
|
|
|
|
{
|
|
|
|
|
var frame = aFrameOrTabBrowser;
|
|
|
|
|
if (frame == '[object XULElement]') {
|
|
|
|
|
if (frame.localName == 'tab') {
|
|
|
|
|
frame = frame.linkedBrowser.contentWindow;
|
|
|
|
|
}
|
|
|
|
|
else if (frame.localName == 'browser') {
|
|
|
|
|
frame = frame.contentWindow;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2007-11-17 08:32:41 -05:00
|
|
|
|
frame = this.getTabBrowserFromChild(frame);
|
2007-10-21 04:16:10 -04:00
|
|
|
|
if (!frame) return null;
|
|
|
|
|
frame = frame.contentWindow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!frame)
|
|
|
|
|
frame = this.browser.contentWindow;
|
|
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
|
},
|
2007-10-21 11:02:58 -04:00
|
|
|
|
|
2007-11-17 07:50:36 -05:00
|
|
|
|
makeNewId : function()
|
|
|
|
|
{
|
|
|
|
|
return 'tab-<'+Date.now()+'-'+parseInt(Math.random() * 65000)+'>';
|
|
|
|
|
},
|
2007-11-17 07:59:48 -05:00
|
|
|
|
|
2007-10-22 05:59:43 -04:00
|
|
|
|
makeURIFromSpec : function(aURI)
|
|
|
|
|
{
|
|
|
|
|
var newURI;
|
|
|
|
|
aURI = aURI || '';
|
|
|
|
|
if (aURI && String(aURI).indexOf('file:') == 0) {
|
|
|
|
|
var fileHandler = this.IOService.getProtocolHandler('file').QueryInterface(Components.interfaces.nsIFileProtocolHandler);
|
|
|
|
|
var tempLocalFile = fileHandler.getFileFromURLSpec(aURI);
|
|
|
|
|
newURI = this.IOService.newFileURI(tempLocalFile);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
newURI = this.IOService.newURI(aURI, null, null);
|
|
|
|
|
}
|
|
|
|
|
return newURI;
|
|
|
|
|
},
|
2007-11-12 11:31:00 -05:00
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
toggleAutoHide : function()
|
2007-11-12 11:31:00 -05:00
|
|
|
|
{
|
2008-06-17 02:22:49 -04:00
|
|
|
|
this.setTreePref('tabbar.autoHide.mode',
|
|
|
|
|
this.getTreePref('tabbar.autoHide.mode') == this.kAUTOHIDE_MODE_DISABLED ?
|
|
|
|
|
this.getTreePref('tabbar.autoHide.mode.toggle') :
|
|
|
|
|
this.kAUTOHIDE_MODE_DISABLED
|
|
|
|
|
);
|
2007-11-12 11:31:00 -05:00
|
|
|
|
},
|
2007-11-17 07:59:48 -05:00
|
|
|
|
|
2008-02-22 12:55:35 -05:00
|
|
|
|
toggleFixed : function()
|
|
|
|
|
{
|
|
|
|
|
this.setTreePref('tabbar.fixed',
|
|
|
|
|
!this.getTreePref('tabbar.fixed'));
|
|
|
|
|
},
|
2008-02-26 12:02:59 -05:00
|
|
|
|
|
|
|
|
|
changeTabbarPosition : function(aNewPosition)
|
|
|
|
|
{
|
|
|
|
|
if (!aNewPosition || !/^(top|bottom|left|right)$/i.test(aNewPosition))
|
|
|
|
|
aNewPosition = 'top';
|
|
|
|
|
|
|
|
|
|
aNewPosition = aNewPosition.toLowerCase();
|
|
|
|
|
this.setTreePref('tabbar.position', aNewPosition);
|
|
|
|
|
|
|
|
|
|
if (!this.getTreePref('tabbar.syncRelatedPrefsForDynamicPosition')) return;
|
|
|
|
|
|
|
|
|
|
var vertical = (aNewPosition == 'left' || aNewPosition == 'right');
|
|
|
|
|
this.setTreePref('enableSubtreeIndent', vertical);
|
|
|
|
|
this.setTreePref('allowSubtreeCollapseExpand', vertical);
|
|
|
|
|
},
|
2008-02-28 02:45:39 -05:00
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
/* get tab(s) */
|
2008-02-22 12:55:35 -05:00
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
getTabById : function(aId, aTabBrowserChildren)
|
|
|
|
|
{
|
|
|
|
|
if (!aId) return null;
|
2007-11-17 08:32:41 -05:00
|
|
|
|
var b = aTabBrowserChildren ? this.getTabBrowserFromChild(aTabBrowserChildren) : null ;
|
2007-11-17 07:59:48 -05:00
|
|
|
|
if (!b) b = this.browser;
|
|
|
|
|
return this.evaluateXPath(
|
|
|
|
|
'descendant::xul:tab[@'+this.kID+' = "'+aId+'"]',
|
|
|
|
|
b.mTabContainer,
|
|
|
|
|
XPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
|
).singleNodeValue;
|
|
|
|
|
},
|
2008-02-22 12:55:35 -05:00
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
getNextVisibleTab : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
var xpathResult = this.evaluateXPath(
|
|
|
|
|
'following-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")]',
|
|
|
|
|
aTab
|
|
|
|
|
);
|
|
|
|
|
return xpathResult.snapshotItem(0);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getPreviousVisibleTab : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
var xpathResult = this.evaluateXPath(
|
|
|
|
|
'preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")]',
|
|
|
|
|
aTab
|
|
|
|
|
);
|
|
|
|
|
return xpathResult.snapshotItem(xpathResult.snapshotLength-1);
|
|
|
|
|
},
|
2007-11-26 17:43:50 -05:00
|
|
|
|
|
2008-02-22 01:58:50 -05:00
|
|
|
|
getLastVisibleTab : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
var xpathResult = this.evaluateXPath(
|
|
|
|
|
'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")]',
|
|
|
|
|
aTab.parentNode
|
|
|
|
|
);
|
|
|
|
|
return xpathResult.snapshotItem(xpathResult.snapshotLength-1);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getVisibleTabs : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
var xpathResult = this.evaluateXPath(
|
|
|
|
|
'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")]',
|
|
|
|
|
aTab.parentNode
|
|
|
|
|
);
|
|
|
|
|
return xpathResult;
|
|
|
|
|
},
|
|
|
|
|
|
2007-11-26 17:43:50 -05:00
|
|
|
|
getVisibleIndex : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
return this.evaluateXPath(
|
|
|
|
|
'preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")]',
|
|
|
|
|
aTab
|
|
|
|
|
).snapshotLength;
|
|
|
|
|
},
|
2008-03-09 01:36:52 -05:00
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
/* tree manipulations */
|
2008-02-22 12:55:35 -05:00
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
get rootTabs()
|
|
|
|
|
{
|
|
|
|
|
return this.getArrayFromXPathResult(
|
|
|
|
|
this.evaluateXPath(
|
|
|
|
|
'child::xul:tab[not(@'+this.kNEST+') or @'+this.kNEST+'="0" or @'+this.kNEST+'=""]',
|
|
|
|
|
this.browser.mTabContainer
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getParentTab : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
var id = aTab.getAttribute(this.kID);
|
|
|
|
|
if (!id) return null; // not initialized yet
|
|
|
|
|
return this.evaluateXPath(
|
2008-02-22 16:09:09 -05:00
|
|
|
|
'parent::*/child::xul:tab[contains(concat("|", @'+this.kCHILDREN+', "|"), "|'+id+'|")]',
|
2007-11-17 07:59:48 -05:00
|
|
|
|
aTab,
|
|
|
|
|
XPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
|
).singleNodeValue;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getRootTab : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
var parent = aTab;
|
|
|
|
|
var root = aTab;
|
|
|
|
|
while (parent = this.getParentTab(parent))
|
|
|
|
|
{
|
|
|
|
|
root = parent;
|
|
|
|
|
}
|
|
|
|
|
return root;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getNextSiblingTab : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
|
|
|
|
|
var parentTab = this.getParentTab(aTab);
|
|
|
|
|
|
|
|
|
|
if (!parentTab) {
|
|
|
|
|
var next = aTab;
|
|
|
|
|
do {
|
|
|
|
|
next = next.nextSibling;
|
|
|
|
|
}
|
|
|
|
|
while (next && this.getParentTab(next));
|
|
|
|
|
return next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var children = parentTab.getAttribute(this.kCHILDREN);
|
|
|
|
|
if (children) {
|
|
|
|
|
var list = ('|'+children).split('|'+aTab.getAttribute(this.kID))[1].split('|');
|
|
|
|
|
for (var i = 0, maxi = list.length; i < maxi; i++)
|
|
|
|
|
{
|
|
|
|
|
var firstChild = this.getTabById(list[i], aTab);
|
|
|
|
|
if (firstChild) return firstChild;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getPreviousSiblingTab : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
|
|
|
|
|
var parentTab = this.getParentTab(aTab);
|
|
|
|
|
|
|
|
|
|
if (!parentTab) {
|
|
|
|
|
var prev = aTab;
|
|
|
|
|
do {
|
|
|
|
|
prev = prev.previousSibling;
|
|
|
|
|
}
|
|
|
|
|
while (prev && this.getParentTab(prev));
|
|
|
|
|
return prev;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var children = parentTab.getAttribute(this.kCHILDREN);
|
|
|
|
|
if (children) {
|
|
|
|
|
var list = ('|'+children).split('|'+aTab.getAttribute(this.kID))[0].split('|');
|
|
|
|
|
for (var i = list.length-1; i > -1; i--)
|
|
|
|
|
{
|
|
|
|
|
var lastChild = this.getTabById(list[i], aTab);
|
|
|
|
|
if (lastChild) return lastChild;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getChildTabs : function(aTab, aAllTabsArray)
|
|
|
|
|
{
|
|
|
|
|
var tabs = [];
|
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
|
|
|
|
|
var children = aTab.getAttribute(this.kCHILDREN);
|
|
|
|
|
if (!children) return tabs;
|
|
|
|
|
|
|
|
|
|
if (aAllTabsArray) tabs = aAllTabsArray;
|
|
|
|
|
|
|
|
|
|
var list = children.split('|');
|
|
|
|
|
var tab;
|
|
|
|
|
for (var i = 0, maxi = list.length; i < maxi; i++)
|
|
|
|
|
{
|
|
|
|
|
tab = this.getTabById(list[i], aTab);
|
|
|
|
|
if (!tab) continue;
|
|
|
|
|
tabs.push(tab);
|
|
|
|
|
if (aAllTabsArray)
|
|
|
|
|
this.getChildTabs(tab, tabs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tabs;
|
|
|
|
|
},
|
|
|
|
|
|
2008-04-29 14:17:44 -04:00
|
|
|
|
hasChildTabs : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
if (!aTab) return false;
|
|
|
|
|
return aTab.hasAttribute(this.kCHILDREN);
|
|
|
|
|
},
|
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
getDescendantTabs : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
var tabs = [];
|
|
|
|
|
this.getChildTabs(aTab, tabs);
|
|
|
|
|
return tabs;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getFirstChildTab : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
|
|
|
|
|
var children = aTab.getAttribute(this.kCHILDREN);
|
|
|
|
|
var firstChild = null;
|
|
|
|
|
if (children) {
|
|
|
|
|
var list = children.split('|');
|
|
|
|
|
for (var i = 0, maxi = list.length; i < maxi; i++)
|
|
|
|
|
{
|
|
|
|
|
firstChild = this.getTabById(list[i], aTab);
|
|
|
|
|
if (firstChild) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return firstChild;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getLastChildTab : function(aTab)
|
|
|
|
|
{
|
|
|
|
|
if (!aTab) return null;
|
|
|
|
|
|
|
|
|
|
var children = aTab.getAttribute(this.kCHILDREN);
|
|
|
|
|
var lastChild = null;
|
|
|
|
|
if (children) {
|
|
|
|
|
var list = children.split('|');
|
|
|
|
|
for (var i = list.length-1; i > -1; i--)
|
|
|
|
|
{
|
|
|
|
|
lastChild = this.getTabById(list[i], aTab);
|
|
|
|
|
if (lastChild) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return lastChild;
|
|
|
|
|
},
|
2007-11-26 17:43:50 -05:00
|
|
|
|
|
|
|
|
|
getChildIndex : function(aTab, aParent)
|
|
|
|
|
{
|
|
|
|
|
var parent = this.getParentTab(aTab);
|
2007-11-26 18:51:26 -05:00
|
|
|
|
if (!aParent || !parent || aParent != parent) {
|
2007-11-26 18:00:30 -05:00
|
|
|
|
parent = aTab;
|
2007-11-26 17:43:50 -05:00
|
|
|
|
while (parent && parent != aParent)
|
|
|
|
|
{
|
|
|
|
|
aTab = parent;
|
|
|
|
|
parent = this.getParentTab(parent);
|
|
|
|
|
}
|
|
|
|
|
if (parent != aParent)
|
|
|
|
|
return -1;
|
|
|
|
|
aParent = parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (aParent) {
|
|
|
|
|
var children = aParent.getAttribute(this.kCHILDREN);
|
|
|
|
|
var list = children.split('|');
|
|
|
|
|
var id = aTab.getAttribute(this.kID);
|
|
|
|
|
for (var i = 0, maxi = list.length; i < maxi; i++)
|
|
|
|
|
{
|
|
|
|
|
if (list[i] == id) return i;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
var tabs = this.rootTabs;
|
|
|
|
|
for (var i = 0, maxi = tabs.length; i < maxi; i++)
|
|
|
|
|
{
|
|
|
|
|
if (tabs[i] == aTab) return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2007-11-14 14:34:36 -05:00
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
/* Session Store API */
|
|
|
|
|
|
|
|
|
|
getTabValue : function(aTab, aKey)
|
|
|
|
|
{
|
|
|
|
|
var value = null;
|
|
|
|
|
try {
|
|
|
|
|
value = this.SessionStore.getTabValue(aTab, aKey);
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-20 01:57:38 -04:00
|
|
|
|
if (this.useTMPSessionAPI) {
|
|
|
|
|
var TMPValue = aTab.getAttribute(this.kTMP_SESSION_DATA_PREFIX+aKey);
|
|
|
|
|
if (TMPValue) value = TMPValue;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
return value;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setTabValue : function(aTab, aKey, aValue)
|
|
|
|
|
{
|
2008-06-20 01:57:38 -04:00
|
|
|
|
if (!aValue) return this.deleteTabValue(aTab, aKey);
|
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
aTab.setAttribute(aKey, aValue);
|
|
|
|
|
try {
|
|
|
|
|
this.SessionStore.setTabValue(aTab, aKey, aValue);
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
}
|
2008-06-20 01:57:38 -04:00
|
|
|
|
|
|
|
|
|
if (this.useTMPSessionAPI)
|
|
|
|
|
aTab.setAttribute(this.kTMP_SESSION_DATA_PREFIX+aKey, aValue);
|
|
|
|
|
|
2007-11-17 07:59:48 -05:00
|
|
|
|
return aValue;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
deleteTabValue : function(aTab, aKey)
|
|
|
|
|
{
|
|
|
|
|
aTab.removeAttribute(aKey);
|
|
|
|
|
try {
|
|
|
|
|
this.SessionStore.deleteTabValue(aTab, aKey);
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
}
|
2008-06-20 01:57:38 -04:00
|
|
|
|
|
|
|
|
|
if (this.useTMPSessionAPI)
|
|
|
|
|
aTab.removeAttribute(this.kTMP_SESSION_DATA_PREFIX+aKey);
|
2007-11-17 07:59:48 -05:00
|
|
|
|
},
|
2008-06-20 01:57:38 -04:00
|
|
|
|
|
2008-09-26 10:13:29 -04:00
|
|
|
|
useTMPSessionAPI : false,
|
2008-06-20 01:57:38 -04:00
|
|
|
|
kTMP_SESSION_DATA_PREFIX : 'tmp-session-data-',
|
2007-11-17 07:59:48 -05:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
/* Initializing */
|
2008-09-26 10:13:29 -04:00
|
|
|
|
|
2008-02-25 20:14:12 -05:00
|
|
|
|
preInit : function()
|
|
|
|
|
{
|
2008-10-14 00:57:35 -04:00
|
|
|
|
if (this.preInitialized) return;
|
|
|
|
|
this.preInitialized = true;
|
|
|
|
|
|
2008-02-26 11:24:25 -05:00
|
|
|
|
window.removeEventListener('DOMContentLoaded', this, true);
|
2008-02-25 20:14:12 -05:00
|
|
|
|
if (!document.getElementById('content')) return;
|
|
|
|
|
|
|
|
|
|
this.overrideExtensionsPreInit(); // hacks.js
|
|
|
|
|
},
|
2008-10-14 00:57:35 -04:00
|
|
|
|
preInitialized : false,
|
2008-03-08 03:57:17 -05:00
|
|
|
|
|
|
|
|
|
init : function()
|
2007-10-16 13:22:28 -04:00
|
|
|
|
{
|
|
|
|
|
if (!('gBrowser' in window)) return;
|
|
|
|
|
|
2008-10-14 00:57:35 -04:00
|
|
|
|
if (this.initialized) return;
|
|
|
|
|
this.initialized = true;
|
|
|
|
|
|
|
|
|
|
if (!this.preInitialized) {
|
|
|
|
|
this.preInit();
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
window.removeEventListener('load', this, false);
|
2008-02-22 00:01:35 -05:00
|
|
|
|
window.addEventListener('unload', this, false);
|
2007-10-22 05:59:43 -04:00
|
|
|
|
document.getElementById('contentAreaContextMenu').addEventListener('popupshowing', this, false);
|
|
|
|
|
|
2007-11-14 10:09:47 -05:00
|
|
|
|
var appcontent = document.getElementById('appcontent');
|
|
|
|
|
appcontent.addEventListener('SubBrowserAdded', this, false);
|
|
|
|
|
appcontent.addEventListener('SubBrowserRemoveRequest', this, false);
|
2007-10-17 09:25:50 -04:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
this.addPrefListener(this);
|
|
|
|
|
|
2008-02-25 20:14:12 -05:00
|
|
|
|
this.overrideExtensionsOnInitBefore(); // hacks.js
|
2007-10-21 11:02:58 -04:00
|
|
|
|
this.overrideGlobalFunctions();
|
2007-10-16 13:22:28 -04:00
|
|
|
|
this.initTabBrowser(gBrowser);
|
2008-02-25 20:14:12 -05:00
|
|
|
|
this.overrideExtensionsOnInitAfter(); // hacks.js
|
2008-03-03 03:26:51 -05:00
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.levelMargin');
|
2008-06-17 02:22:49 -04:00
|
|
|
|
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.tabbar.autoHide.mode');
|
2008-03-03 03:26:51 -05:00
|
|
|
|
this.observe(null, 'nsPref:changed', 'browser.link.open_newwindow.restriction.override');
|
|
|
|
|
this.observe(null, 'nsPref:changed', 'browser.tabs.loadFolderAndReplace.override');
|
2007-10-16 13:22:28 -04:00
|
|
|
|
},
|
2008-10-14 00:57:35 -04:00
|
|
|
|
initialized : false,
|
2007-10-23 04:19:32 -04:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
initTabBrowser : function(aTabBrowser)
|
|
|
|
|
{
|
2007-11-14 14:34:36 -05:00
|
|
|
|
if (aTabBrowser.localName != 'tabbrowser') return;
|
|
|
|
|
aTabBrowser.treeStyleTab = new TreeStyleTabBrowser(aTabBrowser);
|
|
|
|
|
aTabBrowser.treeStyleTab.init();
|
2007-10-16 13:22:28 -04:00
|
|
|
|
},
|
2007-10-19 01:27:06 -04:00
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
updateTabDNDObserver : function(aObserver)
|
2007-11-14 07:31:14 -05:00
|
|
|
|
{
|
2008-10-01 21:32:31 -04:00
|
|
|
|
var canDropFunctionName = '_setEffectAllowedForDataTransfer' in aObserver ?
|
|
|
|
|
'_setEffectAllowedForDataTransfer' : // Firefox 3.1 or later
|
|
|
|
|
'canDrop' ; // Firefox 3.0.x
|
|
|
|
|
eval('aObserver.'+canDropFunctionName+' = '+
|
|
|
|
|
aObserver[canDropFunctionName].toSource().replace(
|
2007-11-14 10:09:47 -05:00
|
|
|
|
'{',
|
|
|
|
|
'{ var TSTTabBrowser = this;'
|
|
|
|
|
).replace(
|
2007-11-17 08:32:41 -05:00
|
|
|
|
/\.screenX/g, '[TreeStyleTabService.getTabBrowserFromChild(TSTTabBrowser).treeStyleTab.positionProp]'
|
2007-11-14 07:31:14 -05:00
|
|
|
|
).replace(
|
2007-11-17 08:32:41 -05:00
|
|
|
|
/\.width/g, '[TreeStyleTabService.getTabBrowserFromChild(TSTTabBrowser).treeStyleTab.sizeProp]'
|
2007-11-14 07:31:14 -05:00
|
|
|
|
).replace( // Tab Mix Plus
|
2007-11-17 08:32:41 -05:00
|
|
|
|
/\.screenY/g, '[TreeStyleTabService.getTabBrowserFromChild(TSTTabBrowser).treeStyleTab.invertedPositionProp]'
|
2007-11-14 07:31:14 -05:00
|
|
|
|
).replace( // Tab Mix Plus
|
2007-11-17 08:32:41 -05:00
|
|
|
|
/\.height/g, '[TreeStyleTabService.getTabBrowserFromChild(TSTTabBrowser).treeStyleTab.invertedSizeProp]'
|
2007-11-14 07:31:14 -05:00
|
|
|
|
).replace(
|
|
|
|
|
/(return true;)/,
|
|
|
|
|
<><![CDATA[
|
|
|
|
|
if (!(function(aSelf) {
|
|
|
|
|
try{
|
|
|
|
|
if (!aDragSession.sourceNode ||
|
|
|
|
|
aDragSession.sourceNode.parentNode != aSelf.mTabContainer ||
|
|
|
|
|
aEvent.target.localName != 'tab')
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (aEvent.target.getAttribute(TreeStyleTabService.kCOLLAPSED) == 'true')
|
|
|
|
|
return false;
|
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
var info = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, aDragSession);
|
2007-11-14 07:31:14 -05:00
|
|
|
|
return info.canDrop;
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
dump('TreeStyleTabService::canDrop\n'+e+'\n');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
})(TSTTabBrowser))
|
2008-10-01 21:32:31 -04:00
|
|
|
|
return TST_DRAGDROP_DISALLOW_RETRUN_VALUE;
|
2007-11-14 07:31:14 -05:00
|
|
|
|
$1
|
|
|
|
|
]]></>
|
2008-10-01 21:32:31 -04:00
|
|
|
|
).replace(
|
|
|
|
|
/TST_DRAGDROP_DISALLOW_RETRUN_VALUE/g,
|
|
|
|
|
(canDropFunctionName == 'canDrop' ?
|
|
|
|
|
'false' :
|
|
|
|
|
'dt.effectAllowed = "none"'
|
|
|
|
|
)
|
2007-11-14 07:31:14 -05:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2008-10-01 21:32:31 -04:00
|
|
|
|
var dragOverFunctionName = '_onDragOver' in aObserver ?
|
|
|
|
|
'_onDragOver' : // Firefox 3.1 or later
|
|
|
|
|
'onDragOver' ; // Firefox 3.0.x
|
|
|
|
|
eval('aObserver.'+dragOverFunctionName+' = '+
|
|
|
|
|
aObserver[dragOverFunctionName].toSource().replace(
|
2007-11-14 07:31:14 -05:00
|
|
|
|
'{',
|
|
|
|
|
<><![CDATA[
|
|
|
|
|
{
|
|
|
|
|
var TSTTabBrowser = this;
|
|
|
|
|
if ((function(aSelf) {
|
|
|
|
|
try{
|
2008-10-01 21:32:31 -04:00
|
|
|
|
var info = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION);
|
2007-11-14 07:31:14 -05:00
|
|
|
|
|
|
|
|
|
if (!info.target || info.target != TreeStyleTabService.evaluateXPath(
|
|
|
|
|
'child::xul:tab[@'+TreeStyleTabService.kDROP_POSITION+']',
|
|
|
|
|
aSelf.mTabContainer,
|
|
|
|
|
XPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
|
).singleNodeValue)
|
2007-11-14 14:34:36 -05:00
|
|
|
|
TSTTabBrowser.treeStyleTab.clearDropPosition();
|
2007-11-14 07:31:14 -05:00
|
|
|
|
|
2008-10-01 21:32:31 -04:00
|
|
|
|
if (TST_DRAGDROP_DISALLOW_CHECK) return true;
|
2007-11-14 07:31:14 -05:00
|
|
|
|
|
|
|
|
|
info.target.setAttribute(
|
|
|
|
|
TreeStyleTabService.kDROP_POSITION,
|
|
|
|
|
info.position == TreeStyleTabService.kDROP_BEFORE ? 'before' :
|
|
|
|
|
info.position == TreeStyleTabService.kDROP_AFTER ? 'after' :
|
|
|
|
|
'self'
|
|
|
|
|
);
|
|
|
|
|
aSelf.mTabDropIndicatorBar.setAttribute('dragging', (info.position == TreeStyleTabService.kDROP_ON) ? 'false' : 'true' );
|
|
|
|
|
return (info.position == TreeStyleTabService.kDROP_ON || aSelf.getAttribute(TreeStyleTabService.kTABBAR_POSITION) != 'top')
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
dump('TreeStyleTabService::onDragOver\n'+e+'\n');
|
|
|
|
|
}
|
|
|
|
|
})(TSTTabBrowser)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
]]></>
|
2008-10-01 21:32:31 -04:00
|
|
|
|
).replace(
|
|
|
|
|
/TST_DRAGSESSION/g,
|
|
|
|
|
(canDropFunctionName == 'canDrop' ?
|
|
|
|
|
'aDragSession' :
|
|
|
|
|
'null'
|
|
|
|
|
)
|
|
|
|
|
).replace(
|
|
|
|
|
/TST_DRAGDROP_DISALLOW_CHECK/g,
|
|
|
|
|
(canDropFunctionName == 'canDrop' ?
|
|
|
|
|
'!aSelf.canDrop(aEvent, aDragSession)' :
|
|
|
|
|
'aSelf._setEffectAllowedForDataTransfer == "none"'
|
|
|
|
|
)
|
2007-11-14 07:31:14 -05:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2008-10-01 21:32:31 -04:00
|
|
|
|
var dragExitFunctionName = '_onDragLeave' in aObserver ?
|
|
|
|
|
'_onDragLeave' : // Firefox 3.1 or later
|
|
|
|
|
'onDragExit' ; // Firefox 3.0.x
|
|
|
|
|
eval('aObserver.'+dragExitFunctionName+' = '+
|
|
|
|
|
aObserver[dragExitFunctionName].toSource().replace(
|
2007-11-14 07:31:14 -05:00
|
|
|
|
/(this.mTabDropIndicatorBar\.[^;]+;)/,
|
2007-11-14 14:34:36 -05:00
|
|
|
|
'$1; this.treeStyleTab.clearDropPosition();'
|
2007-11-14 07:31:14 -05:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2008-10-01 21:32:31 -04:00
|
|
|
|
var dropFunctionName = '_onDrop' in aObserver ?
|
|
|
|
|
'_onDrop' : // Firefox 3.1 or later
|
|
|
|
|
'onDrop' ; // Firefox 3.0.x
|
|
|
|
|
eval('aObserver.'+dropFunctionName+' = '+
|
|
|
|
|
aObserver[dropFunctionName].toSource().replace(
|
2007-11-14 07:31:14 -05:00
|
|
|
|
'{',
|
|
|
|
|
<><![CDATA[
|
|
|
|
|
{
|
|
|
|
|
var TSTTabBrowser = this;
|
2007-11-14 14:34:36 -05:00
|
|
|
|
TSTTabBrowser.treeStyleTab.clearDropPosition();
|
2008-10-01 21:32:31 -04:00
|
|
|
|
var dropActionInfo = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION);
|
2007-11-14 07:31:14 -05:00
|
|
|
|
]]></>
|
2008-02-22 15:59:55 -05:00
|
|
|
|
).replace( // Firefox 2
|
2007-11-14 07:31:14 -05:00
|
|
|
|
/(if \(aDragSession[^\)]+\) \{)/,
|
2008-02-22 15:59:55 -05:00
|
|
|
|
<><![CDATA[$1
|
2008-10-01 21:32:31 -04:00
|
|
|
|
if (TSTTabBrowser.treeStyleTab.processDropAction(dropActionInfo, TST_DRAGSESSION.sourceNode))
|
2007-11-14 07:31:14 -05:00
|
|
|
|
return;
|
|
|
|
|
]]></>
|
2008-10-01 21:32:31 -04:00
|
|
|
|
).replace( // Firefox 3.0.x, 3.1 or later
|
|
|
|
|
/(if \((accelKeyPressed|isCopy|dropEffect == "copy")\) {)/,
|
2008-02-22 15:59:55 -05:00
|
|
|
|
<><![CDATA[
|
2008-02-22 18:31:22 -05:00
|
|
|
|
if (TSTTabBrowser.treeStyleTab.processDropAction(dropActionInfo, draggedTab))
|
2008-02-22 15:59:55 -05:00
|
|
|
|
return;
|
2008-09-26 10:26:17 -04:00
|
|
|
|
$1]]></>
|
2008-02-22 15:59:55 -05:00
|
|
|
|
).replace( // Firefox 3, duplication of tab
|
|
|
|
|
/(this.selectedTab = newTab;(\s*\})?)/g,
|
|
|
|
|
<><![CDATA[$1;
|
|
|
|
|
if (dropActionInfo.position == TreeStyleTabService.kDROP_ON)
|
|
|
|
|
TSTTabBrowser.treeStyleTab.attachTabTo(newTab, dropActionInfo.target);
|
|
|
|
|
]]></>
|
2008-02-24 03:11:17 -05:00
|
|
|
|
).replace( // Firefox 3, dragging tab from another window
|
|
|
|
|
'else if (draggedTab) {',
|
|
|
|
|
<><![CDATA[$&
|
|
|
|
|
if (TSTTabBrowser.treeStyleTab.processDropAction(dropActionInfo, draggedTab))
|
|
|
|
|
return;
|
|
|
|
|
]]></>
|
2007-11-14 07:31:14 -05:00
|
|
|
|
).replace(
|
|
|
|
|
/(this.loadOneTab\([^;]+\));/,
|
|
|
|
|
<><![CDATA[
|
2007-11-14 14:34:36 -05:00
|
|
|
|
TSTTabBrowser.treeStyleTab.processDropAction(dropActionInfo, $1);
|
2007-11-14 07:31:14 -05:00
|
|
|
|
return;
|
|
|
|
|
]]></>
|
|
|
|
|
).replace(
|
|
|
|
|
'document.getBindingParent(aEvent.originalTarget).localName != "tab"',
|
|
|
|
|
'!TreeStyleTabService.getTabFromEvent(aEvent)'
|
|
|
|
|
).replace(
|
|
|
|
|
'var tab = aEvent.target;',
|
|
|
|
|
<><![CDATA[
|
|
|
|
|
var tab = aEvent.target;
|
|
|
|
|
if (
|
|
|
|
|
tab.getAttribute('locked') == 'true' || // Tab Mix Plus
|
|
|
|
|
TreeStyleTabService.getTreePref('loadDroppedLinkToNewChildTab') ||
|
|
|
|
|
dropActionInfo.position != TreeStyleTabService.kDROP_ON
|
|
|
|
|
) {
|
2007-11-14 14:34:36 -05:00
|
|
|
|
TSTTabBrowser.treeStyleTab.processDropAction(dropActionInfo, TSTTabBrowser.loadOneTab(getShortcutOrURI(url), null, null, null, bgLoad, false));
|
2007-11-14 07:31:14 -05:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
]]></>
|
2008-10-01 21:32:31 -04:00
|
|
|
|
).replace(
|
|
|
|
|
/TST_DRAGSESSION/g,
|
|
|
|
|
(canDropFunctionName == 'canDrop' ?
|
|
|
|
|
'aDragSession' :
|
|
|
|
|
'TSTTabBrowser.treeStyleTab.getCurrentDragSession()'
|
|
|
|
|
)
|
2007-11-14 07:31:14 -05:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2007-10-21 11:02:58 -04:00
|
|
|
|
overrideGlobalFunctions : function()
|
|
|
|
|
{
|
2008-09-26 10:13:29 -04:00
|
|
|
|
// window.__treestyletab__BrowserCustomizeToolbar = window.BrowserCustomizeToolbar;
|
|
|
|
|
// window.BrowserCustomizeToolbar = function() {
|
|
|
|
|
// TreeStyleTabService.destroyBar();
|
|
|
|
|
// window.__treestyletab__BrowserCustomizeToolbar.call(window);
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
var toolbox = document.getElementById('browser-toolbox') || // Firefox 3
|
|
|
|
|
document.getElementById('navigator-toolbox'); // Firefox 2
|
|
|
|
|
if (toolbox.customizeDone) {
|
|
|
|
|
toolbox.__treestyletab__customizeDone = toolbox.customizeDone;
|
|
|
|
|
toolbox.customizeDone = function(aChanged) {
|
|
|
|
|
this.__treestyletab__customizeDone(aChanged);
|
|
|
|
|
TreeStyleTabService.initBar();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if ('BrowserToolboxCustomizeDone' in window) {
|
|
|
|
|
window.__treestyletab__BrowserToolboxCustomizeDone = window.BrowserToolboxCustomizeDone;
|
|
|
|
|
window.BrowserToolboxCustomizeDone = function(aChanged) {
|
|
|
|
|
window.__treestyletab__BrowserToolboxCustomizeDone.apply(window, arguments);
|
|
|
|
|
TreeStyleTabService.initBar();
|
|
|
|
|
};
|
|
|
|
|
}
|
2008-10-14 12:40:05 -04:00
|
|
|
|
this.initBar();
|
2008-09-26 10:13:29 -04:00
|
|
|
|
|
2007-10-21 11:50:11 -04:00
|
|
|
|
var funcs;
|
2008-02-21 22:05:52 -05:00
|
|
|
|
var func;
|
2008-02-26 08:21:07 -05:00
|
|
|
|
var overwriteProcess;
|
|
|
|
|
|
|
|
|
|
overwriteProcess = function(aName) {
|
|
|
|
|
var overwroteFunc;
|
|
|
|
|
eval('overwroteFunc = '+aName);
|
2008-09-26 10:13:29 -04:00
|
|
|
|
if (
|
|
|
|
|
!overwroteFunc ||
|
|
|
|
|
overwroteFunc.toSource().indexOf('function BrowserLoadURL') != 0
|
2008-02-26 08:21:07 -05:00
|
|
|
|
)
|
2008-09-26 10:13:29 -04:00
|
|
|
|
return;
|
|
|
|
|
eval(aName + ' = ' + overwroteFunc.toSource().replace(
|
|
|
|
|
'aTriggeringEvent && aTriggeringEvent.altKey',
|
|
|
|
|
'TreeStyleTabService.checkReadyToOpenNewTabOnLocationBar(url, $&)'
|
|
|
|
|
));
|
2008-02-26 08:21:07 -05:00
|
|
|
|
};
|
|
|
|
|
overwriteProcess('window.BrowserLoadURL');
|
|
|
|
|
if ('permaTabs' in window &&
|
|
|
|
|
'window.BrowserLoadURL' in permaTabs.utils.wrappedFunctions)
|
|
|
|
|
overwriteProcess('permaTabs.utils.wrappedFunctions["window.BrowserLoadURL"]');
|
2007-10-21 11:50:11 -04:00
|
|
|
|
|
2007-10-26 07:24:59 -04:00
|
|
|
|
|
2007-10-21 11:02:58 -04:00
|
|
|
|
eval('nsContextMenu.prototype.openLinkInTab = '+
|
|
|
|
|
nsContextMenu.prototype.openLinkInTab.toSource().replace(
|
|
|
|
|
'{',
|
2008-02-26 20:26:38 -05:00
|
|
|
|
<><![CDATA[$&
|
|
|
|
|
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
|
2007-10-21 11:02:58 -04:00
|
|
|
|
]]></>
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
eval('nsContextMenu.prototype.openFrameInTab = '+
|
|
|
|
|
nsContextMenu.prototype.openFrameInTab.toSource().replace(
|
|
|
|
|
'{',
|
2008-02-26 20:26:38 -05:00
|
|
|
|
<><![CDATA[$&
|
|
|
|
|
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
|
2007-10-21 11:02:58 -04:00
|
|
|
|
]]></>
|
|
|
|
|
)
|
|
|
|
|
);
|
2007-10-22 18:45:35 -04:00
|
|
|
|
eval('nsContextMenu.prototype.viewImage = '+
|
|
|
|
|
nsContextMenu.prototype.viewImage.toSource().replace(
|
|
|
|
|
'openUILink(',
|
|
|
|
|
<><![CDATA[
|
|
|
|
|
if (String(whereToOpenLink(e, false, true)).indexOf('tab') == 0)
|
|
|
|
|
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
|
2008-02-26 20:26:38 -05:00
|
|
|
|
$&]]></>
|
2007-10-22 18:45:35 -04:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
eval('nsContextMenu.prototype.viewBGImage = '+
|
|
|
|
|
nsContextMenu.prototype.viewBGImage.toSource().replace(
|
|
|
|
|
'openUILink(',
|
|
|
|
|
<><![CDATA[
|
|
|
|
|
if (String(whereToOpenLink(e, false, true)).indexOf('tab') == 0)
|
|
|
|
|
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
|
2008-02-26 20:26:38 -05:00
|
|
|
|
$&]]></>
|
2007-10-22 18:45:35 -04:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
eval('nsContextMenu.prototype.addDictionaries = '+
|
|
|
|
|
nsContextMenu.prototype.addDictionaries.toSource().replace(
|
|
|
|
|
'openUILinkIn(',
|
|
|
|
|
<><![CDATA[
|
|
|
|
|
if (where.indexOf('tab') == 0)
|
|
|
|
|
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
|
2008-02-26 20:26:38 -05:00
|
|
|
|
$&]]></>
|
2007-10-22 18:45:35 -04:00
|
|
|
|
)
|
|
|
|
|
);
|
2007-10-21 11:02:58 -04:00
|
|
|
|
|
2008-02-25 20:14:12 -05:00
|
|
|
|
funcs = 'handleLinkClick __splitbrowser__handleLinkClick __ctxextensions__handleLinkClick __treestyletab__highlander__origHandleLinkClick'.split(' ');
|
2007-10-21 11:50:11 -04:00
|
|
|
|
for (var i in funcs)
|
|
|
|
|
{
|
2007-10-28 12:07:10 -04:00
|
|
|
|
if (funcs[i] in window && /^function handleLinkClick/.test(window[funcs[i]].toString()))
|
2007-10-21 11:50:11 -04:00
|
|
|
|
eval('window.'+funcs[i]+' = '+
|
|
|
|
|
window[funcs[i]].toSource().replace(
|
2008-02-26 20:26:38 -05:00
|
|
|
|
/(openNewTabWith\()/g,
|
2007-10-21 11:50:11 -04:00
|
|
|
|
<><![CDATA[
|
2007-10-29 10:14:45 -04:00
|
|
|
|
if (!TreeStyleTabService.checkToOpenChildTab(event.target.ownerDocument.defaultView)) TreeStyleTabService.readyToOpenChildTab(event.target.ownerDocument.defaultView);
|
2008-02-26 20:26:38 -05:00
|
|
|
|
$1]]></>
|
2007-10-28 12:07:10 -04:00
|
|
|
|
).replace(
|
|
|
|
|
/(event.ctrlKey|event.metaKey)/,
|
|
|
|
|
<><![CDATA[
|
2007-10-29 11:49:00 -04:00
|
|
|
|
TreeStyleTabService.checkReadyToOpenNewTab({
|
|
|
|
|
uri : href,
|
|
|
|
|
external : {
|
|
|
|
|
newTab : TreeStyleTabService.getTreePref('openOuterLinkInNewTab') || TreeStyleTabService.getTreePref('openAnyLinkInNewTab'),
|
|
|
|
|
forceChild : true
|
|
|
|
|
},
|
|
|
|
|
internal : {
|
|
|
|
|
newTab : TreeStyleTabService.getTreePref('openAnyLinkInNewTab')
|
|
|
|
|
},
|
|
|
|
|
modifier : $1,
|
|
|
|
|
invert : TreeStyleTabService.getTreePref('link.invertDefaultBehavior')
|
|
|
|
|
}) ? true : (TreeStyleTabService.readyToOpenChildTab(), false)
|
2007-10-29 10:01:25 -04:00
|
|
|
|
]]></>
|
|
|
|
|
).replace(
|
|
|
|
|
'return false;case 1:',
|
|
|
|
|
<><![CDATA[
|
2007-11-15 08:01:07 -05:00
|
|
|
|
if (!('TMP_contentAreaClick' in window) && // do nothing for Tab Mix Plus
|
2007-11-15 07:24:12 -05:00
|
|
|
|
TreeStyleTabService.checkToOpenChildTab()) {
|
2007-10-29 11:22:50 -04:00
|
|
|
|
TreeStyleTabService.stopToOpenChildTab();
|
2008-06-28 21:20:55 -04:00
|
|
|
|
if (linkNode)
|
|
|
|
|
urlSecurityCheck(href,
|
|
|
|
|
'nodePrincipal' in linkNode.ownerDocument ?
|
|
|
|
|
linkNode.ownerDocument.nodePrincipal :
|
|
|
|
|
linkNode.ownerDocument.location.href
|
|
|
|
|
);
|
2007-10-29 10:01:25 -04:00
|
|
|
|
var postData = {};
|
|
|
|
|
href = getShortcutOrURI(href, postData);
|
|
|
|
|
if (!href) return false;
|
|
|
|
|
loadURI(href, null, postData.value, false);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
case 1:
|
2007-10-28 12:07:10 -04:00
|
|
|
|
]]></>
|
2007-10-21 11:50:11 -04:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
2007-10-21 11:02:58 -04:00
|
|
|
|
|
2007-11-15 07:24:12 -05:00
|
|
|
|
funcs = 'contentAreaClick __contentAreaClick __ctxextensions__contentAreaClick'.split(' ');
|
2008-02-26 08:21:07 -05:00
|
|
|
|
overwriteProcess = function(aName) {
|
|
|
|
|
var overwroteFunc;
|
|
|
|
|
eval('overwroteFunc = '+aName);
|
2008-02-26 20:16:01 -05:00
|
|
|
|
if (overwroteFunc.toSource().indexOf('function contentAreaClick') != 0) return;
|
2008-02-26 08:21:07 -05:00
|
|
|
|
eval(aName + ' = '+
|
|
|
|
|
overwroteFunc.toSource().replace(
|
2008-09-27 11:26:20 -04:00
|
|
|
|
/((openWebPanel\([^\;]+\);|PlacesUIUtils.showMinimalAddBookmarkUI\([^;]+\);)event.preventDefault\(\);return false;\})/,
|
2008-02-26 08:21:07 -05:00
|
|
|
|
<><![CDATA[
|
|
|
|
|
$1
|
|
|
|
|
else if (!('TMP_contentAreaClick' in window) && // do nothing for Tab Mix Plus
|
|
|
|
|
TreeStyleTabService.checkReadyToOpenNewTab({
|
|
|
|
|
uri : wrapper.href,
|
|
|
|
|
external : {
|
|
|
|
|
newTab : TreeStyleTabService.getTreePref('openOuterLinkInNewTab') || TreeStyleTabService.getTreePref('openAnyLinkInNewTab'),
|
|
|
|
|
forceChild : true
|
|
|
|
|
},
|
|
|
|
|
internal : {
|
|
|
|
|
newTab : TreeStyleTabService.getTreePref('openAnyLinkInNewTab')
|
|
|
|
|
}
|
|
|
|
|
})) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
handleLinkClick(event, wrapper.href, linkNode);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
]]></>
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
};
|
2007-10-28 13:16:48 -04:00
|
|
|
|
for (var i in funcs)
|
|
|
|
|
{
|
2008-02-26 08:21:07 -05:00
|
|
|
|
if (funcs[i] in window && window[funcs[i]])
|
|
|
|
|
overwriteProcess('window.'+funcs[i]);
|
2007-10-28 13:16:48 -04:00
|
|
|
|
}
|
2008-02-26 08:21:07 -05:00
|
|
|
|
if ('permaTabs' in window &&
|
|
|
|
|
'window.contentAreaClick' in permaTabs.utils.wrappedFunctions)
|
|
|
|
|
overwriteProcess('permaTabs.utils.wrappedFunctions["window.contentAreaClick"]');
|
2007-10-28 13:16:48 -04:00
|
|
|
|
|
2007-10-21 11:50:11 -04:00
|
|
|
|
funcs = 'gotoHistoryIndex BrowserForward BrowserBack __rewindforward__BrowserForward __rewindforward__BrowserBack'.split(' ');
|
|
|
|
|
for (var i in funcs)
|
|
|
|
|
{
|
2007-10-28 12:07:10 -04:00
|
|
|
|
if (funcs[i] in window &&
|
|
|
|
|
/^function (gotoHistoryIndex|BrowserForward|BrowserBack)/.test(window[funcs[i]].toString()))
|
2007-10-21 11:50:11 -04:00
|
|
|
|
eval('window.'+funcs[i]+' = '+
|
|
|
|
|
window[funcs[i]].toSource().replace(
|
2008-02-26 20:26:38 -05:00
|
|
|
|
/(openUILinkIn\()/g,
|
2007-10-21 11:50:11 -04:00
|
|
|
|
<><![CDATA[
|
|
|
|
|
if (where == 'tab' || where == 'tabshifted')
|
|
|
|
|
TreeStyleTabService.readyToOpenChildTab();
|
2008-02-26 20:26:38 -05:00
|
|
|
|
$1]]></>
|
2007-10-21 11:50:11 -04:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
2007-10-21 11:02:58 -04:00
|
|
|
|
|
2008-02-21 22:05:52 -05:00
|
|
|
|
func = 'BrowserGoHome' in window ? 'BrowserGoHome' : 'BrowserHomeClick' ;
|
2008-02-26 08:21:07 -05:00
|
|
|
|
overwriteProcess = function(aName, aFunc) {
|
|
|
|
|
var overwroteFunc;
|
|
|
|
|
eval('overwroteFunc = '+aName);
|
2008-02-26 20:16:01 -05:00
|
|
|
|
if (overwroteFunc.toSource().indexOf('function '+func) != 0) return;
|
2008-02-26 08:21:07 -05:00
|
|
|
|
eval(aName + ' = '+
|
|
|
|
|
overwroteFunc.toSource().replace(
|
|
|
|
|
'gBrowser.loadTabs(',
|
|
|
|
|
<><![CDATA[
|
|
|
|
|
TreeStyleTabService.readyToOpenNewTabGroup(gBrowser);
|
2008-02-26 20:26:38 -05:00
|
|
|
|
$&]]></>
|
2008-02-26 08:21:07 -05:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
overwriteProcess('window.'+func);
|
|
|
|
|
if ('permaTabs' in window &&
|
|
|
|
|
'window.BrowserHomeClick' in permaTabs.utils.wrappedFunctions)
|
|
|
|
|
overwriteProcess('permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"]');
|
2007-10-22 18:45:35 -04:00
|
|
|
|
|
2007-10-22 19:29:07 -04:00
|
|
|
|
eval('nsBrowserAccess.prototype.openURI = '+
|
|
|
|
|
nsBrowserAccess.prototype.openURI.toSource().replace(
|
2008-02-26 20:26:38 -05:00
|
|
|
|
/(switch\s*\(aWhere\))/,
|
2007-10-21 11:02:58 -04:00
|
|
|
|
<><![CDATA[
|
|
|
|
|
if (aOpener &&
|
|
|
|
|
aWhere == Components.interfaces.nsIBrowserDOMWindow.OPEN_NEWTAB) {
|
|
|
|
|
TreeStyleTabService.readyToOpenChildTab(aOpener);
|
|
|
|
|
}
|
2008-02-26 20:26:38 -05:00
|
|
|
|
$1]]></>
|
2007-10-21 11:02:58 -04:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = null;
|
|
|
|
|
window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = new nsBrowserAccess();
|
|
|
|
|
|
2007-10-22 18:45:35 -04:00
|
|
|
|
eval('FeedHandler.loadFeed = '+
|
|
|
|
|
FeedHandler.loadFeed.toSource().replace(
|
|
|
|
|
'openUILink(',
|
|
|
|
|
<><![CDATA[
|
|
|
|
|
if (String(whereToOpenLink(event, false, true)).indexOf('tab') == 0)
|
|
|
|
|
TreeStyleTabService.readyToOpenChildTab(gBrowser);
|
2008-02-26 20:26:38 -05:00
|
|
|
|
$&]]></>
|
2007-10-22 18:45:35 -04:00
|
|
|
|
)
|
|
|
|
|
);
|
2008-06-17 07:57:29 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Firefox 3 full screen
|
|
|
|
|
if ('FullScreen' in window && '_animateUp' in FullScreen) {
|
|
|
|
|
eval('FullScreen._animateUp = '+
|
|
|
|
|
FullScreen._animateUp.toSource().replace(
|
|
|
|
|
'gBrowser.mStrip.boxObject.height',
|
|
|
|
|
'((gBrowser.getAttribute(TreeStyleTabService.kTABBAR_POSITION) != "top") ? 0 : gBrowser.mStrip.boxObject.height)'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
eval('FullScreen.mouseoverToggle = '+
|
|
|
|
|
FullScreen.mouseoverToggle.toSource().replace(
|
|
|
|
|
'gBrowser.mStrip.setAttribute("moz-collapsed", !aShow);',
|
|
|
|
|
'if (gBrowser.getAttribute(TreeStyleTabService.kTABBAR_POSITION) == "top") { $& }'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
eval('FullScreen.toggle = '+
|
|
|
|
|
FullScreen.toggle.toSource().replace(
|
|
|
|
|
'{',
|
|
|
|
|
<![CDATA[{
|
|
|
|
|
var treeStyleTab = gBrowser.treeStyleTab;
|
|
|
|
|
if (gBrowser.getAttribute(treeStyleTab.kTABBAR_POSITION) != 'top') {
|
|
|
|
|
treeStyleTab.autoHideMode = treeStyleTab.getTreePref(window.fullScreen ? 'tabbar.autoHide.mode' : 'tabbar.autoHide.mode.fullscreen' );
|
|
|
|
|
treeStyleTab.endAutoHide();
|
2008-09-17 22:57:25 -04:00
|
|
|
|
if (window.fullScreen)
|
|
|
|
|
treeStyleTab.checkTabsIndentOverflow();
|
2008-06-17 07:57:29 -04:00
|
|
|
|
if (treeStyleTab.autoHideMode != treeStyleTab.kAUTOHIDE_MODE_DISABLED)
|
|
|
|
|
treeStyleTab.startAutoHide();
|
|
|
|
|
}
|
|
|
|
|
]]>
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
2007-10-21 11:02:58 -04:00
|
|
|
|
},
|
2008-09-26 10:13:29 -04:00
|
|
|
|
|
|
|
|
|
initBar : function()
|
|
|
|
|
{
|
|
|
|
|
var bar = document.getElementById('urlbar');
|
|
|
|
|
if (!bar) return;
|
|
|
|
|
|
|
|
|
|
var source;
|
|
|
|
|
if (
|
|
|
|
|
'handleCommand' in bar &&
|
|
|
|
|
(source = bar.handleCommand.toSource()) &&
|
|
|
|
|
source.indexOf('TreeStyleTabService') < 0
|
|
|
|
|
) {
|
|
|
|
|
eval('bar.handleCommand = '+source.replace(
|
|
|
|
|
'aTriggeringEvent && aTriggeringEvent.altKey',
|
|
|
|
|
'TreeStyleTabService.checkReadyToOpenNewTabOnLocationBar(url, $&)'
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
},
|
2008-10-14 13:48:19 -04:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
destroy : function()
|
|
|
|
|
{
|
2007-11-14 14:34:36 -05:00
|
|
|
|
window.removeEventListener('unload', this, false);
|
2007-11-08 09:24:54 -05:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
this.destroyTabBrowser(gBrowser);
|
|
|
|
|
|
2008-03-08 03:57:17 -05:00
|
|
|
|
this.endListenKeyEvents();
|
|
|
|
|
|
2007-10-22 05:59:43 -04:00
|
|
|
|
document.getElementById('contentAreaContextMenu').removeEventListener('popupshowing', this, false);
|
|
|
|
|
|
2007-11-14 10:09:47 -05:00
|
|
|
|
var appcontent = document.getElementById('appcontent');
|
|
|
|
|
appcontent.removeEventListener('SubBrowserAdded', this, false);
|
|
|
|
|
appcontent.removeEventListener('SubBrowserRemoveRequest', this, false);
|
2007-10-16 13:22:28 -04:00
|
|
|
|
|
|
|
|
|
this.removePrefListener(this);
|
|
|
|
|
},
|
2007-10-22 05:59:43 -04:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
destroyTabBrowser : function(aTabBrowser)
|
|
|
|
|
{
|
2007-11-14 14:34:36 -05:00
|
|
|
|
if (aTabBrowser.localName != 'tabbrowser') return;
|
|
|
|
|
aTabBrowser.treeStyleTab.destroy();
|
|
|
|
|
delete aTabBrowser.treeStyleTab;
|
2007-10-16 13:22:28 -04:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/* Event Handling */
|
2008-09-26 10:13:29 -04:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
handleEvent : function(aEvent)
|
|
|
|
|
{
|
|
|
|
|
switch (aEvent.type)
|
|
|
|
|
{
|
2008-02-25 20:14:12 -05:00
|
|
|
|
case 'DOMContentLoaded':
|
|
|
|
|
this.preInit();
|
|
|
|
|
return;
|
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
case 'load':
|
2007-11-14 14:34:36 -05:00
|
|
|
|
this.init();
|
2007-10-18 13:11:03 -04:00
|
|
|
|
return;
|
2007-10-16 13:22:28 -04:00
|
|
|
|
|
|
|
|
|
case 'unload':
|
|
|
|
|
this.destroy();
|
2007-10-18 13:11:03 -04:00
|
|
|
|
return;
|
2007-10-16 13:22:28 -04:00
|
|
|
|
|
|
|
|
|
case 'popupshowing':
|
2007-10-22 05:59:43 -04:00
|
|
|
|
if (aEvent.target != aEvent.currentTarget) return;
|
2007-11-14 14:34:36 -05:00
|
|
|
|
this.initContextMenu();
|
2007-10-18 13:11:03 -04:00
|
|
|
|
return;
|
2007-10-17 09:25:50 -04:00
|
|
|
|
|
2008-03-08 03:57:17 -05:00
|
|
|
|
case 'keydown':
|
|
|
|
|
this.onKeyDown(aEvent);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 'keyup':
|
|
|
|
|
case 'keypress':
|
|
|
|
|
this.onKeyRelease(aEvent);
|
|
|
|
|
return;
|
|
|
|
|
|
2007-10-17 09:25:50 -04:00
|
|
|
|
case 'SubBrowserAdded':
|
|
|
|
|
this.initTabBrowser(aEvent.originalTarget.browser);
|
2007-10-18 13:11:03 -04:00
|
|
|
|
return;
|
2007-10-17 09:25:50 -04:00
|
|
|
|
|
|
|
|
|
case 'SubBrowserRemoveRequest':
|
|
|
|
|
this.destroyTabBrowser(aEvent.originalTarget.browser);
|
2007-10-18 13:11:03 -04:00
|
|
|
|
return;
|
2007-10-16 13:22:28 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
2008-03-08 03:57:17 -05:00
|
|
|
|
|
|
|
|
|
onKeyDown : function(aEvent)
|
|
|
|
|
{
|
|
|
|
|
var b = this.browser;
|
|
|
|
|
if (!b || !b.treeStyleTab) return;
|
|
|
|
|
var sv = b.treeStyleTab;
|
|
|
|
|
|
2008-03-09 01:36:52 -05:00
|
|
|
|
if (this.delayedAutoShowDone)
|
|
|
|
|
this.cancelDelayedAutoShow();
|
2008-03-08 03:57:17 -05:00
|
|
|
|
|
2008-03-09 21:43:56 -04:00
|
|
|
|
this.accelKeyPressed = (
|
|
|
|
|
navigator.platform.match(/mac/i) ?
|
|
|
|
|
(aEvent.metaKey || (aEvent.keyCode == aEvent.DOM_VK_META)) :
|
|
|
|
|
(aEvent.ctrlKey || (aEvent.keyCode == aEvent.DOM_VK_CONTROL))
|
|
|
|
|
);
|
2008-03-08 03:57:17 -05:00
|
|
|
|
if (
|
|
|
|
|
b.mTabContainer.childNodes.length > 1 &&
|
|
|
|
|
!aEvent.altKey &&
|
2008-03-09 08:34:10 -04:00
|
|
|
|
this.accelKeyPressed
|
2008-03-08 03:57:17 -05:00
|
|
|
|
) {
|
2008-09-26 10:13:29 -04:00
|
|
|
|
if (this.getTreePref('tabbar.autoShow.accelKeyDown') &&
|
|
|
|
|
!sv.autoHideShown &&
|
2008-03-11 00:16:55 -04:00
|
|
|
|
!this.delayedAutoShowTimer) {
|
2008-03-09 01:36:52 -05:00
|
|
|
|
this.delayedAutoShowTimer = window.setTimeout(
|
|
|
|
|
function(aSelf) {
|
|
|
|
|
aSelf.delayedAutoShowDone = true;
|
|
|
|
|
sv.showTabbar(sv.kSHOWN_BY_SHORTCUT);
|
|
|
|
|
},
|
2008-03-09 08:18:58 -04:00
|
|
|
|
this.getTreePref('tabbar.autoShow.accelKeyDown.delay'),
|
2008-03-09 01:36:52 -05:00
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
this.delayedAutoShowDone = false;
|
2008-03-08 03:57:17 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-03-09 08:18:58 -04:00
|
|
|
|
else {
|
2008-03-09 01:36:52 -05:00
|
|
|
|
sv.hideTabbar();
|
2008-03-09 08:18:58 -04:00
|
|
|
|
}
|
2008-03-08 03:57:17 -05:00
|
|
|
|
},
|
|
|
|
|
cancelDelayedAutoShow : function()
|
|
|
|
|
{
|
|
|
|
|
if (this.delayedAutoShowTimer) {
|
2008-03-11 00:16:55 -04:00
|
|
|
|
window.clearTimeout(this.delayedAutoShowTimer);
|
2008-03-08 03:57:17 -05:00
|
|
|
|
this.delayedAutoShowTimer = null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
delayedAutoShowTimer : null,
|
2008-03-09 01:36:52 -05:00
|
|
|
|
delayedAutoShowDone : true,
|
2008-03-09 08:18:58 -04:00
|
|
|
|
accelKeyPressed : false,
|
2008-03-08 05:07:28 -05:00
|
|
|
|
|
2008-03-08 03:57:17 -05:00
|
|
|
|
onKeyRelease : function(aEvent)
|
|
|
|
|
{
|
|
|
|
|
var b = this.browser;
|
|
|
|
|
if (!b || !b.treeStyleTab) return;
|
|
|
|
|
var sv = b.treeStyleTab;
|
|
|
|
|
|
|
|
|
|
this.cancelDelayedAutoShow();
|
|
|
|
|
|
|
|
|
|
var scrollDown,
|
|
|
|
|
scrollUp;
|
|
|
|
|
var isMac = navigator.platform.match(/mac/i);
|
|
|
|
|
|
2008-03-09 08:34:10 -04:00
|
|
|
|
this.accelKeyPressed = (isMac ? aEvent.metaKey : aEvent.ctrlKey );
|
|
|
|
|
|
2008-03-08 03:57:17 -05:00
|
|
|
|
var standBy = scrollDown = scrollUp = (!aEvent.altKey && (isMac ? aEvent.metaKey : aEvent.ctrlKey ));
|
|
|
|
|
|
|
|
|
|
scrollDown = scrollDown && (
|
|
|
|
|
!aEvent.shiftKey &&
|
|
|
|
|
(
|
|
|
|
|
aEvent.keyCode == aEvent.DOM_VK_TAB ||
|
|
|
|
|
aEvent.keyCode == aEvent.DOM_VK_PAGE_DOWN
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
scrollUp = scrollUp && (
|
|
|
|
|
aEvent.shiftKey ? (aEvent.keyCode == aEvent.DOM_VK_TAB) : (aEvent.keyCode == aEvent.DOM_VK_PAGE_UP)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
scrollDown ||
|
|
|
|
|
scrollUp ||
|
|
|
|
|
( // when you release "shift" key
|
2008-06-18 10:04:50 -04:00
|
|
|
|
sv.autoHideShown &&
|
2008-03-08 03:57:17 -05:00
|
|
|
|
standBy && !aEvent.shiftKey &&
|
|
|
|
|
aEvent.charCode == 0 && aEvent.keyCode == 16
|
|
|
|
|
)
|
|
|
|
|
) {
|
2008-03-09 08:34:10 -04:00
|
|
|
|
if (this.getTreePref('tabbar.autoShow.tabSwitch'))
|
|
|
|
|
sv.showTabbar(sv.kSHOWN_BY_SHORTCUT);
|
2008-03-08 03:57:17 -05:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-09 01:36:52 -05:00
|
|
|
|
if (sv.showHideTabbarReason == sv.kSHOWN_BY_SHORTCUT)
|
|
|
|
|
sv.hideTabbar();
|
2008-03-08 03:57:17 -05:00
|
|
|
|
},
|
2008-09-26 10:13:29 -04:00
|
|
|
|
|
2008-03-08 03:57:17 -05:00
|
|
|
|
keyEventListening : false,
|
|
|
|
|
|
|
|
|
|
startListenKeyEvents : function()
|
|
|
|
|
{
|
|
|
|
|
if (this.keyEventListening) return;
|
|
|
|
|
window.addEventListener('keydown', this, true);
|
|
|
|
|
window.addEventListener('keyup', this, true);
|
|
|
|
|
window.addEventListener('keypress', this, true);
|
|
|
|
|
this.keyEventListening = true;
|
|
|
|
|
},
|
2007-10-16 13:22:28 -04:00
|
|
|
|
|
2008-03-08 03:57:17 -05:00
|
|
|
|
endListenKeyEvents : function()
|
|
|
|
|
{
|
|
|
|
|
if (!this.keyEventListening) return;
|
|
|
|
|
window.removeEventListener('keydown', this, true);
|
|
|
|
|
window.removeEventListener('keyup', this, true);
|
|
|
|
|
window.removeEventListener('keypress', this, true);
|
|
|
|
|
this.keyEventListening = false;
|
|
|
|
|
},
|
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
onTabbarResized : function(aEvent)
|
2007-10-16 13:22:28 -04:00
|
|
|
|
{
|
2008-06-17 02:22:49 -04:00
|
|
|
|
var b = this.getTabBrowserFromChild(aEvent.currentTarget);
|
2008-06-17 08:55:05 -04:00
|
|
|
|
if (!b.treeStyleTab.tabbarExpanded)
|
2008-06-17 02:22:49 -04:00
|
|
|
|
this.setTreePref('tabbar.shrunkenWidth', b.mStrip.boxObject.width);
|
|
|
|
|
else
|
|
|
|
|
this.setTreePref('tabbar.width', b.mStrip.boxObject.width);
|
2007-10-16 13:22:28 -04:00
|
|
|
|
},
|
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
initContextMenu : function()
|
2007-10-18 14:20:54 -04:00
|
|
|
|
{
|
2007-11-14 14:34:36 -05:00
|
|
|
|
var item = document.getElementById('context-treestyletab-openSelectionLinks');
|
|
|
|
|
var sep = document.getElementById('context-treestyletab-openSelectionLinks-separator');
|
|
|
|
|
if (this.getTreePref('show.openSelectionLinks') && this.getSelectionLinks().length) {
|
|
|
|
|
item.removeAttribute('hidden');
|
|
|
|
|
sep.removeAttribute('hidden');
|
2007-10-18 14:20:54 -04:00
|
|
|
|
}
|
2007-11-14 14:34:36 -05:00
|
|
|
|
else {
|
|
|
|
|
item.setAttribute('hidden', true);
|
|
|
|
|
sep.setAttribute('hidden', true);
|
2007-10-20 12:47:08 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2008-10-14 13:48:19 -04:00
|
|
|
|
showHideSubTreeMenuItem : function(aMenuItem, aTabs)
|
2007-10-20 12:47:08 -04:00
|
|
|
|
{
|
2007-11-14 14:34:36 -05:00
|
|
|
|
if (!aMenuItem ||
|
|
|
|
|
aMenuItem.getAttribute('hidden') == 'true' ||
|
|
|
|
|
!aTabs ||
|
|
|
|
|
!aTabs.length)
|
2007-11-12 10:29:12 -05:00
|
|
|
|
return;
|
2007-10-20 12:47:08 -04:00
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
var hasSubTree = false;
|
|
|
|
|
for (var i = 0, maxi = aTabs.length; i < maxi; i++)
|
2007-10-20 12:47:08 -04:00
|
|
|
|
{
|
2008-04-29 14:17:44 -04:00
|
|
|
|
if (!this.hasChildTabs(aTabs[i])) continue;
|
2007-11-14 14:34:36 -05:00
|
|
|
|
hasSubTree = true;
|
2007-10-20 12:47:08 -04:00
|
|
|
|
break;
|
|
|
|
|
}
|
2007-11-14 14:34:36 -05:00
|
|
|
|
if (hasSubTree)
|
|
|
|
|
aMenuItem.removeAttribute('hidden');
|
|
|
|
|
else
|
|
|
|
|
aMenuItem.setAttribute('hidden', true);
|
2007-10-20 12:47:08 -04:00
|
|
|
|
},
|
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
/* Commands */
|
2008-10-14 13:48:19 -04:00
|
|
|
|
|
2007-11-26 09:51:59 -05:00
|
|
|
|
removeTabSubTree : function(aTabOrTabs, aOnlyChildren)
|
2007-10-19 22:44:14 -04:00
|
|
|
|
{
|
|
|
|
|
var tabs = aTabOrTabs;
|
|
|
|
|
if (!(tabs instanceof Array)) {
|
|
|
|
|
tabs = [aTabOrTabs];
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-17 08:32:41 -05:00
|
|
|
|
var b = this.getTabBrowserFromChild(tabs[0]);
|
2007-10-19 22:44:14 -04:00
|
|
|
|
var descendant = [];
|
|
|
|
|
for (var i = 0, maxi = tabs.length; i < maxi; i++)
|
|
|
|
|
{
|
2007-11-14 14:34:36 -05:00
|
|
|
|
descendant = descendant.concat(b.treeStyleTab.getDescendantTabs(tabs[i]));
|
2007-10-19 22:44:14 -04:00
|
|
|
|
}
|
2007-11-26 09:51:59 -05:00
|
|
|
|
|
|
|
|
|
if (aOnlyChildren)
|
|
|
|
|
tabs = this.cleanUpTabsArray(descendant);
|
|
|
|
|
else
|
|
|
|
|
tabs = this.cleanUpTabsArray(tabs.concat(descendant));
|
2007-10-19 22:44:14 -04:00
|
|
|
|
|
|
|
|
|
var max = tabs.length;
|
|
|
|
|
if (!max) return;
|
|
|
|
|
|
2008-10-14 10:45:57 -04:00
|
|
|
|
b.__treestyletab__closedTabsNum = max;
|
2007-10-19 22:44:14 -04:00
|
|
|
|
if (
|
|
|
|
|
max > 1 &&
|
2008-10-14 10:45:57 -04:00
|
|
|
|
!b.warnAboutClosingTabs(true)
|
|
|
|
|
) {
|
|
|
|
|
b.__treestyletab__closedTabsNum = 0;
|
2007-10-19 22:44:14 -04:00
|
|
|
|
return;
|
2008-10-14 10:45:57 -04:00
|
|
|
|
}
|
|
|
|
|
b.__treestyletab__closedTabsNum = 0;
|
2007-10-19 22:44:14 -04:00
|
|
|
|
|
|
|
|
|
for (var i = tabs.length-1; i > -1; i--)
|
|
|
|
|
{
|
|
|
|
|
b.removeTab(tabs[i]);
|
|
|
|
|
}
|
|
|
|
|
},
|
2008-10-14 13:48:19 -04:00
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
|
cleanUpTabsArray : function(aTabs)
|
|
|
|
|
{
|
2007-11-17 08:32:41 -05:00
|
|
|
|
var b = this.getTabBrowserFromChild(aTabs[0]);
|
2007-11-14 14:34:36 -05:00
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
aTabs = aTabs.map(function(aTab) { return aTab.getAttribute(self.kID); });
|
|
|
|
|
aTabs.sort();
|
|
|
|
|
aTabs = aTabs.join('|').replace(/([^\|]+)(\|\1)+/g, '$1').split('|');
|
|
|
|
|
|
|
|
|
|
for (var i = 0, maxi = aTabs.length; i < maxi; i++)
|
|
|
|
|
{
|
|
|
|
|
aTabs[i] = b.treeStyleTab.getTabById(aTabs[i]);
|
|
|
|
|
}
|
|
|
|
|
return aTabs;
|
|
|
|
|
},
|
|
|
|
|
|
2008-10-14 13:48:19 -04:00
|
|
|
|
bookmarkTabSubTree : function(aTabOrTabs)
|
|
|
|
|
{
|
|
|
|
|
var tabs = aTabOrTabs;
|
|
|
|
|
if (!(tabs instanceof Array)) {
|
|
|
|
|
tabs = [aTabOrTabs];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var b = this.getTabBrowserFromChild(tabs[0]);
|
|
|
|
|
var bookmarkedTabs = [];
|
|
|
|
|
for (var i = 0, maxi = tabs.length; i < maxi; i++)
|
|
|
|
|
{
|
|
|
|
|
bookmarkedTabs.push(tabs[i]);
|
|
|
|
|
bookmarkedTabs = bookmarkedTabs.concat(b.treeStyleTab.getDescendantTabs(tabs[i]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('MultipleTabService' in window &&
|
|
|
|
|
'addBookmarkFor' in MultipleTabService) {
|
|
|
|
|
MultipleTabService.addBookmarkFor(bookmarkedTabs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._addBookmarkFor(bookmarkedTabs);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_addBookmarkFor : function(aTabs) // from Multiple Tab Handler
|
|
|
|
|
{
|
|
|
|
|
if (!aTabs) return;
|
|
|
|
|
|
|
|
|
|
var b = this.getTabBrowserFromChild(aTabs[0]);
|
|
|
|
|
|
|
|
|
|
if ('PlacesUIUtils' in window || 'PlacesUtils' in window) { // Firefox 3
|
|
|
|
|
var utils = 'PlacesUIUtils' in window ? PlacesUIUtils : PlacesUtils ;
|
|
|
|
|
utils.showMinimalAddMultiBookmarkUI(Array.slice(aTabs).map(function(aTab) {
|
|
|
|
|
return aTab.linkedBrowser.currentURI;
|
|
|
|
|
}));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var currentTabInfo;
|
|
|
|
|
var tabsInfo = Array.slice(aTabs).map(function(aTab) {
|
|
|
|
|
var webNav = aTab.linkedBrowser.webNavigation;
|
|
|
|
|
var url = webNav.currentURI.spec;
|
|
|
|
|
var name = '';
|
|
|
|
|
var charSet, description;
|
|
|
|
|
try {
|
|
|
|
|
var doc = webNav.document;
|
|
|
|
|
name = doc.title || url;
|
|
|
|
|
charSet = doc.characterSet;
|
|
|
|
|
description = BookmarksUtils.getDescriptionFromDocument(doc);
|
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
|
|
|
|
name = url;
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
name : name,
|
|
|
|
|
url : url,
|
|
|
|
|
charset : charSet,
|
|
|
|
|
description : description
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.openDialog(
|
|
|
|
|
'chrome://browser/content/bookmarks/addBookmark2.xul',
|
|
|
|
|
'',
|
|
|
|
|
BROWSER_ADD_BM_FEATURES,
|
|
|
|
|
(aTabs.length == 1 ?
|
|
|
|
|
tabsInfo[0] :
|
|
|
|
|
{
|
|
|
|
|
name : gNavigatorBundle.getString('bookmarkAllTabsDefault'),
|
|
|
|
|
bBookmarkAllTabs : true,
|
|
|
|
|
objGroup : tabsInfo
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2007-10-22 05:59:43 -04:00
|
|
|
|
openSelectionLinks : function()
|
|
|
|
|
{
|
|
|
|
|
var links = this.getSelectionLinks();
|
|
|
|
|
if (!links.length) return;
|
|
|
|
|
|
|
|
|
|
var b = this.browser;
|
|
|
|
|
var targetWindow = document.commandDispatcher.focusedWindow;
|
|
|
|
|
if (!targetWindow || targetWindow.top == window)
|
|
|
|
|
targetWindow = b.contentWindow;
|
|
|
|
|
|
|
|
|
|
var referrer = this.makeURIFromSpec(targetWindow.location.href);
|
|
|
|
|
|
|
|
|
|
this.readyToOpenChildTab(targetWindow, true);
|
|
|
|
|
var self = this;
|
|
|
|
|
links.forEach(function(aItem, aIndex) {
|
|
|
|
|
var tab = b.addTab(aItem.uri, referrer);
|
|
|
|
|
if (aIndex == 0 && !self.getPref('browser.tabs.loadInBackground'))
|
|
|
|
|
b.selectedTab = tab;
|
|
|
|
|
});
|
|
|
|
|
this.stopToOpenChildTab(targetWindow);
|
|
|
|
|
},
|
2007-11-17 00:20:26 -05:00
|
|
|
|
|
2007-10-22 05:59:43 -04:00
|
|
|
|
getSelectionLinks : function()
|
|
|
|
|
{
|
|
|
|
|
var links = [];
|
|
|
|
|
|
|
|
|
|
var targetWindow = document.commandDispatcher.focusedWindow;
|
|
|
|
|
if (!targetWindow || targetWindow.top == window)
|
|
|
|
|
targetWindow = this.browser.contentWindow;
|
|
|
|
|
|
|
|
|
|
var selection = targetWindow.getSelection();
|
|
|
|
|
if (!selection || !selection.rangeCount)
|
|
|
|
|
return links;
|
|
|
|
|
|
|
|
|
|
const count = selection.rangeCount;
|
|
|
|
|
var range,
|
|
|
|
|
node,
|
|
|
|
|
link,
|
|
|
|
|
uri,
|
|
|
|
|
nodeRange = targetWindow.document.createRange();
|
|
|
|
|
for (var i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
range = selection.getRangeAt(0);
|
|
|
|
|
node = range.startContainer;
|
|
|
|
|
|
|
|
|
|
traceTree:
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
nodeRange.selectNode(node);
|
|
|
|
|
|
|
|
|
|
// <20>u<EFBFBD>m<EFBFBD>[<5B>h<EFBFBD>̏I<CC8F>[<5B><><EFBFBD>A<EFBFBD>I<EFBFBD><49><EFBFBD>͈͂̐<CD82><CC90>[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982>邩<EFBFBD>ǂ<EFBFBD><C782><EFBFBD><EFBFBD>v<EFBFBD><76><EFBFBD>`<60>F<EFBFBD>b<EFBFBD>N<EFBFBD>B
|
|
|
|
|
// <20><><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>A<CE81><41><EFBFBD>̃m<CC83>[<5B>h<EFBFBD>͑I<CD91><49><EFBFBD>͈͓<CD88><CD93>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>ƍl<C68D><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
if (nodeRange.compareBoundaryPoints(Range.START_TO_END, range) > -1) {
|
|
|
|
|
// <20>u<EFBFBD>m<EFBFBD>[<5B>h<EFBFBD>̐<EFBFBD><CC90>[<5B><><EFBFBD>A<EFBFBD>I<EFBFBD><49><EFBFBD>͈͂̏I<CC8F>[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982>邩<EFBFBD>ǂ<EFBFBD><C782><EFBFBD><EFBFBD>v<EFBFBD><76><EFBFBD>`<60>F<EFBFBD>b<EFBFBD>N<EFBFBD>B
|
|
|
|
|
// <20><><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>A<CE81><41><EFBFBD>̃m<CC83>[<5B>h<EFBFBD>͑I<CD91><49><EFBFBD>͈͊O<CD8A>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>ƍl<C68D><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
|
|
|
|
|
if (nodeRange.compareBoundaryPoints(Range.END_TO_START, range) > 0) {
|
|
|
|
|
// <20>u<EFBFBD><75><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD>e<EFBFBD>L<EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>ۂɂ͑I<CD91><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD>v<EFBFBD>ɂ<C982><C282>Ă͏<C482><CD8F>O<EFBFBD><4F><EFBFBD><EFBFBD>
|
|
|
|
|
if (
|
|
|
|
|
links.length &&
|
|
|
|
|
range.startContainer.nodeType != Node.ELEMENT_NODE &&
|
|
|
|
|
range.startOffset == range.startContainer.nodeValue.length &&
|
|
|
|
|
links[0].node == this.getParentLink(range.startContainer)
|
|
|
|
|
)
|
|
|
|
|
links.splice(0, 1);
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
links.length &&
|
|
|
|
|
range.endContainer.nodeType != Node.ELEMENT_NODE &&
|
|
|
|
|
range.endOffset == 0 &&
|
|
|
|
|
links[links.length-1].node == this.getParentLink(range.endContainer)
|
|
|
|
|
)
|
|
|
|
|
links.splice(links.length-1, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (link = this.getParentLink(node)) {
|
|
|
|
|
try {
|
|
|
|
|
uri = link.href;
|
|
|
|
|
if (uri && uri.indexOf('mailto:') < 0)
|
|
|
|
|
links.push({ node : link, uri : uri });
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (node.hasChildNodes() && !link) {
|
|
|
|
|
node = node.firstChild;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
while (!node.nextSibling)
|
|
|
|
|
{
|
|
|
|
|
node = node.parentNode;
|
|
|
|
|
if (!node) break traceTree;
|
|
|
|
|
}
|
|
|
|
|
node = node.nextSibling;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nodeRange.detach();
|
|
|
|
|
|
|
|
|
|
return links;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getParentLink : function(aNode)
|
|
|
|
|
{
|
|
|
|
|
var node = aNode;
|
|
|
|
|
while (!node.href && node.parentNode)
|
|
|
|
|
node = node.parentNode;
|
|
|
|
|
|
|
|
|
|
return node.href ? node : null ;
|
|
|
|
|
},
|
2007-11-17 00:20:26 -05:00
|
|
|
|
|
|
|
|
|
collapseExpandAllSubtree : function(aCollapse)
|
|
|
|
|
{
|
|
|
|
|
this.ObserverService.notifyObservers(
|
|
|
|
|
window,
|
|
|
|
|
'TreeStyleTab:collapseExpandAllSubtree',
|
|
|
|
|
(aCollapse ? 'collapse' : 'open' )
|
|
|
|
|
);
|
|
|
|
|
},
|
2008-02-28 02:45:39 -05:00
|
|
|
|
|
|
|
|
|
registerAttachTabPostProcess : function(aProcess)
|
|
|
|
|
{
|
|
|
|
|
this._attachTabPostProcesses.push(aProcess);
|
|
|
|
|
},
|
|
|
|
|
_attachTabPostProcesses : [],
|
2008-03-02 13:16:57 -05:00
|
|
|
|
|
|
|
|
|
registerTabFocusAllowance : function(aProcess)
|
|
|
|
|
{
|
|
|
|
|
this._tabFocusAllowance.push(aProcess);
|
|
|
|
|
},
|
|
|
|
|
_tabFocusAllowance : [],
|
|
|
|
|
|
|
|
|
|
registerCollapseExpandPostProcess : function(aProcess)
|
|
|
|
|
{
|
|
|
|
|
this._collapseExpandPostProcess.push(aProcess);
|
|
|
|
|
},
|
|
|
|
|
_collapseExpandPostProcess : [],
|
2008-03-08 03:57:17 -05:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
/* Pref Listener */
|
2008-03-08 05:07:28 -05:00
|
|
|
|
|
2008-03-03 03:26:51 -05:00
|
|
|
|
domains : [
|
|
|
|
|
'extensions.treestyletab',
|
|
|
|
|
'browser.link.open_newwindow.restriction.override',
|
|
|
|
|
'browser.tabs.loadFolderAndReplace.override'
|
|
|
|
|
],
|
2007-10-16 13:22:28 -04:00
|
|
|
|
|
|
|
|
|
observe : function(aSubject, aTopic, aPrefName)
|
|
|
|
|
{
|
|
|
|
|
if (aTopic != 'nsPref:changed') return;
|
|
|
|
|
|
|
|
|
|
var value = this.getPref(aPrefName);
|
|
|
|
|
switch (aPrefName)
|
|
|
|
|
{
|
2007-10-20 04:22:42 -04:00
|
|
|
|
case 'extensions.treestyletab.levelMargin':
|
2007-11-14 14:34:36 -05:00
|
|
|
|
this.baseLebelMargin = value;
|
2007-10-20 04:22:42 -04:00
|
|
|
|
this.ObserverService.notifyObservers(null, 'TreeStyleTab:levelMarginModified', value);
|
2007-10-16 13:22:28 -04:00
|
|
|
|
break;
|
|
|
|
|
|
2008-06-17 02:22:49 -04:00
|
|
|
|
case 'extensions.treestyletab.tabbar.autoHide.mode':
|
2008-06-17 08:55:05 -04:00
|
|
|
|
// don't set on this time, because appearance of all tabbrowsers are not updated yet.
|
|
|
|
|
// this.autoHideMode = this.getTreePref('tabbar.autoHide.mode');
|
2008-03-09 08:34:10 -04:00
|
|
|
|
case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown':
|
2008-03-08 03:57:17 -05:00
|
|
|
|
case 'extensions.treestyletab.tabbar.autoShow.tabSwitch':
|
2008-03-09 08:34:10 -04:00
|
|
|
|
case 'extensions.treestyletab.tabbar.autoShow.feedback':
|
|
|
|
|
if (
|
2008-06-17 08:55:05 -04:00
|
|
|
|
this.getTreePref('tabbar.autoHide.mode') &&
|
2008-03-09 08:34:10 -04:00
|
|
|
|
(
|
|
|
|
|
this.getTreePref('tabbar.autoShow.accelKeyDown') ||
|
|
|
|
|
this.getTreePref('tabbar.autoShow.tabSwitch') ||
|
|
|
|
|
this.getTreePref('tabbar.autoShow.feedback')
|
|
|
|
|
)
|
2008-09-27 11:48:25 -04:00
|
|
|
|
) {
|
2008-03-08 03:57:17 -05:00
|
|
|
|
this.startListenKeyEvents();
|
2008-09-27 11:48:25 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2008-03-08 03:57:17 -05:00
|
|
|
|
this.endListenKeyEvents();
|
2008-09-27 11:48:25 -04:00
|
|
|
|
}
|
|
|
|
|
window.setTimeout(function() {
|
|
|
|
|
window.resizeBy(-1,-1);
|
|
|
|
|
window.resizeBy(1,1);
|
|
|
|
|
}, 0);
|
2008-03-08 03:57:17 -05:00
|
|
|
|
break;
|
|
|
|
|
|
2008-06-17 06:29:16 -04:00
|
|
|
|
case 'extensions.treestyletab.tabbar.width':
|
|
|
|
|
case 'extensions.treestyletab.tabbar.shrunkenWidth':
|
|
|
|
|
var expanded = this.getTreePref('tabbar.width');
|
|
|
|
|
var shrunken = this.getTreePref('tabbar.shrunkenWidth');
|
|
|
|
|
if (!this.tabbarWidthResetting &&
|
|
|
|
|
(expanded - this.getTreePref('autoHide.area')) < shrunken) {
|
|
|
|
|
this.tabbarWidthResetting = true;
|
|
|
|
|
if (aPrefName == 'extensions.treestyletab.tabbar.width')
|
|
|
|
|
this.setTreePref('tabbar.shrunkenWidth', parseInt(expanded / 1.2));
|
|
|
|
|
else
|
|
|
|
|
this.setTreePref('tabbar.width', parseInt(shrunken * 1.2));
|
|
|
|
|
this.tabbarWidthResetting = false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2008-03-03 03:26:51 -05:00
|
|
|
|
case 'browser.link.open_newwindow.restriction.override':
|
|
|
|
|
case 'browser.tabs.loadFolderAndReplace.override':
|
|
|
|
|
var target = aPrefName.replace('.override', '');
|
|
|
|
|
this.setPref(target, this.getPref(aPrefName));
|
|
|
|
|
break;
|
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/* Save/Load Prefs */
|
2007-10-21 04:16:10 -04:00
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
get Prefs()
|
|
|
|
|
{
|
|
|
|
|
if (!this._Prefs) {
|
|
|
|
|
this._Prefs = Components.classes['@mozilla.org/preferences;1'].getService(Components.interfaces.nsIPrefBranch);
|
|
|
|
|
}
|
|
|
|
|
return this._Prefs;
|
|
|
|
|
},
|
|
|
|
|
_Prefs : null,
|
|
|
|
|
|
|
|
|
|
getPref : function(aPrefstring)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
switch (this.Prefs.getPrefType(aPrefstring))
|
|
|
|
|
{
|
|
|
|
|
case this.Prefs.PREF_STRING:
|
|
|
|
|
return decodeURIComponent(escape(this.Prefs.getCharPref(aPrefstring)));
|
|
|
|
|
break;
|
|
|
|
|
case this.Prefs.PREF_INT:
|
|
|
|
|
return this.Prefs.getIntPref(aPrefstring);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return this.Prefs.getBoolPref(aPrefstring);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
|
2007-10-26 07:24:59 -04:00
|
|
|
|
getTreePref : function(aPrefstring)
|
|
|
|
|
{
|
|
|
|
|
return this.getPref('extensions.treestyletab.'+aPrefstring);
|
|
|
|
|
},
|
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
setPref : function(aPrefstring, aNewValue)
|
|
|
|
|
{
|
|
|
|
|
var pref = this.Prefs ;
|
|
|
|
|
var type;
|
|
|
|
|
try {
|
|
|
|
|
type = typeof aNewValue;
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
type = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case 'string':
|
|
|
|
|
pref.setCharPref(aPrefstring, unescape(encodeURIComponent(aNewValue)));
|
|
|
|
|
break;
|
|
|
|
|
case 'number':
|
|
|
|
|
pref.setIntPref(aPrefstring, parseInt(aNewValue));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
pref.setBoolPref(aPrefstring, aNewValue);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
|
2007-11-08 23:07:54 -05:00
|
|
|
|
setTreePref : function(aPrefstring, aNewValue)
|
|
|
|
|
{
|
|
|
|
|
return this.setPref('extensions.treestyletab.'+aPrefstring, aNewValue);
|
|
|
|
|
},
|
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
|
clearPref : function(aPrefstring)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
this.Prefs.clearUserPref(aPrefstring);
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
addPrefListener : function(aObserver)
|
|
|
|
|
{
|
|
|
|
|
var domains = ('domains' in aObserver) ? aObserver.domains : [aObserver.domain] ;
|
|
|
|
|
try {
|
|
|
|
|
var pbi = this.Prefs.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
|
|
|
|
for (var i = 0; i < domains.length; i++)
|
|
|
|
|
pbi.addObserver(domains[i], aObserver, false);
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
removePrefListener : function(aObserver)
|
|
|
|
|
{
|
|
|
|
|
var domains = ('domains' in aObserver) ? aObserver.domains : [aObserver.domain] ;
|
|
|
|
|
try {
|
|
|
|
|
var pbi = this.Prefs.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
|
|
|
|
for (var i = 0; i < domains.length; i++)
|
|
|
|
|
pbi.removeObserver(domains[i], aObserver, false);
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2008-02-26 11:24:25 -05:00
|
|
|
|
window.addEventListener('DOMContentLoaded', TreeStyleTabService, true);
|
2007-10-16 13:22:28 -04:00
|
|
|
|
window.addEventListener('load', TreeStyleTabService, false);
|
2007-11-17 00:20:26 -05:00
|
|
|
|
|