Sha256: 5f881d0aa3bc172b94e30dca23e8e36e328005e14156d7031ef00a87fbcbabed

Contents?: true

Size: 929 Bytes

Versions: 27

Compression:

Stored size: 929 Bytes

Contents

/**
 * Module dependencies.
 */

var closest = require('closest')
  , event = require('event');

/**
 * Delegate event `type` to `selector`
 * and invoke `fn(e)`. A callback function
 * is returned which may be passed to `.unbind()`.
 *
 * @param {Element} el
 * @param {String} selector
 * @param {String} type
 * @param {Function} fn
 * @param {Boolean} capture
 * @return {Function}
 * @api public
 */

exports.bind = function(el, selector, type, fn, capture){
  return event.bind(el, type, function(e){
    var target = e.target || e.srcElement;
    e.delegateTarget = closest(target, selector, true, el);
    if (e.delegateTarget) fn.call(el, e);
  }, capture);
};

/**
 * Unbind event `type`'s callback `fn`.
 *
 * @param {Element} el
 * @param {String} type
 * @param {Function} fn
 * @param {Boolean} capture
 * @api public
 */

exports.unbind = function(el, type, fn, capture){
  event.unbind(el, type, fn, capture);
};

Version data entries

27 entries across 14 versions & 1 rubygems

Version Path
ende-0.2.3 vendor/assets/components/component-delegate/index.js
ende-0.2.3 vendor/components/component-delegate/index.js
ende-0.2.2 vendor/assets/components/component-delegate/index.js
ende-0.2.2 vendor/components/component-delegate/index.js
ende-0.2.1 vendor/assets/components/component-delegate/index.js
ende-0.2.1 vendor/components/component-delegate/index.js
ende-0.2.0 vendor/components/component-delegate/index.js
ende-0.2.0 vendor/assets/components/component-delegate/index.js
ende-0.1.14 vendor/assets/components/component-delegate/index.js
ende-0.1.14 vendor/components/component-delegate/index.js
ende-0.1.13 vendor/components/component-delegate/index.js
ende-0.1.13 vendor/assets/components/component-delegate/index.js
ende-0.1.12 vendor/components/component-delegate/index.js
ende-0.1.12 vendor/assets/components/component-delegate/index.js
ende-0.1.11 vendor/components/component-delegate/index.js
ende-0.1.11 vendor/assets/components/component-delegate/index.js
ende-0.1.10 vendor/assets/components/component-delegate/index.js
ende-0.1.10 vendor/components/component-delegate/index.js
ende-0.1.9 vendor/components/component-delegate/index.js
ende-0.1.9 vendor/assets/components/component-delegate/index.js