forked from formio/contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
95 lines (89 loc) · 3.43 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
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Form.io Premium Components</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.form.io/formiojs/formio.full.min.css">
<link rel="stylesheet" href="dist/formio-contrib.css">
</head>
<body>
<div class="row">
<div class="col-sm-8">
<h3 class="text-center text-muted">The <a href="https://github.com/formio/formio.js" target="_blank">Form Builder</a> allows you to build a <select class="form-control" id="form-select" style="display: inline-block; width: 150px;"><option value="form">Form</option><option value="wizard">Wizard</option><option value="pdf">PDF</option></select></h3>
<div id="builder"></div>
</div>
<div class="col-sm-4">
<h3 class="text-center text-muted">as JSON Schema</h3>
<div class="card card-body bg-light jsonviewer">
<pre id="json"></pre>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-sm-8 offset-sm-2">
<h3 class="text-center text-muted">which <a href="https://github.com/formio/ngFormio" target="_blank">Renders as a Form</a> in your Application</h3>
<div id="formio" class="card card-body bg-light"></div>
</div>
<div class="clearfix"></div>
</div>
<div class="row mt-4">
<div class="col-sm-8 offset-sm-2">
<h3 class="text-center text-muted">which creates a Submission JSON</h3>
<div class="card card-body bg-light jsonviewer">
<pre id="subjson"></pre>
</div>
</div>
<div class="clearfix"></div>
</div>
<script src="https://cdn.form.io/formiojs/formio.full.js"></script>
<script src="dist/formio-contrib.js"></script>
<script type="text/javascript">
Formio.use(FormioContrib);
var jsonElement = document.getElementById('json');
var formElement = document.getElementById('formio');
var subJSON = document.getElementById('subjson');
var builder = new Formio.FormBuilder(document.getElementById("builder"), {
display: 'form',
components: [],
settings: {
pdf: {
"id": "1ec0f8ee-6685-5d98-a847-26f67b67d6f0",
"src": "https://files.form.io/pdf/5692b91fd1028f01000407e3/file/1ec0f8ee-6685-5d98-a847-26f67b67d6f0"
}
}
}, {
baseUrl: 'https://examples.form.io'
});
var onForm = function(form) {
form.on('change', function() {
subJSON.innerHTML = '';
subJSON.appendChild(document.createTextNode(JSON.stringify(form.submission, null, 4)));
});
};
var onBuild = function(build) {
jsonElement.innerHTML = '';
formElement.innerHTML = '';
jsonElement.appendChild(document.createTextNode(JSON.stringify(builder.instance.schema, null, 4)));
Formio.createForm(formElement, builder.instance.form).then(onForm);
};
var onReady = function() {
var jsonElement = document.getElementById('json');
var formElement = document.getElementById('formio');
builder.instance.on('saveComponent', onBuild);
builder.instance.on('editComponent', onBuild);
};
var setDisplay = function(display) {
builder.setDisplay(display).then(onReady);
};
// Handle the form selection.
var formSelect = document.getElementById('form-select');
formSelect.addEventListener("change", function() {
setDisplay(this.value);
});
builder.instance.ready.then(onReady);
</script>
</body>
</html>