Changeset 355 for Dev/branches/rest-dojo-ui/client/rft/ui/Selector.js
- Timestamp:
- 07/11/12 18:45:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/Selector.js
r354 r355 1 1 define([ 2 2 'dojo/_base/declare', 3 'dojo/_base/array', 4 'dijit/registry', 3 5 'dojo/_base/lang', 4 6 'dojo/fx', … … 12 14 ],function( 13 15 declare, 16 baseArray, 17 registry, 14 18 lang, 15 19 fx, … … 24 28 return declare('rft.ui.Selector',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 25 29 templateString: templateString, 26 title: " The professional as a participant",30 title: "ERROR: NULL_TOPIC", 27 31 baseClass: 'rftSelector', 28 32 modifiers: 'blue', 33 currentlySelectedId: null, 34 controller: null, // Use events/pubsub instead of a controller variable? Decoupling! 35 29 36 postCreate: function() { 30 37 domClass.add(this.domNode, this.modifiers); 31 38 domClass.add(this.selectedColorNode, "pending"); 32 39 this.domNode.dataset["topic"] = this.topic; 40 33 41 new LineWithActionsWidget({ 34 title: this.t itle,42 title: this.topic, 35 43 modifiers: this.modifiers, 36 44 actions: { 37 45 "AddToSurvey" : { 38 callback: function(arg){},46 callback: lang.hitch(this, this.includeQuestion), 39 47 properties: { 40 48 blockButton: true, … … 46 54 } 47 55 },this.titleNode); 48 56 49 57 this.selectorLine = new LineWithActionsWidget({ 50 58 title: 'None', … … 63 71 },this.selectedItemNode); 64 72 }, 65 _toggleDropdown: function(selectorLine) { 73 _toggleDropdown: function() { 74 66 75 var node = this.optionsNode; 67 76 var show = fx.wipeIn({ … … 94 103 }; 95 104 }, 96 addQuestion: function(question) { 97 new LineWithActionsWidget({ 98 title: question.title, 99 question: question, 100 actions: { 101 "InfoHover" : { 102 callback: this.infoFunction, 103 properties: { 104 blockButton: false, 105 showLabel: false, 106 icon: "Inspect" 105 addQuestion: function(questionId) { 106 var question = this.controller.GetQuestion(questionId); 107 if (question) { 108 var w = new LineWithActionsWidget({ 109 title: question.title, 110 questionId: questionId, 111 actions: { 112 "InfoHover" : { 113 callback: dojo.partial(this.infoFunction, this), 114 properties: { 115 blockButton: false, 116 showLabel: false, 117 icon: "Inspect" 118 } 107 119 } 108 120 } 109 } 110 }).placeAt(this.optionsNode); 121 }); 122 w.placeAt(this.optionsNode); 123 w.on("Click", lang.hitch(this, function(){ 124 this.selectQuestion(questionId); 125 this._toggleDropdown(); 126 }, questionId)); 127 128 } 111 129 }, 112 infoFunction: function(){ 113 alert("Some info here!");text 130 infoFunction: function(selector) { 131 var question = selector.controller.GetQuestion(this.questionId); 132 console.log(question); 133 alert("Some info here!"); 134 }, 135 includeQuestion: function() { 136 if (this.currentlySelectedId) { 137 this.controller.IncludeQuestion(this.currentlySelectedId) 138 } else { 139 return false; 140 } 141 }, 142 selectQuestion: function(questionId) { 143 /* TODO: TEST THOROUGHLY! */ 144 var question = this.controller.GetQuestion(questionId); 145 if (question) { 146 this.currentlySelectedId = questionId; 147 this.selectorLine.questionId = questionId; 148 this.selectorLine.set("title", question.title); 149 // Iterate through optionsNode, add "selected" class to currently selected node 150 baseArray.forEach(this.optionsNode.childNodes, function(node, index){ 151 var line = registry.byNode(node); 152 if (line) { 153 if (line.questionId == this.currentlySelectedId) { 154 domClass.add(line.domNode, "inheritBgColor light"); 155 } else { 156 domClass.remove(line.domNode, "inheritBgColor light"); 157 } 158 } 159 }, this); 160 } 114 161 } 115 162 });
Note: See TracChangeset
for help on using the changeset viewer.