<commit_before>/*
 *
 *
 *
 * Copyright (c) 2015 MediaSQ
 * Licensed under the MIT license.
 */
(function ($) {
  'use strict';

  var AT_SIGN_KEY_CODE = 64;

  var MENTIONER_WRAPPER_HOOK_CLASS = 'js-mentioner-wrapper';
  var MENTIONER_DROPDOWN_HOOK_CLASS = 'js-mentioner-dropdown';

  var Mentioner = function($root, settings) {
    this.$root = $root;
    this.mentionables = settings.onDataRequest ? settings.onDataRequest() : [];

    this._buildDOM();
    this._attachEvents();
  };

  Mentioner.prototype._buildDOM = function() {
    var $parent = $( '<div class="' + MENTIONER_WRAPPER_HOOK_CLASS + '"></div>' );
    this.$root.wrap($parent);

    var $dropdown = $( '<div class="' + MENTIONER_DROPDOWN_HOOK_CLASS + '"></div>' );
    this.getParentWrapper().append($dropdown);
  };

  Mentioner.prototype._attachEvents = function() {
    this.$root.on('keypress', this._onRootKeypress.bind(this));
  };

  Mentioner.prototype._onRootKeypress = function(event) {
    if(event.keyCode === AT_SIGN_KEY_CODE) {
      this.showDropdown();
    }
  };<commit_msg>Replace bind by closure for compatibility with PhantomJS<commit_after>/*
 *
 *
 *
 * Copyright (c) 2015 MediaSQ
 * Licensed under the MIT license.
 */
(function ($) {
  'use strict';

  var AT_SIGN_KEY_CODE = 64;

  var MENTIONER_WRAPPER_HOOK_CLASS = 'js-mentioner-wrapper';
  var MENTIONER_DROPDOWN_HOOK_CLASS = 'js-mentioner-dropdown';

  var Mentioner = function($root, settings) {
    this.$root = $root;
    this.mentionables = settings.onDataRequest ? settings.onDataRequest() : [];

    this._buildDOM();
    this._attachEvents();
  };

  Mentioner.prototype._buildDOM = function() {
    var $parent = $( '<div class="' + MENTIONER_WRAPPER_HOOK_CLASS + '"></div>' );
    this.$root.wrap($parent);

    var $dropdown = $( '<div class="' + MENTIONER_DROPDOWN_HOOK_CLASS + '"></div>' );
    this.getParentWrapper().append($dropdown);
  };

  Mentioner.prototype._attachEvents = function() {
    /*
     * Not using Function.prototype.bind because of incompatibilities
     * with PhantomJS
     *
     * Related bug: https://github.com/ariya/phantomjs/issues/10522
     */
    this.$root.on('keypress', this._onRootKeypress());
  };

  Mentioner.prototype._onRootKeypress = function() {
    var that = this;

    return function(event) {
      if(event.keyCode === AT_SIGN_KEY_CODE) {
        that.showDropdown();
      }
    };
  };
{'fraction_non_alphanumeric': 0.1546477699041267, 'fraction_numerical': 0.0070862859524802, 'mean_word_length': 3.5714285714285716, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '1842977', 'n_tokens_mistral': 842, 'n_tokens_neox': 804, 'n_words': 139}