Changeset 376
- Timestamp:
- 07/25/12 16:04:02 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/pages/question.js
r374 r376 39 39 _refresh: function () { 40 40 this._toolkit.loadQuestion(this.question); 41 this._preview.insertObjects(this.question.content || []); 41 42 }, 42 43 _onSave: function() { 43 44 lang.mixin(this.question, this._toolkit.propertiesForm.get('value')); 44 45 this.question.categories = this._toolkit._categories; 46 this.question.content = this._preview.getContent(); 45 47 store.put(this.question) 46 48 .then(function() { … … 50 52 }, 51 53 _onDiscard: function() { 52 this._toolkit.propertiesForm.reset();53 54 content.goTo('questions'); 54 55 return false; … … 71 72 }, 72 73 _setupEditor: function() { 73 // this.toolkit = new rft.ui.QuestionEditorToolkit( { question: this.question } );74 74 this._toolkit = new rft.ui.QuestionEditorToolkit(); 75 75 this._toolkit.placeAt("QuestionEditorToolkit"); -
Dev/branches/rest-dojo-ui/client/rft/run.js
r374 r376 42 42 'rft/ui/Selector', 43 43 'rft/ui/TitleGroup', 44 44 'rft/ui/PreviewWidgets/HeaderItem', 45 'rft/ui/PreviewWidgets/TextItem', 45 46 // pages -> load dynamically? 46 47 'rft/pages/index', -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorPreview.js
r366 r376 45 45 item: item 46 46 }); 47 return {node: previewItem.domNode, data: item, type: "PreviewItem"};47 return {node: previewItem.domNode, data: previewItem, type: item.type}; 48 48 break; 49 49 } … … 59 59 return innerWidget; 60 60 }, 61 InsertObjects: function(/*Array*/objects) {61 insertObjects: function(/*Array*/objects) { 62 62 // This takes an array of objects {data:{//props}, type:[//types]}. Node is NOT included! 63 63 objects.forEach(function(item){ … … 65 65 }, this); 66 66 }, 67 RemoveObject: function(widget) { 67 getContent: function() { 68 content = []; 69 var nodes = this.dndSource.getAllNodes(); 70 for (var i = 0; i < nodes.length; i++) { 71 content.push(this.dndSource.getItem(nodes[i].id).data.getContent()); 72 } 73 return content; 68 74 }, 69 GetNodeList: function() {75 getNodeList: function() { 70 76 return this.dndSource.getAllNodes(); 71 77 }, -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorPreviewItem.js
r370 r376 9 9 'dijit/_WidgetsInTemplateMixin', 10 10 'dijit/form/TextBox', 11 'rft/ui/PreviewWidgets/HeaderItem', 12 'rft/ui/PreviewWidgets/TextItem', 11 13 'dojo/text!./templates/QuestionEditorPreviewItem.html', 12 ], function(declare, fx, _WidgetBase, domClass, lang, on, _TemplatedMixin, _WidgetsInTemplateMixin, TextBox, templateFull) {14 ], function(declare, fx, _WidgetBase, domClass, lang, on, _TemplatedMixin, _WidgetsInTemplateMixin, TextBox, HeaderItem, TextItem, templateFull) { 13 15 return declare("rft.ui.QuestionEditorPreviewItem", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { 14 16 … … 20 22 foldDuration: [250, 250], 21 23 animation: null, 22 24 _editing: false, 25 23 26 postCreate: function() { 24 27 this.foldButtonNode.onClick = lang.hitch(this, this.toggleFold); 28 this.removeButtonNode.onClick = lang.hitch(this, this.removeObject); 29 this.editButtonNode.onClick = lang.hitch(this, this.toggleEdit); 25 30 if (this.item) { 26 31 this._createInnerWidget(); … … 32 37 this.titleNode.innerHTML = title; 33 38 }); 39 }, 40 toggleEdit: function() { 41 if(this._editing) { 42 this.editButtonNode.iconNode.className = this.editButtonNode.iconNode.className.replace("rftIconAccept", "rftIconEdit"); 43 this.editButtonNode.set("label", "Edit"); 44 this.innerWidget.save(); 45 } 46 else { 47 this.editButtonNode.iconNode.className = this.editButtonNode.iconNode.className.replace("rftIconEdit", "rftIconAccept"); 48 this.editButtonNode.set("label", "Save"); 49 this.innerWidget.edit(); 50 } 51 this._editing = !this._editing; 34 52 }, 35 53 toggleFold: function() { … … 65 83 } 66 84 }, 85 getContent: function() { 86 return { data: this.innerWidget.getContent(), 87 type: this.item.type }; 88 }, 89 removeObject: function(widget) { 90 this.destroyRecursive(); 91 }, 67 92 _createInnerWidget: function() { 68 93 // This always creates a textbox as innerwidget pending creation of actual innerWidgets. 69 94 // Introduce a better way to create these widgets than a switch statement, based on item.widgetType? Perhaps "new eval(item.widgetType)({});" ? 95 this.innerWidget = eval("new "+ this.item.type + "({ disabled: true });"); 96 this.innerWidget.setContent(this.item.data); 97 this.titleNode.innerHTML = this.item.type; 98 /* 70 99 switch (this.item.widgetType) { 71 100 default: 72 this.innerWidget = new TextBox(); 101 this.innerWidget = new HeaderItem({ disabled: true }); 102 this.titleNode.innerHTML = "Header"; 73 103 break; 74 } 104 }*/ 75 105 this.innerWidget.placeAt(this.containerNode); 76 106 } -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorToolkit.js
r375 r376 134 134 objectData: { 135 135 _id: null, 136 widgetType: "rft.surveyContent.HeaderDialog",136 type: "HeaderItem", 137 137 widgetProps: {} 138 138 }, … … 143 143 objectData: { 144 144 _id: null, 145 widgetType: "rft.surveyContent.TextDialog",145 type: "TextItem", 146 146 widgetProps: {} 147 147 }, -
Dev/branches/rest-dojo-ui/client/rft/ui/templates/QuestionEditorPreviewItem.html
r366 r376 4 4 <span class="floatRight"> 5 5 <button class="blue" data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftBlockButton', showLabel: false, iconClass: 'rftIcon rftIconHalfArrowUp'" data-dojo-attach-point="foldButtonNode">Fold</button> 6 <button class="blue" data-dojo-type="dijit.form.Button" data-dojo- props="baseClass: 'rftBlockButton', showLabel: false, iconClass: 'rftIcon rftIconDelete'">Remove</button>6 <button class="blue" data-dojo-type="dijit.form.Button" data-dojo-attach-point="removeButtonNode" data-dojo-props="baseClass: 'rftBlockButton', showLabel: false, iconClass: 'rftIcon rftIconDelete'">Remove</button> 7 7 </span> 8 8 </div> … … 15 15 <div class="bottomBorder inheritBgColor light" data-dojo-attach-point="bottomBorderNode"> 16 16 <span class="floatRight"> 17 <button class="trans" data-dojo-type="dijit.form.Button" data-dojo- props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconEdit'">Edit</button>17 <button class="trans" data-dojo-type="dijit.form.Button" data-dojo-attach-point="editButtonNode" data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconEdit'">Edit</button> 18 18 </span> 19 19 </div>
Note: See TracChangeset
for help on using the changeset viewer.