Changeset 426 for Dev/trunk/client/qed/widgets/MultipleChoiceWidget.js
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk
- Property svn:ignore
-
old new 1 1 data 2 2 nbproject 3 node_modules
-
- Property svn:ignore
-
Dev/trunk/client
- Property svn:externals
-
old new 1 dojo http://svn.dojotoolkit.org/src/tags/release-1.8. 0/dojo2 dijit http://svn.dojotoolkit.org/src/tags/release-1.8. 0/dijit3 dojox http://svn.dojotoolkit.org/src/tags/release-1.8. 0/dojox4 util http://svn.dojotoolkit.org/src/tags/release-1.8. 0/util1 dojo http://svn.dojotoolkit.org/src/tags/release-1.8.3/dojo 2 dijit http://svn.dojotoolkit.org/src/tags/release-1.8.3/dijit 3 dojox http://svn.dojotoolkit.org/src/tags/release-1.8.3/dojox 4 util http://svn.dojotoolkit.org/src/tags/release-1.8.3/util
-
- Property svn:externals
-
Dev/trunk/client/qed/widgets/MultipleChoiceWidget.js
r417 r426 3 3 'dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin','dijit/_Container', 4 4 'dojo/text!./templates/MultipleChoiceWidget.html', 5 'dijit/form/RadioButton','dijit/form/CheckBox','dijit/form/TextBox','dijit/form/Button'], 6 function(declare,array,lang,domConstruct,registry,_WidgetBase,_TemplatedMixin, 7 _WidgetsInTemplateMixin,_Container, 8 templateString,RadioButton,CheckBox,TextBox,Button){ 9 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 10 templateString: templateString, 11 multiple: true, 12 baseClass: 'rftMultipleChoiceWidget', 13 14 allowMultiple: false, 15 name: '', 16 value: null, 17 18 _widgetCache: null, 19 constuctor: function() { 20 this.inherited(arguments); 21 this.value = []; 22 this._widgetCache = {}; 23 }, 24 _setValueAttr: function(value) { 25 this.reset(); 26 this.value = value; 27 array.forEach(this.value,lang.hitch(this,function(val){ 28 this._addRow(val); 29 })); 30 }, 31 _getValueAttr: function() { 32 var value = []; 33 registry.findWidgets(this.domNode).forEach(function(w){ 34 w.isInstanceOf(TextBox) && value.push(w.get('value')); 35 }); 36 this.value = value; 37 return value; 38 }, 39 reset: function() { 40 this._removeWidgetsBelowNode(this.rows); 41 domConstruct.empty(this.rows); 42 }, 43 _onAddRow: function() { 44 this._addRow(); 45 }, 46 _addRow: function(value,tagRow,pos) { 47 var row = domConstruct.create('div',{'class':'row'}); 48 if ( this.allowMultiple ) { 49 new CheckBox({ 50 name:this.name, 51 'class':'rowBox', 52 disabled: this.mode == 'edit' 53 }).placeAt(row); 54 } else { 55 new RadioButton({ 56 name:this.name, 57 'class':'rowBox', 58 disabled: this.mode == 'edit' 59 }).placeAt(row); 60 } 61 new TextBox({ 5 'dijit/form/RadioButton','dijit/form/CheckBox','dijit/form/TextBox','dijit/form/Button' 6 ], function(declare,array,lang,domConstruct,registry,_WidgetBase,_TemplatedMixin, 7 _WidgetsInTemplateMixin,_Container, templateString,RadioButton,CheckBox,TextBox,Button){ 8 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 9 templateString: templateString, 10 multiple: true, 11 baseClass: 'rftMultipleChoiceWidget', 12 13 allowMultiple: false, 14 name: '', 15 value: null, 16 17 _widgetCache: null, 18 constuctor: function() { 19 this.inherited(arguments); 20 this.value = []; 21 this._widgetCache = {}; 22 }, 23 _setValueAttr: function(value) { 24 this.reset(); 25 this.value = value; 26 array.forEach(this.value,lang.hitch(this,function(val){ 27 this._addRow(val); 28 })); 29 }, 30 _getValueAttr: function() { 31 var value = []; 32 registry.findWidgets(this.domNode).forEach(function(w){ 33 if ( w.isInstanceOf(TextBox) ) { value.push(w.get('value')); } 34 }); 35 this.value = value; 36 return value; 37 }, 38 reset: function() { 39 this._removeWidgetsBelowNode(this.rows); 40 domConstruct.empty(this.rows); 41 }, 42 _onAddRow: function() { 43 this._addRow(); 44 }, 45 _addRow: function(value,tagRow,pos) { 46 var row = domConstruct.create('div',{'class':'row'}); 47 if ( this.allowMultiple ) { 48 new CheckBox({ 62 49 name:this.name, 63 value:value || '',64 'class':'rowText'50 'class':'rowBox', 51 disabled: this.mode === 'edit' 65 52 }).placeAt(row); 66 new Button({ 67 label:'-', 68 'class':'rowBtn', 69 onClick:lang.hitch(this,'_removeNodeWithWidgets',row) 53 } else { 54 new RadioButton({ 55 name:this.name, 56 'class':'rowBox', 57 disabled: this.mode === 'edit' 70 58 }).placeAt(row); 71 new Button({72 label:'+',73 'class':'rowBtn',74 onClick:lang.hitch(this,'_addRow','',row,'before')75 }).placeAt(row);76 domConstruct.place(row,tagRow || this.rows,pos||'last');77 },78 _removeNodeWithWidgets: function(node) {79 this._removeWidgetsBelowNode(node);80 domConstruct.destroy(node);81 },82 _removeWidgetsBelowNode: function(node) {83 registry.findWidgets(node).forEach(function(w){84 w.destroyRecursive();85 });86 },87 _onRowChange: function(row) {88 89 59 } 90 }); 60 new TextBox({ 61 name:this.name, 62 value:value || '', 63 'class':'rowText' 64 }).placeAt(row); 65 new Button({ 66 label:'-', 67 'class':'rowBtn', 68 onClick:lang.hitch(this,'_removeNodeWithWidgets',row) 69 }).placeAt(row); 70 new Button({ 71 label:'+', 72 'class':'rowBtn', 73 onClick:lang.hitch(this,'_addRow','',row,'before') 74 }).placeAt(row); 75 domConstruct.place(row,tagRow || this.rows,pos||'last'); 76 }, 77 _removeNodeWithWidgets: function(node) { 78 this._removeWidgetsBelowNode(node); 79 domConstruct.destroy(node); 80 }, 81 _removeWidgetsBelowNode: function(node) { 82 registry.findWidgets(node).forEach(function(w){ 83 w.destroyRecursive(); 84 }); 85 }, 86 _onRowChange: function(/*row*/) {} 91 87 }); 88 });
Note: See TracChangeset
for help on using the changeset viewer.