OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /////////////////////////////////////////////////////////////////////////////// | 5 /////////////////////////////////////////////////////////////////////////////// |
6 // Globals: | 6 // Globals: |
7 var RESULTS_PER_PAGE = 150; | 7 var RESULTS_PER_PAGE = 150; |
8 var MAX_SEARCH_DEPTH_MONTHS = 18; | 8 var MAX_SEARCH_DEPTH_MONTHS = 18; |
9 | 9 |
10 // Amount of time between pageviews that we consider a 'break' in browsing, | 10 // Amount of time between pageviews that we consider a 'break' in browsing, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Page, Public: -------------------------------------------------------------- | 97 // Page, Public: -------------------------------------------------------------- |
98 /** | 98 /** |
99 * Returns a dom structure for a browse page result or a search page result. | 99 * Returns a dom structure for a browse page result or a search page result. |
100 * @param {boolean} Flag to indicate if result is a search result. | 100 * @param {boolean} Flag to indicate if result is a search result. |
101 * @return {Element} The dom structure. | 101 * @return {Element} The dom structure. |
102 */ | 102 */ |
103 Page.prototype.getResultDOM = function(searchResultFlag) { | 103 Page.prototype.getResultDOM = function(searchResultFlag) { |
104 var node = createElementWithClassName('li', 'entry'); | 104 var node = createElementWithClassName('li', 'entry'); |
105 var time = createElementWithClassName('div', 'time'); | 105 var time = createElementWithClassName('div', 'time'); |
106 var entryBox = createElementWithClassName('label', 'entry-box'); | 106 var entryBox = createElementWithClassName('div', 'entry-box'); |
107 var domain = createElementWithClassName('div', 'domain'); | 107 var domain = createElementWithClassName('div', 'domain'); |
108 | 108 |
109 var dropDown = createElementWithClassName('button', 'drop-down'); | 109 var dropDown = createElementWithClassName('button', 'drop-down'); |
110 dropDown.value = 'Open action menu'; | 110 dropDown.value = 'Open action menu'; |
111 dropDown.title = localStrings.getString('actionMenuDescription'); | 111 dropDown.title = localStrings.getString('actionMenuDescription'); |
112 dropDown.setAttribute('menu', '#action-menu'); | 112 dropDown.setAttribute('menu', '#action-menu'); |
113 cr.ui.decorate(dropDown, MenuButton); | 113 cr.ui.decorate(dropDown, MenuButton); |
114 | 114 |
115 // Checkbox is always created, but only visible on hover & when checked. | 115 // Checkbox is always created, but only visible on hover & when checked. |
116 var checkbox = document.createElement('input'); | 116 var checkbox = document.createElement('input'); |
(...skipping 11 matching lines...) Expand all Loading... |
128 activePage = self; | 128 activePage = self; |
129 }; | 129 }; |
130 dropDown.addEventListener('mousedown', setActivePage); | 130 dropDown.addEventListener('mousedown', setActivePage); |
131 dropDown.addEventListener('focus', setActivePage); | 131 dropDown.addEventListener('focus', setActivePage); |
132 | 132 |
133 domain.style.backgroundImage = | 133 domain.style.backgroundImage = |
134 'url(chrome://favicon/' + encodeURIForCSS(this.url_) + ')'; | 134 'url(chrome://favicon/' + encodeURIForCSS(this.url_) + ')'; |
135 domain.textContent = this.domain_; | 135 domain.textContent = this.domain_; |
136 | 136 |
137 // Clicking anywhere in the entryBox will check/uncheck the checkbox. | 137 // Clicking anywhere in the entryBox will check/uncheck the checkbox. |
138 entryBox.setAttribute('for', checkbox.id); | |
139 entryBox.addEventListener('mousedown', entryBoxMousedown, false); | 138 entryBox.addEventListener('mousedown', entryBoxMousedown, false); |
140 | 139 |
141 // Prevent clicks on the drop down from affecting the checkbox. | 140 // Prevent clicks on the drop down from affecting the checkbox. |
142 dropDown.addEventListener('click', function(e) { e.preventDefault(); }); | 141 dropDown.addEventListener('click', function(e) { e.preventDefault(); }); |
143 | 142 |
| 143 // A label around the parts that should be clicked to activate the check box. |
| 144 var label = document.createElement('label'); |
| 145 label.appendChild(time); |
| 146 label.appendChild(domain); |
| 147 |
144 // We use a wrapper div so that the entry contents will be shinkwrapped. | 148 // We use a wrapper div so that the entry contents will be shinkwrapped. |
145 entryBox.appendChild(time); | 149 entryBox.appendChild(label); |
146 entryBox.appendChild(domain); | |
147 entryBox.appendChild(this.getTitleDOM_()); | 150 entryBox.appendChild(this.getTitleDOM_()); |
148 entryBox.appendChild(dropDown); | 151 entryBox.appendChild(dropDown); |
149 | 152 |
150 // Let the entryBox be styled appropriately when it contains keyboard focus. | 153 // Let the entryBox be styled appropriately when it contains keyboard focus. |
151 entryBox.addEventListener('focus', function() { | 154 entryBox.addEventListener('focus', function() { |
152 this.classList.add('contains-focus'); | 155 this.classList.add('contains-focus'); |
153 }, true); | 156 }, true); |
154 entryBox.addEventListener('blur', function() { | 157 entryBox.addEventListener('blur', function() { |
155 this.classList.remove('contains-focus'); | 158 this.classList.remove('contains-focus'); |
156 }, true); | 159 }, true); |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 var cbDate = new Date(checkbox.time); | 977 var cbDate = new Date(checkbox.time); |
975 if (date.getFullYear() != cbDate.getFullYear() || | 978 if (date.getFullYear() != cbDate.getFullYear() || |
976 date.getMonth() != cbDate.getMonth() || | 979 date.getMonth() != cbDate.getMonth() || |
977 date.getDate() != cbDate.getDate()) { | 980 date.getDate() != cbDate.getDate()) { |
978 if (urls.length > 0) { | 981 if (urls.length > 0) { |
979 queue.push([date, urls]); | 982 queue.push([date, urls]); |
980 } | 983 } |
981 urls = []; | 984 urls = []; |
982 date = cbDate; | 985 date = cbDate; |
983 } | 986 } |
984 var link = checkbox.parentNode.parentNode.querySelector('a'); | 987 var link = checkbox.parentNode.parentNode.parentNode.querySelector('a'); |
985 checkbox.disabled = true; | 988 checkbox.disabled = true; |
986 link.classList.add('to-be-removed'); | 989 link.classList.add('to-be-removed'); |
987 disabledItems.push(checkbox); | 990 disabledItems.push(checkbox); |
988 urls.push(link.href); | 991 urls.push(link.href); |
989 } | 992 } |
990 if (urls.length > 0) { | 993 if (urls.length > 0) { |
991 queue.push([date, urls]); | 994 queue.push([date, urls]); |
992 } | 995 } |
993 if (checked.length > 0 && confirm(localStrings.getString('deletewarning'))) { | 996 if (checked.length > 0 && confirm(localStrings.getString('deletewarning'))) { |
994 for (var i = 0; i < queue.length; i++) { | 997 for (var i = 0; i < queue.length; i++) { |
995 // Reload the page when the final entry has been deleted. | 998 // Reload the page when the final entry has been deleted. |
996 var callback = i == 0 ? reloadHistory : null; | 999 var callback = i == 0 ? reloadHistory : null; |
997 | 1000 |
998 queueURLsForDeletion(queue[i][0], queue[i][1], callback); | 1001 queueURLsForDeletion(queue[i][0], queue[i][1], callback); |
999 } | 1002 } |
1000 deleteNextInQueue(); | 1003 deleteNextInQueue(); |
1001 } else { | 1004 } else { |
1002 // If the remove is cancelled, return the checkboxes to their | 1005 // If the remove is cancelled, return the checkboxes to their |
1003 // enabled, non-line-through state. | 1006 // enabled, non-line-through state. |
1004 for (var i = 0; i < disabledItems.length; i++) { | 1007 for (var i = 0; i < disabledItems.length; i++) { |
1005 var checkbox = disabledItems[i]; | 1008 var checkbox = disabledItems[i]; |
1006 var link = checkbox.parentNode.parentNode.querySelector('a'); | 1009 var link = checkbox.parentNode.parentNode.parentNode.querySelector('a'); |
1007 checkbox.disabled = false; | 1010 checkbox.disabled = false; |
1008 link.classList.remove('to-be-removed'); | 1011 link.classList.remove('to-be-removed'); |
1009 } | 1012 } |
1010 } | 1013 } |
1011 return false; | 1014 return false; |
1012 } | 1015 } |
1013 | 1016 |
1014 /** | 1017 /** |
1015 * Toggle state of checkbox and handle Shift modifier. | 1018 * Toggle state of checkbox and handle Shift modifier. |
1016 */ | 1019 */ |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 historyView.reload(); | 1127 historyView.reload(); |
1125 } | 1128 } |
1126 | 1129 |
1127 // Add handlers to HTML elements. | 1130 // Add handlers to HTML elements. |
1128 document.addEventListener('DOMContentLoaded', load); | 1131 document.addEventListener('DOMContentLoaded', load); |
1129 | 1132 |
1130 // This event lets us enable and disable menu items before the menu is shown. | 1133 // This event lets us enable and disable menu items before the menu is shown. |
1131 document.addEventListener('canExecute', function(e) { | 1134 document.addEventListener('canExecute', function(e) { |
1132 e.canExecute = true; | 1135 e.canExecute = true; |
1133 }); | 1136 }); |
OLD | NEW |