Merging changes from Nighthawk - visual tweak to post manager
authorDan
Sat, 15 Mar 2008 15:21:47 -0400
changeset 5 172544257e2c
parent 4 f50742368f90
child 6 c51809bdf6af
Merging changes from Nighthawk - visual tweak to post manager
plugins/nuggie/client/usercp.js
plugins/nuggie/usercp.php
--- a/plugins/nuggie/client/usercp.js	Sat Mar 15 15:19:42 2008 -0400
+++ b/plugins/nuggie/client/usercp.js	Sat Mar 15 15:21:47 2008 -0400
@@ -35,7 +35,7 @@
             }
             var fader = new Spry.Effect.Highlight(row, {to:'#AA0000', duration: 750});
             fader.start();
-            setTimeout('_global_ng_row.parentNode.removeChild(_global_ng_row);', 750);
+            setTimeout('_global_ng_row.parentNode.removeChild(_global_ng_row); nuggie_check_postlist_empty();', 750);
           }
           else
           {
@@ -51,6 +51,21 @@
   }
 }
 
+function nuggie_check_postlist_empty()
+{
+  if ( document.getElementById('nuggie_postlist').childNodes.length == 1 )
+  {
+    var td = document.createElement('td');
+    td.className = 'row3';
+    td.setAttribute('colspan', '6');
+    td.appendChild(document.createTextNode('No posts.'));
+    td.style.textAlign = 'center';
+    var tr = document.createElement('tr');
+    tr.appendChild(td);
+    document.getElementById('nuggie_postlist').appendChild(tr);
+  }
+}
+
 function ajaxNuggieTogglePublished(id, obj)
 {
   var published = obj.getAttribute('nuggie:published') == '1' ? true : false;
--- a/plugins/nuggie/usercp.php	Sat Mar 15 15:19:42 2008 -0400
+++ b/plugins/nuggie/usercp.php	Sat Mar 15 15:21:47 2008 -0400
@@ -436,7 +436,7 @@
         $db->_die();
       
       echo '<div class="tblholder">
-              <table border="0" cellspacing="1" cellpadding="4">';
+              <table border="0" cellspacing="1" cellpadding="4" id="nuggie_postlist">';
               
       echo '<tr>
               <th style="width: 1px;">#</th>
@@ -446,20 +446,27 @@
               <th colspan="2"></th>
             </tr>';
       
-      while ( $row = $db->fetchrow() )
+      if ( $row = $db->fetchrow() )
       {
-        echo '<tr>';
-        
-        $uri = makeUrlNS('Blog', $session->username . date('/Y/n/j/', $row['post_timestamp']) . $row['post_title_clean'], false, true);
-        
-        echo '<td class="row2" style="text-align: center;">' . $row['post_id'] . '</td>';
-        echo '<td class="row1">' . "<a href=\"$uri\">" . htmlspecialchars($row['post_title']) . '</a></td>';
-        $cls = ( $row['post_published'] == 1 ) ? 'row3_green' : 'row3_red';
-        echo '<td class="' . $cls . ' nuggie_publishbtn" onclick="ajaxNuggieTogglePublished(' . $row['post_id'] . ', this);" nuggie:published="' . $row['post_published'] . '" style="text-align: center;">' . ( ( $row['post_published'] == 1 ) ? '<b>Yes</b>' : 'No' ) . '</td>';
-        echo '<td class="row3" style="white-space: nowrap;">' . ( function_exists('enano_date') ? enano_date('Y-m-d', $row['post_timestamp']) : date('Y-m-d h:i', $row['post_timestamp']) ) . '</td>';
-        echo '<td class="row1" style="white-space: nowrap;"><button class="nuggie_edit" name="action" value="edit;id=' . $row['post_id'] . '">Edit</button> <button class="nuggie_delete" name="action" onclick="return ajaxNuggieDeletePost(' . $row['post_id'] . ', this.parentNode.parentNode);" value="delete;id=' . $row['post_id'] . '">Delete</button></td>';
-        
-        echo '</tr>';
+        do
+        {
+          echo '<tr>';
+          
+          $uri = makeUrlNS('Blog', $session->username . date('/Y/n/j/', $row['post_timestamp']) . $row['post_title_clean'], false, true);
+          
+          echo '<td class="row2" style="text-align: center;">' . $row['post_id'] . '</td>';
+          echo '<td class="row1">' . "<a href=\"$uri\">" . htmlspecialchars($row['post_title']) . '</a></td>';
+          $cls = ( $row['post_published'] == 1 ) ? 'row3_green' : 'row3_red';
+          echo '<td class="' . $cls . ' nuggie_publishbtn" onclick="ajaxNuggieTogglePublished(' . $row['post_id'] . ', this);" nuggie:published="' . $row['post_published'] . '" style="text-align: center;">' . ( ( $row['post_published'] == 1 ) ? '<b>Yes</b>' : 'No' ) . '</td>';
+          echo '<td class="row3" style="white-space: nowrap;">' . ( function_exists('enano_date') ? enano_date('Y-m-d', $row['post_timestamp']) : date('Y-m-d h:i', $row['post_timestamp']) ) . '</td>';
+          echo '<td class="row1" style="white-space: nowrap;"><button class="nuggie_edit" name="action" value="edit;id=' . $row['post_id'] . '">Edit</button> <button class="nuggie_delete" name="action" onclick="return ajaxNuggieDeletePost(' . $row['post_id'] . ', this.parentNode.parentNode);" value="delete;id=' . $row['post_id'] . '">Delete</button></td>';
+          
+          echo '</tr>';
+        } while ( $row = $db->fetchrow() );
+      }
+      else
+      {
+        echo '<tr><td class="row3" colspan="6" style="text-align: center;">No posts.</td></tr>';
       }
       
       echo '  </table>