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

Side by Side Diff: chrome/browser/resources/history/history.js

Issue 510213002: history: don't drop focus on the floor when removing a bookmark. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « chrome/browser/resources/history/history.css ('k') | 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 <include src="../uber/uber_utils.js"> 5 <include src="../uber/uber_utils.js">
6 <include src="history_focus_manager.js"> 6 <include src="history_focus_manager.js">
7 7
8 /////////////////////////////////////////////////////////////////////////////// 8 ///////////////////////////////////////////////////////////////////////////////
9 // Globals: 9 // Globals:
10 /** @const */ var RESULTS_PER_PAGE = 150; 10 /** @const */ var RESULTS_PER_PAGE = 150;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 var setActiveVisit = function(e) { 217 var setActiveVisit = function(e) {
218 activeVisit = self; 218 activeVisit = self;
219 var menu = $('action-menu'); 219 var menu = $('action-menu');
220 menu.dataset.devicename = self.deviceName; 220 menu.dataset.devicename = self.deviceName;
221 menu.dataset.devicetype = self.deviceType; 221 menu.dataset.devicetype = self.deviceType;
222 }; 222 };
223 domain.textContent = this.domain_; 223 domain.textContent = this.domain_;
224 224
225 entryBox.appendChild(time); 225 entryBox.appendChild(time);
226 226
227 var bookmarkSection = createElementWithClassName('div', 'bookmark-section'); 227 var bookmarkSection = createElementWithClassName(
228 'button', 'bookmark-section custom-appearance');
228 if (this.starred_) { 229 if (this.starred_) {
229 bookmarkSection.title = loadTimeData.getString('removeBookmark'); 230 bookmarkSection.title = loadTimeData.getString('removeBookmark');
230 bookmarkSection.classList.add('starred'); 231 bookmarkSection.classList.add('starred');
231 bookmarkSection.addEventListener('click', function f(e) { 232 bookmarkSection.addEventListener('click', function f(e) {
232 recordUmaAction('HistoryPage_BookmarkStarClicked'); 233 recordUmaAction('HistoryPage_BookmarkStarClicked');
234 chrome.send('removeBookmark', [self.url_]);
235
236 this.model_.getView().onBeforeUnstarred(this);
233 bookmarkSection.classList.remove('starred'); 237 bookmarkSection.classList.remove('starred');
234 chrome.send('removeBookmark', [self.url_]); 238 this.model_.getView().onAfterUnstarred(this);
239
235 bookmarkSection.removeEventListener('click', f); 240 bookmarkSection.removeEventListener('click', f);
236 e.preventDefault(); 241 e.preventDefault();
237 }); 242 }.bind(this));
238 } 243 }
239 entryBox.appendChild(bookmarkSection); 244 entryBox.appendChild(bookmarkSection);
240 245
241 var visitEntryWrapper = /** @type {HTMLElement} */( 246 var visitEntryWrapper = /** @type {HTMLElement} */(
242 entryBox.appendChild(document.createElement('div'))); 247 entryBox.appendChild(document.createElement('div')));
243 if (addTitleFavicon || this.blockedVisit) 248 if (addTitleFavicon || this.blockedVisit)
244 visitEntryWrapper.classList.add('visit-entry'); 249 visitEntryWrapper.classList.add('visit-entry');
245 if (this.blockedVisit) { 250 if (this.blockedVisit) {
246 visitEntryWrapper.classList.add('blocked-indicator'); 251 visitEntryWrapper.classList.add('blocked-indicator');
247 visitEntryWrapper.appendChild(this.getVisitAttemptDOM_()); 252 visitEntryWrapper.appendChild(this.getVisitAttemptDOM_());
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 var pos = this.focusGrid_.getPositionForTarget(document.activeElement); 1147 var pos = this.focusGrid_.getPositionForTarget(document.activeElement);
1143 if (!pos) 1148 if (!pos)
1144 return; 1149 return;
1145 1150
1146 var row = this.focusGrid_.rows[pos.row + 1] || 1151 var row = this.focusGrid_.rows[pos.row + 1] ||
1147 this.focusGrid_.rows[pos.row - 1]; 1152 this.focusGrid_.rows[pos.row - 1];
1148 if (row) 1153 if (row)
1149 row.focusIndex(Math.min(pos.col, row.items.length - 1)); 1154 row.focusIndex(Math.min(pos.col, row.items.length - 1));
1150 }; 1155 };
1151 1156
1157 /** @param {Visit} visit The visit about to be unstarred. */
1158 HistoryView.prototype.onBeforeUnstarred = function(visit) {
1159 assert(this.currentVisits_.indexOf(visit) >= 0);
1160 assert(visit.bookmarkStar == document.activeElement);
1161
1162 var pos = this.focusGrid_.getPositionForTarget(document.activeElement);
1163 var row = this.focusGrid_.rows[pos.row];
1164 row.focusIndex(Math.min(pos.col + 1, row.items.length - 1));
1165 };
1166
1167 /** @param {Visit} visit The visit that was just unstarred. */
1168 HistoryView.prototype.onAfterUnstarred = function(visit) {
1169 this.updateFocusGrid_();
1170 };
1171
1152 /** 1172 /**
1153 * Removes a single entry from the view. Also removes gaps before and after 1173 * Removes a single entry from the view. Also removes gaps before and after
1154 * entry if necessary. 1174 * entry if necessary.
1155 * @param {Visit} visit The visit to be removed. 1175 * @param {Visit} visit The visit to be removed.
1156 */ 1176 */
1157 HistoryView.prototype.removeVisit = function(visit) { 1177 HistoryView.prototype.removeVisit = function(visit) {
1158 var entry = visit.domNode_; 1178 var entry = visit.domNode_;
1159 var previousEntry = entry.previousSibling; 1179 var previousEntry = entry.previousSibling;
1160 var nextEntry = entry.nextSibling; 1180 var nextEntry = entry.nextSibling;
1161 var toRemove = [entry]; 1181 var toRemove = [entry];
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 historyView.reload(); 2273 historyView.reload();
2254 } 2274 }
2255 2275
2256 // Add handlers to HTML elements. 2276 // Add handlers to HTML elements.
2257 document.addEventListener('DOMContentLoaded', load); 2277 document.addEventListener('DOMContentLoaded', load);
2258 2278
2259 // This event lets us enable and disable menu items before the menu is shown. 2279 // This event lets us enable and disable menu items before the menu is shown.
2260 document.addEventListener('canExecute', function(e) { 2280 document.addEventListener('canExecute', function(e) {
2261 e.canExecute = true; 2281 e.canExecute = true;
2262 }); 2282 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/history/history.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698