- Timestamp:
- 08/06/12 17:39:05 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorPreview.js
r388 r389 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dojo/dnd/Source',5 4 'dojo/dom-construct', 6 'dijit/layout/ContentPane', 7 'rft/ui/QuestionEditorPreviewItem', 8 'dojo/text!./templates/QuestionEditorPreview.html' 9 ], function(declare, lang, Source, domConstruct, ContentPane, QuestionEditorPreviewItem, template) { 10 return declare("rft.ui.QuestionEditorPreview", [ContentPane], { 5 'dijit/registry', 6 './QuestionEditorPreviewItem', 7 './lists/OrderedList', 8 ], function(declare, lang, domConstruct, registry, QuestionEditorPreviewItem, OrderedList) { 9 return declare("rft.ui.QuestionEditorPreview", [OrderedList], { 10 baseClass: 'surveyEditorPreview', 11 type: 'questionContent', 11 12 12 templateString: template, 13 'class': 'surveyEditorPreview', 14 dndSource: null, 15 16 startup: function(){ 17 this.inherited(arguments); 18 this.dndSource = new Source(this.domNode, { 19 accept: ["questionContent"], 20 skipForm: true, 21 creator: lang.hitch(this, this._sourceCreatorMethod) 13 _createAvatarNode: function(item) { 14 return domConstruct.create("span",{ 15 innerHTML: item.type || "Dragging!!!" 22 16 }); 23 this.dndSource.startup();24 17 }, 25 _sourceCreatorMethod: function(item, hint){ 26 var node; 27 switch(hint){ 28 case "avatar": 29 node = domConstruct.create("span",{ 30 innerHTML: item.type || "Dragging!!!" 31 }); 32 default: 33 var previewItem = new QuestionEditorPreviewItem({ 34 item: item.content 35 }); 36 node = previewItem.domNode; 37 } 38 return {node: node, data: item, type: ["questionContent"]}; 18 _createListNode: function(item) { 19 var previewItem = new QuestionEditorPreviewItem({ 20 item: item 21 }); 22 previewItem.on('close',lang.hitch(this,'removeItem',item)); 23 previewItem.startup(); 24 return previewItem.domNode; 39 25 }, 40 insertObjects: function(/*Array*/items) { 41 this.dndSource.insertNodes(false, items); 42 }, 43 getContent: function() { 44 var content = []; 45 var nodes = this.dndSource.getAllNodes(); 46 for (var i = 0; i < nodes.length; i++) { 47 content.push(this.dndSource.getItem(nodes[i].id).data.getContent()); 48 } 49 return content; 50 }, 51 getNodeList: function() { 52 return this.dndSource.getAllNodes(); 53 }, 54 onDropInternal: function() { 55 topic.publish("/QuestionEditor/Preview/MoveItem"); 56 }, 57 onDropExternal: function() { 58 // This is fired when something from the Toolkit is dropped into the Preview -- add operation. 59 topic.publish("/QuestionEditor/Preview/AddItem"); 26 getItems: function() { 27 return this.source.getAllNodes() 28 .map(function(node){ 29 return registry.byNode(node).get('value'); 30 },this); 60 31 } 61 62 32 }); 63 33 });
Note: See TracChangeset
for help on using the changeset viewer.