]>
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 | uses: ['Ext.Component'],\r | |
8 | \r | |
9 | $configStrict: false,\r | |
10 | \r | |
11 | isComponent: true,\r | |
12 | \r | |
13 | liquidLayout: true,\r | |
14 | \r | |
15 | // in Ext JS the rendered flag is set as soon as a component has its element. Since\r | |
16 | // widgets always have an element when constructed, they are always considered to be\r | |
17 | // "rendered"\r | |
18 | rendered: true,\r | |
19 | \r | |
20 | rendering: true,\r | |
21 | \r | |
22 | config: {\r | |
23 | renderTo: null\r | |
24 | },\r | |
25 | \r | |
26 | cachedConfig: {\r | |
27 | baseCls: Ext.baseCSSPrefix + 'widget'\r | |
28 | },\r | |
29 | \r | |
30 | constructor: function(config) {\r | |
31 | var me = this,\r | |
32 | renderTo;\r | |
33 | \r | |
34 | me.callParent([config]);\r | |
35 | \r | |
36 | // initialize the component layout\r | |
37 | me.getComponentLayout();\r | |
38 | renderTo = me.getRenderTo();\r | |
39 | if (renderTo) {\r | |
40 | me.render(renderTo);\r | |
41 | }\r | |
42 | },\r | |
43 | \r | |
44 | addClsWithUI: function(cls) {\r | |
45 | this.el.addCls(cls);\r | |
46 | },\r | |
47 | \r | |
48 | afterComponentLayout: Ext.emptyFn,\r | |
49 | \r | |
50 | updateLayout: function() {\r | |
51 | var owner = this.getRefOwner();\r | |
52 | if (owner) {\r | |
53 | owner.updateLayout();\r | |
54 | }\r | |
55 | },\r | |
56 | \r | |
57 | destroy: function() {\r | |
58 | var me = this,\r | |
59 | ownerCt = me.ownerCt;\r | |
60 | \r | |
61 | if (ownerCt && ownerCt.remove) {\r | |
62 | ownerCt.remove(me, false);\r | |
63 | }\r | |
64 | \r | |
65 | me.callParent();\r | |
66 | },\r | |
67 | \r | |
68 | finishRender: function () {\r | |
69 | this.rendering = false;\r | |
70 | this.initBindable();\r | |
71 | },\r | |
72 | \r | |
73 | getAnimationProps: function() {\r | |
74 | // see Ext.util.Animate mixin\r | |
75 | return {};\r | |
76 | },\r | |
77 | \r | |
78 | getComponentLayout: function() {\r | |
79 | var me = this,\r | |
80 | layout = me.componentLayout;\r | |
81 | \r | |
82 | if (!layout) {\r | |
83 | layout = me.componentLayout = new Ext.layout.component.Auto();\r | |
84 | layout.setOwner(me);\r | |
85 | }\r | |
86 | \r | |
87 | return layout;\r | |
88 | },\r | |
89 | \r | |
90 | getEl: function() {\r | |
91 | return this.element;\r | |
92 | },\r | |
93 | \r | |
94 | /**\r | |
95 | * @private\r | |
96 | * Needed for when widget is rendered into a grid cell. The class to add to the cell element.\r | |
97 | * @member Ext.Widget\r | |
98 | */\r | |
99 | getTdCls: function() {\r | |
100 | return Ext.baseCSSPrefix + this.getTdType() + '-' + (this.ui || 'default') + '-cell';\r | |
101 | },\r | |
102 | \r | |
103 | /**\r | |
104 | * @private\r | |
105 | * Partner method to {@link #getTdCls}.\r | |
106 | *\r | |
107 | * Returns the base type for the component. Defaults to return `this.xtype`, but\r | |
108 | * All derived classes of {@link Ext.form.field.Text TextField} can return the type 'textfield',\r | |
109 | * and all derived classes of {@link Ext.button.Button Button} can return the type 'button'\r | |
110 | * @member Ext.Widget\r | |
111 | */\r | |
112 | getTdType: function() {\r | |
113 | return this.xtype;\r | |
114 | },\r | |
115 | \r | |
116 | getItemId: function() {\r | |
117 | // needed by ComponentQuery\r | |
118 | return this.itemId || this.id;\r | |
119 | },\r | |
120 | \r | |
121 | getSizeModel: function() {\r | |
122 | return Ext.Component.prototype.getSizeModel.apply(this, arguments);\r | |
123 | },\r | |
124 | \r | |
125 | onAdded: function (container, pos, instanced) {\r | |
126 | var me = this,\r | |
127 | inheritedState = me.inheritedState;\r | |
128 | \r | |
129 | me.ownerCt = container;\r | |
130 | \r | |
131 | me.onInheritedAdd(me, instanced);\r | |
132 | },\r | |
133 | \r | |
134 | onRemoved: function(destroying) {\r | |
135 | var me = this;\r | |
136 | \r | |
137 | if (!destroying) {\r | |
138 | me.removeBindings();\r | |
139 | }\r | |
140 | \r | |
141 | me.onInheritedRemove(destroying);\r | |
142 | \r | |
143 | me.ownerCt = me.ownerLayout = null;\r | |
144 | },\r | |
145 | \r | |
146 | parseBox: function(box) {\r | |
147 | return Ext.Element.parseBox(box);\r | |
148 | },\r | |
149 | \r | |
150 | removeClsWithUI: function(cls) {\r | |
151 | this.el.removeCls(cls);\r | |
152 | },\r | |
153 | \r | |
154 | render: function(container, position) {\r | |
155 | var me = this,\r | |
156 | element = me.element,\r | |
157 | proto = Ext.Component.prototype,\r | |
158 | nextSibling;\r | |
159 | \r | |
160 | if (!me.ownerCt || me.floating) {\r | |
161 | if (Ext.scopeCss) {\r | |
162 | element.addCls(proto.rootCls);\r | |
163 | }\r | |
164 | element.addCls(proto.borderBoxCls);\r | |
165 | }\r | |
166 | \r | |
167 | if (position) {\r | |
168 | nextSibling = container.childNodes[position];\r | |
169 | if (nextSibling) {\r | |
170 | Ext.fly(container).insertBefore(element, nextSibling);\r | |
171 | return;\r | |
172 | }\r | |
173 | }\r | |
174 | \r | |
175 | Ext.fly(container).appendChild(element);\r | |
176 | },\r | |
177 | \r | |
178 | setPosition: function(x, y) {\r | |
179 | this.el.setLocalXY(x, y);\r | |
180 | },\r | |
181 | \r | |
182 | up: function() {\r | |
183 | return Ext.Component.prototype.up.apply(this, arguments);\r | |
184 | },\r | |
185 | \r | |
186 | isAncestor: function() {\r | |
187 | return Ext.Component.prototype.isAncestor.apply(this, arguments);\r | |
188 | },\r | |
189 | \r | |
190 | onFocusEnter: function() {\r | |
191 | return Ext.Component.prototype.onFocusEnter.apply(this, arguments);\r | |
192 | },\r | |
193 | \r | |
194 | onFocusLeave: function() {\r | |
195 | return Ext.Component.prototype.onFocusLeave.apply(this, arguments);\r | |
196 | },\r | |
197 | \r | |
198 | isLayoutChild: function(candidate) {\r | |
199 | var ownerCt = this.ownerCt;\r | |
200 | return ownerCt ? (ownerCt === candidate || ownerCt.isLayoutChild(candidate)) : false;\r | |
201 | }\r | |
202 | \r | |
203 | }, function(Cls) {\r | |
204 | var prototype = Cls.prototype;\r | |
205 | \r | |
206 | if (Ext.isIE9m) {\r | |
207 | // Since IE8/9 don't not support Object.defineProperty correctly we can't add the reference\r | |
208 | // nodes on demand, so we just fall back to adding all references up front.\r | |
209 | prototype.addElementReferenceOnDemand = prototype.addElementReference;\r | |
210 | }\r | |
211 | });\r |