Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-07-31 04:35:54 +0400
committerRobin Appelman <icewind1991@gmail.com>2011-07-31 04:35:54 +0400
commiteb3526c9a6f8efab1b0fe3e5588b3ed1f43d2294 (patch)
tree213667186799f97bcd49b8115789c87e4dd4db34 /apps/files_imageviewer
parent2c8b4da840e64aff9f745ae7f75f300a027dad59 (diff)
show images on click in search results
Diffstat (limited to 'apps/files_imageviewer')
-rw-r--r--apps/files_imageviewer/appinfo/app.php6
-rw-r--r--apps/files_imageviewer/js/lightbox.js56
2 files changed, 39 insertions, 23 deletions
diff --git a/apps/files_imageviewer/appinfo/app.php b/apps/files_imageviewer/appinfo/app.php
index 6d32e2d628e..3dfbb76ceb0 100644
--- a/apps/files_imageviewer/appinfo/app.php
+++ b/apps/files_imageviewer/appinfo/app.php
@@ -1,8 +1,6 @@
<?php
-if(OC_App::getCurrentApp()=='files'){
- OC_Util::addScript( 'files_imageviewer', 'lightbox' );
- OC_Util::addStyle( 'files_imageviewer', 'lightbox' );
-}
+OC_Util::addScript( 'files_imageviewer', 'lightbox' );
+OC_Util::addStyle( 'files_imageviewer', 'lightbox' );
?>
diff --git a/apps/files_imageviewer/js/lightbox.js b/apps/files_imageviewer/js/lightbox.js
index 318c764458e..847954d2f15 100644
--- a/apps/files_imageviewer/js/lightbox.js
+++ b/apps/files_imageviewer/js/lightbox.js
@@ -1,31 +1,48 @@
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);
+ $( 'body' ).click(hideLightbox);
if(typeof FileActions!=='undefined'){
- 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]);
- }
+ viewImage($('#dir').val(),filename);
});
- $( 'body' ).click(hideLightbox);
FileActions.setDefault('image','View');
}
+ OC.search.customResults.Images=function(row,item){
+ var image=item.link.substr(item.link.indexOf('file=')+5);
+ var a=row.find('a');
+ var container=$('<div id="lightbox"/>');
+ a.attr('href','#');
+ a.click(function(){
+ var file=image.split('/').pop();
+ var dir=image.substr(0,image.length-file.length-1);
+ viewImage(dir,file);
+ });
+ }
});
+function viewImage(dir,file){
+ var location=OC.filePath('files','ajax','download.php')+'?files='+file+'&dir='+dir;
+ var overlay=$('#lightbox_overlay');
+ var container=$('#lightbox');
+ 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]);
+ }
+}
+
function showLightbox(container,img){
var maxWidth = $( window ).width() - 50;
var maxHeight = $( window ).height() - 50;
@@ -49,8 +66,9 @@ function showLightbox(container,img){
},100);
}
-function hideLightbox(){
+function hideLightbox(event){
if(lightBoxShown){
+ event.stopPropagation();
$('#lightbox_overlay').hide();
$('#lightbox').hide();
lightBoxShown=false;