PDA

View Full Version : poorman's lightbox (not exstension)



saxxiboy
2 Apr 2009, 4:12 AM
hi!
check this super-simple lightbox code.
It's not performance-proof neither so much flexible, but for me it does the trick

Maybe should be implemented an El.getTarget() or something..

usage:
<a href="path_to_image" class="lightbox"><img src="path_to_icon" /></a>
<a href="path_to_image" class="lightbox">link</a>



var winImg;
Ext.onReady(function(){
// ini LIGHTBOX
function openImg(url){
winImg = new Ext.Window({
title: 'Accomodation Image',
modal: true,
border: false,
bodyBorder : false,
resizable: false,
closeAction: 'close',
items: new Ext.Panel({
width: 550,
height: 550,
html: '<img src="'+url+'" onclick="winImg.close()" />'
})
});
winImg.show();
}
var lightboxopener=function(els){
for(x=0;x<els.length;x++){
var el=Ext.fly(els[x]);
if(el){
var imghref = el.dom.href;
el.on("click", function(e){
e.preventDefault();
openImg(this.finhref);
return false;
},{
finhref: imghref
});
}
}
return els;
};
lightboxopener(Ext.query("*[class=lightbox]"));
// end LIGHTBOX
});