PHP Code:
Ext.apply(Ext.core.Element.prototype, {
/*
* Override of this method, to try and protect against a parentNode in the DOM being null.
* See: ATG-391 & http://www.sencha.com/forum/showthread.php?137685-4.0.2a-Bug-in-Element.slideIn&p=616171
* @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to top: 't')
* @param {Object} options (optional) Object literal with any of the Fx config options
* @return {Ext.core.Element} The Element
*/
slideIn: function(anchor, obj, slideOut) {
var me = this,
elStyle = me.dom.style,
beforeAnim, wrapAnim;
anchor = anchor || "t";
obj = obj || {};
beforeAnim = function() {
var animScope = this,
listeners = obj.listeners,
box, position, restoreSize, wrap, anim;
if (!slideOut) {
me.fixDisplay();
}
box = me.getBox();
if ((anchor == 't' || anchor == 'b') && box.height == 0) {
box.height = me.dom.scrollHeight;
}
else if ((anchor == 'l' || anchor == 'r') && box.width == 0) {
box.width = me.dom.scrollWidth;
}
position = me.getPositioning();
me.setSize(box.width, box.height);
wrap = me.wrap({
style: {
visibility: slideOut ? 'visible' : 'hidden'
}
});
wrap.setPositioning(position);
if (wrap.isStyle('position', 'static')) {
wrap.position('relative');
}
me.clearPositioning('auto');
wrap.clip();
// This element is temporarily positioned absolute within its wrapper.
// Restore to its default, CSS-inherited visibility setting.
// We cannot explicitly poke visibility:visible into its style because that overrides the visibility of the wrap.
me.setStyle({
visibility: '',
position: 'absolute'
});
if (slideOut) {
wrap.setSize(box.width, box.height);
}
switch (anchor) {
case 't':
anim = {
from: {
width: box.width + 'px',
height: '0px'
},
to: {
width: box.width + 'px',
height: box.height + 'px'
}
};
elStyle.bottom = '0px';
break;
case 'l':
anim = {
from: {
width: '0px',
height: box.height + 'px'
},
to: {
width: box.width + 'px',
height: box.height + 'px'
}
};
elStyle.right = '0px';
break;
case 'r':
anim = {
from: {
x: box.x + box.width,
width: '0px',
height: box.height + 'px'
},
to: {
x: box.x,
width: box.width + 'px',
height: box.height + 'px'
}
};
break;
case 'b':
anim = {
from: {
y: box.y + box.height,
width: box.width + 'px',
height: '0px'
},
to: {
y: box.y,
width: box.width + 'px',
height: box.height + 'px'
}
};
break;
case 'tl':
anim = {
from: {
x: box.x,
y: box.y,
width: '0px',
height: '0px'
},
to: {
width: box.width + 'px',
height: box.height + 'px'
}
};
elStyle.bottom = '0px';
elStyle.right = '0px';
break;
case 'bl':
anim = {
from: {
x: box.x + box.width,
width: '0px',
height: '0px'
},
to: {
x: box.x,
width: box.width + 'px',
height: box.height + 'px'
}
};
elStyle.right = '0px';
break;
case 'br':
anim = {
from: {
x: box.x + box.width,
y: box.y + box.height,
width: '0px',
height: '0px'
},
to: {
x: box.x,
y: box.y,
width: box.width + 'px',
height: box.height + 'px'
}
};
break;
case 'tr':
anim = {
from: {
y: box.y + box.height,
width: '0px',
height: '0px'
},
to: {
y: box.y,
width: box.width + 'px',
height: box.height + 'px'
}
};
elStyle.bottom = '0px';
break;
}
wrap.show();
wrapAnim = Ext.apply({}, obj);
delete wrapAnim.listeners;
wrapAnim = Ext.create('Ext.fx.Anim', Ext.applyIf(wrapAnim, {
target: wrap,
duration: 500,
easing: 'ease-out',
from: slideOut ? anim.to : anim.from,
to: slideOut ? anim.from : anim.to
}));
// In the absence of a callback, this listener MUST be added first
wrapAnim.on('afteranimate', function() {
if (slideOut) {
me.setPositioning(position);
if (obj.useDisplay) {
me.setDisplayed(false);
} else {
me.hide();
}
}
else {
me.clearPositioning();
me.setPositioning(position);
}
if (wrap.dom) {
// <WestyFix>
if (wrap.dom.parentNode) {
wrap.dom.parentNode.insertBefore(me.dom, wrap.dom);
} else {
// FIXME: No idea what to do here...
}
// </WestyFix>
wrap.remove();
}
me.setSize(box.width, box.height);
animScope.end();
});
// Add configured listeners after
if (listeners) {
wrapAnim.on(listeners);
}
};
me.animate({
duration: obj.duration ? obj.duration * 2 : 1000,
listeners: {
beforeanimate: {
fn: beforeAnim
},
afteranimate: {
fn: function() {
if (wrapAnim && wrapAnim.running) {
wrapAnim.end();
}
}
}
}
});
return me;
}
});