- Timestamp:
- 08/08/12 15:10:30 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/content/ContentWidgetFactory.js
r391 r393 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dijit/_WidgetBase', 5 'dijit/_Container', 4 6 'dijit/form/NumberSpinner', 5 7 'dijit/form/Textarea', … … 8 10 'dojox/form/CheckedMultiSelect', 9 11 'dojox/layout/TableContainer' 10 ],function(declare, lang, NumberSpinner, Textarea, TextBox, StackContainer, CheckedMultiSelect, TableContainer) {12 ],function(declare, lang, _WidgetBase, _Container, NumberSpinner, Textarea, TextBox, StackContainer, CheckedMultiSelect, TableContainer) { 11 13 var factory = declare('rft.ui.content.ContentWidgetFactory', [], { 12 14 /* No default type, all should be valid */ … … 34 36 createHeaderEditWidget: function() { 35 37 return new HeaderEditItem(); 36 } /*,38 }, 37 39 38 40 createTextViewWidget: function(options) { … … 41 43 }); 42 44 }, 43 createTextEditWidget: function(options) { 44 return new TextEditItem({ 45 options: options 46 }); 47 }, 48 49 createFreeTextViewWidget: function(options) { 50 return new FreeTextViewItem({ 51 options: options 52 }); 53 }, 54 createFreeTextEditWidget: function(options) { 55 return new FreeTextEditItem({ 56 options: options 57 }); 58 }, 45 createTextEditWidget: function() { 46 return new TextEditItem(); 47 }, 48 49 createFreeTextInputViewWidget: function(options) { 50 return new FreeTextInputViewItem({ 51 options: options 52 }); 53 }, 54 createFreeTextInputEditWidget: function() { 55 return new FreeTextInputEditItem(); 56 }/*, 59 57 60 58 createIntegerViewWidget: function(options) { … … 82 80 83 81 /* Contents */ 84 var HeaderViewItem = declare(TextBox, { 85 postCreate: function() { 86 this.set('value', this.options.contents); 87 this.set('readOnly', true); 82 var HeaderViewItem = declare([_WidgetBase, _Container], { 83 _textBox: null, 84 postCreate: function() { 85 this._textBox = new TextBox(); 86 this._textBox.set('value', this.options.contents); 87 this._textBox.set('readOnly', true); 88 this.addChild(this._textBox); 88 89 }, 89 90 _getValueAttr: function() { 90 91 return { type: 'Header', 91 contents: this.get('displayedValue'), 92 } 93 } 94 }); 95 96 var HeaderEditItem = declare(TextBox, { 92 contents: this._textBox.get('displayedValue'), 93 }; 94 } 95 }); 96 97 var HeaderEditItem = declare([_WidgetBase, _Container], { 98 _textBox: null, 99 postCreate: function() { 100 this._textBox = new TextBox(); 101 this.addChild(this._textBox); 102 }, 97 103 _setValueAttr: function(value) { 98 this. inherited(arguments, [value.contents || ""]);104 this._textBox.set('value', value.contents || ""); 99 105 }, 100 106 _getValueAttr: function() { 101 107 return { type: 'Header', 102 contents: this.get('displayedValue'), 103 } 104 } 105 }); 106 107 var TextItem = declare(Textarea, { 108 getObject: function() { 108 contents: this._textBox.get('displayedValue'), 109 }; 110 } 111 }); 112 113 var TextViewItem = declare([_WidgetBase, _Container], { 114 _textArea: null, 115 postCreate: function() { 116 this._textArea = new Textarea(); 117 this._textArea.set('value', this.options.contents); 118 this._textArea.set('readOnly', true); 119 this.addChild(this._textArea); 120 }, 121 _getValueAttr: function() { 109 122 return { type: 'Text', 110 contents: this.get('value'), 111 disabled: this.get('disabled') 112 }; 113 }, 114 setObject: function(object) { 115 this.set('value', object.contents); 116 if (object.disabled) { 117 this.set('disabled', true); 118 } 119 } 120 }); 123 contents: this._textArea.get('displayedValue'), 124 }; 125 }, 126 }); 127 128 var TextEditItem = declare([_WidgetBase, _Container], { 129 _textArea: null, 130 postCreate: function() { 131 this._textArea = new Textarea(); 132 this.addChild(this._textArea); 133 }, 134 _setValueAttr: function(value) { 135 this._textArea.set('value', value.contents || ""); 136 }, 137 _getValueAttr: function() { 138 return { type: 'Text', 139 contents: this._textArea.get('displayedValue') 140 }; 141 } 142 }) 121 143 122 144 /* Inputs */ 123 var FreeTextInput = declare(Textarea, { 124 getObject: function() { 125 return { type: 'FreeTextInput' }; 126 } 127 }); 145 var FreeTextViewItem = declare(Textarea, { 146 postCreate: function() { 147 this.set('value', this.options.defaultValue); 148 this.set('readOnly', this.options.readOnly); 149 this._onBlur = undefined; 150 }, 151 _getValueAttr: function() { 152 return { type: "FreeText", 153 defaultValue: this.options.defaultValue, 154 readOnly: this.options.readOnly 155 }; 156 } 157 }); 158 159 var FreeTextEditItem = declare(Textarea, { 160 _setValueAttr: function(value) { 161 this.inherited(arguments, [value]) 162 } 163 }) 128 164 129 165 //Use CheckedMultiSelect
Note: See TracChangeset
for help on using the changeset viewer.