$.fn.uaHOL = function() { this. on(EV_INIT,function(ev) { ev.stopImmediatePropagation(); $(this).trigger('ev.resize'); }). on(EV_SET,function(ev) { ev.stopImmediatePropagation(); pBtn.trigger($.Event(EV_ENABLE,{uaData:{data:{bEnable: ev.uaData.data.idPost!==null}}})); pContents.trigger($.Event(EV_SET,{uaData:ev.uaData})); }). on('ev.resize',function(ev) { ev.stopImmediatePropagation(); pContents.trigger('ev.resize'); }). on(EV_SHOW,function(ev) { ev.stopImmediatePropagation(); pContents.trigger($.Event(EV_SHOW,{uaData:ev.uaData})); }). on(EV_ENABLE,function(ev) { ev.stopImmediatePropagation(); $.each([pBtn,pContents],function() { $(this).trigger($.Event(EV_ENABLE,{uaData:ev.uaData})); }); }). on(EV_NOTIFY,function(ev) { ev.stopImmediatePropagation(); switch(ev.uaData.info.ev) { case EV_CLICKED: pContents.trigger(EV_TOGGLE); break; default: break; }; }); $.fn.uaContents = function() {//absolute position this. on('ev.resize',function(ev) { ev.stopImmediatePropagation(); switch(window.matchMedia("(max-width: 768px)").matches) { case true: // <= 768 $(this).css({ top: parseInt($(this).parent().height()), left: 0 }); break; default:// > 768 $(this).css({ top: parseInt(1.75*$(this).parent().height()), left: parseInt(window.innerWidth-$(this).width() - 16) }); break; }; }). on(EV_CLEAR,function(ev) { ev.stopImmediatePropagation(); $('div',this).html(''); }). on(EV_SET,function(ev) { ev.stopImmediatePropagation(); $(this).data({ idPost:ev.uaData.data.idPost }); $(this).trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_SET}}})); }). on(EV_ENABLE,function(ev) { ev.stopImmediatePropagation(); if(ev.uaData.data.bEnable) return; $(this).trigger($.Event(EV_SHOW,{uaData:{data:{bShow:$(this).css('display')!=='none'}}})); }). on(EV_TOGGLE,function(ev) { ev.stopImmediatePropagation(); $(this).trigger($.Event(EV_SHOW,{uaData:{data:{bShow:$(this).css("display")==='none'}}})); }). on(EV_LOAD,function(ev) { ev.stopImmediatePropagation(); switch($(this).data().idPost) { case null: $(this).trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_LOAD}}})); break; default: (new $.uaBlogger()).getPost({id:$(this).data().idPost},function(pResp) { $("div",meContents).html(pResp.data); meContents.trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_LOAD}}})); }); break; }; }). on(EV_SHOW,function(ev) { ev.stopImmediatePropagation(); switch(ev.uaData.data.bShow) { case true: switch($(this).css('display')) { case 'none': $(this).css({display:'block'}).animate({ opacity:OPACITY_MAX },TIME_FADE,function() { $(this).trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_SHOW},data:{bShow:true}}})); }); break; default: $(this).trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_SHOW},data:{bShow:true}}})); break; };//switch($(this).css('display')) break; default: switch($(this).css('display')) { case 'none': $(this).trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_SHOW},data:{bShow:false}}})); break; default: $(this).animate({ opacity:OPACITY_MIN },TIME_FADE/2,function() { $(this).css({display:'none'}); //$(this).trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_SHOW},data:{bShow:false}}})); }); break; }; break; }; }). on(EV_NEXT,function(ev) { ev.stopImmediatePropagation(); switch(ev.uaData.info.ev) { case EV_SET: switch($(this).data().idPost) { case null: if($(this).css('display')!=='none') { $(this).trigger(EV_TOGGLE); }; break; default: $(this).trigger($.Event(EV_SHOW,{uaData:{data:{bShow:false}}})); break; }; break; case EV_SHOW: if(!ev.uaData.data.bShow && $(this).data().idPost !==null) { $(this).trigger(EV_LOAD); } break; default: break; }; }); const meContents = this; return this; };//$.fn.uaContents = function() const pContents = $("#idHOL_Contents").uaContents(); const pBtn = $("i",this). on(EV_ENABLE,function(ev) { ev.stopImmediatePropagation(); switch(ev.uaData.data.bEnable) { case true: $(this).removeClass('uaDisabled').addClass('text-primary uaSelectable'); break; default: $(this).removeClass('text-primary uaSelectable').addClass('uaDisabled'); break; }; }). on('click',function(ev) { ev.stopImmediatePropagation(); if($(this).hasClass('uaDisabled')) return; $(this).parent().trigger($.Event(EV_NOTIFY,{uaData:{info:{ev:EV_CLICKED}}})); }); $(this).trigger(EV_INIT); return this; };