UNPKG

magix-components

Version:
1 lines 1.58 kB
define("mx-calendar/datepicker",["magix","$","../mx-monitor/index","./index"],function(t,e,i){var _=t("magix"),n=t("$"),a=_.Vframe,d=t("../mx-monitor/index");t("./index"),i.exports=_.View.extend({init:function(t){var e=this;e.__c=t,d.__d();var i=n("#"+e.id),_=function(){e.__e()};e.on("destroy",function(){d.__f(e),d.__g(),n("#dpcnt_"+e.id).remove(),i.off("click",_)}),i.on("click",_),e.__h=i,i.prop("autocomplete","off")},__i:function(t){var e=this;return _.inside(t,e.id)||_.inside(t,"dpcnt_"+e.id)},update:function(t){var e=this;a.get("dpcnt_"+e.id).invoke("update",[t])},render:function(){var t=this,e="dpcnt_"+t.id;n(t.wrapEvent('<div style="position:absolute;display:none;z-index:10" mx-change="__n()" mx-cancel="__a()"></div>')).attr("id",e).insertAfter(t.__h),t.__c.selected||(t.__c.selected=t.__h.val())},__e:function(){var t=this;if(!t.__j){var e=n("#dpcnt_"+t.id),i=t.__h;t.__j=!0,d.__k(t),t.__l||(t.__l=!0,t.owner.mountVframe("dpcnt_"+t.id,"mx-calendar/index",t.__c)),e.show();var _=i.offset(),a=void 0,o=void 0;switch(t.__c.placement){case"top":o=_.top-e.outerHeight()-5;break;default:o=_.top+i.outerHeight()+5}switch(t.__c.align){case"right":a=_.left+i.outerWidth()-e.outerWidth();break;default:a=_.left}e.offset({left:a,top:o})}},__a:function(){var t=this;if(t.__j){var e=n("#dpcnt_"+t.id),i=e.prop("vframe");i&&i.invoke("__m"),t.__j=!1,e.hide(),d.__f(t)}},"__n<change>":function(t){var e=this;t.stopPropagation();var i=t.date;t.time&&(i+=" "+t.time),e.__h.val(i).trigger({type:"change",date:t.date,time:t.time}),e.__a()},"__a<cancel>":function(){this.__a()}})});