diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-06-04 23:14:33 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-06-04 23:14:33 +0200 |
commit | bc0790381e9cf02545bf4b2945c70c246008671f (patch) | |
tree | a29978b23e7b4805e453342d1164df54e99986b3 /apps/files_imageviewer | |
parent | 277e644558a6ff9382b71022d54e3eb3ce50eb9e (diff) | |
download | nextcloud-server-bc0790381e9cf02545bf4b2945c70c246008671f.tar.gz nextcloud-server-bc0790381e9cf02545bf4b2945c70c246008671f.zip |
fix loading of image viewer again
Diffstat (limited to 'apps/files_imageviewer')
-rw-r--r-- | apps/files_imageviewer/js/lightbox.js | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/apps/files_imageviewer/js/lightbox.js b/apps/files_imageviewer/js/lightbox.js index b7a07c2408e..25da2bc6835 100644 --- a/apps/files_imageviewer/js/lightbox.js +++ b/apps/files_imageviewer/js/lightbox.js @@ -1,6 +1,7 @@ -if(typeof ileActions!=='undefined'){ - var lightBoxShown=false; - $(document).ready(function() { + +var lightBoxShown=false; +$(document).ready(function() { + if(typeof FileActions!=='undefined'){ images={};//image cache var overlay=$('<div id="lightbox_overlay"/>'); $( 'body' ).append(overlay); @@ -22,36 +23,36 @@ if(typeof ileActions!=='undefined'){ }); $( 'body' ).click(hideLightbox); FileActions.setDefault('image','View'); - }); + } +}); - function showLightbox(container,img){ - var maxWidth = $( window ).width() - 50; - var maxHeight = $( window ).height() - 50; - if( img.width > maxWidth || img.height > maxHeight ) { // One of these is larger than the window - var ratio = img.width / img.height; - if( img.height >= maxHeight ) { - img.height = maxHeight; - img.width = maxHeight * ratio; - } else { - img.width = maxWidth; - img.height = maxWidth * ratio; - } +function showLightbox(container,img){ + var maxWidth = $( window ).width() - 50; + var maxHeight = $( window ).height() - 50; + if( img.width > maxWidth || img.height > maxHeight ) { // One of these is larger than the window + var ratio = img.width / img.height; + if( img.height >= maxHeight ) { + img.height = maxHeight; + img.width = maxHeight * ratio; + } else { + img.width = maxWidth; + 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(){ - if(lightBoxShown){ - $('#lightbox_overlay').hide(); - $('#lightbox').hide(); - lightBoxShown=false; - } +function hideLightbox(){ + if(lightBoxShown){ + $('#lightbox_overlay').hide(); + $('#lightbox').hide(); + lightBoxShown=false; } }
\ No newline at end of file |