タブバーの位置が変更される前後で常にイベントを発行するようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5615 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-12-25 09:49:47 +00:00
parent 11f04a3505
commit b6bd8ed487
2 changed files with 70 additions and 47 deletions

View File

@ -258,6 +258,52 @@ TreeStyleTabService.overrideExtensionsOnInitBefore = function TSTService_overrid
);
}
// Tabberwocky
// https://addons.mozilla.org/firefox/addon/14439
if ('tabberwocky' in window) {
TreeStyleTabBrowser.prototype.isMultiRow = function()
{
return this.getPref('tabberwocky.multirow') && !this.isVertical;
};
let listener = {
handleEvent : function(aEvent)
{
switch (aEvent.type)
{
case 'TreeStyleTabTabbarPositionChanged':
var b = aEvent.originalTarget;
if (b.treeStyleTab.isVertical)
b.treeStyleTab.setPref('tabberwocky.multirow', false);
break;
case 'unload':
window.removeEventListener('TreeStyleTabTabbarPositionChanged', this, false);
window.removeEventListener('unload', this, false);
break;
}
}
};
window.addEventListener('TreeStyleTabTabbarPositionChanged', listener, false);
window.addEventListener('unload', listener, false);
if ('openSelectedLinks' in tabberwocky) {
eval('tabberwocky.openSelectedLinks = '+
tabberwocky.openSelectedLinks.toSource().replace(
'links.forEach(',
<![CDATA[
TreeStyleTabService.readyToOpenChildTab(aFrame, true)
$&]]>
).replace(
/(\}\)?)$/,
<![CDATA[
TreeStyleTabService.stopToOpenChildTab(aFrame)
$1]]>
)
);
}
}
};
TreeStyleTabService.overrideExtensionsOnInitAfter = function TSTService_overrideExtensionsOnInitAfter() {
@ -932,36 +978,6 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function TSTService_override
}
}
// Tabberwocky
// https://addons.mozilla.org/firefox/addon/14439
if ('multirow' in window &&
'updateMultiRowTabs' in multirow) {
eval('multirow.updateMultiRowTabs = '+
multirow.updateMultiRowTabs.toSource().replace(
'gBrowser.mPrefs.getBoolPref("tabberwocky.multirow")',
'$& && !gBrowser.treeStyleTab.isVertical'
)
);
window.setTimeout('multirow.updateMultiRowTabs();', 0);
}
if ('tabberwocky' in window) {
if ('openSelectedLinks' in tabberwocky) {
eval('tabberwocky.openSelectedLinks = '+
tabberwocky.openSelectedLinks.toSource().replace(
'links.forEach(',
<![CDATA[
TreeStyleTabService.readyToOpenChildTab(aFrame, true)
$&]]>
).replace(
/(\}\)?)$/,
<![CDATA[
TreeStyleTabService.stopToOpenChildTab(aFrame)
$1]]>
)
);
}
}
window.setTimeout(function(aSelf) {
aSelf.overrideExtensionsDelayed();
}, 0, this);

View File

@ -148,6 +148,9 @@ TreeStyleTabBrowser.prototype = {
}
}
let position = this.currentTabbarPosition;
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanging', 'top', position); /* PUBLIC API */
this.initTabbar();
b.addEventListener('TabOpen', this, true);
@ -583,6 +586,8 @@ TreeStyleTabBrowser.prototype = {
this.autoHide;
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanged', 'top', position); /* PUBLIC API */
b = null;
},
@ -1059,6 +1064,17 @@ TreeStyleTabBrowser.prototype = {
}
}, 100);
},
fireTabbarPositionEvent : function TSTBrowser_fireTabbarPositionEvent(aType, aOldPosition, aNewPosition)
{
if (aOldPosition == aNewPosition) return;
var event = document.createEvent('Events');
event.initEvent(aType, true, true);
event.oldPosition = aOldPosition;
event.newPosition = aNewPosition;
this.mTabBrowser.dispatchEvent(event);
},
destroy : function TSTBrowser_destroy()
{
@ -1174,14 +1190,7 @@ TreeStyleTabBrowser.prototype = {
{
case 'extensions.treestyletab.tabbar.position':
var oldPosition = b.getAttribute(this.kTABBAR_POSITION);
let (event) {
/* PUBLIC API */
event = document.createEvent('Events');
event.initEvent('TreeStyleTabTabbarPositionChanging', true, true);
event.oldPosition = oldPosition;
event.newPosition = value;
this.mTabBrowser.dispatchEvent(event);
}
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanging', oldPosition, value); /* PUBLIC API */
this.initTabbar();
tabs.forEach(function(aTab) {
this.initTabAttributes(aTab);
@ -1189,14 +1198,7 @@ TreeStyleTabBrowser.prototype = {
tabs.forEach(function(aTab) {
this.initTabContents(aTab);
}, this);
let (event) {
/* PUBLIC API */
event = document.createEvent('Events');
event.initEvent('TreeStyleTabTabbarPositionChanged', true, true);
event.oldPosition = oldPosition;
event.newPosition = value;
this.mTabBrowser.dispatchEvent(event);
}
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanged', oldPosition, value); /* PUBLIC API */
window.setTimeout(function(aSelf) {
aSelf.checkTabsIndentOverflow();
}, 0, this);
@ -1698,7 +1700,12 @@ TreeStyleTabBrowser.prototype = {
if (
nextFocusedTab &&
this._tabFocusAllowance.every(function(aFunc) {
return aFunc.call(this, b);
try {
return aFunc.call(this, b);
}
catch(e) {
return false;
}
}, this)
)
b.selectedTab = nextFocusedTab;