📄 timeline.js
字号:
var ns=profile.box._getMoveNodes(profile),
dd=linb.DragDrop.getProfile();
ns.left(profile.properties._band_left + dd.offset.x);
}
},
SCROLL:{
onScroll:function(profile, e, src){
profile.getSubNode('ITEMS').top(-linb([src]).scrollTop() );
}
},
ITEMS:{
onMouseover:function(profile,e,src){
if(linb.DragDrop.getProfile().isWorking)return;
profile.$itemspos = linb([src]).offset();
},
onMousemove:function(profile,e){
if(linb.DragDrop.getProfile().isWorking){
//ondrag add here, for performance of 'dont-use-dropable situation'.
if(profile.$$ondrag){
var d=linb.DragDrop.getProfile();
profile.box._moveActive(profile, profile.$active, d.x-profile.$dd_ox, profile.properties._unitPixs);
}
}else{
var t=profile.properties,
date=linb.Date,
s=t._smallLabelStart,
r=t._rate,
u=t._timeFormat,
p1=linb.Event.getPos(e),
p2=profile.$itemspos;
if(p2 && t.showTips)
profile.box._setTips(profile, date.getText(date.add(s, 'ms', (p1.left-p2.left)*r),u));
}
},
onMouseout:function(profile,e,src){
if(linb.DragDrop.getProfile().isWorking)return;
if(profile.properties.showTips)
profile.box._setTips(profile, '');
},
onMousedown:function(profile, e, src){
var pro=profile.properties;
if(pro.disabled || pro.readonly)return;
if(profile.pauseA||profile.pause)return;
if(linb.Event.getSrc(e)!=src)return;
var o = profile.getSubNode('ACTIVE'),
x = linb.Event.getPos(e).left;
o.css({
display:'block',
width:'0'
})
.offset({left :x, top :null});
o.startDrag(e, {dragType:'none'});
},
onMouseup:function(profile, e, src){
profile.box._focus(profile);
}
},
ACTIVE:{
onDragbegin:function(profile, e, src){
profile.$dd_ox = linb.DragDrop.getProfile().x;
profile.$dd_oleft = parseInt(src.style.left)||0;
linb([src,src.parentNode]).css('cursor','e-resize');
},
onDrag:function(profile, e, src){
var x=profile.$dd_oleft,
ddx=linb.DragDrop.getProfile().x,
w,
offset;
if((offset =ddx-profile.$dd_ox)>=0){
w = offset;
}else{
x = x+offset; w = -offset;
}
profile.box._moveActive(profile, src, x, w);
},
onDragstop:function(profile, e, src){
var r = profile.box._deActive(profile);
linb([src,src.parentNode]).css('cursor','');
var box=profile.box,
from=box._getTime(profile, r.left),
to=box._getTime(profile, r.left+r.width),
p=profile.properties,
task,t,
b=profile.boxing();
if(profile.properties.multiTasks){
task={id:_.id(),caption:p.dftTaskName,from:from,to:to};
if(profile.beforeNewTasks && false===b.beforeNewTasks(profile, [task])){}else
b.addTasks([task]);
}else
b.setUIValue(from+":"+to);
profile.$dd_ox =profile.$dd_oleft=null;
}
},
FOCUS:{
onFocus:function(profile, e, src){
_.resetRun(profile.KEY+':focus',function(){
profile.getSubNode('BAR').tagClass('-focus');
});
},
onBlur:function(profile, e, src){
_.resetRun(profile.KEY+':focus',function(){
profile.getSubNode('BAR').tagClass('-focus',false);
});
},
onKeydown:function(profile, e, src){
if(profile.pauseA||profile.pause)return;
profile.pause=true;
// speed
var t=profile.properties,
date=linb.Date,
rate=t._rate,
maxOffset = 30,
o=profile.box._getMoveNodes(profile),
x=o.left(),
xx=t._band_left,
off=t._scroll_offset
;
off = t._scroll_offset = off>maxOffset ? off :off*1.05;
switch(linb.Event.getKey(e)[0]){
case 'left':
case 'up':
if(t.minDate && date.add(t.dateStart,'ms',(xx-x-off)*rate)<t.minDate)
off=date.diff(t.minDate, t.dateStart,'ms')/rate + (xx-x);
if(off<0)off=0;
o.left(x + off);
break;
case 'right':
case 'down':
if(t.maxDate && date.add(t.dateStart,'ms',(xx-x+off+t.width)*rate)>t.maxDate)
off=date.diff(t.dateStart,t.maxDate,'ms')/rate - (xx-x+t.width);
if(off<0)off=0;
o.left(x - off);
break;
}
if((x + maxOffset > 0) || (x + o.width() - t.width - maxOffset < 0))
profile.box._rePosition(profile);
profile.pause=false;
return false;
},
onKeyup:function(profile, e){
var p=profile.properties;
p._scroll_offset = p._scrollRate;
profile.box._rePosition(profile);
}
},
PRE:{
onClick:function(profile, e){
if(profile.pauseA||profile.pause)return;
var t=profile.properties,
date=linb.Date,
rate=t._rate,
o=profile.box._getMoveNodes(profile),
x1=t._band_left,
x2=0;
;
if(t.minDate && t._smallLabelStart<t.minDate)
x2-=date.diff(t._smallLabelStart,t.minDate,'ms')/rate;
profile.pause=true;
o.animate({left:[x1,x2]}, null, function(){
profile.box._rePosition(profile);
profile.pause=false;
},200,Math.max(5,(x2-x1)/100),'inoutsine').start();
}
},
NEXT:{
onClick:function(profile, e){
if(profile.pauseA||profile.pause)return;
var t=profile.properties,
date=linb.Date,
rate=t._rate,
o=profile.box._getMoveNodes(profile),
x1=t._band_left,
x2=t.width-t._band_width;
;
if(t.maxDate && t._smallLabelEnd>t.maxDate)
x2+=date.diff(t.maxDate,t._smallLabelEnd,'ms')/rate;
if(x1>x2){
profile.pause=true;
o.animate({left:[x1,x2]}, null, function(){
profile.box._rePosition(profile);
profile.pause=false;
},200,Math.max(5,(x1-x2)/100),'inoutsine').start();
}
}
},
ZOOMIN:{
onClick:function(profile, e){
if(profile.pauseA||profile.pause)return;
var p=profile.properties,
box=profile.box,
z=box.$zoom,
index = _.arr.indexOf(z,p._unitParas),
o;
if(index > 0){
profile.pause=true;
p.timeSpanKey = z[index- 1][0];
o = profile.getSubNodes(['VIEW','BAND']);
o.animate( {opacity:[1,0.2]}, null, function(){
profile.box._refresh(profile)._focus(profile);
profile.pause=false;
},200,5,'insine').start();
}
}
},
ZOOMOUT:{
onClick:function(profile, e){
if(profile.pauseA||profile.pause)return;
var p=profile.properties,
box=profile.box,
z=box.$zoom,
index = _.arr.indexOf(z,p._unitParas),
o;
if(index < z.length -1){
profile.pause=true;
p.timeSpanKey = z[index + 1][0];
o = profile.getSubNodes(['VIEW','BAND']);
o.animate( {opacity:[1,0.2]}, null, function(){
//if multiTasks, setUIValue will be ignored
profile.box._refresh(profile)._focus(profile);
profile.pause=false;
},200,5,'insine').start();
}
}
},
DATE:{
onClick:function(profile, e, src){
if(profile.pauseA||profile.pause)return;
var cls=profile.box,
box=profile.boxing(),
from=profile.properties.dateStart,
o,node;
if(cls._picker && cls._picker.domNode){
o=cls._picker.boxing();
}else{
o=linb.create('DatePicker');
cls._picker=o.get(0);
o.beforeClose(function(){
this.boxing()._cache();
return false;
})
.beforeUIValueSet(function(p, ov, v){
var profile=this,
obj = profile.getSubNodes(['VIEW','BAND']),
box=profile.boxing(),
p=profile.properties;
p.dateStart=v;
//obj.animate( {opacity:[1,0.2]}, null, function(){
//if multiTasks, setUIValue will be ignored
profile.box._refresh(profile)._focus(profile);
// profile.pause=false;
//},200,5,'insine').start()
box._cache();
});
}
o.setValue(from,true).host(profile);
node=o.reBoxing();
node.popToTop(src);
//for on blur disappear
node.setBlurTrigger(profile.key+" - "+profile.$id, function(){
box._cache();
});
//for esc
linb.Event.keyboardHook('esc',0,0,0,function(){
box._cache();
cls._focus(profile);
//unhook
linb.Event.keyboardHook('esc');
});
}
},
ITEM:{
onClick:function(profile, e, src){
if(profile.onClickTask)
profile.boxing().onClickTask(profile, profile.getItemByDom(src), e, src);
},
onDragbegin:function(profile, e, src){
var t=profile.getItemByDom(src),
type=profile.$dd_type,
cursor=type?'e-resize':'move',
ac=profile.$active;
profile.$dd_ox = linb.DragDrop.getProfile().x;
profile.$dd_oleft = parseInt(src.style.left);
profile.$dd_owidth = parseInt(src.style.width);
linb([ac]).css('display','block').cssPos({left :profile.$dd_oleft, top :null}).width(profile.$dd_owidth-2);
linb([ac,ac.parentNode]).css('cursor',cursor);
},
onDrag:function(profile, e, src){
var x,w,
offset =linb.DragDrop.getProfile().x-profile.$dd_ox,
ddl=profile.$dd_oleft,
ddw=profile.$dd_owidth,
type=profile.$dd_type;
if(type=="left"){
if(offset < ddw){
x = ddl + offset;
w = ddl + ddw - x;
}else{
x = ddl + ddw;
w = offset - ddw;
}
}else if(type == "right"){
if(-offset < ddw){
x = ddl;
w = ddw + offset;
}else{
x = ddl + offset + ddw;
w = -offset - ddw;
}
}else{
x = ddl + offset;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -