2 /** @polymerBehavior Polymer.IronMultiSelectableBehavior */
3 Polymer.IronMultiSelectableBehaviorImpl = {
7 * If true, multiple selections are allowed.
12 observer: 'multiChanged'
16 * Gets or sets the selected elements. This is used instead of `selected` when `multi`
25 * Returns an array of currently selected items.
36 '_updateSelected(attrForSelected, selectedValues)'
40 * Selects the given value. If the `multi` property is true, then the selected state of the
41 * `value` will be toggled; otherwise the `value` will be selected.
44 * @param {string} value the value to select.
46 select: function(value) {
48 if (this.selectedValues) {
49 this._toggleSelected(value);
51 this.selectedValues = [value];
54 this.selected = value;
58 multiChanged: function(multi) {
59 this._selection.multi = multi;
62 _updateSelected: function() {
64 this._selectMulti(this.selectedValues);
66 this._selectSelected(this.selected);
70 _selectMulti: function(values) {
71 this._selection.clear();
73 for (var i = 0; i < values.length; i++) {
74 this._selection.setItemSelected(this._valueToItem(values[i]), true);
79 _selectionChange: function() {
80 var s = this._selection.get();
82 this._setSelectedItems(s);
84 this._setSelectedItems([s]);
85 this._setSelectedItem(s);
89 _toggleSelected: function(value) {
90 var i = this.selectedValues.indexOf(value);
91 var unselected = i < 0;
93 this.selectedValues.push(value);
95 this.selectedValues.splice(i, 1);
97 this._selection.setItemSelected(this._valueToItem(value), unselected);
101 /** @polymerBehavior */
102 Polymer.IronMultiSelectableBehavior = [
103 Polymer.IronSelectableBehavior,
104 Polymer.IronMultiSelectableBehaviorImpl