<commit_before>'use strict';

function rebindAll() {
  $('.tipsit').tipsy({fade: true, gravity: 's', html: true});
  $('.tipsit-n').tipsy({fade: true, gravity: 'n', html: true});
  $('.tipsit-w').tipsy({fade: true, gravity: 'w', html: true});
  $('.tipsit-e').tipsy({fade: true, gravity: 'e', html: true});
  $('.tipsit-treemap').tipsy({fade: true, gravity: $.fn.tipsy.autoNS, html: true});
}

function responsive() {
  if($(window).width() > 740) {
    return true;
  }
  return false;
}

$(document).on('turbolinks:load', function() {
  // $('.spinner').hide();
  // Turbolinks.enableProgressBar();

  // Modals
  $('.open_modal').magnificPopup({
    type: 'inline',
    removalDelay: 300,
    mainClass: 'mfp-fade'
    // other options
  });

  $('body').on('click', '.popup', function(e){
    e.preventDefault();
    window.open($(this).attr("href"), "popupWindow", "width=600,height=600,scrollbars=yes");
    if($(this).data('rel') !== undefined){
      ga('send', 'event', 'Social Shares', 'Click', $(this).data('rel'), {nonInteraction: true});
      if(mixpanel.length > 0) {
        mixpanel.track('Social Shares', { 'Click': $(this).data('rel')});
      }
    }
  });

  if($(window).width() > 740) {
    rebindAll();
  }

  var searchOptions = {
    serviceUrl: '/search',
    onSelect: function(suggestion) {
      if(suggestion.data.type == 'Place') {
        ga('send', 'event', 'Place Search', 'Click', 'Search', {nonInteraction: true});
        if(mixpanel.length > 0) {
          mixpanel.track('Place Search', { 'Place': suggestion.data.slug});
        }
        window.location.href = '/places/' + suggestion.data.slug;
      }
    },
    groupBy: 'category'
  };

  $('.search_auto').autocomplete($.extend({}, AUTOCOMPLETE_DEFAULTS(), searchOptions));
  $('.global .ham .fa-bars').click(function(e){
    e.preventDefault();
    $('.global .desktop').toggle();
  });

  var $searchBudget = $('.search_categories_budget-expense');
  var searchCategoriesOptions = {
    serviceUrl: $searchBudget.data('search-url'),
    onSelect: function(suggestion) {
      window.location.href = suggestion.data.url;
    }
  };
  $searchBudget.autocomplete($.extend({}, AUTOCOMPLETE_DEFAULTS(), searchCategoriesOptions));

  $searchBudget = $('.search_categories_budget-income');
  searchCategoriesOptions = {
    serviceUrl: $searchBudget.data('search-url'),
    onSelect: function(suggestion) {
      window.location.href = suggestion.data.url;
    }
  };
  $searchBudget.autocomplete($.extend({}, AUTOCOMPLETE_DEFAULTS(), searchCategoriesOptions));

  $('.sticky').sticky({topSpacing:0});

  $('#kind').on('change', function(e){
    $.ajax('/categories/economic/' + $(this).val());
  });

  $('#year,#population').on('change', function(e){
    submitForm();
  });

  $(".places_menu ul li").hover(function(e){
    // e.preventDefault();
    $(this).find('ul').toggle();
  });

  $('.metric').on('click','.ranking_link', function(e){
    e.stopImmediatePropagation();
  })

  function render_comp_table(what) {
    what = what.replace('_','-');
    var other = (what == 'per-person') ? 'total-budget' : 'per-person';
    $('.variable_values').each(function() {
      $(this).find('.selected_indicator').text($(this).data(what));
    });
    $('li.' + what).show();
    $('li.' + other).hide();
  }

  if($('.comparison_table').length > 0) {
    var $widget = $('[data-line-widget-url].selected');
    render_comp_table($widget.data('line-widget-type'));
  }

  $(document).on('click', '[data-feedback]', function(e){
    e.preventDefault();
    $('.metric_graphs').hide();
    $('.budget_line_feedback.hidden').removeClass('hidden');
  });

  // adjust height of sidebar
  // if($(window).width() > 740) {
  if(responsive()) {
    $('header.global').css('height', $(document).height());
  };

  $('.switcher').hover(function(e) {
    e.preventDefault();
    // Don't act in mobile
    if(responsive()){
      $(this).find('ul').show();
    }
  }, function(e) {
    $(this).find('ul').hide();
  });

  $('.kind_switcher').click(function(e){
    // Only in mobile
    if(!responsive()){
      var $ul = $(this).find('ul');
      if(!$ul.is(':visible')){
        $ul.show();
        e.preventDefault();
      } else {
        $ul.hide();
      }
    }
  });

  $('.year_switcher').click(function(e){
    ga('send', 'event', 'Year Selection', 'Click', 'ChangeYear', {nonInteraction: true});
    if(mixpanel.length > 0) {
      mixpanel.track('Year Selection', { 'Year Selected': e.target.innerHTML});
    }
    // Only in mobile
    if(!responsive()){
      var $ul = $(this).find('ul');
      if(!$ul.is(':visible')){
        $ul.show();
        e.preventDefault();
      } else {
        $ul.hide();<commit_msg>Fix kind_switcher<commit_after>'use strict';

function rebindAll() {
  $('.tipsit').tipsy({fade: true, gravity: 's', html: true});
  $('.tipsit-n').tipsy({fade: true, gravity: 'n', html: true});
  $('.tipsit-w').tipsy({fade: true, gravity: 'w', html: true});
  $('.tipsit-e').tipsy({fade: true, gravity: 'e', html: true});
  $('.tipsit-treemap').tipsy({fade: true, gravity: $.fn.tipsy.autoNS, html: true});
}

function responsive() {
  if($(window).width() > 740) {
    return true;
  }
  return false;
}

$(document).on('turbolinks:load', function() {
  // $('.spinner').hide();
  // Turbolinks.enableProgressBar();

  // Modals
  $('.open_modal').magnificPopup({
    type: 'inline',
    removalDelay: 300,
    mainClass: 'mfp-fade'
    // other options
  });

  $('body').on('click', '.popup', function(e){
    e.preventDefault();
    window.open($(this).attr("href"), "popupWindow", "width=600,height=600,scrollbars=yes");
    if($(this).data('rel') !== undefined){
      ga('send', 'event', 'Social Shares', 'Click', $(this).data('rel'), {nonInteraction: true});
      if(mixpanel.length > 0) {
        mixpanel.track('Social Shares', { 'Click': $(this).data('rel')});
      }
    }
  });

  if($(window).width() > 740) {
    rebindAll();
  }

  var searchOptions = {
    serviceUrl: '/search',
    onSelect: function(suggestion) {
      if(suggestion.data.type == 'Place') {
        ga('send', 'event', 'Place Search', 'Click', 'Search', {nonInteraction: true});
        if(mixpanel.length > 0) {
          mixpanel.track('Place Search', { 'Place': suggestion.data.slug});
        }
        window.location.href = '/places/' + suggestion.data.slug;
      }
    },
    groupBy: 'category'
  };

  $('.search_auto').autocomplete($.extend({}, AUTOCOMPLETE_DEFAULTS(), searchOptions));
  $('.global .ham .fa-bars').click(function(e){
    e.preventDefault();
    $('.global .desktop').toggle();
  });

  var $searchBudget = $('.search_categories_budget-expense');
  var searchCategoriesOptions = {
    serviceUrl: $searchBudget.data('search-url'),
    onSelect: function(suggestion) {
      window.location.href = suggestion.data.url;
    }
  };
  $searchBudget.autocomplete($.extend({}, AUTOCOMPLETE_DEFAULTS(), searchCategoriesOptions));

  $searchBudget = $('.search_categories_budget-income');
  searchCategoriesOptions = {
    serviceUrl: $searchBudget.data('search-url'),
    onSelect: function(suggestion) {
      window.location.href = suggestion.data.url;
    }
  };
  $searchBudget.autocomplete($.extend({}, AUTOCOMPLETE_DEFAULTS(), searchCategoriesOptions));

  $('.sticky').sticky({topSpacing:0});

  $('#kind').on('change', function(e){
    $.ajax('/categories/economic/' + $(this).val());
  });

  $('#year,#population').on('change', function(e){
    submitForm();
  });

  $(".places_menu ul li").hover(function(e){
    // e.preventDefault();
    $(this).find('ul').toggle();
  });

  $('.metric').on('click','.ranking_link', function(e){
    e.stopImmediatePropagation();
  })

  function render_comp_table(what) {
    what = what.replace('_','-');
    var other = (what == 'per-person') ? 'total-budget' : 'per-person';
    $('.variable_values').each(function() {
      $(this).find('.selected_indicator').text($(this).data(what));
    });
    $('li.' + what).show();
    $('li.' + other).hide();
  }

  if($('.comparison_table').length > 0) {
    var $widget = $('[data-line-widget-url].selected');
    render_comp_table($widget.data('line-widget-type'));
  }

  $(document).on('click', '[data-feedback]', function(e){
    e.preventDefault();
    $('.metric_graphs').hide();
    $('.budget_line_feedback.hidden').removeClass('hidden');
  });

  // adjust height of sidebar
  // if($(window).width() > 740) {
  if(responsive()) {
    $('header.global').css('height', $(document).height());
  };

  $('.switcher').hover(function(e) {
    e.preventDefault();
    // Don't act in mobile
    if(responsive()){
      $(this).find('ul').show();
    }
  }, function(e) {
    $(this).find('ul').hide();
  });

  $('.kind_switcher').click(function(e){
    // Only in mobile
    if(!responsive() && !$('.home_section .switcher').length){
      var $ul = $(this).find('ul');
      if(!$ul.is(':visible')){
        $ul.show();
        e.preventDefault();
      } else {
        $ul.hide();
      }
    }
  });

  $('.year_switcher').click(function(e){
    ga('send', 'event', 'Year Selection', 'Click', 'ChangeYear', {nonInteraction: true});
    if(mixpanel.length > 0) {
      mixpanel.track('Year Selection', { 'Year Selected': e.target.innerHTML});
    }
    // Only in mobile
    if(!responsive()){
      var $ul = $(this).find('ul');
      if(!$ul.is(':visible')){
        $ul.show();
        e.preventDefault();
      } else {
        $ul.hide();
{'fraction_non_alphanumeric': 0.2324181626187962, 'fraction_numerical': 0.004857444561774023, 'mean_word_length': 3.4174440298507465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '4772890', 'n_tokens_mistral': 3303, 'n_tokens_neox': 3184, 'n_words': 498}