Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick commits from jdorn/json-editor #1

Merged
merged 20 commits into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ var name = editor.getEditor('root.name');
// `getEditor` will return null if the path is invalid
if(name) {
name.setValue("John Smith");

console.log(name.getValue());
}
```


### Validate

When feasible, JSON Editor won't let users enter invalid data. This is done by
When feasible, JSON Editor won't let users enter invalid data. This is done by
using input masks and intelligently enabling/disabling controls.

However, in some cases it is still possible to enter data that doesn't validate against the schema.
Expand Down Expand Up @@ -304,9 +304,11 @@ The currently supported themes are:
* foundation5
* jqueryui

The default theme is `html`, which doesn't use any special class names or styling.
The default theme is `html`, which does not rely on an external framework.
This default can be changed by setting the `JSONEditor.defaults.options.theme` variable.

If you want to specify your own styles with CSS, you can use `barebones`, which includes almost no classes or inline styles.

```javascript
JSONEditor.defaults.options.theme = 'foundation5';
```
Expand Down Expand Up @@ -416,6 +418,22 @@ Simple text link
}
```

Make link download when clicked
```js+jinja
{
"title": "Document filename",
"type": "string",
"links": [
{
"rel": "Download File",
"href": "/documents/{{self}}",
// Can also set `download` to a string as per the HTML5 spec
"download": true
}
]
}
```

Show a video preview (using HTML5 video)
```js+jinja
{
Expand Down Expand Up @@ -748,7 +766,7 @@ Editors can accept options which alter the behavior in some way.
},
"properties": {
"name": {
"type": "string"
"type": "string"
}
}
}
Expand All @@ -765,7 +783,7 @@ Dependencies
------------------
Sometimes, it's necessary to have one field's value depend on another's.

The `dependencies` keyword from the JSON Schema specification is not nearly flexible enough to handle most use cases,
The `dependencies` keyword from the JSON Schema specification is not nearly flexible enough to handle most use cases,
so JSON Editor introduces a couple custom keywords that help in this regard.

The first step is to have a field "watch" other fields for changes.
Expand Down Expand Up @@ -928,7 +946,7 @@ Then, we use the special keyword `enumSource` to tell JSON Editor that we want t

Now, anytime the `possible_colors` array changes, the dropdown's values will be changed as well.

This is the most basic usage of `enumSource`. The more verbose form of this property supports
This is the most basic usage of `enumSource`. The more verbose form of this property supports
filtering, pulling from multiple sources, constant values, etc..
Here's a more complex example (this uses the Swig template engine syntax to show some advanced features)

Expand Down Expand Up @@ -979,7 +997,7 @@ You can also specify a list of static items with a slightly different syntax:
}
```

The colors examples used an array of strings directly. Using the verbose form, you can
The colors examples used an array of strings directly. Using the verbose form, you can
also make it work with an array of objects. Here's an example:

```js+jinja
Expand Down Expand Up @@ -1040,7 +1058,7 @@ To accomplish this, use the `headerTemplate` property. All of the watched varia

### Custom Template Engines

If one of the included template engines isn't sufficient,
If one of the included template engines isn't sufficient,
you can use any custom template engine with a `compile` method. For example:

```js
Expand Down Expand Up @@ -1074,10 +1092,10 @@ You can easily override individual translations in the default language or creat

```js+jinja
// Override a specific translation
JSONEditor.defaults.languages.en.error_minLength =
JSONEditor.defaults.languages.en.error_minLength =
"This better be at least {{0}} characters long or else!";


// Create your own language mapping
// Any keys not defined here will fall back to the "en" language
JSONEditor.defaults.languages.es = {
Expand Down Expand Up @@ -1109,7 +1127,7 @@ JSONEditor.defaults.resolvers.unshift(function(schema) {
if(schema.type === "object" && schema.format === "location") {
return "location";
}

// If no valid editor is returned, the next resolver function will be used
});
```
Expand Down Expand Up @@ -1186,9 +1204,9 @@ $("#editor_holder")
.on('ready', function() {
// Get the value
var value = $(this).jsoneditor('value');

value.name = "John Smith";

// Set the value
$(this).jsoneditor('value',value);
});
Expand Down
Loading