<commit_before>PaletteStore    = require "../stores/palette-store"
CodapStore      = require "../stores/codap-store"
GoogleFileStore = require "../stores/google-file-store"
HashParams      = require "../utils/hash-parameters"
tr              = require '../utils/translate'
AppSettingsStore = require '../stores/app-settings-store'

module.exports =

  getInitialAppViewState: (subState) ->
    mixinState =
      selectedNode: null
      selectedConnection: null
      palette: []
      filename: null
      undoRedoShowing: true
      showBuildInfo: false
    _.extend mixinState, subState

  componentDidUpdate: ->
    log.info 'Did Update: AppView'

  addTouchDeviceHandler: (add) ->
    if add
      $(window).on 'touchstart', (e) ->
        AppSettingsStore.actions.setTouchDevice true
        $(window).off 'touchstart'
    else
      $(window).off 'touchstart'

  addDeleteKeyHandler: (add) ->
    if add
      if AppSettingsStore.store.settings.lockdown
        # In Lockdown mode users can only remove relationships between links
        deleteFunction = @props.graphStore.removeSelectedLinks.bind @props.graphStore
      else
        deleteFunction = @props.graphStore.deleteSelected.bind @props.graphStore

      $(window).on 'keydown', (e) ->
        # 8 is backspace, 46 is delete
        if e.which in [8, 46] and not $(e.target).is('input, textarea')
          e.preventDefault()
          deleteFunction()
    else
      $(window).off 'keydown'

  componentDidMount: ->
    @addDeleteKeyHandler true
    @addTouchDeviceHandler true<commit_msg>Check for major userAgent strings to reduce ui changes based on user interaction<commit_after>PaletteStore    = require "../stores/palette-store"
CodapStore      = require "../stores/codap-store"
GoogleFileStore = require "../stores/google-file-store"
HashParams      = require "../utils/hash-parameters"
tr              = require '../utils/translate'
AppSettingsStore = require '../stores/app-settings-store'

module.exports =

  getInitialAppViewState: (subState) ->
    mixinState =
      selectedNode: null
      selectedConnection: null
      palette: []
      filename: null
      undoRedoShowing: true
      showBuildInfo: false
    _.extend mixinState, subState

  componentDidUpdate: ->
    log.info 'Did Update: AppView'

  addTouchDeviceHandler: (add) ->
    isMobileDevice = /Android|webOS|iPhone|iPad|iPod|Opera Mini/i.test navigator.userAgent
    if isMobileDevice
      AppSettingsStore.actions.setTouchDevice true
    else if add
      $(window).on 'touchstart', (e) ->
        AppSettingsStore.actions.setTouchDevice true
        $(window).off 'touchstart'
    else
      $(window).off 'touchstart'

  addDeleteKeyHandler: (add) ->
    if add
      if AppSettingsStore.store.settings.lockdown
        # In Lockdown mode users can only remove relationships between links
        deleteFunction = @props.graphStore.removeSelectedLinks.bind @props.graphStore
      else
        deleteFunction = @props.graphStore.deleteSelected.bind @props.graphStore

      $(window).on 'keydown', (e) ->
        # 8 is backspace, 46 is delete
        if e.which in [8, 46] and not $(e.target).is('input, textarea')
          e.preventDefault()
          deleteFunction()
    else
      $(window).off 'keydown'

  componentDidMount: ->
    @addDeleteKeyHandler true
    @addTouchDeviceHandler true
{'fraction_non_alphanumeric': 0.10673822301729279, 'fraction_numerical': 0.0035778175313059034, 'mean_word_length': 2.843069873997709, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '498629', 'n_tokens_mistral': 962, 'n_tokens_neox': 938, 'n_words': 232}