source: Dev/trunk/src/client/dojox/form/manager/_ClassMixin.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.2 KB
Line 
1define([
2        "dojo/_base/lang",
3        "dojo/_base/kernel",
4        "dojo/dom-class",
5        "./_Mixin",
6        "dojo/_base/declare"
7], function(lang, dojo, domClass, _Mixin, declare){
8        var fm = lang.getObject("dojox.form.manager", true),
9                aa = fm.actionAdapter,
10                ia = fm.inspectorAdapter;
11
12        return declare("dojox.form.manager._ClassMixin", null, {
13                // summary:
14                //              Form manager's mixin for testing/assigning/removing
15                //              classes of controlled elements.
16                // description:
17                //              This mixin provides unified way to check/add/remove a class
18                //              of controlled elements.
19                //              It should be used together with dojox.form.manager.Mixin.
20
21                gatherClassState: function(className, names){
22                        // summary:
23                        //              Gather the presence of a certain class in all controlled elements.
24                        // className: String
25                        //              The class name to test for.
26                        // names: Object?
27                        //              If it is an array, it is a list of names to be processed.
28                        //              If it is an object, dictionary keys are names to be processed.
29                        //              If it is omitted, all known form elements are to be processed.
30
31                        var result = this.inspect(ia(function(name, node){
32                                return domClass.contains(node, className);
33                        }), names);
34
35                        return result;  // Object
36                },
37
38                addClass: function(className, names){
39                        // summary:
40                        //              Add a class to nodes according to the supplied set of names
41                        // className: String
42                        //              Class name to add.
43                        // names: Object?
44                        //              If it is an array, it is a list of names to be processed.
45                        //              If it is an object, dictionary keys are names to be processed.
46                        //              If it is omitted, all known form elements are to be processed.
47
48                        this.inspect(aa(function(name, node){
49                                domClass.add(node, className);
50                        }), names);
51
52                        return this;    // self
53                },
54
55                removeClass: function(className, names){
56                        // summary:
57                        //              Remove a class from nodes according to the supplied set of names
58                        // className: String
59                        //              Class name to remove.
60                        // names: Object?
61                        //              If it is an array, it is a list of names to be processed.
62                        //              If it is an object, dictionary keys are names to be processed.
63                        //              If it is omitted, all known form elements are to be processed.
64
65                        this.inspect(aa(function(name, node){
66                                domClass.remove(node, className);
67                        }), names);
68
69                        return this;    // self
70                }
71        });
72});
Note: See TracBrowser for help on using the repository browser.