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

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

Issue 12217015: History: Fix selecting multiple visits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: A test and minor fix. Created 7 years, 10 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
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 6
7 /////////////////////////////////////////////////////////////////////////////// 7 ///////////////////////////////////////////////////////////////////////////////
8 // Globals: 8 // Globals:
9 /** @const */ var RESULTS_PER_PAGE = 150; 9 /** @const */ var RESULTS_PER_PAGE = 150;
10 10
(...skipping 18 matching lines...) Expand all
29 29
30 /////////////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////////////
31 // Visit: 31 // Visit:
32 32
33 /** 33 /**
34 * Class to hold all the information about an entry in our model. 34 * Class to hold all the information about an entry in our model.
35 * @param {Object} result An object containing the visit's data. 35 * @param {Object} result An object containing the visit's data.
36 * @param {boolean} continued Whether this visit is on the same day as the 36 * @param {boolean} continued Whether this visit is on the same day as the
37 * visit before it. 37 * visit before it.
38 * @param {HistoryModel} model The model object this entry belongs to. 38 * @param {HistoryModel} model The model object this entry belongs to.
39 * @param {number} id The identifier for the entry.
40 * @constructor 39 * @constructor
41 */ 40 */
42 function Visit(result, continued, model, id) { 41 function Visit(result, continued, model) {
43 this.model_ = model; 42 this.model_ = model;
44 this.title_ = result.title; 43 this.title_ = result.title;
45 this.url_ = result.url; 44 this.url_ = result.url;
46 this.starred_ = result.starred; 45 this.starred_ = result.starred;
47 this.snippet_ = result.snippet || ''; 46 this.snippet_ = result.snippet || '';
48 this.id_ = id; 47 // The id will be set according to when the visit was displayed, not
48 // received. Set to -1 to show that it has not been set yet.
49 this.id_ = -1;
49 50
50 this.isRendered = false; // Has the visit already been rendered on the page? 51 this.isRendered = false; // Has the visit already been rendered on the page?
51 52
52 // Holds the timestamps of duplicates of this visit (visits to the same URL on 53 // Holds the timestamps of duplicates of this visit (visits to the same URL on
53 // the same day). 54 // the same day).
54 this.duplicateTimestamps_ = []; 55 this.duplicateTimestamps_ = [];
55 56
56 // All the date information is public so that owners can compare properties of 57 // All the date information is public so that owners can compare properties of
57 // two items easily. 58 // two items easily.
58 59
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 var time = createElementWithClassName('div', 'time'); 97 var time = createElementWithClassName('div', 'time');
97 var entryBox = createElementWithClassName('label', 'entry-box'); 98 var entryBox = createElementWithClassName('label', 'entry-box');
98 var domain = createElementWithClassName('div', 'domain'); 99 var domain = createElementWithClassName('div', 'domain');
99 100
100 var dropDown = createElementWithClassName('button', 'drop-down'); 101 var dropDown = createElementWithClassName('button', 'drop-down');
101 dropDown.value = 'Open action menu'; 102 dropDown.value = 'Open action menu';
102 dropDown.title = loadTimeData.getString('actionMenuDescription'); 103 dropDown.title = loadTimeData.getString('actionMenuDescription');
103 dropDown.setAttribute('menu', '#action-menu'); 104 dropDown.setAttribute('menu', '#action-menu');
104 cr.ui.decorate(dropDown, MenuButton); 105 cr.ui.decorate(dropDown, MenuButton);
105 106
107 this.id_ = this.model_.nextVisitId_++;
108
106 // Checkbox is always created, but only visible on hover & when checked. 109 // Checkbox is always created, but only visible on hover & when checked.
107 var checkbox = document.createElement('input'); 110 var checkbox = document.createElement('input');
108 checkbox.type = 'checkbox'; 111 checkbox.type = 'checkbox';
109 checkbox.id = 'checkbox-' + this.id_; 112 checkbox.id = 'checkbox-' + this.id_;
110 checkbox.time = this.date.getTime(); 113 checkbox.time = this.date.getTime();
111 checkbox.addEventListener('click', checkboxClicked); 114 checkbox.addEventListener('click', checkboxClicked);
112 time.appendChild(checkbox); 115 time.appendChild(checkbox);
113 116
114 // Keep track of the drop down that triggered the menu, so we know 117 // Keep track of the drop down that triggered the menu, so we know
115 // which element to apply the command to. 118 // which element to apply the command to.
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 this.urlsFromLastSeenDay_ = {}; 431 this.urlsFromLastSeenDay_ = {};
429 432
430 // Only create a new Visit object for the first visit to a URL on a 433 // Only create a new Visit object for the first visit to a URL on a
431 // particular day. 434 // particular day.
432 var visit = this.urlsFromLastSeenDay_[thisResult.url]; 435 var visit = this.urlsFromLastSeenDay_[thisResult.url];
433 if (visit) { 436 if (visit) {
434 // Record the timestamp of the duplicate visit. 437 // Record the timestamp of the duplicate visit.
435 visit.addDuplicateTimestamp(thisResult.timestamp); 438 visit.addDuplicateTimestamp(thisResult.timestamp);
436 continue; 439 continue;
437 } 440 }
438 visit = new Visit(thisResult, isSameDay, this, this.nextVisitId_++); 441 visit = new Visit(thisResult, isSameDay, this);
439 this.urlsFromLastSeenDay_[thisResult.url] = visit; 442 this.urlsFromLastSeenDay_[thisResult.url] = visit;
440 this.visits_.push(visit); 443 this.visits_.push(visit);
441 this.changed = true; 444 this.changed = true;
442 lastDay = thisDay; 445 lastDay = thisDay;
443 } 446 }
444 447
445 this.updateSearch_(); 448 this.updateSearch_();
446 }; 449 };
447 450
448 /** 451 /**
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 historyView.reload(); 1537 historyView.reload();
1535 } 1538 }
1536 1539
1537 // Add handlers to HTML elements. 1540 // Add handlers to HTML elements.
1538 document.addEventListener('DOMContentLoaded', load); 1541 document.addEventListener('DOMContentLoaded', load);
1539 1542
1540 // This event lets us enable and disable menu items before the menu is shown. 1543 // This event lets us enable and disable menu items before the menu is shown.
1541 document.addEventListener('canExecute', function(e) { 1544 document.addEventListener('canExecute', function(e) {
1542 e.canExecute = true; 1545 e.canExecute = true;
1543 }); 1546 });
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/history_browsertest.js » ('j') | chrome/test/data/webui/history_browsertest.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698