EXT给放大的图片添加一个关闭按钮
下面是代码.
function magnifyImage(dataView, index, node, e){
var selNode = view.getSelectedNodes()[0];
if(selNode){
var data = lookup[selNode.id];
var imgSrc = data.url;
var imgWidth = 490;
var imgHeight = 400;
var imgLeft = e.getPageX();
var imgTop = e.getPageY();
if(!imgResizeer && !newImgEl){
newImgEl = Ext.DomHelper.append('layout', {
tag: 'img',
id: 'custom',
src: imgSrc,
style: 'button',
qtip: '按Esc键可退出',
style:'position:absolute; width: '+imgWidth+'; height: '+imgHeight+'; left: '+imgLeft+'; top: '+imgTop+';'
}, true);
//
imgResizeer = new Ext.Resizable('custom', {
wrap:true,
pinned:true,
minWidth:50,
minHeight: 50,
maxWidth:700,
maxHeight:700,
preserveRatio: true,
handles: 'all',
draggable:true,
dynamic: true
});
//alert('===============')
new Ext.KeyMap(imgResizeer.getEl(), [
{
key: Ext.EventObject.ESC,
fn: function (){
Ext.EventObject.preventDefault();
imgResizeer.getEl().hide();
newImgEl.hide(true).frame();
},
scope: imgResizeer
}
]);
}else {
imgResizeer.getEl().dom.style.left = imgLeft;
imgResizeer.getEl().dom.style.top = imgTop;
newImgEl.dom.src = imgSrc;
}
newImgEl.show(true).frame();
imgResizeer.getEl().show();
}
&