From e81324719be558e8d60ce5d3973bbe17dffebd26 Mon Sep 17 00:00:00 2001 From: piro Date: Tue, 22 Dec 2009 08:05:16 +0000 Subject: [PATCH] =?UTF-8?q?=E7=8F=BE=E5=9C=A8=E3=81=AE=E3=82=BF=E3=83=96?= =?UTF-8?q?=E3=82=92=E9=96=89=E3=81=98=E3=81=9F=E6=99=82=E3=81=AB=E3=80=81?= =?UTF-8?q?=E4=BA=88=E6=83=B3=E3=81=A0=E3=81=AB=E3=81=97=E3=81=AA=E3=81=84?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E3=81=AE=E3=82=BF=E3=83=96=E3=81=AB=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=BC=E3=82=AB=E3=82=B9=E3=81=8C=E9=A3=9B=E3=82=93?= =?UTF-8?q?=E3=81=A7=E3=81=97=E3=81=BE=E3=81=86=E3=81=93=E3=81=A8=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=81=A3=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20http://piro.sakura.ne.jp/cgi-bin/bbs.cgi=3F2577=20=EF=BC=88?= =?UTF-8?q?=E8=A6=AA=E3=82=BF=E3=83=96=E3=82=92=E9=96=89=E3=81=98=E3=81=9F?= =?UTF-8?q?=E5=BE=8C=E3=81=AB=E5=AD=90=E3=82=BF=E3=83=96=E3=81=8C=E8=A6=AA?= =?UTF-8?q?=E3=81=AE=E9=9A=8E=E5=B1=A4=E3=81=AB=E7=B5=84=E3=81=BF=E8=BE=BC?= =?UTF-8?q?=E3=81=BE=E3=82=8C=E3=81=9F=E6=99=82=E3=80=81=E5=86=85=E9=83=A8?= =?UTF-8?q?=E7=9A=84=E3=81=AA=E3=82=BF=E3=83=96=E3=81=AE=E4=B8=A6=E3=81=B3?= =?UTF-8?q?=E9=A0=86=E3=81=8C=E5=AE=9F=E9=9A=9B=E3=81=AE=E4=B8=A6=E3=81=B3?= =?UTF-8?q?=E9=A0=86=E3=81=A8=E7=95=B0=E3=81=AA=E3=82=8B=E7=8A=B6=E6=85=8B?= =?UTF-8?q?=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86?= =?UTF-8?q?=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82=E3=81=A3=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=EF=BC=89?= 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@5590 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 54 +++++++++++---------- content/treestyletab/treestyletabbrowser.js | 10 +++- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 553f5983..c8f46cd3 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -977,7 +977,7 @@ var TreeStyleTabService = { var parentTab = this.getParentTab(aTab); if (!parentTab) { - var next = aTab; + let next = aTab; do { next = next.nextSibling; } @@ -989,10 +989,10 @@ var TreeStyleTabService = { 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++) + let list = ('|'+children).split('|'+aTab.getAttribute(this.kID))[1].split('|'); + for (let i = 0, maxi = list.length; i < maxi; i++) { - var firstChild = this.getTabById(list[i], aTab); + let firstChild = this.getTabById(list[i], aTab); if (firstChild) return firstChild; } } @@ -1006,7 +1006,7 @@ var TreeStyleTabService = { var parentTab = this.getParentTab(aTab); if (!parentTab) { - var prev = aTab; + let prev = aTab; do { prev = prev.previousSibling; } @@ -1018,10 +1018,10 @@ var TreeStyleTabService = { 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--) + let list = ('|'+children).split('|'+aTab.getAttribute(this.kID))[0].split('|'); + for (let i = list.length-1; i > -1; i--) { - var lastChild = this.getTabById(list[i], aTab); + let lastChild = this.getTabById(list[i], aTab); if (lastChild) return lastChild; } } @@ -1039,10 +1039,9 @@ var TreeStyleTabService = { if (aAllTabsArray) tabs = aAllTabsArray; var list = children.split('|'); - var tab; - for (var i = 0, maxi = list.length; i < maxi; i++) + for (let i = 0, maxi = list.length; i < maxi; i++) { - tab = this.getTabById(list[i], aTab); + let tab = this.getTabById(list[i], aTab); if (!tab) continue; tabs.push(tab); if (aAllTabsArray) @@ -1072,8 +1071,8 @@ var TreeStyleTabService = { 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++) + let list = children.split('|'); + for (let i = 0, maxi = list.length; i < maxi; i++) { firstChild = this.getTabById(list[i], aTab); if (firstChild) break; @@ -1089,8 +1088,8 @@ var TreeStyleTabService = { var children = aTab.getAttribute(this.kCHILDREN); var lastChild = null; if (children) { - var list = children.split('|'); - for (var i = list.length-1; i > -1; i--) + let list = children.split('|'); + for (let i = list.length-1; i > -1; i--) { lastChild = this.getTabById(list[i], aTab); if (lastChild) break; @@ -1123,18 +1122,18 @@ var TreeStyleTabService = { } 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++) + let children = aParent.getAttribute(this.kCHILDREN); + let list = children.split('|'); + let id = aTab.getAttribute(this.kID); + for (let 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++) + let tabs = this.rootTabs; + for (let i = 0, maxi = tabs.length; i < maxi; i++) { if (tabs[i] == aTab) return i; } @@ -1186,7 +1185,7 @@ var TreeStyleTabService = { } if (this.useTMPSessionAPI) { - var TMPValue = aTab.getAttribute(this.kTMP_SESSION_DATA_PREFIX+aKey); + let TMPValue = aTab.getAttribute(this.kTMP_SESSION_DATA_PREFIX+aKey); if (TMPValue) value = TMPValue; } @@ -2552,12 +2551,15 @@ catch(e) { if (!aTab.parentNode) return; // ignore removed tabs if (newTabs.indexOf(aTab) < 0) newTabs.push(aTab); }); - newTabs.sort(function(aA, aB) { - return aA._tPos - aB._tPos; - }); + newTabs.sort(this.sortTabsByOrder); return newTabs; }, - + + sortTabsByOrder : function(aA, aB) + { + return aA._tPos - aB._tPos; + }, + reloadTabSubTree : function(aTabOrTabs, aOnlyChildren) { var tabs = this._normalizeToTabs(aTabOrTabs, aOnlyChildren); diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 95d7f05c..c274e140 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -1831,7 +1831,7 @@ TreeStyleTabBrowser.prototype = { updateChildrenArray : function(aTab) { var children = this.getChildTabs(aTab); - children.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); + children.sort(this.sortTabsByOrder); this.setTabValue( aTab, this.kCHILDREN, @@ -2985,6 +2985,14 @@ TreeStyleTabBrowser.prototype = { } else { children.push(id); + if (aInfo.dontMove && children.length > 1) { + children = children + .map(this.getTabById, this) + .sort(this.sortTabsByOrder) + .map(function(aTab) { + return aTab.getAttribute(this.kID); + }, this); + } let refTab = aParent; let descendant = this.getDescendantTabs(aParent); if (descendant.length) refTab = descendant[descendant.length-1];