From 9177cf7832765e4375fb0b3b6893126706abfaf0 Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 31 Jul 2009 02:16:46 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=88=86?= =?UTF-8?q?=E5=89=B2?= 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@4850 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/editBookmarkOverlay.js | 30 +++++++++++++-------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/content/treestyletab/editBookmarkOverlay.js b/content/treestyletab/editBookmarkOverlay.js index 3fad1776..a4f67f5c 100644 --- a/content/treestyletab/editBookmarkOverlay.js +++ b/content/treestyletab/editBookmarkOverlay.js @@ -68,12 +68,28 @@ var TreeStyleTabBookmarksProperty = { range.selectNodeContents(popup); range.setEndBefore(this.separator); range.deleteContents(); + var fragment = this._createSiblingsFragment(id); + var siblings = Array.slice(fragment.childNodes) + .map(function(aItem) { + return parseInt(aItem.getAttribute('value')); + }); + range.insertNode(fragment); + range.detach(); - var siblings = this._getItemsInFolder(PlacesUtils.bookmarks.getFolderIdForItem(id)); + var index = siblings.indexOf(parent); + var current = siblings.indexOf(id); + if (index < 0 || index >= current) + this.menulist.selectedItem = this.blankItem; + else + this.menulist.value = parent; + }, + _createSiblingsFragment : function(aId) + { var fragment = document.createDocumentFragment(); var afterCurrent = false; var parents = {}; - parents[id] = parent; + parents[aId] = TreeStyleTabService.getParentItemForBookmarkItem(aId); + var siblings = this._getItemsInFolder(PlacesUtils.bookmarks.getFolderIdForItem(aId)); siblings.forEach(function(aId) { let item = document.createElement('menuitem'); item.setAttribute('label', PlacesUtils.bookmarks.getItemTitle(aId)); @@ -95,15 +111,7 @@ var TreeStyleTabBookmarksProperty = { fragment.appendChild(item); }); - range.insertNode(fragment); - range.detach(); - - var index = siblings.indexOf(parent); - var current = siblings.indexOf(id); - if (index < 0 || index >= current) - this.menulist.selectedItem = this.blankItem; - else - this.menulist.value = parent; + return fragment; }, _getItemsInFolder : function(aId) {