<commit_before><commit_msg>Create event-delegate.ts<commit_after>module EventDelegate {
    'use strict';

    export module Directives {

        class EventDelegate implements ng.IDirective {
            restrict = 'A';
            link: ng.IDirectiveLinkFn;

            constructor(){
                this.link = (scope, el, attr) => {
                    var
                        eventDelegate = scope.$eval(attr['eventDelegate']);

                    angular.forEach(eventDelegate, (selector, event) => {

                        el.on(event + '.eventDelegate', selector, (e) => {
                            e.preventDefault();

                            var
                                target: ng.IAugmentedJQuery = angular.element(e.currentTarget),
                                fn: ng.IInterpolationFunction;

                            if (fn = target.data('EventDelegateTarget')) {
                                scope.$apply(() => fn(target.scope()));
                            }
                        });

                    });

                    scope.$on('$destroy', () => {
                        eventDelegate = null;
                        el.off('.eventDelegate');
                    });
                };
            }

            static instance(){
                return [() => new this()];
            }
        }

        export var eventDelegate: ng.IDirective = EventDelegate.instance();

        class EventDelegateTarget implements ng.IDirective {
            restrict = 'A';
            link: ng.IDirectiveLinkFn;

            constructor($parse: ng.IParseService) {
                this.link = (scope, el, attr) => {

                    attr.$observe('eventDelegateTarget', (att) => {
                        el.data('EventDelegateTarget', $parse(att));
                    });

                };
            }

            static instance(){
                return ['$parse', ($parse) => new this($parse)];
            }
        }

        export var eventDelegateTarget: ng.IDirective = EventDelegateTarget.instance();
    }

    angular.module('EventDelegate', []).directive({
      'eventDelegateTarget': Directives.eventDelegateTarget,
      'eventDelegate': Directives.eventDelegate
    });
}
{'fraction_non_alphanumeric': 0.11603188662533215, 'fraction_numerical': 0.0, 'mean_word_length': 1.2432969215491558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3051210', 'n_tokens_mistral': 537, 'n_tokens_neox': 498, 'n_words': 93}