Chromium Code Reviews| Index: chrome/browser/resources/ntp4/bookmarks_page.js |
| =================================================================== |
| --- chrome/browser/resources/ntp4/bookmarks_page.js (revision 97786) |
| +++ chrome/browser/resources/ntp4/bookmarks_page.js (working copy) |
| @@ -216,11 +216,95 @@ |
| return false; |
| }, |
| + bookmarkImportBegan: function() { |
|
Evan Stade
2011/08/23 21:50:50
why is this here? why can't you just handle it in
csilv
2011/08/24 23:15:11
We could handle this in the C++ handler, but I thi
|
| + this.importing = true; |
| + }, |
| + |
| + bookmarkImportEnded: function() { |
| + // When importing is done, reload the bookmarks page. |
| + this.importing = false; |
| + chrome.send('getBookmarksData', []); |
| + }, |
| + |
| + bookmarkNodeAdded: function(id, bookmark) { |
|
Evan Stade
2011/08/23 21:50:50
document each function
csilv
2011/08/24 23:15:11
Done.
|
| + if (this.importing) return; |
| + if (this.id == bookmark.parentId) { |
|
Evan Stade
2011/08/23 21:50:50
no curlies
csilv
2011/08/24 23:15:11
Done.
|
| + this.addTileAt(new Bookmark(bookmark), bookmark.index, false); |
| + } |
| + }, |
| + |
| + bookmarkNodeChanged: function(id, changeInfo) { |
|
Evan Stade
2011/08/23 21:50:50
wouldn't a change to a folder name anywhere in the
csilv
2011/08/24 23:15:11
Yes indeed. Fixed here and also in move/remove.
|
| + if (this.importing) return; |
| + |
| + // If the current folder is being re-named, reload the page. |
| + // TODO(csilv): Optimize this to reload just the titles. |
| + if (this.id == id) { |
| + chrome.send('getBookmarksData', [this.id]); |
| + return; |
| + } |
| + |
| + // If the target item is contained in this folder, update just that item. |
| + for (var i = 0; i < this.tiles.length; i++) { |
| + var tile = this.tiles[i]; |
| + var data = tile.firstChild.data; |
| + |
| + if (data.id == id) { |
| + data.title = changeInfo.title; |
| + var title = tile.querySelector('.title'); |
| + title.textContent = data.title; |
| + |
| + if (changeInfo.url) { |
| + data.url = changeInfo.url; |
| + var button = tile.querySelector('.button'); |
| + button.href = title.href = data.url; |
| + } |
| + break; |
| + } |
| + } |
| + }, |
| + |
| + bookmarkNodeChildrenReordered: function(id, reorderInfo) { |
| + if (this.id == id) |
| + chrome.send('getBookmarksData', [this.id]); |
| + }, |
| + |
| + bookmarkNodeMoved: function(id, moveInfo) { |
| + // Reload the current page if the target item is the current folder |
| + // or the target item is being moved to/from this folder. |
| + // TODO(csilv): Optimize this by doing less than reloading the folder. |
| + if (this.id == id || |
| + this.id == moveInfo.parentId || |
| + this.id == moveInfo.oldParentId) |
|
Evan Stade
2011/08/23 21:50:50
curlies
csilv
2011/08/24 23:15:11
Done.
|
| + chrome.send('getBookmarksData', [this.id]); |
| + }, |
| + |
| + bookmarkNodeRemoved: function(id, removeInfo) { |
| + // If the target item is the visibile folder, load the contents of the |
| + // parent folder. |
| + if (this.id == id) { |
| + chrome.send('getBookmarksData', [removeInfo.parentId]); |
| + return; |
| + } |
| + |
| + // If the target item is contained in the visible folder, find the |
| + // matching tile and delete it. |
| + if (this.id == removeInfo.parentId) { |
| + for (var i = 0; i < this.tiles.length; i++) { |
| + var tile = this.tiles[i]; |
| + if (tile.firstChild.data.id == id) { |
| + this.removeTile(tile, false); |
| + break; |
| + } |
| + } |
| + } |
| + }, |
| + |
| /** |
| * Set the bookmark data that should be displayed, replacing any existing |
| * data. |
| */ |
| set data(data) { |
| + this.id = data.navigationItems[0].id; |
| this.updateBookmarkTiles_(data.items); |
| this.updateBookmarkTitles_(data.navigationItems); |
| }, |