Sha256: 8c4483802a6e83fee56cbeeda20fe16a31affe62fca12298522b9f08680acc1f

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

_header_height = 0
_side_menu = null

$ ->
  $('.next-is-nested').on 'click', (e) ->
    self = $(this)
    self.closest('.row').next().toggle()

  $('.request-action-title').on 'click', (e) ->
    self = $(this)
    next = self.next()
    return unless next.hasClass('flex-table')
    next.toggle()

  $('.add-ico, .edit-ico').on 'click', (e) ->
    self = $(this)
    self.closest('.row').toggleClass('is-active')

  _header_height = $('.aside').offset().top

  _side_menu = $('#side-menu')

$(document).on 'scroll', ->
  _window = $(window)
  _scrollTop = _window.scrollTop()

  console.log _header_height
  if _scrollTop > _header_height
    _side_menu.addClass('fixed')
  else
    _side_menu.removeClass('fixed')

  $("#side-menu li").removeClass('is-current')

  $("#side-menu li a").each () ->
    self = $(this)

    _attached_block_id = self.attr('href')
    # 0 is '#'
    _attached_block = document.getElementById(_attached_block_id.substring(1))
    jq_block = $(_attached_block)

    # 5 is magic number to get block in sight on top get selected in menu
    offset_top =  jq_block.offset().top - 5
    offset_height = jq_block.height()

    if _scrollTop > offset_top && _scrollTop < offset_top + offset_height
      self.closest('li').addClass('is-current')

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_api_documentation-0.2.1 app/assets/javascripts/table.js.coffee
rails_api_documentation-0.2.0 app/assets/javascripts/table.js.coffee
rails_api_documentation-0.1.9 app/assets/javascripts/table.js.coffee
rails_api_documentation-0.1.8 app/assets/javascripts/table.js.coffee
rails_api_documentation-0.1.7 app/assets/javascripts/table.js.coffee
rails_api_documentation-0.1.6 app/assets/javascripts/table.js.coffee