Ignore:
Timestamp:
08/08/12 15:10:30 (13 years ago)
Author:
jkraaijeveld
Message:
  • Made the innerwidgets as seperate widgets instead of inheriting from either TextBox? or Textarea or the like. They now are their own container.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/ui/content/ContentWidgetFactory.js

    r391 r393  
    22    'dojo/_base/declare',
    33    'dojo/_base/lang',
     4    'dijit/_WidgetBase',
     5    'dijit/_Container',
    46    'dijit/form/NumberSpinner',
    57    'dijit/form/Textarea',
     
    810    'dojox/form/CheckedMultiSelect',
    911    '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) {
    1113        var factory = declare('rft.ui.content.ContentWidgetFactory', [], {
    1214            /* No default type, all should be valid */
     
    3436            createHeaderEditWidget: function() {
    3537                return new HeaderEditItem();
    36             }/*,
     38            },
    3739
    3840            createTextViewWidget: function(options) {
     
    4143                });
    4244            },
    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            }/*,
    5957
    6058            createIntegerViewWidget: function(options) {
     
    8280
    8381        /* 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);
    8889            },
    8990            _getValueAttr: function() {
    9091                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            },
    97103            _setValueAttr: function(value) {
    98                 this.inherited(arguments, [value.contents || ""]);
     104                this._textBox.set('value', value.contents || "");
    99105            },
    100106            _getValueAttr: function() {
    101107                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() {
    109122                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        })
    121143
    122144        /* 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        })
    128164
    129165        //Use CheckedMultiSelect
Note: See TracChangeset for help on using the changeset viewer.