Skip to content

Commit ff3a2bb

Browse files
author
daffl
committed
Further drafts for converters
1 parent 6a47e30 commit ff3a2bb

File tree

7 files changed

+67
-11
lines changed

7 files changed

+67
-11
lines changed

build/build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<file name="dform.js" />
4848
<file name="dform.plugins.js" />
4949
<file name="dform.subscribers.js" />
50+
<file name="dform.converters.js" />
5051
<file name="dform.extensions.js" />
5152
</filelist>
5253
</concat>

build/docdata/Menu.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Title: jQuery::dForm 0.1.3
66
# You can also add a sub-title to your menu like this:
77
# SubTitle: [subtitle]
88

9-
Footer: Copyright (C) 2010 - David Luecke - daff@neyeon.de
9+
Footer: Copyright (C) 2011 - David Luecke - daff@neyeon.de
1010

1111
# You can add a timestamp to your documentation like one of these:
1212
# Timestamp: Generated on month day, year

src/dform.converters.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* jQuery dform plugin
3+
* Copyright (C) 2011 David Luecke <daff@neyeon.de>
4+
*
5+
* Licensed under the MIT license
6+
*/
7+
8+
/**
9+
*
10+
*/
11+
(function($)
12+
{
13+
$.dform.converters = {
14+
"dform" : function(data)
15+
{
16+
return data;
17+
},
18+
19+
"json" : function(data)
20+
{
21+
22+
},
23+
24+
"json-schema" : function(data)
25+
{
26+
var dform = { elements : [] };
27+
28+
for (var propName in schema.properties) {
29+
var property = schema.properties[propName];
30+
var type = property.type;
31+
if (type == "string") {
32+
var value = obj[propName];
33+
if (!value) value = "";
34+
var element = {
35+
"name" : "ui-form-" + propName,
36+
"id" : "ui-form-" + propName,
37+
"caption" : property.title,
38+
"type" : "text",
39+
"value" : value
40+
};
41+
dform.elements.push(element);
42+
dform.elements.push({
43+
"type" : "br"
44+
});
45+
} else if (type == "object") {
46+
var element = jsonSchemaToDForm(property, obj);
47+
element.type = "fieldset";
48+
element.caption = property.title;
49+
dform.elements.push(element);
50+
}
51+
}
52+
return dform;
53+
}
54+
};
55+
})(jQuery);

src/dform.extensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* jQuery dform plugin
3-
* Copyright (C) 2010 David Luecke <daff@neyeon.de>
3+
* Copyright (C) 2011 David Luecke <daff@neyeon.de>
44
*
55
* Licensed under the MIT license
66
*/

src/dform.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* jQuery dform plugin
3-
* Copyright (C) 2010 David Luecke <daff@neyeon.de>
3+
* Copyright (C) 2011 David Luecke <daff@neyeon.de>
44
*
55
* Licensed under the MIT license
66
*/
@@ -331,13 +331,6 @@
331331
return $("<" + options.type + ">").dformAttr(options);
332332
}
333333
},
334-
converters :
335-
{
336-
dform : function(data)
337-
{
338-
return data;
339-
}
340-
},
341334
/**
342335
* section: Static helper functions
343336
*

src/dform.plugins.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
* jQuery dform plugin
3+
* Copyright (C) 2011 David Luecke <daff@neyeon.de>
4+
*
5+
* Licensed under the MIT license
6+
*/
7+
18
/**
29
*
310
*/

src/dform.subscribers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* jQuery dform plugin
3-
* Copyright (C) 2010 David Luecke <daff@neyeon.de>
3+
* Copyright (C) 2011 David Luecke <daff@neyeon.de>
44
*
55
* Licensed under the MIT license
66
*/

0 commit comments

Comments
 (0)