<commit_before>import Ember from 'ember'
import _ from 'lodash/lodash'
import FrostList from '../frost-list/component'

export default Ember.Component.extend({
  classNameBindings: ['isSelected', 'frost-list-item'],

  initContext: Ember.on('init', function () {
    this.set('_frostList', this.nearestOfType(FrostList))
  }),

  isSelected: Ember.computed.reads('model.isSelected'),

  onclick: Ember.on('click', function (event) {
    if (!(Ember.ViewUtils.isSimpleClick(event) || event.shiftKey || event.metaKey || event.ctrlKey)) {
      return true
    }

    event.preventDefault()
    event.stopPropagation()

    if (_.isFunction(this.get('_frostList.onSelect'))) {
      let isTargetSelectionIndicator = Ember.$(event.target).hasClass('frost-list-selection-indicator')
      if (event.shiftKey && (!this.get('_frostList.persistedClickState.isSelected')) && !this.get('isSelected')) {
        this.get('_frostList.onShiftSelect').call(this.get('_frostList'), {
          secondClickedRecord: this.get('model'),
          isTargetSelectionIndicator: isTargetSelectionIndicator
        })
      } else {
        this.get('_frostList.onSelect')({
          record: this.get('model'),
          isSelected: !this.get('model.isSelected'),
          isTargetSelectionIndicator: isTargetSelectionIndicator,
          isShiftSelect: false,
          isCtrlSelect: (event.metaKey || event.ctrlKey) && (!this.get('_frostList.persistedClickState.isSelected')) && !this.get('isSelected')
        })
      }
      this.set('_frostList.persistedClickState', {clickedRecord: this.get('model'), isSelected: this.get('isSelected')})
      this.get('isSelected') ? this.$().parent().removeClass('is-selected') : this.$().parent().addClass('is-selected')
    }
  })
})
<commit_msg>Clear selection when shift click<commit_after>import Ember from 'ember'
import _ from 'lodash/lodash'
import FrostList from '../frost-list/component'

export default Ember.Component.extend({
  classNameBindings: ['isSelected', 'frost-list-item'],

  initContext: Ember.on('init', function () {
    this.set('_frostList', this.nearestOfType(FrostList))
  }),

  isSelected: Ember.computed.reads('model.isSelected'),

  onclick: Ember.on('click', function (event) {
    if (!(Ember.ViewUtils.isSimpleClick(event) || event.shiftKey || event.metaKey || event.ctrlKey)) {
      return true
    }

    event.preventDefault()
    event.stopPropagation()

    if (_.isFunction(this.get('_frostList.onSelect'))) {
      let isTargetSelectionIndicator = Ember.$(event.target).hasClass('frost-list-selection-indicator')
      if (event.shiftKey && (!this.get('_frostList.persistedClickState.isSelected')) && !this.get('isSelected')) {
        this.get('_frostList.onShiftSelect').call(this.get('_frostList'), {
          secondClickedRecord: this.get('model'),
          isTargetSelectionIndicator: isTargetSelectionIndicator
        })
        if (window.getSelection) {
          window.getSelection().removeAllRanges()
        } else if (document.selection) {  // IE
          document.selection.empty()
        }
      } else {
        this.get('_frostList.onSelect')({
          record: this.get('model'),
          isSelected: !this.get('model.isSelected'),
          isTargetSelectionIndicator: isTargetSelectionIndicator,
          isShiftSelect: false,
          isCtrlSelect: (event.metaKey || event.ctrlKey) && (!this.get('_frostList.persistedClickState.isSelected')) && !this.get('isSelected')
        })
      }
      this.set('_frostList.persistedClickState', {clickedRecord: this.get('model'), isSelected: this.get('isSelected')})
      this.get('isSelected') ? this.$().parent().removeClass('is-selected') : this.$().parent().addClass('is-selected')
    }
  })
})

{'fraction_non_alphanumeric': 0.1610056164749933, 'fraction_numerical': 0.0, 'mean_word_length': 3.7281921618204805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7653539', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1139, 'n_words': 160}