<commit_before>import angular from 'angular';

export default function($injector, $window, $timeout) {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            const contextMenu = $injector.get(attrs.target);
            const locals = {};
            const wnd = angular.element($window);
            const triggerOnEvent = attrs.triggerOnEvent || 'contextmenu';

            if (attrs.locals) {
                const localKeys = attrs.locals.split(',').map(function(local) {
                    return local.trim();
                });
                angular.forEach(localKeys, function(key) {
                    locals[key] = scope[key];
                });
            }

            function open(event) {
                const pointerPosition = getPositionPropertiesOfEvent(event);
                const cssProperties = getCssPropertiesOfEvent(event);
                const currentTarget = event.currentTarget;
                contextMenu.bindController(locals);
                const shouldOpenContextMenuPromise = contextMenu.controllerImpl && contextMenu.controllerImpl.shouldOpenMenuPromise
                    ? contextMenu.controllerImpl.shouldOpenMenuPromise()
                    : new Promise(resolve => resolve(true));
                shouldOpenContextMenuPromise
                    .then(shouldOpen => {
                        if (shouldOpen) {
                            scope.$apply(function() {
                                contextMenu.open(currentTarget, cssProperties)
                                    .then(function (element) {
                                        element.hide();
                                        $timeout(function () {
                                            element.show(0, function () {
                                                adjustPosition(element, pointerPosition, currentTarget.clientHeight);
                                                angular.element(element).focus();
                                            });
                                        }, 0, false);
                                    });
                            });
                        }
                    });
            }

            function adjustPosition($element, pointerPosition, targetHeight = 0) {
                const viewport = {<commit_msg>Permissions form: right-click event fix (after refreshing dataset list)<commit_after>import angular from 'angular';

export default function($injector, $window, $timeout) {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            const contextMenu = $injector.get(attrs.target);
            const wnd = angular.element($window);
            const triggerOnEvent = attrs.triggerOnEvent || 'contextmenu';

            function open(event) {
                const pointerPosition = getPositionPropertiesOfEvent(event);
                const cssProperties = getCssPropertiesOfEvent(event);
                const currentTarget = event.currentTarget;
                const locals = {};
                if (attrs.locals) {
                    const localKeys = attrs.locals.split(',').map(function(local) {
                        return local.trim();
                    });
                    angular.forEach(localKeys, function(key) {
                        locals[key] = scope[key];
                    });
                }
                contextMenu.bindController(locals);
                const shouldOpenContextMenuPromise = contextMenu.controllerImpl && contextMenu.controllerImpl.shouldOpenMenuPromise
                    ? contextMenu.controllerImpl.shouldOpenMenuPromise()
                    : new Promise(resolve => resolve(true));
                shouldOpenContextMenuPromise
                    .then(shouldOpen => {
                        if (shouldOpen) {
                            scope.$apply(function() {
                                contextMenu.open(currentTarget, cssProperties)
                                    .then(function (element) {
                                        element.hide();
                                        $timeout(function () {
                                            element.show(0, function () {
                                                adjustPosition(element, pointerPosition, currentTarget.clientHeight);
                                                angular.element(element).focus();
                                            });
                                        }, 0, false);
                                    });
                            });
                        }
                    });
            }

            function adjustPosition($element, pointerPosition, targetHeight = 0) {
                const viewport = {
{'fraction_non_alphanumeric': 0.08594560930039444, 'fraction_numerical': 0.0012455885405854266, 'mean_word_length': 1.1537773804202056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7493710', 'n_tokens_mistral': 955, 'n_tokens_neox': 907, 'n_words': 178}