<commit_before>########################################################
# AngularJS service to help with animations.
########################################################

angular.module('feedbunch').service 'animationsSvc',
['$rootScope',
($rootScope)->

  #--------------------------------------------
  # PRIVATE FUNCTION - Add a CSS class that identifies entry as open, for testing.
  # Also set explictly height to 'auto' (setting the CSS class alone does not override the explicitly set
  # height otherwise).
  # This way if images in the entry are lazy-loaded after the open animation is finished,
  # the entry height will adjust instantaneously.
  #--------------------------------------------
  add_entry_open_class = ->
    $(this).addClass('entry_open').css 'height', 'auto'

  #--------------------------------------------
  # PRIVATE FUNCTION - Remove the CSS class that identifies entry as open.
  #--------------------------------------------
  remove_entry_open_class = ->
    $(this).removeClass 'entry_open'

  #--------------------------------------------
  # PRIVATE FUNCTION - Add a CSS class that identifies folder as open.
  # Also set explictly height to 'auto' (setting the CSS class alone does not override the explicitly set
  # height otherwise).
  # This way if feeds are added or removed from the folder, the folder height will adjust instantaneously.
  #--------------------------------------------
  add_folder_open_class = ->
    $(this).addClass('open-folder').css 'height', 'auto'

  #--------------------------------------------
  # PRIVATE FUNCTION - Remove the CSS class that identifies folder as open.
  #--------------------------------------------
  remove_folder_open_class = ->
    $(this).removeClass 'open-folder'

  #--------------------------------------------
  # PRIVATE FUNCTION - Open a dropdown menu.
  # Receives as arguments:
  # - jquery object of the menu wrapper (normally a li or div with class .dropdown)
  # - jquery object of the link that toggles the menu
  # - namespace to apply to the event handler that will be created to close the menu if user clicks outside it.
  # It should be a namespaced "click" event, like "click.mynamespace"
  #--------------------------------------------
  open_menu = (menu_wrapper, menu_link, event_namespace)->
    menu_wrapper.addClass 'open'
    menu = menu_link.siblings '.dropdown-menu'

    # Make menu height 'auto' temporarily to measure its final height
    padding_top = 5
    padding_bottom = 5
    menu.css('height', 'auto')
    height_auto = menu.outerHeight() + padding_top + padding_bottom

    # Set height back to 0px and animate the transition to its final height
    menu
      .css('height', '0')
      .velocity {height: height_auto, 'padding-top': padding_top, 'padding-bottom': padding_bottom},
        {duration: 200, easing: 'swing'}

    # If user clicks anywhere outside the menu link, close it
    $(document).on event_namespace, (event)->
      if $(event.target).closest(menu_link).length == 0
        close_menu menu_wrapper, menu_link, event_namespace
      return true

  #--------------------------------------------
  # PRIVATE FUNCTION - Close a dropdown menu.
  # Receives as arguments:
  # - jquery object of the menu wrapper (normally a li with class .dropdown)
  # - jquery object of the link that toggles the menu
  # - namespace to apply to the event handler that was created to close the menu if user clicks outside it.
  # It should be a namespaced "click" event, like "click.mynamespace"
  #--------------------------------------------
  close_menu = (menu_wrapper, menu_link, event_namespace)->
    menu_wrapper.removeClass 'open'
    menu = menu_link.siblings '.dropdown-menu'

    # Set height back to 0px and animate the transition to its final height
    menu.velocity {height: 0, 'padding-top': 0, 'padding-bottom': 0},
      {duration: 200, easing: 'swing'}

    # Remove the handler that closes the menu if user clicks outside it.
    # It is no longer necessary now that menu is closed, and having too many handlers hurts performance
    $(document).off event_namespace

  service =

    #---------------------------------------------
    # Animate opening an entry, by transitioning its height from zero to its final value.
    #---------------------------------------------
    open_entry: (entry)->
      entry_summary = $("#entry-#{entry.id}-summary")

      # Temporarily make entry content visible (height > 0) to measure its height
      padding_top = 15
      padding_bottom = 15
      entry_summary.css('height', 'auto')
      height_auto = entry_summary.outerHeight() + padding_top + padding_bottom

      # Set height back to 0px and animate the transition to its final height
      # After finishing opening animation, scroll to show as much of the entry content as possible.
      # We leave an offset so that part of the entry above is still visible under the navbar.
      topOffset = -120
      entry_summary
        .css('height', '0')
        .velocity({height: height_auto, 'padding-top': padding_top, 'padding-bottom': padding_bottom},
          {duration: 300, easing: 'swing', complete: add_entry_open_class})
        .velocity 'scroll', {offset: topOffset, duration: 300}

    #---------------------------------------------
    # Animate closing an entry, by transitioning its height from its current value to zero
    #---------------------------------------------
    close_entry: (entry)->
      $("#entry-#{entry.id}-summary")
        .velocity {height: 0, 'padding-top': 0, 'padding-bottom': 0},
          {duration: 300, easing: 'swing', complete: remove_entry_open_class}

    #---------------------------------------------
    # Animate opening a folder, by transitioning its height from zero to its final value.
    #---------------------------------------------
    open_folder: (folder)->
      folder_content = $("#feeds-#{folder.id}.folder-content")

      # Temporarily make folder content visible (height > 0) to measure its height
      folder_content.css('height', 'auto')
      padding_top = 8
      padding_bottom = 8
      height_auto = folder_content.outerHeight() + padding_top + padding_bottom

      # Set height back to 0px and animate the transition to its final height
      folder_content
      .css('height', '0')
      .velocity {height: height_auto, 'padding-top': padding_top, 'padding-bottom': padding_bottom},
        {duration: 300, easing: 'swing', complete: add_folder_open_class}

      # Rotate folder arrow 90 degrees clockwise (pointing down)
      $("#open-folder-#{folder.id} .folder-arrow")
        .velocity {rotateZ:  '90deg', 'margin-top': 3},
          {duration: 300, easing: 'swing'}

    #---------------------------------------------
    # Animate closing a folder, by transitioning its height from its current value to zero
    #---------------------------------------------
    close_folder: (folder)->
      $("#feeds-#{folder.id}.folder-content")
      .velocity {height: 0, 'padding-top': 0, 'padding-bottom': 0},
        {duration: 300, easing: 'swing', complete: remove_folder_open_class}

      # Rotate folder arrow 90 degrees counter-clockwise (pointing right)
      $("#open-folder-#{folder.id} .folder-arrow")
        .velocity {rotateZ:  '0deg', 'margin-top': 4},
          {duration: 300, easing: 'swing'}

    #---------------------------------------------
    # Animate toggling (open/close) the feeds management menu
    #---------------------------------------------
    toggle_feeds_menu: ->
      menu_wrapper = $('#feed-dropdown')
      menu_link = $('#feeds-management')
      event_namespace = 'click.outside_feeds_menu'

      if menu_wrapper.hasClass 'open'
        close_menu menu_wrapper, menu_link, event_namespace
      else
        open_menu menu_wrapper, menu_link, event_namespace

    #---------------------------------------------
    # Animate toggling (open/close) the folders management menu
    #---------------------------------------------
    toggle_folders_menu: ->
      menu_wrapper = $('#folder-management-dropdown')
      menu_link = $('#folder-management')
      event_namespace = 'click.outside_folders_menu'

      if menu_wrapper.hasClass 'open'
        close_menu menu_wrapper, menu_link, event_namespace
      else<commit_msg>Remove unnecessary margin-top animation for folder arrows.<commit_after>########################################################
# AngularJS service to help with animations.
########################################################

angular.module('feedbunch').service 'animationsSvc',
['$rootScope',
($rootScope)->

  #--------------------------------------------
  # PRIVATE FUNCTION - Add a CSS class that identifies entry as open, for testing.
  # Also set explictly height to 'auto' (setting the CSS class alone does not override the explicitly set
  # height otherwise).
  # This way if images in the entry are lazy-loaded after the open animation is finished,
  # the entry height will adjust instantaneously.
  #--------------------------------------------
  add_entry_open_class = ->
    $(this).addClass('entry_open').css 'height', 'auto'

  #--------------------------------------------
  # PRIVATE FUNCTION - Remove the CSS class that identifies entry as open.
  #--------------------------------------------
  remove_entry_open_class = ->
    $(this).removeClass 'entry_open'

  #--------------------------------------------
  # PRIVATE FUNCTION - Add a CSS class that identifies folder as open.
  # Also set explictly height to 'auto' (setting the CSS class alone does not override the explicitly set
  # height otherwise).
  # This way if feeds are added or removed from the folder, the folder height will adjust instantaneously.
  #--------------------------------------------
  add_folder_open_class = ->
    $(this).addClass('open-folder').css 'height', 'auto'

  #--------------------------------------------
  # PRIVATE FUNCTION - Remove the CSS class that identifies folder as open.
  #--------------------------------------------
  remove_folder_open_class = ->
    $(this).removeClass 'open-folder'

  #--------------------------------------------
  # PRIVATE FUNCTION - Open a dropdown menu.
  # Receives as arguments:
  # - jquery object of the menu wrapper (normally a li or div with class .dropdown)
  # - jquery object of the link that toggles the menu
  # - namespace to apply to the event handler that will be created to close the menu if user clicks outside it.
  # It should be a namespaced "click" event, like "click.mynamespace"
  #--------------------------------------------
  open_menu = (menu_wrapper, menu_link, event_namespace)->
    menu_wrapper.addClass 'open'
    menu = menu_link.siblings '.dropdown-menu'

    # Make menu height 'auto' temporarily to measure its final height
    padding_top = 5
    padding_bottom = 5
    menu.css('height', 'auto')
    height_auto = menu.outerHeight() + padding_top + padding_bottom

    # Set height back to 0px and animate the transition to its final height
    menu
      .css('height', '0')
      .velocity {height: height_auto, 'padding-top': padding_top, 'padding-bottom': padding_bottom},
        {duration: 200, easing: 'swing'}

    # If user clicks anywhere outside the menu link, close it
    $(document).on event_namespace, (event)->
      if $(event.target).closest(menu_link).length == 0
        close_menu menu_wrapper, menu_link, event_namespace
      return true

  #--------------------------------------------
  # PRIVATE FUNCTION - Close a dropdown menu.
  # Receives as arguments:
  # - jquery object of the menu wrapper (normally a li with class .dropdown)
  # - jquery object of the link that toggles the menu
  # - namespace to apply to the event handler that was created to close the menu if user clicks outside it.
  # It should be a namespaced "click" event, like "click.mynamespace"
  #--------------------------------------------
  close_menu = (menu_wrapper, menu_link, event_namespace)->
    menu_wrapper.removeClass 'open'
    menu = menu_link.siblings '.dropdown-menu'

    # Set height back to 0px and animate the transition to its final height
    menu.velocity {height: 0, 'padding-top': 0, 'padding-bottom': 0},
      {duration: 200, easing: 'swing'}

    # Remove the handler that closes the menu if user clicks outside it.
    # It is no longer necessary now that menu is closed, and having too many handlers hurts performance
    $(document).off event_namespace

  service =

    #---------------------------------------------
    # Animate opening an entry, by transitioning its height from zero to its final value.
    #---------------------------------------------
    open_entry: (entry)->
      entry_summary = $("#entry-#{entry.id}-summary")

      # Temporarily make entry content visible (height > 0) to measure its height
      padding_top = 15
      padding_bottom = 15
      entry_summary.css('height', 'auto')
      height_auto = entry_summary.outerHeight() + padding_top + padding_bottom

      # Set height back to 0px and animate the transition to its final height
      # After finishing opening animation, scroll to show as much of the entry content as possible.
      # We leave an offset so that part of the entry above is still visible under the navbar.
      topOffset = -120
      entry_summary
        .css('height', '0')
        .velocity({height: height_auto, 'padding-top': padding_top, 'padding-bottom': padding_bottom},
          {duration: 300, easing: 'swing', complete: add_entry_open_class})
        .velocity 'scroll', {offset: topOffset, duration: 300}

    #---------------------------------------------
    # Animate closing an entry, by transitioning its height from its current value to zero
    #---------------------------------------------
    close_entry: (entry)->
      $("#entry-#{entry.id}-summary")
        .velocity {height: 0, 'padding-top': 0, 'padding-bottom': 0},
          {duration: 300, easing: 'swing', complete: remove_entry_open_class}

    #---------------------------------------------
    # Animate opening a folder, by transitioning its height from zero to its final value.
    #---------------------------------------------
    open_folder: (folder)->
      folder_content = $("#feeds-#{folder.id}.folder-content")

      # Temporarily make folder content visible (height > 0) to measure its height
      folder_content.css('height', 'auto')
      padding_top = 8
      padding_bottom = 8
      height_auto = folder_content.outerHeight() + padding_top + padding_bottom

      # Set height back to 0px and animate the transition to its final height
      folder_content
      .css('height', '0')
      .velocity {height: height_auto, 'padding-top': padding_top, 'padding-bottom': padding_bottom},
        {duration: 300, easing: 'swing', complete: add_folder_open_class}

      # Rotate folder arrow 90 degrees clockwise (pointing down)
      $("#open-folder-#{folder.id} .folder-arrow")
        .velocity {rotateZ:  '90deg'},
          {duration: 300, easing: 'swing'}

    #---------------------------------------------
    # Animate closing a folder, by transitioning its height from its current value to zero
    #---------------------------------------------
    close_folder: (folder)->
      $("#feeds-#{folder.id}.folder-content")
      .velocity {height: 0, 'padding-top': 0, 'padding-bottom': 0},
        {duration: 300, easing: 'swing', complete: remove_folder_open_class}

      # Rotate folder arrow 90 degrees counter-clockwise (pointing right)
      $("#open-folder-#{folder.id} .folder-arrow")
        .velocity {rotateZ:  '0deg'},
          {duration: 300, easing: 'swing'}

    #---------------------------------------------
    # Animate toggling (open/close) the feeds management menu
    #---------------------------------------------
    toggle_feeds_menu: ->
      menu_wrapper = $('#feed-dropdown')
      menu_link = $('#feeds-management')
      event_namespace = 'click.outside_feeds_menu'

      if menu_wrapper.hasClass 'open'
        close_menu menu_wrapper, menu_link, event_namespace
      else
        open_menu menu_wrapper, menu_link, event_namespace

    #---------------------------------------------
    # Animate toggling (open/close) the folders management menu
    #---------------------------------------------
    toggle_folders_menu: ->
      menu_wrapper = $('#folder-management-dropdown')
      menu_link = $('#folder-management')
      event_namespace = 'click.outside_folders_menu'

      if menu_wrapper.hasClass 'open'
        close_menu menu_wrapper, menu_link, event_namespace
      else
{'fraction_non_alphanumeric': 0.22712781954887218, 'fraction_numerical': 0.007819548872180452, 'mean_word_length': 2.0103204780010864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '255729', 'n_tokens_mistral': 4314, 'n_tokens_neox': 4078, 'n_words': 1461}