{"size": 1133, "ext": "js", "max_stars_repo_path": "client/templates/includes/filter_control.js", "max_stars_repo_name": "axmatthew/meteor-trading-system", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/templates/includes/filter_control.js", "max_issues_repo_name": "axmatthew/meteor-trading-system", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/templates/includes/filter_control.js", "max_forks_repo_name": "axmatthew/meteor-trading-system", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.8157894737, "max_line_length": 100, "alphanum_fraction": 0.6063548102}
Template.filterControl.onRendered(function() {
  if (Template.currentData().default) {
    var filters = Session.get("filters") || {};
    filters[Template.currentData().field] = {$regex: Template.currentData().default, $options: "i"};
    Session.set("filters", filters);
  }
});

Template.filterControl.helpers({
  defaultValue: function() {
    return this.default || "All";
  },
  values: function() {
    var showValues = (this.showValues === undefined) ? true : this.showValues;
    if (showValues) {
      var field = this.field;
      return _.uniq(this.cursor.map(function(doc) { return doc[field]; })).sort();
    } else {
      return [];
    }
  }
});

Template.filterControl.events({
  "change input": function(e) {
    e.preventDefault();
    if (!e.target.value || e.target.value === "All") {
      var filters = Session.get("filters") || {};
      delete filters[this.field];
      Session.set("filters", filters);
    } else {
      var filters = Session.get("filters") || {};
      filters[this.field] = {$regex: e.target.value, $options: "i"};
      Session.set("filters", filters);
    }
    return false;
  }
});