Changeset 414 for Dev/branches/rest-dojo-ui/client/rft/ui/content
- Timestamp:
- 11/24/12 18:13:18 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/content/ContentWidgetFactory.js
r407 r414 9 9 'dijit/form/Button', 10 10 'dijit/form/CheckBox', 11 'dijit/form/Form', 11 12 'dijit/form/NumberSpinner', 12 13 'dijit/form/RadioButton', … … 16 17 './../lists/_EditableListMixin', 17 18 './../lists/OrderedList' 18 ],function(array, declare, lang, domConstruct, _TemplatedMixin, _WidgetBase, _Container, Button, CheckBox, NumberSpinner, RadioButton, Textarea, TextBox, TableContainer, _EditableListMixin, OrderedList) {19 ],function(array, declare, lang, domConstruct, _TemplatedMixin, _WidgetBase, _Container, Button, CheckBox, Form, NumberSpinner, RadioButton, Textarea, TextBox, TableContainer, _EditableListMixin, OrderedList) { 19 20 var factory = declare(null, { 20 21 createViewWidget: function(/*Object*/options) { … … 95 96 }); 96 97 98 var DefaultEdit = declare([Form,_Container],{ 99 type: null, 100 addChild: function(widget) { 101 domConstruct.create("label",{ 102 innerHTML: widget.title || '' 103 },this.containerNode,'last'); 104 this.inherited(arguments,[widget]); 105 }, 106 _getValueAttr: function() { 107 var val = this.inherited(arguments); 108 val.type = this.type; 109 return val; 110 } 111 }); 112 97 113 var HeaderView = declare([_WidgetBase], { 98 114 postCreate: function() { … … 101 117 }); 102 118 103 var HeaderEdit = declare([_WidgetBase, _Container], { 119 var HeaderEdit = declare([DefaultEdit], { 120 type: 'Header', 121 postCreate: function() { 122 this.inherited(arguments); 123 this.addChild(new TextBox({ 124 title: 'Content', 125 name: 'content' 126 })); 127 } 128 }); 129 130 var TextView = declare([_WidgetBase], { 131 postCreate: function() { 132 this.domNode.innerHTML = "<p>"+this.options.content+"</p>"; 133 } 134 }); 135 136 var TextEdit = declare([DefaultEdit], { 137 type: 'Text', 138 postCreate: function() { 139 this.inherited(arguments); 140 this.addChild(new Textarea({ 141 title: 'Content', 142 name: 'content' 143 })); 144 } 145 }); 146 147 var DividerView = declare([_WidgetBase], { 148 postCreate: function() { 149 this.domNode.innerHTML = "<hr>"; 150 } 151 }); 152 153 var DefaultInputEdit = declare([DefaultEdit],{ 154 postCreate: function() { 155 this.inherited(arguments); 156 this.addChild(new TextBox({ 157 title: 'Text', 158 name: 'text' 159 })); 160 } 161 }); 162 163 var StringInputView = declare([_WidgetBase, _Container],{ 104 164 _textBox: null, 105 165 postCreate: function() { 106 this._textBox = new TextBox(); 166 this._textBox = new TextBox({ 167 name: this.options.code || '' 168 }); 107 169 this.addChild(this._textBox); 108 170 this._textBox.startup(); 109 171 }, 110 _setValueAttr: function(value) {111 this._textBox.set('value', value.content || "");112 },113 _getValueAttr: function() {114 return { type: 'Header',115 content: this._textBox.get('displayedValue')116 };117 }118 });119 120 var TextView = declare([_WidgetBase], {121 postCreate: function() {122 this.domNode.innerHTML = "<p>"+this.options.content+"</p>";123 }124 });125 126 var TextEdit = declare([_WidgetBase, _Container], {127 _textArea: null,128 postCreate: function() {129 this._textArea = new Textarea();130 this.addChild(this._textArea);131 this._textArea.startup();132 },133 _setValueAttr: function(value) {134 this._textArea.set('value', value.content || "");135 },136 _getValueAttr: function() {137 return { type: 'Text',138 content: this._textArea.get('displayedValue')139 };140 }141 })142 143 var DividerView = declare([_WidgetBase], {144 postCreate: function() {145 this.domNode.innerHTML = "<hr>";146 }147 });148 149 var StringInputView = declare([_WidgetBase, _Container],{150 _textBox: null,151 postCreate: function() {152 this._textBox = new TextBox({153 name: this.options.code || ''154 });155 this.addChild(this._textBox);156 this._textBox.startup();157 },158 172 _setReadOnlyAttr: function(value) { 159 173 this._textBox.set('readOnly', value); … … 170 184 }); 171 185 172 var StringInputEdit = declare([_WidgetBase, _Container],{ 173 _codeInput: null, 174 postCreate: function() { 175 var table = new TableContainer({ cols: 1, customClass: "labelsAndValues"} ); 176 177 this._codeInput = new TextBox({ 178 title: "Code" 179 }); 180 table.addChild(this._codeInput); 181 this._codeInput.startup(); 182 183 this.addChild(table); 184 table.startup(); 185 }, 186 _getValueAttr: function() { 187 return { 188 type: "StringInput", 189 code: this._codeInput.get('value') || "" 190 }; 191 }, 192 _setValueAttr: function(value) { 193 this._codeInput.set('value', value.code || ""); 194 } 186 var StringInputEdit = declare([DefaultInputEdit],{ 187 type: 'StringInput' 195 188 }); 196 189 … … 217 210 }); 218 211 219 var TextInputEdit = declare([_WidgetBase, _Container], { 220 _codeInput: null, 221 _maxLengthInput: null, 222 postCreate: function() { 223 var table = new TableContainer({ cols: 1, customClass: "labelsAndValues"} ); 224 225 this._codeInput = new TextBox({ 226 title: "Code" 227 }); 228 table.addChild(this._codeInput); 229 this._codeInput.startup(); 230 231 this._maxLengthInput = new NumberSpinner({ 212 var TextInputEdit = declare([DefaultInputEdit], { 213 type: 'TextInput', 214 postCreate: function() { 215 this.inherited(arguments); 216 this.addChild(new NumberSpinner({ 217 name: 'maxLength', 232 218 title: "Maximum length", 233 219 constraints: { 234 220 min: 0 235 221 } 236 }); 237 table.addChild(this._maxLengthInput); 238 this._maxLengthInput.startup(); 239 240 this.addChild(table); 241 table.startup(); 242 }, 243 244 _setValueAttr: function(value) { 245 this._codeInput.set('value', value.code || ""); 246 this._maxLengthInput.set('value', value.maxLength); 247 }, 248 _getValueAttr: function() { 249 return { 250 type: "TextInput", 251 code: this._codeInput.get('value') || "", 252 maxLength: this._maxLengthInput.get('value') 253 }; 222 })); 254 223 } 255 224 }); … … 280 249 }); 281 250 282 var IntegerInputEdit = declare([_WidgetBase, _Container], { 283 _codeInput: null, 284 _minInput: null, 285 _maxInput: null, 286 postCreate: function() { 287 var table = new TableContainer({ cols: 1, customClass: "labelsAndValues"} ); 288 289 this._codeInput = new TextBox({ 290 title: "Code" 291 }); 292 table.addChild(this._codeInput); 293 this._codeInput.startup(); 294 295 this._minInput = new NumberSpinner({ 296 title: "Minimum" 297 }); 298 table.addChild(this._minInput); 299 this._minInput.startup(); 300 301 this._maxInput = new NumberSpinner({ 302 title: "Maximum" 303 }); 304 table.addChild(this._maxInput); 305 this._maxInput.startup(); 306 307 this._stepInput = new NumberSpinner({ 308 title: "Step" 309 }); 310 table.addChild(this._stepInput); 311 this._stepInput.startup(); 312 313 this.addChild(table); 314 table.startup(); 315 }, 316 317 _setValueAttr: function(value) { 318 this._codeInput.set('value', value.code || ""); 319 this._minInput.set('value', value.min); 320 this._maxInput.set('value', value.max); 321 this._stepInput.set('value', value.step); 322 }, 323 _getValueAttr: function() { 324 return { 325 type: "IntegerInput", 326 code: this._codeInput.get('value') || "", 327 min: this._minInput.get('value'), 328 max: this._maxInput.get('value'), 329 step: this._stepInput.get('value') 330 }; 251 var IntegerInputEdit = declare([DefaultInputEdit], { 252 type: 'IntegerInput', 253 postCreate: function() { 254 this.inherited(arguments); 255 this.addChild(new NumberSpinner({ 256 title: "Minimum", 257 name: 'min' 258 })); 259 this.addChild(new NumberSpinner({ 260 title: "Maximum", 261 name: 'max' 262 })); 263 this.addChild(new NumberSpinner({ 264 title: "Step", 265 name: 'step' 266 })); 331 267 } 332 268 });
Note: See TracChangeset
for help on using the changeset viewer.