Changeset 360 for Dev/branches/rest-dojo-ui/client/rft/ui/SurveyListView.js
- Timestamp:
- 07/13/12 15:13:46 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client
-
Property
svn:ignore
set to
-
Property
svn:ignore
set to
-
Dev/branches/rest-dojo-ui/client/rft/ui/SurveyListView.js
r358 r360 1 1 define([ 2 'dojo/_base/declare', 3 'dijit/_WidgetBase', 4 'dijit/_TemplatedMixin', 5 'dojo/_base/lang', 6 'dojo/fx', 7 'dojo/_base/fx', 8 'dijit/_WidgetsInTemplateMixin', 9 'dijit/_Container', 10 'rft/ui/LineWithActionsWidget', 11 'dojo/text!./templates/SurveyListView.html' 12 ],function( 13 declare, 14 _WidgetBase, 15 _TemplatedMixin, 16 lang, 17 fx, 18 baseFx, 19 _WidgetsInTemplateMixin, 20 _Container, 21 LineWithActionsWidget, 22 templateString 23 ){ 24 return declare('rft.ui.SurveyListView',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 25 templateString: templateString, 26 baseClass: 'rftSurveyListView', 27 source: null, 28 controller: null, 29 region: 'center', 2 'dojo/_base/declare', 3 'dijit/_WidgetBase', 4 'dijit/_TemplatedMixin', 5 'dojo/_base/lang', 6 'dojo/fx', 7 'dojo/_base/fx', 8 'dijit/_WidgetsInTemplateMixin', 9 'dijit/_Container', 10 'rft/ui/LineWithActionsWidget', 11 'dojo/text!./templates/SurveyListView.html' 12 ],function( 13 declare, 14 _WidgetBase, 15 _TemplatedMixin, 16 lang, 17 fx, 18 baseFx, 19 _WidgetsInTemplateMixin, 20 _Container, 21 LineWithActionsWidget, 22 templateString 23 ){ 24 return declare('rft.ui.SurveyListView',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 25 templateString: templateString, 26 baseClass: 'rftSurveyListView', 27 source: null, 28 region: 'center', 30 29 31 32 33 34 35 36 30 postCreate: function() { 31 if (this.title) { 32 this.titleNode.innerHTML = this.title; 33 } else { 34 this.domNode.removeChild(this.titleNode); 35 } 37 36 38 39 40 41 42 43 44 45 46 47 48 creator: dojo.partial(this.creatorMethod, this.controller, this)49 37 this.source = new dojo.dnd.Source(this.sourceNode, { 38 isSource: true, 39 accept: ["SurveyListViewItem"], 40 horizontal: false, 41 withHandles: false, 42 copyOnly: false, 43 selfCopy: false, 44 selfAccept: true, 45 delay: 0, 46 singular: true, 47 creator: lang.hitch(this, this.creatorMethod) 48 }); 50 49 51 52 53 54 55 56 class: "trans",57 58 59 60 50 new dijit.form.Button({ 51 label: "Move up", 52 showLabel: false, 53 iconClass: "rftIcon rftIconFullArrowUp", 54 baseClass: "rftBlockButton", 55 'class': "trans", 56 onClick: lang.hitch(this, function() { 57 this.moveItem("up"); 58 }) 59 }, this.btnListMoveUp); 61 60 62 new dijit.form.Button({ 63 label: "Move down", 64 showLabel: false, 65 iconClass: "rftIcon rftIconFullArrowDown", 66 baseClass: "rftBlockButton", 67 class: "trans", 68 onClick: lang.hitch(this, function() { 69 this.moveItem("down"); 70 }) 71 }, this.btnListMoveDown); 72 }, 73 creatorMethod: function(controller, listView, item, hint) { 74 var node, 75 object = controller.getQuestion(item); 76 if (!object) { 77 return false; 78 } 61 new dijit.form.Button({ 62 label: "Move down", 63 showLabel: false, 64 iconClass: "rftIcon rftIconFullArrowDown", 65 baseClass: "rftBlockButton", 66 'class': "trans", 67 onClick: lang.hitch(this, function() { 68 this.moveItem("down"); 69 }) 70 }, this.btnListMoveDown); 71 }, 72 creatorMethod: function(item, hint) { 73 var node; 79 74 80 81 82 83 node.innerHTML = object.title;84 85 86 title: object.title,87 class: "inheritBgColor",88 89 90 callback: lang.hitch(listView, function(evt){91 this.removeItem(evt);92 93 94 95 96 97 98 99 100 101 callback: function(){ 102 var question = controller.getQuestion(item); 103 console.log(question); 104 alert("info goes here yo!"); 105 },106 properties: { 107 blockButton: false, 108 icon: "Inspect", 109 modifiers: "white", 110 label: "Show info" 111 } 112 } 113 114 }); 115 w.startup(); 116 node = w.domNode; 117 } 118 var fullItem = {node: node, data: item, type: "SurveyListviewItem"} 119 120 121 122 123 124 125 126 127 128 129 75 if (hint == "avatar") { 76 node = document.createElement("div"); 77 node.className = "dragAvatar"; 78 node.innerHTML = item.title; 79 } else { 80 var w = new LineWithActionsWidget({ 81 title: item.title, 82 'class': "inheritBgColor", 83 actions: { 84 "Remove" : { 85 callback: lang.hitch(this, function(){ 86 this.removeItem(item, w); 87 }), 88 properties: { 89 blockButton: false, 90 icon: "Delete", 91 modifiers: "white", 92 label: "Remove" 93 } 94 }, 95 "Info" : { 96 callback: function(){ item.description && alert(item.description); }, 97 properties: { 98 blockButton: false, 99 icon: "Inspect", 100 modifiers: "white", 101 label: "Show info" 102 } 103 } 104 } 105 }); 106 w.startup(); 107 node = w.domNode; 108 } 109 var fullItem = { 110 node: node, 111 data: item, 112 type: "SurveyListviewItem" 113 }; 114 return fullItem; 115 }, 116 moveItem: function(dir) { 117 var node = this.source.getSelectedNodes()[0]; 118 if (node) { 119 if (dir == "up") { 120 if (node.previousSibling) { 121 return node.parentNode.insertBefore(node, node.previousSibling); 122 } else { 123 return false; 124 } 130 125 131 132 133 134 135 136 137 138 139 140 141 142 143 144 insertItem: function(objectId) {145 146 147 this.source.insertNodes(false, [objectId], false, anchor);148 149 this.source.insertNodes(false, [objectId]);150 151 152 removeItem: function(evt){153 debugger;154 155 126 } else if (dir == "down") { 127 if (node.nextSibling) { 128 return node.parentNode.insertBefore(node.nextSibling, node); 129 } else { 130 return false; 131 } 132 } else { 133 throw "Invalid move direction passed!"; 134 } 135 } else { 136 return false; 137 } 138 }, 139 insertItem: function(item) { 140 var anchor = this.source.getSelectedNodes()[0]; 141 if (anchor) { 142 this.source.insertNodes(false,[item], false, anchor); 143 } else { 144 this.source.insertNodes(false,[item]); 145 } 146 }, 147 removeItem: function(item,widget){ 148 widget.destroy(); 149 } 150 }); 156 151 });
Note: See TracChangeset
for help on using the changeset viewer.