<commit_before>// @todo test in IE, especially .form and previous element  selctors

angular
    .module('app')
    .directive("required", ['$window',
        function($window) {

            // global config
            var options = {
                theClass: 'required-message-inserted',
                message: '<span class="required-message pull-right"><small>Fields marked <sup class="required">*</sup> are required</small></span>',
                requiredMessage: '<sup class="required">*</sup>'
            };

            return {
                restrict: "A",
                replace: false,
                link: function(scope, element, attrs) {

                    // get the elements name 
                    // if no name is set, we can't find the inputs label. So get outta here! 
                    var elementName = element[0].name;
                    if (!elementName) return;

                    // get label, assuming label is the first previous element
                    var elemLabel = angular.element(element[0].previousElementSibling);

                    // get the form
                    var elemForm = angular.element(element[0].form);

                    // @todo test checks are working... do we need to user .length? 
                    if (elemForm && !elemForm.hasClass(options.theClass)) {
                        elemForm.append(options.message).addClass(options.theClass);
                    }
                    
                    this.shouldShow = function() {
                        // add required message to elements label
                        if (elemLabel && element.css('display') !== 'none' && !element.prop('disabled') && !element.hasClass('required-label')) {
                            elemLabel.append(options.requiredMessage);
                            element.addClass('required-label');
                        }
                    }
                    
                    scope.$watch('element.disabled', shouldShow);
                    scope.$watch('element.style.display', shouldShow);
                    

                }
            };<commit_msg>Add missing semicolon to required directive.<commit_after>// @todo test in IE, especially .form and previous element  selctors

angular
    .module('app')
    .directive("required", ['$window',
        function($window) {

            // global config
            var options = {
                theClass: 'required-message-inserted',
                message: '<span class="required-message pull-right"><small>Fields marked <sup class="required">*</sup> are required</small></span>',
                requiredMessage: '<sup class="required">*</sup>'
            };

            return {
                restrict: "A",
                replace: false,
                link: function(scope, element, attrs) {

                    // get the elements name 
                    // if no name is set, we can't find the inputs label. So get outta here! 
                    var elementName = element[0].name;
                    if (!elementName) return;

                    // get label, assuming label is the first previous element
                    var elemLabel = angular.element(element[0].previousElementSibling);

                    // get the form
                    var elemForm = angular.element(element[0].form);

                    // @todo test checks are working... do we need to user .length? 
                    if (elemForm && !elemForm.hasClass(options.theClass)) {
                        elemForm.append(options.message).addClass(options.theClass);
                    }
                    
                    this.shouldShow = function() {
                        // add required message to elements label
                        if (elemLabel && element.css('display') !== 'none' && !element.prop('disabled') && !element.hasClass('required-label')) {
                            elemLabel.append(options.requiredMessage);
                            element.addClass('required-label');
                        }
                    };
                    
                    scope.$watch('element.disabled', shouldShow);
                    scope.$watch('element.style.display', shouldShow);
                    

                }
            };
{'fraction_non_alphanumeric': 0.10863509749303621, 'fraction_numerical': 0.001392757660167131, 'mean_word_length': 1.3279308481901675, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4926679', 'n_tokens_mistral': 995, 'n_tokens_neox': 923, 'n_words': 247}