<commit_before>/**
 * The Timeline view presenter.
 *
 * @return TimelinePresenter class
 */
define([
  'underscore',
  'mps',
  'backbone',
  'map/presenters/PresenterClass',
  'map/helpers/layersHelper'
], function(_, mps, Backbone, PresenterClass, layersHelper) {

  'use strict';

  var StatusModel = Backbone.Model.extend({
    defaults: {
      timeline: null, // the current timeline view instance
      begin: null,
      end: null,
      baselayer: null
    }
  });

  var TimelinePresenter = PresenterClass.extend({

    init: function(view) {
      this.view = view;
      this.status = new StatusModel();
      this._super();
      mps.publish('Place/register', [this]);
    },

    _subscriptions: [{
      'Place/go': function(place) {
        this._handleNewLayers(place.layerSpec.getBaselayers(),
          [place.params.begin, place.params.end]);

        if (!place.params.begin) {
          mps.publish('Place/update', [{go: false}]);
        }
      }
    }, {
      'LayerNav/change': function(layerSpec) {
        this._handleNewLayers(layerSpec.getBaselayers());
      }
    }, {
      'Map/center-change': function(lat, lng) {
        this.view.updateLatlng(lat, lng);
      }
    }, {
      'AnalysisTool/stop-drawing': function() {
        if (this.status.get('timeline')) {
          this.view.model.set({hidden: false});
        }
        this.view.model.set('forceHidden', false);
      }
    }, {
      'AnalysisTool/start-drawing': function() {
        if (this.status.get('timeline')) {
          this.view.model.set({hidden: true});
        }
        this.view.model.set('forceHidden', true);
      }
    }],

    /**
     * Add/delete timeline depend on the current active layers.
     *
     * @param {object} layerSpec
     */
    _handleNewLayers: function(baselayers, date) {
      var date;
      var currentTimeline = this.status.get('timeline');
      var baselayer = _.values(_.omit(
        baselayers, ['forestgain','nothing']))[0];

      if (!baselayer) {
        date = undefined;
        this._timelineDisabled();
        return;
      }

      if (currentTimeline) {
        if (currentTimeline.getName() === baselayer.slug) {

          date = [this.status.get('begin') , this.status.get('end')];
          // Return if the timeline is already active.
          return;
        }
        // Remove current timeline.
        date = date;
        this._removeTimeline();<commit_msg>Map: timeline removed when you select only gain layer<commit_after>/**
 * The Timeline view presenter.
 *
 * @return TimelinePresenter class
 */
define([
  'underscore',
  'mps',
  'backbone',
  'map/presenters/PresenterClass',
  'map/helpers/layersHelper'
], function(_, mps, Backbone, PresenterClass, layersHelper) {

  'use strict';

  var StatusModel = Backbone.Model.extend({
    defaults: {
      timeline: null, // the current timeline view instance
      begin: null,
      end: null,
      baselayer: null
    }
  });

  var TimelinePresenter = PresenterClass.extend({

    init: function(view) {
      this.view = view;
      this.status = new StatusModel();
      this._super();
      mps.publish('Place/register', [this]);
    },

    _subscriptions: [{
      'Place/go': function(place) {
        this._handleNewLayers(place.layerSpec.getBaselayers(),
          [place.params.begin, place.params.end]);

        if (!place.params.begin) {
          mps.publish('Place/update', [{go: false}]);
        }
      }
    }, {
      'LayerNav/change': function(layerSpec) {
        this._handleNewLayers(layerSpec.getBaselayers());
      }
    }, {
      'Map/center-change': function(lat, lng) {
        this.view.updateLatlng(lat, lng);
      }
    }, {
      'AnalysisTool/stop-drawing': function() {
        if (this.status.get('timeline')) {
          this.view.model.set({hidden: false});
        }
        this.view.model.set('forceHidden', false);
      }
    }, {
      'AnalysisTool/start-drawing': function() {
        if (this.status.get('timeline')) {
          this.view.model.set({hidden: true});
        }
        this.view.model.set('forceHidden', true);
      }
    }],

    /**
     * Add/delete timeline depend on the current active layers.
     *
     * @param {object} layerSpec
     */
    _handleNewLayers: function(baselayers, date) {
      var date;
      var currentTimeline = this.status.get('timeline');
      var baselayer = _.values(_.omit(
        baselayers, ['forestgain','nothing']))[0];

      if (!baselayer) {
        date = undefined;
        this._timelineDisabled();
        this._removeTimeline();
        return;
      }

      if (currentTimeline) {
        if (currentTimeline.getName() === baselayer.slug) {

          date = [this.status.get('begin') , this.status.get('end')];
          // Return if the timeline is already active.
          return;
        }
        // Remove current timeline.
        date = date;
        this._removeTimeline();
{'fraction_non_alphanumeric': 0.14902676399026765, 'fraction_numerical': 0.00040551500405515005, 'mean_word_length': 2.243261012491782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4937272', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1499, 'n_words': 284}