changeset 176:27039f0d187c

arnica_slides: preload of all images changed to load image on demand
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Wed, 16 Jul 2008 06:51:25 +0200
parents 377e5f674c66
children a399665b4cb9
files data/plugin/action/arnica_slides.py
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Wed Jul 16 00:35:47 2008 +0200
+++ b/data/plugin/action/arnica_slides.py	Wed Jul 16 06:51:25 2008 +0200
@@ -65,8 +65,18 @@
 var rotate_delay = 5; // delay in milliseconds (5000 = 5 secs)
 var current = %(counter)s;
 var theImages = new Array();
+var preloaded_images = new Array(); 
 var AttachFile_action = '?action=AttachFile&do=get&target=';
 
+function load_image(index) {
+    var list = document.slideform.webnail_list.value;
+    var value = list.split("|");
+    if (preloaded_images[index] == false) {
+        theImages[index].src = value[index];
+        preloaded_images[index] = true;
+    }
+}
+      
 function arnica_preload() {
    var list = document.slideform.webnail_list.value;
    var value = list.split("|");
@@ -74,7 +84,7 @@
 
    for (i = 0; i <  n-1; i++){
        theImages[i] = new Image();
-       theImages[i].src = value[i];
+       preloaded_images[i] = false;
    }
 }
 
@@ -99,6 +109,7 @@
 
 function arnica_next_slide() {
    if (document.slideform.slide[current+1]) {
+      load_image(current+1);
       document.images.show.src = theImages[current+1].src;
       document.slideform.slide.selectedIndex = ++current;
       arnica_add_comments();
@@ -110,6 +121,7 @@
 
 function arnica_previous_slide() {
    if (current-1 >= 0) {
+      load_image(current-1);
       document.images.show.src = theImages[current-1].src;
       document.slideform.slide.selectedIndex = --current;
       arnica_add_comments();
@@ -121,6 +133,7 @@
 
 function arnica_first_slide() {
    current = 0;
+   load_image(current);
    document.images.show.src = theImages[0].src;
    document.slideform.slide.selectedIndex = 0;
    arnica_add_comments();
@@ -130,6 +143,7 @@
 
 function arnica_last_slide() {
    current = document.slideform.slide.length-1;
+   load_image(current);
    document.images.show.src = theImages[current].src;
    document.slideform.slide.selectedIndex = current;
    arnica_add_comments();
@@ -144,6 +158,7 @@
 
 function arnica_change() {
    current = document.slideform.slide.selectedIndex;
+   load_image(current);
    document.images.show.src = theImages[current].src;
    arnica_add_comments();
    document.getElementById("arnica_first_slide").innerHTML = '<a class="first_slide" onclick="arnica_first_slide();" name="fs"  title="first slide" >';
@@ -153,6 +168,7 @@
 function arnica_rotate() {
    if (document.slideform.slidebutton.value == "Stop") {
       current = (current == document.slideform.slide.length-1) ? 0 : current+1;
+      load_image(current);
       document.images.show.src = theImages[current].src;
       document.slideform.slide.selectedIndex = current;
       arnica_add_comments();