|
2 | 2 | <html> |
3 | 3 | <head> |
4 | 4 | <script language="javascript" src="../../bower_components/webcomponentsjs/webcomponents.js"></script> |
5 | | - |
6 | 5 | <link rel="import" href="../../build/strand.html" /> |
7 | | - <!-- <link rel="import" href="../mm-dimensions/mm-dimensions.html" /> --> |
8 | | - <!-- <link rel="import" href="mm-form.html" /> --> |
9 | 6 |
|
10 | 7 | <style type="text/css"> |
11 | 8 | body, html { |
|
44 | 41 | </head> |
45 | 42 |
|
46 | 43 | <body> |
47 | | - <!-- dom module for testing special cases --> |
48 | | - <!-- |
49 | | - <dom-module id="special-snowflake"> |
50 | | - <style type="text/css"> |
51 | | - :host { |
52 | | - position: relative; |
53 | | - display: flex; |
54 | | - align-items: center; |
55 | | - font-size: 0; |
56 | | - } |
57 | | - mm-dropdown { |
58 | | - margin-right: 15px; |
59 | | - } |
60 | | - </style> |
61 | | - <template> |
62 | | - <mm-radio |
63 | | - id="standardSize" |
64 | | - group="sizes" |
65 | | - checked |
66 | | - on-selected="_handleRadioSelected"></mm-radio> |
67 | | - <mm-dropdown |
68 | | - id="standardSizeDdl" |
69 | | - disabled$="{{!isStandard}}" |
70 | | - on-changed="_standardSizeChanged" |
71 | | - placeholder="Select One"> |
72 | | - <mm-list-item>160x600</mm-list-item> |
73 | | - <mm-list-item>728x90</mm-list-item> |
74 | | - <mm-list-item>300x250</mm-list-item> |
75 | | - </mm-dropdown> |
76 | | - <mm-radio |
77 | | - id="nonStandardSize" |
78 | | - group="sizes" |
79 | | - on-selected="_handleRadioSelected"></mm-radio> |
80 | | - <mm-group id="nonStandardSizeGroup" disabled$="{{isStandard}}"> |
81 | | - <mm-input |
82 | | - id="width" |
83 | | - placeholder="Width" |
84 | | - validation="int" |
85 | | - on-changed="_widthChanged"></mm-input> |
86 | | - <mm-input |
87 | | - id="height" |
88 | | - placeholder="Height" |
89 | | - validation="int" |
90 | | - on-changed="_heightChanged"></mm-input> |
91 | | - </mm-group> |
92 | | - </template> |
93 | | - </dom-module> |
94 | | - --> |
95 | 44 |
|
96 | 45 | <mm-form id="testForm" unresolved> |
| 46 | + |
97 | 47 | <!-- row 1 --> |
98 | 48 | <div class="col" span="1"> |
99 | | - <mm-input |
100 | | - fitparent |
101 | | - name="input" |
102 | | - validation="int|empty" |
103 | | - placeholder="Type a Number" |
104 | | - label="Type a Number" |
105 | | - error-message="You need to type a number"></mm-input> |
| 49 | + <mm-input fitparent name="input" placeholder="Type a Number" value="123"></mm-input> |
106 | 50 | </div> |
| 51 | + |
107 | 52 | <div class="col" span="1"> |
108 | | - <mm-dropdown |
109 | | - fitparent |
110 | | - name="dropdown" |
111 | | - placeholder="Select an Item" |
112 | | - validation="empty" |
113 | | - label="Select an Item" |
114 | | - error-message="You need to select an item"> |
| 53 | + <mm-dropdown fitparent name="dropdown" placeholder="Select an Item" value="List Item 1"> |
115 | 54 | <mm-list-item>List Item 1</mm-list-item> |
116 | 55 | <mm-list-item>List Item 2</mm-list-item> |
117 | 56 | <mm-list-item>List Item 3</mm-list-item> |
118 | 57 | <mm-list-item>List Item 4</mm-list-item> |
119 | 58 | </mm-dropdown> |
120 | 59 | </div> |
| 60 | + |
121 | 61 | <div class="col" span="2"> |
122 | | - <mm-group |
123 | | - fitparent |
124 | | - unresolved |
125 | | - name="radio" |
126 | | - placeholder="Select an Item" |
127 | | - validation="empty" |
128 | | - label="Select a Color" |
129 | | - error-message="You need to select a color"> |
| 62 | + <mm-group fitparent unresolved name="radio" value="Red"> |
130 | 63 | <mm-radio> |
131 | 64 | <label>Red</label> |
132 | 65 | </mm-radio> |
|
140 | 73 | </div> |
141 | 74 |
|
142 | 75 | <!-- row 2 --> |
| 76 | + <!-- |
143 | 77 | <div class="col" span="1"> |
144 | 78 | <mm-dimensions |
145 | 79 | id="dimensions" |
|
148 | 82 | validation="dimensions|empty" |
149 | 83 | label="Select a Dimension" |
150 | 84 | error-message="You need to select dimensions"></mm-dimensions> |
| 85 | + </div> |
| 86 | + --> |
| 87 | + |
151 | 88 | </mm-form> |
152 | | - <!-- multi-value --> |
153 | 89 |
|
154 | 90 | <script> |
| 91 | + |
| 92 | + var formData = { |
| 93 | + 'input' : { |
| 94 | + validation: 'int|empty', |
| 95 | + errorMsg: 'You need to type a number', |
| 96 | + label: 'Type a number' |
| 97 | + }, |
| 98 | + 'dropdown' : { |
| 99 | + validation: 'empty', |
| 100 | + errorMsg: 'You need to select an item', |
| 101 | + label: 'Select an Item' |
| 102 | + }, |
| 103 | + 'radio' : { |
| 104 | + validation: 'empty', |
| 105 | + errorMsg: 'You need to select a color', |
| 106 | + label: 'Select a Color' |
| 107 | + } |
| 108 | + }; |
| 109 | + |
155 | 110 | window.addEventListener('WebComponentsReady', function(e) { |
156 | 111 | var testForm = document.querySelector('#testForm'); |
157 | 112 |
|
158 | | - // add custom validation rules for the dimension component |
159 | | - // this would probably be more robust, but this is sufficient |
160 | | - testForm.rules.dimensions = function(i) { |
161 | | - return i ? typeof(parseInt(i.width) === 'number') && |
162 | | - typeof(parseInt(i.height) === 'number') : false; |
163 | | - } |
| 113 | + testForm.data = formData; |
164 | 114 |
|
165 | 115 | testForm.addEventListener('serialize-form', function(e){ |
166 | 116 | console.log('serialize-form', e.detail); |
|
0 commit comments