Debian Codegraph @

dojox/form/manager/_DisplayMixin.js

raw symbols SCIP
1 define([
2 "dojo/_base/kernel",
3 "dojo/dom-style",
4 "dojo/_base/declare"
5 ], function(dojo, domStyle, declare){
6 return declare("dojox.form.manager._DisplayMixin", null, {
7 // summary:
8 // Form manager's mixin for controlling show/hide state of
9 // controlled elements (defined by dojoAttachPoint attributes).
10 // description:
11 // This mixin provides unified show/hide functionality for
12 // controlled elements (indicated by dojoAttachPoint attribute).
13 // Essentially it provides a way to change "style.display"
14 // parameter of controlled nodes.
15 // It should be used together with dojox.form.manager.Mixin.
16
17 gatherDisplayState: function(names){
18 // summary:
19 // Gather display state of all attached elements and return as a dictionary.
20 // names: Object?
21 // If it is an array, it is a list of names to be processed.
22 // If it is an object, dictionary keys are names to be processed.
23 // If it is omitted, all known attach point nodes are to be processed.
24
25 var result = this.inspectAttachedPoints(function(name, node){
26 return domStyle.get(node, "display") != "none";
27 }, names);
28
29 return result; // Object
30 },
31
32 show: function(state, defaultState){
33 // summary:
34 // Show attached nodes according to the supplied state object.
35 // state: Object?
36 // Optional. If a name-value dictionary, the value is true
37 // to show and false to hide. If an array, all names in the
38 // array will be set to defaultState. If omitted, all form
39 // elements will be set to defaultState.
40 // defaultState: Boolean?
41 // The default state (true, if omitted).
42
43 if(arguments.length < 2){
44 defaultState = true;
45 }
46
47 this.inspectAttachedPoints(function(name, node, value){
48 domStyle.set(node, "display", value ? "" : "none");
49 }, state, defaultState);
50
51 return this; // self
52 },
53
54 hide: function(state){
55 // summary:
56 // Hide attached nodes according to the supplied state object.
57 // state: Object?
58 // Optional. If a name-value dictionary, the value is true
59 // to show and false to hide. If an array, all names in the
60 // array will be hidden. If omitted, all form elements
61 // will be hidden.
62 return this.show(state, false); // self
63 }
64 });
65 });