/*
*
MARKUP
NOTES
- w/o Effects:
* markup removed (see bottomn line)
* msg displayed 'as is'
* Use: EV_SET -> EV_CLEAR -> EV_SHOW
- w/ Effects:
* EV_CLEAR not needed
* Use: EV_SET -> EV_SHOW
*/
$.fn.uaUsrMsg = function(options)
{
options = $.extend({
bEffects: true,
data: [] //[{idMsg,bError, msg}]
},options);
this.
on(EV_SET,function(ev)
{//set message
ev.stopImmediatePropagation();
switch(ev.uaData.data.msg)
{
case undefined:
$.each(options.data,function()
{
if(ev.uaData.data.idMsg!==this.idMsg) return true;
$(meUsrMsg).data({msg: (this.bError ? "Error
" : "Info:
") + this.msg });
return false;
});
break;
default:
$(meUsrMsg).data({msg: (this.bError ? "Error
" : "Info:
") + this.msg });
break;
};
$(this).trigger($.Event(EV_NOTIFY, {uaData:{info:{ev:EV_SET}}}));
}).
on(EV_CLEAR,function(ev)
{
ev.stopImmediatePropagation();
//$(this).html("").data("msg","").removeClass('uaDisabled');
$(this).html("").removeClass('uaDisabled');
$(this).trigger($.Event(EV_NOTIFY, {uaData:{info:{ev:EV_CLEAR}}}));
}).
on(EV_LOAD,function(ev)
{
ev.stopImmediatePropagation();
$(this).html($(this).data().msg);
$(this).trigger($.Event(EV_NOTIFY, {uaData:{info:{ev:EV_LOAD}}}));
}).
on(EV_SHOW,function(ev)
{
ev.stopImmediatePropagation();
switch(options.bEffects)
{
case true://effects
switch(ev.uaData.data.bShow)
{
case true://show
$(this).css({display:""}).animate({
opacity: OPACITY_MAX
},"short");
break;
default://hide
$(this).animate({
opacity: OPACITY_MIN
},"short",function()
{
$(this).css({display:'none'});
$(this).trigger($.Event(EV_NOTIFY,{uaData:{info:{ev:EV_SHOW}}}));
});
break;
};//switch(ev.uaData.data.bShow)
break;
default://NO Effects
switch(ev.uaData.data.bShow)
{
case true://show
$(this).css({display:'',opacity:OPACITY_MAX});
break;
default://hide
$(this).css({display:'none',opacity:OPACITY_MIN});//.html("").data("msg","");
break;
};//switch(ev.uaData.data.bShow)
break;
};
}).
on(EV_NOTIFY,function(ev)
{
ev.stopImmediatePropagation();
switch(ev.uaData.info.ev)
{
case EV_SET:
$(this).trigger($.Event(EV_SHOW,{uaData:{data:{bShow:false}}}));
break;
case EV_SHOW:
$(this).trigger(EV_CLEAR);
break;
case EV_CLEAR:
$(this).trigger(EV_LOAD);
break;
case EV_LOAD:
$(this).trigger($.Event(EV_SHOW,{uaData:{data:{bShow:true}}}));
break;
default:
break;
};
});
this.getReason = function(idMsg)
{
let pResp = '';
$.each(options.data,function()
{
if(this.idMsg!==idMsg) return true;
pResp = this.msg;
return false;
});
return (!pResp.length ? 'Message not found': pResp);
};//this.getReason = function(idMsg)
this.clear = function()
{//hide
$(this).css({display:'none',oppacity:OPACITY_MIN}).html('');
};
const meUsrMsg = this;
return this;
};