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; |
11 | 11 |
12 // Amount of time between pageviews that we consider a 'break' in browsing, | 12 // Amount of time between pageviews that we consider a 'break' in browsing, |
13 // measured in milliseconds. | 13 // measured in milliseconds. |
14 /** @const */ var BROWSING_GAP_TIME = 15 * 60 * 1000; | 14 /** @const */ var BROWSING_GAP_TIME = 15 * 60 * 1000; |
15 | 15 |
16 // The largest bucket value for UMA histogram, based on entry ID. All entries | 16 // The largest bucket value for UMA histogram, based on entry ID. All entries |
(...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1980 historyView.positionNotificationBar.bind(historyView)); | 1980 historyView.positionNotificationBar.bind(historyView)); |
1981 | 1981 |
1982 if (isMobileVersion()) { | 1982 if (isMobileVersion()) { |
1983 // Move the search box out of the header. | 1983 // Move the search box out of the header. |
1984 var resultsDisplay = $('results-display'); | 1984 var resultsDisplay = $('results-display'); |
1985 resultsDisplay.parentNode.insertBefore($('search-field'), resultsDisplay); | 1985 resultsDisplay.parentNode.insertBefore($('search-field'), resultsDisplay); |
1986 | 1986 |
1987 window.addEventListener( | 1987 window.addEventListener( |
1988 'resize', historyView.updateClearBrowsingDataButton_); | 1988 'resize', historyView.updateClearBrowsingDataButton_); |
1989 | 1989 |
1990 <if expr="is_ios"> | 1990 // <if expr="is_ios"> |
1991 // Trigger window resize event when search field is focused to force update | 1991 // Trigger window resize event when search field is focused to force update |
1992 // of the clear browsing button, which should disappear when search field | 1992 // of the clear browsing button, which should disappear when search field |
1993 // is active. The window is not resized when the virtual keyboard is shown | 1993 // is active. The window is not resized when the virtual keyboard is shown |
1994 // on iOS. | 1994 // on iOS. |
1995 searchField.addEventListener('focus', function() { | 1995 searchField.addEventListener('focus', function() { |
1996 cr.dispatchSimpleEvent(window, 'resize'); | 1996 cr.dispatchSimpleEvent(window, 'resize'); |
1997 }); | 1997 }); |
1998 </if> /* is_ios */ | 1998 // </if> /* is_ios */ |
1999 | 1999 |
2000 // When the search field loses focus, add a delay before updating the | 2000 // When the search field loses focus, add a delay before updating the |
2001 // visibility, otherwise the button will flash on the screen before the | 2001 // visibility, otherwise the button will flash on the screen before the |
2002 // keyboard animates away. | 2002 // keyboard animates away. |
2003 searchField.addEventListener('blur', function() { | 2003 searchField.addEventListener('blur', function() { |
2004 setTimeout(historyView.updateClearBrowsingDataButton_, 250); | 2004 setTimeout(historyView.updateClearBrowsingDataButton_, 250); |
2005 }); | 2005 }); |
2006 | 2006 |
2007 // Move the button to the bottom of the page. | 2007 // Move the button to the bottom of the page. |
2008 $('history-page').appendChild($('clear-browsing-data')); | 2008 $('history-page').appendChild($('clear-browsing-data')); |
2009 } else { | 2009 } else { |
2010 window.addEventListener('message', function(e) { | 2010 window.addEventListener('message', function(e) { |
2011 e = /** @type {!MessageEvent<!{method: string}>} */(e); | 2011 e = /** @type {!MessageEvent<!{method: string}>} */(e); |
2012 if (e.data.method == 'frameSelected') | 2012 if (e.data.method == 'frameSelected') |
2013 searchField.focus(); | 2013 searchField.focus(); |
2014 }); | 2014 }); |
2015 searchField.focus(); | 2015 searchField.focus(); |
2016 } | 2016 } |
2017 | 2017 |
2018 <if expr="is_ios"> | 2018 // <if expr="is_ios"> |
2019 function checkKeyboardVisibility() { | 2019 function checkKeyboardVisibility() { |
2020 // Figure out the real height based on the orientation, becauase | 2020 // Figure out the real height based on the orientation, becauase |
2021 // screen.width and screen.height don't update after rotation. | 2021 // screen.width and screen.height don't update after rotation. |
2022 var screenHeight = window.orientation % 180 ? screen.width : screen.height; | 2022 var screenHeight = window.orientation % 180 ? screen.width : screen.height; |
2023 | 2023 |
2024 // Assume that the keyboard is visible if more than 30% of the screen is | 2024 // Assume that the keyboard is visible if more than 30% of the screen is |
2025 // taken up by window chrome. | 2025 // taken up by window chrome. |
2026 var isKeyboardVisible = (window.innerHeight / screenHeight) < 0.7; | 2026 var isKeyboardVisible = (window.innerHeight / screenHeight) < 0.7; |
2027 | 2027 |
2028 document.body.classList.toggle('ios-keyboard-visible', isKeyboardVisible); | 2028 document.body.classList.toggle('ios-keyboard-visible', isKeyboardVisible); |
2029 } | 2029 } |
2030 window.addEventListener('orientationchange', checkKeyboardVisibility); | 2030 window.addEventListener('orientationchange', checkKeyboardVisibility); |
2031 window.addEventListener('resize', checkKeyboardVisibility); | 2031 window.addEventListener('resize', checkKeyboardVisibility); |
2032 </if> /* is_ios */ | 2032 // </if> /* is_ios */ |
2033 } | 2033 } |
2034 | 2034 |
2035 /** | 2035 /** |
2036 * Handle all commands in the history page. | 2036 * Handle all commands in the history page. |
2037 * @param {!Event} e is a command event. | 2037 * @param {!Event} e is a command event. |
2038 */ | 2038 */ |
2039 function handleCommand(e) { | 2039 function handleCommand(e) { |
2040 switch (e.command.id) { | 2040 switch (e.command.id) { |
2041 case 'remove-visit-command': | 2041 case 'remove-visit-command': |
2042 // Removing visited items needs to be done with a command in order to have | 2042 // Removing visited items needs to be done with a command in order to have |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2413 historyView.reload(); | 2413 historyView.reload(); |
2414 } | 2414 } |
2415 | 2415 |
2416 // Add handlers to HTML elements. | 2416 // Add handlers to HTML elements. |
2417 document.addEventListener('DOMContentLoaded', load); | 2417 document.addEventListener('DOMContentLoaded', load); |
2418 | 2418 |
2419 // This event lets us enable and disable menu items before the menu is shown. | 2419 // This event lets us enable and disable menu items before the menu is shown. |
2420 document.addEventListener('canExecute', function(e) { | 2420 document.addEventListener('canExecute', function(e) { |
2421 e.canExecute = true; | 2421 e.canExecute = true; |
2422 }); | 2422 }); |
OLD | NEW |