1 | require(['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 | }); |
---|