source: Dev/trunk/src/client/qed-client/widgets/_ComplexValueMixin.coffee @ 465

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

Need comma between function arguments in Coffee.

File size: 1.7 KB
Line 
1define [
2    "dijit/_Container",
3    "dijit/form/_FormMixin",
4    "dojo/_base/array",
5    "dojo/_base/declare",
6    "dojo/_base/event"
7], (_Container, _FormMixin, array, declare, event) ->
8    declare [_Container,_FormMixin],
9        name: ""
10        value: null
11        disabled: false
12        readOnly: false
13
14        postCreate: () ->
15            @inherited arguments
16            if @domNode.tagName.toLowerCase() isnt "form"
17                console.warn "Not scoping a _ComplexValueMixin in a form element can cause name clashes. E.g. radio buttons might stop working correctly. It is recommended to use <form> as the root element in your template for", @declaredClass
18
19        _setDisabledAttr: (value) ->
20            @_set "disabled", value
21            array.forEach @_getDescendantFormWidgets(), (child) =>
22                child.set "disabled", value
23
24        _setReadOnlyAttr: (value) ->
25            @_set "readOnly", value
26            array.forEach @_getDescendantFormWidgets(), (child) =>
27                child.set "readOnly", value
28
29        focus: () ->
30            children = @_getDescendantFormWidgets()
31            children[0].focus() if children.length > 0
32
33        onSubmit: (e) =>
34            # since this widget is used to create more complex
35            # widgets within other forms, the onSubmit must either be
36            # ignored or propagated, but not handled here.
37            event.stop e if e
38            false
39
40        _onSubmit: (e) =>
41            # since this widget is used to create more complex
42            # widgets within other forms, the onSubmit must either be
43            # ignored or propagated, but not handled here.
44            event.stop if e
45            false
Note: See TracBrowser for help on using the repository browser.