]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | *\r | |
3 | */\r | |
4 | Ext.define('Ext.overrides.Widget', {\r | |
5 | override: 'Ext.Widget',\r | |
6 | \r | |
7 | mixins: [\r | |
8 | 'Ext.mixin.Traversable'\r | |
9 | ],\r | |
10 | \r | |
11 | config: {\r | |
12 | /**\r | |
13 | * @cfg {Number} flex\r | |
14 | * The flex of this item *if* this item item is inside a {@link Ext.layout.HBox} or {@link Ext.layout.VBox}\r | |
15 | * layout.\r | |
16 | *\r | |
17 | * You can also update the flex of a component dynamically using the {@link Ext.layout.FlexBox#setItemFlex}\r | |
18 | * method.\r | |
19 | */\r | |
20 | flex: {\r | |
21 | evented: true,\r | |
22 | $value: null\r | |
23 | },\r | |
24 | \r | |
25 | /**\r | |
26 | * @cfg {String} id\r | |
27 | * The **unique id of this component instance.**\r | |
28 | *\r | |
29 | * It should not be necessary to use this configuration except for singleton objects in your application. Components\r | |
30 | * created with an id may be accessed globally using {@link Ext#getCmp Ext.getCmp}.\r | |
31 | *\r | |
32 | * Instead of using assigned ids, use the {@link #itemId} config, and {@link Ext.ComponentQuery ComponentQuery}\r | |
33 | * which provides selector-based searching for Sencha Components analogous to DOM querying. The\r | |
34 | * {@link Ext.Container} class contains {@link Ext.Container#down shortcut methods} to query\r | |
35 | * its descendant Components by selector.\r | |
36 | *\r | |
37 | * Note that this id will also be used as the element id for the containing HTML element that is rendered to the\r | |
38 | * page for this component. This allows you to write id-based CSS rules to style the specific instance of this\r | |
39 | * component uniquely, and also to select sub-elements using this component's id as the parent.\r | |
40 | *\r | |
41 | * **Note**: to avoid complications imposed by a unique id also see `{@link #itemId}`.\r | |
42 | *\r | |
43 | * Defaults to an auto-assigned id.\r | |
44 | */\r | |
45 | \r | |
46 | /**\r | |
47 | * @cfg {String} itemId\r | |
48 | * An itemId can be used as an alternative way to get a reference to a component when no object reference is\r | |
49 | * available. Instead of using an `{@link #id}` with {@link Ext#getCmp}, use `itemId` with\r | |
50 | * {@link Ext.Container#getComponent} which will retrieve `itemId`'s or {@link #id}'s. Since `itemId`'s are an\r | |
51 | * index to the container's internal MixedCollection, the `itemId` is scoped locally to the container - avoiding\r | |
52 | * potential conflicts with {@link Ext.ComponentManager} which requires a **unique** `{@link #id}`.\r | |
53 | *\r | |
54 | * Also see {@link #id}, {@link Ext.Container#query}, {@link Ext.Container#down} and {@link Ext.Container#child}.\r | |
55 | *\r | |
56 | * @accessor\r | |
57 | */\r | |
58 | itemId: undefined\r | |
59 | },\r | |
60 | \r | |
61 | constructor: function(config) {\r | |
62 | this.callParent([config]);\r | |
63 | this.initBindable();\r | |
64 | },\r | |
65 | \r | |
66 | applyFlex: function(flex) {\r | |
67 | if (flex) {\r | |
68 | flex = Number(flex);\r | |
69 | \r | |
70 | if (isNaN(flex)) {\r | |
71 | flex = null;\r | |
72 | }\r | |
73 | }\r | |
74 | else {\r | |
75 | flex = null;\r | |
76 | }\r | |
77 | \r | |
78 | return flex;\r | |
79 | },\r | |
80 | \r | |
81 | applyItemId: function(itemId) {\r | |
82 | return itemId || this.getId();\r | |
83 | },\r | |
84 | \r | |
85 | render: function(container, insertBeforeElement) {\r | |
86 | this.renderTo(container, insertBeforeElement);\r | |
87 | },\r | |
88 | \r | |
89 | renderTo: function(container, insertBeforeElement) {\r | |
90 | var dom = this.renderElement.dom,\r | |
91 | containerDom = Ext.getDom(container),\r | |
92 | insertBeforeChildDom;\r | |
93 | \r | |
94 | if (Ext.isNumber(insertBeforeChildDom)) {\r | |
95 | insertBeforeElement = containerDom.childNodes[insertBeforeElement];\r | |
96 | }\r | |
97 | insertBeforeChildDom = Ext.getDom(insertBeforeElement);\r | |
98 | \r | |
99 | if (containerDom) {\r | |
100 | if (insertBeforeChildDom) {\r | |
101 | containerDom.insertBefore(dom, insertBeforeChildDom);\r | |
102 | }\r | |
103 | else {\r | |
104 | containerDom.appendChild(dom);\r | |
105 | }\r | |
106 | \r | |
107 | this.setRendered(Boolean(dom.offsetParent));\r | |
108 | }\r | |
109 | },\r | |
110 | \r | |
111 | destroy: function() {\r | |
112 | var me = this,\r | |
113 | parent = me.getParent();\r | |
114 | \r | |
115 | if (parent && parent.remove) {\r | |
116 | parent.remove(me, false);\r | |
117 | }\r | |
118 | \r | |
119 | me.callParent();\r | |
120 | },\r | |
121 | \r | |
122 | isInnerItem: function() {\r | |
123 | return true;\r | |
124 | },\r | |
125 | \r | |
126 | isCentered: function() {\r | |
127 | return false;\r | |
128 | },\r | |
129 | \r | |
130 | isDocked: function() {\r | |
131 | return Boolean(this.getDocked());\r | |
132 | },\r | |
133 | \r | |
134 | isFloating: function() {\r | |
135 | return false;\r | |
136 | },\r | |
137 | \r | |
138 | getDocked: function() {\r | |
139 | return this._docked;\r | |
140 | },\r | |
141 | \r | |
142 | /**\r | |
143 | * @private\r | |
144 | */\r | |
145 | onAdded: function(parent, instanced) {\r | |
146 | var me = this,\r | |
147 | inheritedState = me.inheritedState,\r | |
148 | currentParent = me.parent;\r | |
149 | \r | |
150 | if (currentParent && currentParent !== parent) {\r | |
151 | currentParent.remove(me, false);\r | |
152 | }\r | |
153 | \r | |
154 | me.parent = parent;\r | |
155 | \r | |
156 | me.onInheritedAdd(parent, instanced);\r | |
157 | },\r | |
158 | \r | |
159 | onRemoved: function(destroying) {\r | |
160 | if (!destroying) {\r | |
161 | this.removeBindings();\r | |
162 | }\r | |
163 | \r | |
164 | this.onInheritedRemove(destroying);\r | |
165 | \r | |
166 | this.parent = null;\r | |
167 | },\r | |
168 | \r | |
169 | setLayoutSizeFlags: Ext.emptyFn,\r | |
170 | \r | |
171 | /**\r | |
172 | * @private\r | |
173 | * @param {Boolean} rendered\r | |
174 | */\r | |
175 | setRendered: function(rendered) {\r | |
176 | var wasRendered = this.rendered;\r | |
177 | \r | |
178 | if (rendered !== wasRendered) {\r | |
179 | this.rendered = rendered;\r | |
180 | \r | |
181 | return true;\r | |
182 | }\r | |
183 | \r | |
184 | return false;\r | |
185 | },\r | |
186 | \r | |
187 | updateLayout: function() {\r | |
188 | // If size monitoring for widgets has improvements to not\r | |
189 | // need to do this anymore, core/Widget will need this to be\r | |
190 | // declared as an emptyFn to preserve toolkit compat\r | |
191 | var parent = this.getParent(),\r | |
192 | scrollable;\r | |
193 | \r | |
194 | if (parent) {\r | |
195 | scrollable = parent.getScrollable();\r | |
196 | if (scrollable) {\r | |
197 | scrollable.refresh();\r | |
198 | }\r | |
199 | }\r | |
200 | }\r | |
201 | }); |