Skip to content

Commit 4ceda53

Browse files
committed
initial commit
0 parents  commit 4ceda53

File tree

10 files changed

+240
-0
lines changed

10 files changed

+240
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.idea
2+
/.sass-cache
3+
/bower_components
4+
/build/**
5+
/node_modules
6+
ssl.json
7+
8+
[Tt]humbs.db
9+
*.DS_Store

.jscs.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"excludeFiles": ["bower_components/**", "node_modules/**"],
3+
"disallowKeywords": ["with"],
4+
"disallowTrailingWhitespace": true,
5+
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
6+
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
7+
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
8+
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
9+
"disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
10+
"disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
11+
"requireRightStickedOperators": ["!"],
12+
"requireLeftStickedOperators": [","],
13+
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
14+
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
15+
"requireOperatorBeforeLineBreak": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
16+
"disallowImplicitTypeConversion": ["string", "numeric", "boolean"],
17+
"disallowMultipleLineBreaks": true,
18+
"disallowSpaceAfterObjectKeys": true,
19+
"disallowDanglingUnderscores": true,
20+
"disallowSpacesInsideParentheses": true,
21+
"disallowSpacesInsideArrayBrackets": true,
22+
"requireBlocksOnNewline": true,
23+
"disallowMixedSpacesAndTabs": true,
24+
"disallowKeywordsOnNewLine": ["else"],
25+
"safeContextKeyword": ["self"],
26+
"requireLineFeedAtFileEnd": true,
27+
"validateJSDoc": {
28+
"checkParamNames": true,
29+
"checkRedundantParams": true
30+
},
31+
"disallowSpacesInNamedFunctionExpression": {
32+
"beforeOpeningRoundBrace": true
33+
},
34+
"requireSpacesInNamedFunctionExpression": {
35+
"beforeOpeningCurlyBrace": true
36+
},
37+
"requireSpacesInAnonymousFunctionExpression": {
38+
"beforeOpeningRoundBrace": true,
39+
"beforeOpeningCurlyBrace": true
40+
}
41+
}

.jshintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bower_components/**
2+
node_modules/**

.jshintrc

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"bitwise": true,
3+
"curly": true,
4+
"eqeqeq": true,
5+
"forin": true,
6+
"immed": true,
7+
"latedef": true,
8+
"newcap": true,
9+
"noarg": true,
10+
"noempty": true,
11+
"nonew": true,
12+
"plusplus": false,
13+
"undef": true,
14+
"strict": true,
15+
"trailing": true,
16+
"quotmark": "single",
17+
"asi": false,
18+
"boss": false,
19+
"debug": true,
20+
"eqnull": false,
21+
"esnext": false,
22+
"evil": false,
23+
"expr": false,
24+
"funcscope": false,
25+
"globalstrict": false,
26+
"iterator": false,
27+
"lastsemic": false,
28+
"laxbreak": false,
29+
"laxcomma": false,
30+
"loopfunc": false,
31+
"camelcase": true,
32+
"freeze": true,
33+
"unused": "vars",
34+
"maxcomplexity": 8,
35+
"maxparams": 7,
36+
"maxlen": 120,
37+
"maxdepth": 4,
38+
"maxstatements": 15,
39+
"maxerr": 50,
40+
"indent": 4,
41+
"multistr": false,
42+
"proto": false,
43+
"scripturl": false,
44+
"smarttabs": false,
45+
"shadow": false,
46+
"sub": false,
47+
"supernew": false,
48+
"validthis": false,
49+
"browser": true,
50+
"devel": true,
51+
"jquery": false,
52+
"node": true,
53+
"nonstandard": false,
54+
"predef": [
55+
"angular"
56+
]
57+
}

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
JSON Editor Angular directive
2+
=============================
3+
4+
This is a directive that wraps jdorn's JSON Editor.
5+
6+
7+
Project is based on Angular-Seed by Qmerce

app/ng-json-editor.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict';
2+
3+
angular.module('ngJsonEditor', [])
4+
.directive('jsonEditor', function () {
5+
return {
6+
restrict: 'A',
7+
scope: false,
8+
/**
9+
* Linking function
10+
*/
11+
link: function (scope, element, attrs) {
12+
/* jshint camelcase:false */
13+
scope.isValid = false;
14+
//TODO: make this configurable
15+
console.log('attrs', attrs)
16+
var startval = {};
17+
if (scope.$parent && attrs.startval) {
18+
startval = scope.$parent[attrs.startval];
19+
}
20+
21+
22+
var editor = new JSONEditor(element[0], {
23+
ajax: true,
24+
startval: startval,
25+
iconlib: 'bootstrap3',
26+
theme: 'bootstrap3',
27+
schema: {
28+
$ref: attrs.jsonEditor
29+
}
30+
});
31+
32+
if (scope.$parent && attrs.editor) {
33+
scope.$parent[attrs.editor] = editor;
34+
35+
}
36+
37+
editor.on('ready', function () {
38+
scope.isValid = (editor.validate().length === 0);
39+
40+
editor.on('change', function () {
41+
42+
scope.$apply(function () {
43+
scope.isValid = (editor.validate().length === 0);
44+
});
45+
});
46+
});
47+
}
48+
};
49+
});

bower.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "ng-json-editor",
3+
"version": "0.0.1",
4+
"dependencies": {
5+
"json-editor": "*"
6+
},
7+
"devDependencies": {
8+
"angular": "1.2.*"
9+
}
10+
}

demo/app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
angular.module('demoApp', ['ngJsonEditor']);
4+
5+
angular.element(window.document).ready(function () {
6+
angular.bootstrap(window.document, ['demoApp']);
7+
});

demo/index.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6+
<meta name="author" content="Rodik">
7+
<meta name="description" content="">
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9+
<link type="image/x-icon" rel="icon" href="data:image/x-icon;base64,AAABAAEAAQECAAEAAQA4AAAAFgAAACgAAAABAAAAAgAAAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8AAAAAAAAAAAAAAAAA">
10+
11+
</head>
12+
<body>
13+
<div>
14+
Test
15+
<div json-editor="schema.json"></div>
16+
</div>
17+
<!-- build:template
18+
<% if (environment !== 'dev') { %>
19+
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
20+
<% } %>
21+
/build -->
22+
<!-- build:inlineJsBlock build/js/app.min.js -->
23+
24+
<!-- app.min.js will be inlined here and replace this entire block's content -->
25+
<script src="../bower_components/angular/angular.js"></script>
26+
<script src="../bower_components/json-editor/dist/jsoneditor.js"></script>
27+
28+
<script src="../app/ng-json-editor.js"></script>
29+
30+
<script src="../demo/app.js"></script>
31+
<!-- /build -->
32+
</body>
33+
</html>

demo/schema.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"type": "object",
3+
"title": "Item Object",
4+
"required": true,
5+
"additionalProperties": false,
6+
"properties": {
7+
"name": {
8+
"type": "string",
9+
"title": "Item Name",
10+
"required": true,
11+
"minLength": 1
12+
},
13+
"age": {
14+
"type": "integer",
15+
"title": "Age",
16+
"required": true,
17+
"min": 0
18+
},
19+
"isCool": {
20+
"type": "boolean",
21+
"title": "Is cool?",
22+
"required": true
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)