| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 numberOfItems: Number, | 127 numberOfItems: Number, |
| 128 | 128 |
| 129 // Search term used to obtain this history-item. | 129 // Search term used to obtain this history-item. |
| 130 searchTerm: String, | 130 searchTerm: String, |
| 131 }, | 131 }, |
| 132 | 132 |
| 133 /** @private {?HistoryFocusRow} */ | 133 /** @private {?HistoryFocusRow} */ |
| 134 row_: null, | 134 row_: null, |
| 135 | 135 |
| 136 /** @private {boolean} */ |
| 137 mouseDown_: false, |
| 138 |
| 136 /** @override */ | 139 /** @override */ |
| 137 attached: function() { | 140 attached: function() { |
| 138 Polymer.RenderStatus.afterNextRender(this, function() { | 141 Polymer.RenderStatus.afterNextRender(this, function() { |
| 139 this.row_ = new HistoryFocusRow( | 142 this.row_ = new HistoryFocusRow( |
| 140 this.$['main-container'], null, new FocusRowDelegate(this)); | 143 this.$['main-container'], null, new FocusRowDelegate(this)); |
| 141 this.row_.makeActive(this.ironListTabIndex == 0); | 144 this.row_.makeActive(this.ironListTabIndex == 0); |
| 142 this.listen(this, 'focus', 'onFocus_'); | 145 this.listen(this, 'focus', 'onFocus_'); |
| 143 this.listen(this, 'dom-change', 'onDomChange_'); | 146 this.listen(this, 'dom-change', 'onDomChange_'); |
| 144 }); | 147 }); |
| 145 }, | 148 }, |
| 146 | 149 |
| 147 /** @override */ | 150 /** @override */ |
| 148 detached: function() { | 151 detached: function() { |
| 149 this.unlisten(this, 'focus', 'onFocus_'); | 152 this.unlisten(this, 'focus', 'onFocus_'); |
| 150 this.unlisten(this, 'dom-change', 'onDomChange_'); | 153 this.unlisten(this, 'dom-change', 'onDomChange_'); |
| 151 if (this.row_) | 154 if (this.row_) |
| 152 this.row_.destroy(); | 155 this.row_.destroy(); |
| 153 }, | 156 }, |
| 154 | 157 |
| 155 /** | 158 /** |
| 156 * @private | 159 * @private |
| 157 */ | 160 */ |
| 158 onFocus_: function() { | 161 onFocus_: function() { |
| 162 // Don't change the focus while the mouse is down, as it prevents text |
| 163 // selection. Not changing focus here is acceptable because the checkbox |
| 164 // will be focused in onItemClick_() anyway. |
| 165 if (this.mouseDown_) |
| 166 return; |
| 167 |
| 159 if (this.lastFocused) | 168 if (this.lastFocused) |
| 160 this.row_.getEquivalentElement(this.lastFocused).focus(); | 169 this.row_.getEquivalentElement(this.lastFocused).focus(); |
| 161 else | 170 else |
| 162 this.row_.getFirstFocusable().focus(); | 171 this.row_.getFirstFocusable().focus(); |
| 163 | 172 |
| 164 this.tabIndex = -1; | 173 this.tabIndex = -1; |
| 165 }, | 174 }, |
| 166 | 175 |
| 167 /** | 176 /** |
| 168 * @private | 177 * @private |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 index: this.index, | 212 index: this.index, |
| 204 shiftKey: e.shiftKey, | 213 shiftKey: e.shiftKey, |
| 205 }); | 214 }); |
| 206 }, | 215 }, |
| 207 | 216 |
| 208 /** | 217 /** |
| 209 * @param {MouseEvent} e | 218 * @param {MouseEvent} e |
| 210 * @private | 219 * @private |
| 211 */ | 220 */ |
| 212 onItemMousedown_: function(e) { | 221 onItemMousedown_: function(e) { |
| 222 this.mouseDown_ = true; |
| 223 listenOnce(document, 'mouseup', function() { |
| 224 this.mouseDown_ = false; |
| 225 }.bind(this)); |
| 213 // Prevent shift clicking a checkbox from selecting text. | 226 // Prevent shift clicking a checkbox from selecting text. |
| 214 if (e.shiftKey) | 227 if (e.shiftKey) |
| 215 e.preventDefault(); | 228 e.preventDefault(); |
| 216 }, | 229 }, |
| 217 | 230 |
| 218 /** | 231 /** |
| 219 * @private | 232 * @private |
| 220 * @return {string} | 233 * @return {string} |
| 221 */ | 234 */ |
| 222 getEntrySummary_: function() { | 235 getEntrySummary_: function() { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 */ | 348 */ |
| 336 HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) { | 349 HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) { |
| 337 var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults'; | 350 var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults'; |
| 338 return loadTimeData.getStringF( | 351 return loadTimeData.getStringF( |
| 339 'foundSearchResults', numberOfResults, loadTimeData.getString(resultId), | 352 'foundSearchResults', numberOfResults, loadTimeData.getString(resultId), |
| 340 searchTerm); | 353 searchTerm); |
| 341 }; | 354 }; |
| 342 | 355 |
| 343 return {HistoryItem: HistoryItem}; | 356 return {HistoryItem: HistoryItem}; |
| 344 }); | 357 }); |
| OLD | NEW |