-
Notifications
You must be signed in to change notification settings - Fork 0
/
formulator.html
162 lines (157 loc) · 7.34 KB
/
formulator.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
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="libs/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
ad>
<body class="dbootstrap">
<script src="release/dojo/dojo.js.uncompressed.js"></script>
<style>
@import "release/rdforms/view/resources/rdforms.css";
.dbootstrap :focus {
outline: 0px;
}
input[type="text"], input[type="password"] { outline: none; }
.dbootstrap .dijitDownArrowButton.dijitArrowButtonContainer {
height: 16px;
}
html, body {
height: 100%;
width: 100%;
padding: 0px;
margin: 0px;
}
.icon {
float: left;
margin-top: 3px;
margin-right: 15px;
width: 45px;
}
.dijitDialog *,
.storeManager * {
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
.main {
position: relative;
height: 100%;
}
#content {
position: absolute;
top: 51px;
bottom: 0em;
left: 0px;
right: 0px;
}
</style>
<script type="text/javascript">
var params = window.location.href.match(/\?([^#]*)/)[1].split("&");
var parobj = {};
for (var i=0;i<params.length;i++) {
var pair = params[i].split("=");
parobj[pair[0]] = pair[1];
}
if (parobj.deps) {
parobj.deps = parobj.deps.split(",");
}
if (parobj.templates) {
parobj.templates = parobj.templates.split(",");
}
require(["rdforms/extras"], function() {
require([
'dbootstrap/main',
'dojo/on',
'dojo/dom',
'dojo/dom-style',
'rdforms/template/ItemStore',
'rdforms/apps/formulator/StoreManager',
'rdfjson/formats/converters',
'dojo/json',
'dojo/domReady!'
],function(main, on, dom, domStyle, ItemStore, StoreManager, converters, json) {
var itemStore = new ItemStore();
var arr = [];
var templatescount = parobj.templates ? parobj.templates.length : 0;
var depscount = parobj.deps ? parobj.deps.length : 0;
for (var i=0;i<templatescount;i++) {
arr.push("dojo/text!"+parobj.templates[i]);
}
for (var i=0;i<depscount;i++) {
arr.push("dojo/text!"+parobj.deps[i]);
}
if (parobj.rdf) {
arr.push("dojo/text!"+parobj.rdf);
}
require(arr, function() {
var args = Array.prototype.slice.call(arguments, 0);
for (var i=0;i<depscount;i++) {
itemStore.registerBundle({path: parobj.deps[i], source: json.parse(args[i+templatescount]), readOnly: true});
}
for (var i=0;i<templatescount;i++) {
itemStore.registerBundle({path: parobj.templates[i], source: json.parse(args[i])});
}
if (parobj.rdf) {
var storeManager = new StoreManager({itemStore: itemStore, data: converters.rdfxml2graph(args[templatescount+depscount]).exportRDFJSON()}, "formulator");
storeManager.startup();
} else {
var storeManager = new StoreManager({itemStore: itemStore, data: {}, saveDisabled: parobj.saveDisabled === "true"}, "formulator");
storeManager.startup();
};
on(dom.byId("formulatorButton"), "click", function() {
domStyle.set(dom.byId("formulator"), "display", "");
domStyle.set(dom.byId("about"), "display", "none");
});
on(dom.byId("aboutButton"), "click", function() {
domStyle.set(dom.byId("formulator"), "display", "none");
domStyle.set(dom.byId("about"), "display", "");
});
});
});
});
</script>
<div class="main">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<img src="http://rdforms.com/favicon.ico" class="icon"/>
<a class="navbar-brand" href="#">RDForms Formulator</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a id="formulatorButton" href="#formulator">Formulator</a></li>
<li><a id="aboutButton" href="#about">About</a></li>
</ul>
</div>
</div>
</div>
<div id="content">
<div id="formulator"></div>
<div class="container" id="about" style="display: none;">
<h2>About RDForms Formulator</h2>
<p>
Formulator is a web application for editing RDForms templates and is a part of the
<a href="http://rdforms.org/">RDForms library</a>.
RDForms Templates are used to generate to HTML forms that can edit and present RDF.
Each RDForms template expresses which RDF expression to edit, cardinality restrictions, labels,
help texts, and also provides user interface hints.
</p>
<p>The development was done by <a href="http://metasolutions.se/">MetaSolutions AB</a>.</p>
<h3>Bird's-eye view of Formulator</h3>
<p>Formulator consists of three panes. The leftmost pane consists of a tree view of all loaded templates
grouped in "bundles", i.e. loaded files containing several templates. The loaded bundles are specified
as the two parameters templates and deps to the Formulator web-application. Those specified in the templates
parameter (provided as relative paths to the formulator, if multiple separated via kommas) are the primary
bundle(s) that can be changed and saved. The bundles provided via the deps argument are grayed out in the
tree-view and can neither be edited nor be saved.
Note that you can right click and create new items as well as drag and drop items between group-items.
</p>
<p>
The pane in the middle consists of the template-editor, i.e. here you provide all the nitty-gritty details
of how the template should work. The last pane to the right provides a preview of how the HTML form
will look like from the current template. Note that you can edit the RDF and switch to the edit or
present mode to see how it will be shown.
</p>
</div>
</div>
</div>
</body>
</html>