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,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>
@@ -0,0 +1,138 @@
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-activate-event</title>
15
+ <meta charset="UTF-8">
16
+
17
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
18
+ <script src="../../web-component-tester/browser.js"></script>
19
+ <script src="../../test-fixture/test-fixture-mocha.js"></script>
20
+
21
+ <link rel="import" href="../../test-fixture/test-fixture.html">
22
+ <link rel="import" href="../iron-selector.html">
23
+
24
+ <style>
25
+ .iron-selected {
26
+ background: #ccc;
27
+ }
28
+ </style>
29
+
30
+ </head>
31
+ <body>
32
+
33
+ <test-fixture id="test">
34
+ <template>
35
+ <iron-selector id="selector" selected="0">
36
+ <div>Item 0</div>
37
+ <div>Item 1</div>
38
+ <div>Item 2</div>
39
+ <div>Item 3</div>
40
+ <div>Item 4</div>
41
+ </iron-selector>
42
+ </template>
43
+ </test-fixture>
44
+
45
+ <script>
46
+
47
+ suite('activate event', function() {
48
+
49
+ var s;
50
+
51
+ setup(function () {
52
+ s = fixture('test');
53
+ });
54
+
55
+ test('activates on tap', function() {
56
+ assert.equal(s.selected, '0');
57
+
58
+ // select Item 1
59
+ s.children[1].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
60
+ assert.equal(s.selected, '1');
61
+ });
62
+
63
+ test('activates on tap and fires iron-activate', function(done) {
64
+ assert.equal(s.selected, '0');
65
+
66
+ // attach iron-activate listener
67
+ s.addEventListener("iron-activate", function(event) {
68
+ assert.equal(event.detail.selected, '1');
69
+ assert.equal(event.detail.item, s.children[1]);
70
+ done();
71
+ });
72
+
73
+ // select Item 1
74
+ s.children[1].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
75
+ });
76
+
77
+ test('tap on already selected and fires iron-activate', function(done) {
78
+ assert.equal(s.selected, '0');
79
+
80
+ // attach iron-activate listener
81
+ s.addEventListener("iron-activate", function(event) {
82
+ assert.equal(event.detail.selected, '0');
83
+ assert.equal(event.detail.item, s.children[0]);
84
+ done();
85
+ });
86
+
87
+ // select Item 0
88
+ s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
89
+ });
90
+
91
+ test('activates on mousedown', function() {
92
+ // set activateEvent to mousedown
93
+ s.activateEvent = 'mousedown';
94
+ // select Item 2
95
+ s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true}));
96
+ assert.equal(s.selected, '2');
97
+ });
98
+
99
+ test('activates on mousedown and fires iron-activate', function(done) {
100
+ // attach iron-activate listener
101
+ s.addEventListener("iron-activate", function(event) {
102
+ assert.equal(event.detail.selected, '2');
103
+ assert.equal(event.detail.item, s.children[2]);
104
+ done();
105
+ });
106
+
107
+ // set activateEvent to mousedown
108
+ s.activateEvent = 'mousedown';
109
+ // select Item 2
110
+ s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true}));
111
+ });
112
+
113
+ test('no activation', function() {
114
+ assert.equal(s.selected, '0');
115
+ // set activateEvent to null
116
+ s.activateEvent = null;
117
+ // select Item 2
118
+ s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true}));
119
+ assert.equal(s.selected, '0');
120
+ });
121
+
122
+ test('activates on tap and preventDefault', function() {
123
+ // attach iron-activate listener
124
+ s.addEventListener("iron-activate", function(event) {
125
+ event.preventDefault();
126
+ });
127
+ // select Item 2
128
+ s.children[2].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
129
+ // shouldn't got selected since we preventDefault in iron-activate
130
+ assert.equal(s.selected, '0');
131
+ });
132
+
133
+ });
134
+
135
+ </script>
136
+
137
+ </body>
138
+ </html>
@@ -0,0 +1,150 @@
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-basic</title>
15
+ <meta charset="utf-8">
16
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
17
+
18
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
19
+ <script src="../../web-component-tester/browser.js"></script>
20
+ <script src="../../test-fixture/test-fixture-mocha.js"></script>
21
+
22
+ <link rel="import" href="../../test-fixture/test-fixture.html">
23
+ <link rel="import" href="../iron-selector.html">
24
+
25
+ <style>
26
+ .iron-selected {
27
+ background: #ccc;
28
+ }
29
+
30
+ .my-selected {
31
+ background: red;
32
+ }
33
+ </style>
34
+
35
+ </head>
36
+ <body>
37
+
38
+ <test-fixture id="defaults">
39
+ <template>
40
+ <iron-selector>
41
+ <div>Item 0</div>
42
+ <div>Item 1</div>
43
+ <div>Item 2</div>
44
+ <div>Item 3</div>
45
+ <div>Item 4</div>
46
+ </iron-selector>
47
+ </template>
48
+ </test-fixture>
49
+
50
+ <br><br>
51
+
52
+ <test-fixture id="basic">
53
+ <template>
54
+ <iron-selector selected="item2" attr-for-selected="id">
55
+ <div id="item0">Item 0</div>
56
+ <div id="item1">Item 1</div>
57
+ <div id="item2">Item 2</div>
58
+ <div id="item3">Item 3</div>
59
+ <div id="item4">Item 4</div>
60
+ </iron-selector>
61
+ </template>
62
+ </test-fixture>
63
+
64
+ <script>
65
+
66
+ suite('defaults', function() {
67
+
68
+ var s1;
69
+
70
+ setup(function () {
71
+ s1 = fixture('defaults');
72
+ });
73
+
74
+ test('to nothing selected', function() {
75
+ assert.equal(s1.selected, null);
76
+ });
77
+
78
+ test('to iron-selected as selectedClass', function() {
79
+ assert.equal(s1.selectedClass, 'iron-selected');
80
+ });
81
+
82
+ test('to false as multi', function() {
83
+ assert.isFalse(s1.multi);
84
+ });
85
+
86
+ test('to tap as activateEvent', function() {
87
+ assert.equal(s1.activateEvent, 'tap');
88
+ });
89
+
90
+ test('to nothing as attrForSelected', function() {
91
+ assert.equal(s1.attrForSelected, null);
92
+ });
93
+
94
+ test('as many items as children', function() {
95
+ assert.equal(s1.items.length, s1.querySelectorAll('div').length);
96
+ });
97
+ });
98
+
99
+ suite('basic', function() {
100
+
101
+ var s2;
102
+
103
+ setup(function () {
104
+ s2 = fixture('basic');
105
+ });
106
+
107
+ test('honors the attrForSelected attribute', function() {
108
+ assert.equal(s2.attrForSelected, 'id');
109
+ assert.equal(s2.selected, 'item2');
110
+ assert.equal(s2.selectedItem, document.querySelector('#item2'));
111
+ });
112
+
113
+ test('allows assignment to selected', function() {
114
+ // set selected
115
+ s2.selected = 'item4';
116
+ // check selected class
117
+ assert.isTrue(s2.children[4].classList.contains('iron-selected'));
118
+ // check item
119
+ assert.equal(s2.selectedItem, s2.children[4]);
120
+ });
121
+
122
+ test('fire iron-select when selected is set', function() {
123
+ // setup listener for iron-select event
124
+ var selectedEventCounter = 0;
125
+ s2.addEventListener('iron-select', function(e) {
126
+ selectedEventCounter++;
127
+ });
128
+ // set selected
129
+ s2.selected = 'item4';
130
+ // check iron-select event
131
+ assert.equal(selectedEventCounter, 1);
132
+ });
133
+
134
+ test('set selected to old value', function() {
135
+ // setup listener for iron-select event
136
+ var selectedEventCounter = 0;
137
+ s2.addEventListener('iron-select', function(e) {
138
+ selectedEventCounter++;
139
+ });
140
+ // selecting the same value shouldn't fire iron-select
141
+ s2.selected = 'item2';
142
+ assert.equal(selectedEventCounter, 0);
143
+ });
144
+
145
+ });
146
+
147
+ </script>
148
+
149
+ </body>
150
+ </html>