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

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: Rebase 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
« no previous file with comments | « no previous file | chrome/test/data/webui/history_browsertest.js » ('j') | 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 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 this.urlsFromLastSeenDay_ = {}; 432 this.urlsFromLastSeenDay_ = {};
430 433
431 // Only create a new Visit object for the first visit to a URL on a 434 // Only create a new Visit object for the first visit to a URL on a
432 // particular day. 435 // particular day.
433 var visit = this.urlsFromLastSeenDay_[thisResult.url]; 436 var visit = this.urlsFromLastSeenDay_[thisResult.url];
434 if (visit) { 437 if (visit) {
435 // Record the timestamp of the duplicate visit. 438 // Record the timestamp of the duplicate visit.
436 visit.addDuplicateTimestamp(thisResult.timestamp); 439 visit.addDuplicateTimestamp(thisResult.timestamp);
437 continue; 440 continue;
438 } 441 }
439 visit = new Visit(thisResult, isSameDay, this, this.nextVisitId_++); 442 visit = new Visit(thisResult, isSameDay, this);
440 this.urlsFromLastSeenDay_[thisResult.url] = visit; 443 this.urlsFromLastSeenDay_[thisResult.url] = visit;
441 this.visits_.push(visit); 444 this.visits_.push(visit);
442 this.changed = true; 445 this.changed = true;
443 lastDay = thisDay; 446 lastDay = thisDay;
444 } 447 }
445 448
446 this.updateSearch_(); 449 this.updateSearch_();
447 }; 450 };
448 451
449 /** 452 /**
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 historyView.reload(); 1550 historyView.reload();
1548 } 1551 }
1549 1552
1550 // Add handlers to HTML elements. 1553 // Add handlers to HTML elements.
1551 document.addEventListener('DOMContentLoaded', load); 1554 document.addEventListener('DOMContentLoaded', load);
1552 1555
1553 // This event lets us enable and disable menu items before the menu is shown. 1556 // This event lets us enable and disable menu items before the menu is shown.
1554 document.addEventListener('canExecute', function(e) { 1557 document.addEventListener('canExecute', function(e) {
1555 e.canExecute = true; 1558 e.canExecute = true;
1556 }); 1559 });
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/history_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698