DOMイベントの方を使うようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4445 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-05-15 17:11:01 +00:00
parent 67b5e27a91
commit 5decba2df2
5 changed files with 74 additions and 66 deletions

View File

@ -401,9 +401,21 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function() {
)
);
TreeStyleTabService.registerCollapseExpandPostProcess(function() {
tabBarScrollStatus();
});
let listener = {
handleEvent : function(aEvent)
{
case 'TreeStyleTabCollapsedStateChange':
tabBarScrollStatus();
break;
case 'unload':
window.removeEventListener('TreeStyleTabCollapsedStateChange', this, false);
window.removeEventListener('unload', this, false);
break;
}
};
window.addEventListener('TreeStyleTabCollapsedStateChange', listener, false);
window.addEventListener('unload', listener, false);
TreeStyleTabBrowser.prototype.isMultiRow = function()
{
@ -506,18 +518,32 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function() {
// ColorfulTab
if ('clrtabsInit' in window) {
this.registerAttachTabPostProcess(function(aChild, aParent, aService) {
if (aChild && aParent) {
setColor(aChild, aService.SessionStore.getTabValue(aParent, 'tabClr'));
}
else if (aChild) {
aService.SessionStore.setTabValue(aChild, 'tabClr', '')
calcTabClr({
target : aChild,
originalTarget : aChild,
});
}
});
let listener = {
handleEvent : function(aEvent)
{
case 'TreeStyleTabAttached':
var child = aEvent.originalTarget;
var parent = aEvent.parentTab;
if (child && parent) {
setColor(child, TreeStyleTabService.SessionStore.getTabValue(parent, 'tabClr'));
}
else if (child) {
TreeStyleTabService.SessionStore.setTabValue(child, 'tabClr', '')
calcTabClr({
target : child,
originalTarget : child,
});
}
break;
case 'unload':
window.removeEventListener('TreeStyleTabAttached', this, false);
window.removeEventListener('unload', this, false);
break;
}
};
window.addEventListener('TreeStyleTabAttached', listener, false);
window.addEventListener('unload', listener, false);
}
// FLST
@ -688,34 +714,36 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function() {
// Autohide
if ('autoHIDE' in window) {
TreeStyleTabService.registerTabbarAutoShowPostProcess(function(aTabBrowser) {
if (!window.fullScreen) return;
aTabBrowser.mStrip.removeAttribute('ahHIDE');
if (
autoHIDE.statBar &&
aTabBrowser.getAttribute(aTabBrowser.treeStyleTab.kTABBAR_POSITION) == 'bottom' &&
!aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') &&
aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar')
) {
autoHIDE.statBar.removeAttribute('ahHIDE');
}
});
TreeStyleTabService.registerTabbarAutoHidePostProcess(function(aTabBrowser) {
if (!window.fullScreen) return;
if (
autoHIDE.statBar &&
aTabBrowser.getAttribute(aTabBrowser.treeStyleTab.kTABBAR_POSITION) == 'bottom' &&
!aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') &&
aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar')
) {
autoHIDE.statBar.setAttribute('ahHIDE', true);
}
});
var autoHideEventListener = {
let autoHideEventListener = {
handleEvent : function(aEvent)
{
switch (aEvent.type)
{
case 'TreeStyleTabAutoHideStateChange':
if (!window.fullScreen) return;
if (aEvent.collapsed) {
if (
autoHIDE.statBar &&
gBrowser.getAttribute(gBrowser.treeStyleTab.kTABBAR_POSITION) == 'bottom' &&
!gBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') &&
gBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar')
) {
autoHIDE.statBar.setAttribute('ahHIDE', true);
}
}
else {
gBrowser.mStrip.removeAttribute('ahHIDE');
if (
autoHIDE.statBar &&
aTabBrowser.getAttribute(gBrowser.treeStyleTab.kTABBAR_POSITION) == 'bottom' &&
!aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') &&
aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar')
) {
autoHIDE.statBar.removeAttribute('ahHIDE');
}
}
break;
case 'fullscreen':
var treeStyleTab = gBrowser.treeStyleTab;
if (gBrowser.getAttribute(treeStyleTab.kTABBAR_POSITION) != 'top') {
@ -728,12 +756,14 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function() {
case 'unload':
var t = aEvent.currentTarget;
t.removeEventListener('TreeStyleTabAutoHideStateChange', this, false);
t.removeEventListener('unload', this, false);
t.removeEventListener('fullscreen', this, false);
break;
}
}
};
window.addEventListener('TreeStyleTabAutoHideStateChange', autoHideEventListener, false);
window.addEventListener('fullscreen', autoHideEventListener, false);
window.addEventListener('unload', autoHideEventListener, false);
}

View File

@ -2265,12 +2265,6 @@ catch(e) {
);
},
registerAttachTabPostProcess : function(aProcess) /* PUBLIC API */
{
this._attachTabPostProcesses.push(aProcess);
},
_attachTabPostProcesses : [],
registerTabFocusAllowance : function(aProcess) /* PUBLIC API */
{
this._tabFocusAllowance.push(aProcess);
@ -2283,23 +2277,6 @@ catch(e) {
},
_expandTwistyAreaAllowance : [],
registerCollapseExpandPostProcess : function(aProcess) /* PUBLIC API */
{
this._collapseExpandPostProcess.push(aProcess);
},
_collapseExpandPostProcess : [],
registerTabbarAutoShowPostProcess : function(aProcess) /* PUBLIC API */
{
this._tabbarAutoShowPostProcess.push(aProcess);
},
registerTabbarAutoHidePostProcess : function(aProcess) /* PUBLIC API */
{
this._tabbarAutoHidePostProcess.push(aProcess);
},
_tabbarAutoShowPostProcess : [],
_tabbarAutoHidePostProcess : [],
tearOffSubTreeFromRemote : function()
{
var remoteTab = window.arguments[0];

View File

@ -2814,7 +2814,10 @@ TreeStyleTabBrowser.prototype = {
this.checkTabsIndentOverflow();
}
this.attachTabPostProcess(aChild, aParent);
var event = document.createEvent('Events');
event.initEvent('TreeStyleTabAttached', true, true);
event.parentTab = aParent;
aChild.dispatchEvent(event);
},
attachTabPostProcess : function(aChild, aParent)
{

View File

@ -237,8 +237,8 @@ function test_cleanUpTabsArray()
/*
sv.registerAttachTabPostProcess(func)
sv.registerTabFocusAllowance(func)
sv.registerExpandTwistyAreaAllowance(func)
*/

View File

@ -16,7 +16,5 @@ sv.getChildIndex(tab, parent)
sv.removeTabSubTree(tabs, onlychildren)
sv.collapseExpandAllSubtree(collapse)
sv.registerCollapseExpandPostProcess(func)
*/