Don't reload the same gallery if requested twice in a row, clear the thumbs container
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 1 Jan 2011 21:40:08 +0000 (16:40 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 1 Jan 2011 21:40:08 +0000 (16:40 -0500)
ansel/js/mobile.js
ansel/lib/Ajax/Application.php

index 72c1d3f..d0173a6 100644 (file)
@@ -13,6 +13,8 @@
  */
 var AnselMobile = {
 
+    currentGallery: null,
+
     /**
      * Build a gallery list
      */
@@ -46,8 +48,14 @@ var AnselMobile = {
      */
     galleryLoaded: function(r)
     {
-        $('#galleryview h1').text(r.n);
         // TODO: error checks, build any subgallery lists etc...
+        if (r.id == AnselMobile.currentGallery) {
+            $.mobile.changePage('galleryview', 'slide', false, true);
+            return;
+        }
+        AnselMobile.currentGallery = r.id;
+        $('#thumbs').text('');
+        $('#galleryview h1').text(r.n);
         $.mobile.changePage('galleryview', 'slide', false, true);
         $.each(r.imgs, function(k, i) {
             var img = $('<li>').append($('<img>').attr({ src: i.url }));
index 7cd096e..a47199d 100644 (file)
@@ -25,6 +25,7 @@ class Ansel_Ajax_Application extends Horde_Core_Ajax_Application
      * @return mixed  False on failure, object representing the gallery with
      *                the following structure:
      * <pre>
+     * 'id' - gallery id
      * 'n'  - gallery name
      * 'dc' - date created
      * 'dm' - date modified