-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
187 lines (174 loc) · 7.75 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><juicy-jsoneditor></title>
<link rel="stylesheet" href="http://juicy.github.io/juicy-tile-list/examples/github-markdown.css">
<!-- Importing Web Component's Polyfill -->
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<script>
Polymer = {
dom: 'shadow'
};
</script>
<!-- Importing Custom Elements -->
<link rel="import" href="juicy-jsoneditor.html">
<style>
body {
font-family: sans-serif;
min-width: 200px;
width: 70%;
margin: 0 auto;
padding: 30px;
height: 100%;
}
juicy-jsoneditor {
height: 18em;
}
#demo {
display: flex;
justify-content: space-around;
}
#examples {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
align-content: center;
align-items: center;
}
#examples > section {
width: 28em;
margin: 0 2em 3em 2em;
}
#examples > section h3 {
margin-bottom: 5px;
}
#examples section .markdown-body .code {
line-height: 1.5;
padding-bottom: 10px;
}
iframe {
float: right;
}
div.juicy-element {
margin: 20px 0px;
}
</style>
</head>
<body>
<a href="https://github.com/Juicy/juicy-jsoneditor"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<article>
<iframe src="http://ghbtns.com/github-btn.html?user=juicy&repo=juicy-jsoneditor&type=watch&count=true&size=medium"
allowtransparency="true" frameborder="0" scrolling="0" width="90" height="30"></iframe>
<!-- Using Custom Elements -->
<dom-bind>
<template is="dom-bind">
<div class="markdown-body">
<h1><juicy-jsoneditor></h1>
<p>
Polymer Element that wraps <a href="https://github.com/josdejong/jsoneditor">josdejong/jsoneditor</a>
</p>
<p>
Play with <code>json</code> variable in your console, to experience two-way binding with <code><juicy-jsoneditor></code>.
</p>
<p>
Please note, that <code>.json</code> itself does not have deep two-way binding, as <a href="https://github.com/josdejong/jsoneditor">josdejong/jsoneditor</a> does not notify on changes, just replaces entire object, so we mock it only on root level.
</p>
</div>
<div class="juicy-element">
<juicy-jsoneditor json="{{model.json}}"></juicy-jsoneditor>
</div>
<div class="markdown-body">
<h2>Examples</h2>
</div>
<section id="examples">
<section>
<div class="markdown-body">
<h3>With <code>name</code> attribute</h3>
<div class="code">
<code><juicy-jsoneditor json="{‍{json}}" name="MyName"></juicy-jsoneditor></code>
</div>
</div>
<juicy-jsoneditor json="{{model.json}}" name="MyName"></juicy-jsoneditor>
</section>
<section>
<div class="markdown-body">
<h3>With <code>modes</code> attribute</h3>
<div class="code">
<code><juicy-jsoneditor json="{‍{json::change}}" modes="['code', 'form', 'text', 'tree', 'view']"></juicy-jsoneditor></code>
</div>
</div>
<juicy-jsoneditor json="{{model.json::change}}" modes='["code", "form", "text", "tree", "view"]'></juicy-jsoneditor>
</section>
<section>
<div class="markdown-body">
<h3>With <code>search</code> attribute set to <code>false</code></h3>
<div class="code">
<code><juicy-jsoneditor json="{‍{json::change}}" search="false"></juicy-jsoneditor></code>
</div>
</div>
<juicy-jsoneditor json="{{model.json::change}}" search="false"></juicy-jsoneditor>
</section>
<section>
<div class="markdown-body">
<h3>With <code>mode</code> attribute</h3>
<div class="code">
<code><juicy-jsoneditor json="{‍{json::change}}" mode="text"></juicy-jsoneditor></code>
</div>
</div>
<juicy-jsoneditor json="{{model.json::change}}" mode="text"></juicy-jsoneditor>
</section>
<section>
<div class="markdown-body">
<h3>With <code>indentation</code> attribute</h3>
<div class="code">
<code><juicy-jsoneditor json="{‍{json::change}}" mode="text" indentation="4"></juicy-jsoneditor></code>
</div>
</div>
<juicy-jsoneditor json="{{model.json::change}}" mode="text" indentation="4"></juicy-jsoneditor>
</section>
<section>
<div class="markdown-body">
<h3>In <code>code</code> mode without any <code>json</code> content</h3>
<div class="code">
<code><juicy-jsoneditor mode="code"></juicy-jsoneditor></code>
</div>
</div>
<juicy-jsoneditor mode="code"></juicy-jsoneditor>
</section>
<section>
<div class="markdown-body">
<h3>In <code>tree</code> mode without any <code>json</code> content</h3>
<div class="code">
<code><juicy-jsoneditor mode="tree"></juicy-jsoneditor></code>
</div>
</div>
<juicy-jsoneditor mode="tree"></juicy-jsoneditor>
</section>
</section>
</template>
</dom-bind>
<script type="text/javascript">
document.addEventListener('WebComponentsReady', function(){
var json = {
'array': [1, 2, 3],
'boolean': true,
'null': null,
'number': 123,
'object': { 'a': 'b', 'c': 'd' },
'string': 'Hello World'
};
var appModel = {json: json};
var template = document.querySelector('dom-bind');
if (!Polymer.Element) {
// Polymer v 1.0
template = document.querySelector('template');
}
template.model = appModel;
window.json = json;
console.info("Play with me! I'm the `json` given to all those editors", json);
});
</script>
</article>
</body>
</html>