<commit_before>import $ from 'jquery'
import Translator from './i18n'
import Modal from './Modal'
import breakpoints from './Breakpoints'

let ChangeList = {
  /**
   * ChangeList component
   *
   * Filtering stuff
   */
  init: function (opts) {
    this._filtersDiv = $('#changelist-filter')
    this.t = new Translator($('html').attr('lang'))
    this.filtersInModal = opts.changelistFiltersInModal
    this.filtersAlwaysOpen = opts.changelistFiltersAlwaysOpen
    this.initTemplates()
    if (this._filtersDiv.length) {
      this.activate()
    }
  },
  activate: function () {
    if ($('.changelist-form-container').length) { // django >= 3.1
      $('#changelist-filter').appendTo($('.changelist-form-container'))
    }
    if (this.filtersAlwaysOpen) {
      $(document.body).addClass('changelist-filter-active changelist-filter-always-open')
    } else {
      // filters active?
      let _activeFilters = /__[^=]+=/.test(location.search)
      // actions ?
      let _activeActions = $('#changelist-form > .actions').length !== 0
      let _changelistForm = $('#changelist-form')
      let _filtersToggler = $('<a />', {
        class:
          'changelist-filter-toggler' +
          (_activeFilters ? ' active' : '') + (_activeActions ? ' with-actions' : '')
      })
        .html('<i class="fa fa-filter"></i> <span>' + this.t.get('filter') + '</span>')

      if (this.filtersInModal || parseInt($(window).width()) < breakpoints.lg) {
        let self = this
        // wait for filters used js to exec
        setTimeout(function () {
          $('#changelist-filter').prop('id', 'changelist-filter-modal')
          let titleEl = $('#changelist-filter-modal > h2')
          let title = titleEl.html()
          titleEl.remove()
          let content = $('#changelist-filter-modal')
          // remove from dom
          self.modal = new Modal({
            title,
            content,
            size: 'md',
            hideFooter: true,
          })
          _filtersToggler
            .click(() => {
              self.modal.toggle()
            })
        }, 100)
      } else {
        _filtersToggler
          .click(() => {
            $(document.body).toggleClass('changelist-filter-active')
            if (parseInt(this._filtersDiv.css('max-width')) === 100) { // diff between mobile and lg
              $('html,body').animate({ scrollTop: this._filtersDiv.offset().top })
            }
          })
      }
      _changelistForm.prepend(_filtersToggler)
    }
    if (/_popup=1/.test(location.href)) {
      $('#changelist-form .results').css('padding-top', '78px')
    }<commit_msg>adds more delay in prev commit<commit_after>import $ from 'jquery'
import Translator from './i18n'
import Modal from './Modal'
import breakpoints from './Breakpoints'

let ChangeList = {
  /**
   * ChangeList component
   *
   * Filtering stuff
   */
  init: function (opts) {
    this._filtersDiv = $('#changelist-filter')
    this.t = new Translator($('html').attr('lang'))
    this.filtersInModal = opts.changelistFiltersInModal
    this.filtersAlwaysOpen = opts.changelistFiltersAlwaysOpen
    this.initTemplates()
    if (this._filtersDiv.length) {
      this.activate()
    }
  },
  activate: function () {
    if ($('.changelist-form-container').length) { // django >= 3.1
      $('#changelist-filter').appendTo($('.changelist-form-container'))
    }
    if (this.filtersAlwaysOpen) {
      $(document.body).addClass('changelist-filter-active changelist-filter-always-open')
    } else {
      // filters active?
      let _activeFilters = /__[^=]+=/.test(location.search)
      // actions ?
      let _activeActions = $('#changelist-form > .actions').length !== 0
      let _changelistForm = $('#changelist-form')
      let _filtersToggler = $('<a />', {
        class:
          'changelist-filter-toggler' +
          (_activeFilters ? ' active' : '') + (_activeActions ? ' with-actions' : '')
      })
        .html('<i class="fa fa-filter"></i> <span>' + this.t.get('filter') + '</span>')

      if (this.filtersInModal || parseInt($(window).width()) < breakpoints.lg) {
        let self = this
        // wait for filters used js to exec
        setTimeout(function () {
          $('#changelist-filter').prop('id', 'changelist-filter-modal')
          let titleEl = $('#changelist-filter-modal > h2')
          let title = titleEl.html()
          titleEl.remove()
          let content = $('#changelist-filter-modal')
          // remove from dom
          self.modal = new Modal({
            title,
            content,
            size: 'md',
            hideFooter: true,
          })
          _filtersToggler
            .click(() => {
              self.modal.toggle()
            })
        }, 200)
      } else {
        _filtersToggler
          .click(() => {
            $(document.body).toggleClass('changelist-filter-active')
            if (parseInt(this._filtersDiv.css('max-width')) === 100) { // diff between mobile and lg
              $('html,body').animate({ scrollTop: this._filtersDiv.offset().top })
            }
          })
      }
      _changelistForm.prepend(_filtersToggler)
    }
    if (/_popup=1/.test(location.href)) {
      $('#changelist-form .results').css('padding-top', '78px')
    }
{'fraction_non_alphanumeric': 0.16314888762122076, 'fraction_numerical': 0.005704506560182544, 'mean_word_length': 2.199513381995134, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '4545837', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1565, 'n_words': 291}