source: Dev/branches/rest-dojo-ui/client/rft/ui/SurveyEditorPreview.js @ 358

Last change on this file since 358 was 355, checked in by tjcschipper, 13 years ago
  • surveyEditor more or less works! Only needed change is addition of "topic" property in question objects (database-side), and the change from "category"(string) to "categories"(string[]).
  • surveyEditor still needs removal function and infofunction to be written properly!
  • Added all files belonging to SurveyAdvanced?. Most do not work properly yet, but at least there will not be a 404 page when you click btnPreview on survey.html.
File size: 2.4 KB
Line 
1define([
2        'dojo/_base/declare',
3        'dojo/_base/lang',
4        'dojo/_base/array',
5        'dijit/_WidgetBase',
6        'dijit/_Container',
7        'dojo/dom-construct',
8        'dojo/store/Memory',
9        'rft/ui/SurveyEditorPreviewItem',
10        'dijit/_TemplatedMixin',
11        'dijit/_WidgetsInTemplateMixin',
12        'dojo/text!./templates/SurveyEditorPreview.html'
13        ], function(declare, lang, baseArray, _WidgetBase, _Container, domConstruct, Memory, SurveyEditorPreviewItem, _TemplatedMixin, _WidgetsInTemplateMixin, template) {
14                return declare("rft.ui.SurveyEditorPreview", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _Container], {
15
16                        templateString: template,
17                        store: null,
18                        dndSource: null,
19
20                        postCreate: function(){
21                                this.dndSource = new dojo.dnd.Source(this.dndSourceNode, {
22                                        isSource: true,
23                                        //accept: ["editorToolkitItem", "editorPreviewItem"],
24                                        horizontal: false,
25                                        withHandles: false,
26                                        copyOnly: false,
27                                        selfCopy: false,
28                                        selfAccept: true,
29                                        delay: 0,
30                                        skipForm: true,
31                                        parent: this.dndSourceContainerNode,
32                                        creator: lang.hitch(this, this._sourceCreatorMethod)
33                                });
34                                this.dndSource.startup();
35
36                                this.store = new Memory({
37                                        data: [],
38                                        idProperty: "code"
39                                });
40                        },
41                        _sourceCreatorMethod: function(item, hint){
42                                switch(hint){
43                                        case "avatar":
44                                        var node = document.createElement("div");
45                                        node.innerHTML = item.title || "Dragging!!!";
46                                        item.node = node;
47                                        break;
48                                        default:
49                                        var widget = new rft.ui.SurveyEditorPreviewItem({
50                                                data: item.data,
51                                                type: item.type
52                                        });
53                                        item.node = widget.domNode;
54                                        break;                                 
55                                }
56                                console.log(item);
57                                return item;
58
59                               
60                                /* TODO: Create widgetFactory method that handles creation of PreviewItem Dialogs and Views */
61                        },
62                       
63                        InsertObjects: function(/*Array*/objects) {
64                                // This takes an array of objects {data:{//props}, type:[//types]}. Node is NOT included!
65                                objects.forEach(function(item){
66                                        this.dndSource.insertNodes(false, [item]);
67                                }, this);
68                        },
69
70                        RemoveObject: function(widget) {
71                        },
72                        GetNodeList: function() {
73                                return this.dndSource.getAllNodes();
74                        },
75                        onDropInternal: function() {
76                                topic.publish("/SurveyEditor/Preview/MoveItem");
77                        },
78                        onDropExternal: function() {
79                                // This is fired when something from the Toolkit is dropped into the Preview -- add operation.
80                                topic.publish("/SurveyEditor/Preview/AddItem");
81                        }
82
83                });
84});
Note: See TracBrowser for help on using the repository browser.