source: Dev/trunk/client/qed/model/widgets/ScaleInputConfigWidget.js @ 435

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

Rename as Input and add 'type' to output.

File size: 3.1 KB
Line 
1define([
2    "dijit/_Container",
3    "dijit/_TemplatedMixin",
4    "dijit/_WidgetBase",
5    "dijit/_WidgetsInTemplateMixin",
6    "dijit/form/Button",
7    "dijit/form/RadioButton",
8    "dijit/form/TextBox",
9    "dijit/form/ValidationTextBox",
10    "dijit/form/_FormMixin",
11    "dojo/_base/array",
12    "dojo/_base/declare",
13    "dojo/_base/event",
14    "dojo/_base/lang",
15    "dojo/dom-attr",
16    "dojo/dom-construct",
17    "dojo/dom-style",
18    "dojo/text!./templates/ScaleInputConfigRowWidget.html",
19    "dojo/text!./templates/ScaleInputConfigWidget.html",
20    "dijit/form/NumberTextBox",
21    "dijit/form/TextBox"
22], function(_Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, Button, RadioButton, TextBox, ValidationTextBox, _FormMixin, array, declare, event, lang, domAttr, domConstruct, domStyle, rowTemplate, template) {
23
24    var Row = declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container,_FormMixin],{
25        templateString: rowTemplate,
26        hasNA: true,
27        startup: function() {
28            if ( this._started ) { return; }
29            this.inherited(arguments);
30        },
31        onDestroy: function(e) {
32            this.destroyRecursive();
33            event.stop(e);
34            return false;
35        },
36        _setHasNAAttr: function(value) {
37            if ( value === true ) {
38                domStyle.set(this.naRadioButton.domNode, "display", "");
39            } else {
40                domStyle.set(this.naRadioButton.domNode, "display", "none");
41            }
42        }
43    });
44   
45    return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container,_FormMixin],{
46        templateString: template,
47        baseClass: "qedScaleWidget",
48        value: null,
49        _hasNA: false,
50        constuctor: function() {
51            this.inherited(arguments);
52            this.value = {};
53        },
54        onAddItem: function(e) {
55            this._addItem();
56            event.stop(e);
57            return false;
58        },
59        _clearItems: function() {
60            domConstruct.empty(this.itemsNode);
61        },
62        _addItem: function(value) {
63            var item = new Row({
64                name: 'items',
65                value: value,
66                hasNA: this._hasNA
67            });
68            item.placeAt(this.itemsNode);
69            return item;
70        },
71        _setValueAttr: function(value) {
72            this.inherited(arguments);
73            this._clearItems();
74            array.forEach(value.items, function(value){
75                this._addItem(value);
76            }, this);
77        },
78        _getValueAttr: function(){
79            var value = this.inherited(arguments);
80            if ( value.items && !lang.isArray(value.items) ) {
81                value.items = [value.items];
82            }
83            value.type = 'ScaleInput';
84            return value;
85        },
86        onNAChange: function(value) {
87            this._hasNA = value !== null && value !== "";
88            this._updateNA();
89        },
90        _updateNA: function(value) {
91            array.forEach(this.getChildren(), function(child) {
92                child.set('hasNA', this._hasNA);
93            }, this);
94        }
95    });
96});
Note: See TracBrowser for help on using the repository browser.