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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
851 * @private | 851 * @private |
852 */ | 852 */ |
853 HistoryModel.prototype.canFillPage_ = function(page) { | 853 HistoryModel.prototype.canFillPage_ = function(page) { |
854 return ((page + 1) * RESULTS_PER_PAGE <= this.getSize()); | 854 return ((page + 1) * RESULTS_PER_PAGE <= this.getSize()); |
855 }; | 855 }; |
856 | 856 |
857 /** | 857 /** |
858 * Enables or disables grouping by domain. | 858 * Enables or disables grouping by domain. |
859 * @param {boolean} groupByDomain New groupByDomain_ value. | 859 * @param {boolean} groupByDomain New groupByDomain_ value. |
860 */ | 860 */ |
861 HistoryModel.prototype.setGroupByDomain = function(groupByDomain) { | 861 HistoryModel.prototype.setGroupByDomain = function(groupByDomain) { |
Evan Stade
2014/08/04 21:50:05
it seems like this isn't used...
Sergiu
2014/09/09 08:59:24
Yeah, this should be removed I guess.
Dan Beam
2014/09/10 23:20:46
Done.
| |
862 this.groupByDomain_ = groupByDomain; | 862 this.groupByDomain_ = groupByDomain; |
863 this.offset_ = 0; | 863 this.offset_ = 0; |
864 }; | 864 }; |
865 | 865 |
866 /** | 866 /** |
867 * Gets whether we are grouped by domain. | 867 * Gets whether we are grouped by domain. |
868 * @return {boolean} Whether the results are grouped by domain. | 868 * @return {boolean} Whether the results are grouped by domain. |
869 */ | 869 */ |
870 HistoryModel.prototype.getGroupByDomain = function() { | 870 HistoryModel.prototype.getGroupByDomain = function() { |
871 return this.groupByDomain_; | 871 return this.groupByDomain_; |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1791 */ | 1791 */ |
1792 PageState.instance = null; | 1792 PageState.instance = null; |
1793 | 1793 |
1794 /** | 1794 /** |
1795 * @return {Object} An object containing parameters from our window hash. | 1795 * @return {Object} An object containing parameters from our window hash. |
1796 */ | 1796 */ |
1797 PageState.prototype.getHashData = function() { | 1797 PageState.prototype.getHashData = function() { |
1798 var result = { | 1798 var result = { |
1799 q: '', | 1799 q: '', |
1800 page: 0, | 1800 page: 0, |
1801 grouped: false, | |
1802 range: 0, | 1801 range: 0, |
1803 offset: 0 | 1802 offset: 0 |
1804 }; | 1803 }; |
1805 | 1804 |
1806 if (!window.location.hash) | 1805 if (!window.location.hash) |
1807 return result; | 1806 return result; |
1808 | 1807 |
1809 var hashSplit = window.location.hash.substr(1).split('&'); | 1808 var hashSplit = window.location.hash.substr(1).split('&'); |
1810 for (var i = 0; i < hashSplit.length; i++) { | 1809 for (var i = 0; i < hashSplit.length; i++) { |
1811 var pair = hashSplit[i].split('='); | 1810 var pair = hashSplit[i].split('='); |
1812 if (pair.length > 1) { | 1811 if (pair.length > 1) |
1813 result[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); | 1812 result[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); |
1814 } | |
1815 } | 1813 } |
1816 | 1814 |
1817 return result; | 1815 return result; |
1818 }; | 1816 }; |
1819 | 1817 |
1820 /** | 1818 /** |
1821 * Set the hash to a specified state, this will create an entry in the | 1819 * Set the hash to a specified state, this will create an entry in the |
1822 * session history so the back button cycles through hash states, which | 1820 * session history so the back button cycles through hash states, which |
1823 * are then picked up by our listener. | 1821 * are then picked up by our listener. |
1824 * @param {string} term The current search string. | 1822 * @param {string} term The current search string. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1872 uber.onContentFrameLoaded(); | 1870 uber.onContentFrameLoaded(); |
1873 | 1871 |
1874 var searchField = $('search-field'); | 1872 var searchField = $('search-field'); |
1875 | 1873 |
1876 historyModel = new HistoryModel(); | 1874 historyModel = new HistoryModel(); |
1877 historyView = new HistoryView(historyModel); | 1875 historyView = new HistoryView(historyModel); |
1878 pageState = new PageState(historyModel, historyView); | 1876 pageState = new PageState(historyModel, historyView); |
1879 | 1877 |
1880 // Create default view. | 1878 // Create default view. |
1881 var hashData = pageState.getHashData(); | 1879 var hashData = pageState.getHashData(); |
1882 var grouped = (hashData.grouped == 'true') || historyModel.getGroupByDomain(); | |
Evan Stade
2014/08/04 21:50:05
I guess that it would make more sense to either us
Sergiu
2014/09/09 08:59:24
Removing this should be fine. We actually infer th
Dan Beam
2014/09/10 23:20:46
Removed the local var, left this.groupByDomain_ as
| |
1883 var page = parseInt(hashData.page, 10) || historyView.getPage(); | 1880 var page = parseInt(hashData.page, 10) || historyView.getPage(); |
1884 var range = parseInt(hashData.range, 10) || historyView.getRangeInDays(); | 1881 var range = parseInt(hashData.range, 10) || historyView.getRangeInDays(); |
1885 var offset = parseInt(hashData.offset, 10) || historyView.getOffset(); | 1882 var offset = parseInt(hashData.offset, 10) || historyView.getOffset(); |
1886 historyView.setPageState(hashData.q, page, range, offset); | 1883 historyView.setPageState(hashData.q, page, range, offset); |
1887 | 1884 |
1888 if ($('overlay')) { | 1885 if ($('overlay')) { |
1889 cr.ui.overlay.setupOverlay($('overlay')); | 1886 cr.ui.overlay.setupOverlay($('overlay')); |
1890 cr.ui.overlay.globalInitialization(); | 1887 cr.ui.overlay.globalInitialization(); |
1891 } | 1888 } |
1892 HistoryFocusManager.getInstance().initialize(); | 1889 HistoryFocusManager.getInstance().initialize(); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2330 historyView.reload(); | 2327 historyView.reload(); |
2331 } | 2328 } |
2332 | 2329 |
2333 // Add handlers to HTML elements. | 2330 // Add handlers to HTML elements. |
2334 document.addEventListener('DOMContentLoaded', load); | 2331 document.addEventListener('DOMContentLoaded', load); |
2335 | 2332 |
2336 // This event lets us enable and disable menu items before the menu is shown. | 2333 // This event lets us enable and disable menu items before the menu is shown. |
2337 document.addEventListener('canExecute', function(e) { | 2334 document.addEventListener('canExecute', function(e) { |
2338 e.canExecute = true; | 2335 e.canExecute = true; |
2339 }); | 2336 }); |
OLD | NEW |