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

Side by Side Diff: chrome/browser/resources/bookmark_manager/js/main.js

Issue 1059323004: Add newly added page or folder last when multiple bookmarks are selected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 /** @const */ var BookmarkList = bmm.BookmarkList; 6 /** @const */ var BookmarkList = bmm.BookmarkList;
7 /** @const */ var BookmarkTree = bmm.BookmarkTree; 7 /** @const */ var BookmarkTree = bmm.BookmarkTree;
8 /** @const */ var Command = cr.ui.Command; 8 /** @const */ var Command = cr.ui.Command;
9 /** @const */ var LinkKind = cr.LinkKind; 9 /** @const */ var LinkKind = cr.LinkKind;
10 /** @const */ var ListItem = cr.ui.ListItem; 10 /** @const */ var ListItem = cr.ui.ListItem;
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 1022
1023 /** 1023 /**
1024 * Callback for the new folder command. This creates a new folder and starts 1024 * Callback for the new folder command. This creates a new folder and starts
1025 * a rename of it. 1025 * a rename of it.
1026 * @param {EventTarget=} opt_target The target to create a new folder in. 1026 * @param {EventTarget=} opt_target The target to create a new folder in.
1027 */ 1027 */
1028 function newFolder(opt_target) { 1028 function newFolder(opt_target) {
1029 performGlobalUndo = null; // This can't be undone, so disable global undo. 1029 performGlobalUndo = null; // This can't be undone, so disable global undo.
1030 1030
1031 var parentId = computeParentFolderForNewItem(); 1031 var parentId = computeParentFolderForNewItem();
1032 var selectedItem = bmm.list.selectedItem; 1032 var selectedItems = bmm.list.selectedItems;
1033 var newIndex; 1033 var newIndex;
1034 // Callback is called after tree and list data model updated. 1034 // Callback is called after tree and list data model updated.
1035 function createFolder(callback) { 1035 function createFolder(callback) {
1036 if (selectedItem && document.activeElement != bmm.tree && 1036 if (selectedItems.length == 1 && document.activeElement != bmm.tree &&
1037 !bmm.isFolder(selectedItem) && selectedItem.id != 'new') { 1037 !bmm.isFolder(selectedItems[0]) && selectedItems[0].id != 'new') {
1038 newIndex = bmm.list.dataModel.indexOf(selectedItem) + 1; 1038 newIndex = bmm.list.dataModel.indexOf(selectedItems[0]) + 1;
1039 } 1039 }
1040 chrome.bookmarks.create({ 1040 chrome.bookmarks.create({
1041 title: loadTimeData.getString('new_folder_name'), 1041 title: loadTimeData.getString('new_folder_name'),
1042 parentId: parentId, 1042 parentId: parentId,
1043 index: newIndex 1043 index: newIndex
1044 }, callback); 1044 }, callback);
1045 } 1045 }
1046 1046
1047 if ((opt_target || document.activeElement) == bmm.tree) { 1047 if ((opt_target || document.activeElement) == bmm.tree) {
1048 createFolder(function(newNode) { 1048 createFolder(function(newNode) {
(...skipping 30 matching lines...) Expand all
1079 item.editing = true; 1079 item.editing = true;
1080 }, 0); 1080 }, 0);
1081 } 1081 }
1082 1082
1083 /** 1083 /**
1084 * Adds a page to the current folder. This is called by the 1084 * Adds a page to the current folder. This is called by the
1085 * add-new-bookmark-command handler. 1085 * add-new-bookmark-command handler.
1086 */ 1086 */
1087 function addPage() { 1087 function addPage() {
1088 var parentId = computeParentFolderForNewItem(); 1088 var parentId = computeParentFolderForNewItem();
1089 var selectedItem = bmm.list.selectedItem; 1089 var selectedItems = bmm.list.selectedItems;
1090 var newIndex; 1090 var newIndex;
1091 function editNewBookmark() { 1091 function editNewBookmark() {
1092 if (selectedItem && document.activeElement != bmm.tree && 1092 if (selectedItems.length == 1 && document.activeElement != bmm.tree &&
1093 !bmm.isFolder(selectedItem)) { 1093 !bmm.isFolder(selectedItems[0])) {
1094 newIndex = bmm.list.dataModel.indexOf(selectedItem) + 1; 1094 newIndex = bmm.list.dataModel.indexOf(selectedItems[0]) + 1;
1095 } 1095 }
1096 1096
1097 var fakeNode = { 1097 var fakeNode = {
1098 title: '', 1098 title: '',
1099 url: '', 1099 url: '',
1100 parentId: parentId, 1100 parentId: parentId,
1101 index: newIndex, 1101 index: newIndex,
1102 id: 'new' 1102 id: 'new'
1103 }; 1103 };
1104 var dataModel = bmm.list.dataModel; 1104 var dataModel = bmm.list.dataModel;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 1506
1507 cr.ui.FocusOutlineManager.forDocument(document); 1507 cr.ui.FocusOutlineManager.forDocument(document);
1508 initializeSplitter(); 1508 initializeSplitter();
1509 bmm.addBookmarkModelListeners(); 1509 bmm.addBookmarkModelListeners();
1510 dnd.init(selectItemsAfterUserAction); 1510 dnd.init(selectItemsAfterUserAction);
1511 bmm.tree.reload(); 1511 bmm.tree.reload();
1512 } 1512 }
1513 1513
1514 initializeBookmarkManager(); 1514 initializeBookmarkManager();
1515 })(); 1515 })();
OLDNEW
« 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