Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated nonsensical variable name.

  • Loading branch information...
commit fdb565ee58f42e423f8633e2cc4d356a768f20ca 1 parent 8c15ec1
Erik Vorhes authored April 03, 2012

Showing 1 changed file with 19 additions and 4 deletions. Show diff stats Hide diff stats

  1. 23  utility-belt.js
23  utility-belt.js
@@ -4,7 +4,7 @@
4 4
     var Utility,
5 5
         _supportsGetElementsByClassName,
6 6
         _supportsQuerySelectorAll,
7  
-        _supportsUseClassList,
  7
+        _supportsClassList,
8 8
         _supportsAddEventListener,
9 9
         _supportsAttachEvent,
10 10
         _DOMContentLoaded,
@@ -12,7 +12,7 @@
12 12
     
13 13
     _supportsGetElementsByClassName = !!doc.getElementsByClassName;
14 14
     _supportsQuerySelectorAll = !!doc.querySelectorAll;
15  
-    _supportsUseClassList = (function _supportsUseClassList() {
  15
+    _supportsClassList = (function _supportsClassList() {
16 16
         var div = document.createElement("div");
17 17
         return !!div.classList;
18 18
     }());
@@ -40,7 +40,7 @@
40 40
         
41 41
         // Add a class name to el.className:
42 42
         self.addClass = function addClass(cls, el) {
43  
-            if (_supportsUseClassList) {
  43
+            if (_supportsClassList) {
44 44
                 el.classList.add(cls);
45 45
             } else {
46 46
                 el.className += (" " + cls);
@@ -50,7 +50,7 @@
50 50
         // Remove a class name from el.className:
51 51
         self.removeClass = function removeClass(cls, el) {
52 52
             var rc;
53  
-            if (_supportsUseClassList) {
  53
+            if (_supportsClassList) {
54 54
                 el.classList.remove(cls);
55 55
             } else {
56 56
                 rc = self.filterClass(cls);
@@ -95,6 +95,21 @@
95 95
             }
96 96
         };
97 97
         
  98
+        // Wrapper for event delegation:
  99
+        self.delegate = function delegate(node, ev, targetEl, elFilter, func) {
  100
+            var funcCall,
  101
+                filter = elFilter || false; // Probably not the best way.
  102
+            // How best to allow this to delegate to a class or attribute selector?
  103
+            funcCall = function funcCall() {
  104
+                if (node.nodeName.toLowerCase() !== targetEl.toLowerCase()) {
  105
+                    return;
  106
+                }
  107
+                func();
  108
+            };
  109
+            
  110
+            self.newEventListener(node, ev, funcCall, false);
  111
+        };
  112
+        
98 113
         // Fire func when DOM is loaded:
99 114
         self.domReady = function domReady(func) {
100 115
             if (_supportsAddEventListener) {

0 notes on commit fdb565e

Please sign in to comment.
Something went wrong with that request. Please try again.