<commit_before>(function ($) {
  var subject_areas, openTermTooltip, handleFlagClick;

  subject_areas = (function () {
    var categoryTerm, checkStorage;

    $('#subjectList li').each(
        function () {

          var iconWidth = $('.taxo-flag').outerWidth(true);
          var columnWidth = $(this).width() - iconWidth;
          var columnPadding = 5 * 2;
          var truncationWidth = (columnWidth - columnPadding);
          var truncTerm = $(this).find('.taxo-term');
          var targetSpan = $(truncTerm).next();
          var getWidth = $(truncTerm).width();
          /* //apply width via js if truncation is needed because the css width needs to be auto otherwise */

          if (getWidth > truncationWidth) {
            var term_truncate = $(truncTerm).css('width', columnWidth + 'px');
          }

          /*//check in localstorage if any thing has already been flagged*/
          categoryTerm = $(targetSpan).next().data('categoryname');
          checkStorage = localStorage[categoryTerm];
          if (checkStorage !== undefined) {
            var term_flagged = $(targetSpan).addClass('flagged');
          }

          return {term_flagged: term_flagged, term_truncate: term_truncate};
        }
    );
  })();

  openTermTooltip = function () {
    var targetSpan, toolContainer;
    targetSpan = this;
    toolContainer = $(targetSpan).next();

    /*// show the tooltip*/
    $(toolContainer).addClass('activate');

    /*// close other open tooltips*/
    if ($(toolContainer).parent().siblings().children('div').hasClass('activate')) {
      $(toolContainer).parent().siblings().children('div').removeClass('activate');
      window.clearTimeout(closeIt);
    }

    /*// close tooltip if click outside of it*/
    $(document).on(
        'click.closeOutside', function (event) {
          if ($(event.target).closest('.taxo-flag').length === 1 || $(event.target).closest('.taxo-tooltip').length === 1) {
            // do nothing
          } else {
            $(toolContainer).removeClass('activate');
            $(document).off("click.closeOutside");
          }
        }
    );
<commit_msg>DPRO-1062: refactor subject area tooltip close logic<commit_after>(function ($) {
  var subject_areas, openTermTooltip, handleFlagClick;

  subject_areas = (function () {
    var categoryTerm, checkStorage;

    $('#subjectList li').each(
        function () {

          var iconWidth = $('.taxo-flag').outerWidth(true);
          var columnWidth = $(this).width() - iconWidth;
          var columnPadding = 5 * 2;
          var truncationWidth = (columnWidth - columnPadding);
          var truncTerm = $(this).find('.taxo-term');
          var targetSpan = $(truncTerm).next();
          var getWidth = $(truncTerm).width();
          /* //apply width via js if truncation is needed because the css width needs to be auto otherwise */

          if (getWidth > truncationWidth) {
            var term_truncate = $(truncTerm).css('width', columnWidth + 'px');
          }

          /*//check in localstorage if any thing has already been flagged*/
          categoryTerm = $(targetSpan).next().data('categoryname');
          checkStorage = localStorage[categoryTerm];
          if (checkStorage !== undefined) {
            var term_flagged = $(targetSpan).addClass('flagged');
          }

          return {term_flagged: term_flagged, term_truncate: term_truncate};
        }
    );
  })();

  openTermTooltip = function () {
    var targetSpan, toolContainer;
    targetSpan = this;
    toolContainer = $(targetSpan).next();

    /*// show the tooltip*/
    $(toolContainer).addClass('activate');

    /*// close other open tooltips*/
    if ($(toolContainer).parent().siblings().children('div').hasClass('activate')) {
      $(toolContainer).parent().siblings().children('div').removeClass('activate');
      window.clearTimeout(closeIt);
    }

    /*// close tooltip if click outside of it*/
    $(document).on('click.closeOutside', function (event) {
      if ($(event.target).closest('.taxo-flag').length !== 1
        && $(event.target).closest('.taxo-tooltip').length !== 1) {
        $(toolContainer).removeClass('activate');
        $(document).off("click.closeOutside");
      }
    });

{'fraction_non_alphanumeric': 0.15471698113207547, 'fraction_numerical': 0.002830188679245283, 'mean_word_length': 2.5879864636209815, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7490009', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1125, 'n_words': 260}