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"> |
| 6 |
5 /////////////////////////////////////////////////////////////////////////////// | 7 /////////////////////////////////////////////////////////////////////////////// |
6 // Globals: | 8 // Globals: |
7 var RESULTS_PER_PAGE = 150; | 9 var RESULTS_PER_PAGE = 150; |
8 var MAX_SEARCH_DEPTH_MONTHS = 18; | 10 var MAX_SEARCH_DEPTH_MONTHS = 18; |
9 | 11 |
10 // 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, |
11 // measured in milliseconds. | 13 // measured in milliseconds. |
12 var BROWSING_GAP_TIME = 15 * 60 * 1000; | 14 var BROWSING_GAP_TIME = 15 * 60 * 1000; |
13 | 15 |
14 function $(o) {return document.getElementById(o);} | 16 function $(o) {return document.getElementById(o);} |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 | 861 |
860 return newHash.join('&'); | 862 return newHash.join('&'); |
861 }; | 863 }; |
862 | 864 |
863 /////////////////////////////////////////////////////////////////////////////// | 865 /////////////////////////////////////////////////////////////////////////////// |
864 // Document Functions: | 866 // Document Functions: |
865 /** | 867 /** |
866 * Window onload handler, sets up the page. | 868 * Window onload handler, sets up the page. |
867 */ | 869 */ |
868 function load() { | 870 function load() { |
| 871 uber.onContentFrameLoaded(); |
| 872 |
869 var searchField = $('search-field'); | 873 var searchField = $('search-field'); |
870 searchField.focus(); | 874 searchField.focus(); |
871 | 875 |
872 localStrings = new LocalStrings(); | 876 localStrings = new LocalStrings(); |
873 historyModel = new HistoryModel(); | 877 historyModel = new HistoryModel(); |
874 historyView = new HistoryView(historyModel); | 878 historyView = new HistoryView(historyModel); |
875 pageState = new PageState(historyModel, historyView); | 879 pageState = new PageState(historyModel, historyView); |
876 | 880 |
877 // Create default view. | 881 // Create default view. |
878 var hashData = pageState.getHashData(); | 882 var hashData = pageState.getHashData(); |
879 historyView.setSearch(hashData.q, hashData.p); | 883 historyView.setSearch(hashData.q, hashData.p); |
880 | 884 |
881 $('search-form').onsubmit = function() { | 885 $('search-form').onsubmit = function() { |
882 setSearch(searchField.value); | 886 setSearch(searchField.value); |
883 return false; | 887 return false; |
884 }; | 888 }; |
885 | 889 |
886 $('remove-page').addEventListener('activate', function(e) { | 890 $('remove-page').addEventListener('activate', function(e) { |
887 activePage.removeFromHistory_(); | 891 activePage.removeFromHistory_(); |
888 activePage = null; | 892 activePage = null; |
889 }); | 893 }); |
890 $('more-from-site').addEventListener('activate', function(e) { | 894 $('more-from-site').addEventListener('activate', function(e) { |
891 activePage.showMoreFromSite_(); | 895 activePage.showMoreFromSite_(); |
892 activePage = null; | 896 activePage = null; |
893 }); | 897 }); |
| 898 |
| 899 var title = localStrings.getString('title'); |
| 900 uber.invokeMethodOnParent('setTitle', {title: title}); |
| 901 |
| 902 window.addEventListener('message', function(e) { |
| 903 if (e.data.method == 'frameSelected') |
| 904 searchField.focus(); |
| 905 }); |
894 } | 906 } |
895 | 907 |
896 /** | 908 /** |
897 * TODO(glen): Get rid of this function. | 909 * TODO(glen): Get rid of this function. |
898 * Set the history view to a specified page. | 910 * Set the history view to a specified page. |
899 * @param {String} term The string to search for | 911 * @param {String} term The string to search for |
900 */ | 912 */ |
901 function setSearch(term) { | 913 function setSearch(term) { |
902 if (historyView) { | 914 if (historyView) { |
903 historyView.setSearch(term); | 915 historyView.setSearch(term); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 historyView.reload(); | 1131 historyView.reload(); |
1120 } | 1132 } |
1121 | 1133 |
1122 // Add handlers to HTML elements. | 1134 // Add handlers to HTML elements. |
1123 document.addEventListener('DOMContentLoaded', load); | 1135 document.addEventListener('DOMContentLoaded', load); |
1124 | 1136 |
1125 // This event lets us enable and disable menu items before the menu is shown. | 1137 // This event lets us enable and disable menu items before the menu is shown. |
1126 document.addEventListener('canExecute', function(e) { | 1138 document.addEventListener('canExecute', function(e) { |
1127 e.canExecute = true; | 1139 e.canExecute = true; |
1128 }); | 1140 }); |
OLD | NEW |