<commit_before>class Sidebar extends JView

  constructor:->

    super

    account           = KD.whoami()
    {profile}         = account
    @_onDevelop       = no
    @_finderExpanded  = no
    @_popupIsActive   = no

    currentGroupData = @getSingleton('groupsController').getCurrentGroupData()

    @avatar = new AvatarView
      tagName    : "div"
      cssClass   : "avatar-image-wrapper"
      size       :
        width    : 160
        height   : 76
    , account

    @avatarAreaIconMenu = new AvatarAreaIconMenu
      delegate     : @

    @groupAvatar = new KDView
      cssClass   : 'group-avatar-image-wrapper hidden'
      tagName : 'div'
    ,currentGroupData

    @currentGroup = new KDCustomHTMLView
      cssClass    : 'current-group-indicator'
      pistachio   : "{{#(title)}}"
      click       : ->
        #KD.getSingleton('router').handleRoute
        console.log @getData()
    , currentGroupData

    @avatarHeader = new KDView
      cssClass : 'avatar-header hidden'
      pistachio : '{{#(title)}}'
      click :=>
        # KD.getSingleton('router').handleRoute "/#{currentGroupData.slug}/Activity"

    , currentGroupData

    # handle group related decisions
    @initializeGroup()

    @navController = new NavigationController
      view           : new NavigationList
        type         : "navigation"
        itemClass    : NavigationLink
      wrapper        : no
      scrollView     : no
    , navItems

    @nav = @navController.getView()

    @footerMenuController = new NavigationController
      view           : new NavigationList
        type         : "footer-menu"
        itemClass    : FooterMenuItem
      wrapper        : no
      scrollView     : no
    , footerMenuItems

    @footerMenu = @footerMenuController.getView()

    @finderHeader = new KDCustomHTMLView
      tagName   : "h2"
      pistachio : "{{#(profile.nickname)}}.#{location.hostname}"
    , account

    @finderResizeHandle = new SidebarResizeHandle
      cssClass  : "finder-resize-handle"

    @finderController = new NFinderController
      fsListeners       : yes
      initDelay         : 5000
      useStorage        : yes
      addOrphansToRoot  : no

    @finder = @finderController.getView()

    @finderBottomControlsController = new KDListViewController
      view        : new FinderBottomControls
      wrapper     : no
      scrollView  : no
    , bottomControlsItems

    @finderBottomControls = @finderBottomControlsController.getView()

    KD.registerSingleton "finderController", @finderController
    @listenWindowResize()

    # @statusLEDs = new StatusLEDView
    @statusLEDs = new KDView
      cssClass : 'status-leds'

  initializeGroup:->
    currentGroupData = @getSingleton('groupsController').getCurrentGroupData()
    unless currentGroupData?.data?.slug is 'koding'
      @avatar.setClass 'shared-avatar'
      @avatar.setWidth 80

      # group avatar should be either a URL or a dataURL

      @groupAvatar.$().css backgroundImage :  "url(#{currentGroupData?.data?.avatar or 'http://lorempixel.com/100/100/?' + @utils.getRandomNumber()})"
      @groupAvatar.show()
      @groupAvatar.setClass 'flash'
      @avatarHeader.setData currentGroupData
      @avatarHeader.show()
