     else KDView.setElementClass html, 'remove', 'app'
 
     if isApp or name in appsWithDock
-    then @getView().showDock()
-    else @getView().hideDock()
+    then dock.getView().show()
+    else dock.getView().hide()


  setViewState: (options = {}) ->

    {behavior, name} = options

    html     = document.documentElement

    mainView.on 'MainTabPaneShown', (pane) =>
      @mainTabPaneChanged mainView, pane

    appManager.on 'AppIsBeingShown', (controller) =>
      @setBodyClass KD.utils.slugify controller.getOption 'name'

    display.on 'ContentDisplayWantsToBeShown', do =>
      type = null
      (view) => @setBodyClass type  if type = view.getOption 'type'

    windowController.on 'ScrollHappened', @bound 'handleScroll'


  loadView:(mainView)->

    mainView.ready =>

      {body} = document
      if KD.checkFlag 'super-admin'
      then KDView.setElementClass body, 'add', 'super'
      else KDView.setElementClass body, 'remove', 'super'


  handleScroll: do ->

    threshold     = 50
    lastScroll    = 0
    currentHeight = 0

    _.throttle (event) ->

      el = document.body
      {scrollHeight, scrollTop} = el

      return  if scrollHeight <= window.innerHeight or scrollTop <= 0

      current = scrollTop + window.innerHeight
      if current > scrollHeight - threshold
        return if lastScroll > 0
        appManager    = KD.singleton 'appManager'
        appManager.getFrontApp()?.emit "LazyLoadThresholdReached"
        lastScroll    = current
        currentHeight = scrollHeight
      else if current < lastScroll then lastScroll = 0

      if scrollHeight isnt currentHeight then lastScroll = 0

    , 200


  setBodyClass: do ->

