summaryrefslogtreecommitdiffstats
path: root/apps/files_imageviewer/js/lightbox.js
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2011-10-16 23:16:32 +0200
committerFlorian Pritz <bluewind@xinu.at>2011-10-21 20:19:39 +0200
commitf0565de900e3abd80557e2912d577a2002809d38 (patch)
treece2a8210f56f3654d49f861bcb517798212efa85 /apps/files_imageviewer/js/lightbox.js
parent2906ea3d78d2ff8ebfa3ceebe1c8cb5afa43225a (diff)
downloadnextcloud-server-f0565de900e3abd80557e2912d577a2002809d38.tar.gz
nextcloud-server-f0565de900e3abd80557e2912d577a2002809d38.zip
use fancybox instead of lightbox
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'apps/files_imageviewer/js/lightbox.js')
-rw-r--r--apps/files_imageviewer/js/lightbox.js68
1 files changed, 6 insertions, 62 deletions
diff --git a/apps/files_imageviewer/js/lightbox.js b/apps/files_imageviewer/js/lightbox.js
index 4f079b6d8af..94743aa85e0 100644
--- a/apps/files_imageviewer/js/lightbox.js
+++ b/apps/files_imageviewer/js/lightbox.js
@@ -1,18 +1,4 @@
-
-var lightBoxShown=false;
$(document).ready(function() {
- images={};//image cache
- loading_str = t('files_imageviewer','Loading');
- var overlay=$('<div id="lightbox_overlay"><div id="lightbox_loader"><img /></div></div>');
- overlay.find('#lightbox_loader img')
- .attr('src',OC.imagePath('core', 'loading-dark.gif'))
- .attr('alt',loading_str)
- .after(loading_str);
- $( 'body' ).append(overlay);
- var container=$('<div id="lightbox"/>');
- $( 'body' ).append(container);
- $( '#lightbox_overlay' ).click(hideLightbox);
- $( '#lightbox' ).click(hideLightbox);
if(typeof FileActions!=='undefined'){
FileActions.register('image','View','',function(filename){
viewImage($('#dir').val(),filename);
@@ -22,7 +8,6 @@ $(document).ready(function() {
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();
@@ -32,52 +17,11 @@ $(document).ready(function() {
}
});
-function 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;
- if($('#lightbox_overlay').is(':visible'))
- showLightbox(container,img);
- }
- img.src = location;
- }else{
- showLightbox(container,images[location]);
- }
+ $.fancybox({
+ "href": location,
+ "title": file,
+ "titlePosition": "inside"
+ });
}
-
-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);
-}
-
-function hideLightbox(event){
- if(event){
- event.stopPropagation();
- $('#lightbox_overlay').hide();
- $('#lightbox').hide();
- lightBoxShown=false;
- }
-} \ No newline at end of file