<commit_before>kd            = require 'kd'
_             = require 'lodash'
ShortcutsPane = require './pane'
defaults      = require '../config'

module.exports = class ShortcutsModal extends kd.ModalViewWithForms

  constructor: (options={}, keyconfig) ->

    options =
      title                   : 'Shortcuts'
      cssClass                : 'shortcuts-modal'
      overlay                 : yes
      width                   : 640
      height                  : 'auto'
      buttons                 :
        restore               :
          title               : 'Restore Defaults'
          style               : 'solid light-gray medium'
          loader              : color : '#444444'
          callback            : -> modal.destroy()
        save                  :
          title               : 'Save'
          cssClass            : 'solid green medium'
          callback            : =>
            # poc code - SY
            console.log "this is fake!!!"
            new kd.NotificationView title : 'Shortcuts saved!'
            @modalTabs.getActivePane().form.inputs.view.listController.getListItems().forEach (item) ->
              item.unsetClass 'updated'
      tabs                    :
        hideHandleCloseIcons  : yes
        enableMoveTabHandle   : no
        cssClass              : 'shortcuts-tab'
        forms                 : @prepareTabData keyconfig

    super options


  viewAppended: ->

    @modalTabs.on 'PaneDidShow', => kd.utils.defer @bound '_windowDidResize'

    @_windowDidResize()


  prepareTabData: (keyconfig) ->

    forms = {}
    keyconfig.forEach (collection) ->
      displayData = defaults[collection.name]
      forms[displayData.title] =
        fields                :
          view                :
            itemClass         : ShortcutsPane
            description       : displayData.description
            collection        : collection

    return forms


  _windowDidResize: ->

    {innerHeight} = window
    titleHeight   = @$('.kdmodal-title').outerHeight no
    handleHeight  = @$('.kdtabhandlecontainer').outerHeight no<commit_msg>shortcuts: adjust modal to new design<commit_after>kd            = require 'kd'
_             = require 'lodash'
ShortcutsPane = require './pane'

module.exports =

class ShortcutsModal extends kd.ModalViewWithForms

  constructor: (options, @config) ->

    super _.extend

      title    : 'Shortcuts'
      content  : """
        <div class=instructions>
          To change a shortcut, click the key combination, then type the new keys.
        </div>
      """
      cssClass : 'shortcuts-modal'
      overlay  : yes
      width    : 600
      height   : 'auto'

      buttons:
        restore:
          title    : 'Restore Defaults'
          style    : 'solid light-gray medium'
          loader   : color: '#444444'
          #callback : -> modal.destroy()

      tabs:
        hideHandleCloseIcons : yes
        enableMoveTabHandle  : no
        forms                : @presentForms()

    , options


  presentForms: ->

    @config.reduce (acc, collection) ->
      acc[collection.title] =
        fields:
          view:
            itemClass: ShortcutsPane
            collection: collection
      return acc
    , {}


  viewAppended: ->

    @modalTabs.on 'PaneDidShow', => kd.utils.defer @bound '_windowDidResize'
    @_windowDidResize()


  _windowDidResize: ->

    {innerHeight} = window
    titleHeight   = @$('.kdmodal-title').outerHeight no
    handleHeight  = @$('.kdtabhandlecontainer').outerHeight no
{'fraction_non_alphanumeric': 0.09396162528216705, 'fraction_numerical': 0.005079006772009029, 'mean_word_length': 1.537580529706514, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '5925939', 'n_tokens_mistral': 975, 'n_tokens_neox': 911, 'n_words': 214}