<commit_before>class EnvironmentItem extends KDDiaObject

  JView.mixin @prototype

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

    options.cssClass       = KD.utils.curry "environments-item", options.cssClass
    options.bind           = KD.utils.curry "contextmenu", options.bind
    options.jointItemClass = EnvironmentItemJoint
    options.draggable      = no
    options.colorTag      ?= "#1AAF5D"

    super options, data

    @chevron   = new KDCustomHTMLView
      tagName  : "span"
      cssClass : "chevron"
      click    : @bound "contextMenu"

  contextMenuItems:->

    colorSelection = new ColorSelection
      selectedColor : @getOption 'colorTag'
    colorSelection.on "ColorChanged", @bound 'setColorTag'

    items =
      Delete      :
        disabled  : KD.isGuest()
        separator : yes
        action    : 'delete'
      customView  : colorSelection

    return items

  contextMenu:(event)->

    KD.utils.stopDOMEvent event

    menuItems = @contextMenuItems()
    return  unless menuItems

    ctxMenu = new KDContextMenu
      menuWidth   : 187
      delegate    : this
      x           : event.pageX
      y           : event.pageY
      lazyLoad    : yes
    ,
      menuItems

    ctxMenu.on 'ContextMenuItemReceivedClick', (item) =>
      {action} = item.getData()
      ctxMenu.destroy()  if @["cm#{action}"]?
      @["cm#{action}"]?()

  # - Context Menu Actions - #

  cmdelete : -> @confirmDestroy?()
  cmunfocus: -> @parent.emit 'UnhighlightDias'

  setColorTag : (color, save = yes) ->

    @options.colorTag = color
    @saveColorTag color  if save
    @parent.emit 'UpdateScene'

  saveColorTag:(color)->

    return unless @parent?.appStorage

    colorTags = (@parent.appStorage.getValue 'colorTags') or {}
    name      = @constructor.name
    uid       = @getData().uid
    colorTags["#{name}-#{uid}"] = color

    @parent.appStorage.setValue 'colorTags', colorTags

  loadColorTag:->

    return unless @parent?.appStorage<commit_msg>EnvironmentItemsView: if callback defined destroy the menu<commit_after>class EnvironmentItem extends KDDiaObject

  JView.mixin @prototype

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

    options.cssClass       = KD.utils.curry "environments-item", options.cssClass
    options.bind           = KD.utils.curry "contextmenu", options.bind
    options.jointItemClass = EnvironmentItemJoint
    options.draggable      = no
    options.colorTag      ?= "#1AAF5D"

    super options, data

    @chevron   = new KDCustomHTMLView
      tagName  : "span"
      cssClass : "chevron"
      click    : @bound "contextMenu"

  contextMenuItems:->

    colorSelection = new ColorSelection
      selectedColor : @getOption 'colorTag'
    colorSelection.on "ColorChanged", @bound 'setColorTag'

    items =
      Delete      :
        disabled  : KD.isGuest()
        separator : yes
        action    : 'delete'
      customView  : colorSelection

    return items

  contextMenu:(event)->

    KD.utils.stopDOMEvent event

    menuItems = @contextMenuItems()
    return  unless menuItems

    ctxMenu = new KDContextMenu
      menuWidth   : 187
      delegate    : this
      x           : event.pageX
      y           : event.pageY
      lazyLoad    : yes
    ,
      menuItems

    ctxMenu.on 'ContextMenuItemReceivedClick', (item) =>
      {action, callback} = item.getData()
      ctxMenu.destroy()  if callback? or @["cm#{action}"]?
      @["cm#{action}"]?()

  # - Context Menu Actions - #

  cmdelete : -> @confirmDestroy?()
  cmunfocus: -> @parent.emit 'UnhighlightDias'

  setColorTag : (color, save = yes) ->

    @options.colorTag = color
    @saveColorTag color  if save
    @parent.emit 'UpdateScene'

  saveColorTag:(color)->

    return unless @parent?.appStorage

    colorTags = (@parent.appStorage.getValue 'colorTags') or {}
    name      = @constructor.name
    uid       = @getData().uid
    colorTags["#{name}-#{uid}"] = color

    @parent.appStorage.setValue 'colorTags', colorTags

  loadColorTag:->

    return unless @parent?.appStorage
{'fraction_non_alphanumeric': 0.11025385764061722, 'fraction_numerical': 0.0024888003982080635, 'mean_word_length': 2.5192644483362523, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6538795', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1172, 'n_words': 268}