Moved getElementsByClassName to functions.js (dependency issues)
authorDan
Sat, 15 Nov 2008 18:22:13 -0500
changeset 740 098e744df928
parent 739 dd13aa042f34
child 741 a216e412c439
Moved getElementsByClassName to functions.js (dependency issues)
includes/clientside/static/functions.js
includes/clientside/static/sliders.js
--- a/includes/clientside/static/functions.js	Sat Nov 15 18:21:35 2008 -0500
+++ b/includes/clientside/static/functions.js	Sat Nov 15 18:22:13 2008 -0500
@@ -1019,6 +1019,46 @@
   return page_id;
 }
 
+/*
+    the getElementsByClassName function I pilfered from this guy.  It's
+    a useful function that'll return any/all tags with a specific css class.
+
+    Written by Jonathan Snook, http://www.snook.ca/jonathan
+    Add-ons by Robert Nyman, http://www.robertnyman.com
+    
+    Modified to match all elements that match the class name plus an integer after the name
+    This is used in Enano to allow sliding sidebar widgets that use their own CSS
+*/
+function getElementsByClassName(oElm, strTagName, strClassName)
+{
+    // first it gets all of the specified tags
+    var arrElements = (strTagName == "*" && document.all) ? document.all : oElm.getElementsByTagName(strTagName);
+    
+    // then it sets up an array that'll hold the results
+    var arrReturnElements = new Array();
+
+    // some regex stuff you don't need to worry about
+    strClassName = strClassName.replace(/\-/g, "\\-");
+
+    var oRegExp = new RegExp("(^|\\s)" + strClassName + "([0-9]*)(\\s|$)");
+    var oElement;
+    
+    // now it iterates through the elements it grabbed above
+    for(var i=0; i<arrElements.length; i++)
+    {
+        oElement = arrElements[i];
+
+        // if the class matches what we're looking for it ads to the results array
+        if(oElement.className.match(oRegExp))
+        {
+            arrReturnElements.push(oElement);
+        }
+    }
+
+    // then it kicks the results back to us
+    return (arrReturnElements)
+}
+
 /**
  * Equivalent to PHP's in_array function.
  */
--- a/includes/clientside/static/sliders.js	Sat Nov 15 18:21:35 2008 -0500
+++ b/includes/clientside/static/sliders.js	Sat Nov 15 18:22:13 2008 -0500
@@ -177,43 +177,4 @@
     }
 }
 
-/*
-    the getElementsByClassName function I pilfered from this guy.  It's
-    a useful function that'll return any/all tags with a specific css class.
 
-    Written by Jonathan Snook, http://www.snook.ca/jonathan
-    Add-ons by Robert Nyman, http://www.robertnyman.com
-    
-    Modified to match all elements that match the class name plus an integer after the name
-    This is used in Enano to allow sliding sidebar widgets that use their own CSS
-*/
-function getElementsByClassName(oElm, strTagName, strClassName)
-{
-    // first it gets all of the specified tags
-    var arrElements = (strTagName == "*" && document.all) ? document.all : oElm.getElementsByTagName(strTagName);
-    
-    // then it sets up an array that'll hold the results
-    var arrReturnElements = new Array();
-
-    // some regex stuff you don't need to worry about
-    strClassName = strClassName.replace(/\-/g, "\\-");
-
-    var oRegExp = new RegExp("(^|\\s)" + strClassName + "([0-9]*)(\\s|$)");
-    var oElement;
-    
-    // now it iterates through the elements it grabbed above
-    for(var i=0; i<arrElements.length; i++)
-    {
-        oElement = arrElements[i];
-
-        // if the class matches what we're looking for it ads to the results array
-        if(oElement.className.match(oRegExp))
-        {
-            arrReturnElements.push(oElement);
-        }
-    }
-
-    // then it kicks the results back to us
-    return (arrReturnElements)
-}
-