| 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 20 matching lines...) Expand all Loading... |
| 31 /** @const */ var Command = cr.ui.Command; | 31 /** @const */ var Command = cr.ui.Command; |
| 32 /** @const */ var Menu = cr.ui.Menu; | 32 /** @const */ var Menu = cr.ui.Menu; |
| 33 /** @const */ var MenuButton = cr.ui.MenuButton; | 33 /** @const */ var MenuButton = cr.ui.MenuButton; |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Enum that shows the filtering behavior for a host or URL to a supervised | 36 * Enum that shows the filtering behavior for a host or URL to a supervised |
| 37 * user. Must behave like the FilteringBehavior enum from | 37 * user. Must behave like the FilteringBehavior enum from |
| 38 * supervised_user_url_filter.h. | 38 * supervised_user_url_filter.h. |
| 39 * @enum {number} | 39 * @enum {number} |
| 40 */ | 40 */ |
| 41 SupervisedUserFilteringBehavior = { | 41 var SupervisedUserFilteringBehavior = { |
| 42 ALLOW: 0, | 42 ALLOW: 0, |
| 43 WARN: 1, | 43 WARN: 1, |
| 44 BLOCK: 2 | 44 BLOCK: 2 |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 /** |
| 48 * The type of the history result object. The definition is based on |
| 49 * chrome/browser/ui/webui/history_ui.cc: |
| 50 * BrowsingHistoryHandler::HistoryEntry::ToValue() |
| 51 * @typedef {{allTimestamps: Array.<number>, |
| 52 * blockedVisit: (boolean|undefined), |
| 53 * dateRelativeDay: (string|undefined), |
| 54 * dateShort: string, |
| 55 * dateTimeOfDay: (string|undefined), |
| 56 * deviceName: string, |
| 57 * deviceType: string, |
| 58 * domain: string, |
| 59 * hostFilteringBehavior: (number|undefined), |
| 60 * snippet: (string|undefined), |
| 61 * starred: boolean, |
| 62 * time: number, |
| 63 * title: string, |
| 64 * url: string}} |
| 65 */ |
| 66 var HistoryEntry; |
| 67 |
| 68 /** |
| 69 * The type of the history results info object. The definition is based on |
| 70 * chrome/browser/ui/webui/history_ui.cc: |
| 71 * BrowsingHistoryHandler::QueryComplete() |
| 72 * @typedef {{finished: boolean, |
| 73 * hasSyncedResults: (boolean|undefined), |
| 74 * queryEndTime: string, |
| 75 * queryStartTime: string, |
| 76 * term: string}} |
| 77 */ |
| 78 var HistoryQuery; |
| 79 |
| 47 MenuButton.createDropDownArrows(); | 80 MenuButton.createDropDownArrows(); |
| 48 | 81 |
| 49 /** | 82 /** |
| 50 * Returns true if the mobile (non-desktop) version is being shown. | 83 * Returns true if the mobile (non-desktop) version is being shown. |
| 51 * @return {boolean} true if the mobile version is being shown. | 84 * @return {boolean} true if the mobile version is being shown. |
| 52 */ | 85 */ |
| 53 function isMobileVersion() { | 86 function isMobileVersion() { |
| 54 return !document.body.classList.contains('uber-frame'); | 87 return !document.body.classList.contains('uber-frame'); |
| 55 } | 88 } |
| 56 | 89 |
| 57 /** | 90 /** |
| 58 * Record an action in UMA. | 91 * Record an action in UMA. |
| 59 * @param {string} actionDesc The name of the action to be logged. | 92 * @param {string} actionDesc The name of the action to be logged. |
| 60 */ | 93 */ |
| 61 function recordUmaAction(actionDesc) { | 94 function recordUmaAction(actionDesc) { |
| 62 chrome.send('metricsHandler:recordAction', [actionDesc]); | 95 chrome.send('metricsHandler:recordAction', [actionDesc]); |
| 63 } | 96 } |
| 64 | 97 |
| 65 /** | 98 /** |
| 66 * Record a histogram value in UMA. If specified value is larger than the max | 99 * Record a histogram value in UMA. If specified value is larger than the max |
| 67 * bucket value, record the value in the largest bucket. | 100 * bucket value, record the value in the largest bucket. |
| 68 * @param {string} histogram The name of the histogram to be recorded in. | 101 * @param {string} histogram The name of the histogram to be recorded in. |
| 69 * @param {integer} maxBucketValue The max value for the last histogram bucket. | 102 * @param {number} maxBucketValue The max value for the last histogram bucket. |
| 70 * @param {integer} value The value to record in the histogram. | 103 * @param {number} value The value to record in the histogram. |
| 71 */ | 104 */ |
| 72 function recordUmaHistogram(histogram, maxBucketValue, value) { | 105 function recordUmaHistogram(histogram, maxBucketValue, value) { |
| 73 chrome.send('metricsHandler:recordInHistogram', | 106 chrome.send('metricsHandler:recordInHistogram', |
| 74 [histogram, | 107 [histogram, |
| 75 ((value > maxBucketValue) ? maxBucketValue : value), | 108 ((value > maxBucketValue) ? maxBucketValue : value), |
| 76 maxBucketValue]); | 109 maxBucketValue]); |
| 77 } | 110 } |
| 78 | 111 |
| 79 /////////////////////////////////////////////////////////////////////////////// | 112 /////////////////////////////////////////////////////////////////////////////// |
| 80 // Visit: | 113 // Visit: |
| 81 | 114 |
| 82 /** | 115 /** |
| 83 * Class to hold all the information about an entry in our model. | 116 * Class to hold all the information about an entry in our model. |
| 84 * @param {Object} result An object containing the visit's data. | 117 * @param {HistoryEntry} result An object containing the visit's data. |
| 85 * @param {boolean} continued Whether this visit is on the same day as the | 118 * @param {boolean} continued Whether this visit is on the same day as the |
| 86 * visit before it. | 119 * visit before it. |
| 87 * @param {HistoryModel} model The model object this entry belongs to. | 120 * @param {HistoryModel} model The model object this entry belongs to. |
| 88 * @constructor | 121 * @constructor |
| 89 */ | 122 */ |
| 90 function Visit(result, continued, model) { | 123 function Visit(result, continued, model) { |
| 91 this.model_ = model; | 124 this.model_ = model; |
| 92 this.title_ = result.title; | 125 this.title_ = result.title; |
| 93 this.url_ = result.url; | 126 this.url_ = result.url; |
| 94 this.domain_ = result.domain; | 127 this.domain_ = result.domain; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 bookmarkSection.addEventListener('click', function f(e) { | 230 bookmarkSection.addEventListener('click', function f(e) { |
| 198 recordUmaAction('HistoryPage_BookmarkStarClicked'); | 231 recordUmaAction('HistoryPage_BookmarkStarClicked'); |
| 199 bookmarkSection.classList.remove('starred'); | 232 bookmarkSection.classList.remove('starred'); |
| 200 chrome.send('removeBookmark', [self.url_]); | 233 chrome.send('removeBookmark', [self.url_]); |
| 201 bookmarkSection.removeEventListener('click', f); | 234 bookmarkSection.removeEventListener('click', f); |
| 202 e.preventDefault(); | 235 e.preventDefault(); |
| 203 }); | 236 }); |
| 204 } | 237 } |
| 205 entryBox.appendChild(bookmarkSection); | 238 entryBox.appendChild(bookmarkSection); |
| 206 | 239 |
| 207 var visitEntryWrapper = entryBox.appendChild(document.createElement('div')); | 240 var visitEntryWrapper = /** @type {HTMLElement} */( |
| 241 entryBox.appendChild(document.createElement('div'))); |
| 208 if (addTitleFavicon || this.blockedVisit) | 242 if (addTitleFavicon || this.blockedVisit) |
| 209 visitEntryWrapper.classList.add('visit-entry'); | 243 visitEntryWrapper.classList.add('visit-entry'); |
| 210 if (this.blockedVisit) { | 244 if (this.blockedVisit) { |
| 211 visitEntryWrapper.classList.add('blocked-indicator'); | 245 visitEntryWrapper.classList.add('blocked-indicator'); |
| 212 visitEntryWrapper.appendChild(this.getVisitAttemptDOM_()); | 246 visitEntryWrapper.appendChild(this.getVisitAttemptDOM_()); |
| 213 } else { | 247 } else { |
| 214 var title = visitEntryWrapper.appendChild( | 248 var title = visitEntryWrapper.appendChild( |
| 215 this.getTitleDOM_(isSearchResult)); | 249 this.getTitleDOM_(isSearchResult)); |
| 216 | 250 |
| 217 if (addTitleFavicon) | 251 if (addTitleFavicon) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 /** | 326 /** |
| 293 * Remove this visit from the history. | 327 * Remove this visit from the history. |
| 294 */ | 328 */ |
| 295 Visit.prototype.removeFromHistory = function() { | 329 Visit.prototype.removeFromHistory = function() { |
| 296 recordUmaAction('HistoryPage_EntryMenuRemoveFromHistory'); | 330 recordUmaAction('HistoryPage_EntryMenuRemoveFromHistory'); |
| 297 this.model_.removeVisitsFromHistory([this], function() { | 331 this.model_.removeVisitsFromHistory([this], function() { |
| 298 this.model_.getView().removeVisit(this); | 332 this.model_.getView().removeVisit(this); |
| 299 }.bind(this)); | 333 }.bind(this)); |
| 300 }; | 334 }; |
| 301 | 335 |
| 336 // Closure Compiler doesn't support Object.defineProperty(). |
| 337 // https://github.com/google/closure-compiler/issues/302 |
| 302 Object.defineProperty(Visit.prototype, 'checkBox', { | 338 Object.defineProperty(Visit.prototype, 'checkBox', { |
| 303 get: function() { | 339 get: /** @this {Visit} */function() { |
| 304 return this.domNode_.querySelector('input[type=checkbox]'); | 340 return this.domNode_.querySelector('input[type=checkbox]'); |
| 305 }, | 341 }, |
| 306 }); | 342 }); |
| 307 | 343 |
| 308 Object.defineProperty(Visit.prototype, 'bookmarkStar', { | 344 Object.defineProperty(Visit.prototype, 'bookmarkStar', { |
| 309 get: function() { | 345 get: /** @this {Visit} */function() { |
| 310 return this.domNode_.querySelector('.bookmark-section.starred'); | 346 return this.domNode_.querySelector('.bookmark-section.starred'); |
| 311 }, | 347 }, |
| 312 }); | 348 }); |
| 313 | 349 |
| 314 Object.defineProperty(Visit.prototype, 'titleLink', { | 350 Object.defineProperty(Visit.prototype, 'titleLink', { |
| 315 get: function() { | 351 get: /** @this {Visit} */function() { |
| 316 return this.domNode_.querySelector('.title a'); | 352 return this.domNode_.querySelector('.title a'); |
| 317 }, | 353 }, |
| 318 }); | 354 }); |
| 319 | 355 |
| 320 Object.defineProperty(Visit.prototype, 'dropDown', { | 356 Object.defineProperty(Visit.prototype, 'dropDown', { |
| 321 get: function() { | 357 get: /** @this {Visit} */function() { |
| 322 return this.domNode_.querySelector('button.drop-down'); | 358 return this.domNode_.querySelector('button.drop-down'); |
| 323 }, | 359 }, |
| 324 }); | 360 }); |
| 325 | 361 |
| 326 // Visit, private: ------------------------------------------------------------ | 362 // Visit, private: ------------------------------------------------------------ |
| 327 | 363 |
| 328 /** | 364 /** |
| 329 * Add child text nodes to a node such that occurrences of the specified text is | 365 * Add child text nodes to a node such that occurrences of the specified text is |
| 330 * highlighted. | 366 * highlighted. |
| 331 * @param {Node} node The node under which new text nodes will be made as | 367 * @param {Node} node The node under which new text nodes will be made as |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 * the data becomes available, the model will call the view back. | 589 * the data becomes available, the model will call the view back. |
| 554 * @param {number} page The page we want to view. | 590 * @param {number} page The page we want to view. |
| 555 */ | 591 */ |
| 556 HistoryModel.prototype.requestPage = function(page) { | 592 HistoryModel.prototype.requestPage = function(page) { |
| 557 this.requestedPage_ = page; | 593 this.requestedPage_ = page; |
| 558 this.updateSearch_(); | 594 this.updateSearch_(); |
| 559 }; | 595 }; |
| 560 | 596 |
| 561 /** | 597 /** |
| 562 * Receiver for history query. | 598 * Receiver for history query. |
| 563 * @param {Object} info An object containing information about the query. | 599 * @param {HistoryQuery} info An object containing information about the query. |
| 564 * @param {Array} results A list of results. | 600 * @param {Array.<HistoryEntry>} results A list of results. |
| 565 */ | 601 */ |
| 566 HistoryModel.prototype.addResults = function(info, results) { | 602 HistoryModel.prototype.addResults = function(info, results) { |
| 567 // If no requests are in flight then this was an old request so we drop the | 603 // If no requests are in flight then this was an old request so we drop the |
| 568 // results. Double check the search term as well. | 604 // results. Double check the search term as well. |
| 569 if (!this.inFlight_ || info.term != this.searchText_) | 605 if (!this.inFlight_ || info.term != this.searchText_) |
| 570 return; | 606 return; |
| 571 | 607 |
| 572 $('loading-spinner').hidden = true; | 608 $('loading-spinner').hidden = true; |
| 573 this.inFlight_ = false; | 609 this.inFlight_ = false; |
| 574 this.isQueryFinished_ = info.finished; | 610 this.isQueryFinished_ = info.finished; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 * @return {boolean} true if the there are more results, otherwise false. | 652 * @return {boolean} true if the there are more results, otherwise false. |
| 617 */ | 653 */ |
| 618 HistoryModel.prototype.hasMoreResults = function() { | 654 HistoryModel.prototype.hasMoreResults = function() { |
| 619 return this.haveDataForPage_(this.requestedPage_ + 1) || | 655 return this.haveDataForPage_(this.requestedPage_ + 1) || |
| 620 !this.isQueryFinished_; | 656 !this.isQueryFinished_; |
| 621 }; | 657 }; |
| 622 | 658 |
| 623 /** | 659 /** |
| 624 * Removes a list of visits from the history, and calls |callback| when the | 660 * Removes a list of visits from the history, and calls |callback| when the |
| 625 * removal has successfully completed. | 661 * removal has successfully completed. |
| 626 * @param {Array<Visit>} visits The visits to remove. | 662 * @param {Array.<Visit>} visits The visits to remove. |
| 627 * @param {Function} callback The function to call after removal succeeds. | 663 * @param {Function} callback The function to call after removal succeeds. |
| 628 */ | 664 */ |
| 629 HistoryModel.prototype.removeVisitsFromHistory = function(visits, callback) { | 665 HistoryModel.prototype.removeVisitsFromHistory = function(visits, callback) { |
| 630 assert(this.deletingHistoryAllowed); | 666 assert(this.deletingHistoryAllowed); |
| 631 | 667 |
| 632 var toBeRemoved = []; | 668 var toBeRemoved = []; |
| 633 for (var i = 0; i < visits.length; i++) { | 669 for (var i = 0; i < visits.length; i++) { |
| 634 toBeRemoved.push({ | 670 toBeRemoved.push({ |
| 635 url: visits[i].url_, | 671 url: visits[i].url_, |
| 636 timestamps: visits[i].allTimestamps | 672 timestamps: visits[i].allTimestamps |
| (...skipping 13 matching lines...) Expand all Loading... |
| 650 * Called when visits have been succesfully removed from the history. | 686 * Called when visits have been succesfully removed from the history. |
| 651 */ | 687 */ |
| 652 HistoryModel.prototype.deleteComplete = function() { | 688 HistoryModel.prototype.deleteComplete = function() { |
| 653 // Call the callback, with 'this' undefined inside the callback. | 689 // Call the callback, with 'this' undefined inside the callback. |
| 654 this.deleteCompleteCallback_.call(); | 690 this.deleteCompleteCallback_.call(); |
| 655 this.deleteCompleteCallback_ = null; | 691 this.deleteCompleteCallback_ = null; |
| 656 }; | 692 }; |
| 657 | 693 |
| 658 // Getter and setter for HistoryModel.rangeInDays_. | 694 // Getter and setter for HistoryModel.rangeInDays_. |
| 659 Object.defineProperty(HistoryModel.prototype, 'rangeInDays', { | 695 Object.defineProperty(HistoryModel.prototype, 'rangeInDays', { |
| 660 get: function() { | 696 get: /** @this {HistoryModel} */function() { |
| 661 return this.rangeInDays_; | 697 return this.rangeInDays_; |
| 662 }, | 698 }, |
| 663 set: function(range) { | 699 set: /** @this {HistoryModel} */function(range) { |
| 664 this.rangeInDays_ = range; | 700 this.rangeInDays_ = range; |
| 665 } | 701 } |
| 666 }); | 702 }); |
| 667 | 703 |
| 668 /** | 704 /** |
| 669 * Getter and setter for HistoryModel.offset_. The offset moves the current | 705 * Getter and setter for HistoryModel.offset_. The offset moves the current |
| 670 * query 'window' |range| days behind. As such for range set to WEEK an offset | 706 * query 'window' |range| days behind. As such for range set to WEEK an offset |
| 671 * of 0 refers to the last 7 days, an offset of 1 refers to the 7 day period | 707 * of 0 refers to the last 7 days, an offset of 1 refers to the 7 day period |
| 672 * that ended 7 days ago, etc. For MONTH an offset of 0 refers to the current | 708 * that ended 7 days ago, etc. For MONTH an offset of 0 refers to the current |
| 673 * calendar month, 1 to the previous one, etc. | 709 * calendar month, 1 to the previous one, etc. |
| 674 */ | 710 */ |
| 675 Object.defineProperty(HistoryModel.prototype, 'offset', { | 711 Object.defineProperty(HistoryModel.prototype, 'offset', { |
| 676 get: function() { | 712 get: /** @this {HistoryModel} */function() { |
| 677 return this.offset_; | 713 return this.offset_; |
| 678 }, | 714 }, |
| 679 set: function(offset) { | 715 set: /** @this {HistoryModel} */function(offset) { |
| 680 this.offset_ = offset; | 716 this.offset_ = offset; |
| 681 } | 717 } |
| 682 }); | 718 }); |
| 683 | 719 |
| 684 // Setter for HistoryModel.requestedPage_. | 720 // Setter for HistoryModel.requestedPage_. |
| 685 Object.defineProperty(HistoryModel.prototype, 'requestedPage', { | 721 Object.defineProperty(HistoryModel.prototype, 'requestedPage', { |
| 686 set: function(page) { | 722 set: /** @this {HistoryModel} */function(page) { |
| 687 this.requestedPage_ = page; | 723 this.requestedPage_ = page; |
| 688 } | 724 } |
| 689 }); | 725 }); |
| 690 | 726 |
| 691 /** | 727 /** |
| 692 * Removes |visit| from this model. | 728 * Removes |visit| from this model. |
| 693 * @param {Visit} visit A visit to remove. | 729 * @param {Visit} visit A visit to remove. |
| 694 */ | 730 */ |
| 695 HistoryModel.prototype.removeVisit = function(visit) { | 731 HistoryModel.prototype.removeVisit = function(visit) { |
| 696 var index = this.visits_.indexOf(visit); | 732 var index = this.visits_.indexOf(visit); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 * Gets whether we are grouped by domain. | 850 * Gets whether we are grouped by domain. |
| 815 * @return {boolean} Whether the results are grouped by domain. | 851 * @return {boolean} Whether the results are grouped by domain. |
| 816 */ | 852 */ |
| 817 HistoryModel.prototype.getGroupByDomain = function() { | 853 HistoryModel.prototype.getGroupByDomain = function() { |
| 818 return this.groupByDomain_; | 854 return this.groupByDomain_; |
| 819 }; | 855 }; |
| 820 | 856 |
| 821 /////////////////////////////////////////////////////////////////////////////// | 857 /////////////////////////////////////////////////////////////////////////////// |
| 822 // HistoryFocusObserver: | 858 // HistoryFocusObserver: |
| 823 | 859 |
| 824 /** @implements {cr.ui.FocusRow.Observer} */ | 860 /** |
| 861 * @constructor |
| 862 * @implements {cr.ui.FocusRow.Observer} |
| 863 */ |
| 825 function HistoryFocusObserver() {} | 864 function HistoryFocusObserver() {} |
| 826 | 865 |
| 827 HistoryFocusObserver.prototype = { | 866 HistoryFocusObserver.prototype = { |
| 828 /** @override */ | 867 /** @override */ |
| 829 onActivate: function(row) { | 868 onActivate: function(row) { |
| 830 this.getActiveRowElement_(row).classList.add('active'); | 869 this.getActiveRowElement_(row).classList.add('active'); |
| 831 }, | 870 }, |
| 832 | 871 |
| 833 /** @override */ | 872 /** @override */ |
| 834 onDeactivate: function(row) { | 873 onDeactivate: function(row) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 recordUmaAction('HistoryPage_NewerHistoryClick'); | 929 recordUmaAction('HistoryPage_NewerHistoryClick'); |
| 891 self.setPage(self.pageIndex_ - 1); | 930 self.setPage(self.pageIndex_ - 1); |
| 892 }); | 931 }); |
| 893 $('older-button').addEventListener('click', function() { | 932 $('older-button').addEventListener('click', function() { |
| 894 recordUmaAction('HistoryPage_OlderHistoryClick'); | 933 recordUmaAction('HistoryPage_OlderHistoryClick'); |
| 895 self.setPage(self.pageIndex_ + 1); | 934 self.setPage(self.pageIndex_ + 1); |
| 896 }); | 935 }); |
| 897 | 936 |
| 898 var handleRangeChange = function(e) { | 937 var handleRangeChange = function(e) { |
| 899 // Update the results and save the last state. | 938 // Update the results and save the last state. |
| 900 self.setRangeInDays(parseInt(e.target.value, 10)); | 939 var value = parseInt(e.target.value, 10); |
| 940 self.setRangeInDays(/** @type {HistoryModel.Range.<number>} */(value)); |
| 901 }; | 941 }; |
| 902 | 942 |
| 903 // Add handlers for the range options. | 943 // Add handlers for the range options. |
| 904 $('timeframe-filter-all').addEventListener('change', handleRangeChange); | 944 $('timeframe-filter-all').addEventListener('change', handleRangeChange); |
| 905 $('timeframe-filter-week').addEventListener('change', handleRangeChange); | 945 $('timeframe-filter-week').addEventListener('change', handleRangeChange); |
| 906 $('timeframe-filter-month').addEventListener('change', handleRangeChange); | 946 $('timeframe-filter-month').addEventListener('change', handleRangeChange); |
| 907 | 947 |
| 908 $('range-previous').addEventListener('click', function(e) { | 948 $('range-previous').addEventListener('click', function(e) { |
| 909 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME) | 949 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME) |
| 910 self.setPage(self.pageIndex_ + 1); | 950 self.setPage(self.pageIndex_ + 1); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 | 1028 |
| 989 /** | 1029 /** |
| 990 * @return {number} The page number being viewed. | 1030 * @return {number} The page number being viewed. |
| 991 */ | 1031 */ |
| 992 HistoryView.prototype.getPage = function() { | 1032 HistoryView.prototype.getPage = function() { |
| 993 return this.pageIndex_; | 1033 return this.pageIndex_; |
| 994 }; | 1034 }; |
| 995 | 1035 |
| 996 /** | 1036 /** |
| 997 * Set the current range for grouped results. | 1037 * Set the current range for grouped results. |
| 998 * @param {string} range The number of days to which the range should be set. | 1038 * @param {HistoryModel.Range} range The number of days to which the range |
| 1039 * should be set. |
| 999 */ | 1040 */ |
| 1000 HistoryView.prototype.setRangeInDays = function(range) { | 1041 HistoryView.prototype.setRangeInDays = function(range) { |
| 1001 // Set the range, offset and reset the page. | 1042 // Set the range, offset and reset the page. |
| 1002 this.setPageState(this.model_.getSearchText(), 0, range, 0); | 1043 this.setPageState(this.model_.getSearchText(), 0, range, 0); |
| 1003 }; | 1044 }; |
| 1004 | 1045 |
| 1005 /** | 1046 /** |
| 1006 * Get the current range in days. | 1047 * Get the current range in days. |
| 1007 * @return {number} Current range in days from the model. | 1048 * @return {HistoryModel.Range} Current range in days from the model. |
| 1008 */ | 1049 */ |
| 1009 HistoryView.prototype.getRangeInDays = function() { | 1050 HistoryView.prototype.getRangeInDays = function() { |
| 1010 return this.model_.rangeInDays; | 1051 return this.model_.rangeInDays; |
| 1011 }; | 1052 }; |
| 1012 | 1053 |
| 1013 /** | 1054 /** |
| 1014 * Set the current offset for grouped results. | 1055 * Set the current offset for grouped results. |
| 1015 * @param {number} offset Offset to set. | 1056 * @param {number} offset Offset to set. |
| 1016 */ | 1057 */ |
| 1017 HistoryView.prototype.setOffset = function(offset) { | 1058 HistoryView.prototype.setOffset = function(offset) { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 | 1396 |
| 1356 for (var i = 0; i < domains.length; ++i) { | 1397 for (var i = 0; i < domains.length; ++i) { |
| 1357 var domain = domains[i]; | 1398 var domain = domains[i]; |
| 1358 this.getGroupedVisitsDOM_(results, domain, visitsByDomain[domain]); | 1399 this.getGroupedVisitsDOM_(results, domain, visitsByDomain[domain]); |
| 1359 } | 1400 } |
| 1360 }; | 1401 }; |
| 1361 | 1402 |
| 1362 /** | 1403 /** |
| 1363 * Adds the results for a month. | 1404 * Adds the results for a month. |
| 1364 * @param {Array} visits Visits returned by the query. | 1405 * @param {Array} visits Visits returned by the query. |
| 1365 * @param {Element} parentElement Element to which to add the results to. | 1406 * @param {Node} parentNode Node to which to add the results to. |
| 1366 * @private | 1407 * @private |
| 1367 */ | 1408 */ |
| 1368 HistoryView.prototype.addMonthResults_ = function(visits, parentElement) { | 1409 HistoryView.prototype.addMonthResults_ = function(visits, parentNode) { |
| 1369 if (visits.length == 0) | 1410 if (visits.length == 0) |
| 1370 return; | 1411 return; |
| 1371 | 1412 |
| 1372 var monthResults = parentElement.appendChild( | 1413 var monthResults = /** @type {HTMLOListElement} */(parentNode.appendChild( |
| 1373 createElementWithClassName('ol', 'month-results')); | 1414 createElementWithClassName('ol', 'month-results'))); |
| 1374 // Don't add checkboxes if entries can not be edited. | 1415 // Don't add checkboxes if entries can not be edited. |
| 1375 if (!this.model_.editingEntriesAllowed) | 1416 if (!this.model_.editingEntriesAllowed) |
| 1376 monthResults.classList.add('no-checkboxes'); | 1417 monthResults.classList.add('no-checkboxes'); |
| 1377 | 1418 |
| 1378 this.groupVisitsByDomain_(visits, monthResults); | 1419 this.groupVisitsByDomain_(visits, monthResults); |
| 1379 }; | 1420 }; |
| 1380 | 1421 |
| 1381 /** | 1422 /** |
| 1382 * Adds the results for a certain day. This includes a title with the day of | 1423 * Adds the results for a certain day. This includes a title with the day of |
| 1383 * the results and the results themselves, grouped or not. | 1424 * the results and the results themselves, grouped or not. |
| 1384 * @param {Array} visits Visits returned by the query. | 1425 * @param {Array} visits Visits returned by the query. |
| 1385 * @param {Element} parentElement Element to which to add the results to. | 1426 * @param {Node} parentNode Node to which to add the results to. |
| 1386 * @private | 1427 * @private |
| 1387 */ | 1428 */ |
| 1388 HistoryView.prototype.addDayResults_ = function(visits, parentElement) { | 1429 HistoryView.prototype.addDayResults_ = function(visits, parentNode) { |
| 1389 if (visits.length == 0) | 1430 if (visits.length == 0) |
| 1390 return; | 1431 return; |
| 1391 | 1432 |
| 1392 var firstVisit = visits[0]; | 1433 var firstVisit = visits[0]; |
| 1393 var day = parentElement.appendChild(createElementWithClassName('h3', 'day')); | 1434 var day = parentNode.appendChild(createElementWithClassName('h3', 'day')); |
| 1394 day.appendChild(document.createTextNode(firstVisit.dateRelativeDay)); | 1435 day.appendChild(document.createTextNode(firstVisit.dateRelativeDay)); |
| 1395 if (firstVisit.continued) { | 1436 if (firstVisit.continued) { |
| 1396 day.appendChild(document.createTextNode(' ' + | 1437 day.appendChild(document.createTextNode(' ' + |
| 1397 loadTimeData.getString('cont'))); | 1438 loadTimeData.getString('cont'))); |
| 1398 } | 1439 } |
| 1399 var dayResults = parentElement.appendChild( | 1440 var dayResults = /** @type {HTMLElement} */(parentNode.appendChild( |
| 1400 createElementWithClassName('ol', 'day-results')); | 1441 createElementWithClassName('ol', 'day-results'))); |
| 1401 | 1442 |
| 1402 // Don't add checkboxes if entries can not be edited. | 1443 // Don't add checkboxes if entries can not be edited. |
| 1403 if (!this.model_.editingEntriesAllowed) | 1444 if (!this.model_.editingEntriesAllowed) |
| 1404 dayResults.classList.add('no-checkboxes'); | 1445 dayResults.classList.add('no-checkboxes'); |
| 1405 | 1446 |
| 1406 if (this.model_.getGroupByDomain()) { | 1447 if (this.model_.getGroupByDomain()) { |
| 1407 this.groupVisitsByDomain_(visits, dayResults); | 1448 this.groupVisitsByDomain_(visits, dayResults); |
| 1408 } else { | 1449 } else { |
| 1409 var lastTime; | 1450 var lastTime; |
| 1410 | 1451 |
| 1411 for (var i = 0, visit; visit = visits[i]; i++) { | 1452 for (var i = 0, visit; visit = visits[i]; i++) { |
| 1412 // If enough time has passed between visits, indicate a gap in browsing. | 1453 // If enough time has passed between visits, indicate a gap in browsing. |
| 1413 var thisTime = visit.date.getTime(); | 1454 var thisTime = visit.date.getTime(); |
| 1414 if (lastTime && lastTime - thisTime > BROWSING_GAP_TIME) | 1455 if (lastTime && lastTime - thisTime > BROWSING_GAP_TIME) |
| 1415 dayResults.appendChild(createElementWithClassName('li', 'gap')); | 1456 dayResults.appendChild(createElementWithClassName('li', 'gap')); |
| 1416 | 1457 |
| 1417 // Insert the visit into the DOM. | 1458 // Insert the visit into the DOM. |
| 1418 dayResults.appendChild(visit.getResultDOM({ addTitleFavicon: true })); | 1459 dayResults.appendChild(visit.getResultDOM({ addTitleFavicon: true })); |
| 1419 this.setVisitRendered_(visit); | 1460 this.setVisitRendered_(visit); |
| 1420 | 1461 |
| 1421 lastTime = thisTime; | 1462 lastTime = thisTime; |
| 1422 } | 1463 } |
| 1423 } | 1464 } |
| 1424 }; | 1465 }; |
| 1425 | 1466 |
| 1426 /** | 1467 /** |
| 1427 * Adds the text that shows the current interval, used for week and month | 1468 * Adds the text that shows the current interval, used for week and month |
| 1428 * results. | 1469 * results. |
| 1429 * @param {Element} resultsFragment The element to which the interval will be | 1470 * @param {Node} resultsFragment The element to which the interval will be |
| 1430 * added to. | 1471 * added to. |
| 1431 * @private | 1472 * @private |
| 1432 */ | 1473 */ |
| 1433 HistoryView.prototype.addTimeframeInterval_ = function(resultsFragment) { | 1474 HistoryView.prototype.addTimeframeInterval_ = function(resultsFragment) { |
| 1434 if (this.getRangeInDays() == HistoryModel.Range.ALL_TIME) | 1475 if (this.getRangeInDays() == HistoryModel.Range.ALL_TIME) |
| 1435 return; | 1476 return; |
| 1436 | 1477 |
| 1437 // If this is a time range result add some text that shows what is the | 1478 // If this is a time range result add some text that shows what is the |
| 1438 // time range for the results the user is viewing. | 1479 // time range for the results the user is viewing. |
| 1439 var timeFrame = resultsFragment.appendChild( | 1480 var timeFrame = resultsFragment.appendChild( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 // Go through all of the visits and process them in chunks of one day. | 1560 // Go through all of the visits and process them in chunks of one day. |
| 1520 while (dayEnd < results.length) { | 1561 while (dayEnd < results.length) { |
| 1521 // Skip over the ones that are already rendered. | 1562 // Skip over the ones that are already rendered. |
| 1522 while (dayStart < results.length && results[dayStart].isRendered) | 1563 while (dayStart < results.length && results[dayStart].isRendered) |
| 1523 ++dayStart; | 1564 ++dayStart; |
| 1524 var dayEnd = dayStart + 1; | 1565 var dayEnd = dayStart + 1; |
| 1525 while (dayEnd < results.length && results[dayEnd].continued) | 1566 while (dayEnd < results.length && results[dayEnd].continued) |
| 1526 ++dayEnd; | 1567 ++dayEnd; |
| 1527 | 1568 |
| 1528 this.addDayResults_( | 1569 this.addDayResults_( |
| 1529 results.slice(dayStart, dayEnd), resultsFragment, groupByDomain); | 1570 results.slice(dayStart, dayEnd), resultsFragment); |
| 1530 } | 1571 } |
| 1531 } | 1572 } |
| 1532 | 1573 |
| 1533 // Add all the days and their visits to the page. | 1574 // Add all the days and their visits to the page. |
| 1534 this.resultDiv_.appendChild(resultsFragment); | 1575 this.resultDiv_.appendChild(resultsFragment); |
| 1535 } | 1576 } |
| 1536 // After the results have been added to the DOM, determine the size of the | 1577 // After the results have been added to the DOM, determine the size of the |
| 1537 // time column. | 1578 // time column. |
| 1538 this.setTimeColumnWidth_(this.resultDiv_); | 1579 this.setTimeColumnWidth_(); |
| 1539 }; | 1580 }; |
| 1540 | 1581 |
| 1541 var focusGridRowSelector = [ | 1582 var focusGridRowSelector = [ |
| 1542 '.day-results > .entry:not(.fade-out)', | 1583 '.day-results > .entry:not(.fade-out)', |
| 1543 '.expand .grouped .entry:not(.fade-out)', | 1584 '.expand .grouped .entry:not(.fade-out)', |
| 1544 '.site-domain-wrapper' | 1585 '.site-domain-wrapper' |
| 1545 ].join(', '); | 1586 ].join(', '); |
| 1546 | 1587 |
| 1547 var focusGridColumnSelector = [ | 1588 var focusGridColumnSelector = [ |
| 1548 '.entry-box input', | 1589 '.entry-box input', |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 var styleEl = $('timeColumnStyle'); | 1663 var styleEl = $('timeColumnStyle'); |
| 1623 if (!styleEl) { | 1664 if (!styleEl) { |
| 1624 styleEl = document.head.appendChild(document.createElement('style')); | 1665 styleEl = document.head.appendChild(document.createElement('style')); |
| 1625 styleEl.id = 'timeColumnStyle'; | 1666 styleEl.id = 'timeColumnStyle'; |
| 1626 } | 1667 } |
| 1627 styleEl.textContent = '.entry .time { min-width: ' + maxWidth + 'px; }'; | 1668 styleEl.textContent = '.entry .time { min-width: ' + maxWidth + 'px; }'; |
| 1628 }; | 1669 }; |
| 1629 | 1670 |
| 1630 /** | 1671 /** |
| 1631 * Toggles an element in the grouped history. | 1672 * Toggles an element in the grouped history. |
| 1632 * @param {Element} e The element which was clicked on. | 1673 * @param {Event} e The event with element |e.target| which was clicked on. |
| 1633 * @private | 1674 * @private |
| 1634 */ | 1675 */ |
| 1635 HistoryView.prototype.toggleGroupedVisits_ = function(e) { | 1676 HistoryView.prototype.toggleGroupedVisits_ = function(e) { |
| 1636 var entry = findAncestorByClass(e.target, 'site-entry'); | 1677 var entry = findAncestorByClass(/** @type {Element} */(e.target), |
| 1678 'site-entry'); |
| 1637 var innerResultList = entry.querySelector('.site-results'); | 1679 var innerResultList = entry.querySelector('.site-results'); |
| 1638 | 1680 |
| 1639 if (entry.classList.contains('expand')) { | 1681 if (entry.classList.contains('expand')) { |
| 1640 innerResultList.style.height = 0; | 1682 innerResultList.style.height = 0; |
| 1641 } else { | 1683 } else { |
| 1642 innerResultList.style.height = 'auto'; | 1684 innerResultList.style.height = 'auto'; |
| 1643 // -webkit-transition does not work on height:auto elements so first set | 1685 // -webkit-transition does not work on height:auto elements so first set |
| 1644 // the height to auto so that it is computed and then set it to the | 1686 // the height to auto so that it is computed and then set it to the |
| 1645 // computed value in pixels so the transition works properly. | 1687 // computed value in pixels so the transition works properly. |
| 1646 var height = innerResultList.clientHeight; | 1688 var height = innerResultList.clientHeight; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 var searchField = $('search-field'); | 1821 var searchField = $('search-field'); |
| 1780 | 1822 |
| 1781 historyModel = new HistoryModel(); | 1823 historyModel = new HistoryModel(); |
| 1782 historyView = new HistoryView(historyModel); | 1824 historyView = new HistoryView(historyModel); |
| 1783 pageState = new PageState(historyModel, historyView); | 1825 pageState = new PageState(historyModel, historyView); |
| 1784 | 1826 |
| 1785 // Create default view. | 1827 // Create default view. |
| 1786 var hashData = pageState.getHashData(); | 1828 var hashData = pageState.getHashData(); |
| 1787 var grouped = (hashData.grouped == 'true') || historyModel.getGroupByDomain(); | 1829 var grouped = (hashData.grouped == 'true') || historyModel.getGroupByDomain(); |
| 1788 var page = parseInt(hashData.page, 10) || historyView.getPage(); | 1830 var page = parseInt(hashData.page, 10) || historyView.getPage(); |
| 1789 var range = parseInt(hashData.range, 10) || historyView.getRangeInDays(); | 1831 var range = /** @type {HistoryModel.Range} */(parseInt(hashData.range, 10)) || |
| 1832 historyView.getRangeInDays(); |
| 1790 var offset = parseInt(hashData.offset, 10) || historyView.getOffset(); | 1833 var offset = parseInt(hashData.offset, 10) || historyView.getOffset(); |
| 1791 historyView.setPageState(hashData.q, page, range, offset); | 1834 historyView.setPageState(hashData.q, page, range, offset); |
| 1792 | 1835 |
| 1793 if ($('overlay')) { | 1836 if ($('overlay')) { |
| 1794 cr.ui.overlay.setupOverlay($('overlay')); | 1837 cr.ui.overlay.setupOverlay($('overlay')); |
| 1795 cr.ui.overlay.globalInitialization(); | 1838 cr.ui.overlay.globalInitialization(); |
| 1796 } | 1839 } |
| 1797 HistoryFocusManager.getInstance().initialize(); | 1840 HistoryFocusManager.getInstance().initialize(); |
| 1798 | 1841 |
| 1799 var doSearch = function(e) { | 1842 var doSearch = function(e) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 // visibility, otherwise the button will flash on the screen before the | 1896 // visibility, otherwise the button will flash on the screen before the |
| 1854 // keyboard animates away. | 1897 // keyboard animates away. |
| 1855 searchField.addEventListener('blur', function() { | 1898 searchField.addEventListener('blur', function() { |
| 1856 setTimeout(historyView.updateClearBrowsingDataButton_, 250); | 1899 setTimeout(historyView.updateClearBrowsingDataButton_, 250); |
| 1857 }); | 1900 }); |
| 1858 | 1901 |
| 1859 // Move the button to the bottom of the page. | 1902 // Move the button to the bottom of the page. |
| 1860 $('history-page').appendChild($('clear-browsing-data')); | 1903 $('history-page').appendChild($('clear-browsing-data')); |
| 1861 } else { | 1904 } else { |
| 1862 window.addEventListener('message', function(e) { | 1905 window.addEventListener('message', function(e) { |
| 1906 e = /** @type {!MessageEvent.<!{method: string}>} */(e); |
| 1863 if (e.data.method == 'frameSelected') | 1907 if (e.data.method == 'frameSelected') |
| 1864 searchField.focus(); | 1908 searchField.focus(); |
| 1865 }); | 1909 }); |
| 1866 searchField.focus(); | 1910 searchField.focus(); |
| 1867 } | 1911 } |
| 1868 | 1912 |
| 1869 <if expr="is_ios"> | 1913 <if expr="is_ios"> |
| 1870 function checkKeyboardVisibility() { | 1914 function checkKeyboardVisibility() { |
| 1871 // Figure out the real height based on the orientation, becauase | 1915 // Figure out the real height based on the orientation, becauase |
| 1872 // screen.width and screen.height don't update after rotation. | 1916 // screen.width and screen.height don't update after rotation. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1926 */ | 1970 */ |
| 1927 function hideConfirmationOverlay() { | 1971 function hideConfirmationOverlay() { |
| 1928 $('alertOverlay').classList.remove('showing'); | 1972 $('alertOverlay').classList.remove('showing'); |
| 1929 $('overlay').hidden = true; | 1973 $('overlay').hidden = true; |
| 1930 uber.invokeMethodOnParent('stopInterceptingEvents'); | 1974 uber.invokeMethodOnParent('stopInterceptingEvents'); |
| 1931 } | 1975 } |
| 1932 | 1976 |
| 1933 /** | 1977 /** |
| 1934 * Shows the confirmation alert for history deletions and permits browser tests | 1978 * Shows the confirmation alert for history deletions and permits browser tests |
| 1935 * to override the dialog. | 1979 * to override the dialog. |
| 1936 * @param {function=} okCallback A function to be called when the user presses | 1980 * @param {function()=} okCallback A function to be called when the user presses |
| 1937 * the ok button. | 1981 * the ok button. |
| 1938 * @param {function=} cancelCallback A function to be called when the user | 1982 * @param {function()=} cancelCallback A function to be called when the user |
| 1939 * presses the cancel button. | 1983 * presses the cancel button. |
| 1940 */ | 1984 */ |
| 1941 function confirmDeletion(okCallback, cancelCallback) { | 1985 function confirmDeletion(okCallback, cancelCallback) { |
| 1942 alertOverlay.setValues( | 1986 alertOverlay.setValues( |
| 1943 loadTimeData.getString('removeSelected'), | 1987 loadTimeData.getString('removeSelected'), |
| 1944 loadTimeData.getString('deleteWarning'), | 1988 loadTimeData.getString('deleteWarning'), |
| 1945 loadTimeData.getString('cancel'), | 1989 loadTimeData.getString('cancel'), |
| 1946 loadTimeData.getString('deleteConfirm'), | 1990 loadTimeData.getString('deleteConfirm'), |
| 1947 cancelCallback, | 1991 cancelCallback, |
| 1948 okCallback); | 1992 okCallback); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 confirmDeletion(onConfirmRemove, onCancelRemove); | 2058 confirmDeletion(onConfirmRemove, onCancelRemove); |
| 2015 $('overlay').addEventListener('cancelOverlay', onCancelRemove); | 2059 $('overlay').addEventListener('cancelOverlay', onCancelRemove); |
| 2016 } | 2060 } |
| 2017 } | 2061 } |
| 2018 | 2062 |
| 2019 /** | 2063 /** |
| 2020 * Handler for the 'click' event on a checkbox. | 2064 * Handler for the 'click' event on a checkbox. |
| 2021 * @param {Event} e The click event. | 2065 * @param {Event} e The click event. |
| 2022 */ | 2066 */ |
| 2023 function checkboxClicked(e) { | 2067 function checkboxClicked(e) { |
| 2024 handleCheckboxStateChange(e.currentTarget, e.shiftKey); | 2068 handleCheckboxStateChange(/** @type {!HTMLInputElement} */(e.currentTarget), |
| 2069 e.shiftKey); |
| 2025 } | 2070 } |
| 2026 | 2071 |
| 2027 /** | 2072 /** |
| 2028 * Post-process of checkbox state change. This handles range selection and | 2073 * Post-process of checkbox state change. This handles range selection and |
| 2029 * updates internal state. | 2074 * updates internal state. |
| 2030 * @param {!HTMLInputElement} checkbox Clicked checkbox. | 2075 * @param {!HTMLInputElement} checkbox Clicked checkbox. |
| 2031 * @param {boolean} shiftKey true if shift key is pressed. | 2076 * @param {boolean} shiftKey true if shift key is pressed. |
| 2032 */ | 2077 */ |
| 2033 function handleCheckboxStateChange(checkbox, shiftKey) { | 2078 function handleCheckboxStateChange(checkbox, shiftKey) { |
| 2034 updateParentCheckbox(checkbox); | 2079 updateParentCheckbox(checkbox); |
| 2035 var id = Number(checkbox.id.slice('checkbox-'.length)); | 2080 var id = Number(checkbox.id.slice('checkbox-'.length)); |
| 2036 // Handle multi-select if shift was pressed. | 2081 // Handle multi-select if shift was pressed. |
| 2037 if (shiftKey && (selectionAnchor != -1)) { | 2082 if (shiftKey && (selectionAnchor != -1)) { |
| 2038 var checked = checkbox.checked; | 2083 var checked = checkbox.checked; |
| 2039 // Set all checkboxes from the anchor up to the clicked checkbox to the | 2084 // Set all checkboxes from the anchor up to the clicked checkbox to the |
| 2040 // state of the clicked one. | 2085 // state of the clicked one. |
| 2041 var begin = Math.min(id, selectionAnchor); | 2086 var begin = Math.min(id, selectionAnchor); |
| 2042 var end = Math.max(id, selectionAnchor); | 2087 var end = Math.max(id, selectionAnchor); |
| 2043 for (var i = begin; i <= end; i++) { | 2088 for (var i = begin; i <= end; i++) { |
| 2044 var checkbox = document.querySelector('#checkbox-' + i); | 2089 var ithCheckbox = document.querySelector('#checkbox-' + i); |
| 2045 if (checkbox) { | 2090 if (ithCheckbox) { |
| 2046 checkbox.checked = checked; | 2091 ithCheckbox.checked = checked; |
| 2047 updateParentCheckbox(checkbox); | 2092 updateParentCheckbox(ithCheckbox); |
| 2048 } | 2093 } |
| 2049 } | 2094 } |
| 2050 } | 2095 } |
| 2051 selectionAnchor = id; | 2096 selectionAnchor = id; |
| 2052 | 2097 |
| 2053 historyView.updateSelectionEditButtons(); | 2098 historyView.updateSelectionEditButtons(); |
| 2054 } | 2099 } |
| 2055 | 2100 |
| 2056 /** | 2101 /** |
| 2057 * Handler for the 'click' event on a domain checkbox. Checkes or unchecks the | 2102 * Handler for the 'click' event on a domain checkbox. Checkes or unchecks the |
| 2058 * checkboxes of the visits to this domain in the respective group. | 2103 * checkboxes of the visits to this domain in the respective group. |
| 2059 * @param {Event} e The click event. | 2104 * @param {Event} e The click event. |
| 2060 */ | 2105 */ |
| 2061 function domainCheckboxClicked(e) { | 2106 function domainCheckboxClicked(e) { |
| 2062 var siteEntry = findAncestorByClass(e.currentTarget, 'site-entry'); | 2107 var siteEntry = findAncestorByClass(/** @type {Element} */(e.currentTarget), |
| 2108 'site-entry'); |
| 2063 var checkboxes = | 2109 var checkboxes = |
| 2064 siteEntry.querySelectorAll('.site-results input[type=checkbox]'); | 2110 siteEntry.querySelectorAll('.site-results input[type=checkbox]'); |
| 2065 for (var i = 0; i < checkboxes.length; i++) | 2111 for (var i = 0; i < checkboxes.length; i++) |
| 2066 checkboxes[i].checked = e.currentTarget.checked; | 2112 checkboxes[i].checked = e.currentTarget.checked; |
| 2067 historyView.updateSelectionEditButtons(); | 2113 historyView.updateSelectionEditButtons(); |
| 2068 // Stop propagation as clicking the checkbox would otherwise trigger the | 2114 // Stop propagation as clicking the checkbox would otherwise trigger the |
| 2069 // group to collapse/expand. | 2115 // group to collapse/expand. |
| 2070 e.stopPropagation(); | 2116 e.stopPropagation(); |
| 2071 } | 2117 } |
| 2072 | 2118 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2089 } | 2135 } |
| 2090 | 2136 |
| 2091 function entryBoxMousedown(event) { | 2137 function entryBoxMousedown(event) { |
| 2092 // Prevent text selection when shift-clicking to select multiple entries. | 2138 // Prevent text selection when shift-clicking to select multiple entries. |
| 2093 if (event.shiftKey) | 2139 if (event.shiftKey) |
| 2094 event.preventDefault(); | 2140 event.preventDefault(); |
| 2095 } | 2141 } |
| 2096 | 2142 |
| 2097 /** | 2143 /** |
| 2098 * Handle click event for entryBox labels. | 2144 * Handle click event for entryBox labels. |
| 2099 * @param {!MouseEvent} event A click event. | 2145 * @param {!Event} event A click event. |
| 2100 */ | 2146 */ |
| 2101 function entryBoxClick(event) { | 2147 function entryBoxClick(event) { |
| 2148 event = /** @type {!MouseEvent} */(event); |
| 2102 // Do nothing if a bookmark star is clicked. | 2149 // Do nothing if a bookmark star is clicked. |
| 2103 if (event.defaultPrevented) | 2150 if (event.defaultPrevented) |
| 2104 return; | 2151 return; |
| 2105 var element = event.target; | 2152 var element = event.target; |
| 2106 // Do nothing if the event happened in an interactive element. | 2153 // Do nothing if the event happened in an interactive element. |
| 2107 for (; element != event.currentTarget; element = element.parentNode) { | 2154 for (; element != event.currentTarget; element = element.parentNode) { |
| 2108 switch (element.tagName) { | 2155 switch (element.tagName) { |
| 2109 case 'A': | 2156 case 'A': |
| 2110 case 'BUTTON': | 2157 case 'BUTTON': |
| 2111 case 'INPUT': | 2158 case 'INPUT': |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2166 updateHostStatus(filterStatusDiv, filteringBehavior); | 2213 updateHostStatus(filterStatusDiv, filteringBehavior); |
| 2167 return filterStatusDiv; | 2214 return filterStatusDiv; |
| 2168 } | 2215 } |
| 2169 | 2216 |
| 2170 | 2217 |
| 2171 /////////////////////////////////////////////////////////////////////////////// | 2218 /////////////////////////////////////////////////////////////////////////////// |
| 2172 // Chrome callbacks: | 2219 // Chrome callbacks: |
| 2173 | 2220 |
| 2174 /** | 2221 /** |
| 2175 * Our history system calls this function with results from searches. | 2222 * Our history system calls this function with results from searches. |
| 2176 * @param {Object} info An object containing information about the query. | 2223 * @param {HistoryQuery} info An object containing information about the query. |
| 2177 * @param {Array} results A list of results. | 2224 * @param {Array.<HistoryEntry>} results A list of results. |
| 2178 */ | 2225 */ |
| 2179 function historyResult(info, results) { | 2226 function historyResult(info, results) { |
| 2180 historyModel.addResults(info, results); | 2227 historyModel.addResults(info, results); |
| 2181 } | 2228 } |
| 2182 | 2229 |
| 2183 /** | 2230 /** |
| 2184 * Called by the history backend when history removal is successful. | 2231 * Called by the history backend when history removal is successful. |
| 2185 */ | 2232 */ |
| 2186 function deleteComplete() { | 2233 function deleteComplete() { |
| 2187 historyModel.deleteComplete(); | 2234 historyModel.deleteComplete(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2205 historyView.reload(); | 2252 historyView.reload(); |
| 2206 } | 2253 } |
| 2207 | 2254 |
| 2208 // Add handlers to HTML elements. | 2255 // Add handlers to HTML elements. |
| 2209 document.addEventListener('DOMContentLoaded', load); | 2256 document.addEventListener('DOMContentLoaded', load); |
| 2210 | 2257 |
| 2211 // This event lets us enable and disable menu items before the menu is shown. | 2258 // This event lets us enable and disable menu items before the menu is shown. |
| 2212 document.addEventListener('canExecute', function(e) { | 2259 document.addEventListener('canExecute', function(e) { |
| 2213 e.canExecute = true; | 2260 e.canExecute = true; |
| 2214 }); | 2261 }); |
| OLD | NEW |