-
Notifications
You must be signed in to change notification settings - Fork 240
/
Copy pathexample.js
158 lines (144 loc) · 4.27 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* An example class showcasing the features of JSDuck.
*
* **Markdown** is supported thoughout the [docs][1].
*
* Link to {@link Ext.form.field.Text external class} and
* {@link Ext.form.field.Text#reset its method}.
* Link to {@link #setSize method of this class}.
*
* {@img some/path.png Alt text}
*
* An embedded live example:
*
* @example
* Ext.create('Ext.master.Switch', {
* text: 'Click me, please!',
* handler: function() {
* alert('You clicked me!')
* }
* });
*
* **Note:** this is not a fully working example. When you run it
* through JSDuck you will get warnings about a lot of missing classes
* that this example class references, additionally it doesn't make
* sense for singleton class to have static methods.
*
* [1]: http://docs.sencha.com/ext-js/4.0/
*/
Ext.define('Ext.master.Switch', {
// These are all detected automatically
// No need to use @extends, @alternateClassName, @mixin, @alias, @singleton
extend: 'Ext.button.Button',
alternateClassName: 'Ext.MasterSwitch',
mixins: {
observable: 'Ext.util.Observable',
floating: 'Ext.util.Floating'
},
alias: 'widget.masterswitch',
singleton: true,
/**
* @cfg {String} [text="Click Me!"]
* A config option with explicit type, name, and default value.
*/
config: {
/**
* A config option with type, name, and default value
* auto-detected. Additionally docs for getIcon and setIcon
* accessor methods are generated.
*/
icon: "some/file.png",
// A private config option of boolean type.
open: true
},
/**
* @cfg {String} name (required)
* A very importand config option that must be specified.
*/
/**
* @property {Object} size
* A property with explicit type name and name.
* It's an object containing the following fields:
* @property {Number} size.width The width.
* @property {Number} size.height The height.
*/
/**
* A property with auto-detected type and name.
*/
disabled: false,
// A private property
cache: {},
/**
* Constructor documentation.
* @param {Object} [cfg] An optional config object
*/
constructor: function(cfg) {
Ext.apply(this, cfg || {});
this.addEvents(
/**
* @event
* Fired when button clicked.
* @param {Ext.master.Switch} this
* @param {Number} times The number of times clicked.
*/
"click"
);
},
/**
* Sets the size.
* @param {Object} size An object describing width and height:
* @param {Number} [size.width=0] The width.
* @param {Number} [size.height=0] The height.
*/
setSize: function(size) {
this.size = size;
},
/**
* Returns the size of component.
* @return {Object} Object with properties:
* @return {Number} return.width The width.
* @return {Number} return.height The height.
* @method
*/
getSize: (function() {
return function() { return this.size; };
})(),
statics: {
/**
* A method documented as static.
* @param {Function} fn Callback function.
* @param {Ext.Component} fn.cmp The component parameter.
* @param {Number} fn.index Component index parameter.
* @param {Boolean} fn.return The return value of callback
* must be true to include the component, false to exclude.
* @param {Object} scope Scope for the callback.
* @return {Ext.Component[]} Array of components.
*/
filter: function(fn, scope) {
return this.items.filter(fn, scope);
}
},
inheritableStatics: {
/**
* A static method that gets inherited by subclasses.
*/
doSomething: function() {
}
},
// A private method
// One can also use tags inside here.
// @return {Ext.master.Switch} this
// @chainable
highlight: function() {
return this;
}
});
Ext.apply(Ext, {
/**
* A method belonging to Ext.
* @member Ext
* @method
* @inheritdoc Ext.master.Switch#setSize
*/
setMasterSwitchSize: Ext.master.Switch.setSize
});