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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 * @return {DOMObject} DOM representation for the title block. | 230 * @return {DOMObject} DOM representation for the title block. |
229 */ | 231 */ |
230 Page.prototype.getTitleDOM_ = function() { | 232 Page.prototype.getTitleDOM_ = function() { |
231 var node = createElementWithClassName('div', 'title'); | 233 var node = createElementWithClassName('div', 'title'); |
232 node.style.backgroundImage = | 234 node.style.backgroundImage = |
233 'url(chrome://favicon/' + encodeURIForCSS(this.url_) + ')'; | 235 'url(chrome://favicon/' + encodeURIForCSS(this.url_) + ')'; |
234 | 236 |
235 var link = document.createElement('a'); | 237 var link = document.createElement('a'); |
236 link.href = this.url_; | 238 link.href = this.url_; |
237 link.id = "id-" + this.id_; | 239 link.id = "id-" + this.id_; |
| 240 link.target = "_top"; |
238 | 241 |
239 // Add a tooltip, since it might be ellipsized. | 242 // Add a tooltip, since it might be ellipsized. |
240 // TODO(dubroy): Find a way to show the tooltip only when necessary. | 243 // TODO(dubroy): Find a way to show the tooltip only when necessary. |
241 link.title = this.title_; | 244 link.title = this.title_; |
242 | 245 |
243 this.addHighlightedText_(link, this.title_, this.model_.getSearchText()); | 246 this.addHighlightedText_(link, this.title_, this.model_.getSearchText()); |
244 node.appendChild(link); | 247 node.appendChild(link); |
245 | 248 |
246 if (this.starred_) | 249 if (this.starred_) |
247 node.appendChild(createElementWithClassName('div', 'starred')); | 250 node.appendChild(createElementWithClassName('div', 'starred')); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 | 862 |
860 return newHash.join('&'); | 863 return newHash.join('&'); |
861 }; | 864 }; |
862 | 865 |
863 /////////////////////////////////////////////////////////////////////////////// | 866 /////////////////////////////////////////////////////////////////////////////// |
864 // Document Functions: | 867 // Document Functions: |
865 /** | 868 /** |
866 * Window onload handler, sets up the page. | 869 * Window onload handler, sets up the page. |
867 */ | 870 */ |
868 function load() { | 871 function load() { |
| 872 uber.onContentFrameLoaded(); |
| 873 |
869 var searchField = $('search-field'); | 874 var searchField = $('search-field'); |
870 searchField.focus(); | 875 searchField.focus(); |
871 | 876 |
872 localStrings = new LocalStrings(); | 877 localStrings = new LocalStrings(); |
873 historyModel = new HistoryModel(); | 878 historyModel = new HistoryModel(); |
874 historyView = new HistoryView(historyModel); | 879 historyView = new HistoryView(historyModel); |
875 pageState = new PageState(historyModel, historyView); | 880 pageState = new PageState(historyModel, historyView); |
876 | 881 |
877 // Create default view. | 882 // Create default view. |
878 var hashData = pageState.getHashData(); | 883 var hashData = pageState.getHashData(); |
879 historyView.setSearch(hashData.q, hashData.p); | 884 historyView.setSearch(hashData.q, hashData.p); |
880 | 885 |
881 $('search-form').onsubmit = function() { | 886 $('search-form').onsubmit = function() { |
882 setSearch(searchField.value); | 887 setSearch(searchField.value); |
883 return false; | 888 return false; |
884 }; | 889 }; |
885 | 890 |
886 $('remove-page').addEventListener('activate', function(e) { | 891 $('remove-page').addEventListener('activate', function(e) { |
887 activePage.removeFromHistory_(); | 892 activePage.removeFromHistory_(); |
888 activePage = null; | 893 activePage = null; |
889 }); | 894 }); |
890 $('more-from-site').addEventListener('activate', function(e) { | 895 $('more-from-site').addEventListener('activate', function(e) { |
891 activePage.showMoreFromSite_(); | 896 activePage.showMoreFromSite_(); |
892 activePage = null; | 897 activePage = null; |
893 }); | 898 }); |
| 899 |
| 900 var title = localStrings.getString('title'); |
| 901 uber.invokeMethodOnParent('setTitle', {title: title}); |
| 902 |
| 903 window.addEventListener('message', function(e) { |
| 904 if (e.data.method == 'frameSelected') |
| 905 searchField.focus(); |
| 906 }); |
894 } | 907 } |
895 | 908 |
896 /** | 909 /** |
897 * TODO(glen): Get rid of this function. | 910 * TODO(glen): Get rid of this function. |
898 * Set the history view to a specified page. | 911 * Set the history view to a specified page. |
899 * @param {String} term The string to search for | 912 * @param {String} term The string to search for |
900 */ | 913 */ |
901 function setSearch(term) { | 914 function setSearch(term) { |
902 if (historyView) { | 915 if (historyView) { |
903 historyView.setSearch(term); | 916 historyView.setSearch(term); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 historyView.reload(); | 1132 historyView.reload(); |
1120 } | 1133 } |
1121 | 1134 |
1122 // Add handlers to HTML elements. | 1135 // Add handlers to HTML elements. |
1123 document.addEventListener('DOMContentLoaded', load); | 1136 document.addEventListener('DOMContentLoaded', load); |
1124 | 1137 |
1125 // This event lets us enable and disable menu items before the menu is shown. | 1138 // This event lets us enable and disable menu items before the menu is shown. |
1126 document.addEventListener('canExecute', function(e) { | 1139 document.addEventListener('canExecute', function(e) { |
1127 e.canExecute = true; | 1140 e.canExecute = true; |
1128 }); | 1141 }); |
OLD | NEW |