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

module.exports =

class ShortcutsModal extends kd.ModalView

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

    options.title   or= 'Shortcuts'
    options.content or= """
      <div class='shortcuts-head'>
        <p>To change a shortcut, select it, click the key combination, and then type the new keys.</p>
      </div>
    """
    options.overlay  or= yes
    options.width    or= 540
    options.height   or= 600
    options.cssClass or= 'shortcuts-modal'

    super options, keyconfig


  viewAppended: ->

    @addSubView tabView = new kd.TabView

      hideHandleCloseIcons : true
      enableMoveTabHandle  : false
      cssClass             : 'shortcuts-tab'

      paneData: @data.map (collection) ->
        displayData = defaults[collection.name]
        return {
          title    : displayData.title
          closable : no
          view     : new ShortcutsPane {},
            title       : displayData.title
            description : displayData.description
            collection  : collection
        }

    tabView.showPaneByIndex 0

    buttonBar = new kd.View
      cssClass: 'buttons'

    buttonBar.addSubView new kd.ButtonView
      title    : 'Restore Defaults'
      cssClass : 'solid light-gray medium'
      callback : kd.noop

    buttonBar.addSubView new kd.ButtonView
      title    : 'Save'
      cssClass : 'solid green medium'
      callback : kd.noop

    @addSubView buttonBar<commit_msg>Shortcuts: rearrange shortcuts modal to use modalviewwithforms<commit_after>kd            = require 'kd'
_             = require 'underscore'
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'
      tabs                    :
        hideHandleCloseIcons  : yes
        enableMoveTabHandle   : no
        cssClass              : 'shortcuts-tab'
        forms                 : @prepareTabData keyconfig

    super options


  viewAppended: ->

  prepareTabData: (keyconfig) ->

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

    return forms


{'fraction_non_alphanumeric': 0.07945552389996835, 'fraction_numerical': 0.005064893953782843, 'mean_word_length': 1.5320512820512822, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '5820473', 'n_tokens_mistral': 863, 'n_tokens_neox': 796, 'n_words': 207}