infrastructureModule.directive('userDetailView', ['$log', '$compile', '$timeout', '$interval',
    function ($log, $compile, $timeout, $interval) {
        'use strict';
        $log.debug('userDetailView.ctor()...');

        return {
            restrict: 'E',
            templateUrl: '/app/admin/infrastructure/userDetail/user-detail-view.html' + '?_=' + Math.random(),
            scope: {},
            replace: true,
            controller: 'UserDetailViewController',
            link: function (scope, element) {

                $(document).on({
                    mouseenter: function () {
                        $(this).find('.remove-role-name').css('display', 'inline');
                    },
                    mouseleave: function () {
                        $(this).find('.remove-role-name').css('display', 'none');
                    }
                }, ".role-name"); //pass the element as an argument to .on

                $(document).on('click', function (e) {

                    var container = $(".assign-user-box");
                    // if the target of the click isn't the container nor a descendant of the container
                    if (!container.is(e.target) && container.has(e.target).length === 0) {
                        container.hide();
                    }
                });

                var stopPropagation = function (event) {
                    event = event || window.event;
                    if (event.stopPropagation) {
                        event.stopPropagation();
                    } else {
                        event.cancelBubble = true;
                    }
                }
            }//# end of link
        }
    }
]);