summaryrefslogtreecommitdiffstats
path: root/js/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/util.js')
-rw-r--r--js/util.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/util.js b/js/util.js
index 8e787847a..666f2666b 100644
--- a/js/util.js
+++ b/js/util.js
@@ -253,3 +253,21 @@ function bz_fireEvent(anElement, anEvent) {
evt.initEvent(anEvent, true, true); // event type, bubbling, cancelable
return !anElement.dispatchEvent(evt);
}
+
+/**
+ * Adds a CSS class to an element if it doesn't have it. Removes the
+ * CSS class from the element if the element does have the class.
+ *
+ * Requires YUI's Dom library.
+ *
+ * @param anElement The element to toggle the class on
+ * @param aClass The name of the CSS class to toggle.
+ */
+function bz_toggleClass(anElement, aClass) {
+ if (YAHOO.util.Dom.hasClass(anElement, aClass)) {
+ YAHOO.util.Dom.removeClass(anElement, aClass);
+ }
+ else {
+ YAHOO.util.Dom.addClass(anElement, aClass);
+ }
+}