
function FolderTreeWidget(callback) {
  var selected

  var id = 'id' + Math.random()
  var render = function() {
    $.ajax({
      url: '/rest/dir/lazyTree',
      success: function(data) {
        if (!data) return

        var root = {}
        root.onLazyRead = function(node) {
          node.appendAjax({
            url: '/rest/dir/lazyTree?parent=' + node.data.key
          })
        }
        root.onClick = function(node) {
          selected = node
        }
        root.children = data
        root.isLazy = true
        root.isFolder = true
        root.expand = true

        $('#add2myaccount').dynatree(root)
      }
    })
  }

  AccountFacade.writeDrag({
    title: 'Add to my account',
    element: $('#add2myaccount'),

    onClose: function() {

    }
  })

  setTimeout(render, 1000)

  return this
}

