📄 comboinput.js
字号:
Class("linb.UI.ComboInput", "linb.UI.Input",{
/*Instance*/
Instance:{
_setCtrlValue:function(value, flag){
var me=arguments.callee, r1=me._r1||(me._r1=/\</),r2=me._r2||(me._r2=/\<\/?[^>]+\>/g);
return this.each(function(profile){
var o=profile.getSubNode('INPUT'), type=profile.properties.type;
value=flag?value:profile.boxing()._getShowValue(value);
if(type!=='none'&& !profile.properties.multiLines && typeof value=='string' && r1.test(value))value=value.replace(r2,'');
o.attr('value',value||'');
if(type=='colorpicker'){
profile.getSubNode('BOX').css('backgroundColor',value);
o.css('color',linb.UI.ColorPicker.getTextColor(value));
}
})
},
_compareValue:function(v1,v2){
var profile=this.get(0),t;
if(t= profile.CF.compareValue||profile.$compareValue)
return t(profile, v1, v2);
return v1===v2;
},
_getShowValue:function(value){
var profile=this.get(0),
pro=profile.properties,v,t;
if(t= profile.CF.getShowValue||profile.$getShowValue)
v = t(profile, value);
else{
//get from items
if('listbox'==pro.type || 'combobox' == pro.type){
if( (v=_.arr.subIndexOf(pro.items,'id',value))!=-1){
v=pro.items[v].caption;
v=v.charAt(0)=='$'?linb.getRes(v.slice(1)):v;
}else
v='';
}else
v = profile.$showValue;
}
v = v || ((value||value===0)?String(value):'');
if(v!==value)profile.$caption=v;
else delete profile.$caption;
return v;
},
_getEditValue:function(value){
var profile=this.get(0),
pro=profile.properties,t;
if(t= profile.CF.getEditValue||profile.$getEditValue)
return t(profile, value);
return value;
},
_fromEditValue:function(value){
var profile=this.get(0),
pro=profile.properties,t;
if(t= profile.CF.fromEditValue||profile.$fromEditValue)
return t(profile, value);
return value;
},
_cache:function(){
var profile=this.get(0),drop=profile.$drop;
if(drop){
if(linb.browser.opr)
drop.root.css('display','none');
_.asyRun(function(){
profile.getSubNode('POOL').append(drop.root)
});
}
delete profile.$poplink;
},
clearPopCache:function(){
var profile=this.get(0);
if(profile.domNode)
profile.getSubNode('POOL').empty();
delete profile.$drop;
return this;
},
//for upload ,special must get the original node
getUploadObj:function(){
var profile=this.get(0);
if(profile.domNode && profile.properties.type=='upload'){
var o = profile.getSubNode('UPLOAD'),c=o.clone();
//a special node, must delete if from cache here:
delete profile.$_domid[profile.keys['UPLOAD']];
o.addPrev(c).remove(false);
this.setValue('',true);
return o.get(0);
}
},
resetValue:function(value){
this.each(function(p){
if(p.properties.type=='upload')
p.getSubNode('UPLOAD').attr('value','');
});
return arguments.callee.upper.apply(this,arguments);
},
_drop:function(e,src){
return this.each(function(profile){
var pro = profile.properties;
if(pro.disabled)return;
if(pro.type=='upload'||pro.type=='none'||pro.type=='spin')return;
//open already
if(profile.$poplink)return;
var o,v,
box = profile.boxing(),
main = profile.root,
pos = main.offset(),
size = main.cssSize()
;
size.width += 2;
pos.top += main.offsetHeight();
//get list
//not normal pop
switch(pro.type){
case 'getter':
case 'cmdbox':
case 'popbox':
box.onClickButton(profile, pos, e, src);
return;
}
//get cache key
var cachekey;
switch(pro.type){
case 'timepicker':
case 'datepicker':
case 'colorpicker':
cachekey=pro.type;
break;
default:
if(pro.listKey)
//function no cache
if(typeof _.get(linb.cache,['UIDATA', pro.listKey])=='function')
profile.$drop = cachekey = null;
else
cachekey = pro.listKey;
else
cachekey = profile.$id;
}
//get from global cache
if(cachekey){
//filter first
_.filter(profile.box.$drop,function(o){
return !!o.domNode;
});
profile.$drop = profile.box.$drop[cachekey];
}
//cache pop
if(!profile.$drop){
switch(pro.type){
case 'combobox':
case 'listbox':
case 'helpinput':
linb.SC('linb.UI.List');
o = linb.create('List').render();
o.host(profile).setItems(_.copy(pro.items)).setListKey(pro.listKey||'').adjustSize();
o.beforeUIValueSet(function(pro, ovalue, value){
var b2=this.boxing();
//update value
b2.setUIValue(value);
//cache pop
b2._cache();
//set activate
b2.activate();
return false;
});
break;
case 'timepicker':
linb.SC('linb.UI.TimePicker');
o = linb.create('TimePicker').render();
o.host(profile);
o.beforeClose(function(){this.boxing()._cache();return false});
o.beforeUIValueSet(function(p, o, v){
//update value
this.boxing().setUIValue(v)._cache();
});
break;
case 'datepicker':
linb.SC('linb.UI.DatePicker');
o = linb.create('DatePicker').render();
o.host(profile);
o.beforeClose(function(){this.boxing()._cache();return false});
o.beforeUIValueSet(function(p, o, v){
//update value
this.boxing().setUIValue(String(v.getTime()))._cache();
});
break;
case 'colorpicker':
linb.SC('linb.UI.ColorPicker');
o = linb.create('ColorPicker').render();
o.host(profile);
o.beforeClose(function(){this.boxing()._cache();return false});
o.beforeUIValueSet(function(p, o, v){
//update value
this.boxing().setUIValue('#'+v)._cache();
});
break;
}
profile.$drop = o.get(0);
//set to global cache
if(cachekey)
profile.box.$drop[cachekey]=profile.$drop;
}
o=profile.$drop.boxing();
o.host(profile);
//set pop
switch(pro.type){
case 'combobox':
case 'listbox':
case 'helpinput':
o.setWidth(profile.root.width());
case 'timepicker':
o.setValue(box.getUIValue(), true);
break;
case 'datepicker':
var t = profile.$drop.properties;
t.WEEK_FIRST=pro.WEEK_FIRST;
if(t=box.getUIValue())
o.setValue(new Date( parseInt(t) ), true);
break;
case 'colorpicker':
o.setValue(box.getUIValue().replace('#',''), true);
break;
}
profile.$poplink = o.get(0);
//pop
var node=o.reBoxing();
node.popToTop(profile.root);
_.tryF(o.activate,[],o);
//for on blur disappear
node.setBlurTrigger(profile.key+":"+profile.$id, function(){
box._cache();
}, null, profile.$id);
//for esc
linb.Event.keyboardHook('esc',0,0,0,function(){
box._cache();
box.activate();
//unhook
linb.Event.keyboardHook('esc');
});
});
}
},
/*Initialize*/
Initialize:function(){
this.addTemplateKeys(['UPLOAD','BTN','TOP','MID','RBTN','R1','R1T','R1B','R2','R2T','R2B']);
//modify default template for shell
var t = this.getTemplate();
_.merge(t.FRAME.BORDER,{
SBTN:{
$order:5,
style:"{saveDisplay}",
STOP:{},
SMID:{}
}
},'all');
t.FRAME.POOL={};
this.setTemplate(t);
},
Static:{
_iniType:function(profile){
var pro=profile.properties, value=pro.type;
if(value=='listbox'||value=='upload')
profile.boxing().setReadonly(true);
if(value!='listbox' && value!='combobox')
if(!pro.items)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -