<commit_before>var Range = require('./range');
var requestAnimationFrame = require('./raf');

var Phantom = Range.extend({
  initialize: function initialize(options) {
    initialize.super$.call(this, $.extend({
      readonly: true,
      label: '+'
    }, options));
    this.$el.addClass('elessar-phantom');
  },

  mousedown: function(ev) {
    if(ev.which === 1) { // left mouse button
      var startX = ev.pageX;
      var newRange = this.options.parent.addRange(this.val());
      this.remove();
      this.options.parent.trigger('addrange', [newRange.val(), newRange]);
      requestAnimationFrame(function() {
        newRange.$el.find('.elessar-handle:first-child').trigger(ev.type);
      });
    }
  },

  removePhantom: function() {
    // NOOP
  }
});

module.exports = Phantom;<commit_msg>explicity attach mousedown handler on phantoms, fixes #38<commit_after>var $ = require('jquery');
var Range = require('./range');
var requestAnimationFrame = require('./raf');

var Phantom = Range.extend({
  initialize: function initialize(options) {
    initialize.super$.call(this, $.extend({
      readonly: true,
      label: '+'
    }, options));
    this.$el.addClass('elessar-phantom');
    this.on('mousedown touchstart', $.proxy(this.mousedown, this));
  },

  mousedown: function(ev) {
    if(ev.which === 1) { // left mouse button
      var startX = ev.pageX;
      var newRange = this.options.parent.addRange(this.val());
      this.remove();
      this.options.parent.trigger('addrange', [newRange.val(), newRange]);
      requestAnimationFrame(function() {
        newRange.$el.find('.elessar-handle:first-child').trigger(ev.type);
      });
    }
  },

  removePhantom: function() {
    // NOOP
  }
});

module.exports = Phantom;
{'fraction_non_alphanumeric': 0.17495711835334476, 'fraction_numerical': 0.002287021154945683, 'mean_word_length': 3.2579075425790753, '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': '1722823', 'n_tokens_mistral': 557, 'n_tokens_neox': 534, 'n_words': 98}