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

Side by Side Diff: third_party/polymer/v0_8/components-chromium/iron-selector/iron-multi-selectable-extracted.js

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also remove polymer/explainer Created 5 years, 7 months 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
OLDNEW
(Empty)
1
2
3 Polymer.IronMultiSelectableBehavior = [
4 Polymer.IronSelectableBehavior, {
5
6 properties: {
7
8 /**
9 * If true, multiple selections are allowed.
10 *
11 * @attribute multi
12 * @type Boolean
13 * @default false
14 */
15 multi: {
16 type: Boolean,
17 value: false,
18 observer: 'multiChanged'
19 },
20
21 /**
22 * Gets or sets the selected elements. This is used instead of `selected ` when `multi`
23 * is true.
24 *
25 * @attribute selectedValues
26 * @type Array
27 */
28 selectedValues: {
29 type: Array,
30 notify: true
31 },
32
33 /**
34 * Returns an array of currently selected items.
35 *
36 * @attribute selectedItems
37 * @type Array
38 */
39 selectedItems: {
40 type: Array,
41 readOnly: true,
42 notify: true
43 },
44
45 },
46
47 observers: [
48 '_updateSelected(attrForSelected, selectedValues)'
49 ],
50
51 /**
52 * Selects the given value. If the `multi` property is true, then the sele cted state of the
53 * `value` will be toggled; otherwise the `value` will be selected.
54 *
55 * @method select
56 * @param {String} value the value to select.
57 */
58 select: function(value) {
59 if (this.multi) {
60 if (this.selectedValues) {
61 this._toggleSelected(value);
62 } else {
63 this.selectedValues = [value];
64 }
65 } else {
66 this.selected = value;
67 }
68 },
69
70 multiChanged: function(multi) {
71 this._selection.multi = multi;
72 },
73
74 _updateSelected: function() {
75 if (this.multi) {
76 this._selectMulti(this.selectedValues);
77 } else {
78 this._selectSelected(this.selected);
79 }
80 },
81
82 _selectMulti: function(values) {
83 this._selection.clear();
84 if (values) {
85 for (var i = 0; i < values.length; i++) {
86 this._selection.setItemSelected(this._valueToItem(values[i]), true);
87 }
88 }
89 },
90
91 _selectionChange: function() {
92 var s = this._selection.get();
93 if (this.multi) {
94 this._setSelectedItems(s);
95 } else {
96 this._setSelectedItems([s]);
97 this._setSelectedItem(s);
98 }
99 },
100
101 _toggleSelected: function(value) {
102 var i = this.selectedValues.indexOf(value);
103 var unselected = i < 0;
104 if (unselected) {
105 this.selectedValues.push(value);
106 } else {
107 this.selectedValues.splice(i, 1);
108 }
109 this._selection.setItemSelected(this._valueToItem(value), unselected);
110 }
111
112 }
113 ];
114
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698