PDA

View Full Version : Issue overriding GetStyle Method



himalpatel
23 Feb 2012, 7:40 AM
Hello, I am trying to override following code, but getting that error in line

return cls.override(overrides);
that object doesn't support this property or method.



(function () {
var ELEMENT = Ext.Element,
view = document.defaultView;
Ext.override(ELEMENT, {
getStyle: function () {
return view && view.getComputedStyle ?
function (prop) {
alert('1');
var el = this.dom,
v, cs, out, display, cleaner;
if (el == document) {
return null;
}
prop = Ext.core.Element.normalize(prop);
if (el != null) {
out = (v = el.style[prop]) ? v :
(cs = view.getComputedStyle(el, "")) ? cs[prop] : null;
}

if (prop == 'marginRight' && out != '0px' && !supports.RightMargin) {
cleaner = Ext.core.Element.getRightMarginFixCleaner(el);
display = this.getStyle('display');
el.style.display = 'inline-block';
out = view.getComputedStyle(el, '').marginRight;
el.style.display = display;
cleaner();
}
if (prop == 'backgroundColor' && out == 'rgba(0, 0, 0, 0)' && !supports.TransparentColor) {
out = 'transparent';
}
return out;
} :
function (prop) {
alert('11');
var el = this.dom,
m, cs;
if (el == document) {
return null;
}
if (prop == 'opacity') {
if (el.style.filter.match) {
m = el.style.filter.match(opacityRe);
if (m) {
var fv = parseFloat(m[1]);
if (!isNaN(fv)) {
return fv ? fv / 100 : 0;
}
}
}
return 1;
}
prop = Ext.core.Element.normalize(prop);
return el.style[prop] || ((cs = el.currentStyle) ? cs[prop] : null);
};
}
});

})();


Looking for the help!!!

Thanks
Himal

himalpatel
23 Feb 2012, 8:05 AM
I was debugging furhter and found that while i am overloading the Ext.Element, if the override method the class name it shows is : Ext.util.Animate
I have just written followin code now.

Ext.override(ELEMENT, {
// isStyle: function (style, val) {
// return this.getStyle(style) == val;
// }
});


and error come in following code.

override: function(cls, overrides) {
if (cls.prototype.$className) {
return cls.override(overrides);
}
else {
Ext.apply(cls.prototype, overrides);
}
}

Hope this get you enough infor.