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

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: Created 6 years 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..e67d7a316e408c70d326146a732ad3d681222fbe 100644
--- a/chrome/browser/resources/bookmark_manager/js/main.js
+++ b/chrome/browser/resources/bookmark_manager/js/main.js
@@ -1029,13 +1029,27 @@ function newFolder(opt_target) {
performGlobalUndo = null; // This can't be undone, so disable global undo.
var parentId = computeParentFolderForNewItem();
-
+ var newIndex = '';
Bernhard Bauer 2014/12/22 11:58:20 |newIndex| is supposed to be an integer. Just beca
Deepak 2014/12/23 04:27:48 Done.
+ var selectedItem = bmm.list.selectedItem;
// Callback is called after tree and list data model updated.
function createFolder(callback) {
+ if (selectedItem && document.activeElement != bmm.tree) {
Bernhard Bauer 2014/12/22 11:58:20 The indentation is way off in this CL. I would sug
Deepak 2014/12/23 04:27:47 Can you please tell me in specific about this.
Bernhard Bauer 2014/12/23 11:54:36 The issues are fixed now.
+ if (!bmm.isFolder(selectedItem))
+ newIndex = 1 + bmm.list.dataModel.indexOf(selectedItem);
Bernhard Bauer 2014/12/22 11:58:20 It's more idiomatic to put the constant summand as
Deepak 2014/12/23 04:27:47 Done.
+ }
+ if (newIndex != '') {
chrome.bookmarks.create({
title: loadTimeData.getString('new_folder_name'),
- parentId: parentId
+ parentId: parentId,
+ index: newIndex
}, callback);
+ } else {
+ // As create bookmark folder does not create bookmark node for empty index.
Bernhard Bauer 2014/12/22 11:58:21 I have no idea what this comment is supposed to me
Deepak 2014/12/23 04:27:48 This part of code is not required after taking new
+ chrome.bookmarks.create({
+ title: loadTimeData.getString('new_folder_name'),
+ parentId: parentId
+ }, callback);
+ }
}
if ((opt_target || document.activeElement) == bmm.tree) {
@@ -1049,10 +1063,12 @@ function newFolder(opt_target) {
function editNewFolderInList() {
createFolder(function() {
- var index = bmm.list.dataModel.length - 1;
+ var length = bmm.list.dataModel.length - 1;
+ if (newIndex != '' && newIndex <= length)
Bernhard Bauer 2014/12/22 11:58:20 This callback will be called asynchronously. What
Deepak 2014/12/23 04:27:47 I understand. Can you please tell me some way to r
Bernhard Bauer 2014/12/23 11:54:36 I don't know how to reproduce this, but the onus i
+ length = newIndex;
Bernhard Bauer 2014/12/22 11:58:20 Why do you rename this variable to |length|, but t
Deepak 2014/12/23 04:27:48 Done.
var sm = bmm.list.selectionModel;
- sm.anchorIndex = sm.leadIndex = sm.selectedIndex = index;
- scrollIntoViewAndMakeEditable(index);
+ sm.anchorIndex = sm.leadIndex = sm.selectedIndex = length;
+ scrollIntoViewAndMakeEditable(length);
});
}
@@ -1080,16 +1096,25 @@ function scrollIntoViewAndMakeEditable(index) {
*/
function addPage() {
var parentId = computeParentFolderForNewItem();
-
+ var newIndex = '';
+ var selectedItem = bmm.list.selectedItem;
function editNewBookmark() {
+ if (selectedItem && document.activeElement != bmm.tree) {
+ if (!bmm.isFolder(selectedItem))
+ newIndex = 1 + bmm.list.dataModel.indexOf(selectedItem);
+ }
+
var fakeNode = {
title: '',
url: '',
parentId: parentId,
+ index: newIndex,
id: 'new'
};
var dataModel = bmm.list.dataModel;
var length = dataModel.length;
+ if (newIndex != '' && newIndex <= length)
+ length = newIndex;
Bernhard Bauer 2014/12/22 11:58:20 Same here; this is not really a length anymore, it
Deepak 2014/12/23 04:27:47 Done.
dataModel.splice(length, 0, fakeNode);
var sm = bmm.list.selectionModel;
sm.anchorIndex = sm.leadIndex = sm.selectedIndex = length;
« 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