Changes to support having more then one tag autocompleter
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 9 Mar 2010 18:50:51 +0000 (13:50 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 9 Mar 2010 18:50:51 +0000 (13:50 -0500)
Fixes tag autocompleter for calendars.

kronolith/js/kronolith.js
kronolith/lib/Ajax/Application.php
kronolith/templates/chunks/calendar.php
kronolith/themes/screen.css

index b91bf48..2d974d7 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);
+        this.doAction('listTopTags', {tagclass: 'kronolithCalendarTag'}, this.topTagsCallback);
         var form = $('kronolithCalendarForm' + type),
             firstTab = form.down('.tabset a.kronolithTabLink'),
             info;
@@ -3359,6 +3359,11 @@ KronolithCore = {
                 e.stop();
                 return;
 
+            case 'kronolithCalendarTag':
+                $('kronolithCalendarinternalTags').autocompleter.addNewItemNode(elt.getText());
+                e.stop();
+                return;
+
             case 'kronolithEventGeo':
                 this.ensureMap();
                 this.geocode($F('kronolithEventLocation'));
@@ -3791,7 +3796,7 @@ KronolithCore = {
         $('kronolithEventSave').show();
         $('kronolithEventDelete').show();
         $('kronolithEventForm').down('.kronolithFormActions .kronolithSeparator').show();
-        this.doAction('listTopTags', {update: 'kronolithEventTopTags'}, this.topTagsCallback);
+        this.doAction('listTopTags', {tagclass: 'kronolithEventTag'}, this.topTagsCallback);
         if (id) {
             RedBox.loading();
             this.doAction('getEvent', { cal: calendar, id: id, date: date }, this.editEventCallback.bind(this));
@@ -3882,15 +3887,16 @@ KronolithCore = {
 
     topTagsCallback: function(r)
     {
+        var update = (r.response.tagclass == 'kronolithEventTag') ? 'kronolithEventTopTags' : 'kronolithCalendarinternalTopTags';
         if (!r.response.tags) {
-            $(r.response.update).update();
+            $(update).update();
             return;
         }
         t = new Element('div');
         r.response.tags.each(function(tag) {
-            t.insert(new Element('span', { className: 'kronolithEventTag' }).update(tag.escapeHTML()));
+            t.insert(new Element('span', { className: r.response.tagclass }).update(tag.escapeHTML()));
         });
-        $(r.response.update).update(t);
+        $(update).update(t);
         return;
     },
 
index 1be5c05..7ad47a3 100644 (file)
@@ -412,7 +412,7 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
 
     /**
      * Generate a list of most frequently used tags for the current user.
-     * Takes a 'update' parameter that gets passed back to indicate what element
+     * Takes a 'tagclass' parameter that gets passed back to indicate what element
      * to update.
      */
     public function listTopTags()
@@ -421,7 +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;
+        $result->tagclass = $this->_vars->tagclass;
         $tags = $tagger->getCloud(Horde_Auth::getAuth(), 10);
         foreach ($tags as $tag) {
             $result->tags[] = $tag['tag_name'];
index e45ece1..1fe9624 100644 (file)
@@ -439,5 +439,10 @@ tbd
 
 </div>
 <?php
-$ctac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'kronolithCalendarinternalTags', 'box' => 'kronolithCalendarinternalACBox', 'pretty' => true, 'no_onload' => true));
+$ctac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'),
+                                  array('triggerId' => 'kronolithCalendarinternalTags',
+                                        'triggerContainer' => 'kronolithACCalendarTriggerContainer',
+                                        'box' => 'kronolithCalendarinternalACBox',
+                                        'pretty' => true,
+                                        'no_onload' => true));
 $ctac->attach();
index 96b0127..33f4ff7 100644 (file)
@@ -829,7 +829,7 @@ div.kronolithFormActions {
     margin: 0;
     height: 100%;
 }
-#kronolithEventACBox {
+#kronolithEventACBox, #kronolithCalendarinternalACBox {
     line-height: 100%;
 }