dummy tab should be saved as a bookmark folder

This commit is contained in:
Piro / SHIMODA Hiroshi 2012-01-28 05:54:25 +09:00
parent 5b5bed7d3d
commit b969cb2800

View File

@ -17,13 +17,13 @@ var TreeStyleTabBookmarksService = {
if (this._observing) return; if (this._observing) return;
this._observing = true; this._observing = true;
aTabs = this.cleanUpTabsArray(aTabs);
this._addingBookmarks = []; this._addingBookmarks = [];
this._addingBookmarkTreeStructure = this this._addingBookmarkTreeStructure = aTabs.map(function(aTab) {
.cleanUpTabsArray(aTabs) var parent = this.getParentTab(aTab);
.map(function(aTab) { return aTabs.indexOf(parent);
var parent = this.getParentTab(aTab); }, this);
return aTabs.indexOf(parent);
}, this);
this.BookmarksService.addObserver(this, false); this.BookmarksService.addObserver(this, false);
}, },
@ -52,13 +52,39 @@ var TreeStyleTabBookmarksService = {
return; return;
} }
aBookarmks.forEach(function(aItem) {
aItem.position = this.BookmarksService.getItemIndex(aItem.id);
},this);
aBookarmks.sort(function(aA, aB) {
return aA.position - aB.position;
});
aBookarmks.forEach(function(aItem, aIndex) { aBookarmks.forEach(function(aItem, aIndex) {
if (this.BookmarksService.getItemType(aItem.id) != this.BookmarksService.TYPE_BOOKMARK)
return;
let uri = this.BookmarksService.getBookmarkURI(aItem.id);
if (/^about:treestyletab-group\b/.test(uri.spec)) {
let title = this.BookmarksService.getItemTitle(aItem.id);
let folderId = this.BookmarksService.createFolder(aItem.parent, title, aItem.position);
this.BookmarksService.removeItem(aItem.id);
aItem.id = folderId;
aItem.isFolder = true;
aBookarmks[aIndex] = aItem;
}
let index = aTreeStructure[aIndex]; let index = aTreeStructure[aIndex];
PlacesUtils.setAnnotationsForItem(aItem.id, [{ let parent = index > -1 ? aBookarmks[index] : null ;
name : this.kPARENT, if (parent && parent.isFolder) {
value : (index > -1 ? aBookarmks[index].id : -1 ), this.BookmarksService.moveItem(aItem.id, parent.id, -1);
expires : PlacesUtils.annotations.EXPIRE_NEVER }
}]); else {
PlacesUtils.setAnnotationsForItem(aItem.id, [{
name : this.kPARENT,
value : parent ? parent.id : -1,
expires : PlacesUtils.annotations.EXPIRE_NEVER
}]);
}
}, this); }, this);
}, },
@ -434,7 +460,8 @@ var TreeStyleTabBookmarksService = {
onItemAdded : function TSTBMService_onItemAdded(aID, aFolderID, aPosition) onItemAdded : function TSTBMService_onItemAdded(aID, aFolderID, aPosition)
{ {
this._addingBookmarks.push({ this._addingBookmarks.push({
id : aID id : aID,
parent : aFolderID
}); });
}, },
onItemRemoved : function TSTBMService_onItemRemoved(aID, aFolderID, aPosition) {}, onItemRemoved : function TSTBMService_onItemRemoved(aID, aFolderID, aPosition) {},