[Rt-commit] r4126 - in rt/branches/3.5-TESTING: . html/NoAuth/js

trs at bestpractical.com trs at bestpractical.com
Mon Nov 21 16:11:33 EST 2005


Author: trs
Date: Mon Nov 21 16:11:32 2005
New Revision: 4126

Modified:
   rt/branches/3.5-TESTING/   (props changed)
   rt/branches/3.5-TESTING/html/NoAuth/js/util.js
Log:
 r6501 at wintermute:  tom | 2005-11-21 16:10:38 -0500
 Better compat. at the suggestion of Jesse


Modified: rt/branches/3.5-TESTING/html/NoAuth/js/util.js
==============================================================================
--- rt/branches/3.5-TESTING/html/NoAuth/js/util.js	(original)
+++ rt/branches/3.5-TESTING/html/NoAuth/js/util.js	Mon Nov 21 16:11:32 2005
@@ -1,9 +1,23 @@
-function e(id) {
-    return document.getElementById(id);
+// Stolen from Prototype
+function $() {
+  var elements = new Array();
+
+  for (var i = 0; i < arguments.length; i++) {
+    var element = arguments[i];
+    if (typeof element == 'string')
+      element = $(element);
+
+    if (arguments.length == 1)
+      return element;
+
+    elements.push(element);
+  }
+
+  return elements;
 }
 
 function rollup(id) {
-    var e   = document.getElementById(id);
+    var e   = $(id);
     var e2  = e.parentNode;
     
     if (e.className.match(/\bhidden\b/)) {
@@ -34,7 +48,7 @@
 }
 
 function hideshow(id) {
-    var e = document.getElementById(id);
+    var e = $(id);
     
     if (e.className.match(/\bhidden\b/))
         show(e);
@@ -57,16 +71,16 @@
 
 function switchVisibility(id1, id2) {
     // Show both and then hide the one we want
-    show(document.getElementById(id1));
-    show(document.getElementById(id2));
+    show($(id1));
+    show($(id2));
     
-    hide(document.getElementById(id2));
+    hide($(id2));
     
     return false;
 }
 
 function focusElementById(id) {
-    var e = document.getElementById(id);
+    var e = $(id);
     if (e) e.focus();
 }
 
@@ -79,7 +93,7 @@
 
 function updateParentField(field, value) {
     if (window.opener) {
-        window.opener.document.getElementById(field).value = value;
+        window.opener.$(field).value = value;
         window.close();
     }
 }
@@ -96,7 +110,7 @@
 }
 
 function createCalendarLink(input) {
-    var e = document.getElementById(input);
+    var e = $(input);
     if (e) {
         var link = document.createElement('a');
         link.setAttribute('href', '#');


More information about the Rt-commit mailing list