| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * @param {!Element} root | 6 * @param {!Element} root |
| 7 * @param {?Element} boundary | 7 * @param {?Element} boundary |
| 8 * @param {cr.ui.FocusRow.Delegate} delegate | 8 * @param {cr.ui.FocusRow.Delegate} delegate |
| 9 * @constructor | 9 * @constructor |
| 10 * @extends {cr.ui.FocusRow} | 10 * @extends {cr.ui.FocusRow} |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 type: Number, | 110 type: Number, |
| 111 observer: 'ironListTabIndexChanged_', | 111 observer: 'ironListTabIndexChanged_', |
| 112 }, | 112 }, |
| 113 | 113 |
| 114 hasTimeGap: Boolean, | 114 hasTimeGap: Boolean, |
| 115 | 115 |
| 116 index: Number, | 116 index: Number, |
| 117 | 117 |
| 118 numberOfItems: Number, | 118 numberOfItems: Number, |
| 119 | 119 |
| 120 // The path of this history item inside its parent. | |
| 121 path: String, | |
| 122 | |
| 123 // Search term used to obtain this history-item. | 120 // Search term used to obtain this history-item. |
| 124 searchTerm: String, | 121 searchTerm: String, |
| 125 }, | 122 }, |
| 126 | 123 |
| 127 /** @private {?HistoryFocusRow} */ | 124 /** @private {?HistoryFocusRow} */ |
| 128 row_: null, | 125 row_: null, |
| 129 | 126 |
| 130 /** @override */ | 127 /** @override */ |
| 131 attached: function() { | 128 attached: function() { |
| 132 Polymer.RenderStatus.afterNextRender(this, function() { | 129 Polymer.RenderStatus.afterNextRender(this, function() { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 (elem.nodeName == 'A' || elem.nodeName == 'BUTTON')) { | 184 (elem.nodeName == 'A' || elem.nodeName == 'BUTTON')) { |
| 188 return; | 185 return; |
| 189 } | 186 } |
| 190 } | 187 } |
| 191 | 188 |
| 192 if (this.selectionNotAllowed_()) | 189 if (this.selectionNotAllowed_()) |
| 193 return; | 190 return; |
| 194 | 191 |
| 195 this.$.checkbox.focus(); | 192 this.$.checkbox.focus(); |
| 196 this.fire('history-checkbox-select', { | 193 this.fire('history-checkbox-select', { |
| 197 element: this, | 194 index: this.index, |
| 198 shiftKey: e.shiftKey, | 195 shiftKey: e.shiftKey, |
| 199 }); | 196 }); |
| 200 }, | 197 }, |
| 201 | 198 |
| 202 /** | 199 /** |
| 203 * @param {MouseEvent} e | 200 * @param {MouseEvent} e |
| 204 * @private | 201 * @private |
| 205 */ | 202 */ |
| 206 onItemMousedown_: function(e) { | 203 onItemMousedown_: function(e) { |
| 207 // Prevent shift clicking a checkbox from selecting text. | 204 // Prevent shift clicking a checkbox from selecting text. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 247 |
| 251 /** | 248 /** |
| 252 * Fires a custom event when the menu button is clicked. Sends the details | 249 * Fires a custom event when the menu button is clicked. Sends the details |
| 253 * of the history item and where the menu should appear. | 250 * of the history item and where the menu should appear. |
| 254 */ | 251 */ |
| 255 onMenuButtonTap_: function(e) { | 252 onMenuButtonTap_: function(e) { |
| 256 this.fire('open-menu', { | 253 this.fire('open-menu', { |
| 257 target: Polymer.dom(e).localTarget, | 254 target: Polymer.dom(e).localTarget, |
| 258 index: this.index, | 255 index: this.index, |
| 259 item: this.item, | 256 item: this.item, |
| 260 path: this.path, | |
| 261 }); | 257 }); |
| 262 | 258 |
| 263 // Stops the 'tap' event from closing the menu when it opens. | 259 // Stops the 'tap' event from closing the menu when it opens. |
| 264 e.stopPropagation(); | 260 e.stopPropagation(); |
| 265 }, | 261 }, |
| 266 | 262 |
| 267 /** | 263 /** |
| 268 * Record metrics when a result is clicked. This is deliberately tied to | 264 * Record metrics when a result is clicked. This is deliberately tied to |
| 269 * on-click rather than on-tap, as on-click triggers from middle clicks. | 265 * on-click rather than on-tap, as on-click triggers from middle clicks. |
| 270 */ | 266 */ |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 317 |
| 322 /** @private */ | 318 /** @private */ |
| 323 addTimeTitle_: function() { | 319 addTimeTitle_: function() { |
| 324 var el = this.$['time-accessed']; | 320 var el = this.$['time-accessed']; |
| 325 el.setAttribute('title', new Date(this.item.time).toString()); | 321 el.setAttribute('title', new Date(this.item.time).toString()); |
| 326 this.unlisten(el, 'mouseover', 'addTimeTitle_'); | 322 this.unlisten(el, 'mouseover', 'addTimeTitle_'); |
| 327 }, | 323 }, |
| 328 }); | 324 }); |
| 329 | 325 |
| 330 /** | 326 /** |
| 331 * Check whether the time difference between the given history item and the | |
| 332 * next one is large enough for a spacer to be required. | |
| 333 * @param {Array<HistoryEntry>} visits | |
| 334 * @param {number} currentIndex | |
| 335 * @param {string} searchedTerm | |
| 336 * @return {boolean} Whether or not time gap separator is required. | |
| 337 */ | |
| 338 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) { | |
| 339 if (currentIndex >= visits.length - 1 || visits.length == 0) | |
| 340 return false; | |
| 341 | |
| 342 var currentItem = visits[currentIndex]; | |
| 343 var nextItem = visits[currentIndex + 1]; | |
| 344 | |
| 345 if (searchedTerm) | |
| 346 return currentItem.dateShort != nextItem.dateShort; | |
| 347 | |
| 348 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && | |
| 349 currentItem.dateRelativeDay == nextItem.dateRelativeDay; | |
| 350 }; | |
| 351 | |
| 352 /** | |
| 353 * @param {number} numberOfResults | 327 * @param {number} numberOfResults |
| 354 * @param {string} searchTerm | 328 * @param {string} searchTerm |
| 355 * @return {string} The title for a page of search results. | 329 * @return {string} The title for a page of search results. |
| 356 */ | 330 */ |
| 357 HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) { | 331 HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) { |
| 358 var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults'; | 332 var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults'; |
| 359 return loadTimeData.getStringF( | 333 return loadTimeData.getStringF( |
| 360 'foundSearchResults', numberOfResults, loadTimeData.getString(resultId), | 334 'foundSearchResults', numberOfResults, loadTimeData.getString(resultId), |
| 361 searchTerm); | 335 searchTerm); |
| 362 }; | 336 }; |
| 363 | 337 |
| 364 return {HistoryItem: HistoryItem}; | 338 return {HistoryItem: HistoryItem}; |
| 365 }); | 339 }); |
| OLD | NEW |