| 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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 * Check to see if we have data to fill the given page. | 837 * Check to see if we have data to fill the given page. |
| 838 * @param {number} page The page number. | 838 * @param {number} page The page number. |
| 839 * @return {boolean} Whether we have data to fill the page. | 839 * @return {boolean} Whether we have data to fill the page. |
| 840 * @private | 840 * @private |
| 841 */ | 841 */ |
| 842 HistoryModel.prototype.canFillPage_ = function(page) { | 842 HistoryModel.prototype.canFillPage_ = function(page) { |
| 843 return ((page + 1) * RESULTS_PER_PAGE <= this.getSize()); | 843 return ((page + 1) * RESULTS_PER_PAGE <= this.getSize()); |
| 844 }; | 844 }; |
| 845 | 845 |
| 846 /** | 846 /** |
| 847 * Enables or disables grouping by domain. | |
| 848 * @param {boolean} groupByDomain New groupByDomain_ value. | |
| 849 */ | |
| 850 HistoryModel.prototype.setGroupByDomain = function(groupByDomain) { | |
| 851 this.groupByDomain_ = groupByDomain; | |
| 852 this.offset_ = 0; | |
| 853 }; | |
| 854 | |
| 855 /** | |
| 856 * Gets whether we are grouped by domain. | 847 * Gets whether we are grouped by domain. |
| 857 * @return {boolean} Whether the results are grouped by domain. | 848 * @return {boolean} Whether the results are grouped by domain. |
| 858 */ | 849 */ |
| 859 HistoryModel.prototype.getGroupByDomain = function() { | 850 HistoryModel.prototype.getGroupByDomain = function() { |
| 860 return this.groupByDomain_; | 851 return this.groupByDomain_; |
| 861 }; | 852 }; |
| 862 | 853 |
| 863 /////////////////////////////////////////////////////////////////////////////// | 854 /////////////////////////////////////////////////////////////////////////////// |
| 864 // HistoryFocusObserver: | 855 // HistoryFocusObserver: |
| 865 | 856 |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 */ | 1750 */ |
| 1760 PageState.instance = null; | 1751 PageState.instance = null; |
| 1761 | 1752 |
| 1762 /** | 1753 /** |
| 1763 * @return {Object} An object containing parameters from our window hash. | 1754 * @return {Object} An object containing parameters from our window hash. |
| 1764 */ | 1755 */ |
| 1765 PageState.prototype.getHashData = function() { | 1756 PageState.prototype.getHashData = function() { |
| 1766 var result = { | 1757 var result = { |
| 1767 q: '', | 1758 q: '', |
| 1768 page: 0, | 1759 page: 0, |
| 1769 grouped: false, | |
| 1770 range: 0, | 1760 range: 0, |
| 1771 offset: 0 | 1761 offset: 0 |
| 1772 }; | 1762 }; |
| 1773 | 1763 |
| 1774 if (!window.location.hash) | 1764 if (!window.location.hash) |
| 1775 return result; | 1765 return result; |
| 1776 | 1766 |
| 1777 var hashSplit = window.location.hash.substr(1).split('&'); | 1767 var hashSplit = window.location.hash.substr(1).split('&'); |
| 1778 for (var i = 0; i < hashSplit.length; i++) { | 1768 for (var i = 0; i < hashSplit.length; i++) { |
| 1779 var pair = hashSplit[i].split('='); | 1769 var pair = hashSplit[i].split('='); |
| 1780 if (pair.length > 1) { | 1770 if (pair.length > 1) |
| 1781 result[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); | 1771 result[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); |
| 1782 } | |
| 1783 } | 1772 } |
| 1784 | 1773 |
| 1785 return result; | 1774 return result; |
| 1786 }; | 1775 }; |
| 1787 | 1776 |
| 1788 /** | 1777 /** |
| 1789 * Set the hash to a specified state, this will create an entry in the | 1778 * Set the hash to a specified state, this will create an entry in the |
| 1790 * session history so the back button cycles through hash states, which | 1779 * session history so the back button cycles through hash states, which |
| 1791 * are then picked up by our listener. | 1780 * are then picked up by our listener. |
| 1792 * @param {string} term The current search string. | 1781 * @param {string} term The current search string. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 uber.onContentFrameLoaded(); | 1829 uber.onContentFrameLoaded(); |
| 1841 | 1830 |
| 1842 var searchField = $('search-field'); | 1831 var searchField = $('search-field'); |
| 1843 | 1832 |
| 1844 historyModel = new HistoryModel(); | 1833 historyModel = new HistoryModel(); |
| 1845 historyView = new HistoryView(historyModel); | 1834 historyView = new HistoryView(historyModel); |
| 1846 pageState = new PageState(historyModel, historyView); | 1835 pageState = new PageState(historyModel, historyView); |
| 1847 | 1836 |
| 1848 // Create default view. | 1837 // Create default view. |
| 1849 var hashData = pageState.getHashData(); | 1838 var hashData = pageState.getHashData(); |
| 1850 var grouped = (hashData.grouped == 'true') || historyModel.getGroupByDomain(); | |
| 1851 var page = parseInt(hashData.page, 10) || historyView.getPage(); | 1839 var page = parseInt(hashData.page, 10) || historyView.getPage(); |
| 1852 var range = /** @type {HistoryModel.Range} */(parseInt(hashData.range, 10)) || | 1840 var range = /** @type {HistoryModel.Range} */(parseInt(hashData.range, 10)) || |
| 1853 historyView.getRangeInDays(); | 1841 historyView.getRangeInDays(); |
| 1854 var offset = parseInt(hashData.offset, 10) || historyView.getOffset(); | 1842 var offset = parseInt(hashData.offset, 10) || historyView.getOffset(); |
| 1855 historyView.setPageState(hashData.q, page, range, offset); | 1843 historyView.setPageState(hashData.q, page, range, offset); |
| 1856 | 1844 |
| 1857 if ($('overlay')) { | 1845 if ($('overlay')) { |
| 1858 cr.ui.overlay.setupOverlay($('overlay')); | 1846 cr.ui.overlay.setupOverlay($('overlay')); |
| 1859 cr.ui.overlay.globalInitialization(); | 1847 cr.ui.overlay.globalInitialization(); |
| 1860 } | 1848 } |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2273 historyView.reload(); | 2261 historyView.reload(); |
| 2274 } | 2262 } |
| 2275 | 2263 |
| 2276 // Add handlers to HTML elements. | 2264 // Add handlers to HTML elements. |
| 2277 document.addEventListener('DOMContentLoaded', load); | 2265 document.addEventListener('DOMContentLoaded', load); |
| 2278 | 2266 |
| 2279 // This event lets us enable and disable menu items before the menu is shown. | 2267 // This event lets us enable and disable menu items before the menu is shown. |
| 2280 document.addEventListener('canExecute', function(e) { | 2268 document.addEventListener('canExecute', function(e) { |
| 2281 e.canExecute = true; | 2269 e.canExecute = true; |
| 2282 }); | 2270 }); |
| OLD | NEW |