<commit_before>define(
  'ephox.alloy.ui.slider.SliderParts',

  [
    'ephox.alloy.api.behaviour.Behaviour',
    'ephox.alloy.api.behaviour.Focusing',
    'ephox.alloy.api.behaviour.Keying',
    'ephox.alloy.construct.EventHandler',
    'ephox.alloy.parts.PartType',
    'ephox.alloy.ui.slider.SliderActions',
    'ephox.boulder.api.FieldSchema',
    'ephox.katamari.api.Cell',
    'ephox.katamari.api.Fun',
    'ephox.katamari.api.Option',
    'ephox.sand.api.PlatformDetection'
  ],

  function (Behaviour, Focusing, Keying, EventHandler, PartType, SliderActions, FieldSchema, Cell, Fun, Option, PlatformDetection) {
    var platform = PlatformDetection.detect();
    var isTouch = platform.deviceType.isTouch();

    var noSketch = { sketch: Fun.identity };

    var edgePart = function (name, action) {
      return PartType.optional(
        noSketch, [ ], '' + name + '-edge', '<alloy.slider.' + name + '-edge>',
        Fun.constant({ }),
        function (detail) {
          var uiEvents = isTouch ? {
            touchstart: EventHandler.nu({
              run: function (l) {
                action(l, detail);
              }
            })
          } : {
            mousedown: EventHandler.nu({
              run: function (l) {
                action(l, detail);
              }
            }),

            'mousemove': EventHandler.nu({
              run: function (l, simulatedEvent) {
                if (detail.mouseIsDown().get()) {
                  action(l, detail);
                }
              }
            })
          };

          return {
            events: uiEvents
          };
        }
      );
    };

    // When the user touches the left edge, it should move the thumb
    var ledgePart = edgePart('left', SliderActions.setToLedge);

    // When the user touches the right edge, it should move the thumb
    var redgePart = edgePart('right', SliderActions.setToRedge);

    // The thumb part needs to have position absolute to be positioned correctly
    var thumbPart = PartType.internal(
      noSketch, [ ], 'thumb', '<alloy.slider.thumb>',
      Fun.constant({
        dom: {
          styles: { position: 'absolute' }
        }
      }),
      Fun.constant({ })
    );

    var spectrumPart = PartType.internal(
      noSketch, [
        FieldSchema.state('mouseIsDown', function () { return Cell(false); })
      ], 'spectrum', '<alloy.slider.spectrum>',
      Fun.constant({ }),
      function (detail) {

        var moveToX = function (spectrum, simulatedEvent) {
          var spectrumBounds = spectrum.element().dom().getBoundingClientRect();
          SliderActions.setXFromEvent(spectrum, detail, spectrumBounds, simulatedEvent);
        };

        var uiEvents = PlatformDetection.detect().deviceType.isTouch() ? {
          touchstart: EventHandler.nu({
            run: moveToX
          }),
          touchmove: EventHandler.nu({
            run: moveToX
          })
        } : {
          'mousedown': EventHandler.nu({
            run: moveToX
          }),

          'mousemove': EventHandler.nu({
            run: function (spectrum, simulatedEvent) {
              if (detail.mouseIsDown().get()) moveToX(spectrum, simulatedEvent);
            }
          })
        };

        return {
          behaviours: Behaviour.derive([
            // Move left and right along the spectrum
            Keying.config({
              mode: 'special',
              onLeft: function (spectrum) {
                SliderActions.moveLeft(spectrum, detail);
                return Option.some(true);
              },
              onRight: function (spectrum) {
                SliderActions.moveRight(spectrum, detail);
                return Option.some(true);
              }
            }),
            // TODO: Do not allow keyboard focus on mobile (TM-25)
            Focusing.config({ })
          ]),

          events: uiEvents
        };
      }
    );

    return [
      ledgePart,
      redgePart,
      thumbPart,
      spectrumPart
    ];
  }
);<commit_msg>TM-34: Merge remote-tracking branch 'origin/master' into TM-34<commit_after>define(
  'ephox.alloy.ui.slider.SliderParts',

  [
    'ephox.alloy.api.behaviour.Behaviour',
    'ephox.alloy.api.behaviour.Focusing',
    'ephox.alloy.api.behaviour.Keying',
    'ephox.alloy.construct.EventHandler',
    'ephox.alloy.parts.PartType',
    'ephox.alloy.ui.slider.SliderActions',
    'ephox.boulder.api.FieldSchema',
    'ephox.katamari.api.Cell',
    'ephox.katamari.api.Fun',
    'ephox.katamari.api.Option',
    'ephox.sand.api.PlatformDetection'
  ],

  function (Behaviour, Focusing, Keying, EventHandler, PartType, SliderActions, FieldSchema, Cell, Fun, Option, PlatformDetection) {
    var platform = PlatformDetection.detect();
    var isTouch = platform.deviceType.isTouch();

    var noSketch = { sketch: Fun.identity };

    var edgePart = function (name, action) {
      return PartType.optional(
        noSketch, [ ], '' + name + '-edge', '<alloy.slider.' + name + '-edge>',
        Fun.constant({ }),
        function (detail) {
          var uiEvents = isTouch ? {
            touchstart: EventHandler.nu({
              run: function (l) {
                action(l, detail);
              }
            })
          } : {
            mousedown: EventHandler.nu({
              run: function (l) {
                action(l, detail);
              }
            }),

            'mousemove': EventHandler.nu({
              run: function (l, simulatedEvent) {
                if (detail.mouseIsDown().get()) {
                  action(l, detail);
                }
              }
            })
          };

          return {
            events: uiEvents
          };
        }
      );
    };

    // When the user touches the left edge, it should move the thumb
    var ledgePart = edgePart('left', SliderActions.setToLedge);

    // When the user touches the right edge, it should move the thumb
    var redgePart = edgePart('right', SliderActions.setToRedge);

    // The thumb part needs to have position absolute to be positioned correctly
    var thumbPart = PartType.internal(
      noSketch, [ ], 'thumb', '<alloy.slider.thumb>',
      Fun.constant({
        dom: {
          styles: { position: 'absolute' }
        }
      }),
      Fun.constant({ })
    );

    var spectrumPart = PartType.internal(
      noSketch, [
        FieldSchema.state('mouseIsDown', function () { return Cell(false); })
      ], 'spectrum', '<alloy.slider.spectrum>',
      Fun.constant({ }),
      function (detail) {

        var moveToX = function (spectrum, simulatedEvent) {
          var spectrumBounds = spectrum.element().dom().getBoundingClientRect();
          SliderActions.setXFromEvent(spectrum, detail, spectrumBounds, simulatedEvent);
        };

        var uiEvents = PlatformDetection.detect().deviceType.isTouch() ? {
          touchstart: EventHandler.nu({
            run: moveToX
          }),
          touchmove: EventHandler.nu({
            run: moveToX
          })
        } : {
          'mousedown': EventHandler.nu({
            run: moveToX
          }),

          'mousemove': EventHandler.nu({
            run: function (spectrum, simulatedEvent) {
              if (detail.mouseIsDown().get()) moveToX(spectrum, simulatedEvent);
            }
          })
        };

        return {
          behaviours: Behaviour.derive(isTouch ? [ ] : [
            // Move left and right along the spectrum
            Keying.config({
              mode: 'special',
              onLeft: function (spectrum) {
                SliderActions.moveLeft(spectrum, detail);
                return Option.some(true);
              },
              onRight: function (spectrum) {
                SliderActions.moveRight(spectrum, detail);
                return Option.some(true);
              }
            }),
            Focusing.config({ })
          ]),

          events: uiEvents
        };
      }
    );

    return [
      ledgePart,
      redgePart,
      thumbPart,
      spectrumPart
    ];
  }
);
{'fraction_non_alphanumeric': 0.12403774521976657, 'fraction_numerical': 0.0007449714427613609, 'mean_word_length': 1.7444633730834753, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1209149', 'n_tokens_mistral': 2318, 'n_tokens_neox': 2252, 'n_words': 459}