<commit_before>class MainTabView extends KDTabView

  lastOpenPaneIndex = null

  constructor:(options,data)->
    options.resizeTabHandles    = yes
    options.lastTabHandleMargin = 40
    options.sortable            = yes
    @visibleHandles             = []
    @totalSize                  = 0
    super options,data

    appManager = @getSingleton("appManager")

    appManager.on 'AppManagerWantsToShowAnApp', (controller, view, options)=>

      if view.parent
        @showPane view.parent
      else
        @createTabPane options, view

    @getSingleton("mainView").on "mainViewTransitionEnd", (e) =>
      if e.target is @getSingleton("contentPanel").domElement[0]
        @tabHandleContainer.setWidth @getWidth()
        @resizeTabHandles()

    @on "PaneAdded", =>
      @tabHandleContainer.setWidth @getWidth()

    mainViewController = @getSingleton "mainViewController"
    mainViewController.on "UILayoutNeedsToChange", @bound "changeLayout"

  changeLayout:(options)->

    {hideTabs} = options

    if hideTabs
      @hideHandleContainer()
    else
      if @getSingleton('contentPanel').navOpenedOnce
        @showHandleContainer()


  # temp fix sinan 27 Nov 12
  # not calling @removePane but @_removePane
  handleClicked:(index, event)->
    pane        = @getPaneByIndex index
    appView     = pane.getMainView()
    appInstance = appManager.getByView appView
    options     = appInstance.getOptions()
    @getSingleton('router').handleRoute "#{options.route}"

    if $(event.target).hasClass "close-tab"
      pane.mainView.destroy()
      return no

    @showPane pane  if options.route is '/Develop'

  showHandleContainer:()->
    @tabHandleContainer.$().css top : -25
    @handlesHidden = no

  hideHandleContainer:()->
    @tabHandleContainer.$().css top : 0
    @handlesHidden = yes

  showPane:(pane)->

    lastOpenPaneIndex = @getPaneIndex @getActivePane()

    # this is to hide stale static tabs
    @$("> .kdtabpaneview").removeClass "active"
    @$("> .kdtabpaneview").addClass "kdhiddentab"

    super pane

    # FIXME: SY
    # paneMainView = pane.getMainView()
    # if paneMainView.data?.constructor.name is 'FSFile'
    #   @getSingleton('mainController').emit "SelectedFileChanged", paneMainView

    @emit "MainTabPaneShown", pane

    return pane

  removePane: (pane) ->
    pane.emit "KDTabPaneDestroy"
    index        = @getPaneIndex pane
    isActivePane = @getActivePane() is pane
    @panes.splice(index,1)
    pane.destroy()
    handle = @getHandleByIndex index
    @handles.splice(index,1)
    handle.destroy()

    appPanes = []
    for pane in @panes
      appPanes.push pane if pane.options.type is "application"

    if isActivePane
      if @getPaneByIndex(lastOpenPaneIndex)?
        @showPane @getPaneByIndex(lastOpenPaneIndex)
      else if firstPane = @getPaneByIndex 0
        @showPane firstPane

    @emit "PaneRemoved"

    if appPanes.length is 0
      @emit "AllApplicationPanesClosed"

  createTabPane:(options = {}, mainView)->

    o = {}
    o.cssClass = @utils.curryCssClass "content-area-pane", options.cssClass
    o.class  or= KDView

    # this is a temporary hack
    # for reviving the main tabs
    # a better solution tbdl - SY
    o.domId         = "maintabpane-#{@utils.slugify options.name}"
    o.domId        += "-#{@utils.getRandomNumber()}" if document.getElementById o.domId
    o.name          = options.name
    o.behavior      = options.behavior
    o.hiddenHandle  = options.hiddenHandle

    paneInstance = new MainTabPane o

    paneInstance.once "viewAppended", =>
      @applicationPaneReady paneInstance, mainView
      if options.appInfo?.title?
        paneInstance.setTitle options.appInfo.title

    @addPane paneInstance

    return paneInstance

  applicationPaneReady: (pane, mainView) ->
    if pane.getOption("behavior") is "application"
      mainView.setClass 'application-page'
    pane.setMainView mainView
    mainView.on "KDObjectWillBeDestroyed", =>
      @removePane pane

  rearrangeVisibleHandlesArray:->
    @visibleHandles = []
    for handle in @handles
      unless handle.getOptions().hidden<commit_msg>maintabs: broken (white) activity tab fixed / custom titles for tabhandles fixed<commit_after>class MainTabView extends KDTabView

  lastOpenPaneIndex = null

  constructor:(options,data)->
    options.resizeTabHandles    = yes
    options.lastTabHandleMargin = 40
    options.sortable            = yes
    @visibleHandles             = []
    @totalSize                  = 0
    super options,data

    appManager = @getSingleton("appManager")

    appManager.on 'AppManagerWantsToShowAnApp', (controller, view, options)=>

      if view.parent
        @showPane view.parent
      else
        @createTabPane options, view

    @getSingleton("mainView").on "mainViewTransitionEnd", (e) =>
      if e.target is @getSingleton("contentPanel").domElement[0]
        @tabHandleContainer.setWidth @getWidth()
        @resizeTabHandles()

    @on "PaneAdded", =>
      @tabHandleContainer.setWidth @getWidth()

    mainViewController = @getSingleton "mainViewController"
    mainViewController.on "UILayoutNeedsToChange", @bound "changeLayout"

  changeLayout:(options)->

    {hideTabs} = options

    if hideTabs
      @hideHandleContainer()
    else
      if @getSingleton('contentPanel').navOpenedOnce
        @showHandleContainer()


  # temp fix sinan 27 Nov 12
  # not calling @removePane but @_removePane
  handleClicked:(index, event)->
    pane        = @getPaneByIndex index
    appView     = pane.getMainView()
    appInstance = appManager.getByView appView
    options     = appInstance.getOptions()
    @getSingleton('router').handleRoute "#{options.route}"

    if $(event.target).hasClass "close-tab"
      pane.mainView.destroy()
      return no

    @showPane pane  if options.route is '/Develop'

  showHandleContainer:()->
    @tabHandleContainer.$().css top : -25
    @handlesHidden = no

  hideHandleContainer:()->
    @tabHandleContainer.$().css top : 0
    @handlesHidden = yes

  showPane:(pane)->

    lastOpenPaneIndex = @getPaneIndex @getActivePane()

    # this is to hide stale static tabs
    @$("> .kdtabpaneview").removeClass "active"
    @$("> .kdtabpaneview").addClass "kdhiddentab"

    super pane

    # FIXME: SY
    # paneMainView = pane.getMainView()
    # if paneMainView.data?.constructor.name is 'FSFile'
    #   @getSingleton('mainController').emit "SelectedFileChanged", paneMainView

    @emit "MainTabPaneShown", pane

    return pane

  removePane: (pane) ->
    pane.emit "KDTabPaneDestroy"
    index        = @getPaneIndex pane
    isActivePane = @getActivePane() is pane
    @panes.splice(index,1)
    pane.destroy()
    handle = @getHandleByIndex index
    @handles.splice(index,1)
    handle.destroy()

    appPanes = []
    for pane in @panes
      appPanes.push pane if pane.options.type is "application"

    if isActivePane
      if @getPaneByIndex(lastOpenPaneIndex)?
        @showPane @getPaneByIndex(lastOpenPaneIndex)
      else if firstPane = @getPaneByIndex 0
        @showPane firstPane

    @emit "PaneRemoved"

    if appPanes.length is 0
      @emit "AllApplicationPanesClosed"

  createTabPane:(options = {}, mainView)->

    o = {}
    o.cssClass = @utils.curryCssClass "content-area-pane", options.cssClass
    o.class  or= KDView

    # this is a temporary hack
    # for reviving the main tabs
    # a better solution tbdl - SY
    if document.getElementById o.domId
      o.domId         = "maintabpane-#{@utils.slugify options.name}"

    o.name          = options.name
    o.behavior      = options.behavior
    o.hiddenHandle  = options.hiddenHandle

    paneInstance = new MainTabPane o

    paneInstance.once "viewAppended", =>
      @applicationPaneReady paneInstance, mainView
      appController = appManager.getByView mainView
      {appInfo}     = appController.getOptions()
      paneInstance.setTitle appInfo.title  if appInfo?.title

    @addPane paneInstance

    return paneInstance

  applicationPaneReady: (pane, mainView) ->
    if pane.getOption("behavior") is "application"
      mainView.setClass 'application-page'
    pane.setMainView mainView
    mainView.on "KDObjectWillBeDestroyed", =>
      @removePane pane

  rearrangeVisibleHandlesArray:->
    @visibleHandles = []
    for handle in @handles
      unless handle.getOptions().hidden
{'fraction_non_alphanumeric': 0.10311004784688996, 'fraction_numerical': 0.0035885167464114833, 'mean_word_length': 3.0062290368950646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3628158', 'n_tokens_mistral': 2655, 'n_tokens_neox': 2475, 'n_words': 562}