1 | define( ['dojo', 'dijit'],
|
---|
2 | function(dojo, dijit) {
|
---|
3 | dojo.provide('rft.ui.InnerWidgetFactory');
|
---|
4 | dojo.provide('rft.ui.HeaderItem');
|
---|
5 | dojo.declare('rft.ui.InnerWidgetFactory', [],{
|
---|
6 | /* No default type, all should be valid */
|
---|
7 | createWidget: function(/*Object*/ options) {
|
---|
8 | // options: Object
|
---|
9 | // type: "header", "text", textinput, etc.
|
---|
10 | // contents: "text"
|
---|
11 | // disabled: bool
|
---|
12 | return this['create'+options.widgetType+'Widget'](options);
|
---|
13 | },
|
---|
14 | createHeaderWidget: function(options) {
|
---|
15 | var headerWidget = new rft.ui.HeaderItem();
|
---|
16 | headerWidget.setObject(options);
|
---|
17 | return headerWidget;
|
---|
18 | },
|
---|
19 | createTextWidget: function(options) {
|
---|
20 | var textWidget = new rft.ui.TextItem();
|
---|
21 | textWidget.setObject(options);
|
---|
22 | return textWidget;
|
---|
23 | },
|
---|
24 | createFreeTextInputWidget: function(options) {
|
---|
25 | return new rft.ui.FreeTextInput();
|
---|
26 | }
|
---|
27 | });
|
---|
28 |
|
---|
29 | /* Contents */
|
---|
30 | dojo.declare('rft.ui.HeaderItem', dijit.form.TextBox, {
|
---|
31 | getObject: function() {
|
---|
32 | return { widgetType : 'Header',
|
---|
33 | contents: this.get('value'),
|
---|
34 | disabled: this.get('disabled')
|
---|
35 | };
|
---|
36 | },
|
---|
37 | setObject: function(object) {
|
---|
38 | this.set('value', object.contents);
|
---|
39 | if (object.disabled) {
|
---|
40 | this.set('disabled', true);
|
---|
41 | }
|
---|
42 | }
|
---|
43 | });
|
---|
44 |
|
---|
45 | dojo.declare('rft.ui.TextItem', dijit.form.Textarea, {
|
---|
46 | getObject: function() {
|
---|
47 | return { widgetType : 'Text',
|
---|
48 | contents: this.get('value'),
|
---|
49 | disabled: this.get('disabled')
|
---|
50 | };
|
---|
51 | },
|
---|
52 | setObject: function(object) {
|
---|
53 | this.set('value', object.contents);
|
---|
54 | if (object.disabled) {
|
---|
55 | this.set('disabled', true);
|
---|
56 | }
|
---|
57 | }
|
---|
58 | });
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 | /* Inputs */
|
---|
63 | dojo.declare('rft.ui.FreeTextInput', dijit.form.Textarea, {
|
---|
64 | getObject: function() {
|
---|
65 | return { widgetType: 'FreeTextInput' };
|
---|
66 | }
|
---|
67 | });
|
---|
68 | }
|
---|
69 | )
|
---|