- Timestamp:
- 04/29/13 19:35:10 (12 years ago)
- Location:
- Dev/trunk/client/qed/model/widgets/questions
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/client/qed/model/widgets/questions/ScaleInputConfigWidget.js
r435 r441 1 1 define([ 2 "dijit/_Container", 3 "dijit/_TemplatedMixin", 4 "dijit/_WidgetBase", 5 "dijit/_WidgetsInTemplateMixin", 2 "../../../widgets/ListWidget", 3 "../../../widgets/_ComplexValueWidget", 6 4 "dijit/form/Button", 7 5 "dijit/form/RadioButton", 8 6 "dijit/form/TextBox", 9 7 "dijit/form/ValidationTextBox", 10 "dijit/form/_FormMixin",11 8 "dojo/_base/array", 12 9 "dojo/_base/declare", … … 20 17 "dijit/form/NumberTextBox", 21 18 "dijit/form/TextBox" 22 ], function( _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, Button, RadioButton, TextBox, ValidationTextBox, _FormMixin, array, declare, event, lang, domAttr, domConstruct, domStyle, rowTemplate, template) {19 ], function(ListWidget, _ComplexValueWidget, Button, RadioButton, TextBox, ValidationTextBox, array, declare, event, lang, domAttr, domConstruct, domStyle, rowTemplate, template) { 23 20 24 var Row = declare([_ WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container,_FormMixin],{21 var Row = declare([_ComplexValueWidget],{ 25 22 templateString: rowTemplate, 26 23 hasNA: true, … … 29 26 this.inherited(arguments); 30 27 }, 31 onDestroy: function(e) { 32 this.destroyRecursive(); 33 event.stop(e); 34 return false; 35 }, 28 onDestroy: function(evt) {}, 36 29 _setHasNAAttr: function(value) { 37 30 if ( value === true ) { … … 43 36 }); 44 37 45 return declare([_ WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container,_FormMixin],{38 return declare([_ComplexValueWidget],{ 46 39 templateString: template, 47 40 baseClass: "qedScaleWidget", 48 value: null,49 41 _hasNA: false, 50 42 constuctor: function() { … … 52 44 this.value = {}; 53 45 }, 54 onAddItem: function(e) { 55 this._addItem(); 46 buildRendering: function() { 47 this.inherited(arguments); 48 this.itemsWidget = new ListWidget({ 49 name: "items", 50 type: "ScaleItem", 51 delay: 5, 52 skipForm: true, 53 createListElement: lang.hitch(this, "_createRowWidget"), 54 createAvatar: lang.hitch(this, "_createAvatar") 55 }, this.itemsNode); 56 }, 57 _createRowWidget: function(id, item) { 58 var widget = new Row({ 59 value: item, 60 hasNA: this._hasNA, 61 id: id, 62 onDestroy: lang.hitch(this,function(evt){ 63 this.itemsWidget.removeItem(id); 64 event.stop(evt); 65 return false; 66 }) 67 }); 68 widget.startup(); 69 return widget; 70 }, 71 _createAvatar: function(id, item) { 72 return domConstruct.create("div", { 73 innerHTML: item.text || "(empty item)" 74 }); 75 }, 76 onAddNewItem: function(e) { 77 this.itemsWidget.appendItem({}); 56 78 event.stop(e); 57 79 return false; 58 80 }, 59 _clearItems: function() {60 domConstruct.empty(this.itemsNode);61 },62 _addItem: function(value) {63 var item = new Row({64 name: 'items',65 value: value,66 hasNA: this._hasNA67 });68 item.placeAt(this.itemsNode);69 return item;70 },71 _setValueAttr: function(value) {72 this.inherited(arguments);73 this._clearItems();74 array.forEach(value.items, function(value){75 this._addItem(value);76 }, this);77 },78 81 _getValueAttr: function(){ 79 82 var value = this.inherited(arguments); 80 if ( value.items && !lang.isArray(value.items) ) {81 value.items = [value.items];82 }83 83 value.type = 'ScaleInput'; 84 84 return value; … … 89 89 }, 90 90 _updateNA: function(value) { 91 array.forEach(this. getChildren(), function(child) {91 array.forEach(this.itemsWidget.getChildren(), function(child) { 92 92 child.set('hasNA', this._hasNA); 93 93 }, this);
Note: See TracChangeset
for help on using the changeset viewer.