Skip to content
Snippets Groups Projects
Commit bc079038 authored by Robin Appelman's avatar Robin Appelman
Browse files

fix loading of image viewer again

parent 277e6445
No related branches found
No related tags found
No related merge requests found
if(typeof ileActions!=='undefined'){
var lightBoxShown=false; var lightBoxShown=false;
$(document).ready(function() { $(document).ready(function() {
if(typeof FileActions!=='undefined'){
images={};//image cache images={};//image cache
var overlay=$('<div id="lightbox_overlay"/>'); var overlay=$('<div id="lightbox_overlay"/>');
$( 'body' ).append(overlay); $( 'body' ).append(overlay);
...@@ -22,36 +23,36 @@ if(typeof ileActions!=='undefined'){ ...@@ -22,36 +23,36 @@ if(typeof ileActions!=='undefined'){
}); });
$( 'body' ).click(hideLightbox); $( 'body' ).click(hideLightbox);
FileActions.setDefault('image','View'); FileActions.setDefault('image','View');
}); }
});
function showLightbox(container,img){ function showLightbox(container,img){
var maxWidth = $( window ).width() - 50; var maxWidth = $( window ).width() - 50;
var maxHeight = $( window ).height() - 50; var maxHeight = $( window ).height() - 50;
if( img.width > maxWidth || img.height > maxHeight ) { // One of these is larger than the window if( img.width > maxWidth || img.height > maxHeight ) { // One of these is larger than the window
var ratio = img.width / img.height; var ratio = img.width / img.height;
if( img.height >= maxHeight ) { if( img.height >= maxHeight ) {
img.height = maxHeight; img.height = maxHeight;
img.width = maxHeight * ratio; img.width = maxHeight * ratio;
} else { } else {
img.width = maxWidth; img.width = maxWidth;
img.height = maxWidth * ratio; img.height = maxWidth * ratio;
}
} }
container.empty();
container.append(img);
container.css('top',Math.round( ($( window ).height() - img.height)/2));
container.css('left',Math.round( ($( window ).width() - img.width)/2));
$('#lightbox').show();
setTimeout(function(){
lightBoxShown=true;
},100);
} }
container.empty();
container.append(img);
container.css('top',Math.round( ($( window ).height() - img.height)/2));
container.css('left',Math.round( ($( window ).width() - img.width)/2));
$('#lightbox').show();
setTimeout(function(){
lightBoxShown=true;
},100);
}
function hideLightbox(){ function hideLightbox(){
if(lightBoxShown){ if(lightBoxShown){
$('#lightbox_overlay').hide(); $('#lightbox_overlay').hide();
$('#lightbox').hide(); $('#lightbox').hide();
lightBoxShown=false; lightBoxShown=false;
}
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment