refactor(dom) if src add event

This commit is contained in:
coderaiser 2013-07-05 12:04:58 +00:00
parent deb3fb5a7c
commit 4c46278748

View file

@ -792,53 +792,51 @@ var CloudCmd, Util, DOM, CloudFunc;
return {code: -1, text: 'name can not be empty'};
}
}
lElement = document.createElement(lName);
lElement = document.createElement(lName);
if (lID)
lElement.id = lID;
lElement.id = lID;
if (lClass)
lElement.className = lClass;
lElement.className = lClass;
/* if working with external css
* using href in any other case
* using src
*/
if (lName === 'link'){
lElement.href = lSrc;
lElement.rel = 'stylesheet';
}else
lElement.src = lSrc;
/*
* if passed arguments function
* then it's onload by default
*
* if object - then onload and onerror
*/
var lLoad = function(pEvent){
Events.remove('load', lLoad, lElement);
Events.remove('error', lError, lElement);
Util.exec(lFunc, pEvent);
},
if(lSrc) {
/* if work with css use href */
if (lName === 'link'){
lElement.href = lSrc;
lElement.rel = 'stylesheet';
}else
lElement.src = lSrc;
lError = function(){
lParent.removeChild(lElement);
Images.showError({
responseText: 'file ' +
lSrc +
' could not be loaded',
status : 404
});
/*
* if passed arguments function
* then it's onload by default
*
* if object - then onload and onerror
*/
var lLoad = function(pEvent){
Events.remove('load', lLoad, lElement);
Events.remove('error', lError, lElement);
Util.exec(lFunc, pEvent);
},
Util.exec(lOnError);
};
Events.add('load', lLoad, lElement);
Events.addError(lError, lElement);
lError = function(){
lParent.removeChild(lElement);
Images.showError({
responseText: 'file ' +
lSrc +
' could not be loaded',
status : 404
});
Util.exec(lOnError);
};
Events.add('load', lLoad, lElement);
Events.addError(lError, lElement);
}
if (lAttr)
for(i in lAttr)