📄 timespan.js
字号:
.setHeight(16) .setCustomStyle({"KEY":"text-align:right"}) ); host.panel61.append((new linb.UI.ComboInput) .host(host,"timeTo") .setLeft(352) .setTop(4) .setWidth(48) .setItems([]) .setType("timepicker") .beforeUIValueSet("_1") ); host.panel61.append((new linb.UI.ComboInput) .host(host,"dateTo") .setLeft(247) .setTop(4) .setItems([]) .setType("datepicker") .setWidth(104) .beforeUIValueSet("_2") ); host.panel61.append((new linb.UI.Div) .host(host,"divTo") .setLeft(217) .setTop(7) .setWidth(28) .setHeight(16) .setCustomStyle({"KEY":"text-align:right"}) ); host.panel61.append((new linb.UI.Div) .host(host,"divTZ") .setLeft(4) .setTop(34) .setWidth(53) .setHeight(16) .setCustomStyle({"KEY":"text-align:right"}) ); host.panelMain.append((new linb.UI.Pane) .host(host,"panelCmd") .setWidth(400) .setHeight(30) .setTabindex("5") .setPosition("relative") ); host.panelCmd.append((new linb.UI.Button) .host(host,"cmdCancel") .setLeft(50) .setTop(5) .setCaption("cmdCancel") .onClick("_cancel") ); host.panelCmd.append((new linb.UI.Button) .host(host,"cmdOK") .setLeft(250) .setTop(5) .setCaption("cmdOK") .onClick("_ok") ); return children; // ]]code created by jsLinb UI Builder }, _getTimezone:function(s) { var sign,hh,mm; sign = s.substr(0,1)=='-'?-1:1; hh = Math.floor(s.substr(1,2)); mm = Math.floor(s.substr(3,2)); return sign*(hh+mm/60); }, _update1:function(dateFrom, dateTo){ var self=this; var date=linb.Date, rd = date.getTimSpanStart(dateFrom,'d'), h = date.get(dateFrom,'h'), n = date.get(dateFrom,'n'); self.dateFrom.setUIValue(String(rd.getTime()), true); self.timeFrom.setUIValue(h+':'+n, true); rd = date.getTimSpanStart(dateTo,'d'); h = date.get(dateTo,'h'); n = date.get(dateTo,'n'); self.dateTo.setUIValue(String(rd.getTime()), true); self.timeTo.setUIValue(h+':'+n, true); }, _update2:function(dateFrom, dateTo){ var self=this; var df=dateFrom.getTime(), dt=dateTo.getTime(); self.timeline.setUIValue(df+":"+dt); }, _adjustTime:function(dateFrom,dateTo){ var self=this, date=linb.Date, adjust, fixEnd, t ; if(self.timeStart && dateFrom>self._timeEnd) dateTo=dateFrom if(self.timeEnd && dateTo<self._timeStart) dateFrom=dateTo; if(self.timeStart && dateFrom<self._timeStart){ adjust=1; dateFrom=self._timeStart; } if(self.timeEnd && dateTo>self._timeEnd){ fixEnd=adjust=1; dateTo=self._timeEnd; } if(self.timeMinCount && (t=date.add(dateFrom, self.timeMinUnit, self.timeMinCount))>dateTo){ adjust=1; if(fixEnd) dateFrom = date.add(dateTo, self.timeMinUnit, -self.timeMinCount); else dateTo = t; } if(self.timeMaxCount && (t=date.add(dateFrom, self.timeMaxUnit, self.timeMaxCount))<dateTo){ adjust=1; dateTo = t; } return [adjust,dateFrom,dateTo]; }, _change1:function(newValue){ var self=this, date=linb.Date, a=newValue.split(':'), dateFrom=new Date(parseInt(a[0])), dateTo=new Date(parseInt(a[1])), df,dt, r, arr = self._adjustTime(dateFrom,dateTo); if(arr[0]){ self._update2(arr[1],arr[2]); r=false; } self._update1(arr[1], arr[2]); return r; }, _change2:function(dateFrom,dateTo,timeFrom,timeTo){ var self=this,r; if(!dateFrom)dateFrom=new Date(parseInt(self.dateFrom.getUIValue())); if(!dateTo)dateTo=new Date(parseInt(self.dateTo.getUIValue())); if(!timeFrom)timeFrom=self.timeFrom.getUIValue().split(':'); if(!timeTo)timeTo=self.timeTo.getUIValue().split(':'); //if set manully, all need if(!dateFrom || !dateTo || timeFrom.length<2 || timeTo.length<2)return; dateFrom.setHours(timeFrom[0]||0); dateFrom.setMinutes(timeFrom[1]||0); dateTo.setHours(timeTo[0]||0); dateTo.setMinutes(timeTo[1]||0); var arr=self._adjustTime(dateFrom, dateTo); if(arr[0]){ self._update1(arr[1],arr[2]); r=false; } self._update2(arr[1],arr[2]); self.timeline.visibleTask(); return r; }, _ok:function(){ _.tryF(this.onOK,[],this); }, _cancel:function(){ _.tryF(this.onCancel,[],this); }, _5:function (profile, oldValue, newValue) { var self=this,r if(!self.$lock){ self.$lock=1; r=self._change1(newValue); self.$lock=0; return r; } }, _4:function (profile, oldValue, newValue) { var self=this,r; if(!self.$lock){ self.$lock=1; r=self._change2(new Date(parseInt(newValue))); self.$lock=0; return r; } }, _3:function (profile, oldValue, newValue) { var self=this,r; if(!self.$lock){ self.$lock=1; r=self._change2(null,null,newValue.split(':'),null); self.$lock=0; return r; } }, _2:function (profile, oldValue, newValue) { var self=this,r; if(!self.$lock){ self.$lock=1; r=self._change2(null,new Date(parseInt(newValue))); self.$lock=0; return r; } }, _1:function (profile, oldValue, newValue) { var self=this,r; if(!self.$lock){ self.$lock=1; r=self._change2(null,null,null,newValue.split(':')); self.$lock=0; return r; } }, _pop:function (profile, item, src) { this.setTimezone(item.value); this.cbiTZ.setValue(item.caption.replace(/\<[^>]*\>/g,''),true); }, _clc:function(profile, pos){ this.tzpop.pop(profile.getSubNode('BTN')); } }});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -