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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/iron-selector/iron-selection-extracted.js

Issue 1766433002: Roll Polymer to 1.3.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
1 /** 1 /**
2 * @param {!Function} selectCallback 2 * @param {!Function} selectCallback
3 * @constructor 3 * @constructor
4 */ 4 */
5 Polymer.IronSelection = function(selectCallback) { 5 Polymer.IronSelection = function(selectCallback) {
6 this.selection = []; 6 this.selection = [];
7 this.selectCallback = selectCallback; 7 this.selectCallback = selectCallback;
8 }; 8 };
9 9
10 Polymer.IronSelection.prototype = { 10 Polymer.IronSelection.prototype = {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 /** 49 /**
50 * Sets the selection state for a given item to either selected or deselecte d. 50 * Sets the selection state for a given item to either selected or deselecte d.
51 * 51 *
52 * @method setItemSelected 52 * @method setItemSelected
53 * @param {*} item The item to select. 53 * @param {*} item The item to select.
54 * @param {boolean} isSelected True for selected, false for deselected. 54 * @param {boolean} isSelected True for selected, false for deselected.
55 */ 55 */
56 setItemSelected: function(item, isSelected) { 56 setItemSelected: function(item, isSelected) {
57 if (item != null) { 57 if (item != null) {
58 if (isSelected) { 58 if (isSelected !== this.isSelected(item)) {
59 this.selection.push(item); 59 // proceed to update selection only if requested state differs from cu rrent
60 } else { 60 if (isSelected) {
61 var i = this.selection.indexOf(item); 61 this.selection.push(item);
62 if (i >= 0) { 62 } else {
63 this.selection.splice(i, 1); 63 var i = this.selection.indexOf(item);
64 if (i >= 0) {
65 this.selection.splice(i, 1);
66 }
64 } 67 }
65 } 68 if (this.selectCallback) {
66 if (this.selectCallback) { 69 this.selectCallback(item, isSelected);
67 this.selectCallback(item, isSelected); 70 }
68 } 71 }
69 } 72 }
70 }, 73 },
71 74
72 /** 75 /**
73 * Sets the selection state for a given item. If the `multi` property 76 * Sets the selection state for a given item. If the `multi` property
74 * is true, then the selected state of `item` will be toggled; otherwise 77 * is true, then the selected state of `item` will be toggled; otherwise
75 * the `item` will be selected. 78 * the `item` will be selected.
76 * 79 *
77 * @method select 80 * @method select
(...skipping 12 matching lines...) Expand all
90 * Toggles the selection state for `item`. 93 * Toggles the selection state for `item`.
91 * 94 *
92 * @method toggle 95 * @method toggle
93 * @param {*} item The item to toggle. 96 * @param {*} item The item to toggle.
94 */ 97 */
95 toggle: function(item) { 98 toggle: function(item) {
96 this.setItemSelected(item, !this.isSelected(item)); 99 this.setItemSelected(item, !this.isSelected(item));
97 } 100 }
98 101
99 }; 102 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698