mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 17:35:34 +00:00
refactor(dom) if src add event
This commit is contained in:
parent
deb3fb5a7c
commit
4c46278748
1 changed files with 38 additions and 40 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue