<commit_before>define(
  'tinymce.themes.mobile.touch.view.TapToEditButton',

  [
    'ephox.alloy.api.behaviour.AdhocBehaviour',
    'ephox.alloy.api.behaviour.Behaviour',
    'ephox.alloy.api.events.AlloyEvents',
    'ephox.alloy.api.ui.TouchMenu',
    'ephox.katamari.api.Future',
    'ephox.katamari.api.Singleton',
    'ephox.sugar.api.properties.Attr',
    'ephox.sugar.api.properties.Class',
    'global!setTimeout',
    'tinymce.themes.mobile.touch.view.TapToEditMenuParts'
  ],

  function (AdhocBehaviour, Behaviour, AlloyEvents, TouchMenu, Future, Singleton, Attr, Class, setTimeout, TapToEditMenuParts) {
    var sketch = function (spec) {
      var state = Singleton.value();

      var gotoView = function (comp) {
        if (state.isSet()) spec.onView();
        state.clear();
      };

      var gotoEdit = function (comp) {
        if (state.isSet()) spec.onEdit();
        state.clear();
      };

      var updateIcon = function (comp, value) {
        var icon = spec.memIcon.get(comp);
        Attr.set(icon.element(), 'data-mode', value);
      };

      var updateState = function (comp, value) {
        updateIcon(comp, value);
        state.set(value);
      };

      var clearState = function (comp) {
        var icon = spec.memIcon.get(comp);
        Attr.remove(icon.element(), 'data-mode');
        state.clear();
      };

      return TouchMenu.sketch({
        dom: spec.dom,
        components: [
          TouchMenu.parts().sink()
        ].concat(spec.components),
   
        fetch: function () {
          return Future.pure([
            { type: 'item', data: { value: 'Edit', text: 'Edit' } }
          ]);
        },
        onExecute: function (comp, menuComp, item, data) {
          updateState(comp, data.value);
        },

        onHoverOn: function (comp) {
          Class.add(comp.element(), 'hovered');
          updateState(comp, 'View');
        },
        onHoverOff: function (comp) {
          Class.remove(comp.element(), 'hovered');
          clearState(comp);
        },

        onTap: function () {
          setTimeout(function () {
            gotoView();
          }, 300);
        },

        toggleClass: 'selected',

        transition: {
          property: 'transform',
          transitionClass: 'longpress-menu-transitioning'
        },

        onClosed: function (comp) {
          state.on(function (s) {
            if (s === 'Edit') gotoEdit(comp);
            else if (s === 'View') gotoView(comp);
          })
        },

        customBehaviours: [<commit_msg>TM-34-longpress: transition > menuTransition<commit_after>define(
  'tinymce.themes.mobile.touch.view.TapToEditButton',

  [
    'ephox.alloy.api.behaviour.AdhocBehaviour',
    'ephox.alloy.api.behaviour.Behaviour',
    'ephox.alloy.api.events.AlloyEvents',
    'ephox.alloy.api.ui.TouchMenu',
    'ephox.katamari.api.Future',
    'ephox.katamari.api.Singleton',
    'ephox.sugar.api.properties.Attr',
    'ephox.sugar.api.properties.Class',
    'global!setTimeout',
    'tinymce.themes.mobile.touch.view.TapToEditMenuParts'
  ],

  function (AdhocBehaviour, Behaviour, AlloyEvents, TouchMenu, Future, Singleton, Attr, Class, setTimeout, TapToEditMenuParts) {
    var sketch = function (spec) {
      var state = Singleton.value();

      var gotoView = function (comp) {
        if (state.isSet()) spec.onView();
        state.clear();
      };

      var gotoEdit = function (comp) {
        if (state.isSet()) spec.onEdit();
        state.clear();
      };

      var updateIcon = function (comp, value) {
        var icon = spec.memIcon.get(comp);
        Attr.set(icon.element(), 'data-mode', value);
      };

      var updateState = function (comp, value) {
        updateIcon(comp, value);
        state.set(value);
      };

      var clearState = function (comp) {
        var icon = spec.memIcon.get(comp);
        Attr.remove(icon.element(), 'data-mode');
        state.clear();
      };

      return TouchMenu.sketch({
        dom: spec.dom,
        components: [
          TouchMenu.parts().sink()
        ].concat(spec.components),
   
        fetch: function () {
          return Future.pure([
            { type: 'item', data: { value: 'Edit', text: 'Edit' } }
          ]);
        },
        onExecute: function (comp, menuComp, item, data) {
          updateState(comp, data.value);
        },

        onHoverOn: function (comp) {
          Class.add(comp.element(), 'hovered');
          updateState(comp, 'View');
        },
        onHoverOff: function (comp) {
          Class.remove(comp.element(), 'hovered');
          clearState(comp);
        },

        onTap: function () {
          setTimeout(function () {
            gotoView();
          }, 300);
        },

        toggleClass: 'selected',

        menuTransition: {
          property: 'transform',
          transitionClass: 'longpress-menu-transitioning'
        },

        onClosed: function (comp) {
          state.on(function (s) {
            if (s === 'Edit') gotoEdit(comp);
            else if (s === 'View') gotoView(comp);
          })
        },

        customBehaviours: [
{'fraction_non_alphanumeric': 0.14829268292682926, 'fraction_numerical': 0.0015609756097560976, 'mean_word_length': 2.051190476190476, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1789914', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1576, 'n_words': 284}