bee_api 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/bee_api +84 -0
- data/lib/mdpreview.rb +80 -0
- data/lib/mdpreview/translator.rb +60 -0
- data/lib/mdpreview/version.rb +3 -0
- data/test/mdptest.rb +100 -0
- data/vendor/HISTORY.md +237 -0
- data/vendor/Jakefile.js +316 -0
- data/vendor/LICENSE +176 -0
- data/vendor/NOTICE +17 -0
- data/vendor/README.md +102 -0
- data/vendor/app/chrome/documentation.txt +12 -0
- data/vendor/app/chrome/manifest.json +24 -0
- data/vendor/app/web/ajax.js +43 -0
- data/vendor/app/web/app.css +292 -0
- data/vendor/app/web/app.js +377 -0
- data/vendor/app/web/beta/index.html +17 -0
- data/vendor/app/web/datapolicy.txt +48 -0
- data/vendor/app/web/doc/doc.css +60 -0
- data/vendor/app/web/doc/img/actions_menu.png +0 -0
- data/vendor/app/web/doc/img/button_actions_menu.png +0 -0
- data/vendor/app/web/doc/img/button_dragarea.png +0 -0
- data/vendor/app/web/doc/img/jsoneditor.png +0 -0
- data/vendor/app/web/doc/img/jsonformatter.png +0 -0
- data/vendor/app/web/doc/img/main_menu.png +0 -0
- data/vendor/app/web/doc/img/splitter.png +0 -0
- data/vendor/app/web/doc/index.html +201 -0
- data/vendor/app/web/favicon.ico +0 -0
- data/vendor/app/web/fileretriever.css +54 -0
- data/vendor/app/web/fileretriever.js +567 -0
- data/vendor/app/web/fileretriever.php +120 -0
- data/vendor/app/web/googlea47c4a0b36d11021.html +1 -0
- data/vendor/app/web/hash.js +133 -0
- data/vendor/app/web/img/description.txt +20 -0
- data/vendor/app/web/img/header_background.png +0 -0
- data/vendor/app/web/img/icon_128.png +0 -0
- data/vendor/app/web/img/icon_16.png +0 -0
- data/vendor/app/web/img/icon_gray.svg +151 -0
- data/vendor/app/web/img/icon_gray_16.svg +150 -0
- data/vendor/app/web/img/icon_orange.svg +151 -0
- data/vendor/app/web/img/logo.png +0 -0
- data/vendor/app/web/img/logo.xcf +0 -0
- data/vendor/app/web/img/logo_app.png +0 -0
- data/vendor/app/web/img/logo_app.xcf +0 -0
- data/vendor/app/web/index.html +191 -0
- data/vendor/app/web/notify.js +150 -0
- data/vendor/app/web/queryparams.js +71 -0
- data/vendor/app/web/robots.txt +0 -0
- data/vendor/app/web/splitter.js +179 -0
- data/vendor/app/web/test.html +224 -0
- data/vendor/component.json +33 -0
- data/vendor/docs/api.md +188 -0
- data/vendor/docs/usage.md +137 -0
- data/vendor/examples/01_basic_usage.html +45 -0
- data/vendor/examples/02_viewer.html +38 -0
- data/vendor/examples/03_switch_mode.html +98 -0
- data/vendor/examples/cur.file +1 -0
- data/vendor/examples/jquery.js +2 -0
- data/vendor/examples/meta.js +1 -0
- data/vendor/examples/requirejs_demo/requirejs_demo.html +19 -0
- data/vendor/examples/requirejs_demo/scripts/main.js +25 -0
- data/vendor/examples/requirejs_demo/scripts/require.js +35 -0
- data/vendor/img/jsoneditor-icons.png +0 -0
- data/vendor/jsoneditor-min.css +1 -0
- data/vendor/jsoneditor-min.js +34 -0
- data/vendor/jsoneditor.css +597 -0
- data/vendor/jsoneditor.js +6069 -0
- data/vendor/jsoneditor/css/contextmenu.css +219 -0
- data/vendor/jsoneditor/css/img/description.txt +13 -0
- data/vendor/jsoneditor/css/img/export.sh +16 -0
- data/vendor/jsoneditor/css/img/jsoneditor-icons.png +0 -0
- data/vendor/jsoneditor/css/img/jsoneditor-icons.svg +861 -0
- data/vendor/jsoneditor/css/jsoneditor.css +220 -0
- data/vendor/jsoneditor/css/menu.css +81 -0
- data/vendor/jsoneditor/css/searchbox.css +73 -0
- data/vendor/jsoneditor/js/appendnode.js +211 -0
- data/vendor/jsoneditor/js/contextmenu.js +440 -0
- data/vendor/jsoneditor/js/header.js +32 -0
- data/vendor/jsoneditor/js/highlighter.js +82 -0
- data/vendor/jsoneditor/js/history.js +218 -0
- data/vendor/jsoneditor/js/jsoneditor.js +206 -0
- data/vendor/jsoneditor/js/module.js +50 -0
- data/vendor/jsoneditor/js/node.js +2864 -0
- data/vendor/jsoneditor/js/searchbox.js +288 -0
- data/vendor/jsoneditor/js/texteditor.js +311 -0
- data/vendor/jsoneditor/js/treeeditor.js +770 -0
- data/vendor/jsoneditor/js/util.js +582 -0
- data/vendor/lib/ace/ace.js +11 -0
- data/vendor/lib/ace/mode-json.js +1 -0
- data/vendor/lib/ace/theme-jsoneditor.js +144 -0
- data/vendor/lib/ace/theme-textmate.js +163 -0
- data/vendor/lib/ace/worker-json.js +1 -0
- data/vendor/lib/jsonlint/README.md +62 -0
- data/vendor/lib/jsonlint/jsonlint.js +432 -0
- data/vendor/misc/screenshots/actionsmenu_640x400.png +0 -0
- data/vendor/misc/screenshots/codeeditor_640x400.png +0 -0
- data/vendor/misc/screenshots/description.json +17 -0
- data/vendor/misc/screenshots/jsoneditoronline.png +0 -0
- data/vendor/misc/screenshots/jsoneditoronline_640x400.png +0 -0
- data/vendor/misc/screenshots/search_640x400.png +0 -0
- data/vendor/misc/screenshots/small_tile.xcf +0 -0
- data/vendor/misc/screenshots/small_tile_440x280.png +0 -0
- data/vendor/misc/todo.txt +101 -0
- data/vendor/package.json +28 -0
- data/vendor/test/couchdbeditor.html +100 -0
- data/vendor/test/largefile.json +12605 -0
- data/vendor/test/test_ace.html +60 -0
- data/vendor/test/test_editable_div.html +449 -0
- metadata +154 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
|
|
2
|
+
.jsoneditor .field,
|
|
3
|
+
.jsoneditor .value,
|
|
4
|
+
.jsoneditor .readonly {
|
|
5
|
+
border: 1px solid transparent;
|
|
6
|
+
min-height: 16px;
|
|
7
|
+
min-width: 32px;
|
|
8
|
+
padding: 2px;
|
|
9
|
+
margin: 1px;
|
|
10
|
+
word-wrap: break-word;
|
|
11
|
+
float: left;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* adjust margin of p elements inside editable divs, needed for Opera, IE */
|
|
15
|
+
.jsoneditor .field p,
|
|
16
|
+
.jsoneditor .value p {
|
|
17
|
+
margin: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.jsoneditor .value {
|
|
21
|
+
word-break: break-word;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.jsoneditor .readonly {
|
|
25
|
+
min-width: 16px;
|
|
26
|
+
color: gray;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.jsoneditor .empty {
|
|
30
|
+
border-color: lightgray;
|
|
31
|
+
border-style: dashed;
|
|
32
|
+
border-radius: 2px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.jsoneditor .field.empty {
|
|
36
|
+
background-image: url('img/jsoneditor-icons.png');
|
|
37
|
+
background-position: 0 -144px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.jsoneditor .value.empty {
|
|
41
|
+
background-image: url('img/jsoneditor-icons.png');
|
|
42
|
+
background-position: -48px -144px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.jsoneditor .value.url {
|
|
46
|
+
color: green;
|
|
47
|
+
text-decoration: underline;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.jsoneditor a.value.url:hover,
|
|
51
|
+
.jsoneditor a.value.url:focus {
|
|
52
|
+
color: red;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.jsoneditor .separator {
|
|
56
|
+
padding: 3px 0;
|
|
57
|
+
vertical-align: top;
|
|
58
|
+
color: gray;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.jsoneditor .field[contenteditable=true]:focus,
|
|
62
|
+
.jsoneditor .field[contenteditable=true]:hover,
|
|
63
|
+
.jsoneditor .value[contenteditable=true]:focus,
|
|
64
|
+
.jsoneditor .value[contenteditable=true]:hover,
|
|
65
|
+
.jsoneditor .field.highlight,
|
|
66
|
+
.jsoneditor .value.highlight {
|
|
67
|
+
background-color: #FFFFAB;
|
|
68
|
+
border: 1px solid yellow;
|
|
69
|
+
border-radius: 2px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.jsoneditor .field.highlight-active,
|
|
73
|
+
.jsoneditor .field.highlight-active:focus,
|
|
74
|
+
.jsoneditor .field.highlight-active:hover,
|
|
75
|
+
.jsoneditor .value.highlight-active,
|
|
76
|
+
.jsoneditor .value.highlight-active:focus,
|
|
77
|
+
.jsoneditor .value.highlight-active:hover {
|
|
78
|
+
background-color: #ffee00;
|
|
79
|
+
border: 1px solid #ffc700;
|
|
80
|
+
border-radius: 2px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.jsoneditor button {
|
|
84
|
+
width: 24px;
|
|
85
|
+
height: 24px;
|
|
86
|
+
padding: 0;
|
|
87
|
+
margin: 0;
|
|
88
|
+
border: none;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
background: transparent url('img/jsoneditor-icons.png');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.jsoneditor button.collapsed {
|
|
94
|
+
background-position: 0 -48px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.jsoneditor button.expanded {
|
|
98
|
+
background-position: 0 -72px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.jsoneditor button.contextmenu {
|
|
102
|
+
background-position: -48px -72px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.jsoneditor button.contextmenu:hover,
|
|
106
|
+
.jsoneditor button.contextmenu:focus,
|
|
107
|
+
.jsoneditor button.contextmenu.selected {
|
|
108
|
+
background-position: -48px -48px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.jsoneditor div.content *:focus {
|
|
112
|
+
outline: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.jsoneditor div.content button:focus {
|
|
116
|
+
/* TODO: nice outline for buttons with focus
|
|
117
|
+
outline: #97B0F8 solid 2px;
|
|
118
|
+
box-shadow: 0 0 8px #97B0F8;
|
|
119
|
+
*/
|
|
120
|
+
background-color: #f5f5f5;
|
|
121
|
+
outline: #e5e5e5 solid 1px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.jsoneditor button.invisible {
|
|
125
|
+
visibility: hidden;
|
|
126
|
+
background: none;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
div.jsoneditor {
|
|
130
|
+
color: #1A1A1A;
|
|
131
|
+
border: 1px solid #97B0F8;
|
|
132
|
+
-moz-box-sizing: border-box;
|
|
133
|
+
-webkit-box-sizing: border-box;
|
|
134
|
+
box-sizing: border-box;
|
|
135
|
+
width: 100%;
|
|
136
|
+
height: 100%;
|
|
137
|
+
overflow: auto;
|
|
138
|
+
position: relative;
|
|
139
|
+
padding: 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.jsoneditor table.content {
|
|
143
|
+
border-collapse: collapse;
|
|
144
|
+
border-spacing: 0;
|
|
145
|
+
width: 100%;
|
|
146
|
+
margin: 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.jsoneditor div.outer {
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: 100%;
|
|
152
|
+
margin: -35px 0 0 0;
|
|
153
|
+
padding: 35px 0 0 0;
|
|
154
|
+
|
|
155
|
+
-moz-box-sizing: border-box;
|
|
156
|
+
-webkit-box-sizing: border-box;
|
|
157
|
+
box-sizing: border-box;
|
|
158
|
+
|
|
159
|
+
overflow: hidden;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.jsoneditor div.content {
|
|
163
|
+
width: 100%;
|
|
164
|
+
height: 100%;
|
|
165
|
+
position: relative;
|
|
166
|
+
overflow: auto;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.jsoneditor textarea.content {
|
|
170
|
+
width: 100%;
|
|
171
|
+
height: 100%;
|
|
172
|
+
margin: 0;
|
|
173
|
+
|
|
174
|
+
-moz-box-sizing: border-box;
|
|
175
|
+
-webkit-box-sizing: border-box;
|
|
176
|
+
box-sizing: border-box;
|
|
177
|
+
|
|
178
|
+
border: none;
|
|
179
|
+
background-color: white;
|
|
180
|
+
resize: none;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.jsoneditor tr.highlight {
|
|
184
|
+
background-color: #FFFFAB;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.jsoneditor button.dragarea {
|
|
188
|
+
background: url('img/jsoneditor-icons.png') -72px -72px;
|
|
189
|
+
cursor: move;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.jsoneditor button.dragarea:hover,
|
|
193
|
+
.jsoneditor button.dragarea:focus {
|
|
194
|
+
background-position: -72px -48px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.jsoneditor tr,
|
|
198
|
+
.jsoneditor th,
|
|
199
|
+
.jsoneditor td {
|
|
200
|
+
padding: 0;
|
|
201
|
+
margin: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.jsoneditor td {
|
|
205
|
+
vertical-align: top;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.jsoneditor td.tree {
|
|
209
|
+
vertical-align: top;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.jsoneditor .field,
|
|
213
|
+
.jsoneditor .value,
|
|
214
|
+
.jsoneditor td,
|
|
215
|
+
.jsoneditor th,
|
|
216
|
+
.jsoneditor textarea {
|
|
217
|
+
font-family: droid sans mono, monospace, courier new, courier, sans-serif;
|
|
218
|
+
font-size: 10pt;
|
|
219
|
+
color: #1A1A1A;
|
|
220
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
|
|
2
|
+
.jsoneditor .menu {
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 35px;
|
|
5
|
+
padding: 2px;
|
|
6
|
+
margin: 0;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
-moz-box-sizing: border-box;
|
|
9
|
+
-webkit-box-sizing: border-box;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
|
|
12
|
+
color: #1A1A1A;
|
|
13
|
+
background-color: #D5DDF6;
|
|
14
|
+
border-bottom: 1px solid #97B0F8;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.jsoneditor .menu button {
|
|
18
|
+
width: 26px;
|
|
19
|
+
height: 26px;
|
|
20
|
+
margin: 2px;
|
|
21
|
+
padding: 2px;
|
|
22
|
+
border-radius: 2px;
|
|
23
|
+
border: 1px solid #aec0f8;
|
|
24
|
+
background: #e3eaf6 url('img/jsoneditor-icons.png');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.jsoneditor .menu button:hover {
|
|
28
|
+
background-color: #f0f2f5;
|
|
29
|
+
}
|
|
30
|
+
.jsoneditor .menu button:active {
|
|
31
|
+
background-color: #ffffff;
|
|
32
|
+
}
|
|
33
|
+
.jsoneditor .menu button:disabled {
|
|
34
|
+
background-color: #e3eaf6;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.jsoneditor .menu button.collapse-all {
|
|
38
|
+
background-position: 0 -96px;
|
|
39
|
+
}
|
|
40
|
+
.jsoneditor .menu button.expand-all {
|
|
41
|
+
background-position: 0 -120px;
|
|
42
|
+
}
|
|
43
|
+
.jsoneditor .menu button.undo {
|
|
44
|
+
background-position: -24px -96px;
|
|
45
|
+
}
|
|
46
|
+
.jsoneditor .menu button.undo:disabled {
|
|
47
|
+
background-position: -24px -120px;
|
|
48
|
+
}
|
|
49
|
+
.jsoneditor .menu button.redo {
|
|
50
|
+
background-position: -48px -96px;
|
|
51
|
+
}
|
|
52
|
+
.jsoneditor .menu button.redo:disabled {
|
|
53
|
+
background-position: -48px -120px;
|
|
54
|
+
}
|
|
55
|
+
.jsoneditor .menu button.compact {
|
|
56
|
+
background-position: -72px -96px;
|
|
57
|
+
}
|
|
58
|
+
.jsoneditor .menu button.format {
|
|
59
|
+
background-position: -72px -120px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.jsoneditor .menu a {
|
|
63
|
+
font-family: arial, sans-serif;
|
|
64
|
+
font-size: 10pt;
|
|
65
|
+
color: #97B0F8;
|
|
66
|
+
vertical-align: middle;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.jsoneditor .menu a:hover {
|
|
70
|
+
color: red;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.jsoneditor .menu a.poweredBy {
|
|
74
|
+
font-size: 8pt;
|
|
75
|
+
position: absolute;
|
|
76
|
+
right: 0;
|
|
77
|
+
top: 0;
|
|
78
|
+
padding: 10px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* TODO: css for button:disabled is not supported by IE8 */
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
|
|
2
|
+
.jsoneditor .search input,
|
|
3
|
+
.jsoneditor .search .results {
|
|
4
|
+
font-family: arial, sans-serif;
|
|
5
|
+
font-size: 10pt;
|
|
6
|
+
color: #1A1A1A;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.jsoneditor .search {
|
|
10
|
+
position: absolute;
|
|
11
|
+
right: 2px;
|
|
12
|
+
top: 2px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.jsoneditor .search .frame {
|
|
16
|
+
border: 1px solid #97B0F8;
|
|
17
|
+
background-color: white;
|
|
18
|
+
padding: 0 2px;
|
|
19
|
+
margin: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.jsoneditor .search .frame table {
|
|
23
|
+
border-collapse: collapse;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.jsoneditor .search input {
|
|
27
|
+
width: 120px;
|
|
28
|
+
border: none;
|
|
29
|
+
outline: none;
|
|
30
|
+
margin: 1px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.jsoneditor .search .results {
|
|
34
|
+
color: #4d4d4d;
|
|
35
|
+
padding-right: 5px;
|
|
36
|
+
line-height: 24px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.jsoneditor .search button {
|
|
40
|
+
width: 16px;
|
|
41
|
+
height: 24px;
|
|
42
|
+
padding: 0;
|
|
43
|
+
margin: 0;
|
|
44
|
+
border: none;
|
|
45
|
+
background: url('img/jsoneditor-icons.png');
|
|
46
|
+
vertical-align: top;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.jsoneditor .search button:hover {
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.jsoneditor .search button.refresh {
|
|
54
|
+
width: 18px;
|
|
55
|
+
background-position: -99px -73px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.jsoneditor .search button.next {
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
background-position: -124px -73px;
|
|
61
|
+
}
|
|
62
|
+
.jsoneditor .search button.next:hover {
|
|
63
|
+
background-position: -124px -49px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.jsoneditor .search button.previous {
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
background-position: -148px -73px;
|
|
69
|
+
margin-right: 2px;
|
|
70
|
+
}
|
|
71
|
+
.jsoneditor .search button.previous:hover {
|
|
72
|
+
background-position: -148px -49px;
|
|
73
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @constructor AppendNode
|
|
3
|
+
* @extends Node
|
|
4
|
+
* @param {TreeEditor} editor
|
|
5
|
+
* Create a new AppendNode. This is a special node which is created at the
|
|
6
|
+
* end of the list with childs for an object or array
|
|
7
|
+
*/
|
|
8
|
+
function AppendNode (editor) {
|
|
9
|
+
/** @type {TreeEditor} */
|
|
10
|
+
this.editor = editor;
|
|
11
|
+
this.dom = {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
AppendNode.prototype = new Node();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Return a table row with an append button.
|
|
18
|
+
* @return {Element} dom TR element
|
|
19
|
+
*/
|
|
20
|
+
AppendNode.prototype.getDom = function () {
|
|
21
|
+
// TODO: implement a new solution for the append node
|
|
22
|
+
var dom = this.dom;
|
|
23
|
+
|
|
24
|
+
if (dom.tr) {
|
|
25
|
+
return dom.tr;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// a row for the append button
|
|
29
|
+
var trAppend = document.createElement('tr');
|
|
30
|
+
trAppend.node = this;
|
|
31
|
+
dom.tr = trAppend;
|
|
32
|
+
|
|
33
|
+
// TODO: consistent naming
|
|
34
|
+
|
|
35
|
+
if (this.editor.mode.edit) {
|
|
36
|
+
// a cell for the dragarea column
|
|
37
|
+
dom.tdDrag = document.createElement('td');
|
|
38
|
+
|
|
39
|
+
// create context menu
|
|
40
|
+
var tdMenu = document.createElement('td');
|
|
41
|
+
dom.tdMenu = tdMenu;
|
|
42
|
+
var menu = document.createElement('button');
|
|
43
|
+
menu.className = 'contextmenu';
|
|
44
|
+
menu.title = 'Click to open the actions menu (Ctrl+M)';
|
|
45
|
+
dom.menu = menu;
|
|
46
|
+
tdMenu.appendChild(dom.menu);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// a cell for the contents (showing text 'empty')
|
|
50
|
+
var tdAppend = document.createElement('td');
|
|
51
|
+
var domText = document.createElement('div');
|
|
52
|
+
domText.innerHTML = '(empty)';
|
|
53
|
+
domText.className = 'readonly';
|
|
54
|
+
tdAppend.appendChild(domText);
|
|
55
|
+
dom.td = tdAppend;
|
|
56
|
+
dom.text = domText;
|
|
57
|
+
|
|
58
|
+
this.updateDom();
|
|
59
|
+
|
|
60
|
+
return trAppend;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Update the HTML dom of the Node
|
|
65
|
+
*/
|
|
66
|
+
AppendNode.prototype.updateDom = function () {
|
|
67
|
+
var dom = this.dom;
|
|
68
|
+
var tdAppend = dom.td;
|
|
69
|
+
if (tdAppend) {
|
|
70
|
+
tdAppend.style.paddingLeft = (this.getLevel() * 24 + 26) + 'px';
|
|
71
|
+
// TODO: not so nice hard coded offset
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var domText = dom.text;
|
|
75
|
+
if (domText) {
|
|
76
|
+
domText.innerHTML = '(empty ' + this.parent.type + ')';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// attach or detach the contents of the append node:
|
|
80
|
+
// hide when the parent has childs, show when the parent has no childs
|
|
81
|
+
var trAppend = dom.tr;
|
|
82
|
+
if (!this.isVisible()) {
|
|
83
|
+
if (dom.tr.firstChild) {
|
|
84
|
+
if (dom.tdDrag) {
|
|
85
|
+
trAppend.removeChild(dom.tdDrag);
|
|
86
|
+
}
|
|
87
|
+
if (dom.tdMenu) {
|
|
88
|
+
trAppend.removeChild(dom.tdMenu);
|
|
89
|
+
}
|
|
90
|
+
trAppend.removeChild(tdAppend);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
if (!dom.tr.firstChild) {
|
|
95
|
+
if (dom.tdDrag) {
|
|
96
|
+
trAppend.appendChild(dom.tdDrag);
|
|
97
|
+
}
|
|
98
|
+
if (dom.tdMenu) {
|
|
99
|
+
trAppend.appendChild(dom.tdMenu);
|
|
100
|
+
}
|
|
101
|
+
trAppend.appendChild(tdAppend);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Check whether the AppendNode is currently visible.
|
|
108
|
+
* the AppendNode is visible when its parent has no childs (i.e. is empty).
|
|
109
|
+
* @return {boolean} isVisible
|
|
110
|
+
*/
|
|
111
|
+
AppendNode.prototype.isVisible = function () {
|
|
112
|
+
return (this.parent.childs.length == 0);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Show a contextmenu for this node
|
|
117
|
+
* @param {HTMLElement} anchor The element to attach the menu to.
|
|
118
|
+
* @param {function} [onClose] Callback method called when the context menu
|
|
119
|
+
* is being closed.
|
|
120
|
+
*/
|
|
121
|
+
AppendNode.prototype.showContextMenu = function (anchor, onClose) {
|
|
122
|
+
var node = this;
|
|
123
|
+
var titles = Node.TYPE_TITLES;
|
|
124
|
+
var items = [
|
|
125
|
+
// create append button
|
|
126
|
+
{
|
|
127
|
+
'text': 'Append',
|
|
128
|
+
'title': 'Append a new field with type \'auto\' (Ctrl+Shift+Ins)',
|
|
129
|
+
'submenuTitle': 'Select the type of the field to be appended',
|
|
130
|
+
'className': 'insert',
|
|
131
|
+
'click': function () {
|
|
132
|
+
node._onAppend('', '', 'auto');
|
|
133
|
+
},
|
|
134
|
+
'submenu': [
|
|
135
|
+
{
|
|
136
|
+
'text': 'Auto',
|
|
137
|
+
'className': 'type-auto',
|
|
138
|
+
'title': titles.auto,
|
|
139
|
+
'click': function () {
|
|
140
|
+
node._onAppend('', '', 'auto');
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
'text': 'Array',
|
|
145
|
+
'className': 'type-array',
|
|
146
|
+
'title': titles.array,
|
|
147
|
+
'click': function () {
|
|
148
|
+
node._onAppend('', []);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
'text': 'Object',
|
|
153
|
+
'className': 'type-object',
|
|
154
|
+
'title': titles.object,
|
|
155
|
+
'click': function () {
|
|
156
|
+
node._onAppend('', {});
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
'text': 'String',
|
|
161
|
+
'className': 'type-string',
|
|
162
|
+
'title': titles.string,
|
|
163
|
+
'click': function () {
|
|
164
|
+
node._onAppend('', '', 'string');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
var menu = new ContextMenu(items, {close: onClose});
|
|
172
|
+
menu.show(anchor);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Handle an event. The event is catched centrally by the editor
|
|
177
|
+
* @param {Event} event
|
|
178
|
+
*/
|
|
179
|
+
AppendNode.prototype.onEvent = function (event) {
|
|
180
|
+
var type = event.type;
|
|
181
|
+
var target = event.target || event.srcElement;
|
|
182
|
+
var dom = this.dom;
|
|
183
|
+
|
|
184
|
+
// highlight the append nodes parent
|
|
185
|
+
var menu = dom.menu;
|
|
186
|
+
if (target == menu) {
|
|
187
|
+
if (type == 'mouseover') {
|
|
188
|
+
this.editor.highlighter.highlight(this.parent);
|
|
189
|
+
}
|
|
190
|
+
else if (type == 'mouseout') {
|
|
191
|
+
this.editor.highlighter.unhighlight();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// context menu events
|
|
196
|
+
if (type == 'click' && target == dom.menu) {
|
|
197
|
+
var highlighter = this.editor.highlighter;
|
|
198
|
+
highlighter.highlight(this.parent);
|
|
199
|
+
highlighter.lock();
|
|
200
|
+
util.addClassName(dom.menu, 'selected');
|
|
201
|
+
this.showContextMenu(dom.menu, function () {
|
|
202
|
+
util.removeClassName(dom.menu, 'selected');
|
|
203
|
+
highlighter.unlock();
|
|
204
|
+
highlighter.unhighlight();
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (type == 'keydown') {
|
|
209
|
+
this.onKeyDown(event);
|
|
210
|
+
}
|
|
211
|
+
};
|