#    else
#      @avatar.unsetClass 'shared-avatar'
#      @avatar.setWidth 160
#      @groupAvatar.hide()
#      @groupAvatar.unsetClass 'flash'
#      @avatarHeader.setData currentGroupData
#      @avatarHeader.hide()
    @render()


  setListeners:->

    mainView = @getDelegate()
    {@contentPanel, @sidebarPanel} = mainView

    @getSingleton('mainController').on "AvatarPopupIsActive", =>
      @_popupIsActive = yes

    @getSingleton('mainController').on "AvatarPopupIsInactive", =>
      @_popupIsActive = no

    $fp = @$('#finder-panel')
    cp  = @contentPanel
    @wc = @getSingleton "windowController"
    fpLastWidth = null

    @finderResizeHandle.on "ClickedButNotDragged", =>
      unless fpLastWidth
        fpLastWidth = parseInt $fp.css("width"), 10
        cp.$().css left : 65, width : @wc.winWidth - 65
        @utils.wait 300, -> $fp.css "width", 13
      else
        fpLastWidth = 208 if fpLastWidth < 100
        $fp.css "width", fpLastWidth
        cpWidth = @wc.winWidth - 52 - fpLastWidth
        cp.$().css left : 52 + fpLastWidth, width : cpWidth
        cp.emit "ViewResized", {newWidth : cpWidth, unit: "px"}
        fpLastWidth = null
      @finderResizeHandle.$().css left: ''

    @finderResizeHandle.on "DragStarted", (e, dragState)=>
      cp._left  = parseInt cp.$().css("left"), 10
      cp._left  = parseInt cp.$().css("left"), 10
      @_fpWidth = parseInt $fp.css("width"), 10
      cp._width = parseInt @wc.winWidth - 52 - @_fpWidth, 10
      cp.unsetClass "transition"

    @finderResizeHandle.on "DragFinished", (e, dragState)=>
      delete cp._left
      delete cp._width
      delete @_fpWidth
      unless @finderResizeHandle._dragged
        @finderResizeHandle.emit "ClickedButNotDragged"
      else
        fpLastWidth = null
      delete @finderResizeHandle._dragged
      cp.setClass "transition"

    @finderResizeHandle.on "DragInAction", (x, y)=>
      @finderResizeHandle._dragged = yes
      newFpWidth = @_fpWidth + x
      return @finderResizeHandle.$().css left: '' if newFpWidth < 13
      cp.$().css left : cp._left + x, width : cp._width - x
      @finderResizeHandle.$().css left: ''
      $fp.css "width", newFpWidth

    KD.utils.wait 8000, =>
      @$('#finder-bottom-controls').addClass 'go-down'
      @$("#finder-holder").height @getHeight() - @$("#finder-header-holder").height() - 27

    # exception - Sinan, Jan 2013<commit_msg>Added ViewResized event emitter for content panel.<commit_after>class Sidebar extends JView

  constructor:->

    super

    account           = KD.whoami()
    {profile}         = account
    @_onDevelop       = no
    @_finderExpanded  = no
    @_popupIsActive   = no

    currentGroupData = @getSingleton('groupsController').getCurrentGroupData()

    @avatar = new AvatarView
      tagName    : "div"
      cssClass   : "avatar-image-wrapper"
      size       :
        width    : 160
        height   : 76
    , account

    @avatarAreaIconMenu = new AvatarAreaIconMenu
      delegate     : @

    @groupAvatar = new KDView
      cssClass   : 'group-avatar-image-wrapper hidden'
      tagName : 'div'
    ,currentGroupData

    @currentGroup = new KDCustomHTMLView
      cssClass    : 'current-group-indicator'
      pistachio   : "{{#(title)}}"
      click       : ->
        #KD.getSingleton('router').handleRoute
        console.log @getData()
    , currentGroupData

    @avatarHeader = new KDView
      cssClass : 'avatar-header hidden'
      pistachio : '{{#(title)}}'
      click :=>
        # KD.getSingleton('router').handleRoute "/#{currentGroupData.slug}/Activity"

    , currentGroupData

    # handle group related decisions
    @initializeGroup()

    @navController = new NavigationController
      view           : new NavigationList
        type         : "navigation"
        itemClass    : NavigationLink
      wrapper        : no
      scrollView     : no
    , navItems

    @nav = @navController.getView()

    @footerMenuController = new NavigationController
      view           : new NavigationList
        type         : "footer-menu"
        itemClass    : FooterMenuItem
      wrapper        : no
      scrollView     : no
    , footerMenuItems

    @footerMenu = @footerMenuController.getView()

    @finderHeader = new KDCustomHTMLView
      tagName   : "h2"
      pistachio : "{{#(profile.nickname)}}.#{location.hostname}"
    , account

    @finderResizeHandle = new SidebarResizeHandle
      cssClass  : "finder-resize-handle"

    @finderController = new NFinderController
      fsListeners       : yes
      initDelay         : 5000
      useStorage        : yes
      addOrphansToRoot  : no

    @finder = @finderController.getView()

    @finderBottomControlsController = new KDListViewController
      view        : new FinderBottomControls
      wrapper     : no
      scrollView  : no
    , bottomControlsItems

    @finderBottomControls = @finderBottomControlsController.getView()

    KD.registerSingleton "finderController", @finderController
    @listenWindowResize()

    # @statusLEDs = new StatusLEDView
    @statusLEDs = new KDView
      cssClass : 'status-leds'

  initializeGroup:->
    currentGroupData = @getSingleton('groupsController').getCurrentGroupData()
    unless currentGroupData?.data?.slug is 'koding'
      @avatar.setClass 'shared-avatar'
      @avatar.setWidth 80

      # group avatar should be either a URL or a dataURL

      @groupAvatar.$().css backgroundImage :  "url(#{currentGroupData?.data?.avatar or 'http://lorempixel.com/100/100/?' + @utils.getRandomNumber()})"
      @groupAvatar.show()
      @groupAvatar.setClass 'flash'
      @avatarHeader.setData currentGroupData
      @avatarHeader.show()
