<commit_before>Clarat.StickyMobileNav = {}
class Clarat.StickyMobileNav.Presenter extends ActiveScript.Presenter

  CALLBACKS:
    window:
      resize: 'handler'
      load: 'handler'

  handler: ()  =>

    wrap = $(window)
    smartphone = ($(window).width() < 501)
    $homeTemplate = $("body.template--pages-home").length
    bannerAndNavHeight = $('.Banner').outerHeight() + $('.nav-welt--notstart').outerHeight() # + 20 if
    distributor = $('.Distributor__search-form')

    if $homeTemplate
      return

    if smartphone
      wrap.on "scroll", ->

        if $(this).scrollTop() > bannerAndNavHeight
          distributor.addClass 'is-fixed'
        else
          distributor.removeClass 'is-fixed'


$(document).ready ->
  new Clarat.StickyMobileNav.Presenter<commit_msg>general js refactoring - refactor sticky_mobile_nav to use more ActiveScript style and prevent pixel jumps<commit_after>Clarat.StickyMobileNav = {}
class Clarat.StickyMobileNav.Presenter extends ActiveScript.Presenter
  constructor: ->
    @bannerAndNavHeight =
      $('.Banner').outerHeight() + $('.nav-welt--notstart').outerHeight()
    @formDistributor = $('.Distributor__search-form')
    @navDistributor = $('.Distributor--navigation')
    super()

  CALLBACKS:
    window:
      resize: 'handleNewScreenWidth'
      load: 'handleNewScreenWidth'
      scroll: 'handleScrolled'

  handleNewScreenWidth: =>
    @isSmartphone = ($(window).width() < 501)

  handleScrolled: =>
    return unless @isSmartphone

    if $(window).scrollTop() > @bannerAndNavHeight
      @formDistributor.addClass 'is-fixed'
      # prevent pixel jump:
      @navDistributor.css 'margin-bottom', "#{@bannerAndNavHeight}px"
    else
      @formDistributor.removeClass 'is-fixed'
      @navDistributor.css 'margin-bottom', '0'


$(document).ready ->
  return if $("body.template--pages-home").length
  new Clarat.StickyMobileNav.Presenter
{'fraction_non_alphanumeric': 0.13557540725170783, 'fraction_numerical': 0.004729374671571204, 'mean_word_length': 3.5118483412322274, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '5041419', 'n_tokens_mistral': 609, 'n_tokens_neox': 561, 'n_words': 109}