polymer-paper-elements-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +51 -0
  3. data/Rakefile +1 -0
  4. data/app/assets/components/iron-a11y-announcer/iron-a11y-announcer.html +125 -0
  5. data/app/assets/components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html +418 -0
  6. data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
  7. data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
  8. data/app/assets/components/iron-behaviors/iron-button-state.html +195 -0
  9. data/app/assets/components/iron-behaviors/iron-control-state.html +102 -0
  10. data/app/assets/components/iron-fit-behavior/iron-fit-behavior.html +230 -0
  11. data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
  12. data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
  13. data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
  14. data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
  15. data/app/assets/components/iron-icon/hero.svg +19 -0
  16. data/app/assets/components/iron-icon/iron-icon.html +187 -0
  17. data/app/assets/components/iron-icons/av-icons.html +73 -0
  18. data/app/assets/components/iron-icons/communication-icons.html +59 -0
  19. data/app/assets/components/iron-icons/device-icons.html +94 -0
  20. data/app/assets/components/iron-icons/editor-icons.html +70 -0
  21. data/app/assets/components/iron-icons/hardware-icons.html +61 -0
  22. data/app/assets/components/iron-icons/hero.svg +35 -0
  23. data/app/assets/components/iron-icons/image-icons.html +164 -0
  24. data/app/assets/components/iron-icons/iron-icons.html +303 -0
  25. data/app/assets/components/iron-icons/maps-icons.html +71 -0
  26. data/app/assets/components/iron-icons/notification-icons.html +62 -0
  27. data/app/assets/components/iron-icons/social-icons.html +40 -0
  28. data/app/assets/components/iron-iconset-svg/iron-iconset-svg.html +191 -0
  29. data/app/assets/components/iron-input/hero.svg +19 -0
  30. data/app/assets/components/iron-input/iron-input.html +235 -0
  31. data/app/assets/components/iron-media-query/hero.svg +29 -0
  32. data/app/assets/components/iron-media-query/iron-media-query.html +84 -0
  33. data/app/assets/components/iron-menu-behavior/iron-menu-behavior.html +214 -0
  34. data/app/assets/components/iron-menu-behavior/iron-menubar-behavior.html +65 -0
  35. data/app/assets/components/iron-meta/hero.svg +33 -0
  36. data/app/assets/components/iron-meta/iron-meta.html +352 -0
  37. data/app/assets/components/iron-overlay-behavior/iron-overlay-backdrop.html +132 -0
  38. data/app/assets/components/iron-overlay-behavior/iron-overlay-behavior.html +432 -0
  39. data/app/assets/components/iron-overlay-behavior/iron-overlay-manager.html +107 -0
  40. data/app/assets/components/iron-range-behavior/iron-range-behavior.html +101 -0
  41. data/app/assets/components/iron-resizable-behavior/iron-resizable-behavior.html +139 -0
  42. data/app/assets/components/iron-selector/iron-multi-selectable.html +120 -0
  43. data/app/assets/components/iron-selector/iron-selectable.html +307 -0
  44. data/app/assets/components/iron-selector/iron-selection.html +115 -0
  45. data/app/assets/components/iron-selector/iron-selector.html +71 -0
  46. data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +100 -0
  47. data/app/assets/components/neon-animation/animations/cascaded-animation.html +84 -0
  48. data/app/assets/components/neon-animation/animations/fade-in-animation.html +49 -0
  49. data/app/assets/components/neon-animation/animations/fade-out-animation.html +49 -0
  50. data/app/assets/components/neon-animation/animations/hero-animation.html +83 -0
  51. data/app/assets/components/neon-animation/animations/opaque-animation.html +46 -0
  52. data/app/assets/components/neon-animation/animations/ripple-animation.html +92 -0
  53. data/app/assets/components/neon-animation/animations/scale-down-animation.html +65 -0
  54. data/app/assets/components/neon-animation/animations/scale-up-animation.html +58 -0
  55. data/app/assets/components/neon-animation/animations/slide-down-animation.html +59 -0
  56. data/app/assets/components/neon-animation/animations/slide-from-left-animation.html +60 -0
  57. data/app/assets/components/neon-animation/animations/slide-from-right-animation.html +60 -0
  58. data/app/assets/components/neon-animation/animations/slide-left-animation.html +59 -0
  59. data/app/assets/components/neon-animation/animations/slide-right-animation.html +59 -0
  60. data/app/assets/components/neon-animation/animations/slide-up-animation.html +59 -0
  61. data/app/assets/components/neon-animation/animations/transform-animation.html +61 -0
  62. data/app/assets/components/neon-animation/guides/neon-animation.md +313 -0
  63. data/app/assets/components/neon-animation/neon-animatable-behavior.html +156 -0
  64. data/app/assets/components/neon-animation/neon-animatable.html +54 -0
  65. data/app/assets/components/neon-animation/neon-animated-pages.html +208 -0
  66. data/app/assets/components/neon-animation/neon-animation-behavior.html +88 -0
  67. data/app/assets/components/neon-animation/neon-animation-runner-behavior.html +110 -0
  68. data/app/assets/components/neon-animation/neon-animation.html +17 -0
  69. data/app/assets/components/neon-animation/neon-animations.html +25 -0
  70. data/app/assets/components/neon-animation/neon-shared-element-animatable-behavior.html +37 -0
  71. data/app/assets/components/neon-animation/neon-shared-element-animation-behavior.html +66 -0
  72. data/app/assets/components/neon-animation/web-animations.html +11 -0
  73. data/app/assets/components/paper-behaviors/paper-button-behavior.html +55 -0
  74. data/app/assets/components/paper-behaviors/paper-inky-focus-behavior.html +44 -0
  75. data/app/assets/components/paper-button/paper-button.html +177 -0
  76. data/app/assets/components/paper-checkbox/metadata.html +17 -0
  77. data/app/assets/components/paper-checkbox/paper-checkbox.css +149 -0
  78. data/app/assets/components/paper-checkbox/paper-checkbox.html +163 -0
  79. data/app/assets/components/paper-dialog-behavior/hero.svg +51 -0
  80. data/app/assets/components/paper-dialog-behavior/paper-dialog-behavior.html +236 -0
  81. data/app/assets/components/paper-dialog-behavior/paper-dialog-common.css +58 -0
  82. data/app/assets/components/paper-dialog-scrollable/hero.svg +69 -0
  83. data/app/assets/components/paper-dialog-scrollable/paper-dialog-scrollable.html +150 -0
  84. data/app/assets/components/paper-dialog/hero.svg +58 -0
  85. data/app/assets/components/paper-dialog/paper-dialog.html +122 -0
  86. data/app/assets/components/paper-drawer-panel/hero.svg +21 -0
  87. data/app/assets/components/paper-drawer-panel/paper-drawer-panel.css +142 -0
  88. data/app/assets/components/paper-drawer-panel/paper-drawer-panel.html +585 -0
  89. data/app/assets/components/paper-fab/paper-fab.html +159 -0
  90. data/app/assets/components/paper-header-panel/hero.svg +38 -0
  91. data/app/assets/components/paper-header-panel/paper-header-panel.html +496 -0
  92. data/app/assets/components/paper-icon-button/paper-icon-button.html +141 -0
  93. data/app/assets/components/paper-input/all-imports.html +12 -0
  94. data/app/assets/components/paper-input/hero.svg +19 -0
  95. data/app/assets/components/paper-input/paper-input-addon-behavior.html +43 -0
  96. data/app/assets/components/paper-input/paper-input-behavior.html +293 -0
  97. data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
  98. data/app/assets/components/paper-input/paper-input-container.html +495 -0
  99. data/app/assets/components/paper-input/paper-input-error.html +99 -0
  100. data/app/assets/components/paper-input/paper-input.html +126 -0
  101. data/app/assets/components/paper-input/paper-textarea.html +100 -0
  102. data/app/assets/components/paper-item/all-imports.html +13 -0
  103. data/app/assets/components/paper-item/paper-icon-item.html +86 -0
  104. data/app/assets/components/paper-item/paper-item-body.html +93 -0
  105. data/app/assets/components/paper-item/paper-item-shared.css +19 -0
  106. data/app/assets/components/paper-item/paper-item.html +95 -0
  107. data/app/assets/components/paper-material/paper-material.html +98 -0
  108. data/app/assets/components/paper-menu/hero.svg +35 -0
  109. data/app/assets/components/paper-menu/paper-menu.html +133 -0
  110. data/app/assets/components/paper-progress/hero.svg +21 -0
  111. data/app/assets/components/paper-progress/paper-progress.html +199 -0
  112. data/app/assets/components/paper-radio-button/hero.svg +22 -0
  113. data/app/assets/components/paper-radio-button/paper-radio-button.css +109 -0
  114. data/app/assets/components/paper-radio-button/paper-radio-button.html +148 -0
  115. data/app/assets/components/paper-radio-group/hero.svg +25 -0
  116. data/app/assets/components/paper-radio-group/paper-radio-group.html +186 -0
  117. data/app/assets/components/paper-ripple/hero.svg +30 -0
  118. data/app/assets/components/paper-ripple/paper-ripple.html +714 -0
  119. data/app/assets/components/paper-scroll-header-panel/hero.svg +41 -0
  120. data/app/assets/components/paper-scroll-header-panel/paper-scroll-header-panel.html +455 -0
  121. data/app/assets/components/paper-slider/hero.svg +20 -0
  122. data/app/assets/components/paper-slider/paper-slider.css +252 -0
  123. data/app/assets/components/paper-slider/paper-slider.html +449 -0
  124. data/app/assets/components/paper-spinner/hero.svg +27 -0
  125. data/app/assets/components/paper-spinner/paper-spinner.css +325 -0
  126. data/app/assets/components/paper-spinner/paper-spinner.html +222 -0
  127. data/app/assets/components/paper-styles/classes/global.html +96 -0
  128. data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
  129. data/app/assets/components/paper-styles/classes/shadow.html +39 -0
  130. data/app/assets/components/paper-styles/classes/typography.html +171 -0
  131. data/app/assets/components/paper-styles/color.html +333 -0
  132. data/app/assets/components/paper-styles/default-theme.html +39 -0
  133. data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
  134. data/app/assets/components/paper-styles/paper-styles.html +17 -0
  135. data/app/assets/components/paper-styles/shadow.html +61 -0
  136. data/app/assets/components/paper-styles/typography.html +240 -0
  137. data/app/assets/components/paper-tabs/hero.svg +23 -0
  138. data/app/assets/components/paper-tabs/paper-tab.html +158 -0
  139. data/app/assets/components/paper-tabs/paper-tabs-icons.html +18 -0
  140. data/app/assets/components/paper-tabs/paper-tabs.html +483 -0
  141. data/app/assets/components/paper-toast/hero.svg +20 -0
  142. data/app/assets/components/paper-toast/paper-toast.html +164 -0
  143. data/app/assets/components/paper-toggle-button/hero.svg +22 -0
  144. data/app/assets/components/paper-toggle-button/paper-toggle-button.css +108 -0
  145. data/app/assets/components/paper-toggle-button/paper-toggle-button.html +183 -0
  146. data/app/assets/components/paper-toolbar/paper-toolbar.html +375 -0
  147. data/app/assets/components/polymer-gestures/Gruntfile.js +60 -0
  148. data/app/assets/components/polymer-gestures/banner.txt +9 -0
  149. data/app/assets/components/polymer-gestures/build.json +17 -0
  150. data/app/assets/components/polymer-gestures/conf/karma.conf.js +39 -0
  151. data/app/assets/components/polymer-gestures/package.json +20 -0
  152. data/app/assets/components/polymer-gestures/polymer-gestures.html +21 -0
  153. data/app/assets/components/polymer-gestures/polymer-gestures.js +46 -0
  154. data/app/assets/components/polymer-gestures/src/dispatcher.js +474 -0
  155. data/app/assets/components/polymer-gestures/src/eventFactory.js +127 -0
  156. data/app/assets/components/polymer-gestures/src/hold.js +129 -0
  157. data/app/assets/components/polymer-gestures/src/mouse.js +135 -0
  158. data/app/assets/components/polymer-gestures/src/ms.js +80 -0
  159. data/app/assets/components/polymer-gestures/src/pinch.js +186 -0
  160. data/app/assets/components/polymer-gestures/src/platform-events.js +39 -0
  161. data/app/assets/components/polymer-gestures/src/pointer.js +68 -0
  162. data/app/assets/components/polymer-gestures/src/pointermap.js +67 -0
  163. data/app/assets/components/polymer-gestures/src/scope.js +10 -0
  164. data/app/assets/components/polymer-gestures/src/tap.js +103 -0
  165. data/app/assets/components/polymer-gestures/src/targetfind.js +244 -0
  166. data/app/assets/components/polymer-gestures/src/touch-action.js +60 -0
  167. data/app/assets/components/polymer-gestures/src/touch.js +341 -0
  168. data/app/assets/components/polymer-gestures/src/track.js +230 -0
  169. data/app/assets/components/web-animations-js/web-animations-next-lite.min.js +17 -0
  170. data/app/assets/components/web-animations-js/web-animations-next.min.js +17 -0
  171. data/app/assets/components/web-animations-js/web-animations.min.js +17 -0
  172. data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
  173. data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
  174. data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
  175. data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
  176. data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
  177. data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
  178. data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
  179. data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
  180. data/app/assets/components/webcomponentsjs/package.json +31 -0
  181. data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
  182. data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
  183. data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
  184. data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
  185. data/lib/polymer-paper-elements-rails.rb +2 -0
  186. data/lib/polymer-paper-elements-rails/engine.rb +4 -0
  187. data/lib/polymer-paper-elements-rails/version.rb +3 -0
  188. metadata +272 -0
