No need to pass the class name around in the ajax communication.
authorJan Schneider <jan@horde.org>
Tue, 9 Mar 2010 23:03:08 +0000 (00:03 +0100)
committerJan Schneider <jan@horde.org>
Tue, 9 Mar 2010 23:03:08 +0000 (00:03 +0100)
kronolith/js/kronolith.js
kronolith/lib/Ajax/Application.php
kronolith/templates/chunks/calendar.php

index b0f7245..bed4af8 100644 (file)
@@ -2238,7 +2238,7 @@ KronolithCore = {
         }
 
         if (newCalendar || info.owner) {
-            this.doAction('listTopTags', {tagclass: 'kronolithCalendarTag'}, this.topTagsCallback);
+            this.doAction('listTopTags', null, this.topTagsCallback.curry('kronolithCalendarinternalTopTags', 'kronolithCalendarTag'));
             form.down('.kronolithColorPicker').show();
             if (type == 'internal') {
                 form.down('.kronolithCalendarSubscribe').hide();
@@ -2259,7 +2259,7 @@ KronolithCore = {
             }
         } else {
             form.disable();
-            this.doAction('listTopTags', {tagclass: 'kronolithTagDisable'}, this.topTagsCallback);
+            this.doAction('listTopTags', null, this.topTagsCallback.curry('kronolithCalendarTag', 'kronolithTagDisable'));
             form.down('.kronolithColorPicker').hide();
             form.down('.kronolithCalendarDelete').hide();
             form.down('.kronolithCalendarSave').hide();
@@ -3814,7 +3814,7 @@ KronolithCore = {
         $('kronolithEventSave').show();
         $('kronolithEventDelete').show();
         $('kronolithEventForm').down('.kronolithFormActions .kronolithSeparator').show();
-        this.doAction('listTopTags', {tagclass: 'kronolithEventTag'}, this.topTagsCallback);
+        this.doAction('listTopTags', null, this.topTagsCallback.curry('kronolithEventTopTags', 'kronolithEventTag'));
         if (id) {
             RedBox.loading();
             this.doAction('getEvent', { cal: calendar, id: id, date: date }, this.editEventCallback.bind(this));
@@ -3903,19 +3903,18 @@ KronolithCore = {
                       }.bind(this));
     },
 
-    topTagsCallback: function(r)
+    topTagsCallback: function(update, tagclass, r)
     {
-        var update = (r.response.tagclass == 'kronolithEventTag') ? 'kronolithEventTopTags' : 'kronolithCalendarinternalTopTags';
         if (!r.response.tags) {
             $(update).update();
             return;
         }
-        t = new Element('div');
+
+        var t = new Element('div');
         r.response.tags.each(function(tag) {
-            t.insert(new Element('span', { className: r.response.tagclass }).update(tag.escapeHTML()));
+            t.insert(new Element('span', { className: tagclass }).update(tag.escapeHTML()));
         });
         $(update).update(t);
-        return;
     },
 
     /**
index 072d759..987030a 100644 (file)
@@ -412,8 +412,6 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
 
     /**
      * Generate a list of most frequently used tags for the current user.
-     * Takes a 'tagclass' parameter that gets passed back to indicate what element
-     * to update.
      */
     public function listTopTags()
     {
@@ -421,7 +419,6 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
         $tagger = new Kronolith_Tagger();
         $result = new stdClass;
         $result->tags = array();
-        $result->tagclass = $this->_vars->tagclass;
         $tags = $tagger->getCloud(Horde_Auth::getAuth(), 10);
         foreach ($tags as $tag) {
             $result->tags[] = $tag['tag_name'];
index 1fe9624..6151df7 100644 (file)
@@ -439,10 +439,11 @@ tbd
 
 </div>
 <?php
-$ctac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'),
-                                  array('triggerId' => 'kronolithCalendarinternalTags',
-                                        'triggerContainer' => 'kronolithACCalendarTriggerContainer',
-                                        'box' => 'kronolithCalendarinternalACBox',
-                                        'pretty' => true,
-                                        'no_onload' => true));
-$ctac->attach();
+Horde_Ajax_Imple::factory(
+    array('kronolith', 'TagAutoCompleter'),
+    array('triggerId' => 'kronolithCalendarinternalTags',
+          'triggerContainer' => 'kronolithACCalendarTriggerContainer',
+          'box' => 'kronolithCalendarinternalACBox',
+          'pretty' => true,
+          'no_onload' => true))
+    ->attach();