]> code.citadel.org Git - citadel.git/blobdiff - webcit/static/wclib.js
* restore context menu in online user list
[citadel.git] / webcit / static / wclib.js
index 61f4b929cc8751410ff1cd6d9915c0b93a43e3a0..6566a1985621000c94dce9b496e7790964c36e6d 100644 (file)
@@ -27,6 +27,7 @@ if (window.navigator.userAgent.toLowerCase().match("gecko")) {
 var ns6=document.getElementById&&!document.all;
 Event.observe(window, 'load', ToggleTaskDateOrNoDateActivate);
 Event.observe(window, 'load', taskViewActivate);
+Event.observe(window, 'load', fixbanner);
 //document.observe("dom:loaded", setupPrefEngine);
 document.observe("dom:loaded", setupIconBar);
 document.observe('dom:loaded', function() { if (!!document.getElementById("ib_chat_launch")) { $('ib_chat_launch').observe('click', launchChat); } });
@@ -131,6 +132,8 @@ function setupIconBar() {
   if (!document.getElementById("switch")) {
       return;
     }
+  _switchToRoomList = getTextContent(document.getElementById("rmlist_template"));
+  _switchToMenu = getTextContent(document.getElementById("mnlist_template"));
   var switchSpan = document.getElementById("switch").firstChild;
   if (switchSpan != null) {
     setTextContent(switchSpan, _switchToRoomList);
@@ -144,8 +147,7 @@ function setupIconBar() {
     }
   }
   var online_users = document.getElementById("online_users");
-  var ou_displayAs = online_users.style.display;
-  if (ou_displayAs != "none") {
+  if (online_users.offsetParent != null && online_users.offsetTop > 0) {
     new Ajax.PeriodicalUpdater('online_users', 'do_template?template=wholist_section', {method: 'get', frequency: 30});
   }
 }
@@ -154,9 +156,7 @@ function changeIconBarEvent(event) {
 }
 function changeIconBar(target) {
   var switchTo = target.ctdlSwitchIconBarTo;
-  if (!!window.console) {
-    console.log("Changing to: " + switchTo);
-  }
+  WCLog("Changing to: " + switchTo);
   ctdlLocalPrefs.setPref("iconbar_view", target.ctdlSwitchIconBarTo);  
   if (switchTo == "rooms") {
     switch_to_room_list();
@@ -198,7 +198,8 @@ function IconBarRoomList() {
   var mailboxLI = document.createElement("li");
   ul.appendChild(mailboxLI);
   var mailboxSPAN = document.createElement("span");
-  mailboxSPAN.appendChild(document.createTextNode("Mailbox"));
+  var _mailbox = getTextContent(document.getElementById("mbox_template"));
+  mailboxSPAN.appendChild(document.createTextNode(_mailbox));
   $(mailboxSPAN).observe('click', expandFloorEvent);
   mailboxLI.appendChild(mailboxSPAN);
   mailboxLI.setAttribute("class", "floor");
@@ -677,9 +678,6 @@ function eventEditAllDay() {
        }
 }
 
-
-
-
 // Functions which handle show/hide of various elements in the recurrence editor
 
 function RecurrenceShowHide() {
@@ -760,3 +758,52 @@ function RecurrenceShowHide() {
 function launchChat(event) {
 window.open('chat', 'ctdl_chat_window', 'toolbar=no,location=no,directories=no,copyhistory=no,status=no,scrollbars=yes,resizable=yes');
 }
+// logger
+function WCLog(msg) {
+  if (!!window.console && !!console.log) {
+    console.log(msg);
+  } else if (!!window.opera && !!opera.postError) {
+    opera.postError(msg);
+  }
+}
+
+function fixMissingCSSTable(elems) {
+ if (elems[0] == null || elems[1] == null) {
+    return;
+  }
+  if (elems[0].getStyle("display") != "table-cell") {
+    var parentNode = elems[0].parentNode;
+    var table = document.createElement("table");
+    table.style.width = "100%";
+    var tbody = document.createElement("tbody");
+    table.appendChild(tbody);
+    var tr = document.createElement("tr");
+    tbody.appendChild(tr);
+    parentNode.appendChild(table);
+    for(var i=0; i<elems.length; i++) {
+      parentNode.removeChild(elems[i]);
+      var td = document.createElement("td");
+      td.appendChild(elems[i]);
+      tr.appendChild(td);
+    }
+  }
+}
+function fixbanner() {
+  // Use prototype api methods here
+  var elems = [$('room_banner'),$('actiondiv')];
+  fixMissingCSSTable(elems);
+  var banner = $('banner'); 
+  if (banner != null) {
+  }
+}
+
+function fixOffsetBanner() {
+  var banner = document.getElementById("banner");
+  if (banner.offsetLeft > 0) {
+    var viewportWidth = document.viewport.getWidth();
+    var iconbarWidth = document.getElementById("iconbar").offsetWidth;
+    var contentDiv = document.getElementById("content");
+    var newContentWidth = viewportWidth-iconbarWidth;
+    contentDiv.style.width = newContentWidth+"px";
+  }
+}