- Timestamp:
- 03/13/14 22:21:55 (11 years ago)
- Location:
- Dev/trunk/src/client/qed-client
- Files:
-
- 3 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/css/qed.less
r510 r513 23 23 @import "ui/topbar.less"; 24 24 @import "ui/LoginDialog.less"; 25 @import "widgets/MultipleChoiceWidget.less";26 25 @import "widgets/lists/List.less"; 27 26 @import "widgets/Selector.less"; -
Dev/trunk/src/client/qed-client/model/widgets/QuestionEditorPreviewItem.js
r512 r513 44 44 return false; 45 45 }, 46 _getValueAttr: function( value) {46 _getValueAttr: function() { 47 47 if ( this._editing === true ) { 48 this.value =this.innerWidget.get('value');48 return this.innerWidget.get('value'); 49 49 } 50 50 return this.value; 51 51 }, 52 _setValueAttr: function(value ) {53 this. value = value;52 _setValueAttr: function(value,priorityChange) { 53 this._setValueInternal(value,priorityChange); 54 54 if ( this._editing === true ) { 55 55 this._showEditWidget(); … … 97 97 if ( this._editing === true ) { 98 98 if (!this.innerWidget.validate || this.innerWidget.validate() ) { 99 this. value = this.innerWidget.get('value');99 this._setValueInternal(this.innerWidget.get('value')); 100 100 this._showViewWidget(); 101 101 } … … 149 149 if ( this.innerWidget !== null ) { 150 150 if ( this._editing === true ) { 151 this.triggerOnChange(); 151 this._onChange(); 152 // how to force event on widget here? 152 153 } 153 154 this.removeChild(this.innerWidget); -
Dev/trunk/src/client/qed-client/model/widgets/SurveyRenderWidget.js
r511 r513 38 38 lang.mixin(newValue,widget.get('value')); 39 39 },this); 40 this.value = newValue; 41 return this.value; 40 return newValue; 42 41 }, 43 _setValueAttr: function(value) { 42 _setValueAttr: function(value,priorityChange) { 43 this._setValueInternal(value,priorityChange); 44 44 array.forEach(this._getDescendantFormWidgets(),function(widget){ 45 45 widget.set('value',value); 46 46 },this); 47 this.value = value;48 47 } 49 48 }); -
Dev/trunk/src/client/qed-client/model/widgets/SurveyRunWidget.js
r512 r513 14 14 })); 15 15 }, 16 startup: function() {17 this.inherited(arguments);18 },19 16 _getValueAttr: function() { 20 17 var value = this.inherited(arguments); -
Dev/trunk/src/client/qed-client/model/widgets/templates/QuestionEditorToolkit.html
r502 r513 6 6 <label>Code:</label><input data-dojo-type="dijit/form/ValidationTextBox" required="required" name="code"/> 7 7 <label>Categories:</label> 8 <div data-dojo-attach-point="categoryListNode" class="rftLineListView"></div> 8 <div data-dojo-attach-point="categoryListNode" class="rftLineListView"></div> 9 9 <div data-dojo-attach-point="categoryBoxNode"></div> 10 10 <button class="inheritBgColor" data-dojo-type="dijit/form/Button" data-dojo-attach-event="onClick:_onCategoryAdd" data-dojo-props="baseClass:'rftBlockButton', iconClass: 'rftIcon rftIconPlus'">Add</button><br/> -
Dev/trunk/src/client/qed-client/model/widgets/templates/SurveyRunWidget.html
r508 r513 3 3 <div> 4 4 <label for="mode" class="qedLabel">Title</label> 5 < textareaname="title" class="qedField"6 7 data-dojo-type="dijit/form/ValidationTextBox"></textarea>5 <div name="title" class="qedField" 6 data-dojo-props="required: true" 7 data-dojo-type="dijit/form/ValidationTextBox"></div> 8 8 </div> 9 9 10 10 <div> 11 11 <label for="mode" class="qedLabel">Description</label> 12 < textareaname="description" class="qedField"13 data-dojo-type="dijit/form/Textarea"></textarea>12 <div name="description" class="qedField" 13 data-dojo-type="dijit/form/Textarea"></div> 14 14 </div> 15 15 16 16 <div> 17 17 <label for="startDate" class="qedLabel">Start date</label> 18 < input type="text"name="startDate" class="qedField"19 20 data-dojo-attach-point="startDateBox" />18 <div name="startDate" class="qedField" 19 data-dojo-type="dijit/form/DateTextBox" 20 data-dojo-attach-point="startDateBox"></div> 21 21 </div> 22 22 23 23 <div> 24 24 <label for="endDate" class="qedLabel">End date</label> 25 < input type="text"name="endDate" class="qedField"26 27 data-dojo-attach-point="endDateBox" />25 <div name="endDate" class="qedField" 26 data-dojo-type="dijit/form/DateTextBox" 27 data-dojo-attach-point="endDateBox"></div> 28 28 </div> 29 29 30 30 <div> 31 31 <label for="endDate" class="qedLabel">Allow respondents to delete their unsubmitted response</label> 32 < inputtype="text" name="respondentCanDeleteOwnResponse"33 34 data-dojo-type="dijit/form/CheckBox" />32 <div type="text" name="respondentCanDeleteOwnResponse" 33 class="qedField" 34 data-dojo-type="dijit/form/CheckBox"></div> 35 35 </div> 36 36 37 37 <div> 38 38 <label for="mode" class="qedLabel">Mode</label> 39 < selectname="mode" class="qedField" data-dojo-type="dijit/form/Select">39 <div name="mode" class="qedField" data-dojo-type="dijit/form/Select"> 40 40 <option value="open" selected="selected">Open</option> 41 41 <option value="closed">Closed</option> 42 </ select>42 </div> 43 43 </div> 44 44 -
Dev/trunk/src/client/qed-client/pages/templates/question.html
r502 r513 32 32 </div> 33 33 </div> 34 < divdata-dojo-type="../model/widgets/QuestionEditorPreview"35 data-dojo-attach-point="contentList"36 data-dojo-props="name:'content',delay:5,region:'center'"></div>34 <form data-dojo-type="../model/widgets/QuestionEditorPreview" 35 data-dojo-attach-point="contentList" 36 data-dojo-props="name:'content',delay:5,region:'center'"></form> 37 37 </div> -
Dev/trunk/src/client/qed-client/widgets/ListWidget.js
r511 r513 1 1 define([ 2 " dijit/_Container",2 "./_ComplexValueMixin", 3 3 "dijit/_WidgetBase", 4 4 "dijit/registry", 5 5 "dojo/_base/array", 6 6 "dojo/_base/declare", 7 "dojo/_base/event", 7 8 "dojo/_base/lang", 8 9 "dojo/dnd/Source", 9 10 "dojo/dnd/common", 10 11 "dojo/dom-construct", 11 "dojo/_base/event",12 12 "dojo/on" 13 ], function(_Container, _WidgetBase, registry, array, declare, lang, Source, dnd, domConstruct, event, on) { 14 return declare([_WidgetBase,_Container],{ 15 name: "", 16 value: null, 17 disabled: false, 18 readOnly: false, 13 ], function(_ComplexValueMixin, _WidgetBase, registry, array, declare, event, lang, Source, dnd, domConstruct, on) { 14 return declare([_WidgetBase,_ComplexValueMixin],{ 19 15 multiple: true, 20 16 type: "text", … … 65 61 this.own(this.source.on('Drop', 66 62 lang.hitch(this,'_handleDrop'))); 67 this.own(on(this.domNode,'change',68 lang.hitch(this,'_handleChange')));69 },70 create: function() {71 this.inherited(arguments);72 this._onChangeActive = true;73 63 }, 74 64 creator: function(item, hint) { … … 83 73 } else { 84 74 if ( this.createListElement ) { 85 nodeOrWidget = this.createListElement(id,item,this._fromDrop); 75 nodeOrWidget = 76 this.createListElement(id,item,this._fromDrop); 86 77 } else { 87 78 return this.source.defaultCreator(item, hint); 88 79 } 89 80 } 90 var node = nodeOrWidget.domNode ? nodeOrWidget.domNode : nodeOrWidget; 81 if ( nodeOrWidget.on ) { 82 this.connectChildsChanges(nodeOrWidget); 83 } 84 var node = nodeOrWidget.domNode ? 85 nodeOrWidget.domNode : 86 nodeOrWidget; 91 87 if ( hint !== "avatar" && node.id !== id ) { 92 88 console.warn("Node id '%s' not equal to generated id '%s'. Is this intended?", node.id, id); … … 101 97 createListElement: null, /* function(id,item,fromDrop){},*/ 102 98 _getValueAttr: function() { 103 this.value = array.map(this.source.getAllNodes(),function(node){ 104 var widget = registry.byNode(node); 105 if ( widget && "value" in widget ) { 106 return widget.get('value'); 107 } else { 108 return this.source.getItem(node.id).data; 109 } 110 },this); 111 return this.value; 99 return array.map( 100 this._getDescendantFormWidgets(), 101 function(child) { return child.get('value'); } 102 ,this); 112 103 }, 113 104 _setValueAttr: function(value,priorityChange) { 114 105 this.clear(); 115 this.appendItems(value || []); 106 this._setValueInternal(value || [], priorityChange); 107 this.appendItems(this.value); 116 108 }, 117 _setDisabledAttr: function(value) { 118 this._set("disabled", value); 119 array.forEach(this.getChildren(), function(child){ 120 child.set("disabled", value); 121 }); 122 this._updateContainer(); 109 _setReadOnlyAttr: function() { 110 this.inherited(arguments); 111 this._updateSource(); 123 112 }, 124 _setReadOnlyAttr: function(value) { 125 this._set("readOnly", value); 126 array.forEach(this.getChildren(), function(child){ 127 child.set("readOnly", value); 128 }); 129 this._updateContainer(); 113 _setDisabledAttr: function() { 114 this.inherited(arguments); 115 this._updateSource(); 130 116 }, 131 _update Container: function() {117 _updateSource: function() { 132 118 if ( this.disabled || this.readOnly ) { 133 119 this.source.accept = []; … … 139 125 } 140 126 }, 141 focus: function() { 142 var children = this.getChildren(); 143 if ( children.length > 0 ) { 144 children[0].focus(); 145 } 127 getChildren: function() { 128 return array.filter( 129 array.map(this.source.getAllNodes(), function(node){ 130 return registry.byNode(node); 131 }), 132 function(widget){ return widget !== null; }); 146 133 }, 134 _getDescendantFormWidgets: function() { 135 return array.filter( 136 this.getChildren(), 137 function(child){ return 'value' in child; }); 138 }, 139 147 140 appendItems: function(items,forceEvent) { 148 141 this._fromDrop = false; 149 142 this.source.insertNodes(false,items); 150 if ( forceEvent ) { this._handleDrop(); } 143 this._setValueInternal( 144 this.get('value'), 145 forceEvent === true ? true : null); 151 146 this._fromDrop = true; 152 147 }, … … 154 149 this._fromDrop = false; 155 150 this.source.insertNodes(false,[item]); 156 if ( forceEvent ) { this._handleDrop(); } 151 this._setValueInternal( 152 this.get('value'), 153 forceEvent === true ? true : null); 157 154 this._fromDrop = true; 158 155 }, 159 156 removeItem: function(key,forceEvent) { 160 array.forEach(array.filter(this.source.getAllNodes(), function(node){ 161 return node.id === key; 162 }), lang.hitch(this, "_destroyNodeOrWidget")); 157 array.forEach( 158 array.filter(this.source.getAllNodes(), function(node){ 159 return node.id === key; 160 }), 161 lang.hitch(this, "_destroyNodeOrWidget")); 163 162 this.source.delItem(key); 164 if ( forceEvent ) { this._handleDrop(); } 165 }, 166 getChildren: function() { 167 return array.filter(array.map(this.source.getAllNodes(), function(node){ 168 return registry.byNode(node); 169 }),function(widget){ return widget !== null; }); 163 this._setValueInternal( 164 this.get('value'), 165 forceEvent === true ? true : null); 170 166 }, 171 167 clear: function(forceEvent) { … … 173 169 lang.hitch(this, "_destroyNodeOrWidget")); 174 170 this.source.clearItems(); 175 if ( forceEvent ) { this._handleDrop(); } 171 this._setValueInternal( 172 this.get('value'), 173 forceEvent === true ? true : null); 176 174 }, 177 175 _destroyNodeOrWidget: function(node) { … … 183 181 } 184 182 }, 185 validate: function() {186 return array.every(array.map(this.source.getAllNodes(),function(node){187 var widget = registry.byNode(node);188 return !widget || widget.disabled || !widget.validate || widget.validate();189 }), function(item){ return item; });190 },191 183 destroy: function() { 192 184 this.source.destroy(); 193 185 this.inherited(arguments); 194 186 }, 195 _handleChange: function(evt) { 196 if ( evt.target !== this.domNode ) { 197 this._onChange(); 198 if ( evt ) { event.stop(evt); } 199 return false; 200 } else { 201 return evt; 202 } 203 }, 204 _handleDrop: function(evt) { 205 this._onChange(); 206 }, 207 _onChange: function() { 208 if ( this._onChangeActive && 209 !(this.readOnly || this.disabled) ) { 210 if ( this._onChangeHandle ) { 211 this._onChangeHandle.cancel(); 212 } 213 this._onChangeHandle = this.defer(function(){ 214 this._onChangeHandle = null; 215 on.emit(this.domNode,'change',{ 216 target: this.domNode, 217 value: this.get('value'), 218 bubbles: true, 219 cancellable: true 220 }); 221 }); 222 } 187 _handleDrop: function() { 188 this._setValueInternal(this.get('value')); 223 189 } 224 190 }); -
Dev/trunk/src/client/qed-client/widgets/ObjectBox.js
r510 r513 2 2 "../lib/object", 3 3 "./LineWithActionsWidget", 4 "./_ComplexValueWidget", 4 5 "dijit/_TemplatedMixin", 5 6 "dijit/_WidgetBase", … … 8 9 "dojo/_base/lang", 9 10 "dojo/text!./templates/ObjectBox.html" 10 ], function(objectFuns, LineWithActionsWidget, _ TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, lang, template) {11 return declare([_ WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {11 ], function(objectFuns, LineWithActionsWidget, _ComplexValueWidget, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, lang, template) { 12 return declare([_ComplexValueWidget], { 12 13 baseClass: "rftObjectBox", 13 14 templateString: template, 14 value: null,15 15 actions: null, 16 16 startup: function() { … … 54 54 }, 55 55 _showInfoBox: function() {}, 56 _setValueAttr: function(value) { 57 this.value = value; 58 this._refresh(); 59 }, 60 _getValueAttr: function(value) { 61 this.value = value; 62 }, 63 _refresh: function() { 64 if ( this.value !== null ) { 65 this.iconNode.className = "rftIcon typeIcon rftIcon"+(this.value.type || ''); 66 this.line1.set('title', this.value.title || ''); 67 this.line2.set('title', this.value.subTitle || ''); 68 this.line3.set('title', this.value.lowerTitle || ''); 56 onChange: function(value) { 57 if ( value ) { 58 this.iconNode.className = "rftIcon typeIcon rftIcon"+(value.type || ''); 59 this.line1.set('title', value.title || ''); 60 this.line2.set('title', value.subTitle || ''); 61 this.line3.set('title', value.lowerTitle || ''); 69 62 } 70 63 } -
Dev/trunk/src/client/qed-client/widgets/_ComplexValueMixin.js
r512 r513 20 20 }, 21 21 buildRendering: function() { 22 // capture child changeevents22 // capture child events 23 23 this.inherited(arguments); 24 this.own(on(this.domNode,'change', 25 lang.hitch(this,'_handleChange'))); 24 if ( this.domNode.tagName.toLowerCase() !== "form" ) { 25 console.warn("Not scoping a _ComplexValueMixin in a form element can cause name clashes. E.g. radio buttons might stop working correctly. It is recommended to use <form> as the root element in your template for", this.declaredClass); 26 } 27 this.own(on(this.domNode,'submit', 28 lang.hitch(this,'_handleSubmit'))); 26 29 }, 27 30 create: function() { … … 30 33 }, 31 34 postCreate: function() { 32 this.inherited(arguments); 33 if ( this.domNode.tagName.toLowerCase() !== "form" ) { 34 console.warn("Not scoping a _ComplexValueMixin in a form element can cause name clashes. E.g. radio buttons might stop working correctly. It is recommended to use <form> as the root element in your template for", this.declaredClass); 35 } 36 this.own(on(this.domNode, 'submit', lang.hitch(this,'_handleSubmit'))); 35 array.forEach(this._getDescendantFormWidgets(), 36 this.connectChildsChanges, 37 this); 37 38 }, 38 startup: function() { 39 if (this._started) { return; } 40 this.inherited(arguments); 41 }, 42 _setDisabledAttr: function(value) { 43 this._set("disabled", value); 44 array.forEach(this._getDescendantFormWidgets(), function(child) { 45 child.set("disabled", value); 46 }); 47 }, 48 _getValueAttr: function() { 49 this.value = this.inherited(arguments); 50 return this.value; 39 connectChildsChanges: function(child) { 40 this.own(child.on('change', 41 lang.hitch(this,'_handleChildChange'))); 51 42 }, 52 43 // Yuk, _setValueAttr is taken directly from _FromMixin only 53 44 // to add the priorityChange parameter 54 45 _setValueAttr: function(obj, priorityChange) { 55 this. value = obj;46 this._setValueInternal(obj, priorityChange); 56 47 57 48 var map = { }; … … 84 75 } 85 76 } 77 78 if ( priorityChange !== null ) { 79 this._handleOnChange(this.value); 80 } 86 81 }, 87 _setReadOnlyAttr: function(value) { 88 this._set("readOnly", value); 89 array.forEach(this._getDescendantFormWidgets(), function(child) { 90 child.set("readOnly", value); 91 }); 82 // use _setValueInternal instead of 'this.value = ?' or 83 // 'this._set('value',?)' so proper events will be generated. 84 _setValueInternal: function(value,priorityChange) { 85 this._set('value',value); 86 if ( priorityChange !== null ){ 87 this._handleOnChange(this.value); 88 } 92 89 }, 90 _setDisabledAttr: function(disabled) { 91 this.inherited(arguments); 92 array.forEach( 93 this._getDescendantFormWidgets(), 94 function(child) { 95 child.set('disabled', disabled); 96 },this); 97 }, 98 _setReadOnlyAttr: function(readOnly) { 99 this.inherited(arguments); 100 array.forEach( 101 this._getDescendantFormWidgets(), 102 function(child) { 103 child.set('readOnly', readOnly); 104 },this); 105 }, 106 93 107 focus: function() { 94 108 /*var children = this._getDescendantFormWidgets(); … … 97 111 }*/ 98 112 }, 99 _handleChange: function(evt) { 100 if ( evt.target !== this.domNode ) { 101 this.triggerOnChange(); 102 if ( evt ) { event.stop(evt); } 103 return false; 104 } else { 105 return evt; 106 } 113 addChild: function(child) { 114 this.inherited(arguments); 115 this.connectChildsChanges(child); 107 116 }, 117 108 118 _handleSubmit: function(evt) { 109 var node = this.domNode; 110 var widget; 111 while ( node ) { 112 node = node.parentNode; 113 widget = registry.byNode(node); 114 if ( widget && typeof widget._onSubmit === "function" ) { 115 widget._onSubmit(evt); 116 break; 119 if ( this._started ) { 120 var node = this.domNode; 121 var widget; 122 while ( node ) { 123 node = node.parentNode; 124 widget = registry.byNode(node); 125 if ( widget && 126 typeof widget._onSubmit === "function" ) { 127 widget._onSubmit(evt); 128 break; 129 } 117 130 } 118 131 } … … 120 133 return false; 121 134 }, 122 triggerOnChange: function() { 135 _handleChildChange: function() { 136 this._setValueInternal(this.get('value')); 137 return false; 138 }, 139 _handleOnChange: function(value) { 123 140 if ( this._onChangeActive && 124 141 !(this.readOnly || this.disabled) ) { 125 142 if ( this._onChangeHandle ) { 126 this._onChangeHandle. cancel();143 this._onChangeHandle.remove(); 127 144 } 128 145 this._onChangeHandle = this.defer(function(){ 129 146 this._onChangeHandle = null; 130 on.emit(this.domNode,'change',{ 131 target: this.domNode, 132 value: this.get('value'), 133 bubbles: true, 134 cancellable: true 135 }); 147 this.onChange(value); 136 148 }); 137 149 } 138 } 150 }, 151 onChange: function() {} 139 152 }); 140 153 });
Note: See TracChangeset
for help on using the changeset viewer.