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,10 +17,10 @@ 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)
.map(function(aTab) {
var parent = this.getParentTab(aTab); var parent = this.getParentTab(aTab);
return aTabs.indexOf(parent); return aTabs.indexOf(parent);
}, this); }, this);
@ -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];
let parent = index > -1 ? aBookarmks[index] : null ;
if (parent && parent.isFolder) {
this.BookmarksService.moveItem(aItem.id, parent.id, -1);
}
else {
PlacesUtils.setAnnotationsForItem(aItem.id, [{ PlacesUtils.setAnnotationsForItem(aItem.id, [{
name : this.kPARENT, name : this.kPARENT,
value : (index > -1 ? aBookarmks[index].id : -1 ), value : parent ? parent.id : -1,
expires : PlacesUtils.annotations.EXPIRE_NEVER 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) {},