// Generated by CoffeeScript 1.10.0 (function() { var EventSource, View, slice = [].slice, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; window.global = function(f) { return window[f.name] = f; }; global(EventSource = (function() { function EventSource(config) { this._dispatcher = d3.dispatch.apply(d3, config.events); this.next_id = 0; } EventSource.prototype.on = function(event_type_ns, callback) { var event_type, event_type_full, namespace, splitted_event_type_ns; splitted_event_type_ns = event_type_ns.split('.'); event_type = splitted_event_type_ns[0]; if (splitted_event_type_ns.length > 1) { namespace = splitted_event_type_ns[1]; } else { namespace = this.next_id; this.next_id += 1; } event_type_full = event_type + '.' + namespace; this._dispatcher.on(event_type_full, callback); return event_type_full; }; EventSource.prototype.trigger = function() { var args, event_type; event_type = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; this._dispatcher.apply(event_type, this, args); return this; }; return EventSource; })()); global(View = (function(superClass) { extend(View, superClass); function View(conf) { View.__super__.constructor.call(this, conf); if (conf.tag == null) { conf.tag = 'div'; } this.el = document.createElement(conf.tag); this.d3el = d3.select(this.el); this.d3el.classed(this.constructor.name, true); if (conf.parent != null) { this.append_to(conf.parent, conf.prepend); } } View.prototype.append_to = function(parent, prepend) { var p_el; if (parent.el != null) { p_el = parent.el; } else { p_el = d3.select(parent).node(); } if (prepend) { return p_el.insertBefore(this.el, p_el.firstChild); } else { return p_el.appendChild(this.el); } }; View.prototype.recompute_size = function() { this.width = this.el.getBoundingClientRect().width; return this.height = this.el.getBoundingClientRect().height; }; return View; })(EventSource)); }).call(this);