update the toptags for the calendar form
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 9 Mar 2010 18:11:21 +0000 (13:11 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 9 Mar 2010 18:11:21 +0000 (13:11 -0500)
kronolith/js/kronolith.js
kronolith/lib/Ajax/Application.php

index 2b0f988..b91bf48 100644 (file)
@@ -2150,7 +2150,7 @@ KronolithCore = {
         calendar = calendar.split('|');
         var type = calendar[0];
         calendar = calendar.length == 1 ? null : calendar[1];
-
+        this.doAction('listTopTags', {update: 'kronolithCalendarinternalTopTags'}, this.topTagsCallback);
         var form = $('kronolithCalendarForm' + type),
             firstTab = form.down('.tabset a.kronolithTabLink'),
             info;
@@ -3791,7 +3791,7 @@ KronolithCore = {
         $('kronolithEventSave').show();
         $('kronolithEventDelete').show();
         $('kronolithEventForm').down('.kronolithFormActions .kronolithSeparator').show();
-        this.doAction('listTopTags', {}, this.topTags);
+        this.doAction('listTopTags', {update: 'kronolithEventTopTags'}, this.topTagsCallback);
         if (id) {
             RedBox.loading();
             this.doAction('getEvent', { cal: calendar, id: id, date: date }, this.editEventCallback.bind(this));
@@ -3880,17 +3880,17 @@ KronolithCore = {
                       }.bind(this));
     },
 
-    topTags: function(r)
+    topTagsCallback: function(r)
     {
         if (!r.response.tags) {
-            $('kronolithEventTopTags').update();
+            $(r.response.update).update();
             return;
         }
         t = new Element('div');
         r.response.tags.each(function(tag) {
             t.insert(new Element('span', { className: 'kronolithEventTag' }).update(tag.escapeHTML()));
         });
-        $('kronolithEventTopTags').update(t);
+        $(r.response.update).update(t);
         return;
     },
 
index 1d7700c..1be5c05 100644 (file)
@@ -411,7 +411,9 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
     }
 
     /**
-     * TODO
+     * Generate a list of most frequently used tags for the current user.
+     * Takes a 'update' parameter that gets passed back to indicate what element
+     * to update.
      */
     public function listTopTags()
     {
@@ -419,6 +421,7 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
         $tagger = new Kronolith_Tagger();
         $result = new stdClass;
         $result->tags = array();
+        $result->update = $this->_vars->update;
         $tags = $tagger->getCloud(Horde_Auth::getAuth(), 10);
         foreach ($tags as $tag) {
             $result->tags[] = $tag['tag_name'];