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