properly support embedded videos with "original" size selected
[booh] / data / booh / themes / cardu / root / booh.js
index ded5c8dad949b1a914fc8c8d4b62b66605259133..3ddff42d896f0d25ed63bdbe0ca53b52e869ec52 100644 (file)
@@ -141,7 +141,6 @@ function get_cookie(key) {
 
 function init() {
 
-
     preferred_pause = get_cookie('booh-slideshow-pause-' + dbltilda_theme);
     if (preferred_pause != null) {
         document.getElementById('secs').value = preferred_pause;
@@ -234,9 +233,15 @@ function show_current_text() {
         document.getElementById('main_text').innerHTML = captions[current];
         for (i = 0; i < other_sizes.length; i++) { 
             if (other_sizes[i] == "original") {
-                document.getElementById('link' + other_sizes[i]).href = eval("images_" + other_sizes[i] + "[current]");
+                var original = eval("elements_" + other_sizes[i] + "[current]");
+                if (original != undefined) {
+                    document.getElementById('link' + other_sizes[i]).href = original;
+                    document.getElementById('link' + other_sizes[i]).style.display = '';
+                } else {
+                    document.getElementById('link' + other_sizes[i]).style.display = 'none';
+                }
             } else {
-                document.getElementById('link' + other_sizes[i]).href = 'image-' + other_sizes[i] + dbltilda_htmlsuffix + '#current=' + eval("images_" + other_sizes[i] + "[current]");
+                document.getElementById('link' + other_sizes[i]).href = 'image-' + other_sizes[i] + dbltilda_htmlsuffix + '#current=' + eval("elements_" + other_sizes[i] + "[current]");
             }
         }
         document.getElementById('thumbnails').href = 'thumbnails-' + dbltilda_current_size + '-' + thumbnailspages[current] + dbltilda_htmlsuffix + '#' + images[current];
@@ -248,7 +253,19 @@ function show_current_text() {
 }
 
 function display_current() {
-    document.main_img.src = images[current];
+    var main_img = document.getElementById('main_img');
+    if (types[current] == 'image') {
+        main_img.innerHTML = '<div class="fullscreen_image"><img src="' + images[current] + '"/></div>';
+    } else {
+        main_img.innerHTML = '<a class="fullscreenvideolink" href="' + videos[current] + '" '
+                           + '   style="display:block;width:' + videos_widths[current] + 'px;height:' + (videos_heights[current] + 24) + 'px" id="player">'
+                           + '  <div class="fullscreen_video"><img src="' + images[current] + '"/></div>'
+                           + '  <img src="' + dbltilda_pathtobase + 'play_video.png" style="position:relative;top:-' + (videos_heights[current] + 48)/2 + 'px;border:0;background-color:transparent"/>'
+                           + '</a>';
+        if (dbltilda_flowplayer_active == 'true') {
+            flowplayer("player", dbltilda_pathtobase + "flowplayer-3.1.5.swf");
+        }
+    }
     oldhref = browser_href();
     newhref = 'image-' + dbltilda_current_size + dbltilda_htmlsuffix + '#current=' + images[current];
     if (oldhref != newhref) {
@@ -326,6 +343,17 @@ function last() {
     display_current();
 }
 
+function toggle_video() {
+    if (types[current] == 'video' && dbltilda_flowplayer_active == 'true') {
+        var player = flowplayer('player');
+        if (player.isLoaded()) {
+            player.toggle();
+        } else {
+            player.play();
+        }
+    }
+}
+
 function keyDownEvent(key) {
     if (!key) {
         key = event;
@@ -335,6 +363,9 @@ function keyDownEvent(key) {
         return;
     }
     switch (key.which) {
+      case 32: // space
+        toggle_video();
+        break;
       case 36: // home
         first();
         break;