 'use strict'
+{CompositeDisposable} = require 'atom'
+
 class AutohideTreeView
   hideDuration = null # cache hideDuration value
   stylesheet = null # this holds the configurable css rules

    duration = calculateHideDuration()
    updateStylesheet '.tree-view-resizer', 'transition-duration', "#{duration}s"

  applyMinWidth: (width) ->
    updateStylesheet '.tree-view-resizer', 'min-width', "#{width}px!important"
    updateStylesheet '.tree-view-resizer', 'max-width', "#{width}px!important"

      minimum: 1
      maximum: 50
    hideDelay:
      description: 'Rough estimation of the delay - in seconds - before the menu starts hiding, 0 turns of the animation entirely (0-INFINITY)'
      type: 'number'
      default: .3
      minimum: 0
    openDelay:
      description: 'The delay before the tree-view is unfolded in seconds'
      type: 'number'
      default: .2
      minimum: 0
    minimizedWidth:
      description: 'The width - in pixels - of the tree-view when minimized/hidden (1-INFINITY)'
      type: 'integer'
      default: 1
      minimum: 1

  activate: ->
    @subs = new CompositeDisposable()
    @subs.add atom.config.observe 'autohide-tree-view.unfoldSpeed', @applyUnfoldSpeed.bind @
    @subs.add atom.config.observe 'autohide-tree-view.hideDelay', @applyHideDelay.bind @
    @subs.add atom.config.observe 'autohide-tree-view.openDelay', @applyOpenDelay.bind @
    @subs.add atom.config.observe 'autohide-tree-view.minimizedWidth', @applyMinWidth.bind @
    @subs.add atom.config.observe 'tree-view.showOnRightSide', @applyTreeViewSide.bind @

  deactivate: ->
    @unfoldSpeedSub.dispose()
