Changeset 394


Ignore:
Timestamp:
08/08/12 15:58:41 (13 years ago)
Author:
jkraaijeveld
Message:
  • Added Free Text Input field
File:
1 edited

Legend:

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

    r393 r394  
    77    'dijit/form/Textarea',
    88    'dijit/form/TextBox',
     9    'dijit/form/CheckBox',
    910    'dijit/layout/StackContainer',
    1011    'dojox/form/CheckedMultiSelect',
    1112    'dojox/layout/TableContainer'
    12     ],function(declare, lang, _WidgetBase, _Container, NumberSpinner, Textarea, TextBox, StackContainer, CheckedMultiSelect, TableContainer) {
     13    ],function(declare, lang, _WidgetBase, _Container, NumberSpinner, Textarea, TextBox, CheckBox, StackContainer, CheckedMultiSelect, TableContainer) {
    1314        var factory = declare('rft.ui.content.ContentWidgetFactory', [], {
    1415            /* No default type, all should be valid */
     
    4849
    4950            createFreeTextInputViewWidget: function(options) {
    50                 return new FreeTextInputViewItem({
     51                return new FreeTextViewItem({
    5152                    options: options
    5253                });
    5354            },
    5455            createFreeTextInputEditWidget: function() {
    55                 return new FreeTextInputEditItem();
     56                return new FreeTextEditItem();
    5657            }/*,
    5758
     
    143144
    144145        /* Inputs */
    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",
     146        var FreeTextViewItem = declare([_WidgetBase, _Container], {
     147            _textArea: null,
     148            postCreate: function() {
     149                this._textArea = new Textarea();
     150                this._textArea.set('maxLength', this.options.maxLength || 1000);
     151                this._textArea.set('readOnly', this.options.readOnly || false);
     152                this._textArea.set('value', this.options.defaultValue || "");
     153                this.addChild(this._textArea);
     154            },
     155            _getValueAttr: function() {
     156                return { type: "FreeTextInput",
    153157                         defaultValue: this.options.defaultValue,
    154                          readOnly: this.options.readOnly
    155                 };
    156             }
    157         });
    158 
    159         var FreeTextEditItem = declare(Textarea, {
     158                         readOnly: this.options.readOnly,
     159                         maxLength: this.options.maxLength
     160                };
     161            }
     162        });
     163
     164        var FreeTextEditItem = declare(StackContainer, {
     165            _propertiesTable: null,
     166            _maxLength: null, _readOnly: null, _defaultValue: null,
     167
     168
     169            postCreate: function() {
     170                this._textArea = new Textarea();
     171                this._propertiesTable = new TableContainer({ cols: 1, customClass: "labelsAndValues"} );
     172                this._maxLength = new NumberSpinner( { title: "Maximum length", constraints: {min:0}} );
     173                this._readOnly = new CheckBox( { title: "Read only" } );
     174                this._defaultValue = new Textarea( { title: "Default value" });
     175                this._propertiesTable.addChild(this._maxLength);
     176                this._propertiesTable.addChild(this._readOnly);
     177                this._propertiesTable.addChild(this._defaultValue);
     178                this.addChild(this._propertiesTable);
     179            },
     180
    160181            _setValueAttr: function(value) {
    161                 this.inherited(arguments, [value])
    162             }
     182                this._maxLength.set('value', value.maxLength);
     183                this._readOnly.set('value', value.readOnly);
     184                this._defaultValue.set('value', value.defaultValue);
     185            },
     186            _getValueAttr: function() {
     187                return { type: "FreeTextInput",
     188                         defaultValue: this._defaultValue.get('value'),
     189                         readOnly: this._readOnly.get('value'),
     190                         maxLength: this._maxLength.get('value')
     191                };
     192            }
     193
     194
    163195        })
    164196
Note: See TracChangeset for help on using the changeset viewer.