- Timestamp:
- 04/29/13 19:35:10 (12 years ago)
- Location:
- Dev/trunk/client/qed
- Files:
-
- 30 added
- 2 deleted
- 17 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/client/qed/css/forms.less
r434 r441 33 33 width: 150px; 34 34 display: inline-block; 35 text-align: right; 36 padding: 1px; 35 37 } 36 38 … … 38 40 max-width: 350px; 39 41 display: inline-block; 42 vertical-align: top; 43 padding: 1px; 44 45 &.dijitTextArea { 46 min-height: 5em; 47 } 40 48 } 41 49 -
Dev/trunk/client/qed/css/model/widgets/QuestionEditor.less
r439 r441 3 3 overflow: hidden; 4 4 } 5 6 .surveyEditorPreview { 7 overflow-y: auto; 8 } 5 9 } -
Dev/trunk/client/qed/css/qed.css
r438 r441 991 991 width: 150px; 992 992 display: inline-block; 993 } 994 /* line 37, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/forms.less */ 995 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/forms\.less}line{font-family:\0000337}} 993 text-align: right; 994 padding: 1px; 995 } 996 /* line 39, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/forms.less */ 997 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/forms\.less}line{font-family:\0000339}} 996 998 #rft.claro .qedField { 997 999 max-width: 350px; 998 1000 display: inline-block; 999 } 1000 /* line 42, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/forms.less */ 1001 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/forms\.less}line{font-family:\0000342}} 1001 vertical-align: top; 1002 padding: 1px; 1003 } 1004 /* line 45, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/forms.less */ 1005 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/forms\.less}line{font-family:\0000345}} 1006 #rft.claro .qedField.dijitTextArea { 1007 min-height: 5em; 1008 } 1009 /* line 50, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/forms.less */ 1010 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/forms\.less}line{font-family:\0000350}} 1002 1011 #rft.claro .qedField.qedFill { 1003 1012 width: 350px; 1004 1013 } 1005 /* line 46, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/forms.less */1006 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/forms\.less}line{font-family:\00003 46}}1014 /* line 54, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/forms.less */ 1015 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/forms\.less}line{font-family:\0000354}} 1007 1016 #rft.claro .qedFieldset { 1008 1017 margin: 1em 0px; … … 1743 1752 overflow: hidden; 1744 1753 } 1754 /* line 6, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/model/widgets/QuestionEditor.less */ 1755 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/model\/widgets\/QuestionEditor\.less}line{font-family:\000036}} 1756 #rft.claro .surveyEditorPreview { 1757 overflow-y: auto; 1758 } 1745 1759 /* line 5, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/pages/questions.less */ 1746 1760 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/pages\/questions\.less}line{font-family:\000035}} -
Dev/trunk/client/qed/model/widgets/AccountListView.js
r417 r441 1 1 define([ 2 'dojo/_base/declare', 3 'dojo/_base/lang', 4 'dojo/dom-construct', 5 '../../widgets/LineWithActionsWidget', 6 '../../widgets/list/OrderedList' 7 ],function( 8 declare, 9 lang, 10 domConstruct, 11 LineWithActionsWidget, 12 OrderedList 13 ) { 14 return declare([OrderedList],{ 2 "../../widgets/LineWithActionsWidget", 3 "../../widgets/ListWidget", 4 "dojo/_base/declare", 5 "dojo/_base/lang", 6 "dojo/dom-construct" 7 ], function(LineWithActionsWidget, ListWidget, declare, lang, domConstruct) { 8 return declare([ListWidget],{ 15 9 baseClass: 'rftAccountListView', 16 10 type: 'account', 17 11 18 _createAvatarNode: function(item){12 createAvatar: function(id, item){ 19 13 return domConstruct.create("div",{ 20 14 'class': 'dragAvatar', … … 22 16 }); 23 17 }, 24 _createListNode: function(item) {18 createListElement: function(id, item) { 25 19 var w = new LineWithActionsWidget({ 20 id: id, 26 21 title: item.title, 27 22 'class': "green", … … 37 32 }); 38 33 w.startup(); 39 return w .domNode;34 return w; 40 35 } 41 36 }); -
Dev/trunk/client/qed/model/widgets/CategoryListView.js
r426 r441 1 1 define([ 2 'dojo/_base/declare',3 'dojo/_base/lang',4 'dojo/dom-construct',5 '../../widgets/LineWithActionsWidget',6 '../../widgets/list/List'7 ], function(declare, lang, domConstruct, LineWithActionsWidget, List) {8 return declare([List ],{2 "../../widgets/LineWithActionsWidget", 3 "../../widgets/ListWidget", 4 "dojo/_base/declare", 5 "dojo/_base/lang", 6 "dojo/dom-construct" 7 ], function(LineWithActionsWidget, ListWidget, declare, lang, domConstruct) { 8 return declare([ListWidget],{ 9 9 baseClass: 'rftLineListView', 10 type: 'category', 10 11 11 _createAvatarNode: function(item) {12 createAvatar: function(id, item) { 12 13 var node = domConstruct.create("div",{ 13 14 className: "dragAvatar", … … 17 18 }, 18 19 19 _createListNode: function(item) {20 createListElement: function(id, item) { 20 21 var w = new LineWithActionsWidget({ 22 id: id, 21 23 title: item, 22 24 'class': "orange", 23 25 actions: { 24 26 "Remove" : { 25 callback: lang.hitch(this, function() { 26 this.removeItem(item, w); 27 }), 27 callback: lang.hitch(this, 'removeItem', id), 28 28 properties: { 29 29 blockButton: false, … … 34 34 }); 35 35 w.startup(); 36 return w .domNode;36 return w; 37 37 } 38 38 -
Dev/trunk/client/qed/model/widgets/QuestionEditorPreview.js
r436 r441 1 1 define([ 2 'dojo/_base/array',3 'dojo/_base/declare',4 'dojo/_base/lang',5 'dojo/dom-construct',6 'dijit/registry',7 './QuestionEditorPreviewItem',8 '../../widgets/list/OrderedList'9 ], function( array, declare, lang, domConstruct, registry, QuestionEditorPreviewItem, OrderedList) {10 return declare([ OrderedList], {2 "../../widgets/ListWidget", 3 "./QuestionEditorPreviewItem", 4 "dijit/registry", 5 "dojo/_base/array", 6 "dojo/_base/declare", 7 "dojo/_base/lang", 8 "dojo/dom-construct" 9 ], function(ListWidget, QuestionEditorPreviewItem, registry, array, declare, lang, domConstruct) { 10 return declare([ListWidget], { 11 11 baseClass: 'surveyEditorPreview', 12 12 type: 'questionContent', 13 13 withHandles: true, 14 14 15 _createAvatarNode: function(item) {16 return domConstruct.create(" span",{17 innerHTML: item.type || " Dragging!!!"15 createAvatar: function(id, item) { 16 return domConstruct.create("div",{ 17 innerHTML: item.type || "(unkown)" 18 18 }); 19 19 }, 20 _createListNode: function(item) {20 createListElement: function(id, item) { 21 21 var previewItem = new QuestionEditorPreviewItem({ 22 id: id, 22 23 value: item 23 24 }); 24 this.own(previewItem.on(' close',25 lang.hitch(this,'removeItem',i tem)));25 this.own(previewItem.on('destroy', 26 lang.hitch(this,'removeItem',id))); 26 27 previewItem.startup(); 27 return previewItem.domNode; 28 }, 29 getItems: function() { 30 return array.map( 31 this.source.getAllNodes(), 32 function(node){ 33 return registry.byNode(node).get('value'); 34 },this); 28 return previewItem; 35 29 } 36 30 }); -
Dev/trunk/client/qed/model/widgets/QuestionEditorPreviewItem.js
r440 r441 1 1 define([ 2 "./ QuestionWidgetFactory",2 "./questions/Factory", 3 3 "dijit/_Container", 4 4 "dijit/_TemplatedMixin", … … 6 6 "dijit/_WidgetsInTemplateMixin", 7 7 "dojo/_base/declare", 8 "dojo/_base/event", 8 9 "dojo/_base/fx", 9 10 "dojo/_base/lang", … … 13 14 "dojo/on", 14 15 "dojo/text!./templates/QuestionEditorPreviewItem.html" 15 ], function(QuestionWidgetFactory, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, fx, lang, domClass, domGeom, domStyle, on, template) {16 ], function(QuestionWidgetFactory, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, event, fx, lang, domClass, domGeom, domStyle, on, template) { 16 17 return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _Container], { 17 18 templateString: template, … … 31 32 lang.hitch(this, 'onToggleFold'))); 32 33 this.own(this.removeButton.on('click', 33 lang.hitch(this, 'on Close')));34 lang.hitch(this, 'onDestroy'))); 34 35 this.own(this.editButton.on('click', 35 36 lang.hitch(this, 'onToggleEdit'))); 36 if (this.value) { 37 this._showEditWidget(); 38 } else { 39 throw "No data supplied to create an innerWidget!"; 37 this.showEdit(); 38 }, 39 onDestroy: function() {}, 40 _getValueAttr: function(value) { 41 if ( this._editing ) { 42 this.value = this.innerWidget.get('value'); 40 43 } 41 },42 onClose: function() {},43 _getValueAttr: function(value) {44 44 return this.value; 45 45 }, 46 46 _setValueAttr: function(value) { 47 47 this.value = value; 48 this._destroyInnerWidget();49 48 if ( this._editing ) { 50 49 this._showEditWidget(); … … 53 52 } 54 53 }, 55 onToggleEdit: function() { 56 if (this._editing) { 57 if ( this.innerWidget !== null ) { 58 if (!this.innerWidget.validate || 59 this.innerWidget.validate() ) { 60 this.value = this.innerWidget.get('value'); 61 this._showViewWidget(); 62 } 63 } else { 54 validate: function() { 55 return !this._editing || this.innerWidget.validate(); 56 }, 57 showView: function() { 58 if ( this._editing ) { 59 if (!this.innerWidget.validate || this.innerWidget.validate() ) { 60 this.value = this.innerWidget.get('value'); 64 61 this._showViewWidget(); 65 62 } 66 } else { 63 } 64 }, 65 showEdit: function() { 66 if (!this._editing) { 67 67 this._showEditWidget(); 68 68 } 69 69 }, 70 onToggleEdit: function(evt) { 71 if (this._editing) { 72 this.showView(); 73 } else { 74 this.showEdit(); 75 } 76 evt && event.stop(evt); 77 return false; 78 }, 70 79 _showViewWidget: function() { 71 this._destroyInnerWidget(); 72 this.innerWidget = this._factory.createViewWidget( this.value ); 73 if ( this.innerWidget !== null ) { 80 var newWidget = this._factory.createViewWidget( this.value ); 81 if ( newWidget !== null ) { 82 this._destroyInnerWidget(); 83 this.innerWidget = newWidget; 74 84 this.innerWidget.placeAt(this.containerNode); 75 85 this.innerWidget.startup(); 76 86 this.innerWidget.set('readOnly',true); 87 this.titleNode.innerHTML = this.value.type+" [preview]"; 88 domClass.replace(this.editButton.iconNode, "rftIconEdit", "rftIconAccept"); 89 this.editButton.set("label", "Edit"); 90 this._editing = false; 77 91 } 78 this.titleNode.innerHTML = this.value.type+" [preview]";79 domClass.replace(this.editButton.iconNode, "rftIconEdit", "rftIconAccept");80 this.editButton.set("label", "Edit");81 this._editing = false;82 92 }, 83 93 _showEditWidget: function() { 84 this._destroyInnerWidget(); 85 this.innerWidget = this._factory.createEditWidget( this.value ); 86 if ( this.innerWidget !== null ) { 94 var newWidget = this._factory.createEditWidget( this.value ); 95 if ( newWidget !== null ) { 96 this._destroyInnerWidget(); 97 this.innerWidget = newWidget; 87 98 this.innerWidget.placeAt(this.containerNode); 88 99 this.innerWidget.startup(); 100 this.titleNode.innerHTML = this.value.type+" [editing]"; 101 domClass.replace(this.editButton.iconNode, "rftIconAccept", "rftIconEdit"); 102 this.editButton.set("label", "Done"); 103 this._editing = true; 89 104 } 90 this.titleNode.innerHTML = this.value.type+" [editing]";91 domClass.replace(this.editButton.iconNode, "rftIconAccept", "rftIconEdit");92 this.editButton.set("label", "Done");93 this._editing = true;94 105 }, 95 106 _destroyInnerWidget: function() { … … 98 109 } 99 110 }, 100 onToggleFold: function( ) {111 onToggleFold: function(evt) { 101 112 if (!this.animation) { 102 113 if (!domClass.contains(this.domNode, "fold")) { … … 130 141 } 131 142 } 143 evt && event.stop(evt); 144 return false; 132 145 } 133 146 -
Dev/trunk/client/qed/model/widgets/QuestionEditorToolkit.js
r428 r441 25 25 _topicSelect: null, 26 26 _topicStore: null, 27 _categories : null,28 27 29 28 _contentItems: [ … … 37 36 { type: "StringInput" }, 38 37 { type: "TextInput" }, 39 { type: " IntegerInput" },38 { type: "NumberInput" }, 40 39 { type: "ScaleInput" }, 41 40 { type: "MultipleChoiceInput" } … … 49 48 "StringInput": "Text line", 50 49 "TextInput": "Free text", 51 " IntegerInput": "Integer number",50 "NumberInput": "Number", 52 51 "ScaleInput": "Scale", 53 52 "MultipleChoiceInput": "Multiple choice" … … 61 60 "StringInput": "Text", 62 61 "TextInput": "Text", 63 " IntegerInput": "Integer",62 "NumberInput": "Number", 64 63 "ScaleInput": "Scale", 65 64 "MultipleChoiceInput": "MultipleChoice" … … 87 86 }, 88 87 _setValueAttr: function(question) { 89 this.propertiesForm.set('value', question);90 this._categories = question.categories || [];91 88 this._setupListView(); 92 89 this._setupCategories(); 93 90 this._setupTopic(question.topic); 91 this.propertiesForm.set('value', question); 92 this._list.set('value', question.categories); 94 93 }, 95 94 _getValueAttr: function() { 96 95 var value = this.propertiesForm.get('value'); 97 value.categories = this._ categories;96 value.categories = this._list.get('value'); 98 97 return value; 99 98 }, … … 125 124 }, 126 125 _setupListView: function() { 127 this._list = new CategoryListView( { 128 removeCallback: lang.hitch(this, this._removeCategory) 126 this._list = new CategoryListView({ 129 127 }).placeAt(this.listNode); 130 128 this._list.startup(); 131 for (var category in this._categories) {132 this._list.appendItem(this._categories[category]);133 }134 129 }, 135 130 _setupCategories: function() { … … 144 139 searchAttr: "id" 145 140 }, this.categoriesBoxNode); 146 this._supportingWidgets.push(this._categorySelect);147 148 141 }, 149 142 _setupTopic: function(topic) { … … 159 152 value: topic 160 153 }, this.topicBoxNode); 161 this._supportingWidgets.push(this._topicSelect);162 154 }, 163 155 _addCategory: function(item) { 164 this._categories.push(item);165 156 this._list.appendItem(item); 166 },167 _removeCategory: function(item) {168 this._categories.splice(this._categories.indexOf(item), 1);169 157 } 170 158 -
Dev/trunk/client/qed/model/widgets/QuestionListView.js
r426 r441 1 1 define([ 2 'dojo/_base/declare', 3 'dojo/_base/lang', 4 'dojo/dom-construct', 5 '../../widgets/LineWithActionsWidget', 6 '../../widgets/list/OrderedList' 7 ],function( 8 declare, 9 lang, 10 domConstruct, 11 LineWithActionsWidget, 12 OrderedList 13 ){ 14 return declare([OrderedList],{ 2 "../../widgets/LineWithActionsWidget", 3 "../../widgets/ListWidget", 4 "dojo/_base/declare", 5 "dojo/_base/lang", 6 "dojo/dom-construct" 7 ], function(LineWithActionsWidget, ListWidget, declare, lang, domConstruct) { 8 return declare([ListWidget],{ 15 9 baseClass: 'rftSurveyListView', 16 10 type: 'question', 17 11 18 _createAvatarNode: function(item){12 createAvatar: function(id, item){ 19 13 return domConstruct.create("div",{ 20 14 'class': 'dragAvatar', … … 22 16 }); 23 17 }, 24 _createListNode: function(item) {18 createListElement: function(id, item) { 25 19 var w = new LineWithActionsWidget({ 20 id: id, 26 21 title: item.title, 27 22 'class': "inheritBgColor", 28 23 actions: { 29 24 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', i tem),25 callback: lang.hitch(this, 'removeItem', id), 31 26 properties: { 32 27 blockButton: false, … … 48 43 }); 49 44 w.startup(); 50 return w .domNode;45 return w; 51 46 } 52 47 }); -
Dev/trunk/client/qed/model/widgets/SurveyWidget.js
r433 r441 1 1 define([ 2 2 "../classes/Survey", 3 ". ./widgets/QuestionWidgetFactory",3 "./questions/Factory", 4 4 "dijit/_Container", 5 5 "dijit/_TemplatedMixin", -
Dev/trunk/client/qed/model/widgets/questions/Factory.js
r435 r441 1 1 define([ 2 "../../widgets/list/OrderedList", 3 "../../widgets/list/_EditableListMixin", 2 "./HeaderConfigWidget", 3 "./HeaderWidget", 4 "./MultipleChoiceInputConfigWidget", 5 "./MultipleChoiceInputWidget", 6 "./NumberInputConfigWidget", 7 "./NumberInputWidget", 4 8 "./ScaleInputConfigWidget", 5 9 "./ScaleInputWidget", 6 "dijit/_Container", 7 "dijit/_TemplatedMixin", 10 "./StringInputConfigWidget", 11 "./StringInputWidget", 12 "./TextConfigWidget", 13 "./TextInputConfigWidget", 14 "./TextInputWidget", 15 "./TextWidget", 8 16 "dijit/_WidgetBase", 9 "dijit/form/Button", 10 "dijit/form/CheckBox", 11 "dijit/form/Form", 12 "dijit/form/NumberSpinner", 13 "dijit/form/RadioButton", 14 "dijit/form/TextBox", 15 "dijit/form/Textarea", 16 "dojo/_base/array", 17 "dojo/_base/declare", 18 "dojo/_base/lang", 19 "dojo/dom-construct", 20 "dojox/layout/TableContainer" 21 ], function(OrderedList, _EditableListMixin, ScaleInputConfigWidget, ScaleInputWidget, _Container, _TemplatedMixin, _WidgetBase, Button, CheckBox, Form, NumberSpinner, RadioButton, TextBox, Textarea, array, declare, lang, domConstruct, TableContainer) { 17 "dojo/_base/declare" 18 ], function(HeaderConfigWidget, HeaderWidget, MultipleChoiceInputConfigWidget, MultipleChoiceInputWidget, NumberInputConfigWidget, NumberInputWidget, ScaleInputConfigWidget, ScaleInputWidget, StringInputConfigWidget, StringInputWidget, TextConfigWidget, TextInputConfigWidget, TextInputWidget, TextWidget, _WidgetBase, declare) { 22 19 var factory = declare(null, { 23 20 createViewWidget: function(/*Object*/options) { … … 31 28 createEditWidget: function(/*Object*/options) { 32 29 var fun = this['create'+options.type+'EditWidget']; 33 var view = fun !== undefined ? fun() : null; 34 if (view) { 35 view.set('value', options); 36 } 30 var view = fun !== undefined ? fun(options) : null; 37 31 return view; 38 32 }, 39 33 40 createHeaderViewWidget: function(options) { 41 return new HeaderView({ 42 options: options 34 createHeaderViewWidget: function(config) { 35 return new HeaderWidget(config); 36 }, 37 createHeaderEditWidget: function(config) { 38 return new HeaderConfigWidget({ 39 value: config 43 40 }); 44 41 }, 45 createHeaderEditWidget: function() { 46 return new HeaderEdit(); 42 43 createTextViewWidget: function(config) { 44 return new TextWidget(config); 47 45 }, 48 49 createTextViewWidget: function(options) { 50 return new TextView({ 51 options: options 46 createTextEditWidget: function(config) { 47 return new TextConfigWidget({ 48 value: config 52 49 }); 53 },54 createTextEditWidget: function() {55 return new TextEdit();56 50 }, 57 51 … … 62 56 }, 63 57 64 createStringInputViewWidget: function(options) { 65 return new StringInputView({ 66 options: options 58 createStringInputViewWidget: function(config) { 59 return new StringInputWidget(config); 60 }, 61 createStringInputEditWidget: function(config) { 62 return new StringInputConfigWidget({ 63 value: config 67 64 }); 68 65 }, 69 createStringInputEditWidget: function() { 70 return new StringInputEdit(); 66 67 createTextInputViewWidget: function(config) { 68 return new TextInputWidget(config); 69 }, 70 createTextInputEditWidget: function(config) { 71 return new TextInputConfigWidget({ 72 value: config 73 }); 71 74 }, 72 75 73 createTextInputViewWidget: function(options) { 74 return new TextInputView({ 75 options: options 76 createNumberInputViewWidget: function(config) { 77 return new NumberInputWidget(config); 78 }, 79 createNumberInputEditWidget: function(config) { 80 return new NumberInputConfigWidget({ 81 value: config 76 82 }); 77 83 }, 78 createTextInputEditWidget: function() { 79 return new TextInputEdit(); 84 85 createMultipleChoiceInputViewWidget: function(config) { 86 return new MultipleChoiceInputWidget(config); 80 87 }, 81 82 createIntegerInputViewWidget: function(options) { 83 return new IntegerInputView({ 84 options: options 88 createMultipleChoiceInputEditWidget: function(config) { 89 return new MultipleChoiceInputConfigWidget({ 90 value: config 85 91 }); 86 },87 createIntegerInputEditWidget: function() {88 return new IntegerInputEdit();89 },90 91 createMultipleChoiceInputViewWidget: function(options) {92 return new MultipleChoiceInputView({93 options: options94 });95 },96 createMultipleChoiceInputEditWidget: function() {97 return new MultipleChoiceInputEdit();98 92 }, 99 93 … … 108 102 }); 109 103 110 var DefaultEdit = declare([Form,_Container],{111 type: null,112 addChild: function(widget) {113 domConstruct.create("label",{114 innerHTML: widget.title || ''115 },this.containerNode,'last');116 this.inherited(arguments,[widget]);117 },118 _getValueAttr: function() {119 var val = this.inherited(arguments);120 val.type = this.type;121 return val;122 }123 });124 125 var HeaderView = declare([_WidgetBase], {126 postCreate: function() {127 this.domNode.innerHTML = "<h2>"+this.options.content+"</h2>";128 }129 });130 131 var HeaderEdit = declare([DefaultEdit], {132 type: 'Header',133 postCreate: function() {134 this.inherited(arguments);135 this.addChild(new TextBox({136 title: 'Content',137 name: 'content'138 }));139 }140 });141 142 var TextView = declare([_WidgetBase], {143 postCreate: function() {144 this.domNode.innerHTML = "<p>"+this.options.content+"</p>";145 }146 });147 148 var TextEdit = declare([DefaultEdit], {149 type: 'Text',150 postCreate: function() {151 this.inherited(arguments);152 this.addChild(new Textarea({153 title: 'Content',154 name: 'content'155 }));156 }157 });158 159 104 var DividerView = declare([_WidgetBase], { 160 105 postCreate: function() { … … 163 108 }); 164 109 165 var DefaultInputEdit = declare([DefaultEdit],{166 postCreate: function() {167 this.inherited(arguments);168 this.addChild(new TextBox({169 title: 'Text',170 name: 'text'171 }));172 }173 });174 175 var StringInputView = declare([_WidgetBase, _Container],{176 _textBox: null,177 postCreate: function() {178 this._textBox = new TextBox({179 name: this.options.code || ''180 });181 this.addChild(this._textBox);182 this._textBox.startup();183 },184 _setReadOnlyAttr: function(value) {185 this._textBox.set('readOnly', value);186 },187 _getCodeAttr: function() {188 return this.options.code;189 },190 _getValueAttr: function() {191 return this._textBox.get('value') || "";192 },193 _setValueAttr: function(value) {194 this._textBox.set('value',value || "");195 }196 });197 198 var StringInputEdit = declare([DefaultInputEdit],{199 type: 'StringInput'200 });201 202 var TextInputView = declare([_WidgetBase, _Container], {203 _textArea: null,204 postCreate: function() {205 this._textArea = new Textarea({206 name: this.options.code207 });208 this._textArea.set('maxLength', this.options.maxLength || 1000);209 this._textArea.set('value', this.options.defaultValue || "");210 this.addChild(this._textArea);211 this._textArea.startup();212 },213 _getCodeAttr: function() {214 return this.options.code;215 },216 _getValueAttr: function() {217 return this._textArea.get('value');218 },219 _setReadOnlyAttr: function(value) {220 this._textArea.set('readOnly', value);221 }222 });223 224 var TextInputEdit = declare([DefaultInputEdit], {225 type: 'TextInput',226 postCreate: function() {227 this.inherited(arguments);228 this.addChild(new NumberSpinner({229 name: 'maxLength',230 title: "Maximum length",231 constraints: {232 min: 0233 }234 }));235 }236 });237 238 var IntegerInputView = declare([_WidgetBase, _Container], {239 _numberInput: null,240 postCreate: function() {241 this._numberInput = new NumberSpinner({242 name: this.options.code || '',243 constraints: {244 min: this.options.min,245 max: this.options.max,246 smallDelta: this.options.step247 }248 });249 this.addChild(this._numberInput);250 this._numberInput.startup();251 },252 _getCodeAttr: function() {253 return this.options.code;254 },255 _getValueAttr: function() {256 return this._numberInput.get('value');257 },258 _setReadOnlyAttr: function(value) {259 this._numberInput.set('readOnly', value);260 }261 });262 263 var IntegerInputEdit = declare([DefaultInputEdit], {264 type: 'IntegerInput',265 postCreate: function() {266 this.inherited(arguments);267 this.addChild(new NumberSpinner({268 title: "Minimum",269 name: 'min'270 }));271 this.addChild(new NumberSpinner({272 title: "Maximum",273 name: 'max'274 }));275 this.addChild(new NumberSpinner({276 title: "Step",277 name: 'step'278 }));279 }280 });281 282 var MultipleChoiceInputView = declare([_WidgetBase, _Container], {283 postCreate: function() {284 var table = new TableContainer({ cols: 1, customClass: "labelsAndValues"} );285 286 var Ctor = this.options.multiple === true ? CheckBox : RadioButton;287 array.forEach(this.options.items || [], function(item){288 table.addChild(new Ctor({289 name: this.options.code || '',290 title: item291 }));292 },this);293 294 this.addChild(table);295 table.startup();296 },297 _getCodeAttr: function() {298 return this.options.code;299 },300 _getValueAttr: function() {301 var checked = array.filter(this.getChildren(),function(child){302 return child.get('checked');303 });304 if ( this.options.multiple ) {305 return array.map(checked,function(child){306 return child.get('value');307 });308 } else {309 return checked.length > 0 ? checked[0].get('value') : null;310 }311 },312 _setReadOnlyAttr: function(value) {313 array.forEach(this.getChildren(),function(child){314 child.set('readOnly', value);315 },this);316 }317 });318 319 var MCOptionItem = declare([_WidgetBase,_TemplatedMixin,_Container],{320 templateString: '<div><span class="dojoDndHandle">=</span></div>',321 _textBox: null,322 postCreate: function() {323 this._textBox = new TextBox({});324 this.addChild(this._textBox);325 this._textBox.startup();326 327 var del = new Button({328 label: "X",329 onClick: lang.hitch(this,'onDelete')330 });331 this.addChild(del);332 del.startup();333 },334 _getValueAttr: function() {335 return this._textBox.set('value');336 },337 _setValueAttr: function(value) {338 this._textBox.set('value',value);339 },340 onDelete: function(){}341 });342 343 var MCOptionList = declare([OrderedList,_EditableListMixin],{344 type: 'multipleChoiceOption',345 withHandles: true,346 _createAvatarNode: function(item){347 return domConstruct.create("div",{348 'class': 'dragAvatar',349 innerHTML: item350 });351 },352 _createListNode: function(item) {353 var w = new MCOptionItem();354 w.startup();355 w.set('value',item);356 w.on('delete',lang.hitch(this,'_onRemove',w,item));357 return w.domNode;358 },359 _onRemove: function(w,item) {360 w.destroyRecursive();361 if ( this.removeCallback ) { this.removeCallback(item); }362 this.source.sync();363 }364 });365 366 var MultipleChoiceInputEdit = declare([_WidgetBase, _Container], {367 _multipleInput: null,368 postCreate: function() {369 var table = new TableContainer({ cols: 1, customClass: "labelsAndValues"} );370 371 this._multipleInput = new CheckBox({372 title: "Allow multiple"373 });374 table.addChild(this._multipleInput);375 this._multipleInput.startup();376 377 var add = new Button({378 label: "Add",379 onClick: lang.hitch(this,'_addOption',"")380 });381 table.addChild(add);382 add.startup();383 384 this._optionsList = new MCOptionList();385 table.addChild(this._optionsList);386 this._optionsList.startup();387 388 this.addChild(table);389 table.startup();390 },391 392 _addOption: function() {393 this._optionsList.appendItems([""]);394 },395 396 _setValueAttr: function(value) {397 this._multipleInput.set('checked', value.multiple);398 this._optionsList.deleteItems();399 this._optionsList.appendItems(value.items || []);400 },401 _getValueAttr: function() {402 return {403 type: "MultipleChoiceInput",404 multiple: this._multipleInput.get('checked'),405 items: array.map(this._optionsList.getItems(),function(item){406 return item.get('value');407 },this)408 };409 }410 });411 412 110 return factory; 413 111 }); -
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); -
Dev/trunk/client/qed/model/widgets/questions/ScaleInputWidget.js
r435 r441 1 1 define([ 2 "dijit/_Container", 3 "dijit/_TemplatedMixin", 4 "dijit/_WidgetBase", 2 "../../../widgets/_ComplexValueWidget", 5 3 "dijit/form/RadioButton", 6 "dijit/form/_FormMixin",7 4 "dojo/_base/array", 8 5 "dojo/_base/declare", … … 11 8 "dojo/dom-construct", 12 9 "dojo/text!./templates/ScaleInputWidget.html" 13 ], function(_Co ntainer, _TemplatedMixin, _WidgetBase, RadioButton, _FormMixin, array, declare, lang, domAttr, domConstruct, template) {14 return declare([_ WidgetBase,_TemplatedMixin,_Container,_FormMixin],{10 ], function(_ComplexValueWidget, RadioButton, array, declare, lang, domAttr, domConstruct, template) { 11 return declare([_ComplexValueWidget],{ 15 12 templateString: template, 16 13 baseClass: "qedScaleWidget", … … 41 38 domConstruct.create("th", { 42 39 innerHTML: i.toString() 43 }, this.m inNode, "after");40 }, this.maxNode, "before"); 44 41 } 45 42 }, … … 69 66 className: 'max' 70 67 }, tr); 71 if ( this.naLabel !== null ) {68 if ( this.naLabel !== null && this.naLabel !== "" ) { 72 69 td = domConstruct.create("td", {}, tr); 73 70 radio = new RadioButton({ -
Dev/trunk/client/qed/model/widgets/questions/templates/ScaleInputConfigWidget.html
r435 r441 41 41 <td class="item"> 42 42 <button data-dojo-type="dijit/form/Button" 43 data-dojo-attach-event="onClick:onAdd Item">Click to add item</button>43 data-dojo-attach-event="onClick:onAddNewItem">Click to add item</button> 44 44 </td> 45 45 </tr> -
Dev/trunk/client/qed/pages/question.js
r426 r441 42 42 _refresh: function () { 43 43 this.titleNode.innerHTML = Question.DisplayTitle.get(this.question); 44 this._toolkit.set('value', this.question);45 this._preview. appendItems(Question.Content.get(this.question));44 this._toolkit.set('value', this.question); 45 this._preview.set('value', Question.Content.get(this.question)); 46 46 }, 47 47 _onSave: function(evt) { 48 lang.mixin(this.question, this._toolkit.get('value')); 49 Question.Content.set(this.question, this._preview.getItems()); 50 store.put(this.question) 51 .then(function() { 52 Router.go('/questions'); 53 },function(err){ 54 Content.notify(err,'error'); 55 }); 48 if ( this._preview.validate() ) { 49 lang.mixin(this.question, this._toolkit.get('value')); 50 Question.Content.set(this.question, this._preview.get('value')); 51 store.put(this.question) 52 .then(function() { 53 Router.go('/questions'); 54 },function(err){ 55 Content.notify(err,'error'); 56 }); 57 } 56 58 if ( evt ) { event.stop( evt ); } 57 59 return false; … … 68 70 69 71 this._preview = new QuestionEditorPreview({ 70 },this.QuestionEditorPreviewNode); 72 name: 'content', 73 delay: 5, 74 region: 'center' 75 }); 71 76 this._preview.startup(); 72 this. _supportingWidgets.push(this._toolkit,this._preview);77 this.addChild(this._preview); 73 78 } 74 79 }); -
Dev/trunk/client/qed/pages/session.js
r420 r441 51 51 onSave: function(evt) { 52 52 lang.mixin(this.session,this.propertiesForm.get('value')); 53 this.session.accounts = array.map(this._accountList.getItems(),function(item){ 54 return store.getIdentity(item); 53 this.session.accounts = array.map(this._accountList.get('value'), 54 function(item){ 55 return store.getIdentity(item); 55 56 }); 56 57 store.put(this.session) … … 71 72 }, 72 73 _setupAccountList: function() { 73 this._accountList = new AccountListView().placeAt(this.accountListNode); 74 this._accountList = new AccountListView({ 75 value: this.session.accounts 76 }).placeAt(this.accountListNode); 74 77 this._accountList.startup(); 75 for (var account in this.session.accounts) {76 this._accountList.insertItem(this.session.accounts[account]);77 }78 78 }, 79 79 _setupAutoComplete: function() { -
Dev/trunk/client/qed/pages/survey.js
r426 r441 55 55 _setupListView: function() { 56 56 this.questionList = new QuestionListView({ 57 region: 'center' 57 region: 'center', 58 name: 'questions' 58 59 },this.surveyListViewNode); 59 60 this.questionList.startup(); … … 67 68 .then(lang.hitch(this,function(survey){ 68 69 this.survey = survey; 69 array.forEach(Survey.Questions.get(this.survey),70 lang.hitch(this.questionList,'appendItem'));70 this.questionList.set('value', 71 Survey.Questions.get(this.survey)); 71 72 this.refresh(); 72 73 })); … … 74 75 }, 75 76 _includeQuestion: function(question) { 76 this.questionList. insertItem(question);77 this.questionList.appendItem(question); 77 78 }, 78 79 refresh: function() { … … 97 98 }, 98 99 _onSave: function(evt) { 99 this.survey.questions = this.questionList.get Items();100 this.survey.questions = this.questionList.get('value'); 100 101 store.put(this.survey) 101 102 .then(function() { -
Dev/trunk/client/qed/pages/templates/question.html
r417 r441 15 15 </div> 16 16 </div> 17 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">18 <div data-dojo-attach-point="QuestionEditorPreviewNode"></div>19 </div>20 17 </div> -
Dev/trunk/client/qed/stddeps.js
r420 r441 28 28 29 29 'qed/model/widgets/AccountListView', 30 'qed/model/widgets/QuestionWidget',31 30 'qed/model/widgets/SurveyFieldset', 32 31 'qed/model/widgets/SurveyRunFieldset', … … 41 40 'qed/widgets/ObjectBox', 42 41 'qed/widgets/Selector', 43 'qed/widgets/TitleGroup', 44 'qed/widgets/list/List', 45 'qed/widgets/list/OrderedList' 42 'qed/widgets/TitleGroup' 46 43 ],function(){}); -
Dev/trunk/client/qed/store.js
r420 r441 9 9 10 10 var couchStore = new CouchStore({ 11 target: 'data/couch/' ,11 target: 'data/couch/' /*, 12 12 validate: function(object) { 13 13 var result = jsonSchema.validate(object,schema); … … 18 18 return false; 19 19 } 20 } 20 }*/ 21 21 }); 22 22 var memoryStore = new Memory({ -
Dev/trunk/client/qed/tests/test_ScaleWidget.html
r435 r441 14 14 'dojo/when', 15 15 'dojo/parser', 16 'qed/model/widgets/ ScaleInputConfigWidget',17 'qed/model/widgets/ ScaleInputWidget',16 'qed/model/widgets/questions/ScaleInputConfigWidget', 17 'qed/model/widgets/questions/ScaleInputWidget', 18 18 'dojo/domReady!' 19 19 ], function(registry,dom,when,parser,ScaleInputConfigWidget,ScaleInputWidget){ … … 73 73 <div> 74 74 <div id="configWidget" 75 data-dojo-type="qed/model/widgets/ ScaleInputConfigWidget"></div>75 data-dojo-type="qed/model/widgets/questions/ScaleInputConfigWidget"></div> 76 76 <button id="defaultConfigButton" 77 77 data-dojo-type="dijit/form/Button">Set Example</button>
Note: See TracChangeset
for help on using the changeset viewer.