親タブ選択用リストをインデント表示

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4841 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-07-30 17:36:02 +00:00
parent 968c70635b
commit cdb0ad6a4e
3 changed files with 29 additions and 17 deletions

View File

@ -16,13 +16,7 @@ window.addEventListener('load', function() {
<![CDATA[
var openGroupBookmarkBehavior = TreeStyleTabService.openGroupBookmarkBehavior();
var treeStructure = ids.map(function(aId) {
let annotations = PlacesUtils.getAnnotationsForItem(aId);
for (let i in annotations)
{
if (annotations[i].name != TreeStyleTabService.kPARENT) continue;
return ids.indexOf(annotations[i].value);
}
return -1;
return ids.indexOf(TreeStyleTabService.getParentItemForBookmark(aId));
});
treeStructure = treeStructure.reverse();
treeStructure = treeStructure.map(function(aPosition, aIndex) {

View File

@ -61,6 +61,7 @@ var TreeStyleTabBookmarksProperty = {
initParentMenuList : function()
{
var id = gEditItemOverlay.itemId;
var parent = TreeStyleTabService.getParentItemForBookmark(id);
var popup = this.popup;
var range = document.createRange();
@ -71,26 +72,32 @@ var TreeStyleTabBookmarksProperty = {
var siblings = this._getItemsInFolder(PlacesUtils.bookmarks.getFolderIdForItem(id));
var fragment = document.createDocumentFragment();
var afterCurrent = false;
var parents = {};
parents[id] = parent;
siblings.forEach(function(aId) {
let item = document.createElement('menuitem');
item.setAttribute('label', PlacesUtils.bookmarks.getItemTitle(aId));
item.setAttribute('value', aId);
let parent;
let current = aId;
let nest = 0;
while ((parent = current in parents ? parents[current] : TreeStyleTabService.getParentItemForBookmark(current) ) != -1)
{
if (siblings.indexOf(parent) >= siblings.indexOf(current)) break;
nest++;
current = parent;
}
if (nest) item.setAttribute('style', 'padding-left:'+nest+'em');
if (!afterCurrent && aId == id) afterCurrent = true;
if (afterCurrent) item.setAttribute('disabled', true);
fragment.appendChild(item);
});
range.insertNode(fragment);
range.detach();
var annotations = PlacesUtils.getAnnotationsForItem(id);
var parent = -1;
for (let i in annotations)
{
if (annotations[i].name != TreeStyleTabService.kPARENT) continue;
parent = parseInt(annotations[i].value);
break;
}
var index = siblings.indexOf(parent);
var current = siblings.indexOf(id);
if (index < 0 || index >= current)

View File

@ -2595,8 +2595,19 @@ catch(e) {
this._addingBookmarkTreeStructure = [];
},
getParentItemForBookmark : function(aId)
{
var annotations = PlacesUtils.getAnnotationsForItem(aId);
for (let i in annotations)
{
if (annotations[i].name != this.kPARENT) continue;
return parseInt(annotations[i].value);
}
return -1;
},
// based on PlacesUtils.getURLsForContainerNode()
getItemIdsForContainerNode: function(aNode)
getItemIdsForContainerNode : function(aNode)
{
var ids = [];
if (!PlacesUtils.nodeIsContainer(aNode)) return ids;