Initial HTML/JS work for expandable roomlist
authorArt Cancro <ajc@uncensored.citadel.org>
Fri, 13 May 2011 19:02:24 +0000 (15:02 -0400)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 20:33:10 +0000 (20:33 +0000)
webcit/iconbar.c
webcit/static/t/iconbar.html
webcit/static/wclib.js

index 60e421bd34fe635d4f4699b7e1de2d7d7893f95c..bdcadfb1caa6552da0721cab02e3ce3abecfa192 100644 (file)
@@ -276,6 +276,23 @@ int ConditionalRoomlistExpanded(StrBuf *Target, WCTemplputParams *TP)
 
 
 
+/*
+ * Toggle the roomlist expanded state in session memory
+ */
+void toggle_roomlist_expanded_state(void) {
+       wcsession *WCC = WC;
+
+       if (!WCC) {
+               wc_printf("no session");
+               return;
+       }
+
+       WCC->ib_roomlist_expanded = IBSTR("wstate");
+       wc_printf("%d", WCC->ib_roomlist_expanded);
+       syslog(LOG_DEBUG, "ib_roomlist_expanded set to %d", WCC->ib_roomlist_expanded);
+}
+
+
 /*
  * Toggle the wholist expanded state in session memory
  */
@@ -302,6 +319,7 @@ InitModule_ICONBAR
        /*WebcitAddUrlHandler(HKEY("user_iconbar"), "", 0, doUserIconStylesheet, 0); */
        WebcitAddUrlHandler(HKEY("commit_iconbar"), "", 0, commit_iconbar, 0);
        WebcitAddUrlHandler(HKEY("toggle_wholist_expanded_state"), "", 0, toggle_wholist_expanded_state, AJAX);
+       WebcitAddUrlHandler(HKEY("toggle_roomlist_expanded_state"), "", 0, toggle_roomlist_expanded_state, AJAX);
        RegisterConditional(HKEY("COND:ICONBAR:ACTIVE"), 3, ConditionalIsActiveStylesheet, CTX_NONE);
        RegisterNamespace("ICONBAR", 0, 0, tmplput_iconbar, NULL, CTX_NONE);
        RegisterConditional(HKEY("COND:ICONBAR:WHOLISTEXPANDED"), 0, ConditionalWholistExpanded, CTX_NONE);
index bc4c2952b15598fa993872ecc5e29ca17b3685a5..dab08c6836e946d8d4747a03378878c47856c090 100644 (file)
@@ -6,8 +6,6 @@
   <div class="iconbar_text">
     <?_("Language:")><?LANG:SELECT>
   </div>
-  <div id="switch" class="iconbar_text"><span></span></div>
-  <div id="roomlist"></div>
   <div id="iconbar_menu">
 <ul id="button">
 <li id="ib_summary" class="ib_button">
 <??("X",3)>
 <li id="ib_rooms" class="ib_button">
 <a class="ib_button_link" href="knrooms?template=knrooms?SortBy=byfloorroom?SortOrder=1" title="<?_("List all your accessible rooms")>">
-<img src="static/expand.gif" onClick="alert('Please do not click this button again.'); return false;">
+<img id="expand_roomlist"
+src=<?%("COND:ICONBAR:ROOMLISTEXPANDED", 1, 1, 1, "static/collapse.gif", "static/expand.gif")>
+onClick="return toggle_roomlist();">
 <span><?_("Rooms")></span>
 </a>
+<div id="roomlist">
+<?_("Loading")>
+</div>
 </li>
 <li id="ib_users" class="ib_button">
 <a class="ib_button_link" href="do_template?template=who" title="<?_("See who is online right now")>">
index cf409d363c7a352599cdd6935f847f66c971902c..2d15e7e19417045548b926a2d3e45495f79a3e90 100644 (file)
@@ -910,6 +910,30 @@ function switch_to_lang(new_lang) {
 }
 
 
+function toggle_roomlist() 
+{
+       /* WARNING: VILE, SLEAZY HACK.  We determine the state of the box based on the image loaded. */
+       if ( $('expand_roomlist').src.substring($('expand_roomlist').src.length - 12) == "collapse.gif" ) {
+               $('roomlist').style.display = 'none';
+               $('expand_roomlist').src = 'static/expand.gif';
+               wstate=0;
+       }
+
+       else {
+               $('roomlist').style.display = 'block';
+               $('expand_roomlist').src = 'static/collapse.gif';
+               /* activate_iconbar_roomlist_populat0r(); */
+               wstate=1;
+       }
+
+       // tell the server what I did
+       p = 'toggle_roomlist_expanded_state?wstate=' + wstate + '?rand=' + Math.random() ;
+       new Ajax.Request(p, { method: 'get' } );
+
+       return false;   /* this prevents the click from registering as a roomlist button press */
+}
+
+
 function toggle_wholist() 
 {
        /* WARNING: VILE, SLEAZY HACK.  We determine the state of the box based on the image loaded. */
@@ -931,5 +955,6 @@ function toggle_wholist()
        new Ajax.Request(p, { method: 'get' } );
 
        return false;   /* this prevents the click from registering as a wholist button press */
-
 }
+
+