Build initial gallery list
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 26 Dec 2010 05:40:42 +0000 (00:40 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 26 Dec 2010 05:41:21 +0000 (00:41 -0500)
ansel/js/mobile.js [new file with mode: 0644]
ansel/lib/Ajax/Application.php [new file with mode: 0644]
ansel/lib/Application.php
ansel/templates/mobile/galleries.html.php
ansel/templates/mobile/javascript_defs.php

diff --git a/ansel/js/mobile.js b/ansel/js/mobile.js
new file mode 100644 (file)
index 0000000..c0f2467
--- /dev/null
@@ -0,0 +1,73 @@
+/**
+ * mobile.js - Base mobile application logic.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author   Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  Ansel
+ */
+var AnselMobile = {
+
+    /**
+     * Build a gallery list
+     */
+    buildGalleryList: function(galleries)
+    {
+        var list = $('<ul>')
+            .addClass('anselGalleryList')
+            .attr({ 'data-role': 'listview' }), item;
+
+        $('#anselgallerylist ul').detach();
+        $.each(galleries, function(k, g) {
+            var item = $('<li>');
+            item.append($('<img>').attr({ src: g.ki }));
+            item.append($('<h3>').append($('<a>').attr({ href: '#' }).text(g.n)));
+            item.append($('<p>').text(g.d));
+            list.append(item);
+        });
+
+        $('#anselgallerylist').append(list);
+    },
+
+    /**
+     * Global click handler
+     *
+     */
+    clickHandler: function(e)
+    {
+
+    },
+
+    /**
+     * Global swipe handler
+     *
+     */
+    handleSwipe: function(map)
+    {
+
+    },
+
+    /**
+     * Initial document ready entry point
+     *
+     */
+    onDocumentReady: function()
+    {
+        // Set up HordeMobile.
+        HordeMobile.urls.ajax = Ansel.conf.URI_AJAX;
+
+        // Bind click and swipe events
+        $(document).click(AnselMobile.clickHandler);
+        $('body').bind('swipeleft', AnselMobile.handleSwipe);
+        $('body').bind('swiperight', AnselMobile.handleSwipe);
+
+        // Todo, eventually move to mobile callback so page reloads work etc...
+        AnselMobile.buildGalleryList(Ansel.conf.galleries);
+    }
+};
+$(AnselMobile.onDocumentReady);
\ No newline at end of file
diff --git a/ansel/lib/Ajax/Application.php b/ansel/lib/Ajax/Application.php
new file mode 100644 (file)
index 0000000..2d35f29
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Defines the AJAX interface for Ansel.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Michael J Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ */
+class Ansel_Ajax_Application extends Horde_Core_Ajax_Application
+{
+    /**
+     * Determines if notification information is sent in response.
+     *
+     * @var boolean
+     */
+    public $notify = true;
+
+
+    
+}
index a704e53..c35d20b 100644 (file)
@@ -84,7 +84,9 @@ class Ansel_Application extends Horde_Registry_Application
         $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create('images')->setLogger($GLOBALS['injector']->getInstance('Horde_Log_Logger'));
 
         /* Build initial Ansel javascript object. */
-        Horde::addInlineJsVars(array('var Ansel' => array('ajax' => new stdClass, 'widgets' => new stdClass)));
+        if (!$GLOBALS['browser']->isMobile()) {
+            Horde::addInlineJsVars(array('var Ansel' => array('ajax' => new stdClass, 'widgets' => new stdClass)));
+        }
     }
 
     /**
@@ -237,11 +239,13 @@ class Ansel_Application extends Horde_Registry_Application
         //Horde::addScriptFile('mobile.js');
         require ANSEL_TEMPLATES . '/mobile/javascript_defs.php';
 
+        Horde::addScriptFile('mobile.js');
         /* Inline script. */
         Horde::addInlineScript(
           '$(window.document).bind("mobileinit", function() {
               $.mobile.page.prototype.options.backBtnText = "' . _("Back") .'";
-              $.mobile.loadingMessage = "' . _("loading") . '";'
+              $.mobile.loadingMessage = "' . _("loading") . '";
+          });'
         );
     }
 
index bd91641..980df3a 100644 (file)
       </ul>
     </div>
   </div>
-  <div data-role="content" class="ui-body">
-      <ul data-role="listview">
-          <li>
-           <?php echo Horde::img('thumb-error.png')?>
-              <h3><a href="#">Gallery One</a></h3>
-              <p>Gallery Description</p>
-          </li>
-          <li>
-           <?php echo Horde::img('thumb-error.png')?>
-              <h3><a href="#">Gallery Two</a></h3>
-              <p>Gallery Description</p>
-          </li>
-          <li>
-           <?php echo Horde::img('thumb-error.png')?>
-              <h3><a href="#">Gallery Three</a></h3>
-              <p>Gallery Description</p>
-          </li>
-      </ul>
+  <div id="anselgallerylist" data-role="content" class="ui-body">
   </div>
 </div>
\ No newline at end of file
index 00d9b82..bc254b5 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 global $prefs, $registry;
 
-$kronolith_webroot = $registry->get('webroot');
+$ansel_webroot = $registry->get('webroot');
 $horde_webroot = $registry->get('webroot', 'horde');
 $has_tasks = $registry->hasInterface('tasks');