1 | define([
|
---|
2 | 'dojo/_base/declare',
|
---|
3 | 'dojo/_base/lang',
|
---|
4 | 'dojo/_base/array',
|
---|
5 | 'dijit/_WidgetBase',
|
---|
6 | 'dijit/_Container',
|
---|
7 | 'dojo/dom-construct',
|
---|
8 | 'rft/ui/QuestionEditorPreviewItem',
|
---|
9 | 'dijit/_TemplatedMixin',
|
---|
10 | 'dijit/_WidgetsInTemplateMixin',
|
---|
11 | 'dojo/text!./templates/QuestionEditorToolkit.html'
|
---|
12 | ], function(declare, lang, baseArray, _WidgetBase, _Container, domConstruct, QuestionEditorPreviewItem, _TemplatedMixin, _WidgetsInTemplateMixin, template) {
|
---|
13 | return declare("rft.ui.QuestionEditorToolkit", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _Container], {
|
---|
14 |
|
---|
15 | templateString: template,
|
---|
16 | postCreate: function(){
|
---|
17 | this.contentSource = new dojo.dnd.Source(this.ToolkitContentSourceNode, {
|
---|
18 | accept: [],
|
---|
19 | horizontal: false,
|
---|
20 | withHandles: false,
|
---|
21 | copyOnly: true,
|
---|
22 | selfCopy: false,
|
---|
23 | selfAccept: false,
|
---|
24 | singular: true,
|
---|
25 | creator: this._creator
|
---|
26 | });
|
---|
27 | this.inputsSource = new dojo.dnd.Source(this.ToolkitInputsSourceNode, {
|
---|
28 | accept: [],
|
---|
29 | horizontal: false,
|
---|
30 | withHandles: false,
|
---|
31 | copyOnly: true,
|
---|
32 | selfCopy: false,
|
---|
33 | selfAccept: false,
|
---|
34 | singular: true,
|
---|
35 | creator: this._creator
|
---|
36 | });
|
---|
37 | var contentItems = this._contentItems();
|
---|
38 | var inputsItems = this._inputsItems();
|
---|
39 | this.contentSource.insertNodes(false, contentItems);
|
---|
40 | this.inputsSource.insertNodes(false, inputsItems);
|
---|
41 | },
|
---|
42 | _creator: function(item, hint) {
|
---|
43 | var node;
|
---|
44 | if (hint == "avatar") {
|
---|
45 | node = document.createElement("span");
|
---|
46 | node.innerHTML = item.widgetType;
|
---|
47 | // debugger;
|
---|
48 | return {node: node, data: item, type: "ToolkitItem"};
|
---|
49 | } else {
|
---|
50 | var w = new dijit.form.Button({
|
---|
51 | baseClass: "rftLargeButton",
|
---|
52 | iconClass: "rftIcon rftIcon"+item.icon,
|
---|
53 | label: item.label,
|
---|
54 | showLabel: true,
|
---|
55 | class: "newline"
|
---|
56 | });
|
---|
57 | return {node: w.domNode, data: item.objectData, type: "ToolkitItem"};
|
---|
58 | }
|
---|
59 | },
|
---|
60 | _contentItems: function() {
|
---|
61 | // Returns an array of objects, from which to generate buttons to populate the ToolkitContentSource list.
|
---|
62 | return [
|
---|
63 | {
|
---|
64 | label: "Header",
|
---|
65 | objectData: {
|
---|
66 | _id: null,
|
---|
67 | widgetType: "rft.surveyContent.HeaderDialog",
|
---|
68 | widgetProps: {}
|
---|
69 | },
|
---|
70 | icon: "Header"
|
---|
71 | },
|
---|
72 | {
|
---|
73 | label: "Text",
|
---|
74 | objectData: {
|
---|
75 | _id: null,
|
---|
76 | widgetType: "rft.surveyContent.TextDialog",
|
---|
77 | widgetProps: {}
|
---|
78 | },
|
---|
79 | icon: "TextBox"
|
---|
80 | },
|
---|
81 | {
|
---|
82 | label: "Image",
|
---|
83 | objectData: {
|
---|
84 | _id: null,
|
---|
85 | widgetType: "rft.surveyContent.ImageDialog",
|
---|
86 | widgetProps: {}
|
---|
87 | },
|
---|
88 | icon: "Image"
|
---|
89 | },
|
---|
90 | {
|
---|
91 | label: "External media",
|
---|
92 | objectData: {
|
---|
93 | _id: null,
|
---|
94 | widgetType: "rft.surveyContent.ExternalDialog",
|
---|
95 | widgetProps: {}
|
---|
96 | },
|
---|
97 | icon: "External"
|
---|
98 | },
|
---|
99 | {
|
---|
100 | label: "Divider",
|
---|
101 | objectData: {
|
---|
102 | _id: null,
|
---|
103 | widgetType: "rft.surveyContent.Divider",
|
---|
104 | widgetProps: {}
|
---|
105 | },
|
---|
106 | icon: "Divider"
|
---|
107 | }];
|
---|
108 | },
|
---|
109 | _inputsItems: function() {
|
---|
110 | // Returns an array of objects, from which to generate buttons to populate the ToolkitInputsSource list.
|
---|
111 | return [
|
---|
112 | {
|
---|
113 | label: "Free text",
|
---|
114 | objectData: {
|
---|
115 | _id: null,
|
---|
116 | widgetType: "rft.surveyContent.TextInput",
|
---|
117 | widgetProps: {}
|
---|
118 | },
|
---|
119 | icon: "Text"
|
---|
120 | },
|
---|
121 | {
|
---|
122 | label: "Integer",
|
---|
123 | objectData: {
|
---|
124 | _id: null,
|
---|
125 | widgetType: "rft.surveyContent.IntegerInput",
|
---|
126 | widgetProps: {}
|
---|
127 | },
|
---|
128 | icon: "Integer"
|
---|
129 | },
|
---|
130 | {
|
---|
131 | label: "Scale",
|
---|
132 | objectData: {
|
---|
133 | _id: null,
|
---|
134 | widgetType: "rft.surveyContent.ScaleInput",
|
---|
135 | widgetProps: {}
|
---|
136 | },
|
---|
137 | icon: "Scale"
|
---|
138 | },
|
---|
139 | {
|
---|
140 | label: "Cards",
|
---|
141 | objectData: {
|
---|
142 | _id: null,
|
---|
143 | widgetType: "rft.surveyContent.CardsInput",
|
---|
144 | widgetProps: {}
|
---|
145 | },
|
---|
146 | icon: "Cards"
|
---|
147 | },
|
---|
148 | {
|
---|
149 | label: "Multiple Choice",
|
---|
150 | objectData: {
|
---|
151 | _id: null,
|
---|
152 | widgetType: "rft.surveyContent.MultipleChoiceInput",
|
---|
153 | widgetProps: {}
|
---|
154 | },
|
---|
155 | icon: "MultipleChoice"
|
---|
156 | }
|
---|
157 | ];
|
---|
158 | }
|
---|
159 |
|
---|
160 | });
|
---|
161 | }); |
---|