- Timestamp:
- 07/25/12 16:04:02 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.