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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 var useMonthDate = propertyBag.useMonthDate || false; | 185 var useMonthDate = propertyBag.useMonthDate || false; |
186 var focusless = propertyBag.focusless || false; | 186 var focusless = propertyBag.focusless || false; |
187 var node = createElementWithClassName('li', 'entry'); | 187 var node = createElementWithClassName('li', 'entry'); |
188 var time = createElementWithClassName('span', 'time'); | 188 var time = createElementWithClassName('span', 'time'); |
189 var entryBox = createElementWithClassName('div', 'entry-box'); | 189 var entryBox = createElementWithClassName('div', 'entry-box'); |
190 var domain = createElementWithClassName('div', 'domain'); | 190 var domain = createElementWithClassName('div', 'domain'); |
191 | 191 |
192 this.id_ = this.model_.getNextVisitId(); | 192 this.id_ = this.model_.getNextVisitId(); |
193 var self = this; | 193 var self = this; |
194 | 194 |
195 // Only create the checkbox if it can be used either to delete an entry or to | 195 // Only create the checkbox if it can be used to delete an entry. |
196 // block/allow it. | |
197 if (this.model_.editingEntriesAllowed) { | 196 if (this.model_.editingEntriesAllowed) { |
198 var checkbox = document.createElement('input'); | 197 var checkbox = document.createElement('input'); |
199 checkbox.type = 'checkbox'; | 198 checkbox.type = 'checkbox'; |
200 checkbox.id = 'checkbox-' + this.id_; | 199 checkbox.id = 'checkbox-' + this.id_; |
201 checkbox.time = this.date.getTime(); | 200 checkbox.time = this.date.getTime(); |
202 checkbox.setAttribute('aria-label', loadTimeData.getStringF( | 201 checkbox.setAttribute('aria-label', loadTimeData.getStringF( |
203 'entrySummary', | 202 'entrySummary', |
204 this.dateTimeOfDay, | 203 this.dateTimeOfDay, |
205 this.starred_ ? loadTimeData.getString('bookmarked') : '', | 204 this.starred_ ? loadTimeData.getString('bookmarked') : '', |
206 this.title_, | 205 this.title_, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 if (addTitleFavicon) | 269 if (addTitleFavicon) |
271 this.addFaviconToElement_(visitEntryWrapper); | 270 this.addFaviconToElement_(visitEntryWrapper); |
272 | 271 |
273 if (focusless) | 272 if (focusless) |
274 title.querySelector('a').tabIndex = -1; | 273 title.querySelector('a').tabIndex = -1; |
275 | 274 |
276 visitEntryWrapper.appendChild(domain); | 275 visitEntryWrapper.appendChild(domain); |
277 } | 276 } |
278 | 277 |
279 if (isMobileVersion()) { | 278 if (isMobileVersion()) { |
280 var removeButton = createElementWithClassName('button', 'remove-entry'); | 279 if (this.model_.editingEntriesAllowed) { |
281 removeButton.setAttribute('aria-label', | 280 var removeButton = createElementWithClassName('button', 'remove-entry'); |
282 loadTimeData.getString('removeFromHistory')); | 281 removeButton.setAttribute('aria-label', |
283 removeButton.classList.add('custom-appearance'); | 282 loadTimeData.getString('removeFromHistory')); |
284 removeButton.addEventListener( | 283 removeButton.classList.add('custom-appearance'); |
285 'click', this.removeEntryFromHistory_.bind(this)); | 284 removeButton.addEventListener( |
286 entryBox.appendChild(removeButton); | 285 'click', this.removeEntryFromHistory_.bind(this)); |
| 286 entryBox.appendChild(removeButton); |
287 | 287 |
288 // Support clicking anywhere inside the entry box. | 288 // Support clicking anywhere inside the entry box. |
289 entryBox.addEventListener('click', function(e) { | 289 entryBox.addEventListener('click', function(e) { |
290 if (!e.defaultPrevented) { | 290 if (!e.defaultPrevented) { |
291 self.titleLink.focus(); | 291 self.titleLink.focus(); |
292 self.titleLink.click(); | 292 self.titleLink.click(); |
293 } | 293 } |
294 }); | 294 }); |
| 295 } |
295 } else { | 296 } else { |
296 var dropDown = createElementWithClassName('button', 'drop-down'); | 297 var dropDown = createElementWithClassName('button', 'drop-down'); |
297 dropDown.value = 'Open action menu'; | 298 dropDown.value = 'Open action menu'; |
298 dropDown.title = loadTimeData.getString('actionMenuDescription'); | 299 dropDown.title = loadTimeData.getString('actionMenuDescription'); |
299 dropDown.setAttribute('menu', '#action-menu'); | 300 dropDown.setAttribute('menu', '#action-menu'); |
300 dropDown.setAttribute('aria-haspopup', 'true'); | 301 dropDown.setAttribute('aria-haspopup', 'true'); |
301 | 302 |
302 if (focusless) | 303 if (focusless) |
303 dropDown.tabIndex = -1; | 304 dropDown.tabIndex = -1; |
304 | 305 |
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2397 historyView.reload(); | 2398 historyView.reload(); |
2398 } | 2399 } |
2399 | 2400 |
2400 // Add handlers to HTML elements. | 2401 // Add handlers to HTML elements. |
2401 document.addEventListener('DOMContentLoaded', load); | 2402 document.addEventListener('DOMContentLoaded', load); |
2402 | 2403 |
2403 // This event lets us enable and disable menu items before the menu is shown. | 2404 // This event lets us enable and disable menu items before the menu is shown. |
2404 document.addEventListener('canExecute', function(e) { | 2405 document.addEventListener('canExecute', function(e) { |
2405 e.canExecute = true; | 2406 e.canExecute = true; |
2406 }); | 2407 }); |
OLD | NEW |