changeset 54:42a449dac415

multi-frame images in the explorer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Sep 2012 15:23:20 +0200
parents 293038baf8f1
children 601ee9b7f2c7
files PalanthirExplorer/explorer.js
diffstat 1 files changed, 30 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/PalanthirExplorer/explorer.js	Mon Sep 10 15:17:02 2012 +0200
+++ b/PalanthirExplorer/explorer.js	Mon Sep 10 15:23:20 2012 +0200
@@ -586,11 +586,36 @@
 
 
 $('#instance-preview').live('click', function(e) {
-  jQuery.slimbox('/instances/' + $.mobile.pageData.uuid + '/preview', '', {
-                   overlayFadeDuration : 1,
-                   resizeDuration : 1,
-                   imageFadeDuration : 1
-                 });
+  if ($.mobile.pageData) {
+    GetSingleResource('instances', $.mobile.pageData.uuid + '/frames', function(frames) {
+      if (frames.length == 1)
+      {
+        // Viewing a single-frame image
+        jQuery.slimbox('/instances/' + $.mobile.pageData.uuid + '/preview', '', {
+          overlayFadeDuration : 1,
+          resizeDuration : 1,
+          imageFadeDuration : 1
+        });
+      }
+      else
+      {
+        // Viewing a multi-frame image
+
+        var images = [];
+        for (var i = 0; i < frames.length; i++) {
+          images.push([ '/instances/' + $.mobile.pageData.uuid + '/frames/' + i + '/preview' ]);
+        }
+
+        jQuery.slimbox(images, 0, {
+          overlayFadeDuration : 1,
+          resizeDuration : 1,
+          imageFadeDuration : 1,
+          loop : true
+        });
+      }
+    });
+
+  }
 });
 
 $('#series-preview').live('click', function(e) {