無駄を減らした
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4851 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
9177cf7832
commit
37f621e173
@ -61,7 +61,6 @@ var TreeStyleTabBookmarksProperty = {
|
|||||||
initParentMenuList : function()
|
initParentMenuList : function()
|
||||||
{
|
{
|
||||||
var id = gEditItemOverlay.itemId;
|
var id = gEditItemOverlay.itemId;
|
||||||
var parent = TreeStyleTabService.getParentItemForBookmarkItem(id);
|
|
||||||
|
|
||||||
var popup = this.popup;
|
var popup = this.popup;
|
||||||
var range = document.createRange();
|
var range = document.createRange();
|
||||||
@ -76,20 +75,17 @@ var TreeStyleTabBookmarksProperty = {
|
|||||||
range.insertNode(fragment);
|
range.insertNode(fragment);
|
||||||
range.detach();
|
range.detach();
|
||||||
|
|
||||||
var index = siblings.indexOf(parent);
|
var selected = popup.getElementsByAttribute('selected', 'true')[0];
|
||||||
var current = siblings.indexOf(id);
|
this.menulist.value = (selected || this.blankItem).value;
|
||||||
if (index < 0 || index >= current)
|
|
||||||
this.menulist.selectedItem = this.blankItem;
|
|
||||||
else
|
|
||||||
this.menulist.value = parent;
|
|
||||||
},
|
},
|
||||||
_createSiblingsFragment : function(aId)
|
_createSiblingsFragment : function(aCurrentItem)
|
||||||
{
|
{
|
||||||
var fragment = document.createDocumentFragment();
|
var fragment = document.createDocumentFragment();
|
||||||
var afterCurrent = false;
|
var afterCurrent = false;
|
||||||
|
var selected = TreeStyleTabService.getParentItemForBookmarkItem(aCurrentItem);
|
||||||
var parents = {};
|
var parents = {};
|
||||||
parents[aId] = TreeStyleTabService.getParentItemForBookmarkItem(aId);
|
parents[aCurrentItem] = selected;
|
||||||
var siblings = this._getItemsInFolder(PlacesUtils.bookmarks.getFolderIdForItem(aId));
|
var siblings = this._getItemsInFolder(PlacesUtils.bookmarks.getFolderIdForItem(aCurrentItem));
|
||||||
siblings.forEach(function(aId) {
|
siblings.forEach(function(aId) {
|
||||||
let item = document.createElement('menuitem');
|
let item = document.createElement('menuitem');
|
||||||
item.setAttribute('label', PlacesUtils.bookmarks.getItemTitle(aId));
|
item.setAttribute('label', PlacesUtils.bookmarks.getItemTitle(aId));
|
||||||
@ -106,8 +102,9 @@ var TreeStyleTabBookmarksProperty = {
|
|||||||
}
|
}
|
||||||
if (nest) item.setAttribute('style', 'padding-left:'+nest+'em');
|
if (nest) item.setAttribute('style', 'padding-left:'+nest+'em');
|
||||||
|
|
||||||
if (!afterCurrent && aId == id) afterCurrent = true;
|
if (aId == aCurrentItem) afterCurrent = true;
|
||||||
if (afterCurrent) item.setAttribute('disabled', true);
|
if (afterCurrent) item.setAttribute('disabled', true);
|
||||||
|
if (aId == selected && !afterCurrent) item.setAttribute('selected', true);
|
||||||
|
|
||||||
fragment.appendChild(item);
|
fragment.appendChild(item);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user