OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // require: listselectionmodel.js | 5 // require: listselectionmodel.js |
6 | 6 |
7 /** | 7 /** |
8 * @fileoverview This implements a list control. | 8 * @fileoverview This implements a list control. |
9 */ | 9 */ |
10 | 10 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 this.beforeFiller_ = this.ownerDocument.createElement('div'); | 262 this.beforeFiller_ = this.ownerDocument.createElement('div'); |
263 this.afterFiller_ = this.ownerDocument.createElement('div'); | 263 this.afterFiller_ = this.ownerDocument.createElement('div'); |
264 this.beforeFiller_.className = 'spacer'; | 264 this.beforeFiller_.className = 'spacer'; |
265 this.afterFiller_.className = 'spacer'; | 265 this.afterFiller_.className = 'spacer'; |
266 this.appendChild(this.beforeFiller_); | 266 this.appendChild(this.beforeFiller_); |
267 this.appendChild(this.afterFiller_); | 267 this.appendChild(this.afterFiller_); |
268 | 268 |
269 var length = this.dataModel ? this.dataModel.length : 0; | 269 var length = this.dataModel ? this.dataModel.length : 0; |
270 this.selectionModel = new ListSelectionModel(length); | 270 this.selectionModel = new ListSelectionModel(length); |
271 | 271 |
272 this.addEventListener('dblclick', this.handleDoubleClick_); | |
272 this.addEventListener('mousedown', this.handleMouseDownUp_); | 273 this.addEventListener('mousedown', this.handleMouseDownUp_); |
273 this.addEventListener('mouseup', this.handleMouseDownUp_); | 274 this.addEventListener('mouseup', this.handleMouseDownUp_); |
274 this.addEventListener('keydown', this.handleKeyDown); | 275 this.addEventListener('keydown', this.handleKeyDown); |
275 this.addEventListener('scroll', this.redraw.bind(this)); | 276 this.addEventListener('scroll', this.redraw.bind(this)); |
276 | 277 |
277 // Make list focusable | 278 // Make list focusable |
278 if (!this.hasAttribute('tabindex')) | 279 if (!this.hasAttribute('tabindex')) |
279 this.tabIndex = 0; | 280 this.tabIndex = 0; |
280 }, | 281 }, |
281 | 282 |
282 /** | 283 /** |
283 * Returns the height of an item, measuring it if necessary. | 284 * Returns the height of an item, measuring it if necessary. |
284 * @private | 285 * @private |
285 */ | 286 */ |
286 getItemHeight_: function() { | 287 getItemHeight_: function() { |
287 if (!this.itemHeight_) | 288 if (!this.itemHeight_) |
288 this.itemHeight_ = measureItem(this); | 289 this.itemHeight_ = measureItem(this); |
289 return this.itemHeight_; | 290 return this.itemHeight_; |
290 }, | 291 }, |
291 | 292 |
292 /** | 293 /** |
294 * Callback for the double click event. | |
295 * @param {Event} e The mouse event object. | |
296 * @private | |
297 */ | |
298 handleDoubleClick_: function(e) { | |
299 if (this.disabled) | |
300 return; | |
301 | |
302 var target = this.getListItemAncestor(e.target); | |
303 var index = target ? this.getIndexOfListItem(target) : -1; | |
304 this.activateItemAtIndex(index); | |
Evan Stade
2011/01/12 00:46:12
this is causing js errors in lists that don't impl
James Hawkins
2011/01/12 00:54:04
I guess I forgot to stub it out; I'll add the stub
| |
305 }, | |
306 | |
307 /** | |
293 * Callback for mousedown and mouseup events. | 308 * Callback for mousedown and mouseup events. |
294 * @param {Event} e The mouse event object. | 309 * @param {Event} e The mouse event object. |
295 * @private | 310 * @private |
296 */ | 311 */ |
297 handleMouseDownUp_: function(e) { | 312 handleMouseDownUp_: function(e) { |
298 if (this.disabled) | 313 if (this.disabled) |
299 return; | 314 return; |
300 | 315 |
301 var target = e.target; | 316 var target = e.target; |
302 | 317 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 } | 608 } |
594 }, | 609 }, |
595 }; | 610 }; |
596 | 611 |
597 cr.defineProperty(List, 'disabled', cr.PropertyKind.BOOL_ATTR); | 612 cr.defineProperty(List, 'disabled', cr.PropertyKind.BOOL_ATTR); |
598 | 613 |
599 return { | 614 return { |
600 List: List | 615 List: List |
601 } | 616 } |
602 }); | 617 }); |
OLD | NEW |