 
     if @width == "auto"
       @$el.css(width: "auto")
-      $content.css(position: "relative")
+      @$content.css(position: "relative")
       @dimensions.width = @$el.width()
     else if @width
       @dimensions.width = @width

  render: ->
    super

    @$el.css(zIndex: @zIndex)
    @$el.addClass("not-scrollable") unless @scrollable

    @$el.addClass("with-footer") if @$("> .modal-footer").length
    @$el.addClass("with-sidebar") if @$("> .modal-sidebar").length

    if @content
      @$("> .modal-content").append(@content.el || @content)

    return this


  scrollable: true
  zIndex: 1024

  headerSelector:  "> .modal-header"
  sidebarSelect:   "> .modal-sidebar"
  contentSelector: "> .modal-content"
  footerSelector:  "> .modal-footer"

  positionElement: ->
    @dimensions ||= { width: null, height: null }

    headerHeight = @$header.outerHeight()

    setHeight = (height) =>
      @dimensions.height = height
      @$el.height height

      @$content.css(position: "absolute")
      @$footer.css(position: "absolute")

      @$content.add(@$sidebar).css
        top: headerHeight
        bottom: @$footer.outerHeight()

    if @height == "auto"
      @$el.css(height: "auto")
      @$content.css(position: "relative")
      @$footer.css(position: "static")

      elHeight = @_detectHeightForPositioning()
      maxHeight = window.innerHeight - 160

      contentHeight = @$content.height()
      if (contentHeight + @$footer.height() + headerHeight) >= maxHeight
        setHeight maxHeight
      else if @$sidebar.length || contentHeight == 0
        setHeight elHeight

    else
