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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 this.displayResults_(doneLoading); | 931 this.displayResults_(doneLoading); |
932 | 932 |
933 // Allow custom styling based on whether there are any results on the page. | 933 // Allow custom styling based on whether there are any results on the page. |
934 // To make this easier, add a class to the body if there are any results. | 934 // To make this easier, add a class to the body if there are any results. |
935 if (this.model_.visits_.length) | 935 if (this.model_.visits_.length) |
936 document.body.classList.add('has-results'); | 936 document.body.classList.add('has-results'); |
937 else | 937 else |
938 document.body.classList.remove('has-results'); | 938 document.body.classList.remove('has-results'); |
939 | 939 |
940 this.updateNavBar_(); | 940 this.updateNavBar_(); |
| 941 |
| 942 if (isMobileVersion()) { |
| 943 // Hide the search field if it is empty and there are no results. |
| 944 var hasResults = this.model_.visits_.length > 0; |
| 945 var isSearch = this.model_.getSearchText().length > 0; |
| 946 $('search-field').hidden = !(hasResults || isSearch); |
| 947 } |
941 }; | 948 }; |
942 | 949 |
943 /** | 950 /** |
944 * Enables or disables the buttons that control editing entries depending on | 951 * Enables or disables the buttons that control editing entries depending on |
945 * whether there are any checked boxes. | 952 * whether there are any checked boxes. |
946 */ | 953 */ |
947 HistoryView.prototype.updateSelectionEditButtons = function() { | 954 HistoryView.prototype.updateSelectionEditButtons = function() { |
948 if (loadTimeData.getBoolean('allowDeletingHistory')) { | 955 if (loadTimeData.getBoolean('allowDeletingHistory')) { |
949 var anyChecked = document.querySelector('.entry input:checked') != null; | 956 var anyChecked = document.querySelector('.entry input:checked') != null; |
950 $('remove-selected').disabled = !anyChecked; | 957 $('remove-selected').disabled = !anyChecked; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 } else { | 1298 } else { |
1292 var resultsFragment = document.createDocumentFragment(); | 1299 var resultsFragment = document.createDocumentFragment(); |
1293 | 1300 |
1294 this.addTimeframeInterval_(resultsFragment); | 1301 this.addTimeframeInterval_(resultsFragment); |
1295 | 1302 |
1296 if (results.length == 0 && doneLoading) { | 1303 if (results.length == 0 && doneLoading) { |
1297 var noResults = resultsFragment.appendChild( | 1304 var noResults = resultsFragment.appendChild( |
1298 createElementWithClassName('div', 'no-results-message')); | 1305 createElementWithClassName('div', 'no-results-message')); |
1299 noResults.textContent = loadTimeData.getString('noResults'); | 1306 noResults.textContent = loadTimeData.getString('noResults'); |
1300 this.resultDiv_.appendChild(resultsFragment); | 1307 this.resultDiv_.appendChild(resultsFragment); |
1301 this.updateNavBar_(); | |
1302 return; | 1308 return; |
1303 } | 1309 } |
1304 | 1310 |
1305 if (this.getRangeInDays() == HistoryModel.Range.MONTH && | 1311 if (this.getRangeInDays() == HistoryModel.Range.MONTH && |
1306 groupByDomain) { | 1312 groupByDomain) { |
1307 // Group everything together in the month view. | 1313 // Group everything together in the month view. |
1308 this.addMonthResults_(results, resultsFragment); | 1314 this.addMonthResults_(results, resultsFragment); |
1309 } else { | 1315 } else { |
1310 var dayStart = 0; | 1316 var dayStart = 0; |
1311 var dayEnd = 0; | 1317 var dayEnd = 0; |
1312 // Go through all of the visits and process them in chunks of one day. | 1318 // Go through all of the visits and process them in chunks of one day. |
1313 while (dayEnd < results.length) { | 1319 while (dayEnd < results.length) { |
1314 // Skip over the ones that are already rendered. | 1320 // Skip over the ones that are already rendered. |
1315 while (dayStart < results.length && results[dayStart].isRendered) | 1321 while (dayStart < results.length && results[dayStart].isRendered) |
1316 ++dayStart; | 1322 ++dayStart; |
1317 var dayEnd = dayStart + 1; | 1323 var dayEnd = dayStart + 1; |
1318 while (dayEnd < results.length && results[dayEnd].continued) | 1324 while (dayEnd < results.length && results[dayEnd].continued) |
1319 ++dayEnd; | 1325 ++dayEnd; |
1320 | 1326 |
1321 this.addDayResults_( | 1327 this.addDayResults_( |
1322 results.slice(dayStart, dayEnd), resultsFragment, groupByDomain); | 1328 results.slice(dayStart, dayEnd), resultsFragment, groupByDomain); |
1323 } | 1329 } |
1324 } | 1330 } |
1325 | 1331 |
1326 // Add all the days and their visits to the page. | 1332 // Add all the days and their visits to the page. |
1327 this.resultDiv_.appendChild(resultsFragment); | 1333 this.resultDiv_.appendChild(resultsFragment); |
1328 } | 1334 } |
1329 this.updateNavBar_(); | |
1330 }; | 1335 }; |
1331 | 1336 |
1332 /** | 1337 /** |
1333 * Update the visibility of the page navigation buttons. | 1338 * Update the visibility of the page navigation buttons. |
1334 * @private | 1339 * @private |
1335 */ | 1340 */ |
1336 HistoryView.prototype.updateNavBar_ = function() { | 1341 HistoryView.prototype.updateNavBar_ = function() { |
1337 this.updateRangeButtons_(); | 1342 this.updateRangeButtons_(); |
| 1343 |
| 1344 // Managed users have the control bar on top, don't show it on the bottom |
| 1345 // as well. |
1338 if (!loadTimeData.getBoolean('isManagedProfile')) { | 1346 if (!loadTimeData.getBoolean('isManagedProfile')) { |
1339 // Managed users have the control bar on top, don't show it on the bottom | |
1340 // as well. | |
1341 $('newest-button').hidden = this.pageIndex_ == 0; | 1347 $('newest-button').hidden = this.pageIndex_ == 0; |
1342 $('newer-button').hidden = this.pageIndex_ == 0; | 1348 $('newer-button').hidden = this.pageIndex_ == 0; |
1343 $('older-button').hidden = | 1349 $('older-button').hidden = |
1344 this.model_.rangeInDays_ != HistoryModel.Range.ALL_TIME || | 1350 this.model_.rangeInDays_ != HistoryModel.Range.ALL_TIME || |
1345 !this.model_.hasMoreResults(); | 1351 !this.model_.hasMoreResults(); |
1346 } | 1352 } |
1347 }; | 1353 }; |
1348 | 1354 |
1349 /** | 1355 /** |
1350 * Updates the visibility of the 'Clear browsing data' button. | 1356 * Updates the visibility of the 'Clear browsing data' button. |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 historyView.reload(); | 1950 historyView.reload(); |
1945 } | 1951 } |
1946 | 1952 |
1947 // Add handlers to HTML elements. | 1953 // Add handlers to HTML elements. |
1948 document.addEventListener('DOMContentLoaded', load); | 1954 document.addEventListener('DOMContentLoaded', load); |
1949 | 1955 |
1950 // This event lets us enable and disable menu items before the menu is shown. | 1956 // This event lets us enable and disable menu items before the menu is shown. |
1951 document.addEventListener('canExecute', function(e) { | 1957 document.addEventListener('canExecute', function(e) { |
1952 e.canExecute = true; | 1958 e.canExecute = true; |
1953 }); | 1959 }); |
OLD | NEW |