Пример #1
0
function off (element, event, selector, callback){
  if (arguments.length == 4) {
    return delegate.unbind(element, selector, event, callback);
  }

  callback = selector;

  events.off(element, event, callback);
}
Пример #2
0
module.exports = function(el, url){
  delegate.unbind(document, 'click', zoomListener, false);
  if (typeof el == 'object'){
    var zooms = [];
    for (var i = 0; i < el.length; i++){
      zooms.push(new Zoom(el[i]).bind());
    }
    return zooms;
  }
  return new Zoom(el, url).bind();
};
Пример #3
0
exports.off = function(el, event, selector, fn, capture){
  switch (typeof selector) {
    case 'function':
      capture = fn;
      fn = selector;
      if (!fn._delegate) break;
    case 'string':
      delegate.unbind(el, event, fn._delegate, capture);
      return this;
  }

  events.unbind(el, event, fn, capture);

  return el;
};
Пример #4
0
Pie.prototype.render = function() {
  var values = this.values;
  var angles = this.angles;

  var w = this.width || width;    // The width of the chart
  var h = this.height || height;  // The height of the chart
  var cx = w/2;                   // The center on x
  var cy = h/2;                   // The cenger on y
  var r = cy;                     // The radius

  var el = document.createElementNS(svgns, "svg:svg");

  el.setAttribute("width", w);
  el.setAttribute("height", h);
  el.setAttribute("viewBox", "0 0 " + w + " " + h);

  // Loop through each slice of pie.
  var startangle = 0;
  for(var i = 0; i < values.length; i++) {

    // This is where the wedge ends
    var endangle = startangle + angles[i];

    // Compute the two points where our wedge intersects the circle
    // These formulas are chosen so that an angle of 0 is at 12 o'clock
    // and positive angles increase clockwise.
    var x1 = cx + r * Math.sin(startangle);
    var y1 = cy - r * Math.cos(startangle);
    var x2 = cx + r * Math.sin(endangle);
    var y2 = cy - r * Math.cos(endangle);

    // This is a flag for angles larger than than a half circle
    // It is required by the SVG arc drawing component
    var big = 0;
    if (endangle - startangle > Math.PI) big = 1;

    // We describe a wedge with an <svg:path> element
    var path = document.createElementNS(svgns, "path");

    // This string holds the path details
    var d = "M " + cx + "," + cy + // Start at circle center
      " L " + x1 + "," + y1 +      // Draw line to (x1,y1)
      " A " + r + "," + r +        // Draw an arc of radius r
      " 0 " + big + " 1 " +        // Arc details...
      x2 + "," + y2 +              // Arc goes to to (x2,y2)
      " Z";                        // Close path back to (cx,cy)

    // Now set attributes on the <svg:path> element
    path.setAttribute("d", d);
    path.setAttribute("fill", this.colors[i] 
      || colors[i % colors.length]);
    path.setAttribute("stroke", "#FFF");
    path.setAttribute("stroke-width", "1");
    
    // Store index on the path
    path.__idx =  i;

    // Add wedge to chart
    el.appendChild(path);                   

    // The next wedge begins where this one ends
    startangle = endangle;
  }
  
  // Unbind events if it was previously rendered.
  if (this.el) {
    delegate.unbind(el, 'mouseover', 
      this.binds.onmouseover);
  }

  // Bind events
  delegate.bind(el, 'path', 'mouseover', 
    this.binds.onmouseover);

  this.el = el;

  return el;
}
Пример #5
0
 this.onunbind(function(name, fn){
   // TODO: selector support here as well...
   // needs updating in delegate
   delegate.unbind(target, name, fn.callback);
 });