//-------------------------------------------------------
// event bind
// ex) $U.eventbind(window,"onresize",chart_common.draw);
//-------------------------------------------------------
, eventbind :
function (vobj, vEvent, pFunction, vrecheck) {
let obj = vobj;
if (typeof(vobj) === "string"){
obj = $hD(vobj);
}
let vFunction = pFunction.bind();
let vkey = pFunction.toString().replaceAll(/ /g,"");
$GC._U_EVENT_CAPTION.push(vkey)
$GC._U_EVENT_OBJ.push(vFunction);
if ($U.isNull(obj)){
if (vrecheck === true){
} else{
setTimeout(function(){ //--** 화면로드등으로 인해 시간이 지체되는 경우 3초뒤 한번더 체크
$U.eventbind(vobj, vEvent, vFunction, true);
},3000);
}
return;
}
if (obj === window){
obj.addEventListener(vEvent.substring(2), vFunction, {capture:false,once:false,passive:$GC._BROWSER_MOBILE_CHK} );
return;
}
if ($U.isNullOrEmpty(vFunction)) return;
if ($U.isNull(obj.length) || obj.length === 0){
if (obj.addEventListener){
obj.addEventListener(vEvent.substring(2), vFunction, {capture:false,once:false,passive:$GC._BROWSER_MOBILE_CHK} );
} else {
if (obj[vEvent]){
obj.attachEvent(vEvent, vFunction);
} else {
obj[vEvent] = vFunction;
}
}
} else {
for (var q=0,eoobj;eoobj=obj[q];q+=1){
if (eoobj.addEventListener){
eoobj.addEventListener(vEvent.substring(2), vFunction, {capture:false,once:false,passive:$GC._BROWSER_MOBILE_CHK} );
} else {
if (eoobj[vEvent]){
eoobj.attachEvent(vEvent, vFunction);
} else {
eoobj[vEvent] = vFunction;
}
}
}
}
}
//-------------------------------------------------------
// event unbind
// addEvent 시 리턴받은 토큰이나 function Name 로 사용시
//-------------------------------------------------------
, eventunbind :
function (vobj, vEvent, pFunction, vrecheck) {
let obj = vobj;
if (typeof(vobj) === "string"){
obj = $hD(vobj);
}
let vFunction = pFunction;
let vkey = pFunction.toString().replaceAll(/ /g,"");
for(let iuyt=0,chkey; chkey=$GC._U_EVENT_CAPTION[iuyt]; iuyt+=1 ){
if (chkey === vkey){
vFunction = $GC._U_EVENT_OBJ[iuyt];
}
}
if ($U.isNull(obj)){
if (vrecheck === true){
} else{
setTimeout(function(){ //--** 화면로드등으로 인해 시간이 지체되는 경우 3초뒤 한번더 체크
$U.eventunbind(vobj, vEvent, vFunction, true);
},3000);
}
return;
}
if (obj === window){
obj.removeEventListener(vEvent.substring(2),vFunction, {capture:false,once:false,passive:$GC._BROWSER_MOBILE_CHK} );
return;
}
if ($U.isNull(obj.length) || obj.length === 0){
if (obj.removeEventListener){
obj.removeEventListener(vEvent.substring(2),vFunction, {capture:false,once:false,passive:$GC._BROWSER_MOBILE_CHK} );
} else {
if (obj[vEvent]){
obj[vEvent] = null;
} else {
try{
obj.detachEvent(vEvent, vFunction);
} catch(e){
}
}
}
} else {
for (var q=0,eoobj;eoobj=obj[q];q+=1){
if (eoobj.removeEventListener){
eoobj.removeEventListener(vEvent.substring(2),vFunction, false );
} else {
if (eoobj[vEvent]){
eoobj[vEvent] = null;
} else {
try{
eoobj.detachEvent(vEvent, vFunction);
} catch(e){
}
}
}
}
}
}