#    else
#      @avatar.unsetClass 'shared-avatar'
#      @avatar.setWidth 160
#      @groupAvatar.hide()
#      @groupAvatar.unsetClass 'flash'
#      @avatarHeader.setData currentGroupData
#      @avatarHeader.hide()
    @render()


  setListeners:->

    mainView = @getDelegate()
    {@contentPanel, @sidebarPanel} = mainView

    @getSingleton('mainController').on "AvatarPopupIsActive", =>
      @_popupIsActive = yes

    @getSingleton('mainController').on "AvatarPopupIsInactive", =>
      @_popupIsActive = no

    $fp = @$('#finder-panel')
    cp  = @contentPanel
    @wc = @getSingleton "windowController"
    fpLastWidth = null

    @finderResizeHandle.on "ClickedButNotDragged", =>
      unless fpLastWidth
        fpLastWidth = parseInt $fp.css("width"), 10
        cp.$().css left : 65, width : @wc.winWidth - 65
        @utils.wait 300, -> $fp.css "width", 13
      else
        fpLastWidth = 208 if fpLastWidth < 100
        $fp.css "width", fpLastWidth
        cpWidth = @wc.winWidth - 52 - fpLastWidth
        cp.$().css left : 52 + fpLastWidth, width : cpWidth
        cp.emit "ViewResized", {newWidth : cpWidth, unit: "px"}
        fpLastWidth = null
      @finderResizeHandle.$().css left: ''

    @finderResizeHandle.on "DragStarted", (e, dragState)=>
      cp._left  = parseInt cp.$().css("left"), 10
      cp._left  = parseInt cp.$().css("left"), 10
      @_fpWidth = parseInt $fp.css("width"), 10
      cp._width = parseInt @wc.winWidth - 52 - @_fpWidth, 10
      cp.unsetClass "transition"

    @finderResizeHandle.on "DragFinished", (e, dragState)=>
      delete cp._left
      delete cp._width
      delete @_fpWidth
      unless @finderResizeHandle._dragged
        @finderResizeHandle.emit "ClickedButNotDragged"
      else
        fpLastWidth = null
      delete @finderResizeHandle._dragged
      cp.setClass "transition"

    @finderResizeHandle.on "DragInAction", (x, y)=>
      @finderResizeHandle._dragged = yes
      newFpWidth = @_fpWidth + x
      return @finderResizeHandle.$().css left: '' if newFpWidth < 13
      cpWidth = cp._width - x
      cp.$().css left : cp._left + x, width : cpWidth
      @finderResizeHandle.$().css left: ''
      $fp.css "width", newFpWidth
      cp.emit "ViewResized", {newWidth : cpWidth, unit: "px"}

    KD.utils.wait 8000, =>
      @$('#finder-bottom-controls').addClass 'go-down'
      @$("#finder-holder").height @getHeight() - @$("#finder-header-holder").height() - 27

    # exception - Sinan, Jan 2013
{'fraction_non_alphanumeric': 0.1149899131655118, 'fraction_numerical': 0.01122708534339093, 'mean_word_length': 2.524574961360124, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, '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': '2137099', 'n_tokens_mistral': 3563, 'n_tokens_neox': 3403, 'n_words': 729}