-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
203 lines (179 loc) · 5.58 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<html>
<head>
<script type="text/javascript" src="substance-forms.js"></script>
<style>
@import url('lib/font-awesome/css/font-awesome.min.css');
@import 'substance-reset.css';
@import 'substance-forms.css';
body {
line-height: 1.5;
font-family: "Avenir Next", arial, sans-serif;
}
.page {
max-width: 600px;
margin: auto;
padding-top: 50px;
}
a {
color: #4990E2;
}
.title {
font-weight: 600;
font-size: 36px;
padding-bottom: 10px;
}
.intro {
padding-bottom: 20px;
font-size: 18px;
}
.intro > p {
padding-bottom: 20px;
}
.form-section {
padding-bottom: 20px;
}
.form-hint {
font-size: 14px;
font-family: Georgia;
color: #777;
padding-bottom: 20px;
}
.form-heading {
font-weight: 600;
font-size: 26px;
padding-bottom: 10px;
}
input.form-input {
font-family: "Avenir Next", arial, sans-serif;
border: 1px solid #ddd;
height: 40px;
padding: 0px 5px;
font-size: 16px;
display: block;
width: 100%;
}
h1, h2, h3 {
font-weight: 600;
font-family: "Avenir Next", arial, sans-serif;
}
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
b { font-weight: 600; }
i { font-style: italic; }
.sc-rich-text-area {
border: 1px solid #ddd;
padding: 0px 20px;
padding-bottom: 0px;
}
.sc-rich-text-area .sc-container-editor > * {
margin: 20px 0;
}
#submit-button {
background-color: #4990E2;
padding: 10px;
border-width: 2px;
border-color: buttonface;
width: 300px;
font-weight: 600;
color: white;
text-align: center;
margin: 20px auto;
}
.text-center {
text-align: center;
}
</style>
<script type="text/javascript">
var forms
window.addEventListener('load', function() {
forms = new SubstanceForms()
// Activate richtext areas via API
forms.addRichTextArea('survey_motivation', document.getElementById('survey_motivation'))
forms.addRichTextArea('survey_cv', document.getElementById('survey_cv'))
})
function _onSubmit(e) {
e.preventDefault()
e.stopPropagation()
var data = {
survey_motivation: forms.getHTML('survey_motivation'),
survey_cv: forms.getHTML('survey_cv'),
survey_name: document.getElementById('survey_name').value,
survey_recommend: document.querySelector('input[name="survey_recommend"]:checked').value
}
console.info(data)
alert(JSON.stringify(data, null, ' '))
}
</script>
</head>
<body>
<div class="page">
<div class="title">Substance Forms</div>
<div class="intro">
<p>
Substance Forms is a <a href="http://github.com/substance/forms">JavaScript library</a>
you can use to create better web forms. You can mark areas of the page as
editable and access the contents with a simple JavaScript API.
</p>
<p>
Below is an example for basic usage. For advanced usage see the <a href="comments.html">comments example</a>.
</p>
</div>
<form id="submission" onsubmit="_onSubmit(event)">
<div class="form-section">
<div class="form-heading">What brought you here?</div>
<div class="form-hint">
The following field is a Substance rich text editor. It produces clean annotated HTML.
</div>
<div id="survey_motivation" editable data-type="area">
<p>Tell us <strong>why</strong> you are here (<em>200-1000 words</em>).</p>
<p>You can also use lists:</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
</div>
<div class="form-section">
<div class="form-heading">Can you provide a short tabular CV?</div>
<div class="form-hint">
This is another rich text field.
</div>
<div id="survey_cv" editable data-type="area">
<p>Here is my CV:</p>
<table>
<tbody>
<tr><td>A</td><td>B</td><td>C</td></tr>
<tr><td>A</td><td>B</td><td>C</td></tr>
</tbody>
</table>
</div>
</div>
<div class="form-section">
<div class="form-heading">What's your name?</div>
<div class="form-hint">
This is a regular HTML input field. We designed Substance forms so you can easily mix it with classic form elements or combine it with 3rd party widget libraries (date picker etc.)
</div>
<input id="survey_name" class="form-input" type="text" placeholder="Enter your full name" name="survey_name">
</div>
<div class="form-section">
<div class="form-heading">Would you recommend this library?</div>
<div class="form-hint">
Regular radio buttons can be used too.
</div>
<div class="option-group">
<div class="option"><input type="radio" name="survey_recommend" value="definitely" checked> Definitely</div>
<div class="option"><input type="radio" name="survey_recommend" value="maybe"> Maybe</div>
<div class="option"><input type="radio" name="survey_recommend" value="never"> Never</div>
</div>
</div>
<div class="form-section">
<button id="submit-button" type="submit" form="submission">Submit Survey</button>
<div class="form-hint text-center">
This is just a demo, nothing is actually submitted.
</div>
</div>
</form>
</div>
</body>
</html>