<commit_before>import Component from 'flarum/component';
import UserCard from 'flarum/components/user-card';
import avatar from 'flarum/helpers/avatar';
import username from 'flarum/helpers/username';
import listItems from 'flarum/helpers/list-items';

/**
  Component for the username/avatar in a post header.
 */
export default class PostHeaderUser extends Component {
  constructor(props) {
    super(props);

    this.showCard = m.prop(false);
  }

  view() {
    var post = this.props.post;
    var user = post.user();

    return m('div.post-user', {config: this.onload.bind(this)}, [
      m('h3',
        user ? [
          m('a', {href: app.route('user', {username: user.username()}), config: m.route}, [
            avatar(user),
            username(user)
          ]),
          m('ul.badges', listItems(user.badges().toArray().reverse()))
        ] : [
          avatar(),
          username()
        ]
      ),
      user && !post.isHidden() && this.showCard()
        ? UserCard.component({user, className: 'user-card-popover fade', controlsButtonClass: 'btn btn-default btn-icon btn-sm btn-naked'})
        : ''
    ]);
  }

  onload(element, isInitialized) {
    if (isInitialized) { return; }

    this.element(element);

    var component = this;
    var timeout;
    this.$().bind('mouseover', '> a, .user-card', function() {
      clearTimeout(timeout);
      timeout = setTimeout(function() {
        component.showCard(true);
        m.redraw();
        setTimeout(() => component.$('.user-card').addClass('in'));
      }, 500);
    }).bind('mouseout', '> a, .user-card', function() {
      clearTimeout(timeout);
      timeout = setTimeout(function() {
        component.$('.user-card').removeClass('in').one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
          component.showCard(false);
          m.redraw();
        });
      }, 250);
    });
  }
}<commit_msg>Tweak user card hover trigger<commit_after>import Component from 'flarum/component';
import UserCard from 'flarum/components/user-card';
import avatar from 'flarum/helpers/avatar';
import username from 'flarum/helpers/username';
import listItems from 'flarum/helpers/list-items';

/**
  Component for the username/avatar in a post header.
 */
export default class PostHeaderUser extends Component {
  constructor(props) {
    super(props);

    this.showCard = m.prop(false);
  }

  view() {
    var post = this.props.post;
    var user = post.user();

    return m('div.post-user', {config: this.onload.bind(this)}, [
      m('h3',
        user ? [
          m('a', {href: app.route('user', {username: user.username()}), config: m.route}, [
            avatar(user),
            username(user)
          ]),
          m('ul.badges', listItems(user.badges().toArray().reverse()))
        ] : [
          avatar(),
          username()
        ]
      ),
      user && !post.isHidden() && this.showCard()
        ? UserCard.component({user, className: 'user-card-popover fade', controlsButtonClass: 'btn btn-default btn-icon btn-sm btn-naked'})
        : ''
    ]);
  }

  onload(element, isInitialized) {
    if (isInitialized) { return; }

    this.element(element);

    var component = this;
    var timeout;
    this.$().on('mouseover', 'h3 a, .user-card', function() {
      clearTimeout(timeout);
      timeout = setTimeout(function() {
        component.showCard(true);
        m.redraw();
        setTimeout(() => component.$('.user-card').addClass('in'));
      }, 500);
    }).on('mouseout', 'h3 a, .user-card', function() {
      clearTimeout(timeout);
      timeout = setTimeout(function() {
        component.$('.user-card').removeClass('in').one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
          component.showCard(false);
          m.redraw();
        });
      }, 250);
    });
  }
}
{'fraction_non_alphanumeric': 0.1660631143300569, 'fraction_numerical': 0.004138644593895499, 'mean_word_length': 2.6793529971455756, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4430291', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1154, 'n_words': 236}