Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6283)

Unified Diff: chrome/browser/resources/bookmark_manager/js/main.js

Issue 795483004: In Bookmark manager 'Add page' and 'Add Folder' always add new page or folder at the end. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/bookmark_manager/js/main.js
diff --git a/chrome/browser/resources/bookmark_manager/js/main.js b/chrome/browser/resources/bookmark_manager/js/main.js
index efab6e96b883df797ce046c817ccc8074953e969..cfab1ac1d80f715105d60cd16b96946d82f4afbf 100644
--- a/chrome/browser/resources/bookmark_manager/js/main.js
+++ b/chrome/browser/resources/bookmark_manager/js/main.js
@@ -1029,12 +1029,18 @@ function newFolder(opt_target) {
performGlobalUndo = null; // This can't be undone, so disable global undo.
var parentId = computeParentFolderForNewItem();
-
+ var selectedItem = bmm.list.selectedItem;
+ var newIndex;
// Callback is called after tree and list data model updated.
function createFolder(callback) {
+ if (selectedItem && document.activeElement != bmm.tree &&
+ !bmm.isFolder(selectedItem)) {
+ newIndex = bmm.list.dataModel.indexOf(selectedItem) + 1;
+ }
chrome.bookmarks.create({
title: loadTimeData.getString('new_folder_name'),
- parentId: parentId
+ parentId: parentId,
+ index: newIndex
}, callback);
}
@@ -1048,8 +1054,8 @@ function newFolder(opt_target) {
}
function editNewFolderInList() {
- createFolder(function() {
- var index = bmm.list.dataModel.length - 1;
+ createFolder(function(newNode) {
+ var index = newNode.index;
var sm = bmm.list.selectionModel;
sm.anchorIndex = sm.leadIndex = sm.selectedIndex = index;
scrollIntoViewAndMakeEditable(index);
@@ -1080,20 +1086,29 @@ function scrollIntoViewAndMakeEditable(index) {
*/
function addPage() {
var parentId = computeParentFolderForNewItem();
-
+ var selectedItem = bmm.list.selectedItem;
+ var newIndex;
function editNewBookmark() {
+ if (selectedItem && document.activeElement != bmm.tree &&
+ !bmm.isFolder(selectedItem)) {
+ newIndex = bmm.list.dataModel.indexOf(selectedItem) + 1;
+ }
+
var fakeNode = {
title: '',
url: '',
parentId: parentId,
+ index: newIndex,
id: 'new'
};
var dataModel = bmm.list.dataModel;
- var length = dataModel.length;
- dataModel.splice(length, 0, fakeNode);
+ var index = dataModel.length;
+ if (newIndex != undefined)
+ index = newIndex;
+ dataModel.splice(index, 0, fakeNode);
var sm = bmm.list.selectionModel;
- sm.anchorIndex = sm.leadIndex = sm.selectedIndex = length;
- scrollIntoViewAndMakeEditable(length);
+ sm.anchorIndex = sm.leadIndex = sm.selectedIndex = index;
+ scrollIntoViewAndMakeEditable(index);
};
navigateTo(parentId, editNewBookmark);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698