Changeset 508 for Dev/trunk/src/client/qed-client/model/widgets/questions
- Timestamp:
- 03/12/14 02:23:11 (11 years ago)
- Location:
- Dev/trunk/src/client/qed-client/model/widgets/questions
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/model/widgets/questions/MultipleChoiceInputWidget.js
r500 r508 1 1 define([ 2 "../../../widgets/_ComplexValueWidget", 2 "dijit/_Container", 3 "dijit/_TemplatedMixin", 4 "dijit/_WidgetBase", 5 "dijit/_WidgetsInTemplateMixin", 3 6 "dijit/form/CheckBox", 4 7 "dijit/form/RadioButton", … … 7 10 "dojo/dom-construct", 8 11 "dojo/text!./templates/MultipleChoiceInputWidget.html" 9 ], function(_Co mplexValueWidget, CheckBox, RadioButton, array, declare, domConstruct, template) {10 return declare([_ ComplexValueWidget],{12 ], function(_Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, CheckBox, RadioButton, array, declare, domConstruct, template) { 13 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 11 14 templateString: template, 12 allowMultiple: false,13 15 startup: function() { 14 16 if ( this._started ) { return; } … … 17 19 domConstruct.empty(this.domNode); 18 20 var Ctor = this.allowMultiple === true ? CheckBox : RadioButton; 19 array.forEach(this.items, function(item , index){21 array.forEach(this.items, function(item){ 20 22 var div = domConstruct.create("div", { 21 23 }, this.domNode, "last"); 22 24 var input = new Ctor({ 23 name: this. allowMultiple === true ? index.toString() : 'choice',24 value: item.text25 name: this.code + (this.allowMultiple === true ? item.subcode : ''), 26 value: this.allowMultiple === true ? null : item.subcode 25 27 }).placeAt(div); 26 28 var label = domConstruct.create("label",{ … … 29 31 }, div); 30 32 }, this); 31 },32 _getValueAttr: function() {33 var value = this.inherited(arguments);34 /*if ( this.allowMultiple === true ) {35 return value;36 } else {37 return value.choice; //.length > 0;38 }*/39 },40 _setValueAttr: function(value) {41 var inherited = this.getInherited(arguments);42 if ( this.allowMultiple === true ) {43 inherited.call(this,value);44 } else {45 inherited.call(this,{choice:value ? ["on"] : []});46 }47 33 } 48 34 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/NumberInputWidget.js
r443 r508 1 1 define([ 2 "../../../widgets/_ComplexValueWidget", 2 "dijit/_Container", 3 "dijit/_TemplatedMixin", 4 "dijit/_WidgetBase", 5 "dijit/_WidgetsInTemplateMixin", 3 6 "dojo/_base/declare", 4 7 "dojo/text!./templates/NumberInputWidget.html" 5 ], function(_ComplexValueWidget, declare, template) { 6 return declare([_ComplexValueWidget],{ 8 ], function(_Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, template) { 9 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 10 templateString: template, 7 11 text: '', 8 maxLength: null,9 templateString: template,10 12 startup: function() { 13 if ( this._started ) { return; } 14 this.inherited(arguments); 15 11 16 var constraints = {}; 12 if ( this.min !== null&& !isNaN(this.min) ) {17 if ( this.min && !isNaN(this.min) ) { 13 18 constraints.min = this.min; 14 19 } 15 if ( this.max !== null&& !isNaN(this.max) ) {20 if ( this.max && !isNaN(this.max) ) { 16 21 constraints.max = this.max; 17 22 } 18 if ( this.places !== null&& !isNaN(this.places) ) {23 if ( this.places && !isNaN(this.places) ) { 19 24 constraints.places = this.places; 20 25 } 21 26 this.numberBox.set('constraints', constraints); 22 },23 _getValueAttr: function() {24 return this.numberBox.get('value');25 },26 _setValueAttr: function(value) {27 return this.numberBox.set('value', value);28 27 } 29 28 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/ScaleInputWidget.js
r443 r508 1 1 define([ 2 "../../../widgets/_ComplexValueWidget", 2 "dijit/_Container", 3 "dijit/_TemplatedMixin", 4 "dijit/_WidgetBase", 5 "dijit/_WidgetsInTemplateMixin", 3 6 "dijit/form/RadioButton", 4 7 "dojo/_base/array", … … 8 11 "dojo/dom-construct", 9 12 "dojo/text!./templates/ScaleInputWidget.html" 10 ], function(_Co mplexValueWidget, RadioButton, array, declare, lang, domAttr, domConstruct, template) {11 return declare([_ ComplexValueWidget],{13 ], function(_Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, RadioButton, array, declare, lang, domAttr, domConstruct, template) { 14 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 12 15 templateString: template, 13 16 baseClass: "qedScaleWidget", 14 min: 0,15 max: 0,16 minLabel: "",17 maxLabel: "",18 naLabel: null,19 items: null,20 value: null,21 constuctor: function() {22 this.items = [];23 this.value = {};24 },25 17 startup: function() { 26 18 if ( this._started ) { return; } … … 42 34 }, 43 35 _renderItems: function() { 44 array.forEach(this.items, function(item ,index) {36 array.forEach(this.items, function(item) { 45 37 var tr = domConstruct.create("tr", {}, this.itemsNode); 46 38 var td; … … 57 49 td = domConstruct.create("td", {}, tr); 58 50 radio = new RadioButton({ 59 name: index.toString(),51 name: this.code+item.subcode, 60 52 value: i.toString() 61 53 }); … … 69 61 td = domConstruct.create("td", {}, tr); 70 62 radio = new RadioButton({ 71 name: index.toString(),63 name: this.code+item.subcode, 72 64 value: "n/a" 73 65 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/StringInputWidget.js
r443 r508 1 1 define([ 2 "../../../widgets/_ComplexValueWidget", 2 "dijit/_Container", 3 "dijit/_TemplatedMixin", 4 "dijit/_WidgetBase", 5 "dijit/_WidgetsInTemplateMixin", 3 6 "dojo/_base/declare", 4 7 "dojo/text!./templates/StringInputWidget.html" 5 ], function(_ComplexValueWidget, declare, template) { 6 return declare([_ComplexValueWidget],{ 7 text: '', 8 ], function(_Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, template) { 9 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 8 10 templateString: template, 9 _getValueAttr: function() { 10 return this.textBox.get('value'); 11 }, 12 _setValueAttr: function(value) { 13 return this.textBox.set('value', value); 14 } 11 text: '' 15 12 }); 16 13 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/TextInputWidget.js
r461 r508 1 1 define([ 2 "../../../widgets/_ComplexValueWidget", 2 "dijit/_Container", 3 "dijit/_TemplatedMixin", 4 "dijit/_WidgetBase", 5 "dijit/_WidgetsInTemplateMixin", 3 6 "dojo/_base/declare", 4 7 "dojo/text!./templates/TextInputWidget.html" 5 ], function(_ComplexValueWidget, declare, template) { 6 return declare([_ComplexValueWidget],{ 8 ], function(_Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, template) { 9 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 10 templateString: template, 7 11 text: '', 8 maxLength: null,9 templateString: template,10 12 startup: function() { 13 if ( this._started ) { return; } 14 this.inherited(arguments); 15 11 16 if ( this.maxLength ) { 12 17 this.textArea.set('maxLength', this.maxLength); 13 18 } 14 },15 _getValueAttr: function() {16 return this.textArea.get('value');17 },18 _setValueAttr: function(value) {19 return this.textArea.set('value', value);20 19 } 21 20 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/MultipleChoiceInputWidget.html
r461 r508 1 < form>2 </ form>1 <div> 2 </div> -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/NumberInputWidget.html
r461 r508 1 < form>1 <div> 2 2 <p>${text}</p> 3 <div class="qedField" data-dojo-attach-point="numberBox" data-dojo-type="dijit/form/NumberTextBox" name="text"></div> 4 </form> 3 <div class="qedField" 4 data-dojo-attach-point="numberBox" 5 data-dojo-type="dijit/form/NumberTextBox" 6 name="${code}${subcode}"></div> 7 </div> -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/ScaleInputWidget.html
r461 r508 1 < formclass="${baseClass}">1 <div class="${baseClass}"> 2 2 <table> 3 3 <thead> … … 12 12 </tbody> 13 13 </table> 14 </ form>14 </div> -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/StringInputWidget.html
r461 r508 1 < form>1 <div> 2 2 <p>${text}</p> 3 <div data-dojo-attach-point="textBox" data-dojo-type="dijit/form/TextBox" name="text"></div> 4 </form> 3 <div data-dojo-type="dijit/form/TextBox" 4 name="${code}${subcode}"></div> 5 </div> -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/TextInputWidget.html
r492 r508 1 < form>1 <div> 2 2 <p>${text}</p> 3 <textarea class="qedField" data-dojo-attach-point="textArea" data-dojo-type="dijit/form/Textarea" name="text"></textarea> 4 </form> 3 <textarea class="qedField" 4 data-dojo-attach-point="textArea" 5 data-dojo-type="dijit/form/Textarea" 6 name="${code}${subcode}"></textarea> 7 </div>
Note: See TracChangeset
for help on using the changeset viewer.