// Generated by CoffeeScript 1.4.0 (function() { var __hasProp = {}.hasOwnProperty, __extends = 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; }; window.DashboardView = (function(_super) { __extends(DashboardView, _super); function DashboardView() { return DashboardView.__super__.constructor.apply(this, arguments); } DashboardView.prototype.initialize = function() { var _this = this; this.render(); this.model.on("change:currentCluster", function() { return _this.showTitle(); }); return this.model.on("change:currentTag", function() { return _this.showTitle(); }); }; DashboardView.prototype.events = function() { return { "click #dashboard .clusters span": "changeCurrentCluster" }; }; DashboardView.prototype.changeCurrentCluster = function(e) { var currentCluster; e.stopPropagation(); this.model.attributes['currentTag'] = null; d3.selectAll(".tag_name").classed("current", 0); currentCluster = d3.select(e.target); d3.selectAll(".clusters span").classed("current", 0); if (currentCluster && this.model.get("currentCluster") === currentCluster.attr("name")) { return this.model.set({ currentCluster: null }); } else { currentCluster.classed("current", 1); return this.model.set({ currentCluster: currentCluster.attr("name") }); } }; DashboardView.prototype.showTitle = function() { var currentCluster, currentTag, title; title = "" + (this.getCurrentRows().length) + " " + this.model.options.rowType; if (this.model.options.showGroups) { title += " from " + (joinSentence(this.model.columnGroups)); } if (this.model.options.showClusters && (currentCluster = this.model.get("currentCluster"))) { title += " (Cluster " + currentCluster + ")"; } if (this.model.options.showTags && (currentTag = this.model.get("currentTag"))) { title += " (Tagged " + currentTag + ")"; } d3.select("title").text(title); return d3.select("#dashboard h1").text(title); }; DashboardView.prototype.getCurrentRows = function() { var currentCluster, currentTag; if (this.model.options.showClusters && (currentCluster = this.model.get("currentCluster"))) { return d3.selectAll(".row[cluster='" + currentCluster + "']")[0]; } else if (this.model.options.showTags && (currentTag = this.model.get("currentTag"))) { return d3.selectAll(".tag[name='" + currentTag + "']")[0]; } else { return this.model.parsedData; } }; DashboardView.prototype.render = function() { var _this = this; this.showTitle(); if (this.model.options.showClusters) { return d3.select("#dashboard .clusters").selectAll("span").data(this.model.clusterNames).enter().append("span").attr("name", function(d) { return d; }).text(function(d) { return "Cluster " + d; }).style("background", function(d) { return window.clusterColor(d); }); } }; return DashboardView; })(Backbone.View); }).call(this);