polymer-neon-rails 1.0.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +39 -0
  3. data/Rakefile +1 -0
  4. data/app/assets/components/iron-flex-layout/README.md +4 -0
  5. data/app/assets/components/iron-flex-layout/bower.json +21 -0
  6. data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
  7. data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
  8. data/app/assets/components/iron-flex-layout/demo/index.html +40 -0
  9. data/app/assets/components/iron-flex-layout/demo/x-app.html +106 -0
  10. data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
  11. data/app/assets/components/iron-meta/README.md +46 -0
  12. data/app/assets/components/iron-meta/bower.json +28 -0
  13. data/app/assets/components/iron-meta/demo/index.html +45 -0
  14. data/app/assets/components/iron-meta/hero.svg +33 -0
  15. data/app/assets/components/iron-meta/index.html +27 -0
  16. data/app/assets/components/iron-meta/iron-meta.html +352 -0
  17. data/app/assets/components/iron-meta/test/basic.html +48 -0
  18. data/app/assets/components/iron-meta/test/index.html +30 -0
  19. data/app/assets/components/iron-meta/test/iron-meta.html +186 -0
  20. data/app/assets/components/iron-resizable-behavior/README.md +16 -0
  21. data/app/assets/components/iron-resizable-behavior/bower.json +26 -0
  22. data/app/assets/components/iron-resizable-behavior/demo/index.html +29 -0
  23. data/app/assets/components/iron-resizable-behavior/demo/src/x-app.html +114 -0
  24. data/app/assets/components/iron-resizable-behavior/index.html +25 -0
  25. data/app/assets/components/iron-resizable-behavior/iron-resizable-behavior.html +139 -0
  26. data/app/assets/components/iron-resizable-behavior/test/basic.html +263 -0
  27. data/app/assets/components/iron-resizable-behavior/test/index.html +31 -0
  28. data/app/assets/components/iron-resizable-behavior/test/test-elements.html +143 -0
  29. data/app/assets/components/iron-selector/README.md +50 -0
  30. data/app/assets/components/iron-selector/bower.json +31 -0
  31. data/app/assets/components/iron-selector/demo/index.html +66 -0
  32. data/app/assets/components/iron-selector/index.html +28 -0
  33. data/app/assets/components/iron-selector/iron-multi-selectable.html +120 -0
  34. data/app/assets/components/iron-selector/iron-selectable.html +307 -0
  35. data/app/assets/components/iron-selector/iron-selection.html +115 -0
  36. data/app/assets/components/iron-selector/iron-selector.html +71 -0
  37. data/app/assets/components/iron-selector/test/activate-event.html +138 -0
  38. data/app/assets/components/iron-selector/test/basic.html +150 -0
  39. data/app/assets/components/iron-selector/test/content-element.html +43 -0
  40. data/app/assets/components/iron-selector/test/content.html +168 -0
  41. data/app/assets/components/iron-selector/test/index.html +36 -0
  42. data/app/assets/components/iron-selector/test/multi.html +135 -0
  43. data/app/assets/components/iron-selector/test/next-previous.html +134 -0
  44. data/app/assets/components/iron-selector/test/selected-attribute.html +72 -0
  45. data/app/assets/components/iron-selector/test/template-repeat.html +110 -0
  46. data/app/assets/components/neon-animation/README.md +304 -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/bower.json +51 -0
  63. data/app/assets/components/neon-animation/demo/declarative/index.html +108 -0
  64. data/app/assets/components/neon-animation/demo/doc/basic.html +47 -0
  65. data/app/assets/components/neon-animation/demo/doc/my-animatable.html +73 -0
  66. data/app/assets/components/neon-animation/demo/doc/my-dialog.html +97 -0
  67. data/app/assets/components/neon-animation/demo/doc/types.html +53 -0
  68. data/app/assets/components/neon-animation/demo/dropdown/animated-dropdown.html +97 -0
  69. data/app/assets/components/neon-animation/demo/dropdown/index.html +54 -0
  70. data/app/assets/components/neon-animation/demo/grid/animated-grid.html +166 -0
  71. data/app/assets/components/neon-animation/demo/grid/fullsize-page-with-card.html +124 -0
  72. data/app/assets/components/neon-animation/demo/grid/index.html +70 -0
  73. data/app/assets/components/neon-animation/demo/index.html +6 -0
  74. data/app/assets/components/neon-animation/demo/list/full-view.html +122 -0
  75. data/app/assets/components/neon-animation/demo/list/index.html +29 -0
  76. data/app/assets/components/neon-animation/demo/list/list-demo.html +112 -0
  77. data/app/assets/components/neon-animation/demo/list/list-view.html +127 -0
  78. data/app/assets/components/neon-animation/demo/load/animated-grid.html +147 -0
  79. data/app/assets/components/neon-animation/demo/load/full-page.html +86 -0
  80. data/app/assets/components/neon-animation/demo/load/index.html +45 -0
  81. data/app/assets/components/neon-animation/demo/reprojection/animated-grid.html +166 -0
  82. data/app/assets/components/neon-animation/demo/reprojection/fullsize-page-with-card.html +124 -0
  83. data/app/assets/components/neon-animation/demo/reprojection/index.html +66 -0
  84. data/app/assets/components/neon-animation/demo/reprojection/reprojected-pages.html +42 -0
  85. data/app/assets/components/neon-animation/demo/shared.css +40 -0
  86. data/app/assets/components/neon-animation/demo/tiles/circles-page.html +110 -0
  87. data/app/assets/components/neon-animation/demo/tiles/index.html +77 -0
  88. data/app/assets/components/neon-animation/demo/tiles/squares-page.html +104 -0
  89. data/app/assets/components/neon-animation/guides/neon-animation.md +313 -0
  90. data/app/assets/components/neon-animation/index.html +30 -0
  91. data/app/assets/components/neon-animation/neon-animatable-behavior.html +156 -0
  92. data/app/assets/components/neon-animation/neon-animatable.html +54 -0
  93. data/app/assets/components/neon-animation/neon-animated-pages.html +208 -0
  94. data/app/assets/components/neon-animation/neon-animation-behavior.html +88 -0
  95. data/app/assets/components/neon-animation/neon-animation-runner-behavior.html +110 -0
  96. data/app/assets/components/neon-animation/neon-animation.html +17 -0
  97. data/app/assets/components/neon-animation/neon-animations.html +25 -0
  98. data/app/assets/components/neon-animation/neon-shared-element-animatable-behavior.html +37 -0
  99. data/app/assets/components/neon-animation/neon-shared-element-animation-behavior.html +66 -0
  100. data/app/assets/components/neon-animation/web-animations.html +11 -0
  101. data/app/assets/components/neon-elements/README.md +19 -0
  102. data/app/assets/components/neon-elements/bower.json +26 -0
  103. data/app/assets/components/paper-styles/README.md +3 -0
  104. data/app/assets/components/paper-styles/bower.json +27 -0
  105. data/app/assets/components/paper-styles/classes/global.html +96 -0
  106. data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
  107. data/app/assets/components/paper-styles/classes/shadow.html +39 -0
  108. data/app/assets/components/paper-styles/classes/typography.html +171 -0
  109. data/app/assets/components/paper-styles/color.html +333 -0
  110. data/app/assets/components/paper-styles/default-theme.html +39 -0
  111. data/app/assets/components/paper-styles/demo-pages.html +72 -0
  112. data/app/assets/components/paper-styles/demo.css +25 -0
  113. data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
  114. data/app/assets/components/paper-styles/paper-styles.html +17 -0
  115. data/app/assets/components/paper-styles/shadow.html +61 -0
  116. data/app/assets/components/paper-styles/typography.html +240 -0
  117. data/app/assets/components/polymer/LICENSE.txt +27 -0
  118. data/app/assets/components/polymer/bower.json +26 -0
  119. data/app/assets/components/polymer/build.log +27 -0
  120. data/app/assets/components/polymer/polymer-micro.html +523 -0
  121. data/app/assets/components/polymer/polymer-mini.html +1368 -0
  122. data/app/assets/components/polymer/polymer.html +3768 -0
  123. data/app/assets/components/web-animations-js/COPYING +202 -0
  124. data/app/assets/components/web-animations-js/History.md +108 -0
  125. data/app/assets/components/web-animations-js/README.md +161 -0
  126. data/app/assets/components/web-animations-js/bower.json +31 -0
  127. data/app/assets/components/web-animations-js/web-animations-next-lite.min.js +17 -0
  128. data/app/assets/components/web-animations-js/web-animations-next-lite.min.js.map +1 -0
  129. data/app/assets/components/web-animations-js/web-animations-next.min.js +17 -0
  130. data/app/assets/components/web-animations-js/web-animations-next.min.js.map +1 -0
  131. data/app/assets/components/web-animations-js/web-animations.html +50 -0
  132. data/app/assets/components/web-animations-js/web-animations.min.js +17 -0
  133. data/app/assets/components/web-animations-js/web-animations.min.js.gz +0 -0
  134. data/app/assets/components/web-animations-js/web-animations.min.js.map +1 -0
  135. data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
  136. data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
  137. data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
  138. data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
  139. data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
  140. data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
  141. data/app/assets/components/webcomponentsjs/README.md +125 -0
  142. data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
  143. data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
  144. data/app/assets/components/webcomponentsjs/bower.json +14 -0
  145. data/app/assets/components/webcomponentsjs/build.log +33 -0
  146. data/app/assets/components/webcomponentsjs/package.json +31 -0
  147. data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
  148. data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
  149. data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
  150. data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
  151. data/lib/polymer-neon-rails.rb +2 -0
  152. data/lib/polymer-neon-rails/engine.rb +4 -0
  153. data/lib/polymer-neon-rails/version.rb +3 -0
  154. metadata +264 -0
