source: Dev/trunk/client/qed/widgets/ScaleWidget.js @ 433

Last change on this file since 433 was 433, checked in by hendrikvanantwerpen, 12 years ago

Added ScaleWidget? and some CSS fixes.

File size: 2.7 KB
Line 
1define([
2    "dijit/_Container",
3    "dijit/_TemplatedMixin",
4    "dijit/_WidgetBase",
5    "dijit/form/RadioButton",
6    "dijit/form/_FormMixin",
7    "dojo/_base/array",
8    "dojo/_base/declare",
9    "dojo/_base/lang",
10    "dojo/dom-attr",
11    "dojo/dom-construct",
12    "dojo/text!./templates/ScaleWidget.html"
13], function(_Container, _TemplatedMixin, _WidgetBase, RadioButton, _FormMixin, array, declare, lang, domAttr, domConstruct, template) {
14    return declare([_WidgetBase,_TemplatedMixin,_Container,_FormMixin],{
15        templateString: template,
16        baseClass: "qedScaleWidget",
17        min: 0,
18        max: 0,
19        minLabel: "",
20        maxLabel: "",
21        naLabel: null,
22        items: null,
23        value: null,
24        constuctor: function() {
25            this.items = [];
26            this.value = {};
27        },
28        startup: function() {
29            if ( this._started ) { return; }
30            this.inherited(arguments);
31            this._renderHead();
32            this._renderItems();
33        },
34        _renderHead: function() {
35            for (var i = this.min; i <= this.max; i++) {
36                domConstruct.create("th", {
37                    innerHTML: i.toString()
38                }, this.rangeNode, "after");
39            }
40            if ( this.naLabel !== null ) {
41                this.naNode.innerHTML = this.naLabel;
42            }
43        },
44        _renderItems: function() {
45            array.forEach(this.items, function(item,index) {
46                var tr = domConstruct.create("tr", {}, this.itemsNode);
47                var td;
48                var radio;
49                domConstruct.create("th", {
50                    innerHTML: item.text || "",
51                    'class': "item"
52                }, tr);
53                domConstruct.create("th", {
54                    innerHTML: item.minLabel || "",
55                    'class': 'min'
56                }, tr);
57                for (var i = this.min; i <= this.max; i++) {
58                    td = domConstruct.create("td", {}, tr);
59                    radio = new RadioButton({
60                        name: index.toString(),
61                        value: i.toString()
62                    });
63                    domConstruct.place(radio.domNode, td);
64                }
65                domConstruct.create("th", {
66                    innerHTML: item.maxLabel || "",
67                    className: 'max'
68                }, tr);
69                if ( this.naLabel !== null ) {
70                    td = domConstruct.create("td", {}, tr);
71                    radio = new RadioButton({
72                        name: index.toString(),
73                        value: "n/a"
74                    });
75                    domConstruct.place(radio.domNode, td);
76                }
77            }, this);
78        }
79    });
80});
Note: See TracBrowser for help on using the repository browser.