only load image viewer when in file browser

This commit is contained in:
Robin Appelman 2011-06-04 23:08:38 +02:00
parent 153d8fec30
commit 277e644558
1 changed files with 49 additions and 47 deletions

View File

@ -1,5 +1,6 @@
var lightBoxShown=false; if(typeof ileActions!=='undefined'){
$(document).ready(function() { var lightBoxShown=false;
$(document).ready(function() {
images={};//image cache images={};//image cache
var overlay=$('<div id="lightbox_overlay"/>'); var overlay=$('<div id="lightbox_overlay"/>');
$( 'body' ).append(overlay); $( 'body' ).append(overlay);
@ -21,9 +22,9 @@ $(document).ready(function() {
}); });
$( '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
@ -44,12 +45,13 @@ function showLightbox(container,img){
setTimeout(function(){ setTimeout(function(){
lightBoxShown=true; lightBoxShown=true;
},100); },100);
} }
function hideLightbox(){ function hideLightbox(){
if(lightBoxShown){ if(lightBoxShown){
$('#lightbox_overlay').hide(); $('#lightbox_overlay').hide();
$('#lightbox').hide(); $('#lightbox').hide();
lightBoxShown=false; lightBoxShown=false;
} }
}
} }