<commit_before>cdb.geo.ui.LegendItemModel = cdb.core.Model.extend({

  defaults: {
    name: "Untitled",
    value: ""
  }

});

cdb.geo.ui.LegendItems = Backbone.Collection.extend({
  model: cdb.geo.ui.LegendItemModel
});

cdb.geo.ui.LegendItem = cdb.core.View.extend({

  tagName: "li",

  initialize: function() {

    _.bindAll(this, "render");

    this.template = this.options.template ? _.template(this.options.template) : cdb.templates.getTemplate('geo/legend');

  },

  render: function() {

    this.$el.html(this.template(this.model.toJSON()));

    return this.$el;
  }

});


/*
 * ChoroplethLegend
 *
 * */
cdb.geo.ui.ChoroplethLegend = cdb.core.View.extend({

  tagName: "ul",
  initialize: function() {

    this.items = this.options.items;
    this.template = _.template('<li class="min"><%= min %></li><li class="max"><%= max %></li><li class="graph"></li>');
    this.model = new cdb.core.Model();

  },

  _renderGraph: function() {

    var s = "";

    s+= "background: <%= left %>;";
    s+= "background: -moz-linear-gradient(left, <%= left %> 0%, <%= right %> 100%);";
    s+= "background: -webkit-gradient(linear, left top, right top, color-stop(0%,<%= left %>), color-stop(100%,<%= right %>));";
    s+= "background: -webkit-linear-gradient(left, <%= left %> 0%,<%= right %> 100%);";
    s+= "background: -o-linear-gradient(left, <%= left %> 0%,<%= right %> 100%);";
    s+= "background: -ms-linear-gradient(left, <%= left %> 0%,<%= right %> 100%)";
    s+= "background: linear-gradient(to right, <%= left %> 0%,<%= right %> 100%);";
    s+= "filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<%= left %>', endColorstr='<%= right %>',GradientType=1 );";

    var backgroundStyle = _.template(s);

    this.$el.find(".graph").attr("style", backgroundStyle({ left: this.min.get("value"), right: this.max.get("value") }));
  },

  render: function() {

    this.min = this.items.at(0);
    this.max = this.items.at(this.items.length - 1);

    this.model.set({ min: this.min.get("name"), max: this.max.get("name") });
    this.$el.html(this.template(this.model.toJSON()));

    this._renderGraph();

    return this;

  }

});


/*
 * BubbleLegend
 *
 * */
cdb.geo.ui.BubbleLegend = cdb.core.View.extend({

  tagName: "ul",

  initialize: function() {

    this.items = this.options.items;
    this.template = _.template('<li><%= min %></li><li class="graph"></li><li><%= max %></li>');
    this.model = new cdb.core.Model();
  },

  _renderGraph: function() {

  },

  render: function() {

    var min = this.items.at(0);
    var max = this.items.at(this.items.length - 1);

    this.model.set({ min: min.get("name"), max: max.get("name") });
    this.$el.html(this.template(this.model.toJSON()));

    this._renderGraph();

    return this;

  }

});

/*
 * CustomLegend
 *
 * */
cdb.geo.ui.CustomLegend = cdb.core.View.extend({

  tagName: "ul",

  initialize: function() {

    this.items = this.options.items;
    this.template = _.template("");
    this.model = new cdb.core.Model({
      type: "custom"
    });

  },

  _renderItems: function() {

    var self = this;

    this.items.each(function(item) {

      view = new cdb.geo.ui.LegendItem({
        model: item,
        template: '<div class="bullet" style="background:<%= value %>"></div><%= name %>'
      });

      self.$el.append(view.render());

    });

  },

  render: function() {

    this.$el.html(this.template(this.model.toJSON()));

    this._renderItems();

    return this;

  }

});

