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

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

Issue 2467007: Bookmarks: Disable the sort command when there are no items to sort.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 | Annotate | Revision Log
« 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html i18n-values="dir:textdirection"> 2 <html i18n-values="dir:textdirection">
3 <!-- 3 <!--
4 4
5 Copyright (c) 2010 The Chromium Authors. All rights reserved. 5 Copyright (c) 2010 The Chromium Authors. All rights reserved.
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 8
9 --> 9 -->
10 <head> 10 <head>
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 1128
1129 // We can always execute the import-menu and export-menu commands. 1129 // We can always execute the import-menu and export-menu commands.
1130 document.addEventListener('canExecute', function(e) { 1130 document.addEventListener('canExecute', function(e) {
1131 var command = e.command; 1131 var command = e.command;
1132 var commandId = command.id; 1132 var commandId = command.id;
1133 if (commandId == 'import-menu-command' || commandId == 'export-menu-command') { 1133 if (commandId == 'import-menu-command' || commandId == 'export-menu-command') {
1134 e.canExecute = true; 1134 e.canExecute = true;
1135 } 1135 }
1136 }); 1136 });
1137 1137
1138 /**
1139 * Helper function for handling canExecute for the list and the tree.
1140 * @param {!Event} e Can exectue event object.
1141 * @param {boolean} isRecentOrSearch Whether the user is trying to do a command
1142 * on recent or search.
1143 */
1144 function canExcuteShared(e, isRecentOrSearch) {
1145 var command = e.command;
1146 var commandId = command.id;
1147 switch (commandId) {
1148 case 'paste-command':
1149 updatePasteCommand();
1150 break;
1151
1152 case 'sort-command':
1153 if (isRecentOrSearch) {
1154 e.canExecute = false;
1155 } else {
1156 e.canExecute = list.items.length > 0;
1157
1158 // The list might be loading
1159 var f = function() {
1160 list.removeEventListener('load', f);
1161 command.disabled = list.items.length == 0;
1162 };
1163 list.addEventListener('load', f);
1164 }
1165 break;
1166
1167 case 'add-new-bookmark-command':
1168 case 'new-folder-command':
1169 e.canExecute = !isRecentOrSearch;
1170 break;
1171
1172 case 'open-in-new-tab-command':
1173 case 'open-in-background-tab-command':
1174 case 'open-in-new-window-command':
1175 case 'open-incognito-window-command':
1176 updateOpenCommands(e, command);
1177 break;
1178 }
1179 }
1180
1138 // Update canExecute for the commands when the list is the active element. 1181 // Update canExecute for the commands when the list is the active element.
1139 list.addEventListener('canExecute', function(e) { 1182 list.addEventListener('canExecute', function(e) {
1140 if (e.target != list) return; 1183 if (e.target != list) return;
1141 1184
1142 var command = e.command; 1185 var command = e.command;
1143 var commandId = command.id; 1186 var commandId = command.id;
1144 1187
1145 function hasSelected() { 1188 function hasSelected() {
1146 return !!e.target.selectedItem; 1189 return !!e.target.selectedItem;
1147 } 1190 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 case 'show-in-folder-command': 1227 case 'show-in-folder-command':
1185 e.canExecute = isRecentOrSearch() && hasSingleSelected(); 1228 e.canExecute = isRecentOrSearch() && hasSingleSelected();
1186 break; 1229 break;
1187 1230
1188 case 'delete-command': 1231 case 'delete-command':
1189 case 'cut-command': 1232 case 'cut-command':
1190 case 'copy-command': 1233 case 'copy-command':
1191 e.canExecute = hasSelected(); 1234 e.canExecute = hasSelected();
1192 break; 1235 break;
1193 1236
1194 case 'paste-command':
1195 updatePasteCommand();
1196 break;
1197
1198 case 'sort-command':
1199 case 'add-new-bookmark-command':
1200 case 'new-folder-command':
1201 e.canExecute = !isRecentOrSearch();
1202 break;
1203
1204 case 'open-in-new-tab-command':
1205 case 'open-in-background-tab-command':
1206 case 'open-in-new-window-command':
1207 case 'open-incognito-window-command':
1208 updateOpenCommands(e, command);
1209 break;
1210
1211 case 'open-in-same-window-command': 1237 case 'open-in-same-window-command':
1212 e.canExecute = hasSelected(); 1238 e.canExecute = hasSelected();
1213 break; 1239 break;
1240
1241 default:
1242 canExcuteShared(e, isRecentOrSearch());
1214 } 1243 }
1215 }); 1244 });
1216 1245
1217 // Update canExecute for the commands when the tree is the active element. 1246 // Update canExecute for the commands when the tree is the active element.
1218 tree.addEventListener('canExecute', function(e) { 1247 tree.addEventListener('canExecute', function(e) {
1219 if (e.target != tree) return; 1248 if (e.target != tree) return;
1220 1249
1221 var command = e.command; 1250 var command = e.command;
1222 var commandId = command.id; 1251 var commandId = command.id;
1223 1252
(...skipping 20 matching lines...) Expand all
1244 command.hidden = true; 1273 command.hidden = true;
1245 e.canExecute = false; 1274 e.canExecute = false;
1246 break; 1275 break;
1247 1276
1248 case 'delete-command': 1277 case 'delete-command':
1249 case 'cut-command': 1278 case 'cut-command':
1250 case 'copy-command': 1279 case 'copy-command':
1251 e.canExecute = hasSelected() && !isTopLevelItem(); 1280 e.canExecute = hasSelected() && !isTopLevelItem();
1252 break; 1281 break;
1253 1282
1254 case 'paste-command': 1283 default:
1255 updatePasteCommand(); 1284 canExcuteShared(e, isRecentOrSearch());
1256 break;
1257
1258 case 'sort-command':
1259 case 'add-new-bookmark-command':
1260 case 'new-folder-command':
1261 e.canExecute = !isRecentOrSearch();
1262 break;
1263
1264 case 'open-in-new-tab-command':
1265 case 'open-in-background-tab-command':
1266 case 'open-in-new-window-command':
1267 case 'open-incognito-window-command':
1268 updateOpenCommands(e, command);
1269 break;
1270 } 1285 }
1271 }); 1286 });
1272 1287
1273 /** 1288 /**
1274 * Update the canExecute state of the commands when the selection changes. 1289 * Update the canExecute state of the commands when the selection changes.
1275 * @param {Event} e The change event object. 1290 * @param {Event} e The change event object.
1276 */ 1291 */
1277 function updateCommandsBasedOnSelection(e) { 1292 function updateCommandsBasedOnSelection(e) {
1278 if (e.target == document.activeElement) { 1293 if (e.target == document.activeElement) {
1279 // Paste only needs to updated when the tree selection changes. 1294 // Paste only needs to updated when the tree selection changes.
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 // Paste is a bit special since we need to do an async call to see if we can 1630 // Paste is a bit special since we need to do an async call to see if we can
1616 // paste because the paste command might not be up to date. 1631 // paste because the paste command might not be up to date.
1617 updatePasteCommand(pasteHandler); 1632 updatePasteCommand(pasteHandler);
1618 }); 1633 });
1619 })(); 1634 })();
1620 1635
1621 </script> 1636 </script>
1622 1637
1623 </body> 1638 </body>
1624 </html> 1639 </html>
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