UNPKG

magix-components

Version:
1 lines 2.2 kB
define("mx-calendar/rangepicker",["magix","$","../mx-monitor/index","./index","./range"],function(_,t,e){var i=_("magix"),a=_("$"),n=_("../mx-monitor/index"),r=_("./index"),o=_("./range"),d=["today","yesterday","passed7","lastestThisMonth","preMonth","lastest15"],s=i.View.extend({init:function(_){var t=this,e=_.start,i=_.end,s=_.timeType,c=_.formatter||"YYYY-MM-dd"+(s?" hh:mm:ss":""),f=r.format(new Date,c);t.__M=c,t.__R=!0,t.__K=s,t.__L=_.dateType,e||(t.__R=!1,e=f),i||(t.__R=!1,i=f),t.__S="false"!=_.shortcuts,t.__F=_.max,t.__E=_.min,t.__I=_.placement,t.__J=_.align,t.__H=t.__S?d:[],t.__G=o.getDescription(e,i,t.__H,c),n.__d();var h=a("#"+t.id),p=function(){t.__e()};t.on("destroy",function(){n.__f(t),n.__g(),a("#rpcnt_"+t.id).remove(),h.off("click",p)}),h.on("click",p),t.__h=h,h.prop("autocomplete","off")},__i:function(_){var t=this,e=i.inside(_,t.id)||i.inside(_,"rpcnt_"+t.id);if(!e)for(var a=t.owner.children(),n=a.length-1;n>=0;n--){var r=i.Vframe.get(a[n]);if(r&&(e=r.invoke("__i",_)),e)break}return e},__T:function(){var _=this,t=_.__G;t.quickDateText?_.__h.val(t.quickDateText):_.__h.val(t.startStr+"至"+t.endStr)},render:function(){var _=this,t="rpcnt_"+_.id;a(_.wrapEvent('<div mx-change="__U()" mx-cancel="__a()" style="position:absolute;display:none;z-index:10"></div>')).attr("id",t).insertAfter(_.__h),_.__R&&_.__T()},__e:function(){var _=this;if(!_.__j){var t=a("#rpcnt_"+_.id),e=_.__h;_.__j=!0,_.__l||(_.__l=!0,_.owner.mountVframe("rpcnt_"+_.id,"mx-calendar/range",{min:_.__E,max:_.__F,timeType:_.__K,dateType:_.__L,formatter:_.__M,dates:_.__G,quickDates:_.__H,placement:_.__I,align:_.__J})),n.__k(_),t.show();var i=e.offset(),r=void 0,o=void 0;switch(_.__I){case"top":o=i.top-t.outerHeight()-5;break;default:o=i.top+e.outerHeight()+5}switch(_.__J){case"right":r=i.left+e.outerWidth()-t.outerWidth();break;default:r=i.left}t.offset({left:r,top:o})}},__a:function(_){var t=this;if(t.__j){var e=a("#rpcnt_"+t.id);t.__j=!1,e.hide(),n.__f(t),_||e.invokeView("__N")}},"__U<change>":function(_){var t=this;_.stopPropagation(),t.__G=_.dates,t.__T(),t.__a(!0),t.__h.trigger({type:"change",dates:_.dates})},"__a<cancel>":function(_){_.stopPropagation(),this.__a()}});e.exports=s});