<commit_before>'use strict';

require('../touch/hammer');
require('../touch/prevent-ghosts');

var
  customEvents = {},
  gestures = ['tap', 'pan', 'pinch', 'press', 'rotate', 'swipe']
  ;

function decodeEvent(event) {
  if (event.indexOf('-') === -1) {
    return [event, null];
  }

  var direction = event.split('-');

  event = direction.shift();
  direction = direction[0] === 'x' ? Hammer.DIRECTION_HORIZONTAL : Hammer.DIRECTION_VERTICAL;

  return [event, direction];
}

/* istanbul ignore next */
Vue.directive('touch', {
  bind: function() {
    if (!this.el.hammer) {
      this.el.hammer = new Hammer.Manager(this.el);
    }

    var mc = this.mc = this.el.hammer;

    quasar.prevent.ghost.click(this.el);

    // determine event type
    var
      decodedEvent = decodeEvent(this.arg),
      event = decodedEvent[0],
      direction = decodedEvent[1],
      recognizerType, recognizer
      ;

    if (customEvents[event]) { // custom event
      var custom = customEvents[event];

      recognizerType = custom.type;
      recognizer = new Hammer[_.capitalize(recognizerType)](custom);
      recognizer.recognizeWith(mc.recognizers);
      mc.add(recognizer);

      return; // EARLY EXIT
    }

    if (!_.includes(gestures, event)) {
      throw new Error('Invalid v-touch event: ' + event);
    }

    recognizer = mc.get(event);
    if (recognizer) {
      if (!direction || recognizer.options.direction === direction) {
        return;
      }
    }

    // add recognizer
    recognizer = new Hammer[_.capitalize(event)]();
    if (direction) {
      recognizer.options.direction = direction;
    }
    // make sure multiple recognizers work together...
    recognizer.recognizeWith(mc.recognizers);
    mc.add(recognizer);
  },

  update: function(fn) {
    var
      mc = this.mc,
      vm = this.vm,<commit_msg>fix: Ghost click on touch directive (non tap) inhibited click/tap events<commit_after>'use strict';

require('../touch/hammer');
require('../touch/prevent-ghosts');

var
  customEvents = {},
  gestures = ['tap', 'pan', 'pinch', 'press', 'rotate', 'swipe']
  ;

function decodeEvent(event) {
  if (event.indexOf('-') === -1) {
    return [event, null];
  }

  var direction = event.split('-');

  event = direction.shift();
  direction = direction[0] === 'x' ? Hammer.DIRECTION_HORIZONTAL : Hammer.DIRECTION_VERTICAL;

  return [event, direction];
}

/* istanbul ignore next */
Vue.directive('touch', {
  bind: function() {
    if (!this.el.hammer) {
      this.el.hammer = new Hammer.Manager(this.el);
    }

    var mc = this.mc = this.el.hammer;

    // determine event type
    var
      decodedEvent = decodeEvent(this.arg),
      event = decodedEvent[0],
      direction = decodedEvent[1],
      recognizerType, recognizer
      ;

    if (customEvents[event]) { // custom event
      var custom = customEvents[event];

      recognizerType = custom.type;
      recognizer = new Hammer[_.capitalize(recognizerType)](custom);
      recognizer.recognizeWith(mc.recognizers);
      mc.add(recognizer);

      return; // EARLY EXIT
    }

    if (!_.includes(gestures, event)) {
      throw new Error('Invalid v-touch event: ' + event);
    }

    if (event === 'tap') {
      quasar.prevent.ghost.click(this.el);
    }

    recognizer = mc.get(event);
    if (recognizer) {
      if (!direction || recognizer.options.direction === direction) {
        return;
      }
    }

    // add recognizer
    recognizer = new Hammer[_.capitalize(event)]();
    if (direction) {
      recognizer.options.direction = direction;
    }
    // make sure multiple recognizers work together...
    recognizer.recognizeWith(mc.recognizers);
    mc.add(recognizer);
  },

  update: function(fn) {
    var
      mc = this.mc,
      vm = this.vm,
{'fraction_non_alphanumeric': 0.15276301806588735, 'fraction_numerical': 0.0021253985122210413, 'mean_word_length': 2.7574850299401197, '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': '352943', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1186, 'n_words': 254}