Tweak output of ajax tag actions - don't show section header if no tags etc...
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 30 Jan 2009 16:51:29 +0000 (11:51 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 31 Jan 2009 14:54:39 +0000 (09:54 -0500)
kronolith/lib/Imple/TagActions.php
kronolith/templates/panel.inc

index 89a5923..1c70151 100644 (file)
@@ -89,7 +89,6 @@ class Kronolith_Imple_TagActions extends Kronolith_Imple
     private function _getTagHtml($tagger, $id, $type)
     {
         $tags = $tagger->getTags($id, 'calendar');
-        $html = '';
         $js = '';
 
         if ($type == 'calendar') {
@@ -103,11 +102,13 @@ class Kronolith_Imple_TagActions extends Kronolith_Imple
             $hasEdit = $event->hasPermission(PERMS_EDIT, Auth::getAuth());
         }
 
+        $html = count($tags) ? '<h5>' . _("Tags") . '</h5>': '';
+        $html .= '<ul>';
         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>';
         }
 
-        return $html;
+        return $html . '</ul><div class="clear">&nbsp;</div>';
     }
 
 }
index 537063f..7a0e1cd 100644 (file)
@@ -44,10 +44,10 @@ $tagger = new Kronolith_Tagger();
  <ul id="mycalendars">
 <?php foreach ($my_calendars as $id => $cal): ?>
   <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">
+   <div class="panel-tags" id="tags-<?php echo $id?>">
    <?php $tags = $tagger->getTags($id, 'calendar'); ?>
    <h5><?php echo (count($tags) ? _("Tags") : '');?></h5>
-   <ul id="tags-<?php echo $id?>" style="margin-left: 10px;">
+   <ul style="margin-left: 10px;">
     <?php foreach ($tags as $tag_id => $tag): ?>
     <li><?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