$.fn.uaButton = function(options) { options = $.extend({ bEnabled: true },options); this. on('click',function(ev) { ev.stopImmediatePropagation(); if($(this).hasClass('uaDisabled')) return; $(this).trigger($.Event(EV_EXTERN,{uaData:{info:EV_CLICKED}})); }). on(EV_CLEAR,function(ev) { ev.stopImmediatePropagation(); }). on(EV_SET_DEFAULT,function(ev) { ev.stopImmediatePropagation(); $(this).trigger($.Event(EV_ENABLE,{uaData:{data:{bEnable:options.bEnabled}}})); }). on(EV_ENABLE,function(ev) { ev.stopImmediatePropagation(); switch(ev.uaData.data.bEnable) { case true: $(this).removeClass('btn-light uaDisabled').addClass('btn-primary'); break; default: $(this).removeClass('btn-primary uaSelectable').addClass('btn-light uaDisabled'); break; };//switch(ev.uaData.data.bEnable) }); $(this).trigger($.Event(EV_ENABLE,{uaData:{data:{bEnable: options.bEnabled}}})); return this; };