<commit_before>/*
==================================================================================================
  Core - JavaScript Foundation
  Copyright 2013 <NAME>
==================================================================================================
*/

"use strict";

(function() 
{
  var maxClickMovement = 5;

  /**
   * #break(core.bom.PointerEventsNext)
   */
  core.Module("core.bom.TapEvent",
  {
    add : function(target, type, callback, context, capture)
    {
      // Hard-wire context to function, re-use existing bound functions
      if (context) {
        callback = core.Function.bind(callback, context);
      }

      var eventId = core.bom.event.Util.getId(type, callback, capture);
      var listeners = core.bom.event.Util.create(target, eventId);

      var downOn = null;
      var downX = -1000;
      var downY = -1000;

      listeners.down = function(e) 
      {
        if (!e.isPrimary) {
          return;
        }

        downOn = e.target;
        downX = e.offsetX;
        downY = e.offsetY;
      };

      listeners.up = function(e) 
      {
        if (!e.isPrimary) {
          return;
        }

        if (e.target == downOn && Math.abs(downX - e.offsetX) < maxClickMovement && Math.abs(downY - e.offsetY) < maxClickMovement) 
        {
          var eventObj = core.bom.event.type.Pointer.obtain(e, "tap");
          callback(eventObj);
          eventObj.release();
        }

        // Garbage collection
        downOn = null;
      };  

      core.bom.event.Util.addPointer(target, eventId, capture);
    },

    remove : function(target, type, callback, context, capture)
    {
      if (context != null) {
        callback = core.Function.bind(callback, context);
      }

      var eventId = core.bom.event.Util.getId(type, callback, capture);
      core.bom.event.Util.removePointer(target, eventId, capture);
    }
  });

})();
<commit_msg>More compact code<commit_after>/*
==================================================================================================
  Core - JavaScript Foundation
  Copyright 2013 Sebastian Werner
==================================================================================================
*/

"use strict";

(function() 
{
  var maxClickMovement = 5;
  var Util = core.bom.event.Util;

  /**
   * #break(core.bom.PointerEventsNext)
   */
  core.Module("core.bom.TapEvent",
  {
    add : function(target, type, callback, context, capture)
    {
      // Hard-wire context to function, re-use existing bound functions
      if (context) {
        callback = core.Function.bind(callback, context);
      }

      var eventId = Util.getId(type, callback, capture);
      var listeners = Util.create(target, eventId);

      var downOn = null;
      var downX = -1000;
      var downY = -1000;

      listeners.down = function(e) 
      {
        if (!e.isPrimary) {
          return;
        }

        downOn = e.target;
        downX = e.offsetX;
        downY = e.offsetY;
      };

      listeners.up = function(e) 
      {
        if (!e.isPrimary) {
          return;
        }

        if (e.target == downOn && Math.abs(downX - e.offsetX) < maxClickMovement && Math.abs(downY - e.offsetY) < maxClickMovement) 
        {
          var eventObj = core.bom.event.type.Pointer.obtain(e, "tap");
          callback(eventObj);
          eventObj.release();
        }

        // Garbage collection
        downOn = null;
      };  

      Util.addPointer(target, eventId, capture);
    },

    remove : function(target, type, callback, context, capture)
    {
      if (context != null) {
        callback = core.Function.bind(callback, context);
      }

      var eventId = Util.getId(type, callback, capture);
      Util.removePointer(target, eventId, capture);
    }
  });

})();

{'fraction_non_alphanumeric': 0.2216968741791437, 'fraction_numerical': 0.006829524560021014, 'mean_word_length': 2.352112676056338, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, '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': '6625692', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1082, 'n_words': 226}