From d9d02b036c47c414c0d8a450f8804284e86b7005 Mon Sep 17 00:00:00 2001 From: piro Date: Sat, 20 Oct 2007 06:12:22 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=83=96=E3=81=AE=E3=83=89=E3=83=AD?= =?UTF-8?q?=E3=83=83=E3=83=97=E4=BD=8D=E7=BD=AE=E3=81=AE=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1240 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.css | 15 +- content/treestyletab/treestyletab.js | 184 +++++++++++------- skin/classic/treestyletab/dropmarker-down.png | Bin 0 -> 356 bytes skin/classic/treestyletab/dropmarker-left.png | Bin 0 -> 292 bytes .../classic/treestyletab/dropmarker-right.png | Bin 0 -> 292 bytes skin/classic/treestyletab/dropmarker-up.png | Bin 0 -> 351 bytes skin/classic/treestyletab/treestyletab.css | 52 +++-- 7 files changed, 163 insertions(+), 88 deletions(-) create mode 100644 skin/classic/treestyletab/dropmarker-down.png create mode 100644 skin/classic/treestyletab/dropmarker-left.png create mode 100644 skin/classic/treestyletab/dropmarker-right.png create mode 100644 skin/classic/treestyletab/dropmarker-up.png diff --git a/content/treestyletab/treestyletab.css b/content/treestyletab/treestyletab.css index 14584cc0..5447a21a 100644 --- a/content/treestyletab/treestyletab.css +++ b/content/treestyletab/treestyletab.css @@ -1,11 +1,18 @@ @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); -tab:not([treestyletab-children]) .treestyletab-tab-tree-twisty, -tab:not([treestyletab-children]) .treestyletab-tab-tree-counter-container, -tab:not([treestyletab-subtree-collapsed="true"]) .treestyletab-tab-tree-counter-container { +tab .treestyletab-twisty, +tab .treestyletab-counter-container, +tab .treestyletab-drop-marker, +tab[treestyletab-children]:not([treestyletab-subtree-collapsed="true"]) .treestyletab-counter-container { display: none; } -tab[treestyletab-tab-collapsed="true"] { +tab[treestyletab-children] .treestyletab-twisty, +tab[treestyletab-children] .treestyletab-counter-container, +tab[treestyletab-drop-position] .treestyletab-drop-marker { + display: -moz-box; +} + +tab[treestyletab-collapsed="true"] { visibility: collapse; } diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 334e1a61..4e35ea23 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -6,14 +6,17 @@ var TreeStyleTabService = { kPARENT : 'treestyletab-parent', kINSERT_BEFORE : 'treestyletab-insert-before', kSUBTREE_COLLAPSED : 'treestyletab-subtree-collapsed', - kCOLLAPSED : 'treestyletab-tab-collapsed', + kCOLLAPSED : 'treestyletab-collapsed', kNEST : 'treestyletab-nest', kDROP_POSITION : 'treestyletab-drop-position', + kVERTICAL : 'treestyletab-vertical', - kTWISTY : 'treestyletab-tab-tree-twisty', - kTWISTY_CONTAINER : 'treestyletab-tab-tree-twisty-container', - kCOUNTER : 'treestyletab-tab-tree-counter', - kCOUNTER_CONTAINER : 'treestyletab-tab-tree-counter-container', + 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', kMENUITEM_REMOVESUBTREE_SELECTION : 'multipletab-selection-item-removeTabSubTree', kMENUITEM_REMOVESUBTREE_CONTEXT : 'context-item-removeTabSubTree', @@ -29,9 +32,9 @@ var TreeStyleTabService = { kACTION_ATTACH : 2, kACTION_PART : 4, - levelMargin : 12, - positionProp : 'screenY', - sizeProp : 'height', + levelMargin : 12, + positionProp : 'screenY', + sizeProp : 'height', NSResolver : { lookupNamespaceURI : function(aPrefix) @@ -79,12 +82,15 @@ var TreeStyleTabService = { isEventFiredOnTwisty : function(aEvent) { - var node = aEvent.originalTarget; - while (node.getAttribute('class') != this.kTWISTY && node.localName != 'tabs') - { - node = node.parentNode; - } - return (node && node.getAttribute('class') == this.kTWISTY) ? true : false ; + var tab = this.getTabFromEvent(aEvent); + var twisty = document.getAnonymousElementByAttribute(tab, 'class', this.kTWISTY); + if (!twisty || !tab.hasAttribute(this.kCHILDREN)) return false; + + var box = twisty.parentNode.parentNode.boxObject; + return !(aEvent.screenX < box.screenX || + aEvent.screenX > box.screenX + box.width || + aEvent.screenY < box.screenY || + aEvent.screenY > box.screenY + box.height); }, get browser() @@ -287,6 +293,8 @@ var TreeStyleTabService = { aTabBrowser.mTabContainer.addEventListener('select', this, true); aTabBrowser.mPanelContainer.addEventListener('click', this, true); + aTabBrowser.setAttribute(this.kVERTICAL, true); + eval('aTabBrowser.mTabContainer.selectNewTab = '+ aTabBrowser.mTabContainer.selectNewTab.toSource().replace( /\{/, @@ -341,7 +349,7 @@ var TreeStyleTabService = { ).replace( /return true;/, <> @@ -381,52 +378,69 @@ catch(e) { '{', <> ) ); + eval('aTabBrowser.onDragExit = '+ + aTabBrowser.onDragExit.toSource().replace( + /(this.mTabDropIndicatorBar\.[^;]+;)/, + '$1; TreeStyleTabService.clearDropPosition(this);' + ) + ); + eval('aTabBrowser.onDrop = '+ aTabBrowser.onDrop.toSource().replace( + '{', '{ TreeStyleTabService.clearDropPosition(this);' + ).replace( /(if \([^\)]+\) \{)/, '$1'+<> ) ); @@ -583,13 +597,20 @@ catch(e) { if (!document.getAnonymousElementByAttribute(aTab, 'class', this.kTWISTY)) { var twisty = document.createElement('image'); twisty.setAttribute('class', this.kTWISTY); - var container = document.createElement('hbox'); container.setAttribute('class', this.kTWISTY_CONTAINER); container.appendChild(twisty); var icon = document.getAnonymousElementByAttribute(aTab, 'class', 'tab-icon'); icon.appendChild(container); + + var marker = document.createElement('image'); + marker.setAttribute('class', this.kDROP_MARKER); + container = document.createElement('hbox'); + container.setAttribute('class', this.kDROP_MARKER_CONTAINER); + container.appendChild(marker); + + icon.appendChild(container); } if (!document.getAnonymousElementByAttribute(aTab, 'class', this.kCOUNTER_CONTAINER)) { @@ -934,7 +955,7 @@ catch(e) { }, /* Tab Utilities */ - + getTabValue : function(aTab, aKey) { var value = null; @@ -1126,7 +1147,23 @@ catch(e) { return lastChild; }, - getDropAction : function(aEvent) + getDropAction : function(aEvent, aDragSession) + { + var info = this.getDropActionInternal(aEvent); + info.canDrop = true; + if (info.action & this.kACTION_ATTACH) { + var orig = aDragSession.sourceNode; + var tab = info.target; + while (tab = this.getParentTab(tab)) + { + if (tab != orig) continue; + info.canDrop = false; + break; + } + } + return info; + }, + getDropActionInternal : function(aEvent) { var tab = aEvent.target; var b = this.getTabBrowserFromChildren(tab); @@ -1244,9 +1281,22 @@ catch(e) { return info; }, - + + clearDropPosition : function(aTabBrowser) + { + var b = this.getTabBrowserFromChildren(aTabBrowser); + var xpathResult = this.evaluateXPath( + 'child::xul:tab[@'+this.kDROP_POSITION+']', + b.mTabContainer + ); + for (var i = 0, maxi = xpathResult.snapshotLength; i < maxi; i++) + { + xpathResult.snapshotItem(i).removeAttribute(this.kDROP_POSITION); + } + }, + /* Commands */ - + /* attach/part */ attachTabTo : function(aChild, aParent, aInfo) @@ -1375,7 +1425,7 @@ catch(e) { }, /* move */ - + moveTabSubTreeTo : function(aTab, aIndex) { if (!aTab) return; @@ -1433,7 +1483,7 @@ catch(e) { }, /* collapse/expand */ - + collapseExpandTabSubTree : function(aTab, aCollapse) { if (!aTab) return; @@ -1542,7 +1592,7 @@ catch(e) { b.removeTab(tabs[i]); } }, - + /* Pref Listener */ domain : 'extensions.treestyletab', diff --git a/skin/classic/treestyletab/dropmarker-down.png b/skin/classic/treestyletab/dropmarker-down.png new file mode 100644 index 0000000000000000000000000000000000000000..eed51ec99d5a3a4818aff49287369e2dc28401c6 GIT binary patch literal 356 zcmV-q0h|7bP)=_zaTtd2=Wpb$Huo)EGg+ud!#a+01BDO^_ z>^MPC7+RF$7R0!y$h9krvOX^C3=1~7pj;Z7&fsTogE_|h(ifgzd6kIl1Bbviu*CfP z1fGEhB_g#}tJU^>f9)RxKomu9jYgxcM5HDn=RpwcMp3jd5Ba|T9fn~~DRrepL;*)- zS)O{Hx0NKxOys(*#Bn^(H0=hsS0Vzi2pkWG!xP)K*ZckcA7q*)-EQ|)*Y#WA4)_{F z_#Ngf&-1!vSt~_R08pt^NYk`145JNPj|O5A0;~efEXxio%UT9V)AXZStv&)x;C&oU zLx2t7veW780XUBH1Y7_wlhG^)umfz4{sGXN4t@aVWoyk!W@Fd@0000~3H+-IP(#WBdfm`Vomm=Go&!4TYFl^B5N|I$c zsKIksN-%a+fcODN&8=T*_shFpyxaX^)j~yvd8s#h46pfJ{<1U5Ihi5G>*bAYch7wO zqq?ANkBXnh`!&J6XI7qhc2R%!lVGxA;$JtOrM(5nm#p00i_>zopr0Eabor~m)} literal 0 HcmV?d00001 diff --git a/skin/classic/treestyletab/dropmarker-right.png b/skin/classic/treestyletab/dropmarker-right.png new file mode 100644 index 0000000000000000000000000000000000000000..b1b0ea39c189702687c304e44a01adec48134523 GIT binary patch literal 292 zcmV+<0o(qGP)HTu2Z5~rlyS(fcY z=llLOFaVOe5n<^&&0000={~a1?;??{9EPSsEG+o8f|67}tl%yRtS!<3%xS z99onE1;MckV!S5e>cX0ESy{LpXt2ozWtQQkGx#ibpfc`DFT5W-o)Qr%Y5?`w{0uz) zUr-fr6F5uLbQ_@6YTW~;z{?`I26Xd0-?eRf6(Gy9Pt!E-fG+S}1y_LM@p#;}ZQCe{ z0szA>$g=FCR;%@a3t;jaE&~T;Sspr$voRbF|J-g_7K6dyRoC?^;2QW+BBFr(>2!MJ zd0st95>@pr*L8{G_({{WOW;O{NK-^kI-O1lv3wPM4G)`uO9@# x`XV$hilR5)_uEQDc7Q!#YxbZ;O@I+_`vc3bYR%e&qu>Al002ovPDHLkV1hImkJ