Fix opening holiday events. Prepare to view tasks.
authorJan Schneider <jan@horde.org>
Fri, 23 Oct 2009 16:58:05 +0000 (18:58 +0200)
committerJan Schneider <jan@horde.org>
Mon, 26 Oct 2009 18:51:02 +0000 (19:51 +0100)
kronolith/js/kronolith.js
kronolith/lib/Event.php
kronolith/lib/Event/Horde.php

index 9e37a59..d3e24c1 100644 (file)
@@ -329,6 +329,10 @@ KronolithCore = {
             this._addHistory(fullloc);
             break;
 
+        case 'task':
+            this._addHistory(fullloc);
+            break;
+
         case 'options':
             //this.highlightSidebar('appoptions');
             this._addHistory(loc);
@@ -999,12 +1003,16 @@ KronolithCore = {
         event.value.nodeId = 'kronolithEvent' + view + event.value.calendar + date + event.key;
 
         _createElement = function(event) {
-            return new Element('DIV', {
+            var el = new Element('DIV', {
                 'id': event.value.nodeId,
-                'calendar': event.value.calendar,
-                'eventid' : event.key,
+                'calendar': event.value.calendar.replace(/:/, '^'),
+                'eventid' : event.key.replace(/:/, '^'),
                 'class': 'kronolithEvent'
             });
+            if (!Object.isUndefined(event.value.aj)) {
+                el.writeAttribute('ajax', event.value.aj);
+            }
+            return el;
         };
 
         switch (view) {
@@ -1880,12 +1888,16 @@ KronolithCore = {
             case 'kronolithNavWeek':
             case 'kronolithNavMonth':
             case 'kronolithNavYear':
-            case 'kronolithNavTasks':
             case 'kronolithNavAgenda':
                 this.go(id.substring(12).toLowerCase() + ':' + this.date.dateString());
                 e.stop();
                 return;
 
+            case 'kronolithNavTasks':
+                this.go('tasks');
+                e.stop();
+                return;
+
             case 'kronolithMinicalDate':
                 this.go('month:' + orig.readAttribute('date'));
                 e.stop();
@@ -2030,7 +2042,11 @@ KronolithCore = {
             }
 
             if (elt.hasClassName('kronolithEvent')) {
-                this.go('event:' + elt.readAttribute('calendar') + ':' + elt.readAttribute('eventid'));
+                if (elt.hasAttribute('ajax')) {
+                    this.go(elt.readAttribute('ajax'));
+                } else {
+                    this.go('event:' + elt.readAttribute('calendar') + ':' + elt.readAttribute('eventid'));
+                }
                 e.stop();
                 return;
             } else if (elt.hasClassName('kronolithWeekDay')) {
@@ -2129,7 +2145,7 @@ KronolithCore = {
         this.doAction('ListTopTags', {}, this._topTags);
         if (id) {
             RedBox.loading();
-            this.doAction('GetEvent', { 'cal': calendar, 'id': id }, this._editEvent.bind(this));
+            this.doAction('GetEvent', { 'cal': calendar.replace(/\^/, ':'), 'id': id.replace(/\^/, ':') }, this._editEvent.bind(this));
         } else {
             var d = date ? this.parseDate(date) : new Date();
             $('kronolithEventId').value = '';
index eebf2fb..a0b55e9 100644 (file)
@@ -1083,6 +1083,7 @@ abstract class Kronolith_Event
      * - r: recurrence type (Horde_Date_Recurrence::RECUR_* constant)
      * - ic: icon
      * - ln: link
+     * - aj: ajax link
      * - id: event id
      * - ty: calendar type (driver)
      * - l: location
index f9fc87d..354efcf 100644 (file)
@@ -22,7 +22,14 @@ class Kronolith_Event_Horde extends Kronolith_Event
      *
      * @var string
      */
-    private $_api;
+    protected $_api;
+
+    /**
+     * The link to this event in the ajax interface.
+     *
+     * @var string
+     */
+    public $ajax_link;
 
     /**
      * Constructor.
@@ -47,6 +54,7 @@ class Kronolith_Event_Horde extends Kronolith_Event
         $this->external_params = $event['params'];
         $this->external_icon = !empty($event['icon']) ? $event['icon'] : null;
         $this->external_link = !empty($event['link']) ? $event['link'] : null;
+        $this->ajax_link = !empty($event['ajax_link']) ? $event['ajax_link'] : null;
         $this->title = $event['title'];
         $this->description = isset($event['description']) ? $event['description'] : '';
         $this->start = $eventStart;
@@ -85,9 +93,11 @@ class Kronolith_Event_Horde extends Kronolith_Event
     {
         $json = parent::toJson($allDay, $full, $time_format);
         $json->ic = $this->external_icon;
-        // @TODO: What is expected for external calendar links? This is currently
-        // broken in the UI.
-        //$json->ln = $this->getLink();
+        if ($this->ajax_link) {
+            $json->aj = $this->ajax_link;
+        } else {
+            $json->ln = $this->getLink();
+        }
         return $json;
     }