$.fn.uaFrame = function() { this. on(EV_SET,function(ev) {//new page selected ev.stopImmediatePropagation(); //store temporarily page to be loaded $(this).removeData(). data({ src: ev.uaData.data.id.split('?')[0], id: !ev.uaData.data.id.split('=')[1]? null : ev.uaData.data.id.split('=')[1] }). trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_SET}}})); }). on(EV_SET_DEFAULT,function(ev) {//clear unconditionally ev.stopImmediatePropagation(); if($(this).html().length) { $(this).fadeTo("fast", OPACITY_MIN,function() { $(this).html('').css({opacity:OPACITY_MAX}); }); };//if }). on(EV_RESPONSE,function(ev) { ev.stopImmediatePropagation(); //Response from model. Set contents to page & show $("#idPage",this).trigger($.Event(EV_RESPONSE,{uaData:ev.uaData})); }). on(EV_CLEAR,function(ev) { ev.stopImmediatePropagation(); $(this).html('').trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_CLEAR}}})); }). on(EV_LOAD,function(ev) { ev.stopImmediatePropagation(); //1. Load page $(this).load(`pages/${$(this).data("src")}${EXTENSION}`,function(pData) { //1. Instantiate, initialize & send request. Response in EV_RESPONSE $("#idPage",this).uaPage(). on(EV_EXTERN,function(ev) { ev.stopImmediatePropagation(); meFrame.trigger($.Event(EV_NOTIFY,{uaData:ev.uaData})); }). trigger($.Event(EV_INIT,{uaData:{data:{iPosition:$(this).data().id}}})); $(this).removeData(); meFrame.trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_LOAD}}})); }); }). on(EV_SHOW,function(ev) {//show/hide ev.stopImmediatePropagation(); switch(ev.uaData.data.bShow) { case false://hide switch(parseInt($(this).css('opacity'))) { case 0: $(this).trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_SHOW}, data:{bShow:false}}})); break; default: $(this).fadeTo("fast", OPACITY_MIN,function() { $(this).trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_SHOW},data:{bShow:false}}})); }); break; };//switch(parseInt($(this).css('opacity'))) break; default://show $(this).fadeTo(TIME_FADE, OPACITY_MAX,function() { $(this).trigger($.Event(EV_NEXT,{uaData:{info:{ev:EV_SHOW},data:{bShow:true}}})); }); break; };//switch(ev.uaData.data.bShow) }). on(EV_NEXT,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: if(!ev.uaData.data.bShow) { $(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://EV_INIT $(this).trigger($.Event(EV_EXTERN,{uaData:ev.uaData})); break; };//switch(ev.uaData.info.ev) }); const meFrame = this; return this; };