<commit_before>'use strict';

angular.module('popup.directives', [])
    /**********************************************************************
     * Popup Directive
     * Author: <NAME>
     *
     * Prerequisites: AngularJS, JQuery
     *
     * Example Use:
     * <input type="text" popup template/>
     * 
     * Description:
     * This directive creates a box that popups up under the focused input
     * field to which it has been applied as an attribute. The directive
     * will handle all positioning of itself and content, as well as, all
     * necessary event handling to open and close itself appropriately.
     * 
     * The directive expects a 'directive' attribute on the element, which
     * it will use for content of the popup box.
     * 
     * Scope functions popupResult and closePopup are available to update
     * the content of the input element and close the popup respectively.
    **********************************************************************/
    .directive('popup', ['$compile', '$timeout', function($compile, $timeout) {
        return {
            restrict: 'A',
            scope: {},
            link: function(scope, element, attrs) {
                var strPopup = null;    // String version of the popup's HTML
                var cPopup = null;      // Compiled version of the popup
                var popup = null;     // Pointer to the current element's popup

                // Wait until the directive is loaded before initializing variables
                $timeout(function() {
                    var directive = element.attr("directive");
                    strPopup = '<div class="popup"><' + directive + '></' + directive + '></div>';
                    cPopup = $compile(strPopup)(scope);
                });

                // Called to prevent popup from closing while actions are being performed
                // inside the popup.
                var preventClose = function(event) {
                    event.stopPropagation();
                }

                // Used to position the popup under the focused element
                var placePopup = function() {
                    var offset = $(element).offset();
                    var top = offset.top + $(element).outerHeight() + 16;
                    var left = offset.left;

                    popup.css('top', top);
                    popup.css('left', left);
                };

                // Used to open the popup
                var openPopup = function(event) {
                    // Make sure any currently open popups are closed
                    closePopup();

                    // Add the popup to the DOM and set it's pointer
                    $("body").append(cPopup);
                    popup = $(cPopup);

                    // Add events to handle the appropriate closing of the popup
                    $(window).bind("mousedown", closePopup);
                    popup.bind("mousedown", preventClose);

                    // Place the popup appropriately
                    placePopup();

                    // Let the popup's content know the element's value
                    scope.$broadcast("POPUP_VALUE", element.val());
                };

                // Used to close the popup and clean up events
                var closePopup = function(event) {
                    if(popup != null) {
                        $(window).unbind("mousedown", closePopup);
                        popup.unbind("mousedown", preventClose);

                        popup.remove();
                        popup = null;
                    }
                };

                // Used by content directives to set the value of the popup's element
                var popupResult = function(result) {
                    $(scope.target).val(result);
                };

                // Events to appropriately handle the opening and closing of the popup
                $(element).bind("focus", openPopup);
                $(element).bind("keydown", function(event){
                    if(event.keyCode == 9)
                        closePopup();
                });

                // Listen for a request to close the popup, and do so
                scope.$on("CLOSE_POPUP", function(event, message) {
                    closePopup(event);
                });

                // Listen for a request to update the element's value, and do so
                scope.$on("UPDATE_POPUP", function(event, message) {
                    element.val(message);
                });
            }
        }
    }])
    
    /**********************************************************************
     * template/templateContent Directives
     * Author: <NAME>
     *
     * Prerequisites: AngularJS, JQuery, Popup Directive
     * 
     * Description:
     * These directives are meant to serve as an example template for
     * popup content. The names, and content of these directives can, and
     * should be changed.<commit_msg>Removed unused function.<commit_after>'use strict';

angular.module('popup.directives', [])
    /**********************************************************************
     * Popup Directive
     * Author: <NAME>
     *
     * Prerequisites: AngularJS, JQuery
     *
     * Example Use:
     * <input type="text" popup template/>
     * 
     * Description:
     * This directive creates a box that popups up under the focused input
     * field to which it has been applied as an attribute. The directive
     * will handle all positioning of itself and content, as well as, all
     * necessary event handling to open and close itself appropriately.
     * 
     * The directive expects a 'directive' attribute on the element, which
     * it will use for content of the popup box.
     * 
     * Scope functions popupResult and closePopup are available to update
     * the content of the input element and close the popup respectively.
    **********************************************************************/
    .directive('popup', ['$compile', '$timeout', function($compile, $timeout) {
        return {
            restrict: 'A',
            scope: {},
            link: function(scope, element, attrs) {
                var strPopup = null;    // String version of the popup's HTML
                var cPopup = null;      // Compiled version of the popup
                var popup = null;     // Pointer to the current element's popup

                // Wait until the directive is loaded before initializing variables
                $timeout(function() {
                    var directive = element.attr("directive");
                    strPopup = '<div class="popup"><' + directive + '></' + directive + '></div>';
                    cPopup = $compile(strPopup)(scope);
                });

                // Called to prevent popup from closing while actions are being performed
                // inside the popup.
                var preventClose = function(event) {
                    event.stopPropagation();
                }

                // Used to position the popup under the focused element
                var placePopup = function() {
                    var offset = $(element).offset();
                    var top = offset.top + $(element).outerHeight() + 16;
                    var left = offset.left;

                    popup.css('top', top);
                    popup.css('left', left);
                };

                // Used to open the popup
                var openPopup = function(event) {
                    // Make sure any currently open popups are closed
                    closePopup();

                    // Add the popup to the DOM and set it's pointer
                    $("body").append(cPopup);
                    popup = $(cPopup);

                    // Add events to handle the appropriate closing of the popup
                    $(window).bind("mousedown", closePopup);
                    popup.bind("mousedown", preventClose);

                    // Place the popup appropriately
                    placePopup();

                    // Let the popup's content know the element's value
                    scope.$broadcast("POPUP_VALUE", element.val());
                };

                // Used to close the popup and clean up events
                var closePopup = function(event) {
                    if(popup != null) {
                        $(window).unbind("mousedown", closePopup);
                        popup.unbind("mousedown", preventClose);

                        popup.remove();
                        popup = null;
                    }
                };

                // Events to appropriately handle the opening and closing of the popup
                $(element).bind("focus", openPopup);
                $(element).bind("keydown", function(event){
                    if(event.keyCode == 9)
                        closePopup();
                });

                // Listen for a request to close the popup, and do so
                scope.$on("CLOSE_POPUP", function(event, message) {
                    closePopup(event);
                });

                // Listen for a request to update the element's value, and do so
                scope.$on("UPDATE_POPUP", function(event, message) {
                    element.val(message);
                });
            }
        }
    }])
    
    /**********************************************************************
     * template/templateContent Directives
     * Author: <NAME>
     *
     * Prerequisites: AngularJS, JQuery, Popup Directive
     * 
     * Description:
     * These directives are meant to serve as an example template for
     * popup content. The names, and content of these directives can, and
     * should be changed.
{'fraction_non_alphanumeric': 0.13035950707811386, 'fraction_numerical': 0.0006110601894286587, 'mean_word_length': 1.5160133230848065, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1627905', 'n_tokens_mistral': 2349, 'n_tokens_neox': 2093, 'n_words': 757}