|
1 |
| -if (!myApp) { // Check if myApp is loaded |
2 |
| - var myApp = new Object(); |
3 |
| -}; |
4 |
| -if (!myApp.hasOwnProperty("schema")) { |
5 |
| - myApp.schema = new Object(); |
6 |
| -}; |
7 |
| - |
8 |
| -// Now we can load the schema |
9 |
| - |
10 |
| -myApp.schema.document = { |
11 |
| - "$schema": "http://coverbuilder.brunoherfst.com/schemas/document#", |
12 |
| - |
13 |
| - // S T A R T D E F I N I N I T I O N S |
14 |
| - // ------------------------------------- |
15 |
| - |
16 |
| - "definitions": { |
17 |
| - |
18 |
| - "positiveNumber": { |
19 |
| - "description" : "A positive number", |
20 |
| - "type" : "number", |
21 |
| - "minimum" : 0, |
22 |
| - "default" : 0 |
23 |
| - }, |
| 1 | +(function () { |
| 2 | + |
| 3 | + var VERSION = 0.1; |
| 4 | + var MODULE_PATH = "schema.document"; |
| 5 | + |
| 6 | + var load = Sky.getUtil(MODULE_PATH); |
| 7 | + if( load && load.version >= VERSION) { |
| 8 | + return; |
| 9 | + }; |
| 10 | + |
| 11 | + //-------------------------- |
| 12 | + // set load |
| 13 | + |
| 14 | + load = { |
| 15 | + "title": "General Document", |
| 16 | + "description": "A general document description.", |
| 17 | + "version": "0.1", |
| 18 | + |
| 19 | + // S T A R T D E F I N I N I T I O N S |
| 20 | + // ------------------------------------- |
| 21 | + |
| 22 | + "definitions": { |
| 23 | + |
| 24 | + "positiveNumber": { |
| 25 | + "description" : "A positive number", |
| 26 | + "type" : "number", |
| 27 | + "minimum" : 0, |
| 28 | + "default" : 0 |
| 29 | + }, |
24 | 30 |
|
25 |
| - "units": { |
26 |
| - "description" : "Measurement unit", |
27 |
| - "type" : ["string","integer"] |
28 |
| - }, |
| 31 | + "units": { |
| 32 | + "description" : "Measurement unit", |
| 33 | + "type" : ["string","integer"] |
| 34 | + }, |
29 | 35 |
|
30 |
| - "measurement": { |
31 |
| - "description" : "An InDesign measurement value", |
32 |
| - "type" : "object", |
33 |
| - "properties" : { |
34 |
| - "value" : { "type" : "number" }, |
35 |
| - "units" : { "$ref": "#/definitions/units" } |
| 36 | + "measurement": { |
| 37 | + "description" : "An InDesign measurement value", |
| 38 | + "type" : "object", |
| 39 | + "properties" : { |
| 40 | + "value" : { "type" : "number" }, |
| 41 | + "units" : { "$ref": "#/definitions/units" } |
| 42 | + }, |
| 43 | + "required" : ["value", "units"] |
36 | 44 | },
|
37 |
| - "required" : ["value", "units"] |
38 |
| - }, |
39 | 45 |
|
40 |
| - "positive_measurement": { |
41 |
| - "description" : "An InDesign measurement value", |
42 |
| - "type" : "object", |
43 |
| - "properties" : { |
44 |
| - "value" : { "$ref": "#/definitions/positiveNumber" }, |
45 |
| - "units" : { "$ref": "#/definitions/units" } |
| 46 | + "positive_measurement": { |
| 47 | + "description" : "An InDesign measurement value", |
| 48 | + "type" : "object", |
| 49 | + "properties" : { |
| 50 | + "value" : { "$ref": "#/definitions/positiveNumber" }, |
| 51 | + "units" : { "$ref": "#/definitions/units" } |
| 52 | + }, |
| 53 | + "required" : ["value", "units"] |
46 | 54 | },
|
47 |
| - "required" : ["value", "units"] |
48 |
| - }, |
49 | 55 |
|
50 |
| - "label": { |
51 |
| - "description" : "A label object", |
52 |
| - "type": "object", |
53 |
| - "properties": { |
54 |
| - "label" : { "type": "string" }, |
55 |
| - "value" : { "type": "string" } |
56 |
| - } |
57 |
| - }, |
| 56 | + "label": { |
| 57 | + "description" : "A label object", |
| 58 | + "type": "object", |
| 59 | + "properties": { |
| 60 | + "label" : { "type": "string" }, |
| 61 | + "value" : { "type": "string" } |
| 62 | + } |
| 63 | + }, |
58 | 64 |
|
59 |
| - "labels": { |
60 |
| - "description" : "A collection of label objects", |
61 |
| - "type" : "array", |
62 |
| - "items": { "$ref": "#/definitions/label" } |
63 |
| - }, |
| 65 | + "labels": { |
| 66 | + "description" : "A collection of label objects", |
| 67 | + "type" : "array", |
| 68 | + "items": { "$ref": "#/definitions/label" } |
| 69 | + }, |
64 | 70 |
|
65 |
| - "bounds": { |
66 |
| - "description" : "Bounds in format [y1, x1, y2, x2]", |
67 |
| - "type" : "array" , "minItems": 4, "maxItems": 4, |
68 |
| - "items": { "type" : "number"} |
69 |
| - }, |
70 |
| - |
71 |
| - "guide": { |
72 |
| - "description" : "Guide", |
73 |
| - "type" : "object", |
74 |
| - "properties" : { |
75 |
| - "horizontal" : { "type" : "boolean" , "description" : "Is the guide horzontal, if false it is vertical" }, |
76 |
| - "location" : { "$ref": "#/definitions/measurement" }, |
77 |
| - "scriptLabel" : { "type" : "string" }, |
78 |
| - "labels" : { "$ref": "#/definitions/labels" } |
| 71 | + "bounds": { |
| 72 | + "description" : "Bounds in format [y1, x1, y2, x2]", |
| 73 | + "type" : "array" , "minItems": 4, "maxItems": 4, |
| 74 | + "items": { "type" : "number"} |
| 75 | + }, |
| 76 | + |
| 77 | + "guide": { |
| 78 | + "description" : "Guide", |
| 79 | + "type" : "object", |
| 80 | + "properties" : { |
| 81 | + "horizontal" : { "type" : "boolean" , "description" : "Is the guide horzontal, if false it is vertical" }, |
| 82 | + "location" : { "$ref": "#/definitions/measurement" }, |
| 83 | + "scriptLabel" : { "type" : "string" }, |
| 84 | + "labels" : { "$ref": "#/definitions/labels" } |
| 85 | + }, |
| 86 | + "required" : ["horizontal", "location"] |
79 | 87 | },
|
80 |
| - "required" : ["horizontal", "location"] |
81 |
| - }, |
82 | 88 |
|
83 |
| - "page": { |
84 |
| - "description" : "Single page (child of spread)", |
85 |
| - "type" : "object", |
86 |
| - "properties" : { |
87 |
| - "name" : { "type" : "st ring" , "description" : "Name of page" }, |
88 |
| - "scriptLabel" : { "type" : "string" }, |
89 |
| - "labels" : { "$ref": "#/definitions/labels" }, |
90 |
| - "width" : { "$ref": "#/definitions/positive_measurement" }, |
91 |
| - "height" : { "$ref": "#/definitions/positive_measurement" }, |
92 |
| - "bounds" : { "$ref": "#/definitions/bounds" }, |
93 |
| - "margins" : { |
94 |
| - "description" : "Margins", |
95 |
| - "type" : "object", |
96 |
| - "properties" : { |
97 |
| - "top" : { "$ref": "#/definitions/positive_measurement" }, |
98 |
| - "bottom" : { "$ref": "#/definitions/positive_measurement" }, |
99 |
| - "left" : { "$ref": "#/definitions/positive_measurement" }, |
100 |
| - "right" : { "$ref": "#/definitions/positive_measurement" } |
101 |
| - }, |
102 |
| - "required" : ["top","bottom","left","right"] |
103 |
| - }, |
104 |
| - "columnCount" : { "type" : "integer" , "minimum" : 1, "default" : 1}, |
105 |
| - "columnGutter" : { "$ref": "#/definitions/positive_measurement" }, |
106 |
| - "guides" : { "type" : "array", "items": { "$ref": "#/definitions/guide" }, "description" : "Guides relative to page" } |
| 89 | + "page": { |
| 90 | + "description" : "Single page (child of spread)", |
| 91 | + "type" : "object", |
| 92 | + "properties" : { |
| 93 | + "name" : { "type" : "st ring" , "description" : "Name of page" }, |
| 94 | + "scriptLabel" : { "type" : "string" }, |
| 95 | + "labels" : { "$ref": "#/definitions/labels" }, |
| 96 | + "width" : { "$ref": "#/definitions/positive_measurement" }, |
| 97 | + "height" : { "$ref": "#/definitions/positive_measurement" }, |
| 98 | + "bounds" : { "$ref": "#/definitions/bounds" }, |
| 99 | + "margins" : { |
| 100 | + "description" : "Margins", |
| 101 | + "type" : "object", |
| 102 | + "properties" : { |
| 103 | + "top" : { "$ref": "#/definitions/positive_measurement" }, |
| 104 | + "bottom" : { "$ref": "#/definitions/positive_measurement" }, |
| 105 | + "left" : { "$ref": "#/definitions/positive_measurement" }, |
| 106 | + "right" : { "$ref": "#/definitions/positive_measurement" } |
| 107 | + }, |
| 108 | + "required" : ["top","bottom","left","right"] |
| 109 | + }, |
| 110 | + "columnCount" : { "type" : "integer" , "minimum" : 1, "default" : 1}, |
| 111 | + "columnGutter" : { "$ref": "#/definitions/positive_measurement" }, |
| 112 | + "guides" : { "type" : "array", "items": { "$ref": "#/definitions/guide" }, "description" : "Guides relative to page" } |
| 113 | + }, |
| 114 | + "required" : ["width","height"] |
107 | 115 | },
|
108 |
| - "required" : ["width","height"] |
109 |
| - }, |
110 | 116 |
|
111 |
| - "spread": { |
112 |
| - "description" : "Spread description", |
113 |
| - "type" : "object", |
114 |
| - "properties" : { |
115 |
| - "name" : { "type" : "string" , "description" : "Name of spread" }, |
116 |
| - "namePrefix" : { "type" : "string" , "description" : "namePrefix of spread" }, |
117 |
| - "baseName" : { "type" : "string" , "description" : "baseName of spread" }, |
118 |
| - "scriptLabel" : { "type" : "string" }, |
119 |
| - "labels" : { "$ref": "#/definitions/labels" }, |
120 |
| - "bounds" : { "$ref": "#/definitions/bounds" }, |
121 |
| - "pages" : { "type" : "array", "items": { "$ref": "#/definitions/page" } , "description" : "All the pages in this spread" }, |
122 |
| - "guides" : { "type" : "array", "items": { "$ref": "#/definitions/guide" } , "description" : "Guides relative to spread" } |
| 117 | + "spread": { |
| 118 | + "description" : "Spread description", |
| 119 | + "type" : "object", |
| 120 | + "properties" : { |
| 121 | + "name" : { "type" : "string" , "description" : "Name of spread" }, |
| 122 | + "namePrefix" : { "type" : "string" , "description" : "namePrefix of spread" }, |
| 123 | + "baseName" : { "type" : "string" , "description" : "baseName of spread" }, |
| 124 | + "scriptLabel" : { "type" : "string" }, |
| 125 | + "labels" : { "$ref": "#/definitions/labels" }, |
| 126 | + "bounds" : { "$ref": "#/definitions/bounds" }, |
| 127 | + "pages" : { "type" : "array", "items": { "$ref": "#/definitions/page" } , "description" : "All the pages in this spread" }, |
| 128 | + "guides" : { "type" : "array", "items": { "$ref": "#/definitions/guide" } , "description" : "Guides relative to spread" } |
| 129 | + }, |
| 130 | + "required" : ["name","pages"] |
123 | 131 | },
|
124 |
| - "required" : ["name","pages"] |
125 |
| - }, |
126 | 132 |
|
127 |
| - "layer": { |
128 |
| - "description" : "Document Layer", |
129 |
| - "type" : "object", |
130 |
| - "properties": { |
131 |
| - "name" : { "type": "string" }, |
132 |
| - "scriptLabel" : { "type" : "string" }, |
133 |
| - "labels" : { "$ref": "#/definitions/labels" }, |
134 |
| - "locked" : { "type": "boolean", "default" : false } |
| 133 | + "layer": { |
| 134 | + "description" : "Document Layer", |
| 135 | + "type" : "object", |
| 136 | + "properties": { |
| 137 | + "name" : { "type": "string" }, |
| 138 | + "scriptLabel" : { "type" : "string" }, |
| 139 | + "labels" : { "$ref": "#/definitions/labels" }, |
| 140 | + "locked" : { "type": "boolean", "default" : false } |
| 141 | + } |
135 | 142 | }
|
136 |
| - } |
137 | 143 |
|
138 |
| - }, |
| 144 | + }, |
139 | 145 |
|
140 | 146 |
|
141 |
| - // E N D D E F I N I N I T I O N S |
142 |
| - // --------------------------------- |
| 147 | + // E N D D E F I N I N I T I O N S |
| 148 | + // --------------------------------- |
143 | 149 |
|
144 | 150 | "type": "object",
|
145 | 151 |
|
@@ -181,4 +187,10 @@ myApp.schema.document = {
|
181 | 187 | },
|
182 | 188 |
|
183 | 189 | "required" : ["name"]
|
184 |
| -}; |
| 190 | + }; |
| 191 | + //-------------------------- |
| 192 | + // End document schema |
| 193 | + |
| 194 | + Sky.setUtil(schema.document, load); |
| 195 | + |
| 196 | +})(); |
0 commit comments