<commit_before>'use strict'

class ExpandableCtrl
  constructor: (@scope, @contentHeight, @elementHeight, @scrollToOffset) ->
    @inverse = false
    @inverse = @scope.inverse if @scope.inverse?
    if !@inverse
      @expanded = false
    else
      @expanded = true
      @expandContent(false)

  getMaxHeight: ->
    return if @expanded then "max-height: #{@contentHeight}px" else ''

  hasOverflow: ->
    return @contentHeight > @elementHeight

  isExpandable: ->
    if @hasOverflow() and !@expanded then true else false

  isCollapsable: ->
    if @expanded then true else false

  expandContent: (doScroll=true) ->
    @expanded = true
    if doScroll
      @scrollToOffset()

  collapseContent: (doScroll=true) ->
    @expanded = false
    if doScroll
      @scrollToOffset()


angular.module('holmesApp')
  .directive('expandable', ($timeout) ->
    replace: true
    transclude: true
    restrict: 'E'
    scope:
      inverse: '='
    templateUrl: 'views/expandable.html'
    link: (scope, element, attrs) ->
      scrollToOffset = ->
        window.scrollTo('top', element.offset().top)

      $timeout ->
        contentHeight = element.find('.expandable-content :first-child')<commit_msg>Fix collapse button on expandable directive (fix #45)<commit_after>'use strict'

class ExpandableCtrl
  constructor: (@scope, @contentHeight, @elementHeight, @scrollToOffset) ->
    @inverse = false
    @inverse = @scope.inverse if @scope.inverse?
    if !@inverse
      @expanded = false
    else
      @expanded = true
      @expandContent(false)

  getMaxHeight: ->
    return if @expanded then "max-height: #{@contentHeight}px" else ''

  hasOverflow: ->
    return @contentHeight > @elementHeight

  isExpandable: ->
    if @hasOverflow() and !@expanded then true else false

  isCollapsable: ->
    @hasOverflow() and @expanded

  expandContent: (doScroll=true) ->
    @expanded = true
    if doScroll
      @scrollToOffset()

  collapseContent: (doScroll=true) ->
    @expanded = false
    if doScroll
      @scrollToOffset()


angular.module('holmesApp')
  .directive('expandable', ($timeout) ->
    replace: true
    transclude: true
    restrict: 'E'
    scope:
      inverse: '='
    templateUrl: 'views/expandable.html'
    link: (scope, element, attrs) ->
      scrollToOffset = ->
        window.scrollTo('top', element.offset().top)

      $timeout ->
        contentHeight = element.find('.expandable-content :first-child')
{'fraction_non_alphanumeric': 0.1268931641424478, 'fraction_numerical': 0.0008186655751125665, 'mean_word_length': 3.0801335559265444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '3940251', 'n_tokens_mistral': 762, 'n_tokens_neox': 734, 'n_words': 181}