(function(){
    angular.module("app.collect")
        .controller("collectCtrl",["$rootScope","$scope","$state","ToolService","$timeout",collectCtrl]);

    function collectCtrl($rootScope,$scope,$state,ToolService,$timeout){
        $rootScope.meauTree = {
            "dataview":["custommenu"],
            "action":["eventstats","funnel","retention","intelligentpath"],
            "user":["usergroup"],
            "event":["event","profile"],
            "tool":["logtool","report"]
        };
        $scope.menustatus = {
          dataview:true,
          action:true,
          user:false,
          event:false,
          tool:false
        }
        $scope.getSubMenu = function(menu){
            $scope.menustatus[menu] = !$scope.menustatus[menu];
        }

        $rootScope.$watch("pagePath",function(n){
            if(angular.isDefined(n)){
                var idx = n.indexOf("Detail");
                if(idx>-1){
                    n = n.substring(0,n);
                }
                $scope.menuCurFlag = "";
                for(var k in $rootScope.meauTree){
                    var ms = $rootScope.meauTree[k];
                    if(ms.indexOf(n)>-1){
                        $scope.menuCurFlag = k;
                        $scope.menustatus[k] = true;
                        break;
                    }
                }
            }

        });

    }
})();
