<commit_before>/**
  The base route for all routes on Discourse. Includes global enter functionality.

  @class Route
  @extends Em.Route
  @namespace Discourse
  @module Discourse
**/
Discourse.Route = Em.Route.extend({

  /**
    NOT called every time we enter a route on Discourse.
    Only called the FIRST time we enter a route.
    So, when going from one topic to another, activate will only be called on the
    TopicRoute for the first topic.

    @method activate
  **/
  activate: function() {
    this._super();
    Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
  }

});


Discourse.Route.reopenClass({

  buildRoutes: function(builder) {
    var oldBuilder = Discourse.routeBuilder;
    Discourse.routeBuilder = function() {
      if (oldBuilder) oldBuilder.call(this);
      return builder.call(this);
    };
  },

  cleanDOM: function() {
    // Close mini profiler
    $('.profiler-results .profiler-result').remove();

    // Close some elements that may be open
    $('.d-dropdown').hide();
    $('header ul.icons li').removeClass('active');
    $('[data-toggle="dropdown"]').parent().removeClass('open');
    // close the lightbox
    if ($.magnificPopup && $.magnificPopup.instance) { $.magnificPopup.instance.close(); }

    // Remove any link focus
    $('a').blur();

    Discourse.set('notifyCount',0);

    var hideDropDownFunction = $('html').data('hide-dropdown');
    if (hideDropDownFunction) { hideDropDownFunction(); }<commit_msg>PERF: Don't blur all elements on a page<commit_after>/**
  The base route for all routes on Discourse. Includes global enter functionality.

  @class Route
  @extends Em.Route
  @namespace Discourse
  @module Discourse
**/
Discourse.Route = Em.Route.extend({

  /**
    NOT called every time we enter a route on Discourse.
    Only called the FIRST time we enter a route.
    So, when going from one topic to another, activate will only be called on the
    TopicRoute for the first topic.

    @method activate
  **/
  activate: function() {
    this._super();
    Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
  }

});


Discourse.Route.reopenClass({

  buildRoutes: function(builder) {
    var oldBuilder = Discourse.routeBuilder;
    Discourse.routeBuilder = function() {
      if (oldBuilder) oldBuilder.call(this);
      return builder.call(this);
    };
  },

  cleanDOM: function() {
    // Close mini profiler
    $('.profiler-results .profiler-result').remove();

    // Close some elements that may be open
    $('.d-dropdown').hide();
    $('header ul.icons li').removeClass('active');
    $('[data-toggle="dropdown"]').parent().removeClass('open');
    // close the lightbox
    if ($.magnificPopup && $.magnificPopup.instance) { $.magnificPopup.instance.close(); }

    // Remove any link focus
    $(document.activeElement).blur();

    Discourse.set('notifyCount',0);

    var hideDropDownFunction = $('html').data('hide-dropdown');
    if (hideDropDownFunction) { hideDropDownFunction(); }
{'fraction_non_alphanumeric': 0.14009983361064893, 'fraction_numerical': 0.0006655574043261231, 'mean_word_length': 3.3883211678832117, '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': '528913', 'n_tokens_mistral': 896, 'n_tokens_neox': 874, 'n_words': 249}