PDA

View Full Version : Minify ext-all Javascript File



himalpatel
21 Feb 2012, 6:01 AM
Hello,

First of all, It's not good practice to make modificaiton in ext-all file. but sometimes, it becomes necessary to modify it to handle the error. I came across a similar error when i want to clear and fill the drop down again during focus event. this works fine first time but after second time it gives error from ext-all file. as a fix. i changed following for function fupdateIndexes : from


ns[i].viewRecordId = records[i].internalId;

to


if (records[i])
ns[i].viewRecordId = records[i].internalId;


I just need to know that what is the best way to minify the script again ? I tried with some tool, but it is not generating the similar script.

Looking forward for your help.

Regards
Himal

mitchellsimoens
21 Feb 2012, 6:40 AM
You should never modify the library files. You should make overrides.

himalpatel
21 Feb 2012, 6:42 AM
Got that, Thanks for your prompt reply,
do you have any reference that i can use to make one ?

Thanks again,
Himal

mitchellsimoens
21 Feb 2012, 6:50 AM
Ext.define('Override.data.Store', {
override : 'Ext.data.Store',

constructor : function() {
this.callOverridden(arguments);
}
});

callOverridden works like callParent in that you can call the superclass method but is optional. This can also be dynamically loaded.

himalpatel
21 Feb 2012, 6:52 AM
great help!!!

I will give it a try and let you know..

Thanks for you help!!!
Himal

himalpatel
23 Feb 2012, 8:42 AM
Hi, I wanted to modify a getStyle method of Ext.Element, but as per one of your thread it cannot be done. and suggestion is to do as follwoing.


Ext.core.Element.prototype.getStyle = function () {
return view && view.getComputedStyle ?
function (prop) {
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);
};
}


Which worked, but while loadig my page in IE, it gives me an error that, Invalid Argument in setStyle Method in following line.


me.dom.style[ELEMENT.normalize(style)] = value;

Please let me know how to get rid of this :)
Thanks
Himal