@@ -0,0 +1,143 @@
1
+ <!--
2
+ @license
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
+ <link rel="import" href="../iron-resizable-behavior.html">
11
+
12
+ <script>
13
+
14
+ Polymer({
15
+
16
+ is: 'x-resizer-parent',
17
+
18
+ behaviors: [
19
+ Polymer.IronResizableBehavior
20
+ ],
21
+
22
+ listeners: {
23
+ 'core-resize': 'resizeHandler'
24
+ },
25
+
26
+ resizeHandler: function() {
27
+ }
28
+
29
+ });
30
+
31
+ </script>
32
+
33
+ <script>
34
+
35
+ Polymer({
36
+
37
+ is: 'x-resizer-parent-filtered',
38
+
39
+ active: null,
40
+
41
+ behaviors: [
42
+ Polymer.IronResizableBehavior
43
+ ],
44
+
45
+ listeners: {
46
+ 'core-resize': 'resizeHandler'
47
+ },
48
+
49
+ resizeHandler: function() {
50
+ },
51
+
52
+ resizerShouldNotify: function(el) {
53
+ return (el == this.active);
54
+ }
55
+
56
+ });
57
+
58
+ </script>
59
+
60
+ <script>
61
+
62
+ Polymer({
63
+
64
+ is: 'x-resizable',
65
+
66
+ behaviors: [
67
+ Polymer.IronResizableBehavior
68
+ ],
69
+
70
+ listeners: {
71
+ 'core-resize': 'resizeHandler'
72
+ },
73
+
74
+ resizeHandler: function() {
75
+ }
76
+
77
+ });
78
+
79
+ </script>
80
+
81
+ <dom-module id="x-resizable-in-shadow">
82
+
83
+ <template>
84
+
85
+ <div>
86
+ <x-resizable id="resizable"></x-resizable>
87
+ </div>
88
+
89
+ </template>
90
+
91
+ </dom-module>
92
+
93
+ <script>
94
+
95
+ Polymer({
96
+
97
+ is: 'x-resizable-in-shadow'
98
+
99
+ });
100
+
101
+ </script>
102
+
103
+ <dom-module id='test-element'>
104
+
105
+ <template>
106
+
107
+ <!-- Normal resizable parent with child resizables -->
108
+ <x-resizer-parent id="parent">
109
+ <x-resizable id="child1a"></x-resizable>
110
+ <div>
111
+ <x-resizable id="child1b"></x-resizable>
112
+ </div>
113
+ <x-resizable-in-shadow id="shadow1c"></x-resizable-in-shadow>
114
+ <div>
115
+ <x-resizable-in-shadow id="shadow1d"></x-resizable-in-shadow>
116
+ </div>
117
+ </x-resizer-parent>
118
+
119
+ <!-- Resizable parent using resizerShouldNotify, with child resizables -->
120
+ <x-resizer-parent-filtered id="parentFiltered">
121
+ <x-resizable id="child2a"></x-resizable>
122
+ <div>
123
+ <x-resizable id="child2b"></x-resizable>
124
+ </div>
125
+ <x-resizable-in-shadow id="shadow2c"></x-resizable-in-shadow>
126
+ <div>
127
+ <x-resizable-in-shadow id="shadow2d"></x-resizable-in-shadow>
128
+ </div>
129
+ </x-resizer-parent-filtered>
130
+
131
+ </template>
132
+
133
+ </dom-module>
134
+
135
+ <script>
136
+
137
+ Polymer({
138
+
139
+ is: 'test-element'
140
+
141
+ });
142
+
143
+ </script>
@@ -0,0 +1,50 @@
1
+ iron-selector
2
+ =============
3
+
4
+ `iron-selector` is an element which can be used to manage a list of elements
5
+ that can be selected. Tapping on the item will make the item selected. The `selected` indicates
6
+ which item is being selected. The default is to use the index of the item.
7
+
8
+ Example:
9
+
10
+ ```html
11
+ <iron-selector selected="0">
12
+ <div>Item 1</div>
13
+ <div>Item 2</div>
14
+ <div>Item 3</div>
15
+ </iron-selector>
16
+ ```
17
+
18
+ If you want to use the attribute value of an element for `selected` instead of the index,
19
+ set `attrForSelected` to the name of the attribute. For example, if you want to select item by
20
+ `name`, set `attrForSelected` to `name`.
21
+
22
+ Example:
23
+
24
+ ```html
25
+ <iron-selector attr-for-selected="name" selected="foo">
26
+ <div name="foo">Foo</div>
27
+ <div name="bar">Bar</div>
28
+ <div name="zot">Zot</div>
29
+ </iron-selector>
30
+ ```
31
+
32
+ `iron-selector` is not styled. Use the `iron-selected` CSS class to style the selected element.
33
+
34
+ Example:
35
+
36
+ ```html
37
+ <style>
38
+ .iron-selected {
39
+ background: #eee;
40
+ }
41
+ </style>
42
+
43
+ ...
44
+
45
+ <iron-selector selected="0">
46
+ <div>Item 1</div>
47
+ <div>Item 2</div>
48
+ <div>Item 3</div>
49
+ </iron-selector>
50
+ ```
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "iron-selector",
3
+ "version": "1.0.2",
4
+ "description": "Manages a set of elements that can be selected",
5
+ "private": true,
6
+ "license": "http://polymer.github.io/LICENSE.txt",
7
+ "main": [
8
+ "iron-selector.html"
9
+ ],
10
+ "authors": [
11
+ "The Polymer Authors"
12
+ ],
13
+ "keywords": [
14
+ "web-components",
15
+ "polymer",
16
+ "selector"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git://github.com/PolymerElements/iron-selector.git"
21
+ },
22
+ "dependencies": {
23
+ "polymer": "Polymer/polymer#^1.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
27
+ "test-fixture": "PolymerElements/test-fixture#^1.0.0",
28
+ "web-component-tester": "*",
29
+ "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
30
+ }
31
+ }
@@ -0,0 +1,66 @@
1
+ <!doctype html>
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
+ <html>
12
+ <head>
13
+
14
+ <title>iron-selector</title>
15
+
16
+ <meta charset="utf-8">
17
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
+
19
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
20
+ <link rel="import" href="../iron-selector.html">
21
+
22
+ <style>
23
+
24
+ iron-selector > * {
25
+ padding: 8px;
26
+ }
27
+
28
+ .iron-selected {
29
+ background-color: #ddd;
30
+ }
31
+
32
+ </style>
33
+
34
+ </head>
35
+ <body>
36
+
37
+ <h3>Basic</h3>
38
+
39
+ <iron-selector selected="0">
40
+ <div>Item 0</div>
41
+ <div>Item 1</div>
42
+ <div>Item 2</div>
43
+ <div>Item 3</div>
44
+ <div>Item 4</div>
45
+ </iron-selector>
46
+
47
+ <h3>Multi-select</h3>
48
+
49
+ <iron-selector multi selected-values='[0,2]'>
50
+ <div>Item 0</div>
51
+ <div>Item 1</div>
52
+ <div>Item 2</div>
53
+ <div>Item 3</div>
54
+ <div>Item 4</div>
55
+ </iron-selector>
56
+
57
+ <h3>Example</h3>
58
+
59
+ <iron-selector selected="foo" attr-for-selected="name">
60
+ <div name="foo">Foo</div>
61
+ <div name="bar">Bar</div>
62
+ <div name="zot">Zot</div>
63
+ </iron-selector>
64
+
65
+ </body>
66
+ </html>
@@ -0,0 +1,28 @@
1
+ <!doctype html>
2
+ <!--
3
+ @license
4
+ Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
+ Code distributed by Google as part of the polymer project is also
9
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
+ -->
11
+
12
+ <html>
13
+ <head>
14
+
15
+ <title>iron-selector</title>
16
+ <meta charset="utf-8">
17
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
+
19
+ <script src="../webcomponentsjs/webcomponents-lite.js"></script>
20
+ <link rel="import" href="../iron-component-page/iron-component-page.html">
21
+
22
+ </head>
23
+ <body>
24
+
25
+ <iron-component-page></iron-component-page>
26
+
27
+ </body>
28
+ </html>
@@ -0,0 +1,120 @@
1
+ <!--
2
+ @license
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
+ <link rel="import" href="iron-selectable.html">
13
+
14
+ <script>
15
+ /** @polymerBehavior Polymer.IronMultiSelectableBehavior */
16
+ Polymer.IronMultiSelectableBehaviorImpl = {
17
+ properties: {
18
+
19
+ /**
20
+ * If true, multiple selections are allowed.
21
+ */
22
+ multi: {
23
+ type: Boolean,
24
+ value: false,
25
+ observer: 'multiChanged'
26
+ },
27
+
28
+ /**
29
+ * Gets or sets the selected elements. This is used instead of `selected` when `multi`
30
+ * is true.
31
+ */
32
+ selectedValues: {
33
+ type: Array,
34
+ notify: true
35
+ },
36
+
37
+ /**
38
+ * Returns an array of currently selected items.
39
+ */
40
+ selectedItems: {
41
+ type: Array,
42
+ readOnly: true,
43
+ notify: true
44
+ },
45
+
46
+ },
47
+
48
+ observers: [
49
+ '_updateSelected(attrForSelected, selectedValues)'
50
+ ],
51
+
52
+ /**
53
+ * Selects the given value. If the `multi` property is true, then the selected state of the
54
+ * `value` will be toggled; otherwise the `value` will be selected.
55
+ *
56
+ * @method select
57
+ * @param {string} value the value to select.
58
+ */
59
+ select: function(value) {
60
+ if (this.multi) {
61
+ if (this.selectedValues) {
62
+ this._toggleSelected(value);
63
+ } else {
64
+ this.selectedValues = [value];
65
+ }
66
+ } else {
67
+ this.selected = value;
68
+ }
69
+ },
70
+
71
+ multiChanged: function(multi) {
72
+ this._selection.multi = multi;
73
+ },
74
+
75
+ _updateSelected: function() {
76
+ if (this.multi) {
77
+ this._selectMulti(this.selectedValues);
78
+ } else {
79
+ this._selectSelected(this.selected);
80
+ }
81
+ },
82
+
83
+ _selectMulti: function(values) {
84
+ this._selection.clear();
85
+ if (values) {
86
+ for (var i = 0; i < values.length; i++) {
87
+ this._selection.setItemSelected(this._valueToItem(values[i]), true);
88
+ }
89
+ }
90
+ },
91
+
92
+ _selectionChange: function() {
93
+ var s = this._selection.get();
94
+ if (this.multi) {
95
+ this._setSelectedItems(s);
96
+ } else {
97
+ this._setSelectedItems([s]);
98
+ this._setSelectedItem(s);
99
+ }
100
+ },
101
+
102
+ _toggleSelected: function(value) {
103
+ var i = this.selectedValues.indexOf(value);
104
+ var unselected = i < 0;
105
+ if (unselected) {
106
+ this.selectedValues.push(value);
107
+ } else {
108
+ this.selectedValues.splice(i, 1);
109
+ }
110
+ this._selection.setItemSelected(this._valueToItem(value), unselected);
111
+ }
112
+ };
113
+
114
+ /** @polymerBehavior */
115
+ Polymer.IronMultiSelectableBehavior = [
116
+ Polymer.IronSelectableBehavior,
117
+ Polymer.IronMultiSelectableBehaviorImpl
118
+ ];
119
+
120
+ </script>
@@ -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>