Browse Source

if we have javascript available, use that to toggle more/less links. This is
faster (instantaneous) and saves a full reload of the page on the server. If
no JS keep old behaviour.

Thijs Kinkhorst 17 years ago
parent
commit
c8503fccd3

+ 7 - 0
templates/default/css/default.css

@@ -1078,3 +1078,10 @@ div.viewText td.spacer {
     padding: 1em;
     padding: 1em;
     font-size: x-large;
     font-size: x-large;
 }
 }
+
+#recpt_tail_to, #recpt_tail_cc {
+    display: none;
+}
+#toggle_to, #toggle_cc {
+    font-size: smaller;
+}

+ 14 - 0
templates/default/js/default.js

@@ -289,3 +289,17 @@ function printThis()
     parent.frames['right'].focus();
     parent.frames['right'].focus();
     parent.frames['right'].print();
     parent.frames['right'].print();
 }
 }
+
+/* JS implementation of more/less links in To/CC. Could later be extended
+ * show/hide other interface items */
+function showhide (item, txtmore, txtless) {
+    var oTemp=document.getElementById("recpt_tail_" + item);
+    var oClick=document.getElementById("toggle_" + item);
+    if (oTemp.style.display=="inline") {
+        oTemp.style.display="none";
+        oClick.innerHTML=txtmore;
+    } else {
+        oTemp.style.display="inline";
+        oClick.innerHTML=txtless;
+    }
+}

+ 17 - 9
templates/default/read_recipient_list.tpl

@@ -31,25 +31,33 @@ extract($t);
 
 
 /** Begin template **/
 /** Begin template **/
 $count = 0;
 $count = 0;
+echo "<span class=\"recpt_head\">";
+
 foreach ($recipients as $r) {
 foreach ($recipients as $r) {
     $count++;
     $count++;
-    if ($count > 3 && !$show_more)
-        continue;
+
     echo $r['Full'];
     echo $r['Full'];
     if ($count != count($recipients)) {
     if ($count != count($recipients)) {
         echo ", \n   ";
         echo ", \n   ";
     }
     }
+    if (!$show_more && $count == 3) {
+        echo "</span><span id=\"recpt_tail_" . $which_field . "\">";
+    }
 }
 }
+echo "</span>\n";
+
 
 
 if (count($recipients) > 3) {
 if (count($recipients) > 3) {
-    if ($show_more) {
-        ?>
-&nbsp;<small>(<a href="<?php echo $more_less_toggle_href; ?>"><?php echo _("less"); ?></a>)</small>
-        <?php
+    if ( checkForJavascript() ) {
+        $url = "javascript:void(0)";
+        $onclick = ' onclick="showhide(\'' . $which_field . "','" . _("more") . "','" . _("less") . "')\"";
     } else {
     } else {
-        ?>
-&nbsp;<small>(<a href="<?php echo $more_less_toggle_href; ?>"><?php echo _("more"); ?></a>)</small>
-        <?php
+        $url = $more_less_toggle_href;
+        $onlclick = '';
     }
     }
+
+    echo "&nbsp;(<a href=\"" . $url . "\"" . $onclick . " id=\"toggle_" . $which_field . "\">" .
+        ($show_more ? _("less") : _("more") ) .
+        "</a>)";
 }
 }