[Bedework-commit] carddav r180 - trunk/clients/javascript/bwAddrbookClient/resources

svnadmin at bedework.org svnadmin at bedework.org
Tue Oct 26 22:58:38 EDT 2010


Author: johnsa
Date: 2010-10-26 22:58:38 -0400 (Tue, 26 Oct 2010)
New Revision: 180

Modified:
   trunk/clients/javascript/bwAddrbookClient/resources/addressbook.css
   trunk/clients/javascript/bwAddrbookClient/resources/addressbook.js
Log:
javascript client: make groups appear in menu tree

Modified: trunk/clients/javascript/bwAddrbookClient/resources/addressbook.css
===================================================================
--- trunk/clients/javascript/bwAddrbookClient/resources/addressbook.css	2010-10-27 02:09:40 UTC (rev 179)
+++ trunk/clients/javascript/bwAddrbookClient/resources/addressbook.css	2010-10-27 02:58:38 UTC (rev 180)
@@ -63,6 +63,8 @@
 li.empty {
 	list-style: none !important;
 }
+ul.books li.group,
+ul.subscriptions li.group,
 ul.groups li,
 li.group {
   list-style-image: url("icons/silk/group.png");

Modified: trunk/clients/javascript/bwAddrbookClient/resources/addressbook.js
===================================================================
--- trunk/clients/javascript/bwAddrbookClient/resources/addressbook.js	2010-10-27 02:09:40 UTC (rev 179)
+++ trunk/clients/javascript/bwAddrbookClient/resources/addressbook.js	2010-10-27 02:58:38 UTC (rev 180)
@@ -36,6 +36,7 @@
   this.creating = true; // are we creating or editing an item?
   this.book; // the currently selected book
   this.card; // the currently selected card
+  this.groupMenus = new Array(); // a place to store groups when building menus
   
   this.init = function(bookTemplate,userid) {
     bwAddressBook.books = bookTemplate;
@@ -103,7 +104,10 @@
       switch(book.type) {
         case "personal-default" :
           // this is the default book; mark it as such.  We will replace the title with the user's id
-          personalBooks += '<li class="bwBook defaultUserBook" id="' + bookId + '"><a href="#" class="selected">' + bwAddressBook.userid + '</a></li>';
+          personalBooks += '<li class="bwBook defaultUserBook" id="' + bookId + '">';
+          personalBooks += '<a href="#" class="selected">' + bwAddressBook.userid + '</a>';
+          personalBooks += '<ul class="bwGroups"></ul>';
+          personalBooks += '</li>';
           break;
         case "personal" :
           personalBooks += '<li class="bwBook" id="' + bookId + '"><a href="#">' + book.label + '</a></li>';
@@ -132,6 +136,11 @@
     $("#bwBooks").html(personalBooks);
     $("#bwSubscriptions").html(subscriptions);
     
+    // got groups? put them with the correct books
+    for (var j=0; j<this.groupMenus.length; j++) {
+      $("#bwBook-" + j + " ul").html(this.groupMenus[j]);
+    }
+    
     $(".defaultUserBook").droppable({ 
       accept: '#bwAddrBookOutputList td.name',  
       drop:   function () { 
@@ -145,7 +154,8 @@
   this.buildList = function(bookIndex) {
     var book = new Array();
     var index = bookIndex;
-    var listing = "";
+    var listing = ""; // for tabular listing
+    var groups = ""; // for listing of groups in the menu
     
     // select the current book
     book = bwAddressBook.books[index];
@@ -244,7 +254,7 @@
           url = curCard.URL[0].value; 
         }
         
-        listing += '<tr id="bwBookRow-' + index + '-' + i + '">'
+        listing += '<tr id="bwBookRow-' + index + '-' + i + '">';
         if (book.listDisp.name) {
           listing += '<td class="name"><img src="' + kindIcon + '" width="16" height="16" alt="' + kind + '"/>' + fn + '</td>';
         }
@@ -270,10 +280,19 @@
           listing += '<td><a href="' + url + '">' + url + '</a></td>';
         }
         listing += "</tr>"
+          
+        // if we have a group, we need to add it to the groups list that belongs in the menu tree
+        if (kind == "group") {
+          groups += '<li id="bwBookGroup-' + index + '-' + i + '" class="group">' + fn + '</li>';
+        }
+          
       }
     }
     listing += "</tbody></table>"
       
+    // write the groups to an array for later use building the menus
+    this.groupMenus[index] = groups;
+      
     // add the output to the page
     $("#bwAddrBookOutputList").append(listing);
     



More information about the Bedework-commit mailing list