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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 * - useMonthDate: Whether or not the full date should be inserted (used for | 143 * - useMonthDate: Whether or not the full date should be inserted (used for |
144 * monthly view). | 144 * monthly view). |
145 * @return {Node} A DOM node to represent the history entry or search result. | 145 * @return {Node} A DOM node to represent the history entry or search result. |
146 */ | 146 */ |
147 Visit.prototype.getResultDOM = function(propertyBag) { | 147 Visit.prototype.getResultDOM = function(propertyBag) { |
148 var isSearchResult = propertyBag.isSearchResult || false; | 148 var isSearchResult = propertyBag.isSearchResult || false; |
149 var addTitleFavicon = propertyBag.addTitleFavicon || false; | 149 var addTitleFavicon = propertyBag.addTitleFavicon || false; |
150 var useMonthDate = propertyBag.useMonthDate || false; | 150 var useMonthDate = propertyBag.useMonthDate || false; |
151 var focusless = propertyBag.focusless || false; | 151 var focusless = propertyBag.focusless || false; |
152 var node = createElementWithClassName('li', 'entry'); | 152 var node = createElementWithClassName('li', 'entry'); |
153 var time = createElementWithClassName('div', 'time'); | 153 var time = createElementWithClassName('label', 'time'); |
154 var entryBox = createElementWithClassName('label', 'entry-box'); | 154 var entryBox = createElementWithClassName('div', 'entry-box'); |
155 var domain = createElementWithClassName('div', 'domain'); | 155 var domain = createElementWithClassName('div', 'domain'); |
156 | 156 |
157 this.id_ = this.model_.nextVisitId_++; | 157 this.id_ = this.model_.nextVisitId_++; |
158 var self = this; | 158 var self = this; |
159 | 159 |
160 // Only create the checkbox if it can be used either to delete an entry or to | 160 // Only create the checkbox if it can be used either to delete an entry or to |
161 // block/allow it. | 161 // block/allow it. |
162 if (this.model_.editingEntriesAllowed) { | 162 if (this.model_.editingEntriesAllowed) { |
163 var checkbox = document.createElement('input'); | 163 var checkbox = document.createElement('input'); |
164 checkbox.type = 'checkbox'; | 164 checkbox.type = 'checkbox'; |
165 checkbox.id = 'checkbox-' + this.id_; | 165 checkbox.id = 'checkbox-' + this.id_; |
166 checkbox.time = this.date.getTime(); | 166 checkbox.time = this.date.getTime(); |
167 checkbox.addEventListener('click', checkboxClicked); | 167 checkbox.addEventListener('click', checkboxClicked); |
| 168 time.setAttribute('for', checkbox.id); |
168 entryBox.appendChild(checkbox); | 169 entryBox.appendChild(checkbox); |
169 | 170 |
170 if (focusless) | 171 if (focusless) |
171 checkbox.tabIndex = -1; | 172 checkbox.tabIndex = -1; |
172 | 173 |
173 // Clicking anywhere in the entryBox will check/uncheck the checkbox. | 174 // Clicking anywhere in the entryBox will check/uncheck the checkbox. |
174 entryBox.setAttribute('for', checkbox.id); | 175 entryBox.setAttribute('for', checkbox.id); |
175 entryBox.addEventListener('mousedown', entryBoxMousedown); | 176 entryBox.addEventListener('mousedown', entryBoxMousedown); |
176 entryBox.addEventListener('click', entryBoxClick); | 177 entryBox.addEventListener('click', entryBoxClick); |
177 entryBox.addEventListener('keydown', this.handleKeydown_.bind(this)); | 178 entryBox.addEventListener('keydown', this.handleKeydown_.bind(this)); |
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 var element = event.target; | 2106 var element = event.target; |
2106 // Do nothing if the event happened in an interactive element. | 2107 // Do nothing if the event happened in an interactive element. |
2107 for (; element != event.currentTarget; element = element.parentNode) { | 2108 for (; element != event.currentTarget; element = element.parentNode) { |
2108 switch (element.tagName) { | 2109 switch (element.tagName) { |
2109 case 'A': | 2110 case 'A': |
2110 case 'BUTTON': | 2111 case 'BUTTON': |
2111 case 'INPUT': | 2112 case 'INPUT': |
2112 return; | 2113 return; |
2113 } | 2114 } |
2114 } | 2115 } |
2115 var checkbox = event.currentTarget.control; | 2116 var checkbox = $(event.currentTarget.getAttribute('for')); |
2116 checkbox.checked = !checkbox.checked; | 2117 checkbox.checked = !checkbox.checked; |
2117 handleCheckboxStateChange(checkbox, event.shiftKey); | 2118 handleCheckboxStateChange(checkbox, event.shiftKey); |
2118 // We don't want to focus on the checkbox. | 2119 // We don't want to focus on the checkbox. |
2119 event.preventDefault(); | 2120 event.preventDefault(); |
2120 } | 2121 } |
2121 | 2122 |
2122 /** | 2123 /** |
2123 * Called when an individual history entry has been removed from the page. | 2124 * Called when an individual history entry has been removed from the page. |
2124 * This will only be called when all the elements affected by the deletion | 2125 * This will only be called when all the elements affected by the deletion |
2125 * have been removed from the DOM and the animations have completed. | 2126 * have been removed from the DOM and the animations have completed. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2205 historyView.reload(); | 2206 historyView.reload(); |
2206 } | 2207 } |
2207 | 2208 |
2208 // Add handlers to HTML elements. | 2209 // Add handlers to HTML elements. |
2209 document.addEventListener('DOMContentLoaded', load); | 2210 document.addEventListener('DOMContentLoaded', load); |
2210 | 2211 |
2211 // This event lets us enable and disable menu items before the menu is shown. | 2212 // This event lets us enable and disable menu items before the menu is shown. |
2212 document.addEventListener('canExecute', function(e) { | 2213 document.addEventListener('canExecute', function(e) { |
2213 e.canExecute = true; | 2214 e.canExecute = true; |
2214 }); | 2215 }); |
OLD | NEW |