cdb.geo.ui.StackedLegend = cdb.core.View.extend({

  className: "cartodb-legend-stack",

  initialize: function() {

  },
<commit_msg>Adds comment explaining how to use stacklegends<commit_after>cdb.geo.ui.LegendItemModel = cdb.core.Model.extend({

  defaults: {
    name: "Untitled",
    value: ""
  }

});

cdb.geo.ui.LegendItems = Backbone.Collection.extend({
  model: cdb.geo.ui.LegendItemModel
});

cdb.geo.ui.LegendItem = cdb.core.View.extend({

  tagName: "li",

  initialize: function() {

    _.bindAll(this, "render");

    this.template = this.options.template ? _.template(this.options.template) : cdb.templates.getTemplate('geo/legend');

  },

  render: function() {

    this.$el.html(this.template(this.model.toJSON()));

    return this.$el;
  }

});


/*
 * ChoroplethLegend
 *
 * */
cdb.geo.ui.ChoroplethLegend = cdb.core.View.extend({

  tagName: "ul",
  initialize: function() {

    this.items = this.options.items;
    this.template = _.template('<li class="min"><%= min %></li><li class="max"><%= max %></li><li class="graph"></li>');
    this.model = new cdb.core.Model();

  },

  _renderGraph: function() {

    var s = "";

    s+= "background: <%= left %>;";
    s+= "background: -moz-linear-gradient(left, <%= left %> 0%, <%= right %> 100%);";
    s+= "background: -webkit-gradient(linear, left top, right top, color-stop(0%,<%= left %>), color-stop(100%,<%= right %>));";
    s+= "background: -webkit-linear-gradient(left, <%= left %> 0%,<%= right %> 100%);";
    s+= "background: -o-linear-gradient(left, <%= left %> 0%,<%= right %> 100%);";
    s+= "background: -ms-linear-gradient(left, <%= left %> 0%,<%= right %> 100%)";
    s+= "background: linear-gradient(to right, <%= left %> 0%,<%= right %> 100%);";
    s+= "filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<%= left %>', endColorstr='<%= right %>',GradientType=1 );";

    var backgroundStyle = _.template(s);

    this.$el.find(".graph").attr("style", backgroundStyle({ left: this.min.get("value"), right: this.max.get("value") }));
  },

  render: function() {

    this.min = this.items.at(0);
    this.max = this.items.at(this.items.length - 1);

    this.model.set({ min: this.min.get("name"), max: this.max.get("name") });
    this.$el.html(this.template(this.model.toJSON()));

    this._renderGraph();

    return this;

  }

});


/*
 * BubbleLegend
 *
 * */
cdb.geo.ui.BubbleLegend = cdb.core.View.extend({

  tagName: "ul",

  initialize: function() {

    this.items = this.options.items;
    this.template = _.template('<li><%= min %></li><li class="graph"></li><li><%= max %></li>');
    this.model = new cdb.core.Model();
  },

  _renderGraph: function() {

  },

  render: function() {

    var min = this.items.at(0);
    var max = this.items.at(this.items.length - 1);

    this.model.set({ min: min.get("name"), max: max.get("name") });
    this.$el.html(this.template(this.model.toJSON()));

    this._renderGraph();

    return this;

  }

});

/*
 * CustomLegend
 *
 * */
cdb.geo.ui.CustomLegend = cdb.core.View.extend({

  tagName: "ul",

  initialize: function() {

    this.items = this.options.items;
    this.template = _.template("");
    this.model = new cdb.core.Model({
      type: "custom"
    });

  },

  _renderItems: function() {

    var self = this;

    this.items.each(function(item) {

      view = new cdb.geo.ui.LegendItem({
        model: item,
        template: '<div class="bullet" style="background:<%= value %>"></div><%= name %>'
      });

      self.$el.append(view.render());

    });

  },

  render: function() {

    this.$el.html(this.template(this.model.toJSON()));

    this._renderItems();

    return this;

  }

});

/*
 *    var legendA = new cdb.geo.ui.Legend({
 *      type: "custom",
 *      data: [
 *        { name: "Category 1", value: "#FFC926" },
 *        { name: "Category 2", value: "#76EC00" },
 *        { name: "Category 3", value: "#00BAF8" },
 *        { name: "Category 4", value: "#D04CFD" }
 *      ]
 *    });
 *
 *    var legendB = new cdb.geo.ui.Legend({
 *      type: "bubble",
 *      data: [
 *        { name: "21,585",     value: "#FFC926" },
 *        { name: "91,585",     value: "#D04CFD" }
 *      ]
 *    });
 *
 *    var stackedLegend = new cdb.geo.ui.StackedLegend({
 *      legends: [legendA, legendB, …]
 *    });
 *
 *    $("#overlay").append(stackedLegend.render().$el);
 *
 *
 * */

cdb.geo.ui.StackedLegend = cdb.core.View.extend({

  className: "cartodb-legend-stack",

  initialize: function() {

  },

{'fraction_non_alphanumeric': 0.22136357970833853, 'fraction_numerical': 0.011093107316465163, 'mean_word_length': 3.034188034188034, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4292665', 'n_tokens_mistral': 3091, 'n_tokens_neox': 2798, 'n_words': 499}