-
Notifications
You must be signed in to change notification settings - Fork 5
/
editable-json.html
19 lines (10 loc) · 3.19 KB
/
editable-json.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<template name="editableJSON"><div class="editable-JSON"><div class="editable-JSON-click-zone editable-JSON-top-level">{{#if collection}}{{#with document}}{{> editable_JSON_object}}{{/with}}{{else}}{{#with observe}}{{watcher}}{{> editable_JSON_object}}{{else}}{{#with json}}{{> editable_JSON_object}}{{else}}{{> editable_JSON_object}}{{/with}}{{/with}}{{/if}}</div></div></template>
<template name="editable_JSON">{{#each fields}}<div class="editable-JSON-click-zone">{{#with field}}<span class="editable-JSON-field {{_idClass}}">"{{#with editingField}}<input type="text" value="{{this}}" />{{else}}<span class="editable-JSON-field-text">{{this}}</span>{{/with}}":</span> {{/with}}{{#with value}}{{#if isArray}}{{> editable_JSON_array val}}{{else}}{{#if isDate}}{{> editable_JSON_date val}}{{else}}{{#if isString}}{{> editable_JSON_string val}}{{else}}{{#if isBoolean}}{{> editable_JSON_boolean val}}{{else}}{{#if isObject}}{{> editable_JSON_object val}}{{else}}{{#if isNumber}}{{> editable_JSON_number val}}{{else}}{{# if isNull}}{{> editable_JSON_null val}}{{/if}}{{/if}}{{/if}}{{/if}}{{/if}}{{/if}}{{/if}}{{/with}}{{#unless last ..}},{{/unless}}</div>{{/each}}</template>
<template name="editable_JSON_array">{{#with elements}}[<div class="editable-JSON-indent">{{#each this}}{{> editable_JSON element}}{{/each}}</div><span class="editable-JSON-closer">]</span>{{else}}<span class="editableJSON-empty-object">[]</span>{{/with}}{{#if ../arrayComma}},{{/if}}</template>
<template name="editable_JSON_object">{{#if notEmpty}}{<div class="editable-JSON-indent">{{> editable_JSON this}}</div><span class="editable-JSON-closer">}</span>{{else}}<span class="editableJSON-empty-object">{}</span>{{/if}}{{#if ../arrayComma}},{{/if}}</template>
<template name="editable_JSON_string"><span class="editable-JSON-string {{#if _idField}}editable-JSON-_id-value{{/if}}">"{{#if editable_JSON_collection}}{{#with editable_JSON_getField}}{{> editableJSONInput value=.. field=this collection=editable_JSON_collection}}{{else}}{{this}}{{/with}}{{else}}{{#if _idField}}{{this}}{{else}}{{> editableJSONInput value=this field=editable_JSON_getField}}{{/if}}{{/if}}"</span>{{#if ../arrayComma}},{{/if}}</template>
<template name="editable_JSON_boolean"><span class="editable-JSON-boolean">{{boolean}}</span>{{#if ../arrayComma}},{{/if}}</template>
<template name="editable_JSON_date"><span class="editable-JSON-date"><span class="editable-JSON-string">"<input type="text" value="{{date}}" />"</span></span>{{#if ../arrayComma}},{{/if}}</template>
<template name="editable_JSON_number"><span class="editable-JSON-number editable-text-trigger">{{#if editable_JSON_collection}}{{#with editable_JSON_getField}}{{> editableJSONInput value=.. field=this collection=editable_JSON_collection number=true}}{{else}}{{this}}{{/with}}{{else}}{{> editableJSONInput value=this field=editable_JSON_getField number=true}}{{/if}}</span>{{#if ../arrayComma}},{{/if}}</template>
<template name="editable_JSON_null"><span class="editable-JSON-null">null</span>{{#if ../arrayComma}},{{/if}}</template>
<template name="editableJSONInput">{{#if editing}}<input type="text" class="editable-JSON-input" value="{{value}}" />{{else}}<span class="editable-JSON-edit">{{value}}</span>{{/if}}</template>