source: Dev/branches/rest-dojo-ui/client/rft/ui/Selector.js @ 354

Last change on this file since 354 was 354, checked in by tjcschipper, 13 years ago
  • Made change to _Page.js to destroy the page's child widgets on page leave. This was causing widgets with identical names (such as "btnSave") to make regsitry throw a duplicate widget error.
  • survey.js/html now sorts loaded questions into categories and topics and creates or adds them to the proper TabPane/Selectors?. TODO: Allow for spaces in category titles.
  • Added "addQuestion()" method to Selector.js, to internalize question visualization logic.
  • Included surveyAdvanced page in run.js
  • Changes index to use proper button format, still need to figure out a way to bind content.goTo to the onclick field (since there is no index.js script being run!)
  • Various css tweaks.
File size: 4.3 KB
Line 
1define([
2    'dojo/_base/declare',
3    'dojo/_base/lang',
4    'dojo/fx',
5    'dijit/_WidgetBase',
6    'dijit/_TemplatedMixin',
7    'dijit/_WidgetsInTemplateMixin',
8    'dijit/_Container',
9    './LineWithActionsWidget',
10    'dojo/text!./templates/Selector.html',
11    'dojo/dom-class'
12    ],function(
13        declare,
14        lang,
15        fx,
16        _WidgetBase,
17        _TemplatedMixin,
18        _WidgetsInTemplateMixin,
19        _Container,
20        LineWithActionsWidget,
21        templateString,
22        domClass
23        ){
24        return declare('rft.ui.Selector',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
25            templateString: templateString,
26            title: "The professional as a participant",
27            baseClass: 'rftSelector',
28            modifiers: 'blue',
29            postCreate: function() {
30                domClass.add(this.domNode, this.modifiers);
31                domClass.add(this.selectedColorNode, "pending");
32               
33                new LineWithActionsWidget({
34                    title: this.title,
35                    modifiers: this.modifiers,
36                    actions: {
37                        "AddToSurvey" : {
38                            callback: function(arg){},
39                            properties: {
40                                blockButton: true,
41                                modifiers: this.modifiers,
42                                icon: "Accept",
43                                label: "Include"
44                            }
45                        }
46                    }
47                },this.titleNode);
48               
49                this.selectorLine = new LineWithActionsWidget({
50                    title: 'None',
51                    modifiers: this.modifiers,
52                    actions: {
53                        "ToggleDropdown" : {
54                            callback: lang.hitch(this, this._toggleDropdown()),
55                            properties: {
56                                blockButton: true,
57                                modifiers: this.modifiers,
58                                showLabel: false,
59                                icon: "HalfArrowDown"
60                            }
61                        }
62                    }
63                },this.selectedItemNode);
64            },
65            _toggleDropdown: function(selectorLine) {
66                var node = this.optionsNode;
67                var show = fx.wipeIn({
68                    node: node
69                });
70                var hide = fx.wipeOut({
71                    node: node
72                });
73                hide.play();
74                var folded = true;
75                return function(e) {
76                    if ( folded ) {
77                        var downArrowIcon = dojo.query(".rftBlockButton .rftIconHalfArrowDown", this.selectorLine.buttonsNode)[0];
78                        if (downArrowIcon){
79                            domClass.replace(downArrowIcon, "rftIconHalfArrowUp", "rftIconHalfArrowDown");
80                        }
81                        show.play();
82                        folded = false;
83                    } else {
84                        var upArrowIcon = dojo.query(".rftBlockButton .rftIconHalfArrowUp", this.selectorLine.buttonsNode)[0];
85                        if (upArrowIcon){
86                            domClass.replace(upArrowIcon, "rftIconHalfArrowDown", "rftIconHalfArrowUp");
87                        }
88                        hide.play();
89                        folded = true;
90
91                    }
92                    e.preventDefault();
93                    e.stopPropagation();
94                };
95            },
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"
107                            }
108                        }
109                    }
110                }).placeAt(this.optionsNode);
111            },
112            infoFunction: function(){
113                alert("Some info here!");text
114            }
115        });
116});
Note: See TracBrowser for help on using the repository browser.