Sha256: ea173dcee1e52aad2447877805e413f3f2f3da4d7a0fd96f1a97d090c5ade33a

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 Bytes

Contents

class @Sidebar
  INSTANCE = null

  @instance: ->
    INSTANCE ||= new this($(window), $('.sidebar-plugins'))

  @newWidgetContainer: ->
    Sidebar.instance().newWidgetContainer()

  constructor: (@$window, @$container) ->
    @saveMinTop()
    @$window.scroll(@updatePosition)
    @$window.resize(@updatePosition)
    @$outerContainer = @$container.parent()

  updatePosition: =>
    @$outerContainer.toggleClass('fixed', @$window.scrollTop() > @minTop)
    @$container.height($(window).height() - @$container[0].getBoundingClientRect().top)

  newWidgetContainer: ->
    $(document.createElement('div')).addClass('sidebar-plugin').prependTo(@$container)

  saveMinTop: ->
    @minTop = @$container.position()?.top || 0

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shipit-engine-0.0.1.pre app/assets/javascripts/task/sidebar.js.coffee