Sha256: c0e33851ce255238e4d84488311e53ea73137c0172d045b83702ef21a43fbfe2

Contents?: true

Size: 1.04 KB

Versions: 31

Compression:

Stored size: 1.04 KB

Contents

// type can be namespaced, e.g., "click.foo"
// listener can be null for removal
d3_selectionPrototype.on = function(type, listener, capture) {
  if (arguments.length < 3) capture = false;

  // parse the type specifier
  var name = "__on" + type, i = type.indexOf(".");
  if (i > 0) type = type.substring(0, i);

  // if called with only one argument, return the current listener
  if (arguments.length < 2) return (i = this.node()[name]) && i._;

  // remove the old event listener, and add the new event listener
  return this.each(function(d, i) {
    var node = this;

    if (node[name]) node.removeEventListener(type, node[name], capture);
    if (listener) node.addEventListener(type, node[name] = l, capture);

    // wrapped event listener that preserves i
    function l(e) {
      var o = d3.event; // Events can be reentrant (e.g., focus).
      d3.event = e;
      try {
        listener.call(node, node.__data__, i);
      } finally {
        d3.event = o;
      }
    }

    // stash the unwrapped listener for retrieval
    l._ = listener;
  });
};

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
picky-statistics-4.5.0 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.4.2 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.4.1 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.4.0 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.3.2 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.3.1 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.3.0 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.2.4 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.2.3 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.2.2 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.2.1 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.2.0 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.1.0 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.0.9 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.0.8 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.0.7 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.0.6 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.0.5 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.0.4 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js
picky-statistics-4.0.3 lib/picky-statistics/application/javascripts/d3/src/core/selection-on.js