サブツリーの折りたたみが無効なときや、子タブを持たないタブの場合は、アイコン上でのクリックを無視するようにした(折りたためないタブでまでtwistyのクリックを認識してしまっていたのを修正)

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4184 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-04-27 02:18:17 +00:00
parent 5a263e46a4
commit f954d5da73
2 changed files with 22 additions and 12 deletions

View File

@ -1,33 +1,40 @@
var TreeStyleTabService = { var TreeStyleTabService = {
/* attributes */
kID : 'treestyletab-id', kID : 'treestyletab-id',
kCHILDREN : 'treestyletab-children', kCHILDREN : 'treestyletab-children',
kPARENT : 'treestyletab-parent', kPARENT : 'treestyletab-parent',
kANCESTOR : 'treestyletab-ancestors', kANCESTOR : 'treestyletab-ancestors',
kNEST : 'treestyletab-nest',
kINSERT_BEFORE : 'treestyletab-insert-before', kINSERT_BEFORE : 'treestyletab-insert-before',
kSUBTREE_COLLAPSED : 'treestyletab-subtree-collapsed', kSUBTREE_COLLAPSED : 'treestyletab-subtree-collapsed',
kCOLLAPSED : 'treestyletab-collapsed', kCOLLAPSED : 'treestyletab-collapsed',
kCOLLAPSED_DONE : 'treestyletab-collapsed-done', kCOLLAPSED_DONE : 'treestyletab-collapsed-done',
kCOLLAPSING : 'treestyletab-collapsing', kCOLLAPSING : 'treestyletab-collapsing',
kALLOW_COLLAPSE : 'treestyletab-allow-subtree-collapse',
kX_OFFSET : 'treestyletab-x-offset', kX_OFFSET : 'treestyletab-x-offset',
kY_OFFSET : 'treestyletab-y-offset', kY_OFFSET : 'treestyletab-y-offset',
kTWISTY_HOVER : 'treestyletab-twisty-hover',
kNEST : 'treestyletab-nest',
kDROP_POSITION : 'treestyletab-drop-position',
kTABBAR_POSITION : 'treestyletab-tabbar-position', kTABBAR_POSITION : 'treestyletab-tabbar-position',
kMODE : 'treestyletab-mode', kMODE : 'treestyletab-mode',
kUI_INVERTED : 'treestyletab-appearance-inverted', kUI_INVERTED : 'treestyletab-appearance-inverted',
kSCROLLBAR_INVERTED : 'treestyletab-scrollbar-inverted', kSCROLLBAR_INVERTED : 'treestyletab-scrollbar-inverted',
kALLOW_COLLAPSE : 'treestyletab-allow-subtree-collapse',
kHIDE_NEWTAB : 'treestyletab-hide-newtab-button', kHIDE_NEWTAB : 'treestyletab-hide-newtab-button',
kHIDE_ALLTABS : 'treestyletab-hide-alltabs-button', kHIDE_ALLTABS : 'treestyletab-hide-alltabs-button',
kSTYLE : 'treestyletab-style', kSTYLE : 'treestyletab-style',
kTWISTY_STYLE : 'treestyletab-twisty-style',
kFIRSTTAB_BORDER : 'treestyletab-firsttab-border', kFIRSTTAB_BORDER : 'treestyletab-firsttab-border',
kAUTOHIDE : 'treestyletab-tabbar-autohide', kAUTOHIDE : 'treestyletab-tabbar-autohide',
kFIXED : 'treestyletab-tabbar-fixed', kFIXED : 'treestyletab-tabbar-fixed',
kRESIZING : 'treestyletab-tabbar-resizing', kRESIZING : 'treestyletab-tabbar-resizing',
kTRANSPARENT : 'treestyletab-tabbar-transparent', kTRANSPARENT : 'treestyletab-tabbar-transparent',
kTWISTY_HOVER : 'treestyletab-twisty-hover',
kTWISTY_STYLE : 'treestyletab-twisty-style',
kDROP_POSITION : 'treestyletab-drop-position',
/* classes */
kTWISTY : 'treestyletab-twisty', kTWISTY : 'treestyletab-twisty',
kTWISTY_CONTAINER : 'treestyletab-twisty-container', kTWISTY_CONTAINER : 'treestyletab-twisty-container',
kDROP_MARKER : 'treestyletab-drop-marker', kDROP_MARKER : 'treestyletab-drop-marker',
@ -460,8 +467,8 @@ var TreeStyleTabService = {
return this.hasChildTabs(tab) && this.evaluateXPath( return this.hasChildTabs(tab) && this.evaluateXPath(
'ancestor-or-self::*[@class="'+this.kTWISTY+'" or (ancestor::xul:tabbrowser[@'+this.kMODE+'="vertical"] and @class="tab-icon")]', 'ancestor-or-self::*[@class="'+this.kTWISTY+'" or (ancestor::xul:tabbrowser[@'+this.kMODE+'="vertical"] and @class="tab-icon")]',
aEvent.originalTarget || aEvent.target, aEvent.originalTarget || aEvent.target,
XPathResult.FIRST_ORDERED_NODE_TYPE XPathResult.BOOLEAN_TYPE
).singleNodeValue ? true : false ; ).booleanValue;
}, },
isEventFiredOnClickable : function(aEvent) isEventFiredOnClickable : function(aEvent)
@ -469,8 +476,8 @@ var TreeStyleTabService = {
return this.evaluateXPath( return this.evaluateXPath(
'ancestor-or-self::*[contains(" button toolbarbutton scrollbar popup menupopup tooltip ", concat(" ", local-name(), " "))]', 'ancestor-or-self::*[contains(" button toolbarbutton scrollbar popup menupopup tooltip ", concat(" ", local-name(), " "))]',
aEvent.originalTarget, aEvent.originalTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE XPathResult.BOOLEAN_TYPE
).singleNodeValue ? true : false ; ).booleanValue;
}, },
isAccelKeyPressed : function(aEvent) isAccelKeyPressed : function(aEvent)

View File

@ -1805,9 +1805,12 @@ TreeStyleTabBrowser.prototype = {
if (this.isEventFiredOnTwisty(aEvent)) { if (this.isEventFiredOnTwisty(aEvent)) {
var tab = this.getTabFromEvent(aEvent); var tab = this.getTabFromEvent(aEvent);
this.collapseExpandSubtree(tab, tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true'); if (this.hasChildTabs(tab) &&
aEvent.preventDefault(); this.mTabBrowser.getAttribute(this.kALLOW_COLLAPSE) == 'true') {
aEvent.stopPropagation(); this.collapseExpandSubtree(tab, tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true');
aEvent.preventDefault();
aEvent.stopPropagation();
}
} }
else if (!this.getTabFromEvent(aEvent)) { else if (!this.getTabFromEvent(aEvent)) {
var tab = this.getTabFromTabbarEvent(aEvent); var tab = this.getTabFromTabbarEvent(aEvent);