issue117, auto-scroll photo-index if thumbnails are out of sight after a page-refresh
[phpfspot.git] / themes / default / templates / photo_index.tpl
index dff6ab1d15e54489940e0b798698bbac2f4aa51b..82f49596576234d13ee386c1914415c3f7261eed 100644 (file)
 
    <div class="thumb" onmouseover="setBackGrdColor(this, 'mouseover');" onmouseout="setBackGrdColor(this, 'mouseout');" style="width: { $thumb_container_width }px; height: { $thumb_container_height }px;">
     <a href="javascript:showImage({$images[thumb]}, 'scrollup');" id="thumblink{$images[thumb]}" name="image{$img_id[thumb]}" class="thumblink" onclick="click(this);" title="{$img_title[thumb]}">
-     <img class="thumb" id="thumbimg{$images[thumb]}" src="phpfspot_img.php?idx={$images[thumb]}&amp;width={$width}" alt="thumb_{$images[thumb]}" width="{$img_width[thumb]}" height="{$img_height[thumb]}" />
+     <img class="thumb" id="thumbimg{$images[thumb]}" width="{$img_width[thumb]}" height="{$img_height[thumb]}" />
      <br />
     {$img_name[thumb]}
     </a>
+    { if $use_lightbox }
+    <a href="phpfspot_img.php?idx={$images[thumb]}&amp;width={$preview_width}" alt="thumb_{$images[thumb]}" rel="lightbox[photoidx]" title="Preview of {$img_fullname[thumb]}"><img src="resources/eyes.png" /></a>
+    { /if }
    </div>
 
   {/if}
@@ -71,7 +74,7 @@
    <img src="resources/arrow_right_gray.png" alt="last page reached" />
   { /if }
  { else }
-  <a href="{$next_url}">
+  <a href="{$next_url}" id="next_link" title="click for the next page (right cursor)">
    <img src="resources/arrow_right.png" alt="next photo" />
   </a>
  { /if}
@@ -84,7 +87,7 @@
    <img src="resources/arrow_left_gray.png" alt="first page reached" />
   { /if }
  { else }
-  <a href="{$previous_url}">
+  <a href="{$previous_url}" id="prev_link" title="click for the previous page (left cursor)">
   <img src="resources/arrow_left.png" alt="previous photo" />
   </a>
  { /if }
  </div>
 </div>
 <br class="clearboth" />
-<script type="text/javascript">
+<script type="text/javascript" language="JavaScript">
 <!--
-   preloadPhotos();
+   /*** image preloading ***/
+   { counter start=-1 }
+
+   var current;
+   var image_urls = new Array();
+   var last_thumb;
+
+   {section name="thumb" loop=$thumbs step=1}
+      {if $images[thumb] }
+         image_urls[{counter}] = 'phpfspot_img.php?idx={$images[thumb]}&width={$width}';
+         last_thumb = {$images[thumb]};
+      {/if}
+   {/section}
+
+   preloadPhotos(image_urls);
+
+   // auto-scroll
+   //
+   // if browser is to far down the page, that he can't see the photo at all
+   // scroll it up so that at least the last photo becomes visisble.
+   { literal }
+
+   var ywnd = 0;
+   var yimg = 0;
+   // check where we are with the browser
+   if (window.pageYOffset) {
+      ywnd = window.pageYOffset;
+   } else if (document.body && document.body.scrollTop) {
+      ywnd = document.body.scrollTop;
+   }
+   // check the y-pos of the last thumbnail
+   if(thumbimg = document.getElementById('thumbimg' + last_thumb)) {
+      yimg = findPos(thumbimg,'top');
+   }
+   // if the browser-window is scrolled further then the last_thumb, scroll back
+   if(ywnd > yimg) {
+      window.scrollTo(0, yimg-100);
+   }
+
+   { /literal }
+   // auto-scroll
+
 -->
 </script>
 <!-- /Photo Index -->