<commit_before>

class Apollos.Controls.NumberKeyboard extends Apollos.Component
  @register "Apollos.Controls.NumberKeyboard"


  vars: -> [
    cancelClick: false
  ]

  events: -> [

    "click": @.stop

    "touchstart [data-key]": @.clickedDataKey
    "click [data-key]": @.clickedDataKey

    "click [data-close], touchstart [data-close]": @.dismiss

  ]

  stop: (event) ->

    event.stopPropagation()
    event.preventDefault()



  onCreated: ->

    self = @
    typedText = @.data().amount
    @.parent = @.data().parent

    if not typedText
      console.error "you must pass a reactive var in to store the amount"
      return


  onRendered: ->
    self = @

    $(document).off("keyup").on "keyup", (event) ->
      if event.which >= 48 and event.which <= 57
        numPressed = event.which - 48

      else if event.which >= 96 and event.which <= 105
        numPressed = event.which - 96

      else if event.which is 46
        numPressed = -1

      else if event.which is 190 or event.which is 110
        numPressed = "."

      if typeof numPressed isnt "undefined"
        self.doPressAnimation $("[data-key=\"#{numPressed}\"]")
        self.processTypedText numPressed
        # self.parent().updateFund self.typedText.get()



  onDestroyed: ->
    $(document).off("keyup")


  dismiss: (event) ->
    @.parent?.keyboardInstance = null

    Blaze.remove @._internals.templateInstance.view
    return

  insertDOMElement: (parent, node, before) ->
    $(node)
      .appendTo(parent)
      # .velocity("transition.slideUpIn", { duration: 500 })
      .velocity({translateY: [0, 200], translateZ: 0}, {duration: 250})
    super

  removeDOMElement: (parent, node) ->
    self = @

    $(node).velocity({
      translateY: 250, translateZ: 0
    }, {
      duration: 250
      complete: (elements) ->
        $(node).remove()
    })

  clickedDataKey: (event, template) ->

    if event.type is "touchstart"
      @.cancelClick.set true
    else if @.cancelClick.get()
      @.cancelClick.set false
      return

    @.doPressAnimation event.currentTarget
    keyPressed = event.currentTarget.getAttribute "data-key"
    @.processTypedText keyPressed

    # @.parent().updateFund @.typedText.get()


<commit_msg>Stop propgation of touch and click events<commit_after>

class Apollos.Controls.NumberKeyboard extends Apollos.Component
  @register "Apollos.Controls.NumberKeyboard"


  vars: -> [
    cancelClick: false
  ]

  events: -> [

    "click [data-key], touchstart [data-key]": @.clickedDataKey

    "click [data-close], touchstart [data-close]": @.dismiss

  ]

  stop: (event) ->

    event.stopPropagation()
    event.preventDefault()


  onCreated: ->

    self = @
    typedText = @.data().amount
    @.parent = @.data().parent

    if not typedText
      console.error "you must pass a reactive var in to store the amount"
      return


  onRendered: ->
    self = @

    $(document).off("keyup").on "keyup", (event) ->
      if event.which >= 48 and event.which <= 57
        numPressed = event.which - 48

      else if event.which >= 96 and event.which <= 105
        numPressed = event.which - 96

      else if event.which is 46
        numPressed = -1

      else if event.which is 190 or event.which is 110
        numPressed = "."

      if typeof numPressed isnt "undefined"
        self.doPressAnimation $("[data-key=\"#{numPressed}\"]")
        self.processTypedText numPressed
        # self.parent().updateFund self.typedText.get()



  onDestroyed: ->
    $(document).off("keyup")


  dismiss: (event) ->
    @.parent?.keyboardInstance = null

    Blaze.remove @._internals.templateInstance.view

    @.stop(event)

    return

  insertDOMElement: (parent, node, before) ->
    $(node)
      .appendTo(parent)
      # .velocity("transition.slideUpIn", { duration: 500 })
      .velocity({translateY: [0, 200], translateZ: 0}, {duration: 250})
    super

  removeDOMElement: (parent, node) ->
    self = @

    $(node).velocity({
      translateY: 250, translateZ: 0
    }, {
      duration: 250
      complete: (elements) ->
        $(node).remove()
    })

  clickedDataKey: (event, template) ->

    if event.type is "touchstart"
      @.cancelClick.set true
    else if @.cancelClick.get()
      @.cancelClick.set false
      return

    @.doPressAnimation event.currentTarget
    keyPressed = event.currentTarget.getAttribute "data-key"
    @.processTypedText keyPressed

    # @.parent().updateFund @.typedText.get()

    @.stop(event)



{'fraction_non_alphanumeric': 0.13589857651245552, 'fraction_numerical': 0.017793594306049824, 'mean_word_length': 2.510538641686183, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 31, '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': '2653566', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1393, 'n_words': 337}