<commit_before>define(
  ['leaflet',
   'jquery',
   'flight'],
  function(L, $, flight) {
    'use strict';
    var map = function () {
      this.defaultAttrs({
        tileUrl: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
        tileSubdomains: 'abc',
        tileAttribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + ' <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'

      });

      this.defineIconStyles = function() {
        // define icon styles
        var path = L.Icon.Default.imagePath;
        if (!path) {
          path = L.Icon.Default.imagePath = 'lib/leaflet/images';
        }
        this.grayIcon = L.icon({
          iconUrl: path + '/marker-icon-gray.png'
        });

        this.defaultIcon = L.icon({
          iconUrl: path + '/marker-icon.png'
        });
      };

      this.configureMap = function(ev, config) {
        var mapConfig = config.map;
        this.map.setView(mapConfig.center, mapConfig.zoom);
        if (mapConfig.maxZoom){
          this.map.options.maxZoom = mapConfig.maxZoom;
        }
        if (mapConfig.maxBounds){
          this.map.setMaxBounds(mapConfig.maxBounds);
        }
        // geolocate once the configuration is set
        this.map.locate({setView: true, maxZoom: mapConfig.zoom});
      };

      this.loadData = function(ev, data) {
        this.defineIconStyles();

        var setupFeature = function(feature, layer) {
          this.attr.features.push(layer);
          layer.on({click: this.emitClick.bind(this)});
        }.bind(this);

        if (this.attr.layer) {
          this.attr.features = [];
          this.map.removeLayer(this.attr.layer);
        }

        this.attr.layer = L.geoJson(data, {onEachFeature: setupFeature});
        this.attr.layer.addTo(this.map);
      };

      this.emitClick = function(e) {
        this.trigger(document, 'selectFeature', e.target.feature);

        if (this.previouslyClicked) {
          this.previouslyClicked.setIcon(this.defaultIcon);
        }

        e.target.setIcon(this.grayIcon);
        this.previouslyClicked = e.target;
      };

      this.selectFeature = function(ev, feature) {
        this.trigger('panTo', {lng: feature.geometry.coordinates[0],
                               lat: feature.geometry.coordinates[1]});
      };

      this.panTo = function(ev, latlng) {
        this.map.panTo(latlng);
      };

      this.after('initialize', function() {
        this.map = L.map(this.node, {zoomControl: false});

        this.attr.features = [];

        L.tileLayer(this.attr.tileUrl, {
          attribution: this.attr.tileAttribution,
          subdomains: this.attr.tileSubdomains
        }).addTo(this.map);

        this.on(document, 'config', this.configureMap);
        this.on(document, 'data', this.loadData);
        this.on(document, 'dataFiltered', this.loadData);

        this.on(document, 'selectFeature', this.selectFeature);
        this.on('panTo', this.panTo);
      });
    };

    return flight.component(map);
  });<commit_msg>use Acetate for tiles<commit_after>define(
  ['leaflet',
   'jquery',
   'flight'],
  function(L, $, flight) {
    'use strict';
    var map = function () {
      this.defaultAttrs({
        tileUrl: 'http://a{s}.acetate.geoiq.com/tiles/acetate-hillshading/{z}/{x}/{y}.png',
	tileAttribution: '&copy;2012 Esri & Stamen, Data from OSM and Natural Earth',
	tileSubdomains: '0123',
	tileMinZoom: 2,
	tileMaxZoom: 18
      });

      this.defineIconStyles = function() {
        // define icon styles
        var path = L.Icon.Default.imagePath;
        if (!path) {
          path = L.Icon.Default.imagePath = 'lib/leaflet/images';
        }
        this.grayIcon = L.icon({
          iconUrl: path + '/marker-icon-gray.png'
        });

        this.defaultIcon = L.icon({
          iconUrl: path + '/marker-icon.png'
        });
      };

      this.configureMap = function(ev, config) {
        var mapConfig = config.map;
        this.map.setView(mapConfig.center, mapConfig.zoom);
        if (mapConfig.maxZoom){
          this.map.options.maxZoom = mapConfig.maxZoom;
        }
        if (mapConfig.maxBounds){
          this.map.setMaxBounds(mapConfig.maxBounds);
        }
        // geolocate once the configuration is set
        this.map.locate({setView: true, maxZoom: mapConfig.zoom});
      };

      this.loadData = function(ev, data) {
        this.defineIconStyles();

        var setupFeature = function(feature, layer) {
          this.attr.features.push(layer);
          layer.on({click: this.emitClick.bind(this)});
        }.bind(this);

        if (this.attr.layer) {
          this.attr.features = [];
          this.map.removeLayer(this.attr.layer);
        }

        this.attr.layer = L.geoJson(data, {onEachFeature: setupFeature});
        this.attr.layer.addTo(this.map);
      };

      this.emitClick = function(e) {
        this.trigger(document, 'selectFeature', e.target.feature);

        if (this.previouslyClicked) {
          this.previouslyClicked.setIcon(this.defaultIcon);
        }

        e.target.setIcon(this.grayIcon);
        this.previouslyClicked = e.target;
      };

      this.selectFeature = function(ev, feature) {
        this.trigger('panTo', {lng: feature.geometry.coordinates[0],
                               lat: feature.geometry.coordinates[1]});
      };

      this.panTo = function(ev, latlng) {
        this.map.panTo(latlng);
      };

      this.after('initialize', function() {
        this.map = L.map(this.node, {zoomControl: false});

        this.attr.features = [];

        L.tileLayer(this.attr.tileUrl, {
          attribution: this.attr.tileAttribution,
          subdomains: this.attr.tileSubdomains,
          minZoom: this.attr.tileMinZoom,
          maxZoom: this.attr.tileMaxZoom
        }).addTo(this.map);

        this.on(document, 'config', this.configureMap);
        this.on(document, 'data', this.loadData);
        this.on(document, 'dataFiltered', this.loadData);

        this.on(document, 'selectFeature', this.selectFeature);
        this.on('panTo', this.panTo);
      });
    };

    return flight.component(map);
  });
{'fraction_non_alphanumeric': 0.14913556309581516, 'fraction_numerical': 0.002746808854419131, 'mean_word_length': 2.1565527791942887, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3894908', 'n_tokens_mistral': 1970, 'n_tokens_neox': 1904, 'n_words': 302}