Address book popup is now rendered using an ajax refresh
authorArt Cancro <ajc@citadel.org>
Fri, 13 Apr 2007 21:55:30 +0000 (21:55 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 13 Apr 2007 21:55:30 +0000 (21:55 +0000)
when it is called up, eliminating the need to render it even
when it has not been requested.

webcit/addressbook_popup.c
webcit/messages.c
webcit/static/wclib.js
webcit/static/webcit.css
webcit/webcit.c
webcit/webcit.h

index 5d90844dd49ea1a4a04d5c00f7abc8332589686c..6d479b3f0e9f03ed669ee8cdb089da85bc07672a 100644 (file)
@@ -8,6 +8,46 @@
 /*@{*/
 #include "webcit.h"
 
+
+/**
+ * \brief Address book popup window
+ */
+void display_address_book_middle_div(void) {
+       char buf[256];
+       char ebuf[256];
+
+       begin_ajax_response();
+
+       wprintf("<table border=0 width=100%%><tr valign=middle>");
+       wprintf("<td align=left><img src=\"static/viewcontacts_32x.gif\"></td>");
+       wprintf("<td align=center>");
+
+       wprintf("<form><select class=\"address_book_popup_title\" size=1>");
+       serv_puts("LKRA");
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+               if (extract_int(buf, 6) == VIEW_ADDRESSBOOK) {
+                       extract_token(ebuf, buf, 0, '|', sizeof ebuf);
+                       wprintf("<option value=\"");
+                       urlescputs(ebuf);
+                       wprintf("\">");
+                       escputs(ebuf);
+                       wprintf("</option>\n");
+               }
+       }
+       wprintf("</select></form>");
+
+       wprintf("</td>");
+       wprintf("<td align=right "
+               "onclick=\"javascript:$('address_book_popup').style.display='none';\" "
+               "><img src=\"static/closewindow.gif\">");
+       wprintf("</td></tr></table>");
+
+       end_ajax_response();
+}
+
+
+
 /**
  * \brief Address book popup results
  */
index b481a979fea5b376727b144f96711ed37854199f..4a4b116e8ccee55557056c37309a3681007346c4 100644 (file)
@@ -3203,42 +3203,20 @@ void display_enter(void)
        }
 
        wprintf("</form>\n");
-
        wprintf("</td></tr></table></div>\n");
 
-       /* Close the main div, now open a new one, hidden initially, for address book popups.
-        * Remember: the final div will be closed by wDumpContent, which will think it's merely
-        * closing the main div.  FIXME put this in its own function so we can use it from the
+       wprintf("</div>\n");    /* End of 'content' div */
+
+       /* Open a new div, hidden initially, for address book popups.
+        * FIXME put this in its own function so we can use it from the
         * calendar too.
         */
-       wprintf("</div><div id=\"address_book_popup\" style=\"display:none;\">");
-       wprintf("<div id=\"address_book_popup_middle_div\">");
-       wprintf("<table border=0 width=100%%><tr valign=middle>");
-       wprintf("<td align=left><img src=\"static/viewcontacts_32x.gif\"></td>");
-       wprintf("<td align=center>");
-
-       wprintf("<form><select class=\"address_book_popup_title\" size=1>");
-       serv_puts("LKRA");
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-               if (extract_int(buf, 6) == VIEW_ADDRESSBOOK) {
-                       extract_token(ebuf, buf, 0, '|', sizeof ebuf);
-                       wprintf("<option value=\"");
-                       urlescputs(ebuf);
-                       wprintf("\">");
-                       escputs(ebuf);
-                       wprintf("</option>\n");
-               }
-       }
-       wprintf("</select></form>");
-
-       wprintf("</td>");
-       wprintf("<td align=right "
-               "onclick=\"javascript:$('address_book_popup').style.display='none';\" "
-               "><img src=\"static/closewindow.gif\">");
-       wprintf("</td></tr></table>");
+       wprintf("<div id=\"address_book_popup\" style=\"display:none;\">");
+       wprintf("<div id=\"address_book_popup_container_div\">");
+       wprintf("<div id=\"address_book_popup_middle_div\"></div>");
        wprintf("<div id=\"address_book_inner_div\"></div>");
        wprintf("</div>");
+       /* The 'address_book_popup' div will be closed by wDumpContent() */
 DONE:  wDumpContent(1);
 }
 
index 11156a33f27fcae766d8b94e848aa8ed1ca0c127..a93f357dadf57769f7a512ec5cd1f1667128b95c 100644 (file)
@@ -660,9 +660,21 @@ function CtdlShowUserInfoPopup(Element) {
 
 // Pop open the address book
 function PopOpenAddressBook() {
-       $('address_book_inner_div').innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\">&nbsp;&nbsp;Loading....</font></td></tr></table><br /></div>";
        $('address_book_popup').style.display = 'block';
-       Nifty('div#address_book_popup_middle_div','big transparent');
+       new Ajax.Updater(
+               'address_book_popup_middle_div',
+               'display_address_book_middle_div',
+               {
+                       method: 'get',
+                       parameters: Math.random(),
+                       onComplete: PopulateAddressBookInnerDiv()
+               }
+       );
+       Nifty('div#address_book_popup_container_div','big transparent');
+}
+
+function PopulateAddressBookInnerDiv() {
+       $('address_book_inner_div').innerHTML = "<div align=center><br><table border=0 cellpadding=10 bgcolor=\"#ffffff\"><tr><td><img src=\"static/throbber.gif\" /><font color=\"#AAAAAA\">&nbsp;&nbsp;Loading....</font></td></tr></table><br /></div>";
        new Ajax.Updater(
                'address_book_inner_div',
                'display_address_book_inner_div',
index c18ef59973979aa45a4fe6bc8782ae2a5432d278..8247a1549445570eb14711ad530d6cc7a547ab14 100644 (file)
@@ -870,13 +870,18 @@ div.auto_complete ul strong.highlight {
        display: none;
 }
 
-#address_book_popup_middle_div {
+#address_book_popup_container_div {
        position: relative;
        width: 100%;
        height: 100%;
        background-color: #ffd;
 }
 
+#address_book_popup_middle_div {
+       position: relative;
+       background-color: #ffd;
+}
+
 #address_book_inner_div {
        margin: 5px;
 }
index ab21eaab8d9eecf51c635b02c3e1e8e87bb95fa3..6ffb08a75662ef42af383bc42148a298bce89d7c 100644 (file)
@@ -1637,6 +1637,8 @@ void session_loop(struct httprequest *req)
                recp_autocomplete(bstr("cc"));
        } else if (!strcasecmp(action, "bcc_autocomplete")) {
                recp_autocomplete(bstr("bcc"));
+       } else if (!strcasecmp(action, "display_address_book_middle_div")) {
+               display_address_book_middle_div();
        } else if (!strcasecmp(action, "display_address_book_inner_div")) {
                display_address_book_inner_div();
        } else if (!strcasecmp(action, "set_floordiv_expanded")) {
index 446c00ef1d0b0c7cccfc57835e5b9db8601a2342..f390de2ba93586f1446593cb07c33948e76df889 100644 (file)
@@ -638,6 +638,7 @@ void CtdlMakeTempFileName(char *, int);
 void display_preferences(void);
 void set_preferences(void);
 void recp_autocomplete(char *);
+void display_address_book_middle_div(void);
 void display_address_book_inner_div(void);
 void begin_ajax_response(void);
 void end_ajax_response(void);