@@ -0,0 +1,307 @@
1
+ <!--
2
+ Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
3
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6
+ Code distributed by Google as part of the polymer project is also
7
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8
+ -->
9
+
10
+ <link rel="import" href="../polymer/polymer.html">
11
+ <link rel="import" href="iron-selection.html">
12
+
13
+ <script>
14
+
15
+ /** @polymerBehavior */
16
+ Polymer.IronSelectableBehavior = {
17
+
18
+ properties: {
19
+
20
+ /**
21
+ * If you want to use the attribute value of an element for `selected` instead of the index,
22
+ * set this to the name of the attribute.
23
+ *
24
+ * @attribute attrForSelected
25
+ * @type {string}
26
+ */
27
+ attrForSelected: {
28
+ type: String,
29
+ value: null
30
+ },
31
+
32
+ /**
33
+ * Gets or sets the selected element. The default is to use the index of the item.
34
+ *
35
+ * @attribute selected
36
+ * @type {string}
37
+ */
38
+ selected: {
39
+ type: String,
40
+ notify: true
41
+ },
42
+
43
+ /**
44
+ * Returns the currently selected item.
45
+ *
46
+ * @attribute selectedItem
47
+ * @type {Object}
48
+ */
49
+ selectedItem: {
50
+ type: Object,
51
+ readOnly: true,
52
+ notify: true
53
+ },
54
+
55
+ /**
56
+ * The event that fires from items when they are selected. Selectable
57
+ * will listen for this event from items and update the selection state.
58
+ * Set to empty string to listen to no events.
59
+ *
60
+ * @attribute activateEvent
61
+ * @type {string}
62
+ * @default 'tap'
63
+ */
64
+ activateEvent: {
65
+ type: String,
66
+ value: 'tap',
67
+ observer: '_activateEventChanged'
68
+ },
69
+
70
+ /**
71
+ * This is a CSS selector sting. If this is set, only items that matches the CSS selector
72
+ * are selectable.
73
+ *
74
+ * @attribute selectable
75
+ * @type {string}
76
+ */
77
+ selectable: String,
78
+
79
+ /**
80
+ * The class to set on elements when selected.
81
+ *
82
+ * @attribute selectedClass
83
+ * @type {string}
84
+ */
85
+ selectedClass: {
86
+ type: String,
87
+ value: 'iron-selected'
88
+ },
89
+
90
+ /**
91
+ * The attribute to set on elements when selected.
92
+ *
93
+ * @attribute selectedAttribute
94
+ * @type {string}
95
+ */
96
+ selectedAttribute: {
97
+ type: String,
98
+ value: null
99
+ }
100
+
101
+ },
102
+
103
+ observers: [
104
+ '_updateSelected(attrForSelected, selected)'
105
+ ],
106
+
107
+ excludedLocalNames: {
108
+ 'template': 1
109
+ },
110
+
111
+ created: function() {
112
+ this._bindFilterItem = this._filterItem.bind(this);
113
+ this._selection = new Polymer.IronSelection(this._applySelection.bind(this));
114
+ },
115
+
116
+ attached: function() {
117
+ this._observer = this._observeItems(this);
118
+ this._contentObserver = this._observeContent(this);
119
+ },
120
+
121
+ detached: function() {
122
+ if (this._observer) {
123
+ this._observer.disconnect();
124
+ }
125
+ if (this._contentObserver) {
126
+ this._contentObserver.disconnect();
127
+ }
128
+ this._removeListener(this.activateEvent);
129
+ },
130
+
131
+ /**
132
+ * Returns an array of selectable items.
133
+ *
134
+ * @property items
135
+ * @type Array
136
+ */
137
+ get items() {
138
+ var nodes = Polymer.dom(this).queryDistributedElements(this.selectable || '*');
139
+ return Array.prototype.filter.call(nodes, this._bindFilterItem);
140
+ },
141
+
142
+ /**
143
+ * Returns the index of the given item.
144
+ *
145
+ * @method indexOf
146
+ * @param {Object} item
147
+ * @returns Returns the index of the item
148
+ */
149
+ indexOf: function(item) {
150
+ return this.items.indexOf(item);
151
+ },
152
+
153
+ /**
154
+ * Selects the given value.
155
+ *
156
+ * @method select
157
+ * @param {string} value the value to select.
158
+ */
159
+ select: function(value) {
160
+ this.selected = value;
161
+ },
162
+
163
+ /**
164
+ * Selects the previous item.
165
+ *
166
+ * @method selectPrevious
167
+ */
168
+ selectPrevious: function() {
169
+ var length = this.items.length;
170
+ var index = (Number(this._valueToIndex(this.selected)) - 1 + length) % length;
171
+ this.selected = this._indexToValue(index);
172
+ },
173
+
174
+ /**
175
+ * Selects the next item.
176
+ *
177
+ * @method selectNext
178
+ */
179
+ selectNext: function() {
180
+ var index = (Number(this._valueToIndex(this.selected)) + 1) % this.items.length;
181
+ this.selected = this._indexToValue(index);
182
+ },
183
+
184
+ _addListener: function(eventName) {
185
+ this.listen(this, eventName, '_activateHandler');
186
+ },
187
+
188
+ _removeListener: function(eventName) {
189
+ // There is no unlisten yet...
190
+ // https://github.com/Polymer/polymer/issues/1639
191
+ //this.removeEventListener(eventName, this._bindActivateHandler);
192
+ },
193
+
194
+ _activateEventChanged: function(eventName, old) {
195
+ this._removeListener(old);
196
+ this._addListener(eventName);
197
+ },
198
+
199
+ _updateSelected: function() {
200
+ this._selectSelected(this.selected);
201
+ },
202
+
203
+ _selectSelected: function(selected) {
204
+ this._selection.select(this._valueToItem(this.selected));
205
+ },
206
+
207
+ _filterItem: function(node) {
208
+ return !this.excludedLocalNames[node.localName];
209
+ },
210
+
211
+ _valueToItem: function(value) {
212
+ return (value == null) ? null : this.items[this._valueToIndex(value)];
213
+ },
214
+
215
+ _valueToIndex: function(value) {
216
+ if (this.attrForSelected) {
217
+ for (var i = 0, item; item = this.items[i]; i++) {
218
+ if (this._valueForItem(item) == value) {
219
+ return i;
220
+ }
221
+ }
222
+ } else {
223
+ return Number(value);
224
+ }
225
+ },
226
+
227
+ _indexToValue: function(index) {
228
+ if (this.attrForSelected) {
229
+ var item = this.items[index];
230
+ if (item) {
231
+ return this._valueForItem(item);
232
+ }
233
+ } else {
234
+ return index;
235
+ }
236
+ },
237
+
238
+ _valueForItem: function(item) {
239
+ return item[this.attrForSelected] || item.getAttribute(this.attrForSelected);
240
+ },
241
+
242
+ _applySelection: function(item, isSelected) {
243
+ if (this.selectedClass) {
244
+ this.toggleClass(this.selectedClass, isSelected, item);
245
+ }
246
+ if (this.selectedAttribute) {
247
+ this.toggleAttribute(this.selectedAttribute, isSelected, item);
248
+ }
249
+ this._selectionChange();
250
+ this.fire('iron-' + (isSelected ? 'select' : 'deselect'), {item: item});
251
+ },
252
+
253
+ _selectionChange: function() {
254
+ this._setSelectedItem(this._selection.get());
255
+ },
256
+
257
+ // observe content changes under the given node.
258
+ _observeContent: function(node) {
259
+ var content = node.querySelector('content');
260
+ if (content && content.parentElement === node) {
261
+ return this._observeItems(node.domHost);
262
+ }
263
+ },
264
+
265
+ // observe items change under the given node.
266
+ _observeItems: function(node) {
267
+ var observer = new MutationObserver(function() {
268
+ if (this.selected != null) {
269
+ this._updateSelected();
270
+ }
271
+ }.bind(this));
272
+ observer.observe(node, {
273
+ childList: true,
274
+ subtree: true
275
+ });
276
+ return observer;
277
+ },
278
+
279
+ _activateHandler: function(e) {
280
+ // TODO: remove this when https://github.com/Polymer/polymer/issues/1639 is fixed so we
281
+ // can just remove the old event listener.
282
+ if (e.type !== this.activateEvent) {
283
+ return;
284
+ }
285
+ var t = e.target;
286
+ var items = this.items;
287
+ while (t && t != this) {
288
+ var i = items.indexOf(t);
289
+ if (i >= 0) {
290
+ var value = this._indexToValue(i);
291
+ this._itemActivate(value, t);
292
+ return;
293
+ }
294
+ t = t.parentNode;
295
+ }
296
+ },
297
+
298
+ _itemActivate: function(value, item) {
299
+ if (!this.fire('iron-activate',
300
+ {selected: value, item: item}, {cancelable: true}).defaultPrevented) {
301
+ this.select(value);
302
+ }
303
+ }
304
+
305
+ };
306
+
307
+ </script>
@@ -0,0 +1,115 @@
1
+
2
+ <!--
3
+ Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
+ Code distributed by Google as part of the polymer project is also
8
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
+ -->
10
+
11
+ <link rel="import" href="../polymer/polymer.html">
12
+
13
+ <script>
14
+
15
+ /**
16
+ * @param {!Function} selectCallback
17
+ * @constructor
18
+ */
19
+ Polymer.IronSelection = function(selectCallback) {
20
+ this.selection = [];
21
+ this.selectCallback = selectCallback;
22
+ };
23
+
24
+ Polymer.IronSelection.prototype = {
25
+
26
+ /**
27
+ * Retrieves the selected item(s).
28
+ *
29
+ * @method get
30
+ * @returns Returns the selected item(s). If the multi property is true,
31
+ * `get` will return an array, otherwise it will return
32
+ * the selected item or undefined if there is no selection.
33
+ */
34
+ get: function() {
35
+ return this.multi ? this.selection : this.selection[0];
36
+ },
37
+
38
+ /**
39
+ * Clears all the selection except the ones indicated.
40
+ *
41
+ * @method clear
42
+ * @param {Array} excludes items to be excluded.
43
+ */
44
+ clear: function(excludes) {
45
+ this.selection.slice().forEach(function(item) {
46
+ if (!excludes || excludes.indexOf(item) < 0) {
47
+ this.setItemSelected(item, false);
48
+ }
49
+ }, this);
50
+ },
51
+
52
+ /**
53
+ * Indicates if a given item is selected.
54
+ *
55
+ * @method isSelected
56
+ * @param {*} item The item whose selection state should be checked.
57
+ * @returns Returns true if `item` is selected.
58
+ */
59
+ isSelected: function(item) {
60
+ return this.selection.indexOf(item) >= 0;
61
+ },
62
+
63
+ /**
64
+ * Sets the selection state for a given item to either selected or deselected.
65
+ *
66
+ * @method setItemSelected
67
+ * @param {*} item The item to select.
68
+ * @param {boolean} isSelected True for selected, false for deselected.
69
+ */
70
+ setItemSelected: function(item, isSelected) {
71
+ if (item != null) {
72
+ if (isSelected) {
73
+ this.selection.push(item);
74
+ } else {
75
+ var i = this.selection.indexOf(item);
76
+ if (i >= 0) {
77
+ this.selection.splice(i, 1);
78
+ }
79
+ }
80
+ if (this.selectCallback) {
81
+ this.selectCallback(item, isSelected);
82
+ }
83
+ }
84
+ },
85
+
86
+ /**
87
+ * Sets the selection state for a given item. If the `multi` property
88
+ * is true, then the selected state of `item` will be toggled; otherwise
89
+ * the `item` will be selected.
90
+ *
91
+ * @method select
92
+ * @param {*} item The item to select.
93
+ */
94
+ select: function(item) {
95
+ if (this.multi) {
96
+ this.toggle(item);
97
+ } else if (this.get() !== item) {
98
+ this.setItemSelected(this.get(), false);
99
+ this.setItemSelected(item, true);
100
+ }
101
+ },
102
+
103
+ /**
104
+ * Toggles the selection state for `item`.
105
+ *
106
+ * @method toggle
107
+ * @param {*} item The item to toggle.
108
+ */
109
+ toggle: function(item) {
110
+ this.setItemSelected(item, !this.isSelected(item));
111
+ }
112
+
113
+ };
114
+
115
+ </script>
@@ -0,0 +1,71 @@
1
+ <!--
2
+ Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
3
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6
+ Code distributed by Google as part of the polymer project is also
7
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8
+ -->
9
+
10
+
11
+ <link rel="import" href="../polymer/polymer.html">
12
+ <link rel="import" href="iron-multi-selectable.html">
13
+
14
+ <script>
15
+ /**
16
+ `iron-selector` is an element which can be used to manage a list of elements
17
+ that can be selected. Tapping on the item will make the item selected. The `selected` indicates
18
+ which item is being selected. The default is to use the index of the item.
19
+
20
+ Example:
21
+
22
+ <iron-selector selected="0">
23
+ <div>Item 1</div>
24
+ <div>Item 2</div>
25
+ <div>Item 3</div>
26
+ </iron-selector>
27
+
28
+ If you want to use the attribute value of an element for `selected` instead of the index,
29
+ set `attrForSelected` to the name of the attribute. For example, if you want to select item by
30
+ `name`, set `attrForSelected` to `name`.
31
+
32
+ Example:
33
+
34
+ <iron-selector attr-for-selected="name" selected="foo">
35
+ <div name="foo">Foo</div>
36
+ <div name="bar">Bar</div>
37
+ <div name="zot">Zot</div>
38
+ </iron-selector>
39
+
40
+ `iron-selector` is not styled. Use the `iron-selected` CSS class to style the selected element.
41
+
42
+ Example:
43
+
44
+ <style>
45
+ .iron-selected {
46
+ background: #eee;
47
+ }
48
+ </style>
49
+
50
+ ...
51
+
52
+ <iron-selector selected="0">
53
+ <div>Item 1</div>
54
+ <div>Item 2</div>
55
+ <div>Item 3</div>
56
+ </iron-selector>
57
+
58
+ @demo demo/index.html
59
+ */
60
+
61
+ Polymer({
62
+
63
+ is: 'iron-selector',
64
+
65
+ behaviors: [
66
+ Polymer.IronMultiSelectableBehavior
67
+ ]
68
+
69
+ });
70
+
71
+ </script>