<commit_before>var cdb = require('cartodb.js');
var MapCardPreview = require('../common/views/mapcard_preview');
var ScrollableHeader = require('../common/views/scrollable_header');
var VisualizationDropdown = require('./dropdown');
var Visualizations = require('./feed_collection');
var Feed = require('../user_feed/view');

module.exports = Feed.extend({
  tagName: 'div',

  _LIMIT: 8,

  _SMALL_WIDTH: 544,
  _MEDIUM_WIDTH: 900,

  _CARD_HEIGHT: 220,
  _LOADER_TITLE: 'Exploring',

  _DROPDOWN_TEXT: {
    null: 'Maps and datasets',
    'table': 'Datasets',
    'derived': 'Maps'
  },

  events: {
    'click .js-more': '_onClickMore',
    'click .js-likes': '_onClickLikes',
    'click .js-updated_at': '_onClickUpdatedAt',
    'click .js-mapviews': '_onClickMapViews',
    'click .js-maps-datasets': '_onClickMapsAndDatasets',
    'click .js-maps': '_onClickMaps',
    'click .js-datasets': '_onClickDatasets'
  },

  initialize: function() {
    _.bindAll(this, '_initLike', '_onWindowResize', '_renderStaticMaps');

    this.maps = [];

    this._initTemplates();
    this._initModels();
    this._initBindings();
    this._fetchItems();
  },

  render: function() {
    this.$el.html(this.template());
    this._renderLoader();

    this._setupVisualizationDropdown();
    this._setupScrollableHeader();

    return this;
  },

  _setupScrollableHeader: function() {
    this.scrollableHeader = new ScrollableHeader({
      el: $('.Filters-explore'),
      anchorPoint: $('.Header').height() + $('.FavMap').height()
    });
    this.addView(this.scrollableHeader);
  },

  _setupVisualizationDropdown: function() {
    this.visualizationDropdown = new VisualizationDropdown({
      target: this.$('.js-dropdown'),
      horizontal_position: 'horizontal_left',
      horizontal_offset: -110,
      tick: 'center',
      model: this.model,
      position: 'offset',
      vertical_offset: 0
    });

    this.addView(this.visualizationDropdown);
    cdb.god.bind('closeDialogs', this.visualizationDropdown.hide, this.visualizationDropdown);
    this.add_related_model(cdb.god);
    $('body').append(this.visualizationDropdown.render().el);
  },

  _onWindowResize: function() {
    var width = $(window).width();

    if (width <= this._SMALL_WIDTH) {
      this.model.set('size', 'small');
    } else if (width <= this._MEDIUM_WIDTH) {
      this.model.set('size', 'medium');
    } else {
      this.model.set('size', 'big');
    }

    this._renderStaticMaps();
  },

  _initTemplates: function() {
    this.template = cdb.templates.getTemplate('explore/template');
    this.mapTemplate = cdb.templates.getTemplate('explore/map_item_template');
    this.datasetTemplate = cdb.templates.getTemplate('explore/dataset_item_template');
    this.loaderTemplatePath = 'explore/loading';
  },

  _initModels: function() {
    var size = 'big';
    var wWidth = $(window).width();

    if (wWidth <= this._SMALL_WIDTH) {
      size = 'small';
    } else if (wWidth <= this._MEDIUM_WIDTH) {
      size = 'medium';
    }

    this.model = new cdb.core.Model({
      rendered_big: false,
      rendered_medium: false,
      rendered_small: false,
      type: '',
      size: size,
      page: 0,
      order_by: 'likes'
    });

    this.collection = new Visualizations();


    this.collection.bind('reset', this._renderVisualizations, this);
    this._likeModels = new Backbone.Collection();
  },

  _initBindings: function() {
    var self = this;

    this.model.bind('change:show_more', this._onChangeShowMore, this);
    this.model.bind('change:show_loader', this._onChangeShowLoader, this);
    this.model.bind('change:show_filters', this._onChangeShowFilters, this);
    this.model.bind('change:show_mast', this._onChangeShowMast, this);
    this.model.bind('change:order_by', this._onChangeOrderBy, this);
    this.model.bind('change:type', this._onChangeType, this);

    this.add_related_model(this.options.authenticatedUser);

    $(window).bind('resize', this._onWindowResize);
  },

  _getGeometryType: function(geomTypes) {
    if (geomTypes && geomTypes.length > 0) {<commit_msg>Removes unused var<commit_after>var cdb = require('cartodb.js');
var MapCardPreview = require('../common/views/mapcard_preview');
var ScrollableHeader = require('../common/views/scrollable_header');
var VisualizationDropdown = require('./dropdown');
var Visualizations = require('./feed_collection');
var Feed = require('../user_feed/view');

module.exports = Feed.extend({
  tagName: 'div',

  _LIMIT: 8,

  _SMALL_WIDTH: 544,
  _MEDIUM_WIDTH: 900,

  _CARD_HEIGHT: 220,
  _LOADER_TITLE: 'Exploring',

  _DROPDOWN_TEXT: {
    null: 'Maps and datasets',
    'table': 'Datasets',
    'derived': 'Maps'
  },

  events: {
    'click .js-more': '_onClickMore',
    'click .js-likes': '_onClickLikes',
    'click .js-updated_at': '_onClickUpdatedAt',
    'click .js-mapviews': '_onClickMapViews',
    'click .js-maps-datasets': '_onClickMapsAndDatasets',
    'click .js-maps': '_onClickMaps',
    'click .js-datasets': '_onClickDatasets'
  },

  initialize: function() {
    _.bindAll(this, '_initLike', '_onWindowResize', '_renderStaticMaps');

    this.maps = [];

    this._initTemplates();
    this._initModels();
    this._initBindings();
    this._fetchItems();
  },

  render: function() {
    this.$el.html(this.template());
    this._renderLoader();

    this._setupVisualizationDropdown();
    this._setupScrollableHeader();

    return this;
  },

  _setupScrollableHeader: function() {
    this.scrollableHeader = new ScrollableHeader({
      el: $('.Filters-explore'),
      anchorPoint: $('.Header').height() + $('.FavMap').height()
    });
    this.addView(this.scrollableHeader);
  },

  _setupVisualizationDropdown: function() {
    this.visualizationDropdown = new VisualizationDropdown({
      target: this.$('.js-dropdown'),
      horizontal_position: 'horizontal_left',
      horizontal_offset: -110,
      tick: 'center',
      model: this.model,
      position: 'offset',
      vertical_offset: 0
    });

    this.addView(this.visualizationDropdown);
    cdb.god.bind('closeDialogs', this.visualizationDropdown.hide, this.visualizationDropdown);
    this.add_related_model(cdb.god);
    $('body').append(this.visualizationDropdown.render().el);
  },

  _onWindowResize: function() {
    var width = $(window).width();

    if (width <= this._SMALL_WIDTH) {
      this.model.set('size', 'small');
    } else if (width <= this._MEDIUM_WIDTH) {
      this.model.set('size', 'medium');
    } else {
      this.model.set('size', 'big');
    }

    this._renderStaticMaps();
  },

  _initTemplates: function() {
    this.template = cdb.templates.getTemplate('explore/template');
    this.mapTemplate = cdb.templates.getTemplate('explore/map_item_template');
    this.datasetTemplate = cdb.templates.getTemplate('explore/dataset_item_template');
    this.loaderTemplatePath = 'explore/loading';
  },

  _initModels: function() {
    var size = 'big';
    var wWidth = $(window).width();

    if (wWidth <= this._SMALL_WIDTH) {
      size = 'small';
    } else if (wWidth <= this._MEDIUM_WIDTH) {
      size = 'medium';
    }

    this.model = new cdb.core.Model({
      rendered_big: false,
      rendered_medium: false,
      rendered_small: false,
      type: '',
      size: size,
      page: 0,
      order_by: 'likes'
    });

    this.collection = new Visualizations();


    this.collection.bind('reset', this._renderVisualizations, this);
  },

  _initBindings: function() {
    var self = this;

    this.model.bind('change:show_more', this._onChangeShowMore, this);
    this.model.bind('change:show_loader', this._onChangeShowLoader, this);
    this.model.bind('change:show_filters', this._onChangeShowFilters, this);
    this.model.bind('change:show_mast', this._onChangeShowMast, this);
    this.model.bind('change:order_by', this._onChangeOrderBy, this);
    this.model.bind('change:type', this._onChangeType, this);

    this.add_related_model(this.options.authenticatedUser);

    $(window).bind('resize', this._onWindowResize);
  },

  _getGeometryType: function(geomTypes) {
    if (geomTypes && geomTypes.length > 0) {
{'fraction_non_alphanumeric': 0.15796585186095075, 'fraction_numerical': 0.003930721041641076, 'mean_word_length': 3.665902578796562, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '4731336', 'n_tokens_mistral': 2713, 'n_tokens_neox': 2614, 'n_words': 447}