More work on tagging.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 31 Jan 2009 14:52:56 +0000 (09:52 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 31 Jan 2009 14:54:39 +0000 (09:54 -0500)
Better dom ids for the tagging nodes, pass the resource id to the
autocompleter so we can (eventually) filter out existing tags on
the item when presenting autocompletion choices.

kronolith/js/tagactions.js
kronolith/lib/Imple/TagActions.php
kronolith/lib/Imple/TagAutoCompleter.php
kronolith/templates/panel.inc

index 6c5cb4c..84c85bc 100755 (executable)
@@ -20,7 +20,7 @@ function removeTag(resource, type, tagid, endpoint)
 {
     var params = new Object();
     params.imple = "TagActions/action=remove/resource=" + resource + "/type=" + type + "/tags=" + tagid;
-    new Ajax.Updater({success:'tags-' + resource},
+    new Ajax.Updater({success:'tags_' + resource},
                      endpoint,
                      {
                          method: 'post',
@@ -30,9 +30,9 @@ function removeTag(resource, type, tagid, endpoint)
     return true;
 }
 
-function toggleNewTags(domid)
+function toggleTags(domid)
 {
-       $('tag-show-' + domid).toggle();
-       $('tag-hide-' + domid).toggle();
-       $('newtags-' + domid).toggle();
+       $('tag-show_' + domid).toggle();
+       $('tag-hide_' + domid).toggle();
+       $('tagnode_' + domid).toggle();
 }
\ No newline at end of file
index ea58180..619a49a 100644 (file)
@@ -104,7 +104,7 @@ class Kronolith_Imple_TagActions extends Kronolith_Imple
         }
 
         foreach ($tags as $tag_id => $tag) {
-            $html .= '<li>' .  $tag . ($hasEdit ? '<a href="#" onclick="removeTag(\'' . $id . '\', \'' . $type . '\',' . $tag_id . ', \'' . Horde::url('imple.php', true) . '\'); Event.stop(event)" id="remove' . md5($id . $tag_id) . '">' . Horde::img('delete-small.png', _("Remove Tag"), '', $GLOBALS['registry']->getImageDir('horde')) . '</a>' : '') . '</li>';
+            $html .= '<li class="panel-tags">' .  $tag . ($hasEdit ? '<a href="#" onclick="removeTag(\'' . $id . '\', \'' . $type . '\',' . $tag_id . ', \'' . Horde::url('imple.php', true) . '\'); Event.stop(event)" id="remove' . md5($id . $tag_id) . '">' . Horde::img('delete-small.png', _("Remove Tag"), '', $GLOBALS['registry']->getImageDir('horde')) . '</a>' : '') . '</li>';
         }
 
         return $html;
index 24fa07d..09e572c 100644 (file)
@@ -21,9 +21,11 @@ class Kronolith_Imple_TagAutoCompleter extends Kronolith_Imple
      */
     public function __construct($params)
     {
-        if (empty($params['triggerId'])) {
-            $params['triggerId'] = $this->_randomid();
+
+        if (!count($params)) {
+            return;
         }
+        $params['triggerId'] = $params['triggerId'] . '_' . $params['id'];
         if (empty($params['resultsId'])) {
             $params['resultsId'] = $params['triggerId'] . '_results';
         }
@@ -84,6 +86,9 @@ class Kronolith_Imple_TagAutoCompleter extends Kronolith_Imple
     {
         $tagger = new Kronolith_Tagger();
         $tags = $tagger->listTags($search);
+
+
+
         return array_values($tags);
     }
 
index f5ff4c5..c410548 100644 (file)
@@ -46,10 +46,10 @@ $tagger = new Kronolith_Tagger();
   <li><label><input type="checkbox" class="checkbox" name="display_cal[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_calendars) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($cal->get('name')) ?></label> <?php echo $info_img ?>
    <div class="panel-tags">
    <?php $tags = $tagger->getTags($id, 'calendar'); ?>
-    <span style="cursor:pointer;" id="tag-show-<?php echo $id?>" onclick="toggleNewTags('<?php echo $id?>');" title="<?php echo _("Add new tags")?>">+</span><span id="tag-hide-<?php echo $id?>" style="display:none;cursor:pointer;" onclick="toggleNewTags('<?php echo $id?>');">-</span>
-   <h5 style="display: inline;"><?php echo _("Tags")?></h5>
-   <div id="newtags-<?php echo $id?>" style="display:none;">
-        <ul id="tags-<?php echo $id?>">
+    <span style="cursor:pointer;" id="tag-show_<?php echo $id?>" onclick="toggleTags('<?php echo $id?>');" title="<?php echo _("Add new tags")?>">+</span><span id="tag-hide_<?php echo $id?>" style="display:none;cursor:pointer;" onclick="toggleTags('<?php echo $id?>');">-</span>
+    <h5 style="display: inline;"><?php echo _("Tags")?></h5>
+    <div id="tagnode_<?php echo $id?>" style="display:none;">
+      <ul id="tags_<?php echo $id?>">
         <?php foreach ($tags as $tag_id => $tag): ?>
          <li class="panel-tags"><?php echo $tag . ($cal->hasPermission(Auth::getAuth(), PERMS_EDIT) ? '<a href="#" id="remove' . md5($id . $tag_id) . '">' . Horde::img('delete-small.png', _("Remove Tag"), '', $registry->getImageDir('horde')) . '</a>' : '') . '</li>'?>
         <?php
@@ -62,11 +62,11 @@ $tagger = new Kronolith_Tagger();
        <?php endforeach;?>
       </ul>
       <div class="clear">&nbsp;</div>
-      <input type="text" name="newtags-input-<?php echo $id?>" id="newtags-input-<?php echo $id?>" size="10" /><input type="button" class="button" value="add" id="test" />
-      <div id="newtags-input-<?php echo $id?>_results" class="autocomplete"></div>
-      <span id="newtags-input-<?php echo $id?>_loading_img" style="display:none;"><?php echo Horde::img('loading.gif', _("Loading...")) ?></span>
+      <input type="text" name="newtags-input_<?php echo $id?>" id="newtags-input_<?php echo $id?>" size="10" /><input type="button" class="button" value="add" id="test" />
+      <div id="newtags-input_<?php echo $id?>_results" class="autocomplete"></div>
+      <span id="newtags-input_<?php echo $id?>_loading_img" style="display:none;"><?php echo Horde::img('loading.gif', _("Loading...")) ?></span>
      <?php
-      Kronolith_Imple::factory('TagAutoCompleter', array('triggerId' => 'newtags-input-' . $id));
+      Kronolith_Imple::factory('TagAutoCompleter', array('triggerId' => 'newtags-input', 'id' => $id));
       ?>
   </div>
   </div>