<commit_before>/**
 * The Timeline view module.
 *
 * Timeline for all layers configured by setting layer-specific options.
 *
 * @return Timeline view (extends Backbone.View).
 */
define([
  'underscore',
  'backbone',
  'moment',
  'd3',
  'mps',
  'handlebars',
  'text!templates/timelineYear.handlebars',
  'text!templates/timelineMonth-mobile.handlebars'

], function(_, Backbone, moment, d3, mps, Handlebars, tpl, tplMobile) {

  'use strict';

  var TimelineYearClass = Backbone.View.extend({

    className: 'timeline-month',

    template: Handlebars.compile(tpl),
    templateMobile: Handlebars.compile(tplMobile),

    months: ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC",],

    defaults: {
      dateRange: [moment([2001]), moment()],
      width: 750,
      height: 50,
      player: true,
      playSpeed: 400,
      effectsSpeed: 0
    },

    events: {
      'click .play': '_togglePlay',
      'change .select-date' : 'setSelects'
    },

    initialize: function(layer, currentDate) {
      this.layer = layer;
      this.name = layer.slug;
      this.options = _.extend({}, this.defaults, this.options || {});
      this.dateRangeStart = this.options.dateRange[0];
      this.dateRangeEnd = this.options.dateRange[1];

      if (currentDate && currentDate[0]) {
        this.currentDate = currentDate;
      } else {
        this._updateCurrentDate(this.options.dateRange);
      }

      // Transitions duration are 100 ms. Give time to them to finish.
      this._updateCurrentDate = _.debounce(this._updateCurrentDate,
        this.options.effectsSpeed);
      this.playing = false;

      // Max date range
      this.drMax = this.options.dateRange;
      // Date range
      this.dr = [[moment(this.drMax[0]).year()], [moment(this.drMax[1]).year() + 1]];

      // Number months to display
      this.monthsCount = Math.floor(moment(this.dr[1]).diff(moment(this.dr[0]),
        'months', true));

      enquire.register("screen and (min-width:"+window.gfw.config.GFW_MOBILE+"px)", {
        match: _.bind(function(){
          this.render();
        },this)
      });
      enquire.register("screen and (max-width:"+window.gfw.config.GFW_MOBILE+"px)", {
        match: _.bind(function(){
          this.renderMobile();
        },this)
      });
    },


    /**<commit_msg>Wrap the ranges in moment<commit_after>/**
 * The Timeline view module.
 *
 * Timeline for all layers configured by setting layer-specific options.
 *
 * @return Timeline view (extends Backbone.View).
 */
define([
  'underscore',
  'backbone',
  'moment',
  'd3',
  'mps',
  'handlebars',
  'text!templates/timelineYear.handlebars',
  'text!templates/timelineMonth-mobile.handlebars'

], function(_, Backbone, moment, d3, mps, Handlebars, tpl, tplMobile) {

  'use strict';

  var TimelineYearClass = Backbone.View.extend({

    className: 'timeline-month',

    template: Handlebars.compile(tpl),
    templateMobile: Handlebars.compile(tplMobile),

    months: ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC",],

    defaults: {
      dateRange: [moment([2001]), moment()],
      width: 750,
      height: 50,
      player: true,
      playSpeed: 400,
      effectsSpeed: 0
    },

    events: {
      'click .play': '_togglePlay',
      'change .select-date' : 'setSelects'
    },

    initialize: function(layer, currentDate) {
      this.layer = layer;
      this.name = layer.slug;
      this.options = _.extend({}, this.defaults, this.options || {});
      this.dateRangeStart = this.options.dateRange[0];
      this.dateRangeEnd = this.options.dateRange[1];

      if (currentDate && currentDate[0]) {
        this.currentDate = currentDate;
      } else {
        this._updateCurrentDate(this.options.dateRange);
      }

      // Transitions duration are 100 ms. Give time to them to finish.
      this._updateCurrentDate = _.debounce(this._updateCurrentDate,
        this.options.effectsSpeed);
      this.playing = false;

      // Max date range
      this.drMax = this.options.dateRange.map(function(dr) { return moment(dr); });
      // Date range
      this.dr = [[moment(this.drMax[0]).year()], [moment(this.drMax[1]).year() + 1]];

      // Number months to display
      this.monthsCount = Math.floor(moment(this.dr[1]).diff(moment(this.dr[0]),
        'months', true));

      enquire.register("screen and (min-width:"+window.gfw.config.GFW_MOBILE+"px)", {
        match: _.bind(function(){
          this.render();
        },this)
      });
      enquire.register("screen and (max-width:"+window.gfw.config.GFW_MOBILE+"px)", {
        match: _.bind(function(){
          this.renderMobile();
        },this)
      });
    },


    /**
{'fraction_non_alphanumeric': 0.1636556854410202, 'fraction_numerical': 0.011052072263549416, 'mean_word_length': 2.8322475570032575, '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': '2890936', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1483, 'n_words': 288}