📄 dialog.js
字号:
}
},
_unModal:function(profile){
if(profile.$inModal){
profile.$modalDiv.setDock('none');
profile.root.css('zIndex',0);
profile.getSubNode('BORDER').append(profile.$modalDiv.reBoxing().css('display','none'));
profile.$inModal=false;
var hash=profile.$focusHash,h;
for(var i in hash){
h=hash[i];
for(var j in h)
h[j].tabIndex=i;
}
_.breakO(profile.$focusHash,2);
linb.Event.popTabOutTrigger();
}
},
_refreshRegion:function(profile){
if(!profile.root) return;
return _.merge(profile.properties, profile.root.cssRegion(), 'all');
},
_adjust:function(dialog,caption, content){
caption = caption ||'';
if(!content){
content = caption;
caption = "";
}
var node = dialog.$div.reBoxing(),
ID='linb:temp:dialog',
me=arguments.callee;
if(!linb.Dom.byId(ID)){
n2 = me._cache=node.clone(false);
linb('body').append(n2);
n2.css({width:'auto',height:'auto',overflow:'visible',position:'absolute',visibility:'visible',left:linb.Dom.HIDE_VALUE})
.id(ID,true);
}
var n2 = me._cache;
n2.html(content,false);
var size = n2.cssSize();
node.html(content);
if(size.width>500){
size.width=500;
n2.width(500);
size.height = n2.offsetHeight() + 10;
n2.width('auto');
}
if(size.height>400)size.height=400;
if(size.width<150)size.width=150;
if(size.height<30)size.height=30;
node.cssSize(size).css('overflow','auto').show();
dialog.setCaption(caption).setWidth(size.width + 30).setHeight(size.height+80);
dialog.$cmd.reBoxing().left((size.width + 30 - dialog.$cmd.reBoxing().width())/2);
},
alert:function(title, content, onOK){
var me=arguments.callee, dialog;
if(!(dialog=me.dialog)){
dialog = me.dialog = new linb.UI.Dialog({
minBtn:false,
maxBtn:false,
pinBtn:false,
resizer:false,
left:200,
top:200
},{
beforeClose:function(){
dialog.hide();
_.tryF(me.onOK);
me.onOK=null;
return false;
}
});
var cmd = dialog.$cmd = new linb.UI.Div({
bottom:10,
width:60,
height:24
}),
btn = dialog.$btn = new linb.UI.Button({
caption:'$inline.ok',
width: 60,
tabindex:1
},
{
onClick:function(){
dialog.hide();
_.tryF(onOK);
}
});
cmd.append(btn);
var div = dialog.$div = new linb.UI.Div({
left:10,
top:10
});
dialog.append(cmd).append(div).render();
}
me.onOK=onOK;
this._adjust(dialog,title, content);
dialog.show(linb('body'),true);
_.asyRun(function(){
dialog.$btn.activate();
});
},
confirm:function(title, caption, onYes, onNo){
var me=arguments.callee, dialog;
if(!(dialog=me.dialog)){
dialog = me.dialog = new linb.UI.Dialog({
minBtn:false,
maxBtn:false,
pinBtn:false,
resizer:false,
left:200,
top:200
},{
beforeClose:function(){
dialog.hide();
_.tryF(me.onNo);
me.onYest=me.onNo=null;
return false;
}
});
var cmd = dialog.$cmd=new linb.UI.Div({
bottom:10,
width:140,
height:24
}),
btn = new linb.UI.Button({
caption:'$inline.yes',
width: 60,
tabindex:1,
left:0
},
{
onClick:function(){
dialog.hide();
_.tryF(me.onYes);
me.onYest=me.onNo=null;
}
});
cmd.append(btn);
btn = dialog.$btn=new linb.UI.Button({
caption:'$inline.no',
tabindex:1,
width: 60,
left:80
},
{
onClick:function(){
dialog.hide();
_.tryF(me.onNo);
me.onYest=me.onNo=null;
}
});
cmd.append(btn);
var div = dialog.$div=new linb.UI.Div({
left:10,
top:10
});
dialog.append(cmd).append(div).render();
}
me.onYes=onYes;
me.onNo=onNo;
this._adjust(dialog, title, caption);
dialog.show(linb('body'), true);
_.asyRun(function(){
dialog.$btn.activate();
});
},
pop:function(title, content, cmdStr, left, top){
var dialog = new linb.UI.Dialog({
minBtn:false,
maxBtn:false,
pinBtn:false,
resizer:false,
left:200 || left,
top:200 || top
}),
cmd = dialog.$cmd = new linb.UI.Div({
bottom:10,
width:60,
height:24
})
.append( dialog.$btn = new linb.UI.Button({
caption: cmdStr || '$inline.ok',
tabindex:1,
width: 60
},
{
onClick:function(){
dialog.destroy();
}
})),
div = dialog.$div = new linb.UI.Div({
left:10,
top:10
}).setCustomStyle({
KEY:'overflow:visible'
});
dialog.append(cmd).append(div).render();;
this._adjust(dialog, title, content);
dialog.show(linb('body'),false,left, top);
_.asyRun(function(){
dialog.$btn.activate();
});
return dialog;
},
prompt:function(title, caption, content, onYes, onNo){
var dialog,
me=arguments.callee;
if(!(dialog=me.dialog)){
var close=function(){
me.$inp.setValue('');
me.onYes=me.onNo=null;
me.dialog.hide();
return false;
};
dialog = me.dialog = new linb.UI.Dialog({
minBtn:false,
maxBtn:false,
pinBtn:false,
resizer:false,
left:200,
top:200,
width:300,
height:130
},{
beforeClose:function(){
_.tryF(me.onNo);
return close();
}
});
var con = me.$con = new linb.UI.Div({
top:4,
left:10,
width:270,
height:18
}),
cmd = new linb.UI.Div({
top:65,
width:270,
height:24
})
.setCustomStyle('KEY',"text-align:center;")
.append(new linb.UI.Button({
caption:'$inline.yes',
width: 60,
left:70,
tabindex:1
},
{
onClick:function(){
_.tryF(me.onYes,[me.$inp.getUIValue()]);
return close();
}
}));
cmd.append(new linb.UI.Button({
caption:'$inline.no',
tabindex:1,
left:140,
width: 60
},
{
onClick:function(){
_.tryF(me.onNo);
return close();
}
}));
var inp=me.$inp=new linb.UI.Input({
left:10,
top:22,
width:270,
height:36,
multiLines:true
})
dialog.append(con).append(cmd).append(inp).render();
}
dialog.setCaption(title||'Prompt');
me.$con.setHtml(caption||"");
me.$inp.setValue(content||"");
me.onYes=onYes;
me.onNo=onNo;
dialog.show(linb('body'), true);
_.asyRun(function(){
me.$inp.activate();
});
},
//
_onresize:function(profile,width,height){
var size = arguments.callee.upper.apply(this,arguments),
region={},
v1=profile.getSubNode('BAR'),
v2=profile.getSubNode('PANEL'),
v3=profile.getSubNode('STATUS'),
bh,bw,h1,h3;
if(height){
bh = size.height,
h1=v1.height(), h3=v3.height();
region.top=h1;
if(bh-h1-h3>0)
region.height = bh-h1-h3;
}
if(width){
bw = size.width;
region.width=bw-2;
}
v2.cssRegion(region, true);
if(bw)
v3.width(bw);
}
}
});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -