OLD | NEW |
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 Visit.prototype.getResultDOM = function(propertyBag) { | 180 Visit.prototype.getResultDOM = function(propertyBag) { |
181 var isSearchResult = propertyBag.isSearchResult || false; | 181 var isSearchResult = propertyBag.isSearchResult || false; |
182 var addTitleFavicon = propertyBag.addTitleFavicon || false; | 182 var addTitleFavicon = propertyBag.addTitleFavicon || false; |
183 var useMonthDate = propertyBag.useMonthDate || false; | 183 var useMonthDate = propertyBag.useMonthDate || false; |
184 var focusless = propertyBag.focusless || false; | 184 var focusless = propertyBag.focusless || false; |
185 var node = createElementWithClassName('li', 'entry'); | 185 var node = createElementWithClassName('li', 'entry'); |
186 var time = createElementWithClassName('span', 'time'); | 186 var time = createElementWithClassName('span', 'time'); |
187 var entryBox = createElementWithClassName('div', 'entry-box'); | 187 var entryBox = createElementWithClassName('div', 'entry-box'); |
188 var domain = createElementWithClassName('div', 'domain'); | 188 var domain = createElementWithClassName('div', 'domain'); |
189 | 189 |
190 this.id_ = this.model_.nextVisitId_++; | 190 this.id_ = this.model_.getNextVisitId(); |
191 var self = this; | 191 var self = this; |
192 | 192 |
193 // Only create the checkbox if it can be used either to delete an entry or to | 193 // Only create the checkbox if it can be used either to delete an entry or to |
194 // block/allow it. | 194 // block/allow it. |
195 if (this.model_.editingEntriesAllowed) { | 195 if (this.model_.editingEntriesAllowed) { |
196 var checkbox = document.createElement('input'); | 196 var checkbox = document.createElement('input'); |
197 checkbox.type = 'checkbox'; | 197 checkbox.type = 'checkbox'; |
198 checkbox.id = 'checkbox-' + this.id_; | 198 checkbox.id = 'checkbox-' + this.id_; |
199 checkbox.setAttribute('aria-label', | |
200 loadTimeData.getString('removeFromHistory')); | |
201 checkbox.time = this.date.getTime(); | 199 checkbox.time = this.date.getTime(); |
| 200 checkbox.setAttribute('aria-label', loadTimeData.getStringF( |
| 201 'entrySummary', |
| 202 this.dateTimeOfDay, |
| 203 this.starred_ ? loadTimeData.getString('bookmarked') : '', |
| 204 this.title_, |
| 205 this.domain_)); |
202 checkbox.addEventListener('click', checkboxClicked); | 206 checkbox.addEventListener('click', checkboxClicked); |
203 entryBox.appendChild(checkbox); | 207 entryBox.appendChild(checkbox); |
204 | 208 |
205 if (focusless) | 209 if (focusless) |
206 checkbox.tabIndex = -1; | 210 checkbox.tabIndex = -1; |
207 | 211 |
208 if (!isMobileVersion()) { | 212 if (!isMobileVersion()) { |
209 // Clicking anywhere in the entryBox will check/uncheck the checkbox. | 213 // Clicking anywhere in the entryBox will check/uncheck the checkbox. |
210 entryBox.setAttribute('for', checkbox.id); | 214 entryBox.setAttribute('for', checkbox.id); |
211 entryBox.addEventListener('mousedown', entryBoxMousedown); | 215 entryBox.addEventListener('mousedown', entryBoxMousedown); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 /** | 740 /** |
737 * Removes |visit| from this model. | 741 * Removes |visit| from this model. |
738 * @param {Visit} visit A visit to remove. | 742 * @param {Visit} visit A visit to remove. |
739 */ | 743 */ |
740 HistoryModel.prototype.removeVisit = function(visit) { | 744 HistoryModel.prototype.removeVisit = function(visit) { |
741 var index = this.visits_.indexOf(visit); | 745 var index = this.visits_.indexOf(visit); |
742 if (index >= 0) | 746 if (index >= 0) |
743 this.visits_.splice(index, 1); | 747 this.visits_.splice(index, 1); |
744 }; | 748 }; |
745 | 749 |
| 750 /** |
| 751 * Automatically generates a new visit ID. |
| 752 * @return {number} The next visit ID. |
| 753 */ |
| 754 HistoryModel.prototype.getNextVisitId = function() { |
| 755 return this.nextVisitId_++; |
| 756 }; |
| 757 |
746 // HistoryModel, Private: ----------------------------------------------------- | 758 // HistoryModel, Private: ----------------------------------------------------- |
747 | 759 |
748 /** | 760 /** |
749 * Clear the history model. | 761 * Clear the history model. |
750 * @private | 762 * @private |
751 */ | 763 */ |
752 HistoryModel.prototype.clearModel_ = function() { | 764 HistoryModel.prototype.clearModel_ = function() { |
753 this.inFlight_ = false; // Whether a query is inflight. | 765 this.inFlight_ = false; // Whether a query is inflight. |
754 this.searchText_ = ''; | 766 this.searchText_ = ''; |
755 // Whether this user is a supervised user. | 767 // Whether this user is a supervised user. |
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 historyView.reload(); | 2284 historyView.reload(); |
2273 } | 2285 } |
2274 | 2286 |
2275 // Add handlers to HTML elements. | 2287 // Add handlers to HTML elements. |
2276 document.addEventListener('DOMContentLoaded', load); | 2288 document.addEventListener('DOMContentLoaded', load); |
2277 | 2289 |
2278 // This event lets us enable and disable menu items before the menu is shown. | 2290 // This event lets us enable and disable menu items before the menu is shown. |
2279 document.addEventListener('canExecute', function(e) { | 2291 document.addEventListener('canExecute', function(e) { |
2280 e.canExecute = true; | 2292 e.canExecute = true; |
2281 }); | 2293 }); |
OLD | NEW |