Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1166)

Side by Side Diff: chrome/browser/resources/shared/js/cr/ui/list_item.js

Issue 5935003: DOMUI: Implement new-style password manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes 2. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/list.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 cr.define('cr.ui', function() { 5 cr.define('cr.ui', function() {
6 6
7 /** 7 /**
8 * Creates a new list item element. 8 * Creates a new list item element.
9 * @param {string} opt_label The text label for the item. 9 * @param {string} opt_label The text label for the item.
10 * @constructor 10 * @constructor
11 * @extends {HTMLLIElement} 11 * @extends {HTMLLIElement}
12 */ 12 */
13 var ListItem = cr.ui.define('li'); 13 var ListItem = cr.ui.define('li');
14 14
15 ListItem.prototype = { 15 ListItem.prototype = {
16 __proto__: HTMLLIElement.prototype, 16 __proto__: HTMLLIElement.prototype,
17 17
18 /** 18 /**
19 * Plain text label. 19 * Plain text label.
20 * @type {string} 20 * @type {string}
21 */ 21 */
22 get label() { 22 get label() {
23 return this.textContent; 23 return this.textContent;
24 }, 24 },
25 set label(label) { 25 set label(label) {
26 this.textContent = label; 26 this.textContent = label;
27 }, 27 },
28 28
29 /** 29 /**
30 * The current selection state.
31 * @type {Boolean}
32 */
33 get selected() {
34 return this.hasAttribute('selected');
35 },
36 set selected(selected) {
37 selected = Boolean(selected);
arv (Not doing code reviews) 2010/12/17 21:48:19 The reason for the Boolean case is so that the tes
38 var oldSelected = this.selected;
39 if (oldSelected == selected)
40 return;
41
42 if (selected)
43 this.setAttribute('selected', '');
44 else
45 this.removeAttribute('selected');
46
47 cr.dispatchPropertyChange(this, 'selected', selected, oldSelected);
48 this.selectionChanged();
49 },
50
51 /**
30 * Called when an element is decorated as a list item. 52 * Called when an element is decorated as a list item.
31 */ 53 */
32 decorate: function() { 54 decorate: function() {
33 } 55 },
56
57 /**
58 * Called when the selection state of this element changes.
59 */
60 selectionChanged: function() {
61 },
34 }; 62 };
35 63
36 /** 64 /**
37 * Whether the item is selected. Setting this does not update the underlying 65 * Whether the item is selected. Setting this does not update the underlying
38 * selection model. This is only used for display purpose. 66 * selection model. This is only used for display purpose.
39 * @type {boolean} 67 * @type {boolean}
40 */ 68 */
41 cr.defineProperty(ListItem, 'selected', cr.PropertyKind.BOOL_ATTR); 69 cr.defineProperty(ListItem, 'selected', cr.PropertyKind.BOOL_ATTR);
42 70
43 /** 71 /**
44 * Whether the item is the lead in a selection. Setting this does not update 72 * Whether the item is the lead in a selection. Setting this does not update
45 * the underlying selection model. This is only used for display purpose. 73 * the underlying selection model. This is only used for display purpose.
46 * @type {boolean} 74 * @type {boolean}
47 */ 75 */
48 cr.defineProperty(ListItem, 'lead', cr.PropertyKind.BOOL_ATTR); 76 cr.defineProperty(ListItem, 'lead', cr.PropertyKind.BOOL_ATTR);
49 77
50 return { 78 return {
51 ListItem: ListItem 79 ListItem: ListItem
52 }; 80 };
53 }); 81 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/list.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698