aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_imageviewer
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-06-04 23:08:38 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-06-04 23:08:38 +0200
commit277e644558a6ff9382b71022d54e3eb3ce50eb9e (patch)
tree736a5a2549a32523971c22674d5fa79b126a537d /apps/files_imageviewer
parent153d8fec30af510cb542db180f1192675ef9f029 (diff)
downloadnextcloud-server-277e644558a6ff9382b71022d54e3eb3ce50eb9e.tar.gz
nextcloud-server-277e644558a6ff9382b71022d54e3eb3ce50eb9e.zip
only load image viewer when in file browser
Diffstat (limited to 'apps/files_imageviewer')
-rw-r--r--apps/files_imageviewer/js/lightbox.js96
1 files changed, 49 insertions, 47 deletions
diff --git a/apps/files_imageviewer/js/lightbox.js b/apps/files_imageviewer/js/lightbox.js
index 5f15c786914..b7a07c2408e 100644
--- a/apps/files_imageviewer/js/lightbox.js
+++ b/apps/files_imageviewer/js/lightbox.js
@@ -1,55 +1,57 @@
-var lightBoxShown=false;
-$(document).ready(function() {
- images={};//image cache
- var overlay=$('<div id="lightbox_overlay"/>');
- $( 'body' ).append(overlay);
- var container=$('<div id="lightbox"/>');
- $( 'body' ).append(container);
- FileActions.register('image','View',function(filename){
- var location='ajax/download.php?files='+filename+'&dir='+$('#dir').val();
- overlay.show();
- if(!images[location]){
- var img = new Image();
- img.onload = function(){
- images[location]=img;
- showLightbox(container,img);
+if(typeof ileActions!=='undefined'){
+ var lightBoxShown=false;
+ $(document).ready(function() {
+ images={};//image cache
+ var overlay=$('<div id="lightbox_overlay"/>');
+ $( 'body' ).append(overlay);
+ var container=$('<div id="lightbox"/>');
+ $( 'body' ).append(container);
+ FileActions.register('image','View',function(filename){
+ var location='ajax/download.php?files='+filename+'&dir='+$('#dir').val();
+ overlay.show();
+ if(!images[location]){
+ var img = new Image();
+ img.onload = function(){
+ images[location]=img;
+ showLightbox(container,img);
+ }
+ img.src = location;
+ }else{
+ showLightbox(container,images[location]);
}
- img.src = location;
- }else{
- showLightbox(container,images[location]);
- }
+ });
+ $( 'body' ).click(hideLightbox);
+ FileActions.setDefault('image','View');
});
- $( '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