source: Dev/branches/rest-dojo-ui/client/rft/ui/QuestionWidget.js @ 281

Last change on this file since 281 was 281, checked in by hendrikvanantwerpen, 13 years ago
  • [Client] Removed local Dojo copy and pull in via svn:external.
  • [Client] Keep categories of questions in alphabetical order.
  • [Client] Added skeleton QuestionWidget? for different question types.
File size: 1.8 KB
Line 
1require(['dojo/_base/declare','dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin','dojo/text!rft/ui/QuestionWidget.html','dijit/form/TextBox'],
2    function(declare,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox){
3        declare('rft.ui.QuestionWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
4            templateString: templateString,
5            mode: 'view', // view || edit
6            type: 'string',
7            _w: null,
8            postCreate: function() {
9                this._setType(this.type);
10            },
11            _setType: function(type) {
12                if ( !this._w || this.type != type ) {
13                    if ( this._w ) {
14                        this._w.destroy();
15                        this._w = null;
16                    }
17                    this.type = type;
18                    switch(type) {
19                        case 'string':
20                            this._getStringWidget().placeAt(this.typeDetails);
21                            break;
22                        case 'text':
23                            break;
24                        case 'multipleChoice':
25                            break;
26                    }
27                }
28            },
29            _getStringWidget: function() {
30                if ( !this._stringWidget ) {
31                    this._stringWidget = new TextBox({
32                        name: 'answers',
33                        disabled: this.mode == 'view'
34                    });
35                }
36                return this._stringWidget;
37            },
38            _getValueAttr: function() {
39                return this.ourForm.get('value');
40            },
41            _setValueAttr: function(value) {
42                return this.ourForm.set('value',value);
43            }
44        });
45    });
Note: See TracBrowser for help on using the repository browser.