Skip to content

Commit

Permalink
Merge pull request #1 from jhnns/feature/upstream-cherry-pick
Browse files Browse the repository at this point in the history
Cherry pick commits from jdorn/json-editor
  • Loading branch information
Sascha Goldhofer committed Apr 20, 2016
2 parents c3fb2cf + b805878 commit dd352b1
Show file tree
Hide file tree
Showing 22 changed files with 484 additions and 342 deletions.
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

0 comments on commit dd352b1

Please sign in to comment.