]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * A Traversable mixin.\r | |
3 | * @private\r | |
4 | */\r | |
5 | Ext.define('Ext.mixin.Traversable', {\r | |
6 | extend: 'Ext.Mixin',\r | |
7 | \r | |
8 | mixinConfig: {\r | |
9 | id: 'traversable'\r | |
10 | },\r | |
11 | \r | |
12 | setParent: function(parent) {\r | |
13 | this.parent = parent;\r | |
14 | \r | |
15 | return this;\r | |
16 | },\r | |
17 | \r | |
18 | /**\r | |
19 | * Returns `true` if this component has a parent.\r | |
20 | * @return {Boolean} `true` if this component has a parent.\r | |
21 | */\r | |
22 | hasParent: function() {\r | |
23 | return Boolean(this.parent);\r | |
24 | },\r | |
25 | \r | |
26 | /**\r | |
27 | * Returns the parent of this component, if it has one.\r | |
28 | * @return {Ext.Component} The parent of this component.\r | |
29 | */\r | |
30 | getParent: function() {\r | |
31 | return this.parent;\r | |
32 | },\r | |
33 | \r | |
34 | getAncestors: function() {\r | |
35 | var ancestors = [],\r | |
36 | parent = this.getParent();\r | |
37 | \r | |
38 | while (parent) {\r | |
39 | ancestors.push(parent);\r | |
40 | parent = parent.getParent();\r | |
41 | }\r | |
42 | \r | |
43 | return ancestors;\r | |
44 | },\r | |
45 | \r | |
46 | getAncestorIds: function() {\r | |
47 | var ancestorIds = [],\r | |
48 | parent = this.getParent();\r | |
49 | \r | |
50 | while (parent) {\r | |
51 | ancestorIds.push(parent.getId());\r | |
52 | parent = parent.getParent();\r | |
53 | }\r | |
54 | \r | |
55 | return ancestorIds;\r | |
56 | }\r | |
57 | });\r |