 
     if isSelected
       @nextButton.enable()
-      @stackPreview.show()
-      @emit 'ScrollTo', 'bottom'
     else
       @nextButton.disable()
-      @stackPreview.hide()
 
 
   handleInstanceTypeChanged: (type) ->

    if err
      return new kd.NotificationView 'Unable to update stack template preview'

    @createStackPreviewFromYaml content
    @stackTemplate = JSON.stringify stackTemplate


  createStackPreviewFromYaml: (content) ->

    linesMarkup   = ''
    codeMarkup    = ''
    templateLines = content.split '\n'

    @stackContent.destroySubViews()
    @stackPreviewLines = []

    for line, index in templateLines when line
      line = new kd.CustomHTMLView
        cssClass : 'line'
        partial  : """
          <div class="number">#{++index}</div>
          <pre><code class="coffee">#{line}</code></pre>
        """

      @stackContent.addSubView line
      @stackPreviewLines.push line

    hljs.highlightBlock line  for line in document.querySelectorAll '.line code'


  hiliteTemplate: (type, keyword) ->

    commonSelector = $ ".stack-preview .line:contains('#{keyword}')"

    if type is 'all'
      lines = document.querySelectorAll '.stack-preview .line'
      line.classList.add 'hilite'  for line in lines

    else if type is 'line'
      if tabView = @currentPage.tabView
        if tabView.getActivePaneIndex() is 1
          commonSelector.last().addClass 'hilite'
        else
          commonSelector.first().addClass 'hilite'
      else
        commonSelector.addClass 'hilite'

    else if type is 'block'
      commonSelector.prev().nextAll().addClass 'hilite'

    @showStackTemplateTooltip type, keyword


  showStackTemplateTooltip: (type, keyword) ->

    return  unless type

    messages =
      all    : 'This is the initial stack template to build your AWS instances.'
      block  : 'This is the lines to add another machine to your stack.'
      line   : ->
        if keyword in [ 'github', 'gitlab', 'yourgitserver', 'bitbucket' ]
          return 'You can clone any git repository to your machines when the stack is built.'
        else
          return 'You can install any package to machines when stack is built.'

    elements =
      all    : @stackPreviewLines.first
      line   : =>
        for line in @stackPreviewLines
          if line.getElement().innerHTML.indexOf(keyword) > -1
            return line

    elements.block = elements.line

    el = if typeof elements[type] is 'function' then elements[type]() else elements[type]

    return  unless el

    el.setTooltip
      title    : messages[type]?() or messages[type]
      cssClass : 'stack-tooltip'

    el.tooltip.show()

    @parent.once 'scroll', -> el.tooltip?.hide()


  getDefaultStackTemplate: (provider, format = 'json') ->

    for pane, index in @configurationView.tabView.panes
      label = @codeSetupView.tabView.panes[index]?.instanceTypeLabel
      label.updatePartial pane.instanceTypeSelectBox.getValue()  if label


  createFooter: ->
