(function () {
  'use strict';

  var namespace = angular.module('app.directory-selector', [
    'hierarchical-selector',
    'app.acceptd.config'
  ]);

  namespace.directive('directorySelector', DirectorySelector);

  function DirectorySelector($q, $http, $timeout, AcceptdService) {
    return {
      restrict: 'AE',
      template: '<hierarchical-selector load-child-items="loadAsyncData(parent)"' +
      '                       selection="selection" on-selection-changed="onSelectionChanged(items)"' +
      '                       tag-name="tagName(item)">' +
      '</hierarchical-selector>',
      scope: {
        'script_params': '&',
        'selection': '&',
        'selected_project': '&'
      },
      link: function (scope, element, attributes) {
        //console.log(attributes.selectedProject);

        AcceptdService.load_config({}).success(function (result) {
          var id = result.selected_project;
          //var id = attributes.selectedProject;

          $http.get('/file_browser/node' + '?id=' + id).success(function (data) {
            //  //data['_hsmeta'] = {'isExpanded':false,'isActive':false,'selected':true};
            scope.selection = data;
          });
        });

        scope.loadAsyncData = function (parent) {
          var id = parent ? parent.id : '/';

          var defer = $q.defer();

          $http.get('/file_browser/tree' + '?id=' + id).success(function (data) {
            defer.resolve(data);
          }).error(function (data) {
            defer.reject(data);
          });

          return defer.promise;
        };

        scope.onSelectionChanged = function (items) {
          scope.mySelection = items;
        };

        scope.tagName = function (item) {
          return item.id;
        };
      }
    }
  }

})();

//$scope.testa = function () {
//  //angular.element(document.body).injector().get('AcceptdController')
//
//  //var root = angular.element(document.querySelector('.hierarchical-control'));
//  //var root_input = angular.element(document.querySelector('.hierarchical-input'));
//  //var tree_view = angular.element(document.querySelector('.tree-view'))
//
//  var root = $('.hierarchical-control');
//  var root_input = $('.hierarchical-input');
//  var tree_view = root.find('.tree-view');
//
//  root_input.click();
//
//  var items = tree_view.find('ul li');
//
//  for (var i = 0; i < items.size(); i++) {
//    var item = items[0];
//    console.log(item);
//    var el1 = $(item).find('.item-container span')[0];
//    el1.click();
//    var item2 = item.find('ul li');
//    var el2 = item2.find('.item-container span')[0];
//  }
//};


@@ -115,16 +115,36 @@
 ector',%0A
+    'app.settings',%0A
     'app
@@ -160,16 +160,16 @@
 config'%0A
-
   %5D);%0A%0A 
@@ -280,16 +280,26 @@
 timeout,
+ Settings,
  Acceptd
@@ -694,41 +694,8 @@
 on':
- '&',%0A        'selected_project':
  '&'
@@ -760,60 +760,8 @@
 ) %7B%0A
-        //console.log(attributes.selectedProject);%0A%0A
     
@@ -917,16 +917,16 @@
 oject;%0A%0A
-
         
@@ -929,32 +929,51 @@
       $http.get(
+Settings.baseUrl + 
 '/file_browser/n

simplify code