Sha256: a0a9e74f45bb583f20923f867b190bf76ac6a26559132bd1ff6f4e61e82e67eb

Contents?: true

Size: 1.84 KB

Versions: 12

Compression:

Stored size: 1.84 KB

Contents

class ADF.Sidebar.Views.Content extends ADF.MVC.Views.Base
  
  top: 39
  bottomlinkheight: 32
  contentTemplate: JST["socmap_adf/modules/sidebar/templates/content"]
  
  constructor: ( options ) ->
    super(options)
    @doNanoScroll =  if options.doNanoScroll? then options.doNanoScroll else true
    @model = @options.model
    @rendered = false
    
  render: ->
    $(@el).html(@contentTemplate) 
    template = if @model then @template( @model.toJSON() ) else @template()
    @$(".level_content_wrap").html(template)
    @renderBottomLinks()
    @bindResize() 
    @onRenderComplete()
    @calculateResize()
    @initNanoScroller() if @doNanoScroll
    @rendered = true
    return @
    
  bindResize: ->
    $(window).bind "resize", @calculateResize

  calculateResize: () =>
    height = $(window).height() - @top - @bottomlinkheight * @countBottomLinks()
    @$(".level_content_wrap").css({ "height" : height + "px"})

  initNanoScroller: () ->
    setTimeout(
      => @$(".level_content_wrap").nanoScroller({autoresize: true}),
      300
    )
  
  setBottomLinks: (bottomlinks) =>
    @bottomlinks = bottomlinks
    @renderBottomLinks()
    @onBottomLinksSat()
           
  addBottomLink: ( bootomlink ) =>
    @bottomlinks = [] if not @bottomlinks
    @bottomlinks.push( bootomlink )

  countBottomLinks: ->
    if @bottomlinks? then @bottomlinks.length else 0
          
  renderBottomLinks: ->
    @$(".panel_buttons").html("")
    return false if not @bottomlinks
    @$(".panel_buttons").append(bottomLink.render().el) for bottomLink in @bottomlinks

  addLoading: ->
    $(@el).prepend('<div class="sidebar_loading"><div class="loader"><img src="/assets/load.gif" alt="" width="31" height="31" /></div><div class="overlay"></div></div>')

  removeLoading: ->
    $(@el).find('.sidebar_loading').remove()

  # CALLBACKS  
  onRenderComplete: ->
  onBottomLinksSat: ->

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
socmap_adf-1.0.0 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.11 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.10 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.9 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.8 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.7 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.6 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.5 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.4 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.3 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.2 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee
socmap_adf-0.0.1 lib/assets/javascripts/socmap_adf/modules/sidebar/views/content.js.coffee